VTK  9.0.1
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:
95  static vtkImageTracerWidget* New();
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 
119  virtual void SetHandleProperty(vtkProperty*);
120  vtkGetObjectMacro(HandleProperty, vtkProperty);
121  virtual void SetSelectedHandleProperty(vtkProperty*);
122  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
124 
126 
130  virtual void SetLineProperty(vtkProperty*);
131  vtkGetObjectMacro(LineProperty, vtkProperty);
132  virtual void SetSelectedLineProperty(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 
172  void SetProjectionPosition(double position);
173  vtkGetMacro(ProjectionPosition, double);
175 
177 
180  void SetSnapToImage(vtkTypeBool snap);
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 
260  void InitializeHandles(vtkPoints*);
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:
284  ~vtkImageTracerWidget() override;
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.
305  void OnLeftButtonDown();
306  void OnLeftButtonUp();
307  void OnMiddleButtonDown();
308  void OnMiddleButtonUp();
309  void OnRightButtonDown();
310  void OnRightButtonUp();
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&);
368  void BuildLinesFromHandles();
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.
387  void CreateDefaultProperties();
388 
389  // Enable/Disable mouse button events
393 
394 private:
396  void operator=(const vtkImageTracerWidget&) = delete;
397 };
398 
399 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:53
#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:45
abstract base class for most VTK objects
Definition: vtkObject.h:62
pick an actor/prop using graphics hardware
Definition: vtkPropPicker.h:45
represent surface properties of a geometric object
Definition: vtkProperty.h:61
#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:35
transform points and associated normals and vectors for polygonal dataset
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
3D widget for tracing on planar props.
int vtkIdType
Definition: vtkType.h:338
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
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:33
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:179
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:66
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:70
virtual void SizeHandles()
Definition: vtk3DWidget.h:155
virtual void PlaceWidget()
This method is used to initially place the widget.
represent and manipulate 3D points
Definition: vtkPoints.h:33
vtkCellPicker * HandlePicker