VTK  9.3.0
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
37VTK_ABI_NAMESPACE_BEGIN
38class vtkActor;
39class vtkBox;
40class vtkCellPicker;
41class vtkConeSource;
42class vtkCutter;
43class vtkDiskSource;
44class vtkFeatureEdges;
46class vtkImageData;
47class vtkLineSource;
48class vtkLookupTable;
50class vtkPlane;
51class vtkPolyData;
54class vtkProperty;
55class vtkSphereSource;
56class vtkTransform;
57class vtkTubeFilter;
58
59class VTKINTERACTIONWIDGETS_EXPORT vtkDisplaySizedImplicitPlaneRepresentation
61{
62public:
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
145 vtkGetMacro(DrawPlane, vtkTypeBool);
146 vtkBooleanMacro(DrawPlane, vtkTypeBool);
148
150
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
256
262
270 void GetPlane(vtkPlane* plane);
271
277 void SetPlane(vtkPlane* plane);
278
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
515protected:
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
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
582 void SetEdgesColor(double, double, double);
583 void SetEdgesColor(double c[3]);
585
586 // The intersection edges with the outline
593
595
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
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);
648
649 // Properties used to control the appearance of selected objects and
650 // the manipulator in general.
663
664 // Support GetBounds() method
666
667private:
670 void operator=(const vtkDisplaySizedImplicitPlaneRepresentation&) = delete;
671};
672
673VTK_ABI_NAMESPACE_END
674#endif
define the API for widget / widget representation
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:41
implicit function for a bounding box
Definition vtkBox.h:31
ray-cast cell picker for all kinds of Prop3Ds
generate polygonal cone
Cut vtkDataSet with user-specified implicit function.
Definition vtkCutter.h:61
create a disk with hole in center
a class defining the representation for a vtkDisplaySizedImplicitPlaneWidget
void SetHandleColor(double, double, double)
Set the color of all the widget's handles (edges, cone1, cone2, line, sphere, selected plane) and the...
void BumpPlane(int dir, double factor)
Translate the plane in the direction of the normal by the specified BumpDistance.
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 PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for the class.
void SetIntersectionEdgesColor(double c[3])
Set color to the intersection edges.
double * GetOrigin()
Set/Get the origin of the plane.
void SetInteractionColor(double, double, double)
Set the color of all the widget's handles (edges, cone1, cone2, line, sphere, selected plane) and the...
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)
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...
vtkPolyDataAlgorithm * GetPolyDataAlgorithm()
Satisfies superclass API.
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.
double * GetBounds() override
Methods supporting the rendering process.
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.
static vtkDisplaySizedImplicitPlaneRepresentation * New()
Instantiate the class.
void SetXTranslationAxisOn()
Toggles constraint translation axis on/off.
void TranslateOrigin(double *p1, double *p2)
void SetHandleColor(double c[3])
Set the color of all the widget's handles (edges, cone1, cone2, line, sphere, selected plane) and the...
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 SetInteractionColor(double c[3])
Set the color of all the widget's handles (edges, cone1, cone2, line, sphere, selected plane) and the...
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 SetForegroundColor(double, double, double)
Set the color of all the widget's handles (edges, cone1, cone2, line, sphere, selected plane) and the...
void SetOrigin(double x, double y, double z)
Set/Get the origin of the plane.
void SetForegroundColor(double c[3])
Set the color of all the widget's handles (edges, cone1, cone2, line, sphere, selected plane) and the...
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.
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.
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
a simple class to control print indentation
Definition vtkIndent.h:29
create a line defined by two end points
map scalar values into colors via a lookup table
Allocate and hold a VTK object.
Definition vtkNew.h:51
create wireframe outline for an arbitrary data set or composite dataset
perform various plane computations
Definition vtkPlane.h:26
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:80
an ordered list of Props
represent surface properties of a geometric object
Definition vtkProperty.h:57
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
filter that generates tubes around lines
abstract specification for Viewports
Definition vtkViewport.h:45
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition vtkWindow.h:25
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_DEPRECATED_IN_9_3_0(reason)
#define VTK_DEPRECATED_IN_9_2_0(reason)
#define VTK_DOUBLE_MAX
Definition vtkType.h:154
#define VTK_SIZEHINT(...)