VTK  9.0.1
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 =========================================================================*/
78 #ifndef vtkPlaneWidget_h
79 #define vtkPlaneWidget_h
80 
81 #include "vtkInteractionWidgetsModule.h" // For export macro
83 
84 class vtkActor;
85 class vtkCellPicker;
86 class vtkConeSource;
87 class vtkLineSource;
88 class vtkPlaneSource;
89 class vtkPoints;
90 class vtkPolyData;
91 class vtkPolyDataMapper;
92 class vtkProp;
93 class vtkProperty;
94 class vtkSphereSource;
95 class vtkTransform;
96 class vtkPlane;
97 
98 #define VTK_PLANE_OFF 0
99 #define VTK_PLANE_OUTLINE 1
100 #define VTK_PLANE_WIREFRAME 2
101 #define VTK_PLANE_SURFACE 3
102 
103 class VTKINTERACTIONWIDGETS_EXPORT vtkPlaneWidget : public vtkPolyDataSourceWidget
104 {
105 public:
109  static vtkPlaneWidget* New();
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);
133  int GetResolution();
135 
137 
140  void SetOrigin(double x, double y, double z);
141  void SetOrigin(double x[3]);
142  double* GetOrigin() VTK_SIZEHINT(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 
229  void GetPolyData(vtkPolyData* pd);
230 
238  void GetPlane(vtkPlane* plane);
239 
247 
252  void UpdatePlacement(void) override;
253 
255 
260  vtkGetObjectMacro(HandleProperty, vtkProperty);
261  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
263 
265 
269  virtual void SetPlaneProperty(vtkProperty*);
270  vtkGetObjectMacro(PlaneProperty, vtkProperty);
271  vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
273 
274 protected:
275  vtkPlaneWidget();
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.
297  void OnLeftButtonDown();
298  void OnLeftButtonUp();
299  void OnMiddleButtonDown();
300  void OnMiddleButtonUp();
301  void OnRightButtonDown();
302  void OnRightButtonUp();
303  void OnMouseMove();
304  void OnStartPinch();
305  void OnPinch();
306  void OnEndPinch();
307 
308  // controlling ivars
313  void SelectRepresentation();
314 
315  // the plane
320  void HighlightPlane(int highlight);
321 
322  // glyphs representing hot spots (e.g., handles)
326  void PositionHandles();
327  void HandlesOn(double length);
328  void HandlesOff();
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.
384  void CreateDefaultProperties();
385 
386  void GeneratePlane();
387 
390 
391 private:
392  vtkPlaneWidget(const vtkPlaneWidget&) = delete;
393  void operator=(const vtkPlaneWidget&) = delete;
394 };
395 
396 #endif
vtkProperty * HandleProperty
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:50
vtkTypeBool NormalToXAxis
virtual vtkPolyDataAlgorithm * GetPolyDataAlgorithm()=0
Returns underlying vtkPolyDataAlgorithm that determines geometry.
vtkLineSource * LineSource
vtkProperty * SelectedHandleProperty
vtkTypeBool NormalToYAxis
vtkPolyDataMapper * ConeMapper
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
abstract base class for most VTK objects
Definition: vtkObject.h:56
abstract PolyDataSource-based 3D widget
vtkPolyDataMapper * LineMapper
void SetRepresentationToWireframe()
Control how the plane appears when GetPolyData() is invoked.
represent surface properties of a geometric object
Definition: vtkProperty.h:61
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Handles the char widget activation event.
vtkActor * ConeActor
vtkSphereSource ** HandleGeometry
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
vtkProperty * PlaneProperty
vtkPolyData * PlaneOutline
void SetRepresentationToOutline()
Control how the plane appears when GetPolyData() is invoked.
vtkActor * LineActor
generate polygonal cone
Definition: vtkConeSource.h:38
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
vtkActor ** Handle
void PlaceWidget() override
Overrides vtk3DWidget PlaceWidget() so that it doesn't complain if there's no Input and no Prop3D...
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
vtkActor * ConeActor2
virtual void UpdatePlacement()=0
If you've made changes to the underlying vtkPolyDataSource AFTER your initial call to PlaceWidget()...
void PlaceWidget() override
Methods that satisfy the superclass' API.
vtkTypeBool NormalToZAxis
void SetRepresentationToSurface()
Control how the plane appears when GetPolyData() is invoked.
vtkLineSource * LineSource2
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkConeSource * ConeSource
int vtkTypeBool
Definition: vtkABI.h:69
create a polygonal sphere centered at the origin
Superclass for algorithms that produce only polydata as output.
vtkActor * LineActor2
a simple class to control print indentation
Definition: vtkIndent.h:33
#define VTK_PLANE_SURFACE
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTransform * Transform
perform various plane computations
Definition: vtkPlane.h:31
#define VTK_PLANE_WIREFRAME
vtkProperty * SelectedPlaneProperty
vtkPolyDataMapper * PlaneMapper
#define VTK_SIZEHINT(...)
vtkPlaneSource * PlaneSource
create an array of quadrilaterals located in a plane
vtkPolyDataMapper * LineMapper2
create a line defined by two end points
Definition: vtkLineSource.h:60
map vtkPolyData to graphics primitives
vtkActor * PlaneActor
#define VTK_PLANE_OUTLINE
#define VTK_PLANE_OFF
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:66
vtkCellPicker * HandlePicker
3D widget for manipulating a finite plane
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Methods that satisfy the superclass' API.
vtkCellPicker * PlanePicker
vtkActor * CurrentHandle
virtual void SizeHandles()
Definition: vtk3DWidget.h:155
virtual void PlaceWidget()
This method is used to initially place the widget.
vtkPolyDataMapper ** HandleMapper
double HandleSizeFactor
represent and manipulate 3D points
Definition: vtkPoints.h:33
vtkConeSource * ConeSource2
vtkPolyDataMapper * ConeMapper2