VTK  9.4.20250114
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
87#ifndef vtkImageTracerWidget_h
88#define vtkImageTracerWidget_h
89
90#include "vtk3DWidget.h"
91#include "vtkInteractionWidgetsModule.h" // For export macro
92
93VTK_ABI_NAMESPACE_BEGIN
95class vtkActor;
96class vtkCellArray;
97class vtkCellPicker;
98class vtkFloatArray;
100class vtkPoints;
101class vtkPolyData;
102class vtkProp;
103class vtkProperty;
104class vtkPropPicker;
105class vtkTransform;
107
108#define VTK_ITW_PROJECTION_YZ 0
109#define VTK_ITW_PROJECTION_XZ 1
110#define VTK_ITW_PROJECTION_XY 2
111#define VTK_ITW_SNAP_CELLS 0
112#define VTK_ITW_SNAP_POINTS 1
113
114class VTKINTERACTIONWIDGETS_EXPORT vtkImageTracerWidget : public vtk3DWidget
115{
116public:
121
123 void PrintSelf(ostream& os, vtkIndent indent) override;
124
126
129 void SetEnabled(int) override;
130 void PlaceWidget(double bounds[6]) override;
131 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
133 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
134 {
135 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
136 }
138
140
145 vtkGetObjectMacro(HandleProperty, vtkProperty);
147 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
149
151
156 vtkGetObjectMacro(LineProperty, vtkProperty);
158 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
160
164 void SetViewProp(vtkProp* prop);
165
167
170 vtkSetMacro(ProjectToPlane, vtkTypeBool);
171 vtkGetMacro(ProjectToPlane, vtkTypeBool);
172 vtkBooleanMacro(ProjectToPlane, vtkTypeBool);
174
176
182 vtkSetClampMacro(ProjectionNormal, int, VTK_ITW_PROJECTION_YZ, VTK_ITW_PROJECTION_XY);
183 vtkGetMacro(ProjectionNormal, int);
184 void SetProjectionNormalToXAxes() { this->SetProjectionNormal(0); }
185 void SetProjectionNormalToYAxes() { this->SetProjectionNormal(1); }
186 void SetProjectionNormalToZAxes() { this->SetProjectionNormal(2); }
188
190
197 void SetProjectionPosition(double position);
198 vtkGetMacro(ProjectionPosition, double);
200
202
206 vtkGetMacro(SnapToImage, vtkTypeBool);
207 vtkBooleanMacro(SnapToImage, vtkTypeBool);
209
211
216 vtkSetMacro(AutoClose, vtkTypeBool);
217 vtkGetMacro(AutoClose, vtkTypeBool);
218 vtkBooleanMacro(AutoClose, vtkTypeBool);
220
222
228 vtkSetMacro(CaptureRadius, double);
229 vtkGetMacro(CaptureRadius, double);
231
239
243 vtkGlyphSource2D* GetGlyphSource() { return this->HandleGenerator; }
244
246
250 vtkSetClampMacro(ImageSnapType, int, VTK_ITW_SNAP_CELLS, VTK_ITW_SNAP_POINTS);
251 vtkGetMacro(ImageSnapType, int);
253
255
258 void SetHandlePosition(int handle, double xyz[3]);
259 void SetHandlePosition(int handle, double x, double y, double z);
260 void GetHandlePosition(int handle, double xyz[3]);
261 double* GetHandlePosition(int handle) VTK_SIZEHINT(3);
263
265
268 vtkGetMacro(NumberOfHandles, int);
270
272
276 vtkGetMacro(Interaction, vtkTypeBool);
277 vtkBooleanMacro(Interaction, vtkTypeBool);
279
286
290 int IsClosed();
291
293
296 vtkSetMacro(HandleLeftMouseButton, vtkTypeBool);
297 vtkGetMacro(HandleLeftMouseButton, vtkTypeBool);
298 vtkBooleanMacro(HandleLeftMouseButton, vtkTypeBool);
299 vtkSetMacro(HandleMiddleMouseButton, vtkTypeBool);
300 vtkGetMacro(HandleMiddleMouseButton, vtkTypeBool);
301 vtkBooleanMacro(HandleMiddleMouseButton, vtkTypeBool);
302 vtkSetMacro(HandleRightMouseButton, vtkTypeBool);
303 vtkGetMacro(HandleRightMouseButton, vtkTypeBool);
304 vtkBooleanMacro(HandleRightMouseButton, vtkTypeBool);
306
307protected:
310
311 // Manage the state of the widget
312 int State;
314 {
315 Start = 0,
322 Outside
323 };
324
325 // handles the events
326 static void ProcessEvents(
327 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
328
329 // ProcessEvents() dispatches to these methods.
337
339
340 // Controlling ivars
347 double CaptureRadius; // tolerance for auto path close
350 int LastX;
351 int LastY;
352
353 void Trace(int, int);
354 void Snap(double*);
355 void MovePoint(const double*, const double*);
356 void Translate(const double*, const double*);
357 void ClosePath();
358
359 // 2D glyphs representing hot spots (e.g., handles)
363
364 // Transforms required as 2D glyphs are generated in the x-y plane
368
369 void AppendHandles(double*);
371 void AllocateHandles(const int&);
372 void AdjustHandlePosition(const int&, double*);
373 int HighlightHandle(vtkProp*); // returns handle index or -1 on fail
374 void EraseHandle(const int&);
375 void SizeHandles() override;
376 void InsertHandleOnLine(double*);
377
381
382 vtkProp* ViewProp; // the prop we want to pick on
383 vtkPropPicker* PropPicker; // the prop's picker
384
385 // Representation of the line
390 vtkIdType CurrentPoints[2];
391
392 void HighlightLine(const int&);
394 void ResetLine(double*);
395 void AppendLine(double*);
397
398 // Do the picking of the handles and the lines
402
403 // Register internal Pickers within PickingManager
404 void RegisterPickers() override;
405
406 // Properties used to control the appearance of selected objects and
407 // the manipulator in general.
413
414 // Enable/Disable mouse button events
418
419private:
421 void operator=(const vtkImageTracerWidget&) = delete;
422};
423
424VTK_ABI_NAMESPACE_END
425#endif
an abstract superclass for 3D widgets
Definition vtk3DWidget.h:60
abstract API for pickers that can pick an instance of vtkProp
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
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:108
abstract base class for most VTK objects
Definition vtkObject.h:162
represent and manipulate 3D points
Definition vtkPoints.h:139
concrete dataset represents vertices, lines, polygons, and triangle strips
pick an actor/prop using graphics hardware
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:66
represent surface properties of a geometric object
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(...)