VTK  9.7.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 "vtkInteractionWidgetsModule.h" // For export macro
32 #include "vtkNew.h" // For vtkNew command
34 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
35 
36 VTK_ABI_NAMESPACE_BEGIN
37 class vtkActor;
38 class vtkBox;
39 class vtkCellPicker;
40 class vtkConeSource;
41 class vtkCutter;
42 class vtkDiskSource;
43 class vtkFeatureEdges;
44 class vtkHardwarePicker;
45 class vtkImageData;
46 class vtkLineSource;
47 class vtkLookupTable;
48 class vtkOutlineFilter;
49 class vtkPlane;
50 class vtkPolyData;
52 class vtkPolyDataMapper;
53 class vtkProperty;
54 class vtkSphereSource;
55 class vtkTransform;
56 class vtkTubeFilter;
57 
60 {
61 public:
66 
68 
72  void PrintSelf(ostream& os, vtkIndent indent) override;
74 
76 
79  void SetOrigin(double x, double y, double z);
80  void SetOrigin(double x[3]);
81  double* GetOrigin() VTK_SIZEHINT(3);
82  void GetOrigin(double xyz[3]);
84 
86 
89  void SetNormal(double x, double y, double z);
90  void SetNormal(double n[3]);
91  void SetNormalToCamera();
92  double* GetNormal() VTK_SIZEHINT(3);
93  void GetNormal(double xyz[3]);
95 
97 
104  void SetNormalToXAxis(vtkTypeBool);
105  vtkGetMacro(NormalToXAxis, vtkTypeBool);
106  vtkBooleanMacro(NormalToXAxis, vtkTypeBool);
107  void SetNormalToYAxis(vtkTypeBool);
108  vtkGetMacro(NormalToYAxis, vtkTypeBool);
109  vtkBooleanMacro(NormalToYAxis, vtkTypeBool);
110  void SetNormalToZAxis(vtkTypeBool);
111  vtkGetMacro(NormalToZAxis, vtkTypeBool);
112  vtkBooleanMacro(NormalToZAxis, vtkTypeBool);
114 
116 
121  virtual void SetLockNormalToCamera(vtkTypeBool);
122  vtkGetMacro(LockNormalToCamera, vtkTypeBool);
123  vtkBooleanMacro(LockNormalToCamera, vtkTypeBool);
125 
127 
130  virtual void SetRadiusMultiplier(double radiusMultiplier);
131  virtual double GetRadiusMultiplierMinValue() { return 0.000001; }
132  virtual double GetRadiusMultiplierMaxValue() { return VTK_DOUBLE_MAX; }
133  vtkGetMacro(RadiusMultiplier, double);
135 
137 
143  void SetDrawPlane(vtkTypeBool plane);
144  vtkGetMacro(DrawPlane, vtkTypeBool);
145  vtkBooleanMacro(DrawPlane, vtkTypeBool);
147 
149 
152  void SetDrawOutline(vtkTypeBool outline);
153  vtkGetMacro(DrawOutline, vtkTypeBool);
154  vtkBooleanMacro(DrawOutline, vtkTypeBool);
156 
158 
163  void SetDrawIntersectionEdges(vtkTypeBool intersectionEdges);
164  vtkGetMacro(DrawIntersectionEdges, vtkTypeBool);
165  vtkBooleanMacro(DrawIntersectionEdges, vtkTypeBool);
167 
169 
173  vtkSetMacro(OutlineTranslation, vtkTypeBool);
174  vtkGetMacro(OutlineTranslation, vtkTypeBool);
175  vtkBooleanMacro(OutlineTranslation, vtkTypeBool);
177 
179 
183  vtkSetMacro(OutsideBounds, vtkTypeBool);
184  vtkGetMacro(OutsideBounds, vtkTypeBool);
185  vtkBooleanMacro(OutsideBounds, vtkTypeBool);
187 
189 
192  void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
193  void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
194  void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
195  void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
197 
199 
202  bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
204 
206 
212  vtkSetVector6Macro(WidgetBounds, double);
213  vtkGetVector6Macro(WidgetBounds, double);
215 
217 
224  vtkSetMacro(ConstrainToWidgetBounds, vtkTypeBool);
225  vtkGetMacro(ConstrainToWidgetBounds, vtkTypeBool);
226  vtkBooleanMacro(ConstrainToWidgetBounds, vtkTypeBool);
228 
230 
237  vtkSetMacro(ConstrainMaximumSizeToWidgetBounds, vtkTypeBool);
238  vtkGetMacro(ConstrainMaximumSizeToWidgetBounds, vtkTypeBool);
239  vtkBooleanMacro(ConstrainMaximumSizeToWidgetBounds, vtkTypeBool);
240 
242 
245  vtkSetMacro(ScaleEnabled, vtkTypeBool);
246  vtkGetMacro(ScaleEnabled, vtkTypeBool);
247  vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
249 
254  void GetPolyData(vtkPolyData* pd);
255 
260  vtkPolyDataAlgorithm* GetPolyDataAlgorithm();
261 
270  void GetPlane(vtkPlane* plane);
271 
278  void SetPlane(vtkPlane* plane);
279 
284  void UpdatePlacement();
285 
287 
291  vtkGetObjectMacro(NormalProperty, vtkProperty);
292  vtkGetObjectMacro(SelectedNormalProperty, vtkProperty);
294 
296 
300  vtkGetObjectMacro(SphereProperty, vtkProperty);
301  vtkGetObjectMacro(SelectedSphereProperty, vtkProperty);
303 
305 
309  vtkGetObjectMacro(PlaneProperty, vtkProperty);
310  vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
312 
314 
317  vtkGetObjectMacro(OutlineProperty, vtkProperty);
318  vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
320 
322 
326  vtkGetObjectMacro(EdgesProperty, vtkProperty);
327  vtkGetObjectMacro(SelectedEdgesProperty, vtkProperty);
329 
331 
334  vtkGetObjectMacro(IntersectionEdgesProperty, vtkProperty);
336 
338 
343  void SetInteractionColor(double, double, double);
344  void SetInteractionColor(double c[3]) { this->SetInteractionColor(c[0], c[1], c[2]); }
345  void SetHandleColor(double, double, double);
346  void SetHandleColor(double c[3]) { this->SetHandleColor(c[0], c[1], c[2]); }
347  void SetForegroundColor(double, double, double);
348  void SetForegroundColor(double c[3]) { this->SetForegroundColor(c[0], c[1], c[2]); }
350 
352 
357  vtkSetClampMacro(BumpDistance, double, 0.000001, 1);
358  vtkGetMacro(BumpDistance, double);
360 
369  void BumpPlane(int dir, double factor);
370 
377  void PushPlane(double distance);
378 
380 
384  vtkGetMacro(PickCameraFocalInfo, bool);
385  vtkSetMacro(PickCameraFocalInfo, bool);
386  vtkBooleanMacro(PickCameraFocalInfo, bool);
388 
396  bool PickOrigin(int X, int Y, bool snapToMeshPoint = false);
397 
405  bool PickNormal(int X, int Y, bool snapToMeshPoint = false);
406 
408 
411  int ComputeInteractionState(int X, int Y, int modify = 0) override;
412  void PlaceWidget(double bounds[6]) override;
413  void BuildRepresentation() override;
414  void StartWidgetInteraction(double eventPos[2]) override;
415  void WidgetInteraction(double newEventPos[2]) override;
416  void EndWidgetInteraction(double newEventPos[2]) override;
418  unsigned long event, void* calldata) override;
420  unsigned long event, void* calldata) override;
422  unsigned long event, void* calldata, int modify = 0) override;
424  unsigned long event, void* calldata) override;
426 
428 
431  double* GetBounds() VTK_SIZEHINT(6) override;
432  void GetActors(vtkPropCollection* pc) override;
433  void ReleaseGraphicsResources(vtkWindow*) override;
434  int RenderOpaqueGeometry(vtkViewport*) override;
435  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
436  vtkTypeBool HasTranslucentPolygonalGeometry() override;
438 
439  // Manage the state of the widget
441  {
442  Outside = 0,
449  Scaling
450  };
451 
453 
462  vtkSetClampMacro(InteractionState, int, Outside, Scaling);
464 
466 
470  virtual void SetRepresentationState(int);
471  vtkGetMacro(RepresentationState, int);
473 
474  // Get the underlying implicit plane object used by this rep
475  // that can be used as a cropping plane in vtkMapper.
476  vtkPlane* GetUnderlyingPlane() { return this->Plane; }
477 
479 
483  vtkGetMacro(SnapToAxes, bool);
484  vtkSetMacro(SnapToAxes, bool);
485  vtkBooleanMacro(SnapToAxes, bool);
487 
489 
495  vtkGetMacro(AlwaysSnapToNearestAxis, bool);
496  virtual void SetAlwaysSnapToNearestAxis(bool snap)
497  {
498  this->AlwaysSnapToNearestAxis = snap;
499  this->SetNormal(this->GetNormal());
500  }
502 
503 protected:
506 
508 
509  // Keep track of event positions
510  double LastEventPosition[3];
511  double LastEventOrientation[4];
512  double StartEventOrientation[4];
513 
514  // Controlling ivars
518 
519  double SnappedEventOrientation[4];
522 
524 
526 
527  // Locking normal to camera
529 
530  // Controlling the push operation
531  double BumpDistance;
532 
534 
535  // The bounding box is represented by a single voxel image data
540  vtkTypeBool OutlineTranslation; // whether the outline can be moved
541  vtkTypeBool ScaleEnabled; // whether the widget can be scaled
542  vtkTypeBool OutsideBounds; // whether the widget can be moved outside input's bounds
543  double WidgetBounds[6];
544  vtkTypeBool ConstrainToWidgetBounds; // whether the widget can be moved outside input's bounds
545  vtkTypeBool ConstrainMaximumSizeToWidgetBounds; // whether the maximum widget size is constrained
546  vtkTypeBool DrawOutline; // whether to draw the outline
547  void HighlightOutline(int highlight);
548 
549  // The plane
556  void HighlightPlane(int highlight);
557 
558  // plane boundary edges are represented as tubes
563  void HighlightEdges(int highlight);
564 
566 
569  void SetEdgesColor(vtkLookupTable*);
570  void SetEdgesColor(double, double, double);
571  void SetEdgesColor(double c[3]);
573 
574  // The intersection edges with the outline
581 
583 
586  void SetIntersectionEdgesColor(vtkLookupTable*);
587  void SetIntersectionEdgesColor(double, double, double);
588  void SetIntersectionEdgesColor(double c[3]);
590 
591  // The + normal cone
595  void HighlightNormal(int highlight);
596 
597  // The normal line
601 
602  // The - normal cone
606 
607  // The origin positioning handle
611  void HighlightSphere(int highlight);
612 
613  // Do the picking
614  vtkNew<vtkHardwarePicker> HardwarePicker; // Used for picking rendered props (screen)
615  vtkNew<vtkCellPicker> CellPicker; // Used for picking widget props (screen and VR)
616  // Compute Cell Picker tolerance
617  void ComputeAdaptivePickerTolerance();
618 
619  // Register internal Pickers within PickingManager
620  void RegisterPickers() override;
621 
622  // Transform the normal (used for rotation)
624 
625  // Methods to manipulate the plane
626  void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
627  void Rotate3D(double* p1, double* p2);
628  void TranslateOutline(double* p1, double* p2);
629  void TranslateOrigin(double* p1, double* p2);
630  void UpdatePose(double* p1, double* d1, double* p2, double* d2);
631  void Push(double* p1, double* p2);
632  void ResizeRadius(double* p1, double* p2, double* vpn);
633  void ResizeRadius3D(double* p1, double* p2);
634  void Scale(double* p1, double* p2, double X, double Y);
635  void SizeHandles();
636 
637  // Properties used to control the appearance of selected objects and
638  // the manipulator in general.
650  virtual void CreateDefaultProperties();
651 
652  // Support GetBounds() method
654 
655 private:
658  void operator=(const vtkDisplaySizedImplicitPlaneRepresentation&) = delete;
659 };
660 
661 VTK_ABI_NAMESPACE_END
662 #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:61
virtual void EndWidgetInteraction(double newEventPos[2])
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:41
virtual void PlaceWidget(double 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:202
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:46
represent surface properties of a geometric object
Definition: vtkProperty.h:59
virtual void StartWidgetInteraction(double eventPos[2])
virtual double GetRadiusMultiplierMaxValue()
Set/Get the Radius Multiplier value.
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:34
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:50
void SetZTranslationAxisOn()
Toggles constraint translation axis on/off.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
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:41
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
Superclass for algorithms that produce only polydata as output.
filter that generates tubes around lines
Definition: vtkTubeFilter.h:75
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:45
perform various plane computations
Definition: vtkPlane.h:31
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 VTK_MARSHALEXCLUDE(reason)
define the API for widget / widget representation
create a line defined by two end points
Definition: vtkLineSource.h:53
map vtkPolyData to graphics primitives
create a disk with hole in center
Definition: vtkDiskSource.h:34
void SetXTranslationAxisOn()
Toggles constraint translation axis on/off.
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:62
#define VTK_MARSHALAUTO
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
#define VTK_MARSHAL_EXCLUDE_REASON_IS_INTERNAL