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 =========================================================================*/
73 #ifndef vtkImplicitPlaneWidget_h
74 #define vtkImplicitPlaneWidget_h
75 
76 #include "vtkInteractionWidgetsModule.h" // For export macro
78 
79 class vtkActor;
80 class vtkPolyDataMapper;
81 class vtkCellPicker;
82 class vtkConeSource;
83 class vtkLineSource;
84 class vtkSphereSource;
85 class vtkTubeFilter;
86 class vtkPlane;
87 class vtkCutter;
88 class vtkProperty;
89 class vtkImageData;
90 class vtkOutlineFilter;
91 class vtkFeatureEdges;
92 class vtkPolyData;
93 class vtkTransform;
94 
95 class VTKINTERACTIONWIDGETS_EXPORT vtkImplicitPlaneWidget : public vtkPolyDataSourceWidget
96 {
97 public:
101  static vtkImplicitPlaneWidget* New();
102 
104  void PrintSelf(ostream& os, vtkIndent indent) override;
105 
107 
110  void SetEnabled(int) override;
111  void PlaceWidget(double bounds[6]) override;
112  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
114  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
115  {
116  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
117  }
119 
121 
124  virtual void SetOrigin(double x, double y, double z);
125  virtual void SetOrigin(double x[3]);
126  double* GetOrigin() VTK_SIZEHINT(3);
127  void GetOrigin(double xyz[3]);
129 
131 
134  void SetNormal(double x, double y, double z);
135  void SetNormal(double x[3]);
136  double* GetNormal() VTK_SIZEHINT(3);
137  void GetNormal(double xyz[3]);
139 
141 
148  void SetNormalToXAxis(vtkTypeBool);
149  vtkGetMacro(NormalToXAxis, vtkTypeBool);
150  vtkBooleanMacro(NormalToXAxis, vtkTypeBool);
151  void SetNormalToYAxis(vtkTypeBool);
152  vtkGetMacro(NormalToYAxis, vtkTypeBool);
153  vtkBooleanMacro(NormalToYAxis, vtkTypeBool);
154  void SetNormalToZAxis(vtkTypeBool);
155  vtkGetMacro(NormalToZAxis, vtkTypeBool);
156  vtkBooleanMacro(NormalToZAxis, vtkTypeBool);
158 
160 
164  vtkSetMacro(Tubing, vtkTypeBool);
165  vtkGetMacro(Tubing, vtkTypeBool);
166  vtkBooleanMacro(Tubing, vtkTypeBool);
168 
170 
176  void SetDrawPlane(vtkTypeBool plane);
177  vtkGetMacro(DrawPlane, vtkTypeBool);
178  vtkBooleanMacro(DrawPlane, vtkTypeBool);
180 
182 
186  vtkSetMacro(OutlineTranslation, vtkTypeBool);
187  vtkGetMacro(OutlineTranslation, vtkTypeBool);
188  vtkBooleanMacro(OutlineTranslation, vtkTypeBool);
190 
192 
195  vtkSetMacro(OutsideBounds, vtkTypeBool);
196  vtkGetMacro(OutsideBounds, vtkTypeBool);
197  vtkBooleanMacro(OutsideBounds, vtkTypeBool);
199 
201 
204  vtkSetMacro(ScaleEnabled, vtkTypeBool);
205  vtkGetMacro(ScaleEnabled, vtkTypeBool);
206  vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
208 
210 
214  vtkSetMacro(OriginTranslation, vtkTypeBool);
215  vtkGetMacro(OriginTranslation, vtkTypeBool);
216  vtkBooleanMacro(OriginTranslation, vtkTypeBool);
218 
220 
224  vtkSetClampMacro(DiagonalRatio, double, 0, 2);
225  vtkGetMacro(DiagonalRatio, double);
227 
232  void GetPolyData(vtkPolyData* pd);
233 
238  vtkPolyDataAlgorithm* GetPolyDataAlgorithm() override;
239 
246  void GetPlane(vtkPlane* plane);
247 
252  void UpdatePlacement() override;
253 
257  void SizeHandles() override;
258 
260 
263  vtkGetObjectMacro(NormalProperty, vtkProperty);
264  vtkGetObjectMacro(SelectedNormalProperty, vtkProperty);
266 
268 
272  vtkGetObjectMacro(PlaneProperty, vtkProperty);
273  vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
275 
277 
280  vtkGetObjectMacro(OutlineProperty, vtkProperty);
281  vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
283 
285 
289  vtkGetObjectMacro(EdgesProperty, vtkProperty);
291 
292 protected:
294  ~vtkImplicitPlaneWidget() override;
295 
296  // Manage the state of the widget
297  int State;
299  {
300  Start = 0,
307  Outside
308  };
309 
310  // handles the events
311  static void ProcessEvents(
312  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
313 
314  // ProcessEvents() dispatches to these methods.
315  void OnLeftButtonDown();
316  void OnLeftButtonUp();
317  void OnMiddleButtonDown();
318  void OnMiddleButtonUp();
319  void OnRightButtonDown();
320  void OnRightButtonUp();
321  void OnMouseMove();
322 
323  // Controlling ivars
327  void UpdateRepresentation();
328 
329  // The actual plane which is being manipulated
331 
332  // The bounding box is represented by a single voxel image data
337  void HighlightOutline(int highlight);
338  vtkTypeBool OutlineTranslation; // whether the outline can be moved
339  vtkTypeBool ScaleEnabled; // whether the widget can be scaled
340  vtkTypeBool OutsideBounds; // whether the widget can be moved outside input's bounds
341 
342  // The cut plane is produced with a vtkCutter
347  virtual void HighlightPlane(int highlight);
348 
349  // Optional tubes are represented by extracting boundary edges and tubing
354  vtkTypeBool Tubing; // control whether tubing is on
355 
356  // Control final length of the arrow:
358 
359  // The + normal cone
363  void HighlightNormal(int highlight);
364 
365  // The + normal line
369 
370  // The - normal cone
374 
375  // The - normal line
379 
380  // The origin positioning handle
384  vtkTypeBool OriginTranslation; // whether the origin (sphere) can be moved
385 
386  // Do the picking
388 
389  // Register internal Pickers within PickingManager
390  void RegisterPickers() override;
391 
392  // Transform the normal (used for rotation)
394 
395  // Methods to manipulate the plane
396  void ConstrainOrigin(double x[3]);
397  void Rotate(int X, int Y, double* p1, double* p2, double* vpn);
398  void TranslatePlane(double* p1, double* p2);
399  void TranslateOutline(double* p1, double* p2);
400  void TranslateOrigin(double* p1, double* p2);
401  void Push(double* p1, double* p2);
402  void Scale(double* p1, double* p2, int X, int Y);
403 
404  // Properties used to control the appearance of selected objects and
405  // the manipulator in general.
413  void CreateDefaultProperties();
414 
415  void GeneratePlane();
416 
417 private:
419  void operator=(const vtkImplicitPlaneWidget&) = delete;
420 };
421 
422 #endif
3D widget for manipulating an infinite plane
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:62
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 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
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