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 =========================================================================*/
38 #ifndef vtkImplicitPlaneRepresentation_h
39 #define vtkImplicitPlaneRepresentation_h
40 
41 #include "vtkInteractionWidgetsModule.h" // For export macro
43 
44 class vtkActor;
45 class vtkBox;
46 class vtkCellPicker;
47 class vtkConeSource;
48 class vtkCutter;
49 class vtkFeatureEdges;
50 class vtkImageData;
51 class vtkLineSource;
52 class vtkLookupTable;
53 class vtkOutlineFilter;
54 class vtkPlane;
55 class vtkPlaneSource;
56 class vtkPolyData;
58 class vtkPolyDataMapper;
59 class vtkProperty;
60 class vtkSphereSource;
61 class vtkTransform;
62 class vtkTubeFilter;
63 
64 class VTKINTERACTIONWIDGETS_EXPORT vtkImplicitPlaneRepresentation : public vtkWidgetRepresentation
65 {
66 public:
71 
73 
77  void PrintSelf(ostream& os, vtkIndent indent) override;
79 
81 
84  void SetOrigin(double x, double y, double z);
85  void SetOrigin(double x[3]);
86  double* GetOrigin() VTK_SIZEHINT(3);
87  void GetOrigin(double xyz[3]);
89 
91 
94  void SetNormal(double x, double y, double z);
95  void SetNormal(double n[3]);
96  void SetNormalToCamera();
97  double* GetNormal() VTK_SIZEHINT(3);
98  void GetNormal(double xyz[3]);
100 
102 
109  void SetNormalToXAxis(vtkTypeBool);
110  vtkGetMacro(NormalToXAxis, vtkTypeBool);
111  vtkBooleanMacro(NormalToXAxis, vtkTypeBool);
112  void SetNormalToYAxis(vtkTypeBool);
113  vtkGetMacro(NormalToYAxis, vtkTypeBool);
114  vtkBooleanMacro(NormalToYAxis, vtkTypeBool);
115  void SetNormalToZAxis(vtkTypeBool);
116  vtkGetMacro(NormalToZAxis, vtkTypeBool);
117  vtkBooleanMacro(NormalToZAxis, vtkTypeBool);
119 
121 
126  virtual void SetLockNormalToCamera(vtkTypeBool);
127  vtkGetMacro(LockNormalToCamera, vtkTypeBool);
128  vtkBooleanMacro(LockNormalToCamera, vtkTypeBool);
130 
132 
136  vtkSetMacro(Tubing, vtkTypeBool);
137  vtkGetMacro(Tubing, vtkTypeBool);
138  vtkBooleanMacro(Tubing, vtkTypeBool);
140 
142 
148  void SetDrawPlane(vtkTypeBool plane);
149  vtkGetMacro(DrawPlane, vtkTypeBool);
150  vtkBooleanMacro(DrawPlane, vtkTypeBool);
152 
154 
157  void SetDrawOutline(vtkTypeBool plane);
158  vtkGetMacro(DrawOutline, vtkTypeBool);
159  vtkBooleanMacro(DrawOutline, vtkTypeBool);
161 
163 
167  vtkSetMacro(OutlineTranslation, vtkTypeBool);
168  vtkGetMacro(OutlineTranslation, vtkTypeBool);
169  vtkBooleanMacro(OutlineTranslation, vtkTypeBool);
171 
173 
177  vtkSetMacro(OutsideBounds, vtkTypeBool);
178  vtkGetMacro(OutsideBounds, vtkTypeBool);
179  vtkBooleanMacro(OutsideBounds, vtkTypeBool);
181 
183 
186  void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
187  void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
188  void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
189  void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
191 
193 
196  bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
198 
200 
206  vtkSetVector6Macro(WidgetBounds, double);
207  vtkGetVector6Macro(WidgetBounds, double);
209 
211 
218  vtkSetMacro(ConstrainToWidgetBounds, vtkTypeBool);
219  vtkGetMacro(ConstrainToWidgetBounds, vtkTypeBool);
220  vtkBooleanMacro(ConstrainToWidgetBounds, vtkTypeBool);
222 
224 
227  vtkSetMacro(ScaleEnabled, vtkTypeBool);
228  vtkGetMacro(ScaleEnabled, vtkTypeBool);
229  vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
231 
237 
243 
251  void GetPlane(vtkPlane* plane);
252 
258  void SetPlane(vtkPlane* plane);
259 
264  void UpdatePlacement(void);
265 
267 
270  vtkGetObjectMacro(NormalProperty, vtkProperty);
271  vtkGetObjectMacro(SelectedNormalProperty, vtkProperty);
273 
275 
279  vtkGetObjectMacro(PlaneProperty, vtkProperty);
280  vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
282 
284 
287  vtkGetObjectMacro(OutlineProperty, vtkProperty);
288  vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
290 
292 
296  vtkGetObjectMacro(EdgesProperty, vtkProperty);
299 
303  void SetEdgeColor(double, double, double);
304  void SetEdgeColor(double c[3]);
306 
308 
313  vtkSetClampMacro(BumpDistance, double, 0.000001, 1);
314  vtkGetMacro(BumpDistance, double);
316 
325  void BumpPlane(int dir, double factor);
326 
333  void PushPlane(double distance);
334 
336 
339  int ComputeInteractionState(int X, int Y, int modify = 0) override;
340  void PlaceWidget(double bounds[6]) override;
341  void BuildRepresentation() override;
342  void StartWidgetInteraction(double eventPos[2]) override;
343  void WidgetInteraction(double newEventPos[2]) override;
344  void EndWidgetInteraction(double newEventPos[2]) override;
346  unsigned long event, void* calldata) override;
348  unsigned long event, void* calldata) override;
350  unsigned long event, void* calldata, int modify = 0) override;
352  unsigned long event, void* calldata) override;
354 
356 
359  double* GetBounds() VTK_SIZEHINT(6) override;
360  void GetActors(vtkPropCollection* pc) override;
361  void ReleaseGraphicsResources(vtkWindow*) override;
362  int RenderOpaqueGeometry(vtkViewport*) override;
363  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
364  vtkTypeBool HasTranslucentPolygonalGeometry() override;
366 
367  // Manage the state of the widget
369  {
370  Outside = 0,
376  Scaling
377  };
378 
380 
389  vtkSetClampMacro(InteractionState, int, Outside, Scaling);
391 
393 
397  virtual void SetRepresentationState(int);
398  vtkGetMacro(RepresentationState, int);
400 
401  // Get the underlying implicit plane object used by this rep
402  // that can be used as a cropping plane in vtkMapper.
403  vtkPlane* GetUnderlyingPlane() { return this->Plane; }
404 
406 
410  virtual void SetCropPlaneToBoundingBox(bool);
411  vtkGetMacro(CropPlaneToBoundingBox, bool);
412  vtkBooleanMacro(CropPlaneToBoundingBox, bool);
414 
416 
420  vtkGetMacro(SnapToAxes, bool);
421  vtkSetMacro(SnapToAxes, bool);
423 
425 
431  vtkGetMacro(AlwaysSnapToNearestAxis, bool);
432  virtual void SetAlwaysSnapToNearestAxis(bool snap)
433  {
434  this->AlwaysSnapToNearestAxis = snap;
435  this->SetNormal(this->GetNormal());
436  }
438 
439 protected:
442 
444 
445  // Keep track of event positions
446  double LastEventPosition[3];
447  double LastEventOrientation[4];
448  double StartEventOrientation[4];
449 
450  // Controlling ivars
454 
455  double SnappedEventOrientation[4];
458 
460 
461  // Locking normal to camera
463 
464  // Controlling the push operation
465  double BumpDistance;
466 
467  // The actual plane which is being manipulated
469 
471 
472  // The bounding box is represented by a single voxel image data
477  void HighlightOutline(int highlight);
478  vtkTypeBool OutlineTranslation; // whether the outline can be moved
479  vtkTypeBool ScaleEnabled; // whether the widget can be scaled
480  vtkTypeBool OutsideBounds; // whether the widget can be moved outside input's bounds
481  double WidgetBounds[6];
483 
484  // The cut plane is produced with a vtkCutter
486  vtkPlaneSource* PlaneSource; // used when plane cropping disabled
491  void HighlightPlane(int highlight);
492 
493  // Optional tubes are represented by extracting boundary edges and tubing
498  vtkTypeBool Tubing; // control whether tubing is on
499 
500  // The + normal cone
504  void HighlightNormal(int highlight);
505 
506  // The normal line
510 
511  // The - normal cone
515 
516  // The origin positioning handle
520 
521  // Do the picking
523 
524  // Register internal Pickers within PickingManager
525  void RegisterPickers() override;
526 
527  // Transform the normal (used for rotation)
529 
530  // Methods to manipulate the plane
531  void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
532  void Rotate3D(double* p1, double* p2);
533  void TranslatePlane(double* p1, double* p2);
534  void TranslateOutline(double* p1, double* p2);
535  void TranslateOrigin(double* p1, double* p2);
536  void UpdatePose(double* p1, double* d1, double* p2, double* d2);
537  void Push(double* p1, double* p2);
538  void Scale(double* p1, double* p2, double X, double Y);
539  void SizeHandles();
540 
541  // Properties used to control the appearance of selected objects and
542  // the manipulator in general.
550  virtual void CreateDefaultProperties();
551 
553 
555 
556  // Support GetBounds() method
558 
559 private:
561  void operator=(const vtkImplicitPlaneRepresentation&) = delete;
562 };
563 
564 #endif
define the API for widget / widget representation
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:46
implicit function for a bounding box
Definition: vtkBox.h:39
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:67
generate polygonal cone
Definition: vtkConeSource.h:39
Cut vtkDataSet with user-specified implicit function.
Definition: vtkCutter.h:64
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
topologically and geometrically regular array of data
Definition: vtkImageData.h:48
a class defining the representation for a vtkImplicitPlaneWidget2
vtkPolyDataAlgorithm * GetPolyDataAlgorithm()
Satisfies superclass API.
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()
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.
double * GetBounds() override
Methods supporting the rendering process.
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)
virtual void SetAlwaysSnapToNearestAxis(bool snap)
Forces the plane's normal to be aligned with x, y or z axis.
double * GetOrigin()
Get the origin of the plane.
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.
static vtkImplicitPlaneRepresentation * New()
Instantiate the class.
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 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.
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:34
create a line defined by two end points
Definition: vtkLineSource.h:61
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:34
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:86
an ordered list of Props
represent surface properties of a geometric object
Definition: vtkProperty.h:62
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:55
filter that generates tubes around lines
Definition: vtkTubeFilter.h:80
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
@ dir
Definition: vtkX3D.h:330
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SIZEHINT(...)