VTK  9.3.0
vtkImageTracerWidget.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
48 #ifndef vtkImageTracerWidget_h
49 #define vtkImageTracerWidget_h
50 
51 #include "vtk3DWidget.h"
52 #include "vtkInteractionWidgetsModule.h" // For export macro
53 
54 VTK_ABI_NAMESPACE_BEGIN
56 class vtkActor;
57 class vtkCellArray;
58 class vtkCellPicker;
59 class vtkFloatArray;
60 class vtkGlyphSource2D;
61 class vtkPoints;
62 class vtkPolyData;
63 class vtkProp;
64 class vtkProperty;
65 class vtkPropPicker;
66 class vtkTransform;
68 
69 #define VTK_ITW_PROJECTION_YZ 0
70 #define VTK_ITW_PROJECTION_XZ 1
71 #define VTK_ITW_PROJECTION_XY 2
72 #define VTK_ITW_SNAP_CELLS 0
73 #define VTK_ITW_SNAP_POINTS 1
74 
75 class VTKINTERACTIONWIDGETS_EXPORT vtkImageTracerWidget : public vtk3DWidget
76 {
77 public:
82 
84  void PrintSelf(ostream& os, vtkIndent indent) override;
85 
87 
90  void SetEnabled(int) override;
91  void PlaceWidget(double bounds[6]) override;
92  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
94  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
95  {
96  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
97  }
99 
101 
106  vtkGetObjectMacro(HandleProperty, vtkProperty);
108  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
110 
112 
116  virtual void SetLineProperty(vtkProperty*);
117  vtkGetObjectMacro(LineProperty, vtkProperty);
119  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
121 
125  void SetViewProp(vtkProp* prop);
126 
128 
131  vtkSetMacro(ProjectToPlane, vtkTypeBool);
132  vtkGetMacro(ProjectToPlane, vtkTypeBool);
133  vtkBooleanMacro(ProjectToPlane, vtkTypeBool);
135 
137 
143  vtkSetClampMacro(ProjectionNormal, int, VTK_ITW_PROJECTION_YZ, VTK_ITW_PROJECTION_XY);
144  vtkGetMacro(ProjectionNormal, int);
145  void SetProjectionNormalToXAxes() { this->SetProjectionNormal(0); }
146  void SetProjectionNormalToYAxes() { this->SetProjectionNormal(1); }
147  void SetProjectionNormalToZAxes() { this->SetProjectionNormal(2); }
149 
151 
159  vtkGetMacro(ProjectionPosition, double);
161 
163 
167  vtkGetMacro(SnapToImage, vtkTypeBool);
168  vtkBooleanMacro(SnapToImage, vtkTypeBool);
170 
172 
177  vtkSetMacro(AutoClose, vtkTypeBool);
178  vtkGetMacro(AutoClose, vtkTypeBool);
179  vtkBooleanMacro(AutoClose, vtkTypeBool);
181 
183 
189  vtkSetMacro(CaptureRadius, double);
190  vtkGetMacro(CaptureRadius, double);
192 
199  void GetPath(vtkPolyData* pd);
200 
204  vtkGlyphSource2D* GetGlyphSource() { return this->HandleGenerator; }
205 
207 
211  vtkSetClampMacro(ImageSnapType, int, VTK_ITW_SNAP_CELLS, VTK_ITW_SNAP_POINTS);
212  vtkGetMacro(ImageSnapType, int);
214 
216 
219  void SetHandlePosition(int handle, double xyz[3]);
220  void SetHandlePosition(int handle, double x, double y, double z);
221  void GetHandlePosition(int handle, double xyz[3]);
222  double* GetHandlePosition(int handle) VTK_SIZEHINT(3);
224 
226 
229  vtkGetMacro(NumberOfHandles, int);
231 
233 
236  void SetInteraction(vtkTypeBool interact);
237  vtkGetMacro(Interaction, vtkTypeBool);
238  vtkBooleanMacro(Interaction, vtkTypeBool);
240 
247 
251  int IsClosed();
252 
254 
257  vtkSetMacro(HandleLeftMouseButton, vtkTypeBool);
258  vtkGetMacro(HandleLeftMouseButton, vtkTypeBool);
259  vtkBooleanMacro(HandleLeftMouseButton, vtkTypeBool);
260  vtkSetMacro(HandleMiddleMouseButton, vtkTypeBool);
261  vtkGetMacro(HandleMiddleMouseButton, vtkTypeBool);
262  vtkBooleanMacro(HandleMiddleMouseButton, vtkTypeBool);
263  vtkSetMacro(HandleRightMouseButton, vtkTypeBool);
264  vtkGetMacro(HandleRightMouseButton, vtkTypeBool);
265  vtkBooleanMacro(HandleRightMouseButton, vtkTypeBool);
267 
268 protected:
271 
272  // Manage the state of the widget
273  int State;
275  {
276  Start = 0,
283  Outside
284  };
285 
286  // handles the events
287  static void ProcessEvents(
288  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
289 
290  // ProcessEvents() dispatches to these methods.
297  void OnMouseMove();
298 
299  void AddObservers();
300 
301  // Controlling ivars
308  double CaptureRadius; // tolerance for auto path close
311  int LastX;
312  int LastY;
313 
314  void Trace(int, int);
315  void Snap(double*);
316  void MovePoint(const double*, const double*);
317  void Translate(const double*, const double*);
318  void ClosePath();
319 
320  // 2D glyphs representing hot spots (e.g., handles)
324 
325  // Transforms required as 2D glyphs are generated in the x-y plane
329 
330  void AppendHandles(double*);
331  void ResetHandles();
332  void AllocateHandles(const int&);
333  void AdjustHandlePosition(const int&, double*);
334  int HighlightHandle(vtkProp*); // returns handle index or -1 on fail
335  void EraseHandle(const int&);
336  void SizeHandles() override;
337  void InsertHandleOnLine(double*);
338 
342 
343  vtkProp* ViewProp; // the prop we want to pick on
344  vtkPropPicker* PropPicker; // the prop's picker
345 
346  // Representation of the line
351  vtkIdType CurrentPoints[2];
352 
353  void HighlightLine(const int&);
355  void ResetLine(double*);
356  void AppendLine(double*);
358 
359  // Do the picking of the handles and the lines
363 
364  // Register internal Pickers within PickingManager
365  void RegisterPickers() override;
366 
367  // Properties used to control the appearance of selected objects and
368  // the manipulator in general.
374 
375  // Enable/Disable mouse button events
379 
380 private:
382  void operator=(const vtkImageTracerWidget&) = delete;
383 };
384 
385 VTK_ABI_NAMESPACE_END
386 #endif
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:60
abstract API for pickers that can pick an instance of vtkProp
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:41
object to represent cell connectivity
Definition: vtkCellArray.h:176
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:62
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:31
create 2D glyphs represented by vtkPolyData
3D widget for tracing on planar props.
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
void SetProjectionNormalToYAxes()
Set the projection normal.
vtkCellPicker * HandlePicker
void AppendLine(double *)
void InsertHandleOnLine(double *)
static vtkImageTracerWidget * New()
Instantiate the object.
void GetHandlePosition(int handle, double xyz[3])
Set/Get the handle position in terms of a zero-based array of handles.
virtual void SetSelectedLineProperty(vtkProperty *)
Set/Get the line properties.
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
Methods that satisfy the superclass' API.
virtual void SetSelectedHandleProperty(vtkProperty *)
Set/Get the handle properties (the 2D glyphs are the handles).
void SetProjectionNormalToZAxes()
Set the projection normal.
void SetEnabled(int) override
Methods that satisfy the superclass' API.
int HighlightHandle(vtkProp *)
void SetHandlePosition(int handle, double x, double y, double z)
Set/Get the handle position in terms of a zero-based array of handles.
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
Methods that satisfy the superclass' API.
vtkFloatArray * TemporaryHandlePoints
void Translate(const double *, const double *)
void SetProjectionNormalToXAxes()
Set the projection normal.
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
Methods that satisfy the superclass' API.
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)
Set/Get the handle position in terms of a zero-based array of handles.
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:29
abstract base class for most VTK objects
Definition: vtkObject.h:52
represent and manipulate 3D points
Definition: vtkPoints.h:29
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:80
pick an actor/prop using graphics hardware
Definition: vtkPropPicker.h:35
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:46
represent surface properties of a geometric object
Definition: vtkProperty.h:57
transform points and associated normals and vectors for polygonal dataset
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:50
@ position
Definition: vtkX3D.h:261
int vtkTypeBool
Definition: vtkABI.h:64
#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:315
#define VTK_SIZEHINT(...)