Index: trunk/SophyaPI/PIext/servnobjm.cc
===================================================================
--- trunk/SophyaPI/PIext/servnobjm.cc	(revision 349)
+++ trunk/SophyaPI/PIext/servnobjm.cc	(revision 357)
@@ -203,5 +203,5 @@
   if (nom.length() < 1) {
      titre = "Function f(x)";
-     nom = "/tmp/func";
+     nom = "/home/func";
     }
   else titre = nom;
@@ -265,5 +265,5 @@
   if (nom.length() < 1) {
      titre = "Function f(x,y)";
-     nom = "/tmp/func2d";
+     nom = "/home/func2d";
     }
   else titre = nom;
@@ -287,5 +287,5 @@
 void Services2NObjMgr::DisplayPoints2D(string& nom,  string& expx, string& expy,
                                        string& experrx, string& experry,
-                                       string& expcut, string dopt)
+                                       string& expcut, string dopt, string loop)
 {
 NObjMgrAdapter* obja=NULL;
@@ -305,5 +305,5 @@
 else {  haserr = false;  experrx = experry = "0."; nt = new NTuple(2, ntn); }
 
-ComputeExpressions(obja, expx, expy, experrx, experry, expcut, nt, NULL, NULL);
+ComputeExpressions(obja, expx, expy, experrx, experry, expcut, loop, nt, NULL, NULL);
 
 if (nt->NEntry() < 1) {
@@ -330,5 +330,5 @@
 /* --Methode-- */
 void Services2NObjMgr::DisplayPoints3D(string& nom,  string& expx, string& expy, 
-                                       string& expz, string& expcut, string dopt)
+                                       string& expz, string& expcut, string dopt, string loop)
 {
 NObjMgrAdapter* obja=NULL;
@@ -344,5 +344,5 @@
 
 string expwt = "1.";
-ComputeExpressions(obja, expx, expy, expz, expwt, expcut, nt, NULL, NULL);
+ComputeExpressions(obja, expx, expy, expz, expwt, expcut, loop, nt, NULL, NULL);
 
 if (nt->NEntry() < 1) {
@@ -372,5 +372,5 @@
 /* --Methode-- */
 void Services2NObjMgr::DisplayPoints2DW(string& nom, string& expx, string& expy, 
-                                        string& expwt, string& expcut, string dopt)
+                                        string& expwt, string& expcut, string dopt, string loop)
 {
 NObjMgrAdapter* obja=NULL;
@@ -386,5 +386,5 @@
 
 string exp = "1.";
-ComputeExpressions(obja, expx, expy, expwt, exp, expcut, nt, NULL, NULL);
+ComputeExpressions(obja, expx, expy, expwt, exp, expcut, loop, nt, NULL, NULL);
 
 if (nt->NEntry() < 1) {
@@ -408,5 +408,5 @@
 /* --Methode-- */
 void Services2NObjMgr::ProjectH1(string& nom, string& expx, string& expwt, 
-                                 string& expcut, string& nomh1, string dopt)
+                                 string& expcut, string& nomh1, string dopt, string loop)
 {
 NObjMgrAdapter* obja=NULL;
@@ -429,5 +429,5 @@
   }
 string expz = "0.";   
-ComputeExpressions(obja, expx, expwt, expz, expwt, expcut, nt, h1, NULL);
+ComputeExpressions(obja, expx, expwt, expz, expwt, expcut, loop, nt, h1, NULL);
 
 if ((!h1) && (!nt)) return;
@@ -457,5 +457,5 @@
 /* --Methode-- */
 void Services2NObjMgr::ProjectH2(string& nom, string& expx, string& expy, string& expwt, 
-                                 string& expcut, string& nomh2, string dopt)
+                                 string& expcut, string& nomh2, string dopt, string loop)
 {
 NObjMgrAdapter* obja=NULL;
@@ -478,5 +478,5 @@
   }
 string expz = "0.";   
-ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, nt, NULL, h2);
+ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, loop, nt, NULL, h2);
 
 if ((!h2) && (!nt)) return;
@@ -508,6 +508,6 @@
 /* --Methode-- cmv 13/10/98 */
 void Services2NObjMgr::ProjectHProf(string& nom, string& expx, string& expy, string& expwt,
-                                    string& expcut, string& nomprof, string dopt)
-//	Pour remplir un ``GeneralFitData'' a partir de divers objets:
+                                    string& expcut, string& nomprof, string dopt, string loop)
+//	Pour remplir un ``GeneralFitData'' a partir de divers objets: 
 //| nom = nom de l'objet a projeter dans un HProf.
 //| expx = expression X de definition du bin.
@@ -539,5 +539,5 @@
 }
 string expz = "0.";
-ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, nt, NULL, NULL, hprof);
+ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, loop, nt, NULL, NULL, hprof);
 
 if((!hprof) && (!nt)) return;
@@ -566,18 +566,120 @@
 }
 
-/* --Methode-- */
-void Services2NObjMgr::FillVect(string& nom, string& expx, string& expcut, 
-                                string& nomvec, string dopt)
+
+/* --Methode-- */
+void Services2NObjMgr::FillVect(string& nom, string& expx, string& expv, 
+                                   string& expcut, string& nomvec, string dopt, string loop)
 {
 NObjMgrAdapter* obja=NULL;
 obja = mOmg->GetObjAdapter(nom);
 if (obja == NULL) {
-  cout << "Services2NObjMgr::FillVect() Error , Pas d'objet de nom " << nom << endl; 
+  cout << "Services2NObjMgr::FillVect() Error , No such object: " << nom << endl; 
   return;
   }
 if (!mImgapp)  return; 
 
+Vector* v1 = NULL;
+AnyDataObj* ov = NULL; 
+ov=mOmg->GetObj(nomvec);
+if (ov != NULL) v1 = dynamic_cast<Vector *>(ov);
+if (v1 == NULL) {
+  cout << "Services2NObjMgr::FillVect() Error , No such object or not a vector: " << nomvec << endl; 
+  return;
+  }
+
+char* ntn[2]= {"vi", "vv"};
+NTuple* nt = new NTuple(2,ntn);  // Creation NTuple 
+
+string expz = "0.";   
+ComputeExpressions(obja, expx, expv, expz, expz, expcut, loop, nt);
+
+if (!nt) return;
+if (nt->NEntry() < 1) {
+  cout << "Services2NObjMgr::FillVect() Warning  Zero points satisfy cut !" << endl; 
+  delete nt;
+  return;
+  }
+
+  int i,k;
+  double* xn;
+  for(k=0; k<nt->NEntry(); k++)    {
+    xn = nt->GetLineD(k);
+    i = xn[0]+0.5;
+    if ( (i < 0) || i >= v1->NElts() ) continue;
+    (*v1)(i) = xn[1];
+    }
+  delete nt;
+  
+
+mOmg->DisplayObj(nomvec, dopt);
+return;  
+}
+
+/* --Methode-- */
+void Services2NObjMgr::FillMatx(string& nom, string& expx, string& expy, string& expv, 
+                                string& expcut, string& nommtx, string dopt, string loop)
+{
+NObjMgrAdapter* obja=NULL;
+obja = mOmg->GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "Services2NObjMgr::FillMatx() Error , No such objet " << nom << endl; 
+  return;
+  }
+if (!mImgapp)  return; 
+
+Matrix* mtx = NULL;
+AnyDataObj* om = NULL; 
+om=mOmg->GetObj(nommtx);
+if (om != NULL) mtx = dynamic_cast<Matrix *>(om);
+if (mtx == NULL) {
+  cout << "Services2NObjMgr::FillMatx() Error , No such object or not a matrix " << nommtx << endl; 
+  return;
+  }
+
+char* ntn[3]= {"mi", "mj", "mv"};
+NTuple* nt = new NTuple(3,ntn);  // Creation NTuple 
+
+string expz = "0.";   
+ComputeExpressions(obja, expx, expy, expv, expz, expcut, loop, nt);
+
+if (!nt) return;
+if (nt->NEntry() < 1) {
+  cout << "Services2NObjMgr::FillMatx() Warning  Zero points satisfy cut !" << endl; 
+  delete nt;
+  return;
+  }
+
+  int ic, jl, k;
+  double* xn;
+  for(k=0; k<nt->NEntry(); k++)    {
+    xn = nt->GetLineD(k);
+    ic = xn[0]+0.5;
+    jl = xn[1]+0.5;
+    if ( (ic < 0) || ic >= mtx->NCol() ) continue;
+    if ( (jl < 0) || jl >= mtx->NRows() ) continue;
+    (*mtx)(jl, ic) = xn[2];
+    }
+  delete nt;
+  
+
+mOmg->DisplayObj(nommtx, dopt);
+return;  
+
+}
+
+/* --Methode-- */
+void Services2NObjMgr::ExpressionToVector(string& nom, string& expx, string& expcut, 
+                                          string& nomvec, string dopt, string loop)
+{
+NObjMgrAdapter* obja=NULL;
+obja = mOmg->GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "Services2NObjMgr::ExpressionToVector() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+  }
+if (!mImgapp)  return; 
+
 NTuple* nt = NULL;
-if (nomvec.length() < 1) nomvec = "/tmp/fillvec";
+if (nomvec.length() < 1) nomvec = "/tmp/expvec";
 
 char* ntn[2]= {"vecval", "vecwt"};
@@ -586,9 +688,9 @@
 string expwt = "1.";
 string expz = "0.";   
-ComputeExpressions(obja, expx, expz, expz, expwt, expcut, nt, NULL, NULL);
+ComputeExpressions(obja, expx, expz, expz, expwt, expcut, loop, nt, NULL, NULL);
 
 if (!nt) return;
 if (nt->NEntry() < 1) {
-  cout << "Services2NObjMgr::FillVect() Warning  Zero points satisfy cut !" << endl; 
+  cout << "Services2NObjMgr::ExpressionToVector() Warning  Zero points satisfy cut !" << endl; 
   delete nt;
   return;
@@ -610,5 +712,5 @@
 /* --Methode-- */
 void Services2NObjMgr::FillNT(string& nom, string& expx, string& expy, string& expz, 
-                              string& expt, string& expcut, string& nomnt)
+                              string& expt, string& expcut, string& nomnt, string loop)
 {
 NObjMgrAdapter* obja=NULL;
@@ -638,5 +740,5 @@
   }
 
-ComputeExpressions(obja, expx, expy, expz, expt, expcut, nt, NULL, NULL);
+ComputeExpressions(obja, expx, expy, expz, expt, expcut, loop, nt, NULL, NULL);
 
 if (fgnnt) mOmg->AddObj(nt, nomnt);
@@ -647,6 +749,5 @@
 /* --Methode-- */
 void Services2NObjMgr::FillNTFrCFile(string & nom, string const & fname, 
-                                     string const & funcname, string & nomnt,
-                                     int nl1, int nl2)
+                                     string const & funcname, string & nomnt, string loop)
 {
 if (!mImgapp)  return; 
@@ -703,11 +804,16 @@
 mImgapp->RedirectStdOutErr(false);
 
+int k1,k2,dk;
+k1 = 0;  k2 = objnt->NbLines();  dk = 1;
+DecodeLoopParameters(loop, k1, k2, dk);
+if (k1 < 0) k1 = 0;
+if (k2 < 0) k2 = objnt->NbLines();
+if (k2 > objnt->NbLines()) k2 = objnt->NbLines();
+if (dk <= 0) dk = 1;
+
 TRY  {
   double* xn;
-  if (nl1 < 0) nl1 = 0;
-  if (nl2 < 0) nl2 = objnt->NbLines();
-  if (nl2 > objnt->NbLines()) nl2 = objnt->NbLines();
-  int kmax = nl2;
-  for(k=nl1; k<kmax; k++)    {
+  int kmax = k2;
+  for(k=k1; k<kmax; k+=dk)    {
     xn = objnt->GetLineD(k);
     if (f(xn, xnt, xnt+1, xnt+2, xnt+3, k, kmax) != 0) {
@@ -804,5 +910,5 @@
 /* --Methode-- cmv 13/10/98 */
 void Services2NObjMgr::FillGFD(string& nom, string& expx, string& expy, string& expz,
-                               string& experr, string& expcut, string& nomgfd)
+                               string& experr, string& expcut, string& nomgfd, string loop)
 //	Pour remplir un ``GeneralFitData'' a partir de divers objets:
 //| nom = nom de l'objet a transcrire selon 1D: Z=f(X) ou 2D: Z=f(X,Y) .
@@ -832,5 +938,5 @@
 
 // Remplissage NTuple buffer
-ComputeExpressions(obja, expx, expy, expz, experr, expcut, nt, NULL, NULL);
+ComputeExpressions(obja, expx, expy, expz, experr, expcut, loop, nt, NULL, NULL);
 if(nt->NEntry() < 1)
   {cout<<"Services2NObjMgr::FillGFD() Warning  Zero points satisfy cut !"<<endl; 
@@ -1339,5 +1445,5 @@
 /* --Methode-- */
 void Services2NObjMgr::ComputeExpressions(NObjMgrAdapter* obja, string& expx, 
-                          string& expy, string& expz, string& expt, string& expcut, 
+                          string& expy, string& expz, string& expt, string& expcut, string& loop, 
                           NTuple* nt, Histo* h1, Histo2D* h2, HProf* hp)
 {
@@ -1360,8 +1466,14 @@
 int i,k;
 for(i=0; i<10; i++) xnt[i] = 0.;
-
+int k1,k2,dk;
+k1 = 0;  k2 = objnt->NbLines();  dk = 1;
+DecodeLoopParameters(loop, k1, k2, dk);
+if (k1 < 0) k1 = 0;
+if (k2 < 0) k2 = objnt->NbLines();
+if (k2 > objnt->NbLines()) k2 = objnt->NbLines();
+if (dk <= 0) dk = 1;
 TRY  {
   double* xn;
-  for(k=0; k<objnt->NbLines(); k++)    {
+  for(k=k1; k<k2; k += dk)    {
     xn = objnt->GetLineD(k);
     if (f(xn, xnt, xnt+1, xnt+2, xnt+3) != 0) {
@@ -1471,4 +1583,26 @@
 }
 
+// Fonction static
+/* --Methode-- */
+void Services2NObjMgr::DecodeLoopParameters(string& loop, int& i1, int& i2, int& di)
+{
+// Decode des paramatres de boucle for(int i=i1; i<i2; i+=di) specifies 
+// sous forme i1[:i2[:di]]
+// cout << "LoopParam() " << loop << " I1=" << i1 << " I2=" << i2 << " DI=" << di; 
+size_t l = loop.length();
+if (l < 1) return;
+size_t p = loop.find(':');
+if (p >= l) { i1 = atoi(loop.c_str()); return; }
+i1 = atoi(loop.substr(0, p).c_str());
+string aa = loop.substr(p+1);
+p = aa.find(':');
+if (p < aa.length() ) { 
+  i2 = atoi(aa.substr(0,p).c_str());
+  di = atoi(aa.substr(p+1).c_str());
+  }
+else i2 = atoi(aa.c_str());
+// cout << "-> I1= " << i1 << " I2= " << i2 << " DI= " << di << endl; 
+return;
+}
 
 /* --Methode-- */
