VTK  9.0.1
vtkImplicitPlaneWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkImplicitPlaneWidget.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 =========================================================================*/
64 #ifndef vtkImplicitPlaneWidget_h
65 #define vtkImplicitPlaneWidget_h
66 
67 #include "vtkInteractionWidgetsModule.h" // For export macro
69 
70 class vtkActor;
71 class vtkPolyDataMapper;
72 class vtkCellPicker;
73 class vtkConeSource;
74 class vtkLineSource;
75 class vtkSphereSource;
76 class vtkTubeFilter;
77 class vtkPlane;
78 class vtkCutter;
79 class vtkProperty;
80 class vtkImageData;
81 class vtkOutlineFilter;
82 class vtkFeatureEdges;
83 class vtkPolyData;
84 class vtkTransform;
85 
86 class VTKINTERACTIONWIDGETS_EXPORT vtkImplicitPlaneWidget : public vtkPolyDataSourceWidget
87 {
88 public:
92  static vtkImplicitPlaneWidget* New();
93 
95  void PrintSelf(ostream& os, vtkIndent indent) override;
96 
98 
101  void SetEnabled(int) override;
102  void PlaceWidget(double bounds[6]) override;
103  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
105  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
106  {
107  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
108  }
110 
112 
115  virtual void SetOrigin(double x, double y, double z);
116  virtual void SetOrigin(double x[3]);
117  double* GetOrigin() VTK_SIZEHINT(3);
118  void GetOrigin(double xyz[3]);
120 
122 
125  void SetNormal(double x, double y, double z);
126  void SetNormal(double x[3]);
127  double* GetNormal() VTK_SIZEHINT(3);
128  void GetNormal(double xyz[3]);
130 
132 
139  void SetNormalToXAxis(vtkTypeBool);
140  vtkGetMacro(NormalToXAxis, vtkTypeBool);
141  vtkBooleanMacro(NormalToXAxis, vtkTypeBool);
142  void SetNormalToYAxis(vtkTypeBool);
143  vtkGetMacro(NormalToYAxis, vtkTypeBool);
144  vtkBooleanMacro(NormalToYAxis, vtkTypeBool);
145  void SetNormalToZAxis(vtkTypeBool);
146  vtkGetMacro(NormalToZAxis, vtkTypeBool);
147  vtkBooleanMacro(NormalToZAxis, vtkTypeBool);
149 
151 
155  vtkSetMacro(Tubing, vtkTypeBool);
156  vtkGetMacro(Tubing, vtkTypeBool);
157  vtkBooleanMacro(Tubing, vtkTypeBool);
159 
161 
167  void SetDrawPlane(vtkTypeBool plane);
168  vtkGetMacro(DrawPlane, vtkTypeBool);
169  vtkBooleanMacro(DrawPlane, vtkTypeBool);
171 
173 
177  vtkSetMacro(OutlineTranslation, vtkTypeBool);
178  vtkGetMacro(OutlineTranslation, vtkTypeBool);
179  vtkBooleanMacro(OutlineTranslation, vtkTypeBool);
181 
183 
186  vtkSetMacro(OutsideBounds, vtkTypeBool);
187  vtkGetMacro(OutsideBounds, vtkTypeBool);
188  vtkBooleanMacro(OutsideBounds, vtkTypeBool);
190 
192 
195  vtkSetMacro(ScaleEnabled, vtkTypeBool);
196  vtkGetMacro(ScaleEnabled, vtkTypeBool);
197  vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
199 
201 
205  vtkSetMacro(OriginTranslation, vtkTypeBool);
206  vtkGetMacro(OriginTranslation, vtkTypeBool);
207  vtkBooleanMacro(OriginTranslation, vtkTypeBool);
209 
211 
215  vtkSetClampMacro(DiagonalRatio, double, 0, 2);
216  vtkGetMacro(DiagonalRatio, double);
218 
223  void GetPolyData(vtkPolyData* pd);
224 
230 
237  void GetPlane(vtkPlane* plane);
238 
243  void UpdatePlacement() override;
244 
248  void SizeHandles() override;
249 
251 
254  vtkGetObjectMacro(NormalProperty, vtkProperty);
255  vtkGetObjectMacro(SelectedNormalProperty, vtkProperty);
257 
259 
263  vtkGetObjectMacro(PlaneProperty, vtkProperty);
264  vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
266 
268 
271  vtkGetObjectMacro(OutlineProperty, vtkProperty);
272  vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
274 
276 
280  vtkGetObjectMacro(EdgesProperty, vtkProperty);
282 
283 protected:
285  ~vtkImplicitPlaneWidget() override;
286 
287  // Manage the state of the widget
288  int State;
290  {
291  Start = 0,
298  Outside
299  };
300 
301  // handles the events
302  static void ProcessEvents(
303  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
304 
305  // ProcessEvents() dispatches to these methods.
306  void OnLeftButtonDown();
307  void OnLeftButtonUp();
308  void OnMiddleButtonDown();
309  void OnMiddleButtonUp();
310  void OnRightButtonDown();
311  void OnRightButtonUp();
312  void OnMouseMove();
313 
314  // Controlling ivars
318  void UpdateRepresentation();
319 
320  // The actual plane which is being manipulated
322 
323  // The bounding box is represented by a single voxel image data
328  void HighlightOutline(int highlight);
329  vtkTypeBool OutlineTranslation; // whether the outline can be moved
330  vtkTypeBool ScaleEnabled; // whether the widget can be scaled
331  vtkTypeBool OutsideBounds; // whether the widget can be moved outside input's bounds
332 
333  // The cut plane is produced with a vtkCutter
338  virtual void HighlightPlane(int highlight);
339 
340  // Optional tubes are represented by extracting boundary edges and tubing
345  vtkTypeBool Tubing; // control whether tubing is on
346 
347  // Control final length of the arrow:
349 
350  // The + normal cone
354  void HighlightNormal(int highlight);
355 
356  // The + normal line
360 
361  // The - normal cone
365 
366  // The - normal line
370 
371  // The origin positioning handle
375  vtkTypeBool OriginTranslation; // whether the origin (sphere) can be moved
376 
377  // Do the picking
379 
380  // Register internal Pickers within PickingManager
381  void RegisterPickers() override;
382 
383  // Transform the normal (used for rotation)
385 
386  // Methods to manipulate the plane
387  void ConstrainOrigin(double x[3]);
388  void Rotate(int X, int Y, double* p1, double* p2, double* vpn);
389  void TranslatePlane(double* p1, double* p2);
390  void TranslateOutline(double* p1, double* p2);
391  void TranslateOrigin(double* p1, double* p2);
392  void Push(double* p1, double* p2);
393  void Scale(double* p1, double* p2, int X, int Y);
394 
395  // Properties used to control the appearance of selected objects and
396  // the manipulator in general.
404  void CreateDefaultProperties();
405 
406  void GeneratePlane();
407 
408 private:
410  void operator=(const vtkImplicitPlaneWidget&) = delete;
411 };
412 
413 #endif
3D widget for manipulating an infinite plane
virtual vtkPolyDataAlgorithm * GetPolyDataAlgorithm()=0
Returns underlying vtkPolyDataAlgorithm that determines geometry.
Cut vtkDataSet with user-specified implicit function.
Definition: vtkCutter.h:63
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
abstract base class for most VTK objects
Definition: vtkObject.h:53
abstract PolyDataSource-based 3D widget
vtkPolyDataMapper * ConeMapper
represent surface properties of a geometric object
Definition: vtkProperty.h:61
vtkPolyDataMapper * EdgesMapper
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Handles the char widget activation event.
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
vtkPolyDataMapper * CutMapper
generate polygonal cone
Definition: vtkConeSource.h:38
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
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
virtual void UpdatePlacement()=0
If you've made changes to the underlying vtkPolyDataSource AFTER your initial call to PlaceWidget()...
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
int vtkTypeBool
Definition: vtkABI.h:69
create wireframe outline for an arbitrary data set or composite dataset
create a polygonal sphere centered at the origin
Superclass for algorithms that produce only polydata as output.
filter that generates tubes around lines
Definition: vtkTubeFilter.h:77
a simple class to control print indentation
Definition: vtkIndent.h:33
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
topologically and geometrically regular array of data
Definition: vtkImageData.h:41
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
perform various plane computations
Definition: vtkPlane.h:31
vtkPolyDataMapper * OutlineMapper
#define VTK_SIZEHINT(...)
vtkPolyDataMapper * ConeMapper2
create a line defined by two end points
Definition: vtkLineSource.h:60
map vtkPolyData to graphics primitives
void PlaceWidget() override
Methods that satisfy the superclass' API.
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:66
vtkPolyDataMapper * LineMapper
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkPolyDataMapper * LineMapper2
virtual void SizeHandles()
Definition: vtk3DWidget.h:152
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Methods that satisfy the superclass' API.
virtual void PlaceWidget()
This method is used to initially place the widget.
vtkPolyDataMapper * SphereMapper