Index: trunk/SophyaPI/PIext/basexecut.cc
===================================================================
--- trunk/SophyaPI/PIext/basexecut.cc	(revision 324)
+++ trunk/SophyaPI/PIext/basexecut.cc	(revision 326)
@@ -13,4 +13,5 @@
 #include "pistdimgapp.h"
 #include "nobjmgr.h"
+#include "servnobjm.h"
 
 #include "histos.h"
@@ -252,5 +253,17 @@
   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); 
+  mObjMgr->GetServiceObj()->PlotFunc(tokens[0], xmin, xmax, np, opt); 
+  }
+else if ( (kw == "funcff") ) {
+  if (tokens.size() < 5) { cout << "Usage: funcff C-filename f(x)-name xmin xmax npt [opt]" << endl; return(0); }
+  string opt = "n";
+  if (tokens.size() > 5)  opt = tokens[5];
+  int np;
+  float xmin, xmax;
+  np = 100;
+  xmin = 0.;  xmax = 1.;
+  np = atoi(tokens[4].c_str());
+  xmin = atof(tokens[2].c_str());   xmax = atof(tokens[3].c_str());
+  mObjMgr->GetServiceObj()->PlotFuncFrCFile(tokens[0], tokens[1], xmin, xmax, np, opt); 
   }
 else if ( (kw == "func2d") ) {
@@ -271,5 +284,24 @@
   string opt = "n";
   if (tokens.size() > 7)  opt = tokens[7];
-  mObjMgr->PlotFunc2D(tokens[0], xmin, xmax, ymin, ymax, npx, npy, opt);
+  mObjMgr->GetServiceObj()->PlotFunc2D(tokens[0], xmin, xmax, ymin, ymax, npx, npy, opt);
+  }
+else if ( (kw == "func2dff") ) {
+  if (tokens.size() < 8) {
+    cout << "Usage: func2d C-filename F(x,y)-name 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[4].c_str());
+  npy = atoi(tokens[7].c_str());
+  xmin = atof(tokens[2].c_str());   xmax = atof(tokens[3].c_str());
+  ymin = atof(tokens[5].c_str());   ymax = atof(tokens[6].c_str());
+  string opt = "n";
+  if (tokens.size() > 8)  opt = tokens[8];
+  mObjMgr->GetServiceObj()->PlotFunc2DFrCFile(tokens[0], tokens[1], xmin, xmax, ymin, ymax, npx, npy, opt);
   }
 
@@ -551,5 +583,10 @@
 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 ";  
+usage += "\n  Related commands: funcff func2d func2dff ";  
+mpiac->RegisterCommand(kw, usage, this);
+kw = "funcff";
+usage = "Displays a function y=f(x) from a C-file (Fills a vector with function values)";
+usage += "\n Usage: funcff C-FileName FunctionName xmin xmax npt [graphic_attributes]";
+usage += "\n  Related commands: func func2d func2dff ";  
 mpiac->RegisterCommand(kw, usage, this);
 kw = "func2d";
@@ -557,4 +594,9 @@
 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 = "func2dff";
+usage = "Displays a function z=f(x,y) from a C-file (Fills a matrix with function values)";
+usage += "\n Usage: func2dff C-FileName FunctionName xmin xmax nptx ymin ymax npty [graphic_attributes]";
+usage += "\n  Related commands: func funcff func2d ";  
 mpiac->RegisterCommand(kw, usage, this);
 
Index: trunk/SophyaPI/PIext/nobjmgr.cc
===================================================================
--- trunk/SophyaPI/PIext/nobjmgr.cc	(revision 324)
+++ trunk/SophyaPI/PIext/nobjmgr.cc	(revision 326)
@@ -23,4 +23,5 @@
 #include "matrix.h"
 #include "cvector.h"
+#include "ntuple.h"
 
 // EVOL-PLANCK
@@ -616,5 +617,7 @@
 if (!myImgApp)  return; 
 
-if (typeid(*obj) != typeid(NTuple)) { 
+NTupleInterface * nt = dynamic_cast<NTupleInterface *>(obj);
+if (nt == NULL) {
+// if (typeid(*obj) != typeid(NTupleInterface)) { 
   string ctyp = typeid(*obj).name();
   cout << "NamedObjMgr::DisplayNT() Error , Objet n'est pas un NTuple " << ctyp << endl; 
@@ -624,8 +627,9 @@
 int wrsid = 0;
 bool fgsr = true;
+dopt = "defline," + dopt;
 int opt = servnobjm->DecodeDispOption(dopt, fgsr);
 
 if (nmz.length()>0)  { // Display 3D
-  PINTuple3D* pin = new PINTuple3D(((NTuple*)obj), false);
+  PINTuple3D* pin = new PINTuple3D(nt, false);
   pin->SelectXYZ(nmx.c_str(), nmy.c_str(), nmz.c_str());
   pin->SelectErrBar(erx.c_str(), ery.c_str(), erz.c_str());
@@ -634,5 +638,5 @@
 }
 else {
-  PINTuple* pin = new PINTuple(((NTuple*)obj), false);
+  PINTuple* pin = new PINTuple(nt, false);
   pin->SelectXY(nmx.c_str(), nmy.c_str());
   pin->SelectErrBar(erx.c_str(), ery.c_str());
@@ -773,4 +777,5 @@
 
 bool fgsr = true;
+dopt = "defline," + dopt;
 int opt = servnobjm->DecodeDispOption(dopt, fgsr);
 string titre =  nom + ":" + expy + "%" + expx;
@@ -808,4 +813,5 @@
 pin->SelectXYZ(ntn[0], ntn[1], ntn[2]);
 bool fgsr = true;
+dopt = "defline," + dopt;
 int opt = servnobjm->DecodeDispOption(dopt, fgsr);
 
@@ -852,5 +858,5 @@
     return;
     }
-  float xmin, xmax;
+  double xmin, xmax;
   nt->GetMinMax(0, xmin, xmax);
   h1 = new Histo(xmin, xmax, 100);
@@ -901,5 +907,5 @@
     return;
     }
-  float xmin, xmax, ymin, ymax;
+  double xmin, xmax, ymin, ymax;
   nt->GetMinMax(0, xmin, xmax);
   nt->GetMinMax(0, ymin, ymax);
@@ -962,5 +968,5 @@
     return;
   }
-  float xmin, xmax;
+  double xmin, xmax;
   nt->GetMinMax(0, xmin, xmax);
   hprof = new HProf(xmin, xmax, 100);
@@ -1117,162 +1123,4 @@
 }
 
-/* --Methode-- */
-void NamedObjMgr::PlotFunc(string& expfunc, float xmin, float xmax, int np, string dopt)
-{
-FILE *fip;
-string fname = (*TmpDir) + "func1_pia_dl.c";
-string fnamer = (*TmpDir) + "func1_pia_dl";
-string  cmd;
-int rc;
-
-if (!myImgApp)  return; 
-
-cmd = "rm -f " + fname;
-rc = system(cmd.c_str());
-printf("PlotFunc_Do> %s  (Rc=%d)\n", cmd.c_str(), rc); 
-
-if ((fip = fopen(fname.c_str(), "w")) == NULL)   { 
-  string sn = fname; 
-  cout << "NamedObjMgr/PlotFunc_Erreur: Pb. Ouverture " << sn << endl; 
-  return; 
-  }
-
-// constitution du fichier a compiler
-fputs("#include <math.h> \n", fip);
-fputs("double func1_pia_dl_func(double x) \n{\n", fip);
-fprintf(fip,"return(%s); \n}\n", expfunc.c_str());
-fclose(fip);
-
-DlFunctionOfX f = (DlFunctionOfX) servnobjm->LinkFunctionFromFile(fnamer, "func1_pia_dl_func");
-if (!f) return; 
-PlotFunc(f, xmin, xmax, np, dopt);
-servnobjm->CloseDLL();
-return;
-}
-
-/* --Methode-- */
-void NamedObjMgr::PlotFunc2D(string& expfunc, float xmin, float xmax, float ymin, float ymax, 
-                             int npx, int npy, string dopt)
-{
-FILE *fip;
-string fname = (*TmpDir) + "func2_pia_dl.c";
-string fnamer = (*TmpDir) + "func2_pia_dl";
-string cmd;
-int rc;
-
-if (!myImgApp)  return; 
-
-cmd = "rm " + fname;
-rc = system(cmd.c_str());
-printf("PlotFunc2D_Do> %s  (Rc=%d)\n", cmd.c_str(), rc); 
-
-if ((fip = fopen(fname.c_str(), "w")) == NULL)   { 
-  string sn = fname; 
-  cout << "NamedObjMgr/PlotFunc2D_Erreur: Pb. Ouverture " << sn << endl; 
-  return; 
-  }
-
-// constitution du fichier a compiler
-fputs("#include <math.h> \n", fip);
-fputs("double func2_pia_dl_func(double x, double y) \n{\n", fip);
-fprintf(fip,"return(%s); \n}\n", expfunc.c_str());
-fclose(fip);
-
-DlFunctionOfXY f = (DlFunctionOfXY) servnobjm->LinkFunctionFromFile(fnamer, "func2_pia_dl_func");
-if (!f)  return;
-PlotFunc2D(f, xmin, xmax, ymin, ymax, npx, npy, dopt);
-servnobjm->CloseDLL();
-return;
-}
-
-/* --Methode-- */
-void NamedObjMgr::PlotFunc(DlFunctionOfX f, float xmin, float xmax, int np, string dopt)
-{
-if (!myImgApp)  return; 
-
-int k;
-if (np < 1) np = 1;
-if (xmax <= xmin) xmax = xmin+1.;
-Vector* vpy = new Vector(np);
-
-double xx;
-double dx = (xmax-xmin)/np;
-TRY {
-  for(k=0; k<np; k++) { xx = xmin+dx*k; (*vpy)(k) = f(xx); }
-} CATCH(merr) {
-  fflush(stdout); 
-  cout << endl; 
-  cerr << endl;
-  string es = PeidaExc(merr);
-  cerr << "NamedObjMgr::PlotFunc()  Exception :" << merr << es;
-  delete vpy;
-  vpy = NULL;
-  } ENDTRY;
-
-
-if (vpy) {
-  string nom = "Func";
-  AddObj(vpy, nom);
-  P1DArrayAdapter* vya = new POVectorAdapter(vpy, false);
-  vya->DefineXCoordinate(xmin, (xmax-xmin)/np);
-  PIYfXDrawer* dr = new   PIYfXDrawer(vya, NULL, true) ; 
-  bool fgsr = true;
-  dopt = "thinline," + dopt;
-  int opt = servnobjm->DecodeDispOption(dopt, fgsr);
-  int wrsid = myImgApp->DispScDrawer(dr, nom, opt);
-  if(wrsid >= 0) {
-    NObjList::iterator it = myObjs->find(nom);
-    if (it == myObjs->end()) return; 
-    (*it).second.wrsid.push_back(wrsid);
-    }
-  if (fgsr) myImgApp->RestoreGraphicAtt(); 
-  }
-
-return;
-}
-
-/* --Methode-- */
-void NamedObjMgr::PlotFunc2D(DlFunctionOfXY f, float xmin, float xmax, float ymin, float ymax, 
-                             int npx, int npy, string dopt)
-{
-if (!myImgApp)  return; 
-
-if (npx < 1) npx = 1;
-if (npy < 1) npy = 1;
-if (xmax <= xmin) xmax = xmin+1.;
-if (ymax <= ymin) ymax = ymin+1.;
-
-Matrix* mtx = new Matrix(npy, npx);
-
-int i,j;
-double xx, yy;
-double dx = (xmax-xmin)/npx;
-double dy = (ymax-ymin)/npy;
-// printf(" -- DBG -- %d %d , %g %g , %g %g \n", npx, npy, xmin, xmax, ymin, ymax);
-TRY {
-  for(j=0; j<npy; j++) {
-    yy = ymin+dy*j; 
-    for(i=0; i<npx; i++) {
-      xx = xmin+dx*i;
-      (*mtx)(j, i) = f(xx, yy);
-    }
-  }
-} CATCH(merr) {
-  fflush(stdout); 
-  cout << endl; 
-  cerr << endl;
-  string es = PeidaExc(merr);
-  cerr << "NamedObjMgr::PlotFunc2D()  Exception :" << merr << es;
-  delete mtx;  mtx = NULL;
-  } ENDTRY;
-
-if (mtx) {
-  string nom = "Func2";
-  AddObj(mtx, nom);
-  DisplaySurf3D(nom, dopt);
-  }
-
-return;
-}
 
 ///////////////////// Fit 1D et 2D //////////////////////////
Index: trunk/SophyaPI/PIext/nobjmgr.h
===================================================================
--- trunk/SophyaPI/PIext/nobjmgr.h	(revision 324)
+++ trunk/SophyaPI/PIext/nobjmgr.h	(revision 326)
@@ -78,12 +78,4 @@
                                string& experr, string& expcut, string& nomgfd);
 
-// Trace de fonctions 1-D , 2-D
-  virtual void          PlotFunc(string& expfunc, float xmin, float xmax, int np=100, string dopt="");
-  virtual void          PlotFunc2D(string& expfunc, float xmin, float xmax, float ymin, float ymax, 
-                                   int npx=50, int npy=50, string dopt="");
-  virtual void          PlotFunc(DlFunctionOfX f, float xmin, float xmax, int np=100, string dopt="");
-  virtual void          PlotFunc2D(DlFunctionOfXY f, float xmin, float xmax, float ymin, float ymax, 
-                                   int npx=50, int npy=50, string dopt="");
-
 //   Methodes de fit, a rajouter  (pour CMV , deux methodes H1 H2 ou 1 seule ??) ...
   virtual void          Fit12D(string const& nom, string& func,
Index: trunk/SophyaPI/PIext/nomhistadapter.cc
===================================================================
--- trunk/SophyaPI/PIext/nomhistadapter.cc	(revision 324)
+++ trunk/SophyaPI/PIext/nomhistadapter.cc	(revision 326)
@@ -83,5 +83,5 @@
 
 /* --Methode-- */
-uint_4 NTupInt_Histo::NbLines()
+uint_4 NTupInt_Histo::NbLines() const 
 {
 return(mHis->NBins());
@@ -89,5 +89,5 @@
 
 /* --Methode-- */
-uint_4 NTupInt_Histo::NbColumns()
+uint_4 NTupInt_Histo::NbColumns() const
 {
 return(4);
@@ -95,5 +95,5 @@
 
 /* --Methode-- */
-r_8* NTupInt_Histo::GetLineD(int k)
+r_8* NTupInt_Histo::GetLineD(int k) const
 {
 int i;
@@ -108,5 +108,5 @@
 
 /* --Methode-- */
-string NTupInt_Histo::VarList_C(const char* nx)
+string NTupInt_Histo::VarList_C(const char* nx) const
 {
 string nomx;
@@ -199,5 +199,5 @@
 
 /* --Methode-- */
-uint_4 NTupInt_Histo2D::NbLines()
+uint_4 NTupInt_Histo2D::NbLines() const 
 {
 return(mHis->NBinX()*mHis->NBinY());
@@ -205,5 +205,5 @@
 
 /* --Methode-- */
-uint_4 NTupInt_Histo2D::NbColumns()
+uint_4 NTupInt_Histo2D::NbColumns() const 
 {
 return(6);
@@ -211,5 +211,5 @@
 
 /* --Methode-- */
-r_8* NTupInt_Histo2D::GetLineD(int n)
+r_8* NTupInt_Histo2D::GetLineD(int n) const
 {
 int i,j;
@@ -228,5 +228,5 @@
 
 /* --Methode-- */
-string NTupInt_Histo2D::VarList_C(const char* nx)
+string NTupInt_Histo2D::VarList_C(const char* nx) const
 {
 string nomx;
@@ -309,5 +309,5 @@
 
 /* --Methode-- */
-uint_4 NTupInt_NTuple::NbLines()
+uint_4 NTupInt_NTuple::NbLines() const 
 {
 return(mNt->NEntry());
@@ -315,5 +315,5 @@
 
 /* --Methode-- */
-uint_4 NTupInt_NTuple::NbColumns()
+uint_4 NTupInt_NTuple::NbColumns() const 
 {
 return(mNt->NVar());
@@ -321,5 +321,5 @@
 
 /* --Methode-- */
-r_8* NTupInt_NTuple::GetLineD(int n)
+r_8* NTupInt_NTuple::GetLineD(int n) const 
 {
 return(mNt->GetVecD(n));
@@ -327,5 +327,5 @@
 
 /* --Methode-- */
-string NTupInt_NTuple::VarList_C(const char* nx)
+string NTupInt_NTuple::VarList_C(const char* nx) const 
 {
 return(mNt->VarList_C(nx));
Index: trunk/SophyaPI/PIext/nomhistadapter.h
===================================================================
--- trunk/SophyaPI/PIext/nomhistadapter.h	(revision 324)
+++ trunk/SophyaPI/PIext/nomhistadapter.h	(revision 326)
@@ -41,11 +41,11 @@
 			NTupInt_Histo(Histo* h);
   virtual		~NTupInt_Histo();
-  virtual uint_4        NbLines();
-  virtual uint_4        NbColumns();
-  virtual r_8 *         GetLineD(int n);
-  virtual string        VarList_C(const char* nomx=NULL);
+  virtual uint_4        NbLines() const ;
+  virtual uint_4        NbColumns() const ;
+  virtual r_8 *         GetLineD(int n) const ;
+  virtual string        VarList_C(const char* nomx=NULL) const ;
 protected:
   Histo* mHis;
-  r_8 mRet[4];
+  mutable r_8 mRet[4];
 };
 
@@ -79,11 +79,11 @@
 			NTupInt_Histo2D(Histo2D* h);
   virtual		~NTupInt_Histo2D();
-  virtual uint_4        NbLines();
-  virtual uint_4        NbColumns();
-  virtual r_8 *         GetLineD(int n);
-  virtual string        VarList_C(const char* nomx=NULL);
+  virtual uint_4        NbLines() const ;
+  virtual uint_4        NbColumns() const ;
+  virtual r_8 *         GetLineD(int n) const ;
+  virtual string        VarList_C(const char* nomx=NULL) const ;
 protected:
   Histo2D* mHis;
-  r_8 mRet[6];
+  mutable r_8 mRet[6];
 };
 
@@ -116,8 +116,8 @@
 			NTupInt_NTuple(NTuple* nt);
   virtual		~NTupInt_NTuple();
-  virtual uint_4        NbLines();
-  virtual uint_4        NbColumns();
-  virtual r_8 *         GetLineD(int n);
-  virtual string        VarList_C(const char* nomx=NULL);
+  virtual uint_4        NbLines() const ;
+  virtual uint_4        NbColumns() const ;
+  virtual r_8 *         GetLineD(int n) const ;
+  virtual string        VarList_C(const char* nomx=NULL) const ;
 protected:
   NTuple* mNt;
Index: trunk/SophyaPI/PIext/nomimagadapter.cc
===================================================================
--- trunk/SophyaPI/PIext/nomimagadapter.cc	(revision 324)
+++ trunk/SophyaPI/PIext/nomimagadapter.cc	(revision 326)
@@ -106,5 +106,5 @@
 /* --Methode-- */
 template <class T>
-uint_4 NTupInt_Image<T>::NbLines()
+uint_4 NTupInt_Image<T>::NbLines() const 
 {
 return( mImg->XSize() * mImg->YSize() );
@@ -113,5 +113,5 @@
 /* --Methode-- */
 template <class T>
-uint_4 NTupInt_Image<T>::NbColumns()
+uint_4 NTupInt_Image<T>::NbColumns() const 
 {
 return(3);
@@ -120,5 +120,5 @@
 /* --Methode-- */
 template <class T>
-r_8* NTupInt_Image<T>::GetLineD(int n)
+r_8* NTupInt_Image<T>::GetLineD(int n) const 
 {
 int i,j;
@@ -134,5 +134,5 @@
 /* --Methode-- */
 template <class T>
-string NTupInt_Image<T>::VarList_C(const char* nx)
+string NTupInt_Image<T>::VarList_C(const char* nx) const 
 {
 string nomx;
Index: trunk/SophyaPI/PIext/nomimagadapter.h
===================================================================
--- trunk/SophyaPI/PIext/nomimagadapter.h	(revision 324)
+++ trunk/SophyaPI/PIext/nomimagadapter.h	(revision 326)
@@ -43,11 +43,11 @@
 			NTupInt_Image(Image<T> * m);
   virtual		~NTupInt_Image();
-  virtual uint_4        NbLines();
-  virtual uint_4        NbColumns();
-  virtual r_8 *         GetLineD(int n);
-  virtual string        VarList_C(const char* nomx=NULL);
+  virtual uint_4        NbLines() const ;
+  virtual uint_4        NbColumns() const ;
+  virtual r_8 *         GetLineD(int n) const ;
+  virtual string        VarList_C(const char* nomx=NULL) const ;
 protected:
   Image<T> * mImg;
-  r_8 mRet[3];
+  mutable r_8 mRet[3];
 };
 
Index: trunk/SophyaPI/PIext/nommatvecadapter.cc
===================================================================
--- trunk/SophyaPI/PIext/nommatvecadapter.cc	(revision 324)
+++ trunk/SophyaPI/PIext/nommatvecadapter.cc	(revision 326)
@@ -81,5 +81,5 @@
 
 /* --Methode-- */
-uint_4 NTupInt_Vector::NbLines()
+uint_4 NTupInt_Vector::NbLines() const
 {
 return(mVec->NElts());
@@ -87,5 +87,5 @@
 
 /* --Methode-- */
-uint_4 NTupInt_Vector::NbColumns()
+uint_4 NTupInt_Vector::NbColumns() const 
 {
 return(2);
@@ -93,5 +93,5 @@
 
 /* --Methode-- */
-r_8* NTupInt_Vector::GetLineD(int n)
+r_8* NTupInt_Vector::GetLineD(int n) const 
 {
 int i;
@@ -105,5 +105,5 @@
 
 /* --Methode-- */
-string NTupInt_Vector::VarList_C(const char* nx)
+string NTupInt_Vector::VarList_C(const char* nx) const 
 {
 string nomx;
@@ -190,5 +190,5 @@
 
 /* --Methode-- */
-uint_4 NTupInt_Matrix::NbLines()
+uint_4 NTupInt_Matrix::NbLines() const
 {
 return( mMtx->NRows()*mMtx->NCol() );
@@ -196,5 +196,5 @@
 
 /* --Methode-- */
-uint_4 NTupInt_Matrix::NbColumns()
+uint_4 NTupInt_Matrix::NbColumns() const 
 {
 return(3);
@@ -202,5 +202,5 @@
 
 /* --Methode-- */
-r_8* NTupInt_Matrix::GetLineD(int n)
+r_8* NTupInt_Matrix::GetLineD(int n) const 
 {
 int i,j;
@@ -215,5 +215,5 @@
 
 /* --Methode-- */
-string NTupInt_Matrix::VarList_C(const char* nx)
+string NTupInt_Matrix::VarList_C(const char* nx) const 
 {
 string nomx;
Index: trunk/SophyaPI/PIext/nommatvecadapter.h
===================================================================
--- trunk/SophyaPI/PIext/nommatvecadapter.h	(revision 324)
+++ trunk/SophyaPI/PIext/nommatvecadapter.h	(revision 326)
@@ -39,11 +39,11 @@
 			NTupInt_Vector(Vector* v);
   virtual		~NTupInt_Vector();
-  virtual uint_4        NbLines();
-  virtual uint_4        NbColumns();
-  virtual r_8 *         GetLineD(int n);
-  virtual string        VarList_C(const char* nomx=NULL);
+  virtual uint_4        NbLines() const ;
+  virtual uint_4        NbColumns() const ;
+  virtual r_8 *         GetLineD(int n) const ;
+  virtual string        VarList_C(const char* nomx=NULL) const ;
 protected:
   Vector* mVec;
-  r_8 mRet[2];
+  mutable r_8 mRet[2];
 };
 
@@ -79,11 +79,11 @@
 			NTupInt_Matrix(Matrix* m);
   virtual		~NTupInt_Matrix();
-  virtual uint_4        NbLines();
-  virtual uint_4        NbColumns();
-  virtual r_8 *         GetLineD(int n);
-  virtual string        VarList_C(const char* nomx=NULL);
+  virtual uint_4        NbLines() const ;
+  virtual uint_4        NbColumns() const ;
+  virtual r_8 *         GetLineD(int n) const ;
+  virtual string        VarList_C(const char* nomx=NULL) const ;
 protected:
   Matrix* mMtx;
-  r_8 mRet[3];
+  mutable r_8 mRet[3];
 };
 
Index: trunk/SophyaPI/PIext/nomstladapter.cc
===================================================================
--- trunk/SophyaPI/PIext/nomstladapter.cc	(revision 324)
+++ trunk/SophyaPI/PIext/nomstladapter.cc	(revision 326)
@@ -84,5 +84,5 @@
 
 /* --Methode-- */
-uint_4 NTupInt_StarList::NbLines()
+uint_4 NTupInt_StarList::NbLines() const
 {
 return(mStl->NbStars());
@@ -90,5 +90,5 @@
 
 /* --Methode-- */
-uint_4 NTupInt_StarList::NbColumns()
+uint_4 NTupInt_StarList::NbColumns() const 
 {
 return(11);
@@ -96,5 +96,5 @@
 
 /* --Methode-- */
-r_8* NTupInt_StarList::GetLineD(int n)
+r_8* NTupInt_StarList::GetLineD(int n) const 
 {
 BStar* bst = mStl->Star(n);
@@ -118,5 +118,5 @@
 
 /* --Methode-- */
-string NTupInt_StarList::VarList_C(const char* nx)
+string NTupInt_StarList::VarList_C(const char* nx) const 
 {
 string nomx;
Index: trunk/SophyaPI/PIext/nomstladapter.h
===================================================================
--- trunk/SophyaPI/PIext/nomstladapter.h	(revision 324)
+++ trunk/SophyaPI/PIext/nomstladapter.h	(revision 326)
@@ -39,11 +39,11 @@
 			NTupInt_StarList(StarList* stl);
   virtual		~NTupInt_StarList();
-  virtual uint_4        NbLines();
-  virtual uint_4        NbColumns();
-  virtual r_8 *         GetLineD(int n);
-  virtual string        VarList_C(const char* nomx=NULL);
+  virtual uint_4        NbLines() const ;
+  virtual uint_4        NbColumns() const ;
+  virtual r_8 *         GetLineD(int n) const ;
+  virtual string        VarList_C(const char* nomx=NULL) const ;
 protected:
   StarList* mStl;
-  r_8 mRet[12];
+  mutable r_8 mRet[12];
 };
 
Index: trunk/SophyaPI/PIext/ntupintf.h
===================================================================
--- trunk/SophyaPI/PIext/ntupintf.h	(revision 324)
+++ 	(revision )
@@ -1,18 +1,0 @@
-// This may look like C code, but it is really -*- C++ -*-
-// Interface de type NTuple           Reza 05/99
-// LAL-IN2P3/CNRS               CEA-DAPNIA      
-
-#ifndef NTUPLEINTERFACE_H_SEEN
-#define NTUPLEINTERFACE_H_SEEN
-#include "machdefs.h"
-
-class NTupleInterface {
-public:
-  virtual		~NTupleInterface() { } 
-  virtual uint_4        NbLines()=0;
-  virtual uint_4        NbColumns()=0;
-  virtual r_8 *         GetLineD(int n)=0;
-  virtual string	VarList_C(const char* nomx=NULL)=0;
-};
-
-#endif
Index: trunk/SophyaPI/PIext/pintup3d.cc
===================================================================
--- trunk/SophyaPI/PIext/pintup3d.cc	(revision 324)
+++ trunk/SophyaPI/PIext/pintup3d.cc	(revision 326)
@@ -4,5 +4,5 @@
  
 /* --Methode-- */
-PINTuple3D::PINTuple3D(NTuple* nt, bool ad)
+PINTuple3D::PINTuple3D(NTupleInterface* nt, bool ad)
 : PIDrawer3D()
 {
@@ -21,11 +21,13 @@
 void  PINTuple3D::SelectXYZ(const char* px, const char* py, const char* pz)
 {
+string name;
 if (mNT == NULL)  xK = yK = zK = -1;
+if (mNT == NULL)  xK = yK = -1;
 if (px == NULL) xK = -1;
-else xK = mNT->IndexNom(px);
+else { name = px; xK = mNT->ColumnIndex(name); }
 if (py == NULL) yK = -1;
-else yK = mNT->IndexNom(py);
+else { name = py; yK = mNT->ColumnIndex(name); }
 if (pz == NULL) zK = -1;
-else zK = mNT->IndexNom(pz);
+else { name = pz; zK = mNT->ColumnIndex(name); }
 }
 
@@ -33,11 +35,12 @@
 void  PINTuple3D::SelectErrBar(const char* erbx, const char* erby, const char* erbz)
 {
+string name;
 if (mNT == NULL)  xebK = yebK = zebK = -1;
 if (erbx == NULL) xebK = -1;
-else xebK = mNT->IndexNom(erbx);
+else { name = erbx;  xebK = mNT->ColumnIndex(name); }
 if (erby == NULL) yebK = -1;
-else yebK = mNT->IndexNom(erby);
+else { name = erby;  yebK = mNT->ColumnIndex(name); }
 if (erbz == NULL) zebK = -1;
-else zebK = mNT->IndexNom(erbz);
+else { name = erbz;  zebK = mNT->ColumnIndex(name); }
 }
 
@@ -46,10 +49,10 @@
 void PINTuple3D::UpdateLimits()
 {
-  if (!mNT) return;
-  if (mNT->NEntry() <= 0)  return;
+  if (!mNT) return; 
+  if (mNT->NbLines() <= 0)  return;
   if ( (xK < 0) || (yK < 0)  || (zK < 0) )   return;
 
   // Commencer par trouver nos limites
-  float xmin, xmax, ymin, ymax, zmin, zmax;
+  double xmin, xmax, ymin, ymax, zmin, zmax;
   xmin = ymin = 9.e19;
   xmax = ymax = -9.e19;
@@ -76,5 +79,5 @@
   z3Max = zmax;  // + 0.05*(zmax-zmin);
 
-//  printf("PINTuple3D::UpdateLimits() : %g-%g  %g-%g  %g-%g (%g) \n", xmin,xmax,ymin,ymax,zmin,zmax,D);
+//  printf("PINTuple3D::UpdateLimits() : %g .. %g  %g .. %g  %g .. %g (%g) \n", xmin,xmax,ymin,ymax,zmin,zmax,D);
 //  printf("PINTuple3D::UpdateLimits() :  %g %g %g << %g %g %g \n", 
 //         (xmin+xmax)/2., (ymin+ymax)/2, (zmin+zmax)*0.5, 
@@ -87,4 +90,5 @@
 {
 double xp,yp,zp,xer,yer,zer;
+double xl,yl,zl;
 int nok;
 
@@ -104,20 +108,24 @@
 
 nok = 0;  
-for (int i=0; i<mNT->NEntry(); i++) {
-  xp = mNT->GetVal(i, xK);
-  yp = mNT->GetVal(i, yK);
-  zp = mNT->GetVal(i, zK);
+xp = yp = zp = xl = yl = zl = 0;
+for (int i=0; i<mNT->NbLines(); i++) {
+  xl = xp;  yl = yp;  zl = zp;
+  xp = mNT->GetCell(i, xK);
+  yp = mNT->GetCell(i, yK);
+  zp = mNT->GetCell(i, zK);
+  if ( (i > 0) && (mLAtt != PI_NotDefLineAtt) )   // On relie les points ...
+    g3->DrawLine3D(xl, yl, zl, xp, yp, zp);
   nok++;
   g3->DrawMarker3D(xp, yp, zp); 
   if ( xebK >= 0 ) {
-    xer = mNT->GetVal(i, xebK);
+    xer = mNT->GetCell(i, xebK);
     g3->DrawLine3D(xp-xer, yp, zp, xp+xer, yp, zp);
   }
   if ( yebK >= 0 ) {
-    yer = mNT->GetVal(i, yebK);
+    yer = mNT->GetCell(i, yebK);
     g3->DrawLine3D(xp, yp-yer, zp, xp, yp+yer, zp);
   }
   if ( zebK >= 0 ) {
-    zer = mNT->GetVal(i, zebK);
+    zer = mNT->GetCell(i, zebK);
     g3->DrawLine3D(xp, yp, zp-zer, xp, yp, zp+zer);
   }
Index: trunk/SophyaPI/PIext/pintup3d.h
===================================================================
--- trunk/SophyaPI/PIext/pintup3d.h	(revision 324)
+++ trunk/SophyaPI/PIext/pintup3d.h	(revision 326)
@@ -2,10 +2,10 @@
 #define PINTUPLE3D_H
 
-#include "ntuple.h"
+#include "ntupintf.h"
 #include "pi3ddrw.h"
 
 class PINTuple3D : public PIDrawer3D {
 public:
-                     PINTuple3D(NTuple* nt, bool ad=false);
+                     PINTuple3D(NTupleInterface* nt, bool ad=false);
   virtual           ~PINTuple3D();
   
@@ -18,5 +18,5 @@
        
 protected:
-  NTuple* mNT;
+  NTupleInterface* mNT;
   bool mAdDO;
   int xK, yK, zK;           // Index du nom de variable en X/Y/Z ds le ntuple
Index: trunk/SophyaPI/PIext/pintuple.cc
===================================================================
--- trunk/SophyaPI/PIext/pintuple.cc	(revision 324)
+++ trunk/SophyaPI/PIext/pintuple.cc	(revision 326)
@@ -4,5 +4,5 @@
  
 /* --Methode-- */
-PINTuple::PINTuple(NTuple* nt, bool ad)
+PINTuple::PINTuple(NTupleInterface* nt, bool ad)
 : PIDrawer()
 {
@@ -21,9 +21,10 @@
 void  PINTuple::SelectXY(const char* px, const char* py)
 {
+string name;
 if (mNT == NULL)  xK = yK = -1;
 if (px == NULL) xK = -1;
-else xK = mNT->IndexNom(px);
+else { name = px; xK = mNT->ColumnIndex(name); }
 if (py == NULL) yK = -1;
-else yK = mNT->IndexNom(py);
+else { name = py; yK = mNT->ColumnIndex(name); }
 }
 
@@ -31,9 +32,10 @@
 void  PINTuple::SelectErrBar(const char* erbx, const char* erby)
 {
+string name;
 if (mNT == NULL)  xebK = yebK = -1;
 if (erbx == NULL) xebK = -1;
-else xebK = mNT->IndexNom(erbx);
+else { name = erbx;  xebK = mNT->ColumnIndex(name); }
 if (erby == NULL) yebK = -1;
-else yebK = mNT->IndexNom(erby);
+else { name = erby;  yebK = mNT->ColumnIndex(name); }
 }
 
@@ -43,10 +45,10 @@
 {
   if (!mNT) return;
-  if (mNT->NEntry() <= 0)  return;
+  if (mNT->NbLines() <= 0)  return;
   if ( (xK < 0) || (yK < 0) )   return;
 
   // Commencer par trouver nos limites
-  float dx, dy;
-  float xmin, xmax, ymin, ymax;
+  double dx, dy;
+  double xmin, xmax, ymin, ymax;
   xmin = ymin = 9.e19;
   xmax = ymax = -9.e19;
@@ -66,4 +68,5 @@
 {
 double xp,yp,xer,yer;
+double xl,yl;
 int nok;
 
@@ -71,16 +74,21 @@
 if ( (xK < 0) || (yK < 0) )  return;
 if (mLAtt == PI_NotDefLineAtt)  g->SelLine(PI_ThinLine);
+
 nok = 0;  
-for (int i=0; i<mNT->NEntry(); i++) {
-  xp = mNT->GetVal(i, xK);
-  yp = mNT->GetVal(i, yK);
+xp = yp = xl = yl = 0;
+for (int i=0; i<mNT->NbLines(); i++) {
+  xl = xp;  yl = yp; 
+  xp = mNT->GetCell(i, xK);
+  yp = mNT->GetCell(i, yK);
   if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) )  continue;
+  if ( (i > 0) && (mLAtt != PI_NotDefLineAtt) )   // On relie les points ...
+    g->DrawLine(xl, yl, xp, yp);
   nok++;
   if ( xebK >= 0 ) {
-    xer = mNT->GetVal(i, xebK);
+    xer = mNT->GetCell(i, xebK);
     if(xer>0.) g->DrawLine(xp-xer, yp, xp+xer, yp);
   }
   if ( yebK >= 0 ) {
-    yer = mNT->GetVal(i, yebK);
+    yer = mNT->GetCell(i, yebK);
     if(yer>0.) g->DrawLine(xp, yp-yer, xp, yp+yer);
   }
Index: trunk/SophyaPI/PIext/pintuple.h
===================================================================
--- trunk/SophyaPI/PIext/pintuple.h	(revision 324)
+++ trunk/SophyaPI/PIext/pintuple.h	(revision 326)
@@ -2,10 +2,10 @@
 #define PINTUPLE_H
 
-#include "ntuple.h"
+#include "ntupintf.h"
 #include "pidrawer.h"
 
 class PINTuple : public PIDrawer {
 public:
-                     PINTuple(NTuple* nt, bool ad);
+                     PINTuple(NTupleInterface* nt, bool ad);
   virtual           ~PINTuple();
   
@@ -18,5 +18,5 @@
        
 protected:
-  NTuple* mNT;
+  NTupleInterface* mNT;
   bool mAdDO;
   int xK, yK;          // Index du nom de variable en X/Y ds le ntuple
Index: trunk/SophyaPI/PIext/servnobjm.cc
===================================================================
--- trunk/SophyaPI/PIext/servnobjm.cc	(revision 324)
+++ trunk/SophyaPI/PIext/servnobjm.cc	(revision 326)
@@ -24,4 +24,8 @@
 #include "ntuple.h"
 #include "hisprof.h"
+
+#include "piscdrawwdg.h"
+#include "pisurfdr.h"
+#include "pipodrw.h"
 
 
@@ -122,5 +126,4 @@
 FILE *fip;
 string fname = TmpDir + "expf_pia_dl.c";
-string fnamer = TmpDir + "expf_pia_dl";
 string cmd;
 int rc;
@@ -147,21 +150,17 @@
 fputs("return(1); \n} \n", fip);
 fclose(fip);
-
-return((PlotExprFunc)LinkFunctionFromFile(fnamer, "expf_pia_dl_func"));
-}
-
-
-/* --Methode-- */
-DlFunction Services2NObjMgr::LinkFunctionFromFile(string& fnamer, char* funcname)
-{
-string fname = fnamer + ".c" ;
-string fnameobj = fnamer + ".o" ;
-string fnameso = fnamer + ".so";
-
+string func = "expf_pia_dl_func";
+return((PlotExprFunc)LinkFunctionFromFile(fname, func));
+}
+
+
+/* --Methode-- */
+DlFunction Services2NObjMgr::LinkFunctionFromFile(string const & fname, string const & funcname)
+{
 //  Le link dynamique
 CloseDLL();
 dynlink = PDynLinkMgr::BuildFromCFile(fname);
 if (dynlink == NULL) { 
-  cerr << "NamedObjMgr/LinkFunctionFromFile_Erreur: Erreur ouverture SO " << endl; 
+  cerr << "NamedObjMgr/LinkFunctionFromFile_Erreur: Erreur creation/Ouverture SO " << endl; 
   return(NULL); 
   }
@@ -181,4 +180,187 @@
 {
 if (dynlink) delete dynlink;   dynlink = NULL;
+}
+
+/* --Methode-- */
+void Services2NObjMgr::PlotFunc(string const & expfunc, float xmin, float xmax, int np, string dopt)
+{
+FILE *fip;
+string fname = TmpDir + "func1_pia_dl.c";
+string  cmd;
+int rc;
+
+if (!mImgapp)  return; 
+
+cmd = "rm -f " + fname;
+rc = system(cmd.c_str());
+// printf("PlotFunc_Do> %s  (Rc=%d)\n", cmd.c_str(), rc); 
+
+if ((fip = fopen(fname.c_str(), "w")) == NULL)   { 
+  string sn = fname; 
+  cout << "NamedObjMgr/PlotFunc_Erreur: Pb. Ouverture " << sn << endl; 
+  return; 
+  }
+
+// constitution du fichier a compiler
+fputs("#include <math.h> \n", fip);
+fputs("double func1_pia_dl_func(double x) \n{\n", fip);
+fprintf(fip,"return(%s); \n}\n", expfunc.c_str());
+fclose(fip);
+
+string func = "func1_pia_dl_func";
+DlFunctionOfX f = (DlFunctionOfX) LinkFunctionFromFile(fname, func);
+if (!f) return; 
+PlotFunc(f, xmin, xmax, np, dopt);
+CloseDLL();
+return;
+}
+
+/* --Methode-- */
+void Services2NObjMgr::PlotFunc2D(string const & expfunc, float xmin, float xmax, float ymin, float ymax, 
+                             int npx, int npy, string dopt)
+{
+FILE *fip;
+string fname = TmpDir + "func2_pia_dl.c";
+string cmd;
+int rc;
+
+if (!mImgapp)  return; 
+
+cmd = "rm " + fname;
+rc = system(cmd.c_str());
+// printf("PlotFunc2D_Do> %s  (Rc=%d)\n", cmd.c_str(), rc); 
+
+if ((fip = fopen(fname.c_str(), "w")) == NULL)   { 
+  string sn = fname; 
+  cout << "NamedObjMgr/PlotFunc2D_Erreur: Pb. Ouverture " << sn << endl; 
+  return; 
+  }
+
+// constitution du fichier a compiler
+fputs("#include <math.h> \n", fip);
+fputs("double func2_pia_dl_func(double x, double y) \n{\n", fip);
+fprintf(fip,"return(%s); \n}\n", expfunc.c_str());
+fclose(fip);
+
+string func = "func2_pia_dl_func";
+DlFunctionOfXY f = (DlFunctionOfXY) LinkFunctionFromFile(fname, func);
+if (!f)  return;
+PlotFunc2D(f, xmin, xmax, ymin, ymax, npx, npy, dopt);
+CloseDLL();
+return;
+}
+
+/* --Methode-- */
+void Services2NObjMgr::PlotFuncFrCFile(string const & fname, string const & func, float xmin, float xmax, 
+                                       int np, string dopt)
+{
+DlFunctionOfX f = (DlFunctionOfX) LinkFunctionFromFile(fname, func);
+if (!f) return; 
+PlotFunc(f, xmin, xmax, np, dopt);
+CloseDLL();
+return;
+}
+
+/* --Methode-- */
+void Services2NObjMgr::PlotFunc2DFrCFile(string const & fname, string const & func, float xmin, float xmax, 
+                                         float ymin, float ymax, int npx, int npy, string dopt)
+{
+DlFunctionOfXY f = (DlFunctionOfXY) LinkFunctionFromFile(fname, func);
+if (!f)  return;
+PlotFunc2D(f, xmin, xmax, ymin, ymax, npx, npy, dopt);
+CloseDLL();
+return;
+}
+
+/* --Methode-- */
+void Services2NObjMgr::PlotFunc(DlFunctionOfX f, float xmin, float xmax, int np, string dopt)
+{
+if (!mImgapp)  return; 
+
+int k;
+if (np < 1) np = 1;
+if (xmax <= xmin) xmax = xmin+1.;
+Vector* vpy = new Vector(np);
+
+double xx;
+double dx = (xmax-xmin)/np;
+TRY {
+  for(k=0; k<np; k++) { xx = xmin+dx*k; (*vpy)(k) = f(xx); }
+} CATCH(merr) {
+  fflush(stdout); 
+  cout << endl; 
+  cerr << endl;
+  string es = PeidaExc(merr);
+  cerr << "Services2NObjMgr::PlotFunc()  Exception :" << merr << es;
+  delete vpy;
+  vpy = NULL;
+  } ENDTRY;
+
+
+if (vpy) {
+  string nom = "Func";
+  P1DArrayAdapter* vya = new POVectorAdapter(vpy, true);
+  vya->DefineXCoordinate(xmin, (xmax-xmin)/np);
+  PIYfXDrawer* dr = new   PIYfXDrawer(vya, NULL, true) ; 
+  bool fgsr = true;
+  dopt = "thinline," + dopt;
+  int opt = DecodeDispOption(dopt, fgsr);
+  int wrsid = mImgapp->DispScDrawer(dr, nom, opt);
+  if (fgsr) mImgapp->RestoreGraphicAtt(); 
+  }
+
+return;
+}
+
+/* --Methode-- */
+void Services2NObjMgr::PlotFunc2D(DlFunctionOfXY f, float xmin, float xmax, float ymin, float ymax, 
+                             int npx, int npy, string dopt)
+{
+if (!mImgapp)  return; 
+
+if (npx < 3) npx = 3;
+if (npy < 3) npy = 3;
+if (npx > 250) npx = 250;
+if (npy > 250) npy = 250;
+if (xmax <= xmin) xmax = xmin+1.;
+if (ymax <= ymin) ymax = ymin+1.;
+
+Matrix* mtx = new Matrix(npy, npx);
+
+int i,j;
+double xx, yy;
+double dx = (xmax-xmin)/npx;
+double dy = (ymax-ymin)/npy;
+// printf(" -- DBG -- %d %d , %g %g , %g %g \n", npx, npy, xmin, xmax, ymin, ymax);
+TRY {
+  for(j=0; j<npy; j++) {
+    yy = ymin+dy*j; 
+    for(i=0; i<npx; i++) {
+      xx = xmin+dx*i;
+      (*mtx)(j, i) = f(xx, yy);
+    }
+  }
+} CATCH(merr) {
+  fflush(stdout); 
+  cout << endl; 
+  cerr << endl;
+  string es = PeidaExc(merr);
+  cerr << "Services2NObjMgr::PlotFunc2D()  Exception :" << merr << es;
+  delete mtx;  mtx = NULL;
+  } ENDTRY;
+
+if (mtx) {
+  string nom = "Func2";
+  int wrsid = 0;
+  bool fgsr = true;
+  int opt = DecodeDispOption(dopt, fgsr);
+  P2DArrayAdapter* arr = new POMatrixAdapter(mtx, true);
+  arr->DefineXYCoordinates(xmin, ymin, dx, dy);
+  PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
+  wrsid = mImgapp->Disp3DDrawer(sdr, nom, opt);
+  if (fgsr) mImgapp->RestoreGraphicAtt();
+  }
+
+return;
 }
 
@@ -211,5 +393,5 @@
 if (fgsrgr) mImgapp->SaveGraphicAtt();
 
-if (gratt.substr(0,3) == "def")  {  // Remise aux valeurs par defaut = non defini
+if ( (gratt == "def") || (gratt == "default") )  {  // Remise aux valeurs par defaut = non defini
   mImgapp->SetColAtt();
   mImgapp->SetLineAtt();
Index: trunk/SophyaPI/PIext/servnobjm.h
===================================================================
--- trunk/SophyaPI/PIext/servnobjm.h	(revision 324)
+++ trunk/SophyaPI/PIext/servnobjm.h	(revision 326)
@@ -45,7 +45,20 @@
   PlotExprFunc  LinkExprFunc(string& vardec, string& expx, string& expy, string& expz, 
                              string& wt, string& cut);
-  DlFunction    LinkFunctionFromFile(string& fnamer, char* funcname);
+  DlFunction    LinkFunctionFromFile(string const & fname, string const & funcname);
   void 		CloseDLL();  
 
+// Trace de fonctions 1-D , 2-D
+  virtual void  PlotFunc(string const & expfunc, float xmin, float xmax, int np=100, string dopt="");
+  virtual void  PlotFunc2D(string const & expfunc, float xmin, float xmax, float ymin, float ymax, 
+                           int npx=50, int npy=50, string dopt="");
+  virtual void  PlotFuncFrCFile(string const & fname, string const & func, float xmin, float xmax, 
+                                int np=100, string dopt="");
+  virtual void  PlotFunc2DFrCFile(string const & fname, string const & func, float xmin, float xmax, 
+                                  float ymin, float ymax, int npx=50, int npy=50, string dopt="");
+  virtual void  PlotFunc(DlFunctionOfX f, float xmin, float xmax, int np=100, string dopt="");
+  virtual void  PlotFunc2D(DlFunctionOfXY f, float xmin, float xmax, float ymin, float ymax, 
+                           int npx=50, int npy=50, string dopt="");
+
+// Utilitaires divers 
   string 	FileName2Name(string const & fn);
   int 		DecodeDispOption(string& dopt, bool& fgsrgr);
