VTK  9.3.1
vtkDisplaySizedImplicitPlaneRepresentation.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
28 #ifndef vtkDisplaySizedImplicitPlaneRepresentation_h
29 #define vtkDisplaySizedImplicitPlaneRepresentation_h
30 
31 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0
32 #include "vtkInteractionWidgetsModule.h" // For export macro
33 #include "vtkLegacy.h" // for VTK_LEGACY_REMOVE
34 #include "vtkNew.h" // For vtkNew command
36 
37 VTK_ABI_NAMESPACE_BEGIN
38 class vtkActor;
39 class vtkBox;
40 class vtkCellPicker;
41 class vtkConeSource;
42 class vtkCutter;
43 class vtkDiskSource;
44 class vtkFeatureEdges;
45 class vtkHardwarePicker;
46 class vtkImageData;
47 class vtkLineSource;
48 class vtkLookupTable;
49 class vtkOutlineFilter;
50 class vtkPlane;
51 class vtkPolyData;
53 class vtkPolyDataMapper;
54 class vtkProperty;
55 class vtkSphereSource;
56 class vtkTransform;
57 class vtkTubeFilter;
58 
59 class VTKINTERACTIONWIDGETS_EXPORT vtkDisplaySizedImplicitPlaneRepresentation
61 {
62 public:
67 
69 
73  void PrintSelf(ostream& os, vtkIndent indent) override;
75 
77 
80  void SetOrigin(double x, double y, double z);
81  void SetOrigin(double x[3]);
82  double* GetOrigin() VTK_SIZEHINT(3);
83  void GetOrigin(double xyz[3]);
85 
87 
90  void SetNormal(double x, double y, double z);
91  void SetNormal(double n[3]);
92  void SetNormalToCamera();
93  double* GetNormal() VTK_SIZEHINT(3);
94  void GetNormal(double xyz[3]);
96 
98 
105  void SetNormalToXAxis(vtkTypeBool);
106  vtkGetMacro(NormalToXAxis, vtkTypeBool);
107  vtkBooleanMacro(NormalToXAxis, vtkTypeBool);
108  void SetNormalToYAxis(vtkTypeBool);
109  vtkGetMacro(NormalToYAxis, vtkTypeBool);
110  vtkBooleanMacro(NormalToYAxis, vtkTypeBool);
111  void SetNormalToZAxis(vtkTypeBool);
112  vtkGetMacro(NormalToZAxis, vtkTypeBool);
113  vtkBooleanMacro(NormalToZAxis, vtkTypeBool);
115 
117 
122  virtual void SetLockNormalToCamera(vtkTypeBool);
123  vtkGetMacro(LockNormalToCamera, vtkTypeBool);
124  vtkBooleanMacro(LockNormalToCamera, vtkTypeBool);
126 
128 
131  virtual void SetRadiusMultiplier(double radiusMultiplier);
132  virtual double GetRadiusMultiplierMinValue() { return 0.000001; }
133  virtual double GetRadiusMultiplierMaxValue() { return VTK_DOUBLE_MAX; }
134  vtkGetMacro(RadiusMultiplier, double);
136 
138 
144  void SetDrawPlane(vtkTypeBool plane);
145  vtkGetMacro(DrawPlane, vtkTypeBool);
146  vtkBooleanMacro(DrawPlane, vtkTypeBool);
148 
150 
153  void SetDrawOutline(vtkTypeBool outline);
154  vtkGetMacro(DrawOutline, vtkTypeBool);
155  vtkBooleanMacro(DrawOutline, vtkTypeBool);
157 
159 
164  void SetDrawIntersectionEdges(vtkTypeBool intersectionEdges);
165  vtkGetMacro(DrawIntersectionEdges, vtkTypeBool);
166  vtkBooleanMacro(DrawIntersectionEdges, vtkTypeBool);
168 
170 
174  vtkSetMacro(OutlineTranslation, vtkTypeBool);
175  vtkGetMacro(OutlineTranslation, vtkTypeBool);
176  vtkBooleanMacro(OutlineTranslation, vtkTypeBool);
178 
180 
184  vtkSetMacro(OutsideBounds, vtkTypeBool);
185  vtkGetMacro(OutsideBounds, vtkTypeBool);
186  vtkBooleanMacro(OutsideBounds, vtkTypeBool);
188 
190 
193  void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
194  void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
195  void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
196  void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
198 
200 
203  bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
205 
207 
213  vtkSetVector6Macro(WidgetBounds, double);
214  vtkGetVector6Macro(WidgetBounds, double);
216 
218 
225  vtkSetMacro(ConstrainToWidgetBounds, vtkTypeBool);
226  vtkGetMacro(ConstrainToWidgetBounds, vtkTypeBool);
227  vtkBooleanMacro(ConstrainToWidgetBounds, vtkTypeBool);
229 
231 
238  vtkSetMacro(ConstrainMaximumSizeToWidgetBounds, vtkTypeBool);
239  vtkGetMacro(ConstrainMaximumSizeToWidgetBounds, vtkTypeBool);
240  vtkBooleanMacro(ConstrainMaximumSizeToWidgetBounds, vtkTypeBool);
241 
243 
246  vtkSetMacro(ScaleEnabled, vtkTypeBool);
247  vtkGetMacro(ScaleEnabled, vtkTypeBool);
248  vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
250 
255  void GetPolyData(vtkPolyData* pd);
256 
261  vtkPolyDataAlgorithm* GetPolyDataAlgorithm();
262 
270  void GetPlane(vtkPlane* plane);
271 
277  void SetPlane(vtkPlane* plane);
278 
283  void UpdatePlacement();
284 
286 
290  vtkGetObjectMacro(NormalProperty, vtkProperty);
291  vtkGetObjectMacro(SelectedNormalProperty, vtkProperty);
293 
295 
299  vtkGetObjectMacro(SphereProperty, vtkProperty);
300  vtkGetObjectMacro(SelectedSphereProperty, vtkProperty);
302 
304 
308  vtkGetObjectMacro(PlaneProperty, vtkProperty);
309  vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
311 
313 
316  vtkGetObjectMacro(OutlineProperty, vtkProperty);
317  vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
319 
321 
325  vtkGetObjectMacro(EdgesProperty, vtkProperty);
326  vtkGetObjectMacro(SelectedEdgesProperty, vtkProperty);
328 
330 
333  vtkGetObjectMacro(IntersectionEdgesProperty, vtkProperty);
335 
337 
342  void SetInteractionColor(double, double, double);
343  void SetInteractionColor(double c[3]) { this->SetInteractionColor(c[0], c[1], c[2]); }
344  void SetHandleColor(double, double, double);
345  void SetHandleColor(double c[3]) { this->SetHandleColor(c[0], c[1], c[2]); }
346  void SetForegroundColor(double, double, double);
347  void SetForegroundColor(double c[3]) { this->SetForegroundColor(c[0], c[1], c[2]); }
349 
350  VTK_DEPRECATED_IN_9_3_0("Please use SetInteractionColor instead.")
351  void SetSelectedWidgetColor(double a, double b, double c) { this->SetInteractionColor(a, b, c); }
352  VTK_DEPRECATED_IN_9_3_0("Please use SetInteractionColor instead.")
353  void SetSelectedWidgetColor(double c[3]) { this->SetInteractionColor(c); }
354  VTK_DEPRECATED_IN_9_3_0("Please use SetHandleColor instead.")
355  void SetUnselectedWidgetColor(double a, double b, double c) { this->SetHandleColor(a, b, c); }
356  VTK_DEPRECATED_IN_9_3_0("Please use SetHandleColor instead.")
357  void SetUnselectedWidgetColor(double c[3]) { this->SetHandleColor(c); }
358 
360 
365  vtkSetClampMacro(BumpDistance, double, 0.000001, 1);
366  vtkGetMacro(BumpDistance, double);
368 
377  void BumpPlane(int dir, double factor);
378 
385  void PushPlane(double distance);
386 
388 
392  vtkGetMacro(PickCameraFocalInfo, bool);
393  vtkSetMacro(PickCameraFocalInfo, bool);
394  vtkBooleanMacro(PickCameraFocalInfo, bool);
396 
404  bool PickOrigin(int X, int Y, bool snapToMeshPoint = false);
405 
413  bool PickNormal(int X, int Y, bool snapToMeshPoint = false);
414 
416 
419  int ComputeInteractionState(int X, int Y, int modify = 0) override;
420  void PlaceWidget(double bounds[6]) override;
421  void BuildRepresentation() override;
422  void StartWidgetInteraction(double eventPos[2]) override;
423  void WidgetInteraction(double newEventPos[2]) override;
424  void EndWidgetInteraction(double newEventPos[2]) override;
426  unsigned long event, void* calldata) override;
428  unsigned long event, void* calldata) override;
430  unsigned long event, void* calldata, int modify = 0) override;
432  unsigned long event, void* calldata) override;
434 
436 
439  double* GetBounds() VTK_SIZEHINT(6) override;
440  void GetActors(vtkPropCollection* pc) override;
441  void ReleaseGraphicsResources(vtkWindow*) override;
442  int RenderOpaqueGeometry(vtkViewport*) override;
443  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
444  vtkTypeBool HasTranslucentPolygonalGeometry() override;
446 
447  // Manage the state of the widget
449  {
450  Outside = 0,
457  Scaling
458  };
459 #if !defined(VTK_LEGACY_REMOVE)
460  VTK_DEPRECATED_IN_9_2_0("because leading underscore is reserved")
462 #endif
463 
465 
474  vtkSetClampMacro(InteractionState, int, Outside, Scaling);
476 
478 
482  virtual void SetRepresentationState(int);
483  vtkGetMacro(RepresentationState, int);
485 
486  // Get the underlying implicit plane object used by this rep
487  // that can be used as a cropping plane in vtkMapper.
488  vtkPlane* GetUnderlyingPlane() { return this->Plane; }
489 
491 
495  vtkGetMacro(SnapToAxes, bool);
496  vtkSetMacro(SnapToAxes, bool);
497  vtkBooleanMacro(SnapToAxes, bool);
499 
501 
507  vtkGetMacro(AlwaysSnapToNearestAxis, bool);
508  virtual void SetAlwaysSnapToNearestAxis(bool snap)
509  {
510  this->AlwaysSnapToNearestAxis = snap;
511  this->SetNormal(this->GetNormal());
512  }
514 
515 protected:
518 
520 
521  // Keep track of event positions
522  double LastEventPosition[3];
523  double LastEventOrientation[4];
524  double StartEventOrientation[4];
525 
526  // Controlling ivars
530 
531  double SnappedEventOrientation[4];
534 
536 
538 
539  // Locking normal to camera
541 
542  // Controlling the push operation
543  double BumpDistance;
544 
546 
547  // The bounding box is represented by a single voxel image data
552  vtkTypeBool OutlineTranslation; // whether the outline can be moved
553  vtkTypeBool ScaleEnabled; // whether the widget can be scaled
554  vtkTypeBool OutsideBounds; // whether the widget can be moved outside input's bounds
555  double WidgetBounds[6];
556  vtkTypeBool ConstrainToWidgetBounds; // whether the widget can be moved outside input's bounds
557  vtkTypeBool ConstrainMaximumSizeToWidgetBounds; // whether the maximum widget size is constrained
558  vtkTypeBool DrawOutline; // whether to draw the outline
559  void HighlightOutline(int highlight);
560 
561  // The plane
568  void HighlightPlane(int highlight);
569 
570  // plane boundary edges are represented as tubes
575  void HighlightEdges(int highlight);
576 
578 
581  void SetEdgesColor(vtkLookupTable*);
582  void SetEdgesColor(double, double, double);
583  void SetEdgesColor(double c[3]);
585 
586  // The intersection edges with the outline
593 
595 
598  void SetIntersectionEdgesColor(vtkLookupTable*);
599  void SetIntersectionEdgesColor(double, double, double);
600  void SetIntersectionEdgesColor(double c[3]);
602 
603  // The + normal cone
607  void HighlightNormal(int highlight);
608 
609  // The normal line
613 
614  // The - normal cone
618 
619  // The origin positioning handle
623  void HighlightSphere(int highlight);
624 
625  // Do the picking
626  vtkNew<vtkHardwarePicker> HardwarePicker; // Used for picking rendered props (screen)
627  vtkNew<vtkCellPicker> CellPicker; // Used for picking widget props (screen and VR)
628  // Compute Cell Picker tolerance
629  void ComputeAdaptivePickerTolerance();
630 
631  // Register internal Pickers within PickingManager
632  void RegisterPickers() override;
633 
634  // Transform the normal (used for rotation)
636 
637  // Methods to manipulate the plane
638  void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
639  void Rotate3D(double* p1, double* p2);
640  void TranslateOutline(double* p1, double* p2);
641  void TranslateOrigin(double* p1, double* p2);
642  void UpdatePose(double* p1, double* d1, double* p2, double* d2);
643  void Push(double* p1, double* p2);
644  void ResizeRadius(double* p1, double* p2, double* vpn);
645  void ResizeRadius3D(double* p1, double* p2);
646  void Scale(double* p1, double* p2, double X, double Y);
647  void SizeHandles();
648 
649  // Properties used to control the appearance of selected objects and
650  // the manipulator in general.
662  virtual void CreateDefaultProperties();
663 
664  // Support GetBounds() method
666 
667 private:
670  void operator=(const vtkDisplaySizedImplicitPlaneRepresentation&) = delete;
671 };
672 
673 VTK_ABI_NAMESPACE_END
674 #endif
virtual void SetAlwaysSnapToNearestAxis(bool snap)
Forces the plane's normal to be aligned with x, y or z axis.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instances of this class.
Cut vtkDataSet with user-specified implicit function.
Definition: vtkCutter.h:60
virtual void EndWidgetInteraction(double newEventPos[2])
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:40
virtual void PlaceWidget(double vtkNotUsed(bounds)[6])
The following is a suggested API for widget representations.
virtual int ComputeInteractionState(int X, int Y, int modify=0)
#define VTK_DOUBLE_MAX
Definition: vtkType.h:154
void SetInteractionColor(double c[3])
Set the color of all the widget's handles (edges, cone1, cone2, line, sphere, selected plane) and the...
abstract specification for Viewports
Definition: vtkViewport.h:44
represent surface properties of a geometric object
Definition: vtkProperty.h:56
virtual void StartWidgetInteraction(double eventPos[2])
virtual double GetRadiusMultiplierMaxValue()
Set/Get the Radius Multiplier value.
#define VTK_DEPRECATED_IN_9_2_0(reason)
virtual int ComputeComplexInteractionState(vtkRenderWindowInteractor *iren, vtkAbstractWidget *widget, unsigned long event, void *callData, int modify=0)
map scalar values into colors via a lookup table
virtual void ComplexInteraction(vtkRenderWindowInteractor *, vtkAbstractWidget *, unsigned long, void *)
virtual void EndComplexInteraction(vtkRenderWindowInteractor *, vtkAbstractWidget *, unsigned long, void *)
virtual void StartComplexInteraction(vtkRenderWindowInteractor *, vtkAbstractWidget *, unsigned long, void *)
generate polygonal cone
Definition: vtkConeSource.h:33
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:49
void SetZTranslationAxisOn()
Toggles constraint translation axis on/off.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
void SetTranslationAxisOff()
Toggles constraint translation axis on/off.
abstract class defines interface between the widget and widget representation classes ...
virtual void BuildRepresentation()=0
Subclasses of vtkWidgetRepresentation must implement these methods.
void SetForegroundColor(double c[3])
Set the color of all the widget's handles (edges, cone1, cone2, line, sphere, selected plane) and the...
void SetHandleColor(double c[3])
Set the color of all the widget's handles (edges, cone1, cone2, line, sphere, selected plane) and the...
double * GetBounds() override
Methods to make this class behave as a vtkProp.
an ordered list of Props
int vtkTypeBool
Definition: vtkABI.h:64
void SetYTranslationAxisOn()
Toggles constraint translation axis on/off.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:27
platform-independent render window interaction including picking and frame rate control.
create wireframe outline for an arbitrary data set or composite dataset
create a polygonal sphere centered at the origin
#define VTK_DEPRECATED_IN_9_3_0(reason)
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
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
perform various plane computations
Definition: vtkPlane.h:25
virtual void WidgetInteraction(double newEventPos[2])
pick a point or snap to point of an actor/prop using graphics hardware
a class defining the representation for a vtkDisplaySizedImplicitPlaneWidget
#define VTK_SIZEHINT(...)
define the API for widget / widget representation
create a line defined by two end points
Definition: vtkLineSource.h:52
map vtkPolyData to graphics primitives
create a disk with hole in center
Definition: vtkDiskSource.h:30
void SetXTranslationAxisOn()
Toggles constraint translation axis on/off.
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:61
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
implicit function for a bounding box
Definition: vtkBox.h:30