00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00062 #ifndef __vtkImageTracerWidget_h
00063 #define __vtkImageTracerWidget_h
00064
00065 #include "vtk3DWidget.h"
00066
00067 class vtkAbstractPropPicker;
00068 class vtkActor;
00069 class vtkCellArray;
00070 class vtkCellPicker;
00071 class vtkFloatArray;
00072 class vtkGlyphSource2D;
00073 class vtkPoints;
00074 class vtkPolyData;
00075 class vtkProp;
00076 class vtkProperty;
00077 class vtkPropPicker;
00078 class vtkTransform;
00079 class vtkTransformPolyDataFilter;
00080
00081 #define VTK_ITW_PROJECTION_YZ 0
00082 #define VTK_ITW_PROJECTION_XZ 1
00083 #define VTK_ITW_PROJECTION_XY 2
00084 #define VTK_ITW_SNAP_CELLS 0
00085 #define VTK_ITW_SNAP_POINTS 1
00086
00087 class VTK_WIDGETS_EXPORT vtkImageTracerWidget : public vtk3DWidget
00088 {
00089 public:
00091 static vtkImageTracerWidget *New();
00092
00093 vtkTypeRevisionMacro(vtkImageTracerWidget,vtk3DWidget);
00094 void PrintSelf(ostream& os, vtkIndent indent);
00095
00097
00098 virtual void SetEnabled(int);
00099 virtual void PlaceWidget(double bounds[6]);
00100 void PlaceWidget()
00101 {this->Superclass::PlaceWidget();}
00102 void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
00103 double zmin, double zmax)
00104 {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
00106
00108
00111 virtual void SetHandleProperty(vtkProperty*);
00112 vtkGetObjectMacro(HandleProperty, vtkProperty);
00113 virtual void SetSelectedHandleProperty(vtkProperty*);
00114 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
00116
00118
00120 virtual void SetLineProperty(vtkProperty*);
00121 vtkGetObjectMacro(LineProperty, vtkProperty);
00122 virtual void SetSelectedLineProperty(vtkProperty*);
00123 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
00125
00127 void SetViewProp(vtkProp* prop);
00128
00130
00131 vtkSetMacro(ProjectToPlane,int);
00132 vtkGetMacro(ProjectToPlane,int);
00133 vtkBooleanMacro(ProjectToPlane,int);
00135
00137
00141 vtkSetClampMacro(ProjectionNormal,int,VTK_ITW_PROJECTION_YZ,VTK_ITW_PROJECTION_XY);
00142 vtkGetMacro(ProjectionNormal,int);
00143 void SetProjectionNormalToXAxes()
00144 { this->SetProjectionNormal(0); }
00145 void SetProjectionNormalToYAxes()
00146 { this->SetProjectionNormal(1); }
00147 void SetProjectionNormalToZAxes()
00148 { this->SetProjectionNormal(2); }
00150
00152
00157 void SetProjectionPosition(double position);
00158 vtkGetMacro(ProjectionPosition,double);
00160
00162
00163 void SetSnapToImage(int snap);
00164 vtkGetMacro(SnapToImage,int);
00165 vtkBooleanMacro(SnapToImage,int);
00167
00169
00171 vtkSetMacro(AutoClose,int);
00172 vtkGetMacro(AutoClose,int);
00173 vtkBooleanMacro(AutoClose,int);
00175
00177
00180 vtkSetMacro(CaptureRadius,double);
00181 vtkGetMacro(CaptureRadius,double);
00183
00189 void GetPath(vtkPolyData *pd);
00190
00192 vtkGlyphSource2D* GetGlyphSource() { return this->HandleGenerator; }
00193
00195
00197 vtkSetClampMacro(ImageSnapType,int,VTK_ITW_SNAP_CELLS,VTK_ITW_SNAP_POINTS);
00198 vtkGetMacro(ImageSnapType,int);
00200
00202
00204 void SetHandlePosition(int handle, double xyz[3]);
00205 void SetHandlePosition(int handle, double x, double y, double z);
00206 void GetHandlePosition(int handle, double xyz[3]);
00207 double* GetHandlePosition(int handle);
00209
00211
00212 vtkGetMacro(NumberOfHandles,int);
00214
00216
00217 void SetInteraction(int interact);
00218 vtkGetMacro(Interaction,int);
00219 vtkBooleanMacro(Interaction,int);
00221
00225 void InitializeHandles(vtkPoints*);
00226
00228 int IsClosed();
00229
00230 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE
00231 # define SetPropA SetProp
00232 # define SetPropW SetProp
00233 #endif
00234
00237 VTK_LEGACY(void SetProp(vtkProp* prop));
00238
00239 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE
00240 # undef SetPropA
00241 # undef SetPropW
00242
00243 VTK_LEGACY(void SetPropA(vtkProp*));
00244 VTK_LEGACY(void SetPropW(vtkProp*));
00245
00246 #endif
00247
00248 protected:
00249 vtkImageTracerWidget();
00250 ~vtkImageTracerWidget();
00251
00252
00253 int State;
00254 enum WidgetState
00255 {
00256 Start=0,
00257 Tracing,
00258 Snapping,
00259 Erasing,
00260 Inserting,
00261 Moving,
00262 Translating,
00263 Outside
00264 };
00265
00266
00267
00268 static void ProcessEvents(vtkObject* object,
00269 unsigned long event,
00270 void* clientdata,
00271 void* calldata);
00272
00273
00274 void OnLeftButtonDown();
00275 void OnLeftButtonUp();
00276 void OnMiddleButtonDown();
00277 void OnMiddleButtonUp();
00278 void OnRightButtonDown();
00279 void OnRightButtonUp();
00280 void OnMouseMove();
00281
00282 void AddObservers();
00283
00284
00285 int Interaction;
00286 int ProjectionNormal;
00287 double ProjectionPosition;
00288 int ProjectToPlane;
00289 int ImageSnapType;
00290 int SnapToImage;
00291 double CaptureRadius;
00292 int AutoClose;
00293 int IsSnapping;
00294 int LastX;
00295 int LastY;
00296
00297 void Trace(int , int );
00298 void Snap(double* );
00299 void MovePoint(const double* , const double* );
00300 void Translate(const double* , const double* );
00301 void ClosePath();
00302
00303
00304 vtkActor **Handle;
00305 vtkPolyData **HandleGeometry;
00306 vtkGlyphSource2D *HandleGenerator;
00307
00308
00309 vtkTransformPolyDataFilter *TransformFilter;
00310 vtkTransform *Transform;
00311 vtkFloatArray *TemporaryHandlePoints;
00312
00313 void AppendHandles(double*);
00314 void ResetHandles();
00315 void AllocateHandles(const int& );
00316 void AdjustHandlePosition(const int& , double*);
00317 int HighlightHandle(vtkProp* );
00318 void EraseHandle(const int& );
00319 virtual void SizeHandles();
00320 void InsertHandleOnLine(double* );
00321
00322 int NumberOfHandles;
00323 vtkActor *CurrentHandle;
00324 int CurrentHandleIndex;
00325
00326 vtkProp *ViewProp;
00327 vtkPropPicker *PropPicker;
00328
00329
00330 vtkPoints *LinePoints;
00331 vtkCellArray *LineCells;
00332 vtkActor *LineActor;
00333 vtkPolyData *LineData;
00334 vtkIdType CurrentPoints[2];
00335
00336 void HighlightLine(const int& );
00337 void BuildLinesFromHandles();
00338 void ResetLine(double* );
00339 void AppendLine(double* );
00340 int PickCount;
00341
00342
00343 vtkCellPicker *HandlePicker;
00344 vtkCellPicker *LinePicker;
00345 vtkAbstractPropPicker* CurrentPicker;
00346
00347
00348
00349 vtkProperty *HandleProperty;
00350 vtkProperty *SelectedHandleProperty;
00351 vtkProperty *LineProperty;
00352 vtkProperty *SelectedLineProperty;
00353 void CreateDefaultProperties();
00354
00355 private:
00356 vtkImageTracerWidget(const vtkImageTracerWidget&);
00357 void operator=(const vtkImageTracerWidget&);
00358 };
00359
00360 #endif