Index: /trunk/SophyaPI/PIext/basexecut.cc
===================================================================
--- /trunk/SophyaPI/PIext/basexecut.cc	(revision 293)
+++ /trunk/SophyaPI/PIext/basexecut.cc	(revision 293)
@@ -0,0 +1,669 @@
+#include "piacmd.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include "basexecut.h"
+
+#include "pdlmgr.h"
+#include "ctimer.h"
+// #include "dlftypes.h"
+
+#include "pistdimgapp.h"
+#include "nobjmgr.h"
+
+#include "histos.h"
+#include "histos2.h"
+#include "hisprof.h"
+#include "ntuple.h"
+#include "generaldata.h"
+
+
+
+/* --Methode-- */
+PIABaseExecutor::PIABaseExecutor(PIACmd* piac, NamedObjMgr* omg, PIStdImgApp* app)
+{
+mpiac = piac;
+mObjMgr = omg; 
+mImgApp = app;
+RegisterCommands();
+}
+
+PIABaseExecutor::~PIABaseExecutor()
+{
+}
+
+
+ 
+/* --Methode-- */
+int PIABaseExecutor::Execute(string& kw, vector<string>& tokens)
+{
+
+// >>>>> Chargement de modules
+if (kw == "loadmodule") {
+  if (tokens.size() < 2) { cout << "Usage: loadmodule fnameso modulename" << endl;  return(0); }
+  mpiac->LoadModule(tokens[0], tokens[1]);
+  }
+// >>>>>>>>>>> Fenetre graphique , changement d'attributs graphiques 
+else if (kw == "zone") {
+  if (tokens.size() < 2) { cout << "Usage: zone nx ny" << endl;  return(0); }
+  int nx, ny;
+  nx = ny = 1;
+  nx = atoi(tokens[0].c_str());    ny = atoi(tokens[1].c_str());
+  mObjMgr->SetGraphicWinZone(nx, ny, false);
+  }  
+else if (kw == "newwin") {
+  if (tokens.size() < 2) { cout << "Usage: newwin nx ny" << endl;  return(0); }
+  int nx, ny;
+  nx = ny = 1;
+  nx = atoi(tokens[0].c_str());    ny = atoi(tokens[1].c_str());
+  mObjMgr->SetGraphicWinZone(nx, ny, true);
+  }  
+else if (kw == "stacknext") mImgApp->StackWinNext(); 
+else if (kw == "gratt") {
+  if (tokens.size() < 1) { cout << "Usage: gratt attributes_list (att=def->defaut)" << endl;  return(0); }
+  mObjMgr->SetGraphicAttributes(tokens[0]); 
+  }
+
+// >>>>>>>>>>> Link dynamique de fonctions C++
+else if (kw == "link" ) {
+  if (tokens.size() < 2) { cout << "Usage: link fnameso f1 [f2 f3]" << endl;  return(0); }
+  string sph = "";
+  for(int gg=0; gg<5; gg++)   tokens.push_back(sph);
+  int rc = LinkUserFuncs(tokens[0], tokens[1], tokens[2], tokens[3]);
+  if (rc == 0)  cout << "PIABaseExecutor: Link from " << tokens[0] << " OK " << endl;
+}
+else if (kw == "call" ) {
+  if (tokens.size() < 1) { cout << "Usage: call userf [arg1 arg2 ...]" << endl;  return(0); }
+  UsFmap::iterator it = usfmap.find(tokens[0]);
+  if (it == usfmap.end()) {
+    cerr << "PIABaseExecutor: No User Function " << tokens[0] << endl;
+    return(0);
+  }
+  cout << "PIABaseExecutor: Call " << tokens[0] << "( ... )" << endl;
+// on est oblige de faire un cast  etant donne qu'on 
+// utilise donc des DlFunction  (Reza 20/08/98)  voir commentaire ds .h (pb g++)
+  DlUserProcFunction fuf = (DlUserProcFunction)(*it).second;
+//   On redirige la sortie sur le terminal 
+  bool red = mImgApp->HasRedirectedStdOutErr();
+  mImgApp->RedirectStdOutErr(false);
+  TRY {
+    tokens.erase(tokens.begin());
+    fuf(tokens);
+  }  CATCH(merr) {
+    fflush(stdout); 
+    cout << endl; 
+    cerr << endl;
+    string es = PeidaExc(merr);
+    cerr << "PIABaseExecutor: Call UserFunc  Exception :" << merr << es;
+    }
+  mImgApp->RedirectStdOutErr(red);
+}
+
+// >>>>>>>>>>> lecture/ecriture des objets, gestion des objets 
+else if (kw == "openfits" ) {
+  if (tokens.size() < 1) { cout << "Usage: openfits file " << endl;  return(0); }
+  else mObjMgr->ReadFits(tokens[0]);
+}
+else if (kw == "savefits" ) {
+  if (tokens.size() < 2) { cout << "Usage: savefits nameobj filename " << endl;  return(0); }
+  else mObjMgr->SaveFits(tokens[0], tokens[1]);
+}
+else if (kw == "openppf" ) {
+  if (tokens.size() < 1) { cout << "Usage: openppf file " << endl; return(0); }
+  mObjMgr->ReadAll(tokens[0]);  
+}
+else if (kw == "saveall" ) {
+  if (tokens.size() < 1) { cout << "Usage: saveall file " << endl; return(0); }
+  mObjMgr->SaveAll(tokens[0]);  
+}
+else if (kw == "print" ) {
+  if (tokens.size() < 1) { cout << "Usage: print nameobj " << endl; return(0); }
+  mObjMgr->PrintObj(tokens[0]);  
+}
+else if (kw == "rename" ) {
+  if (tokens.size() < 2) { cout << "Usage: rename nameobj namenew" << endl; return(0); }
+  mObjMgr->RenameObj(tokens[0], tokens[1]);  
+}
+else if (kw == "del" ) {
+  if (tokens.size() < 1) { cout << "Usage: del nameobj " << endl; return(0); }
+  mObjMgr->DelObj(tokens[0]);  
+}
+else if (kw == "delobjs" ) {
+  if (tokens.size() < 1) { cout << "Usage: delobjs nomobjpattern (*,?) " << endl; return(0); }
+  mObjMgr->DelObjects(tokens[0]);  
+}
+else if (kw == "listobjs")   mObjMgr->ListObjs();
+
+// >>>>>>>>>>> Creation d'histos 1D-2D
+else if (kw == "newh1d") {
+  if (tokens.size() < 4) { cout << "Usage: newh1d name xmin xmax nbin" << endl; return(0); }
+  int nbx;
+  float xmin, xmax;
+  nbx = 100;
+  xmin = 0.;  xmax = 1.;
+  nbx = atoi(tokens[3].c_str());
+  xmin = atof(tokens[1].c_str());   xmax = atof(tokens[2].c_str());
+  Histo* h = new Histo(xmin, xmax, nbx);
+  mObjMgr->AddObj(h, tokens[0]);
+  }
+else if (kw == "newh2d") {
+  if (tokens.size() < 7) { 
+    cout << "Usage: newh2d name xmin xmax nbinx ymin ymax nbiny" << endl; 
+    return(0); 
+    }
+  int nbx, nby;
+  float xmin, xmax;
+  float ymin, ymax;
+  nbx = nby = 50;
+  xmin = 0.;  xmax = 1.;
+  ymin = 0.;  ymax = 1.;
+  nbx = atoi(tokens[3].c_str());
+  nby = atoi(tokens[6].c_str());
+  xmin = atof(tokens[1].c_str());   xmax = atof(tokens[2].c_str());
+  ymin = atof(tokens[4].c_str());   ymax = atof(tokens[5].c_str());
+  Histo2D* h = new Histo2D(xmin, xmax, nbx, ymin, ymax, nby);
+  mObjMgr->AddObj(h, tokens[0]);
+  }
+else if (kw == "newprof") {
+  if (tokens.size() < 4)
+    { cout << "Usage: newprof name xmin xmax nbin [ymin ymax]" << endl; return(0); }
+  int nbx;
+  float xmin, xmax, ymin = 1., ymax = -1.;
+  if(tokens.size() > 5)
+    {ymin = atof(tokens[4].c_str());   ymax = atof(tokens[5].c_str());}
+  nbx = 100;
+  xmin = 0.;  xmax = 1.;
+  nbx = atoi(tokens[3].c_str());
+  xmin = atof(tokens[1].c_str());   xmax = atof(tokens[2].c_str());
+  HProf* h = new HProf(xmin, xmax, nbx, ymin, ymax);
+  mObjMgr->AddObj(h, tokens[0]);
+  }
+else if (kw == "newgfd") {
+  if (tokens.size() < 3)
+    { cout << "Usage: newgfd nvar nalloc [errx(0/1)]" << endl; return(0); }
+  int nvar, nalloc, errx=0;
+  if (tokens.size() > 3)
+    { errx = atoi(tokens[3].c_str()); if(errx>0) errx=1; else errx = 0;}
+  nvar = atoi(tokens[1].c_str()); nalloc = atoi(tokens[2].c_str());
+  if(nvar>0 && nalloc>0) {
+    GeneralFitData* gfd = new GeneralFitData(nvar,nalloc,errx);
+    mObjMgr->AddObj(gfd, tokens[0]);
+    }
+  }
+
+// >>>>>>>>>>>  Affichage des objets 
+else if ( (kw == "disp") || (kw == "surf") ) {
+  if (tokens.size() < 1) { cout << "Usage: disp/surf nameobj [opt]" << endl; return(0); }
+  string opt = "n";
+  if (tokens.size() > 1)  opt = tokens[1];
+  if (kw == "disp") mObjMgr->DisplayObj(tokens[0], opt);
+  else if (kw == "surf")  mObjMgr->DisplaySurf3D(tokens[0], opt);
+  }
+
+else if (kw == "nt2d") {
+  if (tokens.size() < 5) { cout << "Usage: nt2d nameobj varx vary errx erry opt" << endl; return(0); }
+  string opt = "n";
+  if (tokens.size() > 5)  opt = tokens[5];
+  string ph = "";
+  mObjMgr->DisplayNT(tokens[0],tokens[1],tokens[2], ph, tokens[3], tokens[4], ph, opt);
+  }
+else if (kw == "nt3d") {
+  if (tokens.size() < 7) { cout << "Usage: nt3d nameobj varx vary varz errx erry errz opt" << endl; return(0); }
+  string opt = "n";
+  if (tokens.size() > 7)  opt = tokens[7];
+  mObjMgr->DisplayNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], tokens[6], opt);
+  }
+
+else if (kw == "gfd2d") {
+  if(tokens.size()<2)
+    {cout<<"Usage: gfd2d nomobj numvarx erreur=(x y xy) opt"<<endl;
+     return(0);}
+  string numvary = "";
+  string err = "";
+  string opt = "n";
+  if(tokens.size()>2) err = tokens[2];
+  if(tokens.size()>3) opt = tokens[3];
+  mObjMgr->DisplayGFD(tokens[0],tokens[1],numvary,err,opt);
+  }
+else if (kw == "gfd3d") {
+  if(tokens.size()<3)
+    {cout<<"Usage: gfd3d nameobj numvarx numvary erreur=(x y z xy xz yz xyz) opt"<<endl;
+     return(0);}
+  string err = "";
+  string opt = "n";
+  if(tokens.size()>3) err = tokens[3];
+  if(tokens.size()>4) opt = tokens[4];
+  mObjMgr->DisplayGFD(tokens[0],tokens[1],tokens[2],err,opt);
+  }
+
+// >>>>>>>>>>>  Trace de fonctions 
+else if ( (kw == "func") ) {
+  if (tokens.size() < 4) { cout << "Usage: func f(x) xmin xmax npt [opt]" << endl; return(0); }
+  string opt = "n";
+  if (tokens.size() > 4)  opt = tokens[4];
+  int np;
+  float xmin, xmax;
+  np = 100;
+  xmin = 0.;  xmax = 1.;
+  np = atoi(tokens[3].c_str());
+  xmin = atof(tokens[1].c_str());   xmax = atof(tokens[2].c_str());
+  mObjMgr->PlotFunc(tokens[0], xmin, xmax, np, opt); 
+  }
+else if ( (kw == "func2d") ) {
+  if (tokens.size() < 7) {
+    cout << "Usage: func2d f(x,y) xmin xmax nptx ymin ymax npty opt" << endl;
+    return(0);
+    }
+  int npx, npy;
+  float xmin, xmax;
+  float ymin, ymax;
+  npx = npy = 50;
+  xmin = 0.;  xmax = 1.;
+  ymin = 0.;  ymax = 1.;
+  npx = atoi(tokens[3].c_str());
+  npy = atoi(tokens[6].c_str());
+  xmin = atof(tokens[1].c_str());   xmax = atof(tokens[2].c_str());
+  ymin = atof(tokens[4].c_str());   ymax = atof(tokens[5].c_str());
+  string opt = "n";
+  if (tokens.size() > 7)  opt = tokens[7];
+  mObjMgr->PlotFunc2D(tokens[0], xmin, xmax, ymin, ymax, npx, npy, opt);
+  }
+
+// >>>>>>>>>>>  Trace d'expressions de N_Tuple, StarList, etc ...
+else if (kw == "plot2d" ) {
+  if (tokens.size() < 4) {
+    cout << "Usage: plot2d nameobj expx expy [experrx experry] expcut [opt]" << endl;
+    return(0); 
+    }
+  string errx = ""; string erry = ""; string ecut = "1";
+  string opt = "n";
+  if (tokens.size() < 6) { // Plot sans les erreurs
+    ecut = tokens[3];
+    if (tokens.size() > 4)  opt = tokens[4];
+    }
+  else {                 // Plot avec les erreurs
+    errx = tokens[3]; erry = tokens[4]; ecut = tokens[5];
+    if (tokens.size() > 6)  opt = tokens[6];
+    }
+  mObjMgr->DisplayPoints2D(tokens[0],tokens[1],tokens[2],errx,erry,ecut,opt);
+  }
+
+else if (kw == "plot3d" ) {
+  if (tokens.size() < 5) { 
+    cout << "Usage: plot3d nomobj expx expy expz expcut opt" << endl;
+    return(0); 
+    }
+  string opt = "n";
+  if (tokens.size() > 5)  opt = tokens[5];
+  mObjMgr->DisplayPoints3D(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], opt);
+  }
+
+else if (kw == "projh1d" ) {
+  if (tokens.size() < 5) { 
+    cout << "Usage: projh1d nomobj expx expwt expcut nomh1 opt" << endl;
+    return(0);
+    }
+  string opt = "n";
+  if (tokens.size() > 5)  opt = tokens[5];
+  mObjMgr->ProjectH1(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], opt);
+  }
+
+else if (kw == "projh2d" ) {
+  if (tokens.size() < 6) { 
+    cout << "Usage: projh2 nomobj expx expy expwt expcut nomh2 opt" << endl;
+    return(0);
+    }
+  string opt = "n";
+  if (tokens.size() > 6)  opt = tokens[6];
+
+  mObjMgr->ProjectH2(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], opt);
+  }
+
+else if (kw == "projprof" ) {
+  if (tokens.size() < 6) { 
+    cout << "Usage: projprof nomobj expx expy expwt expcut nomprof opt" << endl;
+    return(0);
+    }
+  string opt = "n";
+  if (tokens.size() > 6)  opt = tokens[6];
+
+  mObjMgr->ProjectHProf(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], opt);
+  }
+
+else if (kw == "fillnt" ) {
+  if (tokens.size() < 7) { 
+    cout << "Usage: fillnt nameobj expx expy expz expt expcut nament" << endl;
+    return(0);
+    }
+  mObjMgr->FillNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], tokens[6] );
+  }
+
+else if (kw == "fillvec" ) {
+  if (tokens.size() < 4) { 
+    cout << "Usage: fillvec nameobj expx expcut nomvec opt" << endl;
+    return(0);
+    }
+  string opt = "n";
+  if (tokens.size() > 4)  opt = tokens[4];
+  mObjMgr->FillVect(tokens[0],tokens[1],tokens[2], tokens[3], opt);
+  }
+
+else if (kw == "fillgd1" ) {
+  if (tokens.size() < 5) {
+    cout << "Usage: fillgd1 nomobj expx expy experry expcut nomgfd" << endl;
+    return(0);
+    }
+  string nomgfd = "";
+  if (tokens.size() > 5) nomgfd = tokens[5];
+  string expy = "";
+  mObjMgr->FillGFD(tokens[0],tokens[1], expy, tokens[2], tokens[3], tokens[4],nomgfd);
+  }
+
+else if (kw == "fillgd2" ) {
+  if (tokens.size() < 6) {
+    cout << "Usage: fillgd2 nomobj expx expy expz experrz expcut nomgfd" << endl;
+    return(0);
+    }
+  string nomgfd = "";
+  if (tokens.size() > 6) nomgfd = tokens[6];
+  mObjMgr->FillGFD(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5],nomgfd);
+  }
+
+
+// Fit 1D sur objets 1D. Egalement Fit 2D sur objets 2D.
+else if (kw == "fit") {
+  if (tokens.size() < 2) {
+    cout <<"Usage:fit nomobj func \n"
+         <<" [p:p1,...,pn s:s1,...,sn m:m1,...,mn M:M1,...,Mn o:... o:...]\n";
+    return(0);
+  }
+  string p=""; string s=""; string m=""; string M=""; string O="";
+  if (tokens.size()>2)
+    for(int ip=2;ip<tokens.size();ip++) {
+      if(tokens[ip].length()<=2) continue;
+      const char *c = tokens[ip].c_str();
+      if(c[1]!=':') continue;
+      if(c[0]=='p')      p=c+2;
+      else if(c[0]=='s') s=c+2;
+      else if(c[0]=='m') m=c+2;
+      else if(c[0]=='M') M=c+2;
+      else if(c[0]=='o') {O += ","; O += c+2;}
+    }
+  mObjMgr->Fit12D(tokens[0],tokens[1],p,s,m,M,O);
+}
+
+
+else  { 
+  cerr << "PIABaseExecutor::Do() Erreur - Commande " << kw << " inconuue ! " << endl;    
+  return(-1);
+  }
+
+return(0);
+}
+
+/* --Methode-- */
+void PIABaseExecutor::RegisterCommands()
+{
+string kw, usage;
+kw = "loadmodule";
+usage = "To load and initialize modules \n  Usage: loadmodule fnameso modulename";
+usage += "\n  Related commands: link";  
+mpiac->RegisterCommand(kw, usage, this);
+kw = "link";
+usage = "Dynamic linking of compiled user functions \n  Usage: link fnameso f1 [f2 f3]";
+usage += "\n  fnameso: Shared-object file name, f1,f2,f3 : User function names ";
+usage += "\n  Related commands: call loadmodule";  
+mpiac->RegisterCommand(kw, usage, this);
+kw = "call";
+usage = "Dynamically linked user function call \n Usage: call userf [arg1 arg2 ...]";
+usage += "\n  User function : f(vector<string>& args)";
+usage += "\n  Related commands: link";  
+mpiac->RegisterCommand(kw, usage, this);
+
+kw = "zone";
+usage = "To Divide the Graphic window \n  Usage: zone nx ny";
+mpiac->RegisterCommand(kw, usage, this);
+kw = "newwin";
+usage = "To Create a New Graphic window, with zones \n  Usage: newwin nx ny";
+mpiac->RegisterCommand(kw, usage, this);
+kw = "stacknext";
+usage = "Displays the next widget on stack window \n  Usage: stacknext";
+mpiac->RegisterCommand(kw, usage, this);
+
+kw = "gratt";
+usage = "To change default graphic options \n  Usage: gratt att_list \n";
+usage += "att_list=def back to default values, Example: gratt red,circlemarker5";
+usage += "\n ------------------ Graphic attribute list ------------------ \n";
+usage += ">> Colors: defcol black white grey red blue green yellow magenta cyan \n";
+usage += "           turquoise navyblue orange siennared purple limegreen gold \n";
+usage += ">> Lines:  defline normalline thinline thickline dashedline thindashedline \n";
+usage += "           thickdashedline dottedline thindottedline thickdottedline \n";
+usage += ">> Fonts:  deffont normalfont boldfont italicfont smallfont smallboldfont \n";
+usage += "           smallitalicfont bigfont bigboldfont bigitalicfont \n";
+usage += "           hugefont  hugeboldfont hugeitalicfont \n";
+usage += ">> Marker: dotmarker<T>  plusmarker<T>  crossmarker<T> circlemarker <T> \n";
+usage += "           fcirclemarker<T> boxmarker<T> fboxmarker<T> trianglemarker<T> \n";
+usage += "           ftrianglemarker<T>  starmarker<T>  fstarmarker<T> \n";
+usage += "   with <T> = 1 3 5 7 9 , Example fboxmarker5 , plusmarker9 ... \n";
+usage += ">> ColorTables: defcmap  grey32  greyinv32  colrj32  colbr32 \n";
+usage += "                grey128  greyinv128  colrj128  colbr128 \n";
+usage += ">> ZoomFactors: defzoom zoomx1 zoomx2 zoomx3 zoomx4 zoomx5 \n";
+usage += "                               zoom/2 zoom/3 zoom/4 zoom/5 \n";
+usage += ">> Axes:  stdaxes=defaxes=boxaxes  simpleaxes boxaxesgrid \n";
+usage += "          fineaxes  grid=fineaxesgrid \n"; 
+usage += ">> DisplayWindow: next same win stack \n";
+mpiac->RegisterCommand(kw, usage, this);
+
+kw = "openfits";
+usage = "Loads a FITS file into an Image<T> \n Usage: openfits filename";
+usage += "\n  Related commands: savefits openppf";  
+mpiac->RegisterCommand(kw, usage, this);
+kw = "savefits";
+usage = "Save an object into a FITS file \n Usage: savefits nameobj filename";
+usage += "\n  Related commands: openfits saveall";  
+mpiac->RegisterCommand(kw, usage, this);
+kw = "openppf";
+usage = "Reads all objects from a PPF file \n Usage: openppf filename";
+usage += "\n  Related commands: saveall openfits";  
+mpiac->RegisterCommand(kw, usage, this);
+kw = "saveall";
+usage = "Saves all objects into a PPF file \n Usage: saveall filename";
+usage += "\n  Related commands: openppf savefits";  
+mpiac->RegisterCommand(kw, usage, this);
+
+kw = "print";
+usage = "Prints an object \n Usage: print nameobj";
+mpiac->RegisterCommand(kw, usage, this);
+
+kw = "rename";
+usage = "Rename an object \n Usage: rename nameobj namenew";
+usage += "\n  Related commands: del delobjs";  
+mpiac->RegisterCommand(kw, usage, this);
+kw = "del";
+usage = "Deletes an object \n Usage: del nameobj";
+usage += "\n  Related commands: delobjs  rename";  
+mpiac->RegisterCommand(kw, usage, this);
+kw = "delobjs";
+usage = "Delete a set of objects with names matching a pattern (x?y*)";
+usage += "\n Usage: delobjs nameobjpattern \n";
+usage += "\n  Related commands: del rename";  
+mpiac->RegisterCommand(kw, usage, this);
+
+kw = "newh1d";
+usage = "Creates a 1D histogramm \n Usage: newh1d name xmin xmax nbin";
+usage += "\n  Related commands: newh2d  newprof  newgfd ";  
+mpiac->RegisterCommand(kw, usage, this);
+kw = "newh2d";
+usage = "Creates a 2D histogramm \n Usage: newh2d name xmin xmax nbinx ymin ymax nbiny";
+usage += "\n  Related commands: newh1d  newprof  newgfd ";  
+mpiac->RegisterCommand(kw, usage, this);
+kw = "newprof";
+usage = "Creates a profile histogramm \n Usage: newprof name xmin xmax nbin [ymin ymax]";
+usage += "\n  Related commands: newh1d  newh2d newgfd ";  
+mpiac->RegisterCommand(kw, usage, this);
+kw = "newgfd";
+usage = "Creates GeneralFit Data object \n Usage: newgfd nvar nalloc [errx(0/1)]";
+usage += "\n  Related commands: newh1d  newh2d  newprof ";  
+mpiac->RegisterCommand(kw, usage, this);
+
+kw = "disp";
+usage = "Displays an object \n Usage: disp nameobj [graphic_attributes]";
+usage += "\n  Related commands: surf nt2d nt3d ";  
+mpiac->RegisterCommand(kw, usage, this);
+kw = "surf";
+usage = "Displays an object as a 3D surface \n Usage: surf nameobj [graphic_attributes]";
+usage += "\n  Related commands: disp nt2d nt3d ";  
+mpiac->RegisterCommand(kw, usage, this);
+kw = "nt2d";
+usage = "Displays Points (X-Y) [with error-bars] from an NTuple ";
+usage += "\n Usage : nt2d nameobj varx vary [errx erry] [graphic_attributes]";
+usage += "\n  Related commands: disp  surf  nt3d  gfd2d ";  
+mpiac->RegisterCommand(kw, usage, this);
+kw = "nt3d";
+usage = "Displays 3D-Points (X-Y-Z) [with error-bars] from an NTuple ";
+usage += "\n Usage : nt3d nameobj varx vary varz [errx erry errz] [graphic_attributes]";
+usage += "\n  Related commands: disp  surf  nt2d  gfd3d ";  
+mpiac->RegisterCommand(kw, usage, this);
+kw = "gfd2d";
+usage = "Displays Points (X-Y) with error-bars from a GeneralFit Data ";
+usage += "\n Usage : gfd2d nameobj numvarx erreur=(x y xy) [graphic_attributes]";
+usage += "\n  Related commands: gfd3d nt2d nt3d ";  
+mpiac->RegisterCommand(kw, usage, this);
+kw = "gfd3d";
+usage = "Displays 3D-Points (X-Y-Z) with error-bars from a GeneralFit Data ";
+usage += "\n Usage : gfd3d nameobj numvarx numvary erreur=(x y z xy xz yz xyz) [graphic_attributes]";
+usage += "\n  Related commands: gfd2d nt2d nt3d ";  
+mpiac->RegisterCommand(kw, usage, this);
+
+kw = "func";
+usage = "Displays a function y=f(x) (Fills a vector with function values)";
+usage += "\n Usage: func f(x) xmin xmax npt [graphic_attributes]";
+usage += "\n  Related commands: func2d ";  
+mpiac->RegisterCommand(kw, usage, this);
+kw = "func2d";
+usage = "Displays a function z=f(x,y) (Fills a matrix with function values)";
+usage += "\n Usage: func2d f(x,y) xmin xmax nptx ymin ymax npty [graphic_attributes]";
+usage += "\n  Related commands: func";  
+mpiac->RegisterCommand(kw, usage, this);
+
+kw = "plot2d";
+usage = "Plots (2D) Y=g(Object) vs. X=f(Object) --- Object Variable names (double) :";
+usage += "\nNTuple varnames - Histo1D/HProf: i,x,val,err - Histo2D: i,j,x,y,val,err";
+usage += "\nVector: i,val - Matrix: i,j,val - Image: x=i,y=j, pix=val";
+usage += "\n Usage: plot2d nameobj f_X() g_Y() [ f_ErrX() f_ErrY() ] f_Cut() [graphic_attributes]";
+usage += "\n  Related commands: plot3d  projh1d  projh2d  projprof  fillnt fillvec fillgd1 ";
+mpiac->RegisterCommand(kw, usage, this);
+kw = "plot3d";
+usage = "Plots (3D) Z=h(Object) vs. Y=g(Object) vs. X=f(Object) vs ";
+usage += "\n Usage: plot2d nameobj f_X() g_Y() h_Z() Cut() [graphic_attributes]";
+usage += "\n  Related commands: plot2d  projh1d  projh2d  projprof  fillnt fillvec ";
+mpiac->RegisterCommand(kw, usage, this);
+
+kw = "projh1d";
+usage = "Projects X=f(Object) with weight WT=h(Object) into a 1D histogram ";
+usage += "\n Usage: projh1d nameobj f_X() h_WT() Cut() nameh1d [graphic_attributes]";
+usage += "\n   Histo1D nameh1d is created if necessary ";
+usage += "\n  Related commands: plot2d  projh2d  projprof fillnt  fillvec ";
+mpiac->RegisterCommand(kw, usage, this);
+kw = "projh2d";
+usage = "Projects (X=f(Object),Y=g(Object)) with weight WT=h(Object) into a 2D histogram ";
+usage += "\n Usage: projh2d nameobj f_X() g_Y() h_WT() Cut() nameh2d [graphic_attributes]";
+usage += "\n   Histo2D nameh2d is created if necessary ";
+usage += "\n  Related commands: plot2d  projh1d projprof ";
+mpiac->RegisterCommand(kw, usage, this);
+kw = "projprof";
+usage = "Projects (X=f(Object),Y=g(Object)) with weight WT=h(Object) into a profile histogram ";
+usage += "\n Usage: projh2d nameobj f_X() g_Y() h_WT() Cut() nameprof [graphic_attributes]";
+usage += "\n   HProf nameprof is created if necessary ";
+usage += "\n  Related commands: plot2d  projh2d  ";
+mpiac->RegisterCommand(kw, usage, this);
+
+kw = "fillnt";
+usage = "Creates and Fills an NTuple(x,y,z,t) with (X=f(Object),Y=g(...),Z=h(...),T=k(...))";
+usage += "\n Usage: fillnt nameobj f_X() g_Y() h_Z() k_T() Cut() nameNt";
+usage += "\n  Related commands: plot2d  projh1d projh2d projprof ";
+mpiac->RegisterCommand(kw, usage, this);
+kw = "fillvec";
+usage = "Creates and Fills a Vector with X=f(Object)";
+usage += "\n Usage: fillvec nameobj f_X() Cut() nameVec [graphic_attributes]";
+usage += "\n  Related commands: plot2d  projh1d  fillnt ";
+mpiac->RegisterCommand(kw, usage, this);
+kw = "fillgd1";
+usage = "Creates and Fills a GeneralFitData with (X=f(Object), Y=g(...), ErrY=h(...))";
+usage += "\n Usage: fillgd1 nameobj f_X() g_Y() h_ErrY() Cut() nameGfd";
+usage += "\n  Related commands: plot2d  fillnt ";
+mpiac->RegisterCommand(kw, usage, this);
+kw = "fillgd2";
+usage = "Creates and Fills a GeneralFitData with (X=f(Object), Y=g(...), Z=h(...)) ErrZ=k(...)";
+usage += "\n Usage: fillgd1 nameobj f_X() g_Y() h_Z() k_ErrZ() Cut() nameGfd";
+usage += "\n  Related commands: plot2d  fillgd2 ";
+mpiac->RegisterCommand(kw, usage, this);
+
+kw = "fit";
+usage = "Fitting function to DataObjects (Histo, Histo2D, Vector, ...)";
+usage += "\n Usage: fit nomobj func [Options]";
+usage += "\n [p:p1,...,pn s:s1,...,sn m:m1,...,mn M:M1,...,Mn o:... o:...]";
+mpiac->RegisterCommand(kw, usage, this);
+
+
+}
+
+/* --Methode-- */
+int PIABaseExecutor::LinkUserFuncs(string& fnameso, string& func1, string& func2, string& func3)
+//                          string& func4, string& func5)
+{
+string cmd;
+int rc;
+
+if (dynlink) delete dynlink;    dynlink = NULL;
+usfmap.clear();
+
+dynlink = new PDynLinkMgr(fnameso, true);
+if (dynlink == NULL) { 
+  string sn = fnameso; 
+  cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur ouverture SO " << sn << endl; 
+  return(2); 
+  }
+
+int nok=0;
+// on utilise donc des DlFunction  (Reza 20/08/98)  voir commentaire ds .h (pb g++)
+// DlUserProcFunction f = NULL;
+DlFunction f = NULL;
+if ((func1.length() < 1) || (func1 == "-") || (func1 == ".") )  goto fin;
+// f = (DlUserProcFunction)  dlsym(dlhandle, func1.c_str());
+f = dynlink->GetFunction(func1);
+if (f) { nok++;  usfmap[func1] = f; }
+else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func1 << endl;
+
+if ((func2.length() < 1) || (func2 == "-") || (func2 == ".") )  goto fin;
+// f = (DlUserProcFunction)  dlsym(dlhandle, func2.c_str());
+f = dynlink->GetFunction(func2);
+if (f) { nok++;  usfmap[func2] = f; }
+else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func2 << endl;
+
+if ((func3.length() < 1) || (func3 == "-") || (func3 == ".") )  goto fin;
+// f = (DlUserProcFunction)  dlsym(dlhandle, func3.c_str());
+f = dynlink->GetFunction(func3);
+if (f) { nok++;  usfmap[func3] = f; }
+else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func3 << endl;
+
+/*  Pb compile g++ 2.7.2 
+if ((func4.length() < 1) || (func4 == "-") || (func4 == ".") )  goto fin;
+// f = (DlUserProcFunction)  dlsym(dlhandle, func4.c_str());
+f = dynlink->GetFunction(func4);
+if (f) { nok++;  usfmap[func4] = f; }
+else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func4 << endl;
+
+if ((func5.length() < 1) || (func5 == "-") || (func5 == ".") )  goto fin;
+// f = (DlUserProcFunction)  dlsym(dlhandle, func5.c_str());
+f = dynlink->GetFunction(func5);
+if (f) { nok++;  usfmap[func5] = f; }
+else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func5 << endl;
+*/
+fin:
+if (nok < 1) { if (dynlink) delete dynlink;    dynlink = NULL;  return(3); }
+else return(0);
+}
+
Index: /trunk/SophyaPI/PIext/basexecut.h
===================================================================
--- /trunk/SophyaPI/PIext/basexecut.h	(revision 293)
+++ /trunk/SophyaPI/PIext/basexecut.h	(revision 293)
@@ -0,0 +1,34 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Classe executeur de commande de base pour piapp
+//                                   Reza 05/99
+// LAL-IN2P3/CNRS
+
+#ifndef PIABaseExecutor_H_SEEN
+#define PIABaseExecutor_H_SEEN
+
+#include "piacmd.h"
+
+class PIABaseExecutor : public CmdExecutor {
+public :
+		PIABaseExecutor(PIACmd* piac, NamedObjMgr* omg, PIStdImgApp* app);
+  virtual	~PIABaseExecutor();
+  virtual int	Execute(string& keyw, vector<string>& args);
+
+protected :
+  void		RegisterCommands();
+//  Link dynamique de fonction user
+  int 		LinkUserFuncs(string& fnameso, string& func1, string& func2, string& func3);
+//                            string& func4, string& func5);   compil avec g++ 2.7.2
+  PIACmd* mpiac;
+  NamedObjMgr* mObjMgr;
+  PIStdImgApp* mImgApp;
+// g++ n'arrive pas a avaler ca (lignes trop longues)  on utilise donc des DlFunction  (Reza 20/08/98)
+// typedef map<string, DlUserProcFunction, less<string> > UsFmap;
+  typedef map<string, DlFunction, less<string> > UsFmap;
+  PDynLinkMgr* dynlink;
+  UsFmap usfmap;
+
+};
+
+
+#endif
Index: /trunk/SophyaPI/PIext/dlftypes.h
===================================================================
--- /trunk/SophyaPI/PIext/dlftypes.h	(revision 292)
+++ /trunk/SophyaPI/PIext/dlftypes.h	(revision 293)
@@ -18,4 +18,6 @@
 typedef int (* PlotExprFunc) (float* x, float* rx, float* ry, float* rz, float* wt);
 typedef void (* DlUserProcFunction) (vector<string>& args);
+typedef void (* DlFunction) ();
+typedef void (* DlModuleInitEndFunction) ();
 
 #endif
Index: /trunk/SophyaPI/PIext/exclude
===================================================================
--- /trunk/SophyaPI/PIext/exclude	(revision 292)
+++ /trunk/SophyaPI/PIext/exclude	(revision 293)
@@ -0,0 +1,1 @@
+modrecst.cc
Index: /trunk/SophyaPI/PIext/nobjmgr.cc
===================================================================
--- /trunk/SophyaPI/PIext/nobjmgr.cc	(revision 292)
+++ /trunk/SophyaPI/PIext/nobjmgr.cc	(revision 293)
@@ -15,5 +15,4 @@
 #include "strutil.h"
 #include "datatypes.h"
-#include "fitsimage.h"
 
 #include "nobjmgr.h"
@@ -26,7 +25,11 @@
 #include "matrix.h"
 #include "cvector.h"
-#include "zfidu.h"
-
-#include "fft.h"
+
+// EVOL-PLANCK
+#ifdef SANS_EVOLPLANCK
+#include "fitsimage.h"  
+#include "zfidu.h"  
+#endif
+
 #include "fct1dfit.h"
 #include "fct2dfit.h"
@@ -45,5 +48,5 @@
 
 //  Si le module StarReco++ a ete compile (Pour les StarList, Transfo, etc ...
-#ifndef SANS_StarReco 
+#ifdef SANS_EVOLPLANCK 
 #include "pistlist.h"
 #include "transfo.h"
@@ -388,5 +391,10 @@
 TRY{
 //  obj = RzReadFits((char*)flnm.c_str(), ImgOffX, ImgOffY, ImgSizX, ImgSizY, ImgBitSgn);
+#ifdef SANS_EVOLPLANCK 
   obj = RzReadFits((char*)flnm.c_str());
+#else
+  printf("NamedObjMgr::ReadFITS( NON-Disponible EVOL-PLANCK) \n"); 
+  obj = NULL;
+#endif
   if (obj == NULL)   ok = false;
 }  CATCH(merr) { 
@@ -438,8 +446,14 @@
 void NamedObjMgr::SaveFits(string const& nom, string const & flnm)
 {
+
+#ifndef SANS_EVOLPLANCK 
+printf("NamedObjMgr::SaveFITS( NON-Disponible EVOL-PLANCK) \n"); 
+return;
+
+#else
+
 PPersist* obj=NULL;
 obj = GetObj(nom);
 if (obj == NULL)  return;
-
 int cid = obj->ClassId();
 if ( (cid < ClassId_Image) && ( cid > ClassId_Image+kr_8) ) {
@@ -485,4 +499,6 @@
 } ENDTRY;
 
+#endif
+
 return;
 }
@@ -580,9 +596,9 @@
     break;
 
+#ifdef SANS_EVOLPLANCK 
   case ClassId_ZFidu : 
     ((ZFidu*)obj)->Print();
     break;
 
-#ifndef SANS_StarReco 
   case ClassId_StarList : 
     ((StarList*)obj)->Print(10, 1, 50);
@@ -710,4 +726,5 @@
     break;
 
+#ifdef SANS_EVOLPLANCK 
   case ClassId_ZFidu : 
     {
@@ -723,5 +740,4 @@
     }
 
-#ifndef SANS_StarReco 
   case ClassId_StarList : 
     {
@@ -1333,5 +1349,5 @@
     ndata=((RzImage*)obj)->XSize()*((RzImage*)obj)->YSize();
     break;
-#ifndef SANS_StarReco 
+#ifdef SANS_EVOLPLANCK 
   case ClassId_StarList : 
     ndata=((StarList*)obj)->NbStars();
@@ -1392,5 +1408,5 @@
 if (!myImgApp)  return; 
 
-cmd = "rm " + fname;
+cmd = "rm -f " + fname;
 rc = system(cmd.c_str());
 printf("PlotFunc_Do> %s  (Rc=%d)\n", cmd.c_str(), rc); 
@@ -2010,48 +2026,2 @@
 }
 
-/* --Methode-- */
-void NamedObjMgr::FFT(string const& nom, string dopt)
-{
-PPersist* obj=GetObj(nom);
-if (obj == NULL) {
-  cout << "NamedObjMgr::FFT() Error , Pas d'objet de nom " << nom << endl; 
-  return;
-}
-if (!myImgApp)  return; 
-
-int cid = obj->ClassId();
-if (cid != ClassId_Vector) { 
-  string ctyp = servnobjm->PClassIdToClassName(cid);
-  cout << "NamedObjMgr::FFT() Error , Objet n'est pas un vecteur " << ctyp << endl; 
-  return;
-  }
-
-FFT1 fft( *((Vector*)obj) );
-
-if (fft.NData() < 1)  return;
-
-char* ntn[3] = {"refc", "imfc", "pfc"};
-NTuple* nt = new NTuple(3,ntn);  // Creation NTuple 
-Vector* vf = new Vector(fft.NData()/2);
-
-float xnt[3]; 
-double pf;
-for(int k=0; k<fft.NData()/2; k++) {
-  xnt[0] = fft.ReF(k);  xnt[1] = fft.ImF(k); 
-  pf = (xnt[0]*xnt[0]+xnt[1]*xnt[1]);
-  if (pf >= 0.)  pf = sqrt(pf);  
-  xnt[2] = pf;   (*vf)(k) = pf;
-  nt->Fill(xnt);  
-  }
-
-P1DArrayAdapter* vya = new POVectorAdapter(vf, true);
-// vya->DefineXCoordinate(xmin, xmax);   a determiner
-PIYfXDrawer* dr = new   PIYfXDrawer(vya, NULL, true) ; 
-bool fgsr = true;
-dopt = "thinline," + dopt;
-int opt = servnobjm->DecodeDispOption(dopt, fgsr);
-myImgApp->DispScDrawer(dr, nom, opt);
-if (fgsr) myImgApp->RestoreGraphicAtt(); 
-
-return;
-}
Index: /trunk/SophyaPI/PIext/nobjmgr.h
===================================================================
--- /trunk/SophyaPI/PIext/nobjmgr.h	(revision 292)
+++ /trunk/SophyaPI/PIext/nobjmgr.h	(revision 293)
@@ -87,6 +87,4 @@
                               string par,string step,string min,string max,string opt);
 
-//   Calcul de la transforme de Fourier - A titre d'exemple
-  virtual void          FFT(string const& nom, string dopt);   
 
 // Acces au PIApplication et a la classe de service 
Index: /trunk/SophyaPI/PIext/piacmd.cc
===================================================================
--- /trunk/SophyaPI/PIext/piacmd.cc	(revision 292)
+++ /trunk/SophyaPI/PIext/piacmd.cc	(revision 293)
@@ -1,42 +1,102 @@
+#include "piacmd.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <math.h>
 
-#include <iostream.h>
-#include <string>
-#include <vector>
-#include <map>
-#if defined(__KCC__)
-using std::string ;
-#include <vector.h>
-#include <map.h>
-#endif
-
+#include "basexecut.h"
+
+#include "pdlmgr.h"
 #include "ctimer.h"
-
+// #include "dlftypes.h"
+
+#include "pistdimgapp.h"
 #include "nobjmgr.h"
-#include "piacmd.h"
-#include "pistdimgapp.h"
-
-#include "histos.h"
-#include "histos2.h"
-#include "hisprof.h"
-#include "ntuple.h"
-#include "generaldata.h"
-
-
-//  Pour le decoupage des commandes en lignes 
-typedef vector<string> cmdtok;
-
-//  Fonction pour faire le Fit de PSF sur image   
-static int FitPSFImg(cmdtok& tokens);
-static int Photom_Ouv(cmdtok& tokens);
-
-
+
+#include PISTDWDG_H 
+#include PILIST_H 
+
+// ------------------------------------------------------------
+//         Gestion d'une fenetre d'aide interactive        
+// ------------------------------------------------------------
+
+class PIAHelpWind : public PIWindow {
+public :
+		PIAHelpWind(PIStdImgApp* par, PIACmd* piacmd);
+  virtual	~PIAHelpWind();
+  virtual void  Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+  inline  void	AddHelpItem(const char * hitem) 
+			{ mNitem++;  hitemlist->AppendItem(hitem, 1000+mNitem); }
+protected :
+  PIStdImgApp* dap;
+  PIACmd* piac;
+  int mNitem;
+  PIList* hitemlist;
+  PIButton * mBut;
+  PILabel * mLab;
+  PIText* mTxt;
+};
+
+/* --Methode-- */
+PIAHelpWind::PIAHelpWind(PIStdImgApp *par, PIACmd* piacmd)
+  : PIWindow((PIMsgHandler *)par, "Help-PIApp", PIWK_normal,  400, 300, 100, 350)
+{
+dap = par;
+piac = piacmd;
+mNitem = 0;
+SetMsg(777);
+
+int bsx, bsy;
+int tsx, tsy;
+int spx, spy;
+PIApplicationPrefCompSize(bsx, bsy);
+spx = bsx/6;   spy = bsy/6;
+tsx = 10*bsx+2*spx;  tsy = 7*bsy+3*spy;
+SetSize(tsx,tsy);
+hitemlist = new PIList(this, "hitemlist", bsx*2.0, tsy-2*spy, spx/2, spy);
+hitemlist->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+// hitemlist->SetBorderWidth(2);
+mTxt = new PIText(this, "helptext", bsx*8.0, 6*bsy, bsx*2.0+1.5*spx, spy);
+mTxt->SetMutiLineMode(true);
+mTxt->SetTextEditable(false);
+mTxt->SetText("");
+mTxt->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mLab = new PILabel(this, "helpitem", bsx*4, bsy, bsx*2.5+2*spx, tsy-spy-bsy);
+mLab->SetBorderWidth(1);
+mLab->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mLab->SetLabel("");
+mBut = new PIButton(this, "Close", 700, bsx, bsy, tsx-bsx*1.5-spx, tsy-spy-bsy);
+mBut->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+}
+
+/* --Methode-- */
+PIAHelpWind::~PIAHelpWind()
+{
+delete hitemlist;
+delete mTxt;
+delete mLab;
+delete mBut;
+}
+
+/* --Methode-- */
+void PIAHelpWind::Process(PIMessage msg, PIMsgHandler* sender, void* /*data*/)
+{
+PIMessage um = UserMsg(msg);
+if (((um == 777) && (ModMsg(msg) == PIMsg_Close)) || (um == 700) ) {
+  Hide();
+  return;
+  }
+else if ( (um > 1000) && (sender == hitemlist)) {
+  string s = hitemlist->GetSelectionStr();
+  mTxt->SetText(piac->GetUsage(s));
+  mLab->SetLabel(s);
+  }  
+}
+
+
+static PIACmd* curpiacmd = NULL;
 /* --Methode-- */
 PIACmd::PIACmd(NamedObjMgr* omg, PIStdImgApp* app)
 {
-if (omg)  { mOmg= false; mObjMgr = omg; }
-else { mObjMgr = new NamedObjMgr;  mOmg = true; }
+mObjMgr = omg; 
 mImgApp = app;
 system("cp history.pic hisold.pic");
@@ -44,5 +104,25 @@
 trace = false;   timing = false;
 gltimer = NULL;
-dynlink = NULL;
+
+helpwin = new PIAHelpWind(app, this);
+
+string kw = "piacmd";
+string usage;
+usage = ">>> (piacmd) Interpreter's keywords : \n";
+usage += "  timingon  timingoff traceon  traceoff \n";
+usage += "  set unset listvar listcommands exec shell \n";
+usage += "  > set varname 'string'   # To set a variable, $varname \n";
+usage += "  > unset varname          # clear variable definition \n";
+usage += "  > listvars   # List of variable names and values \n";
+usage += "  > listcommands # List of all known commands \n";
+usage += "  > exec filename  # Execute commands from file \n";
+usage += "  > shell comand_string  # Execute shell command \n";
+usage += "  > help <command_name>  # <command_name> usage info \n"; 
+usage += "  > helpwindow           # Displays help window \n";
+RegisterCommand(kw, usage, NULL);
+
+basexec = new PIABaseExecutor(this, omg, app);
+AddInterpreter(this);
+curcmdi = this;
 }
 
@@ -50,47 +130,82 @@
 PIACmd::~PIACmd()
 {
-if (mOmg)  delete mObjMgr;
 hist.close();
 if (gltimer) { delete gltimer;  gltimer = NULL; }
-}
-
-/* --Methode-- */
-int PIACmd::Exec(string& file)
-{
-char line_buff[512];
-FILE *fip;
-
-if ( (fip = fopen(file.c_str(),"r")) == NULL ) {
-  cerr << "PIACmd::Exec() Error opening file " << file << endl;
-  hist << "##! PIACmd::Exec() Error opening file " << file << endl;
-  return(0);
-  }
- 
-hist << "### Executing commands from " << file << endl;
-if (trace) { 
-  mImgApp->GetConsole()->AddStr("### Executing commands from ", PIVA_Magenta);
-  mImgApp->GetConsole()->AddStr(file.c_str(), PIVA_Magenta);
-  mImgApp->GetConsole()->AddStr("\n", PIVA_Magenta);
-  }
-
-while (fgets(line_buff,511,fip) != NULL)
-  {
-  if (trace) mImgApp->GetConsole()->AddStr(line_buff, PIVA_Magenta);
-  line_buff[strlen(line_buff)-1] = '\0';   /*  LF/CR de la fin */
-  string line(line_buff);
-  Do(line);
-  }
-hist << "### End of Exec( " << file << " ) " << endl;
-if (trace) { 
-  mImgApp->GetConsole()->AddStr("### End of Exec( ", PIVA_Magenta);
-  mImgApp->GetConsole()->AddStr(file.c_str(), PIVA_Magenta);
-  mImgApp->GetConsole()->AddStr(" ) \n", PIVA_Magenta);
-  }
-
-return(0);
-}
-
-/* --Methode-- */
-int PIACmd::Do(string& s)
+Modmap::iterator it;
+for(it = modmap.begin(); it != modmap.end(); it++) {
+  string name = (*it).first + "_end";
+  DlModuleInitEndFunction fend = (*it).second->GetFunction(name);
+  if (fend) fend();
+  delete (*it).second;
+  }
+delete helpwin;
+if (curpiacmd == this)  curpiacmd = NULL;
+}
+
+/* --Methode-- */
+PIACmd* PIACmd::GetInterpreter()
+{
+return(curpiacmd);
+}
+
+/* --Methode-- */
+string PIACmd::Name()
+{
+return("piacmd");
+}
+
+/* --Methode-- */
+void PIACmd::RegisterCommand(string& keyw, string& usage, CmdExecutor * ce)
+{
+  // if (!ce) return;
+cmdex cme;
+cme.us = usage;
+cme.cex = ce;
+cmdexmap[keyw] = cme;
+if (helpwin) helpwin->AddHelpItem(keyw.c_str());
+}
+
+/* --Methode-- */
+void PIACmd::LoadModule(string& fnameso, string& name)
+{
+PDynLinkMgr * dynlink = new PDynLinkMgr(fnameso, false);
+if (dynlink == NULL) {
+  cerr << "PIACmd/LoadModule_Error: Pb opening SO " << fnameso << endl;
+  return;
+  }
+string fname = name + "_init";
+DlModuleInitEndFunction finit = dynlink->GetFunction(fname);
+if (!finit) {
+  cerr << "PIACmd/LoadModule_Error: Pb linking " << fname << endl;
+  return;
+  }
+cout << "PIACmd/LoadModule_Info: Initialisation module" << name 
+     << "  " << fname << "() ..." << endl;
+finit();
+modmap[name] = dynlink;
+return;
+}
+
+/* --Methode-- */
+void PIACmd::AddInterpreter(CmdInterpreter * cl)
+{
+if (!cl) return;
+interpmap[cl->Name()] = cl;
+}
+
+/* --Methode-- */
+void PIACmd::SelInterpreter(string& name)
+{
+InterpMap::iterator it = interpmap.find(name);
+if (it == interpmap.end())   return;
+curcmdi = (*it).second;
+}
+
+
+//  Pour le decoupage des commandes en lignes 
+typedef vector<string> cmdtok;
+
+/* --Methode-- */
+int PIACmd::Interpret(string& s)
 {
 
@@ -101,5 +216,5 @@
 
 if (s[0] == '#') {
-  cout << "PIACmd::Do() Comment-Line:" << s << endl;
+  cout << "PIACmd::Interpret() Comment-Line:" << s << endl;
   return(0); 
   } 
@@ -125,8 +240,8 @@
 
 for(int k=0; k<tokens.size(); k++) { // On remplace les $varname par la valeur de la variable
- if ((tokens[k])[0] != '$')  continue; 
- CmdVarList::iterator it = mVars.find(tokens[k].substr(1));
- if (it != mVars.end())  tokens[k] = (*it).second;
-}
+  if ((tokens[k])[0] != '$')  continue; 
+  CmdVarList::iterator it = mVars.find(tokens[k].substr(1));
+  if (it != mVars.end())  tokens[k] = (*it).second;
+  }
 
 // cout << "PIACmd::Do() DBG  KeyW= " << kw << " NbArgs= " << tokens.size() << endl;
@@ -135,66 +250,40 @@
 
 // >>>>>>>>>>> Commande d'interpreteur
-if (kw == "help") {
-  cout << "\n PIACmd::Do() ----- Help : Liste des commandes ------------ \n";
-  cout << "help  shelp  exec  set  listvars  traceon  traceoff \n"; 
-  cout << "timingon  timingoff  shell \n"; 
-  cout << "link  call    zone  grwin  gratt  stacknext \n" ;
-  cout << "openppf  saveall  listobjs openfits savefits \n"; 
-  cout << "print rename  del delobjs \n";
-  cout << "newh1d  newh2d  newprof newgfd func  func2d \n" ; 
-  cout << "disp  surf  nt2d  nt3d  gfd2d  gfd3d \n" ;
-  cout << "plot2d plot3d  projh1d  projh2d  projprof \n";  
-  cout << "fillvec  fillnt fillgd1 fillgd2  fft fit fitpsf aper\n";
-  cout << "*** Commande sans args -> liste d'arguments\n";
-  cout << "*** dopt: DisplayOption = next/same/win/stack,color,... \n";
-  cout << "*** $varname remplace par la valeur de la variable varname\n" << endl; 
-  }
-
-else if (kw == "shelp" )   {
-  cout << "\n PIACmd::Do() ------------- SHelp ------------ " << endl;
-  cout << "exec filename   --   set varname string  --  clr varname  --  listvars \n"; 
-  cout << "traceon/off  --  timingon/off  --  shell cmdline\n";
-  cout << "link fnameso f1 [f2 f3]  --   call userf [arg1 arg2 ...]\n";
-  cout << "zone nx ny -- newwin nx ny -- gratt attributes_list -- stacknext \n";
-  cout << "openppf file -- saveall file -- listobjs \n";
-  cout << "openfits file -- savefits nomobj file \n";
-  cout << "print nomobj -- rename nomobj nomnew -- del nomobj -- delobjs pattern (*,?) \n";
-  cout << "newh1d nomh xmin xmax nbin  --  newh2d nomh xmin xmax nbinx ymin ymax nbiny\n";
-  cout << "newprof nomh xmin xmax nbin [ymin ymax] \n";
-  cout << "newgfd nomgfd nvar nalloc [errx(0/1)]\n";
-  cout << "func expfunc xmin xmax npt opt\n";
-  cout << "func2d expfunc xmin xmax nptx ymin ymax npty opt\n";
-  cout << "disp nomobj opt  --  surf nomobj opt\n";
-  cout << "nt2d nomobj varx vary errx erry opt\n";
-  cout << "nt3d nomobj varx vary varz errx erry errz dopt\n";
-  cout << "gfd2d nomobj numvarx erreur=(x y xy) opt\n";
-  cout << "gfd3d nomobj numvarx numvary erreur=(x y z xy xz yz xyz) opt\n";
-  cout << "plot2d nomobj expx expy [experrx experry] expcut  dopt\n";
-  cout << "plot3d nomobj expx expy expz expcut dopt\n";
-  cout << "projh1d nomobj expx expwt expcut nomh1 dopt\n";
-  cout << "projh2d nomobj expx expy expwt expcut nomh2 dopt\n";
-  cout << "projprof nomobj expx expy expwt expcut nomprof dopt\n";
-  cout << "fillnt nomobj expx expy expz expt  expcut nomnt dopt\n";
-  cout << "fillvec nomobj expx expcut nomvec dopt\n";
-  cout << "fillgd1 nomobj expx expy experry expcut nomgfd\n";
-  cout << "fillgd2 nomobj expx expy expz experrz expcut nomgfd\n";
-  cout << "fft nomobj dopt\n";
-  cout << "fit nomobj func [p:p1,.,pn s:s1,.,sn m:m1,.,mn M:M1,.,Mn I:i1,i2 o:... o:...]\n";
-  cout << "fitpsf psf_typ [options_fit]\n";
-  cout << "aper fond_typ [options_calcul]\n";
-}
+if (kw == "helpwindow") ShowHelpWindow();
+else if (kw == "help") {
+  if (tokens.size() > 0) {
+    CmdExmap::iterator it = cmdexmap.find(tokens[0]);
+    if (it == cmdexmap.end())  cout << "Nothing known about " << tokens[0] << " ?? " << endl;
+    else cout << (*it).second.us << endl;
+    }
+  else {  
+    cout << "\n -------- PIACmd::Interpret() ::::: Help ------------ \n";
+    cout << ">>> Interpreter's keywords : \n";
+    cout << "  timingon  timingoff traceon  traceoff \n";
+    cout << "  set unset listvar listcommands exec shell \n";
+    cout << "  > set varname 'string'   # To set a variable, $varname \n";
+    cout << "  > unset varname          # clear variable definition \n";
+    cout << "  > listvars   # List of variable names and values \n";
+    cout << "  > listcommands # List of all known commands \n";
+    cout << "  > exec filename  # Execute commands from file \n";
+    cout << "  > shell comand_string  # Execute shell command \n";
+    cout << "  > help <command_name>  # <command_name> usage info \n"; 
+    cout << "  > helpwindow           # Displays help window \n" << endl;
+    }
+  }
+
 
 else if (kw == "set") {
-  if (tokens.size() < 2) { cout << "PIACmd::Do() Usage: set varname string" << endl;  return(0); }
+  if (tokens.size() < 2) { cout << "PIACmd::Interpret() Usage: set varname string" << endl;  return(0); }
   mVars[tokens[0]] = tokens[1];
   }
-else if (kw == "clr") {
-  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: clr varname" << endl;  return(0); }
+else if (kw == "unset") {
+  if (tokens.size() < 1) { cout << "PIACmd::Interpret() Usage: unset varname" << endl;  return(0); }
   CmdVarList::iterator it = mVars.find(tokens[0]);
   if (it != mVars.end())  mVars.erase(it);
-  else cerr << "PIACmd::Do() Pas de variable de nom " << tokens[0] << endl;
+  else cerr << "PIACmd::Interpret() No variable with name " << tokens[0] << endl;
   }
 else if (kw == "listvars") {
-  cout << "PIACmd::Do()  Variable List , VarName = Value \n";
+  cout << "PIACmd::Interpret()  Variable List , VarName = Value \n";
   CmdVarList::iterator it;
   for(it = mVars.begin(); it != mVars.end(); it++)  
@@ -202,892 +291,100 @@
   cout << endl;
   }
-else if (kw == "traceon")  { cout << "PIACmd::Do()  -> Trace ON mode " << endl; trace = true; }
-else if (kw == "traceoff") { cout << "PIACmd::Do()  -> Trace OFF mode " << endl; trace = false; }
+else if (kw == "listvars") {
+  cout << "---- PIACmd::Interpret()  Command keyword  List ----- \n";
+  CmdExmap::iterator it;
+  int kc = 0;
+  for(it = cmdexmap.begin(); it != cmdexmap.end(); it++) {
+    cout << (*it).first << "  ";
+    kc++;
+    if (kc >= 5) { cout << "\n"; kc = 0; }
+    }
+  cout << endl;
+  }
+else if (kw == "traceon")  { cout << "PIACmd::Interpret()  -> Trace ON mode " << endl; trace = true; }
+else if (kw == "traceoff") { cout << "PIACmd::Interpret()  -> Trace OFF mode " << endl; trace = false; }
 else if (kw == "timingon") { 
-  cout << "PIACmd::Do()  -> Timing ON mode " << endl; 
-  if (gltimer)   delete gltimer;   gltimer = new Timer("PIA-CmdInterpreter ");   timing = true; }
+  cout << "PIACmd::Interpret()  -> Timing ON mode " << endl; 
+  if (gltimer)   delete gltimer;   gltimer = new Timer("PIA-CmdInterpreter ");   timing = true; 
+  }
 else if (kw == "timingoff") { 
-  cout << "PIACmd::Do()  -> Timing OFF mode " << endl; 
-  if (gltimer)  delete gltimer;  gltimer = NULL;  timing = false; }
+  cout << "PIACmd::Interpret()  -> Timing OFF mode " << endl; 
+  if (gltimer)  delete gltimer;  gltimer = NULL;  timing = false; 
+  }
 else if (kw == "exec") {
-  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: exec filename" << endl;  return(0); }
-  Exec(tokens[0]);
+  if (tokens.size() < 1) { cout << "PIACmd::Interpret() Usage: exec filename" << endl;  return(0); }
+  ExecFile(tokens[0]);
   }
 else if (kw == "shell") {
-  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: shell cmdline" << endl;  return(0); }
+  if (tokens.size() < 1) { cout << "PIACmd::Interpret() Usage: shell cmdline" << endl;  return(0); }
   system(toks.c_str());
   }
-
-// >>>>>>>>>>> Fenetre graphique , changement d'attributs graphiques 
-else if (kw == "zone") {
-  if (tokens.size() < 2) { cout << "PIACmd::Do() Usage: zone nx ny" << endl;  return(0); }
-  int nx, ny;
-  nx = ny = 1;
-  nx = atoi(tokens[0].c_str());    ny = atoi(tokens[1].c_str());
-  mObjMgr->SetGraphicWinZone(nx, ny, false);
-  }  
-else if (kw == "newwin") {
-  if (tokens.size() < 2) { cout << "PIACmd::Do() Usage: newwin nx ny" << endl;  return(0); }
-  int nx, ny;
-  nx = ny = 1;
-  nx = atoi(tokens[0].c_str());    ny = atoi(tokens[1].c_str());
-  mObjMgr->SetGraphicWinZone(nx, ny, true);
-  }  
-else if (kw == "gratt") {
-  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: gratt attributes_list (att=def->defaut)" << endl;  return(0); }
-  mObjMgr->SetGraphicAttributes(tokens[0]); 
-  }
-else if (kw == "stacknext") mImgApp->StackWinNext(); 
-
-// >>>>>>>>>>> Link dynamique de fonctions C++
-else if (kw == "link" ) {
-  if (tokens.size() < 2) { cout << "PIACmd::Do() Usage: link fnameso f1 [f2 f3]" << endl;  return(0); }
-  string sph = "";
-  for(int gg=0; gg<5; gg++)   tokens.push_back(sph);
-  int rc = LinkUserFuncs(tokens[0], tokens[1], tokens[2], tokens[3]);
-  if (rc == 0)  cout << "PIAcmd::Do(): Link from " << tokens[0] << " OK " << endl;
-}
-else if (kw == "call" ) {
-  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: call userf [arg1 arg2 ...]" << endl;  return(0); }
-  UsFmap::iterator it = usfmap.find(tokens[0]);
-  if (it == usfmap.end()) {
-    cerr << "PIAcmd::Do() No User Function " << tokens[0] << endl;
-    return(0);
-  }
-  cout << "PIAcmd::Do() Call " << tokens[0] << "( ... )" << endl;
-// on est oblige de faire un cast  etant donne qu'on 
-// utilise donc des DlFunction  (Reza 20/08/98)  voir commentaire ds .h (pb g++)
-  DlUserProcFunction fuf = (DlUserProcFunction)(*it).second;
-  TRY {
-    tokens.erase(tokens.begin());
-    fuf(tokens);
-  }  CATCH(merr) {
-    fflush(stdout); 
-    cout << endl; 
-    cerr << endl;
-    string es = PeidaExc(merr);
-    cerr << "PIACmd::Do() Call UserFunc  Exception :" << merr << es;
+//  Execution d'une commande enregistree
+else {
+  CmdExmap::iterator it = cmdexmap.find(kw);
+  if (it == cmdexmap.end())  cout << "No such command : " << kw << " ! " << endl;
+  else { 
+    if ((*it).second.cex) (*it).second.cex->Execute(kw, tokens);
+    else cout << "Dont know how to execute " << kw << " ? " << endl;
     }
-}
-
-// >>>>>>>>>>> lecture/ecriture des objets, gestion des objets 
-else if (kw == "openfits" ) {
-  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: openfits file " << endl;  return(0); }
-  else mObjMgr->ReadFits(tokens[0]);
-}
-else if (kw == "savefits" ) {
-  if (tokens.size() < 2) { cout << "PIACmd::Do() Usage: savefits nomobj filename " << endl;  return(0); }
-  else mObjMgr->SaveFits(tokens[0], tokens[1]);
-}
-else if (kw == "openppf" ) {
-  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: openppf file " << endl; return(0); }
-  mObjMgr->ReadAll(tokens[0]);  
-}
-else if (kw == "saveall" ) {
-  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: saveall file " << endl; return(0); }
-  mObjMgr->SaveAll(tokens[0]);  
-}
-else if (kw == "print" ) {
-  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: print nomobj " << endl; return(0); }
-  mObjMgr->PrintObj(tokens[0]);  
-}
-else if (kw == "rename" ) {
-  if (tokens.size() < 2) { cout << "PIACmd::Do() Usage: rename nomobj nomnew" << endl; return(0); }
-  mObjMgr->RenameObj(tokens[0], tokens[1]);  
-}
-else if (kw == "del" ) {
-  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: del nomobj " << endl; return(0); }
-  mObjMgr->DelObj(tokens[0]);  
-}
-else if (kw == "delobjs" ) {
-  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: delobjs nomobjpattern (*,?) " << endl; return(0); }
-  mObjMgr->DelObjects(tokens[0]);  
-}
-else if (kw == "listobjs")   mObjMgr->ListObjs();
-
-// >>>>>>>>>>> Creation d'histos 1D-2D
-else if (kw == "newh1d") {
-  if (tokens.size() < 4) { cout << "PIACmd::Do() Usage: newh1d nom xmin xmax nbin" << endl; return(0); }
-  int nbx;
-  float xmin, xmax;
-  nbx = 100;
-  xmin = 0.;  xmax = 1.;
-  nbx = atoi(tokens[3].c_str());
-  xmin = atof(tokens[1].c_str());   xmax = atof(tokens[2].c_str());
-  Histo* h = new Histo(xmin, xmax, nbx);
-  mObjMgr->AddObj(h, tokens[0]);
-  }
-else if (kw == "newh2d") {
-  if (tokens.size() < 7) { 
-    cout << "PIACmd::Do() Usage:newh2d nomh xmin xmax nbinx ymin ymax nbiny" << endl; 
-    return(0); 
-    }
-  int nbx, nby;
-  float xmin, xmax;
-  float ymin, ymax;
-  nbx = nby = 50;
-  xmin = 0.;  xmax = 1.;
-  ymin = 0.;  ymax = 1.;
-  nbx = atoi(tokens[3].c_str());
-  nby = atoi(tokens[6].c_str());
-  xmin = atof(tokens[1].c_str());   xmax = atof(tokens[2].c_str());
-  ymin = atof(tokens[4].c_str());   ymax = atof(tokens[5].c_str());
-  Histo2D* h = new Histo2D(xmin, xmax, nbx, ymin, ymax, nby);
-  mObjMgr->AddObj(h, tokens[0]);
-  }
-else if (kw == "newprof") {
-  if (tokens.size() < 4)
-    { cout << "PIACmd::Do() Usage: newprof nom xmin xmax nbin [ymin ymax]" << endl; return(0); }
-  int nbx;
-  float xmin, xmax, ymin = 1., ymax = -1.;
-  if(tokens.size() > 5)
-    {ymin = atof(tokens[4].c_str());   ymax = atof(tokens[5].c_str());}
-  nbx = 100;
-  xmin = 0.;  xmax = 1.;
-  nbx = atoi(tokens[3].c_str());
-  xmin = atof(tokens[1].c_str());   xmax = atof(tokens[2].c_str());
-  HProf* h = new HProf(xmin, xmax, nbx, ymin, ymax);
-  mObjMgr->AddObj(h, tokens[0]);
-  }
-else if (kw == "newgfd") {
-  if (tokens.size() < 3)
-    { cout << "PIACmd::Do() Usage: newgfd nvar nalloc [errx(0/1)]" << endl; return(0); }
-  int nvar, nalloc, errx=0;
-  if (tokens.size() > 3)
-    { errx = atoi(tokens[3].c_str()); if(errx>0) errx=1; else errx = 0;}
-  nvar = atoi(tokens[1].c_str()); nalloc = atoi(tokens[2].c_str());
-  if(nvar>0 && nalloc>0) {
-    GeneralFitData* gfd = new GeneralFitData(nvar,nalloc,errx);
-    mObjMgr->AddObj(gfd, tokens[0]);
-    }
-  }
-
-// >>>>>>>>>>>  Affichage des objets 
-else if ( (kw == "disp") || (kw == "surf") ) {
-  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: disp nomobj opt" << endl; return(0); }
-  string opt = "n";
-  if (tokens.size() > 1)  opt = tokens[1];
-  if (kw == "disp") mObjMgr->DisplayObj(tokens[0], opt);
-  else if (kw == "surf")  mObjMgr->DisplaySurf3D(tokens[0], opt);
-  }
-
-else if (kw == "nt2d") {
-  if (tokens.size() < 5) { cout << "PIACmd::Do() Usage: nt2d nomobj varx vary errx erry opt" << endl; return(0); }
-  string opt = "n";
-  if (tokens.size() > 5)  opt = tokens[5];
-  string ph = "";
-  mObjMgr->DisplayNT(tokens[0],tokens[1],tokens[2], ph, tokens[3], tokens[4], ph, opt);
-  }
-else if (kw == "nt3d") {
-  if (tokens.size() < 7) { cout << "PIACmd::Do() Usage: nt3d nomobj varx vary varz errx erry errz opt" << endl; return(0); }
-  string opt = "n";
-  if (tokens.size() > 7)  opt = tokens[7];
-  mObjMgr->DisplayNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], tokens[6], opt);
-  }
-
-else if (kw == "gfd2d") {
-  if(tokens.size()<2)
-    {cout<<"PIACmd::Do() Usage: gfd2d nomobj numvarx erreur=(x y xy) opt"<<endl;
-     return(0);}
-  string numvary = "";
-  string err = "";
-  string opt = "n";
-  if(tokens.size()>2) err = tokens[2];
-  if(tokens.size()>3) opt = tokens[3];
-  mObjMgr->DisplayGFD(tokens[0],tokens[1],numvary,err,opt);
-  }
-else if (kw == "gfd3d") {
-  if(tokens.size()<3)
-    {cout<<"PIACmd::Do() Usage: gfd3d nomobj numvarx numvary erreur=(x y z xy xz yz xyz) opt"<<endl;
-     return(0);}
-  string err = "";
-  string opt = "n";
-  if(tokens.size()>3) err = tokens[3];
-  if(tokens.size()>4) opt = tokens[4];
-  mObjMgr->DisplayGFD(tokens[0],tokens[1],tokens[2],err,opt);
-  }
-
-// >>>>>>>>>>>  Trace de fonctions 
-else if ( (kw == "func") ) {
-  if (tokens.size() < 4) { cout << "PIACmd::Do() Usage: func expr xmin xmax npt opt" << endl; return(0); }
-  string opt = "n";
-  if (tokens.size() > 4)  opt = tokens[4];
-  int np;
-  float xmin, xmax;
-  np = 100;
-  xmin = 0.;  xmax = 1.;
-  np = atoi(tokens[3].c_str());
-  xmin = atof(tokens[1].c_str());   xmax = atof(tokens[2].c_str());
-  mObjMgr->PlotFunc(tokens[0], xmin, xmax, np, opt); 
-  }
-else if ( (kw == "func2d") ) {
-  if (tokens.size() < 7) {
-    cout << "PIACmd::Do() Usage: func2d expr xmin xmax nptx ymin ymax npty opt" << endl;
-    return(0);
-    }
-  int npx, npy;
-  float xmin, xmax;
-  float ymin, ymax;
-  npx = npy = 50;
-  xmin = 0.;  xmax = 1.;
-  ymin = 0.;  ymax = 1.;
-  npx = atoi(tokens[3].c_str());
-  npy = atoi(tokens[6].c_str());
-  xmin = atof(tokens[1].c_str());   xmax = atof(tokens[2].c_str());
-  ymin = atof(tokens[4].c_str());   ymax = atof(tokens[5].c_str());
-  string opt = "n";
-  if (tokens.size() > 7)  opt = tokens[7];
-  mObjMgr->PlotFunc2D(tokens[0], xmin, xmax, ymin, ymax, npx, npy, opt);
-  }
-
-// >>>>>>>>>>>  Trace d'expressions de N_Tuple, StarList, etc ...
-else if (kw == "plot2d" ) {
-  if (tokens.size() < 4) {
-    cout << "PIACmd::Do() Usage: plot2d nomobj expx expy [experrx experry] expcut opt" << endl;
-    return(0); 
-    }
-  string errx = ""; string erry = ""; string ecut = "1";
-  string opt = "n";
-  if (tokens.size() < 6) { // Plot sans les erreurs
-    ecut = tokens[3];
-    if (tokens.size() > 4)  opt = tokens[4];
-    }
-  else {                 // Plot avec les erreurs
-    errx = tokens[3]; erry = tokens[4]; ecut = tokens[5];
-    if (tokens.size() > 6)  opt = tokens[6];
-    }
-  mObjMgr->DisplayPoints2D(tokens[0],tokens[1],tokens[2],errx,erry,ecut,opt);
-  }
-
-else if (kw == "plot3d" ) {
-  if (tokens.size() < 5) { 
-    cout << "PIACmd::Do() Usage: plot3d nomobj expx expy expz expcut opt" << endl;
-    return(0); 
-    }
-  string opt = "n";
-  if (tokens.size() > 5)  opt = tokens[5];
-  mObjMgr->DisplayPoints3D(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], opt);
-  }
-
-else if (kw == "projh1d" ) {
-  if (tokens.size() < 5) { 
-    cout << "PIACmd::Do() Usage: projh1d nomobj expx expwt expcut nomh1 opt" << endl;
-    return(0);
-    }
-  string opt = "n";
-  if (tokens.size() > 5)  opt = tokens[5];
-  mObjMgr->ProjectH1(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], opt);
-  }
-
-else if (kw == "projh2d" ) {
-  if (tokens.size() < 6) { 
-    cout << "PIACmd::Do() Usage: projh2 nomobj expx expy expwt expcut nomh2 opt" << endl;
-    return(0);
-    }
-  string opt = "n";
-  if (tokens.size() > 6)  opt = tokens[6];
-
-  mObjMgr->ProjectH2(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], opt);
-  }
-
-else if (kw == "projprof" ) {
-  if (tokens.size() < 6) { 
-    cout << "PIACmd::Do() Usage: projprof nomobj expx expy expwt expcut nomprof opt" << endl;
-    return(0);
-    }
-  string opt = "n";
-  if (tokens.size() > 6)  opt = tokens[6];
-
-  mObjMgr->ProjectHProf(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], opt);
-  }
-
-else if (kw == "fillnt" ) {
-  if (tokens.size() < 7) { 
-    cout << "PIACmd::Do() Usage: fillnt nomobj expx expy expz expt expcut nomnt" << endl;
-    return(0);
-    }
-  mObjMgr->FillNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], tokens[6] );
-  }
-
-else if (kw == "fillvec" ) {
-  if (tokens.size() < 4) { 
-    cout << "PIACmd::Do() Usage: fillvec nomobj expx expcut nomvec opt" << endl;
-    return(0);
-    }
-  string opt = "n";
-  if (tokens.size() > 4)  opt = tokens[4];
-  mObjMgr->FillVect(tokens[0],tokens[1],tokens[2], tokens[3], opt);
-  }
-
-else if (kw == "fillgd1" ) {
-  if (tokens.size() < 5) {
-    cout << "PIACmd::Do() Usage: fillgd1 nomobj expx expy experry expcut nomgfd" << endl;
-    return(0);
-    }
-  string nomgfd = "";
-  if (tokens.size() > 5) nomgfd = tokens[5];
-  string expy = "";
-  mObjMgr->FillGFD(tokens[0],tokens[1], expy, tokens[2], tokens[3], tokens[4],nomgfd);
-  }
-
-else if (kw == "fillgd2" ) {
-  if (tokens.size() < 6) {
-    cout << "PIACmd::Do() Usage: fillgd2 nomobj expx expy expz experrz expcut nomgfd" << endl;
-    return(0);
-    }
-  string nomgfd = "";
-  if (tokens.size() > 6) nomgfd = tokens[6];
-  mObjMgr->FillGFD(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5],nomgfd);
-  }
-
-// Calcul TF 
-else if (kw == "fft" ) {
-  if (tokens.size() < 1) { 
-    cout << "PIACmd::Do() Usage: fft nomobj opt" << endl;
-    return(0);
-    }
-  string opt = "n";
-  if (tokens.size() > 1)  opt = tokens[1];
-  mObjMgr->FFT(tokens[0], opt);
-  }
-
-// Fit 1D sur objets 1D. Egalement Fit 2D sur objets 2D.
-else if (kw == "fit") {
-  if (tokens.size() < 2) {
-    cout <<"PIACmd::Do() Usage:fit nomobj func \n"
-         <<" [p:p1,...,pn s:s1,...,sn m:m1,...,mn M:M1,...,Mn o:... o:...]\n";
-    return(0);
-  }
-  string p=""; string s=""; string m=""; string M=""; string O="";
-  if (tokens.size()>2)
-    for(int ip=2;ip<tokens.size();ip++) {
-      if(tokens[ip].length()<=2) continue;
-      const char *c = tokens[ip].c_str();
-      if(c[1]!=':') continue;
-      if(c[0]=='p')      p=c+2;
-      else if(c[0]=='s') s=c+2;
-      else if(c[0]=='m') m=c+2;
-      else if(c[0]=='M') M=c+2;
-      else if(c[0]=='o') {O += ","; O += c+2;}
-    }
-  mObjMgr->Fit12D(tokens[0],tokens[1],p,s,m,M,O);
-}
-
-#ifndef SANS_StarReco 
-// FITPSF sur image
-else if (kw == "fitpsf" ) {
-  if (tokens.size() < 1) { 
-    cout << "PIACmd::Do() Usage: fitpsf psf_typ [options_fit]" << endl;
-    return(0);
-    }
-  FitPSFImg(tokens);
-  }
-
-// Photometrie d'ouvertue sur image 
-else if (kw == "aper" ) {
-  if (tokens.size() < 1) { 
-    cout << "PIACmd::Do() Usage: aper fond_typ [opt_calcul opt_disp]" << endl;
-    return(0);
-    }
-  Photom_Ouv(tokens);
-  }
-#endif
-
-else  { 
-  cerr << "PIACmd::Do() Erreur - Commande " << kw << " inconuue ! " << endl;    
-  return(-1);
-  }
+  }
+
 if (timing)  gltimer->Split();
-
 return(0);
 }
 
 
-
-/* --Methode-- */
-int PIACmd::LinkUserFuncs(string& fnameso, string& func1, string& func2, string& func3)
-//                          string& func4, string& func5)
-{
-string cmd;
-int rc;
-
-if (dynlink) delete dynlink;    dynlink = NULL;
-usfmap.clear();
-
-dynlink = new PDynLinkMgr(fnameso, true);
-if (dynlink == NULL) { 
-  string sn = fnameso; 
-  cerr << "PIACmd/LinkUserFuncs_Erreur: Erreur ouverture SO " << sn << endl; 
-  return(2); 
-  }
-
-int nok=0;
-// on utilise donc des DlFunction  (Reza 20/08/98)  voir commentaire ds .h (pb g++)
-// DlUserProcFunction f = NULL;
-DlFunction f = NULL;
-if ((func1.length() < 1) || (func1 == "-") || (func1 == ".") )  goto fin;
-// f = (DlUserProcFunction)  dlsym(dlhandle, func1.c_str());
-f = dynlink->GetFunction(func1);
-if (f) { nok++;  usfmap[func1] = f; }
-else cerr << "PIACmd/LinkUserFuncs_Erreur: Erreur linking " << func1 << endl;
-
-if ((func2.length() < 1) || (func2 == "-") || (func2 == ".") )  goto fin;
-// f = (DlUserProcFunction)  dlsym(dlhandle, func2.c_str());
-f = dynlink->GetFunction(func2);
-if (f) { nok++;  usfmap[func2] = f; }
-else cerr << "PIACmd/LinkUserFuncs_Erreur: Erreur linking " << func2 << endl;
-
-if ((func3.length() < 1) || (func3 == "-") || (func3 == ".") )  goto fin;
-// f = (DlUserProcFunction)  dlsym(dlhandle, func3.c_str());
-f = dynlink->GetFunction(func3);
-if (f) { nok++;  usfmap[func3] = f; }
-else cerr << "PIACmd/LinkUserFuncs_Erreur: Erreur linking " << func3 << endl;
-
-/*  Pb compile g++ 2.7.2 
-if ((func4.length() < 1) || (func4 == "-") || (func4 == ".") )  goto fin;
-// f = (DlUserProcFunction)  dlsym(dlhandle, func4.c_str());
-f = dynlink->GetFunction(func4);
-if (f) { nok++;  usfmap[func4] = f; }
-else cerr << "PIACmd/LinkUserFuncs_Erreur: Erreur linking " << func4 << endl;
-
-if ((func5.length() < 1) || (func5 == "-") || (func5 == ".") )  goto fin;
-// f = (DlUserProcFunction)  dlsym(dlhandle, func5.c_str());
-f = dynlink->GetFunction(func5);
-if (f) { nok++;  usfmap[func5] = f; }
-else cerr << "PIACmd/LinkUserFuncs_Erreur: Erreur linking " << func5 << endl;
-*/
-fin:
-if (nok < 1) { if (dynlink) delete dynlink;    dynlink = NULL;  return(3); }
-else return(0);
-}
-
-/////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////
-/////////////////////////////// Fonctions ///////////////////////////////
-/////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////
-#ifndef SANS_StarReco 
-#include "psf.h"
-#include "dynccd.h"
-#include "pimgadapter.h"
-#include "nbmath.h"
-#include "nbtri.h"
-
-/* Nouvelle-Fonction    rz + cmv 15/10/98 */
-int FitPSFImg(cmdtok& tokens)
-//	Fit de PSF sur une Image.
-//| tokens[0] = Type de PSF ()
-//|      : G   = fit gaussienne+fond (volume)
-//|      : Gi  = fit gaussienne+fond integree (volume)
-//|      : d   = fit DL de gaussienne+fond (volume)
-//|      : di  = fit DL de gaussienne+fond integree (volume)
-//|      : D   = fit DL de gaussienne+fond avec coeff variable p6 (volume)
-//|      : Di  = fit DL de gaussienne+fond integree avec coeff variable p6 (volume)
-//|      : M   = fit Moffat+fond (expos=p6) (volume)
-//|      : Mi  = fit Moffat+fond integree (expos=p6) (volume)
-//| tokens[1] = options pour le fit ex: l1.0,G2.,R7.,m10.,M65000.,P3.,f,n,r,i,w10/450
-//|      : r = ecriture de l'image des residus (def=non)
-//|      : f = ecriture de l'image de de la PSF fitee (def=non)
-//|      : i = ecriture du pave initial selectionne pour le fit (def=non)
-//|      : n = ecriture de l'image du bruit (def=non)
-//|      : Gaa.bbb = gain en e-/ADU (def=1)
-//|      : Raa.bbb = readout noise en e- (def=0)
-//|      : maa.bbb = limite basse dynamique en ADU (def=-9.e19)
-//|      : Maa.bbb = limite haute dynamique en ADU (def=9.e19)
-//|      : Paa.bbb = valeur du parametre supplementaire pour 
-//|      : la.a = print a=FitPSFImg, b=PSF.Fit PSF.IniFit
-//|      : wa/b = "a" est le facteur de zoom de la fenetre de representation
-//|               des resultats (def=6) et b sa taille maximale (def=500).
-//| Return: 0 si Ok, <0 sinon.
-{
-// Decodage des arguments
-if(tokens.size()<1) return(-1);
-int typ_psf=PSF::psfGaussienne;
-bool wres=false, wpsf=false, wpav=false, wnois=false;
-float gain=1., readout=0., pixmin=-9.e19, pixmax=9.e19;
-int zoom=6, wmax=500;
-float par6=-1.;
-int lp=1, lpg=0;
-string dummy,dum;
-
-if(tokens.size()>=2) {
-  dummy = "," + tokens[1]+ ",";
-  if(strstr(dummy.c_str(),",r,")) wres=true;
-  if(strstr(dummy.c_str(),",f,")) wpsf=true;
-  if(strstr(dummy.c_str(),",i"))  wpav=true;
-  if(strstr(dummy.c_str(),",n"))  wnois=true;
-  if(strstr(dummy.c_str(),",G")) {
-    size_t p = dummy.find(",G"); size_t q = dummy.find_first_of(',',p+1);
-    dum = dummy.substr(p,q-p);
-    if(dum.length()>2) sscanf(dum.c_str(),",G%f",&gain);
-  }
-  if(strstr(dummy.c_str(),",P")) {
-    size_t p = dummy.find(",P"); size_t q = dummy.find_first_of(',',p+1);
-    dum = dummy.substr(p,q-p);
-    if(dum.length()>2) sscanf(dum.c_str(),",P%f",&par6);
-  }
-  if(strstr(dummy.c_str(),",R")) {
-    size_t p = dummy.find(",R"); size_t q = dummy.find_first_of(',',p+1);
-    dum = dummy.substr(p,q-p);
-    if(dum.length()>2) sscanf(dum.c_str(),",R%f",&readout);
-  }
-  if(strstr(dummy.c_str(),",m")) {
-    size_t p = dummy.find(",m"); size_t q = dummy.find_first_of(',',p+1);
-    dum = dummy.substr(p,q-p);
-    if(dum.length()>2) sscanf(dum.c_str(),",m%f",&pixmin);
-  }
-  if(strstr(dummy.c_str(),",M")) {
-    size_t p = dummy.find(",M"); size_t q = dummy.find_first_of(',',p+1);
-    dum = dummy.substr(p,q-p);
-    if(dum.length()>2) sscanf(dum.c_str(),",M%f",&pixmax);
-  }
-  if(strstr(dummy.c_str(),",l")) { // niveau de print
-    size_t p = dummy.find(",l"); size_t q = dummy.find_first_of(',',p+1);
-    dum = dummy.substr(p,q-p);
-    float ab;
-    if(dum.length()>2) sscanf(dum.c_str(),",l%f",&ab);
-    if(ab<0) ab = 0.;
-    lp = (int) ab; lpg = (int) 10.*(ab-lp);
-  }
-  if(strstr(dummy.c_str(),",w")) { // niveau de print
-    size_t p = dummy.find(",w"); size_t q = dummy.find_first_of(',',p+1);
-    dum = dummy.substr(p,q-p);
-    if(dum.length()>2) sscanf(dum.c_str(),",w%d/%d",&zoom,&wmax);
-  }
-}
-
-dummy = "," + tokens[0]+ ",";
-if(strstr(dummy.c_str(),",G,"))        typ_psf=PSF::psfGaussienne;
-else if(strstr(dummy.c_str(),",Gi,"))  typ_psf=PSF::psfGaussInteg;
-else if(strstr(dummy.c_str(),",d,") )  typ_psf=PSF::psfDelGaussienne;
-else if(strstr(dummy.c_str(),",di,"))  typ_psf=PSF::psfDelGaussinteg;
-else if(strstr(dummy.c_str(),",D,") ) {typ_psf=PSF::psfDel1Gaussienne; if(par6<=0.) par6=1.;}
-else if(strstr(dummy.c_str(),",Di,")) {typ_psf=PSF::psfDel1GaussInteg; if(par6<=0.) par6=1.;}
-else if(strstr(dummy.c_str(),",M,") ) {typ_psf=PSF::psfMoffat;         if(par6<=1.) par6=2.5;}
-else if(strstr(dummy.c_str(),",Mi,")) {typ_psf=PSF::psfMoffInteg;      if(par6<=1.) par6=2.5;}
-
-if(gain<=0.) gain=1.; if(readout<0.) readout=0.;
-if(zoom<1) zoom=1; if(zoom>10) zoom=10; // Il semble que le zoom soit limite a 10 !!!
-if(wmax>500) wmax=500;
-if(lp<0) lp=1; if(lpg<0) lpg=0;
-
-// Wigdet,piimage et image courants
-NamedObjMgr omg;
-PIStdImgApp* app = omg.GetImgApp();
-if(app == NULL)
-  {cout<<"Pas de PIStdImgApp*"<<endl; return(-2);}
-PIBaseWdg* curw= app->CurrentBaseWdg() ;
-if(curw == NULL)
-  {cout<<"Pas de PIBaseWdg*"<<endl; return(-3);}
-if(curw->kind() != PIImage::ClassId)
-  {cout<<"Current window not an Image"<<endl; return(-4);}
-PIImage* curpimg = (PIImage*)curw;
-if(curpimg == NULL)
-  {cout<<"Pas de PIImage*"<<endl; return(-5);}
-P2DArrayAdapter* img = curpimg->Image();
-if(img == NULL)
-  {cout<<"Pas de Image*"<<endl; return(-6);}
-string nom = "fitpsf_";
-
-// Definition du pave courant sur la piimage
-int dx = curpimg->XSzPave(), dy = curpimg->YSzPave();  
-int x0 = curpimg->XPave()-dx/2, y0 = curpimg->YPave()-dy/2;
-if(x0<0) x0 = 0; if(y0<0) y0 = 0;
-int x1 = x0+dx, y1 = y0+dy;
-if(x1>img->XSize()) x1=img->XSize(); if(y1>img->YSize()) y1=img->YSize();
-dx = x1-x0;  dy = y1-y0;
-int dxy = (dx>dy)?dx:dy;
-ImageR4* pav = new ImageR4(dx, dy); 
-{for(int j=0;j<dy;j++) for(int i=0;i<dx;i++) (*pav)(i,j)=(*img)(i+x0,j+y0);}
-
-// Bruit sur le pave
-DynCCD mdynccd(kPhotonNoise,pixmin,pixmax,gain,readout);
-ImageR4 *nois = NoiseImage(pav, &mdynccd);
-
-// Print
-int w=2*zoom*dxy+25; if(w>wmax){w=wmax;zoom=(wmax-25)/(2*dxy);if(zoom<1)zoom=1;}
-if(lp>1)
-  {cout<<"FitPSFImg: fun="<<tokens[0]<<","<<typ_psf
-       <<"  Write res="<<wres<<" psf="<<wpsf<<" pav="<<wpav<<" nois="<<wnois
-       <<"  Par6="<<par6<<"  lp="<<lp<<","<<lpg<<endl;
-   mdynccd.Print();
-   cout<<"... dx,y="<<dxy<<" zoom="<<zoom<<" w="<<w<<endl;}
-
-// PSF et Fit
-PSF mypsf(typ_psf,100.0);
-int npar = mypsf.NParm();
-PSFStar mypsfstar(&mypsf);
-if(npar>7) mypsfstar.Parm(6)=(double)par6; // Cas moffat et Dl gauss avec coeff var.
-int rc = mypsfstar.IniFit(*pav,*nois,lpg);
-if(rc != 0)
-  {cout<<"PIDemoApp::FitPSFImg(), Echec IniFit (rc="<<rc<<")"<<endl;
-   delete nois;  delete pav; return(-10); }
-rc = mypsfstar.Fit(*pav,*nois,lpg);
-if(rc != 0)
-  {cout<<"PIDemoApp::FitPSFImg(), Echec Fit (rc="<<rc<<")"<<endl;
-   delete nois;  delete pav; return(-11); }
-if(lp) mypsfstar.Print(2);
-float smax,axisrat,tiltdeg;
-rc = paramga((float) mypsfstar.SigX(),(float) mypsfstar.SigY()
-            ,(float) mypsfstar.Rho(),&smax,&axisrat,&tiltdeg);
-if(rc==0 && lp)
-  printf("...   sa=%g sb=%g (%g) teta=%g\n",smax,smax*axisrat,axisrat,tiltdeg);
-else printf("Erreur paramga \n");
-
-// Creation des pave resultats
-ImageR4* res = new ImageR4(dx, dy);
-ImageR4* psf = new ImageR4(dx, dy);
-CopieImage(*res,*pav); *res -= mypsfstar;
-*psf = 0.; *psf += mypsfstar;
-
-// Si on demande d'ecrire au moins un des resultats (pav,nois,res,psf) => menage!
-bool delobj = (wpav||wnois||wres||wpsf)?true:false;
-
-// Display des resultats, fenetre 2x2 {{pav,nois},{res,psf}}
-app->CreateGraphWin(2,2,w,w); app->SetZoomAtt(zoom);
-dummy = nom+"pav"; dum = dummy+"*"; if(delobj) omg.DelObjects(dum);
-if(wpav) {
-  // Si on veut garder l'objet
-  omg.AddObj(pav,dummy);
-  omg.DisplayObj(omg.LastObjName());
-} else {
-  // "true" pour tuer (delete) de l'objet ImageR4 lors de la destruction de PIImage
-  app->DispImage(new ImageAdapter<r_4>(pav,true),dummy,Disp_Next);
-}
-dummy = nom+"nois"; dum = dummy+"*"; if(delobj) omg.DelObjects(dum);
-if(wnois) {
-  omg.AddObj(nois,dummy);
-  omg.DisplayObj(omg.LastObjName());
-} else {
-  app->DispImage(new ImageAdapter<r_4>(nois,true),dummy,Disp_Next);
-}
-dummy = nom+"res"; dum = dummy+"*"; if(delobj) omg.DelObjects(dum);
-if(wres) {
-  omg.AddObj(res,dummy);
-  omg.DisplayObj(omg.LastObjName());
-} else {
-  app->DispImage(new ImageAdapter<r_4>(res,true),dummy,Disp_Next);
-}
-dummy = nom+"psf"; dum = dummy+"*"; if(delobj) omg.DelObjects(dum);
-if(wpsf) {
-  omg.AddObj(psf,dummy);
-  omg.DisplayObj(omg.LastObjName());
-} else {
-  app->DispImage(new ImageAdapter<r_4>(psf,true),dummy,Disp_Next);
-}
+/* --Methode-- */
+int PIACmd::ExecFile(string& file)
+{
+char line_buff[512];
+FILE *fip;
+
+if ( (fip = fopen(file.c_str(),"r")) == NULL ) {
+  cerr << "PIACmd::Exec() Error opening file " << file << endl;
+  hist << "##! PIACmd::Exec() Error opening file " << file << endl;
+  return(0);
+  }
+ 
+hist << "### Executing commands from " << file << endl;
+if (trace) { 
+  mImgApp->GetConsole()->AddStr("### Executing commands from ", PIVA_Magenta);
+  mImgApp->GetConsole()->AddStr(file.c_str(), PIVA_Magenta);
+  mImgApp->GetConsole()->AddStr("\n", PIVA_Magenta);
+  }
+
+while (fgets(line_buff,511,fip) != NULL)
+  {
+  if (trace) mImgApp->GetConsole()->AddStr(line_buff, PIVA_Magenta);
+  line_buff[strlen(line_buff)-1] = '\0';   /*  LF/CR de la fin */
+  string line(line_buff);
+  Interpret(line);
+  }
+hist << "### End of Exec( " << file << " ) " << endl;
+if (trace) { 
+  mImgApp->GetConsole()->AddStr("### End of Exec( ", PIVA_Magenta);
+  mImgApp->GetConsole()->AddStr(file.c_str(), PIVA_Magenta);
+  mImgApp->GetConsole()->AddStr(" ) \n", PIVA_Magenta);
+  }
 
 return(0);
 }
 
-/* Nouvelle-Fonction    cmv 16/10/98 */
-int Photom_Ouv(cmdtok& tokens)
-//	Photometrie d'ouverture sur une Image.
-//| tokens[0] = Type de calcul du fond et du flux.
-//|   : b = fond calcule sur les pixels du bord du pave.
-//|   : a = fond sur les pixels autres que ceux servant au calcul du flux.
-//|   : faa.bbb = fond fixe a aa.bbb
-//|   defaut : "b"
-//| tokens[1] = options pour le fit ex: l1
-//|      : ra = "a" rayon minimal de scan (def=0)
-//|      : ga = "a" taille de la fenetre glissante pour les extrapolations (def=4)
-//|      : la = "a" niveau de print
-//|      : c  = la surface pour la photometrie est un carre (defaut=cercle)
-//|      : C  = recentrage du pave sur le pixel le + brillant  (defaut=non)
-//| tokens[2] = options graphiques
-//| Return: 0 si Ok, <0 sinon.
-{
-// Decodage des arguments
-if(tokens.size()<1) return(-1);
-int typ_fond=1, rmin=0, rmax, npt_gliss=4, lp=0;
-float fondimpos=0., fondbord=0., fondautre;
-bool cercle=true, centre=false;
-string opt="";
-string dummy; string dum;
-
-if(tokens.size()>=3) opt = tokens[2];
-if(tokens.size()>=2) {
-  dummy = "," + tokens[1]+ ",";
-  if(strstr(dummy.c_str(),",r")) {
-    size_t p = dummy.find(",r"); size_t q = dummy.find_first_of(',',p+1);
-    dum = dummy.substr(p,q-p);
-    if(dum.length()>2) sscanf(dum.c_str(),",r%d",&rmin);
-  }
-  if(strstr(dummy.c_str(),",g")) {
-    size_t p = dummy.find(",g"); size_t q = dummy.find_first_of(',',p+1);
-    dum = dummy.substr(p,q-p);
-    if(dum.length()>2) sscanf(dum.c_str(),",g%d",&npt_gliss);
-  }
-  if(strstr(dummy.c_str(),",l")) {
-    size_t p = dummy.find(",l"); size_t q = dummy.find_first_of(',',p+1);
-    dum = dummy.substr(p,q-p);
-    if(dum.length()>2) sscanf(dum.c_str(),",l%d",&lp);
-  }
-  if(strstr(dummy.c_str(),",c")) cercle = false;
-  if(strstr(dummy.c_str(),",C")) centre = true;
-}
-
-dummy = "," + tokens[0]+ ",";
-if(strstr(dummy.c_str(),",b,"))       typ_fond=1;
-else if(strstr(dummy.c_str(),",a,"))  typ_fond=2;
-else if(strstr(dummy.c_str(),",f"))  {
-  typ_fond=3;
-  size_t p = dummy.find(",f"); size_t q = dummy.find_first_of(',',p+1);
-  dum = dummy.substr(p,q-p);
-  if(dum.length()>2) sscanf(dum.c_str(),",f%f",&fondimpos);
-}
-
-if(rmin<0) rmin=0; if(npt_gliss<=0) npt_gliss=4; if(lp<0) lp=1;
-
-// Wigdet,piimage et image courants
-NamedObjMgr omg;
-PIStdImgApp* app = omg.GetImgApp();
-if(app == NULL)
-  {cout<<"Pas de PIStdImgApp*"<<endl; return(-2);}
-PIBaseWdg* curw= app->CurrentBaseWdg() ;
-if(curw == NULL)
-  {cout<<"Pas de PIBaseWdg*"<<endl; return(-3);}
-if(curw->kind() != PIImage::ClassId)
-  {cout<<"Current window not an Image"<<endl; return(-4);}
-PIImage* curpimg = (PIImage*)curw;
-if(curpimg == NULL)
-  {cout<<"Pas de PIImage*"<<endl; return(-5);}
-P2DArrayAdapter* img = curpimg->Image();
-if(img == NULL)
-  {cout<<"Pas de Image*"<<endl; return(-6);}
-string nom = "ouver_";
-
-// Definition du pave courant sur la piimage
-int xc = curpimg->XPave(), yc = curpimg->YPave();
-int dx = curpimg->XSzPave(), dy = curpimg->YSzPave();
-int dxym = (dx<dy)?dx:dy; if(dxym%2==0) dxym++; rmax = dxym/2;
-if(dxym<3||dxym>img->XSize()||dxym>img->YSize())
-  {cout<<"Pave trop petit/grand: "<<dxym<<endl; return(-10);}
-if(rmin>=rmax)
-  {cout<<"rayon mini="<<rmin<<">= rmax="<<rmax<<endl; return(-11);}
-if(centre) {  // Recentrage autour du pixel le + brillant?
-  int xcnew=-1, ycnew=-1; float pxnew=-1.e20,pxold=-1.e20,px;
-  for(int j=yc-rmax;j<=yc+rmax;j++) {
-    if(j<0 || j>=img->YSize()) continue;
-    for(int i=xc-rmax;i<=xc+rmax;i++) {
-      if(i<0 || i>=img->XSize()) continue;
-      px = (*img)(i,j);
-      if(i==xc && j==yc) pxold = px;
-      if((xcnew==-1 && ycnew==-1) || px>=pxnew) {xcnew=i; ycnew=j; pxnew=px;}
-      // cout<<"xcnew,ycnew,pxnew="<<xcnew<<" "<<ycnew<<" "<<pxnew<<endl;
-  } }
-  if(lp>1) cout<<"Re-centrage(x,y,px): old=("<<xc<<","<<yc<<","<<pxold<<")"
-               <<" -> new=("<<xcnew<<","<<ycnew<<","<<pxnew<<")"<<endl;
-  if(xcnew!=-1 && ycnew!=-1 && pxnew>pxold) {xc=xcnew; yc=ycnew;}
-}
-int x0=xc-rmax, y0=yc-rmax, x1=xc+rmax, y1=yc+rmax;
-if(x0<0||y0<0||x1>=img->XSize()||y1>=img->YSize())
-  {cout<<"Pave hors image"<<endl; return(-12);}
-int ic = rmax, jc = rmax;
-ImageR4* pav = new ImageR4(dxym, dxym);
-{for(int j=-rmax;j<=rmax;j++) for(int i=-rmax;i<=rmax;i++)
-    (*pav)(ic+i,jc+j)=(*img)(xc+i,yc+j);}
-
-// Print
-if(lp>1)
-  cout<<"photom_ouv[cercle="<<cercle<<",typ="<<typ_fond<<"]: pav["
-      <<dx<<","<<dy<<","<<dxym
-      <<"] xc,yc=["<<xc<<","<<yc<<"] ic,jc="<<ic<<","<<jc<<endl
-      <<"          (fond="<<fondimpos<<") pxmil="<<(*pav)(ic,ic)
-      <<" -> Rph de "<<rmin<<" a "<<rmax<<endl;
-
-// Ouverture des buffers et objets necessaires
-float *p = new float[dxym*dxym];
-r_4 xnt[4];
-NTuple *ntfl=NULL, *ntex=NULL;
-{char* name[4]={"npx","flux","fond","mag"}; ntfl = new NTuple(4,name);}
-{char* name[3]={"k","a","f0"};              ntex = new NTuple(3,name);}
-
-// Calcul du fond sur les pixels du bord du pave
-{
-int nf = 0;
-for(int i=0;i<dxym;i++)   {p[nf]=(*pav)(i,0); nf++; p[nf]=(*pav)(i,dxym-1); nf++;}
-for(int j=1;j<dxym-1;j++) {p[nf]=(*pav)(0,j); nf++; p[nf]=(*pav)(dxym-1,j); nf++;}
-qsort(p,(size_t) nf,sizeof(float),qSort_Float);
-fondbord = (p[nf/2]+p[(nf-1)/2])/2.;
-if(lp>0) cout<<"Fond_Bord: "<<fondbord<<" (avec 1 px au bord="<<nf<<")"<<endl;
-}
-
-// Photometrie d'ouverture variable.
-int rfin = -1;
-for(int r=rmin;r<=rmax;r++) {
-  double sum=0.; int ns=0, nf=0;
-  for(int i=0;i<dxym;i++) for(int j=0;j<dxym;j++) {
-    double ray2 = (i-ic)*(i-ic)+(j-jc)*(j-jc)-0.1;
-    if( (cercle && ray2<=r*r) ||
-        (!cercle && ic-r<=i && i<=ic+r && jc-r<=j && j<=jc+r) )
-          {sum += (*pav)(i,j); ns++;}
-    else {p[nf] = (*pav)(i,j); nf++;}
-  }
-  if(typ_fond==2) {
-    if(nf<2) continue;
-    qsort(p,(size_t) nf,sizeof(float),qSort_Float);
-    fondautre = (p[nf/2]+p[(nf-1)/2])/2.;
-  }
-  double fond=-1.e19;
-  if(typ_fond==3) fond=fondimpos; else if(typ_fond==2) fond=fondautre; else fond=fondbord;
-  rfin = r;
-  xnt[0] = ns;
-  xnt[1] = sum-fond*ns;
-  xnt[2] = fond;
-  xnt[3] = (xnt[1]>0.)? -2.5*log10((double)xnt[1]): -99.;
-  if(lp>0)
-    cout<<"Ouv[r="<<r<<",ns="<<xnt[0]<<",nf="<<nf<<"]: fd="<<xnt[2]
-        <<" fl="<<xnt[1]<<" mag="<<xnt[3]<<endl;
-  ntfl->Fill(xnt);
-}
-delete [] p;
-int nr = ntfl->NEntry();
-if(lp>1) cout<<"Nombre de calculs de flux: "<<nr<<endl;
-if(nr<=0)
-  {cout<<"Pas de flux calcules"<<endl; delete pav; delete ntfl; delete ntex; return(-13);}
-
-cout<<"Ouv[rouv="<<rfin<<",npix="<<xnt[0]<<"]: fond="<<xnt[2]
-    <<" flux="<<xnt[1]<<" mag="<<xnt[3]<<endl;
-
-// Extrapolation: F_mes = F_vrai + npxflux*(Fd_vrai-Fd_mes)
-// On fit F_mes=f(npxflux) sur une fenetre glissante de npt_gliss pts.
-bool ex = false;
-if(nr>=npt_gliss) {
-  ex = true;
-  double *npix = new double[nr], *flux = new double[nr], *err  = new double[nr];
-  for(int i=0;i<nr;i++) { ntfl->GetVec(i,xnt); npix[i]=xnt[0]; flux[i]=xnt[1]; err[i]=1.;}
-  double a,b; int n;
-  for(int k=0;k<=nr-npt_gliss;k++) {
-    n = npt_gliss; FitLin(&npix[k],&flux[k],&err[k],&n,&b,&a);
-    xnt[0]=k; xnt[1]=a; xnt[2]=b; ntex->Fill(xnt);
-    if(lp>1)
-      cout<<"Fit["<<k<<","<<k+npt_gliss-1<<"] f0="<<xnt[2]<<" pente="<<xnt[1]<<endl;
-  }
-  delete [] npix; delete [] flux; delete [] err;
-}
-
-// Display des resultats, fenetre 2x2 {{flux%ns,fond%ns},{f0,pente}}
-if(ex) app->CreateGraphWin(2,2); else app->CreateGraphWin(1,2);
-dummy = nom+"*"; omg.DelObjects(dummy);
-
-dummy=nom+"pav"; omg.AddObj(pav,dummy);
-
-string xd=""; string yd=""; string zd,exd,eyd,ezd;
-dummy=nom+"flux"; omg.AddObj(ntfl,dummy);
-xd="npx"; yd="flux";
-omg.DisplayNT(omg.LastObjName(),xd,yd,zd,exd,eyd,ezd,opt);
-if(typ_fond==2)
-  {xd="npx"; yd="fond"; omg.DisplayNT(omg.LastObjName(),xd,yd,zd,exd,eyd,ezd,opt);}
-if(ex) {
-  dummy=nom+"fit"; omg.AddObj(ntex,dummy);
-  if(typ_fond!=2)
-    {xd="a"; yd="f0"; omg.DisplayNT(omg.LastObjName(),xd,yd,zd,exd,eyd,ezd,opt);}
-  xd = "k"; yd = "f0";
-  omg.DisplayNT(omg.LastObjName(),xd,yd,zd,exd,eyd,ezd,opt);
-  xd = "k"; yd = "a";
-  omg.DisplayNT(omg.LastObjName(),xd,yd,zd,exd,eyd,ezd,opt);
-}
-
-return(0);
-}
-#endif
+
+static string* videstr = NULL;
+/* --Methode-- */
+string& PIACmd::GetUsage(const string& kw)
+{
+CmdExmap::iterator it = cmdexmap.find(kw);
+if (it == cmdexmap.end()) {  
+  if (videstr == NULL) videstr = new string("");
+  return(*videstr);
+  }
+else return( (*it).second.us ); 
+}
+
+/* --Methode-- */
+void PIACmd::ShowHelpWindow()
+{
+helpwin->Show();
+}
Index: /trunk/SophyaPI/PIext/piacmd.h
===================================================================
--- /trunk/SophyaPI/PIext/piacmd.h	(revision 292)
+++ /trunk/SophyaPI/PIext/piacmd.h	(revision 293)
@@ -7,40 +7,96 @@
 #define PIACMD_H_SEEN
 
-#include "defs.h"
-
+#include "machdefs.h"
+#include <iostream.h>
 #include <fstream.h>
 #include <string>
+#include <vector>
 #include <map>
 #if defined(__KCC__)
 using std::string ;
+#include <vector.h>
 #include <map.h>
 #endif
 
-#include "pdlmgr.h"
-
-#include "ctimer.h"
 #include "dlftypes.h"
 
+
+// Classe definissant l'interface pour un executeur de commande
+class CmdExecutor {
+public:
+  virtual	~CmdExecutor() {} ;
+  // keyw : Le mot cle associe , args: Arguments de la commande
+  virtual int	Execute(string& keyw, vector<string>& args)=0;
+};
+
+// Classe definissant l'interface pour un interpreteur de commande
+class CmdInterpreter {
+public:
+  virtual		~CmdInterpreter() {} ;
+  virtual string	Name()=0;
+  virtual int		Interpret(string& line)=0;
+};
+
+
+
+// Forward declaration of some classes ...
 class NamedObjMgr;
 class PIStdImgApp;
+class Timer;
+class PDynLinkMgr;
+class PIAHelpWind;
 
+// ---------------------------------------------------------------------
+// Classe Interpreteur de commande, gestionnaire de module chargeable,
+// et de fonctions dynamiquement linke pour PIStdImgApp
+// Permet de gerer plusieurs Interpreter differents 
+// ---------------------------------------------------------------------
 
-class PIACmd {
+class PIACmd : public CmdInterpreter  {
 public:
-		PIACmd(NamedObjMgr* omg=NULL, PIStdImgApp* app=NULL);
-		~PIACmd();
-  int		Exec(string& file);
-  int		Do(string& line);
+  static PIACmd*	GetInterpreter();
 
-//  Link dynamique de fonction user
-  int 		LinkUserFuncs(string& fnameso, string& func1, string& func2, string& func3);
-//                            string& func4, string& func5);   compil avec g++ 2.7.2
+			PIACmd(NamedObjMgr* omg, PIStdImgApp* app);
+  virtual		~PIACmd();
+  virtual string	Name();
+
+  virtual void		RegisterCommand(string& keyw, string& usage, CmdExecutor * ce);
+  virtual void		LoadModule(string& fnameso, string& name);
+
+  virtual void		AddInterpreter(CmdInterpreter * cl);
+  virtual void		SelInterpreter(string& name);
+
+  virtual int		Interpret(string& line);
+  virtual int		ExecFile(string& file);
+
+  virtual string&	GetUsage(const string& kw);
+  virtual void		ShowHelpWindow();
+
+  inline  CmdInterpreter* CurrentInterpreter() { return(curcmdi); }
+  inline  CmdExecutor*    BaseExecutor()  { return(basexec); }
+  inline  PIStdImgApp*    GetImgApp() { return(mImgApp); }
+
+protected:
   NamedObjMgr* mObjMgr;
   PIStdImgApp* mImgApp;
-  bool mOmg;
 
+  CmdInterpreter* curcmdi;
+  CmdExecutor* basexec;
+
+// Pour enregistrer la liste de commandes et leurs executeurs
+  struct cmdex {string us; CmdExecutor * cex; } ;
+  typedef map<string, cmdex, less<string> > CmdExmap;
+  CmdExmap cmdexmap;
+
+// Pour garder la liste des modules 
+  typedef map<string, PDynLinkMgr* , less<string> > Modmap;
+  Modmap modmap;
+
+// Pour garder la liste des interpreteur
+  typedef map<string, CmdInterpreter*, less<string> > InterpMap;
+  InterpMap interpmap;
+ 
 //  Pour stocker les variables definies par l'interpreteur
-typedef map<string, string, less<string> > CmdVarList;
-
+  typedef map<string, string, less<string> > CmdVarList;
   CmdVarList mVars;    // Liste des variables 
   ofstream hist;       //  History file 
@@ -49,11 +105,10 @@
   Timer* gltimer;      // pour Display CPU Time
 
-// g++ n'arrive pas a avaler ca (lignes trop longues)  on utilise donc des DlFunction  (Reza 20/08/98)
-// typedef map<string, DlUserProcFunction, less<string> > UsFmap;
-typedef map<string, DlFunction, less<string> > UsFmap;
-  PDynLinkMgr* dynlink;
-  UsFmap usfmap;
+// Fenetre d'aide interactive 
+  PIAHelpWind* helpwin;
 
 };
 
+
+
 #endif
Index: /trunk/SophyaPI/PIext/piinit.cc
===================================================================
--- /trunk/SophyaPI/PIext/piinit.cc	(revision 292)
+++ /trunk/SophyaPI/PIext/piinit.cc	(revision 293)
@@ -1,3 +1,3 @@
-#include "defs.h"
+#include "machdefs.h"
 #include "piinit.h"
 
@@ -6,5 +6,5 @@
 
 PeidaInteractiveInitiator::PeidaInteractiveInitiator()
- : PeidaImagesInitiator()
+ : PeidaOutilsInitiator()
 {
   FgInit++;
Index: /trunk/SophyaPI/PIext/piinit.h
===================================================================
--- /trunk/SophyaPI/PIext/piinit.h	(revision 292)
+++ /trunk/SophyaPI/PIext/piinit.h	(revision 293)
@@ -2,9 +2,9 @@
 #define PIINIT_H_SEEN
 
-#include "imaginit.h"
+#include "outilsinit.h"
 
 // Classe d'initialisation pour le module PI de PEIDA
 
-class PeidaInteractiveInitiator : public PeidaImagesInitiator{
+class PeidaInteractiveInitiator : public PeidaOutilsInitiator {
 private:
   static int FgInit;
Index: /trunk/SophyaPI/PIext/pisiadw.cc
===================================================================
--- /trunk/SophyaPI/PIext/pisiadw.cc	(revision 292)
+++ /trunk/SophyaPI/PIext/pisiadw.cc	(revision 293)
@@ -1,6 +1,6 @@
+#include "machdefs.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include "machine.h"
 
 #include "perrors.h"
@@ -149,5 +149,5 @@
 mLab[0] = new PILabel(this, "filename", tsx-spx, bsy-spy, spx/2, spy/2);
 mLab[0]->SetLabel("");
-mLab[0]->SetBinding(PIBK_elastic,PIBK_fixed, PIBK_elastic,PIBK_fixed);
+mLab[0]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic,PIBK_elastic);
 mLab[0]->SetBorderWidth(1);
 
Index: /trunk/SophyaPI/PIext/pisiadw.h
===================================================================
--- /trunk/SophyaPI/PIext/pisiadw.h	(revision 292)
+++ /trunk/SophyaPI/PIext/pisiadw.h	(revision 293)
@@ -15,7 +15,4 @@
 
 class PIStdImgApp;
-
-
-
 
 
Index: /trunk/SophyaPI/PIext/pistdimgapp.cc
===================================================================
--- /trunk/SophyaPI/PIext/pistdimgapp.cc	(revision 292)
+++ /trunk/SophyaPI/PIext/pistdimgapp.cc	(revision 293)
@@ -1,2 +1,3 @@
+#include "machdefs.h"
 #include <stdlib.h>
 #include <stdio.h>
@@ -10,5 +11,4 @@
 #endif
 
-#include "machine.h"
 
 #include "strutil.h"
@@ -30,8 +30,4 @@
 
 
-//  Il faudra virer ca (?)  Reza 19/08/98 
-// #include "parmst.h"
-// #define  FLAG_MAINGLPARMPIA  1
-// #include "glparmpia.h"
 static char ImgDir[256];
 static char WorkDir[256];
@@ -49,4 +45,5 @@
 // Les menus
 m[0] = new PIMenu(Menubar(),"Fichier");
+m[0]->AppendItem("Help", 10100);
 m[0]->AppendItem("Open-Fits", 10120);
 m[0]->AppendItem("Open-PPF", 10130);
@@ -66,4 +63,6 @@
 m[2]->AppendItem("Extract Pave", 10305);
 m[2]->SetSensitivityMsg(10305, false);
+m[2]->AppendItem("Cuts X,Y", 10306);
+m[2]->SetSensitivityMsg(10306, false);
 mc = new PIMenu(m[2], "StackTools");
 mc->AppendItem("DispNext", 10320);
@@ -100,4 +99,6 @@
 m[5]->AppendCheckItem("Catch SigFPE/SEGV", 10603);
 
+m[6] = new PIMenu(Menubar(),"Modules");
+
 AppendMenu(m[0]);
 AppendMenu(m[1]);
@@ -106,4 +107,5 @@
 AppendMenu(m[4]);
 AppendMenu(m[5]);
+AppendMenu(m[6]);
 
 int scsx, scsy;
@@ -131,4 +133,5 @@
 mCons->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_fixed); 
 mCons->AcceptCmd(true, 50);
+redirecout = false;
 // RedirectStdOutErr(true);  pas par defaut 
 
@@ -151,6 +154,4 @@
 
 pfc = new PIFileChooser(this,"FileChooser", 5000); 
-
-// mCutTC = new CutTools(this, this->MainWin());
 
 mObjmgrw = new ObjMgrWind(this);
@@ -200,5 +201,5 @@
 
 delete mc;
-for(i=0; i<6; i++)  
+for(i=0; i<7; i++)  
   if (m[i]) delete m[i];
 
@@ -242,18 +243,19 @@
 if (smm == PIMsg_Active)
   {
-  sndw = (PIWdg *)sender;
+  sndw = dynamic_cast<PIWdg *>(sender);
   switch(sndw->kind())
     {
     case PIWindow::ClassId :
-      mCurWin = (PIWindow *)sender;
+      mCurWin = dynamic_cast<PIWindow *>(sndw);
       break;
 
     case PIScDrawWdg::ClassId :
     case PIDraw3DWdg::ClassId :
-      mCurWdg = (PIBaseWdg *)sender;
+      mCurWdg = dynamic_cast<PIBaseWdg *>(sender);
 //      cerr << "*DBG11* ImgTools -> NonSensitive " << sndw->kind() << endl;
       if (mFgCWImg) {
 //        cerr << "*DBG* ImgTools -> NonSensitive " << endl;
         m[2]->SetSensitivityMsg(10305, false);
+        m[2]->SetSensitivityMsg(10306, false);
         m[4]->SetSensitivityMsg(10515, false);
         m[4]->SetSensitivityMsg(10516, false);
@@ -262,8 +264,9 @@
       break;
     case PIImage::ClassId :
-      mCurWdg = (PIBaseWdg *)sender;
+      mCurWdg = dynamic_cast<PIBaseWdg *>(sender);
       if (!mFgCWImg) {
 //        cerr << "*DBG* ImgTools -> Sensitive " << endl;
         m[2]->SetSensitivityMsg(10305, true);
+        m[2]->SetSensitivityMsg(10306, true);
         m[4]->SetSensitivityMsg(10515, true);
         m[4]->SetSensitivityMsg(10516, true);
@@ -271,4 +274,16 @@
         }
       break;
+      /*
+    default :
+      mCurWdg = NULL;
+      if (mFgCWImg) {
+        m[2]->SetSensitivityMsg(10305, false);
+        m[2]->SetSensitivityMsg(10306, false);
+        m[4]->SetSensitivityMsg(10515, false);
+        m[4]->SetSensitivityMsg(10516, false);
+        mFgCWImg = false;
+        }
+      break;
+      */
     }
   }
@@ -301,5 +316,5 @@
   SetBusy();
   TRY {
-    CmdInterpreter()->Do(s);
+    mCmd->Interpret(s);
     }  CATCH(merr) { 
     fflush(stdout); 
@@ -448,5 +463,5 @@
 if (title.length() <= 0)  title = name;  string t2="";   
 scw->SetTitles(title, t2);    
-// scw->Refresh();  Pas necessaire  Reza 19/08/98 $CHECK$ 
+// scw->Refresh();   ? Pas necessaire  Reza 19/08/98, 05/05/99 $CHECK$ 
 mCurWin = win;
 mCurWdg = scw;
@@ -495,5 +510,5 @@
 if (title.length() <= 0)  title = name;  string t2="";   
 wd3->SetTitles(title, t2);    
-// wd3->Refresh();  Pas necessaire   
+// wd3->Refresh();   ?Pas necessaire   $CHECK$ 05/05/99
 mCurWin = win;
 mCurWdg = wd3;
@@ -522,5 +537,5 @@
 mWList[mWId*10+1] = (PIWindow*)win;
 win->SetAutoDelChilds(true);
-win->Show();
+// win->Show();
 mGrW = win; 
 mGrIdx = 0;
@@ -540,5 +555,5 @@
 mWList[mWId*10+2] = (PIWindow*)win;
 win->SetAutoDelChilds(true);
-win->Show();
+// win->Show();
 mStW = win;
 m[2]->SetSensitivity("StackTools", true); 
@@ -588,5 +603,5 @@
     mWList[mWId*10] = rw;
     rw->SetAutoDelChilds(true);
-    rw->Show();
+    //    rw->Show();
     px = py = 0;
     flag = 0;
@@ -595,5 +610,5 @@
   }
 
-// rw->Show();
+rw->Show();
 mCurWin = rw;
 return(rw);
@@ -713,4 +728,5 @@
   RedirectErrStream(mCons);
   m[5]->SetStateMsg(10602, true);
+  redirecout = true;
   }
 else {
@@ -718,4 +734,5 @@
   RedirectErrStream(NULL);
   m[5]->SetStateMsg(10602, false);
+  redirecout = false;
   }
 return;
@@ -745,4 +762,8 @@
   switch(msg)
     {
+    case 10100 :
+      mCmd->ShowHelpWindow();
+      break;
+
     case 10120 :
       pfc->SetPath(ImgDir);
@@ -894,4 +915,16 @@
     ObjMgr()->AddObj(pim, nom);
     ObjMgr()->DisplayObj(nom, "w");
+    break;
+    }
+
+  case 10306 :
+    {
+    PIImage* curpimg = NULL;
+    if (!mCurWdg)  return;
+    if (mCurWdg->kind() != PIImage::ClassId)  return;
+    curpimg = (PIImage*)mCurWdg;
+    if (curpimg == NULL)   return;
+    curpimg->ShowCuts(true);
+    break;
     }
 
Index: /trunk/SophyaPI/PIext/pistdimgapp.h
===================================================================
--- /trunk/SophyaPI/PIext/pistdimgapp.h	(revision 292)
+++ /trunk/SophyaPI/PIext/pistdimgapp.h	(revision 293)
@@ -72,5 +72,6 @@
      inline PIConsole* GetConsole() { return mCons; }
 
-//     inline CutTools*  CutTC()  { return mCutTC; }   A reactiver plus tard ?  Reza 08/98
+     inline PIMenu* SpecialMenu() { return m[5]; }
+     inline PIMenu* ModulesMenu() { return m[6]; }
 
      inline ObjMgrWind* ObjMgrW() { return mObjmgrw; }
@@ -79,4 +80,5 @@
 // Redirection ou Non de StdOut/StdErr
      void  RedirectStdOutErr(bool fg = true);
+     inline bool HasRedirectedStdOutErr() { return(redirecout); }
 // Gestion des signaux
      void  CatchSignals(bool fg = true);
@@ -117,5 +119,5 @@
     PIACmd* mCmd;
 
-    PIMenu* m[6];
+    PIMenu* m[7];
     PIMenu* mc;
 
@@ -126,8 +128,6 @@
     PIFileChooser * pfc;
 
-//    CutTools* mCutTC;               // mTCId = 3   A reactiver plus tard ?  Reza 08/98
-//    PIContainer* mTC;   A reactiver plus tard ?  Reza 08/98 
-
     PIConsole* mCons;
+    bool redirecout;    // true if stdout/err redirected to mCons;
 
     WindMList mWList;
Index: /trunk/SophyaPI/PIext/servnobjm.cc
===================================================================
--- /trunk/SophyaPI/PIext/servnobjm.cc	(revision 292)
+++ /trunk/SophyaPI/PIext/servnobjm.cc	(revision 293)
@@ -32,5 +32,5 @@
 
 //  Si le module StarReco++ a ete compile (Pour les StarList, Transfo, etc ...
-#ifndef SANS_StarReco 
+#ifdef SANS_EVOLPLANCK 
 #include "stlist.h"
 #include "star.h"
@@ -98,5 +98,5 @@
     break;
 
-#ifndef SANS_StarReco 
+#ifdef SANS_EVOLPLANCK 
   case ClassId_StarList : 
     vardec = "double x,y,flux,fond; \n";
@@ -222,5 +222,5 @@
     break;
 
-#ifndef SANS_StarReco 
+#ifdef SANS_EVOLPLANCK 
   case ClassId_StarList : 
     {
@@ -306,5 +306,5 @@
 int rc;
 
-cmd = "rm " + fname;
+cmd = "rm -f " + fname;
 rc = system(cmd.c_str());
 //DBG printf("LinkExprFunc_Do> %s  (Rc=%d)\n", cmd.c_str(), rc); 
@@ -514,5 +514,5 @@
     return("ZFidu");
 
-#ifndef SANS_StarReco 
+#ifdef SANS_EVOLPLANCK 
   case ClassId_StarList : 
     return("StarList");
@@ -585,5 +585,5 @@
     return("Fidu");
 
-#ifndef SANS_StarReco 
+#ifdef SANS_EVOLPLANCK 
   case ClassId_StarList : 
     return("Stl");
@@ -678,5 +678,5 @@
 GrAlines["thickdottedline"] = gi;
 
-// Les fontes (a faire)
+// Les fontes 
 gi.a2 = PI_NotDefFontSize;
 gi.a1 = PI_NotDefFontAtt;
Index: /trunk/SophyaPI/PIext/servnobjm.h
===================================================================
--- /trunk/SophyaPI/PIext/servnobjm.h	(revision 292)
+++ /trunk/SophyaPI/PIext/servnobjm.h	(revision 293)
@@ -7,5 +7,5 @@
 #define SERVNOBJM_H_SEEN
 
-#include "defs.h"
+#include "machdefs.h"
 #include <string>
 
