Changeset 2164 in Sophya for trunk/SophyaPI
- Timestamp:
- Aug 7, 2002, 4:59:52 PM (23 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/pi3ddrw.cc
r2138 r2164 46 46 // double& teta, double& phi, double& psi, double& dax, double& day, double& co, double& dco) 47 47 // Renvoie la définition de la Vue-3D. Retourne "true " si définie par "Set3DView_Obs()" 48 // void Set3DBox(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) 49 // Définition de la boite 3D. 50 // 48 51 // void Draw3DBoxe(PIGraphic3D* g3, double xx1, double xx2, double yy1, double yy2, - 49 52 // double zz1, double zz2, double xl1, double xl2, - … … 62 65 lCO = 10.; dlCO = 3.; 63 66 v3D_obs = false; 64 x3Min = y3Min = z3Min = -1.; 65 x3Max = y3Max = z3Max = 1.; 67 Set3DBox(-1., 1., -1., 1., -1., 1.); 66 68 } 67 69 … … 103 105 co = lCO; dco = dlCO; 104 106 return(v3D_obs); 107 } 108 /* --Methode-- */ 109 void PIDrawer3D::Set3DBox(double xmin, double xmax, double ymin, double ymax, 110 double zmin, double zmax) 111 { 112 x3Min = xmin; x3Max = xmax; 113 y3Min = ymin; y3Max = ymax; 114 z3Min = zmin; z3Max = zmax; 105 115 } 106 116 … … 221 231 } 222 232 233 /* -------------------------------------------------------------- */ 234 /* ------------------- Classe PIElDrawer3D ------------------------ */ 235 /* -------------------------------------------------------------- */ 236 237 //++ 238 // Class PIElDrawer3D 239 // Lib PI 240 // include p3ddrw.h 241 // 242 // Classe de traceur ("Drawer") capable de gérer et de 243 // tracer une liste d'éléments simples. Cette classe 244 // est utilisé pour le tracé des axes et des éléments de 245 // texte ds les "PIScDrawWdg", "PIDraw3DWdg" et "PIImage". 246 //-- 247 //++ 248 // Links Parents 249 // PIDrawer3D 250 //-- 251 //++ 252 // Links Voir aussi 253 // PIElDrawer 254 // PIElDrwMgr 255 //-- 256 257 //++ 258 // Titre Constructeurs et méthodes 259 //-- 260 261 //++ 262 // PIElDrawer3D() 263 // Constructeur 264 //-- 265 266 /* --Methode-- */ 267 PIElDrawer3D::PIElDrawer3D() 268 { 269 ShowTitles(); 270 } 271 272 /* --Methode-- */ 273 PIElDrawer3D::~PIElDrawer3D() 274 { 275 } 276 277 278 //++ 279 // void SetTitles(string tt, string tb) 280 // void SetTitles(string tt, string tb, PIGraphicAtt const& att) 281 // Ajout de titres haut ("tt") et bas ("tb") 282 //-- 283 284 285 /* --Methode-- */ 286 int PIElDrawer3D::DecodeOptionString(vector<string> & opt, bool rmdecopt) 287 { 288 int nopt0 = opt.size(); 289 if (nopt0 < 1) return(0); 290 int ndec1 = PIDrawer::DecodeOptionString(opt, rmdecopt); 291 if ((nopt0 - ndec1) < 1) return(ndec1); // si tout a ete decode 292 vector<string> udopt; 293 unsigned int k = 0; 294 int ndec = opt.size(); 295 for( k=0; k<opt.size(); k++ ) { 296 string opts = opt[k]; 297 if (opts == "title") ShowTitles(true); 298 else if (opts == "notitle") ShowTitles(false); 299 300 else { 301 ndec--; 302 if (rmdecopt) udopt.push_back(opts); 303 } 304 } 305 306 if (rmdecopt) opt = udopt; 307 return(ndec+ndec1); 308 } 309 310 311 /* --Methode-- */ 312 void PIElDrawer3D::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax) 313 { 314 SelGraAtt(g); // DrawAxes change certains attributs graphiques 315 DrawAxes(g); // Trace des axes 316 g->SelFont(PI_NormalSizeFont); 317 SelGraAtt(g); // DrawAxes change certains attributs graphiques 318 319 // Trace des titres 320 if ( showTitles && ((titleT.length() > 0) || (titleB.length() > 0)) ) { 321 PIGraphicAtt grs = GetGraphicAtt(); 322 UpdateGraphicAtt(titleAtt); 323 SelGraAtt(g); 324 325 aXdir = false; // Vrai si Axe X de Droite vers Gauche 326 aYdir = false; // Vrai si Axe Y de Haut vers Bas 327 double fx, fy, fh; 328 // fh = g->GetFontHeightUC(gas, gds); 329 fh = 0.075*(YMax()-YMin()); 330 if ( titleT.length() > 0) { 331 if (g->isAxeYDirUpDown()) fy = g->DeltaUCY(YMin(), -fh); 332 else fy = g->DeltaUCY(YMax(), fh); 333 g->DrawString((XMax()+XMin())*0.5, fy, titleT.c_str(), PI_HorizontalCenter | PI_VerticalBottom); 334 // printf(" PIElDrawer3D::Draw()/DBG (%g , %g) %s - %g \n", fx, fy, titleT.c_str(), fh); 335 } 336 if ( titleB.length() > 0) { 337 fx = g->CalcStringWidth(titleB.c_str()); 338 if(aXdir) fx = g->DeltaUCX(XMax(), -(XMax()-XMin()-fx)/2.); 339 else fx = g->DeltaUCX(XMin(), (XMax()-XMin()-fx)/2.); 340 if (g->isAxeYDirUpDown()) fy = g->DeltaUCY(YMax(), fh*1.5); 341 else fy = g->DeltaUCY(YMin(), -fh*1.5); 342 g->DrawString((XMax()+XMin())*0.5, fy, titleB.c_str(), PI_HorizontalCenter | PI_VerticalBottom); 343 // printf(" PIElDrawer3D::Draw()/DBG (%g , %g) %s - %g \n", fx, fy, titleT.c_str(), fh); 344 } 345 SetGraphicAtt(grs); 346 } 347 348 SelGraAtt(g); 349 // Trace des elements 350 ElDrwMgr().DrawElements(g, xmin, ymin, xmax, ymax); 351 352 } 353 -
trunk/SophyaPI/PI/pi3ddrw.h
r2138 r2164 28 28 bool Get3DView(double& xc, double& yc, double& zc, double& xo, double& yo, double& zo, 29 29 double& teta, double& phi, double& psi, double& dax, double& day, double& co, double& dco); 30 31 virtual void Set3DBox(double xmin, double xmax, double ymin, double ymax, 32 double zmin, double zmax); 30 33 31 34 virtual PIGraphicUC* SetDrwWdg(PIBaseWdgGen* drw, int x0, int y0, int dx, int dy, PIGraphicGen* g); … … 56 59 57 60 61 // ----------------- Traceur d'elements 3D ------------------- 62 class PIElDrawer3D : public PIDrawer3D 63 { 64 public: 65 PIElDrawer3D(); 66 virtual ~PIElDrawer3D(); 67 68 // Methode de decodage des options 69 virtual int DecodeOptionString(vector<string> & opt, bool rmdecopt=true); 70 71 virtual void Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax); 72 73 inline PIElDrwMgr& ElDrwMgr() { return eltsMgr; } 74 75 inline void SetTitles(string tt, string tb) { titleT = tt; titleB = tb; } 76 inline void SetTitles(string tt, string tb, PIGraphicAtt const& att) 77 { titleT = tt; titleB = tb; titleAtt = att; } 78 inline void ShowTitles(bool fg=true) { showTitles = fg; } 79 80 // -- Pour compatibilite avec l'interface precedente , Reza 08/2002 81 inline void ElDel(int id) { eltsMgr.ElDel(id); } 82 inline void ElDelAll() { eltsMgr.ElDelAll(); } 83 84 inline int ElAddText(PIGrCoord x, PIGrCoord y, const char* s) 85 { return eltsMgr.ElAddText(x, y, s); } 86 87 protected: 88 PIElDrwMgr eltsMgr; 89 string titleT, titleB; // Titre Haut - Bas 90 PIGraphicAtt titleAtt; // Attributs graphiques de trace de titre 91 bool showTitles; // Affichage des titres si true 92 93 }; 94 58 95 59 96 #endif -
trunk/SophyaPI/PI/pi3dwdg.cc
r2138 r2164 71 71 // SetDefaultDrawRectangle(0.12, 0.12, 0.88, 0.88, true); 72 72 SetDefaultDrawRectangle(0., 0., 1., 1., true); 73 mBDrw = new PIElDrawer ;73 mBDrw = new PIElDrawer3D; 74 74 mBDrw->SetLimits(0.12,0.88, 0.12,0.88, kAxeDirLtoR,kAxeDirDownUp); 75 75 AddDrawer(mBDrw, 0.12, 0.12, 0.88, 0.88, true, false, false); -
trunk/SophyaPI/PI/pi3dwdg.h
r2138 r2164 40 40 inline void SetTitles(string const & tt, string const & tb) 41 41 { mBDrw->SetTitles(tt, tb); } 42 inline PIElDrawer *BaseDrawer() { return mBDrw; };42 inline PIElDrawer3D* BaseDrawer() { return mBDrw; }; 43 43 44 44 // Methode permettant de decoder des options a partir de chaines … … 70 70 virtual void DrawXYZAxes(); 71 71 72 PIElDrawer * mBDrw; // Objet traceur d'elements de fond72 PIElDrawer3D* mBDrw; // Objet traceur d'elements de fond 73 73 int mPx, mPy; // Position pointeur - Bouton-1 74 74 -
trunk/SophyaPI/PI/piaxes.cc
r2138 r2164 39 39 PIAxes::PIAxes() 40 40 { 41 setupDone = false; 41 42 } 42 43 … … 57 58 //| kGridOn, kAxesNone 58 59 // Si "afsz == true", la taille de fonte est choisie automatiquement. 60 // 59 61 // void DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt, unsigned int flags, bool afsz, \ 60 62 // double xmin, double xmax, double ymin, double ymax) 61 63 // Tracé d'axes avec spécification des limites d'axes. 64 // 65 // void DrawXCaption(PIGraphicUC* g, string const& xLabel, PIGraphicAtt const& att) 66 // Tracé du label d'axe X. 67 // void DrawYCaption(PIGraphicUC* g, string const& YLabel, PIGraphicAtt const& att) 68 // Tracé du label d'axe Y. 62 69 //-- 63 70 … … 195 202 196 203 /* --Methode-- */ 204 void PIAxes::DrawXCaption(PIGraphicUC* g, PIGraphicAtt& att, unsigned int flags, string const& xLabel) 205 { 206 if (xLabel.length() < 1) return; 207 if (!setupDone) { 208 PIGrCoord xmin, xmax, ymin, ymax; 209 g->GetGrSpace(xmin, xmax, ymin, ymax); 210 Setup(g, xmin, xmax, ymin, ymax); 211 } 212 if ( (att.GetFontName() != PI_DefaultFont) || 213 (att.GetFontAtt() != PI_NotDefFontAtt) ) 214 g->SelFont(att.GetFont()); 215 PIColors fcol = att.GetFgColor(); 216 if (fcol != PI_NotDefColor) g->SelForeground(fcol); 217 218 double fy, fh; 219 fh = 0.090*(yMax-yMin); 220 if (flags&kBoxAxes) { 221 if (g->isAxeYDirUpDown()) fy = yMax; 222 else fy = yMin; 223 } 224 225 else fy = 0.5*(yMin+yMax); 226 if (g->isAxeYDirUpDown()) fy += fh; 227 else fy -= fh; 228 g->DrawString(xMax-(xMax-xMin)*0.30, fy, xLabel.c_str(), 229 PI_HorizontalCenter | PI_VerticalCenter); 230 } 231 232 /* --Methode-- */ 233 void PIAxes::DrawYCaption(PIGraphicUC* g, PIGraphicAtt& att, unsigned int flags, string const& yLabel) 234 { 235 if (yLabel.length() < 1) return; 236 if (!setupDone) { 237 PIGrCoord xmin, xmax, ymin, ymax; 238 g->GetGrSpace(xmin, xmax, ymin, ymax); 239 Setup(g, xmin, xmax, ymin, ymax); 240 } 241 if ( (att.GetFontName() != PI_DefaultFont) || 242 (att.GetFontAtt() != PI_NotDefFontAtt) ) 243 g->SelFont(att.GetFont()); 244 PIColors fcol = att.GetFgColor(); 245 if (fcol != PI_NotDefColor) g->SelForeground(fcol); 246 247 double fx, fh; 248 fh = 0.125*(xMax-xMin); 249 if (yLabel.length() > 0) { 250 if (flags&kBoxAxes) { 251 if (g->isAxeXDirRtoL()) fx = xMax; 252 else fx = xMin; 253 } 254 else fx = 0.5*(xMin+xMax); 255 if (g->isAxeXDirRtoL()) fx += fh; 256 else fx -= fh; 257 unsigned long txtflg = PI_HorizontalCenter | PI_VerticalCenter | PI_TextDirectionVerticalUp; 258 if (g->isAxeYDirUpDown()) 259 txtflg = PI_HorizontalCenter | PI_VerticalCenter | PI_TextDirectionVerticalDown; 260 g->DrawString(fx, yMax-(yMax-yMin)*0.30, yLabel.c_str(), txtflg); 261 } 262 } 263 264 /* --Methode-- */ 197 265 void PIAxes::Setup(PIGraphicUC* g, double xmin, double xmax, 198 266 double ymin, double ymax) … … 219 287 xMajTickLen = (yMax-yMin)/100; 220 288 xMinTickLen = (yMax-yMin)/250; 289 290 setupDone = true; 221 291 } 222 292 -
trunk/SophyaPI/PI/piaxes.h
r2115 r2164 40 40 double ymin, double ymax); 41 41 42 43 virtual void DrawXCaption(PIGraphicUC* g, PIGraphicAtt& att, unsigned int flags, 44 string const& xLabel); 45 virtual void DrawYCaption(PIGraphicUC* g, PIGraphicAtt& att, unsigned int flags, 46 string const& YLabel); 47 42 48 // virtual void DrawHorizontalAxe(double xmin, double xmax, double y, 43 49 … … 66 72 void DrawGrid(PIGraphicUC* g); 67 73 74 75 bool setupDone; // Si Setup a ete appele 76 68 77 double xMin, xMax, yMin, yMax; 69 78 bool aXdir, aYdir; // Sens des axes horiz, vertical … … 77 86 double xMajTickLen, xMinTickLen; 78 87 double yMajTickLen, yMinTickLen; 88 79 89 }; 80 90 -
trunk/SophyaPI/PI/pidrawer.cc
r2080 r2164 252 252 if (GetGraphicAtt().GetMarker() != PI_NotDefMarker) 253 253 g->SelMarker(GetGraphicAtt().GetMarkerSize(), GetGraphicAtt().GetMarker()); 254 if (GetGraphicAtt().GetArrowMarker() != PI_NotDefArrowMarker) 255 g->SelArrowMarker(GetGraphicAtt().GetArrowMarkerSize(), 256 GetGraphicAtt().GetArrowMarker()); 254 257 } 255 258 -
trunk/SophyaPI/PI/pieldrw.cc
r2119 r2164 10 10 11 11 #include <math.h> 12 13 /* -------------------------------------------------------------- */ 14 /* ------------------- Classe PIElDrwMgr ------------------------ */ 15 /* -------------------------------------------------------------- */ 16 17 //++ 18 // Class PIElDrwMgr 19 // Lib PI 20 // include pieldrw.h 21 // 22 // Classe gestionnaire de tracé d'éléments. Utilisé par "PIElDrawer". 23 //-- 24 //++ 25 // Links Voir aussi 26 // PIElDrawer 27 //-- 28 //++ 29 // Titre Constructeurs et méthodes 30 //-- 31 32 /* --Methode-- */ 33 //++ 34 PIElDrwMgr::PIElDrwMgr() 35 // Constructeur 36 //-- 37 { 38 mEn = 0; 39 } 40 41 /* --Methode-- */ 42 //++ 43 PIElDrwMgr::~PIElDrwMgr() 44 // destructeur 45 //-- 46 { 47 ElDelAll(); 48 } 49 /* --Methode-- */ 50 //++ 51 void PIElDrwMgr::DrawElements(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax) 52 // Tracé des éléments 53 //-- 54 { 55 DrwElList::iterator it; 56 g->SaveGraphicAtt(); 57 for (it = mElist.begin(); it != mElist.end(); it++) 58 { 59 PIColors fcol = (*it).gatt.GetFgColor(); 60 if (fcol != PI_NotDefColor) g->SelForeground(fcol); 61 PIColors bcol = (*it).gatt.GetBgColor(); 62 if (bcol != PI_NotDefColor) g->SelBackground(bcol); 63 if ((*it).gatt.GetLineAtt() != PI_NotDefLineAtt) 64 g->SelLine((*it).gatt.GetLineAtt()); 65 if ( ((*it).gatt.GetFontName() != PI_DefaultFont) || 66 ((*it).gatt.GetFontAtt() != PI_NotDefFontAtt) ) 67 g->SelFont((*it).gatt.GetFont()); 68 if ((*it).gatt.GetMarker() != PI_NotDefMarker) 69 g->SelMarker((*it).gatt.GetMarkerSize(), (*it).gatt.GetMarker()); 70 if ((*it).gatt.GetArrowMarker() != PI_NotDefArrowMarker) 71 g->SelArrowMarker((*it).gatt.GetArrowMarkerSize(), 72 (*it).gatt.GetArrowMarker()); 73 74 switch ( (*it).etyp ) 75 { 76 case PIDEL_Line : 77 g->DrawLine((*it).ex, (*it).ey, (*it).edx, (*it).edy ); 78 break; 79 case PIDEL_Mark : 80 g->DrawMarker((*it).ex, (*it).ey); 81 break; 82 case PIDEL_Arrow : 83 g->DrawArrowMarker((*it).ex, (*it).ey, (*it).edx, (*it).edy, true); 84 break; 85 case PIDEL_Text : 86 g->DrawString((*it).ex, (*it).ey, (char*) ((*it).es.c_str()) ); 87 break; 88 case PIDEL_Rect : 89 g->DrawBox((*it).ex, (*it).ey, (*it).edx, (*it).edy ); 90 break; 91 case PIDEL_FRect : 92 g->DrawFBox((*it).ex, (*it).ey, (*it).edx, (*it).edy ); 93 break; 94 case PIDEL_Circ : 95 g->DrawCircle((*it).ex, (*it).ey, (*it).edx ); 96 break; 97 case PIDEL_FCirc : 98 g->DrawFCircle((*it).ex, (*it).ey, (*it).edx ); 99 break; 100 case PIDEL_Poly : 101 g->DrawPolygon((*it).xpol, (*it).ypol, (*it).npol, false ); 102 break; 103 case PIDEL_FPoly : 104 g->DrawFPolygon((*it).xpol, (*it).ypol, (*it).npol, false ); 105 break; 106 default : 107 break; 108 } 109 g->RestoreGraphicAtt(); 110 } 111 } 112 113 //++ 114 // int ElAddText(PIGrCoord x, PIGrCoord y, const char* s) 115 // int ElAddText(PIGrCoord x, PIGrCoord y, const char* s, PIGraphicAtt gatt) 116 // int ElAddText(PIGrCoord x, PIGrCoord y, string const & s) 117 // int ElAddText(PIGrCoord x, PIGrCoord y, string const & s, PIGraphicAtt gatt) 118 // Ajout d'un élément texte (possibilité de spécification d'un attribut graphique). 119 // Renvoie le numéro identificateur de l'élément. 120 // 121 // int ElAddLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2) 122 // int ElAddLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, PIGraphicAtt gatt) 123 // Ajout d'un élément de ligne (possibilité de spécification d'un attribut graphique). 124 // Renvoie le numéro identificateur de l'élément. 125 // 126 // int ElAddRect(PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy) 127 // int ElAddRect(PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy, PIGraphicAtt gatt) 128 // Ajout d'un élément de type rectangle (possibilité de spécification d'un attribut graphique). 129 // Renvoie le numéro identificateur de l'élément. 130 // 131 // int ElAddFRect(PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy) 132 // int ElAddFRect(PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy, PIGraphicAtt gatt) 133 // Ajout d'un élément de type rectangle plein 134 // (possibilité de spécification d'un attribut graphique). 135 // Renvoie le numéro identificateur de l'élément. 136 // 137 // int ElAddCirc(PIGrCoord x, PIGrCoord y, PIGrCoord r) 138 // int ElAddCirc(PIGrCoord x, PIGrCoord y, PIGrCoord r, PIGraphicAtt gatt) 139 // Ajout d'un élément de type cercle (possibilité de spécification d'un attribut graphique). 140 // Renvoie le numéro identificateur de l'élément. 141 // 142 // int ElAddFCirc(PIGrCoord x, PIGrCoord y, PIGrCoord r) 143 // int ElAddFCirc(PIGrCoord x, PIGrCoord y, PIGrCoord r, PIGraphicAtt gatt) 144 // Ajout d'un élément de type cercle plein avec un attribut de couleur. 145 // Renvoie le numéro identificateur de l'élément. 146 // 147 // int ElAddPoly(vector<PIGrCoord>& x, vector<PIGrCoord>& y) 148 // int ElAddPoly(vector<PIGrCoord>& x, vector<PIGrCoord>& y, PIGraphicAtt gatt) 149 // Ajout d'un élément de type polygone (possibilité de spécification d'un attribut graphique). 150 // Renvoie le numéro identificateur de l'élément. 151 // 152 // int ElAddFPoly(vector<PIGrCoord>& x, vector<PIGrCoord>& y) 153 // int ElAddFPoly(vector<PIGrCoord>& x, vector<PIGrCoord>& y, PIGraphicAtt gatt) 154 // Ajout d'un élément de type polygone plein 155 // (possibilité de spécification d'un attribut graphique). 156 // Renvoie le numéro identificateur de l'élément. 157 // 158 // void ElDel(int id) 159 // Suppression de l'élément avec l'identificateur "id". 160 // void ElDelAll() 161 // Suppression de tous les éléments de l'objet. 162 //-- 163 164 /* --Methode-- */ 165 int PIElDrwMgr::ElAdd(int typ, PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy, 166 const char* s, PIGraphicAtt const& att) 167 { 168 DrwEl dre; 169 mEn++; 170 dre.eid = mEn; dre.etyp = typ; 171 dre.ex = x; dre.ey = y; 172 dre.edx = dx; dre.edy = dy; 173 dre.gatt = att; 174 if (s) dre.es = s; 175 dre.xpol = dre.ypol = NULL; 176 dre.npol = 0; 177 mElist.push_back(dre); 178 return(mEn); 179 } 180 181 /* --Methode-- */ 182 int PIElDrwMgr::ElAdd(int typ, vector<PIGrCoord>& x, vector<PIGrCoord>& y, PIGraphicAtt const& att) 183 { 184 DrwEl dre; 185 mEn++; 186 dre.eid = mEn; dre.etyp = typ; 187 dre.ex = dre.ey = 0; 188 dre.edx = dre.edy = 0; 189 dre.gatt = att; 190 dre.xpol = dre.ypol = NULL; 191 dre.npol = (y.size() < x.size()) ? y.size() : x.size(); 192 if (dre.npol > 0) { 193 dre.xpol = new PIGrCoord[dre.npol]; 194 dre.ypol = new PIGrCoord[dre.npol]; 195 for(int kk=0; kk<dre.npol; kk++) { 196 dre.xpol[kk] = x[kk]; 197 dre.ypol[kk] = y[kk]; 198 } 199 } 200 mElist.push_back(dre); 201 return(mEn); 202 } 203 204 /* --Methode-- */ 205 void PIElDrwMgr::ElDel(int id) 206 { 207 DrwElList::iterator it; 208 for (it = mElist.begin(); it != mElist.end(); it++) { 209 if ( (*it).eid == id) { 210 if ( (*it).xpol ) delete[] (*it).xpol; 211 if ( (*it).ypol ) delete[] (*it).ypol; 212 mElist.erase(it); 213 break; 214 } 215 } 216 return; 217 } 218 219 /* --Methode-- */ 220 void PIElDrwMgr::ElDelAll() 221 { 222 DrwElList::iterator it; 223 for (it = mElist.begin(); it != mElist.end(); it++) { 224 if ( (*it).xpol ) delete[] (*it).xpol; 225 if ( (*it).ypol ) delete[] (*it).ypol; 226 } 227 mElist.erase(mElist.begin(), mElist.end()); 228 return; 229 } 230 231 12 232 13 233 … … 30 250 // PIDrawer 31 251 //-- 252 //++ 253 // Links Voir aussi 254 // PIElDrwMgr 255 //-- 32 256 33 257 //++ … … 43 267 PIElDrawer::PIElDrawer() 44 268 { 45 mEn = 0;46 titleT = titleB = "";47 269 ShowTitles(); 270 ShowAxesLabels(); 48 271 } 49 272 … … 55 278 56 279 //++ 57 // void SetTitles( const char* tt=NULL, const char* tb=NULL)280 // void SetTitles(string tt, string tb) 58 281 // Ajout de titres haut ("tt") et bas ("tb") 59 // void SetTitles(string const & tt, string const & tb) 60 // Ajout de titres haut ("tt") et bas ("tb") 61 //-- 62 63 /* --Methode-- */ 64 void PIElDrawer::SetTitles(const char* tt, const char* tb) 65 { 66 if (tt != NULL) titleT = tt; 67 if (tb != NULL) titleB = tb; 68 } 69 70 /* --Methode-- */ 71 void PIElDrawer::SetTitles(string const & tt, string const & tb) 72 { 73 titleT = tt; titleB = tb; 74 } 282 //-- 283 75 284 76 285 /* --Methode-- */ … … 119 328 } 120 329 121 //++ 122 // int ElAddText(PIGrCoord x, PIGrCoord y, const char* s, PIColors c=PI_NotDefColor) 123 // Ajout d'un élément texte avec un attribut de couleur. 124 // Renvoie le numéro identificateur de l'élément. 125 // int ElAddLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, - 126 // PIColors c=PI_NotDefColor) 127 // Ajout d'un élément de ligne avec un attribut de couleur. 128 // Renvoie le numéro identificateur de l'élément. 129 // int ElAddRect(PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy, - 130 // PIColors c=PI_NotDefColor) 131 // Ajout d'un élément de type rectangle avec un attribut de couleur. 132 // Renvoie le numéro identificateur de l'élément. 133 // int ElAddFRect(PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy, - 134 // PIColors c=PI_NotDefColor) 135 // Ajout d'un élément de type rectangle plein avec un attribut de couleur. 136 // Renvoie le numéro identificateur de l'élément. 137 // int ElAddCirc(PIGrCoord x, PIGrCoord y, PIGrCoord r, PIColors c=PI_NotDefColor) 138 // Ajout d'un élément de type cercle avec un attribut de couleur. 139 // Renvoie le numéro identificateur de l'élément. 140 // int ElAddFCirc(PIGrCoord x, PIGrCoord y, PIGrCoord r, PIColors c=PI_NotDefColor) 141 // Ajout d'un élément de type cercle plein avec un attribut de couleur. 142 // Renvoie le numéro identificateur de l'élément. 143 // 144 // void ElDel(int id) 145 // Suppression de l'élément avec l'identificateur "id". 146 // void ElDelAll() 147 // Suppression de tous les éléments du dessin. 148 //-- 149 150 /* --Methode-- */ 151 void PIElDrawer::Draw(PIGraphicUC* g, double /*xmin*/, double /*ymin*/, double /*xmax*/, double /*ymax*/) 330 /* --Methode-- */ 331 void PIElDrawer::DrawAxes(PIGraphicUC* g) 332 { 333 g->NoClip(); 334 g->SaveGraphicAtt(); 335 PIAxes axes; 336 axes.DrawXYAxes(g, mGrAtt, axesFlags, axesAFSz, XMin(), XMax(), YMin(), YMax()); 337 g->RestoreGraphicAtt(); 338 if (showAxesLabels) { 339 axes.DrawXCaption(g, labelAtt, axesFlags, xLabel); 340 axes.DrawYCaption(g, labelAtt, axesFlags, yLabel); 341 } 342 g->Clip(); 343 } 344 345 /* --Methode-- */ 346 void PIElDrawer::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax) 152 347 { 153 348 SelGraAtt(g); // DrawAxes change certains attributs graphiques … … 158 353 // Trace des titres 159 354 if ( showTitles && ((titleT.length() > 0) || (titleB.length() > 0)) ) { 355 PIGraphicAtt grs = GetGraphicAtt(); 356 UpdateGraphicAtt(titleAtt); 357 SelGraAtt(g); 358 160 359 aXdir = false; // Vrai si Axe X de Droite vers Gauche 161 360 aYdir = false; // Vrai si Axe Y de Haut vers Bas … … 164 363 fh = 0.075*(YMax()-YMin()); 165 364 if ( titleT.length() > 0) { 166 fx = g->CalcStringWidth(titleT.c_str());167 if(aXdir) fx = g->DeltaUCX(XMax(), -(XMax()-XMin()-fx)/2.);168 else fx = g->DeltaUCX(XMin(), (XMax()-XMin()-fx)/2.);169 365 if (g->isAxeYDirUpDown()) fy = g->DeltaUCY(YMin(), -fh); 170 366 else fy = g->DeltaUCY(YMax(), fh); 171 g->DrawString( fx, fy, titleT.c_str());367 g->DrawString((XMax()+XMin())*0.5, fy, titleT.c_str(), PI_HorizontalCenter | PI_VerticalCenter); 172 368 // printf(" PIElDrawer::Draw()/DBG (%g , %g) %s - %g \n", fx, fy, titleT.c_str(), fh); 173 369 } … … 178 374 if (g->isAxeYDirUpDown()) fy = g->DeltaUCY(YMax(), fh*1.5); 179 375 else fy = g->DeltaUCY(YMin(), -fh*1.5); 180 g->DrawString( fx, fy, titleB.c_str());376 g->DrawString((XMax()+XMin())*0.5, fy, titleB.c_str(), PI_HorizontalCenter | PI_VerticalCenter); 181 377 // printf(" PIElDrawer::Draw()/DBG (%g , %g) %s - %g \n", fx, fy, titleT.c_str(), fh); 182 378 } 183 } 184 DrwElList::iterator it; 185 PIColors cc = g->GetForeground(); 186 for (it = mElist.begin(); it != mElist.end(); it++) 187 { 188 if ((*it).col != PI_NotDefColor) g->SelForeground((*it).col); 189 switch ( (*it).etyp ) 190 { 191 case PIDEL_Line : 192 g->DrawLine((*it).ex, (*it).ey, (*it).edx, (*it).edy ); 193 break; 194 case PIDEL_Text : 195 g->DrawString((*it).ex, (*it).ey, (char*) ((*it).es.c_str()) ); 196 break; 197 case PIDEL_Rect : 198 g->DrawBox((*it).ex, (*it).ey, (*it).edx, (*it).edy ); 199 break; 200 case PIDEL_FRect : 201 g->DrawFBox((*it).ex, (*it).ey, (*it).edx, (*it).edy ); 202 break; 203 case PIDEL_Circ : 204 g->DrawCircle((*it).ex, (*it).ey, (*it).edx ); 205 break; 206 case PIDEL_FCirc : 207 g->DrawFCircle((*it).ex, (*it).ey, (*it).edx ); 208 break; 209 default : 210 break; 211 } 212 g->SelForeground(cc); 213 } 214 } 215 216 217 /* --Methode-- */ 218 int PIElDrawer::ElAdd(int typ, PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy, const char* s, PIColors c) 219 { 220 DrwEl dre; 221 mEn++; 222 dre.eid = mEn; dre.etyp = typ; 223 dre.ex = x; dre.ey = y; 224 dre.edx = dx; dre.edy = dy; 225 dre.col = c; 226 if (s) dre.es = s; 227 mElist.push_back(dre); 228 return(mEn); 229 } 230 231 /* --Methode-- */ 232 void PIElDrawer::ElDel(int id) 233 { 234 DrwElList::iterator it; 235 for (it = mElist.begin(); it != mElist.end(); it++) 236 if ( (*it).eid == id) { mElist.erase(it); break; } 237 return; 238 } 239 240 /* --Methode-- */ 241 void PIElDrawer::ElDelAll() 242 { 243 mElist.erase(mElist.begin(), mElist.end()); 244 return; 245 } 246 379 SetGraphicAtt(grs); 380 } 381 382 SelGraAtt(g); 383 // Trace des elements 384 ElDrwMgr().DrawElements(g, xmin, ymin, xmax, ymax); 385 386 } 387 -
trunk/SophyaPI/PI/pieldrw.h
r1970 r2164 10 10 // Classe avec gestion d une liste d elements a tracer 11 11 12 class PIElDr awer : public PIDrawer12 class PIElDrwMgr 13 13 { 14 14 public: 15 15 enum { PIDEL_Line = 1, PIDEL_Text = 2, 16 16 PIDEL_Rect = 3, PIDEL_FRect = 4, 17 PIDEL_Circ = 5, PIDEL_FCirc = 6 } ; 17 PIDEL_Circ = 5, PIDEL_FCirc = 6, 18 PIDEL_Poly = 7, PIDEL_FPoly = 8, 19 PIDEL_Mark = 9, PIDEL_Arrow = 10 } ; 18 20 19 PIElDrawer();20 virtual ~PIElDrawer();21 PIElDrwMgr(); 22 virtual ~PIElDrwMgr(); 21 23 22 virtual void SetTitles(const char* tt=NULL, const char* tb=NULL); 23 virtual void SetTitles(string const & tt, string const & tb); 24 25 inline void ShowTitles(bool fg=true) { showTitles = fg; } 24 virtual void DrawElements(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax); 26 25 27 // Methode de decodage des options 28 virtual int DecodeOptionString(vector<string> & opt, bool rmdecopt=true); 26 inline int ElAddLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2) 27 { PIGraphicAtt gatt; return( ElAdd(PIDEL_Line, x1, y1, x2, y2, NULL, gatt) ); } 28 inline int ElAddLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, 29 PIGraphicAtt const & gatt) 30 { return( ElAdd(PIDEL_Line, x1, y1, x2, y2, NULL, gatt) ); } 29 31 30 virtual void Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax); 32 inline int ElAddArrow(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2) 33 { PIGraphicAtt gatt; return( ElAdd(PIDEL_Arrow, x1, y1, x2, y2, NULL, gatt) ); } 34 inline int ElAddArrow(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, 35 PIGraphicAtt const & gatt) 36 { return( ElAdd(PIDEL_Arrow, x1, y1, x2, y2, NULL, gatt) ); } 31 37 32 inline int ElAddLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, 33 PIColors c=PI_NotDefColor) 34 { return( ElAdd(PIDEL_Line, x1, y1, x2, y2, NULL, c) ); } 35 inline int ElAddText(PIGrCoord x, PIGrCoord y, const char* s, PIColors c=PI_NotDefColor) 36 { return( ElAdd(PIDEL_Text, x, y, 0, 0, s, c) ); } 37 inline int ElAddRect(PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy, 38 PIColors c=PI_NotDefColor) 39 { return( ElAdd(PIDEL_Rect, x, y, dx, dy, NULL, c) ); } 40 inline int ElAddFRect(PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy, 41 PIColors c=PI_NotDefColor) 42 { return( ElAdd(PIDEL_FRect, x, y, dx, dy, NULL, c) ); } 43 inline int ElAddCirc(PIGrCoord x, PIGrCoord y, PIGrCoord r, PIColors c=PI_NotDefColor) 44 { return( ElAdd(PIDEL_Circ, x, y, r, r, NULL, c) ); } 45 inline int ElAddFCirc(PIGrCoord x, PIGrCoord y, PIGrCoord r, PIColors c=PI_NotDefColor) 46 { return( ElAdd(PIDEL_FCirc, x, y, r, r, NULL, c) ); } 38 inline int ElAddMarker(PIGrCoord x, PIGrCoord y) 39 { PIGraphicAtt gatt; return( ElAdd(PIDEL_Circ, x, y, 0, 0, NULL, gatt) ); } 40 inline int ElAddMarker(PIGrCoord x, PIGrCoord y, PIGraphicAtt const & gatt) 41 { return( ElAdd(PIDEL_Mark, x, y, 0, 0, NULL, gatt) ); } 42 43 inline int ElAddText(PIGrCoord x, PIGrCoord y, const char* s) 44 { PIGraphicAtt gatt; return( ElAdd(PIDEL_Text, x, y, 0, 0, s, gatt) ); } 45 inline int ElAddText(PIGrCoord x, PIGrCoord y, const char* s, PIGraphicAtt const & gatt) 46 { return( ElAdd(PIDEL_Text, x, y, 0, 0, s, gatt) ); } 47 inline int ElAddText(PIGrCoord x, PIGrCoord y, string const & s) 48 { PIGraphicAtt gatt; return( ElAdd(PIDEL_Text, x, y, 0, 0, s.c_str(), gatt) ); } 49 inline int ElAddText(PIGrCoord x, PIGrCoord y, string const & s, PIGraphicAtt const & gatt) 50 { return( ElAdd(PIDEL_Text, x, y, 0, 0, s.c_str(), gatt) ); } 51 52 inline int ElAddRect(PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy) 53 { PIGraphicAtt gatt; return( ElAdd(PIDEL_Rect, x, y, dx, dy, NULL, gatt) ); } 54 inline int ElAddRect(PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy, 55 PIGraphicAtt const & gatt) 56 { return( ElAdd(PIDEL_Rect, x, y, dx, dy, NULL, gatt) ); } 57 58 inline int ElAddFRect(PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy) 59 { PIGraphicAtt gatt; return( ElAdd(PIDEL_FRect, x, y, dx, dy, NULL, gatt) ); } 60 inline int ElAddFRect(PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy, 61 PIGraphicAtt const & gatt) 62 { return( ElAdd(PIDEL_FRect, x, y, dx, dy, NULL, gatt) ); } 63 64 inline int ElAddCirc(PIGrCoord x, PIGrCoord y, PIGrCoord r) 65 { PIGraphicAtt gatt; return( ElAdd(PIDEL_Circ, x, y, r, r, NULL, gatt) ); } 66 inline int ElAddCirc(PIGrCoord x, PIGrCoord y, PIGrCoord r, PIGraphicAtt const & gatt) 67 { return( ElAdd(PIDEL_Circ, x, y, r, r, NULL, gatt) ); } 68 69 inline int ElAddFCirc(PIGrCoord x, PIGrCoord y, PIGrCoord r) 70 { PIGraphicAtt gatt; return( ElAdd(PIDEL_FCirc, x, y, r, r, NULL, gatt) ); } 71 inline int ElAddFCirc(PIGrCoord x, PIGrCoord y, PIGrCoord r, PIGraphicAtt const & gatt) 72 { return( ElAdd(PIDEL_FCirc, x, y, r, r, NULL, gatt) ); } 73 74 inline int ElAddPoly(vector<PIGrCoord>& x, vector<PIGrCoord>& y) 75 { PIGraphicAtt gatt; return( ElAdd(PIDEL_Poly, x, y, gatt) ); } 76 inline int ElAddPoly(vector<PIGrCoord>& x, vector<PIGrCoord>& y, PIGraphicAtt const & gatt) 77 { return( ElAdd(PIDEL_Poly, x, y, gatt) ); } 78 79 inline int ElAddFPoly(vector<PIGrCoord>& x, vector<PIGrCoord>& y) 80 { PIGraphicAtt gatt; return( ElAdd(PIDEL_FPoly, x, y, gatt) ); } 81 inline int ElAddFPoly(vector<PIGrCoord>& x, vector<PIGrCoord>& y, PIGraphicAtt const & gatt) 82 { return( ElAdd(PIDEL_FPoly, x, y, gatt) ); } 47 83 48 84 void ElDel(int id); … … 51 87 protected: 52 88 int ElAdd(int typ, PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy, 53 const char* s, PI Colors c=PI_NotDefColor);54 #ifdef __DECCXX 55 public: 56 #endif 89 const char* s, PIGraphicAtt const & att); 90 int ElAdd(int typ, vector<PIGrCoord>& x, vector<PIGrCoord>& y, 91 PIGraphicAtt const & att); 92 57 93 struct DrwEl{ 58 94 int eid, etyp; … … 60 96 PIGrCoord edx,edy; 61 97 string es; 62 PIColors col; 98 PIGraphicAtt gatt; 99 PIGrCoord* xpol; 100 PIGrCoord* ypol; 101 int npol; 63 102 }; 64 #ifdef __DECCXX 65 protected: 66 #endif 103 67 104 typedef list<DrwEl> DrwElList; 68 69 105 DrwElList mElist; 70 106 int mEn; 107 108 }; 71 109 110 class PIElDrawer : public PIDrawer 111 { 112 public: 113 PIElDrawer(); 114 virtual ~PIElDrawer(); 115 116 // Methode de decodage des options 117 virtual int DecodeOptionString(vector<string> & opt, bool rmdecopt=true); 118 119 virtual void DrawAxes(PIGraphicUC* g); // Trace d'axes avec label axe X,Y 120 121 virtual void Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax); 122 123 inline PIElDrwMgr& ElDrwMgr() { return eltsMgr; } 124 125 inline void SetTitles(string tt, string tb) { titleT = tt; titleB = tb; } 126 inline void SetTitles(string tt, string tb, PIGraphicAtt const& att) 127 { titleT = tt; titleB = tb; titleAtt = att; } 128 inline void ShowTitles(bool fg=true) { showTitles = fg; } 129 130 inline void SetAxesLabels(string xl, string yl) { xLabel = xl; yLabel = yl; } 131 inline void SetAxesLabels(string xl, string yl, PIGraphicAtt const& att) 132 { xLabel = xl; yLabel = yl; labelAtt = att; } 133 inline void ShowAxesLabels(bool fg=true) { showAxesLabels = fg; } 134 135 // -- Pour compatibilite avec l'interface precedente , Reza 08/2002 136 inline void ElDel(int id) { eltsMgr.ElDel(id); } 137 inline void ElDelAll() { eltsMgr.ElDelAll(); } 138 139 inline int ElAddText(PIGrCoord x, PIGrCoord y, const char* s) 140 { return eltsMgr.ElAddText(x, y, s); } 141 142 protected: 143 PIElDrwMgr eltsMgr; 72 144 string titleT, titleB; // Titre Haut - Bas 73 bool showTitles; // Affichage des titres si true 145 PIGraphicAtt titleAtt; // Attributs graphiques de trace de titre 146 bool showTitles; // Affichage des titres si true 147 string xLabel, yLabel; // Label x, label y 148 PIGraphicAtt labelAtt; // Attributs graphiques de trace de label d'axes 149 bool showAxesLabels; // Affichage des labels d'axes si true 74 150 75 151 }; -
trunk/SophyaPI/PI/piimage.cc
r2157 r2164 1104 1104 gvdrw->SetLimits(xw1, xw2, yw1, yw2, kAxeDirLtoR, kAxeDirUpDown); 1105 1105 int cmapid = cmap->Type(); 1106 PIGraphicAtt gatt; 1106 1107 if ( (cmapid == CMAP_GREY32) || (cmapid == CMAP_GREYINV32) || 1107 1108 (cmapid == CMAP_GREY128) || (cmapid == CMAP_GREYINV128)) 1108 g vdrw->GetGraphicAtt().SetColAtt(PI_Red);1109 else g vdrw->GetGraphicAtt().SetColAtt(PI_Turquoise);1110 g vdrw->GetGraphicAtt().SetLineAtt(PI_NormalLine);1111 gvdrw->El AddRect(x,y,dx,dy);1109 gatt.SetColAtt(PI_Red); 1110 else gatt.SetColAtt(PI_Turquoise); 1111 gatt.SetLineAtt(PI_NormalLine); 1112 gvdrw->ElDrwMgr().ElAddRect(x,y,dx,dy,gatt); 1112 1113 gvw->AddDrawer(gvdrw, xw1, yw1, xw2, yw2, false); 1113 1114 gvw->SetColMap(cmap, false); -
trunk/SophyaPI/PI/pisurfdr.cc
r2092 r2164 95 95 Set3DView((xmin+xmax)/2., (ymin+ymax)/2, zmin+(zmax-zmin)*0.40, 96 96 (xmin+xmax)/2.+D , (ymin+ymax)/2.-2.5*D , zmin+(zmax-zmin)*0.85, 0.25, 0.25); 97 98 x3Min = xmin; x3Max = xmax; 99 y3Min = ymin; y3Max = ymax; 100 z3Min = zmin-PERC_GARDE*(zmax-zmin); z3Max = zmax+PERC_GARDE*(zmax-zmin); 97 98 Set3DBox(xmin, xmax, ymin, ymax, zmin-PERC_GARDE*(zmax-zmin), zmax+PERC_GARDE*(zmax-zmin)); 101 99 102 100 // printf("PISurfaceDrawer::UpdateLimits() : %g-%g %g-%g %g-%g (%g) \n", xmin,xmax,ymin,ymax,zmin,zmax,D);
Note:
See TracChangeset
for help on using the changeset viewer.