Index: trunk/SophyaPI/PIext/pawexecut.cc
===================================================================
--- trunk/SophyaPI/PIext/pawexecut.cc	(revision 1059)
+++ trunk/SophyaPI/PIext/pawexecut.cc	(revision 1065)
@@ -105,4 +105,32 @@
 usage += "\n                      n < 0 means Show Info";
 piac->RegisterCommand(kw,usage,this,hgrp);
+
+kw = "h/put_vec";
+usage = "Put content of vector (matrix) into content of histogram 1D or 2D";
+usage += "\n h/put_vec nameh1d namevector [cont,err2]";
+usage += "\n h/put_vec nameh2d namematrix [cont,err2]";
+usage += "\n     cont : put into histogramme content";
+usage += "\n     err2 : put into histogramme error^2";
+usage += "\n  Related commands: h/get_vec";  
+piac->RegisterCommand(kw,usage,this,hgrp);
+
+kw = "h/get_vec";
+usage = "Get content of histogram 1D profile or 2D into vector (matrix)";
+usage += "\n h/get_vec nameh1d namevector [cont,err2,absc] [proj]";
+usage += "\n h/get_vec nameh2d namematrix [cont,err2,absc]";
+usage += "\n   cont : get histogramme content";
+usage += "\n   err2 : get histogramme error^2";
+usage += "\n   absc : get histogramme low bin abscissa (1D only)";
+usage += "\n     proj :";
+usage += "\n            show  : show available projections for Histo2D";
+usage += "\n            px    : get X projection";
+usage += "\n            py    : get Y projection";
+usage += "\n            bx n  : get X band number n";
+usage += "\n            by n  : get Y band number n";
+usage += "\n            sx n  : get X slice number n";
+usage += "\n            sy n  : get Y slice number n";
+usage += "\n  Related commands: h/put_vec";  
+piac->RegisterCommand(kw,usage,this,hgrp);
+
 }
 
@@ -135,4 +163,8 @@
 } else if(kw == "h/plot/2d") {
   h_plot_2d(tokens); return(0);
+} else if(kw == "h/put_vec") {
+  h_put_vec(tokens); return(0);
+} else if(kw == "h/get_vec") {
+  h_get_vec(tokens); return(0);
 } else return(1); 
 }
@@ -509,6 +541,7 @@
 // plot for 2D histogramme: plot histo, bandx/y, slicex/y or projx/y
 {
-if(tokens.size()<2)
+if(tokens.size()<1)
   {cout<<"Usage: h/plot/2d nameh2d to_plot [n/s] [dopt]"<<endl; return;}
+string proj = "h"; if(tokens.size()>1) proj = tokens[1];
 NamedObjMgr omg;
 AnyDataObj* mobj = omg.GetObj(tokens[0]);
@@ -522,19 +555,18 @@
 
 Histo* h1p = NULL; string nametoplot = "/autoc/h_plot_2d_h1";
-AnyDataObj* mobjh1 = omg.GetObj(nametoplot);
-// if(mobjh1!=NULL) omg.DelObj(nametoplot);  $CHECK$ Reza 12/12/99 - Ne pas faire - autoclean
+//AnyDataObj* mobjh1 = omg.GetObj(nametoplot);
 
 string dopt = ""; if(tokens.size()>=3) dopt = tokens[2];
-if(tokens[1] == "show") {
+if(proj == "show") {
   h2->ShowProj();
   h2->ShowBand(2);
   h2->ShowSli(2);
   return;
-} else if(tokens[1] == "h") {
+} else if(proj == "h") {
   nametoplot = tokens[0];
-} else if(tokens[1] == "px") {  
+} else if(proj == "px") {  
   if((h1p=h2->HProjX())) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);}
     else {h2->ShowProj(); return;}
-} else if(tokens[1] == "py") {
+} else if(proj == "py") {
   if((h1p=h2->HProjY())) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);}
     else {h2->ShowProj(); return;}
@@ -544,14 +576,14 @@
   int n = atoi(tokens[2].c_str());
   dopt = ""; if(tokens.size()>=4) dopt = tokens[3];
-  if(tokens[1] == "bx") {
+  if(proj == "bx") {
     if((h1p=h2->HBandX(n))) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);}
     else {h2->ShowBand(); return;}
-  } else if(tokens[1] == "by") {
+  } else if(proj == "by") {
     if((h1p=h2->HBandY(n))) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);}
     else {h2->ShowBand(); return;}
-  } else if(tokens[1] == "sx") {
+  } else if(proj == "sx") {
     if((h1p=h2->HSliX(n))) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);}
     else {h2->ShowSli(); return;}
-  } else if(tokens[1] == "sy") {
+  } else if(proj == "sy") {
     if((h1p=h2->HSliY(n))) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);}
     else {h2->ShowSli(); return;}
@@ -612,2 +644,153 @@
 return np;
 }
+
+/* methode */
+void PAWExecutor::h_put_vec(vector<string>& tokens)
+// Pour remplir un histo avec le contenu d'un vecteur ou d'une matrice
+// L'histogramme doit deja exister. Le nombre de bins remplit
+// depend des tailles respectives des 2 objets.
+// tokens[2] = "cont" : on remplit les valeurs de l'histogramme
+//           = "err2" : on remplit les erreurs de l'histogramme
+{
+if(tokens.size()<2)
+  {cout<<"Usage: h/put_vec  namehisto namevector"<<endl;
+   return;}
+string toput = "cont"; if(tokens.size()>2) toput = tokens[2];
+if(toput!="cont" && toput!="err2")
+  {cout<<"PAWExecutor::h_put_vec Error: unknow filling "<<toput<<endl;
+   return;}
+string hname = tokens[0];
+string vname = tokens[1];
+
+// Get objects
+NamedObjMgr omg;
+AnyDataObj* mobjh = omg.GetObj(hname);
+AnyDataObj* mobjv = omg.GetObj(vname);
+if( mobjh==NULL || mobjv==NULL )
+  {cout<<"PAWExecutor::h_put_vec Error: unknow object(s) "<<hname<<" or "<<vname<<endl;
+  return;}
+
+// Fill histo from vector
+if(typeid(*mobjh) == typeid(Histo) && typeid(*mobjv) == typeid(Vector)) {
+  Histo*  h = dynamic_cast<Histo*>(mobjh);
+  Vector* v = dynamic_cast<Vector*>(mobjv);
+  if(toput=="cont")      h->PutValue(*v);
+  else if(toput=="err2") h->PutError2(*v);
+
+} else if(typeid(*mobjh) == typeid(Histo2D) && typeid(*mobjv) == typeid(Matrix)) {
+  Histo2D* h = dynamic_cast<Histo2D*>(mobjh);
+  Matrix*  v = dynamic_cast<Matrix*>(mobjv);
+  if(toput=="cont")      h->PutValue(*v);
+  else if(toput=="err2") h->PutError2(*v);
+
+} else {
+  cout<<"PAWExecutor::h_put_vec Error: type mismatch between histogram and vector/matrix\n"
+      <<typeid(*mobjh).name()<<" , "<<typeid(*mobjv).name()<<endl;
+  return;
+}
+
+}
+
+/* methode */
+void PAWExecutor::h_get_vec(vector<string>& tokens)
+// Pour copier un histo dans un vecteur ou une matrice
+// Si le vecteur (matrice) n'existe pas, il est cree.
+// Le vecteur ou la matrice est re-dimensionne correctement.
+// tokens[2] = "cont" : on copie les valeurs de l'histogramme
+//           = "err2" : on copie les erreurs de l'histogramme
+//           = "absc" : on copie les erreurs de l'histogramme (1D only)
+// tokens[3[,4]] = show : show available projections for Histo2D
+//                 px   : get X projection
+//                 py   : get Y projection
+//                 bx n : get X band number n
+//                 by n : get Y band number n
+//                 sx n : get X slice number n
+//                 sy n : get Y slice number n
+{
+if(tokens.size()<2)
+  {cout<<"Usage: h/get_vec namehisto namevector"<<endl;
+   return;}
+string toget = "cont"; if(tokens.size()>2) toget = tokens[2];
+if(toget!="cont" && toget!="err2" && toget!="absc")
+  {cout<<"PAWExecutor::h_get_vec Error: unknow filling "<<toget<<endl;
+   return;}
+string proj = "h";  if(tokens.size()>3) proj = tokens[3];
+int nproj = -1;     if(tokens.size()>4) nproj = atoi(tokens[4].c_str());
+string hname = tokens[0];
+string vname = tokens[1];
+
+// Get objects
+NamedObjMgr omg;
+AnyDataObj* mobjh = omg.GetObj(hname);
+AnyDataObj* mobjv = omg.GetObj(vname);
+if( mobjh==NULL)
+  {cout<<"PAWExecutor::h_put_vec Error: unknow object(s) "<<hname<<endl;
+  return;}
+
+// Fill histo from vector
+Histo*   h  = dynamic_cast<Histo*>(mobjh);
+Histo2D* h2 = dynamic_cast<Histo2D*>(mobjh);
+if( h != NULL ) {  // Histo ou HProf
+  HProf* hp  = dynamic_cast<HProf*>(mobjh);
+  if(hp!=NULL) if(!(hp->IsOk())) hp->UpdateHisto();
+  Vector* v = NULL;
+  if(mobjv==NULL)   // le vecteur n'existe pas
+    {v = new Vector(1); omg.AddObj(v,vname);}
+  AnyDataObj* mobjv = omg.GetObj(vname);
+  if(typeid(*mobjv) != typeid(Vector))
+    {cout<<"PAWExecutor::h_get_vec Error: type mismatch between Histo/HProf and vector\n"
+         <<typeid(*mobjv).name()<<endl; return;}
+  v = dynamic_cast<Vector*>(mobjv);
+  if(toget=="cont")      h->GetValue(*v);
+  else if(toget=="err2") h->GetError2(*v);
+  else if(toget=="absc") h->GetAbsc(*v);
+
+} else if( h2 != NULL) {  // Histo2D
+
+  if(proj == "h") {   // On veut les valeurs de l'histogramme 2D
+    Matrix*  v = NULL;
+    if(mobjv==NULL)   // la matrice n'existe pas
+      {v = new Matrix(1,1); omg.AddObj(v,vname);}
+    AnyDataObj* mobjv = omg.GetObj(vname);
+    if(typeid(*mobjv) != typeid(Matrix))
+      {cout<<"PAWExecutor::h_get_vec Error: type mismatch between Histo2D and matrix\n"
+           <<typeid(*mobjv).name()<<endl; return;}
+    v = dynamic_cast<Matrix*>(mobjv);
+    if(toget=="cont")      h2->GetValue(*v);
+    else if(toget=="err2") h2->GetError2(*v);
+    else
+      {cout<<"PAWExecutor::h_get_vec Error: option "<<toget<<" not valid for Histo2D"<<endl;
+      return;}
+
+  } else {   // On veut les valeurs d'une projection de l'histo 2D
+    h = NULL;
+    if(proj == "show") {h2->ShowProj(); h2->ShowBand(2); h2->ShowSli(2);}
+    else if(proj == "px") h = h2->HProjX();
+    else if(proj == "py") h = h2->HProjY();
+    else if(proj == "bx") h = h2->HBandX(nproj);
+    else if(proj == "by") h = h2->HBandY(nproj);
+    else if(proj == "sx") h = h2->HSliX(nproj);
+    else if(proj == "sy") h = h2->HSliY(nproj);
+    if(h==NULL)
+      {cout<<"PAWExecutor::h_get_vec Error: unknown projection "<<proj
+           <<" number "<<nproj<<endl; return;}
+    Vector* v = NULL;
+    if(mobjv==NULL)   // le vecteur n'existe pas
+      {v = new Vector(1); omg.AddObj(v,vname);}
+    AnyDataObj* mobjv = omg.GetObj(vname);
+    if(typeid(*mobjv) != typeid(Vector))
+      {cout<<"PAWExecutor::h_get_vec Error: type mismatch between Histo2D "<<proj
+       <<" and vector\n"<<typeid(*mobjv).name()<<endl; return;}
+    v = dynamic_cast<Vector*>(mobjv);
+    if(toget=="cont")      h->GetValue(*v);
+    else if(toget=="err2") h->GetError2(*v);
+    else if(toget=="absc") h->GetAbsc(*v);
+  }
+
+} else {
+  cout<<"PAWExecutor::h_get_vec Error: type mismatch for histogram\n"
+      <<typeid(*mobjh).name()<<endl;
+  return;
+}
+
+}
Index: trunk/SophyaPI/PIext/pawexecut.h
===================================================================
--- trunk/SophyaPI/PIext/pawexecut.h	(revision 1059)
+++ trunk/SophyaPI/PIext/pawexecut.h	(revision 1065)
@@ -30,4 +30,6 @@
   void h_oper(vector<string>& tokens);
   void h_plot_2d(vector<string>& tokens);
+  void h_put_vec(vector<string>& tokens);
+  void h_get_vec(vector<string>& tokens);
   int  decodepawstring(string tokens,string& nameobj
                       ,string& xexp,string& yexp,string& zexp);
