Changeset 107 in Sophya for trunk/SophyaPI
- Timestamp:
- May 22, 1998, 6:04:01 PM (27 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/pibwdggen.cc
r88 r107 16 16 mWGrC = NULL; // PIGraphic (Contexte graphique) associe a la fenetre} 17 17 // Doit etre cree par PIBaseWdgX/Mac/... 18 SetDefaultDrawRectangle(0., 0., 1., 1., true); 19 SetDefaultDrawerLimits(0., 1., 0., 1., kAxeDirLtoR, kAxeDirUpDown); 18 20 } 19 21 … … 36 38 } 37 39 40 // On met une variable pour eviter des boucles infinies entre les deux methodes 41 // Draw(PIGraphic* g, int, int, int, int) et Draw(PIGraphic* g) 42 static int fgdrawloop = 0; 43 38 44 /* --Methode-- */ 39 45 void PIBaseWdgGen::Draw(PIGraphic* g, int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/) 40 46 { 41 this->Draw(g); 47 if (fgdrawloop == 0) 48 { fgdrawloop=1; Draw(g); } 49 fgdrawloop = 0; 42 50 return; 43 51 } … … 49 57 puts("Debug_PIBaseWdgGen::Draw() Efface la fenetre par defaut ! "); 50 58 #endif 51 this->EraseWindow(); 59 if (fgdrawloop == 0) 60 { fgdrawloop=2; Draw(g, 0, 0, XSize(), YSize()); } 61 fgdrawloop = 0; 52 62 return; 53 63 } … … 169 179 } 170 180 171 172 /* --Methode-- */ 173 int PIBaseWdgGen::AddDrawer(PIDrawer* drw, int x0, int y0, int dx, int dy, bool ad) 181 /* --Methode-- */ 182 void PIBaseWdgGen::SetDefaultDrawRectangle(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, bool psz) 183 { 184 mDrX1 = x1; mDrY1 = y1; 185 mDrX2 = x2; mDrY2 = y2; mDrElastic = psz; 186 } 187 188 /* --Methode-- */ 189 void PIBaseWdgGen::SetDefaultDrawerLimits(float xmin, float xmax, float ymin, float ymax, 190 int axrl, int ayud) 191 { 192 mDrXmin = xmin; mDrXmax = xmax; 193 mDrYmin = ymin; mDrYmax = ymax; 194 mDXdir = axrl; mDYdir = ayud; 195 } 196 197 198 /* --Methode-- */ 199 int PIBaseWdgGen::AddDrawer(PIDrawer* drw, PIGrCoord x1, PIGrCoord y1, 200 PIGrCoord x2, PIGrCoord y2, bool psz, bool ad) 174 201 { 175 202 if (drw == NULL) return(0); 176 203 mDrwId++; 177 204 BWDrwId did; 178 did.x0 = x0; did.y0 = y0; 179 did.dx = dx; did.dy = dy; 205 did.x1 = x1; did.y1 = y1; 206 did.x2 = x2; did.y2 = y2; 207 did.autoszp = did.autolim = false; did.elastic = psz; 180 208 did.id = mDrwId; did.ad = ad; 181 209 did.drw = drw; … … 186 214 187 215 /* --Methode-- */ 188 void PIBaseWdgGen::MoveResizeDrawer(int id, int x0, int y0, int dx, int dy) 189 { 190 list<BWDrwId>::iterator it; 216 int PIBaseWdgGen::AddDrawer(PIDrawer* drw, bool autolim, bool ad) 217 { 218 if (drw == NULL) return(0); 219 mDrwId++; 220 BWDrwId did; 221 did.x1 = 0.; did.y1 = 0.; 222 did.x2 = 1.; did.y2 = 1.; 223 did.autoszp = true; did.autolim = autolim; did.elastic = false; 224 did.id = mDrwId; did.ad = ad; 225 did.drw = drw; 226 mDrwList.push_back(did); 227 drw->Attach(this, mDrwId); 228 return(mDrwId); 229 } 230 231 232 /* --Methode-- */ 233 void PIBaseWdgGen::MoveResizeDrawer(int id, PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, bool psz) 234 { 235 vector<BWDrwId>::iterator it; 191 236 for(it = mDrwList.begin(); it != mDrwList.end(); it++) 192 237 if ((*it).id == id) { 193 (*it).x0 = x0; (*it).y0 = y0; 194 (*it).dx = dx; (*it).dy = dy; 238 (*it).x1 = x1; (*it).y1 = y1; 239 (*it).x2 = x2; (*it).y2 = y2; 240 (*it).elastic = psz; 195 241 break; 196 242 } … … 202 248 { 203 249 if (mAdfg) return; 204 list<BWDrwId>::iterator it;250 vector<BWDrwId>::iterator it; 205 251 for(it = mDrwList.begin(); it != mDrwList.end(); it++) 206 252 if ((*it).id == id) … … 213 259 { 214 260 mAdfg = true; 215 list<BWDrwId>::iterator it;261 vector<BWDrwId>::iterator it; 216 262 for(it = mDrwList.begin(); it != mDrwList.end(); it++) 217 263 if ((*it).ad) delete (*it).drw; … … 221 267 } 222 268 269 /* --Methode-- */ 270 int PIBaseWdgGen::NbDrawers() 271 { 272 return(mDrwList.size()); 273 } 274 275 276 /* --Methode-- */ 277 PIDrawer* PIBaseWdgGen::GetDrawer(int n) 278 { 279 if ( (n < 0) || (n >= mDrwList.size()) ) return(NULL); 280 return(mDrwList[n].drw); 281 } 282 283 /* --Methode-- */ 284 PIDrawer* PIBaseWdgGen::GetDrawerId(int id) 285 { 286 vector<BWDrwId>::iterator it; 287 for(it = mDrwList.begin(); it != mDrwList.end(); it++) 288 if ((*it).id == id) return((*it).drw); 289 return(NULL); 290 } 291 223 292 224 293 /* --Methode-- */ … … 227 296 float xmin,ymin, xmax, ymax; 228 297 PIGraphicUC* guc; 298 int drx0, dry0, drdx, drdy; 299 int ddrx0, ddry0, ddrdx, ddrdy; 300 301 if (mDrElastic) { 302 ddrx0 = (int)((float) mDrX1 * (float)XSize()); 303 ddry0 = (int)((float) mDrY1 * (float)YSize()); 304 ddrdx = (int)((float) mDrX2 * (float)XSize()) - ddrx0 ; 305 ddrdy = (int)((float) mDrY2 * (float)YSize()) - ddry0 ; 306 } 307 else { 308 ddrx0 = (int)mDrX1; ddry0 = (int)mDrY1; 309 ddrdx = (int)mDrX2-ddrx0; ddrdy = (int)mDrY2-ddry0; 310 } 229 311 230 312 bool sxy = false; 231 313 if ((dx > 0) && (dy > 0)) sxy = true; 232 314 233 list<BWDrwId>::iterator it;315 vector<BWDrwId>::iterator it; 234 316 bool fgc=false; 235 317 for(it = mDrwList.begin(); it != mDrwList.end(); it++) { 236 318 g->SaveGraphicAtt(); 237 guc = (*it).drw->SetDrwWdg(this, (*it).x0, (*it).y0, (*it).dx, (*it).dy, g); 238 g->SetClipRectangle((*it).x0, (*it).y0, (*it).dx , (*it).dy); 319 if ( (*it).autoszp ) // Taille/position par defaut impose par PIBaseWdg 320 { drx0 = ddrx0; dry0 = ddry0; drdx = ddrdx; drdy = ddrdy; } 321 else { 322 if ( (*it).elastic ) { // Taille/position defin en fraction de la taille du PIBaseWdg 323 drx0 = (int)((float)(*it).x1 * (float)XSize()); 324 dry0 = (int)((float)(*it).y1 * (float)YSize()); 325 drdx = (int)((float)(*it).x2 * (float)XSize()) - drx0 ; 326 drdy = (int)((float)(*it).y2 * (float)YSize()) - dry0 ; 327 } 328 else { 329 drx0 = (int)(*it).x1 ; dry0 = (int)(*it).y1 ; 330 drdx = (int)(*it).x2-drx0 ; drdy = (int)(*it).y2-dry0 ; 331 } 332 } 333 // L'ordre des operations ici est importante 334 if ( (*it).autolim ) 335 (*it).drw->SetLimits(mDrXmin, mDrXmax, mDrYmin, mDrYmax, mDXdir, mDYdir); 336 guc = (*it).drw->SetDrwWdg(this, drx0, dry0, drdx, drdy, g); 337 g->SetClipRectangle(drx0, dry0, drdx , drdy); 338 (*it).drw->SelGraAtt(guc); 239 339 fgc = true; 240 340 if (sxy) { 241 341 guc->GrC2UC(x0, y0, xmin, ymin); 242 342 guc->GrC2UC(x0+dx, y0+dy, xmax, ymax); 343 } 344 else { 345 guc->GrC2UC(0, 0, xmin, ymin); 346 guc->GrC2UC(XSize(), YSize(), xmax, ymax); 347 } 348 if (xmin > xmax) swap(xmin,xmax); 349 if (ymin > ymax) swap(ymin,ymax); 350 (*it).drw->Draw(guc, xmin, ymin, xmax, ymax); 351 g->RestoreGraphicAtt(); 352 } 353 if (fgc) g->ClearClipRectangle(); 354 355 return; 356 } 357 358 /* --Methode-- */ 359 void PIBaseWdgGen::CallDrawer(int id) 360 { 361 float xmin,ymin, xmax, ymax; 362 PIGraphicUC* guc; 363 int drx0, dry0, drdx, drdy; 364 int ddrx0, ddry0, ddrdx, ddrdy; 365 366 PIGraphic* g = WindowGraphic(); 367 368 if (mDrElastic) { 369 ddrx0 = (int)((float) mDrX1 * (float)XSize()); 370 ddry0 = (int)((float) mDrY1 * (float)YSize()); 371 ddrdx = (int)((float) mDrX2 * (float)XSize()) - ddrx0 ; 372 ddrdy = (int)((float) mDrY2 * (float)YSize()) - ddry0 ; 373 } 374 else { 375 ddrx0 = (int)mDrX1; ddry0 = (int)mDrY1; 376 ddrdx = (int)mDrX2-ddrx0; ddrdy = (int)mDrY2-ddry0; 377 } 378 vector<BWDrwId>::iterator it; 379 for(it = mDrwList.begin(); it != mDrwList.end(); it++) 380 if ((*it).id == id) { 381 g->SaveGraphicAtt(); 382 if ( (*it).autoszp ) // Taille/position par defaut impose par PIBaseWdg 383 { drx0 = ddrx0; dry0 = ddry0; drdx = ddrdx; drdy = ddrdy; } 384 else { 385 if ( (*it).elastic ) { // Taille/position defin en fraction de la taille du PIBaseWdg 386 drx0 = (int)((float)(*it).x1 * (float)XSize()); 387 dry0 = (int)((float)(*it).y1 * (float)YSize()); 388 drdx = (int)((float)(*it).x2 * (float)XSize()) - drx0 ; 389 drdy = (int)((float)(*it).y2 * (float)YSize()) - dry0 ; 390 } 391 else { 392 drx0 = (int)(*it).x1 ; dry0 = (int)(*it).y1 ; 393 drdx = (int)(*it).x2-drx0 ; drdy = (int)(*it).y2-dry0 ; 394 } 395 } 396 // L'ordre des operations ici est importante 397 if ( (*it).autolim ) 398 (*it).drw->SetLimits(mDrXmin, mDrXmax, mDrYmin, mDrYmax, mDXdir, mDYdir); 399 guc = (*it).drw->SetDrwWdg(this, drx0, dry0, drdx, drdy, g); 400 g->SetClipRectangle(drx0, dry0, drdx , drdy); 401 (*it).drw->SelGraAtt(guc); 402 guc->GrC2UC(0, 0, xmin, ymin); 403 guc->GrC2UC(XSize(), YSize(), xmax, ymax); 243 404 if (xmin > xmax) swap(xmin,xmax); 244 405 if (ymin > ymax) swap(ymin,ymax); 245 406 (*it).drw->Draw(guc, xmin, ymin, xmax, ymax); 246 }247 else (*it).drw->Draw(guc);248 g->RestoreGraphicAtt();249 }250 if (fgc) g->ClearClipRectangle();251 252 return;253 }254 255 /* --Methode-- */256 void PIBaseWdgGen::CallDrawer(PIGraphicGen* g, int id)257 {258 PIGraphicUC* guc;259 list<BWDrwId>::iterator it;260 for(it = mDrwList.begin(); it != mDrwList.end(); it++)261 if ((*it).id == id) {262 g->SaveGraphicAtt();263 guc = (*it).drw->SetDrwWdg(this, (*it).x0, (*it).y0, (*it).dx, (*it).dy, g);264 g->SetClipRectangle((*it).x0, (*it).y0, (*it).dx , (*it).dy);265 (*it).drw->Draw(guc);266 407 g->RestoreGraphicAtt(); 267 408 g->ClearClipRectangle(); -
trunk/SophyaPI/PI/pibwdggen.h
r90 r107 7 7 #include PICMAP_H 8 8 #include PIGRAPHIC_H 9 #include "pigraphuc.h" 9 10 #include "psfile.h" 10 11 11 12 // Mettre dans cet ordre, sinon g++ a des problemes 12 #include < list>13 #include <vector> 13 14 14 15 enum PIKeyModifier { PIKM_Blank = 0, PIKM_Shift = 1, PIKM_Alt = 2, PIKM_Cntl = 4 } ; … … 78 79 virtual void PSPrint(PSFile* psf, int ofx = 0, int ofy = 0); 79 80 80 // Gestion des Drawers81 // ------ Gestion des Drawers ------ 81 82 friend class PIDrawer; 82 int AddDrawer(PIDrawer* drw, int x0, int y0, int dx, int dy, 83 bool ad=false); 84 void MoveResizeDrawer(int id, int x0, int y0, int dx, int dy); 83 void SetDefaultDrawRectangle(PIGrCoord x1, PIGrCoord y1, 84 PIGrCoord x2, PIGrCoord y2, bool psz=true); 85 void SetDefaultDrawerLimits(float xmin, float xmax, float ymin, float ymax, 86 int axrl=kAxeDirSame, int ayud=kAxeDirSame); 87 int AddDrawer(PIDrawer* drw, PIGrCoord x1, PIGrCoord y1, 88 PIGrCoord x2, PIGrCoord y2, 89 bool psz=true, bool ad=false); 90 int AddDrawer(PIDrawer* drw, bool autolim=false, bool ad=false); 91 void MoveResizeDrawer(int id, PIGrCoord x1, PIGrCoord y1, 92 PIGrCoord x2, PIGrCoord y2, bool psz=true); 85 93 void RemoveDrawer(int id); // Ote un drawer de la liste 86 94 void DeleteDrawers(); // Ote et detruit tous les drawers 95 // Acces aux drawers 96 int NbDrawers(); 97 PIDrawer* GetDrawerId(int id); 98 PIDrawer* GetDrawer(int n); 87 99 88 100 // Trace des Drawers ... 89 101 virtual void CallDrawers(PIGraphicGen* g, int x0=0, int y0=0, int dx=0, int dy=0); 90 virtual void CallDrawer( PIGraphicGen* g,int id);102 virtual void CallDrawer(int id); 91 103 92 104 // Devrait etre protected - mis ici a cause de cxx 11/07/97 Reza 93 struct BWDrwId { int x0, y0; int dx, dy; int id; bool ad;PIDrawer* drw; };105 struct BWDrwId { int id; PIGrCoord x1, y1, x2, y2; bool autoszp, autolim, elastic, ad; PIDrawer* drw; }; 94 106 95 107 virtual PIGraphic* WindowGraphic(); 96 108 109 // -------------- Variables membre protegees ------------------- 97 110 protected: 98 111 PIGraphicWin* mWGrC; // PIGraphic (Contexte graphique) associe a la fenetre 99 bool mAdfg; 100 int mDrwId; 101 list<BWDrwId> mDrwList; 112 bool mAdfg; // Pour la gestion de DeleteDrawers() quand appele par delete de PIBaseWdg 113 int mDrwId; // Compteur pour DrawerId 114 vector<BWDrwId> mDrwList; 115 // Definition de la zone de trace et limites UC des drawers par defaut 116 PIGrCoord mDrX1, mDrY1, mDrX2, mDrY2; 117 bool mDrElastic; // true --> Coord en fraction de la taille 118 float mDrXmin, mDrXmax, mDrYmin, mDrYmax; // Limites par defaut - UC 119 int mDXdir, mDYdir; // Sens des axes par defaut 102 120 103 121 }; -
trunk/SophyaPI/PI/pidrawer.cc
r72 r107 13 13 SetAxesFlags(kAxesDflt); 14 14 mDndfg = false; // Pour controle de l'appel de Detach() si delete 15 16 mFCol = mBCol = PI_NotDefColor; 17 mLAtt = PI_NotDefLineAtt; 18 mFSz = PI_NotDefFontSize; 19 mFAtt = PI_NotDefFontAtt; 20 mMSz = -1; 21 mMrk = PI_NotDefMarker; 15 22 } 16 23 … … 44 51 } 45 52 53 54 void 55 PIDrawer::UpdateSize() 56 { 57 // Ne fait rien ! 58 return; 59 } 60 61 void 62 PIDrawer::Refresh() 63 { 64 list<DrwBWId>::iterator it; 65 for(it = mBWdgList.begin(); it != mBWdgList.end(); it++) 66 (*it).wdg->CallDrawer((*it).id); 67 68 } 69 70 void 71 PIDrawer::SetColAtt(PIColors fg, PIColors bg) 72 { 73 if (fg != PI_NotDefColor) mFCol = fg; 74 if (bg != PI_NotDefColor) mBCol = bg; 75 } 76 77 void 78 PIDrawer::SetLineAtt(PILineAtt lat) 79 { 80 if (lat != PI_NotDefLineAtt) mLAtt = lat; 81 } 82 83 void 84 PIDrawer::SetFontAtt(PIFontSize fsz, PIFontAtt fat) 85 { 86 if (fsz != PI_NotDefFontSize) mFSz = fsz; 87 if (fat != PI_NotDefFontAtt) mFAtt = fat; 88 } 89 90 void 91 PIDrawer::SetMarkerAtt(int sz, PIMarker mrk) 92 { 93 if (sz >= 0) mMSz = sz; 94 if (mrk != PI_NotDefMarker) mMrk = mrk; 95 } 96 97 void 98 PIDrawer::SelGraAtt(PIGraphicUC* g) 99 { 100 if (mFCol != PI_NotDefColor) g->SelForeground(mFCol); 101 if (mBCol != PI_NotDefColor) g->SelBackground(mBCol); 102 if (mLAtt != PI_NotDefLineAtt) g->SelLine(mLAtt); 103 if ( (mFSz != PI_NotDefFontSize) || (mFAtt != PI_NotDefFontAtt) ) 104 g->SelFont(mFSz, mFAtt); 105 if ( (mMrk != PI_NotDefMarker) || (mMSz >= 0) ) 106 g->SelMarker(mMSz, mMrk); 107 } 46 108 47 109 void … … 234 296 235 297 236 void237 PIDrawer::Draw(PIGraphicUC*)238 {239 }240 298 241 299 void 242 300 PIDrawer::Draw(PIGraphicUC* g, float /*xmin*/, float /*ymin*/, float /*xmax*/, float /*ymax*/) 243 301 { 244 Draw(g);245 302 } 246 303 -
trunk/SophyaPI/PI/pidrawer.h
r71 r107 30 30 virtual void SetAxesFlags(int flags=kAxesDflt); 31 31 32 virtual void Draw(PIGraphicUC* g); 33 virtual void Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax); 32 virtual void Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax); 33 34 virtual void Refresh(); // Recalcule les limites et reaffiche 35 virtual void UpdateSize(); // Calcule et change les limites si non fixees 34 36 35 37 float XMin() const {return xMin;} … … 42 44 int LimitsFixed() const {return limitsFixed;} 43 45 void FreeLimits() {limitsFixed = 0;} 46 47 void SetColAtt(PIColors fg=PI_NotDefColor, 48 PIColors bg=PI_NotDefColor); 49 void SetLineAtt(PILineAtt lat=PI_NotDefLineAtt); 50 void SetFontAtt(PIFontSize fsz=PI_NotDefFontSize, 51 PIFontAtt fat=PI_NotDefFontAtt); 52 void SetMarkerAtt(int sz=-1, PIMarker mrk=PI_NotDefMarker); 53 54 void SelGraAtt(PIGraphicUC* g); 44 55 45 56 // Les objets/methodes suivants devraient etre protected … … 83 94 list<DrwBWId> mBWdgList; 84 95 bool mDndfg; 96 97 // Gestion d attributs graphiques associes a chaque drawer 98 PIColors mFCol, mBCol; 99 PILineAtt mLAtt; 100 PIFontSize mFSz; 101 PIFontAtt mFAtt; 102 int mMSz; 103 PIMarker mMrk; 85 104 86 105 }; -
trunk/SophyaPI/PI/pidrawwin.cc
r52 r107 16 16 17 17 void 18 PIDrawWindow::AddScDrawer(PI ScDrawer* d, bool ad)18 PIDrawWindow::AddScDrawer(PIDrawer* d, bool ad) 19 19 { 20 20 mDrawWdg->AddScDrawer(d, ad); -
trunk/SophyaPI/PI/pidrawwin.h
r52 r107 15 15 ~PIDrawWindow(); 16 16 17 virtual void AddScDrawer(PI ScDrawer*, bool ad=false);17 virtual void AddScDrawer(PIDrawer*, bool ad=false); 18 18 virtual void SetAxesFlags(int flags=-1); 19 19 inline PIScDrawWdg * DrawWdg() { return mDrawWdg; } -
trunk/SophyaPI/PI/pihisto.cc
r71 r107 3 3 4 4 PIHisto::PIHisto(Histo* histo, bool ad) 5 : PI ScDrawer(), mHisto(histo)5 : PIDrawer(), mHisto(histo) 6 6 { 7 7 mAdDO = ad; // Flag pour suppression automatique de mHisto … … 19 19 PIHisto::UpdateSize() 20 20 { 21 if (!mDrawer) return; 22 if (mDrawer->LimitsFixed()) return; 23 // Commencer par trouver nos limites 24 25 float xmin = mHisto->XMin(); 26 float xmax = (mHisto->XMax()); 27 28 float ymax = mHisto->VMax()*1.2; 29 float ymin = mHisto->VMin(); 30 31 if (mDrawWdg) 32 mDrawWdg->SetLimits(xmin, xmax, ymin, ymax); 33 else 34 mDrawer->SetLimits(xmin, xmax, ymin, ymax); 35 36 mDrawer->SetAxesFlags(kBoxAxes | kExtTicks | kLabels); 21 if (!mHisto) return; 22 SetLimits(mHisto->XMin(), mHisto->XMax(), mHisto->VMin(), mHisto->VMax()*1.2); 23 SetAxesFlags(kBoxAxes | kExtTicks | kLabels); 37 24 } 38 25 … … 41 28 PIHisto::Draw(PIGraphicUC* g, float /*xmin*/, float /*ymin*/, float /*xmax*/, float /*ymax*/) 42 29 { 30 if (!mHisto) return; 43 31 for (int i=0; i<mHisto->NBins(); i++) { 44 32 float left = mHisto->BinLowEdge(i); … … 55 43 PIHisto::DrawStats(PIGraphicUC* g) 56 44 { 57 if (!mDrawWdg) return; 58 // Une boite dans le coin superieur droit 59 float cellHeight = (mDrawWdg->YMax() - mDrawWdg->YMin()) * 0.05; 60 float cellWidth = (mDrawWdg->XMax() - mDrawWdg->XMin()) * 0.23; 61 g->DrawLine(mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax(), 62 mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax() - cellHeight); 63 g->DrawLine(mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax() - cellHeight, 64 mDrawWdg->XMax() , mDrawWdg->YMax() - cellHeight); 45 if (!mHisto) return; 46 float cellHeight = (YMax() - YMin()) * 0.05; 47 float cellWidth = (XMax() - XMin()) * 0.23; 48 g->DrawLine(XMax() - cellWidth, YMax(), 49 XMax() - cellWidth, YMax() - cellHeight); 50 g->DrawLine(XMax() - cellWidth, YMax() - cellHeight, 51 XMax() , YMax() - cellHeight); 65 52 char label[50]; 66 53 sprintf(label, "N = %.6g", mHisto->NData()); 67 g->SelFontSz(( mDrawWdg->YMax() - mDrawWdg->YMin())/30);68 g->DrawString( mDrawWdg->XMax() - cellWidth*0.9, mDrawWdg->YMax() - cellHeight*0.8, label);54 g->SelFontSz((YMax() - YMin())/30); 55 g->DrawString(XMax() - cellWidth*0.9, YMax() - cellHeight*0.8, label); 69 56 70 57 } -
trunk/SophyaPI/PI/pihisto.h
r71 r107 3 3 4 4 #include "histos.h" 5 #include "pi scdrawwdg.h"5 #include "pidrawer.h" 6 6 7 class PIHisto : public PI ScDrawer {7 class PIHisto : public PIDrawer { 8 8 public: 9 9 PIHisto(Histo* histo, bool ad=false); … … 16 16 protected: 17 17 Histo* mHisto; 18 bool mAdDO; 18 19 }; 19 20 -
trunk/SophyaPI/PI/pihisto2d.cc
r87 r107 22 22 // Createur d'une classe de dessin pour l'histogramme 2D histo. 23 23 //-- 24 : PI ScDrawer(), mHisto(histo)24 : PIDrawer(), mHisto(histo) 25 25 { 26 26 mAdDO = ad; // Flag pour suppression automatique de mHisto … … 150 150 //-- 151 151 { 152 if (!mDrawer) return;153 if (mDrawer->LimitsFixed()) return;154 152 if(!mHisto) return; 155 // Commencer par trouver nos limites 156 157 float xmin = mHisto->XMin(); 158 float xmax = mHisto->XMax(); 159 160 float ymax = mHisto->YMax(); 161 float ymin = mHisto->YMin(); 162 163 if (mDrawWdg) 164 mDrawWdg->SetLimits(xmin, xmax, ymin, ymax); 165 else 166 mDrawer->SetLimits(xmin, xmax, ymin, ymax); 167 168 mDrawer->SetAxesFlags(kBoxAxes | kExtTicks | kLabels); 153 SetLimits(mHisto->XMin(), mHisto->XMax(), mHisto->YMin() , mHisto->YMax()); 154 SetAxesFlags(kBoxAxes | kExtTicks | kLabels); 169 155 } 170 156 … … 291 277 //-- 292 278 { 293 if (!mDrawWdg) return;294 279 // Une boite dans le coin superieur droit 295 float cellHeight = ( mDrawWdg->YMax() - mDrawWdg->YMin()) * 0.05;296 float cellWidth = ( mDrawWdg->XMax() - mDrawWdg->XMin()) * 0.23;297 g->DrawLine( mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax(),298 mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax() - cellHeight);299 g->DrawLine( mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax() - cellHeight,300 mDrawWdg->XMax() , mDrawWdg->YMax() - cellHeight);280 float cellHeight = (YMax() - YMin()) * 0.05; 281 float cellWidth = (XMax() - XMin()) * 0.23; 282 g->DrawLine(XMax() - cellWidth, YMax(), 283 XMax() - cellWidth, YMax() - cellHeight); 284 g->DrawLine(XMax() - cellWidth, YMax() - cellHeight, 285 XMax() , YMax() - cellHeight); 301 286 char label[50]; 302 287 sprintf(label, "N = %.6g", mHisto->NData()); 303 g->SelFontSz(( mDrawWdg->YMax() - mDrawWdg->YMin())/30);304 g->DrawString( mDrawWdg->XMax() - cellWidth*0.9, mDrawWdg->YMax() - cellHeight*0.8, label);288 g->SelFontSz((YMax() - YMin())/30); 289 g->DrawString(XMax() - cellWidth*0.9, YMax() - cellHeight*0.8, label); 305 290 printf("H[%d,%d] Dynamique: [%g,%g] Frac [%g,%g]\n" 306 291 ,mHisto->NBinX(),mHisto->NBinY(),HMin(),HMax(),FMin(),FMax()); … … 679 664 mpih->UseDyn(mHMin,mHMax); 680 665 mpih->UseFrac(mFracMin,mFracMax); 681 m pih->Refresh(); // On rafraichit le dessin666 mH2Wdg->Refresh(); // On rafraichit le dessin (tout le PIScDrawWdg) 682 667 } 683 668 else if (opt==6002) { -
trunk/SophyaPI/PI/pihisto2d.h
r82 r107 11 11 12 12 //////////////////////////////////////////////////////////////////// 13 class PIHisto2D : public PI ScDrawer {13 class PIHisto2D : public PIDrawer { 14 14 public: 15 15 PIHisto2D(Histo2D* histo, bool ad=false); … … 42 42 43 43 Histo2D* mHisto; 44 bool mAdDO; 44 45 bool mFgCol; 45 46 CMapId mCmap; -
trunk/SophyaPI/PI/piimage.cc
r106 r107 25 25 winovis = true; // $CHECK$ Reza A enlever si possible 17/6/96 26 26 27 admrk = true;28 xpmrk = ypmrk = NULL; nbmrk = 0;29 mrkt = PI_PlusMarker; mrkbsz = 3;30 27 31 28 zow = NULL; … … 82 79 if (lut) delete lut; 83 80 if (aisup) delete img; // Suppression automatique d'image 84 if (admrk)85 {86 if (xpmrk) delete xpmrk;87 if (ypmrk) delete ypmrk;88 }89 81 if (trtw) delete trtw; 90 82 } … … 105 97 106 98 /* --Methode-- */ 107 void PIImage::SetImage(P2DArrayAdapter *pim, bool refr)99 void PIImage::SetImage(P2DArrayAdapter *pim, bool ad, bool refr) 108 100 { 109 101 … … 117 109 zmgv = 1; 118 110 119 if (img) 120 { 111 if (img) { 121 112 // SetSize(img->XSize(), img->YSize()); 122 113 CenterPave(); … … 125 116 img->CheckDyn(min, max, moy, sig, nbnul, nbsat); 126 117 SetLut(min, max, kLutType_Lin, 1, refr); 127 } 128 return; 129 } 130 131 /* --Methode-- */ 132 void PIImage::AddMarks(int nm, float* px, float* py, bool refr, bool ad, PIMarker mrk, int msz) 133 { 134 if ( (nbmrk > 0) && admrk ) { 135 if (xpmrk) delete xpmrk; 136 if (ypmrk) delete ypmrk; 137 } 138 if (nm <= 0) { nbmrk = 0; xpmrk = ypmrk = NULL; } 139 else { nbmrk = nm; xpmrk = px, ypmrk = py; } 140 admrk = ad; mrkt = mrk; mrkbsz = msz; 141 if (refr) DrawMarks(mWGrC, 0, XSize(), 0, YSize()); 142 return; 143 } 144 145 /* --Methode-- */ 146 void PIImage::RemoveMarks(bool refr) 147 { 148 if (nbmrk < 1) return; 149 if (admrk ) { 150 if (xpmrk) delete xpmrk; 151 if (ypmrk) delete ypmrk; 152 } 153 nbmrk = 0; xpmrk = ypmrk = NULL; 154 if (refr) Refresh(); 155 } 118 aisup = ad; 119 } 120 else aisup = false; 121 return; 122 } 123 156 124 157 125 /* --Methode-- */ … … 173 141 return; 174 142 } 175 176 143 177 144 … … 197 164 } 198 165 199 200 /* --Methode-- */201 void PIImage::SetAutoDelImage(bool ad)202 {203 aisup = ad;204 return;205 }206 207 166 /* --Methode-- */ 208 167 void PIImage::ShowCursor(bool sc) … … 380 339 } 381 340 382 DrawMarks(g, x0, x0+dx, y0, y0+dy);383 341 return; 384 342 } … … 689 647 } 690 648 691 /* --Methode-- */692 void PIImage::DrawMarks(PIGraphicGen* g, int x1, int x2, int y1, int y2)693 {694 float fz;695 float tofx, tofy;696 int i,x,y;697 698 if ( (winovis || (nbmrk < 1) ) ) return;699 tofx = tofy = 0;700 if ( img ) { tofx = tofy = 0; } /* img->XOrg(); tofy = img->YOrg(); $CHECK$ REZA 5/04/98 */701 tofx += offx; tofy += offy;702 fz = GetZoomF();703 g->SelGOMode(PI_GOCopy);704 g->SelMarker((int)(fz*mrkbsz), mrkt);705 if ( (GetColMapId() == CMAP_GREY32) || (GetColMapId() == CMAP_GREYINV32) )706 g->SelForeground(PI_Red);707 else g->SelForeground(PI_White);708 for(i=0; i<nbmrk; i++)709 {710 x = (int) ((xpmrk[i]-tofx)*fz);711 y = (int) ((ypmrk[i]-tofy)*fz);712 if ((x < x1) || (x > x2) || (y < y1) || (y > y2)) continue;713 g->DrawMarker(x,y);714 }715 return;716 }717 649 718 650 /* --Methode-- */ -
trunk/SophyaPI/PI/piimage.h
r104 r107 29 29 virtual void Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL); 30 30 31 void SetImage(P2DArrayAdapter* pim, bool refr=true); 32 void SetAutoDelImage(bool ad = false); 33 34 void AddMarks(int nm, float* px, float* py, bool refr=true, 35 bool ad=true, PIMarker mrk=PI_PlusMarker, int msz=3); 36 void RemoveMarks(bool refr=true); 31 void SetImage(P2DArrayAdapter* pim, bool ad = true, bool refr=true); 37 32 38 33 void SetZoomWin(PIPixmap * zw, bool refr=true); … … 86 81 void DrawCursor(PIGraphicGen* g); 87 82 void DrawCursor(PIGraphicGen* g, int xc, int yc); 88 void DrawMarks(PIGraphicGen* g, int x1, int x2, int y1, int y2);89 83 90 84 void ShowTrTxW(); … … 97 91 98 92 // Les donnees 99 100 93 P2DArrayAdapter * img; 101 bool aisup; 94 bool aisup; // Flag de suppression automatique de img 102 95 bool curshow; 103 96 bool winovis; // $CHECK$ Reza A enlever si possible 17/6/96 104 105 // Pour gerer les marques ajoutees106 bool admrk;107 int nbmrk, mrkbsz;108 float * xpmrk, * ypmrk;109 PIMarker mrkt;110 97 // Tableau des pixels principal 111 98 unsigned char * pixm; -
trunk/SophyaPI/PI/pintuple.cc
r72 r107 5 5 /* --Methode-- */ 6 6 PINTuple::PINTuple(NTuple* nt, bool ad) 7 : PI ScDrawer()7 : PIDrawer() 8 8 { 9 9 mNT = nt; … … 45 45 if (mNT->NEntry() <= 0) return; 46 46 if ( (xK < 0) || (yK < 0) ) return; 47 if (!mDrawer) return;48 if (mDrawer->LimitsFixed()) return;49 47 50 48 // Commencer par trouver nos limites … … 59 57 dy = 0.02*(ymax-ymin); 60 58 61 if (mDrawWdg) 62 mDrawWdg->SetLimits(xmin-dx, xmax+dx, ymin-dy, ymax+dy, 63 kAxeDirLtoR, kAxeDirDownUp); 64 else 65 mDrawer->SetLimits(xmin-dx, xmax+dx, ymin-dy, ymax+dy, 66 kAxeDirLtoR, kAxeDirDownUp); 67 68 mDrawer->SetAxesFlags(kBoxAxes | kExtTicks | kLabels); 59 SetLimits(xmin-dx, xmax+dx, ymin-dy, ymax+dy); 60 SetAxesFlags(kBoxAxes | kExtTicks | kLabels); 69 61 } 70 62 … … 78 70 79 71 if (!mNT) return; 80 if (!mDrawer) return;81 72 if ( (xK < 0) || (yK < 0) ) return; 82 73 … … 98 89 } 99 90 100 if (!mDrawWdg) return; 101 if (!MainScDrawer()) return; 91 /* 102 92 sprintf(buff, "NTuple: NEntry= %d NDisp= %d", (int)mNT->NEntry(), nok); 103 93 g->BaseGraphic()->DrawString(15,15,buff); 94 */ 104 95 return; 105 96 } -
trunk/SophyaPI/PI/pintuple.h
r71 r107 5 5 #include "piscdrawwdg.h" 6 6 7 class PINTuple : public PI ScDrawer {7 class PINTuple : public PIDrawer { 8 8 public: 9 9 PINTuple(NTuple* nt, bool ad); … … 19 19 protected: 20 20 NTuple* mNT; 21 bool mAdDO; 21 22 int xK, yK; // Index du nom de variable en X/Y ds le ntuple 22 23 int xebK, yebK; // Index du nom de variable en ErrBarX/Y ds le ntuple -
trunk/SophyaPI/PI/piscdrawwdg.cc
r88 r107 7 7 { 8 8 mBDrw = new PIDrawer; 9 SetLimits(-1.,1.,-1.,1.); 9 SetLimits(-1.,1.,-1.,1.,kAxeDirLtoR,kAxeDirDownUp); 10 SetAxesFlags(kBoxAxes | kExtTicks | kLabels); 10 11 FreeLimits(); 11 12 xEndDrag = yEndDrag = xBegDrag = yBegDrag = 0; 12 13 padsup = false; 13 SetDefaultDrawRectangle(0.12, 0.12, 0.88, 0.88, true); 14 14 15 mTrlb = mTxw = NULL; 15 16 mTrW = NULL; … … 24 25 PIScDrawWdg::~PIScDrawWdg() 25 26 { 26 DeleteScDrawers();27 27 delete mBDrw; 28 28 if (mTrW) delete mTrW; … … 37 37 return; // $CHECK$ exception ? 38 38 mBDrw->SetLimits(xmin, xmax, ymin, ymax, axrl, ayud); 39 SetDefaultDrawerLimits(xmin, xmax, ymin, ymax, axrl, ayud); 39 40 mPPos[0] = 0.5*(XMin()+XMax()); 40 41 mPPos[1] = 0.5*(YMin()+YMax()); … … 79 80 80 81 81 void82 PIScDrawWdg::AddScDrawer(PIScDrawer* d, bool ad)83 {84 bool pd=false;85 if (mScDrawers.size() == 0) pd = true;86 mScDrawers.push_back(d);87 d->AttachTo(this, ad, pd);88 }89 90 void91 PIScDrawWdg::RemoveScDrawer(PIScDrawer* d)92 {93 if (padsup) return;94 vector<PIScDrawer*>::iterator drw;95 for(drw = mScDrawers.begin(); drw != mScDrawers.end(); drw++)96 if (d == (*drw)) { mScDrawers.erase(drw); break; }97 d->mDrawWdg = NULL; d->mDrawer = NULL;98 }99 100 82 int 101 PIScDrawWdg::NbScDrawers() 102 { 103 return(mScDrawers.size()); 104 } 105 106 PIScDrawer* 107 PIScDrawWdg::ScDrawer(int i) 108 { 109 if ( (i<0) || (i>mScDrawers.size()) ) return(NULL); 110 return(mScDrawers[i]); 111 } 112 113 114 void 115 PIScDrawWdg::DeleteScDrawers() 116 { 117 padsup = true; 118 vector<PIScDrawer*>::iterator i; 119 for(i = mScDrawers.begin(); i != mScDrawers.end(); i++) { 120 if ( (*i)->ADelByDrwWdg() ) delete *i; 121 } 122 mScDrawers.erase(mScDrawers.begin(),mScDrawers.end()); 123 padsup = false; 124 } 125 126 void 127 PIScDrawWdg::CallScDrawers(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax) 128 { 129 vector<PIScDrawer*>::iterator drw; 130 for(drw = mScDrawers.begin(); drw != mScDrawers.end(); drw++) { 131 g->SaveGraphicAtt(); 132 (*drw)->SelGraAtt(g); 133 (*drw)->Draw(g, xmin, ymin, xmax, ymax); 134 g->RestoreGraphicAtt(); 135 } 136 } 83 PIScDrawWdg::AddScDrawer(PIDrawer* d, bool ad) 84 { 85 return(AddDrawer(d, true, ad)); 86 } 87 137 88 138 89 void … … 161 112 { 162 113 EraseWindow(); 114 if (! LimitsFixed() ) { // On met a jour les limites a partir du premier Drawer 115 PIDrawer* drw = GetDrawer(0); 116 if (drw != NULL) { 117 drw->UpdateSize(); 118 SetLimits(drw->XMin(), drw->XMax(), drw->YMin(), drw->YMax()); 119 } 120 else SetLimits(0., 1., 0., 1.); 121 } 163 122 PIGraphicUC* guc = SetSpan(g); 164 123 DrawAxes(guc); 165 124 DrawSelf(guc, -9.e19, -9.e19, 9.e19, 9.e19); 166 CallScDrawers(guc, -9.e19, -9.e19, 9.e19, 9.e19);167 125 } 168 126 … … 170 128 PIScDrawWdg::Draw(PIGraphic* g, int x0, int y0, int dx, int dy) 171 129 { 130 EraseWindow(); 131 if (! LimitsFixed() ) { // On met a jour les limites a partir du premier Drawer 132 PIDrawer* drw = GetDrawer(0); 133 if (drw != NULL) { 134 drw->UpdateSize(); 135 SetLimits(drw->XMin(), drw->XMax(), drw->YMin(), drw->YMax()); 136 } 137 else SetLimits(0., 1., 0., 1.); 138 } 172 139 float xmin,xmax,ymin,ymax; 173 140 PIGraphicUC* guc = SetSpan(g); … … 178 145 DrawAxes(guc); 179 146 DrawSelf(guc, xmin, ymin, xmax, ymax); 180 CallScDrawers(guc, xmin, ymin, xmax, ymax);181 147 } 182 148 … … 304 270 } 305 271 272 306 273 //================================================================ 307 // PI ScDrawer274 // PIFuncDrawer 308 275 //================================================================ 309 276 310 311 312 PIScDrawer::PIScDrawer() 313 : mDrawWdg(NULL), mDrawer(NULL) 314 { 315 mADbW = mAdDO = mPrDw = false; 316 mFCol = mBCol = PI_NotDefColor; 317 mLAtt = PI_NotDefLineAtt; 318 mFSz = PI_NotDefFontSize; 319 mFAtt = PI_NotDefFontAtt; 320 mMSz = -1; 321 mMrk = PI_NotDefMarker; 322 } 323 324 PIScDrawer::~PIScDrawer() 325 { 326 if (mDrawWdg) 327 mDrawWdg->RemoveScDrawer(this); 328 } 329 330 void 331 PIScDrawer::UpdateSize() 332 { 333 // Ne fait rien ! 334 return; 335 } 336 337 void 338 PIScDrawer::Refresh() 339 { 340 // Recalcule les limites, et reaffiche 341 if (!mDrawWdg) return; 342 mDrawWdg->FreeLimits(); 343 UpdateSize(); 344 if (mDrawWdg) mDrawWdg->Refresh(); 345 } 346 347 void 348 PIScDrawer::AttachTo(PIScDrawWdg* wdg, bool ad, bool prd) 349 { 350 if (mDrawWdg) 351 mDrawWdg->RemoveScDrawer(this); 352 mDrawWdg = wdg; mDrawer = wdg->BaseDrawer(); 353 UpdateSize(); 354 mADbW = ad; 355 mPrDw = prd; 356 } 357 358 // Classe PIDrawer special pour enrober un PIScDrawer en PIDrawer 359 class PIScContDrw : public PIDrawer { 360 public : 361 PIScContDrw(PIScDrawer* d, bool ad=false); 362 virtual ~PIScContDrw(); 363 virtual void Draw(PIGraphicUC* g); 364 virtual void Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax); 365 private: 366 PIScDrawer* mScDrw; 367 bool mAD; 368 }; 369 370 PIScContDrw::PIScContDrw(PIScDrawer* d, bool ad) 371 { 372 mScDrw = d; 373 mAD=ad; 374 } 375 376 PIScContDrw::~PIScContDrw() 377 { 378 if (mAD) delete mScDrw; 379 } 380 381 void PIScContDrw::Draw(PIGraphicUC* g) 382 { 383 mScDrw->SelGraAtt(g); 384 mScDrw->Draw(g, -9.e19, -9.e19, 9.e19, 9.e19); 385 } 386 387 void PIScContDrw::Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax) 388 { 389 mScDrw->SelGraAtt(g); 390 mScDrw->Draw(g, xmin, ymin, xmax, ymax); 391 } 392 393 PIDrawer* 394 PIScDrawer::Convert() 395 { 396 PIScContDrw* rd; 397 if (mDrawWdg) mDrawWdg->RemoveScDrawer(this); 398 rd = new PIScContDrw(this); 399 mDrawWdg = NULL; mDrawer = rd; 400 UpdateSize(); 401 return((PIDrawer*)rd); 402 } 403 404 void 405 PIScDrawer::SetColAtt(PIColors fg, PIColors bg) 406 { 407 if (fg != PI_NotDefColor) mFCol = fg; 408 if (bg != PI_NotDefColor) mBCol = bg; 409 } 410 411 void 412 PIScDrawer::SetLineAtt(PILineAtt lat) 413 { 414 if (lat != PI_NotDefLineAtt) mLAtt = lat; 415 } 416 417 void 418 PIScDrawer::SetFontAtt(PIFontSize fsz, PIFontAtt fat) 419 { 420 if (fsz != PI_NotDefFontSize) mFSz = fsz; 421 if (fat != PI_NotDefFontAtt) mFAtt = fat; 422 } 423 424 void 425 PIScDrawer::SetMarkerAtt(int sz, PIMarker mrk) 426 { 427 if (sz >= 0) mMSz = sz; 428 if (mrk != PI_NotDefMarker) mMrk = mrk; 429 } 430 431 void 432 PIScDrawer::SelGraAtt(PIGraphicUC* g) 433 { 434 if (mFCol != PI_NotDefColor) g->SelForeground(mFCol); 435 if (mBCol != PI_NotDefColor) g->SelBackground(mBCol); 436 if (mLAtt != PI_NotDefLineAtt) g->SelLine(mLAtt); 437 if ( (mFSz != PI_NotDefFontSize) || (mFAtt != PI_NotDefFontAtt) ) 438 g->SelFont(mFSz, mFAtt); 439 if ( (mMrk != PI_NotDefMarker) || (mMSz >= 0) ) 440 g->SelMarker(mMSz, mMrk); 441 } 442 443 //================================================================ 444 // PIScFuncDrawer 445 //================================================================ 446 447 PIScFuncDrawer::PIScFuncDrawer(PIScFuncDrawer::FUNC f) 277 PIFuncDrawer::PIFuncDrawer(PIFuncDrawer::FUNC f) 448 278 : mFunc(f) 449 279 {} 450 280 451 PI ScFuncDrawer::~PIScFuncDrawer()452 { 453 } 454 455 void 456 PI ScFuncDrawer::Draw(PIGraphicUC* g, float /*xmin*/, float/*ymin*/, float/*xmax*/, float/*ymax*/)281 PIFuncDrawer::~PIFuncDrawer() 282 { 283 } 284 285 void 286 PIFuncDrawer::Draw(PIGraphicUC* g, float /*xmin*/, float/*ymin*/, float/*xmax*/, float/*ymax*/) 457 287 { 458 288 PIGrCoord x1, x2, y1, y2; … … 476 306 477 307 //================================================================ 478 // PI ScGFFDrawer308 // PIGFFDrawer 479 309 //================================================================ 480 310 481 PI ScGFFDrawer::PIScGFFDrawer(GeneralFunction* f)311 PIGFFDrawer::PIGFFDrawer(GeneralFunction* f) 482 312 : mFunc(f), mNParms(f->NPar()), mParms(new double[mNParms]) 483 313 { … … 485 315 } 486 316 487 PI ScGFFDrawer::~PIScGFFDrawer()317 PIGFFDrawer::~PIGFFDrawer() 488 318 { 489 319 delete[] mParms; … … 491 321 492 322 void 493 PI ScGFFDrawer::SetParms(double const* p)323 PIGFFDrawer::SetParms(double const* p) 494 324 { 495 325 for (int i=0; i<mNParms; i++) … … 499 329 500 330 void 501 PI ScGFFDrawer::Draw(PIGraphicUC* g, float /*xmin*/, float/*ymin*/, float/*xmax*/, float/*ymax*/)331 PIGFFDrawer::Draw(PIGraphicUC* g, float /*xmin*/, float/*ymin*/, float/*xmax*/, float/*ymax*/) 502 332 { 503 333 PIGrCoord x1, x2, y1, y2; -
trunk/SophyaPI/PI/piscdrawwdg.h
r88 r107 12 12 13 13 14 class PIScDrawer;15 14 16 15 class PIScDrawWdg : public PIBaseWdg { … … 36 35 void DrawAxes(PIGraphicUC* g, int flags = -1); 37 36 38 void AddScDrawer(PIScDrawer*, bool ad=false); // Ajoute un ScDrawer 39 void RemoveScDrawer(PIScDrawer*); // Ote un ScDrawer sans le detruire 40 int NbScDrawers(); 41 PIScDrawer* ScDrawer(int i); 37 int AddScDrawer(PIDrawer*, bool ad=false); // Ajoute un Drawer en auto 42 38 43 39 PIDrawer* BaseDrawer() { return mBDrw; }; … … 66 62 67 63 protected: 68 void DeleteScDrawers(); // Ote et detruit tous les ScDrawers69 void CallScDrawers(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax);70 64 PIGraphicUC* SetSpan(PIGraphicGen* g); 71 65 … … 74 68 75 69 PIDrawer* mBDrw; 76 vector<PIScDrawer*> mScDrawers;77 bool padsup;78 70 79 71 int xBegDrag, yBegDrag; … … 93 85 94 86 95 class PIScDrawer {96 public:97 PIScDrawer();98 virtual ~PIScDrawer();99 87 100 virtual void Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax) = 0; 101 virtual void UpdateSize(); // Calcule et change les limites si non fixees 102 virtual void Refresh(); // Recalcule les limites et reaffiche 103 104 PIDrawer* Convert(); 105 106 void SetColAtt(PIColors fg=PI_NotDefColor, 107 PIColors bg=PI_NotDefColor); 108 void SetLineAtt(PILineAtt lat=PI_NotDefLineAtt); 109 void SetFontAtt(PIFontSize fsz=PI_NotDefFontSize, 110 PIFontAtt fat=PI_NotDefFontAtt); 111 void SetMarkerAtt(int sz=-1, PIMarker mrk=PI_NotDefMarker); 112 113 void SelGraAtt(PIGraphicUC* g); 114 115 inline void SetAutoDelDataObj(bool ad=false) { mAdDO = ad; } 116 inline bool ADelByDrwWdg() { return mADbW; } 117 inline bool MainScDrawer() { return mPrDw; } 118 119 protected: 120 friend class PIScDrawWdg; 121 virtual void AttachTo(PIScDrawWdg*, bool, bool); 122 123 PIScDrawWdg* mDrawWdg; 124 PIDrawer* mDrawer; 125 bool mADbW, mAdDO, mPrDw; 126 PIColors mFCol, mBCol; 127 PILineAtt mLAtt; 128 PIFontSize mFSz; 129 PIFontAtt mFAtt; 130 int mMSz; 131 PIMarker mMrk; 132 }; 133 134 class PIScFuncDrawer : public PIScDrawer { 88 class PIFuncDrawer : public PIDrawer { 135 89 public: 136 90 typedef double(*FUNC)(double); 137 PI ScFuncDrawer(FUNC);138 virtual ~PI ScFuncDrawer();91 PIFuncDrawer(FUNC); 92 virtual ~PIFuncDrawer(); 139 93 140 94 virtual void Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax); … … 144 98 145 99 class GeneralFunction; 146 class PI ScGFFDrawer : public PIScDrawer {100 class PIGFFDrawer : public PIDrawer { 147 101 public: 148 PI ScGFFDrawer(GeneralFunction*);149 virtual ~PI ScGFFDrawer();102 PIGFFDrawer(GeneralFunction*); 103 virtual ~PIGFFDrawer(); 150 104 151 105 virtual void Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax); -
trunk/SophyaPI/PI/pistlist.cc
r71 r107 5 5 /* --Methode-- */ 6 6 PIStarList::PIStarList(StarList* stl, bool ad, int ayud) 7 : PI ScDrawer(), mStL(stl)7 : PIDrawer(), mStL(stl) 8 8 { 9 9 mAdDO = ad; … … 61 61 { 62 62 if (!mStL) return; 63 if (!mDrawer) return;64 if (mDrawer->LimitsFixed()) return;65 63 66 64 // Commencer par trouver nos limites … … 70 68 dy = 0.02*(mYMax-mYMin); 71 69 72 if (mDrawWdg) 73 mDrawWdg->SetLimits(mXMin-dx, mXMax+dx, mYMin-dy, mYMax+dy, kAxeDirLtoR, mAYdir); 74 else 75 mDrawer->SetLimits(mXMin-dx, mXMax+dx, mYMin-dy, mYMax+dy, false, mAYdir); 76 77 mDrawer->SetAxesFlags(kBoxAxes | kExtTicks | kLabels); 70 SetLimits(mXMin-dx, mXMax+dx, mYMin-dy, mYMax+dy, kAxeDirLtoR, mAYdir); 71 SetAxesFlags(kBoxAxes | kExtTicks | kLabels); 78 72 } 79 73 … … 89 83 90 84 if (!mStL) return; 91 if (!mDrawer) return;92 85 93 86 g->SelFont(); … … 114 107 } 115 108 116 if (!mDrawWdg) return; 117 if (!MainScDrawer()) return; 118 109 /* 119 110 sprintf(buff, "StarList: NbStars= %d NDisp= %d", (int)mStL->NbStars(), nok); 120 111 g->BaseGraphic()->DrawString(15,15,buff); 121 112 sprintf(buff, "FMin= %g FMax= %g Nl= %d Sz0= %d", mFmin, mFmax, mNLev, mMSz0); 122 113 g->BaseGraphic()->DrawString(15,30,buff); 114 */ 123 115 124 116 } -
trunk/SophyaPI/PI/pistlist.h
r71 r107 3 3 4 4 #include "stlist.h" 5 #include "pi scdrawwdg.h"5 #include "pidrawer.h" 6 6 7 class PIStarList : public PI ScDrawer {7 class PIStarList : public PIDrawer { 8 8 public: 9 9 PIStarList(StarList* stl, bool ad, int ayud=kAxeDirUpDown); … … 28 28 protected: 29 29 StarList* mStL; 30 bool mAdDO; 30 31 float mFmin, mFmax; 31 32 int mNLev, mMSz0; -
trunk/SophyaPI/PI/sc_sample.cc
r72 r107 1 #include <stdlib.h>2 #include <stdio.h>3 #include <string>4 5 1 #include "sc_sample.h" 6 2 … … 12 8 13 9 { 14 PI ScFuncDrawer * mfd;15 mfd = new PI ScFuncDrawer(f);10 PIFuncDrawer * mfd; 11 mfd = new PIFuncDrawer(f); 16 12 SetLimits(-3,3,-4,4); 17 13 AddScDrawer(mfd); … … 26 22 27 23 void 28 ScSample::DrawSelf(PIGraphicUC* g , float, float, float, float)24 ScSample::DrawSelf(PIGraphicUC* g) 29 25 { 30 26 PIGrCoord x[5] = {-2, -1., 1., 1.7, 2.2}; … … 36 32 g->DrawMarkers(x, y, 5); 37 33 g->SelForeground(PI_Magenta); 38 printf(" +DBG+ ScSample::DrawSelf - Marker(%g) \n", 0.3);39 34 g->SelMarkerSz(0.3, PI_FCircleMarker); 40 35 for(i=0; i<5; i++) -
trunk/SophyaPI/PI/sc_sample.h
r72 r107 1 //#include "pisysdep.h"1 #include "pisysdep.h" 2 2 3 3 #include "piscdrawwdg.h" … … 10 10 11 11 12 virtual void DrawSelf(PIGraphicUC* g , float, float, float, float);12 virtual void DrawSelf(PIGraphicUC* g); 13 13 14 14 };
Note:
See TracChangeset
for help on using the changeset viewer.