Changeset 505 in Sophya


Ignore:
Timestamp:
Oct 24, 1999, 5:57:21 PM (26 years ago)
Author:
ercodmgr
Message:

Introduction d'echelle Log ds PIGraphicUC / PIScDrawWdg - Reza 24/10/99

Location:
trunk/SophyaPI/PI
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PI/pibwdggen.cc

    r329 r505  
    100100SetDefaultDrawRectangle(0., 0., 1., 1., true);
    101101SetDefaultDrawerLimits(0., 1., 0., 1., kAxeDirLtoR, kAxeDirUpDown);
     102SetDefaultDrawerLogScale(false, false);
    102103}
    103104
     
    316317// void  SetDefaultDrawerLimits(double xmin, double xmax, double ymin, double ymax, -
    317318//                              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".
    319324//
    320325//--
     
    336341}
    337342
     343/* --Methode-- */
     344void PIBaseWdgGen::SetDefaultDrawerLogScale(bool logx, bool logy)
     345{
     346mDXlog = logx;
     347mDYlog = logy;
     348}
    338349
    339350//++
     
    521532    }
    522533// L'ordre des operations ici est importante
    523   if ( (*it).autolim )  
     534  if ( (*it).autolim ) {
    524535     (*it).drw->SetLimits(mDrXmin, mDrXmax, mDrYmin, mDrYmax, mDXdir, mDYdir);     
     536     (*it).drw->SetLogScale(mDXlog, mDYlog);
     537  }
    525538  guc = (*it).drw->SetDrwWdg(this, drx0, dry0, drdx, drdy, g);
    526539  if ((*it).clip)  { g->SetClipRectangle(drx0, dry0, drdx , drdy);  fgc = true; }
     
    583596      }
    584597// L'ordre des operations ici est importante
    585     if ( (*it).autolim )
     598    if ( (*it).autolim ) {
    586599       (*it).drw->SetLimits(mDrXmin, mDrXmax, mDrYmin, mDrYmax, mDXdir, mDYdir);
     600       (*it).drw->SetLogScale(mDXlog, mDYlog);
     601    }
    587602    guc = (*it).drw->SetDrwWdg(this, drx0, dry0, drdx, drdy, g);
    588603    if ((*it).clip)  g->SetClipRectangle(drx0, dry0, drdx , drdy);
  • trunk/SophyaPI/PI/pibwdggen.h

    r440 r505  
    8484  virtual void       SetDefaultDrawerLimits(double xmin, double xmax, double ymin, double ymax,
    8585                                            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
    8690  virtual int        AddDrawer(PIDrawer* drw, PIGrCoord x1, PIGrCoord y1,
    8791                               PIGrCoord x2, PIGrCoord y2,
     
    117121  double mDrXmin, mDrXmax, mDrYmin, mDrYmax;   // Limites par defaut - UC
    118122  int  mDXdir, mDYdir;                        // Sens des axes par defaut
    119 
     123  bool mDXlog, mDYlog;                        // true -> echelle log - axes par defaut
    120124};
    121125
  • trunk/SophyaPI/PI/pidrawer.cc

    r453 r505  
    4343  aXdir = false;  // Vrai si Axe X de Droite vers Gauche
    4444  aYdir = false;  // Vrai si Axe Y de Haut vers Bas
     45  aXlog = aYlog = false;   // Vrai -> echelle axe logarithmique
    4546  SetLimits(-1, 1, -1, 1, kAxeDirLtoR, kAxeDirDownUp);
    4647  limitsFixed = 0;
     
    7677//|     kAxeDirLtoR , kAxeDirRtoL  (Axe X)
    7778//|     kAxeDirDownUp , kAxeDirUpDown (Axe Y)   
     79// void  SetLogScale(bool logx, bool logy)
     80//      Définition d'échelle logarithmique pour les axes X,Y.
    7881// void  GetAxesConfig(int& xa, int& ya)
    7982//      Renvoie la configuration des axes.
     83// bool  isLogScaleX()   isLogScaleY()
     84//      Renvoie "true" si échelle logarithmique pour axe X , Y
    8085// double XMin()  XMax()
    8186//      Limites de l'axe X
     
    128133  limitsFixed = 1;
    129134}
     135
    130136
    131137void
     
    280286  mGrUC = new PIGraphicUC(g, x0, y0, dx, dy);
    281287  mGrUC->SetUCS(xMin, xMax, yMin, yMax, aXFlg, aYFlg);
     288  if (aXlog || aYlog) mGrUC->SetLogScale(aXlog, aYlog);
    282289  return(mGrUC);
    283290}
  • trunk/SophyaPI/PI/pidrawer.h

    r343 r505  
    3232  virtual void       SetLimits(double xmin, double xmax, double ymin, double ymax,
    3333                               int axrl=kAxeDirSame, int ayud=kAxeDirSame);
     34  inline void        SetLogScale(bool logx, bool logy)
     35                             { aXlog = logx; aYlog = logy; }
    3436
    3537  virtual void       DrawAxes(PIGraphicUC* g);
     
    4850  inline double      YMax() const {return yMax;}
    4951
    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
    5156  inline unsigned int GetAxesFlags() { return(axesFlags); }
    52  
     57
    5358  inline PIGraphicUC*    GetGraphicUC() { return(mGrUC); }
    5459
     
    106111  int xW0, yW0, xWd, yWd;        // Origine/largeur ds la fenetre de trace
    107112  bool   aXdir, aYdir;           // Sens des axes horiz, vertical
     113  bool   aXlog, aYlog;           // Echelle log pour les axes horiz, vertical
    108114  int aXFlg, aYFlg;
    109115
  • trunk/SophyaPI/PI/pidrwtools.cc

    r391 r505  
    5555
    5656int wszx = 5*spx+3.5*bsx;
    57 int wszy = (7+3*0.85)*(spy+bsy);
     57int wszy = (8+3*0.85)*(spy+bsy);
    5858SetSize(wszx, wszy);
    5959
     
    8282mCkb[0] = new PICheckBox(this,"X-RtoL", 2000, bsx, bsy, cpx, cpy);
    8383cpx += spx+bsx;
    84 mCkb[1] = new PICheckBox(this,"Y-UpDn", 2000, bsx, bsy, cpx, cpy);
     84mCkb[1] = new PICheckBox(this,"Y-UpDn", 2001, bsx, bsy, cpx, cpy);
    8585cpx += spx+bsx;
    86 mCkb[2] = new PICheckBox(this,"Grid", 2000, bsx, bsy, cpx, cpy);
     86mCkb[2] = new PICheckBox(this,"Grid", 2002, bsx, bsy, cpx, cpy);
    8787mCkb[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
    8888mCkb[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
    8989mCkb[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
    90 
    9190cpy += spy+bsy;
    92 cpx = spx+0.25*bsx;;
     91cpx = spx+0.25*bsx;
     92mCkb[3] = new PICheckBox(this,"LogScale-X", 2003, bsx*1.5, bsy, cpx, cpy);
     93cpx += bsx*1.5+3*spx;
     94mCkb[4] = new PICheckBox(this,"LogScale-Y", 2004, bsx*1.5, bsy, cpx, cpy);
     95mCkb[3]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
     96mCkb[4]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
     97
     98cpy += spy+bsy;
     99cpx = spx+0.25*bsx;
    93100mBut[0] = new PIButton(this, "SetAxes", 2600, bsx*1.5, bsy, cpx, cpy);
    94101cpx += bsx*1.5+3*spx;
     
    257264  }
    258265
    259 for(i=0; i<3; i++) { delete mCkb[i];   delete mButcf[i]; }
     266for(i=0; i<5; i++) delete mCkb[i];
     267for(i=0; i<3; i++) delete mButcf[i];
    260268delete mButcf[3];
    261269for(i=0; i<6; i++)  delete mOpt[i];
     
    306314mCkb[1]->SetState(false);
    307315mCkb[2]->SetState(false);
     316mCkb[3]->SetState(false);
     317mCkb[4]->SetState(false);
    308318
    309319if ((mCurBW != NULL) && ( mCurBW->kind() == PIScDrawWdg::ClassId ) ) {
     
    318328  if (ya & kAxeDirUpDown)  mCkb[1]->SetState(true);
    319329  if (scd->GetAxesFlags() & kGridOn) mCkb[2]->SetState(true);
     330  mCkb[3]->SetState(scd->isLogScaleX());
     331  mCkb[4]->SetState(scd->isLogScaleY());
    320332  }
    321333else {
     
    398410
    399411  case 2600 :
     412    if ( mCurBW->kind() != PIScDrawWdg::ClassId ) {
     413      cerr << "PIDrwTools: SetAxes applicable to PIScDrawWdg only ! " << endl;
     414      return;
     415      }
    400416    sscanf(mText[0]->GetText().c_str(), "%lg %lg" , &xmin, &xmax);
    401417    sscanf(mText[1]->GetText().c_str(), "%lg %lg" , &ymin, &ymax);
     
    407423      if (mCkb[2]->GetState()) ((PIScDrawWdg*)mCurBW)->SetAxesFlags(flags | kGridOn);
    408424      else  ((PIScDrawWdg*)mCurBW)->SetAxesFlags(flags & ~kGridOn);
     425      ((PIScDrawWdg*)mCurBW)->SetLogScale(mCkb[3]->GetState(),
     426                                          mCkb[4]->GetState() );
    409427      }
    410     else mCurBW->SetDefaultDrawerLimits(xmin, xmax, ymin, ymax, axrl, ayud);
     428    //    else mCurBW->SetDefaultDrawerLimits(xmin, xmax, ymin, ymax, axrl, ayud);
    411429    mCurBW->Refresh();
    412430    break;
  • trunk/SophyaPI/PI/pidrwtools.h

    r209 r505  
    3838  PIButton* mBut[2];
    3939  PIText* mText[2];
    40   PICheckBox* mCkb[3];
     40  PICheckBox* mCkb[5];
    4141// Pour couleur, fontes, etc
    4242  PIOptMenu* mOpt[6];
  • trunk/SophyaPI/PI/pigraphuc.cc

    r453 r505  
    6060  aXdir = false;  // Vrai si Axe X de Droite vers Gauche
    6161  aYdir = false;  // Vrai si Axe Y de Haut vers Bas
     62  aXlog = aYlog = false;   // Vrai -> Echelle log
    6263  SetUCS(0., 1., 0., 1., kAxeDirLtoR, kAxeDirDownUp);
     64  SetLogScale(false, false);
    6365  clip = true; 
    6466}
     
    111113//      Par défaut : "xmin=ymin=0." , "ymin=ymax=0." , "kAxeDirLtoR" , "kAxeDirDownUp"
    112114//
     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//     
    113123// void  UC2GrC(double x, double y, double& xpix, double& ypix)
    114124//      Transformation de coordonnées utilisateur "(x,y)" en coordoonnées
     
    176186  else yOrg   = -yMin * yScale;
    177187  yOrg += yW0;
     188  if (aXlog || aYlog) SetLogScale(aXlog, aYlog);
    178189  return;
    179190}
    180191
     192/* --Methode-- */
     193void PIGraphicUC::SetLogScale(bool logx, bool logy)
     194{
     195if (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  }
     201if (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
     208aXlog = logx;
     209aYlog = logy;
     210
     211if (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}
     221else {
     222  xMinLog = 1.;
     223  xScaleLog = xScale;
     224  xOrgLog = xW0;
     225}
     226if (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
     236else {
     237  yMinLog = 1.;
     238  yScaleLog = xScale;
     239  yOrgLog = xW0;
     240}
     241return;
     242}
    181243
    182244/* --Methode-- */
    183245void PIGraphicUC::UC2GrC(double x, double y, double& xpix, double& ypix)
    184246{
    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); 
    187251}
    188252
     
    190254void PIGraphicUC::GrC2UC(double xpix, double ypix, double& x, double& y)
    191255{
    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
    194276}
    195277
  • trunk/SophyaPI/PI/pigraphuc.h

    r316 r505  
    3434  virtual void       SetUCS(double xmin, double xmax, double ymin, double ymax,
    3535                            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; }
    3640
    3741//  Trace graphiques
     
    113117  double xOrg, yOrg;             // Position en pixels de (0.0, 0.0)
    114118  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
    116123  bool   aXdir, aYdir;           // Sens des axes horiz, vertical
     124  bool   aXlog, aYlog;           // true-> Echelle logarithmique pour axe X,y
    117125  bool   clip;
    118126};
  • trunk/SophyaPI/PI/piscdrawwdg.cc

    r485 r505  
    142142                       int axrl, int ayud, bool tmp)
    143143{
    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    }
    146148  SetDefaultDrawerLimits(xmin, xmax, ymin, ymax, axrl, ayud);
    147149  mBDrw->SetLimits(xmin, xmax, ymin, ymax, axrl, ayud);
  • trunk/SophyaPI/PI/piscdrawwdg.h

    r343 r505  
    2828  virtual void       SetLimits(double xmin, double xmax, double ymin, double ymax,
    2929                               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
    3035  virtual void       UpdateLimits();  // Calcule et change les limites a partir de Drawer-No-1
    3136
Note: See TracChangeset for help on using the changeset viewer.