Index: trunk/SophyaPI/PI/piapplgen.h
===================================================================
--- trunk/SophyaPI/PI/piapplgen.h	(revision 127)
+++ trunk/SophyaPI/PI/piapplgen.h	(revision 128)
@@ -34,5 +34,5 @@
 
         virtual void              RedirectOutStream(PIConsole* cons, unsigned char va= PIVA_Def)  = 0;
-        virtual void              RedirectErrStream(PIConsole* cons, unsigned char va= PIVA_Ital) = 0;
+        virtual void              RedirectErrStream(PIConsole* cons, unsigned char va= PIVA_Ital|PIVA_Red) = 0;
 
 protected:
Index: trunk/SophyaPI/PI/piapplx.h
===================================================================
--- trunk/SophyaPI/PI/piapplx.h	(revision 127)
+++ trunk/SophyaPI/PI/piapplx.h	(revision 128)
@@ -23,5 +23,5 @@
 
   virtual void              RedirectOutStream(PIConsole* cons, unsigned char va= PIVA_Def);
-  virtual void              RedirectErrStream(PIConsole* cons, unsigned char va= PIVA_Ital);
+  virtual void              RedirectErrStream(PIConsole* cons, unsigned char va= PIVA_Ital|PIVA_Red);
 
   PIContainer*              MBCont() { return intcont; }
Index: trunk/SophyaPI/PI/picmapview.cc
===================================================================
--- trunk/SophyaPI/PI/picmapview.cc	(revision 127)
+++ trunk/SophyaPI/PI/picmapview.cc	(revision 128)
@@ -27,7 +27,12 @@
 void PICMapView::SetColMap(PIColorMap* cmp, bool refr)
 {
+  if (cmp == NULL)   { 
+    if (cmap) delete cmap;
+    cmap = NULL;
+    return;
+    }
+  if ( cmap && (cmp->Type() == cmap->Type()) && (cmp->Type() != CMAP_OTHER) ) return;
   if (cmap) delete cmap;
-  if (cmp == NULL)   cmap = NULL;
-  else cmap = new PIColorMap(*cmp);
+  cmap = new PIColorMap(*cmp);
   if (refr)  Refresh();  
   return;
Index: trunk/SophyaPI/PI/picons.cc
===================================================================
--- trunk/SophyaPI/PI/picons.cc	(revision 127)
+++ trunk/SophyaPI/PI/picons.cc	(revision 128)
@@ -20,5 +20,5 @@
 
 static int CmdStrLen = 256;
-static int PIVA_Select = 128;
+static int PIVA_Select = 1 << 3;
 
 /* --Methode-- */
@@ -53,4 +53,5 @@
 mNComm = NMxRecall = 0;
 mRCindx = mRindx = 0;
+mChangeFg = false;
 
 // Copier/coller
@@ -79,7 +80,6 @@
   opmc->AppendItem("25L x 132C", 3302);
   opmc->AppendItem("5L x 80C", 3303);
-  opmc->AppendItem("White-Black", 3201);
-  opmc->AppendItem("Black-White", 3202);
-  opmc->AppendItem("Black-Yellow", 3203);
+  opmc->AppendItem("Bkg White", 3201);
+  opmc->AppendItem("Bkg Black", 3202);
   }
 nb_opmc++;
@@ -341,4 +341,5 @@
         mRindx = mRCindx;
         }
+      mChangeFg = false;
       Send( Msg(), PIMsg_OK, mCmdStr);
       ClrCmd();
@@ -351,5 +352,6 @@
         for(k=mCCP-1; k<mCLC-1; k++)  mCmdStr[k] = mCmdStr[k+1];
         mCmdStr[mCLC-1] = ' ';   mCCP--;  mCLC--;
-      }
+        mChangeFg = true;
+        }
       //      printf("Keyb()-Debug- Backspace CCP,CLC= %d %d CmdStr= %s (L=%d) \n", mCCP, mCLC, 
       //      mCmdStr, strlen(mCmdStr));
@@ -360,4 +362,9 @@
 //      printf("Keyb()-Debug- CursorUp/Down(%d)  Index= %d %d  \n", key, mRindx, mRCindx);
       if (mNComm > 0) {
+        if (mChangeFg) { 
+          mCmdStr[mCLC] = '\0';
+          mRStr[mRCindx] = mCmdStr;
+          mChangeFg = false;
+	  }
         int nmxrec = ((mNComm+1) < NMxRecall) ? mNComm+1 : NMxRecall;
         if (key == PIK_Up)  {
@@ -581,4 +588,5 @@
 
 int lva = -1;
+int ccol, cfnt;
 
 PIFontAtt vafat[8] = {PI_RomanFont, PI_BoldFont, PI_ItalicFont,
@@ -586,8 +594,9 @@
                       PI_ItalicFont, PI_RomanFont};
 PIColors fgc, bgc, dbgc;
+PIColors col[6] = {PI_Black, PI_Red, PI_Blue, PI_Green, PI_Yellow, PI_Magenta};
 
 g->SelForeground(mFgC);
 g->SelBackground(mBgC);
-fgc =  g->GetForeground();
+fgc =  col[0] = g->GetForeground();
 dbgc = bgc =  g->GetBackground();
 
@@ -618,9 +627,12 @@
        }
      lva = mAtt[mLPo[l]+j];
-     if (lva & PIVA_Select) 
-       { bgc = PI_Grey;   g->SelFont(mFTaille, vafat[lva-PIVA_Select]); }
-     else { bgc = dbgc; g->SelFont(mFTaille, vafat[lva]); }
+     cfnt = lva & 15;   //  Index de fonte
+     ccol = lva >> 4;   //  Index de couleur
+     fgc = col[ccol];
+     if (cfnt & PIVA_Select) 
+       { bgc = PI_Grey;   g->SelFont(mFTaille, vafat[cfnt-PIVA_Select]); }
+     else { bgc = dbgc; g->SelFont(mFTaille, vafat[cfnt]); }
      
-     if (lva & PIVA_Reverse) { 
+     if (cfnt & PIVA_Reverse) { 
        g->SelForeground(bgc);
        g->SelBackground(fgc);
@@ -700,7 +712,8 @@
       //      printf(" ++DBG++ C=%d L=%d MX=%d KMX=%d\n", mCCP, mCLC, CmdStrLen,kmx);
       for(k=kmx; k>mCCP; k--) mCmdStr[k] = mCmdStr[k-1];   mCLC = kmx+1;      
-    }
+      }
     mCmdStr[mCCP] = key;  mCCP++; 
     if (mCCP > mCLC)  mCLC = mCCP;
+    mChangeFg = true;
     }
 }
Index: trunk/SophyaPI/PI/picons.h
===================================================================
--- trunk/SophyaPI/PI/picons.h	(revision 127)
+++ trunk/SophyaPI/PI/picons.h	(revision 128)
@@ -15,7 +15,14 @@
 enum PIVAType {    
   PIVA_Def = 0,
-  PIVA_Bold = 1,
-  PIVA_Ital = 2,
-  PIVA_Reverse = 4
+  PIVA_Bold = 1 << 0,
+  PIVA_Ital = 1 << 1,
+  PIVA_Reverse = 1 << 2,
+//  Le 4eme bit (<<3) est reserve pour l'usage interne (PIVA_Select)
+  PIVA_DefCol = 0,
+  PIVA_Red = 1 << 4,
+  PIVA_Blue = 2 << 4, 
+  PIVA_Green = 3 << 4, 
+  PIVA_Yellow = 4 << 4,
+  PIVA_Magenta = 5 << 4
 };
 
@@ -92,4 +99,5 @@
   string * mRStr;           // Stockage des chaines 
   int mRCindx, mRindx;      // Index pour le rappel
+  bool mChangeFg;           // Texte modifie
   
 // Gestion du buffer de copie
Index: trunk/SophyaPI/PI/picontainergen.cc
===================================================================
--- trunk/SophyaPI/PI/picontainergen.cc	(revision 127)
+++ trunk/SophyaPI/PI/picontainergen.cc	(revision 128)
@@ -54,5 +54,5 @@
 //--
 
-#define NCHALGRP 4
+#define NCHALGRP 8
 
 /* --Methode-- */
@@ -147,4 +147,10 @@
 }
 
+/* --Methode-- */
+PIWdg* PIContainerGen::GetChild(int n)
+{
+if ( (n < 0) || (n >= mNCh))  return(NULL);
+return ((PIWdg*)mChilds[n]);
+}
 
 /* --Methode-- */
Index: trunk/SophyaPI/PI/picontainergen.h
===================================================================
--- trunk/SophyaPI/PI/picontainergen.h	(revision 127)
+++ trunk/SophyaPI/PI/picontainergen.h	(revision 128)
@@ -27,4 +27,5 @@
   virtual void         ChildDel(PIWdgGen * child);
   virtual int          NbChilds();
+  virtual PIWdg*       GetChild(int n);
 
   void                 SetAutoDelChilds(bool ad = false);
Index: trunk/SophyaPI/PI/piimage.cc
===================================================================
--- trunk/SophyaPI/PI/piimage.cc	(revision 127)
+++ trunk/SophyaPI/PI/piimage.cc	(revision 128)
@@ -77,5 +77,5 @@
 AddDrawer(mdrw, true, false, false);
 
-SetColMap(CMAP_COLRJ32);
+SetColMapId(CMAP_COLRJ32);
 
 // pour le copier-coller
@@ -201,5 +201,5 @@
 {
 cmvw = cw;
-if (cmvw && refr) cmvw->SetColMapId(GetColMapId(),true);
+if (cmvw && refr) cmvw->SetColMap(cmap, true);
 }
 
@@ -341,14 +341,29 @@
 }
 
-
-/* --Methode-- */
-void PIImage::SetColMap(CMapId cmap, bool refr)
-{
-if ( (cmap == CMAP_GREY32) || (cmap == CMAP_GREYINV32) )  mdrw->SetColAtt(PI_Red);
+/* --Methode-- */
+void PIImage::SetColMap(PIColorMap* cmp, bool refr)
+{
+if (!cmp)  return;
+int cmapid = cmp->Type();
+if ( (cmapid == CMAP_GREY32) || (cmapid == CMAP_GREYINV32) || 
+     (cmapid == CMAP_GREY128) || (cmapid == CMAP_GREYINV128))  mdrw->SetColAtt(PI_Red);
 else mdrw->SetColAtt(PI_White);
-PIPixmap::SetColMap(cmap, refr);
-if (zow)  zow->SetColMap(cmap, refr);
-if (gvw)  gvw->SetColMap(cmap, refr);
-if (cmvw) cmvw->SetColMapId(cmap, true);
+PIPixmap::SetColMap(cmp, refr);
+if (zow)  zow->SetColMap(cmp, refr);
+if (gvw)  gvw->SetColMap(cmp, refr);
+if (cmvw) cmvw->SetColMap(cmp, refr);
+return;
+}
+
+/* --Methode-- */
+void PIImage::SetColMapId(CMapId cmapid, bool refr)
+{
+if ( (cmapid == CMAP_GREY32) || (cmapid == CMAP_GREYINV32) || 
+     (cmapid == CMAP_GREY128) || (cmapid == CMAP_GREYINV128))  mdrw->SetColAtt(PI_Red);
+else mdrw->SetColAtt(PI_White);
+PIPixmap::SetColMapId(cmapid, refr);
+if (zow)  zow->SetColMapId(cmapid, refr);
+if (gvw)  gvw->SetColMapId(cmapid, refr);
+if (cmvw) cmvw->SetColMapId(cmapid, refr);
 return;
 }
@@ -377,5 +392,5 @@
 if (gvw != NULL)
   if ( (gvw->UserData() != this) || (mw) )  SetGloVPixmap();
-if (cmvw) cmvw->SetColMapId(GetColMapId(),true);
+if (cmvw) cmvw->SetColMap(cmap, true);
   
 return;
@@ -743,5 +758,5 @@
 
 zpixm = img->ComputePixmap(lut, lofx, lofy, zm, xwsz, ywsz, zpixm, &xszpxm, &yszpxm);
-zow->SetColMap(GetColMapId(), false);
+zow->SetColMap(cmap, false);
 zow->SetPixmap(zpixm, xszpxm, yszpxm); 
 zow->SetUserData((void *)this, 0);
@@ -800,9 +815,12 @@
 gvdrw->ElDelAll();
 gvdrw->SetLimits(xw1, xw2, yw1, yw2, kAxeDirLtoR, kAxeDirUpDown);
-gvdrw->SetColAtt(PI_Yellow);
+int cmapid = cmap->Type();
+if ( (cmapid == CMAP_GREY32) || (cmapid == CMAP_GREYINV32) || 
+     (cmapid == CMAP_GREY128) || (cmapid == CMAP_GREYINV128)) gvdrw->SetColAtt(PI_Red); 
+else gvdrw->SetColAtt(PI_Yellow);
 gvdrw->SetLineAtt(PI_NormalLine);
 gvdrw->ElAddRect(x,y,dx,dy);
 gvw->AddDrawer(gvdrw, xw1, yw1, xw2, yw2, false); 
-gvw->SetColMap(GetColMapId(), false);
+gvw->SetColMap(cmap, false);
 gvw->SetPixmap(gpixm, xsgpxm, ysgpxm, true, xw1, yw1); 
 gvw->SetUserData((void *)this, 0);
Index: trunk/SophyaPI/PI/piimage.h
===================================================================
--- trunk/SophyaPI/PI/piimage.h	(revision 127)
+++ trunk/SophyaPI/PI/piimage.h	(revision 128)
@@ -37,5 +37,5 @@
                        { mdrw->SetAxesFlags(flags); mdrw->Refresh(); }
 
-// Fenetre de Zoom, Vue global, ColorMap, text, ...
+// Fenetre de Zoom, Vue globale, ColorMap, text, ...
   void SetZoomWin(PIPixmap * zw, bool refr=false);
   void SetGloVWin(PIPixmap * zw, bool refr=false);
@@ -55,9 +55,13 @@
   float GetZoomF();
 
-  virtual void SetColMap(CMapId cmap, bool refr=true);
+// Changement de table de couleur
+  virtual void SetColMap(PIColorMap* cmp, bool refr=true);
+  virtual void SetColMapId(CMapId cmapid, bool refr=true);
 
+// Positionnement image - pave
   void SetOffset(int ox, int oy, bool refr=true);
   void SetPave(int x, int y, bool refr=true, bool cent=true);
 
+// Acces aux informations
   inline P2DArrayAdapter * Image() { return(img); }
   inline LUT *     Lut() { return(lut); }
@@ -70,4 +74,5 @@
   inline PIElDrawer* MyElDrawer() { return (mdrw); }
 
+// Rafraichissement des widgets auxiliaires (zoom, ...)
   void Apply(bool mw=true);
 
Index: trunk/SophyaPI/PI/piimgtools.cc
===================================================================
--- trunk/SophyaPI/PI/piimgtools.cc	(revision 127)
+++ trunk/SophyaPI/PI/piimgtools.cc	(revision 128)
@@ -374,7 +374,7 @@
 
 if ((msg <= 110) && (msg >= 90))  // Zoom
-  PIImage::CurrentPIImage()->SetZoom((int)(msg-100));
+  PIImage::CurrentPIImage()->SetZoom((int)(msg-100), true);
 else if ((msg > 200) && (msg < 211)) // Changement de couleur 
-  PIImage::CurrentPIImage()->SetColMap(cmap[msg-201]);
+  PIImage::CurrentPIImage()->SetColMapId(cmap[msg-201], true);
 
 return;
Index: trunk/SophyaPI/PI/pipixmapgen.cc
===================================================================
--- trunk/SophyaPI/PI/pipixmapgen.cc	(revision 127)
+++ trunk/SophyaPI/PI/pipixmapgen.cc	(revision 128)
@@ -48,12 +48,21 @@
 }
 
+/* --Methode-- */
+void PIPixmapGen::SetColMap(PIColorMap* cmp, bool refr)
+{
+if (!cmp)  return;
+if ( (cmp->Type() == cmap->Type()) && (cmp->Type() != CMAP_OTHER) ) return;
+if (cmap) delete cmap;
+cmap = new PIColorMap(*cmp);
+if (refr)  Refresh();  
+}
 
 /* --Methode-- */
-void PIPixmapGen::SetColMap(CMapId cmapid, bool refr)
+void PIPixmapGen::SetColMapId(CMapId cmapid, bool refr)
 {
 if (!cmap || (cmap->Type() != cmapid) || (cmapid == CMAP_OTHER) ) {  
   if (cmap) delete cmap;
   cmap = new PIColorMap(cmapid);
-}
+  }
 if (refr)  Refresh();  
 }
Index: trunk/SophyaPI/PI/pipixmapgen.h
===================================================================
--- trunk/SophyaPI/PI/pipixmapgen.h	(revision 127)
+++ trunk/SophyaPI/PI/pipixmapgen.h	(revision 128)
@@ -24,5 +24,9 @@
   virtual void  SetPixmap(unsigned char *pix, int sx, int sy, 
                           bool refr=true, int ox=0, int oy=0);
-  void          SetColMap(CMapId cmapid, bool refr=true);
+
+  virtual void  SetColMap(PIColorMap* cmp, bool refr=true);
+  virtual void  SetColMapId(CMapId cmapid, bool refr=true);
+
+  inline PIColorMap* GetColMap() { return cmap; }
   inline CMapId GetColMapId() { return ((CMapId)cmap->Type()); }; 
   inline int    NbCol() { return(cmap->NCol()); };
Index: trunk/SophyaPI/PI/pipodrw.cc
===================================================================
--- trunk/SophyaPI/PI/pipodrw.cc	(revision 127)
+++ trunk/SophyaPI/PI/pipodrw.cc	(revision 128)
@@ -102,2 +102,23 @@
 return((*mVec)(i)); 
 }
+
+// Adaptateur d'Histo-2D Peida++ a P2DArrayAdapter
+/* --Methode-- */
+POH2DAdapter::POH2DAdapter(Histo2D* h2d, bool ad)
+        : P2DArrayAdapter(h2d->NBinX(), h2d->NBinY())
+{
+aDel = ad; mH2d = h2d;
+DefineXYCoordinates(h2d->XMin(), h2d->YMin(), h2d->WBinX(), h2d->WBinY() );
+}
+
+/* --Methode-- */
+POH2DAdapter::~POH2DAdapter()
+{
+if (aDel)  delete mH2d;
+}
+
+/* --Methode-- */
+float POH2DAdapter::Value(int ix, int iy)
+{
+return((*mH2d)(ix, iy));
+}
Index: trunk/SophyaPI/PI/pipodrw.h
===================================================================
--- trunk/SophyaPI/PI/pipodrw.h	(revision 127)
+++ trunk/SophyaPI/PI/pipodrw.h	(revision 128)
@@ -1,2 +1,7 @@
+// This may look like C code, but it is really -*- C++ -*-
+//  Adaptateurs et Drawers divers pour Outils PEIDA++
+//                             R. Ansari  06-08/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
 #ifndef PIPODRW_H_SEEN
 #define PIPODRW_H_SEEN
@@ -5,4 +10,5 @@
 #include "parradapter.h"
 #include "cvector.h"
+#include "histos2.h"
 
 class PIFuncDrawer : public PIDrawer {
@@ -44,3 +50,16 @@
 };
 
+// Adaptateur d'Histo-2D Peida++ a P2DArrayAdapter
+class POH2DAdapter :  public P2DArrayAdapter {
+public :
+                  POH2DAdapter(Histo2D* h2d, bool ad=false);
+  virtual         ~POH2DAdapter();
+
+  virtual float   Value(int ix, int iy);   
+
+protected:
+  bool aDel;
+  Histo2D* mH2d;
+};
+
 #endif
