VTK
vtkImplicitPlaneWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkImplicitPlaneWidget.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 =========================================================================*/
72 #ifndef vtkImplicitPlaneWidget_h
73 #define vtkImplicitPlaneWidget_h
74 
75 #include "vtkInteractionWidgetsModule.h" // For export macro
77 
78 class vtkActor;
79 class vtkPolyDataMapper;
80 class vtkCellPicker;
81 class vtkConeSource;
82 class vtkLineSource;
83 class vtkSphereSource;
84 class vtkTubeFilter;
85 class vtkPlane;
86 class vtkCutter;
87 class vtkProperty;
88 class vtkImageData;
89 class vtkOutlineFilter;
90 class vtkFeatureEdges;
91 class vtkPolyData;
92 class vtkTransform;
93 
95 {
96 public:
98  static vtkImplicitPlaneWidget *New();
99 
101  void PrintSelf(ostream& os, vtkIndent indent);
102 
104 
105  virtual void SetEnabled(int);
106  virtual void PlaceWidget(double bounds[6]);
107  void PlaceWidget()
108  {this->Superclass::PlaceWidget();}
109  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
110  double zmin, double zmax)
111  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
113 
115 
116  virtual void SetOrigin(double x, double y, double z);
117  virtual void SetOrigin(double x[3]);
118  double* GetOrigin();
119  void GetOrigin(double xyz[3]);
121 
123 
124  void SetNormal(double x, double y, double z);
125  void SetNormal(double x[3]);
126  double* GetNormal();
127  void GetNormal(double xyz[3]);
129 
131 
135  void SetNormalToXAxis(int);
136  vtkGetMacro(NormalToXAxis,int);
137  vtkBooleanMacro(NormalToXAxis,int);
138  void SetNormalToYAxis(int);
139  vtkGetMacro(NormalToYAxis,int);
140  vtkBooleanMacro(NormalToYAxis,int);
141  void SetNormalToZAxis(int);
142  vtkGetMacro(NormalToZAxis,int);
143  vtkBooleanMacro(NormalToZAxis,int);
145 
147 
149  vtkSetMacro(Tubing,int);
150  vtkGetMacro(Tubing,int);
151  vtkBooleanMacro(Tubing,int);
153 
155 
159  void SetDrawPlane(int plane);
160  vtkGetMacro(DrawPlane,int);
161  vtkBooleanMacro(DrawPlane,int);
163 
165 
167  vtkSetMacro(OutlineTranslation,int);
168  vtkGetMacro(OutlineTranslation,int);
169  vtkBooleanMacro(OutlineTranslation,int);
171 
173 
175  vtkSetMacro(OutsideBounds,int);
176  vtkGetMacro(OutsideBounds,int);
177  vtkBooleanMacro(OutsideBounds,int);
179 
181 
182  vtkSetMacro(ScaleEnabled,int);
183  vtkGetMacro(ScaleEnabled,int);
184  vtkBooleanMacro(ScaleEnabled,int);
186 
188 
190  vtkSetMacro(OriginTranslation,int);
191  vtkGetMacro(OriginTranslation,int);
192  vtkBooleanMacro(OriginTranslation,int);
194 
196 
198  vtkSetClampMacro(DiagonalRatio,double,0,2);
199  vtkGetMacro(DiagonalRatio,double);
201 
204  void GetPolyData(vtkPolyData *pd);
205 
209 
214  void GetPlane(vtkPlane *plane);
215 
219  void UpdatePlacement();
220 
222  virtual void SizeHandles();
223 
225 
226  vtkGetObjectMacro(NormalProperty,vtkProperty);
227  vtkGetObjectMacro(SelectedNormalProperty,vtkProperty);
229 
231 
233  vtkGetObjectMacro(PlaneProperty,vtkProperty);
234  vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty);
236 
238 
239  vtkGetObjectMacro(OutlineProperty,vtkProperty);
240  vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
242 
244 
246  vtkGetObjectMacro(EdgesProperty,vtkProperty);
248 
249 protected:
252 
253  // Manage the state of the widget
254  int State;
256  {
257  Start=0,
264  Outside
265  };
266 
267  //handles the events
268  static void ProcessEvents(vtkObject* object, unsigned long event,
269  void* clientdata, void* calldata);
270 
271  // ProcessEvents() dispatches to these methods.
272  void OnLeftButtonDown();
273  void OnLeftButtonUp();
274  void OnMiddleButtonDown();
275  void OnMiddleButtonUp();
276  void OnRightButtonDown();
277  void OnRightButtonUp();
278  void OnMouseMove();
279 
280  // Controlling ivars
284  void UpdateRepresentation();
285 
286  // The actual plane which is being manipulated
288 
289  // The bounding box is represented by a single voxel image data
294  void HighlightOutline(int highlight);
295  int OutlineTranslation; //whether the outline can be moved
296  int ScaleEnabled; //whether the widget can be scaled
297  int OutsideBounds; //whether the widget can be moved outside input's bounds
298 
299  // The cut plane is produced with a vtkCutter
304  virtual void HighlightPlane(int highlight);
305 
306  // Optional tubes are represented by extracting boundary edges and tubing
311  int Tubing; //control whether tubing is on
312 
313  // Control final length of the arrow:
315 
316  // The + normal cone
320  void HighlightNormal(int highlight);
321 
322  // The + normal line
326 
327  // The - normal cone
331 
332  // The - normal line
336 
337  // The origin positioning handle
341  int OriginTranslation; //whether the origin (sphere) can be moved
342 
343  // Do the picking
345 
346  // Register internal Pickers within PickingManager
347  virtual void RegisterPickers();
348 
349  // Transform the normal (used for rotation)
351 
352  // Methods to manipulate the plane
353  void ConstrainOrigin(double x[3]);
354  void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
355  void TranslatePlane(double *p1, double *p2);
356  void TranslateOutline(double *p1, double *p2);
357  void TranslateOrigin(double *p1, double *p2);
358  void Push(double *p1, double *p2);
359  void Scale(double *p1, double *p2, int X, int Y);
360 
361  // Properties used to control the appearance of selected objects and
362  // the manipulator in general.
370  void CreateDefaultProperties();
371 
372  void GeneratePlane();
373 
374 private:
375  vtkImplicitPlaneWidget(const vtkImplicitPlaneWidget&); //Not implemented
376  void operator=(const vtkImplicitPlaneWidget&); //Not implemented
377 };
378 
379 #endif
3D widget for manipulating an infinite plane
virtual vtkPolyDataAlgorithm * GetPolyDataAlgorithm()=0
void PrintSelf(ostream &os, vtkIndent indent)
Cut vtkDataSet with user-specified implicit function.
Definition: vtkCutter.h:68
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
abstract base class for most VTK objects
Definition: vtkObject.h:61
abstract PolyDataSource-based 3D widget
vtkPolyDataMapper * ConeMapper
represent surface properties of a geometric object
Definition: vtkProperty.h:63
vtkPolyDataMapper * EdgesMapper
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
virtual void SetEnabled(int)
vtkPolyDataMapper * CutMapper
generate polygonal cone
Definition: vtkConeSource.h:43
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:59
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
virtual void UpdatePlacement()=0
virtual void RegisterPickers()
#define VTKINTERACTIONWIDGETS_EXPORT
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:82
a simple class to control print indentation
Definition: vtkIndent.h:38
extract boundary, non-manifold, and/or sharp edges from polygonal data
topologically and geometrically regular array of data
Definition: vtkImageData.h:44
perform various plane computations
Definition: vtkPlane.h:36
vtkPolyDataMapper * OutlineMapper
vtkPolyDataMapper * ConeMapper2
virtual void PlaceWidget()
create a line defined by two end points
Definition: vtkLineSource.h:41
map vtkPolyData to graphics primitives
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:68
vtkPolyDataMapper * LineMapper
static vtkObject * New()
vtkPolyDataMapper * LineMapper2
virtual void SizeHandles()
Definition: vtk3DWidget.h:145
virtual void PlaceWidget()
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
vtkPolyDataMapper * SphereMapper