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=========================================================================*/
47#ifndef vtkImplicitPlaneRepresentation_h
48#define vtkImplicitPlaneRepresentation_h
49
50#include "vtkInteractionWidgetsModule.h" // For export macro
52
53class vtkActor;
54class vtkBox;
55class vtkCellPicker;
56class vtkConeSource;
57class vtkCutter;
58class vtkFeatureEdges;
59class vtkImageData;
60class vtkLineSource;
61class vtkLookupTable;
63class vtkPlane;
64class vtkPlaneSource;
65class vtkPolyData;
68class vtkProperty;
69class vtkSphereSource;
70class vtkTransform;
71class vtkTubeFilter;
72
73class VTKINTERACTIONWIDGETS_EXPORT vtkImplicitPlaneRepresentation : public vtkWidgetRepresentation
74{
75public:
80
82
86 void PrintSelf(ostream& os, vtkIndent indent) override;
88
90
93 void SetOrigin(double x, double y, double z);
94 void SetOrigin(double x[3]);
95 double* GetOrigin() VTK_SIZEHINT(3);
96 void GetOrigin(double xyz[3]);
98
100
103 void SetNormal(double x, double y, double z);
104 void SetNormal(double n[3]);
105 void SetNormalToCamera();
106 double* GetNormal() VTK_SIZEHINT(3);
107 void GetNormal(double xyz[3]);
109
111
118 void SetNormalToXAxis(vtkTypeBool);
119 vtkGetMacro(NormalToXAxis, vtkTypeBool);
120 vtkBooleanMacro(NormalToXAxis, vtkTypeBool);
121 void SetNormalToYAxis(vtkTypeBool);
122 vtkGetMacro(NormalToYAxis, vtkTypeBool);
123 vtkBooleanMacro(NormalToYAxis, vtkTypeBool);
124 void SetNormalToZAxis(vtkTypeBool);
125 vtkGetMacro(NormalToZAxis, vtkTypeBool);
126 vtkBooleanMacro(NormalToZAxis, vtkTypeBool);
128
130
135 virtual void SetLockNormalToCamera(vtkTypeBool);
136 vtkGetMacro(LockNormalToCamera, vtkTypeBool);
137 vtkBooleanMacro(LockNormalToCamera, vtkTypeBool);
139
141
145 vtkSetMacro(Tubing, vtkTypeBool);
146 vtkGetMacro(Tubing, vtkTypeBool);
147 vtkBooleanMacro(Tubing, vtkTypeBool);
149
151
157 void SetDrawPlane(vtkTypeBool plane);
158 vtkGetMacro(DrawPlane, vtkTypeBool);
159 vtkBooleanMacro(DrawPlane, vtkTypeBool);
161
163
166 void SetDrawOutline(vtkTypeBool plane);
167 vtkGetMacro(DrawOutline, vtkTypeBool);
168 vtkBooleanMacro(DrawOutline, vtkTypeBool);
170
172
176 vtkSetMacro(OutlineTranslation, vtkTypeBool);
177 vtkGetMacro(OutlineTranslation, vtkTypeBool);
178 vtkBooleanMacro(OutlineTranslation, vtkTypeBool);
180
182
186 vtkSetMacro(OutsideBounds, vtkTypeBool);
187 vtkGetMacro(OutsideBounds, vtkTypeBool);
188 vtkBooleanMacro(OutsideBounds, vtkTypeBool);
190
192
195 void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
196 void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
197 void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
198 void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
200
202
205 bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
207
209
215 vtkSetVector6Macro(WidgetBounds, double);
216 vtkGetVector6Macro(WidgetBounds, double);
218
220
227 vtkSetMacro(ConstrainToWidgetBounds, vtkTypeBool);
228 vtkGetMacro(ConstrainToWidgetBounds, vtkTypeBool);
229 vtkBooleanMacro(ConstrainToWidgetBounds, vtkTypeBool);
231
233
236 vtkSetMacro(ScaleEnabled, vtkTypeBool);
237 vtkGetMacro(ScaleEnabled, vtkTypeBool);
238 vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
240
246
252
260 void GetPlane(vtkPlane* plane);
261
267 void SetPlane(vtkPlane* plane);
268
273 void UpdatePlacement(void);
274
276
279 vtkGetObjectMacro(NormalProperty, vtkProperty);
280 vtkGetObjectMacro(SelectedNormalProperty, vtkProperty);
282
284
288 vtkGetObjectMacro(PlaneProperty, vtkProperty);
289 vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
291
293
296 vtkGetObjectMacro(OutlineProperty, vtkProperty);
297 vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
299
301
305 vtkGetObjectMacro(EdgesProperty, vtkProperty);
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
389
398 vtkSetClampMacro(InteractionState, int, Outside, Scaling);
400
402
406 virtual void SetRepresentationState(int);
407 vtkGetMacro(RepresentationState, int);
409
410 // Get the underlying implicit plane object used by this rep
411 // that can be used as a cropping plane in vtkMapper.
412 vtkPlane* GetUnderlyingPlane() { return this->Plane; }
413
415
419 virtual void SetCropPlaneToBoundingBox(bool);
420 vtkGetMacro(CropPlaneToBoundingBox, bool);
421 vtkBooleanMacro(CropPlaneToBoundingBox, bool);
423
425
429 vtkGetMacro(SnapToAxes, bool);
430 vtkSetMacro(SnapToAxes, bool);
432
434
440 vtkGetMacro(AlwaysSnapToNearestAxis, bool);
441 virtual void SetAlwaysSnapToNearestAxis(bool snap)
442 {
443 this->AlwaysSnapToNearestAxis = snap;
444 this->SetNormal(this->GetNormal());
445 }
447
448protected:
451
453
454 // Keep track of event positions
455 double LastEventPosition[3];
456 double LastEventOrientation[4];
457 double StartEventOrientation[4];
458
459 // Controlling ivars
463
464 double SnappedEventOrientation[4];
467
469
470 // Locking normal to camera
472
473 // Controlling the push operation
475
476 // The actual plane which is being manipulated
478
480
481 // The bounding box is represented by a single voxel image data
486 void HighlightOutline(int highlight);
487 vtkTypeBool OutlineTranslation; // whether the outline can be moved
488 vtkTypeBool ScaleEnabled; // whether the widget can be scaled
489 vtkTypeBool OutsideBounds; // whether the widget can be moved outside input's bounds
490 double WidgetBounds[6];
492
493 // The cut plane is produced with a vtkCutter
495 vtkPlaneSource* PlaneSource; // used when plane cropping disabled
500 void HighlightPlane(int highlight);
501
502 // Optional tubes are represented by extracting boundary edges and tubing
507 vtkTypeBool Tubing; // control whether tubing is on
508
509 // The + normal cone
513 void HighlightNormal(int highlight);
514
515 // The normal line
519
520 // The - normal cone
524
525 // The origin positioning handle
529
530 // Do the picking
532
533 // Register internal Pickers within PickingManager
534 void RegisterPickers() override;
535
536 // Transform the normal (used for rotation)
538
539 // Methods to manipulate the plane
540 void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
541 void Rotate3D(double* p1, double* p2);
542 void TranslatePlane(double* p1, double* p2);
543 void TranslateOutline(double* p1, double* p2);
544 void TranslateOrigin(double* p1, double* p2);
545 void UpdatePose(double* p1, double* d1, double* p2, double* d2);
546 void Push(double* p1, double* p2);
547 void Scale(double* p1, double* p2, double X, double Y);
549
550 // Properties used to control the appearance of selected objects and
551 // the manipulator in general.
560
562
564
565 // Support GetBounds() method
567
568private:
570 void operator=(const vtkImplicitPlaneRepresentation&) = delete;
571};
572
573#endif
define the API for widget / widget representation
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:55
implicit function for a bounding box
Definition: vtkBox.h:48
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:76
generate polygonal cone
Definition: vtkConeSource.h:48
Cut vtkDataSet with user-specified implicit function.
Definition: vtkCutter.h:73
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
topologically and geometrically regular array of data
Definition: vtkImageData.h:57
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:43
create a line defined by two end points
Definition: vtkLineSource.h:70
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:43
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:95
an ordered list of Props
represent surface properties of a geometric object
Definition: vtkProperty.h:71
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:64
filter that generates tubes around lines
Definition: vtkTubeFilter.h:89
abstract specification for Viewports
Definition: vtkViewport.h:56
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition: vtkWindow.h:45
@ dir
Definition: vtkX3D.h:330
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SIZEHINT(...)