Index: /trunk/SophyaPI/PI/Makefile
===================================================================
--- /trunk/SophyaPI/PI/Makefile	(revision 111)
+++ /trunk/SophyaPI/PI/Makefile	(revision 112)
@@ -4,5 +4,5 @@
  
 all: $(LIB)libPI.a
-$(LIB)libPI.a : $(OBJ)lut.o $(OBJ)pi3ddrw.o $(OBJ)piapplgen.o $(OBJ)piapplx.o $(OBJ)pibwdggen.o $(OBJ)pibwdgx.o $(OBJ)picmap.o $(OBJ)picmapgen.o $(OBJ)picmapx.o $(OBJ)picons.o $(OBJ)picontainergen.o $(OBJ)picontainerx.o $(OBJ)pidrawer.o $(OBJ)pidrawwin.o $(OBJ)pifilechogen.o $(OBJ)pifilechox.o $(OBJ)pigraph3d.o $(OBJ)pigraphgen.o $(OBJ)pigraphps.o $(OBJ)pigraphuc.o $(OBJ)pigraphx.o $(OBJ)pihisto.o $(OBJ)pihisto2d.o $(OBJ)piimage.o $(OBJ)piimgtools.o $(OBJ)piinit.o $(OBJ)pilistgen.o $(OBJ)pilistx.o $(OBJ)pimenubargen.o $(OBJ)pimenubarx.o $(OBJ)pimenugen.o $(OBJ)pimenux.o $(OBJ)pimsghandler.o $(OBJ)pintuple.o $(OBJ)pioptmenugen.o $(OBJ)pioptmenux.o $(OBJ)piperiodx.o $(OBJ)pipixmapgen.o $(OBJ)pipixmapx.o $(OBJ)piscdrawwdg.o $(OBJ)pistdwdggen.o $(OBJ)pistdwdgx.o $(OBJ)pistlist.o $(OBJ)piup.o $(OBJ)piwdggen.o $(OBJ)piwdgx.o $(OBJ)piwindowgen.o $(OBJ)piwindowx.o $(OBJ)pixtbase.o $(OBJ)psfile.o
+$(LIB)libPI.a : $(OBJ)lut.o $(OBJ)pi3ddrw.o $(OBJ)piapplgen.o $(OBJ)piapplx.o $(OBJ)pibwdggen.o $(OBJ)pibwdgx.o $(OBJ)picmap.o $(OBJ)picmapgen.o $(OBJ)picmapx.o $(OBJ)picons.o $(OBJ)picontainergen.o $(OBJ)picontainerx.o $(OBJ)pidrawer.o $(OBJ)pidrawwin.o $(OBJ)pidrwtools.o $(OBJ)pifilechogen.o $(OBJ)pifilechox.o $(OBJ)pigraph3d.o $(OBJ)pigraphgen.o $(OBJ)pigraphps.o $(OBJ)pigraphuc.o $(OBJ)pigraphx.o $(OBJ)pihisto.o $(OBJ)pihisto2d.o $(OBJ)piimage.o $(OBJ)piimgtools.o $(OBJ)piinit.o $(OBJ)pilistgen.o $(OBJ)pilistx.o $(OBJ)pimenubargen.o $(OBJ)pimenubarx.o $(OBJ)pimenugen.o $(OBJ)pimenux.o $(OBJ)pimsghandler.o $(OBJ)pintuple.o $(OBJ)pioptmenugen.o $(OBJ)pioptmenux.o $(OBJ)piperiodx.o $(OBJ)pipixmapgen.o $(OBJ)pipixmapx.o $(OBJ)piscdrawwdg.o $(OBJ)pistdwdggen.o $(OBJ)pistdwdgx.o $(OBJ)pistlist.o $(OBJ)piup.o $(OBJ)piwdggen.o $(OBJ)piwdgx.o $(OBJ)piwindowgen.o $(OBJ)piwindowx.o $(OBJ)pixtbase.o $(OBJ)psfile.o
 	$(AR) $(ARFLAGS)  $@ $? 
 ifeq ($(CXX),cxx)
@@ -12,5 +12,8 @@
  
 $(OBJ)lut.o: lut.cc $(EROSDEVREP)/Include/defs.h lut.h
-$(OBJ)pi3ddrw.o: pi3ddrw.cc pi3ddrw.h
+$(OBJ)pi3ddrw.o: pi3ddrw.cc pi3ddrw.h pidrawer.h pibwdggen.h pisysdep.h \
+ piwdgx.h piwdggen.h pimsghandler.h picmap.h picmapx.h picmapgen.h \
+ pigraphx.h pigraphgen.h pigraphuc.h psfile.h \
+ $(EROSDEVREP)/Include/defs.h
 $(OBJ)piapplgen.o: piapplgen.cc piapplgen.h pimsghandler.h pisysdep.h \
  picontainerx.h picontainergen.h piwdgx.h piwdggen.h pimenubarx.h \
@@ -55,4 +58,11 @@
  $(EROSDEVREP)/Include/defs.h pigraphps.h pistdwdgx.h pistdwdggen.h \
  pidrawer.h
+$(OBJ)pidrwtools.o: pidrwtools.cc pidrwtools.h pisysdep.h pimenux.h \
+ pimenugen.h piwdgx.h piwdggen.h pimsghandler.h piapplx.h piapplgen.h \
+ picontainerx.h picontainergen.h pimenubarx.h pimenubargen.h picons.h \
+ pistdwdgx.h pistdwdggen.h pibwdgx.h pibwdggen.h picmap.h picmapx.h \
+ picmapgen.h pigraphx.h pigraphgen.h pigraphuc.h psfile.h \
+ $(EROSDEVREP)/Include/defs.h pigraphps.h pioptmenux.h \
+ pioptmenugen.h piscdrawwdg.h piwindowx.h piwindowgen.h pidrawer.h
 $(OBJ)pifilechogen.o: pifilechogen.cc pifilechogen.h pisysdep.h piwdgx.h \
  piwdggen.h pimsghandler.h
@@ -104,36 +114,14 @@
  pigraphuc.h psfile.h pipixmapx.h pipixmapgen.h pibwdgx.h pigraphps.h \
  pistdwdgx.h pistdwdggen.h piwindowx.h piwindowgen.h picontainerx.h \
- picontainergen.h $(EROSDEVREP)/Include/imageop.h \
- $(EROSDEVREP)/Include/cimage.h $(EROSDEVREP)/Include/rzimage.h \
- $(EROSDEVREP)/Include/rzvect.h \
- $(EROSDEVREP)/Include/exceptions.h \
- $(EROSDEVREP)/Include/peidainit.h \
- $(EROSDEVREP)/Include/perrors.h \
- $(EROSDEVREP)/Include/imaginit.h \
- $(EROSDEVREP)/Include/datatypes.h \
- $(EROSDEVREP)/Include/ppersist.h \
- $(EROSDEVREP)/Include/pclassids.h \
- $(EROSDEVREP)/Include/dvlist.h \
- $(EROSDEVREP)/Include/fitsimage.h \
- $(EROSDEVREP)/Include/fitsheader.h \
- $(EROSDEVREP)/Include/erosio.h $(EROSDEVREP)/Include/fitskeys.h \
- $(EROSDEVREP)/Include/erostape.h \
- $(EROSDEVREP)/Include/strutil.h \
- $(EROSDEVREP)/Include/ptrarray.h \
- $(EROSDEVREP)/Include/voidptrarray.h \
- $(EROSDEVREP)/Include/basearray.h $(EROSDEVREP)/Include/peida.h \
- $(EROSDEVREP)/Include/utils.h $(EROSDEVREP)/Include/fmath.h \
- $(EROSDEVREP)/Include/array.h $(EROSDEVREP)/Include/lockfile.h \
- $(EROSDEVREP)/Include/erostarfile.h \
- $(EROSDEVREP)/Include/xstrstream.h \
- $(EROSDEVREP)/Include/dates.h $(EROSDEVREP)/Include/tarlib.h
-$(OBJ)piimgtools.o: piimgtools.cc pisysdep.h pistdwdgx.h pistdwdggen.h \
- piwdgx.h piwdggen.h pimsghandler.h pimenux.h pimenugen.h pioptmenux.h \
- pioptmenugen.h piapplx.h piapplgen.h picontainerx.h picontainergen.h \
- pimenubarx.h pimenubargen.h picons.h pibwdgx.h pibwdggen.h picmap.h \
- picmapx.h picmapgen.h pigraphx.h pigraphgen.h pigraphuc.h psfile.h \
- $(EROSDEVREP)/Include/defs.h pigraphps.h piimage.h parradapter.h \
+ picontainergen.h
+$(OBJ)piimgtools.o: piimgtools.cc piimgtools.h pisysdep.h pimenux.h \
+ pimenugen.h piwdgx.h piwdggen.h pimsghandler.h piapplx.h piapplgen.h \
+ picontainerx.h picontainergen.h pimenubarx.h pimenubargen.h picons.h \
+ pistdwdgx.h pistdwdggen.h pibwdgx.h pibwdggen.h picmap.h picmapx.h \
+ picmapgen.h pigraphx.h pigraphgen.h pigraphuc.h psfile.h \
+ $(EROSDEVREP)/Include/defs.h pigraphps.h pioptmenux.h \
+ pioptmenugen.h piimage.h parradapter.h \
  $(EROSDEVREP)/Include/machine.h lut.h pidrawer.h pipixmapx.h \
- pipixmapgen.h piwindowx.h piwindowgen.h piimgtools.h
+ pipixmapgen.h piwindowx.h piwindowgen.h
 $(OBJ)piinit.o: piinit.cc $(EROSDEVREP)/Include/defs.h piinit.h \
  $(EROSDEVREP)/Include/strecinit.h \
Index: /trunk/SophyaPI/PI/picmapx.cc
===================================================================
--- /trunk/SophyaPI/PI/picmapx.cc	(revision 111)
+++ /trunk/SophyaPI/PI/picmapx.cc	(revision 112)
@@ -14,4 +14,5 @@
 mColors = NULL;
 mColRGB = NULL;
+mNewCol = NULL;
 }
 
@@ -24,10 +25,11 @@
 mColors = new PIXColor[n];
 mColRGB = new PIColor[n];
-{for(int i=0; i<n; i++)  
+mNewCol = new bool[n];
+int i;
+for(i=0; i<n; i++)  
   { mColors[i] = BlackPixel(PIXDisplay(), PIXScreen());
-  mColRGB[i].red = mColRGB[i].green = mColRGB[i].blue = 0; }
-}// printf("PIColorMapX::PIColorMapX(CMapId, int) %d %d \n", mNCol, Type());
-
-return;
+  mColRGB[i].red = mColRGB[i].green = mColRGB[i].blue = 0; 
+  mNewCol[i] = false; }
+// printf("PIColorMapX::PIColorMapX(CMapId, int) %d %d \n", mNCol, Type());
 }
 
@@ -38,4 +40,5 @@
 if (mColors)  delete[] mColors;
 if (mColRGB)  delete[] mColRGB;
+if (mNewCol)  delete[] mNewCol;
 }
 
@@ -72,5 +75,5 @@
   }
 
-if ( (index < 0) || (index > mNCol) )  return(false);
+if ( (index < 0) || (index >= mNCol) )  return(false);
 
 if ( (col.red == 0) && (col.green == 0) && (col.blue == 0) )
@@ -78,7 +81,17 @@
   mColors[index] = BlackPixel(PIXDisplay(), PIXScreen());
   mColRGB[index] = col; 
+  mNewCol[index] = false;
   return(true);
   }
 
+// Pour diminuer les requetes X, on verifie si la couleur 
+// ne se trouve pas deja dans la table    Reza 19/05/98
+int kc;
+for(kc=0; kc<mNCol; kc++) 
+  if ( (col.red == mColRGB[kc].red) && (col.green == mColRGB[kc].green) &&   (col.blue == mColRGB[kc].blue) )
+    { mColors[index] = mColors[kc];  mColRGB[index] = mColRGB[kc]; 
+    mNewCol[index] = false;  return(true); }
+
+ 
 myxcol.red = col.red; 
 myxcol.blue = col.blue;
@@ -89,4 +102,5 @@
   mColors[index] = myxcol.pixel;
   mColRGB[index] = col; 
+  mNewCol[index] = true;
 //  printf("PIColorMapX::AllocColor()  RGB= %d %d %d \n",
 //         (int) col.red, (int) col.blue, (int) col.green);
@@ -120,11 +134,10 @@
 
 for (int i=0; i<mNCol; i++)
-  if ( (mColRGB[i].red != 0) && (mColRGB[i].blue != 0) &&  (mColRGB[i].green != 0) )
-    XFreeColors(PIXDisplay(), defxcmap, mColors+i, 1, 0);
+  if ( mNewCol[i] )    XFreeColors(PIXDisplay(), defxcmap, mColors+i, 1, 0);
 
 bpix = BlackPixel(PIXDisplay(), PIXScreen());
 blc.red = blc.green = blc.blue = 0;
 {for (int i=0; i<mNCol; i++)  
-  { mColors[i] = bpix;   mColRGB[i] = blc; }
+  { mColors[i] = bpix;   mColRGB[i] = blc;  mNewCol[i] = false; }
 }
 printf("PIColorMapX::FreeColors()  Type= %d mNCol= %d \n",
@@ -166,9 +179,12 @@
   if (mColors)  delete mColors;
   if (mColRGB)  delete mColRGB;
+  if (mNewCol)  delete mNewCol;
   CopyFromGen(x);
   mColors = new PIXColor[mNCol];
   mColRGB = new PIColor[mNCol];
+  mNewCol = new bool[mNCol];
   for (int i=0; i<mNCol; i++)  
     { mColors[i] = ((PIColorMapX *)x)->mColors[i];
-    mColRGB[i] = ((PIColorMapX *)x)->mColRGB[i]; }
+    mColRGB[i] = ((PIColorMapX *)x)->mColRGB[i]; 
+    mNewCol[i] = ((PIColorMapX *)x)->mNewCol[i]; }
 }
Index: /trunk/SophyaPI/PI/picmapx.h
===================================================================
--- /trunk/SophyaPI/PI/picmapx.h	(revision 111)
+++ /trunk/SophyaPI/PI/picmapx.h	(revision 112)
@@ -28,4 +28,5 @@
   PIXColor  * mColors;     // La table des couleurs ...
   PIColor   * mColRGB;     // Composantes RGB  
+  bool * mNewCol;          // Nouvelle couleur dans table ou pas
 };
 
Index: /trunk/SophyaPI/PI/pidrwtools.cc
===================================================================
--- /trunk/SophyaPI/PI/pidrwtools.cc	(revision 112)
+++ /trunk/SophyaPI/PI/pidrwtools.cc	(revision 112)
@@ -0,0 +1,30 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Outils de manipulation des PIDrawer  R. Ansari 06/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include <stdlib.h>
+#include "pidrwtools.h"
+#include "piscdrawwdg.h"
+
+
+/* --Methode-- */
+PIDrwMenu::PIDrwMenu(PIApplication* par) 
+        : PIMenu(par->Menubar(), "DrawerTools")
+{
+pdm[0] = new PIMenu(this, "Color");
+pdm[0]->AppendItem("White", 303);
+AppendPDMenu(pdm[0]);
+}
+
+/* --Methode-- */
+PIDrwMenu::~PIDrwMenu()
+{
+int i;
+for(i=0; i<1; i++)  delete pdm[i];
+}
+
+/* --Methode-- */
+void PIDrwMenu::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
+{
+return;
+}
Index: /trunk/SophyaPI/PI/pidrwtools.h
===================================================================
--- /trunk/SophyaPI/PI/pidrwtools.h	(revision 112)
+++ /trunk/SophyaPI/PI/pidrwtools.h	(revision 112)
@@ -0,0 +1,22 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Outils de manipulation des PIDrawer  R. Ansari 06/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIDRWTOOLS_H_SEEN
+#define PIDRWTOOLS_H_SEEN
+
+#include "pisysdep.h"
+#include PIMENU_H
+#include PIAPP_H
+
+class PIDrwMenu : public PIMenu 
+{
+public :
+			PIDrwMenu(PIApplication* app);
+ virtual		~PIDrwMenu();
+protected:
+  virtual void		Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+PIMenu* pdm[2];
+};
+
+#endif
Index: /trunk/SophyaPI/PI/pihisto2d.cc
===================================================================
--- /trunk/SophyaPI/PI/pihisto2d.cc	(revision 111)
+++ /trunk/SophyaPI/PI/pihisto2d.cc	(revision 112)
@@ -545,5 +545,5 @@
 mBut[2] = new PIButton(this, "Get"  , 6003, 50, 20, 150,60);
 mBut[3] = new PIButton(this, "Print", 6004, 50, 20, 150,85);
-FinishCreate();
+// FinishCreate();
 }
 
Index: /trunk/SophyaPI/PI/piimage.cc
===================================================================
--- /trunk/SophyaPI/PI/piimage.cc	(revision 111)
+++ /trunk/SophyaPI/PI/piimage.cc	(revision 112)
@@ -10,5 +10,4 @@
 
 #include "piimage.h"
-#include "imageop.h"
 
 // --------------------------------------------------------------------------------
Index: /trunk/SophyaPI/PI/piimgtools.cc
===================================================================
--- /trunk/SophyaPI/PI/piimgtools.cc	(revision 112)
+++ /trunk/SophyaPI/PI/piimgtools.cc	(revision 112)
@@ -0,0 +1,262 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Outils de manipulation des PIImage  R. Ansari 06/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include <stdlib.h>
+
+#include "piimgtools.h"
+#include PISTDWDG_H
+#include PIOPTMENU_H
+#include "piimage.h"
+
+// ------ Menu des options et fenetre de dialogue pour changement de LUT --------
+
+
+/* --Methode-- */
+PIImgLutWind::PIImgLutWind(PIApplication* par)
+: PIWindow((PIMsgHandler*)par, "PIImg-ChangeLut", PIWK_dialog, 240, 240, 150, 150)
+{
+
+mLab[0] = new PILabel(this, "MinPixel", 60, 35, 30, 20); 
+mLab[1] = new PILabel(this, "MaxPixel", 60, 35, 30, 65); 
+
+mLab[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mLab[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+mText[0] = new PIText(this, "MinVal", 100, 35, 110, 20);
+mText[0]->SetText("1");
+mText[1] = new PIText(this, "MaxVal", 100, 35, 110, 65);
+mText[1]->SetText("32000");
+mText[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mText[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+mOlb[0] = new PILabel(this, "LutType", 60, 30, 30, 110); 
+mOlb[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mOpt[0] = new PIOptMenu(this, "imglut-opt-1", 100, 30, 110, 110);
+mOpt[0]->AppendItem("Linear", 1100);
+mOpt[0]->AppendItem("Log.", 1101);
+mOpt[0]->SetValue(1100);
+mOpt[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+mOlb[1] = new PILabel(this, "AutoLut", 60, 30, 30, 140); 
+mOlb[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mOpt[1] = new PIOptMenu(this, "imglut-opt-2", 100, 30, 110, 140);
+mOpt[1]->AppendItem("+3 Sig", 1203);
+mOpt[1]->AppendItem("+2 Sig", 1202);
+mOpt[1]->AppendItem("+1 Sig", 1201);
+mOpt[1]->AppendItem("NoAuto", 1200);
+mOpt[1]->AppendItem("-1 Sig", 1199);
+mOpt[1]->AppendItem("-2 Sig", 1198);
+mOpt[1]->AppendItem("-3 Sig", 1197);
+mOpt[1]->SetValue(1202);
+mOpt[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+mBut[0] = new PIButton(this, "Apply", 1500, 70, 30, 30, 190);
+mBut[1] = new PIButton(this, "Dismiss", 1600, 70, 30, 140, 190);
+mBut[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mBut[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+}
+
+/* --Methode-- */
+PIImgLutWind::~PIImgLutWind()
+{
+for(int i=0; i<2; i++)
+  {
+  delete mLab[i];
+  delete mBut[i];
+  delete mText[i];
+  delete mOpt[i];
+  delete mOlb[i];
+  }
+}
+
+/* --Methode-- */
+void PIImgLutWind::Show()
+{
+char buff[32];
+PIImage *mpii;
+PIWindow::Show();
+mpii = PIImage::CurrentPIImage();
+if (mpii == NULL)  return;
+sprintf(buff,"%g", (mpii->Lut())->Min());
+mText[0]->SetText(buff);
+sprintf(buff,"%g", (mpii->Lut())->Max());
+mText[1]->SetText(buff);
+if ( (mpii->Lut())->Type() == kLutType_Lin ) 
+  mOpt[0]->SetValue(1100);
+else mOpt[0]->SetValue(1101);
+string s("NoAuto");
+mOpt[1]->SetValueStr(s);
+return;
+}
+
+
+/* --Methode-- */
+void PIImgLutWind::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
+{
+float min, max;
+int lauto, typ;
+int typlut[2] = {kLutType_Lin, kLutType_Log} ; 
+
+msg = UserMsg(msg);
+switch (msg)
+  {
+  case 1600:
+    this->Hide();
+    break;
+  case 1500:
+    if (PIImage::CurrentPIImage() == NULL)  return;
+    min = atof(mText[0]->GetText().c_str());
+    max = atof(mText[1]->GetText().c_str());
+    lauto = mOpt[1]->GetValue() - 1200;
+    typ = mOpt[0]->GetValue() - 1100;
+    if ( (typ < 0) || (typ > 1) )  typ = 0;
+    (PIImage::CurrentPIImage())->SetLut(min, max, typlut[typ], lauto);
+//    ((PIImage::CurrentPIImage())->Lut())->Print();
+    break;
+  default:
+//    printf("PIImgLutWind::Process Msg %d received \n", (int)msg);
+    break;
+  }
+}
+
+// --------------------------------------------------------------
+
+/* --Methode-- */
+PIImgMenu::PIImgMenu(PIApplication* par) 
+        : PIMenu(par->Menubar(), "ImgTools")
+{
+pdm[0] = new PIMenu(this, "AutoLut");
+pdm[0]->AppendItem("+3 Sig", 303);
+pdm[0]->AppendItem("+2 Sig", 302);
+pdm[0]->AppendItem("+1 Sig", 301);
+pdm[0]->AppendItem("-1 Sig", 299);
+pdm[0]->AppendItem("-2 Sig", 298);
+AppendPDMenu(pdm[0]);
+
+pdm[1] = new PIMenu(this, "Zoom");
+pdm[1]->AppendItem("Agr. *10", 110);
+pdm[1]->AppendItem("Agr. * 8", 108);
+pdm[1]->AppendItem("Agr. * 6", 106);
+pdm[1]->AppendItem("Agr. * 5", 105);
+pdm[1]->AppendItem("Agr. * 4", 104);
+pdm[1]->AppendItem("Agr. * 3", 103);
+pdm[1]->AppendItem("Agr. * 2", 102);
+pdm[1]->AppendItem("* 1", 101);
+pdm[1]->AppendItem("Red. / 2", 98);
+pdm[1]->AppendItem("Red. / 3", 97);
+pdm[1]->AppendItem("Red. / 4", 96);
+pdm[1]->AppendItem("Red. / 5", 95);
+pdm[1]->AppendItem("Red. / 6", 94);
+pdm[1]->AppendItem("Red. / 8", 92);
+pdm[1]->AppendItem("Red. /10", 90);
+AppendPDMenu(pdm[1]);
+
+pdm[2] = new PIMenu(this, "ColMap");
+pdm[2]->AppendItem("Grey32", 201);
+pdm[2]->AppendItem("GreyInv32", 202);
+pdm[2]->AppendItem("ColRJ32", 203);
+pdm[2]->AppendItem("ColBR32", 204);
+pdm[2]->AppendItem("ColRV32", 205);
+AppendPDMenu(pdm[2]);
+
+AppendItem("Sz x 1", 5101);
+AppendCheckItem("Show Cursor", 5102);
+AppendCheckItem("Show Axes", 5103);
+pdm[3] = new PIMenu(this, "Conf. Axes");
+pdm[3]->AppendItem("Invert-X",  5201);
+pdm[3]->AppendItem("Invert-Y",  5202);
+pdm[3]->AppendItem("Exchange X-Y",  5203);
+AppendPDMenu(pdm[3]);
+
+AppendItem("Lut...", 5300);
+
+mLW = new PIImgLutWind(par);
+}
+
+/* --Methode-- */
+PIImgMenu::~PIImgMenu()
+{
+int i;
+for(i=0; i<4; i++)  delete pdm[i];
+delete mLW;
+}
+
+/* --Methode-- */
+void PIImgMenu::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
+{
+CMapId cmap[5] = { CMAP_GREY32, CMAP_GREYINV32, CMAP_COLRJ32, 
+                   CMAP_COLBR32, CMAP_COLRV32 } ;
+if (PIImage::CurrentPIImage() == NULL)  return;
+msg = UserMsg(msg);
+if ((msg <= 110) && (msg >= 90))  // Zoom
+  PIImage::CurrentPIImage()->SetZoom((int)(msg-100));
+else if ((msg > 200) && (msg < 206)) // Changement de couleur 
+  PIImage::CurrentPIImage()->SetColMap(cmap[msg-201]);
+else if ((msg > 290) && (msg < 310))
+  PIImage::CurrentPIImage()->SetLut( PIImage::CurrentPIImage()->Lut()->Min(), PIImage::CurrentPIImage()->Lut()->Max(), 
+                                 kLutType_Lin, msg-300);
+else if ((msg > 500) && (msg < 505)) {
+  PIImage* mpii = PIImage::CurrentPIImage();
+  float x1 = (mpii->Lut())->Min(); 
+  float x2 = (mpii->Lut())->Max(); 
+  float dx = 0.1*(x2-x1);
+  int typ  = (mpii->Lut())->Type();
+  switch (msg)
+    {
+    case 501 :
+      mpii->SetLut(x1-dx, x2, typ);
+      break;
+    case 502 :
+      mpii->SetLut(x1+dx, x2, typ);
+      break;
+    case 503 :
+      mpii->SetLut(x1, x2-dx, typ);
+      break;
+    case 504 :
+      mpii->SetLut(x1, x2+dx, typ);
+      break;
+    default :
+      break;
+    }
+
+}
+else {
+  PIImage* mpii = PIImage::CurrentPIImage();
+  switch (msg)
+    {
+  case 5101 :
+    mpii->SetOffset(0, 0, false);
+    mpii->SetZoom(1, true);
+    break;
+
+  case 5102 :
+    if (*((bool *)data))  mpii->ShowCursor(true);
+    else  mpii->ShowCursor(false);
+    break;
+
+  case 5103 :
+    if (*((bool *)data))  mpii->SetDrawAxesFlags();
+    else  mpii->SetDrawAxesFlags(kAxesNone);
+    break;
+
+  case 5201 :
+    mpii->ChangeAxesConfiguration(true, false, false);
+    break;
+  case 5202 :
+    mpii->ChangeAxesConfiguration(false, true, false);
+    break;
+  case 5203 :
+    mpii->ChangeAxesConfiguration(false, false, true);
+    break;
+
+  case 5300 :
+    mLW->Show();
+    break;
+
+  default :
+    break;
+  }
+}
+return;
+}
Index: /trunk/SophyaPI/PI/piimgtools.h
===================================================================
--- /trunk/SophyaPI/PI/piimgtools.h	(revision 112)
+++ /trunk/SophyaPI/PI/piimgtools.h	(revision 112)
@@ -0,0 +1,46 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Outils de manipulation des PIImage  R. Ansari 06/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIIMGTOOLS_H_SEEN
+#define PIIMGTOOLS_H_SEEN
+
+#include "pisysdep.h"
+#include PISTDWDG_H
+#include PIMENU_H
+#include PIOPTMENU_H
+#include PIWIN_H
+#include PIAPP_H
+
+// ------ Menu des options et fenetre de dialogue pour changement de LUT --------
+
+// --------------------------------------------------------------
+class PIImgLutWind : public PIWindow {
+public :
+  PIImgLutWind(PIApplication* par);
+  ~PIImgLutWind();
+  virtual void  Show();
+
+protected:
+  virtual void  Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+
+private:
+  PILabel * mLab[2];
+  PIButton * mBut[2];
+  PIText * mText[2];
+  PIOptMenu * mOpt[2];
+  PILabel * mOlb[2];
+};
+
+class PIImgMenu : public PIMenu 
+{
+public :
+			PIImgMenu(PIApplication* app);
+ virtual		~PIImgMenu();
+protected:
+  virtual void		Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+PIMenu* pdm[4];
+PIImgLutWind* mLW;
+};
+
+#endif
Index: /trunk/SophyaPI/PI/pioptmenux.cc
===================================================================
--- /trunk/SophyaPI/PI/pioptmenux.cc	(revision 111)
+++ /trunk/SophyaPI/PI/pioptmenux.cc	(revision 112)
@@ -50,7 +50,8 @@
 XtSetArg(warg[n],XmNmarginLeft,rsy*3);  n++;
 XtSetValues(XtWdg(), warg, n);
-XtUninstallTranslations(XtWdg());
+XtTranslations trans = XtParseTranslationTable( 
+      "<Btn1Down>: \n <Btn1Up>: \n <Btn2Down>: \n <Btn2Up>: \n <Btn3Down>: \n <Btn3Up>:");
+XtOverrideTranslations(XtWdg(), trans);
 XtAddEventHandler( XtWdg(), ButtonPressMask|ExposureMask, FALSE, mouse_handler_optmenux, this);
-SetBinding(PIBK_fixed, PIBK_fixed, PIBK_free, PIBK_fixed);
 mgc = 0;
 char buff[128];
@@ -72,4 +73,5 @@
 void PIOptMenuX::FinishCreate()
 {
+printf("PIOptMenuX::FinishCreate()/DBG  %s \n", Nom().c_str());
 if (mSmsg == 0)  SetValue(mMen->ItemMsg(0)); 
 }
Index: /trunk/SophyaPI/PI/sc_sample.cc
===================================================================
--- /trunk/SophyaPI/PI/sc_sample.cc	(revision 111)
+++ /trunk/SophyaPI/PI/sc_sample.cc	(revision 112)
@@ -1,26 +1,21 @@
+#include <stdio.h>
 #include "sc_sample.h"
 
-static double f(double x) {return x*x;}
-
-ScSample::ScSample(PIContainerGen *par, char *nom,
-                  int sx, int sy, int px, int py)
-:PIScDrawWdg(par, nom, sx, sy, px, py)
-
+static int nscd = 0;
+ScSampleDrawer::ScSampleDrawer() 
+        : PIDrawer() 
 {
-PIFuncDrawer * mfd;
-mfd = new PIFuncDrawer(f);
-  SetLimits(-3,3,-4,4);
-AddScDrawer(mfd);
-SetAxesFlags(kAxesDflt);
+nscd++;
+printf(" ScSampleDrawer::ScSampleDrawer() NScDrw= %d \n",  nscd);
 }
 
-ScSample::~ScSample()
+ScSampleDrawer::~ScSampleDrawer() 
 {
-DeleteDrawers();
+nscd--;
+printf("Delete/ScSampleDrawer::~ScSampleDrawer() NScDrw= %d \n",  nscd);
 }
 
-
 void
-ScSample::DrawSelf(PIGraphicUC* g)
+ScSampleDrawer::Draw(PIGraphicUC* g, float, float, float, float)
 {
 PIGrCoord x[5] = {-2, -1., 1., 1.7, 2.2};
@@ -45,2 +40,25 @@
 }
 
+static double f(double x) {return x*x;}
+
+ScSample::ScSample(PIContainerGen *par, char *nom,
+                  int sx, int sy, int px, int py)
+:PIScDrawWdg(par, nom, sx, sy, px, py)
+
+{
+PIFuncDrawer * mfd;
+mfd = new PIFuncDrawer(f);
+  SetLimits(-3,3,-4,4);
+AddScDrawer(mfd,true);
+ScSampleDrawer* msd = new ScSampleDrawer;
+AddScDrawer((PIDrawer*)msd,true);
+SetAxesFlags(kAxesDflt);
+}
+
+ScSample::~ScSample()
+{
+DeleteDrawers();
+}
+
+
+
Index: /trunk/SophyaPI/PI/sc_sample.h
===================================================================
--- /trunk/SophyaPI/PI/sc_sample.h	(revision 111)
+++ /trunk/SophyaPI/PI/sc_sample.h	(revision 112)
@@ -2,4 +2,11 @@
 
 #include "piscdrawwdg.h"
+
+class ScSampleDrawer : PIDrawer {
+  public:
+  ScSampleDrawer();
+  virtual ~ScSampleDrawer();
+  virtual void       Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax); 
+};
 
 class ScSample : public PIScDrawWdg {
@@ -7,8 +14,6 @@
   ScSample(PIContainerGen *par, char *nom,
            int sx=10, int sy=10, int px=0, int py=0);
-  ~ScSample();
-
-  
-  virtual void DrawSelf(PIGraphicUC* g);
+  virtual ~ScSample();
 
 };
+
