VTK  9.3.20240423
vtkImplicitPlaneRepresentation.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
48#ifndef vtkImplicitPlaneRepresentation_h
49#define vtkImplicitPlaneRepresentation_h
50
51#include "vtkInteractionWidgetsModule.h" // For export macro
53#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
54
55VTK_ABI_NAMESPACE_BEGIN
56class vtkActor;
57class vtkBox;
58class vtkCellPicker;
59class vtkConeSource;
60class vtkCutter;
61class vtkFeatureEdges;
62class vtkImageData;
63class vtkLineSource;
64class vtkLookupTable;
66class vtkPlane;
67class vtkPlaneSource;
68class vtkPolyData;
71class vtkProperty;
72class vtkSphereSource;
73class vtkTransform;
74class vtkTubeFilter;
75
76class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkImplicitPlaneRepresentation
78{
79public:
84
86
90 void PrintSelf(ostream& os, vtkIndent indent) override;
92
94
97 void SetOrigin(double x, double y, double z);
98 void SetOrigin(double x[3]);
99 double* GetOrigin() VTK_SIZEHINT(3);
100 void GetOrigin(double xyz[3]);
102
104
107 void SetNormal(double x, double y, double z);
108 void SetNormal(double n[3]);
109 void SetNormalToCamera();
110 double* GetNormal() VTK_SIZEHINT(3);
111 void GetNormal(double xyz[3]);
113
115
122 void SetNormalToXAxis(vtkTypeBool);
123 vtkGetMacro(NormalToXAxis, vtkTypeBool);
124 vtkBooleanMacro(NormalToXAxis, vtkTypeBool);
125 void SetNormalToYAxis(vtkTypeBool);
126 vtkGetMacro(NormalToYAxis, vtkTypeBool);
127 vtkBooleanMacro(NormalToYAxis, vtkTypeBool);
128 void SetNormalToZAxis(vtkTypeBool);
129 vtkGetMacro(NormalToZAxis, vtkTypeBool);
130 vtkBooleanMacro(NormalToZAxis, vtkTypeBool);
132
134
139 virtual void SetLockNormalToCamera(vtkTypeBool);
140 vtkGetMacro(LockNormalToCamera, vtkTypeBool);
141 vtkBooleanMacro(LockNormalToCamera, vtkTypeBool);
143
145
149 vtkSetMacro(Tubing, vtkTypeBool);
150 vtkGetMacro(Tubing, vtkTypeBool);
151 vtkBooleanMacro(Tubing, vtkTypeBool);
153
155
161 void SetDrawPlane(vtkTypeBool plane);
162 vtkGetMacro(DrawPlane, vtkTypeBool);
163 vtkBooleanMacro(DrawPlane, vtkTypeBool);
165
167
170 void SetDrawOutline(vtkTypeBool plane);
171 vtkGetMacro(DrawOutline, vtkTypeBool);
172 vtkBooleanMacro(DrawOutline, vtkTypeBool);
174
176
180 vtkSetMacro(OutlineTranslation, vtkTypeBool);
181 vtkGetMacro(OutlineTranslation, vtkTypeBool);
182 vtkBooleanMacro(OutlineTranslation, vtkTypeBool);
184
186
190 vtkSetMacro(OutsideBounds, vtkTypeBool);
191 vtkGetMacro(OutsideBounds, vtkTypeBool);
192 vtkBooleanMacro(OutsideBounds, vtkTypeBool);
194
196
199 void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
200 void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
201 void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
202 void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
204
206
209 bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
211
213
219 vtkSetVector6Macro(WidgetBounds, double);
220 vtkGetVector6Macro(WidgetBounds, double);
222
224
231 vtkSetMacro(ConstrainToWidgetBounds, vtkTypeBool);
232 vtkGetMacro(ConstrainToWidgetBounds, vtkTypeBool);
233 vtkBooleanMacro(ConstrainToWidgetBounds, vtkTypeBool);
235
237
240 vtkSetMacro(ScaleEnabled, vtkTypeBool);
241 vtkGetMacro(ScaleEnabled, vtkTypeBool);
242 vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
244
250
256
264 void GetPlane(vtkPlane* plane);
265
271 void SetPlane(vtkPlane* plane);
272
278
280
283 vtkGetObjectMacro(NormalProperty, vtkProperty);
284 vtkGetObjectMacro(SelectedNormalProperty, vtkProperty);
286
288
292 vtkGetObjectMacro(PlaneProperty, vtkProperty);
293 vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
295
297
300 vtkGetObjectMacro(OutlineProperty, vtkProperty);
301 vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
303
305
309 vtkGetObjectMacro(EdgesProperty, vtkProperty);
311
313
318 void SetInteractionColor(double, double, double);
319 void SetInteractionColor(double c[3]) { this->SetInteractionColor(c[0], c[1], c[2]); }
320 void SetHandleColor(double, double, double);
321 void SetHandleColor(double c[3]) { this->SetHandleColor(c[0], c[1], c[2]); }
322 void SetForegroundColor(double, double, double);
323 void SetForegroundColor(double c[3]) { this->SetForegroundColor(c[0], c[1], c[2]); }
325
327
331 void SetEdgeColor(double, double, double);
332 void SetEdgeColor(double c[3]);
334
336
341 vtkSetClampMacro(BumpDistance, double, 0.000001, 1);
342 vtkGetMacro(BumpDistance, double);
344
353 void BumpPlane(int dir, double factor);
354
361 void PushPlane(double distance);
362
364
367 int ComputeInteractionState(int X, int Y, int modify = 0) override;
368 void PlaceWidget(double bounds[6]) override;
369 void BuildRepresentation() override;
370 void StartWidgetInteraction(double eventPos[2]) override;
371 void WidgetInteraction(double newEventPos[2]) override;
372 void EndWidgetInteraction(double newEventPos[2]) override;
374 unsigned long event, void* calldata) override;
376 unsigned long event, void* calldata) override;
378 unsigned long event, void* calldata, int modify = 0) override;
380 unsigned long event, void* calldata) override;
382
384
387 double* GetBounds() VTK_SIZEHINT(6) override;
388 void GetActors(vtkPropCollection* pc) override;
389 void ReleaseGraphicsResources(vtkWindow*) override;
390 int RenderOpaqueGeometry(vtkViewport*) override;
391 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
392 vtkTypeBool HasTranslucentPolygonalGeometry() override;
394
395 // Manage the state of the widget
397 {
398 Outside = 0,
404 Scaling
405 };
406
408
417 vtkSetClampMacro(InteractionState, int, Outside, Scaling);
419
421
425 virtual void SetRepresentationState(int);
426 vtkGetMacro(RepresentationState, int);
428
429 // Get the underlying implicit plane object used by this rep
430 // that can be used as a cropping plane in vtkMapper.
431 vtkPlane* GetUnderlyingPlane() { return this->Plane; }
432
434
438 virtual void SetCropPlaneToBoundingBox(bool);
439 vtkGetMacro(CropPlaneToBoundingBox, bool);
440 vtkBooleanMacro(CropPlaneToBoundingBox, bool);
442
444
448 vtkGetMacro(SnapToAxes, bool);
449 vtkSetMacro(SnapToAxes, bool);
451
453
459 vtkGetMacro(AlwaysSnapToNearestAxis, bool);
460 virtual void SetAlwaysSnapToNearestAxis(bool snap)
461 {
462 this->AlwaysSnapToNearestAxis = snap;
463 this->SetNormal(this->GetNormal());
464 }
466
467protected:
470
472
473 // Keep track of event positions
474 double LastEventPosition[3];
475 double LastEventOrientation[4];
476 double StartEventOrientation[4];
477
478 // Controlling ivars
482
483 double SnappedEventOrientation[4];
486
488
489 // Locking normal to camera
491
492 // Controlling the push operation
494
495 // The actual plane which is being manipulated
497
499
500 // The bounding box is represented by a single voxel image data
505 void HighlightOutline(int highlight);
506 vtkTypeBool OutlineTranslation; // whether the outline can be moved
507 vtkTypeBool ScaleEnabled; // whether the widget can be scaled
508 vtkTypeBool OutsideBounds; // whether the widget can be moved outside input's bounds
509 double WidgetBounds[6];
511
512 // The cut plane is produced with a vtkCutter
514 vtkPlaneSource* PlaneSource; // used when plane cropping disabled
519 void HighlightPlane(int highlight);
520
521 // Optional tubes are represented by extracting boundary edges and tubing
526 vtkTypeBool Tubing; // control whether tubing is on
527
528 // The + normal cone
532 void HighlightNormal(int highlight);
533
534 // The normal line
538
539 // The - normal cone
543
544 // The origin positioning handle
548
549 // Do the picking
551
552 // Register internal Pickers within PickingManager
553 void RegisterPickers() override;
554
555 // Transform the normal (used for rotation)
557
558 // Methods to manipulate the plane
559 void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
560 void Rotate3D(double* p1, double* p2);
561 void TranslateOutline(double* p1, double* p2);
562 void TranslateOrigin(double* p1, double* p2);
563 void UpdatePose(double* p1, double* d1, double* p2, double* d2);
564 void Push(double* p1, double* p2);
565 void Scale(double* p1, double* p2, double X, double Y);
567
568 // Properties used to control the appearance of selected objects and
569 // the manipulator in general.
578
580
581 // Support GetBounds() method
583
584private:
586 void operator=(const vtkImplicitPlaneRepresentation&) = delete;
587};
588
589VTK_ABI_NAMESPACE_END
590#endif
define the API for widget / widget representation
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
implicit function for a bounding box
Definition vtkBox.h:110
ray-cast cell picker for all kinds of Prop3Ds
generate polygonal cone
Cut vtkDataSet with user-specified implicit function.
Definition vtkCutter.h:161
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
topologically and geometrically regular array of data
a class defining the representation for a vtkImplicitPlaneWidget2
void Rotate(double X, double Y, double *p1, double *p2, double *vpn)
void SetZTranslationAxisOn()
Toggles constraint translation axis on/off.
void EndWidgetInteraction(double newEventPos[2]) override
Methods to interface with the vtkImplicitPlaneWidget2.
void SetEdgeColor(vtkLookupTable *)
Set color to the edge.
void SetHandleColor(double c[3])
Set the color of all the widget's handles (edges, cone1, cone2, line, sphere, selected plane) and the...
virtual void SetCropPlaneToBoundingBox(bool)
Control if the plane should be drawn cropped by the bounding box or without cropping.
void PlaceWidget(double bounds[6]) override
Methods to interface with the vtkImplicitPlaneWidget2.
void GetPolyData(vtkPolyData *pd)
Grab the polydata that defines the plane.
void SetEdgeColor(double c[3])
Set color to the edge.
void Scale(double *p1, double *p2, double X, double Y)
virtual void CreateDefaultProperties()
vtkPolyDataAlgorithm * GetPolyDataAlgorithm()
Satisfies superclass API.
void HighlightPlane(int highlight)
int ComputeInteractionState(int X, int Y, int modify=0) override
Methods to interface with the vtkImplicitPlaneWidget2.
void SetOrigin(double x[3])
Get the origin of the plane.
void HighlightNormal(int highlight)
void BuildRepresentation() override
Methods to interface with the vtkImplicitPlaneWidget2.
void GetPlane(vtkPlane *plane)
Get the implicit function for the plane by copying the origin and normal of the cut plane into the pr...
void StartComplexInteraction(vtkRenderWindowInteractor *iren, vtkAbstractWidget *widget, unsigned long event, void *calldata) override
Methods to interface with the vtkImplicitPlaneWidget2.
void Push(double *p1, double *p2)
static vtkImplicitPlaneRepresentation * New()
Instantiate the class.
void SetInteractionColor(double, double, double)
Set the color of all the widget's handles (edges, cone1, cone2, line, sphere, selected plane) and the...
virtual void SetAlwaysSnapToNearestAxis(bool snap)
Forces the plane's normal to be aligned with x, y or z axis.
void SetForegroundColor(double c[3])
Set the color of all the widget's handles (edges, cone1, cone2, line, sphere, selected plane) and the...
void UpdatePlacement()
Satisfies the superclass API.
int ComputeComplexInteractionState(vtkRenderWindowInteractor *iren, vtkAbstractWidget *widget, unsigned long event, void *calldata, int modify=0) override
Methods to interface with the vtkImplicitPlaneWidget2.
void EndComplexInteraction(vtkRenderWindowInteractor *iren, vtkAbstractWidget *widget, unsigned long event, void *calldata) override
Methods to interface with the vtkImplicitPlaneWidget2.
void WidgetInteraction(double newEventPos[2]) override
Methods to interface with the vtkImplicitPlaneWidget2.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for the class.
void ComplexInteraction(vtkRenderWindowInteractor *iren, vtkAbstractWidget *widget, unsigned long event, void *calldata) override
Methods to interface with the vtkImplicitPlaneWidget2.
void PushPlane(double distance)
Push the plane the distance specified along the normal.
void SetOrigin(double x, double y, double z)
Get the origin of the plane.
void StartWidgetInteraction(double eventPos[2]) override
Methods to interface with the vtkImplicitPlaneWidget2.
void BumpPlane(int dir, double factor)
Translate the plane in the direction of the normal by the specified BumpDistance.
void TranslateOrigin(double *p1, double *p2)
void SetHandleColor(double, double, double)
Set the color of all the widget's handles (edges, cone1, cone2, line, sphere, selected plane) and the...
double * GetBounds() override
Methods supporting the rendering process.
void SetEdgeColor(double, double, double)
Set color to the edge.
void SetForegroundColor(double, double, double)
Set the color of all the widget's handles (edges, cone1, cone2, line, sphere, selected plane) and the...
void SetTranslationAxisOff()
Toggles constraint translation axis on/off.
virtual void SetRepresentationState(int)
Sets the visual appearance of the representation based on the state it is in.
void UpdatePose(double *p1, double *d1, double *p2, double *d2)
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
void TranslateOutline(double *p1, double *p2)
bool IsTranslationConstrained()
Returns true if ConstrainedAxis.
double * GetOrigin()
Get the origin of the plane.
void HighlightOutline(int highlight)
void SetYTranslationAxisOn()
Toggles constraint translation axis on/off.
void SetPlane(vtkPlane *plane)
Alternative way to define the cutting plane.
~vtkImplicitPlaneRepresentation() override
void SetInteractionColor(double c[3])
Set the color of all the widget's handles (edges, cone1, cone2, line, sphere, selected plane) and the...
void Rotate3D(double *p1, double *p2)
a simple class to control print indentation
Definition vtkIndent.h:108
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
create an array of quadrilaterals located in a plane
perform various plane computations
Definition vtkPlane.h:135
Superclass for algorithms that produce only polydata as output.
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
an ordered list of Props
represent surface properties of a geometric object
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:65
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition vtkWindow.h:48
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO