VTK  9.3.0
vtkImageTracerWidget.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
54#ifndef vtkImageTracerWidget_h
55#define vtkImageTracerWidget_h
56
57#include "vtk3DWidget.h"
58#include "vtkInteractionWidgetsModule.h" // For export macro
59
60VTK_ABI_NAMESPACE_BEGIN
62class vtkActor;
63class vtkCellArray;
64class vtkCellPicker;
65class vtkFloatArray;
67class vtkPoints;
68class vtkPolyData;
69class vtkProp;
70class vtkProperty;
71class vtkPropPicker;
72class vtkTransform;
74
75#define VTK_ITW_PROJECTION_YZ 0
76#define VTK_ITW_PROJECTION_XZ 1
77#define VTK_ITW_PROJECTION_XY 2
78#define VTK_ITW_SNAP_CELLS 0
79#define VTK_ITW_SNAP_POINTS 1
80
81class VTKINTERACTIONWIDGETS_EXPORT vtkImageTracerWidget : public vtk3DWidget
82{
83public:
88
90 void PrintSelf(ostream& os, vtkIndent indent) override;
91
93
96 void SetEnabled(int) override;
97 void PlaceWidget(double bounds[6]) override;
98 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
100 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
101 {
102 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
103 }
105
107
112 vtkGetObjectMacro(HandleProperty, vtkProperty);
114 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
116
118
123 vtkGetObjectMacro(LineProperty, vtkProperty);
125 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
127
131 void SetViewProp(vtkProp* prop);
132
134
137 vtkSetMacro(ProjectToPlane, vtkTypeBool);
138 vtkGetMacro(ProjectToPlane, vtkTypeBool);
139 vtkBooleanMacro(ProjectToPlane, vtkTypeBool);
141
143
149 vtkSetClampMacro(ProjectionNormal, int, VTK_ITW_PROJECTION_YZ, VTK_ITW_PROJECTION_XY);
150 vtkGetMacro(ProjectionNormal, int);
151 void SetProjectionNormalToXAxes() { this->SetProjectionNormal(0); }
152 void SetProjectionNormalToYAxes() { this->SetProjectionNormal(1); }
153 void SetProjectionNormalToZAxes() { this->SetProjectionNormal(2); }
155
157
164 void SetProjectionPosition(double position);
165 vtkGetMacro(ProjectionPosition, double);
167
169
173 vtkGetMacro(SnapToImage, vtkTypeBool);
174 vtkBooleanMacro(SnapToImage, vtkTypeBool);
176
178
183 vtkSetMacro(AutoClose, vtkTypeBool);
184 vtkGetMacro(AutoClose, vtkTypeBool);
185 vtkBooleanMacro(AutoClose, vtkTypeBool);
187
189
195 vtkSetMacro(CaptureRadius, double);
196 vtkGetMacro(CaptureRadius, double);
198
206
210 vtkGlyphSource2D* GetGlyphSource() { return this->HandleGenerator; }
211
213
217 vtkSetClampMacro(ImageSnapType, int, VTK_ITW_SNAP_CELLS, VTK_ITW_SNAP_POINTS);
218 vtkGetMacro(ImageSnapType, int);
220
222
225 void SetHandlePosition(int handle, double xyz[3]);
226 void SetHandlePosition(int handle, double x, double y, double z);
227 void GetHandlePosition(int handle, double xyz[3]);
228 double* GetHandlePosition(int handle) VTK_SIZEHINT(3);
230
232
235 vtkGetMacro(NumberOfHandles, int);
237
239
243 vtkGetMacro(Interaction, vtkTypeBool);
244 vtkBooleanMacro(Interaction, vtkTypeBool);
246
253
257 int IsClosed();
258
260
263 vtkSetMacro(HandleLeftMouseButton, vtkTypeBool);
264 vtkGetMacro(HandleLeftMouseButton, vtkTypeBool);
265 vtkBooleanMacro(HandleLeftMouseButton, vtkTypeBool);
266 vtkSetMacro(HandleMiddleMouseButton, vtkTypeBool);
267 vtkGetMacro(HandleMiddleMouseButton, vtkTypeBool);
268 vtkBooleanMacro(HandleMiddleMouseButton, vtkTypeBool);
269 vtkSetMacro(HandleRightMouseButton, vtkTypeBool);
270 vtkGetMacro(HandleRightMouseButton, vtkTypeBool);
271 vtkBooleanMacro(HandleRightMouseButton, vtkTypeBool);
273
274protected:
277
278 // Manage the state of the widget
279 int State;
281 {
282 Start = 0,
289 Outside
290 };
291
292 // handles the events
293 static void ProcessEvents(
294 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
295
296 // ProcessEvents() dispatches to these methods.
304
306
307 // Controlling ivars
314 double CaptureRadius; // tolerance for auto path close
317 int LastX;
318 int LastY;
319
320 void Trace(int, int);
321 void Snap(double*);
322 void MovePoint(const double*, const double*);
323 void Translate(const double*, const double*);
324 void ClosePath();
325
326 // 2D glyphs representing hot spots (e.g., handles)
330
331 // Transforms required as 2D glyphs are generated in the x-y plane
335
336 void AppendHandles(double*);
338 void AllocateHandles(const int&);
339 void AdjustHandlePosition(const int&, double*);
340 int HighlightHandle(vtkProp*); // returns handle index or -1 on fail
341 void EraseHandle(const int&);
342 void SizeHandles() override;
343 void InsertHandleOnLine(double*);
344
348
349 vtkProp* ViewProp; // the prop we want to pick on
350 vtkPropPicker* PropPicker; // the prop's picker
351
352 // Representation of the line
357 vtkIdType CurrentPoints[2];
358
359 void HighlightLine(const int&);
361 void ResetLine(double*);
362 void AppendLine(double*);
364
365 // Do the picking of the handles and the lines
369
370 // Register internal Pickers within PickingManager
371 void RegisterPickers() override;
372
373 // Properties used to control the appearance of selected objects and
374 // the manipulator in general.
380
381 // Enable/Disable mouse button events
385
386private:
388 void operator=(const vtkImageTracerWidget&) = delete;
389};
390
391VTK_ABI_NAMESPACE_END
392#endif
an abstract superclass for 3D widgets
Definition vtk3DWidget.h:57
abstract API for pickers that can pick an instance of vtkProp
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:50
object to represent cell connectivity
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.
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 *)
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:38
abstract base class for most VTK objects
Definition vtkObject.h:58
represent and manipulate 3D points
Definition vtkPoints.h:38
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:89
pick an actor/prop using graphics hardware
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:52
represent surface properties of a geometric object
Definition vtkProperty.h:66
transform points and associated normals and vectors for polygonal dataset
describes linear transformations via a 4x4 matrix
int vtkTypeBool
Definition vtkABI.h:64
#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:315
#define VTK_SIZEHINT(...)