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
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:36
vtkImplicitPlaneWidget::ConeActor2
vtkActor * ConeActor2
Definition: vtkImplicitPlaneWidget.h:373
vtkImplicitPlaneWidget::Pushing
@ Pushing
Definition: vtkImplicitPlaneWidget.h:305
vtkPlane
perform various plane computations
Definition: vtkPlane.h:31
vtkImplicitPlaneWidget::ConeSource2
vtkConeSource * ConeSource2
Definition: vtkImplicitPlaneWidget.h:371
vtkImplicitPlaneWidget::Rotating
@ Rotating
Definition: vtkImplicitPlaneWidget.h:306
vtkCutter
Cut vtkDataSet with user-specified implicit function.
Definition: vtkCutter.h:63
vtkImplicitPlaneWidget::ConeMapper2
vtkPolyDataMapper * ConeMapper2
Definition: vtkImplicitPlaneWidget.h:372
vtkImplicitPlaneWidget::Plane
vtkPlane * Plane
Definition: vtkImplicitPlaneWidget.h:330
vtkImplicitPlaneWidget::LineSource
vtkLineSource * LineSource
Definition: vtkImplicitPlaneWidget.h:366
vtkImplicitPlaneWidget::NormalToZAxis
vtkTypeBool NormalToZAxis
Definition: vtkImplicitPlaneWidget.h:326
vtkImplicitPlaneWidget::LineSource2
vtkLineSource * LineSource2
Definition: vtkImplicitPlaneWidget.h:376
vtkPolyDataSourceWidget::PlaceWidget
void PlaceWidget() override
Overrides vtk3DWidget PlaceWidget() so that it doesn't complain if there's no Input and no Prop3D.
vtkImplicitPlaneWidget::PlaceWidget
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Definition: vtkImplicitPlaneWidget.h:113
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkImplicitPlaneWidget::Edges
vtkFeatureEdges * Edges
Definition: vtkImplicitPlaneWidget.h:350
vtkImplicitPlaneWidget::Picker
vtkCellPicker * Picker
Definition: vtkImplicitPlaneWidget.h:387
vtkConeSource
generate polygonal cone
Definition: vtkConeSource.h:38
vtkImplicitPlaneWidget::SphereActor
vtkActor * SphereActor
Definition: vtkImplicitPlaneWidget.h:383
vtkImplicitPlaneWidget::Tubing
vtkTypeBool Tubing
Definition: vtkImplicitPlaneWidget.h:354
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkImplicitPlaneWidget::MovingOutline
@ MovingOutline
Definition: vtkImplicitPlaneWidget.h:302
vtkImplicitPlaneWidget::NormalProperty
vtkProperty * NormalProperty
Definition: vtkImplicitPlaneWidget.h:406
vtkImplicitPlaneWidget::Transform
vtkTransform * Transform
Definition: vtkImplicitPlaneWidget.h:393
vtkImplicitPlaneWidget::SelectedOutlineProperty
vtkProperty * SelectedOutlineProperty
Definition: vtkImplicitPlaneWidget.h:411
vtkImplicitPlaneWidget::LineMapper
vtkPolyDataMapper * LineMapper
Definition: vtkImplicitPlaneWidget.h:367
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
vtkImplicitPlaneWidget::LineMapper2
vtkPolyDataMapper * LineMapper2
Definition: vtkImplicitPlaneWidget.h:377
vtkImplicitPlaneWidget::EdgesActor
vtkActor * EdgesActor
Definition: vtkImplicitPlaneWidget.h:353
vtkImplicitPlaneWidget::DiagonalRatio
double DiagonalRatio
Definition: vtkImplicitPlaneWidget.h:357
vtkImplicitPlaneWidget::ConeActor
vtkActor * ConeActor
Definition: vtkImplicitPlaneWidget.h:362
vtkTubeFilter
filter that generates tubes around lines
Definition: vtkTubeFilter.h:77
vtkImplicitPlaneWidget::CutMapper
vtkPolyDataMapper * CutMapper
Definition: vtkImplicitPlaneWidget.h:344
vtkImplicitPlaneWidget::DrawPlane
vtkTypeBool DrawPlane
Definition: vtkImplicitPlaneWidget.h:346
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:45
vtkSphereSource
create a polygonal sphere centered at the origin
Definition: vtkSphereSource.h:40
vtkInteractorObserver::ProcessEvents
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Handles the char widget activation event.
vtkImplicitPlaneWidget::LineActor
vtkActor * LineActor
Definition: vtkImplicitPlaneWidget.h:368
vtkImplicitPlaneWidget::OutlineActor
vtkActor * OutlineActor
Definition: vtkImplicitPlaneWidget.h:336
vtkImplicitPlaneWidget::OutsideBounds
vtkTypeBool OutsideBounds
Definition: vtkImplicitPlaneWidget.h:340
vtkImplicitPlaneWidget::OriginTranslation
vtkTypeBool OriginTranslation
Definition: vtkImplicitPlaneWidget.h:384
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
vtkImplicitPlaneWidget::SphereMapper
vtkPolyDataMapper * SphereMapper
Definition: vtkImplicitPlaneWidget.h:382
vtkImplicitPlaneWidget::OutlineTranslation
vtkTypeBool OutlineTranslation
Definition: vtkImplicitPlaneWidget.h:338
vtkInteractorObserver::SetEnabled
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
Definition: vtkInteractorObserver.h:79
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:41
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkImplicitPlaneWidget::NormalToYAxis
vtkTypeBool NormalToYAxis
Definition: vtkImplicitPlaneWidget.h:325
vtkImplicitPlaneWidget::ScaleEnabled
vtkTypeBool ScaleEnabled
Definition: vtkImplicitPlaneWidget.h:339
vtkFeatureEdges
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
Definition: vtkFeatureEdges.h:47
vtkImplicitPlaneWidget::SelectedPlaneProperty
vtkProperty * SelectedPlaneProperty
Definition: vtkImplicitPlaneWidget.h:409
vtkImplicitPlaneWidget::Box
vtkImageData * Box
Definition: vtkImplicitPlaneWidget.h:333
vtkImplicitPlaneWidget::EdgesTuber
vtkTubeFilter * EdgesTuber
Definition: vtkImplicitPlaneWidget.h:351
vtkLineSource
create a line defined by two end points
Definition: vtkLineSource.h:60
vtkImplicitPlaneWidget::NormalToXAxis
vtkTypeBool NormalToXAxis
Definition: vtkImplicitPlaneWidget.h:324
vtkImplicitPlaneWidget::SelectedNormalProperty
vtkProperty * SelectedNormalProperty
Definition: vtkImplicitPlaneWidget.h:407
vtkImplicitPlaneWidget::ConeMapper
vtkPolyDataMapper * ConeMapper
Definition: vtkImplicitPlaneWidget.h:361
vtkPolyDataSourceWidget::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkInteractorObserver::RegisterPickers
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkImplicitPlaneWidget::MovingPlane
@ MovingPlane
Definition: vtkImplicitPlaneWidget.h:301
vtkImplicitPlaneWidget::LineActor2
vtkActor * LineActor2
Definition: vtkImplicitPlaneWidget.h:378
vtkImplicitPlaneWidget::WidgetState
WidgetState
Definition: vtkImplicitPlaneWidget.h:298
vtkImplicitPlaneWidget::MovingOrigin
@ MovingOrigin
Definition: vtkImplicitPlaneWidget.h:303
vtk3DWidget::PlaceWidget
virtual void PlaceWidget()
vtkImplicitPlaneWidget
3D widget for manipulating an infinite plane
Definition: vtkImplicitPlaneWidget.h:95
vtkImplicitPlaneWidget::ConeSource
vtkConeSource * ConeSource
Definition: vtkImplicitPlaneWidget.h:360
vtkPolyDataSourceWidget
abstract PolyDataSource-based 3D widget
Definition: vtkPolyDataSourceWidget.h:45
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
vtkOutlineFilter
create wireframe outline for an arbitrary data set or composite dataset
Definition: vtkOutlineFilter.h:36
vtkImplicitPlaneWidget::EdgesProperty
vtkProperty * EdgesProperty
Definition: vtkImplicitPlaneWidget.h:412
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:61
vtkImplicitPlaneWidget::PlaneProperty
vtkProperty * PlaneProperty
Definition: vtkImplicitPlaneWidget.h:408
vtkImplicitPlaneWidget::OutlineMapper
vtkPolyDataMapper * OutlineMapper
Definition: vtkImplicitPlaneWidget.h:335
vtkImplicitPlaneWidget::PlaceWidget
void PlaceWidget() override
Definition: vtkImplicitPlaneWidget.h:112
vtkImplicitPlaneWidget::Scaling
@ Scaling
Definition: vtkImplicitPlaneWidget.h:304
vtkImplicitPlaneWidget::Cutter
vtkCutter * Cutter
Definition: vtkImplicitPlaneWidget.h:343
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:66
vtkImplicitPlaneWidget::OutlineProperty
vtkProperty * OutlineProperty
Definition: vtkImplicitPlaneWidget.h:410
vtkImplicitPlaneWidget::CutActor
vtkActor * CutActor
Definition: vtkImplicitPlaneWidget.h:345
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkImplicitPlaneWidget::Outline
vtkOutlineFilter * Outline
Definition: vtkImplicitPlaneWidget.h:334
vtkPolyDataSourceWidget.h
vtkImplicitPlaneWidget::Sphere
vtkSphereSource * Sphere
Definition: vtkImplicitPlaneWidget.h:381
vtkImplicitPlaneWidget::EdgesMapper
vtkPolyDataMapper * EdgesMapper
Definition: vtkImplicitPlaneWidget.h:352
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:41