VTK  9.2.6
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=========================================================================*/
96#ifndef vtkImageTracerWidget_h
97#define vtkImageTracerWidget_h
98
99#include "vtk3DWidget.h"
100#include "vtkInteractionWidgetsModule.h" // For export macro
101
103class vtkActor;
104class vtkCellArray;
105class vtkCellPicker;
106class vtkFloatArray;
107class vtkGlyphSource2D;
108class vtkPoints;
109class vtkPolyData;
110class vtkProp;
111class vtkProperty;
112class vtkPropPicker;
113class vtkTransform;
115
116#define VTK_ITW_PROJECTION_YZ 0
117#define VTK_ITW_PROJECTION_XZ 1
118#define VTK_ITW_PROJECTION_XY 2
119#define VTK_ITW_SNAP_CELLS 0
120#define VTK_ITW_SNAP_POINTS 1
121
122class VTKINTERACTIONWIDGETS_EXPORT vtkImageTracerWidget : public vtk3DWidget
123{
124public:
129
131 void PrintSelf(ostream& os, vtkIndent indent) override;
132
134
137 void SetEnabled(int) override;
138 void PlaceWidget(double bounds[6]) override;
139 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
141 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
142 {
143 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
144 }
146
148
153 vtkGetObjectMacro(HandleProperty, vtkProperty);
155 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
157
159
164 vtkGetObjectMacro(LineProperty, vtkProperty);
166 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
168
172 void SetViewProp(vtkProp* prop);
173
175
178 vtkSetMacro(ProjectToPlane, vtkTypeBool);
179 vtkGetMacro(ProjectToPlane, vtkTypeBool);
180 vtkBooleanMacro(ProjectToPlane, vtkTypeBool);
182
184
190 vtkSetClampMacro(ProjectionNormal, int, VTK_ITW_PROJECTION_YZ, VTK_ITW_PROJECTION_XY);
191 vtkGetMacro(ProjectionNormal, int);
192 void SetProjectionNormalToXAxes() { this->SetProjectionNormal(0); }
193 void SetProjectionNormalToYAxes() { this->SetProjectionNormal(1); }
194 void SetProjectionNormalToZAxes() { this->SetProjectionNormal(2); }
196
198
206 vtkGetMacro(ProjectionPosition, double);
208
210
214 vtkGetMacro(SnapToImage, vtkTypeBool);
215 vtkBooleanMacro(SnapToImage, vtkTypeBool);
217
219
224 vtkSetMacro(AutoClose, vtkTypeBool);
225 vtkGetMacro(AutoClose, vtkTypeBool);
226 vtkBooleanMacro(AutoClose, vtkTypeBool);
228
230
236 vtkSetMacro(CaptureRadius, double);
237 vtkGetMacro(CaptureRadius, double);
239
247
251 vtkGlyphSource2D* GetGlyphSource() { return this->HandleGenerator; }
252
254
258 vtkSetClampMacro(ImageSnapType, int, VTK_ITW_SNAP_CELLS, VTK_ITW_SNAP_POINTS);
259 vtkGetMacro(ImageSnapType, int);
261
263
266 void SetHandlePosition(int handle, double xyz[3]);
267 void SetHandlePosition(int handle, double x, double y, double z);
268 void GetHandlePosition(int handle, double xyz[3]);
269 double* GetHandlePosition(int handle) VTK_SIZEHINT(3);
271
273
276 vtkGetMacro(NumberOfHandles, int);
278
280
284 vtkGetMacro(Interaction, vtkTypeBool);
285 vtkBooleanMacro(Interaction, vtkTypeBool);
287
294
298 int IsClosed();
299
301
304 vtkSetMacro(HandleLeftMouseButton, vtkTypeBool);
305 vtkGetMacro(HandleLeftMouseButton, vtkTypeBool);
306 vtkBooleanMacro(HandleLeftMouseButton, vtkTypeBool);
307 vtkSetMacro(HandleMiddleMouseButton, vtkTypeBool);
308 vtkGetMacro(HandleMiddleMouseButton, vtkTypeBool);
309 vtkBooleanMacro(HandleMiddleMouseButton, vtkTypeBool);
310 vtkSetMacro(HandleRightMouseButton, vtkTypeBool);
311 vtkGetMacro(HandleRightMouseButton, vtkTypeBool);
312 vtkBooleanMacro(HandleRightMouseButton, vtkTypeBool);
314
315protected:
318
319 // Manage the state of the widget
320 int State;
322 {
323 Start = 0,
330 Outside
331 };
332
333 // handles the events
334 static void ProcessEvents(
335 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
336
337 // ProcessEvents() dispatches to these methods.
345
347
348 // Controlling ivars
355 double CaptureRadius; // tolerance for auto path close
358 int LastX;
359 int LastY;
360
361 void Trace(int, int);
362 void Snap(double*);
363 void MovePoint(const double*, const double*);
364 void Translate(const double*, const double*);
365 void ClosePath();
366
367 // 2D glyphs representing hot spots (e.g., handles)
371
372 // Transforms required as 2D glyphs are generated in the x-y plane
376
377 void AppendHandles(double*);
379 void AllocateHandles(const int&);
380 void AdjustHandlePosition(const int&, double*);
381 int HighlightHandle(vtkProp*); // returns handle index or -1 on fail
382 void EraseHandle(const int&);
383 void SizeHandles() override;
384 void InsertHandleOnLine(double*);
385
389
390 vtkProp* ViewProp; // the prop we want to pick on
391 vtkPropPicker* PropPicker; // the prop's picker
392
393 // Representation of the line
398 vtkIdType CurrentPoints[2];
399
400 void HighlightLine(const int&);
402 void ResetLine(double*);
403 void AppendLine(double*);
405
406 // Do the picking of the handles and the lines
410
411 // Register internal Pickers within PickingManager
412 void RegisterPickers() override;
413
414 // Properties used to control the appearance of selected objects and
415 // the manipulator in general.
421
422 // Enable/Disable mouse button events
426
427private:
429 void operator=(const vtkImageTracerWidget&) = delete;
430};
431
432#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:161
object to represent cell connectivity
Definition: vtkCellArray.h:296
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.
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:119
abstract base class for most VTK objects
Definition: vtkObject.h:79
represent and manipulate 3D points
Definition: vtkPoints.h:149
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:200
pick an actor/prop using graphics hardware
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:73
represent surface properties of a geometric object
Definition: vtkProperty.h:177
transform points and associated normals and vectors for polygonal dataset
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:170
@ 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(...)