Files Classes Functions Hierarchy
00001 #ifndef POINTSDISPLAY_H 00002 #define POINTSDISPLAY_H 00003 00004 #include <cassert> 00005 #include <iostream> 00006 #include <sstream> 00007 #include <string> 00008 #include <vector> 00009 using namespace std; 00010 00011 #include <GL/glut.h> 00012 #include <GL/gl.h> 00013 00014 #include <typedefs.h> 00015 #include <gobj.h> 00016 #include <graphmisc.h> 00017 00033 template< typename T > 00034 class pointsdisplay3D : public gobj 00035 { 00036 public: 00037 00039 gobjQuadric * gq; 00040 00042 pointsdisplay3D 00043 ( 00044 gobjContainer & gX, 00045 vector< T > const & pt, 00046 boolc drawpoints=true, 00047 boolc numberthepoints=true, 00048 boolc countfrom1=true 00049 ); 00050 00052 pointsdisplay3D 00053 ( 00054 vector< T > const & pt, 00055 boolc drawpoints=true, 00056 boolc numberthepoints=true 00057 ) { *this=pointsdisplay3D(*gobj::global,pt,drawpoints,numberthepoints); }; 00058 00060 void draw() { GOBJDEBUGCODE } 00061 }; 00062 00081 template< typename T > 00082 class pointsdisplay2D : public gobj 00083 { 00084 public: 00085 00089 gobjQuadric * gq; 00090 00094 pointsdisplay2D 00095 ( 00096 gobjContainer & gX, 00097 vector< T > const & pt, 00098 boolc drawpoints=true, 00099 boolc numberthepoints=true, 00100 boolc countfrom1=true 00101 ); 00102 00104 pointsdisplay2D 00105 ( 00106 gobjContainer & gX, 00107 vector< T > const & pt, 00108 vector< string > const & labels, 00109 boolc drawpoints=true 00110 ); 00111 00113 void draw() { GOBJDEBUGCODE } 00114 }; 00115 00116 //--------------------------------------------------------- 00117 // Implementation 00118 00119 template< typename T > 00120 pointsdisplay3D<T>::pointsdisplay3D 00121 ( 00122 gobjContainer & gX, 00123 vector< T > const & pt, 00124 boolc drawpoints, 00125 boolc numberthepoints, 00126 boolc countfrom1 00127 ) 00128 : gq(0) 00129 { 00130 uintc n(pt.size()); 00131 vector<string> count; 00132 00133 uint i0=0; 00134 if (countfrom1) 00135 i0=1; 00136 00137 if (numberthepoints) 00138 { 00139 for (uint i=i0; i<n; ++i) 00140 { 00141 stringstream s; 00142 s << i; 00143 gX.push 00144 ( 00145 new gobjMyBitmapCharacter 00146 ( 00147 s.str(), 00148 point3<float>(pt[i].x,pt[i].y,pt[i].z) 00149 ) 00150 ); 00151 } 00152 } 00153 00154 if (drawpoints==false) 00155 return; 00156 00157 gq = new gobjQuadric(); 00158 gq->radius=.002; 00159 gX.push( gq ); 00160 00161 for (uint i=i0; i<n; ++i) 00162 gX.push( new gobjMySphereDraw(pt[i].x,pt[i].y,pt[i].z,gq) ); 00163 } 00164 00165 template< typename T > 00166 pointsdisplay2D<T>::pointsdisplay2D 00167 ( 00168 gobjContainer & gX, 00169 vector< T > const & pt, 00170 boolc drawpoints, 00171 boolc numberthepoints, 00172 boolc countfrom1 00173 ) 00174 : gq(0) 00175 { 00176 uintc n(pt.size()); 00177 vector<string> count; 00178 00179 uint i0=0; 00180 if (countfrom1) 00181 i0=1; 00182 00183 if (numberthepoints) 00184 { 00185 for (uint i=i0; i<n; ++i) 00186 { 00187 stringstream s; 00188 s << i; 00189 gX.push 00190 ( 00191 new gobjMyBitmapCharacter 00192 ( 00193 s.str(), 00194 point3<float>(pt[i].x,pt[i].y,0.0) 00195 ) 00196 ); 00197 } 00198 } 00199 00200 if (drawpoints==false) 00201 return; 00202 00203 gq = new gobjQuadric(); 00204 gq->radius=.002; 00205 gX.push( gq ); 00206 00207 for (uint i=i0; i<n; ++i) 00208 gX.push( new gobjMyDiscDraw(pt[i].x,pt[i].y,gq) ); 00209 } 00210 00211 00212 template< typename T > 00213 pointsdisplay2D<T>::pointsdisplay2D 00214 ( 00215 gobjContainer & gX, 00216 vector< T > const & pt, 00217 vector< string > const & labels, 00218 boolc drawpoints 00219 ) 00220 : gq(0) 00221 { 00222 assert(labels.size()==pt.size()); 00223 00224 uintc n(pt.size()); 00225 for (uint i=0; i<n; ++i) 00226 { 00227 gX.push 00228 ( 00229 new gobjMyBitmapCharacter 00230 ( 00231 labels[i], 00232 point3<float>(pt[i].x,pt[i].y,0.0) 00233 ) 00234 ); 00235 } 00236 00237 if (drawpoints==false) 00238 return; 00239 00240 gq = new gobjQuadric(); 00241 gq->radius=.002; 00242 gX.push( gq ); 00243 00244 for (uint i=0; i<n; ++i) 00245 gX.push( new gobjMyDiscDraw(pt[i].x,pt[i].y,gq) ); 00246 } 00247 00248 #endif 00249
1.5.8