00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00098 #ifndef __vtkSplineWidget_h
00099 #define __vtkSplineWidget_h
00100
00101 #include "vtk3DWidget.h"
00102
00103 class vtkActor;
00104 class vtkCellPicker;
00105 class vtkPlaneSource;
00106 class vtkPoints;
00107 class vtkPolyData;
00108 class vtkPolyDataMapper;
00109 class vtkProp;
00110 class vtkProperty;
00111 class vtkSphereSource;
00112 class vtkSpline;
00113 class vtkTransform;
00114
00115 #define VTK_PROJECTION_YZ 0
00116 #define VTK_PROJECTION_XZ 1
00117 #define VTK_PROJECTION_XY 2
00118 #define VTK_PROJECTION_OBLIQUE 3
00119
00120 class VTK_HYBRID_EXPORT vtkSplineWidget : public vtk3DWidget
00121 {
00122 public:
00124 static vtkSplineWidget *New();
00125
00126 vtkTypeRevisionMacro(vtkSplineWidget,vtk3DWidget);
00127 void PrintSelf(ostream& os, vtkIndent indent);
00128
00130
00131 virtual void SetEnabled(int);
00132 virtual void PlaceWidget(double bounds[6]);
00133 void PlaceWidget()
00134 {this->Superclass::PlaceWidget();}
00135 void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
00136 double zmin, double zmax)
00137 {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
00139
00141
00147 vtkSetMacro(ProjectToPlane,int);
00148 vtkGetMacro(ProjectToPlane,int);
00149 vtkBooleanMacro(ProjectToPlane,int);
00151
00154 void SetPlaneSource(vtkPlaneSource* plane);
00155
00156 vtkSetClampMacro(ProjectionNormal,int,VTK_PROJECTION_YZ,VTK_PROJECTION_OBLIQUE);
00157 vtkGetMacro(ProjectionNormal,int);
00158 void SetProjectionNormalToXAxes()
00159 { this->SetProjectionNormal(0); }
00160 void SetProjectionNormalToYAxes()
00161 { this->SetProjectionNormal(1); }
00162 void SetProjectionNormalToZAxes()
00163 { this->SetProjectionNormal(2); }
00164 void SetProjectionNormalToOblique()
00165 { this->SetProjectionNormal(3); }
00166
00168
00173 void SetProjectionPosition(double position);
00174 vtkGetMacro(ProjectionPosition, double);
00176
00182 void GetPolyData(vtkPolyData *pd);
00183
00185
00188 virtual void SetHandleProperty(vtkProperty*);
00189 vtkGetObjectMacro(HandleProperty, vtkProperty);
00190 virtual void SetSelectedHandleProperty(vtkProperty*);
00191 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
00193
00195
00197 virtual void SetLineProperty(vtkProperty*);
00198 vtkGetObjectMacro(LineProperty, vtkProperty);
00199 virtual void SetSelectedLineProperty(vtkProperty*);
00200 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
00202
00204
00205 virtual void SetNumberOfHandles(int npts);
00206 vtkGetMacro(NumberOfHandles, int);
00208
00210
00212 void SetResolution(int resolution);
00213 vtkGetMacro(Resolution,int);
00215
00217
00221 void SetXSpline(vtkSpline*);
00222 void SetYSpline(vtkSpline*);
00223 void SetZSpline(vtkSpline*);
00225
00227
00229 void SetHandlePosition(int handle, double x, double y, double z);
00230 void SetHandlePosition(int handle, double xyz[3]);
00231 void GetHandlePosition(int handle, double xyz[3]);
00232 double* GetHandlePosition(int handle);
00234
00236
00240 void SetClosed(int closed);
00241 vtkGetMacro(Closed,int);
00242 vtkBooleanMacro(Closed,int);
00244
00248 double GetSummedLength();
00249
00250 protected:
00251 vtkSplineWidget();
00252 ~vtkSplineWidget();
00253
00254
00255 int State;
00256 enum WidgetState
00257 {
00258 Start=0,
00259 Moving,
00260 Scaling,
00261 Spinning,
00262 Outside
00263 };
00264
00265
00266
00267 static void ProcessEvents(vtkObject* object,
00268 unsigned long event,
00269 void* clientdata,
00270 void* calldata);
00271
00272
00273 void OnLeftButtonDown();
00274 void OnLeftButtonUp();
00275 void OnMiddleButtonDown();
00276 void OnMiddleButtonUp();
00277 void OnRightButtonDown();
00278 void OnRightButtonUp();
00279 void OnMouseMove();
00280
00281
00282 int ProjectionNormal;
00283 double ProjectionPosition;
00284 int ProjectToPlane;
00285 vtkPlaneSource* PlaneSource;
00286
00287
00288 void ProjectPointsToPlane();
00289 void ProjectPointsToOrthoPlane();
00290 void ProjectPointsToObliquePlane();
00291
00292
00293 vtkSpline *XSpline;
00294 vtkSpline *YSpline;
00295 vtkSpline *ZSpline;
00296 int NumberOfHandles;
00297 vtkSpline* CreateDefaultSpline();
00298 int Closed;
00299 double Offset;
00300
00301
00302 vtkActor *LineActor;
00303 vtkPolyDataMapper *LineMapper;
00304 vtkPolyData *LineData;
00305 void HighlightLine(int highlight);
00306 int NumberOfSplinePoints;
00307 int Resolution;
00308 double* SplinePositions;
00309
00310
00311 vtkActor **Handle;
00312 vtkPolyDataMapper **HandleMapper;
00313 vtkSphereSource **HandleGeometry;
00314 void Initialize();
00315 int HighlightHandle(vtkProp *prop);
00316 virtual void SizeHandles();
00317 void BuildRepresentation();
00318
00319
00320 vtkCellPicker *HandlePicker;
00321 vtkCellPicker *LinePicker;
00322 vtkActor *CurrentHandle;
00323 int CurrentHandleIndex;
00324
00325
00326 void MovePoint(double *p1, double *p2);
00327 void Scale(double *p1, double *p2, int X, int Y);
00328 void Translate(double *p1, double *p2);
00329 void Spin(double *p1, double *p2, double *vpn);
00330
00331
00332 vtkTransform *Transform;
00333
00334
00335
00336 vtkProperty *HandleProperty;
00337 vtkProperty *SelectedHandleProperty;
00338 vtkProperty *LineProperty;
00339 vtkProperty *SelectedLineProperty;
00340 void CreateDefaultProperties();
00341
00342
00343 double Centroid[3];
00344 void CalculateCentroid();
00345
00346 private:
00347 vtkSplineWidget(const vtkSplineWidget&);
00348 void operator=(const vtkSplineWidget&);
00349 };
00350
00351 #endif