VTK  9.3.1
vtkPlaneWidget.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
69 #ifndef vtkPlaneWidget_h
70 #define vtkPlaneWidget_h
71 
72 #include "vtkInteractionWidgetsModule.h" // For export macro
74 
75 VTK_ABI_NAMESPACE_BEGIN
76 class vtkActor;
77 class vtkCellPicker;
78 class vtkConeSource;
79 class vtkLineSource;
80 class vtkPlaneSource;
81 class vtkPoints;
82 class vtkPolyData;
83 class vtkPolyDataMapper;
84 class vtkProp;
85 class vtkProperty;
86 class vtkSphereSource;
87 class vtkTransform;
88 class vtkPlane;
89 
90 #define VTK_PLANE_OFF 0
91 #define VTK_PLANE_OUTLINE 1
92 #define VTK_PLANE_WIREFRAME 2
93 #define VTK_PLANE_SURFACE 3
94 
95 #define VTK_PLANE_ZERO_THRESHOLD (std::numeric_limits<double>::min() * 1000)
96 
97 class VTKINTERACTIONWIDGETS_EXPORT vtkPlaneWidget : public vtkPolyDataSourceWidget
98 {
99 public:
103  static vtkPlaneWidget* New();
104 
106  void PrintSelf(ostream& os, vtkIndent indent) override;
107 
109 
112  void SetEnabled(int) override;
113  void PlaceWidget(double bounds[6]) override;
114  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
116  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
117  {
118  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
119  }
121 
123 
126  void SetResolution(int r);
127  int GetResolution();
129 
131 
134  void SetOrigin(double x, double y, double z);
135  void SetOrigin(double x[3]);
136  double* GetOrigin() VTK_SIZEHINT(3);
137  void GetOrigin(double xyz[3]);
139 
141 
144  void SetPoint1(double x, double y, double z);
145  void SetPoint1(double x[3]);
146  double* GetPoint1() VTK_SIZEHINT(3);
147  void GetPoint1(double xyz[3]);
149 
151 
154  void SetPoint2(double x, double y, double z);
155  void SetPoint2(double x[3]);
156  double* GetPoint2() VTK_SIZEHINT(3);
157  void GetPoint2(double xyz[3]);
159 
161 
164  void SetCenter(double x, double y, double z);
165  void SetCenter(double x[3]);
166  double* GetCenter() VTK_SIZEHINT(3);
167  void GetCenter(double xyz[3]);
169 
171 
174  void SetNormal(double x, double y, double z);
175  void SetNormal(double x[3]);
176  double* GetNormal() VTK_SIZEHINT(3);
177  void GetNormal(double xyz[3]);
179 
181 
189  vtkSetClampMacro(Representation, int, VTK_PLANE_OFF, VTK_PLANE_SURFACE);
190  vtkGetMacro(Representation, int);
191  void SetRepresentationToOff() { this->SetRepresentation(VTK_PLANE_OFF); }
192  void SetRepresentationToOutline() { this->SetRepresentation(VTK_PLANE_OUTLINE); }
193  void SetRepresentationToWireframe() { this->SetRepresentation(VTK_PLANE_WIREFRAME); }
194  void SetRepresentationToSurface() { this->SetRepresentation(VTK_PLANE_SURFACE); }
196 
198 
204  vtkSetMacro(NormalToXAxis, vtkTypeBool);
205  vtkGetMacro(NormalToXAxis, vtkTypeBool);
206  vtkBooleanMacro(NormalToXAxis, vtkTypeBool);
207  vtkSetMacro(NormalToYAxis, vtkTypeBool);
208  vtkGetMacro(NormalToYAxis, vtkTypeBool);
209  vtkBooleanMacro(NormalToYAxis, vtkTypeBool);
210  vtkSetMacro(NormalToZAxis, vtkTypeBool);
211  vtkGetMacro(NormalToZAxis, vtkTypeBool);
212  vtkBooleanMacro(NormalToZAxis, vtkTypeBool);
214 
223  void GetPolyData(vtkPolyData* pd);
224 
232  void GetPlane(vtkPlane* plane);
233 
241 
246  void UpdatePlacement() override;
247 
249 
254  vtkGetObjectMacro(HandleProperty, vtkProperty);
255  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
257 
259 
263  virtual void SetPlaneProperty(vtkProperty*);
264  vtkGetObjectMacro(PlaneProperty, vtkProperty);
265  vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
267 
268 protected:
269  vtkPlaneWidget();
270  ~vtkPlaneWidget() override;
271 
272  // Manage the state of the widget
273  int State;
275  {
276  Start = 0,
283  Pinching
284  };
285 
286  // handles the events
287  static void ProcessEvents(
288  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
289 
290  // ProcessEvents() dispatches to these methods.
291  void OnLeftButtonDown();
292  void OnLeftButtonUp();
293  void OnMiddleButtonDown();
294  void OnMiddleButtonUp();
295  void OnRightButtonDown();
296  void OnRightButtonUp();
297  void OnMouseMove();
298  void OnStartPinch();
299  void OnPinch();
300  void OnEndPinch();
301 
302  // controlling ivars
307  void SelectRepresentation();
308 
309  // the plane
314  void HighlightPlane(int highlight);
315 
316  // glyphs representing hot spots (e.g., handles)
320  void PositionHandles();
321  void HandlesOn(double length);
322  void HandlesOff();
323  int HighlightHandle(vtkProp* prop); // returns cell id
324  void SizeHandles() override;
325 
326  // the normal cone
330  void HighlightNormal(int highlight);
331 
332  // the normal line
336 
337  // the normal cone
341 
342  // the normal line
346 
347  // Do the picking
351 
352  // Register internal Pickers within PickingManager
353  void RegisterPickers() override;
354 
355  // Methods to manipulate the hexahedron.
356  void MoveOrigin(double* p1, double* p2);
357  void MovePoint1(double* p1, double* p2);
358  void MovePoint2(double* p1, double* p2);
359  void MovePoint3(double* p1, double* p2);
360  void Rotate(int X, int Y, double* p1, double* p2, double* vpn);
361  void Spin(double* p1, double* p2);
362  void Scale(double* p1, double* p2, int X, int Y);
363  void Translate(double* p1, double* p2);
364  void Push(double* p1, double* p2);
365 
366  // Plane normal, normalized
367  double Normal[3];
368 
369  // Transform the hexahedral points (used for rotations)
371 
372  // Properties used to control the appearance of selected objects and
373  // the manipulator in general.
378  void CreateDefaultProperties();
379 
380  void GeneratePlane();
381 
384 
385 private:
386  vtkPlaneWidget(const vtkPlaneWidget&) = delete;
387  void operator=(const vtkPlaneWidget&) = delete;
388 };
389 
390 VTK_ABI_NAMESPACE_END
391 #endif
vtkProperty * HandleProperty
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:45
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:40
abstract base class for most VTK objects
Definition: vtkObject.h:51
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:56
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:33
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:49
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:79
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:64
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:28
#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:25
#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:52
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:61
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:144
virtual void PlaceWidget()
This method is used to initially place the widget.
vtkPolyDataMapper ** HandleMapper
double HandleSizeFactor
represent and manipulate 3D points
Definition: vtkPoints.h:28
vtkConeSource * ConeSource2
vtkPolyDataMapper * ConeMapper2