Changeset 2263 in Sophya for trunk/SophyaPI/PIext/basexecut.cc


Ignore:
Timestamp:
Nov 14, 2002, 8:12:02 PM (23 years ago)
Author:
ansari
Message:
  • Ajout commande de trace d'elements graphiques (addpoly addctext ...)
  • Ajout de commandes de lecture ascii matrices/vecteurs
  • Trace de vecteur vx vs vy pour tout type de vecteurs

Reza 14/11/2002

File:
1 edited

Legend:

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

    r2243 r2263  
    99#include "pdlmgr.h"
    1010#include "ctimer.h"
     11#include "strutilxx.h"
    1112
    1213#include "pistdimgapp.h"
     
    4647
    4748
     49/* Macro pour tester si flag normalized coordinate est present */
     50#define _CkBoolNC_(_jk_) ((tokens.size()>_jk_) && (tokens[_jk_] == "true")) ? true : false;
    4851 
    4952/* --Methode-- */
     
    123126}
    124127else if (kw == "addtext") {
    125   if (tokens.size() < 3) { cout << "Usage: addtext x y txt [colfontatt]" << endl;  return(0); }
     128  if (tokens.size() < 3) {
     129    cout << "Usage: addtext x y txt [colfontatt] [fgnc]" << endl; 
     130    return(0);
     131  }
    126132  double xp = atof(tokens[0].c_str());
    127133  double yp = atof(tokens[1].c_str());
     
    129135  string sop;
    130136  if (tokens.size() > 3) sop = tokens[3];
    131   mImgApp->AddText(txt, xp, yp, sop);
     137  bool fgnc = _CkBoolNC_(4); 
     138  mImgApp->AddText(txt, xp, yp, sop, fgnc);
     139  }
     140else if (kw == "addctext") {
     141  if (tokens.size() < 5) {
     142    cout << "Usage: addctext x y txt s_up s_dn [colfontatt] [updnfatt] [fgnc] " << endl; 
     143    return(0);
     144  }
     145  double xp = atof(tokens[0].c_str());
     146  double yp = atof(tokens[1].c_str());
     147  string sop;
     148  if (tokens.size() > 5) sop = tokens[5];
     149  string sopfss;
     150  if (tokens.size() > 6) sopfss = tokens[6];
     151  bool fgnc = _CkBoolNC_(7); 
     152  mImgApp->AddCompText(tokens[2], tokens[3], tokens[4], xp, yp, sop, sopfss, fgnc);
    132153  }
    133154else if ((kw == "addline") || (kw == "addrect") || (kw == "addfrect") ||
    134155         (kw == "addarrow") ) {
    135   if (tokens.size() < 4) { cout << "Usage: addline/addrect/addfrect x1 y1 x2 y2 [colatt]" << endl;  return(0); }
     156  if (tokens.size() < 4) {
     157    cout << "Usage: addline/addrect/addfrect x1 y1 x2 y2 [colatt] [fgnc]" << endl; 
     158    return(0);
     159  }
    136160  double xp1 = atof(tokens[0].c_str());
    137161  double yp1 = atof(tokens[1].c_str());
     
    140164  string sop;
    141165  if (tokens.size() > 4) sop = tokens[4];
    142   if (kw == "addline") mImgApp->AddLine(xp1, yp1, xp2, yp2, sop, false);
    143   else if (kw == "addarrow") mImgApp->AddLine(xp1, yp1, xp2, yp2, sop, true);
     166  bool fgnc = _CkBoolNC_(5); 
     167  if (kw == "addline") mImgApp->AddLine(xp1, yp1, xp2, yp2, sop, false, fgnc);
     168  else if (kw == "addarrow") mImgApp->AddLine(xp1, yp1, xp2, yp2, sop, true, fgnc);
    144169  else {
    145170    bool fgfill = (kw == "addrect") ? false : true;
    146     mImgApp->AddRectangle(xp1, yp1, xp2, yp2, sop, fgfill);
     171    mImgApp->AddRectangle(xp1, yp1, xp2, yp2, sop, fgfill, fgnc);
    147172  }
    148173}
    149174else if ((kw == "addcirc") || (kw == "addfcirc")) {
    150   if (tokens.size() < 3) { cout << "Usage: addcirc/addfcirc xc yc r [colatt]" << endl;  return(0); }
     175  if (tokens.size() < 3) {
     176    cout << "Usage: addcirc/addfcirc xc yc r [colatt] [fgnc]" << endl; 
     177    return(0);
     178  }
    151179  double xc = atof(tokens[0].c_str());
    152180  double yc = atof(tokens[1].c_str());
     
    154182  string sop;
    155183  if (tokens.size() > 3) sop = tokens[3];
     184  bool fgnc = _CkBoolNC_(4); 
    156185  bool fgfill = (kw == "addcirc") ? false : true;
    157   mImgApp->AddCircle(xc, yc, rad, sop, fgfill);
     186  mImgApp->AddCircle(xc, yc, rad, sop, fgfill, fgnc);
    158187  }
    159188else if (kw == "addmarker") {
    160189  if (tokens.size() < 2) {
    161     cout << "Usage: addmarker x y [gratt]" << endl; 
     190    cout << "Usage: addmarker x y [gratt] [fgnc]" << endl; 
    162191    return(0);
    163192  }
     
    166195  string sop;
    167196  if (tokens.size() > 2) sop = tokens[2];
    168   mImgApp->AddCircle(xm, ym, -1, sop, false);
     197  bool fgnc = _CkBoolNC_(3); 
     198  mImgApp->AddCircle(xm, ym, -1, sop, false, fgnc);
    169199}
    170200else if ((kw == "addarc") || (kw == "addfarc") ) {
    171201  if (tokens.size() < 6) {
    172     cout << "Usage: addarc/addfarc x1 y1 x2 y2 x3 y3 [gratt]" << endl; 
     202    cout << "Usage: addarc/addfarc x1 y1 x2 y2 x3 y3 [gratt] [fgnc]" << endl; 
    173203    return(0);
    174204  }
     
    181211  string sop;
    182212  if (tokens.size() > 6) sop = tokens[6];
     213  bool fgnc = _CkBoolNC_(7); 
    183214  bool fgfill = (kw == "addarc") ? false : true;
    184   mImgApp->AddArc(x1, y1, x2, y2, x3, y3, sop, fgfill);
    185 }
     215  mImgApp->AddArc(x1, y1, x2, y2, x3, y3, sop, fgfill, fgnc);
     216}
     217else if ((kw == "addpoly") || (kw == "addfpoly")) {
     218  if (tokens.size() < 1) {
     219    cout << "Usage: addpoly/addfpoly 'x1,y1 x2,y2 x3,y3 ...' [gratt] [fgnc]" << endl; 
     220    return(0);
     221  }
     222  vector<string> sxy;
     223  vector<double> xpol, ypol;
     224  double xp, yp;
     225  FillVStringFrString(tokens[0], sxy);
     226  for(int jkk=0; jkk<sxy.size(); jkk++) {
     227    xp = yp = 0;
     228    if (sscanf(sxy[jkk].c_str(), "%lg,%lg", &xp, &yp) == 2) {
     229      xpol.push_back(xp);
     230      ypol.push_back(yp);
     231    }
     232  }
     233  string sop;
     234  if (tokens.size() > 1) sop = tokens[1];
     235  bool fgnc = _CkBoolNC_(2); 
     236  bool fgfill = (kw == "addpoly") ? false : true;
     237  mImgApp->AddPoly(xpol, ypol, sop, fgfill, fgnc);
     238  }
    186239
    187240
     
    704757  srvo->NtFromASCIIFile(tokens[0],tokens[1],def_val);
    705758  }
     759
     760#ifndef SANS_EVOLPLANCK
     761/* Lecture matrice/vecteur depuis fichier ASCII  */
     762else if ((kw == "mtxfrascii") || (kw == "vecfrascii") ) {
     763  if(tokens.size() < 2) {
     764    cout<<"Usage: mtxfrascii/vecfrascii mtx/vec_name file_name "<<endl;
     765    return(0);
     766    }
     767  TMatrix<r_8> mtx;
     768  TVector<r_8> vec;
     769  FILE* fip = fopen(tokens[1].c_str(), "r");
     770  if (fip == NULL) {
     771    cout << "vec/mtxfrascii: can not open file " << tokens[1] << endl;
     772    return(0);
     773  }
     774  fclose(fip);
     775  ifstream is(tokens[1].c_str());
     776  sa_size_t nr, nc;
     777  if (kw == "mtxfrascii") {
     778    mtx.ReadASCII(is, nr, nc);
     779    mObjMgr->AddObj(mtx, tokens[0]);   
     780    cout << "mtxfrascii: TMatrix<r_8> " << tokens[0] << " read from file "
     781         << tokens[1] << endl;
     782  }
     783  else {
     784    vec.ReadASCII(is, nr, nc);
     785    mObjMgr->AddObj(vec, tokens[0]);   
     786    cout << "vecfrascii: TVector<r_8> " << tokens[0] << " read from file "
     787         << tokens[1] << endl;
     788  }
     789}
     790#endif
    706791
    707792else if (kw == "fillnt" ) {
     
    851936usage += "             hugefont  hugeboldfont hugeitalicfont hugebolditalicfont \n";
    852937usage += ">> Font Names: deffont courierfont helveticafont timesfont symbolfont  \n";
    853 usage += ">> Marker: dotmarker<T>  plusmarker<T>  crossmarker<T> circlemarker <T> \n";
     938usage += ">> Marker: dotmarker<T>  plusmarker<T>  crossmarker<T> circlemarker<T> \n";
    854939usage += "           fcirclemarker<T> boxmarker<T> fboxmarker<T> trianglemarker<T> \n";
    855940usage += "           ftrianglemarker<T>  starmarker<T>  fstarmarker<T> \n";
    856 usage += "   with <T> = 1 3 5 7 9 , Example fboxmarker5 , plusmarker9 ... \n";
     941usage += "   with <T> = 1 3 5 7 .. 15 , Example fboxmarker5 , plusmarker9 ... \n";
     942usage += ">> ArrowMarker: basicarrow<T>  trianglearrow<T>  ftrianglearrow<T> \n";
     943usage += "                arrowshapedarrow<T> farrowshapedarrow<T> \n";
     944usage += "   with <T> = 5 7 .. 15 , Example trianglearrow7 ... \n";
    857945usage += ">> ColorTables: defcmap  grey32  invgrey32  colrj32  colbr32 \n";
    858946usage += "                grey128  invgrey128  colrj128  colbr128 \n";
     
    9141002usage += "\n The Base/AxesDrawer is used to handle added text strings" ;
    9151003usage += "\n Alt<Z> to remove added elements";
    916 usage += "\n  Usage: addtext x y TextString [ColFontPosAtt]";
     1004usage += "\n  Usage: addtext x y TextString [ColFontPosAtt] [fgnc=false/true]";
    9171005usage += "\n  (use quotes '' for multi word text strings) ";
     1006usage += "\n  if fgnc==true : Normalized 0..1 coordinates specification (def=false)";
    9181007usage += "\n Text position/direction attribute: ";
    9191008usage += "\n      horizleft horizcenter horizright";
    9201009usage += "\n      vertbottom vertcenter verttop ";
    9211010usage += "\n      textdirhoriz textdirvertup textdirvertdown ";
    922 usage += "\n  Related commands: addline addarrow addrect addfrect";
    923 usage += "\n      addcirc addfcirc addarc addfrac settitle graphicatt"; 
     1011usage += "\n  Related commands: addctext addline addarrow addrect addfrect";
     1012usage += "\n      addcirc addfcirc addarc addfrac addpoly addfpoly settitle graphicatt"; 
     1013mpiac->RegisterCommand(kw, usage, this, "Graphics");
     1014
     1015kw = "addctext";
     1016usage = "Adds a composite text string with superscript and subscripts ";
     1017usage += "\n at the specified position (+ color/font/pos/dir attributes) ";
     1018usage += "\n  Usage: addctext x y Text sUp sDown [ColFontPosAtt] [UpDownFontAtt] [fgnc]";
     1019usage += "\n  if fgnc==true : Normalized 0..1 coordinates specification (def=false)";
     1020usage += "\n  Related commands: addtext addline addrect ...";
     1021usage += "\n      (See command addtext and graphicatt for more details)"; 
    9241022mpiac->RegisterCommand(kw, usage, this, "Graphics");
    9251023
     
    9291027usage += "\n The Base/AxesDrawer is used to handle added lines";
    9301028usage += "\n Alt<Z> to remove added elements";
    931 usage += "\n  Usage: addline x1 y1 x2 y2 [GraphicAtt]";
     1029usage += "\n  Usage: addline x1 y1 x2 y2 [GraphicAtt] [fgnc=false/true]";
     1030usage += "\n  if fgnc==true : Normalized 0..1 coordinates specification (def=false)";
    9321031usage += "\n  Related commands: addarrow addtext addrect addfrect ";
    933 usage += "\n       addmarker addcirc addfcirc addarc addfarc graphicatt"; 
     1032usage += "\n       addmarker addcirc addfcirc addarc addfarc addpoly addfpoly graphicatt"; 
    9341033mpiac->RegisterCommand(kw, usage, this, "Graphics");
    9351034
     
    9391038usage += "\n The Base/AxesDrawer is used to handle added lines";
    9401039usage += "\n Alt<Z> to remove added elements";
    941 usage += "\n  Usage: addarrow x1 y1 x2 y2 [GraphicAtt]";
     1040usage += "\n  Usage: addarrow x1 y1 x2 y2 [GraphicAtt] [fgnc=false/true]";
     1041usage += "\n  if fgnc==true : Normalized 0..1 coordinates specification (def=false)";
    9421042usage += "\n  Related commands: addline addtext addrect addfrect ";
    943 usage += "\n       addmarker addcirc addfcirc addarc addfarc graphicatt"; 
    944 mpiac->RegisterCommand(kw, usage, this, "Graphics");
     1043usage += "\n       addmarker addcirc addfcirc addarc addfarc addpoly addfpoly graphicatt"; 
     1044mpiac->RegisterCommand(kw, usage, this, "Graphics");
     1045kw = "addarrow_nc";
    9451046
    9461047kw = "addrect";
     
    9491050usage += "\n The Base/AxesDrawer is used to handle added rectangle";
    9501051usage += "\n Alt<Z> to remove added elements";
    951 usage += "\n  Usage: addrect x1 y1 x2 y2 [GraphicAtt]";
     1052usage += "\n  Usage: addrect x1 y1 x2 y2 [GraphicAtt] [fgnc=false/true]";
     1053usage += "\n  if fgnc==true : Normalized 0..1 coordinates specification (def=false)";
    9521054usage += "\n  Related commands: addtext addline addarrow addfrect";
    953 usage += "\n       addcirc addfcirc addarc addfarc graphicatt"; 
     1055usage += "\n       addcirc addfcirc addarc addfarc addpoly addfpoly graphicatt"; 
    9541056mpiac->RegisterCommand(kw, usage, this, "Graphics");
    9551057
     
    9591061usage += "\n The Base/AxesDrawer is used to handle added rectangle";
    9601062usage += "\n Alt<Z> to remove added elements";
    961 usage += "\n  Usage: addfrect x1 y1 x2 y2 [GraphicAtt]";
     1063usage += "\n  Usage: addfrect x1 y1 x2 y2 [GraphicAtt] [fgnc=false/true]";
     1064usage += "\n  if fgnc==true : Normalized 0..1 coordinates specification (def=false)";
    9621065usage += "\n  Related commands: addtext addline addarrow addrect";
    963 usage += "\n       addcirc addfcirc graphicatt"; 
     1066usage += "\n       addcirc addfcirc addpoly addfpoly graphicatt"; 
    9641067mpiac->RegisterCommand(kw, usage, this, "Graphics");
    9651068
     
    9691072usage += "\n The Base/AxesDrawer is used to handle added circles";
    9701073usage += "\n Alt<Z> to remove added elements";
    971 usage += "\n  Usage: addmarker xpos ypos [GraphicAtt]";
     1074usage += "\n  Usage: addmarker xpos ypos [GraphicAtt] [fgnc=false/true]";
     1075usage += "\n  if fgnc==true : Normalized 0..1 coordinates specification (def=false)";
    9721076usage += "\n  Related commands: addtext addline addarrow addfrect addfrect";
    973 usage += "\n       addcirc addfcirc addarc addfarc graphicatt"; 
     1077usage += "\n       addcirc addfcirc addarc addfarc addpoly addfpoly graphicatt"; 
    9741078mpiac->RegisterCommand(kw, usage, this, "Graphics");
    9751079
     
    9791083usage += "\n The Base/AxesDrawer is used to handle added circles";
    9801084usage += "\n Alt<Z> to remove added elements";
    981 usage += "\n  Usage: addcirc xcenter ycenter radius [GraphicAtt]";
     1085usage += "\n  Usage: addcirc xcenter ycenter radius [GraphicAtt] [fgnc=false/true]";
     1086usage += "\n  if fgnc==true : Normalized 0..1 coordinates specification (def=false)";
    9821087usage += "\n  Related commands: addtext addline addarrow addfrect addfrect";
    983 usage += "\n       addfcirc addarc addfarc graphicatt"; 
     1088usage += "\n       addfcirc addarc addfarc addpoly addfpoly graphicatt"; 
    9841089mpiac->RegisterCommand(kw, usage, this, "Graphics");
    9851090
     
    9891094usage += "\n The Base/AxesDrawer is used to handle added circles";
    9901095usage += "\n Alt<Z> to remove added elements";
    991 usage += "\n  Usage: addcirc xcenter ycenter radius [GraphicAtt]";
     1096usage += "\n  Usage: addcirc xcenter ycenter radius [GraphicAtt] [fgnc=false/true]";
     1097usage += "\n  if fgnc==true : Normalized 0..1 coordinates specification (def=false)";
    9921098usage += "\n  Related commands: addtext addline addarrow addfrect addfrect";
    993 usage += "\n       addcirc addarc addfarc graphicatt"; 
     1099usage += "\n       addcirc addarc addfarc addpoly addfpoly graphicatt"; 
    9941100mpiac->RegisterCommand(kw, usage, this, "Graphics");
    9951101
     
    9991105usage += "\n The Base/AxesDrawer is used to handle added arcs";
    10001106usage += "\n Alt<Z> to remove added elements";
    1001 usage += "\n  Usage: addarc x1 y1 x2 y2 x3 y3 [GraphicAtt]";
     1107usage += "\n  Usage: addarc x1 y1 x2 y2 x3 y3 [GraphicAtt] [fgnc=false/true]";
     1108usage += "\n  if fgnc==true : Normalized 0..1 coordinates specification (def=false)";
    10021109usage += "\n  Related commands: addtext addline addarrow addfrect addfrect";
    1003 usage += "\n       addcirc addfcirc addfarc graphicatt"; 
     1110usage += "\n       addcirc addfcirc addfarc addpoly addfpoly graphicatt"; 
    10041111mpiac->RegisterCommand(kw, usage, this, "Graphics");
    10051112
     
    10091116usage += "\n The Base/AxesDrawer is used to handle added arcs";
    10101117usage += "\n Alt<Z> to remove added elements";
    1011 usage += "\n  Usage: addarc x1 y1 x2 y2 x3 y3 [GraphicAtt]";
     1118usage += "\n  Usage: addarc x1 y1 x2 y2 x3 y3 [GraphicAtt] [fgnc=false/true]";
     1119usage += "\n  if fgnc==true : Normalized 0..1 coordinates specification (def=false)";
    10121120usage += "\n  Related commands: addtext addline addarrow addfrect addfrect";
    1013 usage += "\n       addcirc addfcirc addfarc graphicatt"; 
     1121usage += "\n       addcirc addfcirc addfarc addpoly addfpoly graphicatt"; 
     1122mpiac->RegisterCommand(kw, usage, this, "Graphics");
     1123
     1124kw = "addpoly";
     1125usage = "Adds a polyline/polygon to the current graphic object";
     1126usage += "\n  Usage: addploy 'x1,y1 x2,y2 x3,y3 ...' [GraphicAtt] [fgnc=false/true]";
     1127usage += "\n  Coordinates specified as pairs x,y in a single word (use simple or double quotes";
     1128usage += "\n  if fgnc==true : Normalized 0..1 coordinates specification (def=false)";
     1129usage += "\n  Related commands: addtext addline addarrow addfrect addfrect";
     1130usage += "\n       addcirc addfcirc addfarc  graphicatt"; 
     1131mpiac->RegisterCommand(kw, usage, this, "Graphics");
     1132
     1133kw = "addfpoly";
     1134usage = "Adds a filled polygon to the current graphic object";
     1135usage += "\n  Usage: addploy 'x1,y1 x2,y2 x3,y3 ...' [GraphicAtt] [fgnc=false/true]";
     1136usage += "\n  Coordinates specified as pairs x,y in a single word (use simple or double quotes";
     1137usage += "\n  if fgnc==true : Normalized 0..1 coordinates specification (def=false)";
     1138usage += "\n  Related commands: addtext addline addarrow addfrect addfrect";
     1139usage += "\n       addcirc addfcirc addfarc  graphicatt"; 
    10141140mpiac->RegisterCommand(kw, usage, this, "Graphics");
    10151141
     
    10391165
    10401166kw = "openfits";
    1041 usage = "Loads a FITS file into an apprpiate object \n Usage: openfits filename";
     1167usage = "Loads a FITS file into an appropriate object \n Usage: openfits filename";
    10421168usage += "\n  Related commands: savefits openppf"; 
    10431169mpiac->RegisterCommand(kw, usage, this, "FileIO");
     
    10711197usage += "\n  Related commands: ntloop fillnt ";
    10721198mpiac->RegisterCommand(kw, usage, this, "FileIO");
    1073 
     1199#ifndef SANS_EVOLPLANCK
     1200kw = "mtxfrascii";
     1201usage = "Reads a matrix from an ASCII file (TMatrix<r_8>)";
     1202usage += "\n Usage: mtxfrascii mtx_name file_name";
     1203usage += "\n  Related commands: vecfrascii ntfrascii ";
     1204mpiac->RegisterCommand(kw, usage, this, "FileIO");
     1205kw = "vecfrascii";
     1206usage = "Reads a vactor from an ASCII file (TVector<r_8>)";
     1207usage += "\n Usage: vecfrascii vec_name file_name";
     1208usage += "\n  Related commands: mtxfrascii ntfrascii ";
     1209mpiac->RegisterCommand(kw, usage, this, "FileIO");
     1210#endif
    10741211
    10751212kw = "print";
     
    14911628usage += "o <Alt>C : Copy/Paste / Copies the selected regions content as text in the copy/paste buffer \n";
    14921629usage += "o <Alt>X : Show/Hide the Cut Window \n";
    1493 usage += "o <Alt>Z : Removes signs overlayed on image (Drawer 0) \n";
     1630usage += "o <Alt>Z : Removes added graphic elements (handled by BaseDrawer - 0) \n";
     1631usage += "o <Alt>E : Removes the last added graphic element \n";
    14941632usage += "o <Alt>+ or <Cntl>+ : Zoom in \n";
    14951633usage += "o <Alt>- or <Cntl>- : Zoom out \n";
     
    15101648usage += "           Drawer 0 manages the axes, as well as the added text \n";
    15111649usage += "o <Alt>V : Copy/Paste / Text paste at the current position \n";
    1512 usage += "o <Alt>Z : Removes added signs (text) to Drawer 0 \n";
     1650usage += "o <Alt>Z : Removes added graphic elements (handled by BaseDrawer - 0) \n";
     1651usage += "o <Alt>E : Removes the last added graphic element \n";
    15131652usage += "o <Alt>I : Shows (or updates) a text info window on the selected rectangle \n";
    15141653usage += "o <Alt>M : Activate/Deactivate a measurement cursor on Button-1\n";
     
    15301669usage += "o <Alt>O : = <Alt>G \n";
    15311670usage += "o <Alt>V : Copy/Paste / Text paste at the current position (Drawer 0)\n";
    1532 usage += "o <Alt>Z : Removes added signs (text) to Drawer 0 \n";
     1671usage += "o <Alt>Z : Removes added graphic elements (handled by BaseDrawer - 0) \n";
     1672usage += "o <Alt>E : Removes the last added graphic element \n";
    15331673usage += "o <Alt>A : Activate/Deactivate axes drawing \n";
    15341674usage += "o <Alt>S : Activate/Deactivate object rotation mode on Button-2 \n";
Note: See TracChangeset for help on using the changeset viewer.