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