VTK
vtkPlaneWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkPlaneWidget.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
87 #ifndef __vtkPlaneWidget_h
88 #define __vtkPlaneWidget_h
89 
91 
92 class vtkActor;
93 class vtkCellPicker;
94 class vtkConeSource;
95 class vtkLineSource;
96 class vtkPlaneSource;
97 class vtkPoints;
98 class vtkPolyData;
99 class vtkPolyDataMapper;
100 class vtkProp;
101 class vtkProperty;
102 class vtkSphereSource;
103 class vtkTransform;
104 class vtkPlane;
105 
106 #define VTK_PLANE_OFF 0
107 #define VTK_PLANE_OUTLINE 1
108 #define VTK_PLANE_WIREFRAME 2
109 #define VTK_PLANE_SURFACE 3
110 
112 {
113 public:
115  static vtkPlaneWidget *New();
116 
118  void PrintSelf(ostream& os, vtkIndent indent);
119 
121 
122  virtual void SetEnabled(int);
123  virtual void PlaceWidget(double bounds[6]);
124  void PlaceWidget()
125  {this->Superclass::PlaceWidget();}
126  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
127  double zmin, double zmax)
128  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
130 
132 
133  void SetResolution(int r);
134  int GetResolution();
136 
138 
139  void SetOrigin(double x, double y, double z);
140  void SetOrigin(double x[3]);
141  double* GetOrigin();
142  void GetOrigin(double xyz[3]);
144 
146 
148  void SetPoint1(double x, double y, double z);
149  void SetPoint1(double x[3]);
150  double* GetPoint1();
151  void GetPoint1(double xyz[3]);
153 
155 
157  void SetPoint2(double x, double y, double z);
158  void SetPoint2(double x[3]);
159  double* GetPoint2();
160  void GetPoint2(double xyz[3]);
162 
164 
165  void SetCenter(double x, double y, double z);
166  void SetCenter(double x[3]);
167  double* GetCenter();
168  void GetCenter(double xyz[3]);
170 
172 
173  void SetNormal(double x, double y, double z);
174  void SetNormal(double x[3]);
175  double* GetNormal();
176  void GetNormal(double xyz[3]);
178 
180 
185  vtkSetClampMacro(Representation,int,VTK_PLANE_OFF,VTK_PLANE_SURFACE);
186  vtkGetMacro(Representation,int);
188  {this->SetRepresentation(VTK_PLANE_OFF);}
190  {this->SetRepresentation(VTK_PLANE_OUTLINE);}
192  {this->SetRepresentation(VTK_PLANE_WIREFRAME);}
194  {this->SetRepresentation(VTK_PLANE_SURFACE);}
196 
198 
202  vtkSetMacro(NormalToXAxis,int);
203  vtkGetMacro(NormalToXAxis,int);
204  vtkBooleanMacro(NormalToXAxis,int);
205  vtkSetMacro(NormalToYAxis,int);
206  vtkGetMacro(NormalToYAxis,int);
207  vtkBooleanMacro(NormalToYAxis,int);
208  vtkSetMacro(NormalToZAxis,int);
209  vtkGetMacro(NormalToZAxis,int);
210  vtkBooleanMacro(NormalToZAxis,int);
212 
220  void GetPolyData(vtkPolyData *pd);
221 
227  void GetPlane(vtkPlane *plane);
228 
235 
238  void UpdatePlacement(void);
239 
241 
244  vtkGetObjectMacro(HandleProperty,vtkProperty);
245  vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
247 
249 
251  virtual void SetPlaneProperty(vtkProperty*);
252  vtkGetObjectMacro(PlaneProperty,vtkProperty);
253  vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty);
255 
256 protected:
257  vtkPlaneWidget();
258  ~vtkPlaneWidget();
259 
260 //BTX - manage the state of the widget
261  int State;
263  {
264  Start=0,
270  Outside
271  };
272 //ETX
273 
274  //handles the events
275  static void ProcessEvents(vtkObject* object,
276  unsigned long event,
277  void* clientdata,
278  void* calldata);
279 
280  // ProcessEvents() dispatches to these methods.
281  void OnLeftButtonDown();
282  void OnLeftButtonUp();
283  void OnMiddleButtonDown();
284  void OnMiddleButtonUp();
285  void OnRightButtonDown();
286  void OnRightButtonUp();
287  void OnMouseMove();
288 
289  // controlling ivars
294  void SelectRepresentation();
295 
296  // the plane
301  void HighlightPlane(int highlight);
302 
303  // glyphs representing hot spots (e.g., handles)
307  void PositionHandles();
308  void HandlesOn(double length);
309  void HandlesOff();
310  int HighlightHandle(vtkProp *prop); //returns cell id
311  virtual void SizeHandles();
312 
313  // the normal cone
317  void HighlightNormal(int highlight);
318 
319  // the normal line
323 
324  // the normal cone
328 
329  // the normal line
333 
334  // Do the picking
338 
339  // Methods to manipulate the hexahedron.
340  void MoveOrigin(double *p1, double *p2);
341  void MovePoint1(double *p1, double *p2);
342  void MovePoint2(double *p1, double *p2);
343  void MovePoint3(double *p1, double *p2);
344  void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
345  void Spin(double *p1, double *p2);
346  void Scale(double *p1, double *p2, int X, int Y);
347  void Translate(double *p1, double *p2);
348  void Push(double *p1, double *p2);
349 
350  // Plane normal, normalized
351  double Normal[3];
352 
353  // Transform the hexahedral points (used for rotations)
355 
356  // Properties used to control the appearance of selected objects and
357  // the manipulator in general.
362  void CreateDefaultProperties();
363 
364  void GeneratePlane();
365 
368 
369 private:
370  vtkPlaneWidget(const vtkPlaneWidget&); //Not implemented
371  void operator=(const vtkPlaneWidget&); //Not implemented
372 };
373 
374 #endif