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  // Manage the state of the widget
259  int State;
261  {
262  Start=0,
269  Outside
270  };
271 
272  //handles the events
273  static void ProcessEvents(vtkObject* object,
274  unsigned long event,
275  void* clientdata,
276  void* calldata);
277 
278  // ProcessEvents() dispatches to these methods.
279  void OnLeftButtonDown();
280  void OnLeftButtonUp();
281  void OnMiddleButtonDown();
282  void OnMiddleButtonUp();
283  void OnRightButtonDown();
284  void OnRightButtonUp();
285  void OnMouseMove();
286 
287  void AddObservers();
288 
289  // Controlling ivars
296  double CaptureRadius; // tolerance for auto path close
299  int LastX;
300  int LastY;
301 
302  void Trace(int , int );
303  void Snap(double* );
304  void MovePoint(const double* , const double* );
305  void Translate(const double* , const double* );
306  void ClosePath();
307 
308  // 2D glyphs representing hot spots (e.g., handles)
312 
313  // Transforms required as 2D glyphs are generated in the x-y plane
317 
318  void AppendHandles(double*);
319  void ResetHandles();
320  void AllocateHandles(const int& );
321  void AdjustHandlePosition(const int& , double*);
322  int HighlightHandle(vtkProp* ); // returns handle index or -1 on fail
323  void EraseHandle(const int& );
324  virtual void SizeHandles();
325  void InsertHandleOnLine(double* );
326 
330 
331  vtkProp *ViewProp; // the prop we want to pick on
332  vtkPropPicker *PropPicker; // the prop's picker
333 
334  // Representation of the line
339  vtkIdType CurrentPoints[2];
340 
341  void HighlightLine(const int& );
342  void BuildLinesFromHandles();
343  void ResetLine(double* );
344  void AppendLine(double* );
346 
347  // Do the picking of the handles and the lines
351 
352  // Register internal Pickers within PickingManager
353  virtual void RegisterPickers();
354 
355  // Properties used to control the appearance of selected objects and
356  // the manipulator in general.
361  void CreateDefaultProperties();
362 
363  // Enable/Disable mouse button events
367 
368 private:
369  vtkImageTracerWidget(const vtkImageTracerWidget&); //Not implemented
370  void operator=(const vtkImageTracerWidget&); //Not implemented
371 };
372 
373 #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:247
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
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