00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00073 #ifndef __vtkSphereWidget_h
00074 #define __vtkSphereWidget_h
00075
00076 #include "vtk3DWidget.h"
00077 #include "vtkSphereSource.h"
00078
00079 class vtkActor;
00080 class vtkPolyDataMapper;
00081 class vtkPoints;
00082 class vtkPolyData;
00083 class vtkSphereSource;
00084 class vtkSphere;
00085 class vtkCellPicker;
00086 class vtkProperty;
00087
00088 #define VTK_SPHERE_OFF 0
00089 #define VTK_SPHERE_WIREFRAME 1
00090 #define VTK_SPHERE_SURFACE 2
00091
00092 class VTK_HYBRID_EXPORT vtkSphereWidget : public vtk3DWidget
00093 {
00094 public:
00096 static vtkSphereWidget *New();
00097
00098 vtkTypeRevisionMacro(vtkSphereWidget,vtk3DWidget);
00099 void PrintSelf(ostream& os, vtkIndent indent);
00100
00102
00103 virtual void SetEnabled(int);
00104 virtual void PlaceWidget(double bounds[6]);
00105 void PlaceWidget()
00106 {this->Superclass::PlaceWidget();}
00107 void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
00108 double zmin, double zmax)
00109 {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
00111
00113
00115 vtkSetClampMacro(Representation,int,VTK_SPHERE_OFF,VTK_SPHERE_SURFACE);
00116 vtkGetMacro(Representation,int);
00117 void SetRepresentationToOff()
00118 { this->SetRepresentation(VTK_SPHERE_OFF);}
00119 void SetRepresentationToWireframe()
00120 { this->SetRepresentation(VTK_SPHERE_WIREFRAME);}
00121 void SetRepresentationToSurface()
00122 { this->SetRepresentation(VTK_SPHERE_SURFACE);}
00124
00126
00127 void SetThetaResolution(int r)
00128 { this->SphereSource->SetThetaResolution(r); }
00129 int GetThetaResolution()
00130 { return this->SphereSource->GetThetaResolution(); }
00132
00134
00135 void SetPhiResolution(int r)
00136 { this->SphereSource->SetPhiResolution(r); }
00137 int GetPhiResolution()
00138 { return this->SphereSource->GetPhiResolution(); }
00140
00142
00143 void SetRadius(double r)
00144 {
00145 if ( r <= 0 )
00146 {
00147 r = .00001;
00148 }
00149 this->SphereSource->SetRadius(r);
00150 }
00151 double GetRadius()
00152 { return this->SphereSource->GetRadius(); }
00154
00156
00157 void SetCenter(double x, double y, double z)
00158 {
00159 this->SphereSource->SetCenter(x,y,z);
00160 }
00161 void SetCenter(double x[3])
00162 {
00163 this->SetCenter(x[0], x[1], x[2]);
00164 }
00165 double* GetCenter()
00166 {return this->SphereSource->GetCenter();}
00167 void GetCenter(double xyz[3])
00168 {this->SphereSource->GetCenter(xyz);}
00170
00172
00174 vtkSetMacro(Translation,int);
00175 vtkGetMacro(Translation,int);
00176 vtkBooleanMacro(Translation,int);
00177 vtkSetMacro(Scale,int);
00178 vtkGetMacro(Scale,int);
00179 vtkBooleanMacro(Scale,int);
00181
00183
00187 vtkSetMacro(HandleVisibility,int);
00188 vtkGetMacro(HandleVisibility,int);
00189 vtkBooleanMacro(HandleVisibility,int);
00191
00193
00195 vtkSetVector3Macro(HandleDirection,double);
00196 vtkGetVector3Macro(HandleDirection,double);
00198
00200
00201 vtkGetVector3Macro(HandlePosition,double);
00203
00210 void GetPolyData(vtkPolyData *pd);
00211
00216 void GetSphere(vtkSphere *sphere);
00217
00219
00221 vtkGetObjectMacro(SphereProperty,vtkProperty);
00222 vtkGetObjectMacro(SelectedSphereProperty,vtkProperty);
00224
00226
00229 vtkGetObjectMacro(HandleProperty,vtkProperty);
00230 vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
00232
00233 protected:
00234 vtkSphereWidget();
00235 ~vtkSphereWidget();
00236
00237
00238 int State;
00239 enum WidgetState
00240 {
00241 Start=0,
00242 Moving,
00243 Scaling,
00244 Positioning,
00245 Outside
00246 };
00247
00248
00249
00250 static void ProcessEvents(vtkObject* object,
00251 unsigned long event,
00252 void* clientdata,
00253 void* calldata);
00254
00255
00256 void OnLeftButtonDown();
00257 void OnLeftButtonUp();
00258 void OnRightButtonDown();
00259 void OnRightButtonUp();
00260 void OnMouseMove();
00261
00262
00263 vtkActor *SphereActor;
00264 vtkPolyDataMapper *SphereMapper;
00265 vtkSphereSource *SphereSource;
00266 void HighlightSphere(int highlight);
00267 void SelectRepresentation();
00268
00269
00270 int Representation;
00271
00272
00273 vtkCellPicker *Picker;
00274
00275
00276 int Translation;
00277 int Scale;
00278 void Translate(double *p1, double *p2);
00279 void ScaleSphere(double *p1, double *p2, int X, int Y);
00280 void MoveHandle(double *p1, double *p2, int X, int Y);
00281 void PlaceHandle(double *center, double radius);
00282
00283
00284
00285 vtkProperty *SphereProperty;
00286 vtkProperty *SelectedSphereProperty;
00287 vtkProperty *HandleProperty;
00288 vtkProperty *SelectedHandleProperty;
00289 void CreateDefaultProperties();
00290
00291
00292 vtkActor *HandleActor;
00293 vtkPolyDataMapper *HandleMapper;
00294 vtkSphereSource *HandleSource;
00295 void HighlightHandle(int);
00296 int HandleVisibility;
00297 double HandleDirection[3];
00298 double HandlePosition[3];
00299 virtual void SizeHandles();
00300
00301 private:
00302 vtkSphereWidget(const vtkSphereWidget&);
00303 void operator=(const vtkSphereWidget&);
00304 };
00305
00306 #endif