VTK  9.3.1
vtkImplicitPlaneRepresentation.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
29 #ifndef vtkImplicitPlaneRepresentation_h
30 #define vtkImplicitPlaneRepresentation_h
31 
32 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
33 #include "vtkInteractionWidgetsModule.h" // For export macro
34 #include "vtkLegacy.h" // for VTK_LEGACY_REMOVE
36 
37 VTK_ABI_NAMESPACE_BEGIN
38 class vtkActor;
39 class vtkBox;
40 class vtkCellPicker;
41 class vtkConeSource;
42 class vtkCutter;
43 class vtkFeatureEdges;
44 class vtkImageData;
45 class vtkLineSource;
46 class vtkLookupTable;
47 class vtkOutlineFilter;
48 class vtkPlane;
49 class vtkPlaneSource;
50 class vtkPolyData;
52 class vtkPolyDataMapper;
53 class vtkProperty;
54 class vtkSphereSource;
55 class vtkTransform;
56 class vtkTubeFilter;
57 
58 class VTKINTERACTIONWIDGETS_EXPORT vtkImplicitPlaneRepresentation : public vtkWidgetRepresentation
59 {
60 public:
65 
67 
71  void PrintSelf(ostream& os, vtkIndent indent) override;
73 
75 
78  void SetOrigin(double x, double y, double z);
79  void SetOrigin(double x[3]);
80  double* GetOrigin() VTK_SIZEHINT(3);
81  void GetOrigin(double xyz[3]);
83 
85 
88  void SetNormal(double x, double y, double z);
89  void SetNormal(double n[3]);
90  void SetNormalToCamera();
91  double* GetNormal() VTK_SIZEHINT(3);
92  void GetNormal(double xyz[3]);
94 
96 
103  void SetNormalToXAxis(vtkTypeBool);
104  vtkGetMacro(NormalToXAxis, vtkTypeBool);
105  vtkBooleanMacro(NormalToXAxis, vtkTypeBool);
106  void SetNormalToYAxis(vtkTypeBool);
107  vtkGetMacro(NormalToYAxis, vtkTypeBool);
108  vtkBooleanMacro(NormalToYAxis, vtkTypeBool);
109  void SetNormalToZAxis(vtkTypeBool);
110  vtkGetMacro(NormalToZAxis, vtkTypeBool);
111  vtkBooleanMacro(NormalToZAxis, vtkTypeBool);
113 
115 
120  virtual void SetLockNormalToCamera(vtkTypeBool);
121  vtkGetMacro(LockNormalToCamera, vtkTypeBool);
122  vtkBooleanMacro(LockNormalToCamera, vtkTypeBool);
124 
126 
130  vtkSetMacro(Tubing, vtkTypeBool);
131  vtkGetMacro(Tubing, vtkTypeBool);
132  vtkBooleanMacro(Tubing, vtkTypeBool);
134 
136 
142  void SetDrawPlane(vtkTypeBool plane);
143  vtkGetMacro(DrawPlane, vtkTypeBool);
144  vtkBooleanMacro(DrawPlane, vtkTypeBool);
146 
148 
151  void SetDrawOutline(vtkTypeBool plane);
152  vtkGetMacro(DrawOutline, vtkTypeBool);
153  vtkBooleanMacro(DrawOutline, vtkTypeBool);
155 
157 
161  vtkSetMacro(OutlineTranslation, vtkTypeBool);
162  vtkGetMacro(OutlineTranslation, vtkTypeBool);
163  vtkBooleanMacro(OutlineTranslation, vtkTypeBool);
165 
167 
171  vtkSetMacro(OutsideBounds, vtkTypeBool);
172  vtkGetMacro(OutsideBounds, vtkTypeBool);
173  vtkBooleanMacro(OutsideBounds, vtkTypeBool);
175 
177 
180  void SetXTranslationAxisOn() { this->TranslationAxis = Axis::XAxis; }
181  void SetYTranslationAxisOn() { this->TranslationAxis = Axis::YAxis; }
182  void SetZTranslationAxisOn() { this->TranslationAxis = Axis::ZAxis; }
183  void SetTranslationAxisOff() { this->TranslationAxis = Axis::NONE; }
185 
187 
190  bool IsTranslationConstrained() { return this->TranslationAxis != Axis::NONE; }
192 
194 
200  vtkSetVector6Macro(WidgetBounds, double);
201  vtkGetVector6Macro(WidgetBounds, double);
203 
205 
212  vtkSetMacro(ConstrainToWidgetBounds, vtkTypeBool);
213  vtkGetMacro(ConstrainToWidgetBounds, vtkTypeBool);
214  vtkBooleanMacro(ConstrainToWidgetBounds, vtkTypeBool);
216 
218 
221  vtkSetMacro(ScaleEnabled, vtkTypeBool);
222  vtkGetMacro(ScaleEnabled, vtkTypeBool);
223  vtkBooleanMacro(ScaleEnabled, vtkTypeBool);
225 
230  void GetPolyData(vtkPolyData* pd);
231 
236  vtkPolyDataAlgorithm* GetPolyDataAlgorithm();
237 
245  void GetPlane(vtkPlane* plane);
246 
252  void SetPlane(vtkPlane* plane);
253 
258  void UpdatePlacement();
259 
261 
264  vtkGetObjectMacro(NormalProperty, vtkProperty);
265  vtkGetObjectMacro(SelectedNormalProperty, vtkProperty);
267 
269 
273  vtkGetObjectMacro(PlaneProperty, vtkProperty);
274  vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
276 
278 
281  vtkGetObjectMacro(OutlineProperty, vtkProperty);
282  vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
284 
286 
290  vtkGetObjectMacro(EdgesProperty, vtkProperty);
292 
294 
299  void SetInteractionColor(double, double, double);
300  void SetInteractionColor(double c[3]) { this->SetInteractionColor(c[0], c[1], c[2]); }
301  void SetHandleColor(double, double, double);
302  void SetHandleColor(double c[3]) { this->SetHandleColor(c[0], c[1], c[2]); }
303  void SetForegroundColor(double, double, double);
304  void SetForegroundColor(double c[3]) { this->SetForegroundColor(c[0], c[1], c[2]); }
306 
308 
311  void SetEdgeColor(vtkLookupTable*);
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 #if !defined(VTK_LEGACY_REMOVE)
388  VTK_DEPRECATED_IN_9_2_0("because leading underscore is reserved")
390 #endif
391 
393 
402  vtkSetClampMacro(InteractionState, int, Outside, Scaling);
404 
406 
410  virtual void SetRepresentationState(int);
411  vtkGetMacro(RepresentationState, int);
413 
414  // Get the underlying implicit plane object used by this rep
415  // that can be used as a cropping plane in vtkMapper.
416  vtkPlane* GetUnderlyingPlane() { return this->Plane; }
417 
419 
423  virtual void SetCropPlaneToBoundingBox(bool);
424  vtkGetMacro(CropPlaneToBoundingBox, bool);
425  vtkBooleanMacro(CropPlaneToBoundingBox, bool);
427 
429 
433  vtkGetMacro(SnapToAxes, bool);
434  vtkSetMacro(SnapToAxes, bool);
436 
438 
444  vtkGetMacro(AlwaysSnapToNearestAxis, bool);
445  virtual void SetAlwaysSnapToNearestAxis(bool snap)
446  {
447  this->AlwaysSnapToNearestAxis = snap;
448  this->SetNormal(this->GetNormal());
449  }
451 
452 protected:
454  ~vtkImplicitPlaneRepresentation() override;
455 
457 
458  // Keep track of event positions
459  double LastEventPosition[3];
460  double LastEventOrientation[4];
461  double StartEventOrientation[4];
462 
463  // Controlling ivars
467 
468  double SnappedEventOrientation[4];
471 
473 
474  // Locking normal to camera
476 
477  // Controlling the push operation
478  double BumpDistance;
479 
480  // The actual plane which is being manipulated
482 
484 
485  // The bounding box is represented by a single voxel image data
490  void HighlightOutline(int highlight);
491  vtkTypeBool OutlineTranslation; // whether the outline can be moved
492  vtkTypeBool ScaleEnabled; // whether the widget can be scaled
493  vtkTypeBool OutsideBounds; // whether the widget can be moved outside input's bounds
494  double WidgetBounds[6];
496 
497  // The cut plane is produced with a vtkCutter
499  vtkPlaneSource* PlaneSource; // used when plane cropping disabled
504  void HighlightPlane(int highlight);
505 
506  // Optional tubes are represented by extracting boundary edges and tubing
511  vtkTypeBool Tubing; // control whether tubing is on
512 
513  // The + normal cone
517  void HighlightNormal(int highlight);
518 
519  // The normal line
523 
524  // The - normal cone
528 
529  // The origin positioning handle
533 
534  // Do the picking
536 
537  // Register internal Pickers within PickingManager
538  void RegisterPickers() override;
539 
540  // Transform the normal (used for rotation)
542 
543  // Methods to manipulate the plane
544  void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
545  void Rotate3D(double* p1, double* p2);
546  void TranslateOutline(double* p1, double* p2);
547  void TranslateOrigin(double* p1, double* p2);
548  void UpdatePose(double* p1, double* d1, double* p2, double* d2);
549  void Push(double* p1, double* p2);
550  void Scale(double* p1, double* p2, double X, double Y);
551  void SizeHandles();
552 
553  // Properties used to control the appearance of selected objects and
554  // the manipulator in general.
562  virtual void CreateDefaultProperties();
563 
565 
566  // Support GetBounds() method
568 
569 private:
571  void operator=(const vtkImplicitPlaneRepresentation&) = delete;
572 };
573 
574 VTK_ABI_NAMESPACE_END
575 #endif
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instances of this class.
Cut vtkDataSet with user-specified implicit function.
Definition: vtkCutter.h:60
virtual void EndWidgetInteraction(double newEventPos[2])
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:40
void SetZTranslationAxisOn()
Toggles constraint translation axis on/off.
virtual void PlaceWidget(double vtkNotUsed(bounds)[6])
The following is a suggested API for widget representations.
virtual int ComputeInteractionState(int X, int Y, int modify=0)
abstract specification for Viewports
Definition: vtkViewport.h:44
represent surface properties of a geometric object
Definition: vtkProperty.h:56
virtual void StartWidgetInteraction(double eventPos[2])
#define VTK_DEPRECATED_IN_9_2_0(reason)
virtual int ComputeComplexInteractionState(vtkRenderWindowInteractor *iren, vtkAbstractWidget *widget, unsigned long event, void *callData, int modify=0)
map scalar values into colors via a lookup table
virtual void ComplexInteraction(vtkRenderWindowInteractor *, vtkAbstractWidget *, unsigned long, void *)
virtual void EndComplexInteraction(vtkRenderWindowInteractor *, vtkAbstractWidget *, unsigned long, void *)
void SetInteractionColor(double c[3])
Set the color of all the widget's handles (edges, cone1, cone2, line, sphere, selected plane) and the...
virtual void StartComplexInteraction(vtkRenderWindowInteractor *, vtkAbstractWidget *, unsigned long, void *)
generate polygonal cone
Definition: vtkConeSource.h:33
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:49
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
void SetTranslationAxisOff()
Toggles constraint translation axis on/off.
abstract class defines interface between the widget and widget representation classes ...
virtual void BuildRepresentation()=0
Subclasses of vtkWidgetRepresentation must implement these methods.
double * GetBounds() override
Methods to make this class behave as a vtkProp.
an ordered list of Props
int vtkTypeBool
Definition: vtkABI.h:64
window superclass for vtkRenderWindow
Definition: vtkWindow.h:27
platform-independent render window interaction including picking and frame rate control.
create wireframe outline for an arbitrary data set or composite dataset
create a polygonal sphere centered at the origin
void SetYTranslationAxisOn()
Toggles constraint translation axis on/off.
Superclass for algorithms that produce only polydata as output.
filter that generates tubes around lines
Definition: vtkTubeFilter.h:74
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
a class defining the representation for a vtkImplicitPlaneWidget2
extract interior, boundary, non-manifold, and/or sharp edges from polygonal data
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
void SetHandleColor(double c[3])
Set the color of all the widget's handles (edges, cone1, cone2, line, sphere, selected plane) and the...
perform various plane computations
Definition: vtkPlane.h:25
void SetForegroundColor(double c[3])
Set the color of all the widget's handles (edges, cone1, cone2, line, sphere, selected plane) and the...
virtual void WidgetInteraction(double newEventPos[2])
#define VTK_SIZEHINT(...)
create an array of quadrilaterals located in a plane
define the API for widget / widget representation
create a line defined by two end points
Definition: vtkLineSource.h:52
map vtkPolyData to graphics primitives
virtual void SetAlwaysSnapToNearestAxis(bool snap)
Forces the plane's normal to be aligned with x, y or z axis.
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:61
bool IsTranslationConstrained()
Returns true if ConstrainedAxis.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
implicit function for a bounding box
Definition: vtkBox.h:30