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 =========================================================================*/
63 #ifndef vtkImageTracerWidget_h
64 #define vtkImageTracerWidget_h
65 
66 #include "vtk3DWidget.h"
67 #include "vtkInteractionWidgetsModule.h" // For export macro
68 
70 class vtkActor;
71 class vtkCellArray;
72 class vtkCellPicker;
73 class vtkFloatArray;
74 class vtkGlyphSource2D;
75 class vtkPoints;
76 class vtkPolyData;
77 class vtkProp;
78 class vtkProperty;
79 class vtkPropPicker;
80 class vtkTransform;
82 
83 #define VTK_ITW_PROJECTION_YZ 0
84 #define VTK_ITW_PROJECTION_XZ 1
85 #define VTK_ITW_PROJECTION_XY 2
86 #define VTK_ITW_SNAP_CELLS 0
87 #define VTK_ITW_SNAP_POINTS 1
88 
89 class VTKINTERACTIONWIDGETS_EXPORT vtkImageTracerWidget : public vtk3DWidget
90 {
91 public:
96 
98  void PrintSelf(ostream& os, vtkIndent indent) override;
99 
101 
104  void SetEnabled(int) override;
105  void PlaceWidget(double bounds[6]) override;
106  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
108  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
109  {
110  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
111  }
113 
115 
120  vtkGetObjectMacro(HandleProperty, vtkProperty);
122  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
124 
126 
130  virtual void SetLineProperty(vtkProperty*);
131  vtkGetObjectMacro(LineProperty, vtkProperty);
133  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
135 
139  void SetViewProp(vtkProp* prop);
140 
142 
145  vtkSetMacro(ProjectToPlane, vtkTypeBool);
146  vtkGetMacro(ProjectToPlane, vtkTypeBool);
147  vtkBooleanMacro(ProjectToPlane, vtkTypeBool);
149 
151 
157  vtkSetClampMacro(ProjectionNormal, int, VTK_ITW_PROJECTION_YZ, VTK_ITW_PROJECTION_XY);
158  vtkGetMacro(ProjectionNormal, int);
159  void SetProjectionNormalToXAxes() { this->SetProjectionNormal(0); }
160  void SetProjectionNormalToYAxes() { this->SetProjectionNormal(1); }
161  void SetProjectionNormalToZAxes() { this->SetProjectionNormal(2); }
163 
165 
173  vtkGetMacro(ProjectionPosition, double);
175 
177 
181  vtkGetMacro(SnapToImage, vtkTypeBool);
182  vtkBooleanMacro(SnapToImage, vtkTypeBool);
184 
186 
191  vtkSetMacro(AutoClose, vtkTypeBool);
192  vtkGetMacro(AutoClose, vtkTypeBool);
193  vtkBooleanMacro(AutoClose, vtkTypeBool);
195 
197 
203  vtkSetMacro(CaptureRadius, double);
204  vtkGetMacro(CaptureRadius, double);
206 
213  void GetPath(vtkPolyData* pd);
214 
218  vtkGlyphSource2D* GetGlyphSource() { return this->HandleGenerator; }
219 
221 
225  vtkSetClampMacro(ImageSnapType, int, VTK_ITW_SNAP_CELLS, VTK_ITW_SNAP_POINTS);
226  vtkGetMacro(ImageSnapType, int);
228 
230 
233  void SetHandlePosition(int handle, double xyz[3]);
234  void SetHandlePosition(int handle, double x, double y, double z);
235  void GetHandlePosition(int handle, double xyz[3]);
236  double* GetHandlePosition(int handle) VTK_SIZEHINT(3);
238 
240 
243  vtkGetMacro(NumberOfHandles, int);
245 
247 
250  void SetInteraction(vtkTypeBool interact);
251  vtkGetMacro(Interaction, vtkTypeBool);
252  vtkBooleanMacro(Interaction, vtkTypeBool);
254 
261 
265  int IsClosed();
266 
268 
271  vtkSetMacro(HandleLeftMouseButton, vtkTypeBool);
272  vtkGetMacro(HandleLeftMouseButton, vtkTypeBool);
273  vtkBooleanMacro(HandleLeftMouseButton, vtkTypeBool);
274  vtkSetMacro(HandleMiddleMouseButton, vtkTypeBool);
275  vtkGetMacro(HandleMiddleMouseButton, vtkTypeBool);
276  vtkBooleanMacro(HandleMiddleMouseButton, vtkTypeBool);
277  vtkSetMacro(HandleRightMouseButton, vtkTypeBool);
278  vtkGetMacro(HandleRightMouseButton, vtkTypeBool);
279  vtkBooleanMacro(HandleRightMouseButton, vtkTypeBool);
281 
282 protected:
285 
286  // Manage the state of the widget
287  int State;
289  {
290  Start = 0,
297  Outside
298  };
299 
300  // handles the events
301  static void ProcessEvents(
302  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
303 
304  // ProcessEvents() dispatches to these methods.
311  void OnMouseMove();
312 
313  void AddObservers();
314 
315  // Controlling ivars
322  double CaptureRadius; // tolerance for auto path close
325  int LastX;
326  int LastY;
327 
328  void Trace(int, int);
329  void Snap(double*);
330  void MovePoint(const double*, const double*);
331  void Translate(const double*, const double*);
332  void ClosePath();
333 
334  // 2D glyphs representing hot spots (e.g., handles)
338 
339  // Transforms required as 2D glyphs are generated in the x-y plane
343 
344  void AppendHandles(double*);
345  void ResetHandles();
346  void AllocateHandles(const int&);
347  void AdjustHandlePosition(const int&, double*);
348  int HighlightHandle(vtkProp*); // returns handle index or -1 on fail
349  void EraseHandle(const int&);
350  void SizeHandles() override;
351  void InsertHandleOnLine(double*);
352 
356 
357  vtkProp* ViewProp; // the prop we want to pick on
358  vtkPropPicker* PropPicker; // the prop's picker
359 
360  // Representation of the line
365  vtkIdType CurrentPoints[2];
366 
367  void HighlightLine(const int&);
369  void ResetLine(double*);
370  void AppendLine(double*);
372 
373  // Do the picking of the handles and the lines
377 
378  // Register internal Pickers within PickingManager
379  void RegisterPickers() override;
380 
381  // Properties used to control the appearance of selected objects and
382  // the manipulator in general.
388 
389  // Enable/Disable mouse button events
393 
394 private:
396  void operator=(const vtkImageTracerWidget&) = delete;
397 };
398 
399 #endif
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:71
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.
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:63
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:46
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:54
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(...)