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) override;
96 
98 
101  void SetEnabled(int) override;
102  void PlaceWidget(double bounds[6]) override;
103  void PlaceWidget() override
104  {this->Superclass::PlaceWidget();}
105  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
106  double zmin, double zmax) override
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,vtkTypeBool);
142  vtkGetMacro(ProjectToPlane,vtkTypeBool);
143  vtkBooleanMacro(ProjectToPlane,vtkTypeBool);
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(vtkTypeBool snap);
180  vtkGetMacro(SnapToImage,vtkTypeBool);
181  vtkBooleanMacro(SnapToImage,vtkTypeBool);
183 
185 
190  vtkSetMacro(AutoClose,vtkTypeBool);
191  vtkGetMacro(AutoClose,vtkTypeBool);
192  vtkBooleanMacro(AutoClose,vtkTypeBool);
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) VTK_SIZEHINT(3);
237 
239 
242  vtkGetMacro(NumberOfHandles,int);
244 
246 
249  void SetInteraction(vtkTypeBool interact);
250  vtkGetMacro(Interaction,vtkTypeBool);
251  vtkBooleanMacro(Interaction,vtkTypeBool);
253 
259  void InitializeHandles(vtkPoints*);
260 
264  int IsClosed();
265 
267 
270  vtkSetMacro(HandleLeftMouseButton,vtkTypeBool);
271  vtkGetMacro(HandleLeftMouseButton,vtkTypeBool);
272  vtkBooleanMacro(HandleLeftMouseButton,vtkTypeBool);
273  vtkSetMacro(HandleMiddleMouseButton,vtkTypeBool);
274  vtkGetMacro(HandleMiddleMouseButton,vtkTypeBool);
275  vtkBooleanMacro(HandleMiddleMouseButton,vtkTypeBool);
276  vtkSetMacro(HandleRightMouseButton,vtkTypeBool);
277  vtkGetMacro(HandleRightMouseButton,vtkTypeBool);
278  vtkBooleanMacro(HandleRightMouseButton,vtkTypeBool);
280 
281 protected:
283  ~vtkImageTracerWidget() override;
284 
285  // Manage the state of the widget
286  int State;
288  {
289  Start=0,
296  Outside
297  };
298 
299  //handles the events
300  static void ProcessEvents(vtkObject* object,
301  unsigned long event,
302  void* clientdata,
303  void* calldata);
304 
305  // ProcessEvents() dispatches to these methods.
306  void OnLeftButtonDown();
307  void OnLeftButtonUp();
308  void OnMiddleButtonDown();
309  void OnMiddleButtonUp();
310  void OnRightButtonDown();
311  void OnRightButtonUp();
312  void OnMouseMove();
313 
314  void AddObservers();
315 
316  // Controlling ivars
323  double CaptureRadius; // tolerance for auto path close
326  int LastX;
327  int LastY;
328 
329  void Trace(int , int );
330  void Snap(double* );
331  void MovePoint(const double* , const double* );
332  void Translate(const double* , const double* );
333  void ClosePath();
334 
335  // 2D glyphs representing hot spots (e.g., handles)
339 
340  // Transforms required as 2D glyphs are generated in the x-y plane
344 
345  void AppendHandles(double*);
346  void ResetHandles();
347  void AllocateHandles(const int& );
348  void AdjustHandlePosition(const int& , double*);
349  int HighlightHandle(vtkProp* ); // returns handle index or -1 on fail
350  void EraseHandle(const int& );
351  void SizeHandles() override;
352  void InsertHandleOnLine(double* );
353 
357 
358  vtkProp *ViewProp; // the prop we want to pick on
359  vtkPropPicker *PropPicker; // the prop's picker
360 
361  // Representation of the line
366  vtkIdType CurrentPoints[2];
367 
368  void HighlightLine(const int& );
369  void BuildLinesFromHandles();
370  void ResetLine(double* );
371  void AppendLine(double* );
373 
374  // Do the picking of the handles and the lines
378 
379  // Register internal Pickers within PickingManager
380  void RegisterPickers() override;
381 
382  // Properties used to control the appearance of selected objects and
383  // the manipulator in general.
388  void CreateDefaultProperties();
389 
390  // Enable/Disable mouse button events
394 
395 private:
397  void operator=(const vtkImageTracerWidget&) = delete;
398 };
399 
400 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:52
#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: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:66
#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:347
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
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:39
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: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
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:39
vtkCellPicker * HandlePicker