VTK  9.0.2
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 
90 class vtkActor;
91 class vtkCellPicker;
92 class vtkConeSource;
93 class vtkLineSource;
94 class vtkPlaneSource;
95 class vtkPoints;
96 class vtkPolyData;
97 class vtkPolyDataMapper;
98 class vtkProp;
99 class vtkProperty;
100 class vtkSphereSource;
101 class vtkTransform;
102 class 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 class VTKINTERACTIONWIDGETS_EXPORT vtkPlaneWidget : public vtkPolyDataSourceWidget
110 {
111 public:
115  static vtkPlaneWidget* New();
116 
118  void PrintSelf(ostream& os, vtkIndent indent) override;
119 
121 
124  void SetEnabled(int) override;
125  void PlaceWidget(double bounds[6]) override;
126  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
128  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
129  {
130  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
131  }
133 
135 
138  void SetResolution(int r);
141 
143 
146  void SetOrigin(double x, double y, double z);
147  void SetOrigin(double x[3]);
148  double* GetOrigin() VTK_SIZEHINT(3);
149  void GetOrigin(double xyz[3]);
151 
153 
156  void SetPoint1(double x, double y, double z);
157  void SetPoint1(double x[3]);
158  double* GetPoint1() VTK_SIZEHINT(3);
159  void GetPoint1(double xyz[3]);
161 
163 
166  void SetPoint2(double x, double y, double z);
167  void SetPoint2(double x[3]);
168  double* GetPoint2() VTK_SIZEHINT(3);
169  void GetPoint2(double xyz[3]);
171 
173 
176  void SetCenter(double x, double y, double z);
177  void SetCenter(double x[3]);
178  double* GetCenter() VTK_SIZEHINT(3);
179  void GetCenter(double xyz[3]);
181 
183 
186  void SetNormal(double x, double y, double z);
187  void SetNormal(double x[3]);
188  double* GetNormal() VTK_SIZEHINT(3);
189  void GetNormal(double xyz[3]);
191 
193 
201  vtkSetClampMacro(Representation, int, VTK_PLANE_OFF, VTK_PLANE_SURFACE);
202  vtkGetMacro(Representation, int);
203  void SetRepresentationToOff() { this->SetRepresentation(VTK_PLANE_OFF); }
204  void SetRepresentationToOutline() { this->SetRepresentation(VTK_PLANE_OUTLINE); }
205  void SetRepresentationToWireframe() { this->SetRepresentation(VTK_PLANE_WIREFRAME); }
206  void SetRepresentationToSurface() { this->SetRepresentation(VTK_PLANE_SURFACE); }
208 
210 
216  vtkSetMacro(NormalToXAxis, vtkTypeBool);
217  vtkGetMacro(NormalToXAxis, vtkTypeBool);
218  vtkBooleanMacro(NormalToXAxis, vtkTypeBool);
219  vtkSetMacro(NormalToYAxis, vtkTypeBool);
220  vtkGetMacro(NormalToYAxis, vtkTypeBool);
221  vtkBooleanMacro(NormalToYAxis, vtkTypeBool);
222  vtkSetMacro(NormalToZAxis, vtkTypeBool);
223  vtkGetMacro(NormalToZAxis, vtkTypeBool);
224  vtkBooleanMacro(NormalToZAxis, vtkTypeBool);
226 
236 
244  void GetPlane(vtkPlane* plane);
245 
253 
258  void UpdatePlacement(void) override;
259 
261 
266  vtkGetObjectMacro(HandleProperty, vtkProperty);
267  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
269 
271 
276  vtkGetObjectMacro(PlaneProperty, vtkProperty);
277  vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
279 
280 protected:
282  ~vtkPlaneWidget() override;
283 
284  // Manage the state of the widget
285  int State;
287  {
288  Start = 0,
295  Pinching
296  };
297 
298  // handles the events
299  static void ProcessEvents(
300  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
301 
302  // ProcessEvents() dispatches to these methods.
309  void OnMouseMove();
310  void OnStartPinch();
311  void OnPinch();
312  void OnEndPinch();
313 
314  // controlling ivars
320 
321  // the plane
326  void HighlightPlane(int highlight);
327 
328  // glyphs representing hot spots (e.g., handles)
333  void HandlesOn(double length);
334  void HandlesOff();
335  int HighlightHandle(vtkProp* prop); // returns cell id
336  void SizeHandles() override;
337 
338  // the normal cone
342  void HighlightNormal(int highlight);
343 
344  // the normal line
348 
349  // the normal cone
353 
354  // the normal line
358 
359  // Do the picking
363 
364  // Register internal Pickers within PickingManager
365  void RegisterPickers() override;
366 
367  // Methods to manipulate the hexahedron.
368  void MoveOrigin(double* p1, double* p2);
369  void MovePoint1(double* p1, double* p2);
370  void MovePoint2(double* p1, double* p2);
371  void MovePoint3(double* p1, double* p2);
372  void Rotate(int X, int Y, double* p1, double* p2, double* vpn);
373  void Spin(double* p1, double* p2);
374  void Scale(double* p1, double* p2, int X, int Y);
375  void Translate(double* p1, double* p2);
376  void Push(double* p1, double* p2);
377 
378  // Plane normal, normalized
379  double Normal[3];
380 
381  // Transform the hexahedral points (used for rotations)
383 
384  // Properties used to control the appearance of selected objects and
385  // the manipulator in general.
391 
393 
396 
397 private:
398  vtkPlaneWidget(const vtkPlaneWidget&) = delete;
399  void operator=(const vtkPlaneWidget&) = delete;
400 };
401 
402 #endif
virtual void PlaceWidget()
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:46
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:67
generate polygonal cone
Definition: vtkConeSource.h:39
a simple class to control print indentation
Definition: vtkIndent.h:34
create a line defined by two end points
Definition: vtkLineSource.h:61
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
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()
~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
We have to redeclare this abstract, PlaceWidget() requires it.
vtkPolyDataMapper * PlaneMapper
void OnRightButtonUp()
vtkProperty * PlaneProperty
void PlaceWidget() override
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
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()
void SetRepresentationToOutline()
vtkActor * CurrentHandle
void SelectRepresentation()
double HandleSizeFactor
void SetOrigin(double x[3])
vtkPolyData * PlaneOutline
vtkTransform * Transform
void PositionHandles()
void OnMiddleButtonDown()
void UpdatePlacement(void) override
Satisfies superclass API.
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()
void Translate(double *p1, double *p2)
void OnMiddleButtonUp()
vtkTypeBool NormalToXAxis
vtkActor * LineActor2
perform various plane computations
Definition: vtkPlane.h:32
represent and manipulate 3D points
Definition: vtkPoints.h:34
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:85
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:54
represent surface properties of a geometric object
Definition: vtkProperty.h:62
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:55
@ 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(...)