Index: trunk/SophyaPI/PI/Makefile
===================================================================
--- trunk/SophyaPI/PI/Makefile	(revision 7)
+++ trunk/SophyaPI/PI/Makefile	(revision 8)
@@ -77,14 +77,10 @@
 #------------------------------------------------- End of Makefile.h ------- 
  
-all: $(LIB)libPI.a $(SLB)libPI.so $(EXE)pitest
-$(LIB)libPI.a : $(OBJ)ex_dessin.o $(OBJ)piapplgen.o $(OBJ)piapplx.o $(OBJ)pibwdggen.o $(OBJ)pibwdgx.o $(OBJ)picmap.o $(OBJ)picmapgen.o $(OBJ)picmapx.o $(OBJ)picontainergen.o $(OBJ)picontainerx.o $(OBJ)pifilechogen.o $(OBJ)pifilechox.o $(OBJ)piimage.o $(OBJ)pimenubargen.o $(OBJ)pimenubarx.o $(OBJ)pimenugen.o $(OBJ)pimenux.o $(OBJ)pimsghandler.o $(OBJ)pioptmenugen.o $(OBJ)pioptmenux.o $(OBJ)pipixmapgen.o $(OBJ)pipixmapx.o $(OBJ)pistdwdggen.o $(OBJ)pistdwdgx.o $(OBJ)piwdggen.o $(OBJ)piwdgx.o $(OBJ)piwdgxt.o $(OBJ)piwindowgen.o $(OBJ)piwindowx.o $(OBJ)pixtbase.o
+all: $(LIB)libPI.a $(SLB)libPI.so 
+$(LIB)libPI.a : $(OBJ)ex_dessin.o $(OBJ)piapplgen.o $(OBJ)piapplx.o $(OBJ)pibwdggen.o $(OBJ)pibwdgx.o $(OBJ)picmap.o $(OBJ)picmapgen.o $(OBJ)picmapx.o $(OBJ)picontainergen.o $(OBJ)picontainerx.o $(OBJ)pidrawwin.o $(OBJ)pifilechogen.o $(OBJ)pifilechox.o $(OBJ)pihisto.o $(OBJ)piimage.o $(OBJ)pimenubargen.o $(OBJ)pimenubarx.o $(OBJ)pimenugen.o $(OBJ)pimenux.o $(OBJ)pimsghandler.o $(OBJ)pioptmenugen.o $(OBJ)pioptmenux.o $(OBJ)pipixmapgen.o $(OBJ)pipixmapx.o $(OBJ)piscdrawwdg.o $(OBJ)pistdwdggen.o $(OBJ)pistdwdgx.o $(OBJ)piwdggen.o $(OBJ)piwdgx.o $(OBJ)piwdgxt.o $(OBJ)piwindowgen.o $(OBJ)piwindowx.o $(OBJ)pixtbase.o $(OBJ)sc_sample.o
 	ar -rs $@ $?
  
 $(SLB)libPI.so : $(LIB)libPI.a
 	ld -S -shared -o $(SLB)libPI.so -all -L$(LIB) $(LIB)libPI.a 2>/dev/null
-
-$(EXE)pitest : $(OBJ)pitestapp.o
-	g++ -o $(EXE)pitest $(OBJ)pitestapp.o -L$(LIB) -lPI -lImages -lOutils -lmath -lXm -lXt -lX11 -lm
-
 $(OBJ)ex_dessin.o: ex_dessin.cc ex_dessin.h pisysdep.h pibwdgx.h pibwdggen.h \
  piwdgx.h piwdggen.h pimsghandler.h
@@ -107,4 +103,7 @@
 $(OBJ)picontainerx.o: picontainerx.cc picontainerx.h pisysdep.h \
  picontainergen.h piwdgx.h piwdggen.h pimsghandler.h
+$(OBJ)pidrawwin.o: pidrawwin.cc pidrawwin.h pisysdep.h piwindowx.h \
+ piwindowgen.h picontainerx.h picontainergen.h piwdgx.h piwdggen.h \
+ pimsghandler.h piscdrawwdg.h pibwdgx.h pibwdggen.h
 $(OBJ)pifilechogen.o: pifilechogen.cc pifilechogen.h pisysdep.h piwdgx.h \
  piwdggen.h pimsghandler.h
@@ -112,4 +111,11 @@
  piwdgx.h piwdggen.h pimsghandler.h piwindowx.h piwindowgen.h \
  picontainerx.h picontainergen.h
+$(OBJ)pihisto.o: pihisto.cc pihisto.h piscdrawwdg.h pisysdep.h pibwdgx.h \
+ pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h \
+ $(INC)histos.h $(INC)peida.h \
+ $(INC)defs.h $(INC)utils.h \
+ $(INC)machine.h \
+ $(INC)perrors.h \
+ $(INC)exceptions.h
 $(OBJ)piimage.o: piimage.cc piimage.h $(INC)cimage.h \
  $(INC)rzimage.h \
@@ -133,9 +139,10 @@
  piwdggen.h pimsghandler.h
 $(OBJ)pimsghandler.o: pimsghandler.cc pimsghandler.h
-$(OBJ)pioptmenugen.o: pioptmenugen.cc pioptmenugen.h pisysdep.h piwdgx.h \
- piwdggen.h pimsghandler.h pimenux.h pimenugen.h
+$(OBJ)pioptmenugen.o: pioptmenugen.cc pioptmenugen.h pisysdep.h \
+ picontainerx.h picontainergen.h piwdgx.h piwdggen.h pimsghandler.h \
+ pimenux.h pimenugen.h
 $(OBJ)pioptmenux.o: pioptmenux.cc pisysdep.h pioptmenux.h pioptmenugen.h \
- piwdgx.h piwdggen.h pimsghandler.h pimenux.h pimenugen.h \
- picontainerx.h picontainergen.h
+ picontainerx.h picontainergen.h piwdgx.h piwdggen.h pimsghandler.h \
+ pimenux.h pimenugen.h pistdwdgx.h pistdwdggen.h
 $(OBJ)pipixmapgen.o: pipixmapgen.cc pipixmapgen.h pisysdep.h pibwdgx.h \
  pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h picmap.h picmapx.h \
@@ -144,4 +151,15 @@
  pibwdgx.h pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h picmap.h \
  picmapx.h picmapgen.h
+$(OBJ)piscdrawwdg.o: piscdrawwdg.cc piscdrawwdg.h pisysdep.h pibwdgx.h \
+ pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h \
+ $(INC)generalfit.h \
+ $(INC)exceptions.h \
+ $(INC)defs.h $(INC)matrix.h \
+ $(INC)peida.h $(INC)utils.h \
+ $(INC)machine.h \
+ $(INC)perrors.h \
+ $(INC)ppersist.h \
+ $(INC)pclassids.h \
+ $(INC)cvector.h
 $(OBJ)pistdwdggen.o: pistdwdggen.cc pistdwdggen.h pisysdep.h piwdgx.h \
  piwdggen.h pimsghandler.h
@@ -160,4 +178,43 @@
 $(OBJ)pixtbase.o: pixtbase.cc pixtbaseP.h pibwdgx.h pisysdep.h pibwdggen.h \
  piwdgx.h piwdggen.h pimsghandler.h pixtbase.h
+$(OBJ)sc_sample.o: sc_sample.cc sc_sample.h pisysdep.h piscdrawwdg.h \
+ pibwdgx.h pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h
+$(OBJ)pidemo.o: pidemo.cc pidemo.h pidemoup.h \
+ $(INC)perrors.h \
+ $(INC)exceptions.h \
+ $(INC)defs.h \
+ $(INC)fitsimage.h \
+ $(INC)cimage.h \
+ $(INC)rzimage.h \
+ $(INC)rzvect.h \
+ $(INC)machine.h \
+ $(INC)datatypes.h \
+ $(INC)fitsheader.h \
+ $(INC)fitskeys.h pisysdep.h piapplx.h piapplgen.h \
+ pimsghandler.h picontainerx.h picontainergen.h piwdgx.h piwdggen.h \
+ pimenubarx.h pimenubargen.h pimenux.h pimenugen.h piwindowx.h \
+ piwindowgen.h pioptmenux.h pioptmenugen.h pistdwdgx.h pistdwdggen.h \
+ pifilechox.h pifilechogen.h piimage.h $(INC)lut.h \
+ pipixmapx.h pipixmapgen.h pibwdgx.h pibwdggen.h picmap.h picmapx.h \
+ picmapgen.h pihisto.h piscdrawwdg.h \
+ $(INC)histos.h $(INC)peida.h \
+ $(INC)utils.h pidrawwin.h
+$(OBJ)pidemoup.o: pidemoup.cc  pidemoup.h \
+ $(INC)perrors.h \
+ $(INC)exceptions.h \
+ $(INC)defs.h \
+ $(INC)fitsimage.h \
+ $(INC)cimage.h \
+ $(INC)rzimage.h \
+ $(INC)rzvect.h \
+ $(INC)machine.h \
+ $(INC)datatypes.h \
+ $(INC)fitsheader.h \
+ $(INC)fitskeys.h \
+ $(INC)utils.h $(INC)peida.h 
+piapp : $(EXE)piapp 
+	
+$(EXE)piapp  : $(OBJ)pidemo.o $(OBJ)pidemoup.o $(LIB)libPI.a
+	g++ -o $(EXE)piapp $(OBJ)pidemo.o $(OBJ)pidemoup.o -L$(LIB) -lPI -lImages -lOutils -lmath -lXm -lXt -lX11 -lm
 
 $(OBJ)pitestapp.o: pitestapp.cc pisysdep.h piapplx.h piapplgen.h \
@@ -166,3 +223,15 @@
  piwindowgen.h pioptmenux.h pioptmenugen.h pistdwdgx.h pistdwdggen.h \
  pibwdgx.h pibwdggen.h pipixmapx.h pipixmapgen.h picmap.h picmapx.h \
- picmapgen.h pifilechox.h pifilechogen.h piimage.h ex_dessin.h
+ picmapgen.h pifilechox.h pifilechogen.h ex_dessin.h piimage.h \
+ $(INC)cimage.h \
+ $(INC)rzimage.h \
+ $(INC)rzvect.h \
+ $(INC)machine.h $(INC)defs.h \
+ $(INC)exceptions.h \
+ $(INC)perrors.h \
+ $(INC)datatypes.h $(INC)lut.h
+
+pitest : $(EXE)pitest
+	
+$(EXE)pitest  : $(OBJ)pitestapp.o $(LIB)libPI.a
+	g++ -o $(EXE)pitest $(OBJ)pitestapp.o -L$(LIB) -lPI -lImages -lOutils -lmath -lXm -lXt -lX11 -lm
Index: trunk/SophyaPI/PI/mkmfPI
===================================================================
--- trunk/SophyaPI/PI/mkmfPI	(revision 8)
+++ trunk/SophyaPI/PI/mkmfPI	(revision 8)
@@ -0,0 +1,62 @@
+#!/bin/csh
+# $Id: mkmfPI,v 1.1 1996-03-01 16:53:25 eros Exp $
+
+set libf='$(LIB)libPI.a'
+set slbf='$(SLB)libPI.so'
+
+rm -f Makefile
+
+echo "CC := gcc" >> Makefile
+echo "CXX := g++" >> Makefile
+
+cat ../Mgr/Makefile.h >> Makefile
+
+echo " " >> Makefile
+echo 'all:' $libf $slbf >> Makefile 
+
+set files = `ls -1 *.cc | grep -v mac | grep -v pipp | grep -v attach | grep -v app.cc`
+echo $files
+#  Ca ne marche pas - Reza 1/3/96  10H00
+# echo $libf ':' \
+#  `echo $files | sed -e 's/\.cc/.o/g' | sed -e 's/^/$(OBJ)/'` >> Makefile
+# echo $files | sed -e 's/\.cc/.o/g' | sed -e 's/^/$(OBJ)/' 
+set lstlo =   ( $libf ':' )
+foreach f ($files)
+  set lstlo = ( $lstlo \$\(OBJ\)$f:r.o )
+end
+echo $lstlo  >> Makefile
+echo '	ar -rs $@ $?' >> Makefile
+
+
+echo " " >> Makefile
+echo $slbf ':' $libf >> Makefile
+echo '	ld -S -shared -o '$slbf' -all -L$(LIB) '$libf' 2>/dev/null'>> Makefile 
+
+set inc = $EROSBASEREP/Include
+set incxx = $inc/CxxInc
+
+foreach f ( $files )
+  gcc -MM -I$inc -I$incxx $f  \
+       | sed -e 's/.*\.o/\$(OBJ)&/'  \
+       | sed -e 's?'$incxx/'?$(CXI)?g' \
+       | sed -e 's?'$inc/'?$(INC)?g' >> Makefile
+end
+
+foreach f ( *app.cc )
+  gcc -MM -I$inc -I$incxx $f  \
+       | sed -e 's/.*\.o/\$(OBJ)&/'  \
+       | sed -e 's?'$incxx/'?$(CXI)?g' \
+       | sed -e 's?'$inc/'?$(INC)?g' >> Makefile  
+
+  echo $f:r : '$(EXE)'$f:r >> Makefile
+  echo '	' >> Makefile
+
+  echo '$(EXE)'$f:r ' : $(OBJ)'$f:r.o >> Makefile
+  echo '	g++ -o $(EXE)'$f:r' $(OBJ)'$f:r'.o -L$(LIB) -lPI -lImages -lOutils -lmath -lXm -lXt -lX11 -lm' >> Makefile
+end
+
+
+
+
+
+
Index: trunk/SophyaPI/PI/pibwdggen.h
===================================================================
--- trunk/SophyaPI/PI/pibwdggen.h	(revision 7)
+++ trunk/SophyaPI/PI/pibwdggen.h	(revision 8)
@@ -51,4 +51,5 @@
   virtual void       SelFont(PIFontSize sz=PI_NormalSizeFont, 
                              PIFontAtt att=PI_RomanFont)                   = 0;
+  virtual void       SelFontSzPt(int npt=12, PIFontAtt att=PI_RomanFont)   = 0; 
   virtual void       SelLine(PILineAtt att=PI_NormalLine)                  = 0;
   virtual void       SelPointerShape(PIPointer ptr)                        = 0;
Index: trunk/SophyaPI/PI/pibwdgx.cc
===================================================================
--- trunk/SophyaPI/PI/pibwdgx.cc	(revision 7)
+++ trunk/SophyaPI/PI/pibwdgx.cc	(revision 8)
@@ -15,5 +15,8 @@
 
 /*  Variables globales pour modifier les GC  */
-static Font fnt[3][3];
+#define NMAXFONTSZ  5
+static Font fnt[NMAXFONTSZ][3];
+static int fntsz[NMAXFONTSZ] = {9,10,12,14,16};
+static  PIFontAtt fntatt[3] = { PI_RomanFont, PI_BoldFont, PI_ItalicFont }; 
 #define NMAXCOL  10
 static unsigned long colpix[NMAXCOL];
@@ -146,4 +149,6 @@
 void PIBaseWdgX::DrawBox(int x0, int y0, int dx, int dy)
 {
+if (dx < 0)  { x0 += dx;  dx = -dx; }
+if (dy < 0)  { y0 += dy;  dy = -dy; }
 XDrawRectangle(XtDisplay (XtWdg()), XtWindow(XtWdg()), 
                DefGC(), x0, y0, dx, dy);
@@ -154,4 +159,6 @@
 void PIBaseWdgX::DrawFBox(int x0, int y0, int dx, int dy)
 {
+if (dx < 0)  { x0 += dx;  dx = -dx; }
+if (dy < 0)  { y0 += dy;  dy = -dy; }
 XFillRectangle(XtDisplay (XtWdg()), XtWindow(XtWdg()), 
                DefGC(), x0, y0, dx, dy);
@@ -190,4 +197,25 @@
 XSetBackground(XtDisplay(XtWdg()), DefGC(), colpix[col]); 
 return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::SelFontSzPt(int npt, PIFontAtt att)
+{
+int dsz,i,isel, j;
+
+isel = 0;
+dsz = 9999;
+for(i=0; i<NMAXFONTSZ; i++)
+  {
+  j = npt - fntsz[i];   if (j < 0)  j = -j;
+  if (j < dsz)  {  isel = i; dsz = j; }
+  }
+
+j = 0;
+if (att & PI_RomanFont) j = 0;
+if (att & PI_BoldFont) j = 1;
+if (att & PI_ItalicFont) j = 2;
+
+SelectFont(isel, j);
 }
 
@@ -202,11 +230,11 @@
     break;
   case PI_NormalSizeFont:
-    i = 1;
+    i = 2;
     break;
   case PI_BigSizeFont:
-    i = 2;
+    i = 4;
     break;
   default:
-    i=0;
+    i=2;
     break;
   }
@@ -217,5 +245,14 @@
 if (att & PI_ItalicFont) j = 2;
 
-XSetFont(XtDisplay(XtWdg()), DefGC(), fnt[i][j]);
+SelectFont(i, j);
+}
+
+
+/* --Methode-- */
+void PIBaseWdgX::SelectFont(int isz, int jat)
+{
+mFAtt = fntatt[jat];
+mFSize = fntsz[isz];
+XSetFont(XtDisplay(XtWdg()), DefGC(), fnt[isz][jat]);
 return;
 }
@@ -402,5 +439,4 @@
 char buff[200];
 int i,j;
-int fsz[3]={10,12,14};
 
 if (fgbwdg)  return;
@@ -417,20 +453,20 @@
 
 /* Allocation des fonts */
-for (i=0; i<3; i++)
+for (i=0; i<NMAXFONTSZ; i++)
   {
-  sprintf(buff,"-*-helvetica-medium-r-normal-*-%d-*-*-*-*-*-ISO8859-1", fsz[i]);
+  sprintf(buff,"-*-helvetica-medium-r-normal-*-%d-*-*-*-*-*-ISO8859-1", fntsz[i]);
   fnt[i][0] = XLoadFont(mdsp, buff);
   if (fnt[i][0] == 0)  printf("PIBaseWdgX::Init: Pb font %s \n", buff);
-  sprintf(buff,"-*-helvetica-bold-r-normal-*-%d-*-*-*-*-*-ISO8859-1", fsz[i]);
+  sprintf(buff,"-*-helvetica-bold-r-normal-*-%d-*-*-*-*-*-ISO8859-1", fntsz[i]);
   fnt[i][1] = XLoadFont(mdsp, buff);
   if (fnt[i][0] == 0)  printf("PIBaseWdgX::Init: Pb font %s \n", buff);
-  sprintf(buff,"-*-helvetica-medium-o-normal-*-%d-*-*-*-*-*-ISO8859-1", fsz[i]);
+  sprintf(buff,"-*-helvetica-medium-o-normal-*-%d-*-*-*-*-*-ISO8859-1", fntsz[i]);
   fnt[i][2] = XLoadFont(mdsp, buff);
   if (fnt[i][0] == 0)  printf("PIBaseWdgX::Init: Pb font %s \n", buff);
   }
 
-for(i=0; i<3; i++)
+for(i=0; i<NMAXFONTSZ; i++)
   for(j=0; j<3; j++)
-    if (fnt[i][0] == 0) XLoadFont(mdsp, "fixed");
+    if (fnt[i][j] == 0) XLoadFont(mdsp, "fixed");
 
  
Index: trunk/SophyaPI/PI/pibwdgx.h
===================================================================
--- trunk/SophyaPI/PI/pibwdgx.h	(revision 7)
+++ trunk/SophyaPI/PI/pibwdgx.h	(revision 8)
@@ -36,4 +36,5 @@
   virtual void   SelFont(PIFontSize sz=PI_NormalSizeFont, 
                          PIFontAtt att=PI_RomanFont);
+  virtual void   SelFontSzPt(int npt=12, PIFontAtt att=PI_RomanFont);
   virtual void   SelLine(PILineAtt att=PI_NormalLine);
   virtual void   SelPointerShape(PIPointer ptr);
@@ -65,6 +66,9 @@
 protected:
   void           Init();
+  void           SelectFont(int isz, int jat);
 
   GC mDefGC;
+  PIFontAtt mFAtt;
+  int mFSize;
 };
 
Index: trunk/SophyaPI/PI/pidemo.cc
===================================================================
--- trunk/SophyaPI/PI/pidemo.cc	(revision 8)
+++ trunk/SophyaPI/PI/pidemo.cc	(revision 8)
@@ -0,0 +1,691 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "perrors.h"
+#include "fitsimage.h"
+
+#include "pidemo.h"
+#include "pidemoup.h"
+
+
+
+
+/* ........................................................... */
+/*                    Classe PIDemoApp                         */
+/* ........................................................... */
+
+/* --Methode-- */
+PIDemoApp::PIDemoApp(char *path)
+: PIApplication(300, 200)
+{
+for(int i=0; i<NMXIMG; i++)
+  { wpii[i] = NULL;  pii[i] = NULL;  img[i] = NULL; }
+mNimg = 0;   mCur = NULL;
+mState = 0;
+
+m[0] = new PIPDMenu((PIMsgHandler *)Menubar(),"File");
+m[0]->AppendItem("Open", 10101);
+m[0]->AppendItem("Close", 10102);
+m[0]->AppendItem("Save", 10103);
+m[0]->AppendItem("Exit", 10104);
+
+m[1] = new PIPDMenu((PIMsgHandler *)Menubar(),"Image");
+m[1]->AppendItem("Lut...", 10201);
+m[1]->AppendItem("Size*1", 10202);
+m[1]->AppendItem("Expand*2", 10203);
+m[1]->AppendItem("Compress*2", 10204);
+m[1]->AppendItem("Expand*4", 10205);
+m[1]->AppendItem("Compress*4", 10206);
+
+m[2] = new PIPDMenu((PIMsgHandler *)Menubar(),"Operation");
+m[2]->AppendItem("UserProc-1", 10301);
+m[2]->AppendItem("UserProc-2", 10302);
+m[2]->AppendItem("UserProc-3", 10303);
+m[2]->AppendItem("PixelHisto", 10304);
+m[2]->AppendItem("PrintLut", 10305);
+m[2]->AppendItem("CheckDyn", 10306);
+
+AppendMenu(m[0]);
+AppendMenu(m[1]);   
+AppendMenu(m[2]);
+
+zoom = new PIPixmap(this->MainWin(), "Zoom", 120,120,10,10);
+labimg = new PILabel(this->MainWin(), "PixelValue", 280, 25, 10, 150);
+labimg->SetLabel("");
+
+draw = new PIDrawWindow(this, "histo", PIWK_normal, 300, 300, 300, 300);
+pixelHisto = new Histo(0,2000, 200);
+draw->AddDrawer(piHisto=new PIHisto(pixelHisto));
+
+// lab =  new PILabel(this->MainWin(), "State", 60, 20, 150, 10);
+// lab->SetBorderWidth(1);
+ 
+olb[0] = new PILabel(this->MainWin(), "AutoLut :", 60, 25, 140, 30);
+pum[0] = new PIPUMenu((PIMsgHandler *)this, "AutoLut");
+pum[0]->AppendItem("+3 Sig", 20303);
+pum[0]->AppendItem("+2 Sig", 20302);
+pum[0]->AppendItem("+1 Sig", 20301);
+pum[0]->AppendItem("-1 Sig", 20299);
+pum[0]->AppendItem("-2 Sig", 20298);
+opm[0] = new PIOptMenu(this->MainWin(), pum[0], 80, 25, 210, 30);
+opm[0]->SetValue(20302);
+
+olb[1] = new PILabel(this->MainWin(), "Zoom :", 60, 25, 140, 70);
+pum[1] = new PIPUMenu((PIMsgHandler *)this, "Zoom");
+pum[1]->AppendItem("Agr. * 5", 20105);
+pum[1]->AppendItem("Agr. * 4", 20104);
+pum[1]->AppendItem("Agr. * 3", 20103);
+pum[1]->AppendItem("Agr. * 2", 20102);
+pum[1]->AppendItem("* 1", 20101);
+pum[1]->AppendItem("Red. / 2", 20098);
+pum[1]->AppendItem("Red. / 3", 20097);
+pum[1]->AppendItem("Red. / 4", 20096);
+pum[1]->AppendItem("Red. / 5", 20095);
+opm[1] = new PIOptMenu(this->MainWin(), pum[1], 80, 25, 210, 70);
+opm[1]->SetValue(20101);
+
+olb[2] = new PILabel(this->MainWin(), "ColMap :", 60, 25, 140, 110);
+pum[2] = new PIPUMenu((PIMsgHandler *)this, "ColMap");
+pum[2]->AppendItem("Grey32", 20201);
+pum[2]->AppendItem("GreyInv32", 20202);
+pum[2]->AppendItem("ColRJ32", 20203);
+pum[2]->AppendItem("ColBR32", 20204);
+pum[2]->AppendItem("ColRV32", 20205);
+opm[2] = new PIOptMenu(this->MainWin(), pum[2], 80, 25, 210, 110);
+opm[2]->SetValue(20203);
+
+pfc = new PIFileChooser(this,"FileChooser", 5000); 
+if (path)
+  pfc->SetPath(path);
+
+
+mLutw = new LutWind(this);
+mUP = new UserProcWind(this);
+
+SetReady();
+}
+
+/* --Methode-- */
+PIDemoApp::~PIDemoApp()
+{
+int i;
+for(i=0; i<3; i++)
+  { 
+  delete m[i];
+  delete opm[i];
+  delete pum[i];
+  delete olb[i];
+  }
+delete pfc;
+delete lab;
+
+for(i=0; i<mNimg; i++)
+  {  
+  delete pii[i];
+  delete img[i];
+  delete wpii[i];
+  }
+
+delete zoom;
+delete labimg;
+
+delete draw;
+delete pixelHisto;
+delete piHisto;
+
+delete mLutw;
+delete mUP;
+
+}  
+
+/* --Methode-- */
+void PIDemoApp::Process(long msg, PIMsgHandler* sender, void* data)
+{
+CMapId cmap[5] = { CMAP_GREY32, CMAP_GREYINV32, CMAP_COLRJ32, 
+                   CMAP_COLBR32, CMAP_COLRV32 } ;
+
+
+if  ((mState != 0) && (msg > 9999)) { PIBeep(); return; }
+
+
+if ( (msg > 20000)  && (CurrentPIImage()) )
+  {
+  msg -= 20000;
+  if ((msg < 110) && (msg > 90))  // Zoom
+    CurrentPIImage()->SetZoom(msg-100);
+  else if ((msg > 200) && (msg < 206)) // Changement de couleur 
+    CurrentPIImage()->SetColMap(cmap[msg-201]);
+  else if ((msg > 290) && (msg < 310))
+    CurrentPIImage()->SetLut( CurrentImage()->minPix, CurrentImage()->maxPix,
+                               kLutType_Lin, msg-300);
+  }
+
+else
+  {
+  switch (msg)
+    {
+    case  PIMsg_ActiveWindow :
+      mCur = (PIImage *)sender;
+      break;
+
+    case 10101 :
+      pfc->AcceptNewFile(false); 
+      pfc->SetMsg(5101);
+      SetBlocked();
+      pfc->Show();
+      break;
+
+    case 10102 :
+      CloseCurrent();
+      break;
+        
+    case 10103 :
+      pfc->AcceptNewFile(true); 
+      pfc->SetMsg(5103);
+      SetBlocked();
+      pfc->Show();
+      break;
+
+    case 10104:
+      Stop();
+      break;
+
+    case 5101 :
+      if (data)  OpenImage(pfc->GetFileName());
+      SetReady();
+      break;
+
+    case 5103 :
+      if (data)  SaveCurrent(pfc->GetFileName());
+      SetReady();
+      break;      
+
+    case 10201 :
+      if ( CurrentPIImage() )  mLutw->Show();
+      break;
+
+    case 10202 :
+      if ( CurrentPIImage()) 
+        {
+        CurrentPIImage()->SetZoom(1);
+        CurrentPIImage()->SetOffset(0, 0);
+        CurrentImgWin()->SetSize(CurrentImage()->XSize(), 
+                                  CurrentImage()->YSize());
+        }
+      break;
+
+    case 10203 :
+      if ( CurrentPIImage()) 
+        {
+        CurrentPIImage()->SetZoom(2);
+        CurrentPIImage()->SetOffset(0, 0);
+        CurrentImgWin()->SetSize(CurrentImage()->XSize()*2, 
+                                  CurrentImage()->YSize()*2);
+        }
+      break;
+
+    case 10204 :
+      if ( CurrentPIImage()) 
+        {
+        CurrentPIImage()->SetZoom(-2);
+        CurrentPIImage()->SetOffset(0, 0);
+        CurrentImgWin()->SetSize(CurrentImage()->XSize()/2, 
+                                  CurrentImage()->YSize()/2);
+        }
+      break;
+       
+    case 10205 :
+      if ( CurrentPIImage()) 
+        {
+        CurrentPIImage()->SetZoom(4);
+        CurrentPIImage()->SetOffset(0, 0);
+        CurrentImgWin()->SetSize(CurrentImage()->XSize()*4, 
+                                  CurrentImage()->YSize()*4);
+        }
+      break;
+
+    case 10206 :
+      if ( CurrentPIImage()) 
+        {
+        CurrentPIImage()->SetZoom(-4);
+        CurrentPIImage()->SetOffset(0, 0);
+        CurrentImgWin()->SetSize(CurrentImage()->XSize()/4, 
+                                  CurrentImage()->YSize()/4);
+        }
+      break;
+       
+
+    case 10301:
+    case 10302:
+    case 10303:
+      if ( CurrentPIImage() )
+        {
+        SetBlocked();
+        mUP->SelectUP(msg-10300);
+        mUP->Show();
+        }
+      break;
+      
+    case 10304:
+      pixelHisto->Zero();
+      for (int i=0; i<CurrentImage()->XSize(); i++)
+        for (int j=0; j<CurrentImage()->YSize(); j++)
+          pixelHisto->Add((*CurrentImage())(i,j));
+      piHisto->Refresh();
+      draw->Show();
+      break;
+
+    case 10305:
+      if ( CurrentPIImage() )
+        (CurrentPIImage()->Lut())->Print();
+      break;
+
+    case 10306:
+      if ( CurrentPIImage() )
+        {
+        SetBusy();
+        CurrentImage()->CheckDyn();
+        CurrentImage()->Print();
+        SetReady();
+        }
+      break;
+
+              
+    }
+  }
+}
+
+/* --Methode-- */
+void PIDemoApp::SetBusy()
+{
+mState = 2;
+// lab->SetLabel("Working ...");
+}
+
+/* --Methode-- */
+void PIDemoApp::SetReady()
+{
+mState = 0;
+// lab->SetLabel("**Ready**");
+}
+
+/* --Methode-- */
+void PIDemoApp::SetBlocked()
+{
+mState = 1;
+// lab->SetLabel("--Dialog--");
+}
+
+/* --Methode-- */
+void PIDemoApp::OpenImage(string const & flnm)
+{
+char buff[128];
+char * pn;
+int i,j,k;
+bool ok = true;
+FitsImageR4 * myimg;
+
+if (mNimg >= NMXIMG)
+  {
+  printf("PIDemoApp::OpenImage_Error Two many images (%d) opened ...\n",mNimg);
+  printf("   Close some of the images ... ");
+  return;
+  }
+
+pn = (char *)flnm.c_str();
+printf("PIDemoApp::OpenImage Opening file %s \n", pn);
+
+if ((k=strchr(pn, '.')-pn) < 0)  k = strlen(pn);
+k--;
+if (k < 0)  {printf("PIDemoApp::OpenImage_Error \n"); return;}
+
+for(j=k; j>=0; j--)
+  if (pn[j] == FILESEP)  break;
+for(i=j+1; i<=k; i++)  buff[i-j-1] = pn[i];  
+buff[i-j-1] = '\0';
+printf("PIDemoApp::OpenImage ImageName= %s \n", buff);
+
+TRY{
+  myimg = new FitsImageR4();
+  myimg->Read(flnm);
+}  CATCH(merr) 
+  { printf("PIDemoApp::OpenImage_Error Exception= %d (%s) \n", merr, PeidaExc(merr)); 
+  ok = false; } ENDTRY;
+if (ok)
+  {
+  string s(buff);
+  AddImage(myimg, s);
+  }
+}
+
+/* --Methode-- */
+void PIDemoApp::AddImage(FitsImageR4 * nouv, string const & name)
+{
+int nimg = mNimg;
+int sx, sy;
+
+if (nouv == NULL)
+  {
+  printf("PIDemoApp::AddImage_Error  Cannot Add NULL image \n");
+  return;
+  }
+if (mNimg >= NMXIMG)
+  {
+  printf("PIDemoApp::AddImage_Error Two many images (%d) opened ...\n",mNimg);
+  printf("   Close some of the images ... ");
+  return;
+  }
+
+img[nimg] = nouv;
+if ( (img[nimg]->XSize() <= 0)  || (img[nimg]->YSize() <= 0))
+  {
+  printf("PIDemoApp::OpenImage_Error Pb lecture (FitsImage::Read) \n");
+  return;
+  }
+
+sx = img[nimg]->XSize();  sy = img[nimg]->YSize();
+if (sx > 512) sx = 512;
+if (sy > 512) sy = 512;
+
+wpii[nimg] = new PIWindow(this, (char *)name.c_str(), PIWK_normal, 
+                          sx, sy, 200, 200);
+pii[nimg] = new PIImage(wpii[nimg], (char *)name.c_str(), sx, sy, 0, 0);
+pii[nimg]->SetBinding(true, true, true, true);
+pii[nimg]->SetZoomWin(zoom);
+pii[nimg]->SetTextWin(labimg);
+pii[nimg]->SetImage(img[nimg]);
+// pii[nimg]->Apply();
+wpii[nimg]->Show();
+mCur = pii[nimg];
+mNimg++;
+return; 
+}
+
+/* --Methode-- */
+void PIDemoApp::CloseCurrent()
+{
+int n;
+if ((n=GetNumCurrent()) < 0)  return;
+wpii[n]->Hide();
+delete pii[n];
+delete img[n];
+delete wpii[n];
+zoom->EraseWindow();
+labimg->SetLabel("");
+pii[n] = pii[mNimg];
+wpii[n] = wpii[mNimg];
+img[n] = img[mNimg];
+mNimg--;
+mCur = NULL;
+return;
+}
+
+/* --Methode-- */
+void PIDemoApp::SaveCurrent(string const & flnm)
+{
+int n;
+if ((n=GetNumCurrent()) < 0)  return;
+
+if (strlen(flnm.c_str()) <= 0) 
+  { 
+  printf("PIDemoApp::SaveCurrent_Error: bad filename (%s) \n", flnm.c_str());
+  return;
+  }
+
+printf("PIDemoApp::SaveCurrent: Image %s saved to %s \n", 
+       (char *)pii[n]->Nom().c_str(), (char *)flnm.c_str());
+TRY {
+  img[n]->Save(flnm); 
+}  CATCH(merr) 
+  { printf("PIDemoApp::SaveCurrent_Error Exception= %d (%s) \n", merr, PeidaExc(merr));  } ENDTRY;
+return;
+}
+
+/* --Methode-- */
+int PIDemoApp::GetNumCurrent()
+{
+int n=-1;
+if (mNimg <= 0)  return(-1);
+for(int i=0; i<mNimg; i++)
+  if (mCur == pii[i])  { n = i; break; }
+
+if (n < 0)  
+  printf(" PIDemoApp::GetNumImg() Curret image not found (%lx)\n",(long)mCur);
+
+return(n);  
+}
+
+/* --Methode-- */
+FitsImageR4 * PIDemoApp::CurrentImage()
+{
+int n;
+n = GetNumCurrent();
+if (n < 0)  return(NULL);
+else return(img[n]);
+}
+
+/* --Methode-- */
+PIWindow * PIDemoApp::CurrentImgWin()
+{
+int n;
+n = GetNumCurrent();
+if (n < 0)  return(NULL);
+else return(wpii[n]);
+}
+
+/* ........................................................... */
+/*       Classe LutWind  (Changement de Lut d'image)           */
+/* ........................................................... */
+
+
+
+/* --Methode-- */
+LutWind::LutWind(PIDemoApp *par)
+: PIWindow((PIMsgHandler *)par, "ChangeLut", PIWK_dialog, 240, 220, 150, 150)
+{
+dap = par;
+
+mLab[0] = new PILabel(this, "MinPixel", 60, 30, 30, 20); 
+mLab[1] = new PILabel(this, "MaxPixel", 60, 30, 30, 60); 
+
+mText[0] = new PIText(this, "MinVal", 100, 30, 110, 20);
+mText[0]->SetText("1");
+mText[1] = new PIText(this, "MaxVal", 100, 30, 110, 60);
+mText[1]->SetText("32000");
+
+mOlb[0] = new PILabel(this, "LutType", 60, 25, 30, 100); 
+mPum[0] = new PIPUMenu((PIMsgHandler *)this, "LutType");
+mPum[0]->AppendItem("Linear", 1100);
+mPum[0]->AppendItem("Log.", 1101);
+mOpt[0] = new PIOptMenu(this, mPum[0], 100, 25, 110, 100);
+mOpt[0]->SetValue(1100);
+
+mOlb[1] = new PILabel(this, "AutoLut", 60, 25, 30, 135); 
+mPum[1] = new PIPUMenu((PIMsgHandler *)this, "AutoLut");
+mPum[1]->AppendItem("+3 Sig", 1203);
+mPum[1]->AppendItem("+2 Sig", 1202);
+mPum[1]->AppendItem("+1 Sig", 1201);
+mPum[1]->AppendItem("NoAuto", 1200);
+mPum[1]->AppendItem("-1 Sig", 1199);
+mPum[1]->AppendItem("-2 Sig", 1198);
+mPum[1]->AppendItem("-3 Sig", 1197);
+mOpt[1] = new PIOptMenu(this, mPum[1], 100, 25, 110, 135);
+mOpt[1]->SetValue(1202);
+
+mBut[0] = new PIButton(this, "Apply", 1500, 70, 30, 30, 170);
+mBut[1] = new PIButton(this, "Dismiss", 1600, 70, 30, 140, 170);
+
+FinishCreate();
+}
+
+/* --Methode-- */
+LutWind::~LutWind()
+{
+for(int i=0; i<2; i++)
+  {
+  delete mLab[i];
+  delete mBut[i];
+  delete mText[i];
+  delete mOpt[i];
+  delete mPum[i];
+  }
+}
+/* --Methode-- */
+void LutWind::Show()
+{
+char buff[32];
+PIImage *mpii;
+mpii = dap->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);
+mOpt[1]->SetValueStr("NoAuto");
+dap->SetBlocked();
+PIWindow::Show();
+return;
+}
+
+
+/* --Methode-- */
+void LutWind::Process(long msg, PIMsgHandler* sender, void* data)
+{
+float min, max;
+int lauto, typ;
+int typlut[2] = {kLutType_Lin, kLutType_Log} ; 
+
+switch (msg)
+  {
+  case 1600:
+    dap->SetReady();
+    this->Hide();
+    break;
+  case 1500:
+    if (dap->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;
+    (dap->CurrentPIImage())->SetLut(min, max, typlut[typ], lauto);
+//    ((dap->CurrentPIImage())->Lut())->Print();
+    break;
+  default:
+//    printf("LutWind::Process Msg %d received \n", (int)msg);
+    break;
+  }
+}
+
+
+/* ........................................................... */
+/*       Classe UserProcWindow  (Appel UserProc Function)      */
+/* ........................................................... */
+
+
+/* --Methode-- */
+UserProcWind::UserProcWind(PIDemoApp *par)
+: PIWindow((PIMsgHandler *)par, "UserProc", PIWK_dialog, 260, 200, 150, 150)
+{
+dap = par;
+mUpr = 0;
+
+mLab[0] = new PILabel(this, "OutImageName:", 100, 35, 20, 10); 
+mLab[1] = new PILabel(this, "UserArg(1):", 100, 35, 20, 55);
+mLab[2] = new PILabel(this, "UserArg(2):", 100, 35, 20, 100);
+ 
+mText[0] = new PIText(this, "OutName", 130, 35, 120, 10);
+mText[0]->SetText("ImgOut");
+mText[1] = new PIText(this, "UserArg1", 130, 35, 120, 55);
+mText[1]->SetText("");
+mText[2] = new PIText(this, "UserArg2", 130, 35, 120, 100);
+mText[2]->SetText("");
+
+mBut[0] = new PIButton(this, "Process", 2500, 70, 30, 30, 160);
+mBut[1] = new PIButton(this, "Cancel", 2600, 70, 30, 160, 160);
+FinishCreate();
+
+}
+
+/* --Methode-- */
+UserProcWind::~UserProcWind()
+{
+for(int i=0; i<3; i++)
+  {
+  delete mLab[i];
+  delete mText[i];
+  }
+
+delete mBut[0]; 
+delete mBut[1]; 
+}
+
+/* --Methode-- */
+void UserProcWind::Process(long msg, PIMsgHandler* sender, void* data)
+{
+FitsImageR4 *mimg, *oimg;
+int xp, yp;
+
+switch (msg)
+  {
+  case 2600:
+    dap->SetReady();
+    this->Hide();
+    break;
+
+  case 2500:
+    mimg = dap->CurrentImage();
+    if (mimg == NULL)  return;
+    xp = (dap->CurrentPIImage())->XPave();
+    yp = (dap->CurrentPIImage())->YPave();
+    dap->SetBusy();
+    this->Hide();
+    oimg = NULL;
+    switch (mUpr)
+      {
+      case 1 :
+        oimg = PIUserProc_1(mimg, xp, yp, 
+                            (char *) (mText[1]->GetText().c_str()), 
+                            (char *) (mText[2]->GetText().c_str()));
+        break;
+
+      case 2 :
+        oimg = PIUserProc_2(mimg, xp, yp, 
+                            (char *) (mText[1]->GetText().c_str()), 
+                            (char *) (mText[2]->GetText().c_str()));
+        break;
+
+      case 3 :
+        oimg = PIUserProc_3(mimg, xp, yp, 
+                            (char *) (mText[1]->GetText().c_str()), 
+                            (char *) (mText[2]->GetText().c_str()));
+        break;
+
+      }    
+    if (oimg)  dap->AddImage(oimg,mText[0]->GetText());
+    dap->SetReady();
+    break;
+  }
+    
+return;
+}
+
+// Le main  ....
+
+int main(int narg, char *arg[])
+{
+
+char *path;
+  
+if (narg > 1)  path = arg[1];
+else path = NULL;
+
+PIDemoApp app(path);
+
+app.Run();
+
+exit(0);
+}
Index: trunk/SophyaPI/PI/pidemo.h
===================================================================
--- trunk/SophyaPI/PI/pidemo.h	(revision 8)
+++ trunk/SophyaPI/PI/pidemo.h	(revision 8)
@@ -0,0 +1,100 @@
+#include <string.h>
+
+#include "pisysdep.h"
+
+#include PIAPP_H
+#include PIWIN_H 
+#include PIMENU_H 
+#include PIOPTMENU_H 
+#include PISTDWDG_H 
+
+#include PIFILECHO_H 
+
+#include "piimage.h"
+#include "pihisto.h"
+#include "pidrawwin.h"
+
+
+#define NMXIMG 15   // Nb maxi d'images ouvertes simultanement 
+
+class LutWind;
+class UserProcWind;
+
+class PIDemoApp : public PIApplication {
+public:
+     PIDemoApp(char *path);
+     ~PIDemoApp();
+
+     virtual void   Process(long msg, PIMsgHandler* sender, void* data=NULL);
+
+     void SetBusy();
+     void SetReady();
+     void SetBlocked();
+     void AddImage(FitsImageR4 * nouv, string const & name);
+     void OpenImage(string const & flnm);
+     void CloseCurrent();
+     void SaveCurrent(string const & flnm);
+     int GetNumCurrent();
+     inline PIImage * CurrentPIImage() { return (mCur); }
+     FitsImageR4 * CurrentImage();
+     PIWindow * CurrentImgWin();
+
+private:
+    PIPDMenu  *m[3];
+    PIPUMenu *pum[3];
+    PIOptMenu * opm[3];
+    PILabel *olb[3];
+    PIButton * but;
+    PIPixmap * zoom;
+    PILabel  * labimg, *lab;
+    PIFileChooser * pfc;
+
+    PIDrawWindow *  draw;
+    PIHisto    *    piHisto;
+    Histo*          pixelHisto;
+    PIWindow * wpii[NMXIMG];
+    PIImage *  pii[NMXIMG];
+    FitsImageR4 * img[NMXIMG];
+    int mNimg;
+    PIImage * mCur;
+    int mState;
+
+    LutWind * mLutw;
+    UserProcWind * mUP;
+    
+};
+
+class LutWind : public PIWindow {
+public :
+  LutWind(PIDemoApp *par);
+  ~LutWind();
+  virtual void  Show();
+  virtual void  Process(long msg, PIMsgHandler* sender, void* data=NULL);
+
+private:
+  PIDemoApp * dap;
+  PILabel * mLab[2];
+  PIButton * mBut[2];
+  PIText * mText[2];
+  PIPUMenu * mPum[2];
+  PIOptMenu * mOpt[2];
+  PILabel * mOlb[2];
+  
+};
+
+class UserProcWind : public PIWindow {
+public :
+                UserProcWind(PIDemoApp *par);
+                ~UserProcWind();
+  virtual void  Process(long msg, PIMsgHandler* sender, void* data=NULL);
+  void          SelectUP(int n) { mUpr = n; };
+
+private:
+  PIDemoApp * dap;
+  PILabel  * mLab[3];
+  PIButton * mBut[2];
+  PIText * mText[3];
+  int mUpr;
+  
+};
+
Index: trunk/SophyaPI/PI/pidemoup.cc
===================================================================
--- trunk/SophyaPI/PI/pidemoup.cc	(revision 8)
+++ trunk/SophyaPI/PI/pidemoup.cc	(revision 8)
@@ -0,0 +1,57 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "ctimer.h"
+#include "imageop.h"
+
+#include "pidemoup.h"
+
+FitsImageR4 * PIUserProc_1(FitsImageR4 * myimg, int xp, int yp, 
+                           char * arg1, char * arg2)
+{
+printf(" PIUserProc_1(%d %d %s %s)  Filtrage passe-bas 3*3 \n", xp, yp, arg1, arg2);
+ImageR4 filt(3,3);
+FitsImageR4 * out;
+
+// Definition du filtre passe-bas
+int i,j;
+for(i=0; i<3; i++)
+  for(j=0; j<3; j++)  filt(i,j) = 0.06;
+filt(1,1) = 0.52;
+
+filt.PrintPave();
+out = new FitsImageR4(myimg->XSize(), myimg->YSize());
+TIMEF ;
+FilterImage((ImageR4 *) myimg, (ImageR4 *)out, &filt); 
+return(out);
+}
+ 
+FitsImageR4 * PIUserProc_2(FitsImageR4 * myimg, int xp, int yp, 
+                           char * arg1, char * arg2)
+{
+printf(" PIUserProc_2(%d %d %s %s)  Ombre 3*3 \n", xp, yp, arg1, arg2);
+ImageR4 filt(3,3);
+FitsImageR4 * out;
+
+// Definition du filtre ombre
+int i,j;
+filt(0,0) = filt(1,1) = filt(2,2) = 0.;
+filt(0,1) = filt(1,2) = -1.;
+filt(1,0) = filt(2,1) = 1.;
+filt(0,2) = -2.;
+filt(2,0) = 2.;
+filt.PrintPave();
+out = new FitsImageR4(myimg->XSize(), myimg->YSize());
+TIMEF ;
+FilterImage((ImageR4 *) myimg, (ImageR4 *)out, &filt); 
+return(out);
+}
+ 
+FitsImageR4 * PIUserProc_3(FitsImageR4 * /*myimg*/, int xp, int yp, 
+                           char * arg1, char * arg2)
+{
+printf(" PIUserProc_3(%d %d %s %s) ne fait rien \n", xp, yp, arg1, arg2);
+return(NULL);
+}
+ 
Index: trunk/SophyaPI/PI/pidemoup.h
===================================================================
--- trunk/SophyaPI/PI/pidemoup.h	(revision 8)
+++ trunk/SophyaPI/PI/pidemoup.h	(revision 8)
@@ -0,0 +1,8 @@
+#include "fitsimage.h"
+
+FitsImageR4 * PIUserProc_1(FitsImageR4 * myimg, int xp, int yp, 
+                           char * arg1, char * arg2);
+FitsImageR4 * PIUserProc_2(FitsImageR4 * myimg, int xp, int yp, 
+                           char * arg1, char * arg2);
+FitsImageR4 * PIUserProc_3(FitsImageR4 * myimg, int xp, int yp, 
+                           char * arg1, char * arg2);
Index: trunk/SophyaPI/PI/pidrawwin.cc
===================================================================
--- trunk/SophyaPI/PI/pidrawwin.cc	(revision 8)
+++ trunk/SophyaPI/PI/pidrawwin.cc	(revision 8)
@@ -0,0 +1,28 @@
+#include "pidrawwin.h"
+
+PIDrawWindow::PIDrawWindow(PIMsgHandler* par, char *nom,
+                               PIWindowKind k, int sx, int sy, int px, int py)
+:PIWindow(par, nom, k, sx, sy, px, py)
+{
+   mDrawWdg = new PIScDrawWdg(this, "", sx-20, sy-20, 10, 10);
+   mDrawWdg->SetBinding(true, true, true, true);   
+}
+
+
+PIDrawWindow::~PIDrawWindow()
+{
+  delete mDrawWdg;
+}
+
+void
+PIDrawWindow::AddDrawer(PIScDrawer* d)
+{
+  mDrawWdg->AddDrawer(d);
+}
+
+void
+PIDrawWindow::SetAxesKind(int axesKind, int tickLevel, int markLevel)
+{
+  mDrawWdg->SetAxesKind(axesKind, tickLevel, markLevel);
+}
+
Index: trunk/SophyaPI/PI/pidrawwin.h
===================================================================
--- trunk/SophyaPI/PI/pidrawwin.h	(revision 8)
+++ trunk/SophyaPI/PI/pidrawwin.h	(revision 8)
@@ -0,0 +1,25 @@
+#ifndef PIDRAWWIN_H
+#define PIDRAWWIN_H
+
+// Une fenetre qui contient un drawwdg...
+
+#include "pisysdep.h"
+#include PIWIN_H
+#include "piscdrawwdg.h"
+
+class PIDrawWindow : public PIWindow {
+public:
+                 PIDrawWindow(PIMsgHandler* par, char *nom, 
+                                PIWindowKind k=PIWK_normal, int sx=10, int sy=10, 
+                                int px=0, int py=0);
+                ~PIDrawWindow();
+                
+ virtual void    AddDrawer(PIScDrawer*);                
+ virtual void    SetAxesKind(int axesChoice=1, int tickLevel=1, int markLevel=1);
+private:
+  PIScDrawWdg*   mDrawWdg;
+};
+
+
+
+#endif
Index: trunk/SophyaPI/PI/pifilechox.h
===================================================================
--- trunk/SophyaPI/PI/pifilechox.h	(revision 7)
+++ trunk/SophyaPI/PI/pifilechox.h	(revision 8)
@@ -34,4 +34,7 @@
 typedef PIFileChooserX     PIFileChooser ;
 
+#define FILESEP '/'
+
+
 #endif
 
Index: trunk/SophyaPI/PI/pihisto.cc
===================================================================
--- trunk/SophyaPI/PI/pihisto.cc	(revision 8)
+++ trunk/SophyaPI/PI/pihisto.cc	(revision 8)
@@ -0,0 +1,65 @@
+#include "pihisto.h"
+
+PIHisto::PIHisto(Histo* histo)
+: PIScDrawer(), mHisto(histo)
+{
+}
+
+PIHisto::~PIHisto()
+{
+}
+
+void
+PIHisto::AttachTo(PIScDrawWdg* wdg)
+{
+  PIScDrawer::AttachTo(wdg);
+  UpdateSize();
+}
+
+
+void
+PIHisto::UpdateSize()
+{
+  if (!mDrawWdg) return;
+  if (mDrawWdg->LimitsFixed()) return;
+  // Commencer par trouver nos limites
+  
+  double xmin = mHisto->XMin();
+  double xmax = (mHisto->XMax())*1.2;
+  double margeH = (xmax-xmin)/10;
+  xmin -= margeH;
+  xmax += margeH;
+
+  double ymax = (*mHisto)(mHisto->IMax());
+  double margeV = ymax / 10;
+  double ymin = -margeV;
+  ymax += margeV;
+  
+  mDrawWdg->SetLimits(xmin, xmax, ymin, ymax);
+  mDrawWdg->SetBBoxMargin(margeH, margeV);
+}
+
+
+void
+PIHisto::Draw()
+{
+  if (!mDrawWdg) return;
+  mDrawWdg->DrawBBox(1,2,1);
+  for (int i=0; i<mHisto->NBins(); i++) {
+		double left   = mHisto->BinLowEdge(i);
+		double width  = mHisto->BinWidth();
+		double bottom = 0;
+		double height = (*mHisto)(i);
+		mDrawWdg->ScDrawFBox(left,bottom,width,height);
+//		mDrawWdg->ScDrawLine(left, bottom, left, bottom + height);
+	}
+}
+
+void
+PIHisto::Refresh()
+{
+  if (!mDrawWdg) return;
+  mDrawWdg->FreeLimits();
+  UpdateSize();
+  mDrawWdg->Refresh();
+}
Index: trunk/SophyaPI/PI/pihisto.h
===================================================================
--- trunk/SophyaPI/PI/pihisto.h	(revision 8)
+++ trunk/SophyaPI/PI/pihisto.h	(revision 8)
@@ -0,0 +1,20 @@
+#ifndef PIHISTO_H
+#define PIHISTO_H
+
+
+#include "piscdrawwdg.h"
+#include "histos.h"
+
+class PIHisto : public PIScDrawer {
+public:
+                     PIHisto(Histo* histo);
+  virtual           ~PIHisto();
+  virtual void       Draw();
+  virtual void       Refresh();  // Recalcule les limites, et reaffiche
+protected:
+  Histo* mHisto;
+  virtual void       AttachTo(PIScDrawWdg*);
+  virtual void       UpdateSize();
+};
+
+#endif
Index: trunk/SophyaPI/PI/piimage.cc
===================================================================
--- trunk/SophyaPI/PI/piimage.cc	(revision 7)
+++ trunk/SophyaPI/PI/piimage.cc	(revision 8)
@@ -128,4 +128,15 @@
 }
 
+/* --Methode-- */
+void PIImage::SetOffset(int ox, int oy)
+{
+if (img == NULL)  {offx = offy = 0;  return; }
+if (ox < 0)  ox = 0;
+if (ox >= (img->XSize()-1))  ox = img->XSize()-2;
+if (oy < 0)  oy = 0;
+if (oy >= (img->YSize()-1))  oy = img->YSize()-2;
+offx = ox;  offy = oy;
+return;
+}
 
 /* --Methode-- */
Index: trunk/SophyaPI/PI/piimage.h
===================================================================
--- trunk/SophyaPI/PI/piimage.h	(revision 7)
+++ trunk/SophyaPI/PI/piimage.h	(revision 8)
@@ -50,4 +50,6 @@
   void SetZoom(int zm);
 
+  void SetOffset(int ox, int oy);
+
   virtual void SetColMap(CMapId cmap);
 
Index: trunk/SophyaPI/PI/pimenugen.h
===================================================================
--- trunk/SophyaPI/PI/pimenugen.h	(revision 7)
+++ trunk/SophyaPI/PI/pimenugen.h	(revision 8)
@@ -25,4 +25,5 @@
 
   virtual void    Show()=0;
+  virtual void    Show(PIWdg *w, int px, int py)=0;
   virtual void    Hide()=0;
 
Index: trunk/SophyaPI/PI/pimenux.cc
===================================================================
--- trunk/SophyaPI/PI/pimenux.cc	(revision 7)
+++ trunk/SophyaPI/PI/pimenux.cc	(revision 8)
@@ -24,8 +24,8 @@
 pim = (PIMenuX *) (cusd->pmen);
 
-// pim->Unmanage();
+// pim->Hide();
 pim->Send(cusd->msg, (void *)pim->ItemNameWdg(cusd->itb).c_str());
 #ifdef DEBUG_PIMenuX
-printf("%%%Debug_menub_action: Msg= %d  \n", (int)cusd->msg);
+printf("%%%Debug_menub_action: Msg= %d  %lx\n", (int)cusd->msg, (long)pim);
 #endif
 return;
@@ -144,7 +144,14 @@
 
 /* --Methode-- */
+void PIMenuX::Show(PIWdg *w, int px, int py)
+{
+Manage();
+}
+
+
+/* --Methode-- */
 void PIMenuX::Hide()
 {
-Unmanage();
+// Unmanage();
 }
 
@@ -318,12 +325,15 @@
 void PIPUMenuX::Show()
 {
+// XEvent  mevt;
 XButtonEvent evt;
 
+// XPeekEvent(PIXDisplay(), &mevt);
+// evt = mevt.xbutton; 
 evt.type = ButtonPress;
-evt.serial = 55998877;
-evt.send_event = False;
 evt.display = PIXDisplay();
 evt.window = XtWindow(PIXtTopWdg());
 evt.root = DefaultRootWindow(evt.display);
+evt.serial = 8866559909;
+evt.send_event = False;
 evt.same_screen = XQueryPointer(evt.display, evt.window, &(evt.root), 
                     &(evt.subwindow), &(evt.x_root), &(evt.y_root), 
@@ -340,4 +350,38 @@
 
 /* --Methode-- */
+void PIPUMenuX::Show(PIWdg *w, int px, int py)
+{
+// This method should only be used by a button press ...
+int xr, yr;
+Window cw, sw, rw;
+SysDWdg xtw;
+Display *dsp;
+XButtonEvent evt;
+
+xtw =  w->XtWdg();
+dsp = XtDisplay(xtw);
+sw = XtWindow(xtw);
+rw = DefaultRootWindow(dsp);
+XTranslateCoordinates(dsp, sw, rw, px, py, &xr, &yr, &cw);
+
+evt.type = ButtonPress;
+evt.display = dsp;
+evt.window = sw;
+evt.root = rw;
+evt.x_root = xr;
+evt.y_root = yr; 
+evt.x = px;
+evt.y = py;
+evt.serial = 8866559909;
+evt.send_event = False;
+evt.same_screen = True;
+XmMenuPosition(XtWdg(), &evt);
+// SetPos(xr, yr);
+Manage();
+return;    
+}
+
+
+/* --Methode-- */
 PIPDMenuX::PIPDMenuX(PIMsgHandler* par, char* nom)
 : PIMenuX(par, nom, k_PulldownMenu)
Index: trunk/SophyaPI/PI/pimenux.h
===================================================================
--- trunk/SophyaPI/PI/pimenux.h	(revision 7)
+++ trunk/SophyaPI/PI/pimenux.h	(revision 8)
@@ -33,4 +33,5 @@
 
   virtual void    Show();
+  virtual void   Show(PIWdg *w, int px, int py);
   virtual void    Hide();
 
@@ -55,8 +56,9 @@
 {
 public:
-               PIPUMenuX(PIMsgHandler* par, char* nom);
-               ~PIPUMenuX();
+                 PIPUMenuX(PIMsgHandler* par, char* nom);
+                 ~PIPUMenuX();
 
-virtual void   Show();
+  virtual void   Show();
+  virtual void   Show(PIWdg *w, int px, int py);
 
 protected:
@@ -67,6 +69,6 @@
 {
 public:
-               PIPDMenuX(PIMsgHandler* par, char* nom);
-               ~PIPDMenuX();
+                 PIPDMenuX(PIMsgHandler* par, char* nom);
+                 ~PIPDMenuX();
 
 protected:
Index: trunk/SophyaPI/PI/pimsghandler.h
===================================================================
--- trunk/SophyaPI/PI/pimsghandler.h	(revision 7)
+++ trunk/SophyaPI/PI/pimsghandler.h	(revision 8)
@@ -13,5 +13,6 @@
 	PIMsg_Help          = 4,
 	PIMsg_DataChanged   = 5,
-	PIMsg_Click         = 6
+	PIMsg_Click         = 6,
+        PIMsg_Press         = 7
 };
 
Index: trunk/SophyaPI/PI/pioptmenugen.cc
===================================================================
--- trunk/SophyaPI/PI/pioptmenugen.cc	(revision 7)
+++ trunk/SophyaPI/PI/pioptmenugen.cc	(revision 8)
@@ -2,7 +2,7 @@
 
 
-PIOptMenuGen::PIOptMenuGen(PIContainerGen* par, PIPDMenu *pdm, 
+PIOptMenuGen::PIOptMenuGen(PIContainerGen* par, PIPUMenu *pdm, 
                          int sx, int sy, int px, int py)
-: PIWdg(par, (char*) pdm->Nom().c_str(), sx, sy, px, py) // Attention au const !
+: PIContainer(par, (char*) pdm->Nom().c_str(), sx, sy, px, py) // Attention au const !
 {
 }
Index: trunk/SophyaPI/PI/pioptmenugen.h
===================================================================
--- trunk/SophyaPI/PI/pioptmenugen.h	(revision 7)
+++ trunk/SophyaPI/PI/pioptmenugen.h	(revision 8)
@@ -4,12 +4,12 @@
 #include <string>
 #include "pisysdep.h"
-#include PIWDG_H
+#include PICONT_H
 #include PIMENU_H
 
-class PIOptMenuGen : public PIWdg {
+class PIOptMenuGen : public PIContainer {
 public:
   enum {ClassId = 1100};
 
-	             PIOptMenuGen(PIContainerGen* par, PIPDMenu *pdm,
+	             PIOptMenuGen(PIContainerGen* par, PIPUMenu *pdm,
                                   int sx=10, int sy=10, int px=0, int py=0);
 	             ~PIOptMenuGen();
Index: trunk/SophyaPI/PI/pioptmenux.cc
===================================================================
--- trunk/SophyaPI/PI/pioptmenux.cc	(revision 7)
+++ trunk/SophyaPI/PI/pioptmenux.cc	(revision 8)
@@ -4,4 +4,5 @@
 #include "pioptmenux.h"
 #include PICONT_H
+#include PISTDWDG_H
 
 #include <Xm/Xm.h>
@@ -12,46 +13,19 @@
 
 /* --Methode-- */
-PIOptMenuX::PIOptMenuX(PIContainerGen* par, PIPDMenu *pdm,
+PIOptMenuX::PIOptMenuX(PIContainerGen* par, PIPUMenu *pum,
                      int sx, int sy, int px, int py)
-: PIOptMenuGen(par, pdm, sx, sy, px, py)
+: PIOptMenuGen(par, pum, sx-2, sy-2, px, py)
 {
-SysDWdg cb;
-
-XmString xmstr;
-xmstr = XmStringLtoRCreate(pdm->Nom().c_str(), XmSTRING_DEFAULT_CHARSET);
-
-Arg  warg[7];
-int n = 0;
-XtSetArg(warg[n], XmNsubMenuId, pdm->XtWdg());   n++;
-XtSetArg(warg[n],XmNlabelString, xmstr);    n++;
-XtSetArg(warg[n],XmNresizeWidth, FALSE);   n++;
-XtSetArg(warg[n],XmNresizeHeight, FALSE);   n++;
-if ((sx > 0) && (sy > 0)) 
-  {
-  XtSetArg(warg[n],XtNwidth,sx);   n++;  
-  XtSetArg(warg[n],XtNheight,sy);   n++;
-  }
-
-XtWdg() = XmCreateOptionMenu( par->XtWdg(), pdm->Nom().c_str(), warg, n); 
-wmis == k_wmi_normal ;
-stmng = 0;
-mMen = pdm;
-
-cb = XmOptionButtonGadget (XtWdg());
-XtSetArg(warg[0],XmNhighlightThickness, 0);
-XtSetValues(cb, warg, 1);
-if ((sx > 0) && (sy > 0)) 
-  {
-  cb = XmOptionLabelGadget (XtWdg());
-  XtSetArg(warg[0],XtNwidth,sx/2);   n++;  
-  XtSetArg(warg[1],XtNheight,sy);   n++;
-  XtSetValues(cb, warg, 2);
-  }
-
-SetPos(px,py);
-SetSize(sx, sy);
-SetBinding(false, false, false, false);
-
-mMen->SetMsgParent(this);
+sx -= 2;
+sy -= 2;
+SetBorderWidth(1); 
+// SetBinding(true, true, true, true);
+mAB = new PIButton(this, "?", 0, sy-2, sy-2, 1, 1);
+mAB->SetBinding(true, true, false, true);
+mAB->SetPressMsg(PIMsg_Press);
+mLab = new PILabel(this, "OptLabel", sx-sy-1, sy, sy+1, 0);
+mLab->SetBinding(true, true, true, true);
+mMen = pum;
+SetValue(mMen->ItemMsg(0));
 Manage();
 }
@@ -61,4 +35,6 @@
 PIOptMenuX::~PIOptMenuX()
 {
+delete mAB;
+delete mLab;
 }
 
@@ -66,7 +42,14 @@
 void PIOptMenuX::Process(long msg, PIMsgHandler* sender, void* data)
 {
-printf("PIOptMenuX::Process Msg= %d \n", (int)msg);
-Select((char *)data, msg);
-ReSend(msg, sender, data);
+// printf("PIOptMenuX::Process Msg= %d Sender= %lx \n", (int)msg, (long)sender);
+if ((sender == mAB) && (msg == PIMsg_Press))  
+  {  mMen->SetMsgParent(this);    mMen->Show(this, 0, YSize()); }
+else if (sender == mMen)
+  {
+  mAB->ReleaseButton();
+  SetValue(msg);
+  ReSend(msg, this, data);
+  }
+return;
 }
 
@@ -84,5 +67,5 @@
 mStext = s;
 mSmsg  = mMen->ItemMsg(n);
-
+mLab->SetLabel(mStext);
 return;
 }
@@ -100,5 +83,5 @@
 mStext = mMen->ItemName(n);
 mSmsg  = msg;
-
+mLab->SetLabel(mStext);
 return;
 }
Index: trunk/SophyaPI/PI/pioptmenux.h
===================================================================
--- trunk/SophyaPI/PI/pioptmenux.h	(revision 7)
+++ trunk/SophyaPI/PI/pioptmenux.h	(revision 8)
@@ -2,9 +2,11 @@
 #define PIOPTMENX_H_SEEN
 
+#include "pisysdep.h"
 #include "pioptmenugen.h"
+#include PISTDWDG_H
 
 class PIOptMenuX : public PIOptMenuGen {
 public:
-	            PIOptMenuX(PIContainerGen* par, PIPDMenu *pdm,  
+	            PIOptMenuX(PIContainerGen* par, PIPUMenu *pum,  
                                int sx=10, int sy=10, int px=0, int py=0);
 	            ~PIOptMenuX();
@@ -18,9 +20,9 @@
   
   
-  inline void       Select(char *txt, long msg) { mStext = txt;  mSmsg = msg; }
-
 
 protected:
-  PIPDMenu *mMen;
+  PIButton *mAB;
+  PILabel  *mLab;
+  PIPUMenu *mMen;
   string   mStext;
   long     mSmsg;
Index: trunk/SophyaPI/PI/piscdrawwdg.cc
===================================================================
--- trunk/SophyaPI/PI/piscdrawwdg.cc	(revision 8)
+++ trunk/SophyaPI/PI/piscdrawwdg.cc	(revision 8)
@@ -0,0 +1,447 @@
+#include "piscdrawwdg.h"
+#include "generalfit.h"
+#include <algo.h>
+
+
+PIScDrawWdg::PIScDrawWdg(PIContainerGen *par, char *nom,
+                         int sx, int sy, int px, int py)
+:PIBaseWdg(par, nom, sx, sy, px, py)
+{
+  SetLimits(-1, 1, -1, 1);
+  limitsFixed = 0;
+  xEndDrag = yEndDrag = xBegDrag = yBegDrag = 0;
+}
+
+PIScDrawWdg::~PIScDrawWdg()
+{
+  DeleteDrawers();
+}
+
+
+void
+PIScDrawWdg::SetLimits(double xmin, double xmax, 
+                       double ymin, double ymax, bool tmp)
+{
+  if (xmax <= xmin || ymax <= ymin)
+    return; // $CHECK$ exception ?
+  xMin = xmin;
+  xMax = xmax;
+  yMin = ymin;
+  yMax = ymax;
+  if (!tmp) {
+    xMinS = xmin;
+    xMaxS = xmax;
+    yMinS = ymin;
+    yMaxS = ymax;
+  }
+  CalcScale();
+  CalcTicks();
+  limitsFixed = 1;
+}
+
+void
+PIScDrawWdg::Resize()
+{
+  CalcScale();
+  CalcTicks();
+  Refresh();
+}
+
+void
+PIScDrawWdg::CalcScale()
+{
+  xScale = XSize() / (xMax-xMin);
+  yScale = -YSize() / (yMax-yMin);
+  xOrg   = -xMin * xScale + XPos();
+  yOrg   = -yMax * yScale + YPos();
+}
+
+void
+PIScDrawWdg::CalcTicks()
+{
+	double xExt = xMax-xMin;
+	int lx = (int) ceil(log10(xExt)-0.1);
+	xExt = pow(10.0,lx);
+	xMajTickStep = xExt/10;
+	xMinTickStep = xMajTickStep/10;
+    xFirstMajTick = int(xMin / xMajTickStep) * xMajTickStep;
+    if (xFirstMajTick < xMin) xFirstMajTick += xMajTickStep;
+    xFirstMinTick = int(xMin / xMinTickStep) * xMinTickStep;
+    if (xFirstMinTick < xMin) xFirstMinTick += xMinTickStep;
+    
+    
+	double yExt = yMax-yMin;
+	int ly = (int) ceil(log10(yExt)-0.1);
+	yExt = pow(10.0,ly);
+	yMajTickStep = yExt/10;
+	yMinTickStep = yMajTickStep/10;
+    yFirstMajTick = int(yMin / yMajTickStep) * yMajTickStep;
+    if (yFirstMajTick < yMin) yFirstMajTick += yMajTickStep;
+    yFirstMinTick = int(yMin / yMinTickStep) * yMinTickStep;
+    if (yFirstMinTick < yMin) yFirstMinTick += yMinTickStep;
+    
+    xMajTickLen = -2/yScale;
+    xMinTickLen = -1/yScale;
+    yMajTickLen = 2/xScale;
+    yMinTickLen = 1/xScale;
+}
+
+void
+PIScDrawWdg::Sc2Local(double x, double y, int& xpix, int& ypix)
+{
+  xpix = int(xOrg + x*xScale + .5);
+  ypix = int(yOrg + y*yScale + .5);
+}
+
+void
+PIScDrawWdg::Local2Sc(int xpix, int ypix, double& x, double& y)
+{
+  x = (xpix-xOrg)/xScale;
+  y = (ypix-yOrg)/yScale;
+}
+
+
+void
+PIScDrawWdg::DSc2Local(double dx, double dy, int& dxpix, int& dypix)
+{
+  dxpix = int(dx*xScale + .5);
+  dypix = int(dy*yScale + .5);
+}
+
+void
+PIScDrawWdg::ScDrawString(double x, double y, char* s, int pos)
+{
+  int xPix, yPix;
+  Sc2Local(x, y, xPix, yPix);
+  DrawString(xPix, yPix, s, pos);
+}
+
+void
+PIScDrawWdg::ScDrawLine(double x1, double y1, double x2, double y2)
+{
+  int x1Pix, y1Pix, x2Pix, y2Pix;
+  Sc2Local(x1, y1, x1Pix, y1Pix);
+  Sc2Local(x2, y2, x2Pix, y2Pix);
+  DrawLine(x1Pix, y1Pix, x2Pix, y2Pix);
+}  
+
+void
+PIScDrawWdg::ScDrawBox(double x, double y, double dx, double dy)
+{
+  int xPix, yPix, x2Pix, y2Pix;
+  Sc2Local(x, y, xPix, yPix);
+  Sc2Local(x+dx, y+dy, x2Pix, y2Pix);
+  DrawBox(xPix, yPix, x2Pix-xPix, y2Pix-yPix);
+}  
+
+void
+PIScDrawWdg::ScDrawFBox(double x, double y, double dx, double dy)
+{
+  int xPix, yPix, x2Pix, y2Pix;
+  Sc2Local(x, y, xPix, yPix);
+  Sc2Local(x+dx, y+dy, x2Pix, y2Pix);
+  DrawFBox(xPix, yPix, x2Pix-xPix, y2Pix-yPix);
+}  
+
+void
+PIScDrawWdg::ScDrawCircle(double x, double y, double r)
+{
+  int xPix, yPix, rPix;
+  Sc2Local(x, y, xPix, yPix);
+  rPix = r * xScale;
+  DrawCircle(xPix, yPix, rPix);
+}  
+
+void
+PIScDrawWdg::ScDrawFCircle(double x, double y, double r)
+{
+  int xPix, yPix, rPix;
+  Sc2Local(x, y, xPix, yPix);
+  rPix = r * xScale;
+  DrawFCircle(xPix, yPix, rPix);
+}  
+
+void
+PIScDrawWdg::DrawAxes(int tickLevel, int markLevel)
+{
+  // Les axes
+  
+  ScDrawLine(xMin, 0, xMax, 0);
+  ScDrawLine(0, yMin, 0, yMax);
+  
+  // Les ticks majeurs
+  
+  if (tickLevel > 0) {
+    for (double x=xFirstMajTick; x<=xMax; x += xMajTickStep)
+      ScDrawLine(x, -xMajTickLen, x, xMajTickLen);
+    for (double y=yFirstMajTick; y<=yMax; y += yMajTickStep)
+      ScDrawLine(-yMajTickLen, y, yMajTickLen, y);
+  }
+
+  // Les ticks mineurs
+  
+  if (tickLevel > 1) {
+    for (double x=xFirstMinTick; x<=xMax; x += xMinTickStep)
+      ScDrawLine(x, -xMinTickLen, x, xMinTickLen);
+    for (double y=yFirstMinTick; y<=yMax; y += yMinTickStep)
+      ScDrawLine(-yMinTickLen, y, yMinTickLen, y);
+  }
+
+
+}
+
+void
+PIScDrawWdg::SetBBoxMargin(double h, double v)
+{
+  bbmargeh = h;
+  bbmargev = v; 
+}
+
+void
+PIScDrawWdg::DrawBBox(int tickLevel, int tickFlags, int markLevel)
+{
+
+  double xLow = xMin + bbmargeh;
+  double xHig = xMax - bbmargeh;
+  double yLow = yMin + bbmargev;
+  double yHig = yMax - bbmargev;
+  
+  double extXMajTickLen = tickFlags&2 ? xMajTickLen : 0;
+  double intXMajTickLen = tickFlags&1 ? xMajTickLen : 0;
+  double extXMinTickLen = tickFlags&2 ? xMinTickLen : 0;
+  double intXMinTickLen = tickFlags&1 ? xMinTickLen : 0;
+  double extYMajTickLen = tickFlags&2 ? yMajTickLen : 0;
+  double intYMajTickLen = tickFlags&1 ? yMajTickLen : 0;
+  double extYMinTickLen = tickFlags&2 ? yMinTickLen : 0;
+  double intYMinTickLen = tickFlags&1 ? yMinTickLen : 0;
+  
+  
+  // Les bordures
+  
+  ScDrawLine(xLow, yLow, xHig, yLow);
+  ScDrawLine(xHig, yLow, xHig, yHig);
+  ScDrawLine(xHig, yHig, xLow, yHig);
+  ScDrawLine(xLow, yHig, xLow, yLow);
+  
+  // Les ticks majeurs
+  
+  if (tickLevel > 0) {
+    for (double x=xFirstMajTick; x<=xHig; x += xMajTickStep) {
+      ScDrawLine(x, yLow - extXMajTickLen, x, yLow + intXMajTickLen);
+      ScDrawLine(x, yHig + extXMajTickLen, x, yHig + intXMajTickLen);
+    }
+    for (double y=yFirstMajTick; y<=yHig; y += yMajTickStep) {
+      ScDrawLine(xLow - extYMajTickLen, y, xLow + intYMajTickLen, y);
+      ScDrawLine(xHig + extYMajTickLen, y, xHig - intYMajTickLen, y);
+    }
+  }
+  
+
+  // Les ticks mineurs
+  
+  if (tickLevel > 1) {
+    for (double x=xFirstMinTick; x<=xHig; x += xMinTickStep) {
+      ScDrawLine(x, yLow - extXMinTickLen, x, yLow + intXMinTickLen);
+      ScDrawLine(x, yHig + extXMinTickLen, x, yHig + intXMinTickLen);
+    }
+    for (double y=yFirstMinTick; y<=yHig; y += yMinTickStep) {
+      ScDrawLine(xLow - extYMinTickLen, y, xLow + intYMinTickLen, y);
+      ScDrawLine(xHig + extYMinTickLen, y, xHig - intYMinTickLen, y);
+    }
+  }
+  
+  // Les labels
+  if (markLevel > 0) {
+    for (double x=xFirstMajTick; x<=xHig; x += xMajTickStep) {
+      char label[20]; sprintf(label, "%-6g", x);
+      ScDrawString(x, yLow - 8 * xMajTickLen, label);
+      ScDrawString(x, yHig + 2 * xMajTickLen, label);
+    }
+    for (double y=yFirstMajTick; y<=yHig; y += yMajTickStep) {
+      char label[20]; sprintf(label, "%-6g", y);
+      ScDrawString(xLow - 8 * yMajTickLen, y, label);
+      ScDrawString(xHig + 2 * yMajTickLen, y, label);
+    }
+  }
+}
+
+void
+PIScDrawWdg::AddDrawer(PIScDrawer* d)
+{
+  mDrawers.push_back(d);
+  d->AttachTo(this);
+}
+
+void
+PIScDrawWdg::RemoveDrawer(PIScDrawer* d)
+{
+  mDrawers.remove(d);
+  d->mDrawWdg = NULL;
+}
+
+void
+PIScDrawWdg::DeleteDrawers()
+{
+  for(list<PIScDrawer*>::iterator i = mDrawers.begin(); i != mDrawers.end(); i++)
+    delete *i;
+    
+  mDrawers.erase(mDrawers.begin(),mDrawers.end());
+}
+
+void
+PIScDrawWdg::CallDrawer(PIScDrawer* d)
+{
+  d->Draw();
+}
+
+void
+PIScDrawWdg::CallDrawers()
+{
+  for_each(mDrawers.begin(), mDrawers.end(), CallDrawer);
+}
+
+void
+PIScDrawWdg::SetAxesKind(int axesKind, int tickLevel, int markLevel)
+{
+  axesChoice  = axesKind;
+  tickChoice  = tickLevel;
+  labelChoice = markLevel;
+}
+
+void
+PIScDrawWdg::Draw()
+{
+  EraseWindow();
+  if (axesChoice == 1)
+    DrawAxes(tickChoice, labelChoice);
+  else if (axesChoice == 2)
+    DrawBBox(tickChoice, labelChoice);
+  CallDrawers();
+}
+
+
+// Gestion du zoom
+
+void
+PIScDrawWdg::But2Press(int x, int y)
+{
+  SelPointerShape(PI_CrossPointer);
+  xEndDrag = xBegDrag = x;
+  yEndDrag = yBegDrag = y;
+  PIBeep();
+}
+
+void
+PIScDrawWdg::But2Release(int x, int y)
+{
+
+  SelPointerShape(PI_ArrowPointer);
+  SelForeground(PI_White);
+  DrawBox(xBegDrag, yBegDrag, xEndDrag-xBegDrag, yEndDrag-yBegDrag);
+  SelForeground(PI_Black);
+  
+  if (xBegDrag == xEndDrag || yBegDrag == yEndDrag)
+    SetLimits(xMinS, xMaxS, yMinS, yMaxS);
+  else {
+    double xl,yl,xh,yh;
+    Local2Sc(xBegDrag, yBegDrag, xl, yl);
+    Local2Sc(xEndDrag, yEndDrag, xh, yh);
+    if (xl > xh) swap(xl, xh);
+    if (yl > yh) swap(yl, yh);
+    SetLimits(xl,xh,yl,yh, true);
+  }
+  
+  Refresh();
+}
+
+void
+PIScDrawWdg::Ptr2Move(int x, int y)
+{
+  SelForeground(PI_White);
+  DrawBox(xBegDrag, yBegDrag, xEndDrag-xBegDrag, yEndDrag-yBegDrag);
+  xEndDrag = x;
+  yEndDrag = y;
+  SelForeground(PI_Black);
+  DrawBox(xBegDrag, yBegDrag, xEndDrag-xBegDrag, yEndDrag-yBegDrag);
+}
+
+//================================================================
+// PIScDrawer
+//================================================================
+
+PIScDrawer::PIScDrawer()
+: mDrawWdg(NULL)
+{}
+
+PIScDrawer::~PIScDrawer()
+{
+  if (mDrawWdg)
+    mDrawWdg->RemoveDrawer(this);
+}
+
+void
+PIScDrawer::AttachTo(PIScDrawWdg* wdg)
+{
+  if (mDrawWdg)
+    mDrawWdg->RemoveDrawer(this);
+  mDrawWdg = wdg;
+}
+
+
+
+//================================================================
+// PIScFuncDrawer
+//================================================================
+
+PIScFuncDrawer::PIScFuncDrawer(PIScFuncDrawer::FUNC f)
+: mFunc(f)
+{}
+
+PIScFuncDrawer::~PIScFuncDrawer()
+{
+}
+
+void
+PIScFuncDrawer::Draw()
+{
+  if (!mDrawWdg) return;
+  double xMax = mDrawWdg->XMax();
+  double xMin = mDrawWdg->XMin();
+  double yMax = mDrawWdg->YMax();
+  double yMin = mDrawWdg->YMin();
+  double xStep = (xMax - xMin)/100;
+  double xOld = xMin;
+  double yOld = mFunc(xMin);
+  for (double x = xMin+xStep; x<xMax; x+=xStep) {
+    double y = mFunc(x);
+    if (y>yMin && yOld>yMin && 
+        y<yMax && yOld<yMax) 
+           mDrawWdg->ScDrawLine(xOld, yOld, x, y);
+    xOld = x;
+    yOld = y;
+  }
+}
+
+//================================================================
+// PIScGFFDrawer
+//================================================================
+
+PIScGFFDrawer::PIScGFFDrawer(GeneralFitFunction* f)
+: mFunc(f), mNParms(f->NPar()), mParms(new double[mNParms])
+{}
+
+PIScGFFDrawer::~PIScGFFDrawer()
+{
+  delete[] mParms;
+}
+
+void
+PIScGFFDrawer::SetParms(double const*)
+{}
+
+
+void
+PIScGFFDrawer::Draw()
+{
+}
+
Index: trunk/SophyaPI/PI/piscdrawwdg.h
===================================================================
--- trunk/SophyaPI/PI/piscdrawwdg.h	(revision 8)
+++ trunk/SophyaPI/PI/piscdrawwdg.h	(revision 8)
@@ -0,0 +1,119 @@
+#ifndef PISCDRAWWDG_H
+#define PISCDRAWWDG_H
+
+
+#include "pisysdep.h"
+#include PIBWDG_H
+
+#include <list.h>
+
+class PIScDrawWdg : public PIBaseWdg {
+public:
+                     PIScDrawWdg(PIContainerGen *par, char *nom,
+                                   int sx=10, int sy=10, int px=0, int py=0);
+  virtual           ~PIScDrawWdg();
+
+  virtual void       SetLimits(double xmin, double xmax, double ymin, double ymax, bool tmp=false);
+  
+  virtual void       ScDrawString(double x, double y, char* s, int pos = 0);
+  virtual void       ScDrawLine(double x1, double y1, double x2, double y2);  
+  virtual void       ScDrawBox(double x0, double y0, double dx, double dy);
+  virtual void       ScDrawFBox(double x0, double y0, double dx, double dy);
+  virtual void       ScDrawCircle(double x0, double y0, double r);
+  virtual void       ScDrawFCircle(double x0, double y0, double r);
+
+  virtual void       DrawAxes(int tickLevel=1, int markLevel=1);
+  virtual void       DrawBBox(int tickLevel=1, int tickFlags=3, int markLevel=1);
+  virtual void       SetBBoxMargin(double h, double v);
+  
+  virtual void       Resize();
+  
+  virtual void       CalcTicks();
+  virtual void       CalcScale();
+  
+  virtual void       Sc2Local(double x, double y, int& xpix, int& ypix);
+  virtual void       Local2Sc(int xpix, int ypix, double& x, double& y);
+  virtual void       DSc2Local(double dx, double dy, int& dxpix, int& dypix);
+  
+  virtual void       Draw();
+  
+  friend class PIScDrawer;
+  virtual void       AddDrawer(PIScDrawer*);   // Ajoute un drawer
+  virtual void       RemoveDrawer(PIScDrawer*);  // Ote un drawer sans le detruire
+  virtual void       DeleteDrawers();            // Ote et detruit tous les drawers
+  static  void       CallDrawer(PIScDrawer*);
+  virtual void       CallDrawers();
+  virtual void       SetAxesKind(int axesChoice=1, int tickLevel=1, int markLevel=1);
+  
+  double XMin() const {return xMin;}
+  double XMax() const {return xMax;}
+  double YMin() const {return yMin;}
+  double YMax() const {return yMax;}
+  int    LimitsFixed() const {return limitsFixed;}
+  void   FreeLimits() {limitsFixed = 0;}
+  
+  
+  virtual void       But2Press(int x, int y);
+  virtual void       But2Release(int x, int y);
+  virtual void       Ptr2Move(int x, int y);
+  
+protected:
+  double xMin, xMax, yMin, yMax; // Valeurs en unites user
+  double xMinS, xMaxS, yMinS, yMaxS; // Sauvegarde pour zoom
+  double xOrg, yOrg;             // Position en pixels de (0.0, 0.0)
+  double xScale, yScale;         // Pixels par unites graphiques
+  double xFirstMajTick, xFirstMinTick;
+  double yFirstMajTick, yFirstMinTick;
+  double xMajTickStep, xMinTickStep;
+  double yMajTickStep, yMinTickStep;
+  double xMajTickLen,  xMinTickLen;
+  double yMajTickLen,  yMinTickLen;
+  
+  int limitsFixed;
+  int axesChoice, tickChoice, labelChoice;
+  double bbmargeh, bbmargev;
+  list<PIScDrawer*>   mDrawers;
+  
+  int xBegDrag, yBegDrag;
+  int xEndDrag, yEndDrag;
+};
+
+class PIScDrawer {
+public:
+                     PIScDrawer();
+  virtual           ~PIScDrawer();
+
+  virtual void       Draw() = 0;
+protected:
+  friend class       PIScDrawWdg;
+  virtual void       AttachTo(PIScDrawWdg*);
+  PIScDrawWdg*       mDrawWdg;
+};
+
+class PIScFuncDrawer : public PIScDrawer {
+public:
+  typedef double(*FUNC)(double);
+                     PIScFuncDrawer(FUNC);
+  virtual           ~PIScFuncDrawer();
+  
+  virtual void       Draw();
+protected:
+  FUNC               mFunc;
+};
+
+class GeneralFitFunction;
+class PIScGFFDrawer : public PIScDrawer {
+public:
+                     PIScGFFDrawer(GeneralFitFunction*);
+  virtual           ~PIScGFFDrawer();
+  
+  virtual void       Draw();
+  virtual void       SetParms(double const*);
+protected:
+  GeneralFitFunction* mFunc;
+  int                 mNParms;
+  double*             mParms;
+};
+
+
+#endif
Index: trunk/SophyaPI/PI/pistdwdggen.cc
===================================================================
--- trunk/SophyaPI/PI/pistdwdggen.cc	(revision 7)
+++ trunk/SophyaPI/PI/pistdwdggen.cc	(revision 8)
@@ -15,8 +15,10 @@
 
 PIButtonGen::PIButtonGen(PIContainerGen *par, char *nom, long msg,
-                         int sx, int sy, int px, int py)
+                         int sx, int sy, int px, int py, PIBtnSign bsgn)
 : PIWdg(par, nom, sx, sy, px, py)
 {
 SetMsg(msg);
+mPressMsg = 0;
+mSgn = bsgn;
 }
 
@@ -24,5 +26,9 @@
 {}
 
- 
+void PIButtonGen::SetPressMsg(long prmsg)
+{
+mPressMsg = prmsg;
+}
+
 /************* PIScaleGen ************/
 
Index: trunk/SophyaPI/PI/pistdwdggen.h
===================================================================
--- trunk/SophyaPI/PI/pistdwdggen.h	(revision 7)
+++ trunk/SophyaPI/PI/pistdwdggen.h	(revision 8)
@@ -17,18 +17,28 @@
 };
 
+//  Les differents types de boutons avec un signe dessus ... 
+enum PIBtnSign {  PIBtn_Label=0, PIBtn_ArrowUp=1, PIBtn_ArrowDown=2,  
+                                 PIBtn_ArrowLeft=3, PIBtn_ArrowRight=4 };
+
 class PIButtonGen : public PIWdg
 {
 public:
-  enum {ClassId = 1002};
+  enum {ClassId = 1010};
 
                      PIButtonGen(PIContainerGen* par, char* nom, long msg = PIMsg_Click,
-                                  int sx=10, int sy=10, int px=0, int py=0);
+                                 int sx=10, int sy=10, int px=0, int py=0,
+                                 PIBtnSign bsgn = PIBtn_Label);
   virtual           ~PIButtonGen();
 
   virtual long       kind() {return ClassId; }
-  
+
+  virtual void       SetPressMsg(long prmsg);
+  inline long        PressMsg() { return(mPressMsg); }  
+
 protected:
+  long mPressMsg;
+  PIBtnSign mSgn;
+};
 
-};
 
 class PITextGen : public PIWdg
@@ -36,5 +46,5 @@
 public:
 
-  enum {ClassId = 1003};
+  enum {ClassId = 1020};
 
   		     PITextGen(PIContainerGen* par, char* nom,
@@ -51,5 +61,5 @@
 {
 public:
-  enum {ClassId = 1004};
+  enum {ClassId = 1030};
 
                      PIScaleGen(PIContainerGen* par, char* nom, long msg = PIMsg_Click,
@@ -72,5 +82,5 @@
 public:
 
-  enum {ClassId = 1005};
+  enum {ClassId = 1040};
 
                      PICheckBoxGen(PIContainerGen* par, char* nom, 
Index: trunk/SophyaPI/PI/pistdwdgx.cc
===================================================================
--- trunk/SophyaPI/PI/pistdwdgx.cc	(revision 7)
+++ trunk/SophyaPI/PI/pistdwdgx.cc	(revision 8)
@@ -14,6 +14,10 @@
 : PILabelGen(par, nom, sx, sy, px, py)
 {
+Arg warg[2];
+
 CreateXtWdg(nom, xmLabelWidgetClass, NULL, sx, sy, px, py);
 SetBorderWidth(0);
+XtSetArg(warg[0], XmNrecomputeSize, FALSE);  
+XtSetValues(XtWdg(), warg, 1);
 Manage();
 }
@@ -26,7 +30,9 @@
 /************* PIButtonX ************/
 #include <Xm/PushB.h>
-
-// Fonction prive (CallBack)
+#include <Xm/ArrowB.h>
+
+// Fonctions privees (CallBack)
 static void button_action(Widget w, XtPointer *usd, XtPointer *calld);
+static void button_press(Widget w, XtPointer *usd, XmAnyCallbackStruct *calld);
 
 /* Nouvelle-Fonction */
@@ -39,12 +45,56 @@
 }
 
-/* --Methode-- */
-PIButtonX::PIButtonX(PIContainerGen *par, char *nom, long msg,
-                         int sx, int sy, int px, int py)
-: PIButtonGen(par, nom, msg, sx, sy, px, py)
-{
-CreateXtWdg(nom, xmPushButtonWidgetClass, NULL, sx, sy, px, py);
+/* Nouvelle-Fonction */
+void  button_press(Widget w, XtPointer *usd, XmAnyCallbackStruct *calld)
+{
+PIButtonX *pib;
+pib = (PIButtonX *) usd ;
+pib->Send(pib->PressMsg());
+pib->myevt = *(calld->event);
+pib->myevt.type = pib->myevt.xbutton.type = ButtonRelease;
+pib->myevt.xbutton.serial += 10;
+
+return;
+}
+
+
+/* --Methode-- */
+PIButtonX::PIButtonX(PIContainerGen *par, char *nom, long msg, 
+                     int sx, int sy, int px, int py, PIBtnSign bsgn)
+: PIButtonGen(par, nom, msg, sx, sy, px, py, bsgn)
+{
+
+Arg  warg[3];
+int n = 0;
+
+XtSetArg(warg[n],XmNhighlightThickness, 0);  n++;
+XtSetArg(warg[n], XmNrecomputeSize, FALSE);  n++;
+
+if (bsgn == PIBtn_Label)
+  CreateXtWdg(nom, xmPushButtonWidgetClass, NULL, sx, sy, px, py);
+else
+  {
+  CreateXtWdg(nom, xmArrowButtonWidgetClass, NULL, sx, sy, px, py);
+  switch (bsgn)
+    {
+    case PIBtn_ArrowUp :
+      XtSetArg(warg[n], XmNarrowDirection, XmARROW_UP);  n++;
+      break;
+    case PIBtn_ArrowDown :
+      XtSetArg(warg[n], XmNarrowDirection, XmARROW_DOWN);  n++;
+      break;
+    case PIBtn_ArrowLeft :
+      XtSetArg(warg[n], XmNarrowDirection, XmARROW_LEFT);  n++;
+      break;
+    case PIBtn_ArrowRight :
+      XtSetArg(warg[n], XmNarrowDirection, XmARROW_RIGHT);  n++;
+      break;
+    }
+  }
+
+XtSetValues(XtWdg(), warg, n);
 XtAddCallback(XtWdg(), XmNactivateCallback, 
               button_action, (XtPointer)this);
+SetBorderWidth(0);
 Manage();
 }
@@ -54,4 +104,27 @@
 {}
 
+/* --Methode-- */
+void PIButtonX::SetPressMsg(long prmsg)
+{
+if (PressMsg() == prmsg)  return; 
+    
+if ((PressMsg() != 0)  && (prmsg == 0) )   
+  XtRemoveCallback(XtWdg(), XmNarmCallback, 
+                   button_press, (XtPointer)this);
+else if (PressMsg() == 0)
+  XtAddCallback(XtWdg(), XmNarmCallback, 
+                button_press, (XtPointer)this);
+
+PIButtonGen::SetPressMsg(prmsg);
+
+return;
+}       
+
+/* --Methode-- */
+void PIButtonX::ReleaseButton()
+{
+XPutBackEvent(myevt.xbutton.display, &myevt);
+return;
+}
 
 
Index: trunk/SophyaPI/PI/pistdwdgx.h
===================================================================
--- trunk/SophyaPI/PI/pistdwdgx.h	(revision 7)
+++ trunk/SophyaPI/PI/pistdwdgx.h	(revision 8)
@@ -17,8 +17,14 @@
 {
 public:
-                     PIButtonX(PIContainerGen *par, char *nom, long msg=PIMsg_Click,
-                               int sx=10, int sy=10, int px=0, int py=0);
+                     PIButtonX(PIContainerGen *par, char *nom, long msg = PIMsg_Click,
+                               int sx=10, int sy=10, int px=0, int py=0,
+                               PIBtnSign bsgn = PIBtn_Label);
   virtual           ~PIButtonX();
 
+  virtual void       SetPressMsg(long prmsg);
+
+  void               ReleaseButton();   // Fonction a utiliser avec attention
+
+  XEvent myevt;   // Attention - Pour usage interne 
 };
 
Index: trunk/SophyaPI/PI/pitestapp.cc
===================================================================
--- trunk/SophyaPI/PI/pitestapp.cc	(revision 7)
+++ trunk/SophyaPI/PI/pitestapp.cc	(revision 8)
@@ -58,6 +58,6 @@
     PIScale * scl;
     PIPUMenu  * menu;
-    PIPDMenu * pdm;
-    PIOptMenu * opt, * opt2;
+    PIPUMenu * pum[2];
+    PIOptMenu * opt, * opt2, *opt3;
     PIPixmap * zoom;
     PILabel  * labimg;
@@ -118,5 +118,5 @@
   bouton = new PIButton(this->MainWin(), "OK", 66, 40, 25, 20, 120);
   bouton2 = new PIButton(this->MainWin(), "Image", 133, 40, 25, 80, 120);
-  bouton3 = new PIButton(this->MainWin(), "Test", 233, 40, 25, 140, 120);
+  bouton3 = new PIButton(this->MainWin(), "Test",  233, 40, 25, 140, 120);
   bouton4 = new PIButton(this->MainWin(), "Menu", 555, 40, 25, 200, 120);
   scl = new PIScale(this->MainWin(), "Scale", 88, 5, 45, 100, 20, 10, 150);
@@ -133,14 +133,24 @@
   menu->AppendItem("Check-33", 4433);
 
-  pdm = new PIPDMenu((PIMsgHandler *)this, "myMenu");
-  pdm->AppendItem("Linear", 5601);
-  pdm->AppendItem("Log.", 5602);
-  pdm->AppendItem("Sqrt", 5603);
-  pdm->AppendItem("Expon", 5604);
-  pdm->AppendItem("Polyn", 5605);
-
-  opt = new PIOptMenu(this->MainWin(), pdm, 80, 20, 110, 150);
+  pum[1] = new PIPUMenu((PIMsgHandler *)this,"Edit");
+  pum[1]->AppendItem("Copier", 80201);
+  pum[1]->AppendItem("Coller", 80202);
+  pum[1]->AppendItem("Couper", 80203);
+  pum[1]->AppendItem("Undo", 80204);
+  pum[1]->AppendItem("Select-All", 80205);
+
+  pum[0] = new PIPUMenu((PIMsgHandler *)this, "myMenu");
+  pum[0]->AppendItem("Linear", 5601);
+  pum[0]->AppendItem("Log.", 5602);
+  pum[0]->AppendItem("Sqrt", 5603);
+  pum[0]->AppendItem("Expon", 5604);
+  pum[0]->AppendItem("Polyn", 5605);
+
+  opt = new PIOptMenu(this->MainWin(), pum[0], 90, 25, 110, 150);
   opt->SetValueStr("Sqrt");
-  opt2 = new PIOptMenu(this->MainWin(), m[1], 80, 20, 150, 200);
+  opt2 = new PIOptMenu(this->MainWin(), pum[1], 90, 25, 150, 200);
+
+  opt3 = new PIOptMenu(this->MainWin(), pum[0], 80, 25, 110, 250);
+  opt3->SetValueStr("Linear");
 
 }
@@ -160,5 +170,6 @@
   delete opt;
   delete opt2;
-  delete pdm;
+  delete opt3;
+  delete pum[0];  delete pum[1]; 
   delete zoom;
   delete labimg;
Index: trunk/SophyaPI/PI/piwdggen.h
===================================================================
--- trunk/SophyaPI/PI/piwdggen.h	(revision 7)
+++ trunk/SophyaPI/PI/piwdggen.h	(revision 8)
@@ -56,5 +56,5 @@
 
 
-  
+void PIBeep();  
 
 #endif/* PIWDG_H_SEEN */
Index: trunk/SophyaPI/PI/piwdgx.cc
===================================================================
--- trunk/SophyaPI/PI/piwdgx.cc	(revision 7)
+++ trunk/SophyaPI/PI/piwdgx.cc	(revision 8)
@@ -33,4 +33,11 @@
 {
 return(dpy);
+}
+
+/* Nouvelle-Fonction */
+void PIBeep()
+{
+XBell(dpy, 0);
+return;
 }
 
Index: trunk/SophyaPI/PI/piwindowx.cc
===================================================================
--- trunk/SophyaPI/PI/piwindowx.cc	(revision 7)
+++ trunk/SophyaPI/PI/piwindowx.cc	(revision 8)
@@ -39,4 +39,19 @@
 
 /* --Methode-- */
+void PIWindowX::SetSize(int sx, int sy)
+{
+pwm->SetSize(sx, sy);
+return;
+}
+
+/* --Methode-- */
+void PIWindowX::SetPos(int px, int py)
+{
+pwm->SetPos(px, py);
+return;
+}
+
+
+/* --Methode-- */
 void PIWindowX::Show()
 {
Index: trunk/SophyaPI/PI/piwindowx.h
===================================================================
--- trunk/SophyaPI/PI/piwindowx.h	(revision 7)
+++ trunk/SophyaPI/PI/piwindowx.h	(revision 8)
@@ -14,6 +14,9 @@
   virtual void           SetBinding(bool left, bool top, bool right, bool bottom);
 
-  virtual void  Show();
-  virtual void  Hide();
+  virtual void           SetSize(int sx, int sy);
+  virtual void           SetPos(int px, int py);  
+
+  virtual void           Show();
+  virtual void           Hide();
 
 protected:
Index: trunk/SophyaPI/PI/sc_sample.cc
===================================================================
--- trunk/SophyaPI/PI/sc_sample.cc	(revision 8)
+++ trunk/SophyaPI/PI/sc_sample.cc	(revision 8)
@@ -0,0 +1,22 @@
+#include "sc_sample.h"
+
+
+ScSample::ScSample(PIContainerGen *par, char *nom,
+                  int sx, int sy, int px, int py)
+:PIScDrawWdg(par, nom, sx, sy, px, py)
+
+{
+  SetLimits(-3,3,-4,4);
+}
+
+ScSample::~ScSample()
+{}
+
+static double f(double x) {return x*x;}
+
+void
+ScSample::Draw()
+{
+  DrawAxes(1,0);
+  PlotFunc(f);
+}
Index: trunk/SophyaPI/PI/sc_sample.h
===================================================================
--- trunk/SophyaPI/PI/sc_sample.h	(revision 8)
+++ trunk/SophyaPI/PI/sc_sample.h	(revision 8)
@@ -0,0 +1,14 @@
+#include "pisysdep.h"
+
+#include "piscdrawwdg.h"
+
+class ScSample : public PIScDrawWdg {
+public:
+  ScSample(PIContainerGen *par, char *nom,
+           int sx=10, int sy=10, int px=0, int py=0);
+  ~ScSample();
+
+  
+  void Draw();
+
+};
Index: trunk/SophyaPI/PI/so_locations
===================================================================
--- trunk/SophyaPI/PI/so_locations	(revision 7)
+++ trunk/SophyaPI/PI/so_locations	(revision 8)
@@ -4,5 +4,5 @@
 
 libPI.so \
-		:st = .text 0x000003ffbffc0000, 0x0000000000020000:\
+		:st = .text 0x000003ffbffb0000, 0x0000000000030000:\
 		:st = .data 0x000003fffffe0000, 0x0000000000010000:\
 
