Changeset 2549 in Sophya


Ignore:
Timestamp:
Jun 3, 2004, 4:24:30 PM (21 years ago)
Author:
ansari
Message:

Debugging et mise au point classe PIBarGraph avec les options - Reza 3 Juin 2004

Location:
trunk/SophyaPI/PI
Files:
4 edited

Legend:

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

    r2544 r2549  
    4141  fgFill = fill;
    4242  fgHoriz = horiz;
     43  fgValLabel = false;
    4344  packFrac = 0.5;
     45  SetName("BarGraph");
    4446}
    4547
     
    8082{
    8183  double tmp = a;
    82   a = b;  b = a;
     84  a = b;  b = tmp;
    8385}
    8486
     
    109111{
    110112  PIGrCoord tmp = a;
    111   a = b;  b = a;
     113  a = b;  b = tmp;
    112114}
    113115
     
    119121  double larg = packFrac*(idMax-idMin)/mBars.size();
    120122  for(unsigned int k=0; k<mBars.size(); k++) {
     123    PIColors dcol = g->GetForeground();
    121124    x = mBars[k].id-0.5*larg; dx = larg;
    122125    y = 0.; dy = mBars[k].val;
     
    127130    } 
    128131    if (fgFill) g->DrawFBox(x,y,dx,dy);
    129     else {
    130       g->DrawBox(x,y,dx,dy);
    131       if ( mBars[k].lab.length() > 0 ) {
    132         x = mBars[k].id;
    133         y = 0.5*mBars[k].val;
    134         if (fgHoriz)
    135           g->DrawString(y, x, mBars[k].lab.c_str(),
    136                         PI_VerticalCenter|PI_HorizontalCenter|PI_TextDirectionHorizontal);
    137         else
    138           g->DrawString(x, y, mBars[k].lab.c_str(),
    139                         PI_VerticalCenter|PI_HorizontalCenter|PI_TextDirectionVerticalUp);
    140       }
    141     }
     132    else  g->DrawBox(x,y,dx,dy);
     133    if ((mBars[k].lab.length() == 0 ) && !fgValLabel ) continue;
     134    string lab = mBars[k].lab;
     135    if (fgValLabel) {
     136      char buff[32];
     137      sprintf(buff, " %g ", mBars[k].val);
     138      lab = buff;
     139    }
     140    x = mBars[k].id;
     141    y = mBars[k].val;
     142    double fy = y;
     143    bool fgneg = false;
     144    bool fgin = false;
     145    if (fy > 0.) {
     146      if (fy > mMax/2.)  { fgin = true;  fy *= 0.95; }
     147      else fy *= 1.05;
     148    }
     149    else {
     150      fgneg = true;
     151      if (fy < mMin/2.)  { fgin = true;  fy *= 0.95; }
     152      else fy *= 1.05;
     153    }
     154    y  = fy;
     155    unsigned long pflg = PI_VerticalCenter|PI_HorizontalLeft;
     156    if ( (fgin && !fgneg) || (!fgin && fgneg) ) pflg = PI_VerticalCenter|PI_HorizontalRight;
     157    if (fgHoriz)  pflg |= PI_TextDirectionHorizontal;
     158    else pflg |= PI_TextDirectionVerticalUp;
     159    if (fgHoriz)  swap_ifhoriz_g(x, y);
     160     if (fgin) g->DrawOpaqueString(x, y, lab.c_str(), pflg);
     161    else g->DrawString(x, y, lab.c_str(), pflg);
     162
     163    if (mBars[k].col != PI_NotDefColor) g->SelForeground(dcol);
    142164  }
    143165}
     
    164186    else if (opts=="fill")  SetFill(true);
    165187    else if (opts=="nofill")  SetFill(false);
    166     else if (opts=="packfrac=") {
     188    else if (opts.substr(0,9)=="packfrac=") {
    167189      double frac = atof(opts.substr(9).c_str());
    168190      SetPacking(frac);
    169191    }
     192    else if (opts=="barvaluelabel")  UseBarValueAsLabel(true);
     193    else if (opts=="nobarvaluelabel")  UseBarValueAsLabel(false);
    170194    else {
    171195      // Si option non decode
     
    187211 if (fgHoriz) opt.push_back("horizontalbars"); else opt.push_back("verticalbars");
    188212 if (fgFill) opt.push_back("fill");  else opt.push_back("nofill");
     213 if (fgValLabel) opt.push_back("barvaluelabel");  else opt.push_back("nobarvaluelabel");
    189214 char buff[64];
    190215 sprintf(buff,"packfrac=%g", packFrac);
     
    200225info += "  horizontalbars/verticalbars: set bar orientation \n";
    201226info += "  packfrac=value : set bar packing fraction (0..1) \n";
     227info += "  barvaluelabel/nobarvaluelabel: Use/Don't use bar value as labels \n";
    202228info += " --- + Usual colr/line/font  attribute decoding ... \n";
    203229PIDrawer::GetOptionsHelpInfo(info);
  • trunk/SophyaPI/PI/pibargraph.h

    r2544 r2549  
    3131  // Fraction de remplissage des bars
    3232  inline  void       SetPacking(double frac=0.5) { packFrac=frac; }
     33  // Use Bar values as labels
     34  inline  void       UseBarValueAsLabel(bool fg=true) { fgValLabel = fg; }
    3335
     36  // ------------------------------
    3437  virtual void       Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
    3538  virtual void       UpdateLimits();
     
    4952  double idMin, idMax;
    5053  bool fgFill, fgHoriz;
     54  bool fgValLabel;   // Use values as labels
    5155  double packFrac;
    5256 };
  • trunk/SophyaPI/PI/pitxtdrw.cc

    r2543 r2549  
    3939{
    4040  fgFrame = fgframe;
     41  SetName("TextDrw");
    4142}
    4243
  • trunk/SophyaPI/PI/piversion.h

    r2529 r2549  
    22#define PIVERSION_H_SEEN
    33
    4 #define PI_VERSIONNUMBER  3.97
     4#define PI_VERSIONNUMBER  3.98
    55
    66#endif
Note: See TracChangeset for help on using the changeset viewer.