VTK  9.2.6
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 =========================================================================*/
60 #ifndef vtkImageTracerWidget_h
61 #define vtkImageTracerWidget_h
62 
63 #include "vtk3DWidget.h"
64 #include "vtkInteractionWidgetsModule.h" // For export macro
65 
67 class vtkActor;
68 class vtkCellArray;
69 class vtkCellPicker;
70 class vtkFloatArray;
71 class vtkGlyphSource2D;
72 class vtkPoints;
73 class vtkPolyData;
74 class vtkProp;
75 class vtkProperty;
76 class vtkPropPicker;
77 class vtkTransform;
79 
80 #define VTK_ITW_PROJECTION_YZ 0
81 #define VTK_ITW_PROJECTION_XZ 1
82 #define VTK_ITW_PROJECTION_XY 2
83 #define VTK_ITW_SNAP_CELLS 0
84 #define VTK_ITW_SNAP_POINTS 1
85 
86 class VTKINTERACTIONWIDGETS_EXPORT vtkImageTracerWidget : public vtk3DWidget
87 {
88 public:
92  static vtkImageTracerWidget* New();
93 
95  void PrintSelf(ostream& os, vtkIndent indent) override;
96 
98 
101  void SetEnabled(int) override;
102  void PlaceWidget(double bounds[6]) override;
103  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
105  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
106  {
107  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
108  }
110 
112 
116  virtual void SetHandleProperty(vtkProperty*);
117  vtkGetObjectMacro(HandleProperty, vtkProperty);
118  virtual void SetSelectedHandleProperty(vtkProperty*);
119  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
121 
123 
127  virtual void SetLineProperty(vtkProperty*);
128  vtkGetObjectMacro(LineProperty, vtkProperty);
129  virtual void SetSelectedLineProperty(vtkProperty*);
130  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
132 
136  void SetViewProp(vtkProp* prop);
137 
139 
142  vtkSetMacro(ProjectToPlane, vtkTypeBool);
143  vtkGetMacro(ProjectToPlane, vtkTypeBool);
144  vtkBooleanMacro(ProjectToPlane, vtkTypeBool);
146 
148 
154  vtkSetClampMacro(ProjectionNormal, int, VTK_ITW_PROJECTION_YZ, VTK_ITW_PROJECTION_XY);
155  vtkGetMacro(ProjectionNormal, int);
156  void SetProjectionNormalToXAxes() { this->SetProjectionNormal(0); }
157  void SetProjectionNormalToYAxes() { this->SetProjectionNormal(1); }
158  void SetProjectionNormalToZAxes() { this->SetProjectionNormal(2); }
160 
162 
169  void SetProjectionPosition(double position);
170  vtkGetMacro(ProjectionPosition, double);
172 
174 
177  void SetSnapToImage(vtkTypeBool snap);
178  vtkGetMacro(SnapToImage, vtkTypeBool);
179  vtkBooleanMacro(SnapToImage, vtkTypeBool);
181 
183 
188  vtkSetMacro(AutoClose, vtkTypeBool);
189  vtkGetMacro(AutoClose, vtkTypeBool);
190  vtkBooleanMacro(AutoClose, vtkTypeBool);
192 
194 
200  vtkSetMacro(CaptureRadius, double);
201  vtkGetMacro(CaptureRadius, double);
203 
210  void GetPath(vtkPolyData* pd);
211 
215  vtkGlyphSource2D* GetGlyphSource() { return this->HandleGenerator; }
216 
218 
222  vtkSetClampMacro(ImageSnapType, int, VTK_ITW_SNAP_CELLS, VTK_ITW_SNAP_POINTS);
223  vtkGetMacro(ImageSnapType, int);
225 
227 
230  void SetHandlePosition(int handle, double xyz[3]);
231  void SetHandlePosition(int handle, double x, double y, double z);
232  void GetHandlePosition(int handle, double xyz[3]);
233  double* GetHandlePosition(int handle) VTK_SIZEHINT(3);
235 
237 
240  vtkGetMacro(NumberOfHandles, int);
242 
244 
247  void SetInteraction(vtkTypeBool interact);
248  vtkGetMacro(Interaction, vtkTypeBool);
249  vtkBooleanMacro(Interaction, vtkTypeBool);
251 
257  void InitializeHandles(vtkPoints*);
258 
262  int IsClosed();
263 
265 
268  vtkSetMacro(HandleLeftMouseButton, vtkTypeBool);
269  vtkGetMacro(HandleLeftMouseButton, vtkTypeBool);
270  vtkBooleanMacro(HandleLeftMouseButton, vtkTypeBool);
271  vtkSetMacro(HandleMiddleMouseButton, vtkTypeBool);
272  vtkGetMacro(HandleMiddleMouseButton, vtkTypeBool);
273  vtkBooleanMacro(HandleMiddleMouseButton, vtkTypeBool);
274  vtkSetMacro(HandleRightMouseButton, vtkTypeBool);
275  vtkGetMacro(HandleRightMouseButton, vtkTypeBool);
276  vtkBooleanMacro(HandleRightMouseButton, vtkTypeBool);
278 
279 protected:
281  ~vtkImageTracerWidget() override;
282 
283  // Manage the state of the widget
284  int State;
286  {
287  Start = 0,
294  Outside
295  };
296 
297  // handles the events
298  static void ProcessEvents(
299  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
300 
301  // ProcessEvents() dispatches to these methods.
302  void OnLeftButtonDown();
303  void OnLeftButtonUp();
304  void OnMiddleButtonDown();
305  void OnMiddleButtonUp();
306  void OnRightButtonDown();
307  void OnRightButtonUp();
308  void OnMouseMove();
309 
310  void AddObservers();
311 
312  // Controlling ivars
319  double CaptureRadius; // tolerance for auto path close
322  int LastX;
323  int LastY;
324 
325  void Trace(int, int);
326  void Snap(double*);
327  void MovePoint(const double*, const double*);
328  void Translate(const double*, const double*);
329  void ClosePath();
330 
331  // 2D glyphs representing hot spots (e.g., handles)
335 
336  // Transforms required as 2D glyphs are generated in the x-y plane
340 
341  void AppendHandles(double*);
342  void ResetHandles();
343  void AllocateHandles(const int&);
344  void AdjustHandlePosition(const int&, double*);
345  int HighlightHandle(vtkProp*); // returns handle index or -1 on fail
346  void EraseHandle(const int&);
347  void SizeHandles() override;
348  void InsertHandleOnLine(double*);
349 
353 
354  vtkProp* ViewProp; // the prop we want to pick on
355  vtkPropPicker* PropPicker; // the prop's picker
356 
357  // Representation of the line
362  vtkIdType CurrentPoints[2];
363 
364  void HighlightLine(const int&);
365  void BuildLinesFromHandles();
366  void ResetLine(double*);
367  void AppendLine(double*);
369 
370  // Do the picking of the handles and the lines
374 
375  // Register internal Pickers within PickingManager
376  void RegisterPickers() override;
377 
378  // Properties used to control the appearance of selected objects and
379  // the manipulator in general.
384  void CreateDefaultProperties();
385 
386  // Enable/Disable mouse button events
390 
391 private:
393  void operator=(const vtkImageTracerWidget&) = delete;
394 };
395 
396 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:56
#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:51
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:67
#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:41
transform points and associated normals and vectors for polygonal dataset
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
3D widget for tracing on planar props.
int vtkIdType
Definition: vtkType.h:332
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:90
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:39
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:186
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:72
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:39
vtkCellPicker * HandlePicker