VTK  9.4.20250113
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
55#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
182 vtkSetMacro(ScaleEnabled, vtkTypeBool);
183 vtkGetMacro(ScaleEnabled, vtkTypeBool);
184 vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
186
191 void GetPolyData(vtkPolyData* pd);
192
197 vtkPolyDataAlgorithm* GetPolyDataAlgorithm();
198
207 void GetPlane(vtkPlane* plane);
208
215 void SetPlane(vtkPlane* plane);
216
221 void UpdatePlacement();
222
224
227 vtkGetObjectMacro(NormalProperty, vtkProperty);
228 vtkGetObjectMacro(SelectedNormalProperty, vtkProperty);
230
232
236 vtkGetObjectMacro(PlaneProperty, vtkProperty);
237 vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
239
241
245 vtkGetObjectMacro(EdgesProperty, vtkProperty);
247
249
254 void SetInteractionColor(double, double, double);
255 void SetInteractionColor(double c[3]) { this->SetInteractionColor(c[0], c[1], c[2]); }
256 void SetHandleColor(double, double, double);
257 void SetHandleColor(double c[3]) { this->SetHandleColor(c[0], c[1], c[2]); }
258 void SetForegroundColor(double, double, double);
259 void SetForegroundColor(double c[3]) { this->SetForegroundColor(c[0], c[1], c[2]); }
261
263
267 void SetEdgeColor(double, double, double);
268 void SetEdgeColor(double c[3]);
270
272
277 vtkSetClampMacro(BumpDistance, double, 0.000001, 1);
278 vtkGetMacro(BumpDistance, double);
280
289 void BumpPlane(int dir, double factor);
290
297 void PushPlane(double distance);
298
300
303 int ComputeInteractionState(int X, int Y, int modify = 0) override;
304 void PlaceWidget(double bounds[6]) override;
305 void BuildRepresentation() override;
306 void StartWidgetInteraction(double eventPos[2]) override;
307 void WidgetInteraction(double newEventPos[2]) override;
308 void EndWidgetInteraction(double newEventPos[2]) override;
310 unsigned long event, void* calldata) override;
312 unsigned long event, void* calldata) override;
314 unsigned long event, void* calldata, int modify = 0) override;
316 unsigned long event, void* calldata) override;
318
320
323 double* GetBounds() VTK_SIZEHINT(6) override;
324 void GetActors(vtkPropCollection* pc) override;
325 void ReleaseGraphicsResources(vtkWindow*) override;
326 int RenderOpaqueGeometry(vtkViewport*) override;
327 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
328 vtkTypeBool HasTranslucentPolygonalGeometry() override;
330
331 // Manage the state of the widget
333 {
334 Outside = 0,
340 Scaling
341 };
342
344
353 vtkSetClampMacro(InteractionState, int, Outside, Scaling);
355
357
361 virtual void SetRepresentationState(int);
362 vtkGetMacro(RepresentationState, int);
364
365 // Get the underlying implicit plane object used by this rep
366 // that can be used as a cropping plane in vtkMapper.
367 vtkPlane* GetUnderlyingPlane() { return this->Plane; }
368
370
374 virtual void SetCropPlaneToBoundingBox(bool);
375 vtkGetMacro(CropPlaneToBoundingBox, bool);
376 vtkBooleanMacro(CropPlaneToBoundingBox, bool);
378
380
384 vtkGetMacro(SnapToAxes, bool);
385 vtkSetMacro(SnapToAxes, bool);
387
389
395 vtkGetMacro(AlwaysSnapToNearestAxis, bool);
396 virtual void SetAlwaysSnapToNearestAxis(bool snap)
397 {
398 this->AlwaysSnapToNearestAxis = snap;
399 this->SetNormal(this->GetNormal());
400 }
402
403protected:
406
408
409 // Keep track of event positions
410 double LastEventPosition[3];
411 double LastEventOrientation[4];
412 double StartEventOrientation[4];
413
414 // Controlling ivars
418
419 double SnappedEventOrientation[4];
422
424
425 // Locking normal to camera
427
428 // Controlling the push operation
430
431 // The actual plane which is being manipulated
433
434 vtkTypeBool ScaleEnabled; // whether the widget can be scaled
435
436 // The cut plane is produced with a vtkCutter
438 vtkPlaneSource* PlaneSource; // used when plane cropping disabled
443 void HighlightPlane(int highlight);
444
445 // Optional tubes are represented by extracting boundary edges and tubing
450 vtkTypeBool Tubing; // control whether tubing is on
451
452 // The + normal cone
456 void HighlightNormal(int highlight);
457
458 // The normal line
462
463 // The - normal cone
467
468 // The origin positioning handle
472
473 // Do the picking
475
476 // Register internal Pickers within PickingManager
477 void RegisterPickers() override;
478
479 // Transform the normal (used for rotation)
481
482 // Methods to manipulate the plane
483 void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
484 void Rotate3D(double* p1, double* p2);
486 void TranslateOrigin(double* p1, double* p2);
487 void UpdatePose(double* p1, double* d1, double* p2, double* d2);
488 void Push(double* p1, double* p2);
489 void Scale(double* p1, double* p2, double X, double Y);
491
492 // Properties used to control the appearance of selected objects and
493 // the manipulator in general.
501 void CreateDefaultProperties() override;
502
504
505 // Support GetBounds() method
507
508private:
510 void operator=(const vtkImplicitPlaneRepresentation&) = delete;
511};
512
513VTK_ABI_NAMESPACE_END
514#endif
define the API for widget / widget representation
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
Extends the vtkWidgetRepresentation to help positioning widget in space and how it should be displaye...
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 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 SetEdgeColor(double c[3])
Set color to the edge.
void Scale(double *p1, double *p2, double X, double Y)
void HighlightPlane(int highlight)
int ComputeInteractionState(int X, int Y, int modify=0) override
Methods to interface with the vtkImplicitPlaneWidget2.
void TranslateRepresentation(const vtkVector3d &) override
Translate the representation, to be implemented in derived class.
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.
void CreateDefaultProperties() override
Create and initialize properties with default values.
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...
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.
double * GetOrigin()
Get the origin of the 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: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
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)