VTK  9.4.20241121
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
51#ifndef vtkImplicitPlaneRepresentation_h
52#define vtkImplicitPlaneRepresentation_h
53
54#include "vtkInteractionWidgetsModule.h" // For export macro
56#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
57
58VTK_ABI_NAMESPACE_BEGIN
59class vtkActor;
60class vtkBox;
61class vtkCellPicker;
62class vtkConeSource;
63class vtkCutter;
64class vtkFeatureEdges;
65class vtkImageData;
66class vtkLineSource;
67class vtkLookupTable;
69class vtkPlane;
70class vtkPlaneSource;
71class vtkPolyData;
74class vtkProperty;
75class vtkSphereSource;
76class vtkTransform;
77class vtkTubeFilter;
78
79class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkImplicitPlaneRepresentation
81{
82public:
87
89
93 void PrintSelf(ostream& os, vtkIndent indent) override;
95
97
100 void SetOrigin(double x, double y, double z);
101 void SetOrigin(double x[3]);
103 void GetOrigin(double xyz[3]);
105
107
110 void SetNormal(double x, double y, double z);
111 void SetNormal(double n[3]);
112 void SetNormalToCamera();
113 double* GetNormal() VTK_SIZEHINT(3);
114 void GetNormal(double xyz[3]);
116
118
125 void SetNormalToXAxis(vtkTypeBool);
126 vtkGetMacro(NormalToXAxis, vtkTypeBool);
127 vtkBooleanMacro(NormalToXAxis, vtkTypeBool);
128 void SetNormalToYAxis(vtkTypeBool);
129 vtkGetMacro(NormalToYAxis, vtkTypeBool);
130 vtkBooleanMacro(NormalToYAxis, vtkTypeBool);
131 void SetNormalToZAxis(vtkTypeBool);
132 vtkGetMacro(NormalToZAxis, vtkTypeBool);
133 vtkBooleanMacro(NormalToZAxis, vtkTypeBool);
135
137
142 virtual void SetLockNormalToCamera(vtkTypeBool);
143 vtkGetMacro(LockNormalToCamera, vtkTypeBool);
144 vtkBooleanMacro(LockNormalToCamera, vtkTypeBool);
146
148
152 vtkSetMacro(Tubing, vtkTypeBool);
153 vtkGetMacro(Tubing, vtkTypeBool);
154 vtkBooleanMacro(Tubing, vtkTypeBool);
156
158
164 void SetDrawPlane(vtkTypeBool plane);
165 vtkGetMacro(DrawPlane, vtkTypeBool);
166 vtkBooleanMacro(DrawPlane, vtkTypeBool);
168
170
173 void SetDrawOutline(vtkTypeBool plane);
174 vtkGetMacro(DrawOutline, vtkTypeBool);
175 vtkBooleanMacro(DrawOutline, vtkTypeBool);
177
179
183 vtkSetMacro(OutlineTranslation, vtkTypeBool);
184 vtkGetMacro(OutlineTranslation, vtkTypeBool);
185 vtkBooleanMacro(OutlineTranslation, vtkTypeBool);
187
189
193 vtkSetMacro(OutsideBounds, vtkTypeBool);
194 vtkGetMacro(OutsideBounds, vtkTypeBool);
195 vtkBooleanMacro(OutsideBounds, vtkTypeBool);
197
199
202 void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
203 void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
204 void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
205 void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
207
209
212 bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
214
216
222 vtkSetVector6Macro(WidgetBounds, double);
223 vtkGetVector6Macro(WidgetBounds, double);
225
227
234 vtkSetMacro(ConstrainToWidgetBounds, vtkTypeBool);
235 vtkGetMacro(ConstrainToWidgetBounds, vtkTypeBool);
236 vtkBooleanMacro(ConstrainToWidgetBounds, vtkTypeBool);
238
240
243 vtkSetMacro(ScaleEnabled, vtkTypeBool);
244 vtkGetMacro(ScaleEnabled, vtkTypeBool);
245 vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
247
253
259
268 void GetPlane(vtkPlane* plane);
269
276 void SetPlane(vtkPlane* plane);
277
282 void UpdatePlacement();
283
285
288 vtkGetObjectMacro(NormalProperty, vtkProperty);
289 vtkGetObjectMacro(SelectedNormalProperty, vtkProperty);
291
293
297 vtkGetObjectMacro(PlaneProperty, vtkProperty);
298 vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
300
302
305 vtkGetObjectMacro(OutlineProperty, vtkProperty);
306 vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
308
310
314 vtkGetObjectMacro(EdgesProperty, vtkProperty);
316
318
323 void SetInteractionColor(double, double, double);
324 void SetInteractionColor(double c[3]) { this->SetInteractionColor(c[0], c[1], c[2]); }
325 void SetHandleColor(double, double, double);
326 void SetHandleColor(double c[3]) { this->SetHandleColor(c[0], c[1], c[2]); }
327 void SetForegroundColor(double, double, double);
328 void SetForegroundColor(double c[3]) { this->SetForegroundColor(c[0], c[1], c[2]); }
330
332
336 void SetEdgeColor(double, double, double);
337 void SetEdgeColor(double c[3]);
339
341
346 vtkSetClampMacro(BumpDistance, double, 0.000001, 1);
347 vtkGetMacro(BumpDistance, double);
349
358 void BumpPlane(int dir, double factor);
359
366 void PushPlane(double distance);
367
369
372 int ComputeInteractionState(int X, int Y, int modify = 0) override;
373 void PlaceWidget(double bounds[6]) override;
374 void BuildRepresentation() override;
375 void StartWidgetInteraction(double eventPos[2]) override;
376 void WidgetInteraction(double newEventPos[2]) override;
377 void EndWidgetInteraction(double newEventPos[2]) override;
379 unsigned long event, void* calldata) override;
381 unsigned long event, void* calldata) override;
383 unsigned long event, void* calldata, int modify = 0) override;
385 unsigned long event, void* calldata) override;
387
389
392 double* GetBounds() VTK_SIZEHINT(6) override;
393 void GetActors(vtkPropCollection* pc) override;
394 void ReleaseGraphicsResources(vtkWindow*) override;
395 int RenderOpaqueGeometry(vtkViewport*) override;
396 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
397 vtkTypeBool HasTranslucentPolygonalGeometry() override;
399
400 // Manage the state of the widget
402 {
403 Outside = 0,
409 Scaling
410 };
411
413
422 vtkSetClampMacro(InteractionState, int, Outside, Scaling);
424
426
430 virtual void SetRepresentationState(int);
431 vtkGetMacro(RepresentationState, int);
433
434 // Get the underlying implicit plane object used by this rep
435 // that can be used as a cropping plane in vtkMapper.
436 vtkPlane* GetUnderlyingPlane() { return this->Plane; }
437
439
443 virtual void SetCropPlaneToBoundingBox(bool);
444 vtkGetMacro(CropPlaneToBoundingBox, bool);
445 vtkBooleanMacro(CropPlaneToBoundingBox, bool);
447
449
453 vtkGetMacro(SnapToAxes, bool);
454 vtkSetMacro(SnapToAxes, bool);
456
458
464 vtkGetMacro(AlwaysSnapToNearestAxis, bool);
465 virtual void SetAlwaysSnapToNearestAxis(bool snap)
466 {
467 this->AlwaysSnapToNearestAxis = snap;
468 this->SetNormal(this->GetNormal());
469 }
471
472protected:
475
477
478 // Keep track of event positions
479 double LastEventPosition[3];
480 double LastEventOrientation[4];
481 double StartEventOrientation[4];
482
483 // Controlling ivars
487
488 double SnappedEventOrientation[4];
491
493
494 // Locking normal to camera
496
497 // Controlling the push operation
499
500 // The actual plane which is being manipulated
502
504
505 // The bounding box is represented by a single voxel image data
510 void HighlightOutline(int highlight);
511 vtkTypeBool OutlineTranslation; // whether the outline can be moved
512 vtkTypeBool ScaleEnabled; // whether the widget can be scaled
513 vtkTypeBool OutsideBounds; // whether the widget can be moved outside input's bounds
514 double WidgetBounds[6];
516
517 // The cut plane is produced with a vtkCutter
519 vtkPlaneSource* PlaneSource; // used when plane cropping disabled
524 void HighlightPlane(int highlight);
525
526 // Optional tubes are represented by extracting boundary edges and tubing
531 vtkTypeBool Tubing; // control whether tubing is on
532
533 // The + normal cone
537 void HighlightNormal(int highlight);
538
539 // The normal line
543
544 // The - normal cone
548
549 // The origin positioning handle
553
554 // Do the picking
556
557 // Register internal Pickers within PickingManager
558 void RegisterPickers() override;
559
560 // Transform the normal (used for rotation)
562
563 // Methods to manipulate the plane
564 void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
565 void Rotate3D(double* p1, double* p2);
566 void TranslateOutline(double* p1, double* p2);
567 void TranslateOrigin(double* p1, double* p2);
568 void UpdatePose(double* p1, double* d1, double* p2, double* d2);
569 void Push(double* p1, double* p2);
570 void Scale(double* p1, double* p2, double X, double Y);
572
573 // Properties used to control the appearance of selected objects and
574 // the manipulator in general.
583
585
586 // Support GetBounds() method
588
589private:
591 void operator=(const vtkImplicitPlaneRepresentation&) = delete;
592};
593
594VTK_ABI_NAMESPACE_END
595#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 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.
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...
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.
~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:138
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_MARSHAL_EXCLUDE_REASON_IS_INTERNAL
#define VTK_MARSHALAUTO
#define VTK_MARSHALEXCLUDE(reason)