00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00072 #ifndef __vtkImageTracerWidget_h
00073 #define __vtkImageTracerWidget_h
00074
00075 #include "vtk3DWidget.h"
00076
00077 class vtkAbstractPropPicker;
00078 class vtkActor;
00079 class vtkCellArray;
00080 class vtkCellPicker;
00081 class vtkFloatArray;
00082 class vtkGlyphSource2D;
00083 class vtkPoints;
00084 class vtkPolyData;
00085 class vtkPolyDataMapper;
00086 class vtkProp;
00087 class vtkProperty;
00088 class vtkPropPicker;
00089 class vtkTransform;
00090 class vtkTransformPolyDataFilter;
00091
00092 #define VTK_ITW_PROJECTION_YZ 0
00093 #define VTK_ITW_PROJECTION_XZ 1
00094 #define VTK_ITW_PROJECTION_XY 2
00095 #define VTK_ITW_SNAP_CELLS 0
00096 #define VTK_ITW_SNAP_POINTS 1
00097
00098 class VTK_HYBRID_EXPORT vtkImageTracerWidget : public vtk3DWidget
00099 {
00100 public:
00102 static vtkImageTracerWidget *New();
00103
00104 vtkTypeRevisionMacro(vtkImageTracerWidget,vtk3DWidget);
00105 void PrintSelf(ostream& os, vtkIndent indent);
00106
00108
00109 virtual void SetEnabled(int);
00110 virtual void PlaceWidget(double bounds[6]);
00111 void PlaceWidget()
00112 {this->Superclass::PlaceWidget();}
00113 void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
00114 double zmin, double zmax)
00115 {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
00117
00119
00122 virtual void SetHandleProperty(vtkProperty*);
00123 vtkGetObjectMacro(HandleProperty, vtkProperty);
00124 virtual void SetSelectedHandleProperty(vtkProperty*);
00125 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
00127
00129
00131 virtual void SetLineProperty(vtkProperty*);
00132 vtkGetObjectMacro(LineProperty, vtkProperty);
00133 virtual void SetSelectedLineProperty(vtkProperty*);
00134 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
00136
00138 void SetProp(vtkProp* prop);
00139
00141
00142 vtkSetMacro(ProjectToPlane,int);
00143 vtkGetMacro(ProjectToPlane,int);
00144 vtkBooleanMacro(ProjectToPlane,int);
00146
00148
00152 vtkSetClampMacro(ProjectionNormal,int,VTK_ITW_PROJECTION_YZ,VTK_ITW_PROJECTION_XY);
00153 vtkGetMacro(ProjectionNormal,int);
00154 void SetProjectionNormalToXAxes()
00155 { this->SetProjectionNormal(0); }
00156 void SetProjectionNormalToYAxes()
00157 { this->SetProjectionNormal(1); }
00158 void SetProjectionNormalToZAxes()
00159 { this->SetProjectionNormal(2); }
00161
00163
00168 void SetProjectionPosition(double position);
00169 vtkGetMacro(ProjectionPosition,double);
00171
00173
00174 void SetSnapToImage(int snap);
00175 vtkGetMacro(SnapToImage,int);
00176 vtkBooleanMacro(SnapToImage,int);
00178
00180
00182 vtkSetMacro(AutoClose,int);
00183 vtkGetMacro(AutoClose,int);
00184 vtkBooleanMacro(AutoClose,int);
00186
00188
00191 vtkSetMacro(CaptureRadius,double);
00192 vtkGetMacro(CaptureRadius,double);
00194
00200 void GetPath(vtkPolyData *pd);
00201
00203 vtkGlyphSource2D* GetGlyphSource() { return this->HandleGenerator; }
00204
00206
00208 vtkSetClampMacro(ImageSnapType,int,VTK_ITW_SNAP_CELLS,VTK_ITW_SNAP_POINTS);
00209 vtkGetMacro(ImageSnapType,int);
00211
00213
00215 void SetHandlePosition(int handle, double xyz[3]);
00216 void SetHandlePosition(int handle, double x, double y, double z);
00217 void GetHandlePosition(int handle, double xyz[3]);
00218 double* GetHandlePosition(int handle);
00220
00222
00223 vtkGetMacro(NumberOfHandles,int);
00225
00227
00228 void SetInteraction(int interact);
00229 vtkGetMacro(Interaction,int);
00230 vtkBooleanMacro(Interaction,int);
00232
00236 void InitializeHandles(vtkPoints*);
00237
00239
00240 vtkGetMacro(IsClosed,int);
00242
00243 protected:
00244 vtkImageTracerWidget();
00245 ~vtkImageTracerWidget();
00246
00247
00248 int State;
00249 enum WidgetState
00250 {
00251 Start=0,
00252 Tracing,
00253 Snapping,
00254 Erasing,
00255 Inserting,
00256 Moving,
00257 Outside
00258 };
00259
00260
00261
00262 static void ProcessEvents(vtkObject* object,
00263 unsigned long event,
00264 void* clientdata,
00265 void* calldata);
00266
00267
00268 void OnLeftButtonDown();
00269 void OnLeftButtonUp();
00270 void OnMiddleButtonDown();
00271 void OnMiddleButtonUp();
00272 void OnRightButtonDown();
00273 void OnRightButtonUp();
00274 void OnMouseMove();
00275
00276 void AddObservers();
00277
00278
00279 int Interaction;
00280 int ProjectionNormal;
00281 double ProjectionPosition;
00282 int ProjectToPlane;
00283 int ImageSnapType;
00284 int SnapToImage;
00285 double CaptureRadius;
00286 int AutoClose;
00287
00288 int IsSnapping;
00289 int MouseMoved;
00290 void Trace(int X, int Y);
00291 void Snap(double*);
00292 void MovePoint(double *p1, double *p2);
00293 void ClosePath();
00294 int IsClosed;
00295
00296
00297 vtkActor **Handle;
00298 vtkPolyDataMapper **HandleMapper;
00299 vtkPolyData **HandleGeometry;
00300 vtkGlyphSource2D *HandleGenerator;
00301
00302
00303 vtkTransformPolyDataFilter *TransformFilter;
00304 vtkTransform *Transform;
00305 vtkFloatArray *TemporaryHandlePoints;
00306
00307 void AppendHandles(double*);
00308 void ResetHandles();
00309 void AllocateHandles(int nhandles);
00310 void AdjustHandlePosition(int, double*);
00311 int HighlightHandle(vtkProp *prop);
00312 void EraseHandle(int);
00313 virtual void SizeHandles();
00314 void InsertHandleOnLine(double*);
00315
00316 int NumberOfHandles;
00317 vtkActor *CurrentHandle;
00318 int CurrentHandleIndex;
00319
00320 vtkProp *Prop;
00321 vtkPropPicker *PropPicker;
00322
00323
00324 vtkPoints *LinePoints;
00325 vtkCellArray *LineCells;
00326 vtkActor *LineActor;
00327 vtkPolyDataMapper *LineMapper;
00328 vtkPolyData *LineData;
00329 vtkIdType CurrentPoints[2];
00330
00331 void HighlightLine(int);
00332 void BuildLinesFromHandles();
00333 void ResetLine(double*);
00334 void AppendLine(double*);
00335 int PickCount;
00336
00337
00338 vtkCellPicker *HandlePicker;
00339 vtkCellPicker *LinePicker;
00340 vtkAbstractPropPicker* CurrentPicker;
00341
00342
00343
00344 vtkProperty *HandleProperty;
00345 vtkProperty *SelectedHandleProperty;
00346 vtkProperty *LineProperty;
00347 vtkProperty *SelectedLineProperty;
00348 void CreateDefaultProperties();
00349
00350 private:
00351 vtkImageTracerWidget(const vtkImageTracerWidget&);
00352 void operator=(const vtkImageTracerWidget&);
00353 };
00354
00355 #endif