VTK
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 =========================================================================*/
70 #ifndef vtkImplicitPlaneWidget_h
71 #define vtkImplicitPlaneWidget_h
72 
73 #include "vtkInteractionWidgetsModule.h" // For export macro
75 
76 class vtkActor;
77 class vtkPolyDataMapper;
78 class vtkCellPicker;
79 class vtkConeSource;
80 class vtkLineSource;
81 class vtkSphereSource;
82 class vtkTubeFilter;
83 class vtkPlane;
84 class vtkCutter;
85 class vtkProperty;
86 class vtkImageData;
87 class vtkOutlineFilter;
88 class vtkFeatureEdges;
89 class vtkPolyData;
90 class vtkTransform;
91 
92 class VTKINTERACTIONWIDGETS_EXPORT vtkImplicitPlaneWidget : public vtkPolyDataSourceWidget
93 {
94 public:
98  static vtkImplicitPlaneWidget *New();
99 
101  void PrintSelf(ostream& os, vtkIndent indent) override;
102 
104 
107  void SetEnabled(int) override;
108  void PlaceWidget(double bounds[6]) override;
109  void PlaceWidget() override
110  {this->Superclass::PlaceWidget();}
111  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
112  double zmin, double zmax) override
113  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
115 
117 
120  virtual void SetOrigin(double x, double y, double z);
121  virtual void SetOrigin(double x[3]);
122  double* GetOrigin() VTK_SIZEHINT(3);
123  void GetOrigin(double xyz[3]);
125 
127 
130  void SetNormal(double x, double y, double z);
131  void SetNormal(double x[3]);
132  double* GetNormal() VTK_SIZEHINT(3);
133  void GetNormal(double xyz[3]);
135 
137 
144  void SetNormalToXAxis(vtkTypeBool);
145  vtkGetMacro(NormalToXAxis,vtkTypeBool);
146  vtkBooleanMacro(NormalToXAxis,vtkTypeBool);
147  void SetNormalToYAxis(vtkTypeBool);
148  vtkGetMacro(NormalToYAxis,vtkTypeBool);
149  vtkBooleanMacro(NormalToYAxis,vtkTypeBool);
150  void SetNormalToZAxis(vtkTypeBool);
151  vtkGetMacro(NormalToZAxis,vtkTypeBool);
152  vtkBooleanMacro(NormalToZAxis,vtkTypeBool);
154 
156 
160  vtkSetMacro(Tubing,vtkTypeBool);
161  vtkGetMacro(Tubing,vtkTypeBool);
162  vtkBooleanMacro(Tubing,vtkTypeBool);
164 
166 
172  void SetDrawPlane(vtkTypeBool plane);
173  vtkGetMacro(DrawPlane,vtkTypeBool);
174  vtkBooleanMacro(DrawPlane,vtkTypeBool);
176 
178 
182  vtkSetMacro(OutlineTranslation,vtkTypeBool);
183  vtkGetMacro(OutlineTranslation,vtkTypeBool);
184  vtkBooleanMacro(OutlineTranslation,vtkTypeBool);
186 
188 
191  vtkSetMacro(OutsideBounds,vtkTypeBool);
192  vtkGetMacro(OutsideBounds,vtkTypeBool);
193  vtkBooleanMacro(OutsideBounds,vtkTypeBool);
195 
197 
200  vtkSetMacro(ScaleEnabled,vtkTypeBool);
201  vtkGetMacro(ScaleEnabled,vtkTypeBool);
202  vtkBooleanMacro(ScaleEnabled,vtkTypeBool);
204 
206 
210  vtkSetMacro(OriginTranslation,vtkTypeBool);
211  vtkGetMacro(OriginTranslation,vtkTypeBool);
212  vtkBooleanMacro(OriginTranslation,vtkTypeBool);
214 
216 
220  vtkSetClampMacro(DiagonalRatio,double,0,2);
221  vtkGetMacro(DiagonalRatio,double);
223 
228  void GetPolyData(vtkPolyData *pd);
229 
234  vtkPolyDataAlgorithm* GetPolyDataAlgorithm() override;
235 
242  void GetPlane(vtkPlane *plane);
243 
248  void UpdatePlacement() override;
249 
253  void SizeHandles() override;
254 
256 
259  vtkGetObjectMacro(NormalProperty,vtkProperty);
260  vtkGetObjectMacro(SelectedNormalProperty,vtkProperty);
262 
264 
268  vtkGetObjectMacro(PlaneProperty,vtkProperty);
269  vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty);
271 
273 
276  vtkGetObjectMacro(OutlineProperty,vtkProperty);
277  vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
279 
281 
285  vtkGetObjectMacro(EdgesProperty,vtkProperty);
287 
288 protected:
290  ~vtkImplicitPlaneWidget() override;
291 
292  // Manage the state of the widget
293  int State;
295  {
296  Start=0,
303  Outside
304  };
305 
306  //handles the events
307  static void ProcessEvents(vtkObject* object, unsigned long event,
308  void* clientdata, void* calldata);
309 
310  // ProcessEvents() dispatches to these methods.
311  void OnLeftButtonDown();
312  void OnLeftButtonUp();
313  void OnMiddleButtonDown();
314  void OnMiddleButtonUp();
315  void OnRightButtonDown();
316  void OnRightButtonUp();
317  void OnMouseMove();
318 
319  // Controlling ivars
323  void UpdateRepresentation();
324 
325  // The actual plane which is being manipulated
327 
328  // The bounding box is represented by a single voxel image data
333  void HighlightOutline(int highlight);
334  vtkTypeBool OutlineTranslation; //whether the outline can be moved
335  vtkTypeBool ScaleEnabled; //whether the widget can be scaled
336  vtkTypeBool OutsideBounds; //whether the widget can be moved outside input's bounds
337 
338  // The cut plane is produced with a vtkCutter
343  virtual void HighlightPlane(int highlight);
344 
345  // Optional tubes are represented by extracting boundary edges and tubing
350  vtkTypeBool Tubing; //control whether tubing is on
351 
352  // Control final length of the arrow:
354 
355  // The + normal cone
359  void HighlightNormal(int highlight);
360 
361  // The + normal line
365 
366  // The - normal cone
370 
371  // The - normal line
375 
376  // The origin positioning handle
380  vtkTypeBool OriginTranslation; //whether the origin (sphere) can be moved
381 
382  // Do the picking
384 
385  // Register internal Pickers within PickingManager
386  void RegisterPickers() override;
387 
388  // Transform the normal (used for rotation)
390 
391  // Methods to manipulate the plane
392  void ConstrainOrigin(double x[3]);
393  void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
394  void TranslatePlane(double *p1, double *p2);
395  void TranslateOutline(double *p1, double *p2);
396  void TranslateOrigin(double *p1, double *p2);
397  void Push(double *p1, double *p2);
398  void Scale(double *p1, double *p2, int X, int Y);
399 
400  // Properties used to control the appearance of selected objects and
401  // the manipulator in general.
409  void CreateDefaultProperties();
410 
411  void GeneratePlane();
412 
413 private:
415  void operator=(const vtkImplicitPlaneWidget&) = delete;
416 };
417 
418 #endif
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:42
vtkImplicitPlaneWidget::ConeActor2
vtkActor * ConeActor2
Definition: vtkImplicitPlaneWidget.h:369
vtkImplicitPlaneWidget::Pushing
Definition: vtkImplicitPlaneWidget.h:301
vtkPlane
perform various plane computations
Definition: vtkPlane.h:37
vtkImplicitPlaneWidget::ConeSource2
vtkConeSource * ConeSource2
Definition: vtkImplicitPlaneWidget.h:367
vtkImplicitPlaneWidget::Rotating
Definition: vtkImplicitPlaneWidget.h:302
vtkCutter
Cut vtkDataSet with user-specified implicit function.
Definition: vtkCutter.h:69
vtkImplicitPlaneWidget::ConeMapper2
vtkPolyDataMapper * ConeMapper2
Definition: vtkImplicitPlaneWidget.h:368
vtkImplicitPlaneWidget::Plane
vtkPlane * Plane
Definition: vtkImplicitPlaneWidget.h:326
vtkImplicitPlaneWidget::LineSource
vtkLineSource * LineSource
Definition: vtkImplicitPlaneWidget.h:362
vtkImplicitPlaneWidget::NormalToZAxis
vtkTypeBool NormalToZAxis
Definition: vtkImplicitPlaneWidget.h:322
vtkImplicitPlaneWidget::LineSource2
vtkLineSource * LineSource2
Definition: vtkImplicitPlaneWidget.h:372
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:111
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:346
vtkImplicitPlaneWidget::Picker
vtkCellPicker * Picker
Definition: vtkImplicitPlaneWidget.h:383
vtkConeSource
generate polygonal cone
Definition: vtkConeSource.h:44
vtkImplicitPlaneWidget::SphereActor
vtkActor * SphereActor
Definition: vtkImplicitPlaneWidget.h:379
vtkImplicitPlaneWidget::Tubing
vtkTypeBool Tubing
Definition: vtkImplicitPlaneWidget.h:350
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:59
vtkImplicitPlaneWidget::MovingOutline
Definition: vtkImplicitPlaneWidget.h:298
vtkImplicitPlaneWidget::NormalProperty
vtkProperty * NormalProperty
Definition: vtkImplicitPlaneWidget.h:402
vtkImplicitPlaneWidget::Transform
vtkTransform * Transform
Definition: vtkImplicitPlaneWidget.h:389
vtkImplicitPlaneWidget::SelectedOutlineProperty
vtkProperty * SelectedOutlineProperty
Definition: vtkImplicitPlaneWidget.h:407
vtkImplicitPlaneWidget::LineMapper
vtkPolyDataMapper * LineMapper
Definition: vtkImplicitPlaneWidget.h:363
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
vtkImplicitPlaneWidget::LineMapper2
vtkPolyDataMapper * LineMapper2
Definition: vtkImplicitPlaneWidget.h:373
vtkImplicitPlaneWidget::EdgesActor
vtkActor * EdgesActor
Definition: vtkImplicitPlaneWidget.h:349
vtkImplicitPlaneWidget::DiagonalRatio
double DiagonalRatio
Definition: vtkImplicitPlaneWidget.h:353
vtkImplicitPlaneWidget::ConeActor
vtkActor * ConeActor
Definition: vtkImplicitPlaneWidget.h:358
vtkTubeFilter
filter that generates tubes around lines
Definition: vtkTubeFilter.h:83
vtkImplicitPlaneWidget::CutMapper
vtkPolyDataMapper * CutMapper
Definition: vtkImplicitPlaneWidget.h:340
vtkImplicitPlaneWidget::DrawPlane
vtkTypeBool DrawPlane
Definition: vtkImplicitPlaneWidget.h:342
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:42
vtkSphereSource
create a polygonal sphere centered at the origin
Definition: vtkSphereSource.h:46
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:364
vtkImplicitPlaneWidget::OutlineActor
vtkActor * OutlineActor
Definition: vtkImplicitPlaneWidget.h:332
vtkImplicitPlaneWidget::OutsideBounds
vtkTypeBool OutsideBounds
Definition: vtkImplicitPlaneWidget.h:336
vtkImplicitPlaneWidget::OriginTranslation
vtkTypeBool OriginTranslation
Definition: vtkImplicitPlaneWidget.h:380
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
vtkImplicitPlaneWidget::SphereMapper
vtkPolyDataMapper * SphereMapper
Definition: vtkImplicitPlaneWidget.h:378
vtkImplicitPlaneWidget::OutlineTranslation
vtkTypeBool OutlineTranslation
Definition: vtkImplicitPlaneWidget.h:334
vtkInteractorObserver::SetEnabled
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
Definition: vtkInteractorObserver.h:73
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkImplicitPlaneWidget::NormalToYAxis
vtkTypeBool NormalToYAxis
Definition: vtkImplicitPlaneWidget.h:321
vtkImplicitPlaneWidget::ScaleEnabled
vtkTypeBool ScaleEnabled
Definition: vtkImplicitPlaneWidget.h:335
vtkFeatureEdges
extract boundary, non-manifold, and/or sharp edges from polygonal data
Definition: vtkFeatureEdges.h:49
vtkImplicitPlaneWidget::SelectedPlaneProperty
vtkProperty * SelectedPlaneProperty
Definition: vtkImplicitPlaneWidget.h:405
vtkImplicitPlaneWidget::Box
vtkImageData * Box
Definition: vtkImplicitPlaneWidget.h:329
vtkImplicitPlaneWidget::EdgesTuber
vtkTubeFilter * EdgesTuber
Definition: vtkImplicitPlaneWidget.h:347
vtkLineSource
create a line defined by two end points
Definition: vtkLineSource.h:42
vtkImplicitPlaneWidget::NormalToXAxis
vtkTypeBool NormalToXAxis
Definition: vtkImplicitPlaneWidget.h:320
vtkImplicitPlaneWidget::SelectedNormalProperty
vtkProperty * SelectedNormalProperty
Definition: vtkImplicitPlaneWidget.h:403
vtkImplicitPlaneWidget::ConeMapper
vtkPolyDataMapper * ConeMapper
Definition: vtkImplicitPlaneWidget.h:357
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
Definition: vtkImplicitPlaneWidget.h:297
vtkImplicitPlaneWidget::LineActor2
vtkActor * LineActor2
Definition: vtkImplicitPlaneWidget.h:374
vtkImplicitPlaneWidget::WidgetState
WidgetState
Definition: vtkImplicitPlaneWidget.h:294
vtkImplicitPlaneWidget::MovingOrigin
Definition: vtkImplicitPlaneWidget.h:299
vtk3DWidget::PlaceWidget
virtual void PlaceWidget()
vtkImplicitPlaneWidget
3D widget for manipulating an infinite plane
Definition: vtkImplicitPlaneWidget.h:92
vtkImplicitPlaneWidget::ConeSource
vtkConeSource * ConeSource
Definition: vtkImplicitPlaneWidget.h:356
vtkPolyDataSourceWidget
abstract PolyDataSource-based 3D widget
Definition: vtkPolyDataSourceWidget.h:45
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
vtkOutlineFilter
create wireframe outline for arbitrary data set
Definition: vtkOutlineFilter.h:38
vtkImplicitPlaneWidget::EdgesProperty
vtkProperty * EdgesProperty
Definition: vtkImplicitPlaneWidget.h:408
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:66
vtkImplicitPlaneWidget::PlaneProperty
vtkProperty * PlaneProperty
Definition: vtkImplicitPlaneWidget.h:404
vtkImplicitPlaneWidget::OutlineMapper
vtkPolyDataMapper * OutlineMapper
Definition: vtkImplicitPlaneWidget.h:331
vtkImplicitPlaneWidget::PlaceWidget
void PlaceWidget() override
Definition: vtkImplicitPlaneWidget.h:109
vtkImplicitPlaneWidget::Scaling
Definition: vtkImplicitPlaneWidget.h:300
vtkImplicitPlaneWidget::Cutter
vtkCutter * Cutter
Definition: vtkImplicitPlaneWidget.h:339
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:69
vtkImplicitPlaneWidget::OutlineProperty
vtkProperty * OutlineProperty
Definition: vtkImplicitPlaneWidget.h:406
vtkImplicitPlaneWidget::CutActor
vtkActor * CutActor
Definition: vtkImplicitPlaneWidget.h:341
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkImplicitPlaneWidget::Outline
vtkOutlineFilter * Outline
Definition: vtkImplicitPlaneWidget.h:330
vtkPolyDataSourceWidget.h
vtkImplicitPlaneWidget::Sphere
vtkSphereSource * Sphere
Definition: vtkImplicitPlaneWidget.h:377
vtkImplicitPlaneWidget::EdgesMapper
vtkPolyDataMapper * EdgesMapper
Definition: vtkImplicitPlaneWidget.h:348
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:44