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 =========================================================================*/
57 #ifndef vtkImageTracerWidget_h
58 #define vtkImageTracerWidget_h
59 
60 #include "vtk3DWidget.h"
61 #include "vtkInteractionWidgetsModule.h" // For export macro
62 
64 class vtkActor;
65 class vtkCellArray;
66 class vtkCellPicker;
67 class vtkFloatArray;
68 class vtkGlyphSource2D;
69 class vtkPoints;
70 class vtkPolyData;
71 class vtkProp;
72 class vtkProperty;
73 class vtkPropPicker;
74 class vtkTransform;
76 
77 #define VTK_ITW_PROJECTION_YZ 0
78 #define VTK_ITW_PROJECTION_XZ 1
79 #define VTK_ITW_PROJECTION_XY 2
80 #define VTK_ITW_SNAP_CELLS 0
81 #define VTK_ITW_SNAP_POINTS 1
82 
83 class VTKINTERACTIONWIDGETS_EXPORT vtkImageTracerWidget : public vtk3DWidget
84 {
85 public:
89  static vtkImageTracerWidget* New();
90 
92  void PrintSelf(ostream& os, vtkIndent indent) override;
93 
95 
98  void SetEnabled(int) override;
99  void PlaceWidget(double bounds[6]) override;
100  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
102  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
103  {
104  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
105  }
107 
109 
113  virtual void SetHandleProperty(vtkProperty*);
114  vtkGetObjectMacro(HandleProperty, vtkProperty);
115  virtual void SetSelectedHandleProperty(vtkProperty*);
116  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
118 
120 
124  virtual void SetLineProperty(vtkProperty*);
125  vtkGetObjectMacro(LineProperty, vtkProperty);
126  virtual void SetSelectedLineProperty(vtkProperty*);
127  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
129 
133  void SetViewProp(vtkProp* prop);
134 
136 
139  vtkSetMacro(ProjectToPlane, vtkTypeBool);
140  vtkGetMacro(ProjectToPlane, vtkTypeBool);
141  vtkBooleanMacro(ProjectToPlane, vtkTypeBool);
143 
145 
151  vtkSetClampMacro(ProjectionNormal, int, VTK_ITW_PROJECTION_YZ, VTK_ITW_PROJECTION_XY);
152  vtkGetMacro(ProjectionNormal, int);
153  void SetProjectionNormalToXAxes() { this->SetProjectionNormal(0); }
154  void SetProjectionNormalToYAxes() { this->SetProjectionNormal(1); }
155  void SetProjectionNormalToZAxes() { this->SetProjectionNormal(2); }
157 
159 
166  void SetProjectionPosition(double position);
167  vtkGetMacro(ProjectionPosition, double);
169 
171 
174  void SetSnapToImage(vtkTypeBool snap);
175  vtkGetMacro(SnapToImage, vtkTypeBool);
176  vtkBooleanMacro(SnapToImage, vtkTypeBool);
178 
180 
185  vtkSetMacro(AutoClose, vtkTypeBool);
186  vtkGetMacro(AutoClose, vtkTypeBool);
187  vtkBooleanMacro(AutoClose, vtkTypeBool);
189 
191 
197  vtkSetMacro(CaptureRadius, double);
198  vtkGetMacro(CaptureRadius, double);
200 
207  void GetPath(vtkPolyData* pd);
208 
212  vtkGlyphSource2D* GetGlyphSource() { return this->HandleGenerator; }
213 
215 
219  vtkSetClampMacro(ImageSnapType, int, VTK_ITW_SNAP_CELLS, VTK_ITW_SNAP_POINTS);
220  vtkGetMacro(ImageSnapType, int);
222 
224 
227  void SetHandlePosition(int handle, double xyz[3]);
228  void SetHandlePosition(int handle, double x, double y, double z);
229  void GetHandlePosition(int handle, double xyz[3]);
230  double* GetHandlePosition(int handle) VTK_SIZEHINT(3);
232 
234 
237  vtkGetMacro(NumberOfHandles, int);
239 
241 
244  void SetInteraction(vtkTypeBool interact);
245  vtkGetMacro(Interaction, vtkTypeBool);
246  vtkBooleanMacro(Interaction, vtkTypeBool);
248 
254  void InitializeHandles(vtkPoints*);
255 
259  int IsClosed();
260 
262 
265  vtkSetMacro(HandleLeftMouseButton, vtkTypeBool);
266  vtkGetMacro(HandleLeftMouseButton, vtkTypeBool);
267  vtkBooleanMacro(HandleLeftMouseButton, vtkTypeBool);
268  vtkSetMacro(HandleMiddleMouseButton, vtkTypeBool);
269  vtkGetMacro(HandleMiddleMouseButton, vtkTypeBool);
270  vtkBooleanMacro(HandleMiddleMouseButton, vtkTypeBool);
271  vtkSetMacro(HandleRightMouseButton, vtkTypeBool);
272  vtkGetMacro(HandleRightMouseButton, vtkTypeBool);
273  vtkBooleanMacro(HandleRightMouseButton, vtkTypeBool);
275 
276 protected:
278  ~vtkImageTracerWidget() override;
279 
280  // Manage the state of the widget
281  int State;
283  {
284  Start = 0,
291  Outside
292  };
293 
294  // handles the events
295  static void ProcessEvents(
296  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
297 
298  // ProcessEvents() dispatches to these methods.
299  void OnLeftButtonDown();
300  void OnLeftButtonUp();
301  void OnMiddleButtonDown();
302  void OnMiddleButtonUp();
303  void OnRightButtonDown();
304  void OnRightButtonUp();
305  void OnMouseMove();
306 
307  void AddObservers();
308 
309  // Controlling ivars
316  double CaptureRadius; // tolerance for auto path close
319  int LastX;
320  int LastY;
321 
322  void Trace(int, int);
323  void Snap(double*);
324  void MovePoint(const double*, const double*);
325  void Translate(const double*, const double*);
326  void ClosePath();
327 
328  // 2D glyphs representing hot spots (e.g., handles)
332 
333  // Transforms required as 2D glyphs are generated in the x-y plane
337 
338  void AppendHandles(double*);
339  void ResetHandles();
340  void AllocateHandles(const int&);
341  void AdjustHandlePosition(const int&, double*);
342  int HighlightHandle(vtkProp*); // returns handle index or -1 on fail
343  void EraseHandle(const int&);
344  void SizeHandles() override;
345  void InsertHandleOnLine(double*);
346 
350 
351  vtkProp* ViewProp; // the prop we want to pick on
352  vtkPropPicker* PropPicker; // the prop's picker
353 
354  // Representation of the line
359  vtkIdType CurrentPoints[2];
360 
361  void HighlightLine(const int&);
362  void BuildLinesFromHandles();
363  void ResetLine(double*);
364  void AppendLine(double*);
366 
367  // Do the picking of the handles and the lines
371 
372  // Register internal Pickers within PickingManager
373  void RegisterPickers() override;
374 
375  // Properties used to control the appearance of selected objects and
376  // the manipulator in general.
381  void CreateDefaultProperties();
382 
383  // Enable/Disable mouse button events
387 
388 private:
390  void operator=(const vtkImageTracerWidget&) = delete;
391 };
392 
393 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:50
#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:56
pick an actor/prop using graphics hardware
Definition: vtkPropPicker.h:42
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