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 =========================================================================*/
75 #ifndef vtkPlaneWidget_h
76 #define vtkPlaneWidget_h
77 
78 #include "vtkInteractionWidgetsModule.h" // For export macro
80 
81 class vtkActor;
82 class vtkCellPicker;
83 class vtkConeSource;
84 class vtkLineSource;
85 class vtkPlaneSource;
86 class vtkPoints;
87 class vtkPolyData;
88 class vtkPolyDataMapper;
89 class vtkProp;
90 class vtkProperty;
91 class vtkSphereSource;
92 class vtkTransform;
93 class vtkPlane;
94 
95 #define VTK_PLANE_OFF 0
96 #define VTK_PLANE_OUTLINE 1
97 #define VTK_PLANE_WIREFRAME 2
98 #define VTK_PLANE_SURFACE 3
99 
100 #define VTK_PLANE_ZERO_THRESHOLD (std::numeric_limits<double>::min() * 1000)
101 
102 class VTKINTERACTIONWIDGETS_EXPORT vtkPlaneWidget : public vtkPolyDataSourceWidget
103 {
104 public:
108  static vtkPlaneWidget* New();
109 
111  void PrintSelf(ostream& os, vtkIndent indent) override;
112 
114 
117  void SetEnabled(int) override;
118  void PlaceWidget(double bounds[6]) override;
119  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
121  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
122  {
123  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
124  }
126 
128 
131  void SetResolution(int r);
134 
136 
139  void SetOrigin(double x, double y, double z);
140  void SetOrigin(double x[3]);
141  double* GetOrigin() VTK_SIZEHINT(3);
142  void GetOrigin(double xyz[3]);
144 
146 
149  void SetPoint1(double x, double y, double z);
150  void SetPoint1(double x[3]);
151  double* GetPoint1() VTK_SIZEHINT(3);
152  void GetPoint1(double xyz[3]);
154 
156 
159  void SetPoint2(double x, double y, double z);
160  void SetPoint2(double x[3]);
161  double* GetPoint2() VTK_SIZEHINT(3);
162  void GetPoint2(double xyz[3]);
164 
166 
169  void SetCenter(double x, double y, double z);
170  void SetCenter(double x[3]);
171  double* GetCenter() VTK_SIZEHINT(3);
172  void GetCenter(double xyz[3]);
174 
176 
179  void SetNormal(double x, double y, double z);
180  void SetNormal(double x[3]);
181  double* GetNormal() VTK_SIZEHINT(3);
182  void GetNormal(double xyz[3]);
184 
186 
194  vtkSetClampMacro(Representation, int, VTK_PLANE_OFF, VTK_PLANE_SURFACE);
195  vtkGetMacro(Representation, int);
196  void SetRepresentationToOff() { this->SetRepresentation(VTK_PLANE_OFF); }
197  void SetRepresentationToOutline() { this->SetRepresentation(VTK_PLANE_OUTLINE); }
198  void SetRepresentationToWireframe() { this->SetRepresentation(VTK_PLANE_WIREFRAME); }
199  void SetRepresentationToSurface() { this->SetRepresentation(VTK_PLANE_SURFACE); }
201 
203 
209  vtkSetMacro(NormalToXAxis, vtkTypeBool);
210  vtkGetMacro(NormalToXAxis, vtkTypeBool);
211  vtkBooleanMacro(NormalToXAxis, vtkTypeBool);
212  vtkSetMacro(NormalToYAxis, vtkTypeBool);
213  vtkGetMacro(NormalToYAxis, vtkTypeBool);
214  vtkBooleanMacro(NormalToYAxis, vtkTypeBool);
215  vtkSetMacro(NormalToZAxis, vtkTypeBool);
216  vtkGetMacro(NormalToZAxis, vtkTypeBool);
217  vtkBooleanMacro(NormalToZAxis, vtkTypeBool);
219 
229 
237  void GetPlane(vtkPlane* plane);
238 
246 
251  void UpdatePlacement(void) override;
252 
254 
259  vtkGetObjectMacro(HandleProperty, vtkProperty);
260  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
262 
264 
269  vtkGetObjectMacro(PlaneProperty, vtkProperty);
270  vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
272 
273 protected:
275  ~vtkPlaneWidget() override;
276 
277  // Manage the state of the widget
278  int State;
280  {
281  Start = 0,
288  Pinching
289  };
290 
291  // handles the events
292  static void ProcessEvents(
293  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
294 
295  // ProcessEvents() dispatches to these methods.
302  void OnMouseMove();
303  void OnStartPinch();
304  void OnPinch();
305  void OnEndPinch();
306 
307  // controlling ivars
313 
314  // the plane
319  void HighlightPlane(int highlight);
320 
321  // glyphs representing hot spots (e.g., handles)
326  void HandlesOn(double length);
327  void HandlesOff();
328  int HighlightHandle(vtkProp* prop); // returns cell id
329  void SizeHandles() override;
330 
331  // the normal cone
335  void HighlightNormal(int highlight);
336 
337  // the normal line
341 
342  // the normal cone
346 
347  // the normal line
351 
352  // Do the picking
356 
357  // Register internal Pickers within PickingManager
358  void RegisterPickers() override;
359 
360  // Methods to manipulate the hexahedron.
361  void MoveOrigin(double* p1, double* p2);
362  void MovePoint1(double* p1, double* p2);
363  void MovePoint2(double* p1, double* p2);
364  void MovePoint3(double* p1, double* p2);
365  void Rotate(int X, int Y, double* p1, double* p2, double* vpn);
366  void Spin(double* p1, double* p2);
367  void Scale(double* p1, double* p2, int X, int Y);
368  void Translate(double* p1, double* p2);
369  void Push(double* p1, double* p2);
370 
371  // Plane normal, normalized
372  double Normal[3];
373 
374  // Transform the hexahedral points (used for rotations)
376 
377  // Properties used to control the appearance of selected objects and
378  // the manipulator in general.
384 
386 
389 
390 private:
391  vtkPlaneWidget(const vtkPlaneWidget&) = delete;
392  void operator=(const vtkPlaneWidget&) = delete;
393 };
394 
395 #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: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:54
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 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()
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()
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:34
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:86
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:48
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(...)