VTK
vtkImageTracerWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkImageTracerWidget.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 =========================================================================*/
62 #ifndef __vtkImageTracerWidget_h
63 #define __vtkImageTracerWidget_h
64 
65 #include "vtk3DWidget.h"
66 
68 class vtkActor;
69 class vtkCellArray;
70 class vtkCellPicker;
71 class vtkFloatArray;
72 class vtkGlyphSource2D;
73 class vtkPoints;
74 class vtkPolyData;
75 class vtkProp;
76 class vtkProperty;
77 class vtkPropPicker;
78 class vtkTransform;
80 
81 #define VTK_ITW_PROJECTION_YZ 0
82 #define VTK_ITW_PROJECTION_XZ 1
83 #define VTK_ITW_PROJECTION_XY 2
84 #define VTK_ITW_SNAP_CELLS 0
85 #define VTK_ITW_SNAP_POINTS 1
86 
88 {
89 public:
91  static vtkImageTracerWidget *New();
92 
94  void PrintSelf(ostream& os, vtkIndent indent);
95 
97 
98  virtual void SetEnabled(int);
99  virtual void PlaceWidget(double bounds[6]);
100  void PlaceWidget()
101  {this->Superclass::PlaceWidget();}
102  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
103  double zmin, double zmax)
104  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
106 
108 
111  virtual void SetHandleProperty(vtkProperty*);
112  vtkGetObjectMacro(HandleProperty, vtkProperty);
113  virtual void SetSelectedHandleProperty(vtkProperty*);
114  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
116 
118 
120  virtual void SetLineProperty(vtkProperty*);
121  vtkGetObjectMacro(LineProperty, vtkProperty);
122  virtual void SetSelectedLineProperty(vtkProperty*);
123  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
125 
127  void SetViewProp(vtkProp* prop);
128 
130 
131  vtkSetMacro(ProjectToPlane,int);
132  vtkGetMacro(ProjectToPlane,int);
133  vtkBooleanMacro(ProjectToPlane,int);
135 
137 
141  vtkSetClampMacro(ProjectionNormal,int,VTK_ITW_PROJECTION_YZ,VTK_ITW_PROJECTION_XY);
142  vtkGetMacro(ProjectionNormal,int);
143  void SetProjectionNormalToXAxes()
144  { this->SetProjectionNormal(0); }
145  void SetProjectionNormalToYAxes()
146  { this->SetProjectionNormal(1); }
147  void SetProjectionNormalToZAxes()
148  { this->SetProjectionNormal(2); }
150 
152 
157  void SetProjectionPosition(double position);
158  vtkGetMacro(ProjectionPosition,double);
160 
162 
163  void SetSnapToImage(int snap);
164  vtkGetMacro(SnapToImage,int);
165  vtkBooleanMacro(SnapToImage,int);
167 
169 
171  vtkSetMacro(AutoClose,int);
172  vtkGetMacro(AutoClose,int);
173  vtkBooleanMacro(AutoClose,int);
175 
177 
180  vtkSetMacro(CaptureRadius,double);
181  vtkGetMacro(CaptureRadius,double);
183 
189  void GetPath(vtkPolyData *pd);
190 
192  vtkGlyphSource2D* GetGlyphSource() { return this->HandleGenerator; }
193 
195 
197  vtkSetClampMacro(ImageSnapType,int,VTK_ITW_SNAP_CELLS,VTK_ITW_SNAP_POINTS);
198  vtkGetMacro(ImageSnapType,int);
200 
202 
204  void SetHandlePosition(int handle, double xyz[3]);
205  void SetHandlePosition(int handle, double x, double y, double z);
206  void GetHandlePosition(int handle, double xyz[3]);
207  double* GetHandlePosition(int handle);
209 
211 
212  vtkGetMacro(NumberOfHandles,int);
214 
216 
217  void SetInteraction(int interact);
218  vtkGetMacro(Interaction,int);
219  vtkBooleanMacro(Interaction,int);
221 
225  void InitializeHandles(vtkPoints*);
226 
228  int IsClosed();
229 
231 
232  vtkSetMacro(HandleLeftMouseButton,int);
233  vtkGetMacro(HandleLeftMouseButton,int);
234  vtkBooleanMacro(HandleLeftMouseButton,int);
235  vtkSetMacro(HandleMiddleMouseButton,int);
236  vtkGetMacro(HandleMiddleMouseButton,int);
237  vtkBooleanMacro(HandleMiddleMouseButton,int);
238  vtkSetMacro(HandleRightMouseButton,int);
239  vtkGetMacro(HandleRightMouseButton,int);
240  vtkBooleanMacro(HandleRightMouseButton,int);
242 
243 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE
244 # define SetPropA SetProp
245 # define SetPropW SetProp
246 #endif
247 
250  VTK_LEGACY(void SetProp(vtkProp* prop));
251 
252 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE
253 # undef SetPropA
254 # undef SetPropW
255  //BTX
256  VTK_LEGACY(void SetPropA(vtkProp*));
257  VTK_LEGACY(void SetPropW(vtkProp*));
258  //ETX
259 #endif
260 
261 protected:
264 
265 //BTX - manage the state of the widget
266  int State;
268  {
269  Start=0,
276  Outside
277  };
278 //ETX
279 
280  //handles the events
281  static void ProcessEvents(vtkObject* object,
282  unsigned long event,
283  void* clientdata,
284  void* calldata);
285 
286  // ProcessEvents() dispatches to these methods.
287  void OnLeftButtonDown();
288  void OnLeftButtonUp();
289  void OnMiddleButtonDown();
290  void OnMiddleButtonUp();
291  void OnRightButtonDown();
292  void OnRightButtonUp();
293  void OnMouseMove();
294 
295  void AddObservers();
296 
297  // Controlling ivars
304  double CaptureRadius; // tolerance for auto path close
307  int LastX;
308  int LastY;
309 
310  void Trace(int , int );
311  void Snap(double* );
312  void MovePoint(const double* , const double* );
313  void Translate(const double* , const double* );
314  void ClosePath();
315 
316  // 2D glyphs representing hot spots (e.g., handles)
320 
321  // Transforms required as 2D glyphs are generated in the x-y plane
325 
326  void AppendHandles(double*);
327  void ResetHandles();
328  void AllocateHandles(const int& );
329  void AdjustHandlePosition(const int& , double*);
330  int HighlightHandle(vtkProp* ); // returns handle index or -1 on fail
331  void EraseHandle(const int& );
332  virtual void SizeHandles();
333  void InsertHandleOnLine(double* );
334 
338 
339  vtkProp *ViewProp; // the prop we want to pick on
340  vtkPropPicker *PropPicker; // the prop's picker
341 
342  // Representation of the line
347  vtkIdType CurrentPoints[2];
348 
349  void HighlightLine(const int& );
350  void BuildLinesFromHandles();
351  void ResetLine(double* );
352  void AppendLine(double* );
354 
355  // Do the picking of the handles and the lines
359 
360  // Properties used to control the appearance of selected objects and
361  // the manipulator in general.
366  void CreateDefaultProperties();
367 
368  // Enable/Disable mouse button events
372 
373 private:
374  vtkImageTracerWidget(const vtkImageTracerWidget&); //Not implemented
375  void operator=(const vtkImageTracerWidget&); //Not implemented
376 };
377 
378 #endif