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 =========================================================================*/
50 #ifndef vtkImplicitPlaneRepresentation_h
51 #define vtkImplicitPlaneRepresentation_h
52 
53 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
54 #include "vtkInteractionWidgetsModule.h" // For export macro
56 
57 class vtkActor;
58 class vtkBox;
59 class vtkCellPicker;
60 class vtkConeSource;
61 class vtkCutter;
62 class vtkFeatureEdges;
63 class vtkImageData;
64 class vtkLineSource;
65 class vtkLookupTable;
66 class vtkOutlineFilter;
67 class vtkPlane;
68 class vtkPlaneSource;
69 class vtkPolyData;
71 class vtkPolyDataMapper;
72 class vtkProperty;
73 class vtkSphereSource;
74 class vtkTransform;
75 class vtkTubeFilter;
76 
77 class VTKINTERACTIONWIDGETS_EXPORT vtkImplicitPlaneRepresentation : public vtkWidgetRepresentation
78 {
79 public:
84 
86 
90  void PrintSelf(ostream& os, vtkIndent indent) override;
92 
94 
97  void SetOrigin(double x, double y, double z);
98  void SetOrigin(double x[3]);
99  double* GetOrigin() VTK_SIZEHINT(3);
100  void GetOrigin(double xyz[3]);
102 
104 
107  void SetNormal(double x, double y, double z);
108  void SetNormal(double n[3]);
109  void SetNormalToCamera();
110  double* GetNormal() VTK_SIZEHINT(3);
111  void GetNormal(double xyz[3]);
113 
115 
122  void SetNormalToXAxis(vtkTypeBool);
123  vtkGetMacro(NormalToXAxis, vtkTypeBool);
124  vtkBooleanMacro(NormalToXAxis, vtkTypeBool);
125  void SetNormalToYAxis(vtkTypeBool);
126  vtkGetMacro(NormalToYAxis, vtkTypeBool);
127  vtkBooleanMacro(NormalToYAxis, vtkTypeBool);
128  void SetNormalToZAxis(vtkTypeBool);
129  vtkGetMacro(NormalToZAxis, vtkTypeBool);
130  vtkBooleanMacro(NormalToZAxis, vtkTypeBool);
132 
134 
139  virtual void SetLockNormalToCamera(vtkTypeBool);
140  vtkGetMacro(LockNormalToCamera, vtkTypeBool);
141  vtkBooleanMacro(LockNormalToCamera, vtkTypeBool);
143 
145 
149  vtkSetMacro(Tubing, vtkTypeBool);
150  vtkGetMacro(Tubing, vtkTypeBool);
151  vtkBooleanMacro(Tubing, vtkTypeBool);
153 
155 
161  void SetDrawPlane(vtkTypeBool plane);
162  vtkGetMacro(DrawPlane, vtkTypeBool);
163  vtkBooleanMacro(DrawPlane, vtkTypeBool);
165 
167 
170  void SetDrawOutline(vtkTypeBool plane);
171  vtkGetMacro(DrawOutline, vtkTypeBool);
172  vtkBooleanMacro(DrawOutline, vtkTypeBool);
174 
176 
180  vtkSetMacro(OutlineTranslation, vtkTypeBool);
181  vtkGetMacro(OutlineTranslation, vtkTypeBool);
182  vtkBooleanMacro(OutlineTranslation, vtkTypeBool);
184 
186 
190  vtkSetMacro(OutsideBounds, vtkTypeBool);
191  vtkGetMacro(OutsideBounds, vtkTypeBool);
192  vtkBooleanMacro(OutsideBounds, vtkTypeBool);
194 
196 
199  void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
200  void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
201  void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
202  void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
204 
206 
209  bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
211 
213 
219  vtkSetVector6Macro(WidgetBounds, double);
220  vtkGetVector6Macro(WidgetBounds, double);
222 
224 
231  vtkSetMacro(ConstrainToWidgetBounds, vtkTypeBool);
232  vtkGetMacro(ConstrainToWidgetBounds, vtkTypeBool);
233  vtkBooleanMacro(ConstrainToWidgetBounds, vtkTypeBool);
235 
237 
240  vtkSetMacro(ScaleEnabled, vtkTypeBool);
241  vtkGetMacro(ScaleEnabled, vtkTypeBool);
242  vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
244 
250 
256 
264  void GetPlane(vtkPlane* plane);
265 
271  void SetPlane(vtkPlane* plane);
272 
277  void UpdatePlacement(void);
278 
280 
283  vtkGetObjectMacro(NormalProperty, vtkProperty);
284  vtkGetObjectMacro(SelectedNormalProperty, vtkProperty);
286 
288 
292  vtkGetObjectMacro(PlaneProperty, vtkProperty);
293  vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
295 
297 
300  vtkGetObjectMacro(OutlineProperty, vtkProperty);
301  vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
303 
305 
309  vtkGetObjectMacro(EdgesProperty, vtkProperty);
312 
316  void SetEdgeColor(double, double, double);
317  void SetEdgeColor(double c[3]);
319 
321 
326  vtkSetClampMacro(BumpDistance, double, 0.000001, 1);
327  vtkGetMacro(BumpDistance, double);
329 
338  void BumpPlane(int dir, double factor);
339 
346  void PushPlane(double distance);
347 
349 
352  int ComputeInteractionState(int X, int Y, int modify = 0) override;
353  void PlaceWidget(double bounds[6]) override;
354  void BuildRepresentation() override;
355  void StartWidgetInteraction(double eventPos[2]) override;
356  void WidgetInteraction(double newEventPos[2]) override;
357  void EndWidgetInteraction(double newEventPos[2]) override;
359  unsigned long event, void* calldata) override;
361  unsigned long event, void* calldata) override;
363  unsigned long event, void* calldata, int modify = 0) override;
365  unsigned long event, void* calldata) override;
367 
369 
372  double* GetBounds() VTK_SIZEHINT(6) override;
373  void GetActors(vtkPropCollection* pc) override;
374  void ReleaseGraphicsResources(vtkWindow*) override;
375  int RenderOpaqueGeometry(vtkViewport*) override;
376  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
377  vtkTypeBool HasTranslucentPolygonalGeometry() override;
379 
380  // Manage the state of the widget
382  {
383  Outside = 0,
389  Scaling
390  };
391 #if !defined(VTK_LEGACY_REMOVE)
392  VTK_DEPRECATED_IN_9_2_0("because leading underscore is reserved")
394 #endif
395 
397 
406  vtkSetClampMacro(InteractionState, int, Outside, Scaling);
408 
410 
414  virtual void SetRepresentationState(int);
415  vtkGetMacro(RepresentationState, int);
417 
418  // Get the underlying implicit plane object used by this rep
419  // that can be used as a cropping plane in vtkMapper.
420  vtkPlane* GetUnderlyingPlane() { return this->Plane; }
421 
423 
427  virtual void SetCropPlaneToBoundingBox(bool);
428  vtkGetMacro(CropPlaneToBoundingBox, bool);
429  vtkBooleanMacro(CropPlaneToBoundingBox, bool);
431 
433 
437  vtkGetMacro(SnapToAxes, bool);
438  vtkSetMacro(SnapToAxes, bool);
440 
442 
448  vtkGetMacro(AlwaysSnapToNearestAxis, bool);
449  virtual void SetAlwaysSnapToNearestAxis(bool snap)
450  {
451  this->AlwaysSnapToNearestAxis = snap;
452  this->SetNormal(this->GetNormal());
453  }
455 
456 protected:
459 
461 
462  // Keep track of event positions
463  double LastEventPosition[3];
464  double LastEventOrientation[4];
465  double StartEventOrientation[4];
466 
467  // Controlling ivars
471 
472  double SnappedEventOrientation[4];
475 
477 
478  // Locking normal to camera
480 
481  // Controlling the push operation
482  double BumpDistance;
483 
484  // The actual plane which is being manipulated
486 
488 
489  // The bounding box is represented by a single voxel image data
494  void HighlightOutline(int highlight);
495  vtkTypeBool OutlineTranslation; // whether the outline can be moved
496  vtkTypeBool ScaleEnabled; // whether the widget can be scaled
497  vtkTypeBool OutsideBounds; // whether the widget can be moved outside input's bounds
498  double WidgetBounds[6];
500 
501  // The cut plane is produced with a vtkCutter
503  vtkPlaneSource* PlaneSource; // used when plane cropping disabled
508  void HighlightPlane(int highlight);
509 
510  // Optional tubes are represented by extracting boundary edges and tubing
515  vtkTypeBool Tubing; // control whether tubing is on
516 
517  // The + normal cone
521  void HighlightNormal(int highlight);
522 
523  // The normal line
527 
528  // The - normal cone
532 
533  // The origin positioning handle
537 
538  // Do the picking
540 
541  // Register internal Pickers within PickingManager
542  void RegisterPickers() override;
543 
544  // Transform the normal (used for rotation)
546 
547  // Methods to manipulate the plane
548  void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
549  void Rotate3D(double* p1, double* p2);
550  void TranslateOutline(double* p1, double* p2);
551  void TranslateOrigin(double* p1, double* p2);
552  void UpdatePose(double* p1, double* d1, double* p2, double* d2);
553  void Push(double* p1, double* p2);
554  void Scale(double* p1, double* p2, double X, double Y);
555  void SizeHandles();
556 
557  // Properties used to control the appearance of selected objects and
558  // the manipulator in general.
566  virtual void CreateDefaultProperties();
567 
569 
570  // Support GetBounds() method
572 
573 private:
575  void operator=(const vtkImplicitPlaneRepresentation&) = delete;
576 };
577 
578 #endif
define the API for widget / widget representation
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:61
implicit function for a bounding box
Definition: vtkBox.h:51
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:82
generate polygonal cone
Definition: vtkConeSource.h:54
Cut vtkDataSet with user-specified implicit function.
Definition: vtkCutter.h:83
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
topologically and geometrically regular array of data
Definition: vtkImageData.h:63
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:49
create a line defined by two end points
Definition: vtkLineSource.h:73
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:46
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:100
an ordered list of Props
represent surface properties of a geometric object
Definition: vtkProperty.h:77
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:70
filter that generates tubes around lines
Definition: vtkTubeFilter.h:95
abstract specification for Viewports
Definition: vtkViewport.h:65
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition: vtkWindow.h:48
@ dir
Definition: vtkX3D.h:330
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_DEPRECATED_IN_9_2_0(reason)
#define VTK_SIZEHINT(...)