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 =========================================================================*/
67 #ifndef vtkImplicitPlaneWidget_h
68 #define vtkImplicitPlaneWidget_h
69 
70 #include "vtkInteractionWidgetsModule.h" // For export macro
72 
73 class vtkActor;
74 class vtkPolyDataMapper;
75 class vtkCellPicker;
76 class vtkConeSource;
77 class vtkLineSource;
78 class vtkSphereSource;
79 class vtkTubeFilter;
80 class vtkPlane;
81 class vtkCutter;
82 class vtkProperty;
83 class vtkImageData;
84 class vtkOutlineFilter;
85 class vtkFeatureEdges;
86 class vtkPolyData;
87 class vtkTransform;
88 
89 class VTKINTERACTIONWIDGETS_EXPORT vtkImplicitPlaneWidget : public vtkPolyDataSourceWidget
90 {
91 public:
95  static vtkImplicitPlaneWidget* New();
96 
98  void PrintSelf(ostream& os, vtkIndent indent) override;
99 
101 
104  void SetEnabled(int) override;
105  void PlaceWidget(double bounds[6]) override;
106  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
108  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
109  {
110  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
111  }
113 
115 
118  virtual void SetOrigin(double x, double y, double z);
119  virtual void SetOrigin(double x[3]);
120  double* GetOrigin() VTK_SIZEHINT(3);
121  void GetOrigin(double xyz[3]);
123 
125 
128  void SetNormal(double x, double y, double z);
129  void SetNormal(double x[3]);
130  double* GetNormal() VTK_SIZEHINT(3);
131  void GetNormal(double xyz[3]);
133 
135 
142  void SetNormalToXAxis(vtkTypeBool);
143  vtkGetMacro(NormalToXAxis, vtkTypeBool);
144  vtkBooleanMacro(NormalToXAxis, vtkTypeBool);
145  void SetNormalToYAxis(vtkTypeBool);
146  vtkGetMacro(NormalToYAxis, vtkTypeBool);
147  vtkBooleanMacro(NormalToYAxis, vtkTypeBool);
148  void SetNormalToZAxis(vtkTypeBool);
149  vtkGetMacro(NormalToZAxis, vtkTypeBool);
150  vtkBooleanMacro(NormalToZAxis, vtkTypeBool);
152 
154 
158  vtkSetMacro(Tubing, vtkTypeBool);
159  vtkGetMacro(Tubing, vtkTypeBool);
160  vtkBooleanMacro(Tubing, vtkTypeBool);
162 
164 
170  void SetDrawPlane(vtkTypeBool plane);
171  vtkGetMacro(DrawPlane, vtkTypeBool);
172  vtkBooleanMacro(DrawPlane, vtkTypeBool);
174 
176 
180  vtkSetMacro(OutlineTranslation, vtkTypeBool);
181  vtkGetMacro(OutlineTranslation, vtkTypeBool);
182  vtkBooleanMacro(OutlineTranslation, vtkTypeBool);
184 
186 
189  vtkSetMacro(OutsideBounds, vtkTypeBool);
190  vtkGetMacro(OutsideBounds, vtkTypeBool);
191  vtkBooleanMacro(OutsideBounds, vtkTypeBool);
193 
195 
198  vtkSetMacro(ScaleEnabled, vtkTypeBool);
199  vtkGetMacro(ScaleEnabled, vtkTypeBool);
200  vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
202 
204 
208  vtkSetMacro(OriginTranslation, vtkTypeBool);
209  vtkGetMacro(OriginTranslation, vtkTypeBool);
210  vtkBooleanMacro(OriginTranslation, vtkTypeBool);
212 
214 
218  vtkSetClampMacro(DiagonalRatio, double, 0, 2);
219  vtkGetMacro(DiagonalRatio, double);
221 
226  void GetPolyData(vtkPolyData* pd);
227 
232  vtkPolyDataAlgorithm* GetPolyDataAlgorithm() override;
233 
240  void GetPlane(vtkPlane* plane);
241 
246  void UpdatePlacement() override;
247 
251  void SizeHandles() override;
252 
254 
257  vtkGetObjectMacro(NormalProperty, vtkProperty);
258  vtkGetObjectMacro(SelectedNormalProperty, vtkProperty);
260 
262 
266  vtkGetObjectMacro(PlaneProperty, vtkProperty);
267  vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
269 
271 
274  vtkGetObjectMacro(OutlineProperty, vtkProperty);
275  vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
277 
279 
283  vtkGetObjectMacro(EdgesProperty, vtkProperty);
285 
286 protected:
288  ~vtkImplicitPlaneWidget() override;
289 
290  // Manage the state of the widget
291  int State;
293  {
294  Start = 0,
301  Outside
302  };
303 
304  // handles the events
305  static void ProcessEvents(
306  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
307 
308  // ProcessEvents() dispatches to these methods.
309  void OnLeftButtonDown();
310  void OnLeftButtonUp();
311  void OnMiddleButtonDown();
312  void OnMiddleButtonUp();
313  void OnRightButtonDown();
314  void OnRightButtonUp();
315  void OnMouseMove();
316 
317  // Controlling ivars
321  void UpdateRepresentation();
322 
323  // The actual plane which is being manipulated
325 
326  // The bounding box is represented by a single voxel image data
331  void HighlightOutline(int highlight);
332  vtkTypeBool OutlineTranslation; // whether the outline can be moved
333  vtkTypeBool ScaleEnabled; // whether the widget can be scaled
334  vtkTypeBool OutsideBounds; // whether the widget can be moved outside input's bounds
335 
336  // The cut plane is produced with a vtkCutter
341  virtual void HighlightPlane(int highlight);
342 
343  // Optional tubes are represented by extracting boundary edges and tubing
348  vtkTypeBool Tubing; // control whether tubing is on
349 
350  // Control final length of the arrow:
352 
353  // The + normal cone
357  void HighlightNormal(int highlight);
358 
359  // The + normal line
363 
364  // The - normal cone
368 
369  // The - normal line
373 
374  // The origin positioning handle
378  vtkTypeBool OriginTranslation; // whether the origin (sphere) can be moved
379 
380  // Do the picking
382 
383  // Register internal Pickers within PickingManager
384  void RegisterPickers() override;
385 
386  // Transform the normal (used for rotation)
388 
389  // Methods to manipulate the plane
390  void ConstrainOrigin(double x[3]);
391  void Rotate(int X, int Y, double* p1, double* p2, double* vpn);
392  void TranslatePlane(double* p1, double* p2);
393  void TranslateOutline(double* p1, double* p2);
394  void TranslateOrigin(double* p1, double* p2);
395  void Push(double* p1, double* p2);
396  void Scale(double* p1, double* p2, int X, int Y);
397 
398  // Properties used to control the appearance of selected objects and
399  // the manipulator in general.
407  void CreateDefaultProperties();
408 
409  void GeneratePlane();
410 
411 private:
413  void operator=(const vtkImplicitPlaneWidget&) = delete;
414 };
415 
416 #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:56
abstract PolyDataSource-based 3D widget
vtkPolyDataMapper * ConeMapper
represent surface properties of a geometric object
Definition: vtkProperty.h:61
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:84
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
int vtkTypeBool
Definition: vtkABI.h:69
create wireframe outline for an arbitrary data set or composite dataset
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 interior, boundary, non-manifold, and/or sharp edges from polygonal data
topologically and geometrically regular array of data
Definition: vtkImageData.h:41
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:60
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:66
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