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  int 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 
410 
411 protected:
413  ~vtkImplicitPlaneRepresentation() override;
414 
416 
417  // Keep track of event positions
418  double LastEventPosition[3];
419  double LastEventOrientation[4];
420  double StartEventOrientation[4];
421 
422  // Controlling ivars
426 
427  // Locking normal to camera
429 
430  // Controlling the push operation
431  double BumpDistance;
432 
433  // The actual plane which is being manipulated
435 
436  // The bounding box is represented by a single voxel image data
441  void HighlightOutline(int highlight);
442  vtkTypeBool OutlineTranslation; //whether the outline can be moved
443  vtkTypeBool ScaleEnabled; //whether the widget can be scaled
444  vtkTypeBool OutsideBounds; //whether the widget can be moved outside input's bounds
445  double WidgetBounds[6];
447 
448  // The cut plane is produced with a vtkCutter
455  void HighlightPlane(int highlight);
456 
457  // Optional tubes are represented by extracting boundary edges and tubing
462  vtkTypeBool Tubing; //control whether tubing is on
463 
464  // The + normal cone
468  void HighlightNormal(int highlight);
469 
470  // The + normal line
474 
475  // The - normal cone
479 
480  // The - normal line
484 
485  // The origin positioning handle
489 
490  // Do the picking
492 
493  // Register internal Pickers within PickingManager
494  void RegisterPickers() override;
495 
496  // Transform the normal (used for rotation)
498 
499  // Methods to manipulate the plane
500  void Rotate(double X, double Y, double *p1, double *p2, double *vpn);
501  void Rotate3D(double *p1, double *p2);
502  void TranslatePlane(double *p1, double *p2);
503  void TranslateOutline(double *p1, double *p2);
504  void TranslateOrigin(double *p1, double *p2);
505  void UpdatePose(double *p1, double *d1, double *p2, double *d2);
506  void Push(double *p1, double *p2);
507  void Scale(double *p1, double *p2, double X, double Y);
508  void SizeHandles();
509 
510  // Properties used to control the appearance of selected objects and
511  // the manipulator in general.
519  void CreateDefaultProperties();
520 
521  void GeneratePlane();
522 
524 
525  // Support GetBounds() method
527 
528 private:
530  void operator=(const vtkImplicitPlaneRepresentation&) = delete;
531 };
532 
533 #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