VTK  9.3.1
vtkImplicitPlaneWidget.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
58 #ifndef vtkImplicitPlaneWidget_h
59 #define vtkImplicitPlaneWidget_h
60 
61 #include "vtkInteractionWidgetsModule.h" // For export macro
63 
64 VTK_ABI_NAMESPACE_BEGIN
65 class vtkActor;
66 class vtkPolyDataMapper;
67 class vtkCellPicker;
68 class vtkConeSource;
69 class vtkLineSource;
70 class vtkSphereSource;
71 class vtkTubeFilter;
72 class vtkPlane;
73 class vtkCutter;
74 class vtkProperty;
75 class vtkImageData;
76 class vtkOutlineFilter;
77 class vtkFeatureEdges;
78 class vtkPolyData;
79 class vtkTransform;
80 
81 class VTKINTERACTIONWIDGETS_EXPORT vtkImplicitPlaneWidget : public vtkPolyDataSourceWidget
82 {
83 public:
87  static vtkImplicitPlaneWidget* New();
88 
90  void PrintSelf(ostream& os, vtkIndent indent) override;
91 
93 
96  void SetEnabled(int) override;
97  void PlaceWidget(double bounds[6]) override;
98  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
100  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
101  {
102  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
103  }
105 
107 
110  virtual void SetOrigin(double x, double y, double z);
111  virtual void SetOrigin(double x[3]);
112  double* GetOrigin() VTK_SIZEHINT(3);
113  void GetOrigin(double xyz[3]);
115 
117 
120  void SetNormal(double x, double y, double z);
121  void SetNormal(double n[3]);
122  double* GetNormal() VTK_SIZEHINT(3);
123  void GetNormal(double xyz[3]);
125 
127 
134  void SetNormalToXAxis(vtkTypeBool);
135  vtkGetMacro(NormalToXAxis, vtkTypeBool);
136  vtkBooleanMacro(NormalToXAxis, vtkTypeBool);
137  void SetNormalToYAxis(vtkTypeBool);
138  vtkGetMacro(NormalToYAxis, vtkTypeBool);
139  vtkBooleanMacro(NormalToYAxis, vtkTypeBool);
140  void SetNormalToZAxis(vtkTypeBool);
141  vtkGetMacro(NormalToZAxis, vtkTypeBool);
142  vtkBooleanMacro(NormalToZAxis, vtkTypeBool);
144 
146 
150  vtkSetMacro(Tubing, vtkTypeBool);
151  vtkGetMacro(Tubing, vtkTypeBool);
152  vtkBooleanMacro(Tubing, vtkTypeBool);
154 
156 
162  void SetDrawPlane(vtkTypeBool plane);
163  vtkGetMacro(DrawPlane, vtkTypeBool);
164  vtkBooleanMacro(DrawPlane, vtkTypeBool);
166 
168 
172  vtkSetMacro(OutlineTranslation, vtkTypeBool);
173  vtkGetMacro(OutlineTranslation, vtkTypeBool);
174  vtkBooleanMacro(OutlineTranslation, vtkTypeBool);
176 
178 
181  vtkSetMacro(OutsideBounds, vtkTypeBool);
182  vtkGetMacro(OutsideBounds, vtkTypeBool);
183  vtkBooleanMacro(OutsideBounds, vtkTypeBool);
185 
187 
190  vtkSetMacro(ScaleEnabled, vtkTypeBool);
191  vtkGetMacro(ScaleEnabled, vtkTypeBool);
192  vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
194 
196 
200  vtkSetMacro(OriginTranslation, vtkTypeBool);
201  vtkGetMacro(OriginTranslation, vtkTypeBool);
202  vtkBooleanMacro(OriginTranslation, vtkTypeBool);
204 
206 
210  vtkSetClampMacro(DiagonalRatio, double, 0, 2);
211  vtkGetMacro(DiagonalRatio, double);
213 
218  void GetPolyData(vtkPolyData* pd);
219 
224  vtkPolyDataAlgorithm* GetPolyDataAlgorithm() override;
225 
232  void GetPlane(vtkPlane* plane);
233 
238  void UpdatePlacement() override;
239 
243  void SizeHandles() override;
244 
246 
249  vtkGetObjectMacro(NormalProperty, vtkProperty);
250  vtkGetObjectMacro(SelectedNormalProperty, vtkProperty);
252 
254 
258  vtkGetObjectMacro(PlaneProperty, vtkProperty);
259  vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
261 
263 
266  vtkGetObjectMacro(OutlineProperty, vtkProperty);
267  vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
269 
271 
275  vtkGetObjectMacro(EdgesProperty, vtkProperty);
277 
278 protected:
280  ~vtkImplicitPlaneWidget() override;
281 
282  // Manage the state of the widget
283  int State;
285  {
286  Start = 0,
293  Outside
294  };
295 
296  // handles the events
297  static void ProcessEvents(
298  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
299 
300  // ProcessEvents() dispatches to these methods.
301  void OnLeftButtonDown();
302  void OnLeftButtonUp();
303  void OnMiddleButtonDown();
304  void OnMiddleButtonUp();
305  void OnRightButtonDown();
306  void OnRightButtonUp();
307  void OnMouseMove();
308 
309  // Controlling ivars
313  void UpdateRepresentation();
314 
315  // The actual plane which is being manipulated
317 
318  // The bounding box is represented by a single voxel image data
323  void HighlightOutline(int highlight);
324  vtkTypeBool OutlineTranslation; // whether the outline can be moved
325  vtkTypeBool ScaleEnabled; // whether the widget can be scaled
326  vtkTypeBool OutsideBounds; // whether the widget can be moved outside input's bounds
327 
328  // The cut plane is produced with a vtkCutter
333  virtual void HighlightPlane(int highlight);
334 
335  // Optional tubes are represented by extracting boundary edges and tubing
340  vtkTypeBool Tubing; // control whether tubing is on
341 
342  // Control final length of the arrow:
344 
345  // The + normal cone
349  void HighlightNormal(int highlight);
350 
351  // The + normal line
355 
356  // The - normal cone
360 
361  // The - normal line
365 
366  // The origin positioning handle
370  vtkTypeBool OriginTranslation; // whether the origin (sphere) can be moved
371 
372  // Do the picking
374 
375  // Register internal Pickers within PickingManager
376  void RegisterPickers() override;
377 
378  // Transform the normal (used for rotation)
380 
381  // Methods to manipulate the plane
382  void ConstrainOrigin(double x[3]);
383  void Rotate(int X, int Y, double* p1, double* p2, double* vpn);
384  void TranslatePlane(double* p1, double* p2);
385  void TranslateOutline(double* p1, double* p2);
386  void TranslateOrigin(double* p1, double* p2);
387  void Push(double* p1, double* p2);
388  void Scale(double* p1, double* p2, int X, int Y);
389 
390  // Properties used to control the appearance of selected objects and
391  // the manipulator in general.
399  void CreateDefaultProperties();
400 
401  void GeneratePlane();
402 
403 private:
405  void operator=(const vtkImplicitPlaneWidget&) = delete;
406 };
407 
408 VTK_ABI_NAMESPACE_END
409 #endif
3D widget for manipulating an infinite plane
Cut vtkDataSet with user-specified implicit function.
Definition: vtkCutter.h:60
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:40
abstract base class for most VTK objects
Definition: vtkObject.h:51
abstract PolyDataSource-based 3D widget
vtkPolyDataMapper * ConeMapper
represent surface properties of a geometric object
Definition: vtkProperty.h:56
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:33
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:49
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:64
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:74
a simple class to control print indentation
Definition: vtkIndent.h:28
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
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:25
vtkPolyDataMapper * OutlineMapper
#define VTK_SIZEHINT(...)
vtkPolyDataMapper * ConeMapper2
create a line defined by two end points
Definition: vtkLineSource.h:52
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:61
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