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 protected:
277  ~vtkImageTracerWidget() override;
278 
279  // Manage the state of the widget
280  int State;
282  {
283  Start=0,
290  Outside
291  };
292 
293  //handles the events
294  static void ProcessEvents(vtkObject* object,
295  unsigned long event,
296  void* clientdata,
297  void* calldata);
298 
299  // ProcessEvents() dispatches to these methods.
300  void OnLeftButtonDown();
301  void OnLeftButtonUp();
302  void OnMiddleButtonDown();
303  void OnMiddleButtonUp();
304  void OnRightButtonDown();
305  void OnRightButtonUp();
306  void OnMouseMove();
307 
308  void AddObservers();
309 
310  // Controlling ivars
317  double CaptureRadius; // tolerance for auto path close
320  int LastX;
321  int LastY;
322 
323  void Trace(int , int );
324  void Snap(double* );
325  void MovePoint(const double* , const double* );
326  void Translate(const double* , const double* );
327  void ClosePath();
328 
329  // 2D glyphs representing hot spots (e.g., handles)
333 
334  // Transforms required as 2D glyphs are generated in the x-y plane
338 
339  void AppendHandles(double*);
340  void ResetHandles();
341  void AllocateHandles(const int& );
342  void AdjustHandlePosition(const int& , double*);
343  int HighlightHandle(vtkProp* ); // returns handle index or -1 on fail
344  void EraseHandle(const int& );
345  void SizeHandles() override;
346  void InsertHandleOnLine(double* );
347 
351 
352  vtkProp *ViewProp; // the prop we want to pick on
353  vtkPropPicker *PropPicker; // the prop's picker
354 
355  // Representation of the line
360  vtkIdType CurrentPoints[2];
361 
362  void HighlightLine(const int& );
363  void BuildLinesFromHandles();
364  void ResetLine(double* );
365  void AppendLine(double* );
367 
368  // Do the picking of the handles and the lines
372 
373  // Register internal Pickers within PickingManager
374  void RegisterPickers() override;
375 
376  // Properties used to control the appearance of selected objects and
377  // the manipulator in general.
382  void CreateDefaultProperties();
383 
384  // Enable/Disable mouse button events
388 
389 private:
391  void operator=(const vtkImageTracerWidget&) = delete;
392 };
393 
394 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:46
#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:347
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