VTK  9.0.1
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 vtkPolyDataMapper;
46 class vtkCellPicker;
47 class vtkConeSource;
48 class vtkLineSource;
49 class vtkSphereSource;
50 class vtkTubeFilter;
51 class vtkPlane;
52 class vtkPlaneSource;
53 class vtkCutter;
54 class vtkProperty;
55 class vtkImageData;
56 class vtkOutlineFilter;
57 class vtkFeatureEdges;
58 class vtkPolyData;
60 class vtkTransform;
61 class vtkBox;
62 class vtkLookupTable;
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 x[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);
298 
299 
303  void SetEdgeColor(double, double, double);
304  void SetEdgeColor(double x[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 plane object used by this rep
402  // this 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
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 - normal line
520 
521  // The origin positioning handle
525 
526  // Do the picking
528 
529  // Register internal Pickers within PickingManager
530  void RegisterPickers() override;
531 
532  // Transform the normal (used for rotation)
534 
535  // Methods to manipulate the plane
536  void Rotate(double X, double Y, double* p1, double* p2, double* vpn);
537  void Rotate3D(double* p1, double* p2);
538  void TranslatePlane(double* p1, double* p2);
539  void TranslateOutline(double* p1, double* p2);
540  void TranslateOrigin(double* p1, double* p2);
541  void UpdatePose(double* p1, double* d1, double* p2, double* d2);
542  void Push(double* p1, double* p2);
543  void Scale(double* p1, double* p2, double X, double Y);
544  void SizeHandles();
545 
546  // Properties used to control the appearance of selected objects and
547  // the manipulator in general.
556 
558 
560 
561  // Support GetBounds() method
563 
564 private:
566  void operator=(const vtkImplicitPlaneRepresentation&) = delete;
567 };
568 
569 #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:42
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 EndWidgetInteraction(double newEventPos[2]) override
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
void GetPolyData(vtkPolyData *pd)
Grab the polydata that defines the plane.
void Scale(double *p1, double *p2, double X, double Y)
void HighlightPlane(int highlight)
int ComputeInteractionState(int X, int Y, int modify=0) override
Methods to interface with the vtkImplicitPlaneWidget2.
double * GetBounds() override
Methods supporting the rendering process.
void HighlightNormal(int highlight)
void UpdatePlacement(void)
Satisfies the superclass API.
void BuildRepresentation() override
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
void Push(double *p1, double *p2)
int ComputeComplexInteractionState(vtkRenderWindowInteractor *iren, vtkAbstractWidget *widget, unsigned long event, void *calldata, int modify=0) override
void EndComplexInteraction(vtkRenderWindowInteractor *iren, vtkAbstractWidget *widget, unsigned long event, void *calldata) override
void WidgetInteraction(double newEventPos[2]) override
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void ComplexInteraction(vtkRenderWindowInteractor *iren, vtkAbstractWidget *widget, unsigned long event, void *calldata) override
void PushPlane(double distance)
Push the plane the distance specified along the normal.
void SetEdgeColor(double x[3])
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
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)
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 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:32
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:85
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:78
abstract specification for Viewports
Definition: vtkViewport.h:45
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition: vtkWindow.h:35
@ dir
Definition: vtkX3D.h:330
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SIZEHINT(...)