VTK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 "vtkInteractionWidgetsModule.h" // For export macro
66 #include "vtk3DWidget.h"
67 
68 class vtkAbstractPropPicker;
69 class vtkActor;
70 class vtkCellArray;
71 class vtkCellPicker;
72 class vtkFloatArray;
73 class vtkGlyphSource2D;
74 class vtkPoints;
75 class vtkPolyData;
76 class vtkProp;
77 class vtkProperty;
78 class vtkPropPicker;
79 class vtkTransform;
81 
82 #define VTK_ITW_PROJECTION_YZ 0
83 #define VTK_ITW_PROJECTION_XZ 1
84 #define VTK_ITW_PROJECTION_XY 2
85 #define VTK_ITW_SNAP_CELLS 0
86 #define VTK_ITW_SNAP_POINTS 1
87 
88 class VTKINTERACTIONWIDGETS_EXPORT vtkImageTracerWidget : public vtk3DWidget
89 {
90 public:
92  static vtkImageTracerWidget *New();
93 
95  void PrintSelf(ostream& os, vtkIndent indent);
96 
98 
99  virtual void SetEnabled(int);
100  virtual void PlaceWidget(double bounds[6]);
101  void PlaceWidget()
102  {this->Superclass::PlaceWidget();}
103  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
104  double zmin, double zmax)
105  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
107 
109 
112  virtual void SetHandleProperty(vtkProperty*);
113  vtkGetObjectMacro(HandleProperty, vtkProperty);
114  virtual void SetSelectedHandleProperty(vtkProperty*);
115  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
117 
119 
121  virtual void SetLineProperty(vtkProperty*);
122  vtkGetObjectMacro(LineProperty, vtkProperty);
123  virtual void SetSelectedLineProperty(vtkProperty*);
124  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
126 
128  void SetViewProp(vtkProp* prop);
129 
131 
132  vtkSetMacro(ProjectToPlane,int);
133  vtkGetMacro(ProjectToPlane,int);
134  vtkBooleanMacro(ProjectToPlane,int);
136 
138 
142  vtkSetClampMacro(ProjectionNormal,int,VTK_ITW_PROJECTION_YZ,VTK_ITW_PROJECTION_XY);
143  vtkGetMacro(ProjectionNormal,int);
145  { this->SetProjectionNormal(0); }
147  { this->SetProjectionNormal(1); }
149  { this->SetProjectionNormal(2); }
151 
153 
158  void SetProjectionPosition(double position);
159  vtkGetMacro(ProjectionPosition,double);
161 
163 
164  void SetSnapToImage(int snap);
165  vtkGetMacro(SnapToImage,int);
166  vtkBooleanMacro(SnapToImage,int);
168 
170 
172  vtkSetMacro(AutoClose,int);
173  vtkGetMacro(AutoClose,int);
174  vtkBooleanMacro(AutoClose,int);
176 
178 
181  vtkSetMacro(CaptureRadius,double);
182  vtkGetMacro(CaptureRadius,double);
184 
190  void GetPath(vtkPolyData *pd);
191 
193  vtkGlyphSource2D* GetGlyphSource() { return this->HandleGenerator; }
194 
196 
198  vtkSetClampMacro(ImageSnapType,int,VTK_ITW_SNAP_CELLS,VTK_ITW_SNAP_POINTS);
199  vtkGetMacro(ImageSnapType,int);
201 
203 
205  void SetHandlePosition(int handle, double xyz[3]);
206  void SetHandlePosition(int handle, double x, double y, double z);
207  void GetHandlePosition(int handle, double xyz[3]);
208  double* GetHandlePosition(int handle);
210 
212 
213  vtkGetMacro(NumberOfHandles,int);
215 
217 
218  void SetInteraction(int interact);
219  vtkGetMacro(Interaction,int);
220  vtkBooleanMacro(Interaction,int);
222 
226  void InitializeHandles(vtkPoints*);
227 
229  int IsClosed();
230 
232 
233  vtkSetMacro(HandleLeftMouseButton,int);
234  vtkGetMacro(HandleLeftMouseButton,int);
235  vtkBooleanMacro(HandleLeftMouseButton,int);
236  vtkSetMacro(HandleMiddleMouseButton,int);
237  vtkGetMacro(HandleMiddleMouseButton,int);
238  vtkBooleanMacro(HandleMiddleMouseButton,int);
239  vtkSetMacro(HandleRightMouseButton,int);
240  vtkGetMacro(HandleRightMouseButton,int);
241  vtkBooleanMacro(HandleRightMouseButton,int);
243 
244 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE
245 # define SetPropA SetProp
246 # define SetPropW SetProp
247 #endif
248 
251  VTK_LEGACY(void SetProp(vtkProp* prop));
252 
253 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE
254 # undef SetPropA
255 # undef SetPropW
256  //BTX
257  VTK_LEGACY(void SetPropA(vtkProp*));
258  VTK_LEGACY(void SetPropW(vtkProp*));
259  //ETX
260 #endif
261 
262 protected:
265 
266 //BTX - manage the state of the widget
267  int State;
269  {
270  Start=0,
277  Outside
278  };
279 //ETX
280 
281  //handles the events
282  static void ProcessEvents(vtkObject* object,
283  unsigned long event,
284  void* clientdata,
285  void* calldata);
286 
287  // ProcessEvents() dispatches to these methods.
288  void OnLeftButtonDown();
289  void OnLeftButtonUp();
290  void OnMiddleButtonDown();
291  void OnMiddleButtonUp();
292  void OnRightButtonDown();
293  void OnRightButtonUp();
294  void OnMouseMove();
295 
296  void AddObservers();
297 
298  // Controlling ivars
305  double CaptureRadius; // tolerance for auto path close
308  int LastX;
309  int LastY;
310 
311  void Trace(int , int );
312  void Snap(double* );
313  void MovePoint(const double* , const double* );
314  void Translate(const double* , const double* );
315  void ClosePath();
316 
317  // 2D glyphs representing hot spots (e.g., handles)
318  vtkActor **Handle;
321 
322  // Transforms required as 2D glyphs are generated in the x-y plane
325  vtkFloatArray *TemporaryHandlePoints;
326 
327  void AppendHandles(double*);
328  void ResetHandles();
329  void AllocateHandles(const int& );
330  void AdjustHandlePosition(const int& , double*);
331  int HighlightHandle(vtkProp* ); // returns handle index or -1 on fail
332  void EraseHandle(const int& );
333  virtual void SizeHandles();
334  void InsertHandleOnLine(double* );
335 
337  vtkActor *CurrentHandle;
339 
340  vtkProp *ViewProp; // the prop we want to pick on
341  vtkPropPicker *PropPicker; // the prop's picker
342 
343  // Representation of the line
344  vtkPoints *LinePoints;
346  vtkActor *LineActor;
348  vtkIdType CurrentPoints[2];
349 
350  void HighlightLine(const int& );
351  void BuildLinesFromHandles();
352  void ResetLine(double* );
353  void AppendLine(double* );
355 
356  // Do the picking of the handles and the lines
357  vtkCellPicker *HandlePicker;
358  vtkCellPicker *LinePicker;
359  vtkAbstractPropPicker* CurrentPicker;
360 
361  // Register internal Pickers within PickingManager
362  virtual void RegisterPickers();
363 
364  // Properties used to control the appearance of selected objects and
365  // the manipulator in general.
366  vtkProperty *HandleProperty;
368  vtkProperty *LineProperty;
369  vtkProperty *SelectedLineProperty;
370  void CreateDefaultProperties();
371 
372  // Enable/Disable mouse button events
376 
377 private:
378  vtkImageTracerWidget(const vtkImageTracerWidget&); //Not implemented
379  void operator=(const vtkImageTracerWidget&); //Not implemented
380 };
381 
382 #endif
#define VTK_ITW_PROJECTION_XY
#define VTK_ITW_SNAP_POINTS
#define VTK_ITW_SNAP_CELLS
vtkProperty * SelectedHandleProperty
vtkAbstractPropPicker * CurrentPicker
transform points and associated normals and vectors for polygonal dataset
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:59
3D widget for tracing on planar props.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:82
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
vtkProperty * SelectedLineProperty
vtkTransformPolyDataFilter * TransformFilter
object to represent cell connectivity
Definition: vtkCellArray.h:49
vtkFloatArray * TemporaryHandlePoints
#define VTK_ITW_PROJECTION_YZ
vtkGlyphSource2D * HandleGenerator
vtkGlyphSource2D * GetGlyphSource()
create 2D glyphs represented by vtkPolyData
void PrintSelf(ostream &os, vtkIndent indent)
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:69
virtual void SizeHandles()
Definition: vtk3DWidget.h:145
virtual void PlaceWidget()
vtkCellPicker * HandlePicker