00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00076 #ifndef __vtkImplicitPlaneWidget_h
00077 #define __vtkImplicitPlaneWidget_h
00078
00079 #include "vtkPolyDataSourceWidget.h"
00080
00081 class vtkActor;
00082 class vtkPolyDataMapper;
00083 class vtkCellPicker;
00084 class vtkConeSource;
00085 class vtkLineSource;
00086 class vtkSphereSource;
00087 class vtkTubeFilter;
00088 class vtkPlane;
00089 class vtkCutter;
00090 class vtkProperty;
00091 class vtkImageData;
00092 class vtkOutlineFilter;
00093 class vtkFeatureEdges;
00094 class vtkPolyData;
00095 class vtkTransform;
00096
00097 class VTK_WIDGETS_EXPORT vtkImplicitPlaneWidget : public vtkPolyDataSourceWidget
00098 {
00099 public:
00101 static vtkImplicitPlaneWidget *New();
00102
00103 vtkTypeRevisionMacro(vtkImplicitPlaneWidget,vtkPolyDataSourceWidget);
00104 void PrintSelf(ostream& os, vtkIndent indent);
00105
00107
00108 virtual void SetEnabled(int);
00109 virtual void PlaceWidget(double bounds[6]);
00110 void PlaceWidget()
00111 {this->Superclass::PlaceWidget();}
00112 void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
00113 double zmin, double zmax)
00114 {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
00116
00118
00119 void SetOrigin(double x, double y, double z);
00120 void SetOrigin(double x[3]);
00121 double* GetOrigin();
00122 void GetOrigin(double xyz[3]);
00124
00126
00127 void SetNormal(double x, double y, double z);
00128 void SetNormal(double x[3]);
00129 double* GetNormal();
00130 void GetNormal(double xyz[3]);
00132
00134
00138 void SetNormalToXAxis(int);
00139 vtkGetMacro(NormalToXAxis,int);
00140 vtkBooleanMacro(NormalToXAxis,int);
00141 void SetNormalToYAxis(int);
00142 vtkGetMacro(NormalToYAxis,int);
00143 vtkBooleanMacro(NormalToYAxis,int);
00144 void SetNormalToZAxis(int);
00145 vtkGetMacro(NormalToZAxis,int);
00146 vtkBooleanMacro(NormalToZAxis,int);
00148
00150
00152 vtkSetMacro(Tubing,int);
00153 vtkGetMacro(Tubing,int);
00154 vtkBooleanMacro(Tubing,int);
00156
00158
00162 void SetDrawPlane(int plane);
00163 vtkGetMacro(DrawPlane,int);
00164 vtkBooleanMacro(DrawPlane,int);
00166
00168
00170 vtkSetMacro(OutlineTranslation,int);
00171 vtkGetMacro(OutlineTranslation,int);
00172 vtkBooleanMacro(OutlineTranslation,int);
00173
00174
00175 vtkSetMacro(ScaleEnabled,int);
00176 vtkGetMacro(ScaleEnabled,int);
00177 vtkBooleanMacro(ScaleEnabled,int);
00179
00182 void GetPolyData(vtkPolyData *pd);
00183
00186 vtkPolyDataAlgorithm* GetPolyDataAlgorithm();
00187
00192 void GetPlane(vtkPlane *plane);
00193
00197 void UpdatePlacement(void);
00198
00200 virtual void SizeHandles();
00201
00203
00204 vtkGetObjectMacro(NormalProperty,vtkProperty);
00205 vtkGetObjectMacro(SelectedNormalProperty,vtkProperty);
00207
00209
00211 vtkGetObjectMacro(PlaneProperty,vtkProperty);
00212 vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty);
00214
00216
00217 vtkGetObjectMacro(OutlineProperty,vtkProperty);
00218 vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
00220
00222
00224 vtkGetObjectMacro(EdgesProperty,vtkProperty);
00226
00227 protected:
00228 vtkImplicitPlaneWidget();
00229 ~vtkImplicitPlaneWidget();
00230
00231
00232 int State;
00233 enum WidgetState
00234 {
00235 Start=0,
00236 MovingPlane,
00237 MovingOutline,
00238 MovingOrigin,
00239 Scaling,
00240 Pushing,
00241 Rotating,
00242 Outside
00243 };
00244
00245
00246
00247 static void ProcessEvents(vtkObject* object, unsigned long event,
00248 void* clientdata, void* calldata);
00249
00250
00251 void OnLeftButtonDown();
00252 void OnLeftButtonUp();
00253 void OnMiddleButtonDown();
00254 void OnMiddleButtonUp();
00255 void OnRightButtonDown();
00256 void OnRightButtonUp();
00257 void OnMouseMove();
00258
00259
00260 int NormalToXAxis;
00261 int NormalToYAxis;
00262 int NormalToZAxis;
00263 void UpdateRepresentation();
00264
00265
00266 vtkPlane *Plane;
00267
00268
00269 vtkImageData *Box;
00270 vtkOutlineFilter *Outline;
00271 vtkPolyDataMapper *OutlineMapper;
00272 vtkActor *OutlineActor;
00273 void HighlightOutline(int highlight);
00274 int OutlineTranslation;
00275 int ScaleEnabled;
00276
00277
00278 vtkCutter *Cutter;
00279 vtkPolyDataMapper *CutMapper;
00280 vtkActor *CutActor;
00281 int DrawPlane;
00282 void HighlightPlane(int highlight);
00283
00284
00285 vtkFeatureEdges *Edges;
00286 vtkTubeFilter *EdgesTuber;
00287 vtkPolyDataMapper *EdgesMapper;
00288 vtkActor *EdgesActor;
00289 int Tubing;
00290
00291
00292 vtkConeSource *ConeSource;
00293 vtkPolyDataMapper *ConeMapper;
00294 vtkActor *ConeActor;
00295 void HighlightNormal(int highlight);
00296
00297
00298 vtkLineSource *LineSource;
00299 vtkPolyDataMapper *LineMapper;
00300 vtkActor *LineActor;
00301
00302
00303 vtkConeSource *ConeSource2;
00304 vtkPolyDataMapper *ConeMapper2;
00305 vtkActor *ConeActor2;
00306
00307
00308 vtkLineSource *LineSource2;
00309 vtkPolyDataMapper *LineMapper2;
00310 vtkActor *LineActor2;
00311
00312
00313 vtkSphereSource *Sphere;
00314 vtkPolyDataMapper *SphereMapper;
00315 vtkActor *SphereActor;
00316
00317
00318 vtkCellPicker *Picker;
00319
00320
00321 vtkTransform *Transform;
00322
00323
00324 void ConstrainOrigin(double x[3]);
00325 void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
00326 void TranslatePlane(double *p1, double *p2);
00327 void TranslateOutline(double *p1, double *p2);
00328 void TranslateOrigin(double *p1, double *p2);
00329 void Push(double *p1, double *p2);
00330 void Scale(double *p1, double *p2, int X, int Y);
00331
00332
00333
00334 vtkProperty *NormalProperty;
00335 vtkProperty *SelectedNormalProperty;
00336 vtkProperty *PlaneProperty;
00337 vtkProperty *SelectedPlaneProperty;
00338 vtkProperty *OutlineProperty;
00339 vtkProperty *SelectedOutlineProperty;
00340 vtkProperty *EdgesProperty;
00341 void CreateDefaultProperties();
00342
00343 void GeneratePlane();
00344
00345 private:
00346 vtkImplicitPlaneWidget(const vtkImplicitPlaneWidget&);
00347 void operator=(const vtkImplicitPlaneWidget&);
00348 };
00349
00350 #endif