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 
48 class vtkActor;
49 class vtkBox;
50 class vtkCellPicker;
51 class vtkConeSource;
52 class vtkCutter;
53 class vtkFeatureEdges;
54 class vtkImageData;
55 class vtkLineSource;
56 class vtkLookupTable;
57 class vtkOutlineFilter;
58 class vtkPlane;
59 class vtkPlaneSource;
60 class vtkPolyData;
62 class vtkPolyDataMapper;
63 class vtkProperty;
64 class vtkSphereSource;
65 class vtkTransform;
66 class vtkTubeFilter;
67 
68 class VTKINTERACTIONWIDGETS_EXPORT vtkImplicitPlaneRepresentation : public vtkWidgetRepresentation
69 {
70 public:
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 
240  void GetPolyData(vtkPolyData* pd);
241 
246  vtkPolyDataAlgorithm* GetPolyDataAlgorithm();
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 
306  void SetEdgeColor(vtkLookupTable*);
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
373  {
374  Outside = 0,
380  Scaling
381  };
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 
447 protected:
449  ~vtkImplicitPlaneRepresentation() override;
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
473  double BumpDistance;
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);
546  void SizeHandles();
547 
548  // Properties used to control the appearance of selected objects and
549  // the manipulator in general.
557  virtual void CreateDefaultProperties();
558 
560 
561  // Support GetBounds() method
563 
564 private:
566  void operator=(const vtkImplicitPlaneRepresentation&) = delete;
567 };
568 
569 #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:73
virtual void EndWidgetInteraction(double newEventPos[2])
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
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:55
represent surface properties of a geometric object
Definition: vtkProperty.h:67
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 *)
virtual void StartComplexInteraction(vtkRenderWindowInteractor *, vtkAbstractWidget *, unsigned long, void *)
generate polygonal cone
Definition: vtkConeSource.h:44
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:90
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:69
window superclass for vtkRenderWindow
Definition: vtkWindow.h:38
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:85
a simple class to control print indentation
Definition: vtkIndent.h:39
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:53
perform various plane computations
Definition: vtkPlane.h:36
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:63
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:72
bool IsTranslationConstrained()
Returns true if ContrainedAxis.
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:41