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) override;
90 
92 
95  void SetEnabled(int) override;
96  void PlaceWidget(double bounds[6]) override;
97  void PlaceWidget() override
98  {this->Superclass::PlaceWidget();}
99  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
100  double zmin, double zmax) 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,vtkTypeBool);
136  vtkGetMacro(ProjectToPlane,vtkTypeBool);
137  vtkBooleanMacro(ProjectToPlane,vtkTypeBool);
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(vtkTypeBool snap);
174  vtkGetMacro(SnapToImage,vtkTypeBool);
175  vtkBooleanMacro(SnapToImage,vtkTypeBool);
177 
179 
184  vtkSetMacro(AutoClose,vtkTypeBool);
185  vtkGetMacro(AutoClose,vtkTypeBool);
186  vtkBooleanMacro(AutoClose,vtkTypeBool);
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) VTK_SIZEHINT(3);
231 
233 
236  vtkGetMacro(NumberOfHandles,int);
238 
240 
243  void SetInteraction(vtkTypeBool interact);
244  vtkGetMacro(Interaction,vtkTypeBool);
245  vtkBooleanMacro(Interaction,vtkTypeBool);
247 
253  void InitializeHandles(vtkPoints*);
254 
258  int IsClosed();
259 
261 
264  vtkSetMacro(HandleLeftMouseButton,vtkTypeBool);
265  vtkGetMacro(HandleLeftMouseButton,vtkTypeBool);
266  vtkBooleanMacro(HandleLeftMouseButton,vtkTypeBool);
267  vtkSetMacro(HandleMiddleMouseButton,vtkTypeBool);
268  vtkGetMacro(HandleMiddleMouseButton,vtkTypeBool);
269  vtkBooleanMacro(HandleMiddleMouseButton,vtkTypeBool);
270  vtkSetMacro(HandleRightMouseButton,vtkTypeBool);
271  vtkGetMacro(HandleRightMouseButton,vtkTypeBool);
272  vtkBooleanMacro(HandleRightMouseButton,vtkTypeBool);
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() 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() override;
356  void InsertHandleOnLine(double* );
357 
361 
362  vtkProp *ViewProp; // the prop we want to pick on
363  vtkPropPicker *PropPicker; // the prop's picker
364 
365  // Representation of the line
370  vtkIdType CurrentPoints[2];
371 
372  void HighlightLine(const int& );
373  void BuildLinesFromHandles();
374  void ResetLine(double* );
375  void AppendLine(double* );
377 
378  // Do the picking of the handles and the lines
382 
383  // Register internal Pickers within PickingManager
384  void RegisterPickers() override;
385 
386  // Properties used to control the appearance of selected objects and
387  // the manipulator in general.
392  void CreateDefaultProperties();
393 
394  // Enable/Disable mouse button events
398 
399 private:
401  void operator=(const vtkImageTracerWidget&) = delete;
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:60
#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: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.
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
int vtkTypeBool
Definition: vtkABI.h:69
void SetProjectionNormalToYAxes()
Set the projection normal.
a simple class to control print indentation
Definition: vtkIndent.h:33
void SetProjectionNormalToZAxes()
Set the projection normal.
#define VTK_SIZEHINT(...)
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Methods that satisfy the superclass' API.
vtkProperty * SelectedLineProperty
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
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
vtkCellPicker * HandlePicker