VTK  9.2.6
vtkDisplaySizedImplicitPlaneRepresentation.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkDisplaySizedImplicitPlaneRepresentation.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 =========================================================================*/
40 #ifndef vtkDisplaySizedImplicitPlaneRepresentation_h
41 #define vtkDisplaySizedImplicitPlaneRepresentation_h
42 
43 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
44 #include "vtkInteractionWidgetsModule.h" // For export macro
45 #include "vtkNew.h" // For vtkNew command
47 
48 class vtkActor;
49 class vtkBox;
50 class vtkCellPicker;
51 class vtkConeSource;
52 class vtkCutter;
53 class vtkDiskSource;
54 class vtkFeatureEdges;
55 class vtkHardwarePicker;
56 class vtkImageData;
57 class vtkLineSource;
58 class vtkLookupTable;
59 class vtkOutlineFilter;
60 class vtkPlane;
61 class vtkPolyData;
63 class vtkPolyDataMapper;
64 class vtkProperty;
65 class vtkSphereSource;
66 class vtkTransform;
67 class vtkTubeFilter;
68 
69 class VTKINTERACTIONWIDGETS_EXPORT vtkDisplaySizedImplicitPlaneRepresentation
71 {
72 public:
77 
79 
83  void PrintSelf(ostream& os, vtkIndent indent) override;
85 
87 
90  void SetOrigin(double x, double y, double z);
91  void SetOrigin(double x[3]);
92  double* GetOrigin() VTK_SIZEHINT(3);
93  void GetOrigin(double xyz[3]);
95 
97 
100  void SetNormal(double x, double y, double z);
101  void SetNormal(double n[3]);
102  void SetNormalToCamera();
103  double* GetNormal() VTK_SIZEHINT(3);
104  void GetNormal(double xyz[3]);
106 
108 
115  void SetNormalToXAxis(vtkTypeBool);
116  vtkGetMacro(NormalToXAxis, vtkTypeBool);
117  vtkBooleanMacro(NormalToXAxis, vtkTypeBool);
118  void SetNormalToYAxis(vtkTypeBool);
119  vtkGetMacro(NormalToYAxis, vtkTypeBool);
120  vtkBooleanMacro(NormalToYAxis, vtkTypeBool);
121  void SetNormalToZAxis(vtkTypeBool);
122  vtkGetMacro(NormalToZAxis, vtkTypeBool);
123  vtkBooleanMacro(NormalToZAxis, vtkTypeBool);
125 
127 
132  virtual void SetLockNormalToCamera(vtkTypeBool);
133  vtkGetMacro(LockNormalToCamera, vtkTypeBool);
134  vtkBooleanMacro(LockNormalToCamera, vtkTypeBool);
136 
138 
141  virtual void SetRadiusMultiplier(double radiusMultiplier);
142  virtual double GetRadiusMultiplierMinValue() { return 0.000001; }
143  virtual double GetRadiusMultiplierMaxValue() { return VTK_DOUBLE_MAX; }
144  vtkGetMacro(RadiusMultiplier, double);
146 
148 
154  void SetDrawPlane(vtkTypeBool plane);
155  vtkGetMacro(DrawPlane, vtkTypeBool);
156  vtkBooleanMacro(DrawPlane, vtkTypeBool);
158 
160 
163  void SetDrawOutline(vtkTypeBool outline);
164  vtkGetMacro(DrawOutline, vtkTypeBool);
165  vtkBooleanMacro(DrawOutline, vtkTypeBool);
167 
169 
174  void SetDrawIntersectionEdges(vtkTypeBool intersectionEdges);
175  vtkGetMacro(DrawIntersectionEdges, vtkTypeBool);
176  vtkBooleanMacro(DrawIntersectionEdges, vtkTypeBool);
178 
180 
184  vtkSetMacro(OutlineTranslation, vtkTypeBool);
185  vtkGetMacro(OutlineTranslation, vtkTypeBool);
186  vtkBooleanMacro(OutlineTranslation, vtkTypeBool);
188 
190 
194  vtkSetMacro(OutsideBounds, vtkTypeBool);
195  vtkGetMacro(OutsideBounds, vtkTypeBool);
196  vtkBooleanMacro(OutsideBounds, vtkTypeBool);
198 
200 
203  void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
204  void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
205  void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
206  void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
208 
210 
213  bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
215 
217 
223  vtkSetVector6Macro(WidgetBounds, double);
224  vtkGetVector6Macro(WidgetBounds, double);
226 
228 
235  vtkSetMacro(ConstrainToWidgetBounds, vtkTypeBool);
236  vtkGetMacro(ConstrainToWidgetBounds, vtkTypeBool);
237  vtkBooleanMacro(ConstrainToWidgetBounds, vtkTypeBool);
239 
241 
248  vtkSetMacro(ConstrainMaximumSizeToWidgetBounds, vtkTypeBool);
249  vtkGetMacro(ConstrainMaximumSizeToWidgetBounds, vtkTypeBool);
250  vtkBooleanMacro(ConstrainMaximumSizeToWidgetBounds, vtkTypeBool);
251 
253 
256  vtkSetMacro(ScaleEnabled, vtkTypeBool);
257  vtkGetMacro(ScaleEnabled, vtkTypeBool);
258  vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
260 
265  void GetPolyData(vtkPolyData* pd);
266 
271  vtkPolyDataAlgorithm* GetPolyDataAlgorithm();
272 
280  void GetPlane(vtkPlane* plane);
281 
287  void SetPlane(vtkPlane* plane);
288 
293  void UpdatePlacement();
294 
296 
300  vtkGetObjectMacro(NormalProperty, vtkProperty);
301  vtkGetObjectMacro(SelectedNormalProperty, vtkProperty);
303 
305 
309  vtkGetObjectMacro(SphereProperty, vtkProperty);
310  vtkGetObjectMacro(SelectedSphereProperty, vtkProperty);
312 
314 
318  vtkGetObjectMacro(PlaneProperty, vtkProperty);
319  vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
321 
323 
326  vtkGetObjectMacro(OutlineProperty, vtkProperty);
327  vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
329 
331 
335  vtkGetObjectMacro(EdgesProperty, vtkProperty);
336  vtkGetObjectMacro(SelectedEdgesProperty, vtkProperty);
338 
340 
343  vtkGetObjectMacro(IntersectionEdgesProperty, vtkProperty);
345 
347 
351  void SetSelectedWidgetColor(double, double, double);
352  void SetSelectedWidgetColor(double c[3]);
353  void SetUnselectedWidgetColor(double, double, double);
354  void SetUnselectedWidgetColor(double c[3]);
356 
358 
363  vtkSetClampMacro(BumpDistance, double, 0.000001, 1);
364  vtkGetMacro(BumpDistance, double);
366 
375  void BumpPlane(int dir, double factor);
376 
383  void PushPlane(double distance);
384 
386 
390  vtkGetMacro(PickCameraFocalInfo, bool);
391  vtkSetMacro(PickCameraFocalInfo, bool);
392  vtkBooleanMacro(PickCameraFocalInfo, bool);
394 
402  bool PickOrigin(int X, int Y, bool snapToMeshPoint = false);
403 
411  bool PickNormal(int X, int Y, bool snapToMeshPoint = false);
412 
414 
417  int ComputeInteractionState(int X, int Y, int modify = 0) override;
418  void PlaceWidget(double bounds[6]) override;
419  void BuildRepresentation() override;
420  void StartWidgetInteraction(double eventPos[2]) override;
421  void WidgetInteraction(double newEventPos[2]) override;
422  void EndWidgetInteraction(double newEventPos[2]) override;
424  unsigned long event, void* calldata) override;
426  unsigned long event, void* calldata) override;
428  unsigned long event, void* calldata, int modify = 0) override;
430  unsigned long event, void* calldata) override;
432 
434 
437  double* GetBounds() VTK_SIZEHINT(6) override;
438  void GetActors(vtkPropCollection* pc) override;
439  void ReleaseGraphicsResources(vtkWindow*) override;
440  int RenderOpaqueGeometry(vtkViewport*) override;
441  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
442  vtkTypeBool HasTranslucentPolygonalGeometry() override;
444 
445  // Manage the state of the widget
447  {
448  Outside = 0,
455  Scaling
456  };
457 #if !defined(VTK_LEGACY_REMOVE)
458  VTK_DEPRECATED_IN_9_2_0("because leading underscore is reserved")
460 #endif
461 
463 
472  vtkSetClampMacro(InteractionState, int, Outside, Scaling);
474 
476 
480  virtual void SetRepresentationState(int);
481  vtkGetMacro(RepresentationState, int);
483 
484  // Get the underlying implicit plane object used by this rep
485  // that can be used as a cropping plane in vtkMapper.
486  vtkPlane* GetUnderlyingPlane() { return this->Plane; }
487 
489 
493  vtkGetMacro(SnapToAxes, bool);
494  vtkSetMacro(SnapToAxes, bool);
495  vtkBooleanMacro(SnapToAxes, bool);
497 
499 
505  vtkGetMacro(AlwaysSnapToNearestAxis, bool);
506  virtual void SetAlwaysSnapToNearestAxis(bool snap)
507  {
508  this->AlwaysSnapToNearestAxis = snap;
509  this->SetNormal(this->GetNormal());
510  }
512 
513 protected:
516 
518 
519  // Keep track of event positions
520  double LastEventPosition[3];
521  double LastEventOrientation[4];
522  double StartEventOrientation[4];
523 
524  // Controlling ivars
528 
529  double SnappedEventOrientation[4];
532 
534 
536 
537  // Locking normal to camera
539 
540  // Controlling the push operation
541  double BumpDistance;
542 
544 
545  // The bounding box is represented by a single voxel image data
550  vtkTypeBool OutlineTranslation; // whether the outline can be moved
551  vtkTypeBool ScaleEnabled; // whether the widget can be scaled
552  vtkTypeBool OutsideBounds; // whether the widget can be moved outside input's bounds
553  double WidgetBounds[6];
554  vtkTypeBool ConstrainToWidgetBounds; // whether the widget can be moved outside input's bounds
555  vtkTypeBool ConstrainMaximumSizeToWidgetBounds; // whether the maximum widget size is constrained
556  vtkTypeBool DrawOutline; // whether to draw the outline
557  void HighlightOutline(int highlight);
558 
559  // The plane
566  void HighlightPlane(int highlight);
567 
568  // plane boundary edges are represented as tubes
573  void HighlightEdges(int highlight);
574 
576 
579  void SetEdgesColor(vtkLookupTable*);
580  void SetEdgesColor(double, double, double);
581  void SetEdgesColor(double c[3]);
583 
584  // The intersection edges with the outline
591 
593 
596  void SetIntersectionEdgesColor(vtkLookupTable*);
597  void SetIntersectionEdgesColor(double, double, double);
598  void SetIntersectionEdgesColor(double c[3]);
600 
601  // The + normal cone
605  void HighlightNormal(int highlight);
606 
607  // The normal line
611 
612  // The - normal cone
616 
617  // The origin positioning handle
621  void HighlightSphere(int highlight);
622 
623  // Do the picking
624  vtkNew<vtkHardwarePicker> HardwarePicker; // Used for picking rendered props (screen)
625  vtkNew<vtkCellPicker> CellPicker; // Used for picking widget props (screen and VR)
626  // Compute Cell Picker tolerance
627  void ComputeAdaptivePickerTolerance();
628 
629  // Register internal Pickers within PickingManager
630  void RegisterPickers() override;
631 
632  // Transform the normal (used for rotation)
634 
635  // Methods to manipulate the plane
636  void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
637  void Rotate3D(double* p1, double* p2);
638  void TranslateOutline(double* p1, double* p2);
639  void TranslateOrigin(double* p1, double* p2);
640  void UpdatePose(double* p1, double* d1, double* p2, double* d2);
641  void Push(double* p1, double* p2);
642  void ResizeRadius(double* p1, double* p2, double* vpn);
643  void ResizeRadius3D(double* p1, double* p2);
644  void Scale(double* p1, double* p2, double X, double Y);
645  void SizeHandles();
646 
647  // Properties used to control the appearance of selected objects and
648  // the manipulator in general.
660  virtual void CreateDefaultProperties();
661 
662  // Support GetBounds() method
664 
665 private:
668  void operator=(const vtkDisplaySizedImplicitPlaneRepresentation&) = delete;
669 };
670 
671 #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:73
virtual void EndWidgetInteraction(double newEventPos[2])
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
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:165
abstract specification for Viewports
Definition: vtkViewport.h:55
represent surface properties of a geometric object
Definition: vtkProperty.h:67
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:44
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
void SetZTranslationAxisOn()
Toggles constraint translation axis on/off.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:90
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.
double * GetBounds() override
Methods to make this class behave as a vtkProp.
an ordered list of Props
int vtkTypeBool
Definition: vtkABI.h:69
void SetYTranslationAxisOn()
Toggles constraint translation axis on/off.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:38
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:85
a simple class to control print indentation
Definition: vtkIndent.h:39
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:53
perform various plane computations
Definition: vtkPlane.h:36
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:63
map vtkPolyData to graphics primitives
create a disk with hole in center
Definition: vtkDiskSource.h:41
void SetXTranslationAxisOn()
Toggles constraint translation axis on/off.
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:72
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:41