Changeset 505 in Sophya
- Timestamp:
- Oct 24, 1999, 5:57:21 PM (26 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/pibwdggen.cc
r329 r505 100 100 SetDefaultDrawRectangle(0., 0., 1., 1., true); 101 101 SetDefaultDrawerLimits(0., 1., 0., 1., kAxeDirLtoR, kAxeDirUpDown); 102 SetDefaultDrawerLogScale(false, false); 102 103 } 103 104 … … 316 317 // void SetDefaultDrawerLimits(double xmin, double xmax, double ymin, double ymax, - 317 318 // int axrl=kAxeDirSame, int ayud=kAxeDirSame) 318 // Définition du système de coordonnées par défaut d'un drawer attaché en "autolim=true" 319 // Définition du système de coordonnées par défaut d'un drawer attaché 320 // en "autolim=true" 321 // void SetDefaultDrawerLogScale(bool logx, bool logy) 322 // Définition d'échelle logarithmique pour le système de coordonnées par défaut 323 // d'un drawer attaché en "autolim=true". 319 324 // 320 325 //-- … … 336 341 } 337 342 343 /* --Methode-- */ 344 void PIBaseWdgGen::SetDefaultDrawerLogScale(bool logx, bool logy) 345 { 346 mDXlog = logx; 347 mDYlog = logy; 348 } 338 349 339 350 //++ … … 521 532 } 522 533 // L'ordre des operations ici est importante 523 if ( (*it).autolim ) 534 if ( (*it).autolim ) { 524 535 (*it).drw->SetLimits(mDrXmin, mDrXmax, mDrYmin, mDrYmax, mDXdir, mDYdir); 536 (*it).drw->SetLogScale(mDXlog, mDYlog); 537 } 525 538 guc = (*it).drw->SetDrwWdg(this, drx0, dry0, drdx, drdy, g); 526 539 if ((*it).clip) { g->SetClipRectangle(drx0, dry0, drdx , drdy); fgc = true; } … … 583 596 } 584 597 // L'ordre des operations ici est importante 585 if ( (*it).autolim ) 598 if ( (*it).autolim ) { 586 599 (*it).drw->SetLimits(mDrXmin, mDrXmax, mDrYmin, mDrYmax, mDXdir, mDYdir); 600 (*it).drw->SetLogScale(mDXlog, mDYlog); 601 } 587 602 guc = (*it).drw->SetDrwWdg(this, drx0, dry0, drdx, drdy, g); 588 603 if ((*it).clip) g->SetClipRectangle(drx0, dry0, drdx , drdy); -
trunk/SophyaPI/PI/pibwdggen.h
r440 r505 84 84 virtual void SetDefaultDrawerLimits(double xmin, double xmax, double ymin, double ymax, 85 85 int axrl=kAxeDirSame, int ayud=kAxeDirSame); 86 virtual void SetDefaultDrawerLogScale(bool logx, bool logy); 87 inline bool isDefaultDrawerLogScaleX() { return(mDXlog); } 88 inline bool isDefaultDrawerLogScaleY() { return(mDYlog); } 89 86 90 virtual int AddDrawer(PIDrawer* drw, PIGrCoord x1, PIGrCoord y1, 87 91 PIGrCoord x2, PIGrCoord y2, … … 117 121 double mDrXmin, mDrXmax, mDrYmin, mDrYmax; // Limites par defaut - UC 118 122 int mDXdir, mDYdir; // Sens des axes par defaut 119 123 bool mDXlog, mDYlog; // true -> echelle log - axes par defaut 120 124 }; 121 125 -
trunk/SophyaPI/PI/pidrawer.cc
r453 r505 43 43 aXdir = false; // Vrai si Axe X de Droite vers Gauche 44 44 aYdir = false; // Vrai si Axe Y de Haut vers Bas 45 aXlog = aYlog = false; // Vrai -> echelle axe logarithmique 45 46 SetLimits(-1, 1, -1, 1, kAxeDirLtoR, kAxeDirDownUp); 46 47 limitsFixed = 0; … … 76 77 //| kAxeDirLtoR , kAxeDirRtoL (Axe X) 77 78 //| kAxeDirDownUp , kAxeDirUpDown (Axe Y) 79 // void SetLogScale(bool logx, bool logy) 80 // Définition d'échelle logarithmique pour les axes X,Y. 78 81 // void GetAxesConfig(int& xa, int& ya) 79 82 // Renvoie la configuration des axes. 83 // bool isLogScaleX() isLogScaleY() 84 // Renvoie "true" si échelle logarithmique pour axe X , Y 80 85 // double XMin() XMax() 81 86 // Limites de l'axe X … … 128 133 limitsFixed = 1; 129 134 } 135 130 136 131 137 void … … 280 286 mGrUC = new PIGraphicUC(g, x0, y0, dx, dy); 281 287 mGrUC->SetUCS(xMin, xMax, yMin, yMax, aXFlg, aYFlg); 288 if (aXlog || aYlog) mGrUC->SetLogScale(aXlog, aYlog); 282 289 return(mGrUC); 283 290 } -
trunk/SophyaPI/PI/pidrawer.h
r343 r505 32 32 virtual void SetLimits(double xmin, double xmax, double ymin, double ymax, 33 33 int axrl=kAxeDirSame, int ayud=kAxeDirSame); 34 inline void SetLogScale(bool logx, bool logy) 35 { aXlog = logx; aYlog = logy; } 34 36 35 37 virtual void DrawAxes(PIGraphicUC* g); … … 48 50 inline double YMax() const {return yMax;} 49 51 50 void GetAxesConfig(int& xa, int& ya); 52 void GetAxesConfig(int& xa, int& ya); 53 inline bool isLogScaleX() { return aXlog; } 54 inline bool isLogScaleY() { return aYlog; } 55 51 56 inline unsigned int GetAxesFlags() { return(axesFlags); } 52 57 53 58 inline PIGraphicUC* GetGraphicUC() { return(mGrUC); } 54 59 … … 106 111 int xW0, yW0, xWd, yWd; // Origine/largeur ds la fenetre de trace 107 112 bool aXdir, aYdir; // Sens des axes horiz, vertical 113 bool aXlog, aYlog; // Echelle log pour les axes horiz, vertical 108 114 int aXFlg, aYFlg; 109 115 -
trunk/SophyaPI/PI/pidrwtools.cc
r391 r505 55 55 56 56 int wszx = 5*spx+3.5*bsx; 57 int wszy = ( 7+3*0.85)*(spy+bsy);57 int wszy = (8+3*0.85)*(spy+bsy); 58 58 SetSize(wszx, wszy); 59 59 … … 82 82 mCkb[0] = new PICheckBox(this,"X-RtoL", 2000, bsx, bsy, cpx, cpy); 83 83 cpx += spx+bsx; 84 mCkb[1] = new PICheckBox(this,"Y-UpDn", 200 0, bsx, bsy, cpx, cpy);84 mCkb[1] = new PICheckBox(this,"Y-UpDn", 2001, bsx, bsy, cpx, cpy); 85 85 cpx += spx+bsx; 86 mCkb[2] = new PICheckBox(this,"Grid", 200 0, bsx, bsy, cpx, cpy);86 mCkb[2] = new PICheckBox(this,"Grid", 2002, bsx, bsy, cpx, cpy); 87 87 mCkb[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 88 88 mCkb[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 89 89 mCkb[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 90 91 90 cpy += spy+bsy; 92 cpx = spx+0.25*bsx;; 91 cpx = spx+0.25*bsx; 92 mCkb[3] = new PICheckBox(this,"LogScale-X", 2003, bsx*1.5, bsy, cpx, cpy); 93 cpx += bsx*1.5+3*spx; 94 mCkb[4] = new PICheckBox(this,"LogScale-Y", 2004, bsx*1.5, bsy, cpx, cpy); 95 mCkb[3]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 96 mCkb[4]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 97 98 cpy += spy+bsy; 99 cpx = spx+0.25*bsx; 93 100 mBut[0] = new PIButton(this, "SetAxes", 2600, bsx*1.5, bsy, cpx, cpy); 94 101 cpx += bsx*1.5+3*spx; … … 257 264 } 258 265 259 for(i=0; i<3; i++) { delete mCkb[i]; delete mButcf[i]; } 266 for(i=0; i<5; i++) delete mCkb[i]; 267 for(i=0; i<3; i++) delete mButcf[i]; 260 268 delete mButcf[3]; 261 269 for(i=0; i<6; i++) delete mOpt[i]; … … 306 314 mCkb[1]->SetState(false); 307 315 mCkb[2]->SetState(false); 316 mCkb[3]->SetState(false); 317 mCkb[4]->SetState(false); 308 318 309 319 if ((mCurBW != NULL) && ( mCurBW->kind() == PIScDrawWdg::ClassId ) ) { … … 318 328 if (ya & kAxeDirUpDown) mCkb[1]->SetState(true); 319 329 if (scd->GetAxesFlags() & kGridOn) mCkb[2]->SetState(true); 330 mCkb[3]->SetState(scd->isLogScaleX()); 331 mCkb[4]->SetState(scd->isLogScaleY()); 320 332 } 321 333 else { … … 398 410 399 411 case 2600 : 412 if ( mCurBW->kind() != PIScDrawWdg::ClassId ) { 413 cerr << "PIDrwTools: SetAxes applicable to PIScDrawWdg only ! " << endl; 414 return; 415 } 400 416 sscanf(mText[0]->GetText().c_str(), "%lg %lg" , &xmin, &xmax); 401 417 sscanf(mText[1]->GetText().c_str(), "%lg %lg" , &ymin, &ymax); … … 407 423 if (mCkb[2]->GetState()) ((PIScDrawWdg*)mCurBW)->SetAxesFlags(flags | kGridOn); 408 424 else ((PIScDrawWdg*)mCurBW)->SetAxesFlags(flags & ~kGridOn); 425 ((PIScDrawWdg*)mCurBW)->SetLogScale(mCkb[3]->GetState(), 426 mCkb[4]->GetState() ); 409 427 } 410 else mCurBW->SetDefaultDrawerLimits(xmin, xmax, ymin, ymax, axrl, ayud);428 // else mCurBW->SetDefaultDrawerLimits(xmin, xmax, ymin, ymax, axrl, ayud); 411 429 mCurBW->Refresh(); 412 430 break; -
trunk/SophyaPI/PI/pidrwtools.h
r209 r505 38 38 PIButton* mBut[2]; 39 39 PIText* mText[2]; 40 PICheckBox* mCkb[ 3];40 PICheckBox* mCkb[5]; 41 41 // Pour couleur, fontes, etc 42 42 PIOptMenu* mOpt[6]; -
trunk/SophyaPI/PI/pigraphuc.cc
r453 r505 60 60 aXdir = false; // Vrai si Axe X de Droite vers Gauche 61 61 aYdir = false; // Vrai si Axe Y de Haut vers Bas 62 aXlog = aYlog = false; // Vrai -> Echelle log 62 63 SetUCS(0., 1., 0., 1., kAxeDirLtoR, kAxeDirDownUp); 64 SetLogScale(false, false); 63 65 clip = true; 64 66 } … … 111 113 // Par défaut : "xmin=ymin=0." , "ymin=ymax=0." , "kAxeDirLtoR" , "kAxeDirDownUp" 112 114 // 115 // void SetLogScale(bool logx, bool logy) 116 // Définition d'échelle logarithmique pour l'axe X,Y (si X,Ymin max > 0). 117 // Si X,Ymin max sont modifiés par SetUCS par la suite, avec des 118 // valeurs négatives, l'échelle est remise en linéaire. 119 // bool isLogScaleX() 120 // bool isLogScaleY() 121 // Renvoie "true" si échelle logarithmique pour l'axe X,Y 122 // 113 123 // void UC2GrC(double x, double y, double& xpix, double& ypix) 114 124 // Transformation de coordonnées utilisateur "(x,y)" en coordoonnées … … 176 186 else yOrg = -yMin * yScale; 177 187 yOrg += yW0; 188 if (aXlog || aYlog) SetLogScale(aXlog, aYlog); 178 189 return; 179 190 } 180 191 192 /* --Methode-- */ 193 void PIGraphicUC::SetLogScale(bool logx, bool logy) 194 { 195 if (logx) 196 if (xMax < 1.e-39) { 197 cerr << "PIGraphicUC::SetLogScale() Warning - XLogScale not valid for XMax =" 198 << xMax << " < 1.e-39" << endl; 199 logx = false; 200 } 201 if (logy) 202 if (yMax < 1.e-39) { 203 cerr << "PIGraphicUC::SetLogScale() Warning - YLogScale not valid for YMax =" 204 << yMax << " < 1.e-39" << endl; 205 logy = false; 206 } 207 208 aXlog = logx; 209 aYlog = logy; 210 211 if (aXlog) { 212 xMinLog = (xMin > 1.e-39) ? xMin : ( (1. < xMax/10.) ? 1. : xMax/10.); 213 xScaleLog = xWd*(xMax-xMinLog)/(xMax-xMin) / (log10(xMax)-log10(xMinLog)); 214 if (xScaleLog < 1.e-19) xScaleLog = 1.e-19; // Protection 215 if (aXdir) { 216 xScaleLog = -xScaleLog; 217 xOrgLog = -log10(xMax) * xScaleLog + (xOrg + xMax*xScale); 218 } 219 else xOrgLog = -log10(xMinLog) * xScaleLog + (xOrg + xMinLog*xScale); 220 } 221 else { 222 xMinLog = 1.; 223 xScaleLog = xScale; 224 xOrgLog = xW0; 225 } 226 if (aYlog) { 227 yMinLog = (yMin > 1.e-39) ? yMin : ( (1. < yMax/10.) ? 1. : yMax/10.); 228 yScaleLog = yWd*(yMax-yMinLog)/(yMax-yMin) / (log10(yMax)-log10(yMinLog)); 229 if (yScaleLog < 1.e-19) yScaleLog = 1.e-19; // Protection 230 if (!aYdir) { 231 yScaleLog = -yScaleLog; 232 yOrgLog = -log10(yMax) * yScaleLog + (yOrg + yMax*yScale); 233 } 234 else yOrgLog = -log10(yMinLog) * yScaleLog + (yOrg + yMinLog*yScale); 235 } 236 else { 237 yMinLog = 1.; 238 yScaleLog = xScale; 239 yOrgLog = xW0; 240 } 241 return; 242 } 181 243 182 244 /* --Methode-- */ 183 245 void PIGraphicUC::UC2GrC(double x, double y, double& xpix, double& ypix) 184 246 { 185 xpix = (double)(xOrg + x*xScale); 186 ypix = (double)(yOrg + y*yScale); 247 if (aXlog && (x > xMinLog)) xpix = xOrgLog + log10(x)*xScaleLog; 248 else xpix = (double)(xOrg + x*xScale); 249 if (aYlog && (y > yMinLog)) ypix = yOrgLog + log10(y)*yScaleLog; 250 else ypix = (double)(yOrg + y*yScale); 187 251 } 188 252 … … 190 254 void PIGraphicUC::GrC2UC(double xpix, double ypix, double& x, double& y) 191 255 { 192 x = (xpix-xOrg)/xScale; 193 y = (ypix-yOrg)/yScale; 256 if (!aXlog) x = (xpix-xOrg)/xScale; 257 else { 258 if ( (aXdir && (xpix < (xOrg + xMinLog*xScale))) || 259 (!aXdir && (xpix > (xOrg + xMinLog*xScale))) ) { 260 x = (xpix-xOrgLog)/xScaleLog; 261 x = pow(10., x); 262 } 263 else x = (xpix-xOrg)/xScale; 264 } 265 266 if (!aYlog) y = (ypix-yOrg)/yScale; 267 else { 268 if ( (aYdir && (ypix > (yOrg + yMinLog*yScale))) || 269 (!aYdir && (ypix < (yOrg + yMinLog*yScale))) ) { 270 y = (ypix-yOrgLog)/yScaleLog; 271 y = pow(10., y); 272 } 273 else y = (ypix-yOrg)/yScale; 274 } 275 194 276 } 195 277 -
trunk/SophyaPI/PI/pigraphuc.h
r316 r505 34 34 virtual void SetUCS(double xmin, double xmax, double ymin, double ymax, 35 35 int axrl=kAxeDirSame, int ayud=kAxeDirSame); 36 // Echelle logarithmique 37 virtual void SetLogScale(bool logx, bool logy); 38 inline bool isLogScaleX() { return aXlog; } 39 inline bool isLogScaleY() { return aYlog; } 36 40 37 41 // Trace graphiques … … 113 117 double xOrg, yOrg; // Position en pixels de (0.0, 0.0) 114 118 double xScale, yScale; // Pixels par unites graphiques 115 double xW0, yW0, xWd, yWd; // Origine/largeur ds la fenetre de trace 119 double xMinLog, yMinLog; // Limite basse (>0,x,yMin) pour echelle log 120 double xOrgLog, yOrgLog; // Position en pixels de log10(xyMinLog) 121 double xScaleLog, yScaleLog; // Pixels par unites graphiques Echelle Log 122 double xW0, yW0, xWd, yWd; // Origine/largeur ds la fenetre de trace 116 123 bool aXdir, aYdir; // Sens des axes horiz, vertical 124 bool aXlog, aYlog; // true-> Echelle logarithmique pour axe X,y 117 125 bool clip; 118 126 }; -
trunk/SophyaPI/PI/piscdrawwdg.cc
r485 r505 142 142 int axrl, int ayud, bool tmp) 143 143 { 144 if (xmax <= xmin || ymax <= ymin) 145 return; // $CHECK$ exception ? 144 if (xmax <= xmin || ymax <= ymin) { 145 cerr << "PIScDrawWdg::SetLimits() Error - xmax <= xmin or ymax <= ymin !" << endl; 146 return; 147 } 146 148 SetDefaultDrawerLimits(xmin, xmax, ymin, ymax, axrl, ayud); 147 149 mBDrw->SetLimits(xmin, xmax, ymin, ymax, axrl, ayud); -
trunk/SophyaPI/PI/piscdrawwdg.h
r343 r505 28 28 virtual void SetLimits(double xmin, double xmax, double ymin, double ymax, 29 29 int axrl=kAxeDirSame, int ayud=kAxeDirSame, bool tmp=false); 30 inline void SetLogScale(bool logx, bool logy) 31 { SetDefaultDrawerLogScale(logx, logy); } 32 inline bool isLogScaleX() { return(mDXlog); } 33 inline bool isLogScaleY() { return(mDYlog); } 34 30 35 virtual void UpdateLimits(); // Calcule et change les limites a partir de Drawer-No-1 31 36
Note:
See TracChangeset
for help on using the changeset viewer.