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 =========================================================================*/
75 #ifndef vtkPlaneWidget_h
76 #define vtkPlaneWidget_h
77 
78 #include "vtkInteractionWidgetsModule.h" // For export macro
80 
81 class vtkActor;
82 class vtkCellPicker;
83 class vtkConeSource;
84 class vtkLineSource;
85 class vtkPlaneSource;
86 class vtkPoints;
87 class vtkPolyData;
88 class vtkPolyDataMapper;
89 class vtkProp;
90 class vtkProperty;
91 class vtkSphereSource;
92 class vtkTransform;
93 class vtkPlane;
94 
95 #define VTK_PLANE_OFF 0
96 #define VTK_PLANE_OUTLINE 1
97 #define VTK_PLANE_WIREFRAME 2
98 #define VTK_PLANE_SURFACE 3
99 
100 class VTKINTERACTIONWIDGETS_EXPORT vtkPlaneWidget : public vtkPolyDataSourceWidget
101 {
102 public:
106  static vtkPlaneWidget *New();
107 
109  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
110 
112 
115  void SetEnabled(int) VTK_OVERRIDE;
116  void PlaceWidget(double bounds[6]) VTK_OVERRIDE;
117  void PlaceWidget() VTK_OVERRIDE
118  {this->Superclass::PlaceWidget();}
119  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
120  double zmin, double zmax) VTK_OVERRIDE
121  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
123 
125 
128  void SetResolution(int r);
129  int GetResolution();
131 
133 
136  void SetOrigin(double x, double y, double z);
137  void SetOrigin(double x[3]);
138  double* GetOrigin();
139  void GetOrigin(double xyz[3]);
141 
143 
146  void SetPoint1(double x, double y, double z);
147  void SetPoint1(double x[3]);
148  double* GetPoint1();
149  void GetPoint1(double xyz[3]);
151 
153 
156  void SetPoint2(double x, double y, double z);
157  void SetPoint2(double x[3]);
158  double* GetPoint2();
159  void GetPoint2(double xyz[3]);
161 
163 
166  void SetCenter(double x, double y, double z);
167  void SetCenter(double x[3]);
168  double* GetCenter();
169  void GetCenter(double xyz[3]);
171 
173 
176  void SetNormal(double x, double y, double z);
177  void SetNormal(double x[3]);
178  double* GetNormal();
179  void GetNormal(double xyz[3]);
181 
183 
191  vtkSetClampMacro(Representation,int,VTK_PLANE_OFF,VTK_PLANE_SURFACE);
192  vtkGetMacro(Representation,int);
194  {this->SetRepresentation(VTK_PLANE_OFF);}
196  {this->SetRepresentation(VTK_PLANE_OUTLINE);}
198  {this->SetRepresentation(VTK_PLANE_WIREFRAME);}
200  {this->SetRepresentation(VTK_PLANE_SURFACE);}
202 
204 
210  vtkSetMacro(NormalToXAxis,int);
211  vtkGetMacro(NormalToXAxis,int);
212  vtkBooleanMacro(NormalToXAxis,int);
213  vtkSetMacro(NormalToYAxis,int);
214  vtkGetMacro(NormalToYAxis,int);
215  vtkBooleanMacro(NormalToYAxis,int);
216  vtkSetMacro(NormalToZAxis,int);
217  vtkGetMacro(NormalToZAxis,int);
218  vtkBooleanMacro(NormalToZAxis,int);
220 
229  void GetPolyData(vtkPolyData *pd);
230 
238  void GetPlane(vtkPlane *plane);
239 
247 
252  void UpdatePlacement(void) VTK_OVERRIDE;
253 
255 
260  vtkGetObjectMacro(HandleProperty,vtkProperty);
261  vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
263 
265 
269  virtual void SetPlaneProperty(vtkProperty*);
270  vtkGetObjectMacro(PlaneProperty,vtkProperty);
271  vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty);
273 
274 protected:
275  vtkPlaneWidget();
276  ~vtkPlaneWidget() VTK_OVERRIDE;
277 
278  // Manage the state of the widget
279  int State;
281  {
282  Start=0,
289  Pinching
290  };
291 
292  //handles the events
293  static void ProcessEvents(vtkObject* object,
294  unsigned long event,
295  void* clientdata,
296  void* calldata);
297 
298  // ProcessEvents() dispatches to these methods.
299  void OnLeftButtonDown();
300  void OnLeftButtonUp();
301  void OnMiddleButtonDown();
302  void OnMiddleButtonUp();
303  void OnRightButtonDown();
304  void OnRightButtonUp();
305  void OnMouseMove();
306  void OnStartPinch();
307  void OnPinch();
308  void OnEndPinch();
309 
310  // controlling ivars
315  void SelectRepresentation();
316 
317  // the plane
322  void HighlightPlane(int highlight);
323 
324  // glyphs representing hot spots (e.g., handles)
328  void PositionHandles();
329  void HandlesOn(double length);
330  void HandlesOff();
331  int HighlightHandle(vtkProp *prop); //returns cell id
332  void SizeHandles() VTK_OVERRIDE;
333 
334  // the normal cone
335  vtkActor *ConeActor;
336  vtkPolyDataMapper *ConeMapper;
337  vtkConeSource *ConeSource;
338  void HighlightNormal(int highlight);
339 
340  // the normal line
341  vtkActor *LineActor;
342  vtkPolyDataMapper *LineMapper;
343  vtkLineSource *LineSource;
344 
345  // the normal cone
346  vtkActor *ConeActor2;
347  vtkPolyDataMapper *ConeMapper2;
348  vtkConeSource *ConeSource2;
349 
350  // the normal line
351  vtkActor *LineActor2;
352  vtkPolyDataMapper *LineMapper2;
353  vtkLineSource *LineSource2;
354 
355  // Do the picking
356  vtkCellPicker *HandlePicker;
357  vtkCellPicker *PlanePicker;
358  vtkActor *CurrentHandle;
359 
360  // Register internal Pickers within PickingManager
361  void RegisterPickers() VTK_OVERRIDE;
362 
363  // Methods to manipulate the hexahedron.
364  void MoveOrigin(double *p1, double *p2);
365  void MovePoint1(double *p1, double *p2);
366  void MovePoint2(double *p1, double *p2);
367  void MovePoint3(double *p1, double *p2);
368  void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
369  void Spin(double *p1, double *p2);
370  void Scale(double *p1, double *p2, int X, int Y);
371  void Translate(double *p1, double *p2);
372  void Push(double *p1, double *p2);
373 
374  // Plane normal, normalized
375  double Normal[3];
376 
377  // Transform the hexahedral points (used for rotations)
379 
380  // Properties used to control the appearance of selected objects and
381  // the manipulator in general.
382  vtkProperty *HandleProperty;
383  vtkProperty *SelectedHandleProperty;
384  vtkProperty *PlaneProperty;
385  vtkProperty *SelectedPlaneProperty;
386  void CreateDefaultProperties();
387 
388  void GeneratePlane();
389 
390  int LastPickValid;
391  double HandleSizeFactor;
392 
393 private:
394  vtkPlaneWidget(const vtkPlaneWidget&) VTK_DELETE_FUNCTION;
395  void operator=(const vtkPlaneWidget&) VTK_DELETE_FUNCTION;
396 };
397 
398 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:44
virtual vtkPolyDataAlgorithm * GetPolyDataAlgorithm()=0
Returns underlying vtkPolyDataAlgorithm that determines geometry.
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
abstract base class for most VTK objects
Definition: vtkObject.h:53
abstract PolyDataSource-based 3D widget
void SetRepresentationToWireframe()
Control how the plane appears when GetPolyData() is invoked.
represent surface properties of a geometric object
Definition: vtkProperty.h:58
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Handles the char widget activation event.
vtkSphereSource ** HandleGeometry
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
vtkPolyData * PlaneOutline
void SetRepresentationToOutline()
Control how the plane appears when GetPolyData() is invoked.
generate polygonal cone
Definition: vtkConeSource.h:38
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
vtkActor ** Handle
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
void SetRepresentationToOff()
Control how the plane appears when GetPolyData() is invoked.
void SetRepresentationToSurface()
Control how the plane appears when GetPolyData() is invoked.
create a polygonal sphere centered at the origin
Superclass for algorithms that produce only polydata as output.
a simple class to control print indentation
Definition: vtkIndent.h:33
#define VTK_PLANE_SURFACE
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
perform various plane computations
Definition: vtkPlane.h:31
#define VTK_PLANE_WIREFRAME
vtkPolyDataMapper * PlaneMapper
vtkPlaneSource * PlaneSource
create an array of quadrilaterals located in a plane
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
create a line defined by two end points
Definition: vtkLineSource.h:36
map vtkPolyData to graphics primitives
vtkActor * PlaneActor
#define VTK_PLANE_OUTLINE
#define VTK_PLANE_OFF
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:63
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
3D widget for manipulating a finite plane
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Methods that satisfy the superclass' API.
virtual void SizeHandles()
Definition: vtk3DWidget.h:152
virtual void PlaceWidget()
This method is used to initially place the widget.
vtkPolyDataMapper ** HandleMapper
represent and manipulate 3D points
Definition: vtkPoints.h:33
Transform
Definition: ADIOSDefs.h:39