VTK  9.2.5
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 
155  vtkGetMacro(DrawPlane, vtkTypeBool);
156  vtkBooleanMacro(DrawPlane, vtkTypeBool);
158 
160 
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 
266 
272 
280  void GetPlane(vtkPlane* plane);
281 
287  void SetPlane(vtkPlane* plane);
288 
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 
580  void SetEdgesColor(double, double, double);
581  void SetEdgesColor(double c[3]);
583 
584  // The intersection edges with the outline
591 
593 
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
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
define the API for widget / widget representation
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:161
implicit function for a bounding box
Definition: vtkBox.h:141
ray-cast cell picker for all kinds of Prop3Ds
generate polygonal cone
Cut vtkDataSet with user-specified implicit function.
Definition: vtkCutter.h:173
create a disk with hole in center
a class defining the representation for a vtkDisplaySizedImplicitPlaneWidget
void SetSelectedWidgetColor(double, double, double)
Set the color of all the widgets objects (edges, cone1, cone2, line, sphere, except plane) when unsel...
void BumpPlane(int dir, double factor)
Translate the plane in the direction of the normal by the specified BumpDistance.
double * GetBounds() override
Methods supporting the rendering process.
void ResizeRadius(double *p1, double *p2, double *vpn)
void SetTranslationAxisOff()
Toggles constraint translation axis on/off.
void Push(double *p1, double *p2)
void SetZTranslationAxisOn()
Toggles constraint translation axis on/off.
void TranslateOutline(double *p1, double *p2)
void SetDrawIntersectionEdges(vtkTypeBool intersectionEdges)
Enable/disable the drawing of the intersection edges.
void Rotate(double X, double Y, double *p1, double *p2, double *vpn)
virtual void SetAlwaysSnapToNearestAxis(bool snap)
Forces the plane's normal to be aligned with x, y or z axis.
void SetUnselectedWidgetColor(double c[3])
Set the color of all the widgets objects (edges, cone1, cone2, line, sphere, except plane) when unsel...
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for the class.
void SetUnselectedWidgetColor(double, double, double)
Set the color of all the widgets objects (edges, cone1, cone2, line, sphere, except plane) when unsel...
void SetIntersectionEdgesColor(double c[3])
Set color to the intersection edges.
void Rotate3D(double *p1, double *p2)
virtual void SetRepresentationState(int)
Sets the visual appearance of the representation based on the state it is in.
int ComputeInteractionState(int X, int Y, int modify=0) override
Methods to interface with the vtkDisplaySizedImplicitPlaneWidget.
void SetOrigin(double x[3])
Set/Get the origin of the plane.
bool PickOrigin(int X, int Y, bool snapToMeshPoint=false)
Given the X, Y display coordinates, pick a new origin for the plane from a point that is on the objec...
void UpdatePose(double *p1, double *d1, double *p2, double *d2)
vtkPolyDataAlgorithm * GetPolyDataAlgorithm()
Satisfies superclass API.
void BuildRepresentation() override
Methods to interface with the vtkDisplaySizedImplicitPlaneWidget.
void GetPlane(vtkPlane *plane)
Get the implicit function for the plane by copying the origin and normal of the cut plane into the pr...
bool PickNormal(int X, int Y, bool snapToMeshPoint=false)
Given the X, Y display coordinates, pick a new normal for the plane from a point that is on the objec...
void SetSelectedWidgetColor(double c[3])
Set the color of all the widgets objects (edges, cone1, cone2, line, sphere, except plane) when unsel...
void SetEdgesColor(vtkLookupTable *)
Set color to the edges.
void StartComplexInteraction(vtkRenderWindowInteractor *iren, vtkAbstractWidget *widget, unsigned long event, void *calldata) override
Methods to interface with the vtkDisplaySizedImplicitPlaneWidget.
int ComputeComplexInteractionState(vtkRenderWindowInteractor *iren, vtkAbstractWidget *widget, unsigned long event, void *calldata, int modify=0) override
Methods to interface with the vtkDisplaySizedImplicitPlaneWidget.
void UpdatePlacement()
Satisfies the superclass API.
void SetIntersectionEdgesColor(vtkLookupTable *)
Set color to the intersection edges.
void SetIntersectionEdgesColor(double, double, double)
Set color to the intersection edges.
void PlaceWidget(double bounds[6]) override
Methods to interface with the vtkDisplaySizedImplicitPlaneWidget.
void SetXTranslationAxisOn()
Toggles constraint translation axis on/off.
void TranslateOrigin(double *p1, double *p2)
void GetPolyData(vtkPolyData *pd)
Grab the polydata that defines the plane.
virtual double GetRadiusMultiplierMaxValue()
Set/Get the Radius Multiplier value.
void SetDrawOutline(vtkTypeBool outline)
Enable/disable the drawing of the outline.
void PushPlane(double distance)
Push the plane the distance specified along the normal.
void WidgetInteraction(double newEventPos[2]) override
Methods to interface with the vtkDisplaySizedImplicitPlaneWidget.
void SetPlane(vtkPlane *plane)
Alternative way to define the cutting plane.
void SetEdgesColor(double c[3])
Set color to the edges.
void SetDrawPlane(vtkTypeBool plane)
Enable/disable the drawing of the plane.
void ComplexInteraction(vtkRenderWindowInteractor *iren, vtkAbstractWidget *widget, unsigned long event, void *calldata) override
Methods to interface with the vtkDisplaySizedImplicitPlaneWidget.
void SetOrigin(double x, double y, double z)
Set/Get the origin of the plane.
void StartWidgetInteraction(double eventPos[2]) override
Methods to interface with the vtkDisplaySizedImplicitPlaneWidget.
void Scale(double *p1, double *p2, double X, double Y)
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
void SetYTranslationAxisOn()
Toggles constraint translation axis on/off.
void ResizeRadius3D(double *p1, double *p2)
void SetEdgesColor(double, double, double)
Set color to the edges.
static vtkDisplaySizedImplicitPlaneRepresentation * New()
Instantiate the class.
void EndWidgetInteraction(double newEventPos[2]) override
Methods to interface with the vtkDisplaySizedImplicitPlaneWidget.
void EndComplexInteraction(vtkRenderWindowInteractor *iren, vtkAbstractWidget *widget, unsigned long event, void *calldata) override
Methods to interface with the vtkDisplaySizedImplicitPlaneWidget.
double * GetOrigin()
Set/Get the origin of the plane.
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
pick a point or snap to point of an actor/prop using graphics hardware
topologically and geometrically regular array of data
Definition: vtkImageData.h:163
a simple class to control print indentation
Definition: vtkIndent.h:119
create a line defined by two end points
map scalar values into colors via a lookup table
create wireframe outline for an arbitrary data set or composite dataset
perform various plane computations
Definition: vtkPlane.h:146
Superclass for algorithms that produce only polydata as output.
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:200
an ordered list of Props
represent surface properties of a geometric object
Definition: vtkProperty.h:177
platform-independent render window interaction including picking and frame rate control.
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:170
filter that generates tubes around lines
abstract specification for Viewports
Definition: vtkViewport.h:56
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition: vtkWindow.h:39
@ dir
Definition: vtkX3D.h:330
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_DEPRECATED_IN_9_2_0(reason)
#define VTK_DOUBLE_MAX
Definition: vtkType.h:165
#define VTK_SIZEHINT(...)