VTK  9.0.3
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 "vtk3DWidget.h"
58 #include "vtkInteractionWidgetsModule.h" // For export macro
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:
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 { this->Superclass::PlaceWidget(); }
99  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
100  {
101  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
102  }
104 
106 
111  vtkGetObjectMacro(HandleProperty, vtkProperty);
113  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
115 
117 
121  virtual void SetLineProperty(vtkProperty*);
122  vtkGetObjectMacro(LineProperty, vtkProperty);
124  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
126 
130  void SetViewProp(vtkProp* prop);
131 
133 
136  vtkSetMacro(ProjectToPlane, vtkTypeBool);
137  vtkGetMacro(ProjectToPlane, vtkTypeBool);
138  vtkBooleanMacro(ProjectToPlane, vtkTypeBool);
140 
142 
148  vtkSetClampMacro(ProjectionNormal, int, VTK_ITW_PROJECTION_YZ, VTK_ITW_PROJECTION_XY);
149  vtkGetMacro(ProjectionNormal, int);
150  void SetProjectionNormalToXAxes() { this->SetProjectionNormal(0); }
151  void SetProjectionNormalToYAxes() { this->SetProjectionNormal(1); }
152  void SetProjectionNormalToZAxes() { this->SetProjectionNormal(2); }
154 
156 
164  vtkGetMacro(ProjectionPosition, double);
166 
168 
172  vtkGetMacro(SnapToImage, vtkTypeBool);
173  vtkBooleanMacro(SnapToImage, vtkTypeBool);
175 
177 
182  vtkSetMacro(AutoClose, vtkTypeBool);
183  vtkGetMacro(AutoClose, vtkTypeBool);
184  vtkBooleanMacro(AutoClose, vtkTypeBool);
186 
188 
194  vtkSetMacro(CaptureRadius, double);
195  vtkGetMacro(CaptureRadius, double);
197 
204  void GetPath(vtkPolyData* pd);
205 
209  vtkGlyphSource2D* GetGlyphSource() { return this->HandleGenerator; }
210 
212 
216  vtkSetClampMacro(ImageSnapType, int, VTK_ITW_SNAP_CELLS, VTK_ITW_SNAP_POINTS);
217  vtkGetMacro(ImageSnapType, int);
219 
221 
224  void SetHandlePosition(int handle, double xyz[3]);
225  void SetHandlePosition(int handle, double x, double y, double z);
226  void GetHandlePosition(int handle, double xyz[3]);
227  double* GetHandlePosition(int handle) VTK_SIZEHINT(3);
229 
231 
234  vtkGetMacro(NumberOfHandles, int);
236 
238 
241  void SetInteraction(vtkTypeBool interact);
242  vtkGetMacro(Interaction, vtkTypeBool);
243  vtkBooleanMacro(Interaction, vtkTypeBool);
245 
252 
256  int IsClosed();
257 
259 
262  vtkSetMacro(HandleLeftMouseButton, vtkTypeBool);
263  vtkGetMacro(HandleLeftMouseButton, vtkTypeBool);
264  vtkBooleanMacro(HandleLeftMouseButton, vtkTypeBool);
265  vtkSetMacro(HandleMiddleMouseButton, vtkTypeBool);
266  vtkGetMacro(HandleMiddleMouseButton, vtkTypeBool);
267  vtkBooleanMacro(HandleMiddleMouseButton, vtkTypeBool);
268  vtkSetMacro(HandleRightMouseButton, vtkTypeBool);
269  vtkGetMacro(HandleRightMouseButton, vtkTypeBool);
270  vtkBooleanMacro(HandleRightMouseButton, vtkTypeBool);
272 
273 protected:
276 
277  // Manage the state of the widget
278  int State;
280  {
281  Start = 0,
288  Outside
289  };
290 
291  // handles the events
292  static void ProcessEvents(
293  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
294 
295  // ProcessEvents() dispatches to these methods.
302  void OnMouseMove();
303 
304  void AddObservers();
305 
306  // Controlling ivars
313  double CaptureRadius; // tolerance for auto path close
316  int LastX;
317  int LastY;
318 
319  void Trace(int, int);
320  void Snap(double*);
321  void MovePoint(const double*, const double*);
322  void Translate(const double*, const double*);
323  void ClosePath();
324 
325  // 2D glyphs representing hot spots (e.g., handles)
329 
330  // Transforms required as 2D glyphs are generated in the x-y plane
334 
335  void AppendHandles(double*);
336  void ResetHandles();
337  void AllocateHandles(const int&);
338  void AdjustHandlePosition(const int&, double*);
339  int HighlightHandle(vtkProp*); // returns handle index or -1 on fail
340  void EraseHandle(const int&);
341  void SizeHandles() override;
342  void InsertHandleOnLine(double*);
343 
347 
348  vtkProp* ViewProp; // the prop we want to pick on
349  vtkPropPicker* PropPicker; // the prop's picker
350 
351  // Representation of the line
356  vtkIdType CurrentPoints[2];
357 
358  void HighlightLine(const int&);
360  void ResetLine(double*);
361  void AppendLine(double*);
363 
364  // Do the picking of the handles and the lines
368 
369  // Register internal Pickers within PickingManager
370  void RegisterPickers() override;
371 
372  // Properties used to control the appearance of selected objects and
373  // the manipulator in general.
379 
380  // Enable/Disable mouse button events
384 
385 private:
387  void operator=(const vtkImageTracerWidget&) = delete;
388 };
389 
390 #endif
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:68
abstract API for pickers that can pick an instance of vtkProp
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:46
object to represent cell connectivity
Definition: vtkCellArray.h:180
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:67
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:36
create 2D glyphs represented by vtkPolyData
3D widget for tracing on planar props.
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
vtkCellPicker * HandlePicker
void AppendLine(double *)
void InsertHandleOnLine(double *)
static vtkImageTracerWidget * New()
Instantiate the object.
void GetHandlePosition(int handle, double xyz[3])
virtual void SetSelectedLineProperty(vtkProperty *)
void AppendHandles(double *)
void SetProjectionPosition(double position)
Set the position of the widgets' handles in terms of a plane's position.
void GetPath(vtkPolyData *pd)
Grab the points and lines that define the traced path.
~vtkImageTracerWidget() override
void ResetLine(double *)
void HighlightLine(const int &)
vtkTransformPolyDataFilter * TransformFilter
void PlaceWidget(double bounds[6]) override
This method is used to initially place the widget.
virtual void SetSelectedHandleProperty(vtkProperty *)
void SetEnabled(int) override
Methods that satisfy the superclass' API.
int HighlightHandle(vtkProp *)
void SetHandlePosition(int handle, double x, double y, double z)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetInteraction(vtkTypeBool interact)
Enable/disable mouse interaction when the widget is visible.
void SizeHandles() override
void EraseHandle(const int &)
vtkAbstractPropPicker * CurrentPicker
void InitializeHandles(vtkPoints *)
Initialize the widget with a set of points and generate lines between them.
void PlaceWidget() override
vtkFloatArray * TemporaryHandlePoints
void Translate(const double *, const double *)
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
vtkGlyphSource2D * HandleGenerator
void Snap(double *)
vtkGlyphSource2D * GetGlyphSource()
Get the handles' geometric representation via vtkGlyphSource2D.
void CreateDefaultProperties()
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
void MovePoint(const double *, const double *)
virtual void SetHandleProperty(vtkProperty *)
Set/Get the handle properties (the 2D glyphs are the handles).
vtkProperty * SelectedHandleProperty
void SetSnapToImage(vtkTypeBool snap)
Force snapping to image data while tracing.
void SetHandlePosition(int handle, double xyz[3])
Set/Get the handle position in terms of a zero-based array of handles.
int IsClosed()
Is the path closed or open?
void AllocateHandles(const int &)
void Trace(int, int)
void AdjustHandlePosition(const int &, double *)
vtkProperty * SelectedLineProperty
double * GetHandlePosition(int handle)
void SetViewProp(vtkProp *prop)
Set the prop, usually a vtkImageActor, to trace over.
virtual void SetLineProperty(vtkProperty *)
Set/Get the line properties.
a simple class to control print indentation
Definition: vtkIndent.h:34
abstract base class for most VTK objects
Definition: vtkObject.h:54
represent and manipulate 3D points
Definition: vtkPoints.h:34
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
pick an actor/prop using graphics hardware
Definition: vtkPropPicker.h:40
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:48
represent surface properties of a geometric object
Definition: vtkProperty.h:62
transform points and associated normals and vectors for polygonal dataset
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:55
@ position
Definition: vtkX3D.h:267
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_ITW_SNAP_CELLS
#define VTK_ITW_SNAP_POINTS
#define VTK_ITW_PROJECTION_YZ
#define VTK_ITW_PROJECTION_XY
int vtkIdType
Definition: vtkType.h:338
#define VTK_SIZEHINT(...)