VTK  9.2.6
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 =========================================================================*/
81 #ifndef vtkPlaneWidget_h
82 #define vtkPlaneWidget_h
83 
84 #include "vtkInteractionWidgetsModule.h" // For export macro
86 
87 class vtkActor;
88 class vtkCellPicker;
89 class vtkConeSource;
90 class vtkLineSource;
91 class vtkPlaneSource;
92 class vtkPoints;
93 class vtkPolyData;
94 class vtkPolyDataMapper;
95 class vtkProp;
96 class vtkProperty;
97 class vtkSphereSource;
98 class vtkTransform;
99 class vtkPlane;
100 
101 #define VTK_PLANE_OFF 0
102 #define VTK_PLANE_OUTLINE 1
103 #define VTK_PLANE_WIREFRAME 2
104 #define VTK_PLANE_SURFACE 3
105 
106 #define VTK_PLANE_ZERO_THRESHOLD (std::numeric_limits<double>::min() * 1000)
107 
108 class VTKINTERACTIONWIDGETS_EXPORT vtkPlaneWidget : public vtkPolyDataSourceWidget
109 {
110 public:
114  static vtkPlaneWidget* New();
115 
117  void PrintSelf(ostream& os, vtkIndent indent) override;
118 
120 
123  void SetEnabled(int) override;
124  void PlaceWidget(double bounds[6]) override;
125  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
127  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
128  {
129  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
130  }
132 
134 
137  void SetResolution(int r);
138  int GetResolution();
140 
142 
145  void SetOrigin(double x, double y, double z);
146  void SetOrigin(double x[3]);
147  double* GetOrigin() VTK_SIZEHINT(3);
148  void GetOrigin(double xyz[3]);
150 
152 
155  void SetPoint1(double x, double y, double z);
156  void SetPoint1(double x[3]);
157  double* GetPoint1() VTK_SIZEHINT(3);
158  void GetPoint1(double xyz[3]);
160 
162 
165  void SetPoint2(double x, double y, double z);
166  void SetPoint2(double x[3]);
167  double* GetPoint2() VTK_SIZEHINT(3);
168  void GetPoint2(double xyz[3]);
170 
172 
175  void SetCenter(double x, double y, double z);
176  void SetCenter(double x[3]);
177  double* GetCenter() VTK_SIZEHINT(3);
178  void GetCenter(double xyz[3]);
180 
182 
185  void SetNormal(double x, double y, double z);
186  void SetNormal(double x[3]);
187  double* GetNormal() VTK_SIZEHINT(3);
188  void GetNormal(double xyz[3]);
190 
192 
200  vtkSetClampMacro(Representation, int, VTK_PLANE_OFF, VTK_PLANE_SURFACE);
201  vtkGetMacro(Representation, int);
202  void SetRepresentationToOff() { this->SetRepresentation(VTK_PLANE_OFF); }
203  void SetRepresentationToOutline() { this->SetRepresentation(VTK_PLANE_OUTLINE); }
204  void SetRepresentationToWireframe() { this->SetRepresentation(VTK_PLANE_WIREFRAME); }
205  void SetRepresentationToSurface() { this->SetRepresentation(VTK_PLANE_SURFACE); }
207 
209 
215  vtkSetMacro(NormalToXAxis, vtkTypeBool);
216  vtkGetMacro(NormalToXAxis, vtkTypeBool);
217  vtkBooleanMacro(NormalToXAxis, vtkTypeBool);
218  vtkSetMacro(NormalToYAxis, vtkTypeBool);
219  vtkGetMacro(NormalToYAxis, vtkTypeBool);
220  vtkBooleanMacro(NormalToYAxis, vtkTypeBool);
221  vtkSetMacro(NormalToZAxis, vtkTypeBool);
222  vtkGetMacro(NormalToZAxis, vtkTypeBool);
223  vtkBooleanMacro(NormalToZAxis, vtkTypeBool);
225 
234  void GetPolyData(vtkPolyData* pd);
235 
243  void GetPlane(vtkPlane* plane);
244 
252 
257  void UpdatePlacement(void) override;
258 
260 
265  vtkGetObjectMacro(HandleProperty, vtkProperty);
266  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
268 
270 
274  virtual void SetPlaneProperty(vtkProperty*);
275  vtkGetObjectMacro(PlaneProperty, vtkProperty);
276  vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
278 
279 protected:
280  vtkPlaneWidget();
281  ~vtkPlaneWidget() override;
282 
283  // Manage the state of the widget
284  int State;
286  {
287  Start = 0,
294  Pinching
295  };
296 
297  // handles the events
298  static void ProcessEvents(
299  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
300 
301  // ProcessEvents() dispatches to these methods.
302  void OnLeftButtonDown();
303  void OnLeftButtonUp();
304  void OnMiddleButtonDown();
305  void OnMiddleButtonUp();
306  void OnRightButtonDown();
307  void OnRightButtonUp();
308  void OnMouseMove();
309  void OnStartPinch();
310  void OnPinch();
311  void OnEndPinch();
312 
313  // controlling ivars
318  void SelectRepresentation();
319 
320  // the plane
325  void HighlightPlane(int highlight);
326 
327  // glyphs representing hot spots (e.g., handles)
331  void PositionHandles();
332  void HandlesOn(double length);
333  void HandlesOff();
334  int HighlightHandle(vtkProp* prop); // returns cell id
335  void SizeHandles() override;
336 
337  // the normal cone
341  void HighlightNormal(int highlight);
342 
343  // the normal line
347 
348  // the normal cone
352 
353  // the normal line
357 
358  // Do the picking
362 
363  // Register internal Pickers within PickingManager
364  void RegisterPickers() override;
365 
366  // Methods to manipulate the hexahedron.
367  void MoveOrigin(double* p1, double* p2);
368  void MovePoint1(double* p1, double* p2);
369  void MovePoint2(double* p1, double* p2);
370  void MovePoint3(double* p1, double* p2);
371  void Rotate(int X, int Y, double* p1, double* p2, double* vpn);
372  void Spin(double* p1, double* p2);
373  void Scale(double* p1, double* p2, int X, int Y);
374  void Translate(double* p1, double* p2);
375  void Push(double* p1, double* p2);
376 
377  // Plane normal, normalized
378  double Normal[3];
379 
380  // Transform the hexahedral points (used for rotations)
382 
383  // Properties used to control the appearance of selected objects and
384  // the manipulator in general.
389  void CreateDefaultProperties();
390 
391  void GeneratePlane();
392 
395 
396 private:
397  vtkPlaneWidget(const vtkPlaneWidget&) = delete;
398  void operator=(const vtkPlaneWidget&) = delete;
399 };
400 
401 #endif
vtkProperty * HandleProperty
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:56
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:51
abstract base class for most VTK objects
Definition: vtkObject.h:62
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:67
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:44
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
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:90
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 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:39
#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:36
#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:63
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:72
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:155
virtual void PlaceWidget()
This method is used to initially place the widget.
vtkPolyDataMapper ** HandleMapper
double HandleSizeFactor
represent and manipulate 3D points
Definition: vtkPoints.h:39
vtkConeSource * ConeSource2
vtkPolyDataMapper * ConeMapper2