Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

dox/Hybrid/vtkImageTracerWidget.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkImageTracerWidget.h,v $ 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00065 #ifndef __vtkImageTracerWidget_h 00066 #define __vtkImageTracerWidget_h 00067 00068 #include "vtk3DWidget.h" 00069 00070 class vtkAbstractPropPicker; 00071 class vtkActor; 00072 class vtkCellArray; 00073 class vtkCellPicker; 00074 class vtkFloatArray; 00075 class vtkGlyphSource2D; 00076 class vtkPoints; 00077 class vtkPolyData; 00078 class vtkPolyDataMapper; 00079 class vtkProp; 00080 class vtkProperty; 00081 class vtkPropPicker; 00082 class vtkTransform; 00083 class vtkTransformPolyDataFilter; 00084 00085 #define VTK_ITW_PROJECTION_YZ 0 00086 #define VTK_ITW_PROJECTION_XZ 1 00087 #define VTK_ITW_PROJECTION_XY 2 00088 #define VTK_ITW_SNAP_CELLS 0 00089 #define VTK_ITW_SNAP_POINTS 1 00090 00091 class VTK_HYBRID_EXPORT vtkImageTracerWidget : public vtk3DWidget 00092 { 00093 public: 00095 static vtkImageTracerWidget *New(); 00096 00097 vtkTypeRevisionMacro(vtkImageTracerWidget,vtk3DWidget); 00098 void PrintSelf(ostream& os, vtkIndent indent); 00099 00101 00102 virtual void SetEnabled(int); 00103 virtual void PlaceWidget(double bounds[6]); 00104 void PlaceWidget() 00105 {this->Superclass::PlaceWidget();} 00106 void PlaceWidget(double xmin, double xmax, double ymin, double ymax, 00107 double zmin, double zmax) 00108 {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);} 00110 00112 00115 virtual void SetHandleProperty(vtkProperty*); 00116 vtkGetObjectMacro(HandleProperty, vtkProperty); 00117 virtual void SetSelectedHandleProperty(vtkProperty*); 00118 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty); 00120 00122 00124 virtual void SetLineProperty(vtkProperty*); 00125 vtkGetObjectMacro(LineProperty, vtkProperty); 00126 virtual void SetSelectedLineProperty(vtkProperty*); 00127 vtkGetObjectMacro(SelectedLineProperty, vtkProperty); 00129 00131 void SetProp(vtkProp* prop); 00132 00134 00135 vtkSetMacro(ProjectToPlane,int); 00136 vtkGetMacro(ProjectToPlane,int); 00137 vtkBooleanMacro(ProjectToPlane,int); 00139 00141 00145 vtkSetClampMacro(ProjectionNormal,int,VTK_ITW_PROJECTION_YZ,VTK_ITW_PROJECTION_XY); 00146 vtkGetMacro(ProjectionNormal,int); 00147 void SetProjectionNormalToXAxes() 00148 { this->SetProjectionNormal(0); } 00149 void SetProjectionNormalToYAxes() 00150 { this->SetProjectionNormal(1); } 00151 void SetProjectionNormalToZAxes() 00152 { this->SetProjectionNormal(2); } 00154 00156 00161 vtkSetMacro(ProjectionPosition,double); 00162 vtkGetMacro(ProjectionPosition,double); 00164 00166 00167 void SetSnapToImage(int snap); 00168 vtkGetMacro(SnapToImage,int); 00169 vtkBooleanMacro(SnapToImage,int); 00171 00173 00175 vtkSetMacro(AutoClose,int); 00176 vtkGetMacro(AutoClose,int); 00177 vtkBooleanMacro(AutoClose,int); 00179 00181 00182 vtkSetMacro(GlyphAngle,double); 00183 vtkGetMacro(GlyphAngle,double); 00185 00187 00190 vtkSetMacro(CaptureRadius,double); 00191 vtkGetMacro(CaptureRadius,double); 00193 00199 void GetPath(vtkPolyData *pd); 00200 00202 vtkGlyphSource2D* GetGlyphSource() { return this->HandleGeometryGenerator; } 00203 00205 00207 vtkSetClampMacro(ImageSnapType,int,VTK_ITW_SNAP_CELLS,VTK_ITW_SNAP_POINTS); 00208 vtkGetMacro(ImageSnapType,int); 00210 00212 00214 void SetHandlePosition(int handle, double xyz[3]); 00215 void SetHandlePosition(int handle, double x, double y, double z); 00216 void GetHandlePosition(int handle, double xyz[3]); 00217 double* GetHandlePosition(int handle); 00219 00221 00222 vtkGetMacro(NumberOfHandles,int); 00224 00226 00227 void SetInteraction(int interact); 00228 vtkGetMacro(Interaction,int); 00229 vtkBooleanMacro(Interaction,int); 00231 00235 void InitializeHandles(vtkPoints*); 00236 00238 00239 vtkGetMacro(IsClosed,int); 00241 00242 protected: 00243 vtkImageTracerWidget(); 00244 ~vtkImageTracerWidget(); 00245 00246 //BTX - manage the state of the widget 00247 int State; 00248 enum WidgetState 00249 { 00250 Start=0, 00251 Tracing, 00252 Snapping, 00253 Erasing, 00254 Inserting, 00255 Moving, 00256 Outside 00257 }; 00258 //ETX 00259 00260 //handles the events 00261 static void ProcessEvents(vtkObject* object, 00262 unsigned long event, 00263 void* clientdata, 00264 void* calldata); 00265 00266 // ProcessEvents() dispatches to these methods. 00267 void OnLeftButtonDown(); 00268 void OnLeftButtonUp(); 00269 void OnMiddleButtonDown(); 00270 void OnMiddleButtonUp(); 00271 void OnRightButtonDown(); 00272 void OnRightButtonUp(); 00273 void OnMouseMove(); 00274 00275 void AddObservers(); 00276 00277 // Controlling vars 00278 int Interaction; 00279 int ProjectionNormal; 00280 double ProjectionPosition; 00281 int ProjectToPlane; 00282 int ImageSnapType; 00283 int SnapToImage; 00284 double CaptureRadius; // tolerance for auto path close 00285 double GlyphAngle; // pre-rotation of a glyph 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 // 2D glyphs representing hot spots (e.g., handles) 00297 vtkActor **Handle; 00298 vtkPolyDataMapper **HandleMapper; 00299 vtkPolyData **HandleGeometry; 00300 vtkGlyphSource2D *HandleGeometryGenerator; 00301 00302 // Transforms required as 2D glyphs are generated in the x-y plane 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); // returns handle index or -1 on fail 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; // the prop we want to pick on 00321 vtkPropPicker *PropPicker; // the prop's picker 00322 00323 // Representation of the line 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 // Do the picking of the handles and the lines 00338 vtkCellPicker *HandlePicker; 00339 vtkCellPicker *LinePicker; 00340 vtkAbstractPropPicker* CurrentPicker; 00341 00342 // Properties used to control the appearance of selected objects and 00343 // the manipulator in general. 00344 vtkProperty *HandleProperty; 00345 vtkProperty *SelectedHandleProperty; 00346 vtkProperty *LineProperty; 00347 vtkProperty *SelectedLineProperty; 00348 void CreateDefaultProperties(); 00349 00350 private: 00351 vtkImageTracerWidget(const vtkImageTracerWidget&); //Not implemented 00352 void operator=(const vtkImageTracerWidget&); //Not implemented 00353 }; 00354 00355 #endif