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 "vtkInteractionWidgetsModule.h" // For export macro
66 #include "vtk3DWidget.h"
67 
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 
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 
249 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE
250 # undef SetPropA
251 # undef SetPropW
252 #endif
253 
254 protected:
257 
258 //BTX - manage the state of the widget
259  int State;
261  {
262  Start=0,
269  Outside
270  };
271 //ETX
272 
273  //handles the events
274  static void ProcessEvents(vtkObject* object,
275  unsigned long event,
276  void* clientdata,
277  void* calldata);
278 
279  // ProcessEvents() dispatches to these methods.
280  void OnLeftButtonDown();
281  void OnLeftButtonUp();
282  void OnMiddleButtonDown();
283  void OnMiddleButtonUp();
284  void OnRightButtonDown();
285  void OnRightButtonUp();
286  void OnMouseMove();
287 
288  void AddObservers();
289 
290  // Controlling ivars
297  double CaptureRadius; // tolerance for auto path close
300  int LastX;
301  int LastY;
302 
303  void Trace(int , int );
304  void Snap(double* );
305  void MovePoint(const double* , const double* );
306  void Translate(const double* , const double* );
307  void ClosePath();
308 
309  // 2D glyphs representing hot spots (e.g., handles)
313 
314  // Transforms required as 2D glyphs are generated in the x-y plane
318 
319  void AppendHandles(double*);
320  void ResetHandles();
321  void AllocateHandles(const int& );
322  void AdjustHandlePosition(const int& , double*);
323  int HighlightHandle(vtkProp* ); // returns handle index or -1 on fail
324  void EraseHandle(const int& );
325  virtual void SizeHandles();
326  void InsertHandleOnLine(double* );
327 
331 
332  vtkProp *ViewProp; // the prop we want to pick on
333  vtkPropPicker *PropPicker; // the prop's picker
334 
335  // Representation of the line
340  vtkIdType CurrentPoints[2];
341 
342  void HighlightLine(const int& );
343  void BuildLinesFromHandles();
344  void ResetLine(double* );
345  void AppendLine(double* );
347 
348  // Do the picking of the handles and the lines
352 
353  // Register internal Pickers within PickingManager
354  virtual void RegisterPickers();
355 
356  // Properties used to control the appearance of selected objects and
357  // the manipulator in general.
362  void CreateDefaultProperties();
363 
364  // Enable/Disable mouse button events
368 
369 private:
370  vtkImageTracerWidget(const vtkImageTracerWidget&); //Not implemented
371  void operator=(const vtkImageTracerWidget&); //Not implemented
372 };
373 
374 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:52
#define VTK_ITW_PROJECTION_XY
#define VTK_ITW_SNAP_POINTS
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
abstract base class for most VTK objects
Definition: vtkObject.h:61
pick an actor/prop using graphics hardware
Definition: vtkPropPicker.h:44
represent surface properties of a geometric object
Definition: vtkProperty.h:63
#define VTK_ITW_SNAP_CELLS
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
vtkProperty * SelectedHandleProperty
vtkAbstractPropPicker * CurrentPicker
virtual void SetEnabled(int)
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:45
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.
int vtkIdType
Definition: vtkType.h:275
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:83
virtual void RegisterPickers()
#define VTKINTERACTIONWIDGETS_EXPORT
a simple class to control print indentation
Definition: vtkIndent.h:38
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
abstract API for pickers that can pick an instance of vtkProp
vtkFloatArray * TemporaryHandlePoints
#define VTK_ITW_PROJECTION_YZ
vtkGlyphSource2D * HandleGenerator
vtkGlyphSource2D * GetGlyphSource()
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:68
create 2D glyphs represented by vtkPolyData
static vtkObject * New()
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()
represent and manipulate 3D points
Definition: vtkPoints.h:38
vtkCellPicker * HandlePicker