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 =========================================================================*/
54 #ifndef vtkImageTracerWidget_h
55 #define vtkImageTracerWidget_h
56 
57 #include "vtkInteractionWidgetsModule.h" // For export macro
58 #include "vtk3DWidget.h"
59 
61 class vtkActor;
62 class vtkCellArray;
63 class vtkCellPicker;
64 class vtkFloatArray;
65 class vtkGlyphSource2D;
66 class vtkPoints;
67 class vtkPolyData;
68 class vtkProp;
69 class vtkProperty;
70 class vtkPropPicker;
71 class vtkTransform;
73 
74 #define VTK_ITW_PROJECTION_YZ 0
75 #define VTK_ITW_PROJECTION_XZ 1
76 #define VTK_ITW_PROJECTION_XY 2
77 #define VTK_ITW_SNAP_CELLS 0
78 #define VTK_ITW_SNAP_POINTS 1
79 
80 class VTKINTERACTIONWIDGETS_EXPORT vtkImageTracerWidget : public vtk3DWidget
81 {
82 public:
86  static vtkImageTracerWidget *New();
87 
89  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
90 
92 
95  void SetEnabled(int) VTK_OVERRIDE;
96  void PlaceWidget(double bounds[6]) VTK_OVERRIDE;
97  void PlaceWidget() VTK_OVERRIDE
98  {this->Superclass::PlaceWidget();}
99  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
100  double zmin, double zmax) VTK_OVERRIDE
101  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
103 
105 
109  virtual void SetHandleProperty(vtkProperty*);
110  vtkGetObjectMacro(HandleProperty, vtkProperty);
111  virtual void SetSelectedHandleProperty(vtkProperty*);
112  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
114 
116 
120  virtual void SetLineProperty(vtkProperty*);
121  vtkGetObjectMacro(LineProperty, vtkProperty);
122  virtual void SetSelectedLineProperty(vtkProperty*);
123  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
125 
129  void SetViewProp(vtkProp* prop);
130 
132 
135  vtkSetMacro(ProjectToPlane,int);
136  vtkGetMacro(ProjectToPlane,int);
137  vtkBooleanMacro(ProjectToPlane,int);
139 
141 
147  vtkSetClampMacro(ProjectionNormal,int,VTK_ITW_PROJECTION_YZ,VTK_ITW_PROJECTION_XY);
148  vtkGetMacro(ProjectionNormal,int);
150  { this->SetProjectionNormal(0); }
152  { this->SetProjectionNormal(1); }
154  { this->SetProjectionNormal(2); }
156 
158 
165  void SetProjectionPosition(double position);
166  vtkGetMacro(ProjectionPosition,double);
168 
170 
173  void SetSnapToImage(int snap);
174  vtkGetMacro(SnapToImage,int);
175  vtkBooleanMacro(SnapToImage,int);
177 
179 
184  vtkSetMacro(AutoClose,int);
185  vtkGetMacro(AutoClose,int);
186  vtkBooleanMacro(AutoClose,int);
188 
190 
196  vtkSetMacro(CaptureRadius,double);
197  vtkGetMacro(CaptureRadius,double);
199 
206  void GetPath(vtkPolyData *pd);
207 
211  vtkGlyphSource2D* GetGlyphSource() { return this->HandleGenerator; }
212 
214 
218  vtkSetClampMacro(ImageSnapType,int,VTK_ITW_SNAP_CELLS,VTK_ITW_SNAP_POINTS);
219  vtkGetMacro(ImageSnapType,int);
221 
223 
226  void SetHandlePosition(int handle, double xyz[3]);
227  void SetHandlePosition(int handle, double x, double y, double z);
228  void GetHandlePosition(int handle, double xyz[3]);
229  double* GetHandlePosition(int handle);
231 
233 
236  vtkGetMacro(NumberOfHandles,int);
238 
240 
243  void SetInteraction(int interact);
244  vtkGetMacro(Interaction,int);
245  vtkBooleanMacro(Interaction,int);
247 
253  void InitializeHandles(vtkPoints*);
254 
258  int IsClosed();
259 
261 
264  vtkSetMacro(HandleLeftMouseButton,int);
265  vtkGetMacro(HandleLeftMouseButton,int);
266  vtkBooleanMacro(HandleLeftMouseButton,int);
267  vtkSetMacro(HandleMiddleMouseButton,int);
268  vtkGetMacro(HandleMiddleMouseButton,int);
269  vtkBooleanMacro(HandleMiddleMouseButton,int);
270  vtkSetMacro(HandleRightMouseButton,int);
271  vtkGetMacro(HandleRightMouseButton,int);
272  vtkBooleanMacro(HandleRightMouseButton,int);
274 
275 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE
276 # define SetPropA SetProp
277 # define SetPropW SetProp
278 #endif
279 
280 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE
281 # undef SetPropA
282 # undef SetPropW
283 #endif
284 
285 protected:
287  ~vtkImageTracerWidget() VTK_OVERRIDE;
288 
289  // Manage the state of the widget
290  int State;
292  {
293  Start=0,
300  Outside
301  };
302 
303  //handles the events
304  static void ProcessEvents(vtkObject* object,
305  unsigned long event,
306  void* clientdata,
307  void* calldata);
308 
309  // ProcessEvents() dispatches to these methods.
310  void OnLeftButtonDown();
311  void OnLeftButtonUp();
312  void OnMiddleButtonDown();
313  void OnMiddleButtonUp();
314  void OnRightButtonDown();
315  void OnRightButtonUp();
316  void OnMouseMove();
317 
318  void AddObservers();
319 
320  // Controlling ivars
327  double CaptureRadius; // tolerance for auto path close
330  int LastX;
331  int LastY;
332 
333  void Trace(int , int );
334  void Snap(double* );
335  void MovePoint(const double* , const double* );
336  void Translate(const double* , const double* );
337  void ClosePath();
338 
339  // 2D glyphs representing hot spots (e.g., handles)
343 
344  // Transforms required as 2D glyphs are generated in the x-y plane
348 
349  void AppendHandles(double*);
350  void ResetHandles();
351  void AllocateHandles(const int& );
352  void AdjustHandlePosition(const int& , double*);
353  int HighlightHandle(vtkProp* ); // returns handle index or -1 on fail
354  void EraseHandle(const int& );
355  void SizeHandles() VTK_OVERRIDE;
356  void InsertHandleOnLine(double* );
357 
358  int NumberOfHandles;
359  vtkActor *CurrentHandle;
360  int CurrentHandleIndex;
361 
362  vtkProp *ViewProp; // the prop we want to pick on
363  vtkPropPicker *PropPicker; // the prop's picker
364 
365  // Representation of the line
366  vtkPoints *LinePoints;
367  vtkCellArray *LineCells;
368  vtkActor *LineActor;
369  vtkPolyData *LineData;
370  vtkIdType CurrentPoints[2];
371 
372  void HighlightLine(const int& );
373  void BuildLinesFromHandles();
374  void ResetLine(double* );
375  void AppendLine(double* );
376  int PickCount;
377 
378  // Do the picking of the handles and the lines
379  vtkCellPicker *HandlePicker;
380  vtkCellPicker *LinePicker;
381  vtkAbstractPropPicker* CurrentPicker;
382 
383  // Register internal Pickers within PickingManager
384  void RegisterPickers() VTK_OVERRIDE;
385 
386  // Properties used to control the appearance of selected objects and
387  // the manipulator in general.
388  vtkProperty *HandleProperty;
389  vtkProperty *SelectedHandleProperty;
390  vtkProperty *LineProperty;
391  vtkProperty *SelectedLineProperty;
392  void CreateDefaultProperties();
393 
394  // Enable/Disable mouse button events
395  int HandleLeftMouseButton;
396  int HandleMiddleMouseButton;
397  int HandleRightMouseButton;
398 
399 private:
400  vtkImageTracerWidget(const vtkImageTracerWidget&) VTK_DELETE_FUNCTION;
401  void operator=(const vtkImageTracerWidget&) VTK_DELETE_FUNCTION;
402 };
403 
404 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:44
#define VTK_ITW_PROJECTION_XY
#define VTK_ITW_SNAP_POINTS
void PlaceWidget() override
Methods that satisfy the superclass' API.
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
abstract base class for most VTK objects
Definition: vtkObject.h:53
pick an actor/prop using graphics hardware
Definition: vtkPropPicker.h:39
represent surface properties of a geometric object
Definition: vtkProperty.h:58
#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.
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:35
transform points and associated normals and vectors for polygonal dataset
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
3D widget for tracing on planar props.
int vtkIdType
Definition: vtkType.h:345
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetProjectionNormalToYAxes()
Set the projection normal.
a simple class to control print indentation
Definition: vtkIndent.h:33
void SetProjectionNormalToZAxes()
Set the projection normal.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Methods that satisfy the superclass' API.
vtkTransformPolyDataFilter * TransformFilter
object to represent cell connectivity
Definition: vtkCellArray.h:44
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:63
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...
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:33