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
38#ifndef vtkImplicitPlaneRepresentation_h
39#define vtkImplicitPlaneRepresentation_h
40
41#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
42#include "vtkInteractionWidgetsModule.h" // For export macro
43#include "vtkLegacy.h" // for VTK_LEGACY_REMOVE
45
46VTK_ABI_NAMESPACE_BEGIN
47class vtkActor;
48class vtkBox;
49class vtkCellPicker;
50class vtkConeSource;
51class vtkCutter;
52class vtkFeatureEdges;
53class vtkImageData;
54class vtkLineSource;
55class vtkLookupTable;
57class vtkPlane;
58class vtkPlaneSource;
59class vtkPolyData;
62class vtkProperty;
63class vtkSphereSource;
64class vtkTransform;
65class vtkTubeFilter;
66
67class VTKINTERACTIONWIDGETS_EXPORT vtkImplicitPlaneRepresentation : public vtkWidgetRepresentation
68{
69public:
74
76
80 void PrintSelf(ostream& os, vtkIndent indent) override;
82
84
87 void SetOrigin(double x, double y, double z);
88 void SetOrigin(double x[3]);
89 double* GetOrigin() VTK_SIZEHINT(3);
90 void GetOrigin(double xyz[3]);
92
94
97 void SetNormal(double x, double y, double z);
98 void SetNormal(double n[3]);
99 void SetNormalToCamera();
100 double* GetNormal() VTK_SIZEHINT(3);
101 void GetNormal(double xyz[3]);
103
105
112 void SetNormalToXAxis(vtkTypeBool);
113 vtkGetMacro(NormalToXAxis, vtkTypeBool);
114 vtkBooleanMacro(NormalToXAxis, vtkTypeBool);
115 void SetNormalToYAxis(vtkTypeBool);
116 vtkGetMacro(NormalToYAxis, vtkTypeBool);
117 vtkBooleanMacro(NormalToYAxis, vtkTypeBool);
118 void SetNormalToZAxis(vtkTypeBool);
119 vtkGetMacro(NormalToZAxis, vtkTypeBool);
120 vtkBooleanMacro(NormalToZAxis, vtkTypeBool);
122
124
129 virtual void SetLockNormalToCamera(vtkTypeBool);
130 vtkGetMacro(LockNormalToCamera, vtkTypeBool);
131 vtkBooleanMacro(LockNormalToCamera, vtkTypeBool);
133
135
139 vtkSetMacro(Tubing, vtkTypeBool);
140 vtkGetMacro(Tubing, vtkTypeBool);
141 vtkBooleanMacro(Tubing, vtkTypeBool);
143
145
151 void SetDrawPlane(vtkTypeBool plane);
152 vtkGetMacro(DrawPlane, vtkTypeBool);
153 vtkBooleanMacro(DrawPlane, vtkTypeBool);
155
157
160 void SetDrawOutline(vtkTypeBool plane);
161 vtkGetMacro(DrawOutline, vtkTypeBool);
162 vtkBooleanMacro(DrawOutline, vtkTypeBool);
164
166
170 vtkSetMacro(OutlineTranslation, vtkTypeBool);
171 vtkGetMacro(OutlineTranslation, vtkTypeBool);
172 vtkBooleanMacro(OutlineTranslation, vtkTypeBool);
174
176
180 vtkSetMacro(OutsideBounds, vtkTypeBool);
181 vtkGetMacro(OutsideBounds, vtkTypeBool);
182 vtkBooleanMacro(OutsideBounds, vtkTypeBool);
184
186
189 void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
190 void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
191 void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
192 void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
194
196
199 bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
201
203
209 vtkSetVector6Macro(WidgetBounds, double);
210 vtkGetVector6Macro(WidgetBounds, double);
212
214
221 vtkSetMacro(ConstrainToWidgetBounds, vtkTypeBool);
222 vtkGetMacro(ConstrainToWidgetBounds, vtkTypeBool);
223 vtkBooleanMacro(ConstrainToWidgetBounds, vtkTypeBool);
225
227
230 vtkSetMacro(ScaleEnabled, vtkTypeBool);
231 vtkGetMacro(ScaleEnabled, vtkTypeBool);
232 vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
234
240
246
254 void GetPlane(vtkPlane* plane);
255
261 void SetPlane(vtkPlane* plane);
262
268
270
273 vtkGetObjectMacro(NormalProperty, vtkProperty);
274 vtkGetObjectMacro(SelectedNormalProperty, vtkProperty);
276
278
282 vtkGetObjectMacro(PlaneProperty, vtkProperty);
283 vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
285
287
290 vtkGetObjectMacro(OutlineProperty, vtkProperty);
291 vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
293
295
299 vtkGetObjectMacro(EdgesProperty, vtkProperty);
301
303
308 void SetInteractionColor(double, double, double);
309 void SetInteractionColor(double c[3]) { this->SetInteractionColor(c[0], c[1], c[2]); }
310 void SetHandleColor(double, double, double);
311 void SetHandleColor(double c[3]) { this->SetHandleColor(c[0], c[1], c[2]); }
312 void SetForegroundColor(double, double, double);
313 void SetForegroundColor(double c[3]) { this->SetForegroundColor(c[0], c[1], c[2]); }
315
317
321 void SetEdgeColor(double, double, double);
322 void SetEdgeColor(double c[3]);
324
326
331 vtkSetClampMacro(BumpDistance, double, 0.000001, 1);
332 vtkGetMacro(BumpDistance, double);
334
343 void BumpPlane(int dir, double factor);
344
351 void PushPlane(double distance);
352
354
357 int ComputeInteractionState(int X, int Y, int modify = 0) override;
358 void PlaceWidget(double bounds[6]) override;
359 void BuildRepresentation() override;
360 void StartWidgetInteraction(double eventPos[2]) override;
361 void WidgetInteraction(double newEventPos[2]) override;
362 void EndWidgetInteraction(double newEventPos[2]) override;
364 unsigned long event, void* calldata) override;
366 unsigned long event, void* calldata) override;
368 unsigned long event, void* calldata, int modify = 0) override;
370 unsigned long event, void* calldata) override;
372
374
377 double* GetBounds() VTK_SIZEHINT(6) override;
378 void GetActors(vtkPropCollection* pc) override;
379 void ReleaseGraphicsResources(vtkWindow*) override;
380 int RenderOpaqueGeometry(vtkViewport*) override;
381 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
382 vtkTypeBool HasTranslucentPolygonalGeometry() override;
384
385 // Manage the state of the widget
387 {
388 Outside = 0,
394 Scaling
395 };
396#if !defined(VTK_LEGACY_REMOVE)
397 VTK_DEPRECATED_IN_9_2_0("because leading underscore is reserved")
399#endif
400
402
411 vtkSetClampMacro(InteractionState, int, Outside, Scaling);
413
415
419 virtual void SetRepresentationState(int);
420 vtkGetMacro(RepresentationState, int);
422
423 // Get the underlying implicit plane object used by this rep
424 // that can be used as a cropping plane in vtkMapper.
425 vtkPlane* GetUnderlyingPlane() { return this->Plane; }
426
428
432 virtual void SetCropPlaneToBoundingBox(bool);
433 vtkGetMacro(CropPlaneToBoundingBox, bool);
434 vtkBooleanMacro(CropPlaneToBoundingBox, bool);
436
438
442 vtkGetMacro(SnapToAxes, bool);
443 vtkSetMacro(SnapToAxes, bool);
445
447
453 vtkGetMacro(AlwaysSnapToNearestAxis, bool);
454 virtual void SetAlwaysSnapToNearestAxis(bool snap)
455 {
456 this->AlwaysSnapToNearestAxis = snap;
457 this->SetNormal(this->GetNormal());
458 }
460
461protected:
464
466
467 // Keep track of event positions
468 double LastEventPosition[3];
469 double LastEventOrientation[4];
470 double StartEventOrientation[4];
471
472 // Controlling ivars
476
477 double SnappedEventOrientation[4];
480
482
483 // Locking normal to camera
485
486 // Controlling the push operation
488
489 // The actual plane which is being manipulated
491
493
494 // The bounding box is represented by a single voxel image data
499 void HighlightOutline(int highlight);
500 vtkTypeBool OutlineTranslation; // whether the outline can be moved
501 vtkTypeBool ScaleEnabled; // whether the widget can be scaled
502 vtkTypeBool OutsideBounds; // whether the widget can be moved outside input's bounds
503 double WidgetBounds[6];
505
506 // The cut plane is produced with a vtkCutter
508 vtkPlaneSource* PlaneSource; // used when plane cropping disabled
513 void HighlightPlane(int highlight);
514
515 // Optional tubes are represented by extracting boundary edges and tubing
520 vtkTypeBool Tubing; // control whether tubing is on
521
522 // The + normal cone
526 void HighlightNormal(int highlight);
527
528 // The normal line
532
533 // The - normal cone
537
538 // The origin positioning handle
542
543 // Do the picking
545
546 // Register internal Pickers within PickingManager
547 void RegisterPickers() override;
548
549 // Transform the normal (used for rotation)
551
552 // Methods to manipulate the plane
553 void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
554 void Rotate3D(double* p1, double* p2);
555 void TranslateOutline(double* p1, double* p2);
556 void TranslateOrigin(double* p1, double* p2);
557 void UpdatePose(double* p1, double* d1, double* p2, double* d2);
558 void Push(double* p1, double* p2);
559 void Scale(double* p1, double* p2, double X, double Y);
561
562 // Properties used to control the appearance of selected objects and
563 // the manipulator in general.
572
574
575 // Support GetBounds() method
577
578private:
580 void operator=(const vtkImplicitPlaneRepresentation&) = delete;
581};
582
583VTK_ABI_NAMESPACE_END
584#endif
define the API for widget / widget representation
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:50
implicit function for a bounding box
Definition vtkBox.h:40
ray-cast cell picker for all kinds of Prop3Ds
generate polygonal cone
Cut vtkDataSet with user-specified implicit function.
Definition vtkCutter.h:70
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:38
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:35
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:89
an ordered list of Props
represent surface properties of a geometric object
Definition vtkProperty.h:66
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:54
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition vtkWindow.h:34
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_DEPRECATED_IN_9_2_0(reason)
#define VTK_SIZEHINT(...)