Index: /trunk/SophyaPI/PIext/graphexecut.cc
===================================================================
--- /trunk/SophyaPI/PIext/graphexecut.cc	(revision 3354)
+++ /trunk/SophyaPI/PIext/graphexecut.cc	(revision 3355)
@@ -463,5 +463,5 @@
 usage = "Define the display rectangle for drawers added as insets \n";
 usage += " over existing graphic objects - limits expressed as fraction \n";  
-usage += " graphic object size (0. .. 1.) Xmax at right, YMax top. ";
+usage += " graphic object size (0. .. 1.) Xmax at right, YMax top \n ";
 usage += " Usage: setinsetlimits xmin xmax ymin ymax";
 usage += "\n  Related commands: graphicatt /inset";  
@@ -859,6 +859,8 @@
 usage += "o Most objects can be also be displayed overlayed \n";
 usage += "  on the last displayed widget (gr_att= same) \n";
-usage += "o The overlay can be on a selected rectangle of the \n";  
-usage += "  last displayed widget (gr_att= inset) - See setinsetlimits\n";
+usage += "  or by specifying a widget name samew=Widgetname \n";
+usage += "o The widget/window name can be specified (gr_att wname=Name) \n";
+usage += "o The overlay can be on a selected rectangle of the last \n";  
+usage += "  displayed widget (gr_att: inset  or inset=fxmin,fxmax,fymin,fymax) \n";
 usage += "\n  Related commands: newwin zone stacknext graphicatt setinsetlimits";  
 piac->RegisterHelp(kw, usage, grp);
Index: /trunk/SophyaPI/PIext/nobjmgr.cc
===================================================================
--- /trunk/SophyaPI/PIext/nobjmgr.cc	(revision 3354)
+++ /trunk/SophyaPI/PIext/nobjmgr.cc	(revision 3355)
@@ -1638,4 +1638,23 @@
 
 /* --Methode-- */
+int NamedObjMgr::NameToOId(string & nom)
+{
+ZSync zs(*myMutex); zs.NOp(); 
+return NameToOId_P(nom);
+}
+
+/* --Methode-- */
+int NamedObjMgr::NameToOId_P(string & nom)
+{
+string n1,r1;
+ParseObjectName(nom, r1, n1);
+nom = '/' + r1 + '/' + n1;
+NObjList::iterator it = myObjs->find(nom);
+if (it == myObjs->end()) return(-1); 
+else return((*it).second.oid);
+}
+
+
+/* --Methode-- */
 void NamedObjMgr::AddWRsId(string & nom, int wrsid)
 {
Index: /trunk/SophyaPI/PIext/nobjmgr.h
===================================================================
--- /trunk/SophyaPI/PIext/nobjmgr.h	(revision 3354)
+++ /trunk/SophyaPI/PIext/nobjmgr.h	(revision 3355)
@@ -100,4 +100,7 @@
   virtual void                  SetTmpDir(string const& tmpdir);
 
+// Pour convertir un nom d'objet en identificateur d'objet (OId)
+  virtual int           NameToOId(string & nom);
+
 // Ajoute un identificateur d'objet widget/drawer/fenetre pour l'objet nom
 // Ces identificateurs servent lors de la destruction de l'objet nom
@@ -125,4 +128,5 @@
   virtual void          SaveObj_P(string & nom, POutPersist& s, bool keeppath=false);
 
+  virtual int           NameToOId_P(string & nom);
   virtual void		AddWRsId_P(string & nom, int wrsid);
   virtual void		UpdateObjMgrWindow_P(int did);
Index: /trunk/SophyaPI/PIext/pistdimgapp.cc
===================================================================
--- /trunk/SophyaPI/PIext/pistdimgapp.cc	(revision 3354)
+++ /trunk/SophyaPI/PIext/pistdimgapp.cc	(revision 3355)
@@ -761,13 +761,14 @@
   }
 
+// <ZThread> global PIApplication event loop synchronisation
+SyncPIS zs(getMutex(), fglock, 2);
+
 // On decode les options graphiques
 vector<string> opts;
-DispWinEnum dwopt = ParseDisplayOption(sop, opts);
+string wname = name; 
+DispWinEnum dwopt = ParseDisplayOption(sop, opts, wname);
 
 // Pas de same ou inset pour DispImage
 if ((dwopt == Disp_Same) || (dwopt == Disp_Inset) ) dwopt = Disp_Next;
-
-// <ZThread> global PIApplication event loop synchronisation
-SyncPIS zs(getMutex(), fglock, 2);
 
 // Choix de la taille de fenetre
@@ -778,7 +779,7 @@
 if (sy > 400+mFgScSz*100) sy = 400+mFgScSz*100;
 px = py = 0;
-win = GetWindow(dwopt, sx, sy, px, py, flag, (char *)name.c_str());
+win = GetWindow(dwopt, sx, sy, px, py, flag, (char *)wname.c_str());
 if (fgimagnav) {  // Creation de naviguateur d'image 
-  piin = new PIImageNavigator(win, (char *)name.c_str(), sx, sy, px,py);
+  piin = new PIImageNavigator(win, (char *)wname.c_str(), sx, sy, px,py);
   piin->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
   piin->Show();
@@ -789,5 +790,5 @@
 }
 else { // Creation de widget PIImage normal
-  pii = new PIImage(win, (char *)name.c_str(), sx, sy, px,py);
+  pii = new PIImage(win, (char *)wname.c_str(), sx, sy, px,py);
   pii->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
   pii->SetZoomWin(zoom, false);
@@ -845,11 +846,12 @@
   }
 
+// <ZThread> global PIApplication event loop synchronisation
+SyncPIS zs(getMutex(), fglock, 2);
+
 // On decode les options graphiques
 vector<string> opts;
-DispWinEnum dwopt = ParseDisplayOption(sop, opts);
+string wname = name;
+DispWinEnum dwopt = ParseDisplayOption(sop, opts, wname);
 if ( (!mLastWdg) && ( (dwopt == Disp_Same) || (dwopt == Disp_Inset) ) )  dwopt = Disp_Next;
-
-// <ZThread> global PIApplication event loop synchronisation
-SyncPIS zs(getMutex(), fglock, 2);
 
 // Trace en superpoistion
@@ -898,7 +900,7 @@
 sx = 200+mFgScSz*100;
 sy = 200+mFgScSz*100;
-win = GetWindow(dwopt, sx, sy, px, py, flag, (char *)name.c_str());
-
-scw = new PIScDrawWdg(win, (char *)name.c_str(), sx, sy, px, py);
+win = GetWindow(dwopt, sx, sy, px, py, flag, (char *)wname.c_str());
+
+scw = new PIScDrawWdg(win, (char *)wname.c_str(), sx, sy, px, py);
 scw->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
 scw->SetUserData(NULL, oid);
@@ -923,5 +925,5 @@
 //   Titre du plot
 if (mAddTitle) {
-  if (title.length() <= 0)  title = name;  string t2="";   
+  if (title.length() <= 0)  title = wname;  string t2="";   
   scw->SetTitles(title, t2);    
 }
@@ -948,12 +950,13 @@
   }
 
+// <ZThread> global PIApplication event loop synchronisation
+SyncPIS zs(getMutex(), fglock, 2);
+
 // On decode les options graphiques
 vector<string> opts;
-DispWinEnum dwopt = ParseDisplayOption(sop, opts);
+string wname = name;
+DispWinEnum dwopt = ParseDisplayOption(sop, opts, wname);
 
 if ( (!mLastWdg) && ( (dwopt == Disp_Same) || (dwopt == Disp_Inset) ) )  dwopt = Disp_Next;
-
-// <ZThread> global PIApplication event loop synchronisation
-SyncPIS zs(getMutex(), fglock, 2);
 
 // Trace en superpoistion
@@ -1002,6 +1005,6 @@
 sx = 200+mFgScSz*100;
 sy = 200+mFgScSz*100;
-win = GetWindow(dwopt, sx, sy, px, py, flag, (char *)name.c_str());
-PIDraw3DWdg* wd3 = new PIDraw3DWdg(win, (char *)name.c_str(), sx, sy, px, py);
+win = GetWindow(dwopt, sx, sy, px, py, flag, (char *)wname.c_str());
+PIDraw3DWdg* wd3 = new PIDraw3DWdg(win, (char *)wname.c_str(), sx, sy, px, py);
 wd3->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
 wd3->SetUserData(NULL, oid);
@@ -1026,5 +1029,5 @@
 //   Titre du plot
 if (mAddTitle) {
-  if (title.length() <= 0)  title = name;  string t2="";   
+  if (title.length() <= 0)  title = wname;  string t2="";   
   wd3->SetTitles(title, t2);    
 }
@@ -1493,4 +1496,58 @@
 {
 if (mStW)  mStW->DispNext();
+}
+
+/* --Methode-- */
+void PIStdImgApp::SelectLastWidget(string & nom)
+{
+
+  if ( (mLastWdg != NULL) && (mLastWdg->Nom() == nom) ) return;
+  if ( (mCurWdg != NULL) && (mCurWdg->Nom() == nom) ) {
+    mLastWdg = mCurWdg;
+    return;
+  }
+
+  PIWdg* bw = NULL;
+  long wsid = -1;
+  BWMList::iterator it;
+  for(it = mBWList.begin(); it != mBWList.end(); it++) {
+    if ( ((*it).second->Nom() == nom) && ((*it).first > wsid)) { 
+      bw = (*it).second; wsid = (*it).first; 
+    } 
+  }
+  if (bw != NULL) {
+    if (bw->kind() == PIImageNavigator::ClassId) 
+      mLastWdg = dynamic_cast<PIImageNavigator *>(bw)->ImageWdg();
+    else mLastWdg = dynamic_cast<PIBaseWdg *>(bw);
+  }
+  return;
+}
+
+/* --Methode-- */
+void PIStdImgApp::SelectLastWidgetByObjName(string & nom)
+{
+  int oid = ObjMgr()->NameToOId(nom);
+  if (oid < 0) return;
+
+  if ( (mLastWdg != NULL) && (mLastWdg->UserFlag() == oid) ) return;
+  if ( (mCurWdg != NULL) && (mCurWdg->UserFlag() == oid) ) {
+    mLastWdg = mCurWdg;
+    return;
+  }
+
+  PIWdg* bw = NULL;
+  long wsid = -1;
+  BWMList::iterator it;
+  for(it = mBWList.begin(); it != mBWList.end(); it++) {
+    if ( ((*it).second->UserFlag() == oid) && ((*it).first > wsid)) { 
+      bw = (*it).second; wsid = (*it).first; 
+    } 
+  }
+  if (bw != NULL) {
+    if (bw->kind() == PIImageNavigator::ClassId) 
+      mLastWdg = dynamic_cast<PIImageNavigator *>(bw)->ImageWdg();
+    else mLastWdg = dynamic_cast<PIBaseWdg *>(bw);
+  }
+  return;
 }
 
@@ -1749,5 +1806,5 @@
 
 /* --Methode-- */
-DispWinEnum PIStdImgApp::ParseDisplayOption(string const & sop, vector<string>& opts)
+DispWinEnum PIStdImgApp::ParseDisplayOption(string const & sop, vector<string>& opts, string& wname)
 {
   DispWinEnum rc = Disp_Next;
@@ -1774,6 +1831,21 @@
     else if (token == "same")  rc = Disp_Same;
     else if (token == "inset")   rc = Disp_Inset;
-    else  if (token == "stack")   rc = Disp_Stack;
-    else  if (token == "next")   rc = Disp_Next;
+    else if (token == "stack")   rc = Disp_Stack;
+    else if (token == "next")   rc = Disp_Next;
+    else if (token.substr(0,6)=="samew=") {
+      string snom=token.substr(6);
+      SelectLastWidget(snom);
+      rc = Disp_Same;
+    }
+    else if (token.substr(0,6)=="inset=") {
+      double fx1,fx2,fy1,fy2;
+      fx1=fy1=0.4; fx2=fy2=0.6;
+      sscanf(token.substr(6).c_str(),"%lg,%lg,%lg,%lg",&fx1,&fx2,&fy1,&fy2);
+      SetInsetLimits(fx1, fx2, fy1, fy2);
+      rc = Disp_Inset;
+    }
+    else if (token.substr(0,6)=="wname=") {   // specification de nom de widget
+      wname=token.substr(6);
+    }
     // Option a etre decode par les drawers, etc ...
     else  opts.push_back(token); 
Index: /trunk/SophyaPI/PIext/pistdimgapp.h
===================================================================
--- /trunk/SophyaPI/PIext/pistdimgapp.h	(revision 3354)
+++ /trunk/SophyaPI/PIext/pistdimgapp.h	(revision 3355)
@@ -114,4 +114,9 @@
      void StackWinNext();
 
+  // Pour specifier le widget pour le trace en superpose, en specifiant un nom de widget
+     void SelectLastWidget(string & nom);
+  // Pour specifier le widget pour le trace en superpose, en specifiant un nom d'objet
+     void SelectLastWidgetByObjName(string & nom);
+     
      void DeleteWindow(PIWindow* w);
      void DeleteWidget(PIWdg* w, bool dw=true, bool dwin=true);
@@ -156,5 +161,10 @@
      void  SetDefaultGraphicAttributes(string const & opt);
      void  SetDefaultAxesAttributes(string const & opt);
-     DispWinEnum ParseDisplayOption(string const & opt, vector<string>& opts);
+     DispWinEnum ParseDisplayOption(string const & opt, vector<string>& opts, string& wname);
+     inline DispWinEnum ParseDisplayOption(string const & opt, vector<string>& opts)
+       {
+	 string wname;
+	 return ParseDisplayOption(opt, opts, wname);
+       }
 
 // Gestion fichiers PS
