Changeset 1642 in Sophya for trunk/SophyaPI/PIext


Ignore:
Timestamp:
Aug 16, 2001, 2:19:01 PM (24 years ago)
Author:
ansari
Message:

1/ Definition d'attributs graphiques texte pour les nouvelles couleurs violettes
2/ Ajout commandes addline addrect addfrect addfcircle ....

Reza 16/8/2001

Location:
trunk/SophyaPI/PIext
Files:
4 edited

Legend:

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

    r1569 r1642  
    9898  }
    9999else if (kw == "addtext") {
    100   if (tokens.size() < 4) { cout << "Usage: addtext x y colfontatt txt" << endl;  return(0); }
     100  if (tokens.size() < 3) { cout << "Usage: addtext x y txt [colfontatt]" << endl;  return(0); }
    101101  double xp = atof(tokens[0].c_str());
    102102  double yp = atof(tokens[1].c_str());
    103   bool fgsr = true;
    104   string txt = tokens[3];
    105   for(int k=4; k<(int)tokens.size(); k++) txt += (' ' + tokens[k]);
    106   //int opt = mObjMgr->GetServiceObj()->DecodeDispOption(tokens[2], fgsr);
     103  string txt = tokens[2];
     104  bool fgsr = false;
     105  if (tokens.size() > 3)
     106    mObjMgr->GetServiceObj()->DecodeDispOption(tokens[3], fgsr);
    107107  mImgApp->AddText(txt, xp, yp);
    108108  if (fgsr) mImgApp->RestoreGraphicAtt();
    109109  }
     110else if ((kw == "addline") || (kw == "addrect") || (kw == "addfrect")) {
     111  if (tokens.size() < 4) { cout << "Usage: addline/addrect/addfrect x1 y1 x2 y2 [colatt]" << endl;  return(0); }
     112  double xp1 = atof(tokens[0].c_str());
     113  double yp1 = atof(tokens[1].c_str());
     114  double xp2 = atof(tokens[2].c_str());
     115  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);
     120  else {
     121    bool fgfill = (kw == "addrect") ? false : true;
     122    mImgApp->AddRectangle(xp1, yp1, xp2, yp2, fgfill);
     123  }
     124  if (fgsr) mImgApp->RestoreGraphicAtt();
     125  }
     126else if ((kw == "addcirc") || (kw == "addfcirc")) {
     127  if (tokens.size() < 3) { cout << "Usage: addcirc/addfcirc xc yc r [colatt]" << endl;  return(0); }
     128  double xc = atof(tokens[0].c_str());
     129  double yc = atof(tokens[1].c_str());
     130  double rad = atof(tokens[2].c_str());
     131  bool fgsr = false;
     132  if (tokens.size() > 3)
     133    mObjMgr->GetServiceObj()->DecodeDispOption(tokens[3], fgsr);
     134  bool fgfill = (kw == "addcirc") ? false : true;
     135  mImgApp->AddCircle(xc, yc, rad, fgfill);
     136  if (fgsr) mImgApp->RestoreGraphicAtt();
     137  }
     138
     139
    110140else if (kw == "settitle") {
    111   if (tokens.size() < 2) { cout << "Usage: addtitle fontatt titleup " << endl;  return(0); }
     141  if (tokens.size() < 1) { cout << "Usage: settitle TopTitle [BotTitle] [fontatt]" << endl;  return(0); }
    112142  bool fgsr = true;
    113   //int opt = mObjMgr->GetServiceObj()->DecodeDispOption(tokens[0], fgsr);
    114   string txt = tokens[1];
    115   for(int k=2; k<(int)tokens.size(); k++) txt += (' ' + tokens[k]);
    116   string td = "";
    117   mImgApp->SetTitle(txt, td);
     143  if (tokens.size() > 2)
     144    mObjMgr->GetServiceObj()->DecodeDispOption(tokens[2], fgsr);
     145  if (tokens.size() < 2)
     146    tokens.push_back("");
     147  mImgApp->SetTitle(tokens[0], tokens[1]);
    118148  if (fgsr) mImgApp->RestoreGraphicAtt();
    119149  }
     
    744774usage += "att_list=def back to default values, Example: gratt red,circlemarker5";
    745775usage += "\n ------------------ Graphic attribute list ------------------ \n";
    746 usage += ">> Colors: defcol black white grey red blue green yellow magenta cyan \n";
    747 usage += "           turquoise navyblue orange siennared purple limegreen gold \n";
     776usage += ">> Colors: defcol black white grey red blue green yellow \n";
     777usage += "           magenta cyan turquoise navyblue orange siennared purple \n";
     778usage += "           limegreen gold violet violetred blueviolet darkviolet \n";
    748779usage += ">> Lines:  defline normalline thinline thickline dashedline thindashedline \n";
    749780usage += "           thickdashedline dottedline thindottedline thickdottedline \n";
     
    796827kw = "addtext";
    797828usage = "Adds a text string to the current graphic object";
    798 usage += "\n at the specified position (Gr-Object Coordinate) with graphic attribute specification";
    799 usage += "\n  Usage: addtext x y ColFontAtt TextString";
    800 usage += "\n  Related commands: settitle graphicatt"; 
     829usage += "\n at the specified position (+ color and font attributes) ";
     830usage += "\n The Base/AxesDrawer is used to handle added text strings" ;
     831usage += "\n Alt<Z> to remove added elements";
     832usage += "\n Font attribute is common with axes";
     833usage += "\n  Usage: addtext x y TextString [ColFontAtt]";
     834usage += "\n  (use quotes '' for multi word text strings) ";
     835usage += "\n  Related commands: addline addrect addfrect addcirc addfcirc settitle graphicatt"; 
    801836mpiac->RegisterCommand(kw, usage, this, "Graphics");
    802837
     838kw = "addline";
     839usage = "Adds a line to the current graphic object";
     840usage += "\n at the specified position (+ color attribute)";
     841usage += "\n The Base/AxesDrawer is used to handle added lines";
     842usage += "\n Alt<Z> to remove added elements";
     843usage += "\n  Usage: addline x1 y1 x2 y2 [ColAtt]";
     844usage += "\n  Related commands: addtext addrect addfrect addcirc addfcirc graphicatt"; 
     845mpiac->RegisterCommand(kw, usage, this, "Graphics");
     846
     847kw = "addrect";
     848usage = "Adds a rectangle to the current graphic object";
     849usage += "\n between the specified positions (+ color attribute)";
     850usage += "\n The Base/AxesDrawer is used to handle added rectangle";
     851usage += "\n Alt<Z> to remove added elements";
     852usage += "\n  Usage: addrect x1 y1 x2 y2 [ColAtt]";
     853usage += "\n  Related commands: addtext addline addfrect addcirc addfcirc graphicatt"; 
     854mpiac->RegisterCommand(kw, usage, this, "Graphics");
     855
     856kw = "addfrect";
     857usage = "Adds a filled rectangle to the current graphic object";
     858usage += "\n between the specified positions (+ color attribute)";
     859usage += "\n The Base/AxesDrawer is used to handle added rectangle";
     860usage += "\n Alt<Z> to remove added elements";
     861usage += "\n  Usage: addfrect x1 y1 x2 y2 [ColAtt]";
     862usage += "\n  Related commands: addtext addline addrect addcirc addfcirc graphicatt"; 
     863mpiac->RegisterCommand(kw, usage, this, "Graphics");
     864
     865kw = "addcirc";
     866usage = "Adds a circle to the current graphic object";
     867usage += "\n with the specified center and radius (+ color attribute)";
     868usage += "\n The Base/AxesDrawer is used to handle added circles";
     869usage += "\n Alt<Z> to remove added elements";
     870usage += "\n  Usage: addcirc xcenter ycenter radius [ColAtt]";
     871usage += "\n  Related commands: addtext addline addfrect addfrect addfcirc graphicatt"; 
     872mpiac->RegisterCommand(kw, usage, this, "Graphics");
     873
     874kw = "addfcirc";
     875usage = "Adds a filled circle to the current graphic object";
     876usage += "\n with the specified center and radius (+ color attribute)";
     877usage += "\n The Base/AxesDrawer is used to handle added circles";
     878usage += "\n Alt<Z> to remove added elements";
     879usage += "\n  Usage: addcirc xcenter ycenter radius [ColAtt]";
     880usage += "\n  Related commands: addtext addline addfrect addfrect addcirc graphicatt"; 
     881mpiac->RegisterCommand(kw, usage, this, "Graphics");
     882
    803883kw = "settitle";
    804 usage = "Set the title string (top title) for the current graphic object";
    805 usage += "\n  Usage: settitle FontAtt TopTitle";
     884usage = "Set the title string (top title / bottom title) for the current graphic object";
     885usage += "\n  Usage: settitle TopTitle [BottomTitle] [fontAtt]";
    806886usage += "\n  Related commands: addtext graphicatt"; 
    807887mpiac->RegisterCommand(kw, usage, this, "Graphics");
  • trunk/SophyaPI/PIext/pistdimgapp.cc

    r1593 r1642  
    661661void PIStdImgApp::AddText(string const & txt, double xp, double yp)
    662662{
    663 if (!mLastWdg)  return;
     663PIElDrawer *eld=CurrentElDrawer();
     664if (eld == NULL) return;
     665
     666if ( (mFSz != PI_NotDefFontSize) && (mFAtt != PI_NotDefFontAtt) )
     667  eld->SetFontAtt(mFSz, mFAtt);
     668if ( mFName != PI_DefaultFont )
     669  eld->SetFont(mFName, eld->GetFontSz(), eld->GetFontAtt());
     670eld->ElAddText(xp,yp,txt.c_str(),mFCol);
     671eld->Refresh();
     672}
     673
     674/* --Methode-- */
     675void PIStdImgApp::AddLine(double xp1, double yp1, double xp2, double yp2)
     676{
     677PIElDrawer *eld=CurrentElDrawer();
     678if (eld == NULL) return;
     679
     680eld->ElAddLine(xp1, yp1, xp2, yp2, mFCol);
     681eld->Refresh();
     682}
     683
     684/* --Methode-- */
     685void PIStdImgApp::AddRectangle(double xp1, double yp1, double xp2, double yp2, bool fgfill)
     686{
     687PIElDrawer *eld=CurrentElDrawer();
     688if (eld == NULL) return;
     689
     690double xp,yp;
     691double dx, dy;
     692if (xp1 < xp2) {
     693  xp = xp1; dx = xp2-xp1;
     694}
     695else {
     696  xp = xp2; dx = xp1-xp2;
     697}
     698if (yp1 < yp2) {
     699  yp = yp1; dy = yp2-yp1;
     700}
     701else {
     702  yp = yp2; dy = yp1-yp2;
     703}
     704if (fgfill) eld->ElAddFRect(xp, yp, dx, dy, mFCol);
     705else eld->ElAddRect(xp, yp, dx, dy, mFCol);
     706eld->Refresh();
     707}
     708
     709/* --Methode-- */
     710void PIStdImgApp::AddCircle(double xc, double yc, double r, bool fgfill)
     711{
     712PIElDrawer *eld=CurrentElDrawer();
     713if (eld == NULL) return;
     714
     715if (fgfill) eld->ElAddFCirc(xc, yc, r, mFCol);
     716else eld->ElAddCirc(xc, yc, r, mFCol);
     717eld->Refresh();
     718}
     719
     720/* --Methode-- */
     721void PIStdImgApp::SetTitle(string const & titletop, string const & titlebottom)
     722{
     723PIElDrawer *eld=CurrentElDrawer();
     724if (eld == NULL) return;
     725
     726if ( (mFSz != PI_NotDefFontSize) && (mFAtt != PI_NotDefFontAtt) )
     727  eld->SetFontAtt(mFSz, mFAtt);
     728if ( mFName != PI_DefaultFont )
     729  eld->SetFont(mFName, eld->GetFontSz(), eld->GetFontAtt());
     730eld->SetTitles(titletop, titlebottom);
     731eld->Refresh();
     732}
     733
     734/* --Methode-- */
     735PIElDrawer* PIStdImgApp::CurrentElDrawer()
     736{
    664737PIElDrawer *eld=NULL;
     738if (!mLastWdg)  return(eld);
    665739PIScDrawWdg* sdw=NULL;
    666740PIDraw3DWdg* w3d=NULL;
     
    677751  case PIImage::ClassId :
    678752    imgw = dynamic_cast<PIImage *>(mLastWdg);
    679     if (imgw) eld = imgw->MyElDrawer();
     753    if (imgw) eld = imgw->BaseDrawer();
    680754    break;
    681755  default :
    682756    break;
    683757  }
    684 if (eld) {
    685   if ( (mFSz != PI_NotDefFontSize) && (mFAtt != PI_NotDefFontAtt) )     eld->SetFontAtt(mFSz, mFAtt);
    686   eld->ElAddText(xp,yp,txt.c_str(),mFCol);
    687   eld->Refresh();
    688   }
    689 }
    690 /* --Methode-- */
    691 void PIStdImgApp::SetTitle(string const & titletop, string const & titlebottom)
    692 {
    693 if (!mLastWdg)  return;
    694 PIElDrawer *eld=NULL;
    695 PIScDrawWdg* sdw=NULL;
    696 PIDraw3DWdg* w3d=NULL;
    697 PIImage* imgw;
    698 switch(mLastWdg->kind()) {
    699   case PIScDrawWdg::ClassId :
    700     sdw = dynamic_cast<PIScDrawWdg *>(mLastWdg);
    701     if (sdw) eld = sdw->BaseDrawer();
    702     break;
    703   case PIDraw3DWdg::ClassId :
    704     w3d = dynamic_cast<PIDraw3DWdg *>(mLastWdg);
    705     if (w3d) eld = w3d->BaseDrawer();
    706     break;
    707   case PIImage::ClassId :
    708     imgw = dynamic_cast<PIImage *>(mLastWdg);
    709     if (imgw) eld = imgw->MyElDrawer();
    710     break;
    711   default :
    712     break;
    713   }
    714 if (eld) {
    715   if ( (mFSz != PI_NotDefFontSize) && (mFAtt != PI_NotDefFontAtt) )     eld->SetFontAtt(mFSz, mFAtt);
    716   eld->SetTitles(titletop, titlebottom);
    717   eld->Refresh();
    718   }
     758return(eld);
    719759}
    720760
  • trunk/SophyaPI/PIext/pistdimgapp.h

    r1569 r1642  
    5151     int  Disp3DDrawer(PIDrawer3D* scd, string const & name, int opt, string title="", int oid=0);
    5252
    53   //  Fonction d'ajout de texte (provisoire - Aout 99)
     53  //  Fonction d'ajout de texte (provisoire - Aout 99) 
    5454     void AddText(string const & txt, double xp, double yp);
     55  //  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);
     59
    5560  //  Fonction Ajout de titre de trace
    5661     void SetTitle(string const & titleup, string const & titledown);
    5762
     63  //  Acces au BaseDrawer (PIElDrawer) du PIBaseWdg courant
     64     PIElDrawer* CurrentElDrawer();
    5865
    5966     void CreateGraphWin(int nx=1, int ny=1, int sx=0, int sy = 0);
  • trunk/SophyaPI/PIext/servnobjm.cc

    r1569 r1642  
    15151515gi.a1 = PI_Gold;
    15161516GrAcolors["gold"] = gi;
     1517gi.a1 = PI_Violet;
     1518GrAcolors["violet"] = gi;
     1519gi.a1 = PI_VioletRed;
     1520GrAcolors["violetred"] = gi;
     1521gi.a1 = PI_BlueViolet;
     1522GrAcolors["blueviolet"] = gi;
     1523gi.a1 = PI_DarkViolet;
     1524GrAcolors["darkviolet"] = gi;
    15171525
    15181526// Les attributs de lignes
Note: See TracChangeset for help on using the changeset viewer.