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