VTK  9.0.2
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:
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:
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.
321  void OnMouseMove();
322 
323  // Controlling ivars
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.
414 
416 
417 private:
419  void operator=(const vtkImplicitPlaneWidget&) = delete;
420 };
421 
422 #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
Cut vtkDataSet with user-specified implicit function.
Definition: vtkCutter.h:64
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
3D widget for manipulating an infinite plane
vtkPolyDataMapper * ConeMapper
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
void TranslateOutline(double *p1, double *p2)
vtkPolyDataMapper * CutMapper
void TranslatePlane(double *p1, double *p2)
vtkPolyDataMapper * ConeMapper2
static vtkImplicitPlaneWidget * New()
Instantiate the object.
void Rotate(int X, int Y, double *p1, double *p2, double *vpn)
virtual void HighlightPlane(int highlight)
vtkPolyDataMapper * LineMapper
vtkPolyDataMapper * SphereMapper
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
void ConstrainOrigin(double x[3])
virtual void SetOrigin(double x, double y, double z)
Get the origin of the plane.
void Scale(double *p1, double *p2, int X, int Y)
void HighlightNormal(int highlight)
void SetEnabled(int) override
Methods that satisfy the superclass' API.
void TranslateOrigin(double *p1, double *p2)
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
vtkPolyDataMapper * OutlineMapper
void PlaceWidget(double bounds[6]) override
We have to redeclare this abstract, PlaceWidget() requires it.
virtual void SetOrigin(double x[3])
void HighlightOutline(int highlight)
vtkPolyDataMapper * EdgesMapper
vtkPolyDataMapper * LineMapper2
void Push(double *p1, double *p2)
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 wireframe outline for an arbitrary data set or composite dataset
perform various plane computations
Definition: vtkPlane.h:32
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
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
filter that generates tubes around lines
Definition: vtkTubeFilter.h:78
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SIZEHINT(...)