VTK
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 "vtkInteractionWidgetsModule.h" // For export macro
46 
47 class vtkActor;
48 class vtkPolyDataMapper;
49 class vtkCellPicker;
50 class vtkConeSource;
51 class vtkLineSource;
52 class vtkSphereSource;
53 class vtkTubeFilter;
54 class vtkPlane;
55 class vtkPlaneSource;
56 class vtkCutter;
57 class vtkProperty;
58 class vtkImageData;
59 class vtkOutlineFilter;
60 class vtkFeatureEdges;
61 class vtkPolyData;
63 class vtkTransform;
64 class vtkBox;
65 class vtkLookupTable;
66 
67 class VTKINTERACTIONWIDGETS_EXPORT vtkImplicitPlaneRepresentation : public vtkWidgetRepresentation
68 {
69 public:
74 
76 
80  void PrintSelf(ostream& os, vtkIndent indent) override;
82 
84 
87  void SetOrigin(double x, double y, double z);
88  void SetOrigin(double x[3]);
89  double* GetOrigin() VTK_SIZEHINT(3);
90  void GetOrigin(double xyz[3]);
92 
94 
97  void SetNormal(double x, double y, double z);
98  void SetNormal(double x[3]);
99  void SetNormalToCamera();
100  double* GetNormal() VTK_SIZEHINT(3);
101  void GetNormal(double xyz[3]);
103 
105 
112  void SetNormalToXAxis(vtkTypeBool);
113  vtkGetMacro(NormalToXAxis,vtkTypeBool);
114  vtkBooleanMacro(NormalToXAxis,vtkTypeBool);
115  void SetNormalToYAxis(vtkTypeBool);
116  vtkGetMacro(NormalToYAxis,vtkTypeBool);
117  vtkBooleanMacro(NormalToYAxis,vtkTypeBool);
118  void SetNormalToZAxis(vtkTypeBool);
119  vtkGetMacro(NormalToZAxis,vtkTypeBool);
120  vtkBooleanMacro(NormalToZAxis,vtkTypeBool);
122 
124 
129  virtual void SetLockNormalToCamera(vtkTypeBool);
130  vtkGetMacro(LockNormalToCamera,vtkTypeBool);
131  vtkBooleanMacro(LockNormalToCamera,vtkTypeBool);
133 
135 
139  vtkSetMacro(Tubing,vtkTypeBool);
140  vtkGetMacro(Tubing,vtkTypeBool);
141  vtkBooleanMacro(Tubing,vtkTypeBool);
143 
145 
151  void SetDrawPlane(vtkTypeBool plane);
152  vtkGetMacro(DrawPlane,vtkTypeBool);
153  vtkBooleanMacro(DrawPlane,vtkTypeBool);
155 
157 
160  void SetDrawOutline(vtkTypeBool plane);
161  vtkGetMacro(DrawOutline,vtkTypeBool);
162  vtkBooleanMacro(DrawOutline,vtkTypeBool);
164 
166 
170  vtkSetMacro(OutlineTranslation,vtkTypeBool);
171  vtkGetMacro(OutlineTranslation,vtkTypeBool);
172  vtkBooleanMacro(OutlineTranslation,vtkTypeBool);
174 
176 
180  vtkSetMacro(OutsideBounds,vtkTypeBool);
181  vtkGetMacro(OutsideBounds,vtkTypeBool);
182  vtkBooleanMacro(OutsideBounds,vtkTypeBool);
184 
186 
192  vtkSetVector6Macro(WidgetBounds, double);
193  vtkGetVector6Macro(WidgetBounds, double);
195 
197 
204  vtkSetMacro(ConstrainToWidgetBounds,vtkTypeBool);
205  vtkGetMacro(ConstrainToWidgetBounds,vtkTypeBool);
206  vtkBooleanMacro(ConstrainToWidgetBounds,vtkTypeBool);
208 
210 
213  vtkSetMacro(ScaleEnabled,vtkTypeBool);
214  vtkGetMacro(ScaleEnabled,vtkTypeBool);
215  vtkBooleanMacro(ScaleEnabled,vtkTypeBool);
217 
222  void GetPolyData(vtkPolyData *pd);
223 
228  vtkPolyDataAlgorithm* GetPolyDataAlgorithm();
229 
237  void GetPlane(vtkPlane *plane);
238 
244  void SetPlane(vtkPlane *plane);
245 
250  void UpdatePlacement(void);
251 
253 
256  vtkGetObjectMacro(NormalProperty,vtkProperty);
257  vtkGetObjectMacro(SelectedNormalProperty,vtkProperty);
259 
261 
265  vtkGetObjectMacro(PlaneProperty,vtkProperty);
266  vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty);
268 
270 
273  vtkGetObjectMacro(OutlineProperty,vtkProperty);
274  vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
276 
278 
282  vtkGetObjectMacro(EdgesProperty,vtkProperty);
284 
285 
288  void SetEdgeColor(vtkLookupTable*);
289  void SetEdgeColor(double, double, double);
290  void SetEdgeColor(double x[3]);
292 
294 
299  vtkSetClampMacro(BumpDistance,double,0.000001,1);
300  vtkGetMacro(BumpDistance,double);
302 
311  void BumpPlane(int dir, double factor);
312 
319  void PushPlane(double distance);
320 
322 
325  int ComputeInteractionState(int X, int Y, int modify=0) override;
326  void PlaceWidget(double bounds[6]) override;
327  void BuildRepresentation() override;
328  void StartWidgetInteraction(double eventPos[2]) override;
329  void WidgetInteraction(double newEventPos[2]) override;
330  void EndWidgetInteraction(double newEventPos[2]) override;
331  void StartComplexInteraction(
333  vtkAbstractWidget *widget,
334  unsigned long event, void *calldata) override;
335  void ComplexInteraction(
337  vtkAbstractWidget *widget,
338  unsigned long event, void *calldata) override;
339  int ComputeComplexInteractionState(
341  vtkAbstractWidget *widget,
342  unsigned long event, void *calldata, int modify = 0) override;
343  void EndComplexInteraction(
345  vtkAbstractWidget *widget,
346  unsigned long event, void *calldata) override;
348 
350 
353  double *GetBounds() VTK_SIZEHINT(6) override;
354  void GetActors(vtkPropCollection *pc) override;
355  void ReleaseGraphicsResources(vtkWindow*) override;
356  int RenderOpaqueGeometry(vtkViewport*) override;
357  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
358  vtkTypeBool HasTranslucentPolygonalGeometry() override;
360 
361  // Manage the state of the widget
363  {
364  Outside=0,
370  Scaling
371  };
372 
374 
383  vtkSetClampMacro(InteractionState,int,Outside,Scaling);
385 
387 
391  virtual void SetRepresentationState(int);
392  vtkGetMacro(RepresentationState, int);
394 
395  // Get the underlying plane object used by this rep
396  // this can be used as a cropping plane in vtkMapper
398  return this->Plane; }
399 
401 
405  virtual void SetCropPlaneToBoundingBox(bool);
406  vtkGetMacro(CropPlaneToBoundingBox,bool);
407  vtkBooleanMacro(CropPlaneToBoundingBox,bool);
409 
411 
415  vtkGetMacro(SnapToAxes, bool);
416  vtkSetMacro(SnapToAxes, bool);
418 
419 protected:
421  ~vtkImplicitPlaneRepresentation() override;
422 
424 
425  // Keep track of event positions
426  double LastEventPosition[3];
427  double LastEventOrientation[4];
428  double StartEventOrientation[4];
429 
430  // Controlling ivars
434 
435  double SnappedEventOrientation[4];
438 
439  // Locking normal to camera
441 
442  // Controlling the push operation
443  double BumpDistance;
444 
445  // The actual plane which is being manipulated
447 
448  // The bounding box is represented by a single voxel image data
453  void HighlightOutline(int highlight);
454  vtkTypeBool OutlineTranslation; //whether the outline can be moved
455  vtkTypeBool ScaleEnabled; //whether the widget can be scaled
456  vtkTypeBool OutsideBounds; //whether the widget can be moved outside input's bounds
457  double WidgetBounds[6];
459 
460  // The cut plane is produced with a vtkCutter
467  void HighlightPlane(int highlight);
468 
469  // Optional tubes are represented by extracting boundary edges and tubing
474  vtkTypeBool Tubing; //control whether tubing is on
475 
476  // The + normal cone
480  void HighlightNormal(int highlight);
481 
482  // The + normal line
486 
487  // The - normal cone
491 
492  // The - normal line
496 
497  // The origin positioning handle
501 
502  // Do the picking
504 
505  // Register internal Pickers within PickingManager
506  void RegisterPickers() override;
507 
508  // Transform the normal (used for rotation)
510 
511  // Methods to manipulate the plane
512  void Rotate(double X, double Y, double *p1, double *p2, double *vpn);
513  void Rotate3D(double *p1, double *p2);
514  void TranslatePlane(double *p1, double *p2);
515  void TranslateOutline(double *p1, double *p2);
516  void TranslateOrigin(double *p1, double *p2);
517  void UpdatePose(double *p1, double *d1, double *p2, double *d2);
518  void Push(double *p1, double *p2);
519  void Scale(double *p1, double *p2, double X, double Y);
520  void SizeHandles();
521 
522  // Properties used to control the appearance of selected objects and
523  // the manipulator in general.
531  void CreateDefaultProperties();
532 
533  void GeneratePlane();
534 
536 
537  // Support GetBounds() method
539 
540 private:
542  void operator=(const vtkImplicitPlaneRepresentation&) = delete;
543 };
544 
545 #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:69
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
abstract specification for Viewports
Definition: vtkViewport.h:47
represent surface properties of a geometric object
Definition: vtkProperty.h:66
map scalar values into colors via a lookup table
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:85
abstract class defines interface between the widget and widget representation classes ...
an ordered list of Props
int vtkTypeBool
Definition: vtkABI.h:69
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
platform-independent render window interaction including picking and frame rate control.
create wireframe outline for arbitrary data set
create a polygonal sphere centered at the origin
Superclass for algorithms that produce only polydata as output.
filter that generates tubes around lines
Definition: vtkTubeFilter.h:83
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 boundary, non-manifold, and/or sharp edges from polygonal data
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
perform various plane computations
Definition: vtkPlane.h:37
#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:42
map vtkPolyData to graphics primitives
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:69
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