VTK  9.3.0
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
78 #ifndef vtkPlaneWidget_h
79 #define vtkPlaneWidget_h
80 
81 #include "vtkInteractionWidgetsModule.h" // For export macro
83 
84 VTK_ABI_NAMESPACE_BEGIN
85 class vtkActor;
86 class vtkCellPicker;
87 class vtkConeSource;
88 class vtkLineSource;
89 class vtkPlaneSource;
90 class vtkPoints;
91 class vtkPolyData;
92 class vtkPolyDataMapper;
93 class vtkProp;
94 class vtkProperty;
95 class vtkSphereSource;
96 class vtkTransform;
97 class vtkPlane;
98 
99 #define VTK_PLANE_OFF 0
100 #define VTK_PLANE_OUTLINE 1
101 #define VTK_PLANE_WIREFRAME 2
102 #define VTK_PLANE_SURFACE 3
103 
104 #define VTK_PLANE_ZERO_THRESHOLD (std::numeric_limits<double>::min() * 1000)
105 
106 class VTKINTERACTIONWIDGETS_EXPORT vtkPlaneWidget : public vtkPolyDataSourceWidget
107 {
108 public:
112  static vtkPlaneWidget* New();
113 
115  void PrintSelf(ostream& os, vtkIndent indent) override;
116 
118 
121  void SetEnabled(int) override;
122  void PlaceWidget(double bounds[6]) override;
123  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
125  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
126  {
127  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
128  }
130 
132 
135  void SetResolution(int r);
138 
140 
143  void SetOrigin(double x, double y, double z);
144  void SetOrigin(double x[3]);
145  double* GetOrigin() VTK_SIZEHINT(3);
146  void GetOrigin(double xyz[3]);
148 
150 
153  void SetPoint1(double x, double y, double z);
154  void SetPoint1(double x[3]);
155  double* GetPoint1() VTK_SIZEHINT(3);
156  void GetPoint1(double xyz[3]);
158 
160 
163  void SetPoint2(double x, double y, double z);
164  void SetPoint2(double x[3]);
165  double* GetPoint2() VTK_SIZEHINT(3);
166  void GetPoint2(double xyz[3]);
168 
170 
173  void SetCenter(double x, double y, double z);
174  void SetCenter(double x[3]);
175  double* GetCenter() VTK_SIZEHINT(3);
176  void GetCenter(double xyz[3]);
178 
180 
183  void SetNormal(double x, double y, double z);
184  void SetNormal(double x[3]);
185  double* GetNormal() VTK_SIZEHINT(3);
186  void GetNormal(double xyz[3]);
188 
190 
198  vtkSetClampMacro(Representation, int, VTK_PLANE_OFF, VTK_PLANE_SURFACE);
199  vtkGetMacro(Representation, int);
200  void SetRepresentationToOff() { this->SetRepresentation(VTK_PLANE_OFF); }
201  void SetRepresentationToOutline() { this->SetRepresentation(VTK_PLANE_OUTLINE); }
202  void SetRepresentationToWireframe() { this->SetRepresentation(VTK_PLANE_WIREFRAME); }
203  void SetRepresentationToSurface() { this->SetRepresentation(VTK_PLANE_SURFACE); }
205 
207 
213  vtkSetMacro(NormalToXAxis, vtkTypeBool);
214  vtkGetMacro(NormalToXAxis, vtkTypeBool);
215  vtkBooleanMacro(NormalToXAxis, vtkTypeBool);
216  vtkSetMacro(NormalToYAxis, vtkTypeBool);
217  vtkGetMacro(NormalToYAxis, vtkTypeBool);
218  vtkBooleanMacro(NormalToYAxis, vtkTypeBool);
219  vtkSetMacro(NormalToZAxis, vtkTypeBool);
220  vtkGetMacro(NormalToZAxis, vtkTypeBool);
221  vtkBooleanMacro(NormalToZAxis, vtkTypeBool);
223 
233 
241  void GetPlane(vtkPlane* plane);
242 
250 
255  void UpdatePlacement() override;
256 
258 
263  vtkGetObjectMacro(HandleProperty, vtkProperty);
264  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
266 
268 
273  vtkGetObjectMacro(PlaneProperty, vtkProperty);
274  vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
276 
277 protected:
279  ~vtkPlaneWidget() override;
280 
281  // Manage the state of the widget
282  int State;
284  {
285  Start = 0,
292  Pinching
293  };
294 
295  // handles the events
296  static void ProcessEvents(
297  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
298 
299  // ProcessEvents() dispatches to these methods.
306  void OnMouseMove();
307  void OnStartPinch();
308  void OnPinch();
309  void OnEndPinch();
310 
311  // controlling ivars
317 
318  // the plane
323  void HighlightPlane(int highlight);
324 
325  // glyphs representing hot spots (e.g., handles)
330  void HandlesOn(double length);
331  void HandlesOff();
332  int HighlightHandle(vtkProp* prop); // returns cell id
333  void SizeHandles() override;
334 
335  // the normal cone
339  void HighlightNormal(int highlight);
340 
341  // the normal line
345 
346  // the normal cone
350 
351  // the normal line
355 
356  // Do the picking
360 
361  // Register internal Pickers within PickingManager
362  void RegisterPickers() override;
363 
364  // Methods to manipulate the hexahedron.
365  void MoveOrigin(double* p1, double* p2);
366  void MovePoint1(double* p1, double* p2);
367  void MovePoint2(double* p1, double* p2);
368  void MovePoint3(double* p1, double* p2);
369  void Rotate(int X, int Y, double* p1, double* p2, double* vpn);
370  void Spin(double* p1, double* p2);
371  void Scale(double* p1, double* p2, int X, int Y);
372  void Translate(double* p1, double* p2);
373  void Push(double* p1, double* p2);
374 
375  // Plane normal, normalized
376  double Normal[3];
377 
378  // Transform the hexahedral points (used for rotations)
380 
381  // Properties used to control the appearance of selected objects and
382  // the manipulator in general.
388 
390 
393 
394 private:
395  vtkPlaneWidget(const vtkPlaneWidget&) = delete;
396  void operator=(const vtkPlaneWidget&) = delete;
397 };
398 
399 VTK_ABI_NAMESPACE_END
400 #endif
virtual void PlaceWidget()
This method is used to initially place the widget.
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:71
generate polygonal cone
Definition: vtkConeSource.h:43
a simple class to control print indentation
Definition: vtkIndent.h:38
create a line defined by two end points
Definition: vtkLineSource.h:62
abstract base class for most VTK objects
Definition: vtkObject.h:61
create an array of quadrilaterals located in a plane
3D widget for manipulating a finite plane
vtkProperty * HandleProperty
void MovePoint3(double *p1, double *p2)
void SetOrigin(double x, double y, double z)
Set/Get the origin of the plane.
vtkConeSource * ConeSource
vtkTypeBool NormalToYAxis
vtkPolyDataAlgorithm * GetPolyDataAlgorithm() override
Satisfies superclass API.
vtkPlaneSource * PlaneSource
vtkSphereSource ** HandleGeometry
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkLineSource * LineSource
double * GetOrigin()
Set/Get the origin of the plane.
~vtkPlaneWidget() override
void GetPlane(vtkPlane *plane)
Get the planes describing the implicit function defined by the plane widget.
void MovePoint2(double *p1, double *p2)
void PlaceWidget(double bounds[6]) override
Methods that satisfy the superclass' API.
vtkPolyDataMapper * PlaneMapper
void OnRightButtonUp()
vtkProperty * PlaneProperty
void PlaceWidget() override
Methods that satisfy the superclass' API.
void UpdatePlacement() override
Satisfies superclass API.
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Methods that satisfy the superclass' API.
int HighlightHandle(vtkProp *prop)
vtkActor * ConeActor2
vtkActor ** Handle
void OnStartPinch()
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
void CreateDefaultProperties()
void OnLeftButtonDown()
void HighlightNormal(int highlight)
void SetEnabled(int) override
Methods that satisfy the superclass' API.
void GetPolyData(vtkPolyData *pd)
Grab the polydata (including points) that defines the plane.
vtkPolyDataMapper * LineMapper2
void MovePoint1(double *p1, double *p2)
vtkProperty * SelectedHandleProperty
void GeneratePlane()
vtkPolyDataMapper * ConeMapper2
void Scale(double *p1, double *p2, int X, int Y)
void Push(double *p1, double *p2)
vtkProperty * SelectedPlaneProperty
void OnLeftButtonUp()
void SizeHandles() override
void HandlesOn(double length)
void MoveOrigin(double *p1, double *p2)
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
void OnMouseMove()
void SetResolution(int r)
Set/Get the resolution (number of subdivisions) of the plane.
vtkPolyDataMapper ** HandleMapper
vtkCellPicker * HandlePicker
vtkPolyDataMapper * LineMapper
vtkActor * ConeActor
vtkTypeBool NormalToZAxis
void SetRepresentationToSurface()
Control how the plane appears when GetPolyData() is invoked.
void SetRepresentationToOutline()
Control how the plane appears when GetPolyData() is invoked.
vtkActor * CurrentHandle
void SelectRepresentation()
double HandleSizeFactor
void SetOrigin(double x[3])
Set/Get the origin of the plane.
int GetResolution()
Set/Get the resolution (number of subdivisions) of the plane.
vtkPolyData * PlaneOutline
vtkTransform * Transform
void PositionHandles()
void OnMiddleButtonDown()
vtkLineSource * LineSource2
vtkPolyDataMapper * ConeMapper
void OnRightButtonDown()
vtkCellPicker * PlanePicker
static vtkPlaneWidget * New()
Instantiate the object.
virtual void SetPlaneProperty(vtkProperty *)
Get the plane properties.
void Rotate(int X, int Y, double *p1, double *p2, double *vpn)
vtkConeSource * ConeSource2
vtkActor * LineActor
void Spin(double *p1, double *p2)
void HighlightPlane(int highlight)
vtkActor * PlaneActor
void SetRepresentationToWireframe()
Control how the plane appears when GetPolyData() is invoked.
void Translate(double *p1, double *p2)
void OnMiddleButtonUp()
vtkTypeBool NormalToXAxis
vtkActor * LineActor2
perform various plane computations
Definition: vtkPlane.h:35
represent and manipulate 3D points
Definition: vtkPoints.h:38
Superclass for algorithms that produce only polydata as output.
map vtkPolyData to graphics primitives
abstract PolyDataSource-based 3D widget
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:89
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:55
represent surface properties of a geometric object
Definition: vtkProperty.h:66
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:59
@ Normal
Definition: vtkX3D.h:45
@ length
Definition: vtkX3D.h:393
int vtkTypeBool
Definition: vtkABI.h:64
#define VTK_PLANE_OUTLINE
#define VTK_PLANE_WIREFRAME
#define VTK_PLANE_OFF
#define VTK_PLANE_SURFACE
#define VTK_SIZEHINT(...)