00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00093 #ifndef __vtkSplineWidget_h
00094 #define __vtkSplineWidget_h
00095
00096 #include "vtk3DWidget.h"
00097
00098 class vtkActor;
00099 class vtkCellPicker;
00100 class vtkParametricSpline;
00101 class vtkParametricFunctionSource;
00102 class vtkPlaneSource;
00103 class vtkPoints;
00104 class vtkPolyData;
00105 class vtkProp;
00106 class vtkProperty;
00107 class vtkSphereSource;
00108 class vtkTransform;
00109
00110 #define VTK_PROJECTION_YZ 0
00111 #define VTK_PROJECTION_XZ 1
00112 #define VTK_PROJECTION_XY 2
00113 #define VTK_PROJECTION_OBLIQUE 3
00114
00115 class VTK_WIDGETS_EXPORT vtkSplineWidget : public vtk3DWidget
00116 {
00117 public:
00119 static vtkSplineWidget *New();
00120
00121 vtkTypeRevisionMacro(vtkSplineWidget,vtk3DWidget);
00122 void PrintSelf(ostream& os, vtkIndent indent);
00123
00125
00126 virtual void SetEnabled(int);
00127 virtual void PlaceWidget(double bounds[6]);
00128 void PlaceWidget()
00129 {this->Superclass::PlaceWidget();}
00130 void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
00131 double zmin, double zmax)
00132 {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
00134
00136
00142 vtkSetMacro(ProjectToPlane,int);
00143 vtkGetMacro(ProjectToPlane,int);
00144 vtkBooleanMacro(ProjectToPlane,int);
00146
00149 void SetPlaneSource(vtkPlaneSource* plane);
00150
00151 vtkSetClampMacro(ProjectionNormal,int,VTK_PROJECTION_YZ,VTK_PROJECTION_OBLIQUE);
00152 vtkGetMacro(ProjectionNormal,int);
00153 void SetProjectionNormalToXAxes()
00154 { this->SetProjectionNormal(0); }
00155 void SetProjectionNormalToYAxes()
00156 { this->SetProjectionNormal(1); }
00157 void SetProjectionNormalToZAxes()
00158 { this->SetProjectionNormal(2); }
00159 void SetProjectionNormalToOblique()
00160 { this->SetProjectionNormal(3); }
00161
00163
00168 void SetProjectionPosition(double position);
00169 vtkGetMacro(ProjectionPosition, double);
00171
00178 void GetPolyData(vtkPolyData *pd);
00179
00181
00184 virtual void SetHandleProperty(vtkProperty*);
00185 vtkGetObjectMacro(HandleProperty, vtkProperty);
00186 virtual void SetSelectedHandleProperty(vtkProperty*);
00187 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
00189
00191
00193 virtual void SetLineProperty(vtkProperty*);
00194 vtkGetObjectMacro(LineProperty, vtkProperty);
00195 virtual void SetSelectedLineProperty(vtkProperty*);
00196 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
00198
00200
00201 virtual void SetNumberOfHandles(int npts);
00202 vtkGetMacro(NumberOfHandles, int);
00204
00206
00208 void SetResolution(int resolution);
00209 vtkGetMacro(Resolution,int);
00211
00213
00219 virtual void SetParametricSpline(vtkParametricSpline*);
00220 vtkGetObjectMacro(ParametricSpline,vtkParametricSpline);
00222
00224
00226 void SetHandlePosition(int handle, double x, double y, double z);
00227 void SetHandlePosition(int handle, double xyz[3]);
00228 void GetHandlePosition(int handle, double xyz[3]);
00229 double* GetHandlePosition(int handle);
00231
00233
00238 void SetClosed(int closed);
00239 vtkGetMacro(Closed,int);
00240 vtkBooleanMacro(Closed,int);
00242
00246 int IsClosed();
00247
00251 double GetSummedLength();
00252
00257 void InitializeHandles(vtkPoints* points);
00258
00259 protected:
00260 vtkSplineWidget();
00261 ~vtkSplineWidget();
00262
00263
00264 int State;
00265 enum WidgetState
00266 {
00267 Start=0,
00268 Moving,
00269 Scaling,
00270 Spinning,
00271 Inserting,
00272 Erasing,
00273 Outside
00274 };
00275
00276
00277
00278 static void ProcessEvents(vtkObject* object,
00279 unsigned long event,
00280 void* clientdata,
00281 void* calldata);
00282
00283
00284 void OnLeftButtonDown();
00285 void OnLeftButtonUp();
00286 void OnMiddleButtonDown();
00287 void OnMiddleButtonUp();
00288 void OnRightButtonDown();
00289 void OnRightButtonUp();
00290 void OnMouseMove();
00291
00292
00293 int ProjectionNormal;
00294 double ProjectionPosition;
00295 int ProjectToPlane;
00296 vtkPlaneSource* PlaneSource;
00297
00298
00299 void ProjectPointsToPlane();
00300 void ProjectPointsToOrthoPlane();
00301 void ProjectPointsToObliquePlane();
00302
00303
00304 vtkParametricSpline *ParametricSpline;
00305 vtkParametricFunctionSource *ParametricFunctionSource;
00306 int NumberOfHandles;
00307 int Closed;
00308 void BuildRepresentation();
00309
00310
00311 vtkActor *LineActor;
00312 void HighlightLine(int highlight);
00313 int Resolution;
00314
00315
00316 vtkActor **Handle;
00317 vtkSphereSource **HandleGeometry;
00318 void Initialize();
00319 int HighlightHandle(vtkProp *prop);
00320 virtual void SizeHandles();
00321 void InsertHandleOnLine(double* pos);
00322 void EraseHandle(const int&);
00323
00324
00325 vtkCellPicker *HandlePicker;
00326 vtkCellPicker *LinePicker;
00327 vtkActor *CurrentHandle;
00328 int CurrentHandleIndex;
00329
00330
00331 void MovePoint(double *p1, double *p2);
00332 void Scale(double *p1, double *p2, int X, int Y);
00333 void Translate(double *p1, double *p2);
00334 void Spin(double *p1, double *p2, double *vpn);
00335
00336
00337 vtkTransform *Transform;
00338
00339
00340
00341 vtkProperty *HandleProperty;
00342 vtkProperty *SelectedHandleProperty;
00343 vtkProperty *LineProperty;
00344 vtkProperty *SelectedLineProperty;
00345 void CreateDefaultProperties();
00346
00347
00348 double Centroid[3];
00349 void CalculateCentroid();
00350
00351 private:
00352 vtkSplineWidget(const vtkSplineWidget&);
00353 void operator=(const vtkSplineWidget&);
00354 };
00355
00356 #endif