VTK  9.1.0
vtkImplicitPlaneRepresentation.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkImplicitPlaneRepresentation.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
57#ifndef vtkImplicitPlaneRepresentation_h
58#define vtkImplicitPlaneRepresentation_h
59
60#include "vtkInteractionWidgetsModule.h" // For export macro
62
63class vtkActor;
64class vtkBox;
65class vtkCellPicker;
66class vtkConeSource;
67class vtkCutter;
68class vtkFeatureEdges;
69class vtkImageData;
70class vtkLineSource;
71class vtkLookupTable;
73class vtkPlane;
74class vtkPlaneSource;
75class vtkPolyData;
78class vtkProperty;
79class vtkSphereSource;
80class vtkTransform;
81class vtkTubeFilter;
82
83class VTKINTERACTIONWIDGETS_EXPORT vtkImplicitPlaneRepresentation : public vtkWidgetRepresentation
84{
85public:
90
92
96 void PrintSelf(ostream& os, vtkIndent indent) override;
98
100
103 void SetOrigin(double x, double y, double z);
104 void SetOrigin(double x[3]);
106 void GetOrigin(double xyz[3]);
108
110
113 void SetNormal(double x, double y, double z);
114 void SetNormal(double n[3]);
115 void SetNormalToCamera();
116 double* GetNormal() VTK_SIZEHINT(3);
117 void GetNormal(double xyz[3]);
119
121
128 void SetNormalToXAxis(vtkTypeBool);
129 vtkGetMacro(NormalToXAxis, vtkTypeBool);
130 vtkBooleanMacro(NormalToXAxis, vtkTypeBool);
131 void SetNormalToYAxis(vtkTypeBool);
132 vtkGetMacro(NormalToYAxis, vtkTypeBool);
133 vtkBooleanMacro(NormalToYAxis, vtkTypeBool);
134 void SetNormalToZAxis(vtkTypeBool);
135 vtkGetMacro(NormalToZAxis, vtkTypeBool);
136 vtkBooleanMacro(NormalToZAxis, vtkTypeBool);
138
140
145 virtual void SetLockNormalToCamera(vtkTypeBool);
146 vtkGetMacro(LockNormalToCamera, vtkTypeBool);
147 vtkBooleanMacro(LockNormalToCamera, vtkTypeBool);
149
151
155 vtkSetMacro(Tubing, vtkTypeBool);
156 vtkGetMacro(Tubing, vtkTypeBool);
157 vtkBooleanMacro(Tubing, vtkTypeBool);
159
161
167 void SetDrawPlane(vtkTypeBool plane);
168 vtkGetMacro(DrawPlane, vtkTypeBool);
169 vtkBooleanMacro(DrawPlane, vtkTypeBool);
171
173
176 void SetDrawOutline(vtkTypeBool plane);
177 vtkGetMacro(DrawOutline, vtkTypeBool);
178 vtkBooleanMacro(DrawOutline, vtkTypeBool);
180
182
186 vtkSetMacro(OutlineTranslation, vtkTypeBool);
187 vtkGetMacro(OutlineTranslation, vtkTypeBool);
188 vtkBooleanMacro(OutlineTranslation, vtkTypeBool);
190
192
196 vtkSetMacro(OutsideBounds, vtkTypeBool);
197 vtkGetMacro(OutsideBounds, vtkTypeBool);
198 vtkBooleanMacro(OutsideBounds, vtkTypeBool);
200
202
205 void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
206 void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
207 void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
208 void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
210
212
215 bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
217
219
225 vtkSetVector6Macro(WidgetBounds, double);
226 vtkGetVector6Macro(WidgetBounds, double);
228
230
237 vtkSetMacro(ConstrainToWidgetBounds, vtkTypeBool);
238 vtkGetMacro(ConstrainToWidgetBounds, vtkTypeBool);
239 vtkBooleanMacro(ConstrainToWidgetBounds, vtkTypeBool);
241
243
246 vtkSetMacro(ScaleEnabled, vtkTypeBool);
247 vtkGetMacro(ScaleEnabled, vtkTypeBool);
248 vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
250
256
262
270 void GetPlane(vtkPlane* plane);
271
277 void SetPlane(vtkPlane* plane);
278
283 void UpdatePlacement(void);
284
286
289 vtkGetObjectMacro(NormalProperty, vtkProperty);
290 vtkGetObjectMacro(SelectedNormalProperty, vtkProperty);
292
294
298 vtkGetObjectMacro(PlaneProperty, vtkProperty);
299 vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
301
303
306 vtkGetObjectMacro(OutlineProperty, vtkProperty);
307 vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
309
311
315 vtkGetObjectMacro(EdgesProperty, vtkProperty);
318
322 void SetEdgeColor(double, double, double);
323 void SetEdgeColor(double c[3]);
325
327
332 vtkSetClampMacro(BumpDistance, double, 0.000001, 1);
333 vtkGetMacro(BumpDistance, double);
335
344 void BumpPlane(int dir, double factor);
345
352 void PushPlane(double distance);
353
355
358 int ComputeInteractionState(int X, int Y, int modify = 0) override;
359 void PlaceWidget(double bounds[6]) override;
360 void BuildRepresentation() override;
361 void StartWidgetInteraction(double eventPos[2]) override;
362 void WidgetInteraction(double newEventPos[2]) override;
363 void EndWidgetInteraction(double newEventPos[2]) override;
365 unsigned long event, void* calldata) override;
367 unsigned long event, void* calldata) override;
369 unsigned long event, void* calldata, int modify = 0) override;
371 unsigned long event, void* calldata) override;
373
375
378 double* GetBounds() VTK_SIZEHINT(6) override;
379 void GetActors(vtkPropCollection* pc) override;
380 void ReleaseGraphicsResources(vtkWindow*) override;
381 int RenderOpaqueGeometry(vtkViewport*) override;
382 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
383 vtkTypeBool HasTranslucentPolygonalGeometry() override;
385
386 // Manage the state of the widget
388 {
389 Outside = 0,
395 Scaling
396 };
397
399
408 vtkSetClampMacro(InteractionState, int, Outside, Scaling);
410
412
416 virtual void SetRepresentationState(int);
417 vtkGetMacro(RepresentationState, int);
419
420 // Get the underlying implicit plane object used by this rep
421 // that can be used as a cropping plane in vtkMapper.
422 vtkPlane* GetUnderlyingPlane() { return this->Plane; }
423
425
429 virtual void SetCropPlaneToBoundingBox(bool);
430 vtkGetMacro(CropPlaneToBoundingBox, bool);
431 vtkBooleanMacro(CropPlaneToBoundingBox, bool);
433
435
439 vtkGetMacro(SnapToAxes, bool);
440 vtkSetMacro(SnapToAxes, bool);
442
444
450 vtkGetMacro(AlwaysSnapToNearestAxis, bool);
451 virtual void SetAlwaysSnapToNearestAxis(bool snap)
452 {
453 this->AlwaysSnapToNearestAxis = snap;
454 this->SetNormal(this->GetNormal());
455 }
457
458protected:
461
463
464 // Keep track of event positions
465 double LastEventPosition[3];
466 double LastEventOrientation[4];
467 double StartEventOrientation[4];
468
469 // Controlling ivars
473
474 double SnappedEventOrientation[4];
477
479
480 // Locking normal to camera
482
483 // Controlling the push operation
485
486 // The actual plane which is being manipulated
488
490
491 // The bounding box is represented by a single voxel image data
496 void HighlightOutline(int highlight);
497 vtkTypeBool OutlineTranslation; // whether the outline can be moved
498 vtkTypeBool ScaleEnabled; // whether the widget can be scaled
499 vtkTypeBool OutsideBounds; // whether the widget can be moved outside input's bounds
500 double WidgetBounds[6];
502
503 // The cut plane is produced with a vtkCutter
505 vtkPlaneSource* PlaneSource; // used when plane cropping disabled
510 void HighlightPlane(int highlight);
511
512 // Optional tubes are represented by extracting boundary edges and tubing
517 vtkTypeBool Tubing; // control whether tubing is on
518
519 // The + normal cone
523 void HighlightNormal(int highlight);
524
525 // The normal line
529
530 // The - normal cone
534
535 // The origin positioning handle
539
540 // Do the picking
542
543 // Register internal Pickers within PickingManager
544 void RegisterPickers() override;
545
546 // Transform the normal (used for rotation)
548
549 // Methods to manipulate the plane
550 void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
551 void Rotate3D(double* p1, double* p2);
552 void TranslatePlane(double* p1, double* p2);
553 void TranslateOutline(double* p1, double* p2);
554 void TranslateOrigin(double* p1, double* p2);
555 void UpdatePose(double* p1, double* d1, double* p2, double* d2);
556 void Push(double* p1, double* p2);
557 void Scale(double* p1, double* p2, double X, double Y);
559
560 // Properties used to control the appearance of selected objects and
561 // the manipulator in general.
570
572
574
575 // Support GetBounds() method
577
578private:
580 void operator=(const vtkImplicitPlaneRepresentation&) = delete;
581};
582
583#endif
define the API for widget / widget representation
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:155
implicit function for a bounding box
Definition: vtkBox.h:138
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:96
generate polygonal cone
Cut vtkDataSet with user-specified implicit function.
Definition: vtkCutter.h:163
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
topologically and geometrically regular array of data
Definition: vtkImageData.h:157
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.
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 UpdatePlacement(void)
Satisfies the superclass API.
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.
virtual void SetAlwaysSnapToNearestAxis(bool snap)
Forces the plane's normal to be aligned with x, y or z axis.
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)
double * GetBounds() override
Methods supporting the rendering process.
void SetEdgeColor(double, double, double)
Set color to the edge.
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 TranslatePlane(double *p1, double *p2)
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 ContrainedAxis.
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 Rotate3D(double *p1, double *p2)
a simple class to control print indentation
Definition: vtkIndent.h:113
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:143
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:195
an ordered list of Props
represent surface properties of a geometric object
Definition: vtkProperty.h:171
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
Definition: vtkTransform.h:164
filter that generates tubes around lines
abstract specification for Viewports
Definition: vtkViewport.h:47
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition: vtkWindow.h:39
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SIZEHINT(...)