VTK  9.2.5
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 =========================================================================*/
60 #ifndef vtkImplicitPlaneRepresentation_h
61 #define vtkImplicitPlaneRepresentation_h
62 
63 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
64 #include "vtkInteractionWidgetsModule.h" // For export macro
66 
67 class vtkActor;
68 class vtkBox;
69 class vtkCellPicker;
70 class vtkConeSource;
71 class vtkCutter;
72 class vtkFeatureEdges;
73 class vtkImageData;
74 class vtkLineSource;
75 class vtkLookupTable;
76 class vtkOutlineFilter;
77 class vtkPlane;
78 class vtkPlaneSource;
79 class vtkPolyData;
81 class vtkPolyDataMapper;
82 class vtkProperty;
83 class vtkSphereSource;
84 class vtkTransform;
85 class vtkTubeFilter;
86 
87 class VTKINTERACTIONWIDGETS_EXPORT vtkImplicitPlaneRepresentation : public vtkWidgetRepresentation
88 {
89 public:
94 
96 
100  void PrintSelf(ostream& os, vtkIndent indent) override;
102 
104 
107  void SetOrigin(double x, double y, double z);
108  void SetOrigin(double x[3]);
109  double* GetOrigin() VTK_SIZEHINT(3);
110  void GetOrigin(double xyz[3]);
112 
114 
117  void SetNormal(double x, double y, double z);
118  void SetNormal(double n[3]);
119  void SetNormalToCamera();
120  double* GetNormal() VTK_SIZEHINT(3);
121  void GetNormal(double xyz[3]);
123 
125 
132  void SetNormalToXAxis(vtkTypeBool);
133  vtkGetMacro(NormalToXAxis, vtkTypeBool);
134  vtkBooleanMacro(NormalToXAxis, vtkTypeBool);
135  void SetNormalToYAxis(vtkTypeBool);
136  vtkGetMacro(NormalToYAxis, vtkTypeBool);
137  vtkBooleanMacro(NormalToYAxis, vtkTypeBool);
138  void SetNormalToZAxis(vtkTypeBool);
139  vtkGetMacro(NormalToZAxis, vtkTypeBool);
140  vtkBooleanMacro(NormalToZAxis, vtkTypeBool);
142 
144 
149  virtual void SetLockNormalToCamera(vtkTypeBool);
150  vtkGetMacro(LockNormalToCamera, vtkTypeBool);
151  vtkBooleanMacro(LockNormalToCamera, vtkTypeBool);
153 
155 
159  vtkSetMacro(Tubing, vtkTypeBool);
160  vtkGetMacro(Tubing, vtkTypeBool);
161  vtkBooleanMacro(Tubing, vtkTypeBool);
163 
165 
171  void SetDrawPlane(vtkTypeBool plane);
172  vtkGetMacro(DrawPlane, vtkTypeBool);
173  vtkBooleanMacro(DrawPlane, vtkTypeBool);
175 
177 
180  void SetDrawOutline(vtkTypeBool plane);
181  vtkGetMacro(DrawOutline, vtkTypeBool);
182  vtkBooleanMacro(DrawOutline, vtkTypeBool);
184 
186 
190  vtkSetMacro(OutlineTranslation, vtkTypeBool);
191  vtkGetMacro(OutlineTranslation, vtkTypeBool);
192  vtkBooleanMacro(OutlineTranslation, vtkTypeBool);
194 
196 
200  vtkSetMacro(OutsideBounds, vtkTypeBool);
201  vtkGetMacro(OutsideBounds, vtkTypeBool);
202  vtkBooleanMacro(OutsideBounds, vtkTypeBool);
204 
206 
209  void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
210  void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
211  void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
212  void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
214 
216 
219  bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
221 
223 
229  vtkSetVector6Macro(WidgetBounds, double);
230  vtkGetVector6Macro(WidgetBounds, double);
232 
234 
241  vtkSetMacro(ConstrainToWidgetBounds, vtkTypeBool);
242  vtkGetMacro(ConstrainToWidgetBounds, vtkTypeBool);
243  vtkBooleanMacro(ConstrainToWidgetBounds, vtkTypeBool);
245 
247 
250  vtkSetMacro(ScaleEnabled, vtkTypeBool);
251  vtkGetMacro(ScaleEnabled, vtkTypeBool);
252  vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
254 
260 
266 
274  void GetPlane(vtkPlane* plane);
275 
281  void SetPlane(vtkPlane* plane);
282 
287  void UpdatePlacement(void);
288 
290 
293  vtkGetObjectMacro(NormalProperty, vtkProperty);
294  vtkGetObjectMacro(SelectedNormalProperty, vtkProperty);
296 
298 
302  vtkGetObjectMacro(PlaneProperty, vtkProperty);
303  vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
305 
307 
310  vtkGetObjectMacro(OutlineProperty, vtkProperty);
311  vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
313 
315 
319  vtkGetObjectMacro(EdgesProperty, vtkProperty);
322 
326  void SetEdgeColor(double, double, double);
327  void SetEdgeColor(double c[3]);
329 
331 
336  vtkSetClampMacro(BumpDistance, double, 0.000001, 1);
337  vtkGetMacro(BumpDistance, double);
339 
348  void BumpPlane(int dir, double factor);
349 
356  void PushPlane(double distance);
357 
359 
362  int ComputeInteractionState(int X, int Y, int modify = 0) override;
363  void PlaceWidget(double bounds[6]) override;
364  void BuildRepresentation() override;
365  void StartWidgetInteraction(double eventPos[2]) override;
366  void WidgetInteraction(double newEventPos[2]) override;
367  void EndWidgetInteraction(double newEventPos[2]) override;
369  unsigned long event, void* calldata) override;
371  unsigned long event, void* calldata) override;
373  unsigned long event, void* calldata, int modify = 0) override;
375  unsigned long event, void* calldata) override;
377 
379 
382  double* GetBounds() VTK_SIZEHINT(6) override;
383  void GetActors(vtkPropCollection* pc) override;
384  void ReleaseGraphicsResources(vtkWindow*) override;
385  int RenderOpaqueGeometry(vtkViewport*) override;
386  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
387  vtkTypeBool HasTranslucentPolygonalGeometry() override;
389 
390  // Manage the state of the widget
392  {
393  Outside = 0,
399  Scaling
400  };
401 #if !defined(VTK_LEGACY_REMOVE)
402  VTK_DEPRECATED_IN_9_2_0("because leading underscore is reserved")
404 #endif
405 
407 
416  vtkSetClampMacro(InteractionState, int, Outside, Scaling);
418 
420 
424  virtual void SetRepresentationState(int);
425  vtkGetMacro(RepresentationState, int);
427 
428  // Get the underlying implicit plane object used by this rep
429  // that can be used as a cropping plane in vtkMapper.
430  vtkPlane* GetUnderlyingPlane() { return this->Plane; }
431 
433 
437  virtual void SetCropPlaneToBoundingBox(bool);
438  vtkGetMacro(CropPlaneToBoundingBox, bool);
439  vtkBooleanMacro(CropPlaneToBoundingBox, bool);
441 
443 
447  vtkGetMacro(SnapToAxes, bool);
448  vtkSetMacro(SnapToAxes, bool);
450 
452 
458  vtkGetMacro(AlwaysSnapToNearestAxis, bool);
459  virtual void SetAlwaysSnapToNearestAxis(bool snap)
460  {
461  this->AlwaysSnapToNearestAxis = snap;
462  this->SetNormal(this->GetNormal());
463  }
465 
466 protected:
469 
471 
472  // Keep track of event positions
473  double LastEventPosition[3];
474  double LastEventOrientation[4];
475  double StartEventOrientation[4];
476 
477  // Controlling ivars
481 
482  double SnappedEventOrientation[4];
485 
487 
488  // Locking normal to camera
490 
491  // Controlling the push operation
492  double BumpDistance;
493 
494  // The actual plane which is being manipulated
496 
498 
499  // The bounding box is represented by a single voxel image data
504  void HighlightOutline(int highlight);
505  vtkTypeBool OutlineTranslation; // whether the outline can be moved
506  vtkTypeBool ScaleEnabled; // whether the widget can be scaled
507  vtkTypeBool OutsideBounds; // whether the widget can be moved outside input's bounds
508  double WidgetBounds[6];
510 
511  // The cut plane is produced with a vtkCutter
513  vtkPlaneSource* PlaneSource; // used when plane cropping disabled
518  void HighlightPlane(int highlight);
519 
520  // Optional tubes are represented by extracting boundary edges and tubing
525  vtkTypeBool Tubing; // control whether tubing is on
526 
527  // The + normal cone
531  void HighlightNormal(int highlight);
532 
533  // The normal line
537 
538  // The - normal cone
542 
543  // The origin positioning handle
547 
548  // Do the picking
550 
551  // Register internal Pickers within PickingManager
552  void RegisterPickers() override;
553 
554  // Transform the normal (used for rotation)
556 
557  // Methods to manipulate the plane
558  void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
559  void Rotate3D(double* p1, double* p2);
560  void TranslateOutline(double* p1, double* p2);
561  void TranslateOrigin(double* p1, double* p2);
562  void UpdatePose(double* p1, double* d1, double* p2, double* d2);
563  void Push(double* p1, double* p2);
564  void Scale(double* p1, double* p2, double X, double Y);
565  void SizeHandles();
566 
567  // Properties used to control the appearance of selected objects and
568  // the manipulator in general.
576  virtual void CreateDefaultProperties();
577 
579 
580  // Support GetBounds() method
582 
583 private:
585  void operator=(const vtkImplicitPlaneRepresentation&) = delete;
586 };
587 
588 #endif
define the API for widget / widget representation
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:161
implicit function for a bounding box
Definition: vtkBox.h:141
ray-cast cell picker for all kinds of Prop3Ds
generate polygonal cone
Cut vtkDataSet with user-specified implicit function.
Definition: vtkCutter.h:173
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
topologically and geometrically regular array of data
Definition: vtkImageData.h:163
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 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:119
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:146
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:200
an ordered list of Props
represent surface properties of a geometric object
Definition: vtkProperty.h:177
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:170
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
@ dir
Definition: vtkX3D.h:330
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_DEPRECATED_IN_9_2_0(reason)
#define VTK_SIZEHINT(...)