VTK  9.0.1
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) override;
110 
112 
115  void SetEnabled(int) override;
116  void PlaceWidget(double bounds[6]) override;
117  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
119  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
120  {
121  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
122  }
124 
126 
129  void SetResolution(int r);
130  int GetResolution();
132 
134 
137  void SetOrigin(double x, double y, double z);
138  void SetOrigin(double x[3]);
139  double* GetOrigin() VTK_SIZEHINT(3);
140  void GetOrigin(double xyz[3]);
142 
144 
147  void SetPoint1(double x, double y, double z);
148  void SetPoint1(double x[3]);
149  double* GetPoint1() VTK_SIZEHINT(3);
150  void GetPoint1(double xyz[3]);
152 
154 
157  void SetPoint2(double x, double y, double z);
158  void SetPoint2(double x[3]);
159  double* GetPoint2() VTK_SIZEHINT(3);
160  void GetPoint2(double xyz[3]);
162 
164 
167  void SetCenter(double x, double y, double z);
168  void SetCenter(double x[3]);
169  double* GetCenter() VTK_SIZEHINT(3);
170  void GetCenter(double xyz[3]);
172 
174 
177  void SetNormal(double x, double y, double z);
178  void SetNormal(double x[3]);
179  double* GetNormal() VTK_SIZEHINT(3);
180  void GetNormal(double xyz[3]);
182 
184 
192  vtkSetClampMacro(Representation, int, VTK_PLANE_OFF, VTK_PLANE_SURFACE);
193  vtkGetMacro(Representation, int);
194  void SetRepresentationToOff() { this->SetRepresentation(VTK_PLANE_OFF); }
195  void SetRepresentationToOutline() { this->SetRepresentation(VTK_PLANE_OUTLINE); }
196  void SetRepresentationToWireframe() { this->SetRepresentation(VTK_PLANE_WIREFRAME); }
197  void SetRepresentationToSurface() { this->SetRepresentation(VTK_PLANE_SURFACE); }
199 
201 
207  vtkSetMacro(NormalToXAxis, vtkTypeBool);
208  vtkGetMacro(NormalToXAxis, vtkTypeBool);
209  vtkBooleanMacro(NormalToXAxis, vtkTypeBool);
210  vtkSetMacro(NormalToYAxis, vtkTypeBool);
211  vtkGetMacro(NormalToYAxis, vtkTypeBool);
212  vtkBooleanMacro(NormalToYAxis, vtkTypeBool);
213  vtkSetMacro(NormalToZAxis, vtkTypeBool);
214  vtkGetMacro(NormalToZAxis, vtkTypeBool);
215  vtkBooleanMacro(NormalToZAxis, vtkTypeBool);
217 
226  void GetPolyData(vtkPolyData* pd);
227 
235  void GetPlane(vtkPlane* plane);
236 
244 
249  void UpdatePlacement(void) override;
250 
252 
257  vtkGetObjectMacro(HandleProperty, vtkProperty);
258  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
260 
262 
266  virtual void SetPlaneProperty(vtkProperty*);
267  vtkGetObjectMacro(PlaneProperty, vtkProperty);
268  vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
270 
271 protected:
272  vtkPlaneWidget();
273  ~vtkPlaneWidget() override;
274 
275  // Manage the state of the widget
276  int State;
278  {
279  Start = 0,
286  Pinching
287  };
288 
289  // handles the events
290  static void ProcessEvents(
291  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
292 
293  // ProcessEvents() dispatches to these methods.
294  void OnLeftButtonDown();
295  void OnLeftButtonUp();
296  void OnMiddleButtonDown();
297  void OnMiddleButtonUp();
298  void OnRightButtonDown();
299  void OnRightButtonUp();
300  void OnMouseMove();
301  void OnStartPinch();
302  void OnPinch();
303  void OnEndPinch();
304 
305  // controlling ivars
310  void SelectRepresentation();
311 
312  // the plane
317  void HighlightPlane(int highlight);
318 
319  // glyphs representing hot spots (e.g., handles)
323  void PositionHandles();
324  void HandlesOn(double length);
325  void HandlesOff();
326  int HighlightHandle(vtkProp* prop); // returns cell id
327  void SizeHandles() override;
328 
329  // the normal cone
333  void HighlightNormal(int highlight);
334 
335  // the normal line
339 
340  // the normal cone
344 
345  // the normal line
349 
350  // Do the picking
354 
355  // Register internal Pickers within PickingManager
356  void RegisterPickers() override;
357 
358  // Methods to manipulate the hexahedron.
359  void MoveOrigin(double* p1, double* p2);
360  void MovePoint1(double* p1, double* p2);
361  void MovePoint2(double* p1, double* p2);
362  void MovePoint3(double* p1, double* p2);
363  void Rotate(int X, int Y, double* p1, double* p2, double* vpn);
364  void Spin(double* p1, double* p2);
365  void Scale(double* p1, double* p2, int X, int Y);
366  void Translate(double* p1, double* p2);
367  void Push(double* p1, double* p2);
368 
369  // Plane normal, normalized
370  double Normal[3];
371 
372  // Transform the hexahedral points (used for rotations)
374 
375  // Properties used to control the appearance of selected objects and
376  // the manipulator in general.
381  void CreateDefaultProperties();
382 
383  void GeneratePlane();
384 
387 
388 private:
389  vtkPlaneWidget(const vtkPlaneWidget&) = delete;
390  void operator=(const vtkPlaneWidget&) = delete;
391 };
392 
393 #endif
vtkProperty * HandleProperty
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:47
vtkTypeBool NormalToXAxis
virtual vtkPolyDataAlgorithm * GetPolyDataAlgorithm()=0
Returns underlying vtkPolyDataAlgorithm that determines geometry.
vtkLineSource * LineSource
vtkProperty * SelectedHandleProperty
vtkTypeBool NormalToYAxis
vtkPolyDataMapper * ConeMapper
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
vtkPolyDataMapper * LineMapper
void SetRepresentationToWireframe()
Control how the plane appears when GetPolyData() is invoked.
represent surface properties of a geometric object
Definition: vtkProperty.h:61
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Handles the char widget activation event.
vtkActor * ConeActor
vtkSphereSource ** HandleGeometry
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
vtkProperty * PlaneProperty
vtkPolyData * PlaneOutline
void SetRepresentationToOutline()
Control how the plane appears when GetPolyData() is invoked.
vtkActor * LineActor
generate polygonal cone
Definition: vtkConeSource.h:38
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
vtkActor ** Handle
void PlaceWidget() override
Overrides vtk3DWidget PlaceWidget() so that it doesn't complain if there's no Input and no Prop3D...
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
vtkActor * ConeActor2
virtual void UpdatePlacement()=0
If you've made changes to the underlying vtkPolyDataSource AFTER your initial call to PlaceWidget()...
void PlaceWidget() override
Methods that satisfy the superclass' API.
vtkTypeBool NormalToZAxis
void SetRepresentationToOff()
Control how the plane appears when GetPolyData() is invoked.
void SetRepresentationToSurface()
Control how the plane appears when GetPolyData() is invoked.
vtkLineSource * LineSource2
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkConeSource * ConeSource
int vtkTypeBool
Definition: vtkABI.h:69
create a polygonal sphere centered at the origin
Superclass for algorithms that produce only polydata as output.
vtkActor * LineActor2
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.
vtkTransform * Transform
perform various plane computations
Definition: vtkPlane.h:31
#define VTK_PLANE_WIREFRAME
vtkProperty * SelectedPlaneProperty
vtkPolyDataMapper * PlaneMapper
#define VTK_SIZEHINT(...)
vtkPlaneSource * PlaneSource
create an array of quadrilaterals located in a plane
vtkPolyDataMapper * LineMapper2
create a line defined by two end points
Definition: vtkLineSource.h:60
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:66
vtkCellPicker * HandlePicker
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.
vtkCellPicker * PlanePicker
vtkActor * CurrentHandle
virtual void SizeHandles()
Definition: vtk3DWidget.h:152
virtual void PlaceWidget()
This method is used to initially place the widget.
vtkPolyDataMapper ** HandleMapper
double HandleSizeFactor
represent and manipulate 3D points
Definition: vtkPoints.h:33
vtkConeSource * ConeSource2
vtkPolyDataMapper * ConeMapper2