VTK  9.1.0
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
70class vtkActor;
71class vtkCellArray;
72class vtkCellPicker;
73class vtkFloatArray;
75class vtkPoints;
76class vtkPolyData;
77class vtkProp;
78class vtkProperty;
79class vtkPropPicker;
80class 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
89class VTKINTERACTIONWIDGETS_EXPORT vtkImageTracerWidget : public vtk3DWidget
90{
91public:
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
120 vtkGetObjectMacro(HandleProperty, vtkProperty);
122 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
124
126
131 vtkGetObjectMacro(LineProperty, 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
173 vtkGetMacro(ProjectionPosition, double);
175
177
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
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
251 vtkGetMacro(Interaction, vtkTypeBool);
252 vtkBooleanMacro(Interaction, vtkTypeBool);
254
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
282protected:
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.
312
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*);
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&);
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.
388
389 // Enable/Disable mouse button events
393
394private:
396 void operator=(const vtkImageTracerWidget&) = delete;
397};
398
399#endif
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:68
abstract API for pickers that can pick an instance of vtkProp
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:55
object to represent cell connectivity
Definition: vtkCellArray.h:190
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:76
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:45
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 *)
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.
static vtkImageTracerWidget * New()
Instantiate the object.
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).
vtkGlyphSource2D * GetGlyphSource()
Get the handles' geometric representation via vtkGlyphSource2D.
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 &)
double * GetHandlePosition(int handle)
Set/Get the handle position in terms of a zero-based array of handles.
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 *)
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
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:43
abstract base class for most VTK objects
Definition: vtkObject.h:63
represent and manipulate 3D points
Definition: vtkPoints.h:43
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:95
pick an actor/prop using graphics hardware
Definition: vtkPropPicker.h:49
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:57
represent surface properties of a geometric object
Definition: vtkProperty.h:71
transform points and associated normals and vectors for polygonal dataset
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:64
@ 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(...)