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
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:53
abstract PolyDataSource-based 3D widget
vtkPolyDataMapper * ConeMapper
represent surface properties of a geometric object
Definition: vtkProperty.h:60
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:79
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
int vtkTypeBool
Definition: vtkABI.h:69
create wireframe outline for arbitrary data set
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 boundary, non-manifold, and/or sharp edges from polygonal data
topologically and geometrically regular array of data
Definition: vtkImageData.h:39
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:36
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:63
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