Changeset 3558 in Sophya for trunk


Ignore:
Timestamp:
Dec 24, 2008, 12:18:58 AM (17 years ago)
Author:
ansari
Message:

Amelioration gestion AutoFontSize - mis ds la classe PIDrawer - Le flag mAFsz et mFontSzF peut donc etre utilise pour autofontsize du trace des axes, mais aussi des autres drawers - Reza , 24/12/2008

Location:
trunk/SophyaPI/PI
Files:
7 edited

Legend:

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

    r3498 r3558  
    5353//++
    5454// void  DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt, \
    55 //                  unsigned int flags=kAxesDflt, bool afsz=true)
     55//                  unsigned int flags, bool afsz, double fszf)
    5656//      Trace les axes en utilisant les limites de l'objet PIGraphicUC.
    5757//      "flags" spécifie les attributs d'axes. Constantes prédéfinies:
     
    6464//|           kBoxAxes | kTicks | | kIntTicks | kLabels
    6565//|     kGridOn, kAxesNone
    66 //      Si "afsz == true", la taille de fonte est choisie automatiquement.
     66//      Si "afsz == true", la taille de fonte est choisie automatiquement avec "fszf"
     67//      representant la taille de fonte en fraction de (ymax-ymin)
     68//
     69// void DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt, unsigned int flags=kAxesDflt)
     70//        Appel de DrawXYAxes avec les parametres "axesAFSz. fontSz" de l'objet.
    6771//
    6872// void DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt, \
    6973//        double xmin, double xmax, double ymin, double ymax, \
    70 //        unsigned int flags=kAxesDflt, bool afsz=true)
     74//        unsigned int flags, bool afsz, double )
    7175//      Tracé d'axes avec spécification des limites d'axes.
     76//
     77// void DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt, \
     78//        double xmin, double xmax, double ymin, double ymax, unsigned int flags=kAxesDflt)
     79//        Appel de DrawXYAxes avec les parametres "axesAFSz. fontSz" de l'objet.
    7280//
    7381// void DrawXCaption(PIGraphicUC* g, string const& xLabel, PIGraphicAtt const& att)
     
    7987/* --Methode-- */
    8088void PIAxes::DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt,
    81                         unsigned int flags, bool afsz)
     89                        unsigned int flags, bool afsz, double fszf)
    8290{
    8391  PIGrCoord xmin, xmax, ymin, ymax;
    8492  g->GetGrSpace(xmin, xmax, ymin, ymax);
    8593  DrawXYAxes(g, gratt, (double)xmin, (double)xmax,
    86              (double)ymin, (double)ymax, flags, afsz);
     94             (double)ymin, (double)ymax, flags, afsz, fszf);
    8795}
    8896
     
    9098void PIAxes::DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt,
    9199                        double xmin, double xmax, double ymin, double ymax,
    92                         unsigned int flags, bool afsz)
     100                        unsigned int flags, bool afsz, double fszf)
    93101
    94102{
     
    107115
    108116  if(afsz) {
    109     double fsz = (yMax-yMin)*fontSz;
     117    double fsz = (yMax-yMin)*fszf;
    110118    g->SelFontSz(fsz);
    111119  }
     
    332340
    333341/* --Methode-- */
    334 void PIAxes::ConfigureAutoFontSize(double fszf)
    335 {
     342void PIAxes::ConfigureAutoFontSize(bool afsz, double fszf)
     343{
     344  axesAFSz = afsz;
    336345  if (fszf > 1.e-19) fontSz = fszf;
    337346}
  • trunk/SophyaPI/PI/piaxes.h

    r3144 r3558  
    4040
    4141  virtual void      DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt,
    42                                unsigned int flags=kAxesDflt, bool afsz=true);
     42                               unsigned int flags, bool afsz, double fszf);
     43  inline  void      DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt, unsigned int flags=kAxesDflt)
     44     { DrawXYAxes(g, gratt, flags, axesAFSz, fontSz); }
    4345
    4446  virtual void      DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt,
    4547                               double xmin, double xmax,
    4648                               double ymin, double ymax,
    47                                unsigned int flags=kAxesDflt, bool afsz=true);
    48 
     49                               unsigned int flags, bool afsz, double fszf);
     50  inline void       DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt,
     51                               double xmin, double xmax, double ymin, double ymax, unsigned int flags=kAxesDflt)
     52    {   DrawXYAxes(g, gratt, xmin, xmax, ymin, ymax, flags, axesAFSz, fontSz); }
    4953
    5054  virtual void      DrawXCaption(PIGraphicUC* g, PIGraphicAtt& att, unsigned int flags,
     
    5660  void  ConfigureTicks(int ntickx=10, int nticky=12,
    5761                       double majtl=0.016, double mintl=0.01);
    58   void  ConfigureAutoFontSize(double fszf=0.04);
     62  void  ConfigureAutoFontSize(bool afsz=true, double fszf=0.06);
    5963  void  ConfigureAxesCenter(bool fset=false,double x0=0.,double y0=0.);
    6064
     
    9195  bool   aXdir, aYdir;           // Sens des axes horiz, vertical
    9296  bool   aXlog, aYlog;           // Echelle log pour les axes horiz, vertical
    93   bool   axesAFSz;
     97  bool   axesAFSz;               // true -> AutoFontSize
    9498 
    9599  int xNTicks, yNTicks;             // Nb de ticks en X, Y
  • trunk/SophyaPI/PI/piaxestools.cc

    r2615 r3558  
    237237  mCkb[3]->SetState(scd->isLogScaleX());
    238238  mCkb[4]->SetState(scd->isLogScaleY());
    239   mCkb[7]->SetState(scd->BaseDrawer()->isAxesAutoFontSize());
     239  mCkb[7]->SetState(scd->BaseDrawer()->GetAutoFontSizeState());
    240240  }
    241241else {
     
    312312
    313313  scd->SetLogScale(mCkb[3]->GetState(), mCkb[4]->GetState() );
    314   scd->BaseDrawer()->SetAxesAutoFontSize(mCkb[7]->GetState() );
     314  scd->BaseDrawer()->ConfigureAutoFontSize(mCkb[7]->GetState(), -1);
    315315  if (refr) scd->Refresh();
    316316  return;
  • trunk/SophyaPI/PI/pidrawer.cc

    r2780 r3558  
    6565  limitsFixed = false;
    6666  SetAxesFlags(kAxesNone);   // Pas de trace d'axes par defaut
    67   SetAxesAutoFontSize();
     67  ConfigureAutoFontSize();
    6868
    6969  mDndfg = false;  // Pour controle de l'appel de Detach() si delete
     
    395395PIDrawer::DecodeOptionString(vector<string> & opt, bool rmdecop)
    396396{
    397   if (opt.size() < 1)  return(0); 
     397  int nopt0 = opt.size();
     398  if (nopt0 < 1)  return(0); 
    398399  PIGraphicAtt gratt;
    399   int ndec = gratt.DecodeAttStrings(opt, rmdecop);
     400  int ndec1 = gratt.DecodeAttStrings(opt, rmdecop);
    400401  UpdateGraphicAtt(gratt);
    401   return(ndec);
     402  if ((nopt0 - ndec1) < 1) return(ndec1);  // si tout a ete decode
     403  vector<string> udopt;
     404  unsigned int k = 0;
     405  int ndec = opt.size();
     406  string opts;
     407  for( k=0; k<opt.size(); k++ ) {
     408    opts = opt[k];
     409    if (opts.substr(0,13) == "autofontsize=") {
     410       double fszf = atof(opts.substr(13).c_str());
     411       ConfigureAutoFontSize(true, fszf);
     412    }
     413    else if (opts == "fixedfontsize")
     414       ConfigureAutoFontSize(false, -1.); 
     415    else {
     416      ndec--;
     417      if (rmdecop)  udopt.push_back(opts);
     418    }
     419  }
     420
     421  if (rmdecop)  opt = udopt;
     422  return(ndec+ndec1);
    402423}
    403424
     
    424445  info += "   FontAtt: roman, bold, italic, bolditalic  \n";
    425446  info += "   FontSize: 6,8,10,12... (pts) - integer \n";
     447  info += ">>> Automatic font size selection : \n";
     448  info += "    autofontsize=FontSizeFrac fixedfontsize \n";
     449  info += ">>> ColorTables: defcmap  grey32  invgrey32  colrj32  colbr32 \n";
    426450  info += ">>> marker=MarkerType,MarkerSize (MarkerSize: integer 3,5,7... \n";
    427451  info += "   MarkerType: dot, plus, cross, circle, fcircle, box, fbox \n";
     
    505529  PIAxes axes;
    506530  axes.DrawXYAxes(g, mGrAtt, XMin(), XMax(), YMin(), YMax(),
    507                   axesFlags, axesAFSz);
     531                  axesFlags, mAFSz, mFontSzF);
    508532  g->Clip();
    509533}
  • trunk/SophyaPI/PI/pidrawer.h

    r2780 r3558  
    3030
    3131  virtual void       SetAxesFlags(unsigned int flags=kAxesNone);
    32   inline  void       SetAxesAutoFontSize(bool fg=true) { axesAFSz = fg; }
     32
     33//  Choix automatique ou pas de taille de fonte
     34  inline void        ConfigureAutoFontSize(bool afsz=true, double fszf=0.06)
     35    { mAFSz = afsz;  if (fszf>1e-5)  mFontSzF = fszf; }
    3336
    3437  virtual void       DrawAxes(PIGraphicUC* g);
     
    6366
    6467  inline unsigned int GetAxesFlags() { return(axesFlags); }
    65   inline bool         isAxesAutoFontSize() { return axesAFSz; }
     68
     69  inline bool         GetAutoFontSizeState() { return mAFSz; }
     70  inline double       GetAutoFontSizeFraction() { return mFontSzF; }
    6671
    6772  inline PIGraphicUC*    GetGraphicUC() { return(mGrUC); }
     
    127132  bool limitsFixed;
    128133  unsigned int axesFlags;
    129   bool axesAFSz;
     134
     135  bool mAFSz;  // true -> Choix automatique de taille de font en fraction (ymax-ymin)
     136  double mFontSzF;   // TailleFonteAuto = mFontSzF*(ymax-ymin)
     137
    130138  PIBaseWdgGen* mBWdg;
    131139  PIGraphicUC* mGrUC;
  • trunk/SophyaPI/PI/pieldrw.cc

    r2797 r3558  
    593593      }
    594594    }
    595 
    596     else if (opts.substr(0,13) == "autofontsize=") {
    597       double fszf = atof(opts.substr(13).c_str());
    598       ConfigureAxeAutoFontSize(fszf);
    599       SetAxesAutoFontSize(true);
    600     }
    601     else if (opts == "fixedfontsize")
    602       SetAxesAutoFontSize(false);
    603 
     595 
    604596    else if (opts == "title" || opts == "tit") ShowTitles(true);
    605597    else if (opts == "notitle" || opts == "notit") ShowTitles(false);
     
    639631  info += "   ticks/noticks minorticks/nominorticks \n";
    640632  info += "   extticks/intticks/extintticks nbticks=X_NbTicks,Y_NbTicks \n";
    641   info += "   tickslen=MajorTickLenFrac,MinorTickLenFraC \n";
    642   info += " >> Axe label font size: \n";
     633  info += "   tickslen=MajorTickLenFrac,MinorTickLenFraC \n"; 
     634  info += " >> Axe labels font size: \n";
    643635  info += "    autofontsize=FontSizeFrac fixedfontsize \n";
    644636  info += " >> Up/Down title: title tit notitle notit \n";
     
    655647  //  g->NoClip();
    656648  axeDr.DrawXYAxes(g, mGrAtt, XMin(), XMax(), YMin(), YMax(),
    657                    axesFlags, axesAFSz);
     649                   axesFlags, mAFSz, mFontSzF);
    658650  if (showAxesLabels) {
    659651    axeDr.DrawXCaption(g, labelAtt, axesFlags, xLabel);
  • trunk/SophyaPI/PI/pieldrw.h

    r2637 r3558  
    246246                                       double majtl=0., double mintl=0.)
    247247     { axeDr.ConfigureTicks(ntickx, nticky, majtl, mintl); }
    248   inline void        ConfigureAxeAutoFontSize(double fszf=0.)
    249      { axeDr.ConfigureAutoFontSize(fszf); }
    250248
    251249  inline PIElDrwMgr& ElDrwMgr()    { return eltsMgr; }
Note: See TracChangeset for help on using the changeset viewer.