VTK  9.1.0
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=========================================================================*/
84#ifndef vtkPlaneWidget_h
85#define vtkPlaneWidget_h
86
87#include "vtkInteractionWidgetsModule.h" // For export macro
89
90class vtkActor;
91class vtkCellPicker;
92class vtkConeSource;
93class vtkLineSource;
94class vtkPlaneSource;
95class vtkPoints;
96class vtkPolyData;
98class vtkProp;
99class vtkProperty;
100class vtkSphereSource;
101class vtkTransform;
102class vtkPlane;
103
104#define VTK_PLANE_OFF 0
105#define VTK_PLANE_OUTLINE 1
106#define VTK_PLANE_WIREFRAME 2
107#define VTK_PLANE_SURFACE 3
108
109#define VTK_PLANE_ZERO_THRESHOLD (std::numeric_limits<double>::min() * 1000)
110
111class VTKINTERACTIONWIDGETS_EXPORT vtkPlaneWidget : public vtkPolyDataSourceWidget
112{
113public:
118
120 void PrintSelf(ostream& os, vtkIndent indent) override;
121
123
126 void SetEnabled(int) override;
127 void PlaceWidget(double bounds[6]) override;
128 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
130 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
131 {
132 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
133 }
135
137
140 void SetResolution(int r);
143
145
148 void SetOrigin(double x, double y, double z);
149 void SetOrigin(double x[3]);
151 void GetOrigin(double xyz[3]);
153
155
158 void SetPoint1(double x, double y, double z);
159 void SetPoint1(double x[3]);
160 double* GetPoint1() VTK_SIZEHINT(3);
161 void GetPoint1(double xyz[3]);
163
165
168 void SetPoint2(double x, double y, double z);
169 void SetPoint2(double x[3]);
170 double* GetPoint2() VTK_SIZEHINT(3);
171 void GetPoint2(double xyz[3]);
173
175
178 void SetCenter(double x, double y, double z);
179 void SetCenter(double x[3]);
180 double* GetCenter() VTK_SIZEHINT(3);
181 void GetCenter(double xyz[3]);
183
185
188 void SetNormal(double x, double y, double z);
189 void SetNormal(double x[3]);
190 double* GetNormal() VTK_SIZEHINT(3);
191 void GetNormal(double xyz[3]);
193
195
203 vtkSetClampMacro(Representation, int, VTK_PLANE_OFF, VTK_PLANE_SURFACE);
204 vtkGetMacro(Representation, int);
205 void SetRepresentationToOff() { this->SetRepresentation(VTK_PLANE_OFF); }
206 void SetRepresentationToOutline() { this->SetRepresentation(VTK_PLANE_OUTLINE); }
207 void SetRepresentationToWireframe() { this->SetRepresentation(VTK_PLANE_WIREFRAME); }
208 void SetRepresentationToSurface() { this->SetRepresentation(VTK_PLANE_SURFACE); }
210
212
218 vtkSetMacro(NormalToXAxis, vtkTypeBool);
219 vtkGetMacro(NormalToXAxis, vtkTypeBool);
220 vtkBooleanMacro(NormalToXAxis, vtkTypeBool);
221 vtkSetMacro(NormalToYAxis, vtkTypeBool);
222 vtkGetMacro(NormalToYAxis, vtkTypeBool);
223 vtkBooleanMacro(NormalToYAxis, vtkTypeBool);
224 vtkSetMacro(NormalToZAxis, vtkTypeBool);
225 vtkGetMacro(NormalToZAxis, vtkTypeBool);
226 vtkBooleanMacro(NormalToZAxis, vtkTypeBool);
228
238
246 void GetPlane(vtkPlane* plane);
247
255
260 void UpdatePlacement(void) override;
261
263
268 vtkGetObjectMacro(HandleProperty, vtkProperty);
269 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
271
273
278 vtkGetObjectMacro(PlaneProperty, vtkProperty);
279 vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
281
282protected:
284 ~vtkPlaneWidget() override;
285
286 // Manage the state of the widget
287 int State;
289 {
290 Start = 0,
297 Pinching
298 };
299
300 // handles the events
301 static void ProcessEvents(
302 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
303
304 // ProcessEvents() dispatches to these methods.
313 void OnPinch();
315
316 // controlling ivars
322
323 // the plane
328 void HighlightPlane(int highlight);
329
330 // glyphs representing hot spots (e.g., handles)
335 void HandlesOn(double length);
337 int HighlightHandle(vtkProp* prop); // returns cell id
338 void SizeHandles() override;
339
340 // the normal cone
344 void HighlightNormal(int highlight);
345
346 // the normal line
350
351 // the normal cone
355
356 // the normal line
360
361 // Do the picking
365
366 // Register internal Pickers within PickingManager
367 void RegisterPickers() override;
368
369 // Methods to manipulate the hexahedron.
370 void MoveOrigin(double* p1, double* p2);
371 void MovePoint1(double* p1, double* p2);
372 void MovePoint2(double* p1, double* p2);
373 void MovePoint3(double* p1, double* p2);
374 void Rotate(int X, int Y, double* p1, double* p2, double* vpn);
375 void Spin(double* p1, double* p2);
376 void Scale(double* p1, double* p2, int X, int Y);
377 void Translate(double* p1, double* p2);
378 void Push(double* p1, double* p2);
379
380 // Plane normal, normalized
381 double Normal[3];
382
383 // Transform the hexahedral points (used for rotations)
385
386 // Properties used to control the appearance of selected objects and
387 // the manipulator in general.
393
395
398
399private:
400 vtkPlaneWidget(const vtkPlaneWidget&) = delete;
401 void operator=(const vtkPlaneWidget&) = delete;
402};
403
404#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:55
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:76
generate polygonal cone
Definition: vtkConeSource.h:48
a simple class to control print indentation
Definition: vtkIndent.h:43
create a line defined by two end points
Definition: vtkLineSource.h:70
abstract base class for most VTK objects
Definition: vtkObject.h:63
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 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()
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()
void UpdatePlacement(void) override
Satisfies superclass API.
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:43
represent and manipulate 3D points
Definition: vtkPoints.h:43
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:95
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:57
represent surface properties of a geometric object
Definition: vtkProperty.h:71
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:64
@ Normal
Definition: vtkX3D.h:51
@ length
Definition: vtkX3D.h:399
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_PLANE_OUTLINE
#define VTK_PLANE_WIREFRAME
#define VTK_PLANE_OFF
#define VTK_PLANE_SURFACE
#define VTK_SIZEHINT(...)