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
75#ifndef vtkPlaneWidget_h
76#define vtkPlaneWidget_h
77
78#include "vtkInteractionWidgetsModule.h" // For export macro
80
81VTK_ABI_NAMESPACE_BEGIN
82class vtkActor;
83class vtkCellPicker;
84class vtkConeSource;
85class vtkLineSource;
86class vtkPlaneSource;
87class vtkPoints;
88class vtkPolyData;
90class vtkProp;
91class vtkProperty;
92class vtkSphereSource;
93class vtkTransform;
94class vtkPlane;
95
96#define VTK_PLANE_OFF 0
97#define VTK_PLANE_OUTLINE 1
98#define VTK_PLANE_WIREFRAME 2
99#define VTK_PLANE_SURFACE 3
100
101#define VTK_PLANE_ZERO_THRESHOLD (std::numeric_limits<double>::min() * 1000)
102
103class VTKINTERACTIONWIDGETS_EXPORT vtkPlaneWidget : public vtkPolyDataSourceWidget
104{
105public:
110
112 void PrintSelf(ostream& os, vtkIndent indent) override;
113
115
118 void SetEnabled(int) override;
119 void PlaceWidget(double bounds[6]) override;
120 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
122 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
123 {
124 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
125 }
127
129
132 void SetResolution(int r);
135
137
140 void SetOrigin(double x, double y, double z);
141 void SetOrigin(double x[3]);
143 void GetOrigin(double xyz[3]);
145
147
150 void SetPoint1(double x, double y, double z);
151 void SetPoint1(double x[3]);
152 double* GetPoint1() VTK_SIZEHINT(3);
153 void GetPoint1(double xyz[3]);
155
157
160 void SetPoint2(double x, double y, double z);
161 void SetPoint2(double x[3]);
162 double* GetPoint2() VTK_SIZEHINT(3);
163 void GetPoint2(double xyz[3]);
165
167
170 void SetCenter(double x, double y, double z);
171 void SetCenter(double x[3]);
172 double* GetCenter() VTK_SIZEHINT(3);
173 void GetCenter(double xyz[3]);
175
177
180 void SetNormal(double x, double y, double z);
181 void SetNormal(double x[3]);
182 double* GetNormal() VTK_SIZEHINT(3);
183 void GetNormal(double xyz[3]);
185
187
195 vtkSetClampMacro(Representation, int, VTK_PLANE_OFF, VTK_PLANE_SURFACE);
196 vtkGetMacro(Representation, int);
197 void SetRepresentationToOff() { this->SetRepresentation(VTK_PLANE_OFF); }
198 void SetRepresentationToOutline() { this->SetRepresentation(VTK_PLANE_OUTLINE); }
199 void SetRepresentationToWireframe() { this->SetRepresentation(VTK_PLANE_WIREFRAME); }
200 void SetRepresentationToSurface() { this->SetRepresentation(VTK_PLANE_SURFACE); }
202
204
210 vtkSetMacro(NormalToXAxis, vtkTypeBool);
211 vtkGetMacro(NormalToXAxis, vtkTypeBool);
212 vtkBooleanMacro(NormalToXAxis, vtkTypeBool);
213 vtkSetMacro(NormalToYAxis, vtkTypeBool);
214 vtkGetMacro(NormalToYAxis, vtkTypeBool);
215 vtkBooleanMacro(NormalToYAxis, vtkTypeBool);
216 vtkSetMacro(NormalToZAxis, vtkTypeBool);
217 vtkGetMacro(NormalToZAxis, vtkTypeBool);
218 vtkBooleanMacro(NormalToZAxis, vtkTypeBool);
220
230
238 void GetPlane(vtkPlane* plane);
239
247
252 void UpdatePlacement() override;
253
255
260 vtkGetObjectMacro(HandleProperty, vtkProperty);
261 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
263
265
270 vtkGetObjectMacro(PlaneProperty, vtkProperty);
271 vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
273
274protected:
276 ~vtkPlaneWidget() override;
277
278 // Manage the state of the widget
279 int State;
281 {
282 Start = 0,
289 Pinching
290 };
291
292 // handles the events
293 static void ProcessEvents(
294 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
295
296 // ProcessEvents() dispatches to these methods.
305 void OnPinch();
307
308 // controlling ivars
314
315 // the plane
320 void HighlightPlane(int highlight);
321
322 // glyphs representing hot spots (e.g., handles)
327 void HandlesOn(double length);
329 int HighlightHandle(vtkProp* prop); // returns cell id
330 void SizeHandles() override;
331
332 // the normal cone
336 void HighlightNormal(int highlight);
337
338 // the normal line
342
343 // the normal cone
347
348 // the normal line
352
353 // Do the picking
357
358 // Register internal Pickers within PickingManager
359 void RegisterPickers() override;
360
361 // Methods to manipulate the hexahedron.
362 void MoveOrigin(double* p1, double* p2);
363 void MovePoint1(double* p1, double* p2);
364 void MovePoint2(double* p1, double* p2);
365 void MovePoint3(double* p1, double* p2);
366 void Rotate(int X, int Y, double* p1, double* p2, double* vpn);
367 void Spin(double* p1, double* p2);
368 void Scale(double* p1, double* p2, int X, int Y);
369 void Translate(double* p1, double* p2);
370 void Push(double* p1, double* p2);
371
372 // Plane normal, normalized
373 double Normal[3];
374
375 // Transform the hexahedral points (used for rotations)
377
378 // Properties used to control the appearance of selected objects and
379 // the manipulator in general.
385
387
390
391private:
392 vtkPlaneWidget(const vtkPlaneWidget&) = delete;
393 void operator=(const vtkPlaneWidget&) = delete;
394};
395
396VTK_ABI_NAMESPACE_END
397#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
generate polygonal cone
a simple class to control print indentation
Definition vtkIndent.h:38
create a line defined by two end points
abstract base class for most VTK objects
Definition vtkObject.h:58
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: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:52
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
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(...)