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 =========================================================================*/
76 #ifndef __vtkImplicitPlaneWidget_h
77 #define __vtkImplicitPlaneWidget_h
78 
80 
81 class vtkActor;
82 class vtkPolyDataMapper;
83 class vtkCellPicker;
84 class vtkConeSource;
85 class vtkLineSource;
86 class vtkSphereSource;
87 class vtkTubeFilter;
88 class vtkPlane;
89 class vtkCutter;
90 class vtkProperty;
91 class vtkImageData;
92 class vtkOutlineFilter;
93 class vtkFeatureEdges;
94 class vtkPolyData;
95 class vtkTransform;
96 
98 {
99 public:
101  static vtkImplicitPlaneWidget *New();
102 
104  void PrintSelf(ostream& os, vtkIndent indent);
105 
107 
108  virtual void SetEnabled(int);
109  virtual void PlaceWidget(double bounds[6]);
110  void PlaceWidget()
111  {this->Superclass::PlaceWidget();}
112  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
113  double zmin, double zmax)
114  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
116 
118 
119  virtual void SetOrigin(double x, double y, double z);
120  virtual void SetOrigin(double x[3]);
121  double* GetOrigin();
122  void GetOrigin(double xyz[3]);
124 
126 
127  void SetNormal(double x, double y, double z);
128  void SetNormal(double x[3]);
129  double* GetNormal();
130  void GetNormal(double xyz[3]);
132 
134 
138  void SetNormalToXAxis(int);
139  vtkGetMacro(NormalToXAxis,int);
140  vtkBooleanMacro(NormalToXAxis,int);
141  void SetNormalToYAxis(int);
142  vtkGetMacro(NormalToYAxis,int);
143  vtkBooleanMacro(NormalToYAxis,int);
144  void SetNormalToZAxis(int);
145  vtkGetMacro(NormalToZAxis,int);
146  vtkBooleanMacro(NormalToZAxis,int);
148 
150 
152  vtkSetMacro(Tubing,int);
153  vtkGetMacro(Tubing,int);
154  vtkBooleanMacro(Tubing,int);
156 
158 
162  void SetDrawPlane(int plane);
163  vtkGetMacro(DrawPlane,int);
164  vtkBooleanMacro(DrawPlane,int);
166 
168 
170  vtkSetMacro(OutlineTranslation,int);
171  vtkGetMacro(OutlineTranslation,int);
172  vtkBooleanMacro(OutlineTranslation,int);
174 
176 
178  vtkSetMacro(OutsideBounds,int);
179  vtkGetMacro(OutsideBounds,int);
180  vtkBooleanMacro(OutsideBounds,int);
182 
184 
185  vtkSetMacro(ScaleEnabled,int);
186  vtkGetMacro(ScaleEnabled,int);
187  vtkBooleanMacro(ScaleEnabled,int);
189 
191 
193  vtkSetMacro(OriginTranslation,int);
194  vtkGetMacro(OriginTranslation,int);
195  vtkBooleanMacro(OriginTranslation,int);
197 
199 
201  vtkSetClampMacro(DiagonalRatio,double,0,2);
202  vtkGetMacro(DiagonalRatio,double);
204 
207  void GetPolyData(vtkPolyData *pd);
208 
212 
217  void GetPlane(vtkPlane *plane);
218 
222  void UpdatePlacement();
223 
225  virtual void SizeHandles();
226 
228 
229  vtkGetObjectMacro(NormalProperty,vtkProperty);
230  vtkGetObjectMacro(SelectedNormalProperty,vtkProperty);
232 
234 
236  vtkGetObjectMacro(PlaneProperty,vtkProperty);
237  vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty);
239 
241 
242  vtkGetObjectMacro(OutlineProperty,vtkProperty);
243  vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
245 
247 
249  vtkGetObjectMacro(EdgesProperty,vtkProperty);
251 
252 protected:
255 
256 //BTX - manage the state of the widget
257  int State;
259  {
260  Start=0,
267  Outside
268  };
269 //ETX
270 
271  //handles the events
272  static void ProcessEvents(vtkObject* object, unsigned long event,
273  void* clientdata, void* calldata);
274 
275  // ProcessEvents() dispatches to these methods.
276  void OnLeftButtonDown();
277  void OnLeftButtonUp();
278  void OnMiddleButtonDown();
279  void OnMiddleButtonUp();
280  void OnRightButtonDown();
281  void OnRightButtonUp();
282  void OnMouseMove();
283 
284  // Controlling ivars
288  void UpdateRepresentation();
289 
290  // The actual plane which is being manipulated
292 
293  // The bounding box is represented by a single voxel image data
298  void HighlightOutline(int highlight);
299  int OutlineTranslation; //whether the outline can be moved
300  int ScaleEnabled; //whether the widget can be scaled
301  int OutsideBounds; //whether the widget can be moved outside input's bounds
302 
303  // The cut plane is produced with a vtkCutter
308  virtual void HighlightPlane(int highlight);
309 
310  // Optional tubes are represented by extracting boundary edges and tubing
315  int Tubing; //control whether tubing is on
316 
317  // Control final length of the arrow:
319 
320  // The + normal cone
324  void HighlightNormal(int highlight);
325 
326  // The + normal line
330 
331  // The - normal cone
335 
336  // The - normal line
340 
341  // The origin positioning handle
345  int OriginTranslation; //whether the origin (sphere) can be moved
346 
347  // Do the picking
349 
350  // Transform the normal (used for rotation)
352 
353  // Methods to manipulate the plane
354  void ConstrainOrigin(double x[3]);
355  void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
356  void TranslatePlane(double *p1, double *p2);
357  void TranslateOutline(double *p1, double *p2);
358  void TranslateOrigin(double *p1, double *p2);
359  void Push(double *p1, double *p2);
360  void Scale(double *p1, double *p2, int X, int Y);
361 
362  // Properties used to control the appearance of selected objects and
363  // the manipulator in general.
371  void CreateDefaultProperties();
372 
373  void GeneratePlane();
374 
375 private:
376  vtkImplicitPlaneWidget(const vtkImplicitPlaneWidget&); //Not implemented
377  void operator=(const vtkImplicitPlaneWidget&); //Not implemented
378 };
379 
380 #endif