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

dox/Hybrid/vtkSphereWidget.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkSphereWidget.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 =========================================================================*/ 00062 #ifndef __vtkSphereWidget_h 00063 #define __vtkSphereWidget_h 00064 00065 #include "vtk3DWidget.h" 00066 #include "vtkSphereSource.h" // Needed for faster access to the sphere source 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_HYBRID_EXPORT vtkSphereWidget : public vtk3DWidget 00082 { 00083 public: 00085 static vtkSphereWidget *New(); 00086 00087 vtkTypeRevisionMacro(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 00104 vtkSetClampMacro(Representation,int,VTK_SPHERE_OFF,VTK_SPHERE_SURFACE); 00105 vtkGetMacro(Representation,int); 00106 void SetRepresentationToOff() 00107 { this->SetRepresentation(VTK_SPHERE_OFF);} 00108 void SetRepresentationToWireframe() 00109 { this->SetRepresentation(VTK_SPHERE_WIREFRAME);} 00110 void SetRepresentationToSurface() 00111 { this->SetRepresentation(VTK_SPHERE_SURFACE);} 00113 00115 00116 void SetThetaResolution(int r) 00117 { this->SphereSource->SetThetaResolution(r); } 00118 int GetThetaResolution() 00119 { return this->SphereSource->GetThetaResolution(); } 00121 00123 00124 void SetPhiResolution(int r) 00125 { this->SphereSource->SetPhiResolution(r); } 00126 int GetPhiResolution() 00127 { return this->SphereSource->GetPhiResolution(); } 00129 00131 00132 void SetRadius(double r) 00133 { 00134 if ( r <= 0 ) 00135 { 00136 r = .00001; 00137 } 00138 this->SphereSource->SetRadius(r); 00139 } 00140 double GetRadius() 00141 { return this->SphereSource->GetRadius(); } 00143 00145 00146 void SetCenter(double x, double y, double z) 00147 { 00148 this->SphereSource->SetCenter(x,y,z); 00149 } 00150 void SetCenter(double x[3]) 00151 { 00152 this->SetCenter(x[0], x[1], x[2]); 00153 } 00154 double* GetCenter() 00155 {return this->SphereSource->GetCenter();} 00156 void GetCenter(double xyz[3]) 00157 {this->SphereSource->GetCenter(xyz);} 00159 00161 00163 vtkSetMacro(Translation,int); 00164 vtkGetMacro(Translation,int); 00165 vtkBooleanMacro(Translation,int); 00166 vtkSetMacro(Scale,int); 00167 vtkGetMacro(Scale,int); 00168 vtkBooleanMacro(Scale,int); 00170 00172 00176 vtkSetMacro(HandleVisibility,int); 00177 vtkGetMacro(HandleVisibility,int); 00178 vtkBooleanMacro(HandleVisibility,int); 00180 00182 00184 vtkSetVector3Macro(HandleDirection,double); 00185 vtkGetVector3Macro(HandleDirection,double); 00187 00189 00190 vtkGetVector3Macro(HandlePosition,double); 00192 00199 void GetPolyData(vtkPolyData *pd); 00200 00205 void GetSphere(vtkSphere *sphere); 00206 00208 00210 vtkGetObjectMacro(SphereProperty,vtkProperty); 00211 vtkGetObjectMacro(SelectedSphereProperty,vtkProperty); 00213 00215 00218 vtkGetObjectMacro(HandleProperty,vtkProperty); 00219 vtkGetObjectMacro(SelectedHandleProperty,vtkProperty); 00221 00222 protected: 00223 vtkSphereWidget(); 00224 ~vtkSphereWidget(); 00225 00226 //BTX - manage the state of the widget 00227 int State; 00228 enum WidgetState 00229 { 00230 Start=0, 00231 Moving, 00232 Scaling, 00233 Positioning, 00234 Outside 00235 }; 00236 //ETX 00237 00238 //handles the events 00239 static void ProcessEvents(vtkObject* object, 00240 unsigned long event, 00241 void* clientdata, 00242 void* calldata); 00243 00244 // ProcessEvents() dispatches to these methods. 00245 void OnLeftButtonDown(); 00246 void OnLeftButtonUp(); 00247 void OnRightButtonDown(); 00248 void OnRightButtonUp(); 00249 void OnMouseMove(); 00250 00251 // the sphere 00252 vtkActor *SphereActor; 00253 vtkPolyDataMapper *SphereMapper; 00254 vtkSphereSource *SphereSource; 00255 void HighlightSphere(int highlight); 00256 void SelectRepresentation(); 00257 00258 // The representation of the sphere 00259 int Representation; 00260 00261 // Do the picking 00262 vtkCellPicker *Picker; 00263 00264 // Methods to manipulate the sphere widget 00265 int Translation; 00266 int Scale; 00267 void Translate(double *p1, double *p2); 00268 void ScaleSphere(double *p1, double *p2, int X, int Y); 00269 void MoveHandle(double *p1, double *p2, int X, int Y); 00270 void PlaceHandle(double *center, double radius); 00271 00272 // Properties used to control the appearance of selected objects and 00273 // the manipulator in general. 00274 vtkProperty *SphereProperty; 00275 vtkProperty *SelectedSphereProperty; 00276 vtkProperty *HandleProperty; 00277 vtkProperty *SelectedHandleProperty; 00278 void CreateDefaultProperties(); 00279 00280 // Managing the handle 00281 vtkActor *HandleActor; 00282 vtkPolyDataMapper *HandleMapper; 00283 vtkSphereSource *HandleSource; 00284 void HighlightHandle(int); 00285 int HandleVisibility; 00286 double HandleDirection[3]; 00287 double HandlePosition[3]; 00288 virtual void SizeHandles(); 00289 00290 private: 00291 vtkSphereWidget(const vtkSphereWidget&); //Not implemented 00292 void operator=(const vtkSphereWidget&); //Not implemented 00293 }; 00294 00295 #endif