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 =========================================================================*/
60 #ifndef vtkImageTracerWidget_h
61 #define vtkImageTracerWidget_h
62 
63 #include "vtkInteractionWidgetsModule.h" // For export macro
64 #include "vtk3DWidget.h"
65 
67 class vtkActor;
68 class vtkCellArray;
69 class vtkCellPicker;
70 class vtkFloatArray;
71 class vtkGlyphSource2D;
72 class vtkPoints;
73 class vtkPolyData;
74 class vtkProp;
75 class vtkProperty;
76 class vtkPropPicker;
77 class vtkTransform;
79 
80 #define VTK_ITW_PROJECTION_YZ 0
81 #define VTK_ITW_PROJECTION_XZ 1
82 #define VTK_ITW_PROJECTION_XY 2
83 #define VTK_ITW_SNAP_CELLS 0
84 #define VTK_ITW_SNAP_POINTS 1
85 
86 class VTKINTERACTIONWIDGETS_EXPORT vtkImageTracerWidget : public vtk3DWidget
87 {
88 public:
92  static vtkImageTracerWidget *New();
93 
95  void PrintSelf(ostream& os, vtkIndent indent);
96 
98 
101  virtual void SetEnabled(int);
102  virtual void PlaceWidget(double bounds[6]);
103  void PlaceWidget()
104  {this->Superclass::PlaceWidget();}
105  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
106  double zmin, double zmax)
107  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
109 
111 
115  virtual void SetHandleProperty(vtkProperty*);
116  vtkGetObjectMacro(HandleProperty, vtkProperty);
117  virtual void SetSelectedHandleProperty(vtkProperty*);
118  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
120 
122 
126  virtual void SetLineProperty(vtkProperty*);
127  vtkGetObjectMacro(LineProperty, vtkProperty);
128  virtual void SetSelectedLineProperty(vtkProperty*);
129  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
131 
135  void SetViewProp(vtkProp* prop);
136 
138 
141  vtkSetMacro(ProjectToPlane,int);
142  vtkGetMacro(ProjectToPlane,int);
143  vtkBooleanMacro(ProjectToPlane,int);
145 
147 
153  vtkSetClampMacro(ProjectionNormal,int,VTK_ITW_PROJECTION_YZ,VTK_ITW_PROJECTION_XY);
154  vtkGetMacro(ProjectionNormal,int);
156  { this->SetProjectionNormal(0); }
158  { this->SetProjectionNormal(1); }
160  { this->SetProjectionNormal(2); }
162 
164 
171  void SetProjectionPosition(double position);
172  vtkGetMacro(ProjectionPosition,double);
174 
176 
179  void SetSnapToImage(int snap);
180  vtkGetMacro(SnapToImage,int);
181  vtkBooleanMacro(SnapToImage,int);
183 
185 
190  vtkSetMacro(AutoClose,int);
191  vtkGetMacro(AutoClose,int);
192  vtkBooleanMacro(AutoClose,int);
194 
196 
202  vtkSetMacro(CaptureRadius,double);
203  vtkGetMacro(CaptureRadius,double);
205 
212  void GetPath(vtkPolyData *pd);
213 
217  vtkGlyphSource2D* GetGlyphSource() { return this->HandleGenerator; }
218 
220 
224  vtkSetClampMacro(ImageSnapType,int,VTK_ITW_SNAP_CELLS,VTK_ITW_SNAP_POINTS);
225  vtkGetMacro(ImageSnapType,int);
227 
229 
232  void SetHandlePosition(int handle, double xyz[3]);
233  void SetHandlePosition(int handle, double x, double y, double z);
234  void GetHandlePosition(int handle, double xyz[3]);
235  double* GetHandlePosition(int handle);
237 
239 
242  vtkGetMacro(NumberOfHandles,int);
244 
246 
249  void SetInteraction(int interact);
250  vtkGetMacro(Interaction,int);
251  vtkBooleanMacro(Interaction,int);
253 
259  void InitializeHandles(vtkPoints*);
260 
264  int IsClosed();
265 
267 
270  vtkSetMacro(HandleLeftMouseButton,int);
271  vtkGetMacro(HandleLeftMouseButton,int);
272  vtkBooleanMacro(HandleLeftMouseButton,int);
273  vtkSetMacro(HandleMiddleMouseButton,int);
274  vtkGetMacro(HandleMiddleMouseButton,int);
275  vtkBooleanMacro(HandleMiddleMouseButton,int);
276  vtkSetMacro(HandleRightMouseButton,int);
277  vtkGetMacro(HandleRightMouseButton,int);
278  vtkBooleanMacro(HandleRightMouseButton,int);
280 
281 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE
282 # define SetPropA SetProp
283 # define SetPropW SetProp
284 #endif
285 
286 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE
287 # undef SetPropA
288 # undef SetPropW
289 #endif
290 
291 protected:
294 
295  // Manage the state of the widget
296  int State;
298  {
299  Start=0,
306  Outside
307  };
308 
309  //handles the events
310  static void ProcessEvents(vtkObject* object,
311  unsigned long event,
312  void* clientdata,
313  void* calldata);
314 
315  // ProcessEvents() dispatches to these methods.
316  void OnLeftButtonDown();
317  void OnLeftButtonUp();
318  void OnMiddleButtonDown();
319  void OnMiddleButtonUp();
320  void OnRightButtonDown();
321  void OnRightButtonUp();
322  void OnMouseMove();
323 
324  void AddObservers();
325 
326  // Controlling ivars
333  double CaptureRadius; // tolerance for auto path close
336  int LastX;
337  int LastY;
338 
339  void Trace(int , int );
340  void Snap(double* );
341  void MovePoint(const double* , const double* );
342  void Translate(const double* , const double* );
343  void ClosePath();
344 
345  // 2D glyphs representing hot spots (e.g., handles)
349 
350  // Transforms required as 2D glyphs are generated in the x-y plane
354 
355  void AppendHandles(double*);
356  void ResetHandles();
357  void AllocateHandles(const int& );
358  void AdjustHandlePosition(const int& , double*);
359  int HighlightHandle(vtkProp* ); // returns handle index or -1 on fail
360  void EraseHandle(const int& );
361  virtual void SizeHandles();
362  void InsertHandleOnLine(double* );
363 
367 
368  vtkProp *ViewProp; // the prop we want to pick on
369  vtkPropPicker *PropPicker; // the prop's picker
370 
371  // Representation of the line
376  vtkIdType CurrentPoints[2];
377 
378  void HighlightLine(const int& );
379  void BuildLinesFromHandles();
380  void ResetLine(double* );
381  void AppendLine(double* );
383 
384  // Do the picking of the handles and the lines
388 
389  // Register internal Pickers within PickingManager
390  virtual void RegisterPickers();
391 
392  // Properties used to control the appearance of selected objects and
393  // the manipulator in general.
398  void CreateDefaultProperties();
399 
400  // Enable/Disable mouse button events
404 
405 private:
406  vtkImageTracerWidget(const vtkImageTracerWidget&) VTK_DELETE_FUNCTION;
407  void operator=(const vtkImageTracerWidget&) VTK_DELETE_FUNCTION;
408 };
409 
410 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:50
#define VTK_ITW_PROJECTION_XY
#define VTK_ITW_SNAP_POINTS
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
abstract base class for most VTK objects
Definition: vtkObject.h:59
pick an actor/prop using graphics hardware
Definition: vtkPropPicker.h:42
represent surface properties of a geometric object
Definition: vtkProperty.h:64
#define VTK_ITW_SNAP_CELLS
void SetProjectionNormalToXAxes()
Set the projection normal.
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Handles the char widget activation event.
vtkProperty * SelectedHandleProperty
vtkAbstractPropPicker * CurrentPicker
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:41
transform points and associated normals and vectors for polygonal dataset
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
3D widget for tracing on planar props.
int vtkIdType
Definition: vtkType.h:287
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
void SetProjectionNormalToYAxes()
Set the projection normal.
a simple class to control print indentation
Definition: vtkIndent.h:39
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
Methods that satisfy the superclass' API.
void PlaceWidget()
Methods that satisfy the superclass' API.
void SetProjectionNormalToZAxes()
Set the projection normal.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
vtkProperty * SelectedLineProperty
vtkTransformPolyDataFilter * TransformFilter
object to represent cell connectivity
Definition: vtkCellArray.h:50
abstract API for pickers that can pick an instance of vtkProp
vtkFloatArray * TemporaryHandlePoints
#define VTK_ITW_PROJECTION_YZ
vtkGlyphSource2D * HandleGenerator
vtkGlyphSource2D * GetGlyphSource()
Get the handles' geometric representation via vtkGlyphSource2D.
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:69
create 2D glyphs represented by vtkPolyData
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:67
virtual void SizeHandles()
Definition: vtk3DWidget.h:152
virtual void PlaceWidget()
This method is used to initially place the widget.
represent and manipulate 3D points
Definition: vtkPoints.h:39
vtkCellPicker * HandlePicker