VTK  9.2.5
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 =========================================================================*/
99 #ifndef vtkImageTracerWidget_h
100 #define vtkImageTracerWidget_h
101 
102 #include "vtk3DWidget.h"
103 #include "vtkInteractionWidgetsModule.h" // For export macro
104 
106 class vtkActor;
107 class vtkCellArray;
108 class vtkCellPicker;
109 class vtkFloatArray;
110 class vtkGlyphSource2D;
111 class vtkPoints;
112 class vtkPolyData;
113 class vtkProp;
114 class vtkProperty;
115 class vtkPropPicker;
116 class vtkTransform;
118 
119 #define VTK_ITW_PROJECTION_YZ 0
120 #define VTK_ITW_PROJECTION_XZ 1
121 #define VTK_ITW_PROJECTION_XY 2
122 #define VTK_ITW_SNAP_CELLS 0
123 #define VTK_ITW_SNAP_POINTS 1
124 
125 class VTKINTERACTIONWIDGETS_EXPORT vtkImageTracerWidget : public vtk3DWidget
126 {
127 public:
132 
134  void PrintSelf(ostream& os, vtkIndent indent) override;
135 
137 
140  void SetEnabled(int) override;
141  void PlaceWidget(double bounds[6]) override;
142  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
144  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
145  {
146  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
147  }
149 
151 
156  vtkGetObjectMacro(HandleProperty, vtkProperty);
158  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
160 
162 
166  virtual void SetLineProperty(vtkProperty*);
167  vtkGetObjectMacro(LineProperty, vtkProperty);
169  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
171 
175  void SetViewProp(vtkProp* prop);
176 
178 
181  vtkSetMacro(ProjectToPlane, vtkTypeBool);
182  vtkGetMacro(ProjectToPlane, vtkTypeBool);
183  vtkBooleanMacro(ProjectToPlane, vtkTypeBool);
185 
187 
193  vtkSetClampMacro(ProjectionNormal, int, VTK_ITW_PROJECTION_YZ, VTK_ITW_PROJECTION_XY);
194  vtkGetMacro(ProjectionNormal, int);
195  void SetProjectionNormalToXAxes() { this->SetProjectionNormal(0); }
196  void SetProjectionNormalToYAxes() { this->SetProjectionNormal(1); }
197  void SetProjectionNormalToZAxes() { this->SetProjectionNormal(2); }
199 
201 
209  vtkGetMacro(ProjectionPosition, double);
211 
213 
217  vtkGetMacro(SnapToImage, vtkTypeBool);
218  vtkBooleanMacro(SnapToImage, vtkTypeBool);
220 
222 
227  vtkSetMacro(AutoClose, vtkTypeBool);
228  vtkGetMacro(AutoClose, vtkTypeBool);
229  vtkBooleanMacro(AutoClose, vtkTypeBool);
231 
233 
239  vtkSetMacro(CaptureRadius, double);
240  vtkGetMacro(CaptureRadius, double);
242 
249  void GetPath(vtkPolyData* pd);
250 
254  vtkGlyphSource2D* GetGlyphSource() { return this->HandleGenerator; }
255 
257 
261  vtkSetClampMacro(ImageSnapType, int, VTK_ITW_SNAP_CELLS, VTK_ITW_SNAP_POINTS);
262  vtkGetMacro(ImageSnapType, int);
264 
266 
269  void SetHandlePosition(int handle, double xyz[3]);
270  void SetHandlePosition(int handle, double x, double y, double z);
271  void GetHandlePosition(int handle, double xyz[3]);
272  double* GetHandlePosition(int handle) VTK_SIZEHINT(3);
274 
276 
279  vtkGetMacro(NumberOfHandles, int);
281 
283 
286  void SetInteraction(vtkTypeBool interact);
287  vtkGetMacro(Interaction, vtkTypeBool);
288  vtkBooleanMacro(Interaction, vtkTypeBool);
290 
297 
301  int IsClosed();
302 
304 
307  vtkSetMacro(HandleLeftMouseButton, vtkTypeBool);
308  vtkGetMacro(HandleLeftMouseButton, vtkTypeBool);
309  vtkBooleanMacro(HandleLeftMouseButton, vtkTypeBool);
310  vtkSetMacro(HandleMiddleMouseButton, vtkTypeBool);
311  vtkGetMacro(HandleMiddleMouseButton, vtkTypeBool);
312  vtkBooleanMacro(HandleMiddleMouseButton, vtkTypeBool);
313  vtkSetMacro(HandleRightMouseButton, vtkTypeBool);
314  vtkGetMacro(HandleRightMouseButton, vtkTypeBool);
315  vtkBooleanMacro(HandleRightMouseButton, vtkTypeBool);
317 
318 protected:
321 
322  // Manage the state of the widget
323  int State;
325  {
326  Start = 0,
333  Outside
334  };
335 
336  // handles the events
337  static void ProcessEvents(
338  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
339 
340  // ProcessEvents() dispatches to these methods.
347  void OnMouseMove();
348 
349  void AddObservers();
350 
351  // Controlling ivars
358  double CaptureRadius; // tolerance for auto path close
361  int LastX;
362  int LastY;
363 
364  void Trace(int, int);
365  void Snap(double*);
366  void MovePoint(const double*, const double*);
367  void Translate(const double*, const double*);
368  void ClosePath();
369 
370  // 2D glyphs representing hot spots (e.g., handles)
374 
375  // Transforms required as 2D glyphs are generated in the x-y plane
379 
380  void AppendHandles(double*);
381  void ResetHandles();
382  void AllocateHandles(const int&);
383  void AdjustHandlePosition(const int&, double*);
384  int HighlightHandle(vtkProp*); // returns handle index or -1 on fail
385  void EraseHandle(const int&);
386  void SizeHandles() override;
387  void InsertHandleOnLine(double*);
388 
392 
393  vtkProp* ViewProp; // the prop we want to pick on
394  vtkPropPicker* PropPicker; // the prop's picker
395 
396  // Representation of the line
401  vtkIdType CurrentPoints[2];
402 
403  void HighlightLine(const int&);
405  void ResetLine(double*);
406  void AppendLine(double*);
408 
409  // Do the picking of the handles and the lines
413 
414  // Register internal Pickers within PickingManager
415  void RegisterPickers() override;
416 
417  // Properties used to control the appearance of selected objects and
418  // the manipulator in general.
424 
425  // Enable/Disable mouse button events
429 
430 private:
432  void operator=(const vtkImageTracerWidget&) = delete;
433 };
434 
435 #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:161
object to represent cell connectivity
Definition: vtkCellArray.h:296
ray-cast cell picker for all kinds of Prop3Ds
dynamic, self-adjusting array of float
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:119
abstract base class for most VTK objects
Definition: vtkObject.h:82
represent and manipulate 3D points
Definition: vtkPoints.h:149
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:200
pick an actor/prop using graphics hardware
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:76
represent surface properties of a geometric object
Definition: vtkProperty.h:177
transform points and associated normals and vectors for polygonal dataset
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:170
@ 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:332
#define VTK_SIZEHINT(...)