Changeset 2265 in Sophya for trunk/SophyaPI/PIext


Ignore:
Timestamp:
Nov 15, 2002, 12:58:41 AM (23 years ago)
Author:
ansari
Message:

Ajout addarca et addfarca: Trace d'arc defini par un angle et dangle + sum/product/mean/sigma ds RPNEvaluator - Reza 14/11/2002

Location:
trunk/SophyaPI/PIext
Files:
4 edited

Legend:

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

    r2263 r2265  
    117117  double ymax = atof(tokens[3].c_str());
    118118  char buff[128];
    119   sprintf(buff, "axesnone xylimits=%g,%g,%g,%g", xmin, xmax, ymin, ymax);
     119  sprintf(buff, "axesnone xylimits=%g,%g,%g,%g ", xmin, xmax, ymin, ymax);
    120120  string sop = buff;
    121121  if (tokens.size() > 4) sop += tokens[4];
    122122  string name;
    123   if (tokens.size() > 5) sop += tokens[5];
     123  if (tokens.size() > 5) name = tokens[5];
    124124  PIFuncDrawer* gdr = new PIFuncDrawer(NULL);
    125125  mImgApp->DispScDrawer(gdr, name, sop);
     
    185185  bool fgfill = (kw == "addcirc") ? false : true;
    186186  mImgApp->AddCircle(xc, yc, rad, sop, fgfill, fgnc);
     187  }
     188else if ((kw == "addarca") || (kw == "addfarca")) {
     189  if (tokens.size() < 5) {
     190    cout << "Usage: addarca/addfarca xc yc r a da [colatt] [fgnc]" << endl; 
     191    return(0);
     192  }
     193  double xc = atof(tokens[0].c_str());
     194  double yc = atof(tokens[1].c_str());
     195  double rad = atof(tokens[2].c_str());
     196  double ang = atof(tokens[3].c_str());
     197  double dang = atof(tokens[4].c_str());
     198  string sop;
     199  if (tokens.size() > 5) sop = tokens[5];
     200  bool fgnc = _CkBoolNC_(6); 
     201  bool fgfill = (kw == "addarca") ? false : true;
     202  mImgApp->AddArc(xc, yc, rad, ang, dang, sop, fgfill, fgnc);
    187203  }
    188204else if (kw == "addmarker") {
     
    10011017usage += "\n at the specified position (+ color/font/pos/dir attributes) ";
    10021018usage += "\n The Base/AxesDrawer is used to handle added text strings" ;
    1003 usage += "\n Alt<Z> to remove added elements";
     1019usage += "\n Alt<E> to remove the added element";
    10041020usage += "\n  Usage: addtext x y TextString [ColFontPosAtt] [fgnc=false/true]";
    10051021usage += "\n  (use quotes '' for multi word text strings) ";
     
    10111027usage += "\n  Related commands: addctext addline addarrow addrect addfrect";
    10121028usage += "\n      addcirc addfcirc addarc addfrac addpoly addfpoly settitle graphicatt"; 
    1013 mpiac->RegisterCommand(kw, usage, this, "Graphics");
     1029mpiac->RegisterCommand(kw, usage, this, "Graphic-Elts");
    10141030
    10151031kw = "addctext";
     
    10201036usage += "\n  Related commands: addtext addline addrect ...";
    10211037usage += "\n      (See command addtext and graphicatt for more details)"; 
    1022 mpiac->RegisterCommand(kw, usage, this, "Graphics");
     1038mpiac->RegisterCommand(kw, usage, this, "Graphic-Elts");
    10231039
    10241040kw = "addline";
     
    10261042usage += "\n at the specified position (+ graphic attribute)";
    10271043usage += "\n The Base/AxesDrawer is used to handle added lines";
    1028 usage += "\n Alt<Z> to remove added elements";
     1044usage += "\n Alt<E> to remove the added element";
    10291045usage += "\n  Usage: addline x1 y1 x2 y2 [GraphicAtt] [fgnc=false/true]";
    10301046usage += "\n  if fgnc==true : Normalized 0..1 coordinates specification (def=false)";
    10311047usage += "\n  Related commands: addarrow addtext addrect addfrect ";
    10321048usage += "\n       addmarker addcirc addfcirc addarc addfarc addpoly addfpoly graphicatt"; 
    1033 mpiac->RegisterCommand(kw, usage, this, "Graphics");
     1049mpiac->RegisterCommand(kw, usage, this, "Graphic-Elts");
    10341050
    10351051kw = "addarrow";
     
    10371053usage += "\n at the specified position (+ graphic attribute)";
    10381054usage += "\n The Base/AxesDrawer is used to handle added lines";
    1039 usage += "\n Alt<Z> to remove added elements";
     1055usage += "\n Alt<E> to remove the added element";
    10401056usage += "\n  Usage: addarrow x1 y1 x2 y2 [GraphicAtt] [fgnc=false/true]";
    10411057usage += "\n  if fgnc==true : Normalized 0..1 coordinates specification (def=false)";
    10421058usage += "\n  Related commands: addline addtext addrect addfrect ";
    10431059usage += "\n       addmarker addcirc addfcirc addarc addfarc addpoly addfpoly graphicatt"; 
    1044 mpiac->RegisterCommand(kw, usage, this, "Graphics");
     1060mpiac->RegisterCommand(kw, usage, this, "Graphic-Elts");
    10451061kw = "addarrow_nc";
    10461062
     
    10491065usage += "\n between the specified positions (+ graphic attribute)";
    10501066usage += "\n The Base/AxesDrawer is used to handle added rectangle";
    1051 usage += "\n Alt<Z> to remove added elements";
     1067usage += "\n Alt<E> to remove added element";
    10521068usage += "\n  Usage: addrect x1 y1 x2 y2 [GraphicAtt] [fgnc=false/true]";
    10531069usage += "\n  if fgnc==true : Normalized 0..1 coordinates specification (def=false)";
    10541070usage += "\n  Related commands: addtext addline addarrow addfrect";
    10551071usage += "\n       addcirc addfcirc addarc addfarc addpoly addfpoly graphicatt"; 
    1056 mpiac->RegisterCommand(kw, usage, this, "Graphics");
     1072mpiac->RegisterCommand(kw, usage, this, "Graphic-Elts");
    10571073
    10581074kw = "addfrect";
     
    10601076usage += "\n between the specified positions (+ graphic attribute)";
    10611077usage += "\n The Base/AxesDrawer is used to handle added rectangle";
    1062 usage += "\n Alt<Z> to remove added elements";
     1078usage += "\n Alt<E> to remove added element";
    10631079usage += "\n  Usage: addfrect x1 y1 x2 y2 [GraphicAtt] [fgnc=false/true]";
    10641080usage += "\n  if fgnc==true : Normalized 0..1 coordinates specification (def=false)";
    10651081usage += "\n  Related commands: addtext addline addarrow addrect";
    10661082usage += "\n       addcirc addfcirc addpoly addfpoly graphicatt"; 
    1067 mpiac->RegisterCommand(kw, usage, this, "Graphics");
     1083mpiac->RegisterCommand(kw, usage, this, "Graphic-Elts");
    10681084
    10691085kw = "addmarker";
     
    10711087usage += "\n at the specified position (+ graphic attribute)";
    10721088usage += "\n The Base/AxesDrawer is used to handle added circles";
    1073 usage += "\n Alt<Z> to remove added elements";
     1089usage += "\n Alt<E> to remove added element";
    10741090usage += "\n  Usage: addmarker xpos ypos [GraphicAtt] [fgnc=false/true]";
    10751091usage += "\n  if fgnc==true : Normalized 0..1 coordinates specification (def=false)";
    10761092usage += "\n  Related commands: addtext addline addarrow addfrect addfrect";
    10771093usage += "\n       addcirc addfcirc addarc addfarc addpoly addfpoly graphicatt"; 
    1078 mpiac->RegisterCommand(kw, usage, this, "Graphics");
     1094mpiac->RegisterCommand(kw, usage, this, "Graphic-Elts");
    10791095
    10801096kw = "addcirc";
     
    10821098usage += "\n with the specified center and radius (+ graphic attribute)";
    10831099usage += "\n The Base/AxesDrawer is used to handle added circles";
    1084 usage += "\n Alt<Z> to remove added elements";
     1100usage += "\n Alt<E> to remove added element";
    10851101usage += "\n  Usage: addcirc xcenter ycenter radius [GraphicAtt] [fgnc=false/true]";
    10861102usage += "\n  if fgnc==true : Normalized 0..1 coordinates specification (def=false)";
    10871103usage += "\n  Related commands: addtext addline addarrow addfrect addfrect";
    10881104usage += "\n       addfcirc addarc addfarc addpoly addfpoly graphicatt"; 
    1089 mpiac->RegisterCommand(kw, usage, this, "Graphics");
     1105mpiac->RegisterCommand(kw, usage, this, "Graphic-Elts");
    10901106
    10911107kw = "addfcirc";
     
    10931109usage += "\n with the specified center and radius (+ graphic attribute)";
    10941110usage += "\n The Base/AxesDrawer is used to handle added circles";
    1095 usage += "\n Alt<Z> to remove added elements";
     1111usage += "\n Alt<E> to remove added element";
    10961112usage += "\n  Usage: addcirc xcenter ycenter radius [GraphicAtt] [fgnc=false/true]";
    10971113usage += "\n  if fgnc==true : Normalized 0..1 coordinates specification (def=false)";
    10981114usage += "\n  Related commands: addtext addline addarrow addfrect addfrect";
    10991115usage += "\n       addcirc addarc addfarc addpoly addfpoly graphicatt"; 
    1100 mpiac->RegisterCommand(kw, usage, this, "Graphics");
     1116mpiac->RegisterCommand(kw, usage, this, "Graphic-Elts");
     1117
     1118kw = "addarca";
     1119usage = "Adds an arc to the current graphic object";
     1120usage += "\n defined by the circle (center+radius), start angle and angular extension";
     1121usage += "\n Angles are specified in degrees";
     1122usage += "\n  Usage: addarca xc yc r a0deg dadeg [GraphicAtt] [fgnc=false/true]";
     1123usage += "\n  if fgnc==true : Normalized 0..1 coordinates specification (def=false)";
     1124usage += "\n  Related commands: addtext addline addfarca addarc ...";
     1125mpiac->RegisterCommand(kw, usage, this, "Graphic-Elts");
     1126
     1127kw = "addfarca";
     1128usage = "Adds a filled arc to the current graphic object";
     1129usage += "\n defined by the circle (center+radius), start angle and angular extension";
     1130usage += "\n Angles are specified in degrees";
     1131usage += "\n  Usage: addfarca xc yc r a0deg dadeg [GraphicAtt] [fgnc=false/true]";
     1132usage += "\n  if fgnc==true : Normalized 0..1 coordinates specification (def=false)";
     1133usage += "\n  Related commands: addtext addline addarca addarc ...";
     1134mpiac->RegisterCommand(kw, usage, this, "Graphic-Elts");
    11011135
    11021136kw = "addarc";
     
    11041138usage += "\n defined by 3 points (+ graphic attribute)";
    11051139usage += "\n The Base/AxesDrawer is used to handle added arcs";
    1106 usage += "\n Alt<Z> to remove added elements";
     1140usage += "\n Alt<E> to remove the added element";
     1141usage += "\n  Usage: addarc x1 y1 x2 y2 x3 y3 [GraphicAtt] [fgnc=false/true]";
     1142usage += "\n  if fgnc==true : Normalized 0..1 coordinates specification (def=false)";
     1143usage += "\n  Related commands: addtext addline addarrow addfrect addfrect";
     1144usage += "\n       addcirc addfcirc addfarc addarca addpoly addfpoly graphicatt"; 
     1145mpiac->RegisterCommand(kw, usage, this, "Graphic-Elts");
     1146
     1147kw = "addfarc";
     1148usage = "Adds a filled arc to the current graphic object";
     1149usage += "\n defined by 3 points (+ graphic attribute)";
     1150usage += "\n The Base/AxesDrawer is used to handle added arcs";
     1151usage += "\n Alt<E> to remove added element";
    11071152usage += "\n  Usage: addarc x1 y1 x2 y2 x3 y3 [GraphicAtt] [fgnc=false/true]";
    11081153usage += "\n  if fgnc==true : Normalized 0..1 coordinates specification (def=false)";
    11091154usage += "\n  Related commands: addtext addline addarrow addfrect addfrect";
    11101155usage += "\n       addcirc addfcirc addfarc addpoly addfpoly graphicatt"; 
    1111 mpiac->RegisterCommand(kw, usage, this, "Graphics");
    1112 
    1113 kw = "addfarc";
    1114 usage = "Adds a filled arc to the current graphic object";
    1115 usage += "\n defined by 3 points (+ graphic attribute)";
    1116 usage += "\n The Base/AxesDrawer is used to handle added arcs";
    1117 usage += "\n Alt<Z> to remove added elements";
    1118 usage += "\n  Usage: addarc x1 y1 x2 y2 x3 y3 [GraphicAtt] [fgnc=false/true]";
    1119 usage += "\n  if fgnc==true : Normalized 0..1 coordinates specification (def=false)";
    1120 usage += "\n  Related commands: addtext addline addarrow addfrect addfrect";
    1121 usage += "\n       addcirc addfcirc addfarc addpoly addfpoly graphicatt"; 
    1122 mpiac->RegisterCommand(kw, usage, this, "Graphics");
     1156mpiac->RegisterCommand(kw, usage, this, "Graphic-Elts");
    11231157
    11241158kw = "addpoly";
     
    11291163usage += "\n  Related commands: addtext addline addarrow addfrect addfrect";
    11301164usage += "\n       addcirc addfcirc addfarc  graphicatt"; 
    1131 mpiac->RegisterCommand(kw, usage, this, "Graphics");
     1165mpiac->RegisterCommand(kw, usage, this, "Graphic-Elts");
    11321166
    11331167kw = "addfpoly";
     
    11381172usage += "\n  Related commands: addtext addline addarrow addfrect addfrect";
    11391173usage += "\n       addcirc addfcirc addfarc  graphicatt"; 
    1140 mpiac->RegisterCommand(kw, usage, this, "Graphics");
     1174mpiac->RegisterCommand(kw, usage, this, "Graphic-Elts");
    11411175
    11421176kw = "settitle";
  • trunk/SophyaPI/PIext/piacmd.cc

    r2263 r2265  
    12331233}
    12341234
     1235int Sum_RPNStack_(stack<double>& s, double& sx, double& sx2, string& line)
     1236{
     1237  sx = sx2 = 0.;
     1238  int nn = 0;
     1239  double x = 0.;
     1240  while( !s.empty() ) {
     1241    x = s.top(); s.pop();
     1242    sx += x; sx2 += x*x;
     1243    nn++;
     1244  }
     1245  return(nn); 
     1246}
     1247
     1248int Product_RPNStack_(stack<double>& s, double& px, string& line)
     1249{
     1250  px = 1.;
     1251  int nn = 0;
     1252  double x = 0.;
     1253  while( !s.empty() ) {
     1254    x = s.top(); s.pop();
     1255    px *= x;  nn++;
     1256  }
     1257  return(nn); 
     1258}
    12351259 
    12361260/* --Methode-- */
     
    13291353      if ( Check_myRPNStack_(rpnstack, x, y, line) ) return(1);
    13301354      rpnstack.top() = atan2(x,y);
     1355    }
     1356    // Fonction a N arguments  - Somme, produit, etc ...
     1357    else if ((args[k] == "sum") || (args[k] == "mean") ||
     1358             (args[k] == "sigma") || (args[k] == "sigma2") ) {
     1359      double sx, sx2;
     1360      int nn = Sum_RPNStack_(rpnstack, sx, sx2, line);
     1361      if (args[k] == "sum") rpnstack.push(sx);
     1362      else {
     1363        if (nn == 0) {
     1364          cerr << "PIACmd::EvalRPNExpr: mean/sigma error- RPN stack empty: "
     1365               << line << endl;
     1366          return(1);
     1367        }
     1368        double fnn = nn;
     1369        if (args[k] == "mean")  rpnstack.push(sx/fnn);
     1370        else if (args[k] == "sigma2") rpnstack.push(sx2/fnn-(x*x/(fnn*fnn)));
     1371        else rpnstack.push(sqrt(sx2/fnn-(x*x/(fnn*fnn))));
     1372      }
     1373    }
     1374    else if (args[k] == "product") {
     1375      double px;
     1376      int nn = Product_RPNStack_(rpnstack, px, line);
     1377      if (nn == 0) {
     1378        cerr << "PIACmd::EvalRPNExpr: product error- RPN stack empty: "
     1379             << line << endl;
     1380        return(1);
     1381      }
     1382      rpnstack.push(px);
    13311383    }
    13321384    // Fonctions de manipulation de stack
  • trunk/SophyaPI/PIext/pistdimgapp.cc

    r2263 r2265  
    933933eld->Refresh();
    934934}
     935/* --Methode-- */
     936void PIStdImgApp::AddArc(double xc, double yc, double r, double a, double da,
     937                         string const& sop, bool fgfill, bool fgcn)
     938{
     939PIDrawer *eld=CurrentElDrawer();
     940if (eld == NULL) return;
     941PIElDrawer* eld2 = dynamic_cast<PIElDrawer *>(eld);
     942PIElDrawer3D* eld3 = dynamic_cast<PIElDrawer3D *>(eld);
     943if ((eld2 == NULL) && (eld3 == NULL)) return;
     944PIElDrwMgr* elmgr = NULL;
     945if (eld2) elmgr = &(eld2->ElDrwMgr());
     946else if (eld3) elmgr = &(eld3->ElDrwMgr());
     947
     948vector<string> opts;
     949ParseDisplayOption(sop, opts);
     950PIGraphicAtt gratt(opts);
     951if (fgfill) elmgr->ElAddFArc(xc, yc, r, a, da, gratt, fgcn);
     952else elmgr->ElAddArc(xc, yc, r, a, da, gratt, fgcn);
     953eld->Refresh();
     954}
    935955
    936956/* --Methode-- */
  • trunk/SophyaPI/PIext/pistdimgapp.h

    r2263 r2265  
    7777     void AddCircle(double xc, double yc, double r, string const& opt,
    7878                    bool fgfill=false, bool fgcn=false);
     79     void AddArc(double xc, double yc, double r, double a, double da,
     80                 string const& opt, bool fgfill=false, bool fgcn=false);
    7981     void AddArc(double x1, double y1, double x2, double y2,
    8082                 double x3, double y3, string const& opt, bool fgfill=false, bool fgcn=false);
Note: See TracChangeset for help on using the changeset viewer.