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
66#ifndef vtkPlaneWidget_h
67#define vtkPlaneWidget_h
68
69#include "vtkInteractionWidgetsModule.h" // For export macro
71
72VTK_ABI_NAMESPACE_BEGIN
73class vtkActor;
74class vtkCellPicker;
75class vtkConeSource;
76class vtkLineSource;
77class vtkPlaneSource;
78class vtkPoints;
79class vtkPolyData;
81class vtkProp;
82class vtkProperty;
83class vtkSphereSource;
84class vtkTransform;
85class vtkPlane;
86
87#define VTK_PLANE_OFF 0
88#define VTK_PLANE_OUTLINE 1
89#define VTK_PLANE_WIREFRAME 2
90#define VTK_PLANE_SURFACE 3
91
92#define VTK_PLANE_ZERO_THRESHOLD (std::numeric_limits<double>::min() * 1000)
93
94class VTKINTERACTIONWIDGETS_EXPORT vtkPlaneWidget : public vtkPolyDataSourceWidget
95{
96public:
101
103 void PrintSelf(ostream& os, vtkIndent indent) override;
104
106
109 void SetEnabled(int) override;
110 void PlaceWidget(double bounds[6]) override;
111 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
113 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
114 {
115 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
116 }
118
120
123 void SetResolution(int r);
126
128
131 void SetOrigin(double x, double y, double z);
132 void SetOrigin(double x[3]);
134 void GetOrigin(double xyz[3]);
136
138
141 void SetPoint1(double x, double y, double z);
142 void SetPoint1(double x[3]);
143 double* GetPoint1() VTK_SIZEHINT(3);
144 void GetPoint1(double xyz[3]);
146
148
151 void SetPoint2(double x, double y, double z);
152 void SetPoint2(double x[3]);
153 double* GetPoint2() VTK_SIZEHINT(3);
154 void GetPoint2(double xyz[3]);
156
158
161 void SetCenter(double x, double y, double z);
162 void SetCenter(double x[3]);
163 double* GetCenter() VTK_SIZEHINT(3);
164 void GetCenter(double xyz[3]);
166
168
171 void SetNormal(double x, double y, double z);
172 void SetNormal(double x[3]);
173 double* GetNormal() VTK_SIZEHINT(3);
174 void GetNormal(double xyz[3]);
176
178
186 vtkSetClampMacro(Representation, int, VTK_PLANE_OFF, VTK_PLANE_SURFACE);
187 vtkGetMacro(Representation, int);
188 void SetRepresentationToOff() { this->SetRepresentation(VTK_PLANE_OFF); }
189 void SetRepresentationToOutline() { this->SetRepresentation(VTK_PLANE_OUTLINE); }
190 void SetRepresentationToWireframe() { this->SetRepresentation(VTK_PLANE_WIREFRAME); }
191 void SetRepresentationToSurface() { this->SetRepresentation(VTK_PLANE_SURFACE); }
193
195
201 vtkSetMacro(NormalToXAxis, vtkTypeBool);
202 vtkGetMacro(NormalToXAxis, vtkTypeBool);
203 vtkBooleanMacro(NormalToXAxis, vtkTypeBool);
204 vtkSetMacro(NormalToYAxis, vtkTypeBool);
205 vtkGetMacro(NormalToYAxis, vtkTypeBool);
206 vtkBooleanMacro(NormalToYAxis, vtkTypeBool);
207 vtkSetMacro(NormalToZAxis, vtkTypeBool);
208 vtkGetMacro(NormalToZAxis, vtkTypeBool);
209 vtkBooleanMacro(NormalToZAxis, vtkTypeBool);
211
221
229 void GetPlane(vtkPlane* plane);
230
238
243 void UpdatePlacement() override;
244
246
251 vtkGetObjectMacro(HandleProperty, vtkProperty);
252 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
254
256
261 vtkGetObjectMacro(PlaneProperty, vtkProperty);
262 vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
264
265protected:
267 ~vtkPlaneWidget() override;
268
269 // Manage the state of the widget
270 int State;
272 {
273 Start = 0,
280 Pinching
281 };
282
283 // handles the events
284 static void ProcessEvents(
285 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
286
287 // ProcessEvents() dispatches to these methods.
296 void OnPinch();
298
299 // controlling ivars
305
306 // the plane
311 void HighlightPlane(int highlight);
312
313 // glyphs representing hot spots (e.g., handles)
318 void HandlesOn(double length);
320 int HighlightHandle(vtkProp* prop); // returns cell id
321 void SizeHandles() override;
322
323 // the normal cone
327 void HighlightNormal(int highlight);
328
329 // the normal line
333
334 // the normal cone
338
339 // the normal line
343
344 // Do the picking
348
349 // Register internal Pickers within PickingManager
350 void RegisterPickers() override;
351
352 // Methods to manipulate the hexahedron.
353 void MoveOrigin(double* p1, double* p2);
354 void MovePoint1(double* p1, double* p2);
355 void MovePoint2(double* p1, double* p2);
356 void MovePoint3(double* p1, double* p2);
357 void Rotate(int X, int Y, double* p1, double* p2, double* vpn);
358 void Spin(double* p1, double* p2);
359 void Scale(double* p1, double* p2, int X, int Y);
360 void Translate(double* p1, double* p2);
361 void Push(double* p1, double* p2);
362
363 // Plane normal, normalized
364 double Normal[3];
365
366 // Transform the hexahedral points (used for rotations)
368
369 // Properties used to control the appearance of selected objects and
370 // the manipulator in general.
376
378
381
382private:
383 vtkPlaneWidget(const vtkPlaneWidget&) = delete;
384 void operator=(const vtkPlaneWidget&) = delete;
385};
386
387VTK_ABI_NAMESPACE_END
388#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:41
ray-cast cell picker for all kinds of Prop3Ds
generate polygonal cone
a simple class to control print indentation
Definition vtkIndent.h:29
create a line defined by two end points
abstract base class for most VTK objects
Definition vtkObject.h:49
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
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
~vtkPlaneWidget() override
void GetPlane(vtkPlane *plane)
Get the planes describing the implicit function defined by the plane widget.
void MovePoint2(double *p1, double *p2)
vtkPolyDataAlgorithm * GetPolyDataAlgorithm() override
Satisfies superclass API.
void PlaceWidget(double bounds[6]) override
Methods that satisfy the superclass' API.
double * GetOrigin()
Set/Get the origin of the plane.
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)
static vtkPlaneWidget * New()
Instantiate the object.
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()
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
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:26
represent and manipulate 3D points
Definition vtkPoints.h:29
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:80
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:43
represent surface properties of a geometric object
Definition vtkProperty.h:57
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
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(...)