VTK
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=========================================================================*/
60#ifndef vtkImageTracerWidget_h
61#define vtkImageTracerWidget_h
62
63#include "vtkInteractionWidgetsModule.h" // For export macro
64#include "vtk3DWidget.h"
65
67class vtkActor;
68class vtkCellArray;
69class vtkCellPicker;
70class vtkFloatArray;
72class vtkPoints;
73class vtkPolyData;
74class vtkProp;
75class vtkProperty;
76class vtkPropPicker;
77class vtkTransform;
79
80#define VTK_ITW_PROJECTION_YZ 0
81#define VTK_ITW_PROJECTION_XZ 1
82#define VTK_ITW_PROJECTION_XY 2
83#define VTK_ITW_SNAP_CELLS 0
84#define VTK_ITW_SNAP_POINTS 1
85
86class VTKINTERACTIONWIDGETS_EXPORT vtkImageTracerWidget : public vtk3DWidget
87{
88public:
93
95 void PrintSelf(ostream& os, vtkIndent indent);
96
98
101 virtual void SetEnabled(int);
102 virtual void PlaceWidget(double bounds[6]);
104 {this->Superclass::PlaceWidget();}
105 void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
106 double zmin, double zmax)
107 {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
109
111
116 vtkGetObjectMacro(HandleProperty, vtkProperty);
118 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
120
122
127 vtkGetObjectMacro(LineProperty, vtkProperty);
129 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
131
135 void SetViewProp(vtkProp* prop);
136
138
141 vtkSetMacro(ProjectToPlane,int);
142 vtkGetMacro(ProjectToPlane,int);
143 vtkBooleanMacro(ProjectToPlane,int);
145
147
153 vtkSetClampMacro(ProjectionNormal,int,VTK_ITW_PROJECTION_YZ,VTK_ITW_PROJECTION_XY);
154 vtkGetMacro(ProjectionNormal,int);
156 { this->SetProjectionNormal(0); }
158 { this->SetProjectionNormal(1); }
160 { this->SetProjectionNormal(2); }
162
164
172 vtkGetMacro(ProjectionPosition,double);
174
176
179 void SetSnapToImage(int snap);
180 vtkGetMacro(SnapToImage,int);
181 vtkBooleanMacro(SnapToImage,int);
183
185
190 vtkSetMacro(AutoClose,int);
191 vtkGetMacro(AutoClose,int);
192 vtkBooleanMacro(AutoClose,int);
194
196
202 vtkSetMacro(CaptureRadius,double);
203 vtkGetMacro(CaptureRadius,double);
205
213
217 vtkGlyphSource2D* GetGlyphSource() { return this->HandleGenerator; }
218
220
224 vtkSetClampMacro(ImageSnapType,int,VTK_ITW_SNAP_CELLS,VTK_ITW_SNAP_POINTS);
225 vtkGetMacro(ImageSnapType,int);
227
229
232 void SetHandlePosition(int handle, double xyz[3]);
233 void SetHandlePosition(int handle, double x, double y, double z);
234 void GetHandlePosition(int handle, double xyz[3]);
235 double* GetHandlePosition(int handle);
237
239
242 vtkGetMacro(NumberOfHandles,int);
244
246
249 void SetInteraction(int interact);
250 vtkGetMacro(Interaction,int);
251 vtkBooleanMacro(Interaction,int);
253
260
264 int IsClosed();
265
267
270 vtkSetMacro(HandleLeftMouseButton,int);
271 vtkGetMacro(HandleLeftMouseButton,int);
272 vtkBooleanMacro(HandleLeftMouseButton,int);
273 vtkSetMacro(HandleMiddleMouseButton,int);
274 vtkGetMacro(HandleMiddleMouseButton,int);
275 vtkBooleanMacro(HandleMiddleMouseButton,int);
276 vtkSetMacro(HandleRightMouseButton,int);
277 vtkGetMacro(HandleRightMouseButton,int);
278 vtkBooleanMacro(HandleRightMouseButton,int);
280
281#ifdef VTK_WORKAROUND_WINDOWS_MANGLE
282# define SetPropA SetProp
283# define SetPropW SetProp
284#endif
285
286#ifdef VTK_WORKAROUND_WINDOWS_MANGLE
287# undef SetPropA
288# undef SetPropW
289#endif
290
291protected:
294
295 // Manage the state of the widget
296 int State;
298 {
299 Start=0,
306 Outside
307 };
308
309 //handles the events
310 static void ProcessEvents(vtkObject* object,
311 unsigned long event,
312 void* clientdata,
313 void* calldata);
314
315 // ProcessEvents() dispatches to these methods.
323
325
326 // Controlling ivars
333 double CaptureRadius; // tolerance for auto path close
336 int LastX;
337 int LastY;
338
339 void Trace(int , int );
340 void Snap(double* );
341 void MovePoint(const double* , const double* );
342 void Translate(const double* , const double* );
343 void ClosePath();
344
345 // 2D glyphs representing hot spots (e.g., handles)
349
350 // Transforms required as 2D glyphs are generated in the x-y plane
354
355 void AppendHandles(double*);
357 void AllocateHandles(const int& );
358 void AdjustHandlePosition(const int& , double*);
359 int HighlightHandle(vtkProp* ); // returns handle index or -1 on fail
360 void EraseHandle(const int& );
361 virtual void SizeHandles();
362 void InsertHandleOnLine(double* );
363
367
368 vtkProp *ViewProp; // the prop we want to pick on
369 vtkPropPicker *PropPicker; // the prop's picker
370
371 // Representation of the line
376 vtkIdType CurrentPoints[2];
377
378 void HighlightLine(const int& );
380 void ResetLine(double* );
381 void AppendLine(double* );
383
384 // Do the picking of the handles and the lines
388
389 // Register internal Pickers within PickingManager
390 virtual void RegisterPickers();
391
392 // Properties used to control the appearance of selected objects and
393 // the manipulator in general.
399
400 // Enable/Disable mouse button events
404
405private:
406 vtkImageTracerWidget(const vtkImageTracerWidget&) VTK_DELETE_FUNCTION;
407 void operator=(const vtkImageTracerWidget&) VTK_DELETE_FUNCTION;
408};
409
410#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:52
object to represent cell connectivity
Definition: vtkCellArray.h:51
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:70
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:42
create 2D glyphs represented by vtkPolyData
3D widget for tracing on planar props.
void SetInteraction(int interact)
Enable/disable mouse interaction when the widget is visible.
vtkCellPicker * HandlePicker
void AppendLine(double *)
void InsertHandleOnLine(double *)
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
void GetHandlePosition(int handle, double xyz[3])
virtual void SetSelectedLineProperty(vtkProperty *)
void AppendHandles(double *)
void SetSnapToImage(int snap)
Force snapping to image data while tracing.
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
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.
void ResetLine(double *)
void HighlightLine(const int &)
vtkTransformPolyDataFilter * TransformFilter
virtual void SetSelectedHandleProperty(vtkProperty *)
vtkGlyphSource2D * GetGlyphSource()
Get the handles' geometric representation via vtkGlyphSource2D.
int HighlightHandle(vtkProp *)
void SetHandlePosition(int handle, double x, double y, double z)
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
void EraseHandle(const int &)
double * GetHandlePosition(int handle)
vtkAbstractPropPicker * CurrentPicker
void InitializeHandles(vtkPoints *)
Initialize the widget with a set of points and generate lines between them.
vtkFloatArray * TemporaryHandlePoints
void Translate(const double *, const double *)
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
vtkGlyphSource2D * HandleGenerator
void Snap(double *)
void CreateDefaultProperties()
void MovePoint(const double *, const double *)
virtual void SetHandleProperty(vtkProperty *)
Set/Get the handle properties (the 2D glyphs are the handles).
virtual void SetEnabled(int)
Methods that satisfy the superclass' API.
vtkProperty * SelectedHandleProperty
void SetHandlePosition(int handle, double xyz[3])
Set/Get the handle position in terms of a zero-based array of handles.
virtual void PlaceWidget(double bounds[6])
This method is used to initially place the widget.
int IsClosed()
Is the path closed or open?
void AllocateHandles(const int &)
void Trace(int, int)
void AdjustHandlePosition(const int &, double *)
vtkProperty * SelectedLineProperty
virtual void SizeHandles()
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:40
abstract base class for most VTK objects
Definition: vtkObject.h:60
represent and manipulate 3D points
Definition: vtkPoints.h:40
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:86
pick an actor/prop using graphics hardware
Definition: vtkPropPicker.h:43
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:48
represent surface properties of a geometric object
Definition: vtkProperty.h:65
transform points and associated normals and vectors for polygonal dataset
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:61
@ position
Definition: vtkX3D.h:261
#define VTK_ITW_SNAP_CELLS
#define VTK_ITW_SNAP_POINTS
#define VTK_ITW_PROJECTION_YZ
#define VTK_ITW_PROJECTION_XY
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
int vtkIdType
Definition: vtkType.h:287