VTK  9.2.6
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=========================================================================*/
41#ifndef vtkImplicitPlaneRepresentation_h
42#define vtkImplicitPlaneRepresentation_h
43
44#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
45#include "vtkInteractionWidgetsModule.h" // For export macro
47
48class vtkActor;
49class vtkBox;
50class vtkCellPicker;
51class vtkConeSource;
52class vtkCutter;
53class vtkFeatureEdges;
54class vtkImageData;
55class vtkLineSource;
56class vtkLookupTable;
58class vtkPlane;
59class vtkPlaneSource;
60class vtkPolyData;
63class vtkProperty;
64class vtkSphereSource;
65class vtkTransform;
66class vtkTubeFilter;
67
68class VTKINTERACTIONWIDGETS_EXPORT vtkImplicitPlaneRepresentation : public vtkWidgetRepresentation
69{
70public:
75
77
81 void PrintSelf(ostream& os, vtkIndent indent) override;
83
85
88 void SetOrigin(double x, double y, double z);
89 void SetOrigin(double x[3]);
90 double* GetOrigin() VTK_SIZEHINT(3);
91 void GetOrigin(double xyz[3]);
93
95
98 void SetNormal(double x, double y, double z);
99 void SetNormal(double n[3]);
100 void SetNormalToCamera();
101 double* GetNormal() VTK_SIZEHINT(3);
102 void GetNormal(double xyz[3]);
104
106
113 void SetNormalToXAxis(vtkTypeBool);
114 vtkGetMacro(NormalToXAxis, vtkTypeBool);
115 vtkBooleanMacro(NormalToXAxis, vtkTypeBool);
116 void SetNormalToYAxis(vtkTypeBool);
117 vtkGetMacro(NormalToYAxis, vtkTypeBool);
118 vtkBooleanMacro(NormalToYAxis, vtkTypeBool);
119 void SetNormalToZAxis(vtkTypeBool);
120 vtkGetMacro(NormalToZAxis, vtkTypeBool);
121 vtkBooleanMacro(NormalToZAxis, vtkTypeBool);
123
125
130 virtual void SetLockNormalToCamera(vtkTypeBool);
131 vtkGetMacro(LockNormalToCamera, vtkTypeBool);
132 vtkBooleanMacro(LockNormalToCamera, vtkTypeBool);
134
136
140 vtkSetMacro(Tubing, vtkTypeBool);
141 vtkGetMacro(Tubing, vtkTypeBool);
142 vtkBooleanMacro(Tubing, vtkTypeBool);
144
146
152 void SetDrawPlane(vtkTypeBool plane);
153 vtkGetMacro(DrawPlane, vtkTypeBool);
154 vtkBooleanMacro(DrawPlane, vtkTypeBool);
156
158
161 void SetDrawOutline(vtkTypeBool plane);
162 vtkGetMacro(DrawOutline, vtkTypeBool);
163 vtkBooleanMacro(DrawOutline, vtkTypeBool);
165
167
171 vtkSetMacro(OutlineTranslation, vtkTypeBool);
172 vtkGetMacro(OutlineTranslation, vtkTypeBool);
173 vtkBooleanMacro(OutlineTranslation, vtkTypeBool);
175
177
181 vtkSetMacro(OutsideBounds, vtkTypeBool);
182 vtkGetMacro(OutsideBounds, vtkTypeBool);
183 vtkBooleanMacro(OutsideBounds, vtkTypeBool);
185
187
190 void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
191 void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
192 void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
193 void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
195
197
200 bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
202
204
210 vtkSetVector6Macro(WidgetBounds, double);
211 vtkGetVector6Macro(WidgetBounds, double);
213
215
222 vtkSetMacro(ConstrainToWidgetBounds, vtkTypeBool);
223 vtkGetMacro(ConstrainToWidgetBounds, vtkTypeBool);
224 vtkBooleanMacro(ConstrainToWidgetBounds, vtkTypeBool);
226
228
231 vtkSetMacro(ScaleEnabled, vtkTypeBool);
232 vtkGetMacro(ScaleEnabled, vtkTypeBool);
233 vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
235
241
247
255 void GetPlane(vtkPlane* plane);
256
262 void SetPlane(vtkPlane* plane);
263
268 void UpdatePlacement(void);
269
271
274 vtkGetObjectMacro(NormalProperty, vtkProperty);
275 vtkGetObjectMacro(SelectedNormalProperty, vtkProperty);
277
279
283 vtkGetObjectMacro(PlaneProperty, vtkProperty);
284 vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
286
288
291 vtkGetObjectMacro(OutlineProperty, vtkProperty);
292 vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
294
296
300 vtkGetObjectMacro(EdgesProperty, vtkProperty);
303
307 void SetEdgeColor(double, double, double);
308 void SetEdgeColor(double c[3]);
310
312
317 vtkSetClampMacro(BumpDistance, double, 0.000001, 1);
318 vtkGetMacro(BumpDistance, double);
320
329 void BumpPlane(int dir, double factor);
330
337 void PushPlane(double distance);
338
340
343 int ComputeInteractionState(int X, int Y, int modify = 0) override;
344 void PlaceWidget(double bounds[6]) override;
345 void BuildRepresentation() override;
346 void StartWidgetInteraction(double eventPos[2]) override;
347 void WidgetInteraction(double newEventPos[2]) override;
348 void EndWidgetInteraction(double newEventPos[2]) override;
350 unsigned long event, void* calldata) override;
352 unsigned long event, void* calldata) override;
354 unsigned long event, void* calldata, int modify = 0) override;
356 unsigned long event, void* calldata) override;
358
360
363 double* GetBounds() VTK_SIZEHINT(6) override;
364 void GetActors(vtkPropCollection* pc) override;
365 void ReleaseGraphicsResources(vtkWindow*) override;
366 int RenderOpaqueGeometry(vtkViewport*) override;
367 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
368 vtkTypeBool HasTranslucentPolygonalGeometry() override;
370
371 // Manage the state of the widget
382#if !defined(VTK_LEGACY_REMOVE)
383 VTK_DEPRECATED_IN_9_2_0("because leading underscore is reserved")
385#endif
386
388
397 vtkSetClampMacro(InteractionState, int, Outside, Scaling);
399
401
405 virtual void SetRepresentationState(int);
406 vtkGetMacro(RepresentationState, int);
408
409 // Get the underlying implicit plane object used by this rep
410 // that can be used as a cropping plane in vtkMapper.
411 vtkPlane* GetUnderlyingPlane() { return this->Plane; }
412
414
418 virtual void SetCropPlaneToBoundingBox(bool);
419 vtkGetMacro(CropPlaneToBoundingBox, bool);
420 vtkBooleanMacro(CropPlaneToBoundingBox, bool);
422
424
428 vtkGetMacro(SnapToAxes, bool);
429 vtkSetMacro(SnapToAxes, bool);
431
433
439 vtkGetMacro(AlwaysSnapToNearestAxis, bool);
440 virtual void SetAlwaysSnapToNearestAxis(bool snap)
441 {
442 this->AlwaysSnapToNearestAxis = snap;
443 this->SetNormal(this->GetNormal());
444 }
446
447protected:
450
452
453 // Keep track of event positions
454 double LastEventPosition[3];
455 double LastEventOrientation[4];
456 double StartEventOrientation[4];
457
458 // Controlling ivars
462
463 double SnappedEventOrientation[4];
466
468
469 // Locking normal to camera
471
472 // Controlling the push operation
474
475 // The actual plane which is being manipulated
477
479
480 // The bounding box is represented by a single voxel image data
485 void HighlightOutline(int highlight);
486 vtkTypeBool OutlineTranslation; // whether the outline can be moved
487 vtkTypeBool ScaleEnabled; // whether the widget can be scaled
488 vtkTypeBool OutsideBounds; // whether the widget can be moved outside input's bounds
489 double WidgetBounds[6];
491
492 // The cut plane is produced with a vtkCutter
494 vtkPlaneSource* PlaneSource; // used when plane cropping disabled
499 void HighlightPlane(int highlight);
500
501 // Optional tubes are represented by extracting boundary edges and tubing
506 vtkTypeBool Tubing; // control whether tubing is on
507
508 // The + normal cone
512 void HighlightNormal(int highlight);
513
514 // The normal line
518
519 // The - normal cone
523
524 // The origin positioning handle
528
529 // Do the picking
531
532 // Register internal Pickers within PickingManager
533 void RegisterPickers() override;
534
535 // Transform the normal (used for rotation)
537
538 // Methods to manipulate the plane
539 void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
540 void Rotate3D(double* p1, double* p2);
541 void TranslateOutline(double* p1, double* p2);
542 void TranslateOrigin(double* p1, double* p2);
543 void UpdatePose(double* p1, double* d1, double* p2, double* d2);
544 void Push(double* p1, double* p2);
545 void Scale(double* p1, double* p2, double X, double Y);
547
548 // Properties used to control the appearance of selected objects and
549 // the manipulator in general.
558
560
561 // Support GetBounds() method
563
564private:
566 void operator=(const vtkImplicitPlaneRepresentation&) = delete;
567};
568
569#endif
define the API for widget / widget representation
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:52
implicit function for a bounding box
Definition vtkBox.h:42
ray-cast cell picker for all kinds of Prop3Ds
generate polygonal cone
Cut vtkDataSet with user-specified implicit function.
Definition vtkCutter.h:74
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.
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 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:40
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:37
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:91
an ordered list of Props
represent surface properties of a geometric object
Definition vtkProperty.h:68
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:56
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_DEPRECATED_IN_9_2_0(reason)
#define VTK_SIZEHINT(...)