00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00084 #ifndef __vtkPlaneWidget_h
00085 #define __vtkPlaneWidget_h
00086
00087 #include "vtkPolyDataSourceWidget.h"
00088
00089 class vtkActor;
00090 class vtkCellPicker;
00091 class vtkConeSource;
00092 class vtkLineSource;
00093 class vtkPlaneSource;
00094 class vtkPoints;
00095 class vtkPolyData;
00096 class vtkPolyDataMapper;
00097 class vtkProp;
00098 class vtkProperty;
00099 class vtkSphereSource;
00100 class vtkTransform;
00101 class vtkPlane;
00102
00103 #define VTK_PLANE_OFF 0
00104 #define VTK_PLANE_OUTLINE 1
00105 #define VTK_PLANE_WIREFRAME 2
00106 #define VTK_PLANE_SURFACE 3
00107
00108 class VTK_WIDGETS_EXPORT vtkPlaneWidget : public vtkPolyDataSourceWidget
00109 {
00110 public:
00112 static vtkPlaneWidget *New();
00113
00114 vtkTypeRevisionMacro(vtkPlaneWidget,vtkPolyDataSourceWidget);
00115 void PrintSelf(ostream& os, vtkIndent indent);
00116
00118
00119 virtual void SetEnabled(int);
00120 virtual void PlaceWidget(double bounds[6]);
00121 void PlaceWidget()
00122 {this->Superclass::PlaceWidget();}
00123 void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
00124 double zmin, double zmax)
00125 {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
00127
00129
00130 void SetResolution(int r);
00131 int GetResolution();
00133
00135
00136 void SetOrigin(double x, double y, double z);
00137 void SetOrigin(double x[3]);
00138 double* GetOrigin();
00139 void GetOrigin(double xyz[3]);
00141
00143
00145 void SetPoint1(double x, double y, double z);
00146 void SetPoint1(double x[3]);
00147 double* GetPoint1();
00148 void GetPoint1(double xyz[3]);
00150
00152
00154 void SetPoint2(double x, double y, double z);
00155 void SetPoint2(double x[3]);
00156 double* GetPoint2();
00157 void GetPoint2(double xyz[3]);
00159
00161
00162 void SetCenter(double x, double y, double z);
00163 void SetCenter(double x[3]);
00164 double* GetCenter();
00165 void GetCenter(double xyz[3]);
00167
00169
00170 void SetNormal(double x, double y, double z);
00171 void SetNormal(double x[3]);
00172 double* GetNormal();
00173 void GetNormal(double xyz[3]);
00175
00177
00182 vtkSetClampMacro(Representation,int,VTK_PLANE_OFF,VTK_PLANE_SURFACE);
00183 vtkGetMacro(Representation,int);
00184 void SetRepresentationToOff()
00185 {this->SetRepresentation(VTK_PLANE_OFF);}
00186 void SetRepresentationToOutline()
00187 {this->SetRepresentation(VTK_PLANE_OUTLINE);}
00188 void SetRepresentationToWireframe()
00189 {this->SetRepresentation(VTK_PLANE_WIREFRAME);}
00190 void SetRepresentationToSurface()
00191 {this->SetRepresentation(VTK_PLANE_SURFACE);}
00193
00195
00199 vtkSetMacro(NormalToXAxis,int);
00200 vtkGetMacro(NormalToXAxis,int);
00201 vtkBooleanMacro(NormalToXAxis,int);
00202 vtkSetMacro(NormalToYAxis,int);
00203 vtkGetMacro(NormalToYAxis,int);
00204 vtkBooleanMacro(NormalToYAxis,int);
00205 vtkSetMacro(NormalToZAxis,int);
00206 vtkGetMacro(NormalToZAxis,int);
00207 vtkBooleanMacro(NormalToZAxis,int);
00209
00217 void GetPolyData(vtkPolyData *pd);
00218
00224 void GetPlane(vtkPlane *plane);
00225
00231 vtkPolyDataAlgorithm* GetPolyDataAlgorithm();
00232
00235 void UpdatePlacement(void);
00236
00238
00241 vtkGetObjectMacro(HandleProperty,vtkProperty);
00242 vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
00244
00246
00248 virtual void SetPlaneProperty(vtkProperty*);
00249 vtkGetObjectMacro(PlaneProperty,vtkProperty);
00250 vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty);
00252
00253 protected:
00254 vtkPlaneWidget();
00255 ~vtkPlaneWidget();
00256
00257
00258 int State;
00259 enum WidgetState
00260 {
00261 Start=0,
00262 Moving,
00263 Scaling,
00264 Pushing,
00265 Rotating,
00266 Spinning,
00267 Outside
00268 };
00269
00270
00271
00272 static void ProcessEvents(vtkObject* object,
00273 unsigned long event,
00274 void* clientdata,
00275 void* calldata);
00276
00277
00278 void OnLeftButtonDown();
00279 void OnLeftButtonUp();
00280 void OnMiddleButtonDown();
00281 void OnMiddleButtonUp();
00282 void OnRightButtonDown();
00283 void OnRightButtonUp();
00284 void OnMouseMove();
00285
00286
00287 int NormalToXAxis;
00288 int NormalToYAxis;
00289 int NormalToZAxis;
00290 int Representation;
00291 void SelectRepresentation();
00292
00293
00294 vtkActor *PlaneActor;
00295 vtkPolyDataMapper *PlaneMapper;
00296 vtkPlaneSource *PlaneSource;
00297 vtkPolyData *PlaneOutline;
00298 void HighlightPlane(int highlight);
00299
00300
00301 vtkActor **Handle;
00302 vtkPolyDataMapper **HandleMapper;
00303 vtkSphereSource **HandleGeometry;
00304 void PositionHandles();
00305 void HandlesOn(double length);
00306 void HandlesOff();
00307 int HighlightHandle(vtkProp *prop);
00308 virtual void SizeHandles();
00309
00310
00311 vtkActor *ConeActor;
00312 vtkPolyDataMapper *ConeMapper;
00313 vtkConeSource *ConeSource;
00314 void HighlightNormal(int highlight);
00315
00316
00317 vtkActor *LineActor;
00318 vtkPolyDataMapper *LineMapper;
00319 vtkLineSource *LineSource;
00320
00321
00322 vtkActor *ConeActor2;
00323 vtkPolyDataMapper *ConeMapper2;
00324 vtkConeSource *ConeSource2;
00325
00326
00327 vtkActor *LineActor2;
00328 vtkPolyDataMapper *LineMapper2;
00329 vtkLineSource *LineSource2;
00330
00331
00332 vtkCellPicker *HandlePicker;
00333 vtkCellPicker *PlanePicker;
00334 vtkActor *CurrentHandle;
00335
00336
00337 void MoveOrigin(double *p1, double *p2);
00338 void MovePoint1(double *p1, double *p2);
00339 void MovePoint2(double *p1, double *p2);
00340 void MovePoint3(double *p1, double *p2);
00341 void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
00342 void Spin(double *p1, double *p2);
00343 void Scale(double *p1, double *p2, int X, int Y);
00344 void Translate(double *p1, double *p2);
00345 void Push(double *p1, double *p2);
00346
00347
00348 double Normal[3];
00349
00350
00351 vtkTransform *Transform;
00352
00353
00354
00355 vtkProperty *HandleProperty;
00356 vtkProperty *SelectedHandleProperty;
00357 vtkProperty *PlaneProperty;
00358 vtkProperty *SelectedPlaneProperty;
00359 void CreateDefaultProperties();
00360
00361 void GeneratePlane();
00362
00363 int LastPickValid;
00364 double HandleSizeFactor;
00365
00366 private:
00367 vtkPlaneWidget(const vtkPlaneWidget&);
00368 void operator=(const vtkPlaneWidget&);
00369 };
00370
00371 #endif