Changeset 1971 in Sophya


Ignore:
Timestamp:
Apr 30, 2002, 2:34:41 PM (23 years ago)
Author:
ansari
Message:

1/ Basculement de decodage des options de display aux methodes
PIDrawer/PIWdg::DecodeOptionString()
2/ Possibilite de Show/Hide de la partie Zoom/ColorMap/Stat du MainWindow

Reza 30/4/2002

Location:
trunk/SophyaPI/PIext
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PIext/basexecut.cc

    r1938 r1971  
    6161  nx = ny = 1;
    6262  nx = atoi(tokens[0].c_str());    ny = atoi(tokens[1].c_str());
    63   mObjMgr->SetGraphicWinZone(nx, ny, false);
     63  if (mImgApp) mImgApp->SetZone(nx, ny);
    6464  } 
    6565else if (kw == "newwin") {
     
    6868  if(tokens.size() > 0) nx = atoi(tokens[0].c_str());
    6969  if(tokens.size() > 1) ny = atoi(tokens[1].c_str());
    70   mObjMgr->SetGraphicWinZone(nx, ny, true);
     70  if (mImgApp) mImgApp->CreateGraphWin(nx, ny);
    7171  } 
    7272else if (kw == "stacknext") mImgApp->StackWinNext();
    7373else if (kw == "graphicatt") {
    7474  if (tokens.size() < 1) { cout << "Usage: graphicatt attributes_list (att=def->defaut)" << endl;  return(0); }
    75   mObjMgr->SetGraphicAttributes(tokens[0]);
    76   }
    77 else if (kw == "setxylimits") {
    78   if (tokens.size() < 4) { cout << "Usage: setxylimits xmin xmax ymin ymax" << endl;  return(0); }
    79   double xmin = atof(tokens[0].c_str());
    80   double xmax = atof(tokens[1].c_str());
    81   double ymin = atof(tokens[2].c_str());
    82   double ymax = atof(tokens[3].c_str());
    83   mImgApp->SetXYLimits(xmin, xmax, ymin, ymax);
     75  string opts = tokens[0];
     76  if (tokens.size() > 1)
     77    for(int kt=1; kt<tokens.size(); kt++)  { opts += ' '; opts += tokens[kt]; }
     78  if (mImgApp) mImgApp->SetDefaultGraphicAttributes(opts);
     79  }
     80else if (kw == "setaxesatt") {
     81  if (tokens.size() < 1) { cout << "Usage: setaxesatt attributes_list " << endl;  return(0); }
     82  string opts = tokens[0];
     83  if (tokens.size() > 1)
     84    for(int kt=1; kt<tokens.size(); kt++)  { opts += ' '; opts += tokens[kt]; }
     85  if (mImgApp) mImgApp->SetDefaultAxesAttributes(opts);
    8486  }
    8587else if (kw == "setinsetlimits") {
     
    9193  mImgApp->SetInsetLimits(xmin, xmax, ymin, ymax);
    9294  }
    93 else if (kw == "setimgcenter") {
    94   if (tokens.size() < 2) { cout << "Usage: setimgcenter xc yc" << endl;  return(0); }
    95   int xc = atoi(tokens[0].c_str());
    96   int yc = atoi(tokens[1].c_str());
    97   mImgApp->SetImageCenterPosition(xc, yc);
    98   }
    9995else if (kw == "addtext") {
    10096  if (tokens.size() < 3) { cout << "Usage: addtext x y txt [colfontatt]" << endl;  return(0); }
     
    10298  double yp = atof(tokens[1].c_str());
    10399  string txt = tokens[2];
    104   bool fgsr = false;
    105   if (tokens.size() > 3)
    106     mObjMgr->GetServiceObj()->DecodeDispOption(tokens[3], fgsr);
    107   mImgApp->AddText(txt, xp, yp);
    108   if (fgsr) mImgApp->RestoreGraphicAtt();
     100  string sop;
     101  if (tokens.size() > 3) sop = tokens[3];
     102  mImgApp->AddText(txt, xp, yp, sop);
    109103  }
    110104else if ((kw == "addline") || (kw == "addrect") || (kw == "addfrect")) {
     
    114108  double xp2 = atof(tokens[2].c_str());
    115109  double yp2 = atof(tokens[3].c_str());
    116   bool fgsr = false;
    117   if (tokens.size() > 4)
    118    mObjMgr->GetServiceObj()->DecodeDispOption(tokens[4], fgsr);
    119   if (kw == "addline") mImgApp->AddLine(xp1, yp1, xp2, yp2);
     110  string sop;
     111  if (tokens.size() > 4) sop = tokens[4];
     112  if (kw == "addline") mImgApp->AddLine(xp1, yp1, xp2, yp2, sop);
    120113  else {
    121114    bool fgfill = (kw == "addrect") ? false : true;
    122     mImgApp->AddRectangle(xp1, yp1, xp2, yp2, fgfill);
    123   }
    124   if (fgsr) mImgApp->RestoreGraphicAtt();
     115    mImgApp->AddRectangle(xp1, yp1, xp2, yp2, sop, fgfill);
     116  }
    125117  }
    126118else if ((kw == "addcirc") || (kw == "addfcirc")) {
     
    130122  double rad = atof(tokens[2].c_str());
    131123  bool fgsr = false;
    132   if (tokens.size() > 3)
    133     mObjMgr->GetServiceObj()->DecodeDispOption(tokens[3], fgsr);
     124  string sop;
     125  if (tokens.size() > 3) sop = tokens[3];
    134126  bool fgfill = (kw == "addcirc") ? false : true;
    135   mImgApp->AddCircle(xc, yc, rad, fgfill);
    136   if (fgsr) mImgApp->RestoreGraphicAtt();
     127  mImgApp->AddCircle(xc, yc, rad, sop, fgfill);
    137128  }
    138129
     
    141132  if (tokens.size() < 1) { cout << "Usage: settitle TopTitle [BotTitle] [fontatt]" << endl;  return(0); }
    142133  bool fgsr = true;
    143   if (tokens.size() > 2)
    144     mObjMgr->GetServiceObj()->DecodeDispOption(tokens[2], fgsr);
    145   if (tokens.size() < 2)
    146     tokens.push_back("");
    147134  mImgApp->SetTitle(tokens[0], tokens[1]);
    148   if (fgsr) mImgApp->RestoreGraphicAtt();
    149135  }
    150136 
     
    397383    }
    398384  else {
    399     if (tokens.size() < 5)  tokens.push_back("n");
     385    if (tokens.size() < 5)  tokens.push_back("next");
    400386    mObjMgr->GetServiceObj()->PlotFunc2D(tokens[3], tokens[0], xmin, xmax, ymin, ymax,
    401387                                         nx, ny, tokens[4]);
     
    415401else if ( (kw == "disp") || (kw == "surf") || (kw == "imag") ) {
    416402  if (tokens.size() < 1) { cout << "Usage: disp/surf/imag nameobj [opt]" << endl; return(0); }
    417   string opt = "n";
     403  string opt = "next";
    418404  if (tokens.size() > 1)  opt = tokens[1];
    419405  if (kw == "disp") mObjMgr->DisplayObj(tokens[0], opt);
     
    457443  string numvary = "";
    458444  string err = "";
    459   string opt = "n";
     445  string opt = "next";
    460446  if(tokens.size()>2) err = tokens[2];
    461447  if(tokens.size()>3) opt = tokens[3];
     
    468454     return(0);}
    469455  string err = "";
    470   string opt = "n";
     456  string opt = "next";
    471457  if(tokens.size()>3) err = tokens[3];
    472458  if(tokens.size()>4) opt = tokens[4];
     
    767753kw = "graphicatt";
    768754usage = "To change default graphic options \n  Usage: graphicatt att_list \n";
    769 usage += "att_list=def back to default values, Example: gratt red,circlemarker5";
     755usage += "att_list=def back to default values, Example: gratt 'red circlemarker5'";
    770756usage += "\n ------------------ Graphic attribute list ------------------ \n";
    771757usage += ">> Colors: defcol black white grey red blue green yellow \n";
     
    791777usage += ">> ZoomFactors: defzoom zoomx1 zoomx2 zoomx3 zoomx4 zoomx5 \n";
    792778usage += "                               zoom/2 zoom/3 zoom/4 zoom/5 \n";
    793 usage += ">> Image centering: centerimg -> Position the image in widget \n";
     779usage += ">> imagecenter=ix,iy -> Position the image in widget \n";
    794780usage += ">> Axes:  stdaxes=defaxes=boxaxes  simpleaxes boxaxesgrid \n";
    795 usage += "          fineaxes  grid=fineaxesgrid \n";
     781usage += "          fineaxes  fineaxesgrid \n";
    796782usage += ">> LogScale : linx liny logx logy -> Lin/Log Scales for 2D plots \n";
    797783usage += ">> XYLimits : xylimits  -> Forces X-Y limits in 2-D plots \n";
     
    799785usage += ">> title/notitle or tit/notit -> Toggle Auto AddTitle flag \n";
    800786usage += ">> DisplayWindow: next same win stack inset \n";
    801 usage += "   Related commands: setxylimits setinsetlimits setimgcenter"; 
     787usage += "   Related commands: setaxesatt setinsetlimits "; 
    802788mpiac->RegisterCommand(kw, usage, this, "Graphics");
    803789
    804 kw = "setxylimits";
    805 usage = "Define 2-D plot limits \n Usage: setxylimits xmin xmax ymin ymax";
    806 usage += "\n  Related commands: graphicatt /xylimits"; 
     790kw = "setaxesatt";
     791usage = "To set default axes attributes \n  Usage: setaxesatt att_list \n";
     792usage += ">> Axes:  stdaxes=defaxes=boxaxes  simpleaxes boxaxesgrid \n";
     793usage += "          fineaxes  fineaxesgrid \n";
     794usage += ">> LogScale : linx liny logx logy -> Lin/Log Scales for 2D plots \n";
     795usage += ">> xylimits=xmin,xmax,ymin,ymax  -> Forces X-Y limits in 2-D plots \n";
    807796mpiac->RegisterCommand(kw, usage, this, "Graphics");
     797
    808798
    809799kw = "setinsetlimits";
  • trunk/SophyaPI/PIext/contmodex.cc

    r1920 r1971  
    106106   // On affiche le Drawer
    107107   int wrsid = 0;
    108    bool fgsr = true;
    109    cout << " dopt " << dopt<<endl;
    110    int opt = omg.GetServiceObj()->DecodeDispOption(dopt, fgsr);
    111108   
    112109   string name = "contour";
    113    cout << " ContModExecutor::Execute() : name "<<name<<" " <<" opt |"<<opt<<"| dopt |"<<dopt<<"| contdrw |"<<contdrw<<endl;
    114    wrsid = omg.GetImgApp()->DispScDrawer(contdrw, name, opt);
     110   cout << " ContModExecutor::Execute() : name "<<name<<" " <<"| dopt |"<<dopt<<"| contdrw |"<<contdrw<<endl;
     111   wrsid = omg.GetImgApp()->DispScDrawer(contdrw, name, dopt);
    115112   cout << " fin de ContModExecutor::Execute() "<< endl;
    116113   
    117114
    118    if (fgsr) omg.GetImgApp()->RestoreGraphicAtt();   
    119115   // Ne pas oublier d'associer le wrsid a l'objet si on utilise le P2DArrayAdapter* arr
    120    // Il semble que cela ne soit pas accessible pour le moment depuis l'exterieur ds NamedObjMgr
    121 
    122 
    123 
     116   omg.AddWRsId(tokens[0], wrsid);
     117   
    124118
    125119   }
     
    180174     bool fgsr = true;
    181175     
    182      int opt = omg.GetServiceObj()->DecodeDispOption(dopt, fgsr);
    183    
    184176     string name = "contour";
    185177     
    186      wrsid = omg.GetImgApp()->DispScDrawer(contdrw, name, opt);
     178     wrsid = omg.GetImgApp()->DispScDrawer(contdrw, name, dopt);
    187179     
    188      
    189 
    190      if (fgsr) omg.GetImgApp()->RestoreGraphicAtt();   
     180     // Ne pas oublier d'associer le wrsid a l'objet si on utilise le P2DArrayAdapter* arr
     181     omg.AddWRsId(tokens[0], wrsid);
    191182
    192183   }
  • trunk/SophyaPI/PIext/flowmodex.cc

    r1925 r1971  
    8989   // On affiche le Drawer
    9090   int wrsid = 0;
    91    bool fgsr = true;
    92    int opt = omg.GetServiceObj()->DecodeDispOption(dopt, fgsr);
    93    
    9491   string name = "ChampVec";
    9592   
    96    wrsid = omg.GetImgApp()->DispScDrawer(p2dv , name, opt);
     93   wrsid = omg.GetImgApp()->DispScDrawer(p2dv , name, dopt);
     94   omg.AddWRsId(tokens[0], wrsid);
    9795
    9896}else if(kw == "plot2dvec"){
     
    140138  p2dv->SelectVW(ntn[2],ntn[3]);
    141139
    142   bool fgsr = true;
    143140  if (tokens.size() > 6) dopt = tokens[6];
    144141
    145   int opt = omg.GetServiceObj()->DecodeDispOption(dopt, fgsr);
    146142  string name = "ChampVec";
    147143   
    148   int wrsid = omg.GetImgApp()->DispScDrawer(p2dv , name, opt);
     144  int wrsid = omg.GetImgApp()->DispScDrawer(p2dv , name, dopt);
    149145
    150146}
  • trunk/SophyaPI/PIext/nobjmgr.cc

    r1905 r1971  
    11351135
    11361136int wrsid = 0;
    1137 bool fgsr = true;
    1138 int opt = servnobjm->DecodeDispOption(dopt, fgsr);
    11391137
    11401138string n1,r1;
     
    11431141if (dr) {
    11441142  PIDrawer3D * dr3 = dynamic_cast<PIDrawer3D *>(dr);
    1145   if(dr3)  wrsid = myImgApp->Disp3DDrawer(dr3, n1, opt);
    1146   else wrsid = myImgApp->DispScDrawer( dr, n1, opt);
    1147   }
    1148 else if (arr) wrsid = myImgApp->DispImage(arr, n1, opt);
     1143  if(dr3)  wrsid = myImgApp->Disp3DDrawer(dr3, n1, dopt);
     1144  else wrsid = myImgApp->DispScDrawer( dr, n1, dopt);
     1145  }
     1146else if (arr) wrsid = myImgApp->DispImage(arr, n1, dopt);
    11491147
    11501148if(wrsid != 0) {
     
    11531151  (*it).second.wrsid.push_back(wrsid);
    11541152  }
    1155 if (fgsr) myImgApp->RestoreGraphicAtt();
     1153
    11561154return;
    11571155}
     
    11841182
    11851183int wrsid = 0;
    1186 bool fgsr = true;
    1187 int opt = servnobjm->DecodeDispOption(dopt, fgsr);
    1188 wrsid = myImgApp->DispImage(arr, n1, opt);
     1184wrsid = myImgApp->DispImage(arr, n1, dopt);
    11891185
    11901186if(wrsid != 0) {
     
    11931189  (*it).second.wrsid.push_back(wrsid);
    11941190  }
    1195 if (fgsr) myImgApp->RestoreGraphicAtt();
    11961191return;
    11971192}
     
    12301225
    12311226int wrsid = 0;
    1232 bool fgsr = true;
    1233 int opt = servnobjm->DecodeDispOption(dopt, fgsr);
    12341227PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
    1235 wrsid = myImgApp->Disp3DDrawer(sdr, n1, opt);
     1228wrsid = myImgApp->Disp3DDrawer(sdr, n1, dopt);
    12361229if(wrsid >= 0) {
    12371230  NObjList::iterator it = myObjs->find(nom);
     
    12401233  }
    12411234
    1242 if (fgsr) myImgApp->RestoreGraphicAtt(); 
    12431235return;
    12441236}
     
    12651257
    12661258int wrsid = 0;
    1267 bool fgsr = true;
    1268 dopt = "defline," + dopt;
    1269 int opt = servnobjm->DecodeDispOption(dopt, fgsr);
     1259dopt = "defline " + dopt;
    12701260
    12711261string n1,r1;
     
    12791269  pin->SelectErrBar(erx.c_str(), ery.c_str(), erz.c_str());
    12801270  string titre = nmz + "%" + nmy + "%" + nmz;
    1281   wrsid = myImgApp->Disp3DDrawer(pin, n1, opt, titre); 
     1271  wrsid = myImgApp->Disp3DDrawer(pin, n1, dopt, titre); 
    12821272}
    12831273else {
    12841274  PINTuple* pin = new PINTuple(nt, false);
    1285   pin->SetStats(Services2NObjMgr::GetStatsOption(dopt));
    12861275  pin->SelectXY(nmx.c_str(), nmy.c_str());
    12871276  pin->SelectWt(wt.c_str());
     
    12891278  pin->SelectErrBar(erx.c_str(), ery.c_str());
    12901279  string titre = nmy + "%" + nmx;
    1291   wrsid = myImgApp->DispScDrawer( (PIDrawer*)pin, n1, opt, titre);
     1280  wrsid = myImgApp->DispScDrawer( (PIDrawer*)pin, n1, dopt, titre);
    12921281  }
    12931282
     
    12981287  }
    12991288
    1300 if (fgsr) myImgApp->RestoreGraphicAtt();
    13011289return;
    13021290}
     
    13261314   return;}
    13271315
    1328 // Decodage des options classiques
    1329 bool fgsr = true;
    1330 int opt = servnobjm->DecodeDispOption(dopt, fgsr);
    13311316// Decodage des erreurs a representer
    13321317bool errx=false, erry=false, errz=false;
     
    13501335  pigfd->SelectXY(numvx,numvy);
    13511336  pigfd->SelectErrBar(errx,erry,errz);
    1352   wrsid = myImgApp->Disp3DDrawer(pigfd,n1,opt); 
     1337  wrsid = myImgApp->Disp3DDrawer(pigfd,n1,dopt); 
    13531338} else {                   // display 2D
    13541339  PIGenFitDat* pigfd = new PIGenFitDat(((GeneralFitData*)obj),false);
    13551340  pigfd->SelectX(numvx);
    13561341  pigfd->SelectErrBar(errx,erry);
    1357   wrsid = myImgApp->DispScDrawer((PIDrawer*)pigfd,n1,opt);
     1342  wrsid = myImgApp->DispScDrawer((PIDrawer*)pigfd,n1,dopt);
    13581343}
    13591344
     
    13631348  (*it).second.wrsid.push_back(wrsid);
    13641349}
    1365 if (fgsr) myImgApp->RestoreGraphicAtt();
     1350
    13661351return;
    13671352}
     
    14241409PIYfXDrawer * vxydrw = new PIYfXDrawer(avx, avy, true);
    14251410
    1426 // Decodage des options classiques
    1427 bool fgsr = true;
    1428 int opt = servnobjm->DecodeDispOption(dopt, fgsr);
    14291411string nx,rx;
    14301412ParseObjectName(nomvx, rx, nx);
     
    14341416string title = ny + " (Y) vs. " + nx + " (X)";
    14351417// display 2D
    1436 int wrsid = myImgApp->DispScDrawer(vxydrw, title, opt);
    1437 
    1438 if (fgsr) myImgApp->RestoreGraphicAtt();
     1418int wrsid = myImgApp->DispScDrawer(vxydrw, title, dopt);
     1419
    14391420return;
    14401421
     
    14521433
    14531434
    1454 /* --Methode-- */
     1435/* --Methode--
    14551436void NamedObjMgr::SetGraphicAttributes(string gratt)
    14561437{
     
    14601441}
    14611442
    1462 /* --Methode-- */
    14631443void NamedObjMgr::SetGraphicWinZone(int nzx, int nzy, bool fcr)
    14641444{
     
    14671447else myImgApp->SetZone(nzx, nzy);
    14681448}
     1449*/
    14691450
    14701451/* --Methode-- */
  • trunk/SophyaPI/PIext/nobjmgr.h

    r1525 r1971  
    9292  virtual void          DisplayVector(string & nomvx, string& nomvy, string dopt="");
    9393
    94   virtual void          SetGraphicAttributes(string gratt="");
    95   virtual void          SetGraphicWinZone(int nzx, int nzy, bool fcr=false);
    96 
    9794
    9895// Acces au PIApplication et a la classe de service
  • trunk/SophyaPI/PIext/nomhistadapter.cc

    r1321 r1971  
    7979PIDrawer* NOMAdapter_Histo::GetDrawer(string & dopt)
    8080{
    81 if (typeid(*mHis) == typeid(HProf))  dopt = "fcirclemarker5," + dopt;
    82 else dopt = "thinline," + dopt;
     81if (typeid(*mHis) == typeid(HProf))  dopt = "fcirclemarker5 " + dopt;
     82else dopt = "thinline " + dopt;
    8383PIHisto * pih = new PIHisto(mHis, false);
    84 pih->SetStats(Services2NObjMgr::GetStatsOption(dopt));
    8584return( pih );
    8685}
     
    252251PIDrawer* NOMAdapter_Histo2D::GetDrawer(string & dopt)
    253252{
    254 dopt = "thinline," + dopt;
     253dopt = "thinline " + dopt;
    255254return( new PIHisto2D(mHis, false) );
    256255}
  • trunk/SophyaPI/PIext/nommatvecadapter.cc

    r1905 r1971  
    6868PIDrawer* NOMAdapter_Vector::GetDrawer(string & dopt)
    6969{
    70 dopt = "thinline," + dopt;
     70dopt = "thinline " + dopt;
    7171return( new PIYfXDrawer( new POVectorAdapter(mVec, false), NULL, true) );
    7272}
  • trunk/SophyaPI/PIext/nomtmatvecadapter.cc

    r1905 r1971  
    141141if (v == NULL) return(NULL);
    142142else {
    143   dopt = "thinline," + dopt;
     143  dopt = "thinline " + dopt;
    144144  return( new PIYfXDrawer( new POTVectorAdapter<T>(v, false), NULL, true) );
    145145  }
  • trunk/SophyaPI/PIext/piaversion.h

    r1565 r1971  
    22#define PIAPPVERSION_H_SEEN
    33
    4 #define PIAPP_VERSIONNUMBER  3.20
     4#define PIAPP_VERSIONNUMBER  3.40
    55
    66#endif
  • trunk/SophyaPI/PIext/pihisto.cc

    r1905 r1971  
    133133}
    134134
     135int
     136PIHisto::DecodeOptionString(vector<string> & opt, bool rmdecopt)
     137{
     138  if (opt.size() < 1)  return(0); 
     139  int ndec1 = PIDrawer::DecodeOptionString(opt, rmdecopt);
     140  if ((opt.size() - ndec1) < 1) return(ndec1);  // si tout a ete decode
     141
     142  vector<string> udopt;  // On gardera ici les options non decodees
     143  unsigned int k = 0;
     144  int ndec = opt.size();
     145  for( k=0; k<opt.size(); k++ ) {
     146    string opts = opt[k];
     147    if (opts == "stat")  SetStats(true);
     148    else if (opts == "nostat")  SetStats(false);
     149    else {
     150      ndec--;
     151      // S'il faut supprimer les options decodees
     152      if (rmdecopt)  udopt.push_back(opts);
     153    }
     154  } 
     155  // S'il faut supprimer les options decodees, on remplace l'argument opt
     156  // par le vecteur des options non decodees.
     157  if (rmdecopt)  opt = udopt;
     158  return(ndec+ndec1); 
     159}
     160
    135161void
    136162PIHisto::DrawStats(PIGraphicUC* g)
  • trunk/SophyaPI/PIext/pihisto.h

    r546 r1971  
    1717  inline  Histo*     Histogram() { return(mHisto); }
    1818
     19//   Methode de decodage des options
     20  virtual int        DecodeOptionString(vector<string> & opt, bool rmdecopt=true);
     21
    1922protected:
    2023  virtual void       DrawStats(PIGraphicUC* g);
  • trunk/SophyaPI/PIext/pintuple.cc

    r1920 r1971  
    259259return;
    260260}
     261
     262/*  La methode DecodeOptionString permet de decoder un ensemble d'options
     263    et de parametre d'affichage specifie sous forme d'un vecteur de string.
     264    Si rmdecopt == true, les options decodees sont supprimees du vecteur
     265    de string fourni en entree - ce qui permet l'enchainement eventuel
     266    de plusieurs decodages de string.
     267    Les options peuvent etre sous forme de flag : "stat" "nostat"
     268    ou plus complexes, par exemple "dynamic=-3,3"
     269    Rc: La methode renvoie le nombre d'options decodees
     270*/
     271
     272/* --Methode-- */
     273int PINTuple::DecodeOptionString(vector<string> & opt, bool rmdecopt)
     274{
     275  if (opt.size() < 1)  return(0); 
     276  // On appelle d'abord le decodage de la classe PIDrawer de laquelle
     277  // on herite. (Pas obligatoire) on decode donc ici les attributs de
     278  // couleur, fontes ...
     279  int ndec1 = PIDrawer::DecodeOptionString(opt, rmdecopt);
     280  if ((opt.size() - ndec1) < 1) return(ndec1);  // si tout a ete decode
     281
     282  vector<string> udopt;  // On gardera ici les options non decodees
     283  unsigned int k = 0;
     284  int ndec = opt.size();
     285  for( k=0; k<opt.size(); k++ ) {
     286    string opts = opt[k];
     287    if (opts == "stat")  SetStats(true);
     288    else if (opts == "nostat")  SetStats(false);
     289    else {
     290      // Si option non decode
     291      ndec--;
     292      // S'il faut supprimer les options decodees
     293      if (rmdecopt)  udopt.push_back(opts);
     294    }
     295  } 
     296  // S'il faut supprimer les options decodees, on remplace l'argument opt
     297  // par le vecteur des options non decodees.
     298  if (rmdecopt)  opt = udopt;
     299  return(ndec+ndec1); 
     300}
  • trunk/SophyaPI/PIext/pintuple.h

    r546 r1971  
    1414  virtual           ~PINTuple();
    1515 
     16
    1617  virtual void       Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
    1718  virtual void       UpdateLimits();
     
    2425  inline  void       SetStats(bool fg=true) { stats = fg; }
    2526  virtual void       AppendTextInfo(string& info, double xmin, double ymin, double xmax, double ymax);
     27
     28//   Methode de decodage des options
     29  virtual int        DecodeOptionString(vector<string> & opt, bool rmdecopt=true);
    2630       
    2731protected:
  • trunk/SophyaPI/PIext/pistdimgapp.cc

    r1905 r1971  
    9393m[3]->AppendItem("Window", 10411);
    9494m[3]->AppendItem("Window 2x1", 10421);
    95 m[3]->AppendItem("Window 1x2", 10412);
     95// m[3]->AppendItem("Window 1x2", 10412);
    9696m[3]->AppendItem("Window 2x2", 10422);
    97 m[3]->AppendItem("Window 3x1", 10431);
     97// m[3]->AppendItem("Window 3x1", 10431);
    9898m[3]->AppendItem("Window 3x3", 10433);
    9999m[3]->AppendItem("Cur->LastWdg", 10441);
    100100m[3]->AppendItem("Close CurWin", 10460);
     101m[3]->AppendCheckItem("StatZoomWin", 10470);
     102m[3]->SetStateMsg(10470, true);
    101103
    102104m[4] = new PIMenu(Menubar(),"PostScript");
     
    138140MainWin()->SetSize(msx, msy);
    139141
     142//------------------------------------------------------
     143// On cree un container intermediaire permettant de gerer
     144// le widget zoom, colormap, stats, ...
     145
    140146int bss = 100+mFgScSz*15;
    141 gimv = new PIPixmap(MainWin(), "GloV", bss, bss, 5, 5);
     147
     148int statc_szy = bss+10+14+mFgScSz*2+5;
     149statcont = new PIContainer(MainWin(), "ZGCSCont", msx, statc_szy, 0, 0);
     150statcont->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free);
     151
     152gimv = new PIPixmap(statcont, "GloV", bss, bss, 5, 5);
    142153gimv->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_free, PIBK_free);
    143 zoom = new PIPixmap(MainWin(), "Zoom", bss, bss, bss+10, 5);
     154zoom = new PIPixmap(statcont, "Zoom", bss, bss, bss+10, 5);
    144155zoom->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_free, PIBK_free);
    145 cmapv = new PICMapView(MainWin(), "CMapView", msx-10, 14+mFgScSz*2, 5, bss+10);
     156cmapv = new PICMapView(statcont, "CMapView", msx-10, 14+mFgScSz*2, 5, bss+10);
    146157cmapv->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free);
    147 
    148 int cpy = bss+10+14+mFgScSz*2+5;
     158labstat = new PILabel(statcont, "statlabel", msx-2*(bss+20), 20, 2*bss+20, 10);
     159labstat->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free);
     160labstat->SetLabel("Stat-Zoom-ColMap Window");
     161labstat->SetForegroundColor(PI_Red);
     162labstat->SetBorderWidth(1);
     163statcont->Show();
     164// StatZoomWindowSetVisible(true);
     165//------------------------------------------------------
     166
     167//int cpy = bss+10+14+mFgScSz*2+5;
     168int cpy = statc_szy;
    149169
    150170// Creation d'une console avec gestion des commandes 
    151 mCons = new PIConsole(MainWin(), "Console", 30200, 512, 132, msx, msy-cpy, 0, cpy );
     171consolecont = new PIContainer(MainWin(), "ConsoleCont", msx, msy-cpy, 0, cpy );
     172consolecont->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_fixed);
     173mCons = new PIConsole(consolecont, "Console", 30200, 512, 132, msx, msy-cpy, 0, 0 );
    152174mCons->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_fixed);
    153175mCons->AcceptCmd(true, 50);
     176consolecont->Show();
    154177redirecout = false;
    155178// RedirectStdOutErr(true);  pas par defaut
     
    200223
    201224// Attributs graphiques courants
    202 mFCol = mBCol = PI_NotDefColor;
    203 mLAtt = PI_NotDefLineAtt;
    204 mFName = PI_DefaultFont;   
    205 mFSz = PI_NotDefFontSize;
    206 mFAtt = PI_NotDefFontAtt;
    207 mMSz = -1;
    208 mMrk = PI_NotDefMarker;
    209 mCmapid = CMAP_OTHER;
    210 mRevCmap = false;
    211 mZoom = 0;
    212225mAxesFlags = kBoxAxes | kExtTicks | kLabels;
    213 SetXYLimits(-1, 1., -1., 1.);
    214 mFXYlim = false;
    215226SetInsetLimits(0.4, 0.6, 0.4, 0.6);
    216 SetImageCenterPosition(-1,-1);
    217 mFImgCenter = false;
    218 maXlog = maYlog = false;
    219227mAddTitle = true;
    220 SaveGraphicAtt();
    221228
    222229// Initialisation
     
    269276delete gimv;
    270277delete cmapv;
     278delete labstat;
     279
     280delete statcont;
    271281
    272282delete pfc_fits;
     
    275285
    276286delete mCons;
     287 delete consolecont;
    277288
    278289delete mObjmgrw;
     
    449460
    450461/* --Methode-- */
    451 int PIStdImgApp::DispImage(P2DArrayAdapter* nouv, string const & name, int opt, int oid)
     462int PIStdImgApp::DispImage(P2DArrayAdapter* nouv, string const & name, string const& sop, int oid)
    452463{
    453464PIImage* pii;
     
    468479  }
    469480
    470 int zm = 1;
    471 if (mZoom == 0) {  // Facteur de zoom auto
    472   zm = (nouv->XSize() > nouv->YSize()) ? nouv->XSize() :  nouv->YSize();
    473   zm = (zm >= 250) ? 250/zm : 1;
    474   }
    475 else zm = mZoom;
    476 
    477 if (zm == 0)  zm = 1;
    478 if (zm < -10)  zm = -10;
    479 if (zm > 10)  zm = 10;
    480 
    481 if (zm > 0)  { sx = nouv->XSize()*zm;  sy = nouv->YSize()*zm; }
    482 else  {
    483   sx = (int)((float)nouv->XSize()*(-1./float(zm))); 
    484   sy = (int)((float)nouv->YSize()*(-1./float(zm)));
    485   }
     481// On decode les options graphiques
     482vector<string> opts;
     483DispWinEnum dwopt = ParseDisplayOption(sop, opts);
     484
     485// Pas de same ou inset pour DispImage
     486if ((dwopt == Disp_Same) || (dwopt == Disp_Inset) ) dwopt = Disp_Next;
     487
     488// Choix de la taille de fenetre
     489#define MINPIIMGSIZE 100
     490sx = (nouv->XSize() > MINPIIMGSIZE) ? nouv->XSize() : MINPIIMGSIZE;
     491sy = (nouv->YSize() > MINPIIMGSIZE) ? nouv->XSize() : MINPIIMGSIZE;
    486492if (sx > 400+mFgScSz*100) sx = 400+mFgScSz*100;
    487493if (sy > 400+mFgScSz*100) sy = 400+mFgScSz*100;
    488494px = py = 0;
    489 win = GetWindow(opt, sx, sy, px, py, flag, (char *)name.c_str());
     495win = GetWindow(dwopt, sx, sy, px, py, flag, (char *)name.c_str());
    490496pii = new PIImage(win, (char *)name.c_str(), sx, sy, px,py);
    491497pii->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
     
    493499pii->SetGloVWin(gimv, false);
    494500pii->SetCMapWin(cmapv, false);
    495 pii->SetZoom(zm, false);
    496 if ( mCmapid != CMAP_OTHER ) pii->SetColMapId(mCmapid, mRevCmap, false);
    497501pii->ShowCursor(true);
    498502pii->SetUserData(NULL, oid);
    499 // Centrage eventuel du pave
    500 if (mFImgCenter && (mXImgCenter > 0) && (mYImgCenter > 0)) {
    501   pii->SetImage(nouv, false);
    502   pii->SetPave(mXImgCenter, mYImgCenter, true, true);
    503   }
    504 else pii->SetImage(nouv, true);
     503
     504// decode des options en chaine de caracteres
     505pii->DecodeOptionString(mDefaultAtt, false);  // d'abord les options par defaut
     506pii->DecodeOptionString(opts);      // ensuite, les options specifies en argument
     507
     508
     509// On recalcule la taille de la fenetre si Disp_Win
     510if (dwopt == Disp_Win) {
     511  int sx2 = (int)((float)nouv->XSize()*pii->GetZoomF());
     512  int sy2 = (int)((float)nouv->YSize()*pii->GetZoomF());
     513 
     514  if (sx2 > 400+mFgScSz*100) sx2 = 400+mFgScSz*100;
     515  if (sy2 > 400+mFgScSz*100) sy2 = 400+mFgScSz*100;
     516  if (sx2 < MINPIIMGSIZE) sx = MINPIIMGSIZE;
     517  if (sy2 < MINPIIMGSIZE) sy = MINPIIMGSIZE;
     518  if ((sx2 != sx) || (sy2 != sy))  win->SetSize(sx2, sy2);
     519}
     520
     521pii->SetImage(nouv, false);
     522
    505523// printf("!!DBG!! PIImage Pos= %d %d  Size= %d %d \n", pii->XPos(), pii->YPos(), pii->XSize(), pii->YSize()   );
    506524mCurWin = win;
     
    509527mBWId++;
    510528mBWList[mBWId] = pii;
     529pii->Refresh();
    511530return(mBWId);
    512531}
     
    514533
    515534/* --Methode-- */
    516 int PIStdImgApp::DispScDrawer(PIDrawer* scd, string const & name, int opt, string title, int oid)
     535int PIStdImgApp::DispScDrawer(PIDrawer* scd, string const & name, string const& sop,
     536                              string title, int oid)
    517537{
    518538if (scd == NULL)
     
    522542  }
    523543
    524 // Changement d'attributs graphiques courants du drawer
    525 if (mFCol != PI_NotDefColor) scd->GetGraphicAtt().SetColAtt(mFCol, mBCol);
    526 if (mLAtt != PI_NotDefLineAtt) scd->GetGraphicAtt().SetLineAtt(mLAtt);
    527 if ( (mFSz != PI_NotDefFontSize) && (mFAtt != PI_NotDefFontAtt) )
    528   scd->GetGraphicAtt().SetFontAtt(mFSz, mFAtt);
    529 if ( mFName != PI_DefaultFont )
    530   scd->GetGraphicAtt().SetFontAtt(mFName, scd->GetGraphicAtt().GetFontSz(),
    531                                scd->GetGraphicAtt().GetFontAtt());
    532 if ( (mMrk != PI_NotDefMarker) && (mMSz >= 0) )
    533   scd->GetGraphicAtt().SetMarkerAtt(mMSz, mMrk);
    534 if ( mCmapid != CMAP_OTHER ) scd->GetGraphicAtt().SetColMapId(mCmapid);
    535 
    536 
    537 if ( (!mLastWdg) && ( (opt == Disp_Same) || (opt == Disp_Inset) ) )  opt = Disp_Next;
     544// On decode les options graphiques
     545vector<string> opts;
     546DispWinEnum dwopt = ParseDisplayOption(sop, opts);
     547if ( (!mLastWdg) && ( (dwopt == Disp_Same) || (dwopt == Disp_Inset) ) )  dwopt = Disp_Next;
    538548// Trace en superpoistion
    539 if ( (opt == Disp_Same) && (mLastWdg) ) { 
     549if ( (dwopt == Disp_Same) && (mLastWdg) ) { 
     550  // Les options
     551  scd->DecodeOptionString(mDefaultAtt, false);
     552  scd->DecodeOptionString(opts, true);
     553
    540554  if (mLastWdg->kind() == PIScDrawWdg::ClassId)  ((PIScDrawWdg*)mLastWdg)->AddScDrawer(scd, true);
    541555  else mLastWdg->AddDrawer(scd, true, true, true);
     
    546560}
    547561// Trace en medaillon
    548 else if ( (opt == Disp_Inset) && (mLastWdg) ) {
     562else if ( (dwopt == Disp_Inset) && (mLastWdg) ) {
    549563  PIGrCoord x1, x2, y1, y2;
    550564  x1 = mIXmin;  x2 = mIXmax;
    551565  y2 = 1.-mIYmin;  y1 = 1.-mIYmax;
     566  // Les options
     567  scd->DecodeOptionString(mDefaultAtt, false);
     568  scd->DecodeOptionString(opts, true);
     569
    552570  scd->SetAxesFlags(mAxesFlags);
    553   if (maXlog || maYlog)  scd->SetLogScale(maXlog, maYlog);  // Echelle log
    554   if (mFXYlim)  // Forcage limites XY
    555     scd->SetLimits(mXmin, mXmax, mYmin, mYmax); 
    556   else scd->UpdateLimits();
     571  scd->UpdateLimits();
    557572  mLastWdg->AddDrawer(scd, x1, y1, x2, y2, true, false, true);
    558573  scd->Refresh();
     
    562577}
    563578
     579// Creation d'un nouveau PIScDrawWdg
    564580PIWindow* win;
    565581PIScDrawWdg* scw;
     
    567583sx = 200+mFgScSz*100;
    568584sy = 200+mFgScSz*100;
    569 win = GetWindow(opt, sx, sy, px, py, flag, (char *)name.c_str());
    570 /*
    571 if (typeid(*scd) != typeid(PIHisto2D))
    572 else scw = new PIH2DWdg(win, (char *)name.c_str(), sx, sy, px, py);
    573 */
     585win = GetWindow(dwopt, sx, sy, px, py, flag, (char *)name.c_str());
     586
    574587scw = new PIScDrawWdg(win, (char *)name.c_str(), sx, sy, px, py);
    575588scw->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
    576589scw->SetUserData(NULL, oid);
    577 if (maXlog || maYlog)  scw->SetLogScale(maXlog, maYlog);  // Echelle log
    578 if (mFXYlim)  // Forcage limites XY
    579   scw->SetLimits(mXmin, mXmax, mYmin, mYmax);
     590
     591// Decodage des options :
     592vector<string> scwatt;
    580593scw->SetAxesFlags(mAxesFlags);
    581 // Fonte de trace d'axe
    582 scw->BaseDrawer()->GetGraphicAtt().SetFontAtt(mFName, mFSz, mFAtt);
    583 /*
    584 if (typeid(*scd) != typeid(PIHisto2D))
    585 else ((PIH2DWdg*)scw)->SetPIHisto((PIHisto2D*)scd);
    586 */
    587 scw->AddScDrawer(scd, true);
     594if ( mDefaultAtt.size() > 0) {
     595  scwatt = mDefaultAtt;
     596  scw->DecodeOptionString(scwatt, true);
     597}
     598if ( mAxesAtt.size() > 0) {
     599  scwatt = mAxesAtt;
     600  scw->DecodeOptionString(scwatt, true);
     601}
     602if (opts.size() > 0)
     603  scd->DecodeOptionString(opts, true);
     604if (opts.size() > 0)
     605  scw->DecodeOptionString(opts, false);
     606
    588607//   Titre du plot
    589608if (mAddTitle) {
     
    592611}
    593612
     613scw->AddScDrawer(scd, true);
    594614// scw->Refresh();   ? Pas necessaire  Reza 19/08/98, 05/05/99 $CHECK$
     615
    595616mCurWin = win;
    596617mCurWdg = scw;
     
    602623
    603624/* --Methode-- */
    604 int PIStdImgApp::Disp3DDrawer(PIDrawer3D* dr3, string const & name, int opt, string title, int oid)
     625int PIStdImgApp::Disp3DDrawer(PIDrawer3D* dr3, string const & name, string const& sop,
     626                              string title, int oid)
    605627{
    606628if (dr3 == NULL)
     
    610632  }
    611633
    612 // Changement d'attributs graphiques courants du drawer
    613 if (mFCol != PI_NotDefColor) dr3->GetGraphicAtt().SetColAtt(mFCol, mBCol);
    614 if (mLAtt != PI_NotDefLineAtt) dr3->GetGraphicAtt().SetLineAtt(mLAtt);
    615 if ( (mFSz != PI_NotDefFontSize) && (mFAtt != PI_NotDefFontAtt) )
    616   dr3->GetGraphicAtt().SetFontAtt(mFSz, mFAtt);
    617 if ( mFName != PI_DefaultFont )
    618   dr3->GetGraphicAtt().SetFontAtt(mFName, dr3->GetGraphicAtt().GetFontSz(),
    619                                   dr3->GetGraphicAtt().GetFontAtt());
    620 if ( (mMrk != PI_NotDefMarker) && (mMSz >= 0) )
    621   dr3->GetGraphicAtt().SetMarkerAtt(mMSz, mMrk);
    622 if ( mCmapid != CMAP_OTHER ) dr3->GetGraphicAtt().SetColMapId(mCmapid);
    623 
    624 if ( (!mLastWdg) && ( (opt == Disp_Same) || (opt == Disp_Inset) ) )  opt = Disp_Next;
     634// On decode les options graphiques
     635vector<string> opts;
     636DispWinEnum dwopt = ParseDisplayOption(sop, opts);
     637
     638if ( (!mLastWdg) && ( (dwopt == Disp_Same) || (dwopt == Disp_Inset) ) )  dwopt = Disp_Next;
    625639// Trace en superpoistion
    626 if ( (opt == Disp_Same) && (mLastWdg) ) {
     640if ( (dwopt == Disp_Same) && (mLastWdg) ) {
     641  // Les options
     642  dr3->DecodeOptionString(mDefaultAtt, false);
     643  dr3->DecodeOptionString(opts, true);
     644
    627645  if (mLastWdg->kind() == PIDraw3DWdg::ClassId)  ((PIDraw3DWdg*)mLastWdg)->AddDrawer3D(dr3, true);
    628646  else mLastWdg->AddDrawer(dr3, true, true, true);
     
    633651}
    634652// Trace en medaillon
    635 else if ( (opt == Disp_Inset) && (mLastWdg) ) {
     653else if ( (dwopt == Disp_Inset) && (mLastWdg) ) {
    636654  PIGrCoord x1, x2, y1, y2;
    637655  x1 = mIXmin;  x2 = mIXmax;
    638656  y2 = 1.-mIYmin;  y1 = 1.-mIYmax;
     657  // Les options
     658  dr3->DecodeOptionString(mDefaultAtt, false);
     659  dr3->DecodeOptionString(opts, true);
     660
    639661  dr3->SetAxesFlags(mAxesFlags);
    640662  dr3->UpdateLimits();
     
    651673sx = 200+mFgScSz*100;
    652674sy = 200+mFgScSz*100;
    653 win = GetWindow(opt, sx, sy, px, py, flag, (char *)name.c_str());
     675win = GetWindow(dwopt, sx, sy, px, py, flag, (char *)name.c_str());
    654676PIDraw3DWdg* wd3 = new PIDraw3DWdg(win, (char *)name.c_str(), sx, sy, px, py);
    655677wd3->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
    656678wd3->SetUserData(NULL, oid);
    657 wd3->AddDrawer3D(dr3, true);
     679
     680// Decodage des options :
     681vector<string> scwatt;
     682// wd3->SetAxesFlags(mAxesFlags);  Attributs d'axes 3D a faire
     683if ( mDefaultAtt.size() > 0) {
     684  scwatt = mDefaultAtt;
     685  wd3->DecodeOptionString(scwatt, true);
     686}
     687if ( mAxesAtt.size() > 0) {
     688  scwatt = mAxesAtt;
     689  wd3->DecodeOptionString(scwatt, true);
     690}
     691if (opts.size() > 0) 
     692  dr3->DecodeOptionString(opts, true);
     693if (opts.size() > 0) 
     694  wd3->DecodeOptionString(opts, false);
     695
    658696//   Titre du plot
    659697if (mAddTitle) {
     
    661699  wd3->SetTitles(title, t2);   
    662700}
     701
     702wd3->AddDrawer3D(dr3, true);
    663703// wd3->Refresh();   ?Pas necessaire   $CHECK$ 05/05/99
     704
    664705mCurWin = win;
    665706mCurWdg = wd3;
     
    671712
    672713/* --Methode-- */
    673 void PIStdImgApp::AddText(string const & txt, double xp, double yp)
     714void PIStdImgApp::AddText(string const & txt, double xp, double yp, string const& sop)
    674715{
    675716PIElDrawer *eld=CurrentElDrawer();
    676717if (eld == NULL) return;
    677718
    678 if ( (mFSz != PI_NotDefFontSize) && (mFAtt != PI_NotDefFontAtt) )
    679   eld->GetGraphicAtt().SetFontAtt(mFSz, mFAtt);
    680 if ( mFName != PI_DefaultFont )
    681   eld->GetGraphicAtt().SetFontAtt(mFName, eld->GetGraphicAtt().GetFontSz(),
    682                                   eld->GetGraphicAtt().GetFontAtt());
    683 eld->ElAddText(xp,yp,txt.c_str(),mFCol);
     719vector<string> opts;
     720ParseDisplayOption(sop, opts);
     721PIGraphicAtt gratt(opts);
     722eld->ElAddText(xp,yp,txt.c_str(), gratt.GetColor());
    684723eld->Refresh();
    685724}
    686725
    687726/* --Methode-- */
    688 void PIStdImgApp::AddLine(double xp1, double yp1, double xp2, double yp2)
     727void PIStdImgApp::AddLine(double xp1, double yp1, double xp2, double yp2, string const& sop)
    689728{
    690729PIElDrawer *eld=CurrentElDrawer();
    691730if (eld == NULL) return;
    692731
    693 eld->ElAddLine(xp1, yp1, xp2, yp2, mFCol);
     732vector<string> opts;
     733ParseDisplayOption(sop, opts);
     734PIGraphicAtt gratt(opts);
     735eld->ElAddLine(xp1, yp1, xp2, yp2, gratt.GetColor());
    694736eld->Refresh();
    695737}
    696738
    697739/* --Methode-- */
    698 void PIStdImgApp::AddRectangle(double xp1, double yp1, double xp2, double yp2, bool fgfill)
     740void PIStdImgApp::AddRectangle(double xp1, double yp1, double xp2, double yp2,
     741                               string const& sop, bool fgfill)
    699742{
    700743PIElDrawer *eld=CurrentElDrawer();
     
    715758  yp = yp2; dy = yp1-yp2;
    716759}
    717 if (fgfill) eld->ElAddFRect(xp, yp, dx, dy, mFCol);
    718 else eld->ElAddRect(xp, yp, dx, dy, mFCol);
     760
     761vector<string> opts;
     762ParseDisplayOption(sop, opts);
     763PIGraphicAtt gratt(opts);
     764
     765if (fgfill) eld->ElAddFRect(xp, yp, dx, dy, gratt.GetColor());
     766else eld->ElAddRect(xp, yp, dx, dy, gratt.GetColor());
    719767eld->Refresh();
    720768}
    721769
    722770/* --Methode-- */
    723 void PIStdImgApp::AddCircle(double xc, double yc, double r, bool fgfill)
     771void PIStdImgApp::AddCircle(double xc, double yc, double r, string const& sop, bool fgfill)
    724772{
    725773PIElDrawer *eld=CurrentElDrawer();
    726774if (eld == NULL) return;
    727775
    728 if (fgfill) eld->ElAddFCirc(xc, yc, r, mFCol);
    729 else eld->ElAddCirc(xc, yc, r, mFCol);
     776vector<string> opts;
     777ParseDisplayOption(sop, opts);
     778PIGraphicAtt gratt(opts);
     779
     780if (fgfill) eld->ElAddFCirc(xc, yc, r, gratt.GetColor());
     781else eld->ElAddCirc(xc, yc, r, gratt.GetColor());
    730782eld->Refresh();
    731783}
     
    737789if (eld == NULL) return;
    738790
    739 if ( (mFSz != PI_NotDefFontSize) && (mFAtt != PI_NotDefFontAtt) )
    740   eld->GetGraphicAtt().SetFontAtt(mFSz, mFAtt);
    741 if ( mFName != PI_DefaultFont )
    742   eld->GetGraphicAtt().SetFontAtt(mFName, eld->GetGraphicAtt().GetFontSz(),
    743                                   eld->GetGraphicAtt().GetFontAtt());
    744791eld->SetTitles(titletop, titlebottom);
    745792eld->Refresh();
     
    815862
    816863/* --Methode-- */
    817 PIWindow* PIStdImgApp::GetWindow(int typ, int& sx, int& sy, int& px, int& py, int& flag, char * nom)
     864PIWindow* PIStdImgApp::GetWindow(DispWinEnum typ, int& sx, int& sy, int& px, int& py, int& flag, char * nom)
    818865{
    819866PIWindow* rw;
     
    821868switch (typ) {
    822869  case Disp_Next :  // Fenetre graphique courante
     870  case Disp_Default :
    823871    {
    824872    if (mGrW == NULL) CreateGraphWin();
     
    9931041}
    9941042
     1043/* --Methode-- */
     1044void PIStdImgApp::StatZoomWindowSetVisible(bool fg)
     1045{
     1046
     1047  if (fg) {
     1048    consolecont->SetBinding(PIBK_free,PIBK_free,PIBK_free, PIBK_free);
     1049    int szy = MainWin()->YSize();
     1050    MainWin()->SetSize(MainWin()->XSize(), szy+statcont->YSize());
     1051    consolecont->SetPos(0, statcont->YSize());
     1052    consolecont->SetSize(MainWin()->XSize(), szy);
     1053    consolecont->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_fixed);
     1054    statcont->Show();
     1055    m[3]->SetStateMsg(10470, true);
     1056  }
     1057  else {
     1058    statcont->Hide();
     1059    consolecont->SetBinding(PIBK_free,PIBK_free,PIBK_free, PIBK_free);
     1060    MainWin()->SetSize(MainWin()->XSize(), MainWin()->YSize()-statcont->YSize());
     1061    consolecont->SetPos(0, 0);
     1062    consolecont->SetSize(MainWin()->XSize(), MainWin()->YSize());
     1063    consolecont->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_fixed);
     1064    m[3]->SetStateMsg(10470, false);   
     1065  }
     1066 
     1067}
    9951068
    9961069/* --Methode-- */
     
    10401113m[4]->SetSensitivityMsg(10516, false);
    10411114}
     1115
     1116//---------------------------------------------------------------------------
     1117//--------- Gestion des attributs graphiques et autres options de trace -----
     1118
     1119/* --Methode-- */
     1120void PIStdImgApp::SetInsetLimits(double xmin, double xmax, double ymin, double ymax)
     1121{
     1122  mIXmin = xmin;  mIXmax= xmax;
     1123  mIYmin = ymin;  mIYmax= ymax;
     1124}
     1125
     1126/* --Methode-- */
     1127void PIStdImgApp::SetDefaultGraphicAttributes(string const & opt)
     1128{
     1129  ParseDisplayOption(opt, mDefaultAtt);
     1130}
     1131
     1132/* --Methode-- */
     1133void PIStdImgApp::SetDefaultAxesAttributes(string const & opt)
     1134{
     1135  ParseDisplayOption(opt, mAxesAtt);
     1136}
     1137
     1138/* --Methode-- */
     1139DispWinEnum PIStdImgApp::ParseDisplayOption(string const & sop, vector<string>& opts)
     1140{
     1141  DispWinEnum rc = Disp_Next;
     1142  //DBG  cerr << " DBG-Parse-A sop=" << sop << " sop.length()= " << sop.length() << endl;
     1143  if (opts.size() > 0)  opts.erase(opts.begin(), opts.end());
     1144  if (sop.length() < 1) return(rc);
     1145  string gratt = sop;
     1146  for(int i=0; i<gratt.length(); i++) gratt[i] = tolower(gratt[i]);
     1147  if ( (gratt == "def") || (gratt == "default") ) return(rc);
     1148// On separe en mots espaces par des blancs ou tabulation
     1149  size_t p = 0;
     1150  size_t q = 0;
     1151  size_t l = gratt.length();
     1152  string token;
     1153  while (q < l)  {
     1154    p = gratt.find_first_not_of(" \t",q);   // au debut d'un token
     1155    if (p >= l) break;
     1156    q = gratt.find_first_of(" \t",p);       // Premier blanc ou tab suivant
     1157    if (q<l) token = gratt.substr(p,q-p);
     1158    else token = gratt.substr(p);
     1159    if (token == "") continue;
     1160    // Decodage option fenetre d'affichage (win, next, ...)
     1161    if (token == "win")   rc =  Disp_Win;
     1162    else if (token == "same")  rc = Disp_Same;
     1163    else if (token == "inset")   rc = Disp_Inset;
     1164    else  if (token == "stack")   rc = Disp_Stack;
     1165    // Option a etre decode par les drawers, etc ...
     1166    else  opts.push_back(token);
     1167  }
     1168
     1169  //DBG  cerr << " DBG-Parse-B opts.size()=" << opts.size() << endl;
     1170  return (rc);
     1171}
     1172
     1173//---------------------------------------------------------------------------
     1174//------------       Methodes privees (MBProcessx, ...)    ----------
    10421175
    10431176/* --Methode-- */
     
    12951428      DeleteWindow(mCurWin);
    12961429      break;
     1430    case 10470 :
     1431      StatZoomWindowSetVisible(m[3]->GetStateMsg(10470));
     1432      break;
    12971433  default:
    12981434    cerr << "PIStdImgApp::MBProcess4() BUG?? Msg= " <<  msg << endl;   
     
    14611597
    14621598
    1463 /* --Methode-- */
    1464 void PIStdImgApp::SetColAtt(PIColors fg, PIColors bg)
    1465 {
    1466   mFCol = fg;
    1467   mBCol = bg;
    1468 }
    1469 /* --Methode-- */
    1470 void PIStdImgApp::SetLineAtt(PILineAtt lat)
    1471 {
    1472   mLAtt = lat;
    1473 }
    1474 
    1475 /* --Methode-- */
    1476 void PIStdImgApp::SetFontName(PIFontName fn)
    1477 {
    1478   mFName = fn;
    1479 }
    1480 
    1481 /* --Methode-- */
    1482 void PIStdImgApp::SetFontAtt(PIFontSize fsz, PIFontAtt fat)
    1483 {
    1484   mFSz = fsz;
    1485   mFAtt = fat;
    1486 }
    1487 /* --Methode-- */
    1488 void PIStdImgApp::SetMarkerAtt(int sz, PIMarker mrk)
    1489 {
    1490   mMSz = sz;
    1491   mMrk = mrk;
    1492 }
    1493 
    1494 /* --Methode-- */
    1495 void PIStdImgApp::SetZoomAtt(int zoom)
    1496 {
    1497   if ( (zoom > 10) || (zoom < -10) ) zoom = 0;
    1498   mZoom = zoom;
    1499 }
    1500 /* --Methode-- */
    1501 void PIStdImgApp::SetAxesAtt(unsigned int axfl)
    1502 {
    1503   mAxesFlags = axfl;
    1504 }
    1505 /* --Methode-- */
    1506 void PIStdImgApp::SetXYLimits(double xmin, double xmax, double ymin, double ymax)
    1507 {
    1508   mXmin = xmin;  mXmax= xmax;
    1509   mYmin = ymin;  mYmax= ymax;
    1510 }
    1511 /* --Methode-- */
    1512 void PIStdImgApp::SetInsetLimits(double xmin, double xmax, double ymin, double ymax)
    1513 {
    1514   mIXmin = xmin;  mIXmax= xmax;
    1515   mIYmin = ymin;  mIYmax= ymax;
    1516 }
    1517 /* --Methode-- */
    1518 void PIStdImgApp::SetImageCenterPosition(int x, int y)
    1519 {
    1520   mXImgCenter = x;  mYImgCenter = y;
    1521 }
    1522 
    1523 /* --Methode-- */
    1524 void PIStdImgApp::SaveGraphicAtt()
    1525 {
    1526   mSFCol = mFCol;
    1527   mSBCol = mBCol;
    1528   mSLAtt = mLAtt;
    1529   mSFName = mFName;
    1530   mSFSz = mFSz;
    1531   mSFAtt = mFAtt;
    1532   mSMSz = mMSz;
    1533   mSMrk = mMrk;
    1534   mSCmapid = mCmapid;
    1535   mSRevCmap = mRevCmap;
    1536   mSZoom = mZoom;
    1537   mSAxesFlags = mAxesFlags;
    1538   mSXmin = mXmin;  mSXmax = mXmax;
    1539   mSYmin = mYmin;  mSYmax = mYmax;
    1540   mSIXmin = mIXmin;  mSIXmax = mIXmax;
    1541   mSIYmin = mIYmin;  mSIYmax = mIYmax;
    1542   mSFXYlim = mFXYlim;
    1543   mSXImgCenter = mXImgCenter;
    1544   mSYImgCenter = mYImgCenter;
    1545   mSFImgCenter = mFImgCenter;
    1546   mSaXlog = maXlog;
    1547   mSaYlog = maYlog;
    1548   mSAddTitle = mAddTitle;
    1549 }
    1550 
    1551 /* --Methode-- */
    1552 void PIStdImgApp::RestoreGraphicAtt()
    1553 {
    1554   mFCol = mSFCol;
    1555   mBCol = mSBCol;
    1556   mLAtt = mSLAtt;
    1557   mFName = mSFName;
    1558   mFSz = mSFSz;
    1559   mFAtt = mSFAtt;
    1560   mMSz = mSMSz;
    1561   mMrk = mSMrk;
    1562   mCmapid = mSCmapid;
    1563   mRevCmap = mSRevCmap;
    1564   mZoom = mSZoom;
    1565   mAxesFlags = mSAxesFlags;
    1566   mXmin = mSXmin;  mXmax = mSXmax;
    1567   mYmin = mSYmin;  mYmax = mSYmax;
    1568   mIXmin = mSIXmin;  mIXmax = mSIXmax;
    1569   mIYmin = mSIYmin;  mIYmax = mSIYmax;
    1570   mFXYlim = mSFXYlim;
    1571   mXImgCenter = mSXImgCenter;
    1572   mYImgCenter = mSYImgCenter;
    1573   mFImgCenter = mSFImgCenter;
    1574   maXlog = mSaXlog;
    1575   maYlog = mSaYlog;
    1576   mAddTitle = mSAddTitle;
    1577 }
    15781599
    15791600//  -------------------------------------------------
     
    16201641string info = "piapp : Interactive analysis program\n";
    16211642info += buff;
    1622 info += "(C) LAL-IN2P3/CNRS  1996-2000\n";
    1623 info += "(C) SPP-DAPNIA/CEA  1996-2000\n";
     1643info += "(C) LAL-IN2P3/CNRS  1996-2002\n";
     1644info += "(C) SPP-DAPNIA/CEA  1996-2002\n";
    16241645infow_txt->SetText(info);
    16251646}
  • trunk/SophyaPI/PIext/pistdimgapp.h

    r1642 r1971  
    3131
    3232
    33 enum {Disp_Next=0, Disp_Win=1, Disp_Same=2, Disp_Stack=3, Disp_Inset=4};
     33enum DispWinEnum {Disp_Default, Disp_Next, Disp_Win, Disp_Same, Disp_Stack, Disp_Inset};
    3434
    3535typedef map<long, PIWindow*, less<long> > WindMList;
     
    4747     virtual void   SetBlocked();
    4848
    49      int  DispImage(P2DArrayAdapter* nouv, string const & name, int opt, int oid=0);
    50      int  DispScDrawer(PIDrawer* scd, string const & name, int opt, string title="", int oid=0);
    51      int  Disp3DDrawer(PIDrawer3D* scd, string const & name, int opt, string title="", int oid=0);
     49     int  DispImage(P2DArrayAdapter* nouv, string const & name, string const & opt, int oid=0);
     50     int  DispScDrawer(PIDrawer* scd, string const & name, string const & opt,
     51                       string title="", int oid=0);
     52     int  Disp3DDrawer(PIDrawer3D* scd, string const & name, string const & opt,
     53                       string title="", int oid=0);
    5254
    5355  //  Fonction d'ajout de texte (provisoire - Aout 99)
    54      void AddText(string const & txt, double xp, double yp);
     56     void AddText(string const & txt, double xp, double yp, string const& opt);
    5557  //  Ajout de lignes, rectangles, cercles (provisoires - Aout 2001)
    56      void AddLine(double xp1, double yp1, double xp2, double yp2);
    57      void AddRectangle(double xp1, double yp1, double xp2, double yp2, bool fgfill=false);
    58      void AddCircle(double xc, double yc, double r, bool fgfill=false);
     58     void AddLine(double xp1, double yp1, double xp2, double yp2, string const& opt);
     59     void AddRectangle(double xp1, double yp1, double xp2, double yp2, string const& opt,
     60                       bool fgfill=false);
     61     void AddCircle(double xc, double yc, double r, string const& opt,
     62                    bool fgfill=false);
    5963
    6064  //  Fonction Ajout de titre de trace
     
    6670     void CreateGraphWin(int nx=1, int ny=1, int sx=0, int sy = 0);
    6771     void CreateStackWin(int sx=0, int sy = 0);
    68      PIWindow * GetWindow(int typ, int& sx, int& sy, int& px, int& py, int& flag, char * nom);
     72     PIWindow * GetWindow(DispWinEnum typ, int& sx, int& sy, int& px, int& py, int& flag, char * nom);
    6973     void SetZone(int nzx=1, int nzy=1);
    7074     void StackWinNext();
     
    9397     inline PPInMgrWind* PPInMgrW() { return mPpinmgrw; }
    9498
     99// Gestion (show/hide) de la fenetre Stat/ZoomWindow
     100    void   StatZoomWindowSetVisible(bool fg=true);
     101
    95102// Redirection ou Non de StdOut/StdErr
    96103     void  RedirectStdOutErr(bool fg = true);
     
    99106     void  CatchSignals(bool fgfpe=true, bool fgsegv=true);
    100107
    101 //  Gestion d attributs graphiques courants
    102      void  SetColAtt(PIColors fg=PI_NotDefColor,
    103                      PIColors bg=PI_NotDefColor);
    104      void  SetLineAtt(PILineAtt lat=PI_NotDefLineAtt);
    105      void  SetFontName(PIFontName fn=PI_DefaultFont);
    106      void  SetFontAtt(PIFontSize fsz=PI_NotDefFontSize,
    107                       PIFontAtt fat=PI_NotDefFontAtt);
    108      void  SetMarkerAtt(int sz=-1, PIMarker mrk=PI_NotDefMarker);
    109      inline void  SetColMapId(CMapId cid=CMAP_OTHER) { mCmapid = cid; }
    110      inline void  SetReverseColMapFlag(bool fg=false) { mRevCmap = fg; }
    111      void  SetZoomAtt(int zoom=0);
    112      void  SetAxesAtt(unsigned int axfl=kBoxAxes | kExtTicks | kLabels);
    113      void  SetXYLimits(double xmin=-1., double xmax=1., double ymin=-1., double ymax=1.);
    114108     void  SetInsetLimits(double xmin=0.4, double xmax=0.6, double ymin=0.4, double ymax=0.6);
    115      void  SetImageCenterPosition(int x=-1, int y=-1);
    116      inline void  UseXYLimits(bool fg=false) {  mFXYlim=fg; }
    117      inline void  UseImageCenter(bool fg=false) { mFImgCenter=fg; }
    118      inline void  SetXLogScale(bool logx=false) { maXlog = logx; }
    119      inline void  SetYLogScale(bool logy=false) { maYlog = logy; }
    120109     inline void  SetAutoAddTitle(bool aatit=true) { mAddTitle = aatit; }
    121 
    122 // Pour sauvegarder-restauration de  l'etat des attributs graphiques
    123      void  SaveGraphicAtt();   
    124      void  RestoreGraphicAtt();   
     110     void  SetAxesAtt(unsigned int axfl) { mAxesFlags = axfl; }
     111  //     void  SaveGraphicAtt();
     112  //     void  RestoreGraphicAtt();
     113     void  SetDefaultGraphicAttributes(string const & opt);
     114     void  SetDefaultAxesAttributes(string const & opt);
     115     DispWinEnum ParseDisplayOption(string const & opt, vector<string>& opts);
    125116
    126117// Gestion fichiers PS
     
    141132    void MBProcess6(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
    142133
     134   
    143135
    144136    NamedObjMgr* mObjMgr;
     
    148140    PIMenu* mc;
    149141
     142    PIContainer* statcont;    // Container pour les widgets zoom, gimv, cmapv ...
    150143    PIPixmap* zoom;
    151144    PIPixmap* gimv;
    152145    PICMapView* cmapv;
     146    PILabel* labstat;
    153147
    154148    PIFileChooser * pfc_fits;   // Pour les fichiers FITS
     
    156150    PIFileChooser * pfc_ps;     // Pour les PostScript
    157151
     152    PIContainer* consolecont;    // Container pour la PIConsole
    158153    PIConsole* mCons;
    159154    bool redirecout;    // true if stdout/err redirected to mCons;
     
    176171    PPInMgrWind* mPpinmgrw;
    177172
    178 //  Gestion d attributs graphiques courants, etat sauvegarde
    179     PIColors     mFCol, mBCol, mSFCol, mSBCol;
    180     PILineAtt    mLAtt, mSLAtt;
    181     PIFontName   mFName, mSFName;
    182     PIFontSize   mFSz, mSFSz;
    183     PIFontAtt    mFAtt, mSFAtt;
    184     int          mMSz, mSMSz;
    185     PIMarker     mMrk,mSMrk; 
    186     CMapId       mCmapid, mSCmapid;
    187     bool         mRevCmap, mSRevCmap;
    188     int          mZoom, mSZoom;
    189     unsigned int mAxesFlags, mSAxesFlags;
    190     double       mXmin, mXmax, mYmin, mYmax;
    191     double       mSXmin, mSXmax, mSYmin, mSYmax;
     173  // Attributs graphiques, etc ...
    192174    double       mIXmin, mIXmax, mIYmin, mIYmax;
    193     double       mSIXmin, mSIXmax, mSIYmin, mSIYmax;
    194     int          mXImgCenter, mYImgCenter;
    195     int          mSXImgCenter, mSYImgCenter;
    196     bool         mFXYlim, mSFXYlim;
    197     bool         mFImgCenter, mSFImgCenter;
    198     bool         maXlog, mSaXlog;
    199     bool         maYlog, mSaYlog;
    200     bool         mAddTitle, mSAddTitle;
     175    bool         mAddTitle;
     176    unsigned int mAxesFlags;
    201177
     178    vector<string> mDefaultAtt;
     179    vector<string> mAxesAtt; 
     180
     181  //  Controles et gestion divers
    202182    PIMessage mFCMsg;  // Message for processing FileOpen
    203     int mFgScSz;   // Dlag ScreenSize
     183    int mFgScSz;   // Flag ScreenSize
    204184    bool mFgCWImg; // true -> Current Widget is PIImage
    205185};
  • trunk/SophyaPI/PIext/servnobjm.cc

    r1931 r1971  
    5353mOmg = omg;
    5454dynlink = NULL;
    55 InitGrAttNames();
    5655}
    5756 
     
    235234  vya->DefineXCoordinate(xmin, (xmax-xmin)/np);
    236235  PIYfXDrawer* dr = new   PIYfXDrawer(vya, NULL, true) ;
    237   bool fgsr = true;
    238   dopt = "thinline," + dopt;
    239   int opt = DecodeDispOption(dopt, fgsr);
    240   int rsid = mImgapp->DispScDrawer(dr, titre, opt);
    241   if (fgsr) mImgapp->RestoreGraphicAtt();
     236  dopt = "thinline " + dopt;
     237  int rsid = mImgapp->DispScDrawer(dr, titre, dopt);
    242238  if (nom.length() > 0) {
    243239    mOmg->AddObj(vpy, nom);
     
    245241    }
    246242  }
    247 
    248243return;
    249244}
     
    304299    }
    305300  else titre = nom;
    306   bool fgsr = true;
    307   int opt = DecodeDispOption(dopt, fgsr);
    308301  P2DArrayAdapter* arr = new POMatrixAdapter(mtx, false);
    309302  arr->DefineXYCoordinates(xmin, ymin, dx, dy);
    310303  PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
    311   int rsid = mImgapp->Disp3DDrawer(sdr, titre, opt);
    312   if (fgsr) mImgapp->RestoreGraphicAtt();
     304  int rsid = mImgapp->Disp3DDrawer(sdr, titre, dopt);
    313305  if (nom.length() > 0)  {
    314306    mOmg->AddObj(mtx, nom);
     
    352344// nt->Print(0,10);
    353345PINTuple* pin = new PINTuple(nt, true);
    354 pin->SetStats(Services2NObjMgr::GetStatsOption(dopt));
    355346pin->SelectXY(ntn[0], ntn[1]);
    356347if ( haserr ) pin->SelectErrBar(ntn[2], ntn[3]);
    357348
    358 bool fgsr = true;
    359 dopt = "defline," + dopt;
    360 int opt = DecodeDispOption(dopt, fgsr);
     349dopt = "defline " + dopt;
    361350string titre =  nom + ":" + expy + "%" + expx;
    362 mImgapp->DispScDrawer( (PIDrawer*)pin, titre, opt);
    363 if (fgsr) mImgapp->RestoreGraphicAtt();
     351mImgapp->DispScDrawer( (PIDrawer*)pin, titre, dopt);
    364352return;
    365353}
     
    392380PINTuple3D* pin = new PINTuple3D(nt, true);
    393381pin->SelectXYZ(ntn[0], ntn[1], ntn[2]);
    394 bool fgsr = true;
    395 dopt = "defline," + dopt;
    396 int opt = DecodeDispOption(dopt, fgsr);
     382dopt = "defline " + dopt;
    397383
    398384// Pour plot a partir de DispScDrawer
     
    401387// Pour plot a partir de Disp3DDrawer
    402388string titre =  nom + ":" + expy + "%" + expx;
    403 mImgapp->Disp3DDrawer(pin, titre, opt);
    404 
    405 if (fgsr) mImgapp->RestoreGraphicAtt();
     389mImgapp->Disp3DDrawer(pin, titre, dopt);
     390
    406391return;
    407392}
     
    432417
    433418PINTuple* pin = new PINTuple(nt, true);
    434 pin->SetStats(Services2NObjMgr::GetStatsOption(dopt));
    435419pin->SelectXY(ntn[0], ntn[1]);
    436420pin->SelectWt(ntn[2]);
    437421
    438 bool fgsr = true;
    439 int opt = DecodeDispOption(dopt, fgsr);
    440422string titre =  nom + ":" + expwt + "_" + expy + "%" + expx ;
    441 mImgapp->DispScDrawer( (PIDrawer*)pin, titre, opt);
    442 if (fgsr) mImgapp->RestoreGraphicAtt();
     423mImgapp->DispScDrawer( (PIDrawer*)pin, titre, dopt);
    443424return;
    444425}
     
    13151296
    13161297
    1317 // Variable pour stocker l'option de stat des drawers
    1318 static bool stats_option = true;
    1319 /* --Methode-- */
    1320 void Services2NObjMgr::SetDefaultStatsOption(bool opt)
    1321 {
    1322   stats_option = opt;
    1323 }
    1324 
    1325 typedef vector<string> GraTok;
    1326 
    1327 /* --Methode-- */
    1328 bool Services2NObjMgr::GetStatsOption(string& gratt)
    1329 {
    1330 int ropt = Disp_Next;
    1331 for(int i=0; i<gratt.length(); i++) gratt[i] = tolower(gratt[i]);
    1332 // On separe en mots separes par des virgules
    1333 gratt = ","+gratt;
    1334 size_t p = 0;
    1335 size_t q = 0;
    1336 size_t l = gratt.length();
    1337 string token;
    1338 
    1339 GraTok grt;
    1340 
    1341 while (q < l)  {
    1342   p = gratt.find_first_not_of(" ,",q+1); // au debut d'un token
    1343   if (p>=l) break;
    1344   q = gratt.find_first_of(" ,",p); // la fin du token;
    1345   token = gratt.substr(p,q-p);
    1346   grt.push_back(token);
    1347   }
    1348 int k;
    1349 bool fgsame = false;
    1350 int option = 0;
    1351 for(k=0; k<grt.size(); k++) {
    1352   if ( (grt[k] == "same") || (grt[k] == "s") )  option = 1;
    1353   else if ( (grt[k] == "stat") || (grt[k] == "stats") ) option = 2;
    1354   else if ( (grt[k] == "nostat") || (grt[k] == "nostats") ) option = 3;
    1355 }
    1356 
    1357 if (option == 0)  return(stats_option);
    1358 else if ( (option == 1) || (option == 3) )  return(false);
    1359 else return(true);
    1360 }
    1361 
    1362 /* --Methode-- */
    1363 int Services2NObjMgr::DecodeDispOption(string& gratt, bool& fgsrgr)
    1364 {
    1365 int ropt = Disp_Next;
    1366 if (!mImgapp)  return(ropt);
    1367 
    1368 for(int i=0; i<gratt.length(); i++) gratt[i] = tolower(gratt[i]);
    1369 
    1370 if (fgsrgr) mImgapp->SaveGraphicAtt();
    1371 
    1372 if ( (gratt == "def") || (gratt == "default") )  {  // Remise aux valeurs par defaut = non defini
    1373   mImgapp->SetColAtt();
    1374   mImgapp->SetLineAtt();
    1375   mImgapp->SetFontName();
    1376   mImgapp->SetFontAtt();
    1377   mImgapp->SetMarkerAtt();
    1378   mImgapp->SetColMapId();
    1379   mImgapp->SetReverseColMapFlag();
    1380   mImgapp->SetZoomAtt();
    1381   mImgapp->SetAxesAtt();
    1382   mImgapp->SetXYLimits();
    1383   mImgapp->UseXYLimits();
    1384   mImgapp->SetImageCenterPosition();
    1385   mImgapp->UseImageCenter();
    1386   mImgapp->SetXLogScale();
    1387   mImgapp->SetYLogScale();
    1388   mImgapp->SetAutoAddTitle();
    1389   stats_option = true;
    1390   return(ropt);
    1391   }
    1392 
    1393 // On separe en mots separes par des virgules
    1394 gratt = ","+gratt;
    1395 size_t p = 0;
    1396 size_t q = 0;
    1397 size_t l = gratt.length();
    1398 string token;
    1399 
    1400 GraTok grt;
    1401 
    1402 while (q < l)  {
    1403   p = gratt.find_first_not_of(" ,",q+1); // au debut d'un token
    1404   if (p>=l) break;
    1405   q = gratt.find_first_of(" ,",p); // la fin du token;
    1406   token = gratt.substr(p,q-p);
    1407   grt.push_back(token);
    1408   }
    1409 
    1410 
    1411 static GrAttNames::iterator it;
    1412 
    1413 int k;
    1414 bool fgcont = true;
    1415 fgsrgr = false;
    1416 
    1417 for(k=0; k<grt.size(); k++) {
    1418 //  cout << "--DBG--SetGraphicAttributes() " << grt[k] << endl;
    1419 
    1420  // Decodage option affichage (win, next, etc
    1421   fgcont = true;
    1422   if ( (grt[k] == "win") || (grt[k] == "w") )  ropt =  Disp_Win;
    1423   else if ( (grt[k] == "same") || (grt[k] == "s") )  ropt = Disp_Same;
    1424   else if ( (grt[k] == "inset") || (grt[k] == "ins") )  ropt = Disp_Inset;
    1425   else  if ( (grt[k] == "stack") || (grt[k] == "st") )  ropt = Disp_Stack;
    1426   else fgcont = false;
    1427   if (fgcont)   continue;
    1428 
    1429   // Utilisation limites X-Y
    1430   if ( grt[k] == "xylimits" ) { mImgapp->UseXYLimits(true);  fgsrgr = true;  continue; }
    1431   if ( grt[k] == "centerimg" ) { mImgapp->UseImageCenter(true);  fgsrgr = true;  continue; }
    1432   // Echelle logarithmique d'axe
    1433   if ( grt[k] == "logx" )  { mImgapp->SetXLogScale(true); fgsrgr = true;  continue; }
    1434   if ( grt[k] == "linx" )  { mImgapp->SetXLogScale(false); fgsrgr = true;  continue; }
    1435   if ( grt[k] == "logy" )  { mImgapp->SetYLogScale(true); fgsrgr = true;  continue; }
    1436   if ( grt[k] == "liny" )  { mImgapp->SetYLogScale(false); fgsrgr = true;  continue; }
    1437   // Ajout automatique de titre
    1438   if ( ( grt[k] == "tit" ) || ( grt[k] == "title" ) )
    1439     { mImgapp->SetAutoAddTitle(true); fgsrgr = true;  continue; }
    1440   if ( ( grt[k] == "notit" ) || ( grt[k] == "notitle" ) )
    1441     { mImgapp->SetAutoAddTitle(false); fgsrgr = true;  continue; }
    1442 
    1443   // Inversion d'indexage de ColorMap
    1444   if (grt[k] == "revcmap")
    1445     { mImgapp->SetReverseColMapFlag(true); fgsrgr = true;  continue; }
    1446 
    1447   // Si c'est une couleur
    1448   it = GrAcolors.find(grt[k]);
    1449   if (it != GrAcolors.end())  { mImgapp->SetColAtt((PIColors)((*it).second.a1)); fgsrgr = true; continue; }
    1450   // Si c'est un attribut de lignes
    1451   it = GrAlines.find(grt[k]);
    1452   if (it != GrAlines.end())  { mImgapp->SetLineAtt(PILineAtt((PILineTypes)((*it).second.a1)));  fgsrgr = true; continue; }
    1453   // Si c'est un attribut de fontes
    1454   it = GrAfonts.find(grt[k]);
    1455   if (it != GrAfonts.end())  { mImgapp->SetFontAtt((PIFontSize)((*it).second.a2), (PIFontAtt)((*it).second.a1) );
    1456                                fgsrgr = true;  continue; }
    1457   // Si c'est un nom de fontes
    1458   it = GrAfontNames.find(grt[k]);
    1459   if (it != GrAfontNames.end()) { mImgapp->SetFontName((PIFontName)((*it).second.a1));
    1460                                  fgsrgr = true;  continue; }
    1461   // Si c'est un attribut de markers
    1462   it = GrAmarkers.find(grt[k]);
    1463   if (it != GrAmarkers.end())  { mImgapp->SetMarkerAtt((*it).second.a2, (PIMarker)((*it).second.a1) );
    1464                                  fgsrgr = true;  continue; }
    1465   // Si c'est un colormap
    1466   it = GrAcmap.find(grt[k]);
    1467   if (it != GrAcmap.end())  { mImgapp->SetColMapId( (CMapId)((*it).second.a1) ); fgsrgr = true; continue; } 
    1468   // Si c'est un facteur de zoom
    1469   it = GrAzoom.find(grt[k]);
    1470   if (it != GrAzoom.end())  { mImgapp->SetZoomAtt( (*it).second.a1 );  fgsrgr = true; continue; } 
    1471   // Si c'est un attribut d'axe
    1472   it = GrAaxes.find(grt[k]);
    1473   if (it != GrAaxes.end())  { mImgapp->SetAxesAtt( (*it).second.a1 );  fgsrgr = true; continue; } 
    1474  
    1475   } 
    1476 
    1477 return(ropt);
    1478 }
    1479 
    1480 
    1481 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    1482 // Initialisation des chaines de caracteres designant les attributs graphiques
    1483 
    1484 /* --Methode-- */
    1485 void Services2NObjMgr::InitGrAttNames()
    1486 {
    1487 gratt_item gi;
    1488 // Les couleurs
    1489 gi.a2 = 0;
    1490 gi.a1 = PI_NotDefColor;
    1491 GrAcolors["defcol"] = gi;
    1492 gi.a1 = PI_Black;
    1493 GrAcolors["black"] = gi;
    1494 gi.a1 = PI_White;
    1495 GrAcolors["white"] = gi;
    1496 gi.a1 = PI_Grey;
    1497 GrAcolors["grey"] = gi;
    1498 gi.a1 = PI_Red;
    1499 GrAcolors["red"] = gi;
    1500 gi.a1 = PI_Blue;
    1501 GrAcolors["blue"] = gi;
    1502 gi.a1 = PI_Green;
    1503 GrAcolors["green"] = gi;
    1504 gi.a1 = PI_Yellow;
    1505 GrAcolors["yellow"] = gi;
    1506 gi.a1 = PI_Magenta;
    1507 GrAcolors["magenta"] = gi;
    1508 
    1509 gi.a1 = PI_Cyan;
    1510 GrAcolors["cyan"] = gi;
    1511 gi.a1 = PI_Turquoise;
    1512 GrAcolors["turquoise"] = gi;
    1513 gi.a1 = PI_NavyBlue;
    1514 GrAcolors["navyblue"] = gi;
    1515 gi.a1 = PI_Orange;
    1516 GrAcolors["orange"] = gi;
    1517 gi.a1 = PI_SiennaRed;
    1518 GrAcolors["siennared"] = gi;
    1519 gi.a1 = PI_Purple;
    1520 GrAcolors["purple"] = gi;
    1521 gi.a1 = PI_LimeGreen;
    1522 GrAcolors["limegreen"] = gi;
    1523 gi.a1 = PI_Gold;
    1524 GrAcolors["gold"] = gi;
    1525 gi.a1 = PI_Violet;
    1526 GrAcolors["violet"] = gi;
    1527 gi.a1 = PI_VioletRed;
    1528 GrAcolors["violetred"] = gi;
    1529 gi.a1 = PI_BlueViolet;
    1530 GrAcolors["blueviolet"] = gi;
    1531 gi.a1 = PI_DarkViolet;
    1532 GrAcolors["darkviolet"] = gi;
    1533 
    1534 // Les attributs de lignes
    1535 gi.a2 = 0;
    1536 gi.a1 = PI_NotDefLineAtt;
    1537 GrAlines["defline"] = gi;
    1538 gi.a1 = PI_NormalLine;
    1539 GrAlines["normalline"] = gi;
    1540 gi.a1 = PI_ThinLine;
    1541 GrAlines["thinline"] = gi;
    1542 gi.a1 = PI_ThickLine;
    1543 GrAlines["thickline"] = gi;
    1544 gi.a1 = PI_DashedLine;
    1545 GrAlines["dashedline"] = gi;
    1546 gi.a1 = PI_ThinDashedLine;
    1547 GrAlines["thindashedline"] = gi;
    1548 gi.a1 = PI_ThickDashedLine;
    1549 GrAlines["thickdashedline"] = gi;
    1550 gi.a1 = PI_DottedLine;
    1551 GrAlines["dottedline"] = gi;
    1552 gi.a1 = PI_ThinDottedLine;
    1553 GrAlines["thindottedline"] = gi;
    1554 gi.a1 = PI_ThickDottedLine;
    1555 GrAlines["thickdottedline"] = gi;
    1556 gi.a1 = PI_DashDottedLine;
    1557 GrAlines["dashdottedline"] = gi;
    1558 gi.a1 = PI_ThinDashDottedLine;
    1559 GrAlines["thindashdottedline"] = gi;
    1560 gi.a1 = PI_ThickDashDottedLine;
    1561 GrAlines["thickdashdottedline"] = gi;
    1562 
    1563 // Noms de fontes
    1564 gi.a2 = 0;
    1565 gi.a1 = PI_DefaultFont;
    1566 GrAfontNames["deffont"] = gi;
    1567 gi.a1 = PI_CourierFont;
    1568 GrAfontNames["courierfont"] = gi;
    1569 gi.a1 = PI_HelveticaFont;
    1570 GrAfontNames["helveticafont"] = gi;
    1571 gi.a1 = PI_TimesFont;
    1572 GrAfontNames["timesfont"] = gi;
    1573 gi.a1 = PI_SymbolFont;
    1574 GrAfontNames["symbolfont"] = gi;
    1575 
    1576 // Attributs de fontes
    1577 gi.a2 = PI_NotDefFontSize;
    1578 gi.a1 = PI_NotDefFontAtt;
    1579 GrAfontNames["deffontatt"] = gi;
    1580 gi.a2 = PI_NormalSizeFont;
    1581 gi.a1 = PI_RomanFont;
    1582 GrAfonts["normalfont"] = gi;
    1583 gi.a1 = PI_BoldFont;
    1584 GrAfonts["boldfont"] = gi;
    1585 gi.a1 = PI_ItalicFont;
    1586 GrAfonts["italicfont"] = gi;
    1587 gi.a1 = PI_BoldItalicFont;
    1588 GrAfonts["bolditalicfont"] = gi;
    1589 gi.a2 = PI_SmallSizeFont;
    1590 gi.a1 = PI_RomanFont;
    1591 GrAfonts["smallfont"] = gi;
    1592 gi.a1 = PI_BoldFont;
    1593 GrAfonts["smallboldfont"] = gi;
    1594 gi.a1 = PI_ItalicFont;
    1595 GrAfonts["smallitalicfont"] = gi;
    1596 gi.a1 = PI_BoldItalicFont;
    1597 GrAfonts["smallbolditalicfont"] = gi;
    1598 gi.a2 = PI_LargeSizeFont;
    1599 gi.a1 = PI_RomanFont;
    1600 GrAfonts["bigfont"] = gi;
    1601 GrAfonts["largefont"] = gi;
    1602 gi.a1 = PI_BoldFont;
    1603 GrAfonts["bigboldfont"] = gi;
    1604 gi.a1 = PI_ItalicFont;
    1605 GrAfonts["bigitalicfont"] = gi;
    1606 GrAfonts["largeitalicfont"] = gi;
    1607 gi.a1 = PI_BoldItalicFont;
    1608 GrAfonts["bigbolditalicfont"] = gi;
    1609 GrAfonts["largebolditalicfont"] = gi;
    1610 gi.a2 = PI_HugeSizeFont;
    1611 gi.a1 = PI_RomanFont;
    1612 GrAfonts["hugefont"] = gi;
    1613 gi.a1 = PI_BoldFont;
    1614 GrAfonts["hugeboldfont"] = gi;
    1615 gi.a1 = PI_ItalicFont;
    1616 GrAfonts["hugeitalicfont"] = gi;
    1617 gi.a1 = PI_BoldItalicFont;
    1618 GrAfonts["hugebolditalicfont"] = gi;
    1619 
    1620 
    1621 // Les markers
    1622 const char* mrkn[11] = { "dotmarker", "plusmarker", "crossmarker",
    1623                          "circlemarker", "fcirclemarker", "boxmarker", "fboxmarker",
    1624                          "trianglemarker", "ftrianglemarker", "starmarker", "fstarmarker"};
    1625 PIMarker mrk[11] = { PI_DotMarker, PI_PlusMarker, PI_CrossMarker,
    1626                      PI_CircleMarker, PI_FCircleMarker, PI_BoxMarker, PI_FBoxMarker,
    1627                      PI_TriangleMarker, PI_FTriangleMarker, PI_StarMarker, PI_FStarMarker};
    1628 
    1629 gi.a2 = 0;
    1630 gi.a1 = PI_NotDefMarker;
    1631 GrAmarkers["defmarker"] = gi;
    1632  
    1633 for(int j=0; j<11; j++) {
    1634   string smrk;
    1635   char buff[16];
    1636   for(int m=1; m<10; m+=2) {
    1637     sprintf(buff,"%d",m);
    1638     smrk = (string)mrkn[j] + (string)buff;
    1639     gi.a1 = mrk[j];  gi.a2 = m;
    1640     GrAmarkers[smrk] = gi;
    1641     }
    1642   }
    1643 
    1644 // Les tables de couleurs
    1645 gi.a2 = 0;
    1646 gi.a1 = CMAP_OTHER;
    1647 GrAcmap["defcmap"] = gi;
    1648 for(int kcc=0; kcc<PIColorMap::NumberStandardColorMaps(); kcc++) {
    1649   gi.a1 = PIColorMap::GetStandardColorMapId(kcc);
    1650   string colname = PIColorMap::GetStandardColorMapName(kcc);
    1651   for(int jll=0; jll<colname.length(); jll++)
    1652     colname[jll] = tolower(colname[jll]);
    1653   GrAcmap[colname] = gi;
    1654 }
    1655 
    1656 
    1657 // La valeur de zoom
    1658 gi.a2 = 0;
    1659 gi.a1 = 0;
    1660 GrAzoom["defzoom"] = gi;
    1661 gi.a1 = 1;
    1662 GrAzoom["zoomx1"] = gi;
    1663 gi.a1 = 2;
    1664 GrAzoom["zoomx2"] = gi;
    1665 gi.a1 = 3;
    1666 GrAzoom["zoomx3"] = gi;
    1667 gi.a1 = 4;
    1668 GrAzoom["zoomx4"] = gi;
    1669 gi.a1 = 5;
    1670 GrAzoom["zoomx5"] = gi;
    1671 gi.a1 = -2;
    1672 GrAzoom["zoom/2"] = gi;
    1673 gi.a1 = -3;
    1674 GrAzoom["zoom/3"] = gi;
    1675 gi.a1 = -4;
    1676 GrAzoom["zoom/4"] = gi;
    1677 gi.a1 = -5;
    1678 GrAzoom["zoom/5"] = gi;
    1679 
    1680 // Attributs d'axes
    1681 gi.a2 = 0;
    1682 gi.a1 = (int)(kBoxAxes | kExtTicks | kLabels);
    1683 GrAaxes["stdaxes"] = gi;
    1684 GrAaxes["defaxes"] = gi;
    1685 GrAaxes["boxaxes"] = gi;
    1686 gi.a1 = (int)kAxesDflt;
    1687 GrAaxes["simpleaxes"] = gi;
    1688 gi.a1 = (int)(kBoxAxes | kExtTicks | kLabels | kGridOn);
    1689 GrAaxes["boxaxesgrid"] = gi;
    1690 
    1691 gi.a1 = (int)(kBoxAxes | kTicks | kLabels | kMinTicks | kMajTicks);
    1692 GrAaxes["fineaxes"] = gi;
    1693  gi.a1 = (int)(kBoxAxes | kTicks | kLabels | kMinTicks | kMajTicks | kGridOn);
    1694 GrAaxes["grid"] = gi;
    1695 GrAaxes["fineaxesgrid"] = gi;
    1696                
    1697 }
    16981298
    16991299
  • trunk/SophyaPI/PIext/servnobjm.h

    r1569 r1971  
    113113// Utilitaires divers
    114114  static void   DecodeLoopParameters(string& loop, int& i1, int& i2, int& di);
    115   int           DecodeDispOption(string& dopt, bool& fgsrgr);
    116   static bool   GetStatsOption(string& dopt);
    117   static void   SetDefaultStatsOption(bool opt);
    118115  string        FileName2Name(string const & fn);
    119116  char*         PClassIdToClassName(int cid);
    120117
    121118protected:
    122   void          InitGrAttNames();
    123119
    124120// Pour enregister les objets et leurs adaptateurs pour NamedObjMgr
     
    129125  ObjAdaptList objadaplist;
    130126
    131 //   Variables membre , en public pour le moment
    132   struct gratt_item {
    133     int a1, a2;
    134   };
    135   typedef map<string, gratt_item, less<string> > GrAttNames;
    136  
    137 //  Pour les changements d'attributs graphiques / de visualisation
    138   GrAttNames GrAcolors;
    139   GrAttNames GrAlines;
    140   GrAttNames GrAmarkers;
    141   GrAttNames GrAfonts;
    142   GrAttNames GrAfontNames;
    143   GrAttNames GrAcmap; 
    144   GrAttNames GrAzoom; 
    145   GrAttNames GrAaxes; 
    146127
    147128  PDynLinkMgr * dynlink;  // shared-lib lib.so
Note: See TracChangeset for help on using the changeset viewer.