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=========================================================================*/
69#ifndef vtkImageTracerWidget_h
70#define vtkImageTracerWidget_h
71
72#include "vtk3DWidget.h"
73#include "vtkInteractionWidgetsModule.h" // For export macro
74
76class vtkActor;
77class vtkCellArray;
78class vtkCellPicker;
79class vtkFloatArray;
81class vtkPoints;
82class vtkPolyData;
83class vtkProp;
84class vtkProperty;
85class vtkPropPicker;
86class vtkTransform;
88
89#define VTK_ITW_PROJECTION_YZ 0
90#define VTK_ITW_PROJECTION_XZ 1
91#define VTK_ITW_PROJECTION_XY 2
92#define VTK_ITW_SNAP_CELLS 0
93#define VTK_ITW_SNAP_POINTS 1
94
95class VTKINTERACTIONWIDGETS_EXPORT vtkImageTracerWidget : public vtk3DWidget
96{
97public:
102
104 void PrintSelf(ostream& os, vtkIndent indent) override;
105
107
110 void SetEnabled(int) override;
111 void PlaceWidget(double bounds[6]) override;
112 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
114 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
115 {
116 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
117 }
119
121
126 vtkGetObjectMacro(HandleProperty, vtkProperty);
128 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
130
132
137 vtkGetObjectMacro(LineProperty, vtkProperty);
139 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
141
145 void SetViewProp(vtkProp* prop);
146
148
151 vtkSetMacro(ProjectToPlane, vtkTypeBool);
152 vtkGetMacro(ProjectToPlane, vtkTypeBool);
153 vtkBooleanMacro(ProjectToPlane, vtkTypeBool);
155
157
163 vtkSetClampMacro(ProjectionNormal, int, VTK_ITW_PROJECTION_YZ, VTK_ITW_PROJECTION_XY);
164 vtkGetMacro(ProjectionNormal, int);
165 void SetProjectionNormalToXAxes() { this->SetProjectionNormal(0); }
166 void SetProjectionNormalToYAxes() { this->SetProjectionNormal(1); }
167 void SetProjectionNormalToZAxes() { this->SetProjectionNormal(2); }
169
171
178 void SetProjectionPosition(double position);
179 vtkGetMacro(ProjectionPosition, double);
181
183
187 vtkGetMacro(SnapToImage, vtkTypeBool);
188 vtkBooleanMacro(SnapToImage, vtkTypeBool);
190
192
197 vtkSetMacro(AutoClose, vtkTypeBool);
198 vtkGetMacro(AutoClose, vtkTypeBool);
199 vtkBooleanMacro(AutoClose, vtkTypeBool);
201
203
209 vtkSetMacro(CaptureRadius, double);
210 vtkGetMacro(CaptureRadius, double);
212
220
224 vtkGlyphSource2D* GetGlyphSource() { return this->HandleGenerator; }
225
227
231 vtkSetClampMacro(ImageSnapType, int, VTK_ITW_SNAP_CELLS, VTK_ITW_SNAP_POINTS);
232 vtkGetMacro(ImageSnapType, int);
234
236
239 void SetHandlePosition(int handle, double xyz[3]);
240 void SetHandlePosition(int handle, double x, double y, double z);
241 void GetHandlePosition(int handle, double xyz[3]);
242 double* GetHandlePosition(int handle) VTK_SIZEHINT(3);
244
246
249 vtkGetMacro(NumberOfHandles, int);
251
253
257 vtkGetMacro(Interaction, vtkTypeBool);
258 vtkBooleanMacro(Interaction, vtkTypeBool);
260
267
271 int IsClosed();
272
274
277 vtkSetMacro(HandleLeftMouseButton, vtkTypeBool);
278 vtkGetMacro(HandleLeftMouseButton, vtkTypeBool);
279 vtkBooleanMacro(HandleLeftMouseButton, vtkTypeBool);
280 vtkSetMacro(HandleMiddleMouseButton, vtkTypeBool);
281 vtkGetMacro(HandleMiddleMouseButton, vtkTypeBool);
282 vtkBooleanMacro(HandleMiddleMouseButton, vtkTypeBool);
283 vtkSetMacro(HandleRightMouseButton, vtkTypeBool);
284 vtkGetMacro(HandleRightMouseButton, vtkTypeBool);
285 vtkBooleanMacro(HandleRightMouseButton, vtkTypeBool);
287
288protected:
291
292 // Manage the state of the widget
293 int State;
295 {
296 Start = 0,
303 Outside
304 };
305
306 // handles the events
307 static void ProcessEvents(
308 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
309
310 // ProcessEvents() dispatches to these methods.
318
320
321 // Controlling ivars
328 double CaptureRadius; // tolerance for auto path close
331 int LastX;
332 int LastY;
333
334 void Trace(int, int);
335 void Snap(double*);
336 void MovePoint(const double*, const double*);
337 void Translate(const double*, const double*);
338 void ClosePath();
339
340 // 2D glyphs representing hot spots (e.g., handles)
344
345 // Transforms required as 2D glyphs are generated in the x-y plane
349
350 void AppendHandles(double*);
352 void AllocateHandles(const int&);
353 void AdjustHandlePosition(const int&, double*);
354 int HighlightHandle(vtkProp*); // returns handle index or -1 on fail
355 void EraseHandle(const int&);
356 void SizeHandles() override;
357 void InsertHandleOnLine(double*);
358
362
363 vtkProp* ViewProp; // the prop we want to pick on
364 vtkPropPicker* PropPicker; // the prop's picker
365
366 // Representation of the line
371 vtkIdType CurrentPoints[2];
372
373 void HighlightLine(const int&);
375 void ResetLine(double*);
376 void AppendLine(double*);
378
379 // Do the picking of the handles and the lines
383
384 // Register internal Pickers within PickingManager
385 void RegisterPickers() override;
386
387 // Properties used to control the appearance of selected objects and
388 // the manipulator in general.
394
395 // Enable/Disable mouse button events
399
400private:
402 void operator=(const vtkImageTracerWidget&) = delete;
403};
404
405#endif
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:71
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:72
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:55
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:66
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
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(...)