Index: /trunk/SophyaPI/PIext/pawexecut.cc
===================================================================
--- /trunk/SophyaPI/PIext/pawexecut.cc	(revision 1069)
+++ /trunk/SophyaPI/PIext/pawexecut.cc	(revision 1070)
@@ -131,4 +131,14 @@
 usage += "\n            sy n  : get Y slice number n";
 usage += "\n  Related commands: h/put_vec";  
+piac->RegisterCommand(kw,usage,this,hgrp);
+
+kw = "h/copy";
+usage = "Copy content of object1 into objecft2";
+usage += "\n objects are Vector,Matrix,Histo,Histo2D";
+usage += "\n h/copy namefrom nametocopy [i1[:i2]] [j1[:j2]]";
+usage += "\n   copy obj1Dfrom(i1->i2) into obj1Dto";
+usage += "\n   copy obj2Dfrom(i1:j1->i2:j2) into obj2Dto";
+usage += "\n Warnig: elements from i1 to i2 included are copied";
+usage += "\n  Related commands: copy";  
 piac->RegisterCommand(kw,usage,this,hgrp);
 
@@ -167,4 +177,6 @@
 } else if(kw == "h/get_vec") {
   h_get_vec(tokens); return(0);
+} else if(kw == "h/copy") {
+  h_copy(tokens); return(0);
 } else return(1); 
 }
@@ -797,2 +809,140 @@
 
 }
+
+/* methode */
+void PAWExecutor::h_copy(vector<string>& tokens)
+// Pour copier un object dans un object
+// objects are Vector,Matrix,Histo,Histo2D
+//   h/copy namefrom nametocopy [i1[:i2]] [j1[:j2]]
+//   copy obj1Dfrom(i1->i2) into obj1Dto
+//   copy obj2Dfrom(i1:j1->i2:j2) into obj2Dto
+// Attention: elements depuis i1 jusqu'a i2 COMPRIS
+{
+if(tokens.size()<2)
+  {cout<<"Usage: h_copy namefrom nametocopy [i1[:i2]] [j1[:j2]]"<<endl;
+   return;}
+
+NamedObjMgr omg;
+AnyDataObj* mobjv1 = omg.GetObj(tokens[0]);
+if( mobjv1==NULL)
+  {cout<<"PAWExecutor::h_copy Error: unknow object "<<tokens[0]<<endl;
+  return;}
+
+// Cas d'un Vector
+if(typeid(*mobjv1) == typeid(Vector)) {
+  Vector* v1 = dynamic_cast<Vector*>(mobjv1);
+  int_4 i1=0,i2=v1->NElts()-1;
+  if(tokens.size()>2) sscanf(tokens[2].c_str(),"%d:%d",&i1,&i2);
+  if(i1<0) i1=0; if(i2>=(int_4)v1->NElts()) i2=v1->NElts()-1;
+  if(i2<i1)
+    {cout<<"PAWExecutor::h_copy Error: wrong range ["<<i1<<":"<<i2<<"] for NElts="
+         <<v1->NElts()<<endl; return;}
+  cout<<"copy "<<tokens[0]<<"("<<i1<<":"<<i2<<") to "<<tokens[1]<<endl;
+  Vector* v2 = NULL;
+  AnyDataObj* mobjv2 = omg.GetObj(tokens[1]);
+  if(mobjv2==NULL)
+    {v2 = new Vector(i2-i1+1); omg.AddObj(v2,tokens[1]);}
+  mobjv2 = omg.GetObj(tokens[1]);
+  if(typeid(*mobjv2) != typeid(Vector))
+    {cout<<"PAWExecutor::h_copy Error: type mismatch for Vector "
+         <<typeid(*mobjv2).name()<<endl; return;}
+  v2 = dynamic_cast<Vector*>(mobjv2);
+  if(i2-i1+1>(int_4)v2->NElts())
+    {cout<<"PAWExecutor::h_copy Error: Vector to copy to small "
+         <<v2->NElts()<<endl; return;}
+  for(int i=i1,ii=0;i<=i2;i++,ii++) (*v2)(ii) = (*v1)(i);
+  return;
+}
+
+// Cas d'un Histo
+if(typeid(*mobjv1) == typeid(Histo)) {
+  Histo* v1 = dynamic_cast<Histo*>(mobjv1);
+  int_4 i1=0,i2=v1->NBins()-1;
+  if(tokens.size()>2) sscanf(tokens[2].c_str(),"%d:%d",&i1,&i2);
+  if(i1<0) i1=0; if(i2>=(int_4)v1->NBins()) i2=v1->NBins()-1;
+  if(i2<i1)
+    {cout<<"PAWExecutor::h_copy Error: wrong range ["<<i1<<":"<<i2<<"] for NBins="
+         <<v1->NBins()<<endl; return;}
+  cout<<"copy "<<tokens[0]<<"("<<i1<<":"<<i2<<") to "<<tokens[1]<<endl;
+  Histo* v2 = NULL;
+  AnyDataObj* mobjv2 = omg.GetObj(tokens[1]);
+  if(mobjv2==NULL)
+    {v2 = new Histo(0.,(float)(i2-i1+1),i2-i1+1); omg.AddObj(v2,tokens[1]);}
+  mobjv2 = omg.GetObj(tokens[1]);
+  if(typeid(*mobjv2) != typeid(Histo))
+    {cout<<"PAWExecutor::h_copy Error: type mismatch for Histo "
+         <<typeid(*mobjv2).name()<<endl; return;}
+  v2 = dynamic_cast<Histo*>(mobjv2);
+  if(i2-i1+1>(int_4)v2->NBins())
+    {cout<<"PAWExecutor::h_copy Error: Histo to copy to small "
+         <<v2->NBins()<<endl; return;}
+  for(int i=i1,ii=0;i<=i2;i++,ii++) (*v2)(ii) = (*v1)(i);
+  return;
+}
+
+// Cas d'une Matrix
+if(typeid(*mobjv1) == typeid(Matrix)) {
+  Matrix* v1 = dynamic_cast<Matrix*>(mobjv1);
+  int_4 i1=0,i2=v1->NRows()-1, j1=0,j2=v1->NCol()-1;
+  if(tokens.size()>2) if(tokens[2]!="!") sscanf(tokens[2].c_str(),"%d:%d",&i1,&i2);
+  if(tokens.size()>3) sscanf(tokens[3].c_str(),"%d:%d",&j1,&j2);
+  if(i1<0) i1=0; if(i2>=(int_4)v1->NRows()) i2=v1->NRows()-1;
+  if(j1<0) j1=0; if(j2>=(int_4)v1->NCol())  j2=v1->NCol()-1;
+  if(i2<i1 || j2<j1)
+    {cout<<"PAWExecutor::h_copy Error: wrong range ["<<i1<<":"<<i2
+         <<"] , ["<<j1<<":"<<j2<<"] for NRows,NCol="
+         <<v1->NRows()<<" , "<<v1->NCol()<<endl; return;}
+  cout<<"copy "<<tokens[0]<<"("<<i1<<":"<<i2<<","<<j1<<":"<<j2<<") to "<<tokens[1]<<endl;
+  Matrix* v2 = NULL;
+  AnyDataObj* mobjv2 = omg.GetObj(tokens[1]);
+  if(mobjv2==NULL)
+    {v2 = new Matrix(i2-i1+1,j2-j1+1); omg.AddObj(v2,tokens[1]);}
+  mobjv2 = omg.GetObj(tokens[1]);
+  if(typeid(*mobjv2) != typeid(Matrix))
+    {cout<<"PAWExecutor::h_copy Error: type mismatch for Matrix "
+         <<typeid(*mobjv2).name()<<endl; return;}
+  v2 = dynamic_cast<Matrix*>(mobjv2);
+  if(i2-i1+1>(int_4)v2->NRows() || j2-j1+1>(int_4)v2->NCol())
+    {cout<<"PAWExecutor::h_copy Error: Matrix to copy to small "
+         <<v2->NRows()<<","<<v2->NCol()<<endl; return;}
+  for(int i=i1,ii=0;i<=i2;i++,ii++)
+    for(int j=j1,jj=0;j<=j2;j++,jj++) (*v2)(ii,jj) = (*v1)(i,j);
+  return;
+}
+
+// Cas d'un Histo2D
+if(typeid(*mobjv1) == typeid(Histo2D)) {
+  Histo2D* v1 = dynamic_cast<Histo2D*>(mobjv1);
+  int_4 i1=0,i2=v1->NBinX()-1, j1=0,j2=v1->NBinY()-1;
+  if(tokens.size()>2) if(tokens[2]!="!") sscanf(tokens[2].c_str(),"%d:%d",&i1,&i2);
+  if(tokens.size()>3) sscanf(tokens[3].c_str(),"%d:%d",&j1,&j2);
+  if(i1<0) i1=0; if(i2>=(int_4)v1->NBinX()) i2=v1->NBinX()-1;
+  if(j1<0) j1=0; if(j2>=(int_4)v1->NBinY())  j2=v1->NBinY()-1;
+  if(i2<i1 || j2<j1)
+    {cout<<"PAWExecutor::h_copy Error: wrong range ["<<i1<<":"<<i2
+         <<"] , ["<<j1<<":"<<j2<<"] for NBinX,NBinY="
+         <<v1->NBinX()<<" , "<<v1->NBinY()<<endl; return;}
+  cout<<"copy "<<tokens[0]<<"("<<i1<<":"<<i2<<","<<j1<<":"<<j2<<") to "<<tokens[1]<<endl;
+  Histo2D* v2 = NULL;
+  AnyDataObj* mobjv2 = omg.GetObj(tokens[1]);
+  if(mobjv2==NULL)
+    {v2 = new Histo2D(0.,(float)(i2-i1+1),i2-i1+1,0.,(float)(j2-j1+1),j2-j1+1);
+     omg.AddObj(v2,tokens[1]);}
+  mobjv2 = omg.GetObj(tokens[1]);
+  if(typeid(*mobjv2) != typeid(Histo2D))
+    {cout<<"PAWExecutor::h_copy Error: type mismatch for Histo2D"
+         <<typeid(*mobjv2).name()<<endl; return;}
+  v2 = dynamic_cast<Histo2D*>(mobjv2);
+  if(i2-i1+1>(int_4)v2->NBinX() || j2-j1+1>(int_4)v2->NBinY())
+    {cout<<"PAWExecutor::h_copy Error: Histo2D to copy to small "
+         <<v2->NBinX()<<","<<v2->NBinY()<<endl; return;}
+  for(int i=i1,ii=0;i<=i2;i++,ii++)
+    for(int j=j1,jj=0;j<=j2;j++,jj++) (*v2)(ii,jj) = (*v1)(i,j);
+  return;
+}
+
+// Cas non prevu
+cout<<"PAWExecutor::h_copy Error: type mismatch for Vector/Matrix/Histo/Histo2D\n"
+    <<typeid(*mobjv1).name()<<endl;
+return;
+}
Index: /trunk/SophyaPI/PIext/pawexecut.h
===================================================================
--- /trunk/SophyaPI/PIext/pawexecut.h	(revision 1069)
+++ /trunk/SophyaPI/PIext/pawexecut.h	(revision 1070)
@@ -32,4 +32,5 @@
   void h_put_vec(vector<string>& tokens);
   void h_get_vec(vector<string>& tokens);
+  void h_copy(vector<string>& tokens);
   int  decodepawstring(string tokens,string& nameobj
                       ,string& xexp,string& yexp,string& zexp);
