VTK  9.3.0
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
29#ifndef vtkImplicitPlaneRepresentation_h
30#define vtkImplicitPlaneRepresentation_h
31
32#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
33#include "vtkInteractionWidgetsModule.h" // For export macro
34#include "vtkLegacy.h" // for VTK_LEGACY_REMOVE
36
37VTK_ABI_NAMESPACE_BEGIN
38class vtkActor;
39class vtkBox;
40class vtkCellPicker;
41class vtkConeSource;
42class vtkCutter;
43class vtkFeatureEdges;
44class vtkImageData;
45class vtkLineSource;
46class vtkLookupTable;
48class vtkPlane;
49class vtkPlaneSource;
50class vtkPolyData;
53class vtkProperty;
54class vtkSphereSource;
55class vtkTransform;
56class vtkTubeFilter;
57
58class VTKINTERACTIONWIDGETS_EXPORT vtkImplicitPlaneRepresentation : public vtkWidgetRepresentation
59{
60public:
65
67
71 void PrintSelf(ostream& os, vtkIndent indent) override;
73
75
78 void SetOrigin(double x, double y, double z);
79 void SetOrigin(double x[3]);
80 double* GetOrigin() VTK_SIZEHINT(3);
81 void GetOrigin(double xyz[3]);
83
85
88 void SetNormal(double x, double y, double z);
89 void SetNormal(double n[3]);
90 void SetNormalToCamera();
91 double* GetNormal() VTK_SIZEHINT(3);
92 void GetNormal(double xyz[3]);
94
96
103 void SetNormalToXAxis(vtkTypeBool);
104 vtkGetMacro(NormalToXAxis, vtkTypeBool);
105 vtkBooleanMacro(NormalToXAxis, vtkTypeBool);
106 void SetNormalToYAxis(vtkTypeBool);
107 vtkGetMacro(NormalToYAxis, vtkTypeBool);
108 vtkBooleanMacro(NormalToYAxis, vtkTypeBool);
109 void SetNormalToZAxis(vtkTypeBool);
110 vtkGetMacro(NormalToZAxis, vtkTypeBool);
111 vtkBooleanMacro(NormalToZAxis, vtkTypeBool);
113
115
120 virtual void SetLockNormalToCamera(vtkTypeBool);
121 vtkGetMacro(LockNormalToCamera, vtkTypeBool);
122 vtkBooleanMacro(LockNormalToCamera, vtkTypeBool);
124
126
130 vtkSetMacro(Tubing, vtkTypeBool);
131 vtkGetMacro(Tubing, vtkTypeBool);
132 vtkBooleanMacro(Tubing, vtkTypeBool);
134
136
142 void SetDrawPlane(vtkTypeBool plane);
143 vtkGetMacro(DrawPlane, vtkTypeBool);
144 vtkBooleanMacro(DrawPlane, vtkTypeBool);
146
148
151 void SetDrawOutline(vtkTypeBool plane);
152 vtkGetMacro(DrawOutline, vtkTypeBool);
153 vtkBooleanMacro(DrawOutline, vtkTypeBool);
155
157
161 vtkSetMacro(OutlineTranslation, vtkTypeBool);
162 vtkGetMacro(OutlineTranslation, vtkTypeBool);
163 vtkBooleanMacro(OutlineTranslation, vtkTypeBool);
165
167
171 vtkSetMacro(OutsideBounds, vtkTypeBool);
172 vtkGetMacro(OutsideBounds, vtkTypeBool);
173 vtkBooleanMacro(OutsideBounds, vtkTypeBool);
175
177
180 void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
181 void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
182 void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
183 void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
185
187
190 bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
192
194
200 vtkSetVector6Macro(WidgetBounds, double);
201 vtkGetVector6Macro(WidgetBounds, double);
203
205
212 vtkSetMacro(ConstrainToWidgetBounds, vtkTypeBool);
213 vtkGetMacro(ConstrainToWidgetBounds, vtkTypeBool);
214 vtkBooleanMacro(ConstrainToWidgetBounds, vtkTypeBool);
216
218
221 vtkSetMacro(ScaleEnabled, vtkTypeBool);
222 vtkGetMacro(ScaleEnabled, vtkTypeBool);
223 vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
225
231
237
245 void GetPlane(vtkPlane* plane);
246
252 void SetPlane(vtkPlane* plane);
253
259
261
264 vtkGetObjectMacro(NormalProperty, vtkProperty);
265 vtkGetObjectMacro(SelectedNormalProperty, vtkProperty);
267
269
273 vtkGetObjectMacro(PlaneProperty, vtkProperty);
274 vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
276
278
281 vtkGetObjectMacro(OutlineProperty, vtkProperty);
282 vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
284
286
290 vtkGetObjectMacro(EdgesProperty, vtkProperty);
292
294
299 void SetInteractionColor(double, double, double);
300 void SetInteractionColor(double c[3]) { this->SetInteractionColor(c[0], c[1], c[2]); }
301 void SetHandleColor(double, double, double);
302 void SetHandleColor(double c[3]) { this->SetHandleColor(c[0], c[1], c[2]); }
303 void SetForegroundColor(double, double, double);
304 void SetForegroundColor(double c[3]) { this->SetForegroundColor(c[0], c[1], c[2]); }
306
308
312 void SetEdgeColor(double, double, double);
313 void SetEdgeColor(double c[3]);
315
317
322 vtkSetClampMacro(BumpDistance, double, 0.000001, 1);
323 vtkGetMacro(BumpDistance, double);
325
334 void BumpPlane(int dir, double factor);
335
342 void PushPlane(double distance);
343
345
348 int ComputeInteractionState(int X, int Y, int modify = 0) override;
349 void PlaceWidget(double bounds[6]) override;
350 void BuildRepresentation() override;
351 void StartWidgetInteraction(double eventPos[2]) override;
352 void WidgetInteraction(double newEventPos[2]) override;
353 void EndWidgetInteraction(double newEventPos[2]) override;
355 unsigned long event, void* calldata) override;
357 unsigned long event, void* calldata) override;
359 unsigned long event, void* calldata, int modify = 0) override;
361 unsigned long event, void* calldata) override;
363
365
368 double* GetBounds() VTK_SIZEHINT(6) override;
369 void GetActors(vtkPropCollection* pc) override;
370 void ReleaseGraphicsResources(vtkWindow*) override;
371 int RenderOpaqueGeometry(vtkViewport*) override;
372 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
373 vtkTypeBool HasTranslucentPolygonalGeometry() override;
375
376 // Manage the state of the widget
378 {
379 Outside = 0,
385 Scaling
386 };
387#if !defined(VTK_LEGACY_REMOVE)
388 VTK_DEPRECATED_IN_9_2_0("because leading underscore is reserved")
390#endif
391
393
402 vtkSetClampMacro(InteractionState, int, Outside, Scaling);
404
406
410 virtual void SetRepresentationState(int);
411 vtkGetMacro(RepresentationState, int);
413
414 // Get the underlying implicit plane object used by this rep
415 // that can be used as a cropping plane in vtkMapper.
416 vtkPlane* GetUnderlyingPlane() { return this->Plane; }
417
419
423 virtual void SetCropPlaneToBoundingBox(bool);
424 vtkGetMacro(CropPlaneToBoundingBox, bool);
425 vtkBooleanMacro(CropPlaneToBoundingBox, bool);
427
429
433 vtkGetMacro(SnapToAxes, bool);
434 vtkSetMacro(SnapToAxes, bool);
436
438
444 vtkGetMacro(AlwaysSnapToNearestAxis, bool);
445 virtual void SetAlwaysSnapToNearestAxis(bool snap)
446 {
447 this->AlwaysSnapToNearestAxis = snap;
448 this->SetNormal(this->GetNormal());
449 }
451
452protected:
455
457
458 // Keep track of event positions
459 double LastEventPosition[3];
460 double LastEventOrientation[4];
461 double StartEventOrientation[4];
462
463 // Controlling ivars
467
468 double SnappedEventOrientation[4];
471
473
474 // Locking normal to camera
476
477 // Controlling the push operation
479
480 // The actual plane which is being manipulated
482
484
485 // The bounding box is represented by a single voxel image data
490 void HighlightOutline(int highlight);
491 vtkTypeBool OutlineTranslation; // whether the outline can be moved
492 vtkTypeBool ScaleEnabled; // whether the widget can be scaled
493 vtkTypeBool OutsideBounds; // whether the widget can be moved outside input's bounds
494 double WidgetBounds[6];
496
497 // The cut plane is produced with a vtkCutter
499 vtkPlaneSource* PlaneSource; // used when plane cropping disabled
504 void HighlightPlane(int highlight);
505
506 // Optional tubes are represented by extracting boundary edges and tubing
511 vtkTypeBool Tubing; // control whether tubing is on
512
513 // The + normal cone
517 void HighlightNormal(int highlight);
518
519 // The normal line
523
524 // The - normal cone
528
529 // The origin positioning handle
533
534 // Do the picking
536
537 // Register internal Pickers within PickingManager
538 void RegisterPickers() override;
539
540 // Transform the normal (used for rotation)
542
543 // Methods to manipulate the plane
544 void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
545 void Rotate3D(double* p1, double* p2);
546 void TranslateOutline(double* p1, double* p2);
547 void TranslateOrigin(double* p1, double* p2);
548 void UpdatePose(double* p1, double* d1, double* p2, double* d2);
549 void Push(double* p1, double* p2);
550 void Scale(double* p1, double* p2, double X, double Y);
552
553 // Properties used to control the appearance of selected objects and
554 // the manipulator in general.
563
565
566 // Support GetBounds() method
568
569private:
571 void operator=(const vtkImplicitPlaneRepresentation&) = delete;
572};
573
574VTK_ABI_NAMESPACE_END
575#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
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:29
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: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_2_0(reason)
#define VTK_SIZEHINT(...)