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 =========================================================================*/
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
104  {this->Superclass::PlaceWidget();}
105  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
106  double zmin, double zmax) override
107  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
109 
111 
114  virtual void SetOrigin(double x, double y, double z);
115  virtual void SetOrigin(double x[3]);
116  double* GetOrigin() VTK_SIZEHINT(3);
117  void GetOrigin(double xyz[3]);
119 
121 
124  void SetNormal(double x, double y, double z);
125  void SetNormal(double x[3]);
126  double* GetNormal() VTK_SIZEHINT(3);
127  void GetNormal(double xyz[3]);
129 
131 
138  void SetNormalToXAxis(vtkTypeBool);
139  vtkGetMacro(NormalToXAxis,vtkTypeBool);
140  vtkBooleanMacro(NormalToXAxis,vtkTypeBool);
141  void SetNormalToYAxis(vtkTypeBool);
142  vtkGetMacro(NormalToYAxis,vtkTypeBool);
143  vtkBooleanMacro(NormalToYAxis,vtkTypeBool);
144  void SetNormalToZAxis(vtkTypeBool);
145  vtkGetMacro(NormalToZAxis,vtkTypeBool);
146  vtkBooleanMacro(NormalToZAxis,vtkTypeBool);
148 
150 
154  vtkSetMacro(Tubing,vtkTypeBool);
155  vtkGetMacro(Tubing,vtkTypeBool);
156  vtkBooleanMacro(Tubing,vtkTypeBool);
158 
160 
166  void SetDrawPlane(vtkTypeBool plane);
167  vtkGetMacro(DrawPlane,vtkTypeBool);
168  vtkBooleanMacro(DrawPlane,vtkTypeBool);
170 
172 
176  vtkSetMacro(OutlineTranslation,vtkTypeBool);
177  vtkGetMacro(OutlineTranslation,vtkTypeBool);
178  vtkBooleanMacro(OutlineTranslation,vtkTypeBool);
180 
182 
185  vtkSetMacro(OutsideBounds,vtkTypeBool);
186  vtkGetMacro(OutsideBounds,vtkTypeBool);
187  vtkBooleanMacro(OutsideBounds,vtkTypeBool);
189 
191 
194  vtkSetMacro(ScaleEnabled,vtkTypeBool);
195  vtkGetMacro(ScaleEnabled,vtkTypeBool);
196  vtkBooleanMacro(ScaleEnabled,vtkTypeBool);
198 
200 
204  vtkSetMacro(OriginTranslation,vtkTypeBool);
205  vtkGetMacro(OriginTranslation,vtkTypeBool);
206  vtkBooleanMacro(OriginTranslation,vtkTypeBool);
208 
210 
214  vtkSetClampMacro(DiagonalRatio,double,0,2);
215  vtkGetMacro(DiagonalRatio,double);
217 
222  void GetPolyData(vtkPolyData *pd);
223 
228  vtkPolyDataAlgorithm* GetPolyDataAlgorithm() override;
229 
236  void GetPlane(vtkPlane *plane);
237 
242  void UpdatePlacement() override;
243 
247  void SizeHandles() override;
248 
250 
253  vtkGetObjectMacro(NormalProperty,vtkProperty);
254  vtkGetObjectMacro(SelectedNormalProperty,vtkProperty);
256 
258 
262  vtkGetObjectMacro(PlaneProperty,vtkProperty);
263  vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty);
265 
267 
270  vtkGetObjectMacro(OutlineProperty,vtkProperty);
271  vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
273 
275 
279  vtkGetObjectMacro(EdgesProperty,vtkProperty);
281 
282 protected:
284  ~vtkImplicitPlaneWidget() override;
285 
286  // Manage the state of the widget
287  int State;
289  {
290  Start=0,
297  Outside
298  };
299 
300  //handles the events
301  static void ProcessEvents(vtkObject* object, unsigned long event,
302  void* clientdata, void* calldata);
303 
304  // ProcessEvents() dispatches to these methods.
305  void OnLeftButtonDown();
306  void OnLeftButtonUp();
307  void OnMiddleButtonDown();
308  void OnMiddleButtonUp();
309  void OnRightButtonDown();
310  void OnRightButtonUp();
311  void OnMouseMove();
312 
313  // Controlling ivars
317  void UpdateRepresentation();
318 
319  // The actual plane which is being manipulated
321 
322  // The bounding box is represented by a single voxel image data
327  void HighlightOutline(int highlight);
328  vtkTypeBool OutlineTranslation; //whether the outline can be moved
329  vtkTypeBool ScaleEnabled; //whether the widget can be scaled
330  vtkTypeBool OutsideBounds; //whether the widget can be moved outside input's bounds
331 
332  // The cut plane is produced with a vtkCutter
337  virtual void HighlightPlane(int highlight);
338 
339  // Optional tubes are represented by extracting boundary edges and tubing
344  vtkTypeBool Tubing; //control whether tubing is on
345 
346  // Control final length of the arrow:
348 
349  // The + normal cone
353  void HighlightNormal(int highlight);
354 
355  // The + normal line
359 
360  // The - normal cone
364 
365  // The - normal line
369 
370  // The origin positioning handle
374  vtkTypeBool OriginTranslation; //whether the origin (sphere) can be moved
375 
376  // Do the picking
378 
379  // Register internal Pickers within PickingManager
380  void RegisterPickers() override;
381 
382  // Transform the normal (used for rotation)
384 
385  // Methods to manipulate the plane
386  void ConstrainOrigin(double x[3]);
387  void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
388  void TranslatePlane(double *p1, double *p2);
389  void TranslateOutline(double *p1, double *p2);
390  void TranslateOrigin(double *p1, double *p2);
391  void Push(double *p1, double *p2);
392  void Scale(double *p1, double *p2, int X, int Y);
393 
394  // Properties used to control the appearance of selected objects and
395  // the manipulator in general.
403  void CreateDefaultProperties();
404 
405  void GeneratePlane();
406 
407 private:
409  void operator=(const vtkImplicitPlaneWidget&) = delete;
410 };
411 
412 #endif
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:36
vtkImplicitPlaneWidget::ConeActor2
vtkActor * ConeActor2
Definition: vtkImplicitPlaneWidget.h:363
vtkImplicitPlaneWidget::Pushing
Definition: vtkImplicitPlaneWidget.h:295
vtkPlane
perform various plane computations
Definition: vtkPlane.h:31
vtkImplicitPlaneWidget::ConeSource2
vtkConeSource * ConeSource2
Definition: vtkImplicitPlaneWidget.h:361
vtkImplicitPlaneWidget::Rotating
Definition: vtkImplicitPlaneWidget.h:296
vtkCutter
Cut vtkDataSet with user-specified implicit function.
Definition: vtkCutter.h:63
vtkImplicitPlaneWidget::ConeMapper2
vtkPolyDataMapper * ConeMapper2
Definition: vtkImplicitPlaneWidget.h:362
vtkImplicitPlaneWidget::Plane
vtkPlane * Plane
Definition: vtkImplicitPlaneWidget.h:320
vtkImplicitPlaneWidget::LineSource
vtkLineSource * LineSource
Definition: vtkImplicitPlaneWidget.h:356
vtkImplicitPlaneWidget::NormalToZAxis
vtkTypeBool NormalToZAxis
Definition: vtkImplicitPlaneWidget.h:316
vtkImplicitPlaneWidget::LineSource2
vtkLineSource * LineSource2
Definition: vtkImplicitPlaneWidget.h:366
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:105
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:340
vtkImplicitPlaneWidget::Picker
vtkCellPicker * Picker
Definition: vtkImplicitPlaneWidget.h:377
vtkConeSource
generate polygonal cone
Definition: vtkConeSource.h:38
vtkImplicitPlaneWidget::SphereActor
vtkActor * SphereActor
Definition: vtkImplicitPlaneWidget.h:373
vtkImplicitPlaneWidget::Tubing
vtkTypeBool Tubing
Definition: vtkImplicitPlaneWidget.h:344
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:53
vtkImplicitPlaneWidget::MovingOutline
Definition: vtkImplicitPlaneWidget.h:292
vtkImplicitPlaneWidget::NormalProperty
vtkProperty * NormalProperty
Definition: vtkImplicitPlaneWidget.h:396
vtkImplicitPlaneWidget::Transform
vtkTransform * Transform
Definition: vtkImplicitPlaneWidget.h:383
vtkImplicitPlaneWidget::SelectedOutlineProperty
vtkProperty * SelectedOutlineProperty
Definition: vtkImplicitPlaneWidget.h:401
vtkImplicitPlaneWidget::LineMapper
vtkPolyDataMapper * LineMapper
Definition: vtkImplicitPlaneWidget.h:357
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
vtkImplicitPlaneWidget::LineMapper2
vtkPolyDataMapper * LineMapper2
Definition: vtkImplicitPlaneWidget.h:367
vtkImplicitPlaneWidget::EdgesActor
vtkActor * EdgesActor
Definition: vtkImplicitPlaneWidget.h:343
vtkImplicitPlaneWidget::DiagonalRatio
double DiagonalRatio
Definition: vtkImplicitPlaneWidget.h:347
vtkImplicitPlaneWidget::ConeActor
vtkActor * ConeActor
Definition: vtkImplicitPlaneWidget.h:352
vtkTubeFilter
filter that generates tubes around lines
Definition: vtkTubeFilter.h:77
vtkImplicitPlaneWidget::CutMapper
vtkPolyDataMapper * CutMapper
Definition: vtkImplicitPlaneWidget.h:334
vtkImplicitPlaneWidget::DrawPlane
vtkTypeBool DrawPlane
Definition: vtkImplicitPlaneWidget.h:336
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:42
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:358
vtkImplicitPlaneWidget::OutlineActor
vtkActor * OutlineActor
Definition: vtkImplicitPlaneWidget.h:326
vtkImplicitPlaneWidget::OutsideBounds
vtkTypeBool OutsideBounds
Definition: vtkImplicitPlaneWidget.h:330
vtkImplicitPlaneWidget::OriginTranslation
vtkTypeBool OriginTranslation
Definition: vtkImplicitPlaneWidget.h:374
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
vtkImplicitPlaneWidget::SphereMapper
vtkPolyDataMapper * SphereMapper
Definition: vtkImplicitPlaneWidget.h:372
vtkImplicitPlaneWidget::OutlineTranslation
vtkTypeBool OutlineTranslation
Definition: vtkImplicitPlaneWidget.h:328
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:39
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkImplicitPlaneWidget::NormalToYAxis
vtkTypeBool NormalToYAxis
Definition: vtkImplicitPlaneWidget.h:315
vtkImplicitPlaneWidget::ScaleEnabled
vtkTypeBool ScaleEnabled
Definition: vtkImplicitPlaneWidget.h:329
vtkFeatureEdges
extract boundary, non-manifold, and/or sharp edges from polygonal data
Definition: vtkFeatureEdges.h:46
vtkImplicitPlaneWidget::SelectedPlaneProperty
vtkProperty * SelectedPlaneProperty
Definition: vtkImplicitPlaneWidget.h:399
vtkImplicitPlaneWidget::Box
vtkImageData * Box
Definition: vtkImplicitPlaneWidget.h:323
vtkImplicitPlaneWidget::EdgesTuber
vtkTubeFilter * EdgesTuber
Definition: vtkImplicitPlaneWidget.h:341
vtkLineSource
create a line defined by two end points
Definition: vtkLineSource.h:36
vtkImplicitPlaneWidget::NormalToXAxis
vtkTypeBool NormalToXAxis
Definition: vtkImplicitPlaneWidget.h:314
vtkImplicitPlaneWidget::SelectedNormalProperty
vtkProperty * SelectedNormalProperty
Definition: vtkImplicitPlaneWidget.h:397
vtkImplicitPlaneWidget::ConeMapper
vtkPolyDataMapper * ConeMapper
Definition: vtkImplicitPlaneWidget.h:351
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:291
vtkImplicitPlaneWidget::LineActor2
vtkActor * LineActor2
Definition: vtkImplicitPlaneWidget.h:368
vtkImplicitPlaneWidget::WidgetState
WidgetState
Definition: vtkImplicitPlaneWidget.h:288
vtkImplicitPlaneWidget::MovingOrigin
Definition: vtkImplicitPlaneWidget.h:293
vtk3DWidget::PlaceWidget
virtual void PlaceWidget()
vtkImplicitPlaneWidget
3D widget for manipulating an infinite plane
Definition: vtkImplicitPlaneWidget.h:86
vtkImplicitPlaneWidget::ConeSource
vtkConeSource * ConeSource
Definition: vtkImplicitPlaneWidget.h:350
vtkPolyDataSourceWidget
abstract PolyDataSource-based 3D widget
Definition: vtkPolyDataSourceWidget.h:45
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
vtkOutlineFilter
create wireframe outline for arbitrary data set
Definition: vtkOutlineFilter.h:32
vtkImplicitPlaneWidget::EdgesProperty
vtkProperty * EdgesProperty
Definition: vtkImplicitPlaneWidget.h:402
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:60
vtkImplicitPlaneWidget::PlaneProperty
vtkProperty * PlaneProperty
Definition: vtkImplicitPlaneWidget.h:398
vtkImplicitPlaneWidget::OutlineMapper
vtkPolyDataMapper * OutlineMapper
Definition: vtkImplicitPlaneWidget.h:325
vtkImplicitPlaneWidget::PlaceWidget
void PlaceWidget() override
Definition: vtkImplicitPlaneWidget.h:103
vtkImplicitPlaneWidget::Scaling
Definition: vtkImplicitPlaneWidget.h:294
vtkImplicitPlaneWidget::Cutter
vtkCutter * Cutter
Definition: vtkImplicitPlaneWidget.h:333
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:63
vtkImplicitPlaneWidget::OutlineProperty
vtkProperty * OutlineProperty
Definition: vtkImplicitPlaneWidget.h:400
vtkImplicitPlaneWidget::CutActor
vtkActor * CutActor
Definition: vtkImplicitPlaneWidget.h:335
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkImplicitPlaneWidget::Outline
vtkOutlineFilter * Outline
Definition: vtkImplicitPlaneWidget.h:324
vtkPolyDataSourceWidget.h
vtkImplicitPlaneWidget::Sphere
vtkSphereSource * Sphere
Definition: vtkImplicitPlaneWidget.h:371
vtkImplicitPlaneWidget::EdgesMapper
vtkPolyDataMapper * EdgesMapper
Definition: vtkImplicitPlaneWidget.h:342
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:41