Index: /tags/V_LaSilla191199/SophyaPI/PI/Makefile
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/Makefile	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/Makefile	(revision 464)
@@ -0,0 +1,287 @@
+MODULECXXREPNAME := PI
+MODULEDECCXXFLAGS := -msg_quiet
+MODULECPPFLAGS := -DSANS_EVOLPLANCK
+include ../Mgr/Makefile.h
+ 
+all: $(LIB)libPI.a
+$(LIB)libPI.a : $(OBJ)lut.o $(OBJ)parradapter.o $(OBJ)pi3ddrw.o $(OBJ)piapplgen.o $(OBJ)piapplx.o $(OBJ)pibwdggen.o $(OBJ)pibwdgx.o $(OBJ)picmap.o $(OBJ)picmapgen.o $(OBJ)picmapview.o $(OBJ)picmapx.o $(OBJ)picons.o $(OBJ)picontainergen.o $(OBJ)picontainerx.o $(OBJ)pidrawer.o $(OBJ)pidrawwin.o $(OBJ)pidrwtools.o $(OBJ)pievthandler.o $(OBJ)pifilechogen.o $(OBJ)pifilechox.o $(OBJ)pifontgen.o $(OBJ)pifontx.o $(OBJ)pigraph3d.o $(OBJ)pigraphgen.o $(OBJ)pigraphps.o $(OBJ)pigraphuc.o $(OBJ)pigraphx.o $(OBJ)piimage.o $(OBJ)piimgtools.o $(OBJ)pilistgen.o $(OBJ)pilistx.o $(OBJ)pimenubargen.o $(OBJ)pimenubarx.o $(OBJ)pimenugen.o $(OBJ)pimenux.o $(OBJ)pimsghandler.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)pistzwin.o $(OBJ)pisurfdr.o $(OBJ)piwdggen.o $(OBJ)piwdgx.o $(OBJ)piwindowgen.o $(OBJ)piwindowx.o $(OBJ)pixtbase.o $(OBJ)psfile.o
+	$(AR) $(ARFLAGS)  $@ $? 
+ifeq ($(CXX),cxx)
+	$(CXX) $? $(CPPFLAGS) $(CXXFLAGS) -L$(LIB) -lPI -lOutils++ -lImages++ -lStarReco++ -o $(OBJ)xx.x -Hf
+endif 
+ 
+clean:
+	rm -f $(OBJ)lut.o $(OBJ)parradapter.o $(OBJ)pi3ddrw.o $(OBJ)piapplgen.o $(OBJ)piapplx.o $(OBJ)pibwdggen.o $(OBJ)pibwdgx.o $(OBJ)picmap.o $(OBJ)picmapgen.o $(OBJ)picmapview.o $(OBJ)picmapx.o $(OBJ)picons.o $(OBJ)picontainergen.o $(OBJ)picontainerx.o $(OBJ)pidrawer.o $(OBJ)pidrawwin.o $(OBJ)pidrwtools.o $(OBJ)pievthandler.o $(OBJ)pifilechogen.o $(OBJ)pifilechox.o $(OBJ)pifontgen.o $(OBJ)pifontx.o $(OBJ)pigraph3d.o $(OBJ)pigraphgen.o $(OBJ)pigraphps.o $(OBJ)pigraphuc.o $(OBJ)pigraphx.o $(OBJ)piimage.o $(OBJ)piimgtools.o $(OBJ)pilistgen.o $(OBJ)pilistx.o $(OBJ)pimenubargen.o $(OBJ)pimenubarx.o $(OBJ)pimenugen.o $(OBJ)pimenux.o $(OBJ)pimsghandler.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)pistzwin.o $(OBJ)pisurfdr.o $(OBJ)piwdggen.o $(OBJ)piwdgx.o $(OBJ)piwindowgen.o $(OBJ)piwindowx.o $(OBJ)pixtbase.o $(OBJ)psfile.o
+ifeq ($(CXX),cxx)
+	cd $(REPM); rm -f *.o
+endif 
+ 
+$(OBJ)lut.o: lut.cc /home/ansari/Include/machdefs.h \
+ /home/ansari/Include/machine.h /home/ansari/Include/defs.h lut.h
+$(OBJ)parradapter.o: parradapter.cc parradapter.h \
+ /home/ansari/Include/machdefs.h /home/ansari/Include/machine.h \
+ /home/ansari/Include/defs.h lut.h
+$(OBJ)pi3ddrw.o: pi3ddrw.cc pi3ddrw.h pisysdep.h pidrawer.h pibwdggen.h \
+ piwdgx.h piwdggen.h pimsghandler.h /home/ansari/Include/machdefs.h \
+ /home/ansari/Include/machine.h /home/ansari/Include/defs.h picmap.h \
+ picmapx.h picmapgen.h pigraphx.h pigraphgen.h pifontx.h pifontgen.h \
+ pigraphuc.h pievthandler.h psfile.h pigraph3d.h pibwdgx.h pigraphps.h \
+ pidrwtools.h pistdwdgx.h pistdwdggen.h pioptmenux.h pioptmenugen.h \
+ pimenux.h pimenugen.h piwindowx.h piwindowgen.h picontainerx.h \
+ picontainergen.h piapplx.h piapplgen.h pimenubarx.h pimenubargen.h \
+ picons.h
+$(OBJ)piapplgen.o: piapplgen.cc piapplgen.h pimsghandler.h \
+ /home/ansari/Include/machdefs.h /home/ansari/Include/machine.h \
+ /home/ansari/Include/defs.h pisysdep.h picontainerx.h \
+ picontainergen.h piwdgx.h piwdggen.h pimenubarx.h pimenubargen.h \
+ pimenux.h pimenugen.h picons.h pistdwdgx.h pistdwdggen.h pibwdgx.h \
+ pibwdggen.h picmap.h picmapx.h picmapgen.h pigraphx.h pigraphgen.h \
+ pifontx.h pifontgen.h pigraphuc.h pievthandler.h psfile.h pigraphps.h
+$(OBJ)piapplx.o: piapplx.cc piapplx.h piapplgen.h pimsghandler.h \
+ /home/ansari/Include/machdefs.h /home/ansari/Include/machine.h \
+ /home/ansari/Include/defs.h pisysdep.h picontainerx.h \
+ picontainergen.h piwdgx.h piwdggen.h pimenubarx.h pimenubargen.h \
+ pimenux.h pimenugen.h picons.h pistdwdgx.h pistdwdggen.h pibwdgx.h \
+ pibwdggen.h picmap.h picmapx.h picmapgen.h pigraphx.h pigraphgen.h \
+ pifontx.h pifontgen.h pigraphuc.h pievthandler.h psfile.h pigraphps.h
+$(OBJ)pibwdggen.o: pibwdggen.cc pibwdggen.h pisysdep.h piwdgx.h piwdggen.h \
+ pimsghandler.h /home/ansari/Include/machdefs.h \
+ /home/ansari/Include/machine.h /home/ansari/Include/defs.h picmap.h \
+ picmapx.h picmapgen.h pigraphx.h pigraphgen.h pifontx.h pifontgen.h \
+ pigraphuc.h pievthandler.h psfile.h pidrawer.h pigraphps.h \
+ pidrwtools.h pistdwdgx.h pistdwdggen.h pioptmenux.h pioptmenugen.h \
+ pimenux.h pimenugen.h piwindowx.h piwindowgen.h picontainerx.h \
+ picontainergen.h piapplx.h piapplgen.h pimenubarx.h pimenubargen.h \
+ picons.h pibwdgx.h
+$(OBJ)pibwdgx.o: pibwdgx.cc pixtbaseP.h pibwdgx.h pisysdep.h pibwdggen.h \
+ piwdgx.h piwdggen.h pimsghandler.h /home/ansari/Include/machdefs.h \
+ /home/ansari/Include/machine.h /home/ansari/Include/defs.h picmap.h \
+ picmapx.h picmapgen.h pigraphx.h pigraphgen.h pifontx.h pifontgen.h \
+ pigraphuc.h pievthandler.h psfile.h pigraphps.h pixtbase.h
+$(OBJ)picmap.o: picmap.cc picmap.h pisysdep.h picmapx.h picmapgen.h
+$(OBJ)picmapgen.o: picmapgen.cc picmapgen.h pisysdep.h picmapx.h picmap.h
+$(OBJ)picmapview.o: picmapview.cc picmapview.h pisysdep.h pibwdgx.h \
+ pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/Include/machdefs.h /home/ansari/Include/machine.h \
+ /home/ansari/Include/defs.h picmap.h picmapx.h picmapgen.h pigraphx.h \
+ pigraphgen.h pifontx.h pifontgen.h pigraphuc.h pievthandler.h \
+ psfile.h pigraphps.h
+$(OBJ)picmapx.o: picmapx.cc piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/Include/machdefs.h /home/ansari/Include/machine.h \
+ /home/ansari/Include/defs.h picmapx.h picmapgen.h pisysdep.h
+$(OBJ)picons.o: picons.cc pisysdep.h pimenux.h pimenugen.h piwdgx.h \
+ piwdggen.h pimsghandler.h /home/ansari/Include/machdefs.h \
+ /home/ansari/Include/machine.h /home/ansari/Include/defs.h picons.h \
+ pistdwdgx.h pistdwdggen.h picontainerx.h picontainergen.h pibwdgx.h \
+ pibwdggen.h picmap.h picmapx.h picmapgen.h pigraphx.h pigraphgen.h \
+ pifontx.h pifontgen.h pigraphuc.h pievthandler.h psfile.h pigraphps.h
+$(OBJ)picontainergen.o: picontainergen.cc picontainergen.h pisysdep.h \
+ piwdgx.h piwdggen.h pimsghandler.h /home/ansari/Include/machdefs.h \
+ /home/ansari/Include/machine.h /home/ansari/Include/defs.h
+$(OBJ)picontainerx.o: picontainerx.cc picontainerx.h pisysdep.h \
+ picontainergen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/Include/machdefs.h /home/ansari/Include/machine.h \
+ /home/ansari/Include/defs.h
+$(OBJ)pidrawer.o: pidrawer.cc pidrawer.h pibwdggen.h pisysdep.h piwdgx.h \
+ piwdggen.h pimsghandler.h /home/ansari/Include/machdefs.h \
+ /home/ansari/Include/machine.h /home/ansari/Include/defs.h picmap.h \
+ picmapx.h picmapgen.h pigraphx.h pigraphgen.h pifontx.h pifontgen.h \
+ pigraphuc.h pievthandler.h psfile.h
+$(OBJ)pidrawwin.o: pidrawwin.cc pidrawwin.h pisysdep.h piwindowx.h \
+ piwindowgen.h picontainerx.h picontainergen.h piwdgx.h piwdggen.h \
+ pimsghandler.h /home/ansari/Include/machdefs.h \
+ /home/ansari/Include/machine.h /home/ansari/Include/defs.h \
+ piscdrawwdg.h pibwdgx.h pibwdggen.h picmap.h picmapx.h picmapgen.h \
+ pigraphx.h pigraphgen.h pifontx.h pifontgen.h pigraphuc.h \
+ pievthandler.h psfile.h pigraphps.h pistdwdgx.h pistdwdggen.h \
+ pidrawer.h
+$(OBJ)pidrwtools.o: pidrwtools.cc pidrwtools.h pisysdep.h pistdwdgx.h \
+ pistdwdggen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/Include/machdefs.h /home/ansari/Include/machine.h \
+ /home/ansari/Include/defs.h pioptmenux.h pioptmenugen.h pimenux.h \
+ pimenugen.h piwindowx.h piwindowgen.h picontainerx.h picontainergen.h \
+ piapplx.h piapplgen.h pimenubarx.h pimenubargen.h picons.h pibwdgx.h \
+ pibwdggen.h picmap.h picmapx.h picmapgen.h pigraphx.h pigraphgen.h \
+ pifontx.h pifontgen.h pigraphuc.h pievthandler.h psfile.h pigraphps.h \
+ piscdrawwdg.h pidrawer.h pi3ddrw.h pigraph3d.h
+$(OBJ)pievthandler.o: pievthandler.cc pievthandler.h pisysdep.h \
+ pimsghandler.h /home/ansari/Include/machdefs.h \
+ /home/ansari/Include/machine.h /home/ansari/Include/defs.h piwdgx.h \
+ piwdggen.h pigraphx.h pigraphgen.h picmap.h picmapx.h picmapgen.h \
+ pifontx.h pifontgen.h
+$(OBJ)pifilechogen.o: pifilechogen.cc pifilechogen.h pisysdep.h piwdgx.h \
+ piwdggen.h pimsghandler.h /home/ansari/Include/machdefs.h \
+ /home/ansari/Include/machine.h /home/ansari/Include/defs.h
+$(OBJ)pifilechox.o: pifilechox.cc pisysdep.h piapplx.h piapplgen.h \
+ pimsghandler.h /home/ansari/Include/machdefs.h \
+ /home/ansari/Include/machine.h /home/ansari/Include/defs.h \
+ picontainerx.h picontainergen.h piwdgx.h piwdggen.h pimenubarx.h \
+ pimenubargen.h pimenux.h pimenugen.h picons.h pistdwdgx.h \
+ pistdwdggen.h pibwdgx.h pibwdggen.h picmap.h picmapx.h picmapgen.h \
+ pigraphx.h pigraphgen.h pifontx.h pifontgen.h pigraphuc.h \
+ pievthandler.h psfile.h pigraphps.h pifilechox.h pifilechogen.h \
+ piwindowx.h piwindowgen.h
+$(OBJ)pifontgen.o: pifontgen.cc pigraphgen.h pisysdep.h piwdgx.h piwdggen.h \
+ pimsghandler.h /home/ansari/Include/machdefs.h \
+ /home/ansari/Include/machine.h /home/ansari/Include/defs.h picmap.h \
+ picmapx.h picmapgen.h pifontx.h pifontgen.h
+$(OBJ)pifontx.o: pifontx.cc pisysdep.h pifontx.h pifontgen.h piwdgx.h \
+ piwdggen.h pimsghandler.h /home/ansari/Include/machdefs.h \
+ /home/ansari/Include/machine.h /home/ansari/Include/defs.h
+$(OBJ)pigraph3d.o: pigraph3d.cc pigraph3d.h pisysdep.h pigraphuc.h \
+ pigraphgen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/Include/machdefs.h /home/ansari/Include/machine.h \
+ /home/ansari/Include/defs.h picmap.h picmapx.h picmapgen.h pifontx.h \
+ pifontgen.h
+$(OBJ)pigraphgen.o: pigraphgen.cc pigraphgen.h pisysdep.h piwdgx.h \
+ piwdggen.h pimsghandler.h /home/ansari/Include/machdefs.h \
+ /home/ansari/Include/machine.h /home/ansari/Include/defs.h picmap.h \
+ picmapx.h picmapgen.h pifontx.h pifontgen.h
+$(OBJ)pigraphps.o: pigraphps.cc pigraphps.h pisysdep.h pigraphgen.h piwdgx.h \
+ piwdggen.h pimsghandler.h /home/ansari/Include/machdefs.h \
+ /home/ansari/Include/machine.h /home/ansari/Include/defs.h picmap.h \
+ picmapx.h picmapgen.h pifontx.h pifontgen.h psfile.h
+$(OBJ)pigraphuc.o: pigraphuc.cc pigraphuc.h pisysdep.h pigraphgen.h piwdgx.h \
+ piwdggen.h pimsghandler.h /home/ansari/Include/machdefs.h \
+ /home/ansari/Include/machine.h /home/ansari/Include/defs.h picmap.h \
+ picmapx.h picmapgen.h pifontx.h pifontgen.h
+$(OBJ)pigraphx.o: pigraphx.cc pigraphx.h pisysdep.h pigraphgen.h piwdgx.h \
+ piwdggen.h pimsghandler.h /home/ansari/Include/machdefs.h \
+ /home/ansari/Include/machine.h /home/ansari/Include/defs.h picmap.h \
+ picmapx.h picmapgen.h pifontx.h pifontgen.h
+$(OBJ)piimage.o: piimage.cc piimage.h parradapter.h \
+ /home/ansari/Include/machdefs.h /home/ansari/Include/machine.h \
+ /home/ansari/Include/defs.h lut.h pisysdep.h pidrawer.h pibwdggen.h \
+ piwdgx.h piwdggen.h pimsghandler.h picmap.h picmapx.h picmapgen.h \
+ pigraphx.h pigraphgen.h pifontx.h pifontgen.h pigraphuc.h \
+ pievthandler.h psfile.h pipixmapx.h pipixmapgen.h pibwdgx.h \
+ pigraphps.h pistdwdgx.h pistdwdggen.h piwindowx.h piwindowgen.h \
+ picontainerx.h picontainergen.h picmapview.h piimgtools.h \
+ pioptmenux.h pioptmenugen.h pimenux.h pimenugen.h piapplx.h \
+ piapplgen.h pimenubarx.h pimenubargen.h picons.h pidrwtools.h \
+ piscdrawwdg.h
+$(OBJ)piimgtools.o: piimgtools.cc piimgtools.h pisysdep.h pistdwdgx.h \
+ pistdwdggen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/Include/machdefs.h /home/ansari/Include/machine.h \
+ /home/ansari/Include/defs.h pioptmenux.h pioptmenugen.h pimenux.h \
+ pimenugen.h piwindowx.h piwindowgen.h picontainerx.h picontainergen.h \
+ piapplx.h piapplgen.h pimenubarx.h pimenubargen.h picons.h pibwdgx.h \
+ pibwdggen.h picmap.h picmapx.h picmapgen.h pigraphx.h pigraphgen.h \
+ pifontx.h pifontgen.h pigraphuc.h pievthandler.h psfile.h pigraphps.h \
+ piimage.h parradapter.h lut.h pidrawer.h pipixmapx.h pipixmapgen.h \
+ picmapview.h
+$(OBJ)pilistgen.o: pilistgen.cc pilistgen.h pisysdep.h piwdgx.h piwdggen.h \
+ pimsghandler.h /home/ansari/Include/machdefs.h \
+ /home/ansari/Include/machine.h /home/ansari/Include/defs.h
+$(OBJ)pilistx.o: pilistx.cc pilistx.h pilistgen.h pisysdep.h piwdgx.h \
+ piwdggen.h pimsghandler.h /home/ansari/Include/machdefs.h \
+ /home/ansari/Include/machine.h /home/ansari/Include/defs.h \
+ picontainerx.h picontainergen.h
+$(OBJ)pimenubargen.o: pimenubargen.cc pimenubargen.h pisysdep.h pimenux.h \
+ pimenugen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/Include/machdefs.h /home/ansari/Include/machine.h \
+ /home/ansari/Include/defs.h piapplx.h piapplgen.h picontainerx.h \
+ picontainergen.h pimenubarx.h picons.h pistdwdgx.h pistdwdggen.h \
+ pibwdgx.h pibwdggen.h picmap.h picmapx.h picmapgen.h pigraphx.h \
+ pigraphgen.h pifontx.h pifontgen.h pigraphuc.h pievthandler.h \
+ psfile.h pigraphps.h
+$(OBJ)pimenubarx.o: pimenubarx.cc pimenubarx.h pimenubargen.h pisysdep.h \
+ pimenux.h pimenugen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/Include/machdefs.h /home/ansari/Include/machine.h \
+ /home/ansari/Include/defs.h piapplx.h piapplgen.h picontainerx.h \
+ picontainergen.h picons.h pistdwdgx.h pistdwdggen.h pibwdgx.h \
+ pibwdggen.h picmap.h picmapx.h picmapgen.h pigraphx.h pigraphgen.h \
+ pifontx.h pifontgen.h pigraphuc.h pievthandler.h psfile.h pigraphps.h
+$(OBJ)pimenugen.o: pimenugen.cc pimenugen.h pisysdep.h piwdgx.h piwdggen.h \
+ pimsghandler.h /home/ansari/Include/machdefs.h \
+ /home/ansari/Include/machine.h /home/ansari/Include/defs.h
+$(OBJ)pimenux.o: pimenux.cc pisysdep.h pimenubarx.h pimenubargen.h pimenux.h \
+ pimenugen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/Include/machdefs.h /home/ansari/Include/machine.h \
+ /home/ansari/Include/defs.h
+$(OBJ)pimsghandler.o: pimsghandler.cc pimsghandler.h \
+ /home/ansari/Include/machdefs.h /home/ansari/Include/machine.h \
+ /home/ansari/Include/defs.h
+$(OBJ)pioptmenugen.o: pioptmenugen.cc pioptmenugen.h pisysdep.h pimenux.h \
+ pimenugen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/Include/machdefs.h /home/ansari/Include/machine.h \
+ /home/ansari/Include/defs.h
+$(OBJ)pioptmenux.o: pioptmenux.cc pisysdep.h pioptmenux.h pioptmenugen.h \
+ pimenux.h pimenugen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/Include/machdefs.h /home/ansari/Include/machine.h \
+ /home/ansari/Include/defs.h pistdwdgx.h pistdwdggen.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 pifontx.h pifontgen.h pigraphuc.h \
+ pievthandler.h psfile.h pigraphps.h
+$(OBJ)piperiodx.o: piperiodx.cc piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/Include/machdefs.h /home/ansari/Include/machine.h \
+ /home/ansari/Include/defs.h piperiodx.h \
+ /home/ansari/Include/periodic.h
+$(OBJ)pipixmapgen.o: pipixmapgen.cc pipixmapgen.h pisysdep.h pibwdgx.h \
+ pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/Include/machdefs.h /home/ansari/Include/machine.h \
+ /home/ansari/Include/defs.h picmap.h picmapx.h picmapgen.h pigraphx.h \
+ pigraphgen.h pifontx.h pifontgen.h pigraphuc.h pievthandler.h \
+ psfile.h pigraphps.h
+$(OBJ)pipixmapx.o: pipixmapx.cc pipixmapx.h pipixmapgen.h pisysdep.h \
+ pibwdgx.h pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/Include/machdefs.h /home/ansari/Include/machine.h \
+ /home/ansari/Include/defs.h picmap.h picmapx.h picmapgen.h pigraphx.h \
+ pigraphgen.h pifontx.h pifontgen.h pigraphuc.h pievthandler.h \
+ psfile.h pigraphps.h
+$(OBJ)piscdrawwdg.o: piscdrawwdg.cc piscdrawwdg.h pisysdep.h pibwdgx.h \
+ pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/Include/machdefs.h /home/ansari/Include/machine.h \
+ /home/ansari/Include/defs.h picmap.h picmapx.h picmapgen.h pigraphx.h \
+ pigraphgen.h pifontx.h pifontgen.h pigraphuc.h pievthandler.h \
+ psfile.h pigraphps.h pistdwdgx.h pistdwdggen.h piwindowx.h \
+ piwindowgen.h picontainerx.h picontainergen.h pidrawer.h pidrwtools.h \
+ pioptmenux.h pioptmenugen.h pimenux.h pimenugen.h piapplx.h \
+ piapplgen.h pimenubarx.h pimenubargen.h picons.h parradapter.h lut.h
+$(OBJ)pistdwdggen.o: pistdwdggen.cc pistdwdggen.h pisysdep.h piwdgx.h \
+ piwdggen.h pimsghandler.h /home/ansari/Include/machdefs.h \
+ /home/ansari/Include/machine.h /home/ansari/Include/defs.h
+$(OBJ)pistdwdgx.o: pistdwdgx.cc pisysdep.h pistdwdgx.h pistdwdggen.h \
+ piwdgx.h piwdggen.h pimsghandler.h /home/ansari/Include/machdefs.h \
+ /home/ansari/Include/machine.h /home/ansari/Include/defs.h
+$(OBJ)pistzwin.o: pistzwin.cc pistzwin.h pisysdep.h piwindowx.h \
+ piwindowgen.h picontainerx.h picontainergen.h piwdgx.h piwdggen.h \
+ pimsghandler.h /home/ansari/Include/machdefs.h \
+ /home/ansari/Include/machine.h /home/ansari/Include/defs.h \
+ piperiodx.h /home/ansari/Include/periodic.h psfile.h pigraphgen.h \
+ picmap.h picmapx.h picmapgen.h pifontx.h pifontgen.h
+$(OBJ)pisurfdr.o: pisurfdr.cc pisurfdr.h parradapter.h \
+ /home/ansari/Include/machdefs.h /home/ansari/Include/machine.h \
+ /home/ansari/Include/defs.h lut.h pi3ddrw.h pisysdep.h pidrawer.h \
+ pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h picmap.h picmapx.h \
+ picmapgen.h pigraphx.h pigraphgen.h pifontx.h pifontgen.h pigraphuc.h \
+ pievthandler.h psfile.h pigraph3d.h pibwdgx.h pigraphps.h
+$(OBJ)piwdggen.o: piwdggen.cc piwdggen.h pimsghandler.h \
+ /home/ansari/Include/machdefs.h /home/ansari/Include/machine.h \
+ /home/ansari/Include/defs.h picontainergen.h pisysdep.h piwdgx.h \
+ pievthandler.h pigraphx.h pigraphgen.h picmap.h picmapx.h picmapgen.h \
+ pifontx.h pifontgen.h psfile.h
+$(OBJ)piwdgx.o: piwdgx.cc piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/Include/machdefs.h /home/ansari/Include/machine.h \
+ /home/ansari/Include/defs.h picontainerx.h pisysdep.h \
+ picontainergen.h pievthandler.h pigraphx.h pigraphgen.h picmap.h \
+ picmapx.h picmapgen.h pifontx.h pifontgen.h
+$(OBJ)piwindowgen.o: piwindowgen.cc piwindowgen.h pisysdep.h picontainerx.h \
+ picontainergen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/Include/machdefs.h /home/ansari/Include/machine.h \
+ /home/ansari/Include/defs.h psfile.h pigraphgen.h picmap.h picmapx.h \
+ picmapgen.h pifontx.h pifontgen.h
+$(OBJ)piwindowx.o: piwindowx.cc piwindowx.h piwindowgen.h pisysdep.h \
+ picontainerx.h picontainergen.h piwdgx.h piwdggen.h pimsghandler.h \
+ /home/ansari/Include/machdefs.h /home/ansari/Include/machine.h \
+ /home/ansari/Include/defs.h
+$(OBJ)pixtbase.o: pixtbase.cc pixtbaseP.h pibwdgx.h pisysdep.h pibwdggen.h \
+ piwdgx.h piwdggen.h pimsghandler.h /home/ansari/Include/machdefs.h \
+ /home/ansari/Include/machine.h /home/ansari/Include/defs.h picmap.h \
+ picmapx.h picmapgen.h pigraphx.h pigraphgen.h pifontx.h pifontgen.h \
+ pigraphuc.h pievthandler.h psfile.h pigraphps.h pixtbase.h
+$(OBJ)psfile.o: psfile.cc psfile.h /home/ansari/Include/machdefs.h \
+ /home/ansari/Include/machine.h /home/ansari/Include/defs.h pisysdep.h \
+ pigraphgen.h piwdgx.h piwdggen.h pimsghandler.h picmap.h picmapx.h \
+ picmapgen.h pifontx.h pifontgen.h
Index: /tags/V_LaSilla191199/SophyaPI/PI/exclude
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/exclude	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/exclude	(revision 464)
@@ -0,0 +1,30 @@
+piperiodmac.cc
+pifontmac.cc
+piapplmac.cc
+pibwdgmac.cc
+picmapmac.cc
+picontainermac.cc
+pifilechomac.cc
+pigraphmac.cc
+pilistmac.cc
+pimenubarmac.cc
+pimenumac.cc
+pioptmenumac.cc
+pipixmapmac.cc
+pippapplmac.cc
+pippwindowmac.cc
+pistdwdgmac.cc
+piwdgmac.cc
+piwindowmac.cc
+pippapplmac.cc
+pipplist.cc
+pippmenubar.cc
+pippoptmenu.cc
+pippviewadapter.cc
+pippwindowmac.cc
+piupdattachment.cc
+pierrdisp.cc
+piup.cc
+piup_def.cc
+xdispim.c
+piup.c
Index: /tags/V_LaSilla191199/SophyaPI/PI/lut.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/lut.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/lut.cc	(revision 464)
@@ -0,0 +1,106 @@
+// Classe Look-Up-Table  pour convertir image en entree ds
+// une table de couleur.
+//       Classe LUT              R. Ansari  05/95
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "machdefs.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+
+#include "lut.h"
+
+
+/* --Methode-- */
+
+LUT::LUT(double min, double max, unsigned short ncol, int typ, int ntable) 
+{
+int nlev;
+
+bornes=NULL;  
+nlev = ncol-2;
+if (nlev < 1)  nlev = 1;
+bornes = new double[nlev+1];
+
+if (bornes == NULL)  return;
+type = typ;  nLevel = nlev;
+SetLut(min, max, typ);
+table = NULL;  
+ComputeTable(ntable);
+return;
+}
+
+/* --Methode-- */
+LUT::~LUT()
+{
+if (type<0)  return;
+delete[] bornes;
+delete[] table;
+}
+
+/* --Methode-- */
+void LUT::SetLut(double min, double max, int typ)
+{
+
+if ( (typ != kLutType_Lin) && (typ != kLutType_Log) )  typ = kLutType_Lin;
+type = typ;
+if (max <= min)  max = min+1.;
+if (nLevel > 0)
+  {
+  int i;
+  double dx;
+  double dlx;
+  switch (typ)
+    {
+    case kLutType_Lin :
+      dx = (max-min)/(double)nLevel;
+      for(i=0; i<nLevel; i++)
+        bornes[i] = min+(double)i*dx;
+      break;
+    case kLutType_Log :
+      dlx = log(max-min) / (double)nLevel;
+      for(i=0; i<nLevel; i++)
+        bornes[i] = min+(double)exp((double)i*dlx);
+      break;
+    default:
+      for(i=0; i<nLevel; i++)
+        bornes[i] = min;
+      break;
+    }
+  bornes[nLevel] = max; 
+  }
+else  bornes[0] = 0.5*(min+max);
+return; 
+}
+
+/* --Methode-- */
+void LUT::Print()
+{
+int i;
+
+printf("LUT_Info: Type= %d NLevel= %d Min,Max= %g %g \n",
+       type, nLevel, bornes[0], bornes[nLevel]);
+for(i=0; i<=nLevel; i++)
+  printf("..Bornes[%d] = %g \n", i, bornes[i]);
+return;
+}
+
+/* --Methode-- */
+unsigned short LUT::Apply(double x)
+{
+int i;
+for(i=0;i<=nLevel;i++)  
+  if (x < bornes[i])  return(i);
+return(nLevel+1);
+}
+
+/* --Methode-- */
+void LUT::ComputeTable(int nt)
+{
+if (nt < 0) nt = 16*(nLevel+2);
+else if (nt < (nLevel+2))  nt = (nLevel+2);
+table = new unsigned short [nt-2];
+tablebinwidth = (Max()-Min())/(nt-2);
+double x = Min()+0.5*tablebinwidth;
+for(int i=0; i<nt-2; i++)  { table[i] = Apply(x); x += tablebinwidth; }
+}
Index: /tags/V_LaSilla191199/SophyaPI/PI/lut.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/lut.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/lut.h	(revision 464)
@@ -0,0 +1,54 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Classe Look-Up-Table  pour convertir image en entree ds
+// une table de couleur.
+//       Classe LUT              R. Ansari  05/95
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef LUT_SEEN
+#define LUT_SEEN
+
+// LUT : Look-Up-Table avec nLevel bins entre min et max
+// Apply retourne * 0 < min   * nLevel+1 > max 
+// et de 1 a nLevel pour min<=x<max
+
+// Type de lut possibles (Seul Lineaire implemente 05/95
+enum {kLutType_Lin=1, kLutType_Log=2};
+
+class LUT 
+{
+public:
+  
+  LUT(double min, double max, unsigned short ncol=16, int typ=kLutType_Lin, int ntable=-1);
+  ~LUT();
+  void SetLut(double min, double max, int typ=0);
+  void Print();
+  unsigned short Apply(double x);
+  inline unsigned short ApplyFast(double x)
+    { 
+    if (x < Min())  return(0);
+    if (x >= Max() )  return(nLevel+1);  
+    int k = (int)((x-Min())/tablebinwidth);
+    return(table[k]); 
+    } 
+
+  inline double Min() { return(bornes[0]); };
+  inline double Max() { return(bornes[nLevel]); };
+  inline int Type() { return(type); };
+  inline int NCol() { return(nLevel+2); };
+
+protected:
+  void ComputeTable(int nt);
+
+  int type;
+  int nLevel;
+  double * bornes;
+  unsigned short * table;
+  double tablebinwidth;
+
+};
+
+#endif
+
+
+
+  
Index: /tags/V_LaSilla191199/SophyaPI/PI/parradapter.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/parradapter.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/parradapter.cc	(revision 464)
@@ -0,0 +1,371 @@
+//     Classes ArrayAdapter           R. Ansari  05/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+
+// #include "ctimer.h"   Pour mesure TCPU 
+#include "parradapter.h"
+
+/* --Methode-- */
+P1DArrayAdapter::P1DArrayAdapter(int sz)
+{
+mSize=sz;
+DefineXCoordinate(0, 1.);
+}
+
+/* --Methode-- */
+P1DArrayAdapter::~P1DArrayAdapter()
+{
+}
+
+/* --Methode-- */
+void P1DArrayAdapter::DefineXCoordinate(double x0, double dx)
+{
+mOx = x0;  mDx = dx;
+}
+
+/* --Methode-- */
+double P1DArrayAdapter::X(int i)
+{
+return(mOx+mDx*i);
+}
+
+/* --Methode-- */
+P2DArrayAdapter::P2DArrayAdapter(int sx, int sy)
+{
+sX = sx; sY = sy; 
+sgnX = sgnY = 1;
+offX = offY = 0;
+invX = invY = eXY = false;
+DefineXYCoordinates(0.,0.,1.,1.);
+}
+
+/* --Methode-- */
+P2DArrayAdapter::~P2DArrayAdapter()
+{
+}
+
+/* --Methode-- */
+void P2DArrayAdapter::ConfigureAxes(bool invx, bool invy, bool exy, int sx, int sy)
+{
+invX = invx;  invY = invy;  eXY = exy; 
+if ( (sx > 0) && (sy > 0) )   { sX = sx; sY = sy; }
+if (invX) { sgnX = -1;  offX = sX-1; } 
+else { sgnX = 1; offX = 0; }
+if (invY) { sgnY = -1;  offY = sY-1; } 
+else { sgnY = 1; offY = 0; }
+}
+
+/* --Methode-- */
+void P2DArrayAdapter::DefineXYCoordinates(double x0, double y0, double dx, double dy)
+{
+mOx = x0;   mOy = y0;
+mDx = dx;   mDy = dy;
+}
+
+/* --Methode-- */
+void P2DArrayAdapter::XYfromxy(int ix, int iy, double& x, double& y)
+{
+x = mOx+ix*mDx;
+y = mOy+iy*mDy; 
+}
+
+/* --Methode-- */
+int P2DArrayAdapter::CheckDyn(double& min, double& max, double& moy, double& sig, int& nbnul, int& nbsat, int vit)
+{
+// TIMEF ; 
+double m = 0.;
+double s = 0.;
+double dv; 
+
+int n9 = 0;
+int n0 = 0;
+
+if (min >= max) { min = -9.e19; max = 9.e19; }
+double minpix = max;
+double maxpix = min; 
+double pixv;
+// printf("DEBUG_CHECKDYN-IN %d - %g %g ", vit, min, max);
+
+int n = 0;
+if (vit < 1) vit = 1;
+if (sX*sY/vit < 1000) {
+  vit = sX*sY/1000;
+  if (vit < 1) vit = 1;
+}
+
+// printf(" -> vit=%d \n", vit);
+for(int j=0; j<sY; j++) 
+  for(int i=0; i<sX; i++)   {
+    if (++n % vit != 0)  continue;
+    pixv = Value(i,j);
+    if (pixv <= max && pixv >= min) {  
+      if (pixv < minpix)  minpix = pixv;
+      if (pixv > maxpix)  maxpix = pixv; 
+      dv = (double)pixv;
+      m += dv;  s += (dv*dv);
+      }
+    else  {  
+      if (pixv > max)  n9++;
+      if (pixv < min)  n0++; 
+    }
+  }
+
+nbnul = n0*vit;  nbsat = n9*vit;
+min = minpix;  max = maxpix; 
+
+n -= (n0+n9);
+if (n > 0)
+  { dv = (double)n;  m /= dv;  s = s/dv - m*m;
+  if (s>0.)  s = sqrt(s);  else s = 0.;
+  moy = m;  sig = s; }
+else { moy = 0.;  sig = -1.; }
+
+// printf("DEBUG_CHECKDYN: %d %g %g - %g %g \n", n, min, max, moy, sig);
+return(n);
+}
+
+
+/* --Methode-- */
+void P2DArrayAdapter::ComputeLut_PicHisto(double& min, double& max, int nbsig, double fracmax)
+{
+// TIMEF ; 
+int MINNBIN = 64;
+int MAXNBIN = 1024;
+
+int nbin = sX*sY/10;
+nbin = (nbin < MINNBIN) ? MINNBIN : ((nbin > MAXNBIN) ? MAXNBIN : nbin );
+int vitesse = sX*sY / 20000;
+vitesse = (vitesse < 1) ? 1 : ((vitesse > 25) ? 25 : vitesse );
+
+
+//  Variable decrivant l'histogramme 
+double minhis, maxhis, binwidth;
+int under,over,tothis;
+int_4 *phis;
+int_4 *q;
+
+double MINDYNAMIC = 1.e-8;          /* Gamme dynamique minimale (MaxAff-MinAff)*/
+double FRACPIC = 0.6065;            /*  Valeur de exp(-0.5)   */
+
+
+
+if ( min >= (max-MINDYNAMIC) ) { 
+  int nbnul, nbsat, nok;
+  double moy, sig; 
+  nok = CheckDyn(min, max, moy, sig, nbnul, nbsat, vitesse);
+  if (nok < 1) { min=0.; max = 1.;  return; }
+  }
+if ( min >= (max-MINDYNAMIC) )  max = min+MINDYNAMIC;
+minhis = min;
+maxhis = max;
+binwidth = (maxhis-minhis) / nbin;
+if (binwidth < MINDYNAMIC/MINNBIN) { 
+  binwidth = MINDYNAMIC/MINNBIN;
+  maxhis = nbin*binwidth + minhis;
+  }
+// printf("DEBUG nbin minhis maxhis binwidth = %d %g %g %g \n", nbin, minhis, maxhis, binwidth);
+
+/* allocation dynamique de memoire et mise a zero de l'histogramme */
+phis = new int_4[nbin];
+for ( q=phis ; q<phis+nbin ; *q++ = 0 )  ;
+under = over = tothis = 0;
+
+//  Boucle sur les pixels   
+//  Pour aller plus vite, on prend un pixel sur vitesse   
+int kk = 0;
+int bin;
+for(int j=0; j<sY; j++)
+  for(int i=0; i<sX; i++) {
+    if ( (++kk % vitesse) != 0) continue;
+   /* remplissage de l'histogramme */
+    bin = (int)((Value(i, j) - minhis) / binwidth) ;
+    if ( bin < 0 )  under++;
+    else  {
+      if (bin < nbin) { (*(phis+bin))++; tothis++; }
+      else   over++; 
+      }
+    }     /*  Fin de for : Boucle sur les pixels   */
+
+/*  On verifie qu'il y a eu une entree ds l'histo */
+if (tothis <= 0)
+  { delete[] phis;  return; }
+  
+/* recherche du maximum */
+int binmax = -1 ; 
+int hmax = -1 ; 
+q = phis;
+for (kk = 0 ; kk < nbin ;  kk++, q++ )
+  if ( *(q) > hmax ) {hmax = *(q) ; binmax = kk ;}
+
+if ( (binmax < 0) || (binmax >= nbin) )
+  { delete[] phis;  return; }
+
+
+/*   On va chercher le sigma du fond  SigmaLeft, SigmaRight */
+int hmin = (int) ( (double)(hmax) * FRACPIC ) ;
+
+int sigr = 0;
+q = phis+binmax;
+while ( ((*q) > hmin) && (sigr < (nbin-binmax)) )  { sigr++;  q++; }
+int sigl = 0;
+q = phis+binmax;
+while ( ((*q) > hmin) && (sigl < binmax) )  { sigl++; q--; }
+
+
+if (nbsig == 0) nbsig = 1;
+if (nbsig < 0)  {  /*   On considere le cas ou NbSigmas est negatif   */
+  if ( (bin = binmax+nbsig*sigl) < 0 )  bin = 0;
+  min = minhis + (double)bin*binwidth;
+  if ( (bin = binmax-nbsig*sigr) >= nbin ) bin = nbin-1;
+  max = minhis + (double)bin*binwidth;
+  if (max < (min+MINDYNAMIC))  max = min+MINDYNAMIC;
+  delete[] phis;  return; 
+  }
+
+// NbSigma positif 
+if ( (bin = binmax+nbsig*sigl) >= nbin ) {
+  min = minhis + binmax*binwidth;
+  max = maxhis;
+  if (max < (min+MINDYNAMIC))  max = min+MINDYNAMIC;
+  delete[] phis;  return;
+  }
+
+min = minhis + bin*binwidth;
+
+/*   Calcul du nb de pixel entre MinAff et ValSat  */
+int nbpix = 0;
+for( q = phis+bin ; q < phis+nbin ; q++)  nbpix += (*q);
+nbpix = (int_4)((double)nbpix * fracmax);
+int nbpix2 = 0; q = phis+bin; 
+int k = bin;
+while( (nbpix2 < nbpix) && (k < nbin) )  
+  { nbpix2 += (*q); k++; q++; }
+
+max = minhis + (double)k*binwidth;
+delete[] phis;
+if (max < (min+MINDYNAMIC))  max = min+MINDYNAMIC;
+
+return;
+}
+
+
+/* --Methode-- */
+unsigned char * P2DArrayAdapter::ComputePixmap(LUT* lut, int ofx, int ofy, int zm, 
+                int xwsz, int ywsz, unsigned char * opix, int * oxsp, int * oysp)
+{
+// TIMEF ; 
+unsigned char *pix, *pp, ucp;
+int zmm=1;
+int npx, npy, nppx, nppy, nszp, oszp;
+int i,j,k,l;
+double vpx;
+
+
+if ( (XSize() <= 0) || (YSize() <= 0) || (lut == NULL) ) 
+  { *oxsp = *oysp = 0; return(NULL); }
+
+npx = XSize()-ofx;
+npy = YSize()-ofy;
+
+if ((zm == 0) || (zm == -1))  zm = 1;
+
+if (zm >= 1)
+  {
+  if (npx > (xwsz/zm))  npx = xwsz/zm; 
+  if (npy > (ywsz/zm))  npy = ywsz/zm;
+  nppx = npx*zm;   nppy = npy*zm;
+  }
+else
+  {
+  zmm = -zm;
+  nppx = npx/zmm;   nppy = npy/zmm;
+  if (nppx > xwsz)  nppx = xwsz; 
+  if (nppy > ywsz)  nppy = ywsz;
+  npx = nppx*zmm;   npy = nppy*zmm; 
+  }
+
+oszp = (*oxsp)*(*oysp);
+nszp = nppx*nppy;
+if ( oszp != nszp )
+  {
+  if (opix)  delete[] opix;
+  pix = new unsigned char[nppx*nppy];
+  if (pix == NULL)  { *oxsp = *oysp = 0; ; return(NULL); }
+  }
+else  pix = opix;
+*oxsp = nppx; *oysp = nppy;
+
+/*
+printf("Debug_ComputePixmap %d %d %d (%d-%d %d-%d)\n", 
+      ofx, ofy, zm, npx,nppx, npy,nppy);
+*/
+
+pp = pix;
+if (eXY) { // Echange Axe X,Y 
+  if (zm == 1)  {  // Pas de zoom  
+    for(j=ofy; j<ofy+npy; j++)
+      for(i=ofx; i<ofx+npx; i++) 
+        { *pp = (unsigned char) lut->ApplyFast( 
+                this->Value(j*sgnX+offX, i*sgnY+offY));  
+           pp++; }
+    }
+  else if (zm < -1) {       // Compression 
+    double fv = (double)(zmm*zmm); 
+    for(j=ofy; j<ofy+npy; j+=zmm)
+      for(i=ofx; i<ofx+npx; i+=zmm) {
+        vpx = 0;
+        for(l=0; l<zmm; l++)
+          for(k=0; k<zmm; k++)
+            vpx += this->Value( (j+l)*sgnX+offX, (i+k)*sgnY+offY);
+        *pp = (unsigned char) lut->ApplyFast(vpx/fv); 
+        pp++;
+        }
+    }
+  else  {      // Agrandissement
+    for(j=ofy; j<ofy+npy; j++)
+      for(i=ofx; i<ofx+npx; i++)  {
+        ucp = (unsigned char) lut->ApplyFast(this->Value(j*sgnX+offX, i*sgnY+offY));
+        for(l=0; l<zm; l++)  {
+          pp = pix+((j-ofy)*zm+l)*nppx+((i-ofx)*zm);
+          for(k=0; k<zm; k++)  { *pp = ucp; pp++; }  
+	  }
+        }
+    }
+  }     // Fin du cas avec echange d'axe X/Y 
+else {
+  if (zm == 1)  {  // Pas de zoom  
+    for(j=ofy; j<ofy+npy; j++)
+      for(i=ofx; i<ofx+npx; i++) 
+        { *pp = (unsigned char) lut->ApplyFast( 
+                this->Value(i*sgnX+offX, j*sgnY+offY));  
+           pp++; }
+    }
+  else if (zm < -1) {       // Compression 
+    double fv = (double)(zmm*zmm); 
+    for(j=ofy; j<ofy+npy; j+=zmm)
+      for(i=ofx; i<ofx+npx; i+=zmm) {
+        vpx = 0;
+        for(l=0; l<zmm; l++)
+          for(k=0; k<zmm; k++)
+            vpx += this->Value( (i+k)*sgnX+offX, (j+l)*sgnY+offY);
+        *pp = (unsigned char) lut->ApplyFast(vpx/fv); 
+        pp++;
+        }
+    }
+  else  {      // Agrandissement
+    for(j=ofy; j<ofy+npy; j++)
+      for(i=ofx; i<ofx+npx; i++)  {
+        ucp = (unsigned char) lut->ApplyFast(this->Value(i*sgnX+offX, j*sgnY+offY));
+        for(l=0; l<zm; l++)  {
+          pp = pix+((j-ofy)*zm+l)*nppx+((i-ofx)*zm);
+          for(k=0; k<zm; k++)  { *pp = ucp; pp++; }  
+	  }
+        }
+    }
+  }
+return(pix);
+}
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/parradapter.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/parradapter.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/parradapter.h	(revision 464)
@@ -0,0 +1,117 @@
+// This may look like C code, but it is really -*- C++ -*-
+//     Classes ArrayAdapter           R. Ansari  05/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+
+#ifndef PARRADAPTER_SEEN
+#define PARRADAPTER_SEEN
+
+#include "machdefs.h"
+#include "lut.h"
+
+class P1DArrayAdapter {
+public :
+                  P1DArrayAdapter(int sz=0);
+  virtual         ~P1DArrayAdapter();
+ 
+  virtual double  Value(int i) = 0;
+  inline  int     Size() { return (mSize) ; }
+  virtual void    DefineXCoordinate(double x0, double dx);
+  virtual double  X(int i);
+     
+protected :
+  int mSize;
+  double mOx, mDx;
+};
+
+// Cette classe est un adaptateur pour les PIImages et 
+// autres classes de PI qui operent sur des structures 
+// de type Tableaux 2-D (images, ...) 
+
+class P2DArrayAdapter {
+public :
+                  P2DArrayAdapter(int sx=0, int sy=0);
+  virtual 	  ~P2DArrayAdapter();
+
+  void  	  ConfigureAxes(bool invx=false, bool invy=false, bool exy=false,
+                                int sx=-1, int sy=-1);
+
+  inline void     GetAxesConfiguration(bool& invx, bool& invy, bool& exy)
+                               { invx = invX; invy = invY; exy = eXY; }
+
+  virtual void    DefineXYCoordinates(double x0, double y0, double dx, double dy);
+// Doit etre defini par les classes derivees
+  virtual double  Value(int ix, int iy) = 0;   
+
+  virtual void    XYfromxy(int ix, int iy, double& x, double& y);
+
+  inline  int     XSize() { return ( eXY ? sY : sX ) ; }
+  inline  int     YSize() { return ( eXY ? sX : sY ) ; }
+
+  inline  void    XYCoord(int i, int j, double& x, double& y)
+                         { int ix, iy;  IJ2xy(i, j, ix, iy); 
+                           XYfromxy(ix, iy, x, y); }
+  inline  void    Coord(int i, int j, double& x, double& y)
+                       { int ix, iy;  double f; IJ2xy(i, j, ix, iy); 
+                       XYfromxy(ix, iy, x, y); if (eXY) {f=x; x=y; y=f; } }
+  inline  double  operator() (int i, int j) 
+                         { int ix, iy;  IJ2xy(i, j, ix, iy); 
+                         return Value(ix, iy); }
+  inline void     IJ2xy(int i, int j, int& x, int& y)
+                  { if  (eXY) {int ii = i; i = j; j = ii; }
+                  x = i*sgnX+offX; y = j*sgnY+offY; 
+                  return; }
+
+//    Calcul Min-Max, Moy-Sig
+  virtual int     CheckDyn(double& min, double& max, double& moy, double& sig, int& nbnul, int& nbsat, int vit=10);
+//    Calcul AutoLut
+  virtual void    ComputeLut_PicHisto(double& min, double& max, int nbsig=1, double fracmax=0.95);
+
+//    Calcul pixmap avec un LUT
+  virtual unsigned char * ComputePixmap(LUT* lut, int ofx, int ofy, int zm, 
+                           int xwsz, int ywsz, unsigned char * opix, 
+                           int * oxsp, int * oysp);
+protected :
+  int sX, sY;
+  double mOx, mDx, mOy, mDy;
+  int sgnX, sgnY;
+  int offX, offY;
+  bool invX, invY, eXY;
+};
+
+template <class T> 
+class P1DAdapter : public P1DArrayAdapter {
+public :
+                  P1DAdapter(T* data, int sz, bool ad=false) :
+                    P1DArrayAdapter(sz)
+                    { aDel = ad; mData = data; }
+
+  virtual 	  ~P1DAdapter() { if ( (aDel) && (mData != NULL) ) delete[] mData; }
+  virtual double  Value(int i) 
+                    {  if ( (i < 0) || (i >= mSize) ) return(0.); 
+                    return(mData[i]); }
+protected :
+  bool aDel;
+  T* mData;
+};
+
+
+template <class T> 
+class P2DAdapter : public P2DArrayAdapter {
+public :
+                  P2DAdapter(T* data, int sx, int sy, bool ad=false) :
+                    P2DArrayAdapter(sx, sy)
+                    { aDel = ad; mData = data; }
+
+  virtual 	  ~P2DAdapter() { if ( (aDel) && (mData != NULL) ) delete[] mData; }
+  virtual double   Value(int ix, int iy) 
+                    {  if ( (ix < 0)  || (iy < 0) || (ix >= sX) || (iy >= sY) ) return(0.); 
+                    return(mData[ix+iy*sX]); }
+protected :
+  bool aDel;
+  T* mData;
+};
+
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pi.rsc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pi.rsc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pi.rsc	(revision 464)
@@ -0,0 +1,28 @@
+PeidaInt*background:                         LightGrey
+PeidaInt*default*background:                 LightGrey
+PeidaInt*bottomShadowColor:                  Black
+PeidaInt*default*bottomShadowColor:          Black
+PeidaInt*Foreground:                         Black
+PeidaInt*default*Foreground:                 Black
+PeidaInt*topShadowColor:                     White
+PeidaInt*default*topShadowColor:             White
+PeidaInt*borderColor:                        Black
+
+PeidaInt*XmLabel.borderWidth:                1
+PeidaInt*XmScrollBar*background:             LightBlue
+PeidaInt*XmDrawingArea*background:           Black
+PeidaInt*XmPushButton*borderWidth:           0
+
+PeidaInt*XmText*XmNshadowThickness:          1
+PeidaInt*XmText*XmNhighlightThickness:          2
+
+PeidaInt*DefMenubar*XtNwidth:           250
+PeidaInt*DefMenubar*XtNheight:          30
+
+PeidaInt*fontList:           -*-helvetica-bold-r-normal-*-14-*-*-*-*-*-ISO8859-1
+PeidaInt*default*fontList:    -*-helvetica-bold-r-normal-*-14-*-*-*-*-*-ISO8859-1
+
+# Attention, ne pas mettre de blanc a la fin du nom de fonte
+PeidaInt*fontFamilyName:   *-courier
+
+PeidaInt*XmToggleButton*selectColor:                  Red
Index: /tags/V_LaSilla191199/SophyaPI/PI/pi3ddrw.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pi3ddrw.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pi3ddrw.cc	(revision 464)
@@ -0,0 +1,725 @@
+// Module PI : Peida Interactive PIDrawer3D PIDraw3DWdg
+// Drawer et DrawWidget 3D       R. Ansari 06/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include "pi3ddrw.h"
+#include "pidrwtools.h"
+
+
+// ......................................................................
+// ........................  Classe PIDrawer3D ..........................
+// ......................................................................
+//++
+// Class	PIDrawer3D
+// Lib		PI
+// include	pidrawer.h
+//
+//	Classe pour la création d'objets, capables de produire
+//	un dessin 3D dans une composante graphique.
+//--
+//++
+// Links	Parent
+// PIDrawer
+//--
+//++
+// Links	Voir aussi
+// PIGraphic3D
+// PIDraw3DWdg
+//--
+
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+// PIDrawer3D()
+//	Cosntructeur
+// void Set3DView_Obs(double xo, double yo, double zo, double teta, double phi, double psi, -
+//               double dax, double day, double co, double dco=0.2)
+//	Définition de la vue 3D. Voir "PIGraphic3D::Set3DCS_Obs(...)"
+// void Set3DView(double xc, double yc, double zc, double xo, double yo, double zo, -
+//                double dax, double day, double dco=0.2, double psi=0.)
+//	Définition de la vue 3D. Voir "PIGraphic3D::Set3DCS(...)"
+// bool Get3DView(double& xc, double& yc, double& zc, double& xo, double& yo, double& zo, -
+//                double& teta, double& phi, double& psi, double& dax, double& day, double& co, double& dco)
+//	Renvoie la définition de la Vue-3D. Retourne "true " si définie par "Set3DView_Obs()"
+// void Draw3DBoxe(PIGraphic3D* g3, double xx1, double xx2, double yy1, double yy2,  -
+//                 double zz1, double zz2, double xl1, double xl2, -
+//                 double yl1, double yl2, double zl1, double zl2)
+//	Trace une boîte avec les coordonnées matérialisant la vue 3D.
+//--
+
+/* --Methode-- */
+PIDrawer3D::PIDrawer3D()
+        : PIDrawer()
+{
+  xO = yO = 0.; zO = -10.;
+  xC = yC = zC = 0.;
+  tO = fO = pO = 0.; 
+  daxO = dayO = 0.25;
+  lCO = 10.;  dlCO = 3.;  
+  v3D_obs = false;
+  x3Min = y3Min = z3Min = -1.;  
+  x3Max = y3Max = z3Max = 1.;
+}
+
+/* --Methode-- */
+PIDrawer3D::~PIDrawer3D()
+{
+}
+
+/* --Methode-- */
+void PIDrawer3D::Set3DView_Obs(double xo, double yo, double zo, double teta, double phi, double psi, 
+                               double dax, double day, double co, double dco)
+{
+  tO = teta;  fO = phi;  pO = psi;
+  daxO = dax;  dayO = day;
+  lCO = co;   dlCO = dco;
+  v3D_obs = true;
+}
+
+/* --Methode-- */
+void PIDrawer3D::Set3DView(double xc, double yc, double zc, double xo, double yo, double zo, 
+                           double dax, double day, double dco, double psi)
+{
+  xC = xc;  yC = yc;  zC = zc;
+  xO = xo;  yO = yo;  zO = zo;
+  pO = psi;
+  daxO = dax;  dayO = day;
+  dlCO = dco;
+  v3D_obs = false;
+}
+
+/* --Methode-- */
+bool PIDrawer3D::Get3DView(double& xc, double& yc, double& zc, double& xo, double& yo, double& zo,
+                           double& teta, double& phi, double& psi, double& dax, double& day, double& co, double& dco)
+{
+  xo = xO;  yo = yO;  zo = zO;
+  xc = xC;  yc = yC;  zc = zC;
+  teta = tO;  phi = fO;  psi = pO;
+  dax = daxO;   day = dayO;
+  co = lCO;     dco = dlCO;
+  return(v3D_obs);
+}
+
+/* --Methode-- */
+PIGraphicUC* PIDrawer3D::SetDrwWdg(PIBaseWdgGen* drw, int x0, int y0, int dx, int dy, PIGraphicGen* g)
+{
+  mBWdg = drw;
+  xW0 = x0;   yW0 = y0;
+  xWd = dx;   yWd = dy;
+  if (mGrUC)  delete mGrUC;
+  PIGraphic3D* gr3d;
+  gr3d = new PIGraphic3D(g, x0, y0, dx, dy);
+  if (v3D_obs)  gr3d->Set3DCS_Obs(xO, yO, zO, tO, fO, pO, daxO, dayO, lCO, dlCO);
+  else  gr3d->Set3DCS(xC,yC,zC, xO, yO, zO, daxO, dayO, dlCO, pO);
+  mGrUC = gr3d;
+  return(gr3d); 
+}
+
+/* --Methode-- */
+void PIDrawer3D::DrawAxes(PIGraphicUC* g)
+{
+  if (axesFlags == kAxesNone) return;
+#if defined(CC_HAS_RTTI_SUPPORT)
+  PIGraphic3D* g3 = dynamic_cast<PIGraphic3D*>(g);
+#else
+  PIGraphic3D* g3 = (PIGraphic3D*)(g);
+#endif
+  Draw3DBoxe(g3, XMin3(), XMax3(), YMin3(), YMax3(), ZMin3(), ZMax3(),
+                 XMin3(), XMax3(), YMin3(), YMax3(), ZMin3(), ZMax3());  
+}
+
+/* --Methode-- */
+void PIDrawer3D::Draw3DBoxe(PIGraphic3D* g3, 
+                            double xx1, double xx2, double yy1, double yy2, 
+                            double zz1, double zz2, double xl1, double xl2, 
+                            double yl1, double yl2, double zl1, double zl2)
+{
+  if (mLAtt == PI_NotDefLineAtt)    g3->SelLine(PI_ThinLine);
+  if (mFSz == PI_NotDefFontSize)    g3->SelFontSz((YMax()-YMin())/150.);
+
+  PIGrCoord x1,y1,z1,x2,y2,z2;
+  char strg[64];
+  int k;
+  int NTicks = 5;  // Nb de ticks sur chaque axe
+
+  x1 = xx1;  y1 = yy1;  z1 = zz1;
+  x2 = xx2;   y2 = yy1;   z2 = zz1; 
+  g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+  y1 = y2 = yy2;
+  g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+  z1 = z2 = zz2;
+  g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+  y1 = y2 = yy1;  
+  g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+
+// Trace des ticks et labels axe X :
+  x1 = x2 = xx1;   y1 = y2 = yy1;  z1 = z2 = zz1;
+  for (k=0; k<NTicks; k++) {
+    x1 = x2 = (xx1+(double)k*(xx2-xx1)/(NTicks-1.));
+    z1 = zz1; z2 = zz1-0.02*(zz2-zz1);
+    y1 = y2 = yy1;
+    g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+    z2 = zz1-0.05*(zz2-zz1); 
+    y2 = yy1-0.075*(yy2-yy1);  
+    sprintf(strg,"%.2g", xl1+(double)k*(xl2-xl1)/(NTicks-1.));
+    g3->DrawString3D(x2, y2, z2, strg);
+    }
+  x2 = xx2+0.075*(xx2-xx1);  y2 = yy1;   z2 = zz1-0.05*(zz2-zz1); 
+  g3->DrawString3D(x2, y2, z2, "X");
+
+  x1 = xx1;  y1 = yy1;  z1 = zz1;
+  x2 = xx1;   y2 = yy2;   z2 = zz1; 
+  g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+  x1 = x2 = xx2;
+  g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+  z1 = z2 = zz2;
+  g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+  x1 = x2 = xx1;  
+  g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+  x1 = x2 = xx2;   y1 = y2 = yy1;  z1 = z2 = zz1;
+  for (k=1; k<NTicks; k++) {   // Attention, par le tick 0 pour Y
+    y1 = y2 = (yy1+(double)k*(yy2-yy1)/(NTicks-1.));
+    z2 = zz1-0.02*(zz2-zz1);
+    x1 = x2 = xx2; 
+    g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+    z2 = zz1-0.05*(zz2-zz1); 
+    x2 = xx2+0.075*(xx2-xx1);  
+    sprintf(strg,"%.2g", yl1+(double)k*(yl2-yl1)/(NTicks-1.));
+    g3->DrawString3D(x2, y2, z2, strg);
+    }
+  x2 = xx2;  y2 = yy2+0.075*(yy2-yy1);   z2 = zz1-0.05*(zz2-zz1); 
+  g3->DrawString3D(x2, y2, z2, "Y");
+
+  x1 = xx1;  y1 = yy1;  z1 = zz1;
+  x2 = xx1;   y2 = yy1;   z2 = zz2; 
+  g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+  x1 = x2 = xx2;
+  g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+  y1 = y2 = yy2;
+  g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+  x1 = x2 = xx1;  
+  g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+  x1 = x2 = xx1;   y1 = y2 = yy1;  z1 = z2 = zz1;
+  for (k=0; k<NTicks; k++) {
+    z1 = z2 = (zz1+(double)k*(zz2-zz1)/(NTicks-1.));
+    y2 = yy1-0.015*(yy2-yy1);
+    x2 = xx1-0.015*(xx2-xx1);
+    g3->DrawLine3D(x1, y1, z1, x2, y2, z2);
+    x2 = xx1-0.1*(xx2-xx1);  
+    y2 = yy1-0.1*(yy2-yy1);  
+    sprintf(strg,"%.2g", zl1+(double)k*(zl2-zl1)/(NTicks-1.));
+    g3->DrawString3D(x2, y2, z2, strg);
+    }
+  x2 = xx1-0.075*(xx2-xx1);  y2 = yy1-0.075*(yy2-yy1);   z2 = zz2+0.05*(zz2-zz1); 
+  g3->DrawString3D(x2, y2, z2, "Z");
+
+}
+
+// ......................................................................
+// .......................  Classe PIDraw3DWdg ..........................
+// ......................................................................
+
+//++
+// Class	PIDraw3DWdg
+// Lib		PI
+// include	pi3ddrw.h
+//
+//   	Classe pour la l'affichage et la manipulation d'un ensemble
+//	de *Drawer3D* avec la gestion de zoom, rotation, déplacement
+//	d'objet.
+//	* Bouton-1 : Envoie le message "PIMsg_Active".
+//	* Bouton-2 : Permet de faire tourner l'observateur (caméra) 
+//	autour de l'objet.
+//	* Shift-Bouton-2 : Permet de tourner l'objet en maintenant 
+//	la caméra fixe. Cette fonction peut-être réalisée sans le shift
+//	à partir du centre de l'objet, en l'ayant préalablement activée
+//	par <Alt>S.
+//	* Bouton-3 : Gestion de zoom (On approche/ éloigne la caméra, ou 
+//	on change l'angle d'ouverture) 
+//
+//	Gestion du clavier :
+//	* <Alt>G : Affichage d'une fenêtre de changement des attributs graphiques
+//	* <Alt>O : Action identique a <Alt>G
+//	* <Alt>V : Copier/*Coller* Ajout du texte du buffer copier/coller
+//	sur l'objet à la position courante de la souris
+//	* <Alt>Z : Supprime les textes et signes ajoutés au dessin.
+//	* <Alt>A : Active/desactive l'affichage des axes
+//	* <Alt>R : Reinitialise la vue 3D (vue par défaut) et rafraichit le dessin.
+//	* <Alt>S : Active/desactive le mode de rotation d'objet sans Shift
+//
+//--
+//++
+// Links	Parents
+// PIBaseWdg
+//--
+//++
+// Links	Voir aussi
+// PIDrawer3D
+//--
+
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+// PIDraw3DWdg(PIContainerGen *par, const char *nom, int sx=100, int sy=100, int px=0, int py=0)
+//	Constructeur
+// long	 kind()
+//	Renvoie le type de l'objet ("=PIDraw3DWdg::ClassId")
+// int AddDrawer3D(PIDrawer3D*, bool ad=false)
+//	Ajoute un Drawer3D
+//--
+
+/* --Methode-- */
+PIDraw3DWdg::PIDraw3DWdg(PIContainerGen *par, const char *nom, int sx, int sy, int px, int py)
+        : PIBaseWdg(par, nom, sx, sy, px, py)
+{  
+  vfixed = false;
+//  SetDefaultDrawRectangle(0.12, 0.12, 0.88, 0.88, true);
+  SetDefaultDrawRectangle(0., 0., 1., 1., true);
+  mBDrw = new PIElDrawer;
+  mBDrw->SetLimits(0.12,0.88, 0.12,0.88, kAxeDirLtoR,kAxeDirDownUp);
+  AddDrawer(mBDrw, 0.12, 0.12, 0.88, 0.88, true, false, false);
+  mPx = mPy = 0;
+
+  lPx = lPy = 0;
+  lCol = PI_Black;
+  cTeta = cPhi = 0.;  cUlen = 1.;
+
+  ActivateKeyboard();
+  ActivateButton(2);    //  Pour pouvoir tourner la camera
+  ActivateMove(2);      
+  ActivateButton(3);    //  Pour deplacer la camera le long de son axe
+  ActivateMove(3);
+  ActivateButton(1);    
+
+  mGr3d = new PIGraphic3D(mWGrC, 0, 0, sx, sy);
+  rOfg = false;
+  axfg = true;
+  skcfg = false;
+}
+
+/* --Methode-- */
+PIDraw3DWdg::~PIDraw3DWdg()
+{
+  delete mBDrw;
+  delete mGr3d;
+}
+
+/* --Methode-- */
+void PIDraw3DWdg::Set3DView_Obs(double xo, double yo, double zo, double teta, double phi, double psi, 
+                                double dax, double day, double co, double dco)
+{
+  mGr3d->Set3DCS_Obs(xo, yo, zo, teta, phi, psi, dax, day, co, dco);
+  list<int>::iterator it;
+  for(it = m3DrIl.begin(); it != m3DrIl.end(); it++)   
+#if defined(CC_HAS_RTTI_SUPPORT)
+    (dynamic_cast<PIDrawer3D*>(GetDrawerId(*it)))->Set3DView_Obs(xo, yo, zo, teta, phi, psi, dax, day, co, dco);
+#else
+    ((PIDrawer3D*)(GetDrawerId(*it)))->Set3DView_Obs(xo, yo, zo, teta, phi, psi, dax, day, co, dco);
+#endif
+  vfixed = true;
+}
+
+/* --Methode-- */
+void PIDraw3DWdg::Set3DView(double xc, double yc, double zc, double xo, double yo, double zo, 
+                            double dax, double day, double dco, double psi)
+{
+  mGr3d->Set3DCS(xc, yc, zc, xo, yo, zo, dax, day, dco, psi);
+  list<int>::iterator it;
+  for(it = m3DrIl.begin(); it != m3DrIl.end(); it++)   
+#if defined(CC_HAS_RTTI_SUPPORT)
+    (dynamic_cast<PIDrawer3D*>(GetDrawerId(*it)))->Set3DView(xc, yc, zc, xo, yo, zo, dax, day, dco, psi);
+#else
+    ((PIDrawer3D*)(GetDrawerId(*it)))->Set3DView(xc, yc, zc, xo, yo, zo, dax, day, dco, psi);
+#endif
+  vfixed = true;
+}
+
+/* --Methode-- */
+bool PIDraw3DWdg::Get3DView(double& xc, double& yc, double& zc, double& xo, double& yo, double& zo, 
+                            double& teta, double& phi, double& psi, double& dax, double& day, double& co, double& dco)
+{
+  return(mGr3d->Get3DCS(xc, yc, zc, xo, yo, zo, teta, phi, psi, dax, day, co, dco));
+}
+
+
+/* --Methode-- */
+void PIDraw3DWdg::Update3DView()
+{
+  list<int>::iterator it = m3DrIl.begin();
+  if (it == m3DrIl.end())  return;
+#if defined(CC_HAS_RTTI_SUPPORT)
+  PIDrawer3D* dr3 = dynamic_cast<PIDrawer3D*>(GetDrawerId(*it));
+#else
+  PIDrawer3D* dr3 = (PIDrawer3D*)(GetDrawerId(*it));
+#endif
+  if (dr3 == NULL)  return;
+  dr3->UpdateLimits();
+  double xo, yo, zo, xc, yc, zc, teta, phi, psi, dax, day, co, dco;
+  bool vobs;
+  vobs = dr3->Get3DView(xc, yc, zc, xo, yo, zo, teta, phi, psi, dax, day, co, dco);
+  if (vobs) Set3DView_Obs(xo, yo, zo, teta, phi, psi, dax, day, co, dco);
+  else Set3DView(xc, yc, zc, xo, yo, zo, dax, day, dco, psi);
+  Refresh();
+}
+
+
+/* --Methode-- */
+void PIDraw3DWdg::SetDrawers3DView()
+{
+  double xc, yc, zc, xo, yo, zo;
+  double teta, phi, psi;
+  double dax, day, co, dco;
+  bool vo;
+  vo = mGr3d->Get3DCS( xc, yc, zc, xo, yo, zo, teta, phi, psi, dax, day, co, dco);
+  list<int>::iterator it;
+
+#if defined(CC_HAS_RTTI_SUPPORT)
+  if (vo)   for(it = m3DrIl.begin(); it != m3DrIl.end(); it++)   
+    (dynamic_cast<PIDrawer3D*>(GetDrawerId(*it)))->Set3DView_Obs(xo, yo, zo, teta, phi, psi, dax, day, co, dco);
+  else   for(it = m3DrIl.begin(); it != m3DrIl.end(); it++)   
+    (dynamic_cast<PIDrawer3D*>(GetDrawerId(*it)))->Set3DView(xc, yc, zc, xo, yo, zo, dax, day, dco, psi);    
+#else
+  if (vo)   for(it = m3DrIl.begin(); it != m3DrIl.end(); it++)   
+    ((PIDrawer3D*)(GetDrawerId(*it)))->Set3DView_Obs(xo, yo, zo, teta, phi, psi, dax, day, co, dco);
+  else   for(it = m3DrIl.begin(); it != m3DrIl.end(); it++)   
+    ((PIDrawer3D*)(GetDrawerId(*it)))->Set3DView(xc, yc, zc, xo, yo, zo, dax, day, dco, psi);    
+#endif
+
+}
+
+/* --Methode-- */
+int PIDraw3DWdg::AddDrawer3D(PIDrawer3D* dr3, bool ad)
+{
+if (!vfixed)  { 
+  dr3->UpdateLimits();
+  double xo, yo, zo, xc, yc, zc, teta, phi, psi, dax, day, co, dco;
+  bool vobs;
+  vobs = dr3->Get3DView(xc, yc, zc, xo, yo, zo, teta, phi, psi, dax, day, co, dco);
+  if (vobs) Set3DView_Obs(xo, yo, zo, teta, phi, psi, dax, day, co, dco);
+  else Set3DView(xc, yc, zc, xo, yo, zo, dax, day, dco, psi);
+  }
+else { 
+  double xc, yc, zc, xo, yo, zo, teta, phi, psi, dax, day, co, dco;
+  if ( Get3DView(xc, yc, zc, xo, yo, zo, teta, phi, psi, dax, day, co, dco) ) 
+      dr3->Set3DView_Obs(xo, yo, zo, teta, phi, psi, dax, day, co, dco);
+  else  dr3->Set3DView(xc, yc, zc, xo, yo, zo, dax, day, co, psi);
+  }
+int id = AddDrawer(dr3, false, false, ad);
+if (m3DrIl.size() == 0)  dr3->SetAxesFlags(kStdAxes);
+m3DrIl.push_back(id);
+return(id);
+}
+
+/* --Methode-- */
+void PIDraw3DWdg::RemoveDrawer(int id)
+{
+  list<int>::iterator it;
+  for(it = m3DrIl.begin(); it != m3DrIl.end(); it++)   
+    if ( (*it) == id )  { m3DrIl.erase(it);  break; }
+  PIBaseWdg::RemoveDrawer(id);
+}
+
+/* --Methode-- */
+void PIDraw3DWdg::DeleteDrawers()
+{
+  m3DrIl.erase(m3DrIl.begin(),  m3DrIl.end());
+  PIBaseWdg::DeleteDrawers();
+}
+
+/* --Methode-- */
+void PIDraw3DWdg::Keyboard(int key, PIKeyModifier kmod)
+{
+if (kmod == PIKM_Alt) {
+  if (key == 'V' || key == 'v') RequestSelection();  // Pour coller (copier/coller)  
+  if (key == 'Z' || key == 'z') { mBDrw->ElDelAll();  Refresh(); } // Pour supprimer tous les signes 
+  if (key == 'O' || key == 'o' || key == 'G' || key == 'g') { 
+    PIDrwTools::SetCurrentBaseWdg(this);
+    PIDrwTools::ShowPIDrwTools();   // Fentre axes et options de trace
+    }
+  if (key == 'A' || key == 'a')  {    // On affiche ou on enleve les axes
+    axfg = !axfg;
+    list<int>::iterator it;
+    if (axfg) 
+      for(it = m3DrIl.begin(); it != m3DrIl.end(); it++)  
+         GetDrawerId(*it)->SetAxesFlags(kAxesNone);
+    else { 
+      it = m3DrIl.begin(); 
+      if (it != m3DrIl.end())  GetDrawerId(*it)->SetAxesFlags(kStdAxes);
+      }
+    Refresh(); 
+    }
+//  <Alt>S active la sensibilite de la zone centrale pour tourner l'objet
+  if (key == 'S' || key == 's')  skcfg = !skcfg;  
+  if (key == 'R' || key == 'r')  Update3DView();
+  }
+}
+
+/* --Methode-- */
+void PIDraw3DWdg::PasteSelection(unsigned int typ, void *pdata, unsigned int l)
+{
+if (typ != PICP_string) return;
+int ll = (l<256) ? l+1 : 256;
+char pc[256];
+strncpy(pc, (char*)pdata, ll-1);  pc[ll-1] = '\0';
+// printf("PIDraw3DWdg::PasteSelection() / Debug  %s - %d %d -> %g %g \n", pc, 
+//        mPx, mPy, (double)mPx/(double)XSize(), 1.-(double)mPy/(double)YSize());
+mBDrw->ElAddText((double)mPx/(double)XSize(), 1.-(double)mPy/(double)YSize(), pc );
+mBDrw->Refresh();
+}
+
+/* --Methode-- */
+void PIDraw3DWdg::But2Press(int x, int y)
+{
+  mGr3d->SetBaseGraphic(mWGrC, 0, 0, XSize(), YSize());
+  double xo, yo, zo;
+  double teta, phi, psi;
+  double dax, day, co, dco;
+  mGr3d->Get3DCS(cXc, cYc, cZc, xo, yo, zo, teta, phi, psi, dax, day, co, dco);
+//   puts("\n PIDraw3DWdg::But2Press() ");
+//   mGr3d->PrintCS();
+  lPx = x;  lPy = y;
+
+// Pour savoir si on se trouve ds la zone centrale   
+  int czx = XSize()/10;
+  int czy = YSize()/10;
+  PIKeyModifier kmod;
+  unsigned long tm;
+  GetLastEventInfo(kmod, tm);
+  rOfg = false;
+  if (kmod ==  PIKM_Shift)  rOfg = true;
+  else if (skcfg) {
+    int dmix = x-XSize()/2;
+    int dmiy = y-YSize()/2;
+    if (dmix < 0) dmix = -dmix;
+    if (dmiy < 0) dmiy = -dmiy;
+    if ((dmix < czx) && (dmiy < czy))  rOfg = true;
+    }
+
+  cUlen = 0.5*(dax+day)*co*0.3;    cDax = dax;   cDay = day;  clCO = co; 
+  cTeta = teta;   cPhi = phi;
+  SelPointerShape(PI_TDLRArrowPointer);
+  lCol = mWGrC->GetForeground();
+  //  mWGrC->SelForeground(GetBackgroundColor());
+  mWGrC->SelForeground(PI_Magenta);
+/*
+  {
+  char buff[256];
+  sprintf(buff, "But2Press() C=%g %g %g  T,P=%g %g   ", xc, yc, zc, cTeta, cPhi); 
+  mWGrC->DrawOpaqueString(0,20,buff);
+  }
+*/
+  DrawXYZAxes();
+  if (rOfg)  { czx /= 2;   czy /= 2;  mWGrC->DrawBox(XSize()/2-czx, YSize()/2-czy, czx*2, czy*2); }
+ 
+  Send(Msg(), PIMsg_Active);
+  PIDrwTools::SetCurrentBaseWdg(this);
+}
+
+/* --Methode-- */
+void PIDraw3DWdg::Ptr2Move(int x, int y)
+{
+  DrawXYZAxes();
+  double teta, phi;
+
+  if (rOfg) { 
+    phi = cPhi + (M_PI*0.25*(double)(x-lPx)/XSize());
+    teta = cTeta - (M_PI*0.25*(double)(y-lPy)/YSize());
+    mGr3d->RotateObject(teta, phi, false);
+    }
+  else {
+    phi = cPhi - (M_PI*0.5*(double)(x-lPx)/XSize());
+    teta = cTeta + (M_PI*0.5*(double)(y-lPy)/YSize());
+    mGr3d->RotateObserver(teta, phi, 0., false);
+    }
+/*  {
+  char buff[256];
+  sprintf(buff, "Ptr2Move() T,P=%g %g -> %g %g  ", cTeta, cPhi, teta, phi); 
+  mWGrC->DrawOpaqueString(0,20,buff);
+  }
+*/
+  DrawXYZAxes();
+}
+
+
+/* --Methode-- */
+void PIDraw3DWdg::But2Release(int x, int y)
+{
+  DrawXYZAxes();
+  if (rOfg) {
+    int czx = XSize()/20;
+    int czy = YSize()/20;
+    mWGrC->DrawBox(XSize()/2-czx, YSize()/2-czy, czx*2, czy*2);
+    }
+
+//  puts("\n PIDraw3DWdg::But2Release()");
+//  mGr3d->PrintCS();
+  SelPointerShape(PI_ArrowPointer);
+  mWGrC->SelForeground(lCol);
+  SetDrawers3DView();
+  Refresh();
+}
+
+
+/* --Methode-- */
+void PIDraw3DWdg::But3Press(int x, int y)
+{
+  double xo, yo, zo;
+  double teta, phi, psi;
+  double dax, day, co, dco;
+  mGr3d->Get3DCS(cXc, cYc, cZc, xo, yo, zo, teta, phi, psi, dax, day, co, dco);
+  mGr3d->SetBaseGraphic(mWGrC, 0, 0, XSize(), YSize());
+  lPx = x;  lPy = y;  
+  cUlen = 0.5*(dax+day)*co*0.3;    cDax = dax;   cDay = day;  clCO = co;
+  cTeta = teta;   cPhi = phi;
+  SelPointerShape(PI_TDLRArrowPointer);
+  lCol = mWGrC->GetForeground();
+  //  mWGrC->SelForeground(GetBackgroundColor());
+  mWGrC->SelForeground(PI_Magenta);
+/*
+  {
+  char buff[256];
+  sprintf(buff, "But3Press() C=%g %g %g  O= %g %g %g  L= %g   ", xc, yc, zc, xo, yo, zo, co); 
+  mWGrC->DrawOpaqueString(0,20,buff);
+  }
+*/
+  DrawXYZAxes();
+  Send(Msg(), PIMsg_Active);
+  PIDrwTools::SetCurrentBaseWdg(this);
+}
+
+/* --Methode-- */
+void PIDraw3DWdg::Ptr3Move(int x, int y)
+{
+  DrawXYZAxes();
+  double rapx = (double)(lPx-x)/XSize();
+  if (rapx > 0.) rapx = rapx*2.+1;
+  else rapx += 1.;
+  if (rapx < 0.3)  rapx = 0.3;
+  if (rapx > 3.)  rapx = 3.;
+  double rapy = (double)(y-lPy)/YSize();
+  if (rapy > 0.) rapy = rapy*2.+1;
+  else rapy += 1.;
+  if (rapy < 0.3)  rapy = 0.3;
+  if (rapy > 3.)  rapy = 3.;
+/*
+  {
+  char buff[256];
+  sprintf(buff, "Ptr3Move() Rap=%g %g -> %g %g %g     ", rapx, rapy, rapy*clCO, rapx*cDax, rapx*cDay);
+  mWGrC->DrawOpaqueString(0,20,buff);
+  }
+*/
+  mGr3d->ZoomInOut(rapy*clCO, rapx*cDax, rapx*cDay, false);
+  DrawXYZAxes();
+}
+
+/* --Methode-- */
+void PIDraw3DWdg::But3Release(int x, int y)
+{
+  DrawXYZAxes();
+  SelPointerShape(PI_ArrowPointer);
+  mWGrC->SelForeground(lCol);
+  SetDrawers3DView();
+  Refresh();
+}
+
+
+/* --Methode-- */
+void PIDraw3DWdg::DrawXYZAxes()
+{
+  mWGrC->SelGOMode(PI_GOXOR);
+  PIGrCoord x1,y1,z1,x2,y2,z2;
+  x1 = cXc;  y1 = cYc;  z1 = cZc;
+  x2 = cXc+cUlen;   y2 = cYc;   z2 = cZc; 
+  mGr3d->DrawLine3D(x1, y1, z1, x2, y2, z2);
+  x2 = cXc+cUlen*1.1;
+  mGr3d->DrawString3D(x2, y2, z2, "X");
+  x2 = cXc;   y2 = cYc+cUlen;   z2 = cZc; 
+  mGr3d->DrawLine3D(x1, y1, z1, x2, y2, z2);
+  y2 = cYc+cUlen*1.1;
+  mGr3d->DrawString3D(x2, y2, z2, "Y");   
+  x2 = cXc;   y2 = cYc;   z2 = cZc+cUlen; 
+  mGr3d->DrawLine3D(x1, y1, z1, x2, y2, z2);
+  z2 = cZc+cUlen*1.1;
+  mGr3d->DrawString3D(x2, y2, z2, "Z");   
+//   mGr3d->DrawCircle(0., 0., daxO*0.30);
+  char buff[256];
+  double xc,yc,zc,xo,yo,zo,teta,phi,psi,dax,day,co,dco;
+  mGr3d->Get3DCS(xc,yc,zc,xo,yo,zo,teta,phi,psi,dax,day,co,dco);
+  sprintf(buff, " C: %g %g %g -> O: %g %g %g  (T/P0= %g %g)     ", xc,yc,zc, xo, yo, zo, cTeta, cPhi);
+  mWGrC->DrawString(0,20,buff);
+  sprintf(buff, " T,P= %g %g %g lCO= %g  dax= %g %g UL=%g    ", teta,phi,psi,co,dax,day,cUlen); 
+  mWGrC->DrawString(0,40,buff);
+  mWGrC->SelGOMode(PI_GOCopy);  
+
+}
+
+
+/* --Methode-- */
+void PIDraw3DWdg::But1Press(int x, int y)
+{
+  Send(Msg(), PIMsg_Active);
+  PIDrwTools::SetCurrentBaseWdg(this);
+  mPx = x;  mPy = y;
+  if ( (x > 50) || ( y > 50) ) return; 
+  Update3DView();
+}
+
+/*   Pour debugger sur bouton-3 
+static int isw = 0;
+void PIDraw3DWdg::But3Press(int x, int y)
+x -= XSize()/2;
+y -= YSize()/2;
+
+double fx = (double)x/XSize(); 
+double fy = (double)y/YSize(); 
+if ( (fx<0.2) && (fx>-0.2) && (fy<0.2) && (fy>-0.2) ) {
+  
+  if ((isw%3) == 0) { 
+    Set3DView(0., 0., 0., 0., 0., -3. , 0.3, 0.3, 2); 
+    puts("\n Set3DView(0., 0., 0., 0., 0., -3. , 0.3, 0.3, 2)");
+  }
+  else if ((isw%3) == 1) { 
+    Set3DView(0., 0., 0., 2., 1., 3. , 0.3, 0.3, 2);
+    puts("\n Set3DView(0., 0., 0., 2., 1., 3. , 0.3, 0.3, 2)");
+  }
+  else if ((isw%3) == 2) { 
+    Set3DView_Obs(0.,4.,0.,3.14159/2.,-3.14159/2.,0.,0.25,0.25,4.,2.);
+    puts("\n Set3DView_Obs(0.,4.,0.,3.14159/2.,3.14159/2.,0.,0.25,0.25,4.,2.)");
+  }
+  isw++;
+  mGr3d->PrintCS();
+  double xc,yc,zc,xo,yo,zo,teta,phi,psi,dax,day,co,dco;
+  mGr3d->Get3DCS(xc,yc,zc,xo,yo,zo,teta,phi,psi,dax,day,co,dco);
+  mGr3d->Set3DCS(xc,yc,zc,xo,yo,zo,dax,day,dco,psi);
+  mGr3d->PrintCS();
+  mGr3d->Set3DCS_Obs(xo,yo,zo,teta,phi,psi,dax,day,co,dco);
+  mGr3d->PrintCS();
+  puts(" --------------------- \n");
+  Refresh();
+  return;
+}
+if ((x > 0) && (y > 0) )  { 
+  puts(" But3Press()Set3DView(0., 0., 0., 5., 0., 0. , 0.3, 0.3, 2)");
+  Set3DView(0., 0., 0., 5., 0., 0. , 0.3, 0.3, 2);
+}
+else if ((x < 0) && (y > 0) )  { 
+  puts(" But3Press()Set3DView(0., 0., 0., 0., 5., 1. , 0.3, 0.3, 2) ");
+  Set3DView(0., 0., 0., 0., 5., 1. , 0.3, 0.3, 2);
+}
+else  if ((x < 0) && (y < 0) ) {
+  puts(" But3Press()Set3DView(0., 0., 0., 1., 1., 5. , 0.3, 0.3, 2)");
+  Set3DView(0., 0., 0., 1., 1., 5. , 0.3, 0.3, 2);
+}
+else {
+  puts(" But3Press()Set3DView(0., 0., 0., -3., -3., 3. , 0.3, 0.3, 2)");
+  Set3DView(0., 0., 0., -3., -3., 3. , 0.3, 0.3, 2);
+}
+
+Refresh();
+*/
Index: /tags/V_LaSilla191199/SophyaPI/PI/pi3ddrw.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pi3ddrw.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pi3ddrw.h	(revision 464)
@@ -0,0 +1,125 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive PIDrawer3D PIDraw3DWdg
+// Drawer et DrawWidget 3D       R. Ansari 06/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIDRW3D_H_SEEN
+#define PIDRW3D_H_SEEN
+
+#include "pisysdep.h"
+#include "pidrawer.h"
+#include "pigraph3d.h"
+
+#include PIBWDG_H
+
+
+// -----------------  Traceur (Drawer) 3D  -------------------
+
+class PIDrawer3D : public PIDrawer
+{
+public :
+			PIDrawer3D();
+  virtual		~PIDrawer3D();
+
+  virtual void		Set3DView_Obs(double xo, double yo, double zo, double teta, double phi, double psi, 
+                                      double dax, double day, double co, double dco=0.2);
+  virtual void       	Set3DView(double xc, double yc, double zc, double xo, double yo, double zo, 
+                                  double dax, double day, double dco=0.2, double psi=0.);
+  bool           	Get3DView(double& xc, double& yc, double& zc, double& xo, double& yo, double& zo,
+                                  double& teta, double& phi, double& psi, double& dax, double& day, double& co, double& dco);
+  
+  virtual PIGraphicUC*	SetDrwWdg(PIBaseWdgGen* drw, int x0, int y0, int dx, int dy, PIGraphicGen* g);
+
+  virtual void       	DrawAxes(PIGraphicUC* g);
+  virtual void       	Draw3DBoxe(PIGraphic3D* g3, double xx1, double xx2, double yy1, double yy2, 
+                                                    double zz1, double zz2, double xl1, double xl2, 
+                                                    double yl1, double yl2, double zl1, double zl2);
+
+  double XMin3() const {return x3Min;}
+  double XMax3() const {return x3Max;}
+  double YMin3() const {return y3Min;}
+  double YMax3() const {return y3Max;}
+  double ZMin3() const {return z3Min;}
+  double ZMax3() const {return z3Max;}
+
+protected :
+  double xO, yO, zO;  // Position observateur = camera
+  double xC, yC, zC;  // Position centre du champ
+  double tO,fO,pO;    // Orientation observateur (Teta, Phi, Psi, Angles d Euler)
+  double daxO, dayO;  // Demi-ouverture de la camera suivant les deux axes de projection (xp/zp, yp/zp) 
+  double lCO, dlCO;   // Distance Camera-Centre du champ et profondeur de champ 
+  bool v3D_obs;      // Si defini par Set3DView_Obs 
+  double x3Min, x3Max;  // Pour delimiter le cube 3D 
+  double y3Min, y3Max;  // Pour delimiter le cube 3D 
+  double z3Min, z3Max;  // Pour delimiter le cube 3D 
+};
+
+
+//------------------------------ Classe PIDrawer3D --------------------
+
+class PIDraw3DWdg : public PIBaseWdg {
+public:
+  enum {ClassId = 5500};
+
+			PIDraw3DWdg(PIContainerGen *par, const char *nom,
+                                    int sx=100, int sy=100, int px=0, int py=0);
+  virtual		~PIDraw3DWdg();
+  virtual long		kind() {return ClassId; }
+
+
+  virtual void		Set3DView_Obs(double xo, double yo, double zo, double teta, double phi, double psi, 
+                                      double dax, double day, double co, double dco=0.2);
+  virtual void       	Set3DView(double xc, double yc, double zc, double xo, double yo, double zo, 
+                                  double dax, double day, double dco=0.2, double psi=0.);
+  bool           	Get3DView(double& xc, double& yc, double& zc, double& xo, double& yo, double& zo, 
+                                  double& teta, double& phi, double& psi, double& dax, double& day, double& co, double& dco);
+
+  virtual void          Update3DView();   // Vue 3-D a partir de Drawer No 1
+
+  inline void	     	SetTitles(const char* tt=NULL, const char* tb=NULL)
+                                  { mBDrw->SetTitles(tt, tb); }
+  inline void	     	SetTitles(string const & tt, string const & tb)
+                                  { mBDrw->SetTitles(tt, tb); }
+  inline PIElDrawer*    BaseDrawer() { return mBDrw; };
+
+  int                   AddDrawer3D(PIDrawer3D*, bool ad=false);   // Ajoute un Drawer 
+
+//  Pour tenir trace des Drawers-3D qui sont detruits 
+  virtual void      	RemoveDrawer(int id);       
+  virtual void       	DeleteDrawers();            
+
+  virtual void		But1Press(int x, int y);
+
+  virtual void		But2Press(int x, int y);
+  virtual void		But2Release(int x, int y);
+  virtual void		Ptr2Move(int x, int y);
+
+  virtual void		But3Press(int x, int y);
+  virtual void		But3Release(int x, int y);
+  virtual void		Ptr3Move(int x, int y);
+
+  virtual void 		Keyboard(int key, PIKeyModifier kmod);
+  virtual void 		PasteSelection(unsigned int typ, void *pdata, unsigned int l);
+
+
+protected :
+  virtual void		SetDrawers3DView();
+  virtual void		DrawXYZAxes();
+
+  PIElDrawer* mBDrw;   // Objet traceur d'elements de fond
+  int mPx, mPy;        // Position pointeur - Bouton-1 
+  
+  bool vfixed;       // SetView fait ou pas
+  list<int> m3DrIl;  // Liste des Id drawers 3D 
+  PIGraphic3D* mGr3d;   // PIGraphic3D courante
+  int lPx, lPy;         // dernier position pointeur
+  PIColors lCol;        // Couleur
+  double cTeta, cPhi, cUlen;    // Pour garder valeurs avant rotation, Unite de longeur
+  double cXc, cYc, cZc;         // Pour garder position du centre de champ 
+  double clCO, cDax, cDay;      // Pour garder les valeurs avant Zoom In/Out
+  bool  rOfg;                  // si Vrai  on fait tourner l'objet et pas la camera
+  bool  axfg;                  // si Vrai on trace les axes
+  bool  skcfg;                 // si Vrai click-2 au centre -> rotation objet
+};
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/piapplgen.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piapplgen.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piapplgen.cc	(revision 464)
@@ -0,0 +1,161 @@
+//  Classe de base d'objets application pour 
+//  les programmes graphiques interactives
+//
+//                  E.Aubourg , R. Ansari  96 - 98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+//++
+// Class	PIApplication
+// Lib		PI
+// include	piapplgen.h
+//
+//	Classe de base pour l'objet application. L'objet PIApplication 
+//	doit être créé avant la création des autres objets de PI.
+//	La classe "PIApplication" a implémentation dépendante 
+//	du systeme utilisé (Mac, XWindow, ...). La classe "PIApplicationGen" 
+//	est la classe qui définit l'interface, et ne doit pas être instanciée 
+//	directement (Méthodes virtuelles pures). Les objets instanciés sont 
+//	de la classes "PIApplication" et le fichier entête correspondant est 
+//	"PIAPP_H" défini dans "pisysdep.h".
+//--
+//++
+// Links	Parents
+// PIMsgHandler
+//--
+//++
+// Titre	Constructeur
+//--
+//++
+// PIApplication(int sx=200, int sy=30, int narg=0, char *arg[]=NULL)
+//	Constructeur. "sx,sy" est la taille de la fenêtre principale
+//	(ou PIContainer) associée à l'application. Des arguments
+//	optionnels, par exemple celle de la ligne de commande peuvent 
+//	être transmis à l'objet PIApplication. Dans le cas d'Unix/XWindow
+//	par exemple, les options reconnues par la Xtoolkit peuvent 
+//	être passées à l'objet application.
+//--
+
+//++
+// Titre	Méthodes
+//--
+//++
+// PIContainer*   MainWin()
+//	Renvoie le pointeur de l'objet "PIContainer" associé à l'application.
+// PIMenubar*   Menubar()
+//	Renvoie le pointeur de l'objet "PIMenubar" associé à l'application.
+// void AppendMenu(PIMenu *pdm)
+//	Ajoute le "PIMenu *pdm" au Menubar de l'application. Le titre 
+//	du menu dans le menubar est le nom de l'objet menu. 
+// void Run() Stop
+//	Démarre, arrête la boucle d'événements.
+//--
+
+
+#include "piapplgen.h"
+
+// Variable qui contient le pointeur de l'application courante
+// permet de recuperer la taille pref pour la fonction globale 
+static PIApplicationGen * curapp = NULL;
+
+PIApplicationGen::PIApplicationGen()
+:topcont(NULL), menubar(NULL), mState(0)
+{
+curapp = this;   
+}
+
+PIApplicationGen::~PIApplicationGen()
+{}
+
+
+void PIApplicationGen::AppendMenu(PIMenu *pdm)
+{
+if (menubar)
+  menubar->AppendMenu(pdm);
+return;
+}
+
+//++
+// void SetReady()
+//	Modifie l'état global de l'application - Pssage à l'état normal,
+//	prêt à traiter les actions utilisateur.
+// void SetBusy()
+//	Passage en mode de calcul - La souris prend la forme de la montre
+//	pour la fenêtre principale
+// void SetBlocked()
+//	Passge en mode bloqué. La barre de menu devient insensible
+// int GetState()
+//	Renvoie l'état global de l'application "(kReadyState, kBusyState, kBlockedState)".
+//--
+void PIApplicationGen::SetReady()
+{
+mState = kReadyState;
+}
+
+void PIApplicationGen::SetBusy()
+{
+mState = kBusyState;
+}
+
+void PIApplicationGen::SetBlocked()
+{
+mState = kBlockedState;
+}
+
+int PIApplicationGen::GetState()
+{
+return mState;
+}
+
+//++
+// Titre	Redirection StdOut, StdErr
+//	Il est possible de rediriger les flots de sortie
+//	standard et d'erreur vers un objet PIConsol.
+//--
+
+//++
+// void  RedirectOutStream(PIConsole* cons, unsigned char va= PIVA_Def)
+//	Redirige le flot de sortie ("stdout" sous Unix) vers l'objet 
+//	PIConsole "cons". si "cons==NULL", redirection 
+//	sur le flot original.
+//
+// void  RedirectErrStream(PIConsole* cons, unsigned char va= PIVA_Def)
+//	Redirige le flot des messages d'erreur ("stderr" sous Unix) 
+//	vers l'objet PIConsole "cons". si "cons==NULL", redirection
+//	 sur le flot original.
+//--
+
+//++
+// Titre	Informations globales
+//	Les méthodes suivantes permettent d'acceder aux informations  
+//	concernant l'écran (tailles, ...). Des fonctions globales sont 
+//	prévues ( "PIApplicationPrefCompSize()" et "PIApplicationScreenSize()" )
+//	afin d'obtenir ces informations sans avoir besoin d'une instance de la 
+//	classes application.
+//--
+//++
+// void  PIApplicationPrefCompSize(int& szx, int& szy)
+//	Fonction globale
+// void  PrefCompSz(int& szx, int& szy)
+//	Renvoie la taille préférée pour les composantes standard. "szx,szy" 
+//	est la taille (en pixels) pour un champ texte, ou un bouton "(PIText, PIButton)" 
+//	avec l'étiquette ou un contenu de 6 caractères (Ex: Cancel).
+//
+// void  PIApplicationScreenSize()
+//	Fonction globale
+// void  ScreenSz(int& szx, int& szy)
+//	Renvoie la taille en pixels de l'écran
+//  
+//--
+
+void     PIApplicationPrefCompSize(int& szx, int& szy)
+{
+szx = szy = 10;
+if (curapp)  curapp->PrefCompSz(szx, szy);
+return; 
+}
+void     PIApplicationScreenSize(int& szx, int& szy)
+{
+szx = szy = 500;
+if (curapp)  curapp->ScreenSz(szx, szy);
+return; 
+}
Index: /tags/V_LaSilla191199/SophyaPI/PI/piapplgen.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piapplgen.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piapplgen.h	(revision 464)
@@ -0,0 +1,48 @@
+#ifndef PIAPPLGEN_H_SEEN
+#define PIAPPLGEN_H_SEEN
+
+#include "pimsghandler.h"
+#include "pisysdep.h"
+#include PICONT_H
+#include PIMENUBAR_H
+#include "picons.h"
+
+
+class PIApplicationGen : public PIMsgHandler {
+public:
+        enum { kReadyState=0, kBusyState=1, kBlockedState=2 };
+
+				  PIApplicationGen();
+	virtual		          ~PIApplicationGen();
+	
+	virtual void              Run()=0;
+	virtual void              Stop()=0;
+
+        virtual void              SetReady();
+        virtual void              SetBusy(); 
+        virtual void              SetBlocked();
+        virtual int               GetState();
+
+
+	virtual PIContainer*      MainWin() {return topcont;}
+        virtual PIMenubar*        Menubar() {return menubar;}
+
+        virtual void              AppendMenu(PIMenu *pdm);
+
+        virtual void              PrefCompSz(int& szx, int& szy) = 0;
+        virtual void              ScreenSz(int& szx, int& szy) = 0;
+
+        virtual void              RedirectOutStream(PIConsole* cons, unsigned char va= PIVA_Def)  = 0;
+        virtual void              RedirectErrStream(PIConsole* cons, unsigned char va= PIVA_Ital|PIVA_Red) = 0;
+
+protected:
+    PIContainer               *topcont;
+    PIMenubar                 *menubar;
+    int                       mState;
+};
+
+//   Fonction globale pour recuperer la taille standard des composants (taille x,y) 
+void     PIApplicationPrefCompSize(int& szx, int& szy);  
+void     PIApplicationScreenSize(int& szx, int& szy);  
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/piapplmac.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piapplmac.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piapplmac.cc	(revision 464)
@@ -0,0 +1,120 @@
+
+#include "piapplmac.h"
+#include "pippmenubar.h"
+#include "pippapplmac.h"
+#include "piwindowmac.h"
+
+#include <LApplication.h>
+#include <LGrowZone.h>
+#include <UDrawingState.h>
+#include <UMemoryMgr.h>
+#include <SIOUX.h>
+#include <LAttachment.h>
+
+class PIInit {
+public:
+  PIInit() {
+    SIOUXSettings.initializeTB = false;
+    SIOUXSettings.standalone = false;
+    SIOUXSettings.setupmenus = false;
+    SIOUXSettings.showstatusline = true;
+  }
+};
+
+PIInit piInit;
+
+static PIApplication* cur_piapp = NULL;
+PIApplication* PIApplicationGetApp() { return cur_piapp; }
+
+
+class PISIOUXAttachment : public LAttachment {
+public:
+  PISIOUXAttachment();
+protected:
+ virtual void	ExecuteSelf(
+							MessageT		inMessage,
+							void			*ioParam);
+};
+
+PISIOUXAttachment::PISIOUXAttachment()
+: LAttachment()
+{}
+
+void PISIOUXAttachment::ExecuteSelf(MessageT msg, void* p)
+{
+  if (msg == msg_Event)
+    mExecuteHost = !SIOUXHandleOneEvent((EventRecord*)p);
+  if (!mExecuteHost)
+    UDesktop::NormalizeWindowOrder();
+}
+
+PIApplicationMac::PIApplicationMac(int sx, int sy, int /*narg*/, char** /*arg*/)
+{
+  SIOUXSettings.initializeTB = false;
+  SIOUXSettings.standalone = false;
+  SIOUXSettings.setupmenus = false;
+  SIOUXSettings.showstatusline = true;
+									// Set Debugging options
+	SetDebugThrow_(debugAction_Alert);
+	SetDebugSignal_(debugAction_Alert);
+
+	InitializeHeap(3);				// Initialize Memory Manager
+									// Parameter is number of Master Pointer
+									//   blocks to allocate
+	
+									// Initialize standard Toolbox managers
+	UQDGlobals::InitializeToolbox(&qd);
+	
+	new LGrowZone(20000);			// Install a GrowZone function to catch
+									//    low memory situations.
+									
+		// Register functions to create core PowerPlant classes
+	
+	RegisterAllPPClasses();
+
+	macAppli = new PIPPApplMac;
+	macAppli->AddAttachment(new PISIOUXAttachment);
+	
+    menubar = new PIMenubar(this, "DefMenubar");
+    topcont = new PIWindowMac(this, "TopLevel", PIWK_floating, sx, sy, 10, 45);
+
+  cur_piapp = this;
+}
+
+
+PIApplicationMac::~PIApplicationMac()
+{
+	delete macAppli;
+}
+
+void
+PIApplicationMac::Run()
+{
+    topcont->Show();
+	macAppli->Run();
+}
+
+void
+PIApplicationMac::Stop()
+{
+	macAppli->DoQuit();
+}
+
+/* --Methode-- */
+void PIApplicationMac::PrefCompSz(int& szx, int& szy)
+{
+  szx = 10;
+  szy = 10;
+}
+
+/* --Methode-- */
+void PIApplicationMac::ScreenSz(int& szx, int& szy)
+{
+  szx = 800;
+  szy = 600;
+}
+
+void PIApplicationMac::RedirectOutStream(PIConsole* cons, unsigned char va)
+{}
+void PIApplicationMac::RedirectErrStream(PIConsole* cons, unsigned char va)
+{}
Index: /tags/V_LaSilla191199/SophyaPI/PI/piapplmac.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piapplmac.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piapplmac.h	(revision 464)
@@ -0,0 +1,28 @@
+#ifndef PIAPPLMAC_H_SEEN
+#define PIAPPLMAC_H_SEEN
+
+#include "piapplgen.h"
+
+class LApplication;
+class PIApplicationMac : public PIApplicationGen {
+public:
+					PIApplicationMac(int sx=200, int sy=30, int narg=0, char *arg[]=NULL);
+	virtual		   ~PIApplicationMac();
+	
+	virtual void    Run();
+	virtual void    Stop();
+	
+        virtual void              PrefCompSz(int& szx, int& szy);
+        virtual void              ScreenSz(int& szx, int& szy);
+
+        virtual void              RedirectOutStream(PIConsole* cons, unsigned char va= PIVA_Def);
+        virtual void              RedirectErrStream(PIConsole* cons, unsigned char va= PIVA_Ital);
+//protected:
+	LApplication* macAppli;
+};
+
+typedef PIApplicationMac PIApplication;
+
+//  Pour recuperer un objet PIApplication 
+PIApplication* PIApplicationGetApp();
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/piapplx.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piapplx.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piapplx.cc	(revision 464)
@@ -0,0 +1,329 @@
+#include <stdio.h>
+#include <X11/cursorfont.h>
+#include "piapplx.h"
+#include "picontainerx.h"
+
+// $CHECK$ - Reza Aout 99
+// Il y a un probleme sur la gestion de la taille de la fenetre principale
+// SetBinding(elastic) ne marche correctement pas sur la fenetre principale
+// et Des SetSize intempestive peuvent generer des comportements bizarres ! 
+
+// Pour rediriger stdout 
+#include <unistd.h>
+#include <fcntl.h>
+
+#include <iostream.h>
+
+
+// #define DEBUG_APPLX
+
+static Cursor a_curs[3];
+static bool a_fgcur=false;
+
+//  Voir fichier pimenux.cc , Pour resoudre certains conflits avec les WindowManagers
+void SetTopWdgForMenuX(SysDWdg mtw);
+
+static PIApplication* cur_piapp = NULL;
+PIApplication* PIApplicationGetApp() { return cur_piapp; }
+
+
+// Classe de container special pour top-container de Application X
+
+class PITopContAppX : public PIContainer {
+public :
+	    	PITopContAppX(PIContainer *par, char *nom, PIWdg* topw,
+                          int sx=10, int sy=10, int px=0, int py=0);
+   virtual  	~PITopContAppX(); 
+
+   virtual void SetSize(int sx, int sy);
+   virtual void SetPos(int px, int py);
+
+PIWdg* mTopWdg;
+};
+
+/* --Methode-- */
+PITopContAppX::PITopContAppX(PIContainer *par, char *nom, PIWdg* topw, int sx, int sy, int px, int py)
+        : PIContainer(par, nom, (sx>10)?sx:10, (sy>10)?sy:10, px, py)
+{
+ mTopWdg = topw;
+ SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_fixed);  
+}
+
+/* --Methode-- */
+PITopContAppX::~PITopContAppX()
+{
+}
+
+/* --Methode-- */
+void PITopContAppX::SetSize(int sx, int sy)
+{
+if ((sx <10) || (sy < 10) ) return; 
+#if !defined(SunOS)
+// Probleme sur Sun - Reza 10/99
+mTopWdg->SetSize(sx+XPos(), sy+YPos());
+#endif
+Parent()->SetSize(sx+XPos(), sy+YPos());
+// PIContainer::SetSize(sx, sy);   Probleme sur Sun - Reza 9/08/99
+}
+
+
+/* --Methode-- */
+void PITopContAppX::SetPos(int px, int py)
+{
+}
+
+/* --Methode-- */
+PIApplicationX::PIApplicationX(int sx, int sy, int narg, char *arg[])
+: PIApplicationGen()
+{
+int sxt, syt;
+
+#ifdef DEBUG_APPLX
+puts("PIApplicationX::PIApplicationX()_info : App creation");
+#endif
+mStop = true;
+
+
+topwdg = new PIWdgX(narg, arg);
+
+int msx,msy;
+PrefCompSz(msx, msy);
+msy+=5;
+topwdg->SetSize(sx, sy+msy);
+//DBG printf("PIApplicationX-DBG:: Size=%d %d \n", topwdg->XSize(), topwdg->YSize());
+
+intcont = new PIContainerX((PIMsgHandler *)this, topwdg, "MBCont", 
+                            sx, sy+msy, 0, 0);
+// Pb avec les Popup MenuX et certains Window Manager , voir pimenux.cc
+SetTopWdgForMenuX(intcont->XtWdg());
+
+menubar = new PIMenubar(this, "DefMenubar");
+Menubar()->SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_free);
+sxt = ( sx > Menubar()->XSize() ) ? sx : Menubar()->XSize();
+syt = ( sy > 10 ) ? sy : 10;
+// syt += Menubar()->YSize();
+// syt += msy;
+// topwdg->SetSize(sxt, syt);
+// MBCont()->SetSize(sxt, syt);
+if (sx < sxt)  sx = sxt;
+if (sy < 10) sy = 10;
+topcont = new PITopContAppX(MBCont(), "TopLevelCont", topwdg, 
+                            sx, sy, 0, msy);
+MBCont()->Show();
+//DBG printf("PIApplicationX-DBG2:: MBContSize=%d %d \n", MBCont()->XSize(), MBCont()->YSize());
+//DBG printf("PIApplicationX-DBG2:: topcontSize=%d %d \n", MainWin()->XSize(), MainWin()->YSize());
+
+topcont->Show();
+
+
+if (!a_fgcur)
+  {
+  Display *mdsp;
+  mdsp = XtDisplay (topwdg->XtWdg()); 
+  a_curs[0] = XCreateFontCursor(mdsp, XC_arrow);
+  a_curs[1] = XCreateFontCursor(mdsp, XC_X_cursor);
+  a_curs[2] = XCreateFontCursor(mdsp, XC_watch);
+  }
+
+topwdg->Manage();
+cur_piapp = this;
+mState = -1;
+SetReady();
+}
+
+/* --Methode-- */
+PIApplicationX::~PIApplicationX()
+{
+#ifdef DEBUG_APPLX
+puts("PIApplicationX::~PIApplicationX()_info : App delete");
+#endif
+Display *mdsp;
+mdsp = XtDisplay (topwdg->XtWdg()); 
+topwdg->UnManage();
+delete menubar;
+if (topcont != MBCont())  delete topcont;
+delete intcont;
+delete topwdg;
+XtCloseDisplay(mdsp);
+cur_piapp = NULL;
+return;
+}
+
+/* --Methode-- */
+void PIApplicationX::Run()
+{
+XEvent evt;
+#ifdef DEBUG_APPLX
+puts("PIApplicationX::Run()_info : App Run ");
+#endif
+
+
+int szx, szy, szf;
+XtAppContext * appctx = PIXtAppCtx(szx, szy, szf);
+
+// Pour appeler FinishCreate() des objets dans la fenetre principale 
+if (mStop) { // C'est la premiere fois
+  topwdg->SetSize(MBCont()->XSize(), MBCont()->YSize());
+  MBCont()->FinishCreate();   
+  }
+else mStop = true;   // On rerentre apres un stop 
+while (mStop)
+  {
+  XtAppNextEvent(*appctx, &evt);
+  XtDispatchEvent(&evt);
+  }
+return;
+}
+
+
+/* --Methode-- */
+void PIApplicationX::SetReady()
+{
+Display * mdsp = XtDisplay (topwdg->XtWdg());
+if (mState != kReadyState)
+  {
+  mState = kReadyState;
+  Menubar()->SetSensitive();
+  XDefineCursor(mdsp, XtWindow(topwdg->XtWdg()), a_curs[0]);
+  }
+XFlush(mdsp);
+}
+
+/* --Methode-- */
+void PIApplicationX::SetBusy()
+{
+Display * mdsp = XtDisplay (topwdg->XtWdg());
+if (mState != kBusyState)
+  {
+  mState = kBusyState;
+  Menubar()->SetSensitive();
+//  if ( XtIsRealized(topwdg->XtWdg()) )
+  XDefineCursor(mdsp, XtWindow(topwdg->XtWdg()), a_curs[2]);
+  }
+XFlush(mdsp);
+}
+
+/* --Methode-- */
+void PIApplicationX::SetBlocked()
+{
+Display * mdsp = XtDisplay (topwdg->XtWdg());
+if (mState != kBlockedState)
+  {
+  mState = kBlockedState;
+  Menubar()->SetUnSensitive();
+  XDefineCursor(mdsp, XtWindow(topwdg->XtWdg()), a_curs[1]);
+  }
+XFlush(mdsp);
+return;
+}
+
+
+/* --Methode-- */
+void PIApplicationX::PrefCompSz(int& szx, int& szy)
+{
+int szf;
+PIXtAppCtx(szx, szy, szf);
+return;
+}
+
+/* --Methode-- */
+void PIApplicationX::ScreenSz(int& szx, int& szy)
+{
+Display * dsp = PIXDisplay();
+szx = DisplayWidth(dsp, DefaultScreen(dsp));
+szy = DisplayHeight(dsp, DefaultScreen(dsp));
+}
+
+
+
+/* Call-Back - Fonction privee de ce fichier */
+static void redirectstream_callback(XtPointer, int *, XtInputId*);
+
+static PIConsole* consstream[2] = {NULL, NULL};
+static unsigned char streamva[2] = { PIVA_Def, PIVA_Ital};
+static int streamno[2] = {0,1};
+static XtInputId inputid[2];
+static int origfiledes[2]={-1, -1};   // descripteurs de fichiers de depart
+
+static void redirectstream_callback(XtPointer cld, int * fd, XtInputId* /*iid*/)
+{
+char buff[128];
+int nr;
+
+int idx = *((int*)cld);
+if (idx != 1) idx = 0; 
+if (!consstream[idx]) return;
+while ( (nr=read(*fd, buff, 127)) > 0 ) {
+  buff[nr] = '\0'; consstream[idx]->AddStr(buff, streamva[idx], false);
+  }
+consstream[idx]->Refresh();
+}
+
+/* --Methode-- */
+void PIApplicationX::RedirectOutStream(PIConsole* cons, unsigned char va)
+{
+if ( origfiledes[0]<0 )  origfiledes[0] = fcntl(1, F_DUPFD);     
+if ( cons == consstream[0]) return;
+if ( (consstream[0]) && (cons) ) { consstream[0] = cons; streamva[0] = va; return; }
+else if (!cons) { 
+  consstream[0] = NULL;  
+  XtRemoveInput(inputid[0]);
+  dup2(origfiledes[0], 1);
+  return;
+  }
+
+consstream[0] = cons; streamva[0] = va;
+
+int p[2];
+pipe(p);
+// Redirection de stdout (fid=1) :  
+close(1);
+dup(p[1]);
+close(p[1]);
+fcntl(p[0], F_SETFL, O_NONBLOCK);
+
+#if (!defined(__GNUG__) && !defined(HPUX))
+setlinebuf(stdout);
+#endif
+ios::sync_with_stdio();
+
+int szx, szy, szf;
+XtAppContext * appctx = PIXtAppCtx(szx, szy, szf);
+inputid[0] = XtAppAddInput(*appctx, p[0], (XtPointer) XtInputReadMask, 
+                           redirectstream_callback, (XtPointer) streamno);
+}
+
+/* --Methode-- */
+void PIApplicationX::RedirectErrStream(PIConsole* cons, unsigned char va)
+{
+if ( origfiledes[1]<0 )  origfiledes[1] = fcntl(2, F_DUPFD);     
+if ( cons == consstream[1]) return;
+if ( (consstream[1]) && (cons) ) { consstream[1] = cons; streamva[1] = va; return; }
+else if (!cons) { 
+  consstream[1] = NULL;  
+  XtRemoveInput(inputid[1]);
+  dup2(origfiledes[1], 2);
+  return;
+  }
+
+consstream[1] = cons; streamva[1] = va;
+
+int p[2];
+pipe(p);
+// Redirection de stderr (fid=2) :
+close(2);
+dup(p[1]);
+close(p[1]);
+fcntl(p[0], F_SETFL, O_NONBLOCK);
+
+#if (!defined(__GNUG__) && !defined(HPUX))
+setlinebuf(stderr);
+#endif
+ios::sync_with_stdio();
+
+int szx, szy, szf;
+XtAppContext * appctx = PIXtAppCtx(szx, szy, szf);
+inputid[1] = XtAppAddInput(*appctx, p[0], (XtPointer) XtInputReadMask, 
+                           redirectstream_callback, (XtPointer) (streamno+1));
+}
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/piapplx.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piapplx.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piapplx.h	(revision 464)
@@ -0,0 +1,38 @@
+#ifndef PIAPPLX_H_SEEN
+#define PIAPPLX_H_SEEN
+
+#include "piapplgen.h"
+#include "piwdgx.h"
+#include "picontainerx.h"
+
+class PIApplicationX : public PIApplicationGen {
+public:
+  		            PIApplicationX(int sx=200, int sy=30, int narg=0, char *arg[]=NULL);
+
+  virtual	            ~PIApplicationX();
+	
+  virtual void              Run();
+  virtual void              Stop() { mStop = false; }
+
+  virtual void              SetReady();
+  virtual void              SetBusy(); 
+  virtual void              SetBlocked();
+
+  virtual void              PrefCompSz(int& szx, int& szy);
+  virtual void              ScreenSz(int& szx, int& szy);
+
+  virtual void              RedirectOutStream(PIConsole* cons, unsigned char va= PIVA_Def);
+  virtual void              RedirectErrStream(PIConsole* cons, unsigned char va= PIVA_Ital|PIVA_Red);
+
+  PIContainer*              MBCont() { return intcont; }
+protected:
+  PIWdg * topwdg;
+  PIContainer * intcont;
+  bool mStop;
+};
+
+typedef PIApplicationX PIApplication;
+
+//  Pour recuperer un objet PIApplication 
+PIApplication* PIApplicationGetApp();
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pibwdggen.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pibwdggen.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pibwdggen.cc	(revision 464)
@@ -0,0 +1,607 @@
+// Module PI : Peida Interactive     PIBaseWdg
+// Classe de base pour nouvelles composantes graphiques  96
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include <stdio.h>
+
+#include "pibwdggen.h"
+#include "pidrawer.h"
+#include "pigraphps.h"
+#include "pidrwtools.h"
+
+static inline void dbl_swap(double& a, double& b) { double tmp = a; a = b; b = tmp;  } 
+
+//++
+// Class	PIBaseWdg
+// Lib		PI
+// include	pibwdggen.h
+//
+//   	Classe de base pour la création de nouvelles composantes graphiques.
+//	Le traitement des événements liés à l'écran, clavier, souris se fait
+//	à travers des méthodes de cette classe : "Resize()", "But1Press()", ...
+//	La classe "PIBaseWdg" supporte en outre un mécanisme permettant
+//	d'associer un ou plusieurs objets traceur (*Drawer*) capables 
+//	de se dessiner dans la fenêtre associée à l'objet.
+//	La classe "PIBaseWdgGen" définit l'interface et ne peut pas être instanciée 
+//	directement (Méthodes virtuelles pures). Les objets instanciés sont de la 
+//	classe "PIBaseWdg" et le fichier entête correspondant est "PIBWDG_H"
+//	défini dans "pisysdep.h".
+//--
+//++
+// Links	Parents
+// PIWdg
+//--
+//++
+// Links	Voir aussi
+// PIGraphic
+// PIDrawer
+//--
+
+// ---------- Les methodes de la classe  PIBWdgGen ------------
+
+//++
+// Titre	Constructeur
+//--
+//++
+//  PIBaseWdgGen(PIContainerGen *par, const char *nom, int sx=10, int sy=10, int px=0, int py=0)
+//	Création d'un objet contenu dans l'objet *PIContainer* "par", de
+//	taille "sx,sy", se trouvant à la position "px,py" avec le nom "nom"	
+//--
+
+//++
+// Titre	Méthodes
+//--
+//++
+// void  SetBackgroundColor(PIColors col=PI_White)
+//	Choix de la couleur de fond.
+// void  EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0) 
+//	Efface la zone rectangulaire définie par le coin "(x0,y0)" ,
+//	de taille "dx,dy" à l'aide de la couleur de fond.
+// void  SelPointerShape(PIPointer ptr=PI_ArrowPointer) 
+//	Choix de la forme du pointeur (souris) pour la fenêtre 
+//	associée à l'objet.
+//|	PI_ArrowPointer, PI_CrossPointer, PI_HandPointer, PI_TDLRArrowPointer
+// PIColors  GetBackgroundColor()
+//	Renvoie la couleur de fond
+// PIPointer  GetPointerShape() 
+//	Renvoie la forme du pointeur
+//--
+
+//++
+// Titre	Activation du traitement des événements
+//--
+//++
+// void  ActivatePtrCross()
+//	Active l'appel aux méthodes "Enter()" et "Leave()" lorsque la souris
+//	rentre ou sort de la fenêtre correspondante à l'objet
+// void  ActivateButton(int b)
+//	Active l'appel aux méthodes "ButbPress()" et "ButxRelease()" pour
+//	le bouton "b" de la souris ("b=1,2,3")
+// void  ActivateMove(int b) 
+//	Active l'appel aux méthodes "PtrbMove()" lors des mouvements de
+//	la souris avec le bouton "b" enfoncé ("b=1,2,3")
+//	L'appel avec "bid=0" active l'appel à la méthode "PtrMove()"
+//	Lors des mouvements de souris sans bouton enfoncé.
+// void  ActivateKeyboard()
+//	Active l'appel à la méthode "Keyboard()" lors de l'appui sur les 
+//	touches du clavier.
+//--
+
+ 
+/* --Methode-- */
+PIBaseWdgGen::PIBaseWdgGen(PIContainerGen *par, const char *nom,
+                       int sx, int sy, int px, int py) :
+PIWdg(par, nom, sx, sy, px, py)
+{
+mDrwId=0;   // Compteur des numeros sequentiel des PIDrawer
+mAdfg=false;    // Pour controle d'appel de RemoveDrawer()
+mWGrC = NULL;   // PIGraphic (Contexte graphique) associe a la fenetre}
+                // Doit etre cree par PIBaseWdgX/Mac/... 
+SetDefaultDrawRectangle(0., 0., 1., 1., true);
+SetDefaultDrawerLimits(0., 1., 0., 1., kAxeDirLtoR, kAxeDirUpDown);
+}
+
+/* --Methode-- */
+PIBaseWdgGen::~PIBaseWdgGen()
+{
+delete mWGrC;
+DeleteDrawers();
+if (PIDrwTools::GetCurrentBaseWdg() == this) 
+  PIDrwTools::SetCurrentBaseWdg(NULL);
+}
+ 
+
+/* --Methode-- 
+void PIBaseWdgGen::Refresh()
+{
+if ( IsVisible() )  { 
+  Draw(mWGrC, 0, 0, XSize(), YSize());
+  CallDrawers(mWGrC); 
+}
+return;
+}
+*/
+
+//++
+// Titre	Gestion des événements
+//--
+//++
+// void  Draw(PIGraphic* g, int x0, int y0, int dx, int dy)
+//	Méthode appelée lorsqu'il faut redessiner tout ou partie de
+//	la fenêtre. La zone a rafraîchir est determinée par 
+//	"(x0,y0)", "dx,dy" et "g" est l'objet "PIGraphic" 
+//	qui doit être utilisé.
+//	Cette méthode ne doit pas être appelé directement. 
+//	Pour rafraîchir le contenu de la fenêtre, il faut appeler
+//	la méthode "Refresh()"
+// void  Resize()
+//	Méthode appelée lorsque la taille de l'objet est modifiée.
+//	"XSize()", "YSize()" fournissent la nouvelle taille de l'objet.
+// void  Enter()
+//	Méthode appelée lorsque le pointeur rentre dans la fenêtre
+//	(Si "ActivatePtrCross()" a été appelé )
+// void  Leave()
+//	Méthode appelée lorsque le pointeur quitte la fenêtre
+//	(Si "ActivatePtrCross()" a été appelé )
+// void  ButbPress(int x, int y)  (b=1,2,3)
+//	Méthode appelée lorsque le bouton "b=1,2,3" de la souris est enfoncé.
+//	"x,y" : Position de la souris
+//	(Si "ActivateButton(b)" a été appelé )
+// void  ButbRelease(int x, int y)   (b=1,2,3)
+//	Méthode appelée lorsque le bouton "b=1,2,3" de la souris est relaché.
+//	"x,y" : Position de la souris
+//	(Si "ActivateButton(b)" a été appelé )
+// void  PtrMove(int x, int y)
+//	Méthode appelée lors des mouvements de la souris. "x,y" : Position de la souris
+//	(Si "ActivateMove(0)" a été appelé )
+// void  PtrbMove(int x, int y)     (b=1,2,3)
+//	Méthode appelée lors des mouvements de la souris, avec le 
+//	bouton "b=1,2,3" appuyé. "x,y" : Position de la souris
+//	(Si "ActivateMove(b)" a été appelé )
+// void  Keyboard(int key, PIKeyModifier kmod)
+//	Méthode appelée en réponse à des actions sur le clavier.
+//	"key" est le code ASCII de la touche enfoncé - "kmod" indique
+//	si des touches speciaux étaient enfoncés en même temps.
+//|	kmod =  PIKM_Blank |  PIKM_Shift | PIKM_Alt | PIKM_Cntl
+//	Des constantes ont été définis pour certaines touches particulières
+//|	PIK_Return , PIK_Enter , PIK_BackSpace, PIK_Delete
+//|	PIK_Tab , PIK_Escape , PIK_Up , PIK_Down, 
+//|	PIK_Right , PIK_Left , PIK_Previous , PIK_Next
+//--
+
+/* --Methode-- */
+void PIBaseWdgGen::Draw(PIGraphic* g, int x0, int y0, int dx, int dy)
+{
+#ifdef DEBUG_RZXB
+puts("Debug_PIBaseWdgGen::Draw() Efface la fenetre par defaut ! ");
+#endif
+if (g->kind() != PI_PSFileGraphics) EraseWindow(x0, y0, dx, dy);
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::Resize()
+{
+#ifdef DEBUG_RZXB
+puts("Debug_PIBaseWdgGen::Resize()  resize notify ");
+#endif
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgGen::Enter()
+{
+#ifdef DEBUG_RZXB
+puts("Debug_PIBaseWdgGen::Enter() enter notify ");
+#endif
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::Leave()
+{
+#ifdef DEBUG_RZXB
+puts("Debug_PIBaseWdgGen::Leave() leave notify ");
+#endif
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgGen::But1Press(int /*x*/, int /*y*/)
+{
+Send(Msg(), PIMsg_Active);
+#ifdef DEBUG_RZXB
+printf ("PIBaseWdgGen::But1Press PosX,Y= %d %d \n", x, y);
+#endif
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::But1Release(int /*x*/, int /*y*/)
+{
+#ifdef DEBUG_RZXB
+printf ("PIBaseWdgGen::ButReleasePosX,Y= %d %d \n", x, y);
+#endif
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::But2Press(int /*x*/, int /*y*/)
+{
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::But2Release(int /*x*/, int /*y*/)
+{
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::But3Press(int /*x*/, int /*y*/)
+{
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::But3Release(int /*x*/, int /*y*/)
+{
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::PtrMove(int /*x*/, int /*y*/)
+{
+#ifdef DEBUG_RZXB
+printf ("Debug_PIBaseWdgGen::PtrMove PosX,Y= %d %d \n", x, y);
+#endif
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::Ptr1Move(int /*x*/, int /*y*/)
+{
+#ifdef DEBUG_RZXB
+printf ("Debug_PIBaseWdgGen::Ptr1Move PosX,Y= %d %d \n", x, y);
+#endif
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::Ptr2Move(int /*x*/, int /*y*/)
+{
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgGen::Ptr3Move(int /*x*/, int /*y*/)
+{
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::Keyboard(int /*key*/, PIKeyModifier /*kmod*/)
+{
+#ifdef DEBUG_RZXB
+printf("PIBaseWdgGen::Keyboard: Key= %d (%c)  Mod= %d \n", key, (char)key, (int)kmod); 
+#endif
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgGen::PSPrint(PSFile * psf, int ofx, int ofy)
+{
+if (!psf) return;
+PIGraphicPS grpsf(psf, (PIWdg *)this, ofx, ofy);
+Draw(&grpsf, 0, 0, XSize(), YSize());
+CallDrawers(&grpsf); 
+return;
+}
+
+//++
+// Titre	Gestion des traceurs (PIDrawer)
+//	Un même "PIDrawer" peut être attaché simultanement à plusieurs "PIBaseWdg", ainsi
+//	que plusieurs fois au même "PIBaseWdg", avec des identificateurs différents.
+//--
+//++
+// void  SetDefaultDrawRectangle(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, bool psz=true)
+//	Définition du rectangle d'attachement par défaut. "(x1,y1)" et "(x2,y2)" determinent
+//	les positions des deux coins opposés.
+//	si "psz=true", les coordonnées sont supposées être des facteurs multiplicatifs 
+//	des dimensions de l'objet.
+// void  SetDefaultDrawerLimits(double xmin, double xmax, double ymin, double ymax, -
+//                              int axrl=kAxeDirSame, int ayud=kAxeDirSame)
+//	Définition du système de coordonnées par défaut d'un drawer attaché en "autolim=true"
+//
+//--
+
+/* --Methode-- */
+void PIBaseWdgGen::SetDefaultDrawRectangle(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, bool psz)
+{
+mDrX1 = x1;  mDrY1 = y1;
+mDrX2 = x2;  mDrY2 = y2;   mDrElastic = psz;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::SetDefaultDrawerLimits(double xmin, double xmax, double ymin, double ymax,
+                                          int axrl, int ayud)
+{
+mDrXmin = xmin;   mDrXmax = xmax; 
+mDrYmin = ymin;   mDrYmax = ymax; 
+mDXdir = axrl;    mDYdir = ayud;
+}
+
+
+//++
+// int  AddDrawer(PIDrawer* drw, PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, -
+//                bool psz=true, bool clip=true, bool ad=false)
+//	Attachement d'un "PIDrawer" au rectangle défini les coordonnées des deux coins opposés.
+//	si "psz=true", les coordonnées sont supposées être des facteurs multiplicatifs 
+//	des dimensions de l'objet.
+//	si "clip=true", "PIDrawer* drw" ne peut dessiner en dehors de son rectangle
+//	d'attachement.
+//	si "ad=true", le "PIDrawer* drw" est détruit lors de la destruction de l'objet PIBaseWdg.
+//	La méthode retourne l'identificateur du drawer attaché.
+// int  AddDrawer(PIDrawer* drw, bool autolim=false, bool clip=true, bool ad=false)
+//	Ajout d'un "PIDrawer" au rectangle d'attachement par défaut. 
+//	Si "autolim=true", l'objet "PIBaseWdg" impose l'espace de coordonnées utilisateur
+//	à l'aide des valeurs définies par "SetDefaultDrawerLimits()".
+//	Si ""clip=true", "PIDrawer* drw" ne peut dessiner en dehors de son rectangle 
+//	d'attachement.
+//	si "ad=true", le "PIDrawer* drw" est détruit lors de la destruction de l'objet PIBaseWdg.
+//	La méthode retourne l'identificateur du drawer attaché.
+//--
+
+/* --Methode-- */
+int PIBaseWdgGen::AddDrawer(PIDrawer* drw, PIGrCoord x1, PIGrCoord y1,  
+                            PIGrCoord x2, PIGrCoord y2, bool psz, bool clip, bool ad)
+{
+if (drw == NULL)   return(0);
+mDrwId++;
+BWDrwId did;
+did.x1 = x1;  did.y1 = y1;
+did.x2 = x2;  did.y2 = y2;
+did.autoszp = did.autolim = false;   
+did.elastic = psz;  did.clip = clip;
+did.id = mDrwId;  did.ad = ad; 
+did.drw = drw;
+mDrwList.push_back(did);
+drw->Attach(this, mDrwId);
+return(mDrwId);
+}
+
+/* --Methode-- */
+int PIBaseWdgGen::AddDrawer(PIDrawer* drw, bool autolim, bool clip, bool ad)
+{
+if (drw == NULL)   return(0);
+mDrwId++;
+BWDrwId did;
+did.x1 = 0.;  did.y1 = 0.;
+did.x2 = 1.;  did.y2 = 1.;
+did.autoszp = true;   did.autolim = autolim;   
+did.elastic = false;   did.clip = clip;
+did.id = mDrwId;  did.ad = ad; 
+did.drw = drw;
+mDrwList.push_back(did);
+drw->Attach(this, mDrwId);
+return(mDrwId);
+}
+
+
+//++
+// void  MoveResizeDrawer(int id, PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, bool psz=true)
+//	Modification du rectangle d'attachement du PIDrawer avec l'identificateur "id" , retourné
+//	par "AddDrawer()"
+// void  RemoveDrawer(int id)
+//	Ote le drawer "id" de la liste
+// void  DeleteDrawers()
+//	Ote tous les drawers de la liste. Détruit ceux ajoutés avec l'option "ad=true" 
+//--
+
+/* --Methode-- */
+void PIBaseWdgGen::MoveResizeDrawer(int id,  PIGrCoord x1, PIGrCoord y1,  PIGrCoord x2, PIGrCoord y2, bool psz)
+{
+vector<BWDrwId>::iterator it;
+for(it = mDrwList.begin(); it != mDrwList.end(); it++)  
+  if ((*it).id == id) { 
+    (*it).x1 = x1;  (*it).y1 = y1;
+    (*it).x2 = x2;  (*it).y2 = y2;
+    (*it).elastic = psz;
+    break;
+  }
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::RemoveDrawer(int id)
+{
+if (mAdfg)  return;
+vector<BWDrwId>::iterator it;
+for(it = mDrwList.begin(); it != mDrwList.end(); it++)
+  if ((*it).id == id) 
+    { (*it).drw->Detach(this, id); mDrwList.erase(it); break; }
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::DeleteDrawers()
+{
+mAdfg = true;
+vector<BWDrwId>::iterator it;
+for(it = mDrwList.begin(); it != mDrwList.end(); it++)  
+  if ((*it).ad)  delete (*it).drw;
+mDrwList.erase(mDrwList.begin(), mDrwList.end() );
+mAdfg = false;
+return;
+}
+
+//++
+// int  NbDrawers()
+//	Retourne le nombre de PIDrawer attachés
+// PIDrawer*  GetDrawerId(int id)
+//	Retourne le PIDrawer avec l'identificateur id
+// PIDrawer*  GetDrawer(int n)
+//	Retourne le PIDrawer "n=0..NbDrawers()-1" de la liste
+//--
+
+/* --Methode-- */
+int PIBaseWdgGen::NbDrawers()
+{
+return(mDrwList.size());
+}
+
+
+/* --Methode-- */
+PIDrawer* PIBaseWdgGen::GetDrawer(int n)
+{
+if ( (n < 0) || (n >= mDrwList.size()) ) return(NULL);
+return(mDrwList[n].drw);
+}
+
+/* --Methode-- */
+PIDrawer* PIBaseWdgGen::GetDrawerId(int id)
+{
+vector<BWDrwId>::iterator it;
+for(it = mDrwList.begin(); it != mDrwList.end(); it++)  
+  if ((*it).id == id)  return((*it).drw);
+return(NULL);
+}
+
+
+//++
+// void  CallDrawers(PIGraphic* g, int x0=0, int y0=0, int dx=0, int dy=0)
+//	Appel de la méthode de tracé pour tous les Drawers
+// void  CallDrawer(int id);
+//	Appel de la méthode de tracé pour le drawer avec l'identificateur "id"
+//--
+
+/* --Methode-- */
+void PIBaseWdgGen::CallDrawers(PIGraphic* g, int x0, int y0, int dx, int dy)
+{
+double xmin,ymin, xmax, ymax;
+PIGraphicUC* guc;
+int drx0, dry0, drdx, drdy;
+int ddrx0, ddry0, ddrdx, ddrdy;
+
+if (mDrElastic) { 
+  ddrx0 = (int)((double) mDrX1 * (double)XSize());
+  ddry0 = (int)((double) mDrY1 * (double)YSize());
+  ddrdx = (int)((double) mDrX2 * (double)XSize()) - ddrx0 ;
+  ddrdy = (int)((double) mDrY2 * (double)YSize()) - ddry0 ;
+  }
+else {
+  ddrx0 = (int)mDrX1;   ddry0 = (int)mDrY1;  
+  ddrdx = (int)mDrX2-ddrx0;   ddrdy = (int)mDrY2-ddry0;  
+  }
+
+bool sxy = false;
+if ((dx > 0) && (dy > 0))  sxy = true;
+
+vector<BWDrwId>::iterator it;
+bool fgc=false;
+for(it = mDrwList.begin(); it != mDrwList.end(); it++) {
+  g->SaveGraphicAtt();
+  if ( (*it).autoszp )   // Taille/position  par defaut impose par PIBaseWdg 
+    { drx0 = ddrx0;  dry0 = ddry0;   drdx = ddrdx;  drdy = ddrdy; } 
+  else {
+    if ( (*it).elastic  ) {   // Taille/position defin en fraction de la taille du PIBaseWdg
+      drx0 = (int)((double)(*it).x1 * (double)XSize());
+      dry0 = (int)((double)(*it).y1 * (double)YSize());
+      drdx = (int)((double)(*it).x2 * (double)XSize()) - drx0 ;
+      drdy = (int)((double)(*it).y2 * (double)YSize()) - dry0 ;
+      }
+    else {
+      drx0 = (int)(*it).x1 ;  dry0 = (int)(*it).y1 ; 
+      drdx = (int)(*it).x2-drx0 ;  drdy = (int)(*it).y2-dry0 ; 
+      }
+    }
+// L'ordre des operations ici est importante 
+  if ( (*it).autolim )  
+     (*it).drw->SetLimits(mDrXmin, mDrXmax, mDrYmin, mDrYmax, mDXdir, mDYdir);     
+  guc = (*it).drw->SetDrwWdg(this, drx0, dry0, drdx, drdy, g);
+  if ((*it).clip)  { g->SetClipRectangle(drx0, dry0, drdx , drdy);  fgc = true; }
+  (*it).drw->SelGraAtt(guc);
+  if (sxy) {
+    guc->GrC2UC(x0, y0, xmin, ymin);
+    guc->GrC2UC(x0+dx, y0+dy, xmax, ymax);
+    }
+  else {
+    guc->GrC2UC(0, 0, xmin, ymin);
+    guc->GrC2UC(XSize(), YSize(), xmax, ymax);    
+    } 
+  if (xmin > xmax)  dbl_swap(xmin,xmax);
+  if (ymin > ymax)  dbl_swap(ymin,ymax);
+  (*it).drw->Draw(guc, xmin, ymin, xmax, ymax);
+  g->RestoreGraphicAtt();
+  }
+if (fgc)  g->ClearClipRectangle();
+
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::CallDrawer(int id)
+{
+double xmin,ymin, xmax, ymax;
+PIGraphicUC* guc;
+int drx0, dry0, drdx, drdy;
+int ddrx0, ddry0, ddrdx, ddrdy;
+
+PIGraphic* g = WindowGraphic();
+
+if (mDrElastic) { 
+  ddrx0 = (int)((double) mDrX1 * (double)XSize());
+  ddry0 = (int)((double) mDrY1 * (double)YSize());
+  ddrdx = (int)((double) mDrX2 * (double)XSize()) - ddrx0 ;
+  ddrdy = (int)((double) mDrY2 * (double)YSize()) - ddry0 ;
+  }
+else {
+  ddrx0 = (int)mDrX1;   ddry0 = (int)mDrY1;  
+  ddrdx = (int)mDrX2-ddrx0;   ddrdy = (int)mDrY2-ddry0;  
+  }
+vector<BWDrwId>::iterator it;
+for(it = mDrwList.begin(); it != mDrwList.end(); it++) 
+  if ((*it).id == id) {
+    g->SaveGraphicAtt();
+    if ( (*it).autoszp )   // Taille/position  par defaut impose par PIBaseWdg 
+      { drx0 = ddrx0;  dry0 = ddry0;   drdx = ddrdx;  drdy = ddrdy; } 
+    else {
+      if ( (*it).elastic  ) {   // Taille/position defin en fraction de la taille du PIBaseWdg
+        drx0 = (int)((double)(*it).x1 * (double)XSize());
+        dry0 = (int)((double)(*it).y1 * (double)YSize());
+        drdx = (int)((double)(*it).x2 * (double)XSize()) - drx0 ;
+        drdy = (int)((double)(*it).y2 * (double)YSize()) - dry0 ;
+        }
+      else {
+        drx0 = (int)(*it).x1 ;  dry0 = (int)(*it).y1 ; 
+        drdx = (int)(*it).x2-drx0 ;  drdy = (int)(*it).y2-dry0 ; 
+        }
+      }
+// L'ordre des operations ici est importante 
+    if ( (*it).autolim ) 
+       (*it).drw->SetLimits(mDrXmin, mDrXmax, mDrYmin, mDrYmax, mDXdir, mDYdir);
+    guc = (*it).drw->SetDrwWdg(this, drx0, dry0, drdx, drdy, g);
+    if ((*it).clip)  g->SetClipRectangle(drx0, dry0, drdx , drdy);
+    (*it).drw->SelGraAtt(guc);
+    guc->GrC2UC(0, 0, xmin, ymin);
+    guc->GrC2UC(XSize(), YSize(), xmax, ymax);     
+    if (xmin > xmax)  dbl_swap(xmin,xmax);
+    if (ymin > ymax)  dbl_swap(ymin,ymax);
+    (*it).drw->Draw(guc, xmin, ymin, xmax, ymax);
+    g->RestoreGraphicAtt();    
+    if ((*it).clip)  g->ClearClipRectangle();
+    break;
+  }
+return;
+}
+
+
+/* --Methode-- */
+PIGraphic* PIBaseWdgGen::WindowGraphic()
+{
+return(mWGrC);
+}
Index: /tags/V_LaSilla191199/SophyaPI/PI/pibwdggen.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pibwdggen.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pibwdggen.h	(revision 464)
@@ -0,0 +1,124 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive      PIBaseWdgGen
+// Classe de base pour la creation de nouvelles composantes
+// graphiques interactives       
+//                        R.Ansari -  E.Aubourg 96
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIBWDGGEN_H_SEEN
+#define PIBWDGGEN_H_SEEN
+
+
+#include "pisysdep.h"
+#include PIWDG_H
+#include PICMAP_H
+#include PIGRAPHIC_H
+#include "pigraphuc.h"
+#include "pievthandler.h"
+#include "psfile.h"
+
+// Mettre dans cet ordre, sinon g++ a des problemes   
+#include <vector>   
+
+
+enum PIPointer { PI_ArrowPointer = 1, PI_CrossPointer = 2, 
+                 PI_HandPointer = 3, PI_TDLRArrowPointer = 4 };
+
+
+class PIBaseWdgGen : public PIWdg
+{
+public:
+  enum {ClassId = 5000};
+
+// Les methodes ...
+
+                     PIBaseWdgGen(PIContainerGen *par, const char *nom,
+                                   int sx=10, int sy=10, int px=0, int py=0);
+  virtual            ~PIBaseWdgGen();
+
+  virtual long       kind() {return ClassId; }
+
+//  Activation des evenements
+  virtual void       ActivatePtrCross()        = 0;
+  virtual void       ActivateButton(int bid)   = 0;
+  virtual void       ActivateMove(int bid)     = 0;
+  virtual void       ActivateKeyboard()        = 0;
+
+//  Divers : couleur de fond, Effacement fenetre,  forme de la souris
+  virtual void       SetBackgroundColor(PIColors col=PI_White)               = 0;
+  virtual void       EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0)     = 0;
+  virtual void       SelPointerShape(PIPointer ptr=PI_ArrowPointer)          = 0;
+  virtual PIColors   GetBackgroundColor()                                    = 0;
+  virtual PIPointer  GetPointerShape()                                       = 0;
+  virtual void       AssignKeyboard()                                        = 0;
+
+//  Fonctions qui doivent contenir le dessin du contenu du widget lui-meme
+  virtual void       Draw(PIGraphic* g, int x0, int y0, int dx, int dy);
+  
+// Traitement des evenements   
+  virtual void       Resize();
+  virtual void       Enter();
+  virtual void       Leave();  
+  virtual void       But1Press(int x, int y);  
+  virtual void       But1Release(int x, int y); 
+  virtual void       But2Press(int x, int y);
+  virtual void       But2Release(int x, int y);
+  virtual void       But3Press(int x, int y);
+  virtual void       But3Release(int x, int y);
+  virtual void       PtrMove(int x, int y);
+  virtual void       Ptr1Move(int x, int y);
+  virtual void       Ptr2Move(int x, int y);
+  virtual void       Ptr3Move(int x, int y);
+  virtual void       Keyboard(int key, PIKeyModifier kmod);
+
+// Acces aux caracteristiques du dernier evenement 
+  virtual void       GetLastEventInfo(PIKeyModifier& kmod, unsigned long& tm) = 0;
+
+// PostScript output
+  virtual void       PSPrint(PSFile* psf, int ofx = 0, int ofy = 0);
+
+// ------ Gestion des Drawers  ------
+  friend class PIDrawer;
+  virtual void       SetDefaultDrawRectangle(PIGrCoord x1, PIGrCoord y1, 
+                                             PIGrCoord x2, PIGrCoord y2, bool psz=true); 
+  virtual void       SetDefaultDrawerLimits(double xmin, double xmax, double ymin, double ymax,
+                                            int axrl=kAxeDirSame, int ayud=kAxeDirSame); 
+  virtual int        AddDrawer(PIDrawer* drw, PIGrCoord x1, PIGrCoord y1, 
+                               PIGrCoord x2, PIGrCoord y2, 
+                               bool psz=true, bool clip=true, bool ad=false);
+  virtual int        AddDrawer(PIDrawer* drw, bool autolim=false, bool clip=true, bool ad=false);
+  virtual void       MoveResizeDrawer(int id, PIGrCoord x1, PIGrCoord y1, 
+                                      PIGrCoord x2, PIGrCoord y2, bool psz=true);
+  virtual void       RemoveDrawer(int id);       // Ote un drawer de la liste
+  virtual void       DeleteDrawers();            // Ote tous les drawers, delete des drawers ajoute avec ad=true
+// Acces aux drawers 
+  virtual int        NbDrawers();
+  virtual PIDrawer*  GetDrawerId(int id);   
+  virtual PIDrawer*  GetDrawer(int n);   
+
+//  Trace des Drawers ...          
+  virtual void       CallDrawers(PIGraphic* g, int x0=0, int y0=0, int dx=0, int dy=0); 
+  virtual void       CallDrawer(int id);
+
+// Devrait etre protected - mis ici a cause de cxx  11/07/97  Reza
+  struct BWDrwId { int id; PIGrCoord x1, y1, x2, y2; bool autoszp, autolim, elastic, clip, ad;  PIDrawer* drw; };
+
+  virtual PIGraphic*  WindowGraphic();
+
+// -------------- Variables membre protegees -------------------
+protected:
+  PIGraphicWin* mWGrC;  // PIGraphic (Contexte graphique) associe a la fenetre
+  bool mAdfg;           // Pour la gestion de DeleteDrawers() quand appele par delete de PIBaseWdg
+  int mDrwId;           // Compteur pour DrawerId
+  vector<BWDrwId> mDrwList;
+//  Definition de la zone de trace et limites UC des drawers par defaut  
+  PIGrCoord mDrX1, mDrY1,  mDrX2,  mDrY2;  
+  bool mDrElastic;   // true --> Coord en fraction de la taille 
+  double mDrXmin, mDrXmax, mDrYmin, mDrYmax;   // Limites par defaut - UC
+  int  mDXdir, mDYdir;                        // Sens des axes par defaut
+
+};
+
+
+#endif /* PIBWDGGEN_H_SEEN */
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pibwdgmac.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pibwdgmac.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pibwdgmac.cc	(revision 464)
@@ -0,0 +1,157 @@
+#include <stdio.h>
+
+#include <LString.h>
+#include "pibwdgmac.h"
+#include "piupdattachment.h"
+#include <algobase.h>
+#include <string.h>
+
+#define mGraphic mWGrC  
+
+// Les methodes de la classe  PIBWdgGen
+ 
+/* --Methode-- */
+PIBaseWdgMac::PIBaseWdgMac(PIContainerGen *par, char *nom,
+                       int sx, int sy, int px, int py) :
+PIBaseWdgGen(par, nom, sx, sy, px, py) 
+{
+    mGraphic = new PIGraphicMac(this);
+
+    mAdapter->AddAttachment(new PIUpdAttachment(this));
+    mPane->AddAttachment(new PIUpdAttachment(this));
+    cursor = NULL;
+    
+
+}
+
+
+/* --Methode-- */
+PIBaseWdgMac::~PIBaseWdgMac()
+{
+}
+
+/* --Methode-- */
+void PIBaseWdgMac::ActivatePtrCross()
+{
+// toujours actif pour le moment
+}
+
+/* --Methode-- */
+void PIBaseWdgMac::ActivateButton(int /*bid*/)
+{
+}
+
+/* --Methode-- */
+void PIBaseWdgMac::ActivateMove(int /*bid*/)
+{
+}
+
+/* --Methode-- */
+void PIBaseWdgMac::ActivateKeyboard()
+{
+}
+
+/* --Methode-- */
+void PIBaseWdgMac::EraseWindow(int x0, int y0, int dx, int dy)
+{
+  if (mPane->FocusDraw()) {
+     GrafPtr p = mPane->GetMacPort();
+     if (p) EraseRgn(p->visRgn);
+//	   Rect r;
+//	   mPane->CalcPortFrameRect(r);
+//       EraseRect(&r);
+  }
+}
+
+
+
+/* --Methode-- */
+void PIBaseWdgMac::SelPointerShape(PIPointer ptr)
+{
+  CursHandle c;
+  if (mPane->FocusDraw()) {
+    switch(ptr) {
+      case PI_ArrowPointer:
+        cursor = &qd.arrow;
+        break;
+      case PI_CrossPointer:
+        c = GetCursor(crossCursor);
+        HLock((Handle)c);
+        cursor = c ? *c : NULL;
+        break;
+      case PI_HandPointer:
+        c = GetCursor(128);
+        HLock((Handle)c);
+        cursor = c ? *c : NULL;
+        break;
+    }
+  }
+  mPtrS = ptr;
+}
+
+
+
+/* --Methode-- */
+PIPointer  PIBaseWdgMac::GetPointerShape()
+{
+return (mPtrS);
+}
+
+
+
+/* --Methode-- */
+bool PIBaseWdgMac::AdjustCursor()
+{
+  if (cursor) {
+    ::SetCursor(cursor);
+    return true;
+  }
+  return false;
+}
+
+/* --Methode-- 
+void PIBaseWdgMac::Refresh()
+{
+if (mPane->IsVisible())
+  Draw();
+}
+   J'ai mis cette fonction ds PIWdgMac::IsVisible()    Reza $CHECK$  01/12/97 
+*/
+
+
+
+void PIBaseWdgMac::SetBackgroundColor(PIColors col)
+{
+  if (mPane->FocusDraw()) {
+    long color;
+    switch (col) {
+      case PI_Black:
+        color = blackColor;
+        break;
+      case PI_White:
+        color = whiteColor;
+        break;
+      case PI_Red:
+        color = redColor;
+        break;
+      case PI_Blue:
+        color = blueColor;
+        break;
+      case PI_Green:
+        color = greenColor;
+        break;
+      case PI_Yellow:
+        color = yellowColor;
+        break;
+      default:
+        color = blackColor;
+    }
+    mBCol = col;
+    ::BackColor(color);
+  }
+}
+
+PIColors  PIBaseWdgMac::GetBackgroundColor() 
+{
+return (mBCol);
+}
Index: /tags/V_LaSilla191199/SophyaPI/PI/pibwdgmac.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pibwdgmac.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pibwdgmac.h	(revision 464)
@@ -0,0 +1,49 @@
+/* Widget Xt pour affichage d'image  Interface Public    */
+/*                                    Reza 10/95         */
+
+#ifndef PIBWDGMAC_H_SEEN
+#define PIBWDGMAC_H_SEEN
+
+#include "pisysdep.h"
+#include "pibwdggen.h"
+
+
+class PIBaseWdgMac : public PIBaseWdgGen
+{
+public:
+// Les methodes ...
+
+                     PIBaseWdgMac(PIContainerGen *par, char *nom,
+                                   int sx=10, int sy=10, int px=0, int py=0);
+  virtual           ~PIBaseWdgMac();
+
+//  Activation des evenements
+  virtual void       ActivatePtrCross();
+  virtual void       ActivateButton(int bid);
+  virtual void       ActivateMove(int bid);
+  virtual void       ActivateKeyboard();
+
+//  Divers : couleur de fond, Effacement fenetre,  forme de la souris
+  virtual void       SetBackgroundColor(PIColors col=PI_White);
+  virtual void       EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0);
+  virtual void       SelPointerShape(PIPointer ptr=PI_ArrowPointer);
+  virtual PIColors   GetBackgroundColor();
+  virtual PIPointer  GetPointerShape();
+  virtual void       AssignKeyboard() {}
+
+// Acces aux caracteristiques du dernier evenement 
+  virtual void       GetLastEventInfo(PIKeyModifier& kmod, unsigned long& tm);
+
+protected:
+  friend class       PIUpdAttachment;
+  virtual bool       AdjustCursor();
+  CursPtr            cursor;
+  
+
+  PIPointer mPtrS;
+  PIColors  mBCol;
+};
+
+typedef PIBaseWdgMac PIBaseWdg;
+
+#endif /* RZXBASE_H_SEEN */
Index: /tags/V_LaSilla191199/SophyaPI/PI/pibwdgx.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pibwdgx.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pibwdgx.cc	(revision 464)
@@ -0,0 +1,268 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive      PIBaseWdg
+//                                    Reza 95-96
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include <stdio.h>
+
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/cursorfont.h>
+
+#include <X11/IntrinsicP.h>
+#include <X11/CoreP.h>
+
+#include "pixtbaseP.h"
+#include "pixtbase.h"
+
+#include "pibwdgx.h"
+
+
+// #define DEBUG_PIBWDGX     Flag pour impression de debug etc ...
+static unsigned long colpixwhite, colpixblack;
+#define NMAXCURS 5 
+static Cursor curs[NMAXCURS];
+
+
+/* --Methode-- */
+PIBaseWdgX::PIBaseWdgX(PIContainerGen *par, const char *nom,
+                       int sx, int sy, int px, int py) 
+: PIBaseWdgGen(par, nom, sx, sy, px, py)
+
+{
+Arg  wargs[3];
+
+Init();
+mWGrC = NULL; // PIGraphic (Contexte graphique) associe a la fenetre
+finishDone = false;     // FinishCreate() pas encore appele
+
+CreateXtWdg(nom, piXtBaseWidgetClass, NULL, sx, sy, px, py);
+
+XtSetArg(wargs[0],PIXNobject,this); 
+XtSetArg(wargs[1],XtNbackground, colpixwhite);  
+XtSetArg(wargs[2],XtNborderWidth, (Dimension)0);  
+XtSetValues(XtWdg(), wargs, 3);
+
+((PIXtBaseWidget)XtWdg())->pixtbase.myeventmask = 0;
+XtUninstallTranslations(XtWdg());
+
+mPtrS = PI_CrossPointer;
+SelPointerShape();
+// PIGraphic (Contexte graphique) associe a la fenetre
+// Si pas cree par FinishCreate()
+if (!mWGrC) mWGrC = new PIGraphicX(this);   
+Manage();
+}
+
+
+/* --Methode-- */
+PIBaseWdgX::~PIBaseWdgX()
+{
+#ifdef DEBUG_PIBWDGX 
+printf("PIBaseWdgX::~PIBaseWdgX()_Debug: Object= %lx (%lx) Wdg= %lx \n",
+(long)this, (long)(((PIXtBaseWidget)XtWdg())->pixtbase.objet), (long)XtWdg() );  
+#endif
+Arg  wargs[2];
+XtSetArg(wargs[0],PIXNobject,NULL); 
+XtSetValues(XtWdg(), wargs, 1);
+}
+
+/* --Methode-- */
+void PIBaseWdgX::FinishCreate()
+{
+// appele par la fenetre mere, apres XtRealize()
+if (finishDone) { 
+  fprintf(stderr, "BUG/PIBaseWdgX::FinishCreate() multiple call \n"); 
+  return; 
+  }
+PIWdgX::FinishCreate();
+
+// J'active le backing store pour la fenetre X
+XSetWindowAttributes xswa;
+if (!XtIsRealized(XtWdg())) XtRealizeWidget( XtWdg() ) ;
+
+Window mwi = XtWindow(XtWdg());
+
+/*
+XWindowAttributes xwa;
+XGetWindowAttributes(PIXDisplay(), mwi, &xwa);
+printf("PIBaseWdgX::FinishCreate()  BS= %d  (No=%d Map=%d Always=%d) planes=%lx \n", 
+       xwa.backing_store, NotUseful, WhenMapped, Always, (long)xwa.backing_planes);
+*/
+xswa.backing_store = WhenMapped;
+// xswa.backing_planes = ~0;
+// XChangeWindowAttributes(PIXDisplay(), XtWindow(XtWdg()), CWBackingPlanes|CWBackingStore, &xswa);
+XChangeWindowAttributes(PIXDisplay(), mwi, CWBackingStore, &xswa);
+
+// PIGraphic (Contexte graphique) associe a la fenetre
+if (!mWGrC) mWGrC = new PIGraphicX(this);   
+mWGrC->TerminateInit();
+} 
+
+/* --Methode-- */
+bool PIBaseWdgX::IsVisible()
+{
+return (finishDone && PIWdg::IsVisible() ); 
+}
+
+/* --Methode-- */
+void PIBaseWdgX::Refresh()
+{
+if (XtIsRealized(XtWdg())) {
+// if ( IsVisible() )  {
+//  EraseWindow();   --> Ne pas faire  Reza 12/98 
+  Draw(mWGrC, 0, 0, XSize(), YSize());
+  CallDrawers(mWGrC); 
+  CallDrawHandlers(0, 0, XSize(), YSize());
+  }
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgX::ActivatePtrCross()
+{
+XtAddEventHandler( XtWdg(), EnterWindowMask | LeaveWindowMask, 
+                   FALSE, event_handler_pixtbase, NULL);
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgX::ActivateButton(int bid)
+{
+#ifdef DEBUG_PIBWDGX
+printf("PIBaseWdgX::ActivateButton %d \n \n", bid);
+#endif
+if ( (bid < 1) && (bid > 3) ) return; 
+XtAddEventHandler( XtWdg(), ButtonPressMask | ButtonReleaseMask, 
+                   FALSE, event_handler_pixtbase, NULL);
+if (bid == 1)  ((PIXtBaseWidget)XtWdg())->pixtbase.myeventmask |= Button1Mask ;
+else if (bid == 2) ((PIXtBaseWidget)XtWdg())->pixtbase.myeventmask |= Button2Mask ;
+else if (bid == 3) ((PIXtBaseWidget)XtWdg())->pixtbase.myeventmask |= Button3Mask ;
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::ActivateMove(int bid)
+{
+#ifdef DEBUG_PIBWDGX
+printf("PIBaseWdgX::ActivateMove %d \n \n", bid);
+#endif
+unsigned long evtmask = 0;
+
+// bid == 0  -> PointerMove sans bouton 
+if ( (bid < 0) && (bid > 3) ) return; 
+
+if (bid == 0) evtmask = PointerMotionHintMask ;
+else if (bid == 1) evtmask = Button1MotionMask | PointerMotionHintMask ;
+else if (bid == 2) evtmask = Button2MotionMask | PointerMotionHintMask ;
+else if (bid == 3) evtmask = Button3MotionMask | PointerMotionHintMask ;
+XtAddEventHandler( XtWdg(), evtmask, FALSE, event_handler_pixtbase, NULL);
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgX::ActivateKeyboard()
+{
+XtAddEventHandler( XtWdg(), KeyPressMask, FALSE, event_handler_pixtbase, NULL);
+((PIXtBaseWidget)XtWdg())->pixtbase.myeventmask |= ShiftMask ;
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::SetBackgroundColor(PIColors col)
+{
+Arg  wargs[2];
+XtSetArg(wargs[0],XtNbackground, mWGrC->GetPixelValueforColor(col) );  
+XtSetValues(XtWdg(), wargs, 1);
+mBCol = col;
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::EraseWindow(int x0, int y0, int dx, int dy)
+{
+XClearArea (XtDisplay(XtWdg()),XtWindow(XtWdg()), x0, y0, dx, dy, False );
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::SelPointerShape(PIPointer ptr)  
+{
+if (ptr == mPtrS)  return;
+if ( (ptr < 0) || (ptr >= NMAXCURS))  return;
+if ( XtIsRealized(XtWdg()) )
+  XDefineCursor(XtDisplay (XtWdg()), XtWindow(XtWdg()), curs[ptr]);
+mPtrS = ptr;
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::AssignKeyboard()
+{
+XSetInputFocus(XtDisplay (XtWdg()), XtWindow(XtWdg()), RevertToParent, PIXGetLastEventTime());
+}
+
+/* --Methode-- */
+PIColors   PIBaseWdgX::GetBackgroundColor()
+{
+return(mBCol);
+}
+
+/* --Methode-- */
+PIPointer  PIBaseWdgX::GetPointerShape()
+{
+return (mPtrS);
+}
+
+/* --Methode-- */
+void PIBaseWdgX::GetLastEventInfo(PIKeyModifier& kmod, unsigned long& tm)
+{
+unsigned int st;
+Time t;
+PIXGetLastEventInfo(st, t);
+tm = t;
+kmod = PIKM_Blank;
+if  (st & ShiftMask)   kmod = (PIKeyModifier) (kmod | PIKM_Shift);
+if  (st & ControlMask) kmod = (PIKeyModifier) (kmod | PIKM_Cntl);
+if  (st & Mod1Mask)    kmod = (PIKeyModifier) (kmod | PIKM_Alt);
+return;
+}
+
+static bool fgbwdg = false ;
+
+/* --Methode-- */
+void PIBaseWdgX::Init()
+{
+int i;
+
+if (fgbwdg)  return;
+fgbwdg = true;
+
+Display *mdsp = PIXDisplay();
+int scr = XDefaultScreen(mdsp);
+
+colpixwhite = XWhitePixel(mdsp, scr);
+colpixblack = XBlackPixel(mdsp, scr);
+
+curs[0] = XCreateFontCursor(mdsp, XC_X_cursor);
+for(i=1; i<NMAXCURS; i++)  curs[i] = curs[0];
+
+curs[PI_ArrowPointer] =  XCreateFontCursor(mdsp, XC_arrow);
+curs[PI_CrossPointer] =  XCreateFontCursor(mdsp, XC_crosshair);
+curs[PI_HandPointer] =  XCreateFontCursor(mdsp, XC_hand2);
+curs[PI_TDLRArrowPointer] =  XCreateFontCursor(mdsp, XC_fleur);
+
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::eXposeProcess(int x0, int y0, int dx, int dy)                                 
+{ 
+// Appel depuis le PIXtBaseWidget uniquement (ExposeEvt de Xt )
+Draw(mWGrC, x0, y0, dx, dy);
+CallDrawers(mWGrC, x0, y0, dx, dy); 
+return;
+}
Index: /tags/V_LaSilla191199/SophyaPI/PI/pibwdgx.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pibwdgx.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pibwdgx.h	(revision 464)
@@ -0,0 +1,62 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive      PIBaseWdg
+//                                    Reza  95-96
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIBWDGX_H_SEEN
+#define PIBWDGX_H_SEEN
+
+#include "pisysdep.h"
+#include "pibwdggen.h"
+
+#include "pigraphx.h"
+            
+#include "pigraphps.h"
+
+class PIBaseWdgX : public PIBaseWdgGen
+{
+
+public:
+// Les methodes ...
+
+                     PIBaseWdgX(PIContainerGen *par, const char *nom,
+                                int sx=10, int sy=10, int px=0, int py=0);
+  virtual            ~PIBaseWdgX();
+
+  virtual void       FinishCreate();   // appele par la fenetre mere, apres XtRealize()
+
+//  Activation des evenements   
+  virtual void       ActivatePtrCross();
+  virtual void       ActivateButton(int bid);
+  virtual void       ActivateMove(int bid);
+  virtual void       ActivateKeyboard();
+
+//  Divers : couleur de fond, Effacement fenetre,  forme de la souris
+  virtual void       SetBackgroundColor(PIColors col=PI_White);
+  virtual void       EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0);
+  virtual void       SelPointerShape(PIPointer ptr=PI_ArrowPointer);
+  virtual PIColors   GetBackgroundColor();
+  virtual PIPointer  GetPointerShape();
+  virtual void       AssignKeyboard();
+
+// Acces aux caracteristiques du dernier evenement 
+  virtual void       GetLastEventInfo(PIKeyModifier& kmod, unsigned long& tm);
+
+// On redefinit IsVisible() pour tenir compte de l appel a FinsihCreate  
+  virtual bool       IsVisible();
+
+//  Fonction qui doit etre appelee pour rafraichir la fenetre 
+  virtual void       Refresh();
+
+//  Appel depuis le PIXtBaseWidget uniquement (ExposeEvt de Xt )
+  virtual void       eXposeProcess(int x0, int y0, int dx, int dy);
+ 
+protected:
+  void               Init();
+  PIPointer mPtrS;
+  PIColors mBCol;
+};
+
+typedef PIBaseWdgX PIBaseWdg;
+
+#endif /* PIBWDGX_H_SEEN */
Index: /tags/V_LaSilla191199/SophyaPI/PI/picmap.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/picmap.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/picmap.cc	(revision 464)
@@ -0,0 +1,362 @@
+// Module PI : Peida Interactive     PIColorMap
+// Gestion de table de couleurs        96
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "picmap.h"
+
+//++
+// Class	PIColorMap
+// Lib		PI
+// include	picmap.h
+//
+//   	Classe fournissant les services de gestion des tables de couleur.
+//	Une hiérachie un peu complexe a été mise en place pour 
+//	l'implémentation des tables de couleurs pour chaque système
+//	(Mac, XWindow, ...) :
+//|	PIColorMapGen  -----  PIColorMapX     (=PIColorMapNative)
+//|	                 |--  PIColorMapMac   (=PIColorMapNative)
+//	et la gestion de table de couleurs standard partagée.
+//|	PIColorMapNative (=X,Mac,...) ----- PIColorMap.
+//	La seule classe à utiliser est *PIColorMap* qui fournit 
+//	l'ensemble des services de gestion de table de couleurs.
+//--
+
+#define  MXMAPIDS   10 
+static   int    MapNCols[MXMAPIDS] = {256, 256, 256, 256, 256, 256, 256, 256, 256, 256};
+static   const char*  MapNoms[MXMAPIDS]  = {"Grey32","InvGrey32","ColRJ32","ColBR32",
+                               "ColRV32", "Grey128", "InvGrey128", "ColRJ128",
+                               "ColBR128", "Col16"};
+static   CMapId MapIds[MXMAPIDS] = { CMAP_GREY32, CMAP_GREYINV32, CMAP_COLRJ32,
+                               CMAP_COLBR32, CMAP_COLRV32, CMAP_GREY128, 
+                               CMAP_GREYINV128, CMAP_COLRJ128, CMAP_COLBR128,  
+                               CMAP_COL16 } ;
+
+static   int mColTNums[8192];   // Max 8192 tables differentes pour le moment  
+static   int CTNum = 0;        //  Numero des tables ds mColTNum - s'incremente a chaque creation 
+
+static   int NMaxTableAuto = 0;
+static   PIColorMap* mMaps[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL };
+
+//++
+// Titre	Constructeurs, méthodes
+//--
+//++
+// PIColorMap(CMapId id)
+//	Constructeur d'une table de couleur standard, identifiée par "CMapId id"
+//|	CMAP_GREY32     :  32 niveaux de gris
+//|	CMAP_GREYINV32  :  32 niveaux gris du blanc au noir
+//|	CMAP_COLRJ32    :  32 couleurs, du Rouge au Jaune/blanc
+//|	CMAP_COLBR32    :  32 couleurs du bleu au rouge (arcenciel)
+//|	CMAP_COLRV32    :  32 couleurs du rouge au violet
+//|	CMAP_GREY128    :  128 niveaux de gris
+//|	CMAP_GREYINV128 :  128 niveaux gris inversé
+//|	CMAP_COLRJ128   :  128 couleurs, du Rouge au Jaune/blanc
+//|	CMAP_COLBR128   :  128 couleurs du bleu au rouge (arcenciel)
+//|	CMAP_COL16      :  16 Couleurs arcenciel
+//|	CMAP_OTHER      :  Table non standard
+//	Toutes les tables de couleurs standard possèdent 256 cellules de couleurs,
+//	contenant 16 ou 32 ou 128 couleurs distinctes.
+//
+// PIColorMap(string const& nom, int nCol)
+//	Constructeur d'une table de "nCol" couleurs identifié par la chaîne "nom".
+// PIColorMap(PIColorMap&)
+//	Constructeur par copie.
+// int Type()
+//	Retourne le type de la table, correspondant à "CMapId id"
+// int NCol()
+//	Retourne le nombre de cellules de couleurs dans la table
+// string const& Nom()
+//	Renvoie le nom de la table.
+//--
+
+PIColorMap::PIColorMap(CMapId id)
+: PIColorMapNative()
+{
+   int k, kdx;
+   string mnom;
+
+   if (NMaxTableAuto == 0) { //  Il faut allouer les tables de depart
+     if ( TotNbColors() > 2048 ) NMaxTableAuto = MXMAPIDS-1;
+     else NMaxTableAuto = 3; 
+     for(k=0; k<NMaxTableAuto; k++)  { 
+        mnom = MapNoms[k]; 
+        mMaps[k] = new PIColorMap(MapIds[k], MapNCols[k], mnom);
+     }
+   }
+
+//  Protection pour valeur de Id  
+   for(kdx=0; kdx<MXMAPIDS; kdx++)  if (id == MapIds[kdx])  break;
+   if (kdx == MXMAPIDS)  { id = MapIds[0];  kdx = 0; }
+   for(k=0; k<NMaxTableAuto; k++)  
+     if (id == mMaps[k]->Type()) {
+       CopyFrom(mMaps[k]);  
+       mCTId = mMaps[k]->mCTId;  mColTNums[mCTId]++;
+       break;
+     }
+   if (Type() != id)  {  // Table pas encore trouve dans la liste
+     k = NMaxTableAuto;
+     if (!mMaps[k] || mMaps[k]->Type() != id) {
+       if ( mMaps[k] ) {  
+         mColTNums[mMaps[k]->mCTId] = 1;  // Je force a liberer les couleurs 
+         delete mMaps[k] ;
+       }
+       mnom = MapNoms[kdx];
+       mMaps[k] = new PIColorMap(MapIds[kdx],  MapNCols[kdx], mnom); 
+     }
+    CopyFrom(mMaps[k]);  
+    mCTId = mMaps[k]->mCTId;  mColTNums[mCTId]++;
+   }
+}
+
+
+PIColorMap::PIColorMap(string const& nom, int nCol)
+: PIColorMapNative(CMAP_OTHER, nCol, nom)
+{
+  MakeColMap();
+  mCTId = CTNum;
+  mColTNums[mCTId] = 1;
+  CTNum++;
+}
+
+PIColorMap::PIColorMap(CMapId id, int nCol, string const& nom)
+: PIColorMapNative(id, nCol, nom)
+{
+  MakeColMap();
+  mCTId = CTNum;
+  mColTNums[mCTId] = 1;
+  CTNum++;
+//  printf("PIColorMap/Debug-Creation:  %d %d - %s ", Type(), NCol(), Nom().c_str());
+//  printf("  ..CRE.. %d %d \n", CTNum-1, mColTNums[CTNum-1]);
+}
+
+PIColorMap::PIColorMap(PIColorMap& cm)
+{
+  CopyFrom(&cm);
+  mCTId = cm.mCTId;
+  mColTNums[mCTId]++;
+}
+
+PIColorMap::~PIColorMap()
+{
+//  printf("PIColorMap/Debug-Delete:  %d %d - %s ", Type(), NCol(), Nom().c_str());
+//  printf("...DEL.CTNum,mColTNums= %d %d (%d %d) ", 
+//        CTNum, mColTNums[CTNum], mCTId,mColTNums[mCTId] );
+  mColTNums[mCTId]--; 
+  if ( mColTNums[mCTId] == 0 )  { FreeColors();  mColTNums[mCTId] = 0; }
+//  printf("\n");
+}
+
+
+//++
+// Titre	Gestion des couleurs
+//	Une structure *PIColor* permet la manipulation des couleurs à 
+//	travers 3 champs de type "unsigned short: 0 ... 65535" définissant
+//	les intensité des couleurs de base: Rouge, Bleue, Vert.
+//|	struct PIColor {
+//|	  unsigned short red;
+//|	  unsigned short green;
+//|	  unsigned short blue; }
+//
+//--
+//++
+// PIColor GetColor(int n)	
+//	Renvoie la couleur de la cellule "n"
+// bool AllocColor(PIColor const& col, int index)
+//	Alloue la couleur définie par "col" dans la cellule numéro "index".
+//	Renvoie "true" si OK, "false" sinon.
+// void  FreeColors()
+//	Libère les couleurs allouées par la table
+// long  TotNbColors()
+//	Renvoie le nombre total de couleurs disponibles 
+//	(Ex 256 pour un système à 8 plans image, 65536 pour 16 plans, etc ...)
+// int  NbAllocColors()
+//	Renvoie le nombre total de couleurs déjà utilisée par l'application
+//--
+
+void PIColorMap::CleanColorMaps()
+{
+  int k;
+  for(k=0; k<MXMAPIDS; k++)  { 
+    if (!mMaps[k])  continue;
+    mMaps[k]->FreeColors();
+    delete mMaps[k];
+  }
+}
+
+/*  Definition d' une table de couleurs  R G B   */
+
+static float R_RGB1[16] =
+{0.0,0.00,0.0,0.0,0.0,0.00,0.0,0.6,0.8,1.0,1.00,1.0,0.75,1.0,0.85,1.0};
+static float G_RGB1[16] =
+{0.0,0.00,0.0,0.8,1.0,1.00,1.0,0.8,0.8,1.0,0.75,0.6,0.00,0.0,0.0,0.0};
+static float B_RGB1[16] =
+{0.0,0.75,1.0,1.0,1.0,0.75,0.0,0.0,0.0,0.0,0.00,0.5,0.75,1.0,0.0,0.0};
+
+
+
+void PIColorMap::MakeColMap()
+{
+  PIColor mycol;
+  int i,j,k;
+
+  switch (mType) {
+
+    case CMAP_GREY32 :
+      for(i=0; i<32; i++) {
+        mycol.red = mycol.green = mycol.blue = 3535+(i*62000/32);
+        for(k=0; k<8; k++)     AllocColor(mycol, i*8+k);
+      }
+      break;
+    
+
+    case CMAP_GREYINV32 :
+      for(i=0; i<32; i++) {
+        mycol.red = mycol.green = mycol.blue = 3535+(i*62000/32);
+        for(k=0; k<8; k++)     AllocColor(mycol, mNCol-(i*8+k)-1);
+      }
+      break;
+
+    case CMAP_COL16 :
+      for(i=0; i<16; i++) {
+        mycol.red = (int)(R_RGB1[i]*65535.);
+        mycol.green = (int)(G_RGB1[i]*65535.);
+        mycol.blue =(int)(B_RGB1[i]*65535.) ;
+        for(k=0; k<16; k++)     AllocColor(mycol, i*16+k);
+      }
+      break;
+
+    case CMAP_COLRJ32 :
+      for( i=0; i<32; i++) {
+        if (i < 12)  { 
+          mycol.green = mycol.blue = 0;  
+          mycol.red = 21535+(i*4000);  }
+        else if (i < 24) { 
+          mycol.blue = 0;   mycol.red = 65535;
+          mycol.green = 21535+(i-12)*4000;  }
+        else { 
+          mycol.green = mycol.red = 65535;
+          mycol.blue = 17535+(i-23)*6000; }
+        for(k=0; k<8; k++)   AllocColor(mycol, i*8+k); 
+        }
+      break;
+
+  case CMAP_COLBR32 :
+    for( i=0; i<32; i++) {
+      if (i < 5) { 
+        mycol.green = mycol.red = 0;    // Du bleu sombre au bleu clair
+        mycol.blue = 5535+i*15000; }
+      else if (i < 10) { 
+        mycol.blue = 65535;             // Plein bleu - On rajoute du vert -> bleu clair
+        mycol.green = 5535+(i-5)*9000;
+        mycol.red = 0;  }
+      else if (i < 15) { 
+        mycol.blue = 60000-(i-10)*15000;   // On passe au vert
+        mycol.green = 41535+(i-10)*6000;
+        mycol.red = 0;  }
+      else if (i < 21) { 
+        mycol.blue = 0;
+        mycol.green = 65535;               // Plein vert, on rajoute du rouge -> jaune
+        mycol.red = 5535+(i-15)*12000;  }
+      else if (i < 27) {  
+        mycol.blue = 0;                     //  On diminue vert -> Orange
+        mycol.green = 60000-(i-21)*12000;
+        mycol.red = 65535-(i-21)*2000;  }
+      else {
+        mycol.blue = 0;                     // Plein rouge
+        mycol.green = 0;
+        mycol.red = 57535+(i-27)*2000; }
+
+      for(k=0; k<8; k++)   AllocColor(mycol, i*8+k); 
+      }
+    break;
+
+  case CMAP_COLRV32 :
+    for( i=0; i<32; i++) {
+      if (i < 8) {
+        mycol.green = 15000+(i*5000); mycol.blue = 0;  
+        mycol.red = 15000+(i*5000); }
+      else if (i < 21) {
+        mycol.green = 50000-(i-7)*5000;   
+        if (mycol.green < 0)  mycol.green = 0;
+        mycol.blue = 0;
+        mycol.red = 53535+(i-8)*1000;  }
+      else { 
+        mycol.green = 0;  mycol.red = 65535;
+        mycol.blue = 15535+(i-21)*5000; }
+
+      for(k=0; k<8; k++)   AllocColor(mycol, i*8+k); 
+      }
+    break;
+
+    case CMAP_GREY128 :
+      for(i=0; i<128; i++) {
+        mycol.red = mycol.green = mycol.blue = 2035+(i*500);
+        for(k=0; k<2; k++)     AllocColor(mycol, i*2+k);
+      }
+      break;
+    
+
+    case CMAP_GREYINV128 :
+      for(i=0; i<128; i++) {
+        mycol.red = mycol.green = mycol.blue = 2035+(i*500);
+        for(k=0; k<2; k++)     AllocColor(mycol, mNCol-(i*2+k)-1);
+      }
+      break;
+
+    case CMAP_COLRJ128 :
+      for( i=0; i<128; i++) {
+        if (i < 48)  { 
+          mycol.green = mycol.blue = 0;  
+          mycol.red = 5375+(i*1280);  }
+        else if (i < 96) { 
+          mycol.blue = 0;   mycol.red = 65535;
+          mycol.green = 5375+((i-48)*1280);  }
+        else { 
+          mycol.green = mycol.red = 65535;
+          mycol.blue = 3535+(i-96)*2000; }
+        for(k=0; k<2; k++)   AllocColor(mycol, i*2+k); 
+        }
+      break;
+
+    case CMAP_COLBR128 :
+      for( i=0; i<128; i++) {
+        if (i < 20) { 
+          mycol.green = mycol.red = 0;  // Du bleu sombre au bleu clair
+          mycol.blue = 2835+i*3300; }
+        else if (i < 36) { 
+          mycol.blue = 65535;           // Plein bleu - On rajoute du vert -> bleu clair
+          mycol.green = 3000+(i-20)*2000;
+          mycol.red = 0;  }
+        else if (i < 56) { 
+          mycol.blue = 64600-(i-36)*3400;    // On passe au vert 
+          mycol.green = 32300+(i-36)*1700;
+          mycol.red = 0;  }
+        else if (i < 81) {         
+          mycol.blue = 0;              // Plein vert, on rajoute du rouge -> jaune
+          mycol.green = 65535;
+          mycol.red = 3135+(i-56)*2600;  }
+        else if (i < 96) { 
+          mycol.blue = 0;
+          mycol.green = 63535-(i-80)*2000;
+          mycol.red = 65535;  }
+        else if (i < 112) { 
+          mycol.blue = 0;
+          mycol.green = 30000-(i-96)*2000;
+          mycol.red = 65535-(i-96)*1000;  }
+        else {
+          mycol.blue = 0;
+          mycol.green = 0 ;
+          mycol.red = 50535+(i-112)*1000; }
+
+        for(k=0; k<2; k++)   AllocColor(mycol, i*2+k); 
+      }
+      break;
+
+  default :
+    for(i=0; i<mNCol; i++) {
+      mycol.green = mycol.red = mycol.blue = 0;
+      AllocColor(mycol, i);
+    }
+    break;
+  }
+}
Index: /tags/V_LaSilla191199/SophyaPI/PI/picmap.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/picmap.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/picmap.h	(revision 464)
@@ -0,0 +1,45 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive     PIColorMap
+// Gestion de table de couleurs        96
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PICMAP_H_SEEN
+#define PICMAP_H_SEEN
+
+#include "pisysdep.h"
+#include PICMAPNTV_H
+
+enum CMapId
+ {
+ CMAP_OTHER       = 0, 
+ CMAP_GREY32      = 1,     // 32 niveaux de gris                    * permanent
+ CMAP_GREYINV32   = 2,     // 32 niveaux gris du blan au noir       * permanent
+ CMAP_COLRJ32     = 3,     // 32 couleurs, du Rouge au Jaune/blanc  * permanent
+ CMAP_COLBR32     = 4,     // 32 couleurs du bleu au rouge
+ CMAP_COLRV32     = 5,     // 32 couleurs 
+ CMAP_GREY128     = 6,     // 128 couleurs  niveaux de gris
+ CMAP_GREYINV128  = 7,     //    "     "      "      " 
+ CMAP_COLRJ128    = 8,     // 128 couleurs du rouge au jaune/blanc
+ CMAP_COLBR128    = 9,     // 128 couleurs du bleu au rouge
+ CMAP_COL16       = 10     // 16 Couleurs Arcenciel
+ };
+
+
+class PIColorMap : public PIColorMapNative {
+public:
+  PIColorMap(CMapId);
+  PIColorMap(string const& nom, int nCol); 
+  PIColorMap(PIColorMap&);
+  virtual ~PIColorMap();
+
+  static void CleanColorMaps();
+
+protected:
+  PIColorMap(CMapId id, int nc, string const& nom);  // Fait l'allocation des couleurs     
+  void     MakeColMap();
+
+  int mCTId;    // Pour tenir trace de la derniere table qui doit liberer les couleurs 
+};
+
+#endif
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/picmapgen.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/picmapgen.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/picmapgen.cc	(revision 464)
@@ -0,0 +1,35 @@
+#include "picmapgen.h"
+#include <list>
+#include <algorithm>
+#include "pisysdep.h"
+#include PICMAPNTV_H
+#include PICMAP_H
+
+
+
+PIColorMapGen::PIColorMapGen()
+{
+  mNom = "";
+  mNCol = 0;
+  mType = -1;
+}
+PIColorMapGen::PIColorMapGen(int id, int nc, string const& nom)
+{
+  mNom = nom;
+  mNCol = nc;
+  mType = id;
+}
+
+
+PIColorMapGen::~PIColorMapGen()
+{
+}
+
+void PIColorMapGen::CopyFromGen(PIColorMapGen* m)
+{
+  mNom = m->mNom;
+  mNCol = m->mNCol;
+  mType = m->mType;
+}
+
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/picmapgen.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/picmapgen.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/picmapgen.h	(revision 464)
@@ -0,0 +1,43 @@
+#ifndef PICMAPBASE_H_SEEN
+#define PICMAPBASE_H_SEEN
+
+#include "pisysdep.h"
+#include <string>
+#include <string.h>
+
+ 
+struct PIColor {
+  unsigned short red;
+  unsigned short green;
+  unsigned short blue;
+};
+
+class PIColorMapGen {
+public:
+  PIColorMapGen();  
+  PIColorMapGen(int id, int nc, string const& nom);  
+  virtual ~PIColorMapGen();
+
+  int Type() const          {return mType;}
+  int NCol() const          {return mNCol;}
+  string const& Nom() const {return mNom;}
+
+  virtual PIColor GetColor(int n)=0;
+  virtual bool AllocColor(PIColor const& col, int index)=0;
+  virtual void FreeColors()=0;     // Desalloue les couleurs
+
+  virtual long   TotNbColors()=0;   // Donne le nombre total de couleurs disponibles
+  virtual int   NbAllocColors()=0;  // Nb de couleurs deja allouees 
+protected:
+  void CopyFromGen(PIColorMapGen*);
+  virtual void CopyFrom(PIColorMapGen*)=0;
+  
+
+  int    mNCol;
+  int    mType;
+  string mNom;
+  
+};
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/picmapmac.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/picmapmac.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/picmapmac.cc	(revision 464)
@@ -0,0 +1,114 @@
+#include "picmapmac.h"
+#include <UDebugging.h>
+
+static int NTotAllocCol;
+
+
+PIColorMapMac::PIColorMapMac()
+: PIColorMapGen(), mPalette(NULL), mCTab(NULL)
+{
+}
+
+PIColorMapMac::PIColorMapMac(int id, int nc, string const& nom) 
+: PIColorMapGen(id, nc, nom)
+{
+    int n = nc+2;
+	mCTab = (CTabHandle) ::NewHandle(sizeof(long) + 
+				sizeof(short) + sizeof(short) + 
+				n*sizeof(ColorSpec));
+	(**mCTab).ctFlags = 0;
+	(**mCTab).ctSeed = GetCTSeed();
+	(**mCTab).ctSize = n;
+    ColorSpec* sp = (**mCTab).ctTable;
+    sp[0].rgb.red   = 0;
+    sp[0].rgb.green = 0;
+    sp[0].rgb.blue  = 0;
+    sp[0].value     = 0;
+    sp[1].rgb.red   = 65535;
+    sp[1].rgb.green = 65535;
+    sp[1].rgb.blue  = 65535;
+    sp[1].value     = 1;
+    for (int i=2; i<n; i++) {
+      sp[i].rgb.red   = 0;
+      sp[i].rgb.green = 0;
+      sp[i].rgb.blue  = 0;
+      sp[i].value     = i;
+    }
+  mPalette = NewPalette(mNCol,mCTab,pmTolerant,0);
+}
+
+PIColorMapMac::~PIColorMapMac()
+{
+  DisposePalette(mPalette);
+  DisposeHandle((Handle)mCTab);
+}
+
+/* --Methode-- */
+PIColor PIColorMapMac::GetColor(int n)
+{
+PIColor picr;
+picr.red = picr.green = picr.blue = 0;
+
+if ((n<0) || (n >= NCol()))   
+  return(picr);
+
+RGBColor qdCol;
+GetEntryColor(mPalette,n+2,&qdCol);
+
+picr.red   = qdCol.red;
+picr.green = qdCol.green;
+picr.blue  = qdCol.blue;
+
+return(picr);
+}
+
+
+bool PIColorMapMac::AllocColor(PIColor const& col, int index)
+{
+  if (!mPalette) return false;
+  if ((index < 0) || (index > mNCol))  return(false);
+  
+  RGBColor srcRGB;
+  srcRGB.red   = col.red;
+  srcRGB.green = col.green;
+  srcRGB.blue  = col.blue;
+  
+  SetEntryColor(mPalette,index+2,&srcRGB);
+  ((**mCTab).ctTable)[index+2].rgb = srcRGB;
+  NTotAllocCol++;
+  return true;    //  $CHECK$  retourne true si OK - Reza 01/12/97
+}
+
+long PIColorMapMac::TotNbColors()
+{
+   PixMapHandle pmh = ((CGrafPort*)qd.thePort)->portPixMap;
+   int depth = (**pmh).cmpSize * (**pmh).cmpCount;
+   long nbcol = 1;
+   for (int i=0; i<depth; i++)
+     nbcol *= 2;
+   return nbcol;
+}
+
+void PIColorMapMac::FreeColors()
+{
+  Assert_(mPalette);
+  DisposePalette(mPalette);
+  DisposeCTable(mCTab);
+}
+
+int PIColorMapMac::NbAllocColors()
+{
+return(NTotAllocCol);
+}
+
+
+void PIColorMapMac::CopyFrom(PIColorMapGen* x)
+{
+  CopyFromGen(x);
+  PIColorMapMac* y = (PIColorMapMac*) x;
+  mPalette = y->mPalette;
+  mCTab = y->mCTab;
+  HandToHand(&(Handle)mCTab);
+  HandToHand(&(Handle)mPalette);
+  Assert_(mPalette);
+}
Index: /tags/V_LaSilla191199/SophyaPI/PI/picmapmac.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/picmapmac.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/picmapmac.h	(revision 464)
@@ -0,0 +1,34 @@
+#ifndef PICMAPMAC_H_SEEN
+#define PICMAPMAC_H_SEEN
+
+#include "picmapgen.h"
+#include <Palettes.h>
+
+
+class PIColorMapMac : public PIColorMapGen {
+public:
+  PIColorMapMac();
+  PIColorMapMac(int id, int nc, string const& nom);  
+  ~PIColorMapMac();
+  
+  virtual PIColor GetColor(int n);
+  virtual bool AllocColor(PIColor const& col, int index);   // $CHECK$  Reza 01/12/97(Modif)
+  virtual void FreeColors();
+
+  virtual long  TotNbColors();
+  virtual int   NbAllocColors();
+  
+  CTabHandle    GetCTab() {return mCTab;}
+protected:
+  void CopyFrom(PIColorMapGen*);
+  
+  CTabHandle    mCTab;
+  PaletteHandle mPalette;
+
+  friend class PIColorMapGen;
+  friend class PIPixmapMac;
+};
+
+typedef PIColorMapMac PIColorMapNative;
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/picmapview.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/picmapview.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/picmapview.cc	(revision 464)
@@ -0,0 +1,129 @@
+// Module PI : Peida Interactive     PICMapView
+// Visualisation de table de couleur     R. Ansari  07/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "picmapview.h"
+
+
+
+/* --Methode-- */
+PICMapView::PICMapView(PIContainerGen *par, char *nom,
+                       int sx, int sy, int px, int py) 
+: PIBaseWdg(par, nom, sx, sy, px, py)
+
+{
+  cmap = NULL;
+  vmin = 1.;   vmax = -1.; 
+}
+
+
+/* --Methode-- */
+PICMapView::~PICMapView()
+{
+  if (cmap) delete cmap;
+}
+
+ 
+/* --Methode-- */
+void PICMapView::SetColMap(PIColorMap* cmp, float min, float max, bool refr)
+{
+  if (cmp == NULL)   { 
+    if (cmap) delete cmap;
+    cmap = NULL;
+    vmin = 1.;  vmax = -1.;
+    if (refr)  Refresh();  
+    return;
+    }
+  if ( cmap && (cmp->Type() == cmap->Type()) && (cmp->Type() != CMAP_OTHER) 
+       && ((vmin-min) < 1.e-19) &&  ((vmin-min) > -1.e-19) &&
+       ((vmax-max) < 1.e-19) &&  ((vmax-max) > -1.e-19) )  return;
+  if (cmap) delete cmap;
+  cmap = new PIColorMap(*cmp);
+  vmin = min;  vmax = max;
+  if (refr)  Refresh();  
+  return;
+}
+
+/* --Methode-- */
+void PICMapView::SetColMapId(CMapId cmapid, float min, float max, bool refr)
+{
+  if ( cmap && (cmapid == cmap->Type()) && (cmapid != CMAP_OTHER) 
+       && ((vmin-min) < 1.e-19) &&  ((vmin-min) > -1.e-19) &&
+       ((vmax-max) < 1.e-19) &&  ((vmax-max) > -1.e-19) )  return;
+  if (cmap) delete cmap;
+  cmap = new PIColorMap(cmapid);
+  vmin = min;  vmax = max;
+  if (refr)  Refresh();  
+  return;
+}
+
+
+/* --Methode-- */
+void PICMapView::Draw(PIGraphicGen* g, int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/)
+{
+  if (!cmap) { 
+    EraseWindow(0, 0, XSize(), YSize());
+    return;
+    }
+  // On presente la table de couleur verticalement si SizeY > SizeX 
+  // ou horizontale  si SizeX > SizeY
+
+  int sx = XSize(); 
+  int sy = YSize(); 
+
+  int k;
+  if (sx > sy) {    // horizontal
+    int xc, dx;
+    xc = 0;
+    for(k=0; k<cmap->NCol(); k++) {
+      dx = (sx-xc)/(cmap->NCol()-k);
+      g->SelForeground((*cmap), k);
+      g->DrawFBox(xc, 0, dx, sy);
+      xc += dx;
+    }
+  }
+  else  {    // vertical
+    int yc, dy;
+    yc = sy;
+    for(k=0; k<cmap->NCol(); k++) {
+      dy = yc/(cmap->NCol()-k);
+      yc -= dy;
+      g->SelForeground((*cmap), k);
+      g->DrawFBox(0, yc, sx, dy);
+    }
+  }
+  
+  if (vmin > vmax)   return;
+  if ( (cmap->Type() == CMAP_GREY32) || (cmap->Type() == CMAP_GREYINV32) ||
+       (cmap->Type() == CMAP_GREY128) || (cmap->Type() == CMAP_GREYINV128) )  g->SelForeground(PI_Red);
+  else if ( (cmap->Type() == CMAP_COLRJ32) || (cmap->Type() == CMAP_COLRJ128) ) g->SelForeground(PI_Magenta);
+  else g->SelForeground(PI_White);
+
+  if (sx > sy) {    // horizontal
+    int fsz = (sy < 20) ? sy-8 : 12;
+    g->SelFontSzPt(fsz);
+    char buff[32];
+    sprintf(buff, "%.2f", vmin);
+    g->DrawString(4, sy-4, buff);
+    sprintf(buff, "%.2f", vmax);
+    g->DrawString(sx-4-(int)g->CalcStringWidth(buff), sy-4, buff);
+    } 
+  else {   // vertical 
+    int fsz = (sx < 40) ? sx/4 : 12;
+    g->SelFontSzPt(fsz);
+    char buff[32];
+    sprintf(buff, "%.2f", vmin);
+    g->DrawString(4, sy-4, buff);
+    sprintf(buff, "%.2f", vmax);
+    int fa, fd;
+    g->DrawString(4, g->GetFont().GetFontHeight(fa,fd)+4, buff);
+    } 
+    
+  return;
+}
+
+
+
+
+
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/picmapview.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/picmapview.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/picmapview.h	(revision 464)
@@ -0,0 +1,39 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive     PICMapView
+// Visualisation de table de couleur     R. Ansari  07/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PICMAPVIEW_H_SEEN
+#define PICMAPVIEW_H_SEEN
+
+#include "pisysdep.h"
+
+#include PIBWDG_H
+#include PICMAP_H
+
+class PICMapView : public PIBaseWdg
+{
+public:
+  enum {ClassId = 5150};
+
+                  PICMapView(PIContainerGen *par, char *nom,
+                             int sx=256, int sy=10, int px=0, int py=0);
+  virtual         ~PICMapView();
+
+  virtual long	  kind() {return ClassId; }
+
+  void            SetColMap(PIColorMap* cmp=NULL, float min=1., float max=-1., bool refr=true);
+  void            SetColMapId(CMapId cmapid, float min=1., float max=-1., bool refr=true);
+
+// Traitement des evenements   
+
+  virtual void   Draw(PIGraphic* g, int x0, int y0, int dx, int dy);
+
+
+protected:
+  PIColorMap* cmap;
+  float vmin, vmax;
+};
+
+
+#endif 
Index: /tags/V_LaSilla191199/SophyaPI/PI/picmapx.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/picmapx.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/picmapx.cc	(revision 464)
@@ -0,0 +1,192 @@
+#include <stdio.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+
+#include "piwdgx.h"
+#include "picmapx.h"
+
+/* --Methode-- */
+PIColorMapX::PIColorMapX()    
+: PIColorMapGen()
+{
+mColors = NULL;
+mColRGB = NULL;
+mNewCol = NULL;
+}
+
+/* --Methode-- */
+PIColorMapX::PIColorMapX(int id, int nc, string const& nom)    
+: PIColorMapGen(id, nc, nom)
+{
+
+int n = nc;
+mColors = new PIXColor[n];
+mColRGB = new PIColor[n];
+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; 
+  mNewCol[i] = false; }
+// printf("PIColorMapX::PIColorMapX(CMapId, int) %d %d \n", mNCol, Type());
+}
+
+
+/* --Methode-- */
+PIColorMapX::~PIColorMapX()
+{
+if (mColors)  delete[] mColors;
+if (mColRGB)  delete[] mColRGB;
+if (mNewCol)  delete[] mNewCol;
+}
+
+
+/* --Methode-- */
+PIColor PIColorMapX::GetColor(int n)
+{
+if ((n<0) || (n >= NCol()))   
+  {
+  PIColor picr;
+  picr.red = picr.green = picr.blue = 0;
+  return(picr);
+  }
+return(mColRGB[n]);
+}
+
+static  Colormap  defxcmap;
+static  int xinicmap = 0;
+static int NTotColors = 0;
+static int NTotAllocCol = 0;
+
+static int nerrallocol = 0;
+
+/* --Methode-- */
+bool PIColorMapX::AllocColor(PIColor const& col, int index)
+{
+XColor myxcol;
+
+if (!xinicmap)  
+  {
+  defxcmap = XDefaultColormap (PIXDisplay(), PIXScreen());
+  xinicmap = 1;
+  }
+
+if ( (index < 0) || (index >= mNCol) )  return(false);
+
+if ( (col.red == 0) && (col.green == 0) && (col.blue == 0) )
+  {
+  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;
+myxcol.green = col.green;
+
+
+if ( XAllocColor(PIXDisplay(), defxcmap, &myxcol) ) {
+  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);
+  NTotAllocCol++;  
+  return(true);
+  }
+else {
+  nerrallocol++;
+  if (nerrallocol < 21) printf("PIColorMapX::AllocColor() Error: Pb Allocation RGB= %d %d %d \n",
+         (int) col.red, (int) col.blue, (int) col.green);
+  if (nerrallocol == 20) printf("No more  PIColorMapX::AllocColor() Errors will be reported \n");
+  return(false);
+  }
+}
+
+/* --Methode-- 
+void PIColorMapX::MakeColMap()
+{
+}
+*/
+
+/* --Methode-- */
+void PIColorMapX::FreeColors()
+{
+PIXColor bpix;
+PIColor blc;
+
+if (!xinicmap)  
+  {
+  defxcmap = XDefaultColormap (PIXDisplay(), PIXScreen());
+  xinicmap = 1;
+  }
+
+for (int i=0; i<mNCol; i++)
+  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;  mNewCol[i] = false; }
+}
+// printf("PIColorMapX::FreeColors()  Type= %d mNCol= %d \n",
+//        Type(), NCol());
+
+}
+
+
+/* --Methode-- */
+long PIColorMapX::TotNbColors()
+{
+if (NTotColors > 0)  return(NTotColors);
+// Visual* vis;
+// DefaultVisual(PIXDisplay(),  PIXScreen() );
+int k,kk;
+// On calcule le nombre de couleurs a partir du nb de plans image
+kk = DefaultDepth(PIXDisplay(),  PIXScreen() );
+NTotColors = 1;
+for(k=0; k<kk; k++) NTotColors *= 2;
+/*
+ printf("PIColorMapX::TotNbColor() / Debug : Nb Tot Colors = %d - D=%d - NCol=%d NP= %d \n", NTotColors, 
+ DefaultDepth(PIXDisplay(),  PIXScreen()), 
+ DisplayCells(PIXDisplay(),  PIXScreen()), 
+ DisplayPlanes(PIXDisplay(),  PIXScreen()) );
+*/
+return(NTotColors);
+}
+
+/* --Methode-- */
+int PIColorMapX::NbAllocColors()
+{
+return(NTotAllocCol);
+}
+
+
+/* --Methode-- */
+void PIColorMapX::CopyFrom(PIColorMapGen* x)
+{
+  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]; 
+// C'est la table de couleur originale qui est responsable de liberer les couleurs - Reza 8/2/98
+    mNewCol[i] = false; }  
+}
Index: /tags/V_LaSilla191199/SophyaPI/PI/picmapx.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/picmapx.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/picmapx.h	(revision 464)
@@ -0,0 +1,35 @@
+#ifndef PICMAPX_H_SEEN
+#define PICMAPX_H_SEEN
+
+#include "picmapgen.h"
+
+typedef   unsigned long PIXColor ;
+
+
+class PIColorMapX : public PIColorMapGen {
+public:
+  PIColorMapX();  
+  PIColorMapX(int id, int nc, string const& nom);  
+  virtual ~PIColorMapX();
+
+  inline PIXColor  Color(int index) 
+    { return ((index < mNCol) ? mColors[index] : 0); } ;
+
+  virtual PIColor GetColor(int n);
+  virtual bool AllocColor(PIColor const& col, int index);
+  virtual void FreeColors();
+
+  virtual long TotNbColors();
+  virtual int  NbAllocColors();
+
+protected:
+  virtual void CopyFrom(PIColorMapGen*);
+  
+  PIXColor  * mColors;     // La table des couleurs ...
+  PIColor   * mColRGB;     // Composantes RGB  
+  bool * mNewCol;          // Nouvelle couleur dans table ou pas
+};
+
+typedef PIColorMapX PIColorMapNative;
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/picons.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/picons.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/picons.cc	(revision 464)
@@ -0,0 +1,886 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "pisysdep.h"
+#include PIMENU_H
+#include "picons.h"
+
+
+// #define DEBUG_PICONS 1
+
+//  Le menu qui va servir a changer de fontes, couleurs, ...
+// de bouton-3
+static PIMenu* opmc=NULL;
+static int nb_opmc = 0;
+
+static void ActivatePIConsOptionMenu(PIConsole* par)
+{
+  if (opmc)  delete opmc;
+  opmc = NULL;
+
+  opmc = new PIMenu(par, "OptCons", k_PopupMenu);
+  opmc->AppendItem("SmallFont", 3101);
+  opmc->AppendItem("NormalFont", 3102);
+  opmc->AppendItem("LargeFont", 3103);
+  opmc->AppendItem("25L x 132C", 3301);
+  opmc->AppendItem("20L x 80C", 3302);
+  opmc->AppendItem("10L x 80C", 3303);
+  opmc->AppendItem("5L x 60C", 3304);
+  opmc->AppendItem("Bkg White", 3201);
+  opmc->AppendItem("Bkg Black", 3202);
+  opmc->AppendItem("Black/Yellow", 3203);
+  
+  opmc->SetMsgParent((PIMsgHandler*)par);
+  opmc->Show(); 
+  
+}
+
+/*  --------------------------------------------------------------------------------- */
+/*  ---------  Classe PIConsole : I/O (Ecriture/lecture) texte standard  ------------ */
+/*  --------------------------------------------------------------------------------- */
+
+static int CmdStrLen = 256;
+static int PIVA_Select = 1 << 3;
+
+//  Gestion du scroll-bar
+static int Scb_Width = 14;
+
+/* --Methode-- */
+PIConsole::PIConsole(PIContainer* par, const char* nom, PIMessage msg,
+                     int nl, int nc, int sx, int sy, int px, int py, bool scb) :
+PIBaseWdg(par, nom, ((scb)?sx-Scb_Width:sx), sy, px, py) 
+{
+mNL = (nl > 10) ? nl : 10;
+mNC = (nc > 30) ? nc : 30;
+mText = new char[mNL*mNC];
+mAtt = new unsigned char[mNL*mNC];
+mLPo = new int[mNL];
+mStrBuf = new char[mNC+1];
+mCmdStr = new char[CmdStrLen+1];
+mCCP = mCLC = 0;
+mDCOff = 0;
+mScb = NULL;
+
+SetMsg(msg);
+
+int i;
+for(i=0; i<mNL; i++) {
+  mLPo[i] = i*mNC;
+  ClearLine(i);
+  }
+
+mOffL = 0;
+mNCmdL = 0;
+mCmd = "";
+
+// Pile de rappel des commandes 
+mRStr = NULL;
+mNComm = NMxRecall = 0;
+mRCindx = mRindx = 0;
+mChangeFg = false;
+
+// Copier/coller
+mCPBuffer = NULL;
+mCPBufLen = 0;
+mCPbeginC =  mCPendC = -1;
+mCPbeginL = mCPendL = -1;
+
+SetPrompt("Cmd> ");
+ClrCmd();
+SelectFont();
+SelFgBgCol();
+mCurL = mNL-mWSzL-1; 
+mCurC = 0;
+
+
+// Pour ajouter un scroll-bar
+AssocScrollBar(par, nom, scb, sx, sy, px, py);
+
+
+ActivateKeyboard();  // Gestion de l'edition 
+ActivateButton(1);   //  Action selection / copier - coller 
+ActivateMove(1);     //      "    "     "  
+ActivateButton(2);   //      "    "     "  
+ActivateButton(3);   // Pour afficher le menu des options (Fontes/couleur)
+Manage();
+return;
+}
+
+/* --Methode-- */
+PIConsole::~PIConsole()
+{
+delete[] mText;
+delete[] mAtt;
+delete[] mLPo;
+delete[] mStrBuf;
+delete[] mCmdStr;
+if (mScb) delete mScb;
+if (opmc) { delete opmc;  opmc=NULL; }
+}
+
+/* --Methode-- */
+void PIConsole::AddChar(char c, unsigned char va, bool ref)
+{
+int l1, l2;
+if (mOffL != 0)  // Decalage d'affichage precedant -> Tout rafraichir 
+  { l1 = mNL-mWSzL-1; l2 = mNL-1;  SetDispOffset(-1); }
+else l1 = l2 = mCurL; 
+if (c == '\n') {
+  mCurC = 0;
+  mCurL++;   
+  }
+else {
+  mText[mLPo[mCurL]+mCurC] = c;
+  mAtt[mLPo[mCurL]+mCurC] = va;
+  if (++mCurC == mNC) {mCurC = 0;  mCurL++; }
+  }
+
+if (mCurL >= (mNL-mNCmdL) ) { // Il faut scroller 
+  ScrollUp();  
+  mCurL = mNL-mNCmdL-1;
+  l1 = mNL-mWSzL-1; 
+  }
+if (l2 < mCurL) l2 = mCurL;
+if (ref) DisplayLines(mWGrC, l1, l2);
+return;
+}
+
+
+/* --Methode-- */
+void PIConsole::AddStr(const char* strg, unsigned char va, bool ref)
+{
+int l1, l2;
+if (mOffL != 0)  // Decalage d'affichage precedant -> Tout rafraichir 
+  { l1 = mNL-mWSzL-1; l2 = mNL-1;  SetDispOffset(-1); }
+else l1 = l2 = mCurL; 
+
+char c;
+while ( (c = *strg) != '\0') {
+  if ( c != '\n' ) {
+    mText[mLPo[mCurL]+mCurC] = c;
+    mAtt[mLPo[mCurL]+mCurC] = va;
+    if (++mCurC == mNC) {mCurC = 0;  mCurL++; }
+    }
+  else { mCurL++; mCurC = 0; } 
+  if (mCurL >= (mNL-mNCmdL) ) { // Il faut scroller 
+    ScrollUp();  
+    mCurL = mNL-mNCmdL-1;
+    l1 = mNL-mWSzL-1; 
+    }
+  strg++;
+  }
+
+if (l2 < mCurL) l2 = mCurL;
+if (ref) DisplayLines(mWGrC, l1, l2);
+return;
+}
+
+/* --Methode-- */
+void PIConsole::SelectFont(PIFontSize sz)
+{
+int asc, desc;
+mWGrC->SelFont(sz);
+mFTaille = sz;
+mFHaut = mWGrC->GetFont().GetFontHeight(asc, desc);
+mFLarg = (int)mWGrC->CalcStringWidth("ABCDEFGHIJ")/10;
+mWSzL = YSize()/mFHaut - 1;
+mWSzC = XSize()/mFLarg - 2;
+mOffL = 0;
+if (mScb) {
+  mScb->SetMinMax(0, NbLines()-1);
+  mScb->SetSlSize(WindNbLines());
+  mScb->SetValue(0);
+  }
+}
+
+
+/* --Methode-- */
+void PIConsole::AutoSize(int nl, int nc)
+{
+if ( (nl < 1) || (nc < 1) ) {
+  nl = mWSzL;   nc = mNC;
+  }
+if (nc > mNC) nc = mNC;
+int dsz[2];
+dsz[0] = (nc+2)*mFLarg - XSize();
+dsz[1] = (nl+1)*mFHaut - YSize();
+Send(Msg(), PIMsg_ResizeRequest, dsz);
+
+mWSzL = YSize()/mFHaut - 1;
+mWSzC = XSize()/mFLarg - 2;
+/*
+if (mScb) {
+  mScb->SetMinMax(0, NbLines()-1);
+  mScb->SetSlSize(WindNbLines());
+  mScb->SetValue(0);
+  }
+  */
+mOffL = 0;
+}
+
+/* --Methode-- */
+void PIConsole::PreferedSize(int& sx, int& sy)
+{
+sx = (mNC+2)*mFLarg;
+sy = (mWSzL+1)*mFHaut;
+return;
+}
+
+/* --Methode-- */
+void PIConsole::AcceptCmd(bool acc, int nmxrec)
+{
+int l1, l2;
+if (acc) {
+  if (mNCmdL)  return;  // Pas de changement d'etat
+  if (mCurL == (mNL-1) ) { l1 = mNL-mWSzL-1; ScrollUp(); mCurL = (mNL-2); }
+  else l1 = mNL-1;
+  mNCmdL = 1;
+  ClrCmd();
+  UpdCmdLine();
+  l2 = mNL-1;
+  if (nmxrec > 0) {
+    NMxRecall = (nmxrec > 5) ? nmxrec : 5;
+    if (mRStr)  delete[] mRStr;
+    mRStr = new string[NMxRecall];
+    mNComm = mRCindx = mRindx = 0;
+    mRStr[0] = "";
+    }
+  }
+else {
+  if (mNCmdL == 0)  return;  // Pas de changement d'etat
+  mNCmdL = 0;
+  ClearLine(mNL-1);
+  ClrCmd();
+  l1 = l2 = mNL-1;
+  delete[] mRStr;
+  mRCindx = mRindx = 0;
+  }
+DisplayLines(mWGrC, l1, l2);
+return;
+}
+
+/* --Methode-- */
+void PIConsole::SetPrompt(const char* prompt)
+{
+strncpy(mPrompt, prompt, 31);  
+mPrompt[31] = '\0';
+return;
+}
+
+/* --Methode-- */
+void PIConsole::SetDispOffset(int ldeb)
+{
+if (ldeb < 0)    { 
+  if (mScb) mScb->SetValue(0); 
+  mOffL = 0;
+  }
+else mOffL = (ldeb < mNL-mWSzL-1) ? ldeb : mNL-mWSzL-1;
+}
+
+
+/* --Methode-- */
+void PIConsole::Resize()
+{
+mWSzL = YSize()/mFHaut - 1;
+mWSzC = XSize()/mFLarg - 2;
+if (mScb) {
+  mScb->SetMinMax(0, NbLines()-1);
+  mScb->SetSlSize(WindNbLines());
+  mScb->SetValue(0);
+  }
+mOffL = 0;
+}
+
+/* --Methode-- */
+void PIConsole::Draw(PIGraphicGen* g, int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/)
+{
+EraseWindow();
+DisplayLines(g, 0, mNL);
+}
+
+
+/* --Methode-- */
+void PIConsole::Keyboard(int key, PIKeyModifier kmod)
+{
+
+if (kmod == PIKM_Alt) {
+  if (key == 'O' || key == 'o') {   // Menu des options 
+    ActivatePIConsOptionMenu(this);
+    return;
+    }
+  else if (key == 'A' || key == 'a') {  // Pour tout selectionner
+    mCPbeginC = 0; mCPendC = XSize(); 
+    mCPbeginL = 0;  mCPendL = YSize(); 
+    SaveSelection();
+    return;
+    }
+  }
+
+if (mNCmdL < 1)  return;
+
+int k;
+bool fgfk = false;
+
+if (kmod == PIKM_Cntl) {
+  switch (key) {
+    case 1 :  // <Cntl> A
+      mCCP = 0;
+      break;
+    case 5 :  // <Cntl> E
+      mCCP = mCLC;
+      break;
+    case 11 :  // <Cntl> K
+      mCLC = mCCP;
+      break;
+    }
+  }
+
+else if (kmod == PIKM_Alt) {
+  if (key == 'V' || key == 'v') RequestSelection();  // Pour coller (copier/coller)
+  }
+
+else if (kmod == PIKM_Blank) {
+  switch (key) {
+    case PIK_Return :    
+    case PIK_Enter :
+      mCmdStr[mCLC] = '\0';
+//      printf("Keyb()-Debug- <CR/Enter> CmdStr= %s (L=%d)\n", mCmdStr, strlen(mCmdStr) );
+// Gestion de rappel des commandes 
+      if (mCLC > 0) {
+        mRStr[mRCindx] = mCmdStr;
+        mRCindx++;  mNComm++;
+        if (mRCindx >= NMxRecall)  mRCindx = 0;
+        mRindx = mRCindx;
+        }
+      mChangeFg = false;
+      mCmd = mCmdStr;
+      ClrCmd();
+      Send( Msg(), PIMsg_OK, NULL);
+      break;
+
+    case PIK_BackSpace :
+    case 127 :    // Touche del
+    case 8 :      // Touche backspace
+      if (mCCP > 0)  { 
+        for(k=mCCP-1; k<mCLC-1; k++)  mCmdStr[k] = mCmdStr[k+1];
+        mCmdStr[mCLC-1] = ' ';   mCCP--;  mCLC--;
+        mChangeFg = true;
+        }
+      //      printf("Keyb()-Debug- Backspace CCP,CLC= %d %d CmdStr= %s (L=%d) \n", mCCP, mCLC, 
+      //      mCmdStr, strlen(mCmdStr));
+      break;
+      
+    case PIK_Up :
+    case PIK_Down :
+//      printf("Keyb()-Debug- CursorUp/Down(%d)  Index= %d %d  \n", key, mRindx, mRCindx);
+      if (mNComm > 0) {
+        if (mChangeFg) { 
+          mCmdStr[mCLC] = '\0';
+          mRStr[mRCindx] = mCmdStr;
+          mChangeFg = false;
+	  }
+        int nmxrec = ((mNComm+1) < NMxRecall) ? mNComm+1 : NMxRecall;
+        if (key == PIK_Up)  {
+          mRindx--; 
+          if (mRindx < 0)  mRindx = 0;
+          }
+        else { 
+          mRindx++;
+          if (mRindx >= nmxrec) mRindx= nmxrec-1;
+          }
+        mCLC = mCCP = mRStr[mRindx].length();
+        for(k=0; k< mCLC; k++)  mCmdStr[k] =  mRStr[mRindx][k];
+        mCmdStr[mCLC] = '\0';      
+        }      
+      break;
+
+    case PIK_Left :
+      if (mCCP > 0)  mCCP--;
+      //      printf("Keyb()-Debug- Left CCP,CLC= %d %d  \n", mCCP, mCLC);
+      break;
+    case PIK_Right :
+      if (mCCP < mCLC)  mCCP++;
+      //      printf("Keyb()-Debug- Right CCP,CLC= %d %d  \n", mCCP, mCLC);
+      break;
+    default :
+      fgfk = true;
+      break;
+    }
+  }
+if ( ( fgfk && (kmod == PIKM_Blank) ) || (kmod == PIKM_Shift)  ) CmdAddChar(key);
+UpdCmdLine();
+// DisplayLines(mNL-1, mNL-1);
+return;
+}
+
+
+/* --Methode-- */
+void PIConsole::But1Press(int x, int y)
+{
+Send(Msg(), PIMsg_Active);
+AssignKeyboard();
+mWGrC->SelGOMode(PI_GOXOR);
+mWGrC->SelForeground(PI_Grey);
+mCPbeginC = x;  mCPbeginL = y;
+mCPendC = mCPendL = -1;
+} 
+
+/* --Methode-- */
+void PIConsole::Ptr1Move(int x, int y)
+{
+if (mCPendC >= 0) mWGrC->DrawBox(mCPbeginC, mCPbeginL, mCPendC-mCPbeginC, mCPendL-mCPbeginL);
+mCPendC = x;  mCPendL = y;
+mWGrC->DrawBox(mCPbeginC, mCPbeginL, mCPendC-mCPbeginC, mCPendL-mCPbeginL);
+}
+ 
+/* --Methode-- */
+void PIConsole::But1Release(int x, int y)
+{
+if ( (mCPendC >= 0) && (mCPbeginC >= 0) ) { 
+  mWGrC->DrawBox(mCPbeginC, mCPbeginL, mCPendC-mCPbeginC, mCPendL-mCPbeginL);
+  mCPendC = x;  mCPendL = y;
+  }
+else { 
+  mCPbeginC =  mCPendC = -1;
+  mCPbeginL = mCPendL = -1;
+  }
+mWGrC->SelGOMode(PI_GOCopy);
+mWGrC->SelForeground(mFgC);
+SaveSelection();
+} 
+
+/* --Methode-- */
+void PIConsole::But2Press(int x, int y)
+{
+RequestSelection();  // Pour recuperer la selection = coller (copier/coller)
+} 
+
+/* --Methode-- */
+void PIConsole::But3Press(int x, int y)
+{
+ActivatePIConsOptionMenu(this);
+}
+
+/* --Methode-- */
+void PIConsole::PasteSelection(unsigned int typ, void *pdata, unsigned int l)
+{
+if (typ != PICP_string) return;
+int i;
+char *pc = (char *)pdata;
+for(i=0; i<l; i++) CmdAddChar(pc[i]);
+UpdCmdLine();
+}
+
+/* --Methode-- */
+void PIConsole::SelectionLost()
+{
+// printf("Debug PIConsole::SelectionLost() %lx (L=%d)\n",(long)mCPBuffer, mCPBufLen);
+if (!mCPBuffer) return;
+delete[] mCPBuffer;  
+mCPBuffer = NULL;
+mCPBufLen = 0;
+mCPbeginC =  mCPendC = -1;
+mCPbeginL = mCPendL = -1;
+int i,j;
+int l1,l2;
+l1 = mNL+1; l2 = -1;
+for(i=0; i<mNL; i++)   // On enleve le bit select a tous les caracteres 
+  for(j=0; j<mNC; j++) 
+    if ( mAtt[mLPo[i]+j] & PIVA_Select) {
+      if (l1 > i)  l1 = i;
+      if (l2 < i)  l2 = i;
+      mAtt[mLPo[i]+j] &= ~PIVA_Select ;
+    }
+
+if (IsVisible() && l2 > -1)  DisplayLines(mWGrC, l1, l2);
+return;
+}
+
+/* --Methode-- */
+void PIConsole::SelectionTransferEnd()
+{
+// printf("Debug PIConsole::SelectionTransferEnd() -Rien- %lx (L=%d)\n",(long)mCPBuffer, mCPBufLen);
+}
+
+
+/* --Methode-- */
+void * PIConsole::ProvideSelection(unsigned int& typ, unsigned int& len)
+{
+typ = PICP_string;
+len = mCPBufLen;
+return(mCPBuffer);
+}
+
+/* ----------------------------------------------------------------------------- */
+/*    ---------------------- Methodes protected -------------------------        */
+/* ----------------------------------------------------------------------------- */
+
+
+/* --Methode-- 
+void PIConsole::DebugPrint(int lp)
+{
+printf("PIConsole::DebugPrint() - NL,NC= %d %d - WSzL,C= %d %d Cur= %d %d\n", mNL, mNC, 
+        mWSzL, mWSzC, mCurL, mCurC);
+printf(" OffL, NCmdL= %d %d - mCCP, mCLC= %d %d - LPo= %d %d \n", 
+        mOffL, mNCmdL, mCCP, mCLC, mLPo[mNL-2], mLPo[mNL-1]);
+
+if (lp == 0)  return;
+int i,j;
+for(j=0; j<mNL; j++) {
+  printf("Line[%d] (%d) = ", j, mLPo[j]);
+  for(i=0; i<mNC; i++)  putchar(mText[mLPo[j]+i]);
+  putchar('\n');
+  }
+return;
+}
+*/
+
+
+/* --Methode-- */
+void PIConsole::AssocScrollBar(PIContainer* par, const char* nom, bool scb, int sx, int sy, int px, int py)
+{
+if (!scb) {
+  mScb = NULL;
+  msgScb = 0;
+  SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_fixed);
+  return;   
+}
+
+sx -= Scb_Width;
+// SetSize(sx, sy);
+SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_fixed);
+char name[128];
+strcpy(name,"ScrollBar_");
+strncat(name, nom, 127);
+msgScb = Msg()+55;
+mScb = new PIScrollBar (par, name, msgScb, kSDirDownUp, Scb_Width, sy, px+sx, py);
+mScb->SetBinding(PIBK_free, PIBK_fixed, PIBK_fixed, PIBK_fixed);
+  
+mScb->SetMsgParent(this);
+mScb->SetMinMax(0, NbLines()-1);
+mScb->SetSlSize(WindNbLines());
+mScb->SetValue(0);
+}
+
+/* --Methode-- */
+void PIConsole::ScrollUp()
+{
+int i,l,kpo;
+l = mNL-1-mNCmdL;
+kpo = mLPo[0];
+for(i=0; i<mNL-mNCmdL-1; i++)   mLPo[i] = mLPo[i+1];
+mLPo[l] = kpo;
+ClearLine(l);
+return;
+}
+
+/* --Methode-- */
+void PIConsole::ClearLine(int l)
+{
+if ((l<0) || (l >= mNL)) return;
+int j;
+for(j=0; j<mNC; j++) {
+  mText[mLPo[l]+j] = ' ';
+  mAtt[mLPo[l]+j] = PIVA_Def;
+  }
+return;
+}
+
+/* --Methode-- */
+void PIConsole::DisplayLines(PIGraphicGen* g, int l1, int l2)
+{
+int j,l,k,l0;
+int x,y;
+
+// DBG printf("PIConsole::DisplayLines(%d %d ) -> %d - %lx \n ", l1, l2, 
+//            (int)IsVisible(), (long)XtWindow(XtWdg()));
+
+if (! IsVisible() )   return;
+
+int lva = -1;
+int ccol, cfnt;
+
+PIFontAtt vafat[8] = {PI_RomanFont, PI_BoldFont, PI_ItalicFont,
+                      PI_RomanFont, PI_RomanFont, PI_BoldFont, 
+                      PI_ItalicFont, PI_RomanFont};
+PIColors fgc, bgc, dbgc;
+PIColors col[6] = {PI_Black, PI_Red, PI_Blue, PI_Green, PI_Yellow, PI_Magenta};
+
+g->SelForeground(mFgC);
+g->SelBackground(mBgC);
+fgc =  col[0] = g->GetForeground();
+dbgc = bgc =  g->GetBackground();
+
+int dx = mFLarg;
+int dy = mFHaut/2;
+int dxo2 = dx/2;
+if (dxo2 > 3)  dxo2 = 3;
+int dyo2 = dy/2;
+if (dyo2 > 3)  dyo2 = 3;
+
+g->DrawBox(dxo2, dyo2, (mNC+2)*mFLarg-2*dxo2, (mWSzL+1)*mFHaut-dyo2);
+
+l0 = mNL-mWSzL-mOffL;
+if (l0 < 0) l0 = 0;
+if (l1 < l0) l1 = l0;
+if (++l2 > mNL-mOffL) l2 =  mNL-mOffL;
+
+for(l=l1; l<l2; l++) {
+ y = (l-l0+1)*mFHaut+dy;
+ k = 0;   x = dx;
+ for(j=0; j<mNC; j++) {
+   if (mAtt[mLPo[l]+j] != lva) {
+     if (k > 0) {
+       mStrBuf[k] = '\0';     
+       g->DrawOpaqueString(x, y, mStrBuf);
+       //     printf("l,J,K=%d %d %d - X,Y= %d %d - %s \n", l,j,k,x,y,mStrBuf);
+       x += k*mFLarg;  k = 0;  
+       }
+     lva = mAtt[mLPo[l]+j];
+     cfnt = lva & 15;   //  Index de fonte
+     ccol = lva >> 4;   //  Index de couleur
+     fgc = col[ccol];
+     if (cfnt & PIVA_Select) 
+       { bgc = PI_Grey;   g->SelFont(mFTaille, vafat[cfnt-PIVA_Select]); }
+     else { bgc = dbgc; g->SelFont(mFTaille, vafat[cfnt]); }
+     
+     if (cfnt & PIVA_Reverse) { 
+       g->SelForeground(bgc);
+       g->SelBackground(fgc);
+       }
+     else  { 
+       g->SelForeground(fgc);
+       g->SelBackground(bgc);
+       }
+     }
+   mStrBuf[k] = mText[mLPo[l]+j];
+   k++;
+   }
+   if (k > 0) {
+     mStrBuf[k] = '\0';     
+     g->DrawOpaqueString(x, y, mStrBuf);
+     //     printf("l,J,K=%d %d %d - X,Y= %d %d - %s \n", l,j,k,x,y,mStrBuf);
+   }
+ }
+
+g->SelForeground(fgc);
+g->SelBackground(dbgc);
+return;
+}
+
+/* --Methode-- */
+void PIConsole::UpdCmdLine()
+{
+//  char strg[260];  debug
+int l1,l2;
+l1 = l2 = mNL-1;
+if (mOffL != 0)  // Decalage d'affichage precedant -> Tout rafraichir 
+  { l1 = mNL-mWSzL-1; l2 = mNL-1;  SetDispOffset(-1); }
+
+ClearLine(mNL-1);
+int j1,j2,j,jj2;
+j1 = strlen(mPrompt);
+for(j=0; j<j1; j++) {
+  mText[mLPo[mNL-1]+j] = mPrompt[j];
+  mAtt[mLPo[mNL-1]+j] = PIVA_Def;
+//  strg[j] = mPrompt[j];    debug
+  }  
+jj2 = mWSzC-j1;
+if (mDCOff>=mCCP) mDCOff = 0;
+int koff = ((mCCP-mDCOff) >= jj2) ? mCCP-(jj2/2) : mDCOff;
+mDCOff = koff;
+int kmx = mCLC-koff;
+j2 = j1+kmx;
+if (j2 > mWSzC)  j2 = mWSzC;
+int k = koff;
+for(j=j1; j<j2; j++) {
+  mText[mLPo[mNL-1]+j] = mCmdStr[k];
+  mAtt[mLPo[mNL-1]+j] = PIVA_Bold;
+//  strg[j] = mCmdStr[k];   debug 
+  k++;
+  }  
+
+// strg[j] = '\0';   Debug
+// printf("UpdCmdLine() %d %d - %s (%d) \n [%d %d %d] %d\n", koff,kmx,strg,j1+mCCP-koff, mWSzC, j1, jj2, mCCP-(jj2/2));
+mAtt[mLPo[mNL-1]+j1+mCCP-koff] = PIVA_Reverse;    // Pour le curseur
+DisplayLines(mWGrC, l1, l2);
+}
+
+/* --Methode-- */
+void PIConsole::ClrCmd() 
+{ 
+mCCP = 0; mCLC = 0; mDCOff = 0;
+mCmdStr[0] = '\0'; 
+}  
+
+/* --Methode-- */
+void PIConsole::CmdAddChar(int key)
+{
+  int k, kmx;
+  if ( (mCCP < CmdStrLen) && isprint(key) ) {   // Ajout de caracteres
+    if (mCCP < mCLC)  { // Insertion au milieu de la chaine
+      kmx = (mCLC < CmdStrLen) ? mCLC : CmdStrLen-1;
+      //      printf(" ++DBG++ C=%d L=%d MX=%d KMX=%d\n", mCCP, mCLC, CmdStrLen,kmx);
+      for(k=kmx; k>mCCP; k--) mCmdStr[k] = mCmdStr[k-1];   mCLC = kmx+1;      
+      }
+    mCmdStr[mCCP] = key;  mCCP++; 
+    if (mCCP > mCLC)  mCLC = mCCP;
+    mChangeFg = true;
+    }
+}
+
+
+/* --Methode-- */
+void PIConsole::SelFgBgCol(PIColors fc, PIColors bc)
+{
+mFgC = fc; mBgC = bc;
+SetBackgroundColor(bc);
+}
+
+
+/* --Methode-- */
+void PIConsole::SaveSelection()
+{
+int i,j,k,l;
+int l1, l2, nl, nc;
+
+if (mCPbeginC > mCPendC) { j = mCPbeginC; mCPbeginC = mCPendC ; mCPendC = j; }
+if (mCPbeginL > mCPendL) { j = mCPbeginL; mCPbeginL = mCPendL ; mCPendL = j; }
+
+nc = (mCPendC-mCPbeginC)/mFLarg;
+nl = (mCPendL-mCPbeginL)/mFHaut;
+if (nl < 1) nl = 1;  // On selectionne au moins une ligne
+// printf("*DBG* NC=%d NL=%d \n",nc, nl); 
+l1 = mNL+1; l2 = -1;
+
+if (mCPBuffer) {
+  delete[] mCPBuffer;  
+  mCPBuffer = NULL;
+  mCPBufLen = 0;
+  for(i=0; i<mNL; i++)   // On enleve le bit select a tous les caracteres 
+    for(j=0; j<mNC; j++) 
+      if ( mAtt[mLPo[i]+j] & PIVA_Select) {
+        if (l1 > i)  l1 = i;
+        if (l2 < i)  l2 = i;
+        mAtt[mLPo[i]+j] &= ~PIVA_Select ;
+      }
+  }
+
+// printf("**DBG** Save: C= %d %d  L = %d %d \n", mCPbeginC, mCPendC, mCPbeginL, mCPendL);
+
+
+// On transforme la position sur la fenetre en position en caracteres ds les buffers
+
+mCPbeginC = mCPbeginC/mFLarg-1;
+mCPendC = (int) ( (float)mCPendC/(float)mFLarg-0.8 );
+mCPbeginL = (int) ( (float)mCPbeginL/(float)mFHaut-0.5 ) ;
+mCPendL = (int) ( (float)mCPendL/(float)mFHaut-0.5 ) ;
+if (mCPendL <= mCPbeginL) mCPendL = mCPbeginL+1;  // Au moins une ligne selectionnee
+// printf("..DBG.. C= %d %d  L = %d %d ", mCPbeginC, mCPendC, mCPbeginL, mCPendL);
+j = mNL-mWSzL-mOffL;
+mCPbeginL += j;  mCPendL += j;
+// printf(" -> %d %d \n", mCPbeginL, mCPendL);
+
+if (mCPbeginC < 0) mCPbeginC = 0;
+if (mCPendC > mNC) mCPendC = mNC;
+if (mCPbeginL < 0) mCPbeginL = 0;
+if (mCPendL > mNL) mCPendL = mNL;
+
+if ( (nc > 0) && (nl > 0) ) {
+if (!ClaimSelection()) { 
+  mCPbeginC = mCPendC = -1;
+  mCPbeginL = mCPendL = -1;
+  if (l2 > -1) DisplayLines(mWGrC, l1, l2);  
+  return;
+  }
+  l = (mCPendC-mCPbeginC+1) * (mCPendL-mCPbeginL);
+  if (l < 0) l = 0;
+  mCPBufLen = l;
+  mCPBuffer = new char[l+1];  
+  k = 0;  
+  for(j=mCPbeginL; j<mCPendL; j++) { 
+    for(i=mCPbeginC; i<mCPendC; i++)  { 
+      mAtt[mLPo[j]+i] |= PIVA_Select;
+      mCPBuffer[k] = mText[mLPo[j]+i]; k++; 
+      }
+    mCPBuffer[k] = '\n'; k++;
+    }
+  mCPBuffer[l] = '\0';
+  if (l1 > mCPbeginL) l1 = mCPbeginL;
+  if (l2 < (mCPendL-1))  l2 = mCPendL-1;
+  }
+else {  
+  l = 0;   
+  mCPbeginC =  mCPendC = mCPbeginL = mCPendL = -1; 
+  mCPBufLen = 0;
+  mCPBuffer = new char[10];  
+  mCPBuffer[0] = mCPBuffer[1] = '\0';
+  }
+
+//  printf("*DBG* Save_Display %d %d \n", l1, l2);
+
+if (l2 > -1) DisplayLines(mWGrC, l1, l2);
+}
+
+/* --Methode-- */
+void PIConsole::Process(PIMessage msg, PIMsgHandler* sender, void* data)
+{
+int off;
+// printf("PIConsole::Process() UserMsg()= %d ModMsg= %d \n", (int)UserMsg(msg), 
+//        (int)ModMsg(msg) );
+
+if (sender == opmc) { // Menu des options 
+  bool fgr = true;
+  switch (UserMsg(msg)) {
+    case 3101 :
+      SelectFont(PI_SmallSizeFont);
+      AutoSize();
+      break;
+    case 3102 :
+      SelectFont(PI_NormalSizeFont);
+      AutoSize();
+      break;
+    case 3103 :
+      SelectFont(PI_BigSizeFont);
+      AutoSize();
+      break;
+    case 3201 :
+      SelFgBgCol(PI_Black, PI_White);
+      break;
+    case 3202 :
+      SelFgBgCol(PI_White, PI_Black);
+      break;
+    case 3203 :
+      SelFgBgCol(PI_Yellow, PI_Black);
+      break;
+    case 3301 :
+      AutoSize(25, 132);
+      break;
+    case 3302 :
+      AutoSize(20, 80);
+      break;
+    case 3303 :
+      AutoSize(10, 80);
+      break;      
+    case 3304 :
+      AutoSize(5, 60);
+      break;      
+    default :
+      fgr = false;
+      break;
+    }
+  if (fgr) Refresh();
+  delete opmc;  opmc = NULL;
+  }
+// Le traitement du scroll-bar
+else if ((ModMsg(msg) == PIMsg_DataChanged) && (UserMsg(msg) == msgScb) ) {
+  off = * ((int *)data);
+//  printf(" PIConsole::Process() From ScrollBar : Off=%d \n ", off);
+  SetDispOffset(off);
+  Refresh();
+  }
+// Sinon, on retranmet le message
+else ReSend(msg, sender, data); 
+}
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/picons.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/picons.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/picons.h	(revision 464)
@@ -0,0 +1,116 @@
+// This may look like C code, but it is really -*- C++ -*-
+// composant graphique de type console (terminal) 
+//                    R. Ansari   12/97
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PICONSOLE_H
+#define PICONSOLE_H
+
+#include "pisysdep.h"
+
+#include PISTDWDG_H 
+#include PICONT_H
+#include PIBWDG_H
+
+enum PIVAType {    
+  PIVA_Def = 0,
+  PIVA_Bold = 1 << 0,
+  PIVA_Ital = 1 << 1,
+  PIVA_Reverse = 1 << 2,
+//  Le 4eme bit (<<3) est reserve pour l'usage interne (PIVA_Select)
+  PIVA_DefCol = 0,
+  PIVA_Red = 1 << 4,
+  PIVA_Blue = 2 << 4, 
+  PIVA_Green = 3 << 4, 
+  PIVA_Yellow = 4 << 4,
+  PIVA_Magenta = 5 << 4
+};
+
+class PIConsole : public PIBaseWdg {
+public:
+                     PIConsole(PIContainer* par, const char* nom, PIMessage msg, int nl, int nc, 
+                               int sx=300, int sy=200, int px=0, int py=0, bool scb=true);
+                     ~PIConsole();
+
+// Interface d utilisation : 
+          void       AddChar(char c, unsigned char va= PIVA_Def, bool ref=true);
+          void       AddStr(const char* strg, unsigned char va= PIVA_Def, bool ref=true);
+
+          void       SelectFont(PIFontSize sz=PI_NormalSizeFont);
+          void       AutoSize(int nl=-1, int nc=-1);
+          void       PreferedSize(int& sx, int& sy);
+          void       AcceptCmd(bool acc=true, int nrecmx=20);
+          void       SetPrompt(const char* prompt); 
+
+  inline  int        WindNbLines() { return mWSzL; }
+  inline  int        NbLines() { return mNL; }          
+  inline  string     GetCmdString() { return(mCmd); }
+
+// Gestion des evenements input/draw 
+  virtual void       Draw(PIGraphic* g, int x0, int y0, int dx, int dy);
+  virtual void       Resize();
+  virtual void       Keyboard(int key, PIKeyModifier kmod);
+  virtual void       But1Press(int x, int y);
+  virtual void       Ptr1Move(int x, int y);
+  virtual void       But1Release(int x, int y);
+  virtual void       But2Press(int x, int y);
+  virtual void       But3Press(int x, int y);
+
+// Gestion de copier/coller
+  virtual void       PasteSelection(unsigned int typ, void *pdata, unsigned int l);
+  virtual void*      ProvideSelection(unsigned int& typ, unsigned int& len);
+  virtual void       SelectionLost();
+  virtual void       SelectionTransferEnd();
+
+protected:
+          void       AssocScrollBar(PIContainer* par, const char* nom, bool scb, int sx, int sy, int px, int py);
+          void       ScrollUp();
+          void       SetDispOffset(int ldeb=-1);
+          void       ClearLine(int l);
+          void       DisplayLines(PIGraphicGen* g, int l1, int l2);
+          void       UpdCmdLine();
+          void       ClrCmd();
+          void       CmdAddChar(int key);
+          void       SelFgBgCol(PIColors fc=PI_Black, PIColors bc=PI_White);
+          void       SaveSelection();  // Pour copier la selection dans un buffer
+
+  virtual void       Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+
+
+  int mNL, mNC;         // Nb de lignes, colonnes total de la console
+  int mCurL, mCurC;     // Numero de ligne, colonne courante
+  int mWSzL, mWSzC;     // Taille de fenetre en lignes, colonnes
+  int mOffL;            // Offset d affichage (lignes) 
+  int mNCmdL, mLCOff;   // Nb de lignes reserve a l entree des commandes
+  int mDCOff;           // Offset (en caractere) pour l affichage de la ligne de commande
+  char* mText;          // Contenu de la console
+  unsigned char* mAtt;  // Attributs du contenu (bold, ...)
+  int* mLPo;            // Adresse des lignes ds les tableaux mText, mAtt
+  char* mStrBuf;        // Buffer 
+  int mFHaut, mFLarg;   // Hauteur, Largeur des caracteres 
+  PIFontSize mFTaille;  // Taille des caracteres 
+  PIColors mFgC, mBgC;  // Couleur Avant - arriere plan
+  char  mPrompt[32];    // Le prompt
+  char* mCmdStr;        // La commande 
+  int mCCP, mCLC;       // Position du curseur, longeur de la commande
+  string mCmd;          // Le string de la derniere commande validee
+
+// Pour le rappel des commandes
+  int NMxRecall, mNComm;    // Profondeur de la pile de rappels, nb de commandes
+  string * mRStr;           // Stockage des chaines 
+  int mRCindx, mRindx;      // Index pour le rappel
+  bool mChangeFg;           // Texte modifie
+  
+// Gestion du buffer de copie
+  char* mCPBuffer;
+  unsigned int mCPBufLen;
+  int mCPbeginC, mCPbeginL;
+  int mCPendC, mCPendL;
+  
+// S il y a un scroll-bar associe
+  PIScrollBar* mScb;
+  PIMessage msgScb;
+};
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/picontainergen.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/picontainergen.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/picontainergen.cc	(revision 464)
@@ -0,0 +1,290 @@
+//  Classe de base pour les conteneurs de PIWdg pour
+//  programmes graphiques interactives
+//
+//                  E.Aubourg , R. Ansari  96 - 98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include <stdio.h>
+
+#include "picontainergen.h"
+
+//++
+// Class	PIContainer
+// Lib		PI
+// include	picontainergen.h
+//
+//	Classe conteneur gérant un ensemble d'objets "PIWdg". Cette classe 
+//	organise la hiérarchie des objets "PIWdg" et donc aussi des "PIMsgHandler",
+//	contrôle la géométrie des objets "PIWdg" contenus, ainsi que leur 
+//	visibilité et activité. Le positionnement initial est controle par
+//	un objet *PILayoutMgr* qui peut eventuellement modifier la postion
+//	ou la taille de l'objet "PIWdg" ajouté. Les attributs d'attachement
+//	de l'objet ("PIWdg::SetBinding()") contrôle le repositionnement
+//	lors du changement de taille du "PIContainer".
+//	La classe "PIContainer" est une des 
+//	classes de PI qui ont une implementation dépendante du systeme utilisé
+//	(Mac, XWindow, ...). La classe "PIContainerGen" est la classe qui
+//	définit l'interface, et ne pas doit être instanciée directement
+//	(Méthodes virtuelles pures). Les objets instanciés sont de la 
+//	classes "PIContainer" et le fichier entête correspondant est "PICONT_H"
+//	défini dans "pisysdep.h"
+//--
+//++
+// Links	Parents
+// PIWdg
+//--
+//++
+// Links	Voir aussi
+// PILayoutMgr
+//--
+//++
+// Titre	Constructeur
+//--
+//++
+// PIContainer(PIContainerGen *par, const char *nom, int sx, int sy, int px, int py)
+//	Création d'un objet "PIContainer" dans le conteneur parent "par", de
+//	taille "sx,sy", se trouvant à la position "px,py" avec le nom "nom".
+//	Tous les widgets fils sont détruits (delete) par le destructeur
+//	(voir "SetAutoDelChilds()")
+// long kind()
+//	Renvoie le type de la classe de l'objet ("=PIContainerGen::ClassId") pour cette classe.
+//--
+//++
+// Titre	Méthodes
+//--
+//++
+// void SetLayoutMgr(PILayoutMgr* nlay)
+//	Permet de changer le gestionnaire de positions ("PILayoutMgr") du conteneur,
+//	et donc la stratégie de positionnement des objets "PIWdg" fils. 
+//	le LayoutMgr par défaut n'applique aucune contrainte sur la position
+//	ou la taille des objets ajoutés.
+//	Cette méthode ne peut être appelé que pour un conteneur vide (sans PIWdg fils).
+//	Il est conseillé de l'appeler juste après la création du "PIContainer"
+// PILayoutMgr* GetLayoutMgr()
+//	Retourne le gestionnaire de positions/tailles du conteneur.
+// void Show()
+//	Rend l'objet visible à l'écran. Tous les objets "PIWdg" contenus et qui sont dans 
+//	l'état actif sont visibles.
+// void Hide()
+//	Rend l'objet et tous les objets contenus invisibles.
+// void  PSPrint(PSFile *psf, int ofx=0, int ofy=0)
+//	Appelle la méthode "PSPrint()" pour tous les objets contenus.
+// void  SetAutoDelChilds(bool ad = true)
+//	Contrôle le comportement de l'objet conteneur vis à vis des objets
+//	contenus lors de la destruction. si "ad=true", les objets contenus 
+//	sont détruits lors de l'appel du destructeur de l'objet conteneur. 
+// int  NbChilds()
+//	Retourne le nombre de "PIWdg" contenus.
+// PIWdg* GetChild(int n)
+//	Retourne le "PIWdg" numéro "n" (0..NbChilds()-1) 
+//--
+//++
+// Titre 	Méthodes particulières
+//	Les méthodes ci-dessous ne doivent pas être appelées directement.
+//--
+//++
+// void ChildAdd(PIWdg* child)
+//	Méthode qui est appelée lors de l'attachement d'un nouvel objet (création)
+//	Appelle la méthode correspondante du "PILayoutMgr"
+// void ChildAdd(PIWdg* child)
+//	Méthode qui est appelée lors du détachement d'un objet (destruction)
+//	Appelle la méthode correspondante du "PILayoutMgr"	
+//--
+
+
+/* --Methode-- */
+PIContainerGen::PIContainerGen(PIContainerGen *par, const char *nom, 
+                               int sx, int sy, int px, int py)
+: PIWdg(par, nom, sx, sy, px, py)  
+{
+stvis = false;
+stfcr = false;
+layout = new PILayoutMgr;
+layout->SetContainer(this); 
+}
+
+
+/* --Methode-- */
+PIContainerGen::~PIContainerGen()
+{
+delete layout;
+}
+
+/* --Methode-- */
+void PIContainerGen::SetLayoutMgr(PILayoutMgr* nlay)
+{
+if (nlay == NULL) return;
+if (NbChilds() > 0) {
+  fprintf(stderr, "PIContainerGen::SetLayoutMgr()/ Error! Container has childs (N = %d) \n", NbChilds()); 
+  return;
+  }
+delete layout;
+layout = nlay;
+layout->SetContainer(this); 
+}
+
+/* --Methode-- */
+void PIContainerGen::PSPrint(PSFile *psf, int ofx, int ofy)
+{
+int i;
+if (!psf)  return;
+if (!Visible())  return;
+for(i=0; i<NbChilds(); i++)  GetChild(i)->PSPrint(psf, ofx+XPos(), ofy+YPos()); 
+return;
+}
+
+/* --Methode-- */
+void PIContainerGen::Show()
+{
+stvis = true;
+Manage();
+return;
+}
+
+/* --Methode-- */
+void PIContainerGen::Hide()
+{
+stvis = false;
+UnManage();
+return;
+}
+
+/* --Methode-- */
+bool PIContainerGen::Visible()
+{
+if (Parent())  return(stvis && Parent()->Visible());
+else return(stvis && IsVisible());
+}
+
+/* --Methode-- */
+void PIContainerGen::ChildAdd(PIWdg* child)
+{
+layout->ChildAdd(child);
+// Reza 13/10/98 : il faut que child->FinishCreate() 
+// soit appele pour les PIWdg ajoute quand le  container est deja affiche et son FinishCreate() appele
+if (stfcr)  child->FinishCreate(); 
+return;
+}
+
+/* --Methode-- */
+void PIContainerGen::ChildDel(PIWdg* child)
+{
+layout->ChildDel(child);
+}
+
+/* --Methode-- */
+int PIContainerGen::NbChilds()
+{
+return(layout->NbChilds());
+}
+
+/* --Methode-- */
+PIWdg* PIContainerGen::GetChild(int n)
+{
+return(layout->GetChild(n));
+}
+
+/* --Methode-- */
+void PIContainerGen::SetAutoDelChilds(bool ad)
+{
+layout->SetAutoDelChilds(ad) ;
+}
+
+
+/* --Methode-- */
+void PIContainerGen::FinishCreate()
+{
+if (stfcr)  return;
+PIWdg::FinishCreate();    
+int k;
+for(k=0; k<NbChilds(); k++)  GetChild(k)->FinishCreate();
+stfcr = true;
+}
+
+
+// ------------------------------------------------------------------
+//  Classe PILayoutMgr (Gestionnaire de positions/tailles PIWdg fils
+// ------------------------------------------------------------------
+//++
+// Class	PILayoutMgr
+// Lib		PI
+// include	picontainergen.h
+//
+//	Classe de gestionnaire de positions/tailles initiales des "PIWdg"
+//	fils pour les "PIContainer".
+//	La classe de base n'impose aucune contrainte sur les positions/tailles.
+//--
+//++
+// Links	Voir
+// PIContainer
+//--
+
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+// PILayoutMgr()
+//	Constructeur
+// void ChildAdd(PIWdg* child)
+//	Méthode appelé lors de l'ajout d'un nouveau "PIWdg" au conteneur.
+// void ChildDel(PIWdg* child)
+//	Méthode appelé lors de la suppression d'un "PIWdg"
+// int  NbChilds() 
+//	Nombre de "PIWdg" gérés.
+// PIWdg* GetChild(int n)
+//	Retourne l'objet "PIWdg" numéro "n"
+//--
+
+#define NCHALGRP 8
+
+/* --Methode-- */
+PILayoutMgr::PILayoutMgr()
+{
+mNCh = 0;
+mACSup = false;   // Pas de Suppression automatique des widgets fils au delete
+mPaSup = false;
+mChilds = new (PIWdg* [NCHALGRP]);
+mMxCh = NCHALGRP;
+mCont = NULL;
+}
+
+/* --Methode-- */
+PILayoutMgr::~PILayoutMgr()
+{
+mPaSup = true;   // Pour prevenir ChildDel()
+if (mACSup)
+  for(int i=0; i<mNCh; i++)  delete mChilds[i];
+delete[] mChilds;
+}
+
+/* --Methode-- */
+void PILayoutMgr::ChildAdd(PIWdg* child)
+{
+if (child == NULL)  return;
+if (mNCh == mMxCh)
+  {
+  PIWdg ** och = mChilds;
+  mChilds = new (PIWdg * [mMxCh+NCHALGRP]);
+  for(int i=0; i<mNCh; i++)  mChilds[i] = och[i];
+  delete[] och;
+  mMxCh += NCHALGRP;
+  }  
+mChilds[mNCh] = child;   mNCh++; 
+return;
+}
+
+/* --Methode-- */
+void PILayoutMgr::ChildDel(PIWdg* child)
+{
+if (mPaSup) return;  // Ne rien faire si delete initie par Container-parent : Le LayoutMgr lui-meme
+if ((child == NULL) || (mNCh < 1))  return;
+for(int i=0; i<mNCh; i++)  
+  if (mChilds[i] == child)
+    {
+    mNCh--;
+    mChilds[i] = mChilds[mNCh];
+    break;
+    }
+return;
+}
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/picontainergen.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/picontainergen.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/picontainergen.h	(revision 464)
@@ -0,0 +1,72 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive    PIContainerGen
+//                  E.Aubourg , R. Ansari  96 - 98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PICONTAINERBASE_SEEN
+#define PICONTAINERBASE_SEEN
+
+#include "pisysdep.h"
+
+#include PIWDG_H
+
+class PIContainerGen;
+//  Classe gestionnaire du positionnement/tailles des PIWdg d'un PIContainer
+class PILayoutMgr {
+public:
+  			PILayoutMgr();
+  virtual 		~PILayoutMgr();
+
+  inline  void		SetContainer(PIContainerGen* pic) { mCont = pic; }
+
+  virtual void		ChildAdd(PIWdg* child);
+  virtual void		ChildDel(PIWdg* child);
+
+  inline  int		NbChilds() { return(mNCh); }
+  inline  PIWdg*	GetChild(int n) 
+                        { if ( (n < 0) || (n >= mNCh))  return(NULL);
+                        else return (mChilds[n]); }
+  inline  void		SetAutoDelChilds(bool ad = true) { mACSup = ad; } 
+
+protected:
+  PIWdg                ** mChilds;
+  int                  mNCh, mMxCh;
+  bool                 mPaSup, mACSup;
+  PIContainerGen*      mCont;   // Le PIContainer auquel on est attache
+};
+
+// Classe conteneur pour le regroupement hierarchique (Fenetre/MsgHandler) des PIWdg
+class PIContainerGen : public PIWdg 
+{
+public:
+  enum {ClassId = 1500};
+
+               PIContainerGen(PIContainerGen *par, const char *nom, 
+                              int sx=10, int sy=10, int px=0, int py=0);
+  virtual      ~PIContainerGen();
+
+  virtual long         kind() {return ClassId; }
+
+  virtual void	       SetLayoutMgr(PILayoutMgr* nlay);
+  inline  PILayoutMgr* GetLayoutMgr() { return(layout); }
+
+  virtual void         PSPrint(PSFile *psf, int ofx=0, int ofy=0);
+
+  virtual void         Show();
+  virtual void         Hide();
+  virtual bool         Visible();
+
+  virtual void         ChildAdd(PIWdg* child);
+  virtual void         ChildDel(PIWdg* child);
+  virtual int          NbChilds();
+  virtual PIWdg*       GetChild(int n);
+          void         SetAutoDelChilds(bool ad = true);
+
+  virtual void	       FinishCreate(); // appelle FinishCreate() pour les descendants 
+
+protected:
+  bool                 stvis, stfcr;  // Statut visible ou pas, FinishCreate appele ou pas
+  PILayoutMgr*         layout;        // Gestionnaire de positionnement (/tailles) des PIWdg fils
+};
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/picontainermac.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/picontainermac.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/picontainermac.cc	(revision 464)
@@ -0,0 +1,13 @@
+#include "picontainermac.h"
+
+PIContainerMac::PIContainerMac(PIContainerGen *par, char *nom,
+                         int sx, int sy, int px, int py)
+: PIContainerGen(par, nom, sx, sy, px, py)
+{
+  // Par dfaut, un container est invisible.
+  UnManage();
+}
+
+PIContainerMac::~PIContainerMac()
+{}
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/picontainermac.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/picontainermac.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/picontainermac.h	(revision 464)
@@ -0,0 +1,20 @@
+#ifndef PICONTAINERMAC_SEEN
+#define PICONTAINERMAC_SEEN
+
+#include "picontainergen.h"
+#include "pisysdep.h"
+#include <LView.h>
+
+class PIContainerMac : public PIContainerGen {
+public:
+                         PIContainerMac(PIContainerGen *par, char *nom,
+                                   int sx=10, int sy=10, int px=0, int py=0);
+  virtual                ~PIContainerMac();
+  
+protected:
+
+};
+
+typedef PIContainerMac PIContainer;
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/picontainerx.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/picontainerx.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/picontainerx.cc	(revision 464)
@@ -0,0 +1,77 @@
+#include "picontainerx.h"
+
+#include <Xm/Form.h>
+
+/* *** ATTENTION *** La constante ci-dessous PIXMFORMFRACBASE
+   doit etre identique ds piwdgx.cc  picontainerx.cc et piwindowx.cc
+   ***************************************************************** */
+#define PIXMFORMFRACBASE 1000
+
+
+/* --Methode-- */
+PIContainerX::PIContainerX(PIContainerGen *par, const char *nom, 
+                           int sx, int sy, int px, int py) 
+: PIContainerGen(par, nom, sx, sy, px, py)
+{
+if ((sx > 0) && (sy > 0)) {
+  CreateXtWdg(nom, xmFormWidgetClass , NULL, sx, sy, px, py);
+  int fbase = PIXMFORMFRACBASE ;  // Valeur de XmNfractionBase des XmForm ds PIContainerX
+  Arg  wargs[2];
+  int n=0;
+  XtSetArg(wargs[n],XmNfractionBase, fbase);  n++;
+  XtSetValues(XtWdg(), wargs, n);
+  }
+//  CreateXtWdg(nom, xmBulletinBoardWidgetClass , NULL, sx, sy, px, py);
+mTopWdg = NULL;
+}
+
+// constructeur special a utiliser par PIApplicationX ...
+PIContainerX::PIContainerX(PIMsgHandler *par, PIWdgX *parwdg, const char *nom,  
+                           int sx, int sy, int px, int py) 
+: PIContainerGen(NULL, nom, sx, sy, px, py)
+{
+SetMsgParent(par);
+if ((sx > 0) && (sy > 0)) {
+  CreateXtWdg(nom, xmFormWidgetClass , parwdg->XtWdg(), sx, sy, px, py);
+  int fbase = PIXMFORMFRACBASE ;  // Valeur de XmNfractionBase des XmForm ds PIContainerX
+  Arg  wargs[2];
+  int n=0;
+  XtSetArg(wargs[n],XmNfractionBase, fbase);  n++;
+  XtSetValues(XtWdg(), wargs, n);
+  }
+mTopWdg = parwdg;
+}
+
+/* --Methode-- */
+PIContainerX::~PIContainerX()
+{}
+
+
+/* --Methode-- */
+void PIContainerX::Process(PIMessage msg, PIMsgHandler* sender, void* data)
+{
+// Traitement specifique pour le top-container de PIApplicationX
+if ((mTopWdg != NULL) && (ModMsg(msg) == PIMsg_ResizeRequest)) {
+  // On change la taille de la fenetre - data est un pointeur sur entier
+  // data[0] represente l'increment (positif ou negatif) en X, data[1] en Y
+  int* nsz = (int*) data;
+  mTopWdg->SetSize(mTopWdg->XSize()+nsz[0], mTopWdg->YSize()+nsz[1]);
+  return;
+  }  
+else ReSend(msg, sender, data);
+}
+
+/* --Methode-- 
+void PIContainerX::Show()
+{
+PIContainerGen::Show();
+Manage();
+}
+
+void PIContainerX::Hide()
+{
+PIContainerGen::Hide();
+UnManage();
+}
+
+*/
Index: /tags/V_LaSilla191199/SophyaPI/PI/picontainerx.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/picontainerx.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/picontainerx.h	(revision 464)
@@ -0,0 +1,29 @@
+#ifndef PICONTAINERX_SEEN
+#define PICONTAINERX_SEEN
+
+#include "pisysdep.h"
+#include "picontainergen.h"
+
+
+class PIContainerX : public PIContainerGen 
+{
+public:
+	              PIContainerX(PIContainerGen *par, const char *nom,
+                           int sx=10, int sy=10, int px=0, int py=0);
+
+// Ce constructeur est a utiliser par PIApplicationX ...
+              	      PIContainerX(PIMsgHandler *par, PIWdgX *parwdg, const char *nom,
+                           int sx=10, int sy=10, int px=0, int py=0);
+
+  virtual  	      ~PIContainerX();
+
+// Pour traiter les Resize-Request si TopContainer de PIApplicationX
+  virtual void        Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+
+protected :
+  PIWdgX* mTopWdg;
+};
+
+typedef PIContainerX PIContainer;
+
+#endif  /* PICONTAINERX_SEEN */
Index: /tags/V_LaSilla191199/SophyaPI/PI/pidrawer.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pidrawer.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pidrawer.cc	(revision 464)
@@ -0,0 +1,671 @@
+// Module PI : Peida Interactive     PIDrawer
+// Classe de traceurs pouvat être attachés à une PIBaseWdg
+//	      E. Aubourg , R.Ansari     96-98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "machdefs.h"
+#include <iostream.h>
+#include "pidrawer.h"
+
+#include <math.h>
+//  Pour la declaration de finite() isnan() ...
+#if defined(SunOS)
+#include <ieeefp.h>
+#endif
+
+//++
+// Class	PIDrawer
+// Lib		PI
+// include	pidrawer.h
+//
+//	Classe pour la création d'objets, capables de se dessiner
+//	dans une composante graphique ("PIBaseWdg").
+//--
+//++
+// Links	Voir
+// PIBaseWdg
+//--
+
+//++
+// Titre	Constructeurs et méthodes
+//--
+
+//++
+// PIDawer()
+//	Constructeur.
+//--
+
+PIDrawer::PIDrawer()
+{
+  mBWdg = NULL; 
+  mGrUC = NULL;
+  xW0 = yW0 = 0; xWd = yWd = 100; 
+  aXdir = false;  // Vrai si Axe X de Droite vers Gauche 
+  aYdir = false;  // Vrai si Axe Y de Haut vers Bas
+  SetLimits(-1, 1, -1, 1, kAxeDirLtoR, kAxeDirDownUp);
+  limitsFixed = 0;
+  SetAxesFlags();   // Pas de trace d'axes par defaut 
+  mDndfg = false;  // Pour controle de l'appel de Detach() si delete
+
+  mFCol = mBCol = PI_NotDefColor;
+  mLAtt = PI_NotDefLineAtt;
+  mFSz = PI_NotDefFontSize;
+  mFAtt = PI_NotDefFontAtt;
+  mMSz = -1;
+  mMrk = PI_NotDefMarker;
+  mCmapid = CMAP_OTHER;
+}
+
+PIDrawer::~PIDrawer()
+{
+  list<DrwBWId>::iterator it;
+  mDndfg = true;
+  for(it = mBWdgList.begin(); it != mBWdgList.end(); it++)
+         (*it).wdg->RemoveDrawer((*it).id);
+  if (mGrUC)  delete mGrUC;
+}
+
+//++
+// Titre	Les axes
+//--
+//++
+// void  SetLimits(double xmin, double xmax, double ymin, double ymax, -
+//                 int axrl=kAxeDirSame, int ayud=kAxeDirSame)
+//	Définit les limites du système de coordonnées.
+//|	kAxeDirSame , kAxeDirAuto
+//|	kAxeDirLtoR , kAxeDirRtoL  (Axe X)
+//|	kAxeDirDownUp , kAxeDirUpDown (Axe Y)	
+// void  GetAxesConfig(int& xa, int& ya) 
+//	Renvoie la configuration des axes.
+// double XMin()  XMax()
+//	Limites de l'axe X
+// double YMin()  YMax()
+//	Limites de l'axe Y
+// void  SetAxesFlags(unsigned int flags=kAxesNone)
+//	Attributs de tracé d'axes
+//|	kStdAxes , kBoxAxes , kTicks , kIntTicks , kExtTicks 
+//|	kMajTicks , kMinTicks , kLabels , kGridOn
+//|	kAxesDflt , kAxesNone
+// unsigned int GetAxesFlags()
+//	Renvoie les attributs de tracé d'axes  
+// void  DrawAxes(PIGraphicUC* g)
+//	Méthode de tracé des axes
+//--
+
+void
+PIDrawer::SetLimits(double xmin, double xmax, double ymin, double ymax,
+                    int axrl, int ayud)
+{
+  if (axrl == kAxeDirAuto) {
+    double ff;
+    if (xmax < xmin)  { axrl = kAxeDirRtoL;   ff=xmin;  xmin=xmax;  xmax=ff; }
+    else  axrl = kAxeDirLtoR;
+  }
+  if (ayud == kAxeDirAuto) {
+    double ff;
+    if (ymax < ymin)  { ayud = kAxeDirUpDown;   ff=ymin;  ymin=ymax;  ymax=ff; }
+    else  ayud = kAxeDirDownUp;
+  }
+  if (xmax <= xmin || ymax <= ymin) {  
+    cerr << "PIDrawer::SetLimits() Error - xmax <= xmin  || ymax <= ymin ! " << endl;
+    return; 
+    }
+#if defined(OSF1) || defined(SunOS) || (defined(Linux) && !defined(__KCC__) )
+  if (!finite(xmin) || !finite(xmax) || !finite(ymin) || !finite(ymax)) {
+    cerr << "PIDrawer::SetLimits() Error - Non finite value for x/ymin-max ! " << endl;
+    return; 
+    }
+#endif
+  if (axrl == kAxeDirLtoR)  aXdir = false;
+  else if (axrl == kAxeDirRtoL)  aXdir = true;
+  if (ayud == kAxeDirDownUp)  aYdir = false;
+  else if (ayud == kAxeDirUpDown)  aYdir = true;
+  xMin = xmin;
+  xMax = xmax;
+  yMin = ymin;
+  yMax = ymax;
+  aXFlg = axrl;  aYFlg = ayud;
+  limitsFixed = 1;
+}
+
+void
+PIDrawer::GetAxesConfig(int& xa, int& ya)
+{
+xa = (aXdir) ? kAxeDirRtoL : kAxeDirLtoR;
+ya = (aYdir) ? kAxeDirUpDown : kAxeDirDownUp;
+}
+
+//++
+//  void  Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
+//	Méthode qui est appelé lorsquer l'objet PIDrawer doit rafraichir la zone
+//	définie par "xmin-xmax" , "ymin-ymax" dans le système de coordonnées du
+//	PIDrawer.
+//  void  Refresh()
+//	Rafraîchit le dessin du PIDrawer sur tous les PIBaseWdg auxquel il est attaché.
+//  void  UpdateLimits()
+//	Cette méthode doit calculer les limites (X/Y Min-Max) préferées par l'objet
+//	et doit appeler "SetLimits()". L'implementation par défaut ne fait rien.
+//  void  AppendTextInfo(string& info, double xmin, double ymin, double xmax, double ymax)
+//	Méthode qui met à jour la chaîne "info", avec les informations (textuelles) de 
+//	la zone définie par "xmin-xmax" , "ymin-ymax".
+//--
+
+void
+PIDrawer::UpdateLimits()
+{
+// Ne fait rien !
+  return;
+}
+
+void
+PIDrawer::Refresh()
+{
+  list<DrwBWId>::iterator it;
+  for(it = mBWdgList.begin(); it != mBWdgList.end(); it++)
+         (*it).wdg->CallDrawer((*it).id);
+
+}
+
+//++
+// Titre	Les attributs graphiques
+//--
+//++
+// void  SetColAtt(PIColors fg=PI_NotDefColor, PIColors bg=PI_NotDefColor)
+//	Modifie la couleur d'avant-plan et de fond par défaut
+// void  SetLineAtt(PILineAtt lat=PI_NotDefLineAtt)
+//	Modifie l'attribut type de ligne
+// void  SetFontAtt(PIFontSize fsz=PI_NotDefFontSize, PIFontAtt fat=PI_NotDefFontAtt)
+//	L'attribut Type de fonte 
+// void  SetMarkerAtt(int sz=-1, PIMarker mrk=PI_NotDefMarker)
+//	L'attribut type et taille de marker
+// void  SetColMapId(CMapId cid=CMAP_OTHER)
+//	L'attribut choix de la table de couleurs
+// void  SelGraAtt(PIGraphicUC* g)
+//	Modifie les attributs graphiques de "g" à partir des attributs courant
+//	de l'objet "PIDrawer"
+// 
+// PIColors  GetFgColAtt()
+//	Renvoie l'attribut de couleur d'avant-plan
+// PIColors  GetBgColAtt()
+//	Renvoie l'attribut de couleur d'arrière-plan
+// PILineAtt  GetLineAtt()
+//	Renvoie l'attribut de ligne
+// PIFontSize GetFontSz()
+//	Renvoie l'attribut de taille de fonte
+// PIFontAtt  GetFontAtt()
+//	Renvoie l'attribut de type de fonte
+// int  GetMarkerSz()
+//	Renvoie l'attribut de taille de marker
+// PIMarker GetMarker()
+//	Renvoie l'attribut de type de marker
+// CMapId GetColMapId()
+//	Renvoie l'attribut de type de table de couleur
+//--
+
+void 
+PIDrawer::SetColAtt(PIColors fg, PIColors bg)
+{
+  mFCol = fg;
+  mBCol = bg;
+}
+
+void 
+PIDrawer::SetLineAtt(PILineAtt lat)
+{
+  mLAtt = lat;
+}
+
+void 
+PIDrawer::SetFontAtt(PIFontSize fsz, PIFontAtt fat)
+{
+  mFSz = fsz;
+  mFAtt = fat;
+}
+
+void 
+PIDrawer::SetMarkerAtt(int sz, PIMarker mrk)
+{
+  mMSz = sz;
+  mMrk = mrk;
+}
+
+void 
+PIDrawer::SetColMapId(CMapId cid)
+{
+  mCmapid = cid;
+}
+
+void 
+PIDrawer::SelGraAtt(PIGraphicUC* g)
+{
+  if (mFCol != PI_NotDefColor)    g->SelForeground(mFCol);
+  if (mBCol != PI_NotDefColor)    g->SelBackground(mBCol);
+  if (mLAtt != PI_NotDefLineAtt)  g->SelLine(mLAtt);
+  if ( (mFSz != PI_NotDefFontSize) || (mFAtt != PI_NotDefFontAtt) )
+                                  g->SelFont(mFSz, mFAtt);
+  if ( (mMrk != PI_NotDefMarker) || (mMSz >= 0) )
+                                  g->SelMarker(mMSz, mMrk);
+}
+
+
+void
+PIDrawer::Attach(PIBaseWdgGen* wdg, int id)
+{
+  if (!wdg) return;
+  DrwBWId bwi;
+  bwi.id = id;  bwi.wdg = wdg;
+  mBWdgList.push_back(bwi);
+  return;
+}
+
+void
+PIDrawer::Detach(PIBaseWdgGen* wdg, int id)
+{
+  if (mDndfg) return;
+  if (!wdg) return;
+  list<DrwBWId>::iterator it;
+  for(it = mBWdgList.begin(); it != mBWdgList.end(); it++)
+     if ( ((*it).id == id) && ((*it).wdg == wdg) ) { mBWdgList.erase(it);  break; }
+  return;
+}
+
+
+PIGraphicUC*
+PIDrawer::SetDrwWdg(PIBaseWdgGen* drw, int x0, int y0, int dx, int dy, PIGraphicGen* g)
+{
+  mBWdg = drw;
+  xW0 = x0;   yW0 = y0;
+  xWd = dx;   yWd = dy;
+  if (mGrUC)  delete mGrUC;
+  mGrUC = new PIGraphicUC(g, x0, y0, dx, dy);
+  mGrUC->SetUCS(xMin, xMax, yMin, yMax, aXFlg, aYFlg);
+  return(mGrUC);
+}
+
+/* --Methode-Static-- */
+void PIDrawer::BestTicks(double rmin,double rmax,int nticks,double& majt)
+{
+double d = rmax - rmin;
+double ld = log10(d);
+double fld = floor(fabs(ld));
+double del,del0;
+double fac[4] = {2.,5.,10.,20.};
+if(ld>=0.) { fld -= 1.; del0 = del = pow(10.,fld); }
+else { fld += 2.; del0 = del = pow(10., -fld); }
+int k=0;
+while( d/del > (double) nticks && k<4 ) { del = fac[k]*del0; k++; }
+majt = del;
+}
+
+void
+PIDrawer::CalcTicks()
+{
+  BestTicks(xMin,xMax,7,xMajTickStep);
+  xMinTickStep = xMajTickStep/5;
+  xFirstMajTick = int(xMin / xMajTickStep) * xMajTickStep;
+  if (xFirstMajTick < xMin) xFirstMajTick += xMajTickStep;
+  xFirstMinTick = int(xMin / xMinTickStep) * xMinTickStep;
+  if (xFirstMinTick < xMin) xFirstMinTick += xMinTickStep;
+
+  BestTicks(yMin,yMax,12,yMajTickStep);
+  yMinTickStep = yMajTickStep/5;
+  yFirstMajTick = int(yMin / yMajTickStep) * yMajTickStep;
+  if (yFirstMajTick < yMin) yFirstMajTick += yMajTickStep;
+  yFirstMinTick = int(yMin / yMinTickStep) * yMinTickStep;
+  if (yFirstMinTick < yMin) yFirstMinTick += yMinTickStep;
+
+  yMajTickLen = (xMax-xMin)/100;
+  yMinTickLen = (xMax-xMin)/250;
+  xMajTickLen = (yMax-yMin)/100;
+  xMinTickLen = (yMax-yMin)/250;
+}
+
+void
+PIDrawer::SetAxesFlags(unsigned int flags)
+{
+  axesFlags = flags;
+  if (axesFlags & (kIntTicks | kExtTicks | kMajTicks | kMinTicks))
+    axesFlags |= kTicks;
+  if ((axesFlags & (kTicks | kIntTicks | kExtTicks)) == kTicks)
+    axesFlags |= kIntTicks | kExtTicks;
+  if ((axesFlags & (kTicks | kMajTicks | kMinTicks)) == kTicks)
+    axesFlags |= kMajTicks;
+}
+
+
+void
+PIDrawer::DrawAxes(PIGraphicUC* g)
+{
+  g->NoClip();
+  if (mLAtt == PI_NotDefLineAtt)  g->SelLine(PI_ThinLine);
+  else g->SelLine(mLAtt);
+//  On calcule les ticks 
+  CalcTicks();
+
+  unsigned int flags = axesFlags;
+
+  if (flags & kStdAxes) {
+
+    // Les axes
+    
+    g->DrawLine(xMin, 0, xMax, 0);
+    g->DrawLine(0, yMin, 0, yMax);
+
+    // La grille en pointilles
+
+    if (flags & kGridOn) DrawGrid(g);
+  
+    // Les ticks majeurs
+  
+    if (flags & kMajTicks) {
+        DrawHTicks(g, 0, xMajTickLen, xMajTickLen, xFirstMajTick, xMajTickStep);
+        DrawVTicks(g, 0, yMajTickLen, yMajTickLen, yFirstMajTick, yMajTickStep);
+    }
+    
+    // Les ticks mineurs
+  
+    if (flags & kMinTicks) {
+        DrawHTicks(g, 0, xMinTickLen, xMinTickLen, xFirstMinTick, xMinTickStep);
+        DrawVTicks(g, 0, yMinTickLen, yMinTickLen, yFirstMinTick, yMinTickStep);
+    }
+    
+    // Les labels
+    
+    if (flags & kLabels) {
+      if (!aYdir)
+        DrawHLabels(g, -xMajTickLen*8, xFirstMajTick, xMajTickStep,0);
+      else 
+        DrawHLabels(g, xMajTickLen*8, xFirstMajTick, xMajTickStep,0);
+      if (!aXdir)
+        DrawVLabels(g, -yMajTickLen*2, yFirstMajTick, yMajTickStep,1);
+      else 
+        DrawVLabels(g, yMajTickLen*2, yFirstMajTick, yMajTickStep,1);
+    }
+    
+  }
+  
+  if (flags & kBoxAxes) {
+  
+    // La boite
+    
+    g->DrawLine(xMin, yMin, xMax, yMin);
+    g->DrawLine(xMax, yMin, xMax, yMax);
+    g->DrawLine(xMax, yMax, xMin, yMax);
+    g->DrawLine(xMin, yMax, xMin, yMin);
+
+    // Longueur des ticks
+    
+    double extXMajTickLen = flags&kExtTicks ? xMajTickLen : 0;
+    double intXMajTickLen = flags&kIntTicks ? xMajTickLen : 0;
+    double extXMinTickLen = flags&kExtTicks ? xMinTickLen : 0;
+    double intXMinTickLen = flags&kIntTicks ? xMinTickLen : 0;
+    double extYMajTickLen = flags&kExtTicks ? yMajTickLen : 0;
+    double intYMajTickLen = flags&kIntTicks ? yMajTickLen : 0;
+    double extYMinTickLen = flags&kExtTicks ? yMinTickLen : 0;
+    double intYMinTickLen = flags&kIntTicks ? yMinTickLen : 0;
+
+    // La grille en pointilles
+
+    if (flags & kGridOn) DrawGrid(g);
+
+    // Les ticks majeurs
+  
+    if (flags & kMajTicks) {
+        DrawHTicks(g, yMin, intXMajTickLen, extXMajTickLen, xFirstMajTick, xMajTickStep);
+        DrawHTicks(g, yMax, extXMajTickLen, intXMajTickLen, xFirstMajTick, xMajTickStep);
+        DrawVTicks(g, xMin, extYMajTickLen, intYMajTickLen, yFirstMajTick, yMajTickStep);
+        DrawVTicks(g, xMax, intYMajTickLen, extYMajTickLen, yFirstMajTick, yMajTickStep);
+    }
+    
+    // Les ticks mineurs
+  
+    if (flags & kMinTicks) {
+        DrawHTicks(g, yMin, intXMinTickLen, extXMinTickLen, xFirstMinTick, xMinTickStep);
+        DrawHTicks(g, yMax, extXMinTickLen, intXMinTickLen, xFirstMinTick, xMinTickStep);
+        DrawVTicks(g, xMin, extYMinTickLen, intYMinTickLen, yFirstMinTick, yMinTickStep);
+        DrawVTicks(g, xMax, intYMinTickLen, extYMinTickLen, yFirstMinTick, yMinTickStep);
+    }
+
+
+    // Les labels
+    
+    if (flags & kLabels) {
+      if (!aYdir) {
+        DrawHLabels(g, yMin-xMajTickLen*8, xFirstMajTick, xMajTickStep,0);
+        DrawHLabels(g, yMax+xMajTickLen*2, xFirstMajTick, xMajTickStep,0);
+      }
+      else {
+        DrawHLabels(g, yMin-xMajTickLen*2, xFirstMajTick, xMajTickStep,0);
+        DrawHLabels(g, yMax+xMajTickLen*8, xFirstMajTick, xMajTickStep,0);
+      }
+      if (!aXdir) {
+        DrawVLabels(g, xMin-yMajTickLen*2, yFirstMajTick, yMajTickStep,1);
+        DrawVLabels(g, xMax+yMajTickLen*2, yFirstMajTick, yMajTickStep,-1);
+      }
+      else {
+        DrawVLabels(g, xMin-yMajTickLen*2, yFirstMajTick, yMajTickStep,-1);
+        DrawVLabels(g, xMax+yMajTickLen*2, yFirstMajTick, yMajTickStep,1);
+      }
+    }
+  }
+  g->Clip();
+}
+
+  
+
+void
+PIDrawer::Draw(PIGraphicUC* g, double /*xmin*/, double /*ymin*/, double /*xmax*/, double /*ymax*/)
+{
+}
+
+void
+PIDrawer::AppendTextInfo(string& info, double /*xmin*/, double /*ymin*/, double /*xmax*/, double /*ymax*/)
+{
+}
+
+
+
+
+void
+PIDrawer::DrawHTicks(PIGraphicUC* g, double y, double tickUp, double tickDown, double xBeg, double xStep)
+{
+  for (double x=xBeg; x<=xMax; x += xStep)
+    g->DrawLine(x, y-tickDown, x, y+tickUp);
+}
+
+void
+PIDrawer::DrawVTicks(PIGraphicUC* g, double x, double tickLeft, double tickRight, double yBeg, double yStep)
+{
+  for (double y=yBeg; y<=yMax; y += yStep)
+    g->DrawLine(x-tickLeft, y, x+tickRight, y);
+}
+
+void
+PIDrawer::DrawHLabels(PIGraphicUC* g, double y, double xBeg, double xStep, int just)
+{
+  double xOffset = 0;
+  int kk;
+  g->SelFontSz(xMajTickLen*4.);
+  for (double x=xBeg; x<=xMax; x += xStep) {
+      // Attention aux erreurs d'arrondi quand x->0
+      //        car on code 5.1698e-26 au lieu de 0
+      double xx = (fabs(x/xStep)<1.e-5) ? 0.: x;
+      char label[20]; sprintf(label, "%-6g", xx);
+      for(kk=0; kk<20; kk++)
+        if (label[kk] == ' ')   { label[kk] = '\0' ; break; }
+      double largeur = g->CalcStringWidth(label);
+      if (just == 1)
+        xOffset = -largeur;
+      else if (just == 0)
+        xOffset = -largeur/2;
+      else
+        xOffset = 0;
+      if (aXdir)  xOffset = -xOffset;
+      g->DrawString(x+xOffset, y, label);
+  }
+}
+
+void
+PIDrawer::DrawVLabels(PIGraphicUC* g, double x, double yBeg, double yStep, int just)
+{
+  double xOffset = 0;
+  g->SelFontSz(xMajTickLen*4.);
+  for (double y=yBeg; y<=yMax; y += yStep) {
+      double yy = (fabs(y/yStep)<1.e-5) ? 0.: y;
+//    char label[20]; sprintf(label, "%-6g", yy);
+      char label[20]; sprintf(label, "%g", yy);
+      double largeur = g->CalcStringWidth(label);
+      if (just == 1)
+        xOffset = -largeur;
+      else if (just == 0)
+        xOffset = -largeur/2;
+      else
+        xOffset = 0;
+      if (aXdir)  xOffset = -xOffset;
+      g->DrawString(x+xOffset, y, label);
+  }
+}
+
+void
+PIDrawer::DrawGrid(PIGraphicUC* g)
+{
+  PILineAtt savlineatt = g->GetLineAtt();
+//  g->SelLine(PI_ThinDashedLine);
+  g->SelLine(PI_ThinDottedLine);
+
+  for (double x=xFirstMajTick; x<=xMax; x += xMajTickStep)
+    g->DrawLine(x, yMin, x, yMax);
+
+  for (double y=yFirstMajTick; y<=yMax; y += yMajTickStep)
+    g->DrawLine(xMin, y, xMax, y);
+
+  g->SelLine(savlineatt);
+}
+
+
+/*  --------------------------------------------------------------  */
+/*  ------------------- Classe PIElDrawer ------------------------  */
+/*  --------------------------------------------------------------  */
+
+/* --Methode-- */
+PIElDrawer::PIElDrawer()
+{
+mEn = 0;
+titleT = titleB = "";
+}
+
+/* --Methode-- */
+PIElDrawer::~PIElDrawer()
+{
+}
+
+/* --Methode-- */
+void PIElDrawer::SetTitles(const char* tt, const char* tb)
+{
+if (tt != NULL)  titleT = tt;
+if (tb != NULL)  titleB = tb;
+}
+
+/* --Methode-- */
+void PIElDrawer::SetTitles(string const & tt, string const & tb)
+{
+titleT = tt;  titleB = tb;
+}
+
+/* --Methode-- */
+void  PIElDrawer::Draw(PIGraphicUC* g, double /*xmin*/, double /*ymin*/, double /*xmax*/, double /*ymax*/)
+{
+DrawAxes(g);   // Trace des axes 
+
+SelGraAtt(g);   // DrawAxes change certains attributs graphiques
+if (mFSz == PI_NotDefFontSize) g->SelFont(PI_NormalSizeFont);
+// Trace des titres 
+if ( (titleT.length() > 0) || (titleB.length() > 0) ) {
+  aXdir = false;  // Vrai si Axe X de Droite vers Gauche 
+  aYdir = false;  // Vrai si Axe Y de Haut vers Bas
+  PIGrCoord gas, gds;
+  double fx, fy, fh;
+//  fh = g->GetFontHeightUC(gas, gds);
+  fh = 0.075*(YMax()-YMin());
+  if ( titleT.length() > 0) {
+      fx = g->CalcStringWidth(titleT.c_str());
+      if(aXdir) fx = XMax()-(XMax()-XMin()-fx)/2.;
+      else fx = XMin()+(XMax()-XMin()-fx)/2.;
+      if (aYdir) fy = YMin()-fh;
+      else fy = YMax()+fh;
+      g->DrawString(fx, fy, titleT.c_str());
+//      printf(" PIElDrawer::Draw()/DBG (%g , %g) %s  - %g \n", fx, fy, titleT.c_str(), fh);
+    }
+  if ( titleB.length() > 0) {
+      fx = g->CalcStringWidth(titleB.c_str());
+      if(aXdir) fx = XMax()-(XMax()-XMin()-fx)/2.;
+      else fx = XMin()+(XMax()-XMin()-fx)/2.;
+      if (aYdir) fy =  YMax()+fh*1.5;
+      else fy = YMin()-fh*1.5;
+      g->DrawString(fx, fy, titleB.c_str());
+//      printf(" PIElDrawer::Draw()/DBG (%g , %g) %s  - %g \n", fx, fy, titleT.c_str(), fh);
+    }
+  }
+DrwElList::iterator it;
+PIColors cc = g->GetForeground();
+for (it = mElist.begin(); it != mElist.end(); it++)
+  {
+  if ((*it).col != PI_NotDefColor)  g->SelForeground((*it).col);
+  switch ( (*it).etyp )
+    {
+    case PIDEL_Line :
+      g->DrawLine((*it).ex, (*it).ey, (*it).edx, (*it).edy ); 
+      break;
+    case PIDEL_Text :
+      g->DrawString((*it).ex, (*it).ey, (char*) ((*it).es.c_str()) ); 
+      break;
+    case PIDEL_Rect :
+      g->DrawBox((*it).ex, (*it).ey, (*it).edx, (*it).edy ); 
+      break;
+    case PIDEL_FRect :
+      g->DrawFBox((*it).ex, (*it).ey, (*it).edx, (*it).edy ); 
+      break;
+    case PIDEL_Circ :
+      g->DrawCircle((*it).ex, (*it).ey, (*it).edx ); 
+      break;
+    case PIDEL_FCirc :
+      g->DrawFCircle((*it).ex, (*it).ey, (*it).edx ); 
+      break;
+    default :
+      break;
+    }
+  g->SelForeground(cc);
+  }
+}
+
+
+/* --Methode-- */
+int PIElDrawer::ElAdd(int typ, PIGrCoord x, PIGrCoord  y, PIGrCoord dx, PIGrCoord dy, const char* s, PIColors c)
+{
+DrwEl dre;
+mEn++;
+dre.eid = mEn;  dre.etyp = typ;
+dre.ex = x;   dre.ey = y;
+dre.edx = dx;  dre.edy = dy;
+dre.col = c;
+if (s)  dre.es = s;
+mElist.push_back(dre);
+return(mEn);
+}
+
+/* --Methode-- */
+void  PIElDrawer::ElDel(int id)
+{
+DrwElList::iterator it;
+for (it = mElist.begin(); it != mElist.end(); it++)
+  if ( (*it).eid == id) { mElist.erase(it);   break; }
+return;
+}
+
+/* --Methode-- */
+void  PIElDrawer::ElDelAll()
+{
+mElist.erase(mElist.begin(), mElist.end());
+return;
+}
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pidrawer.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pidrawer.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pidrawer.h	(revision 464)
@@ -0,0 +1,199 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Objets traceur qui peuvent etre attaches a un PIBaseWidget
+//                             R. Ansari  97-98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+#ifndef PIDRAWER_H
+#define PIDRAWER_H
+
+#include "pibwdggen.h"
+#include "pigraphuc.h"
+
+
+enum {
+  kStdAxes     = 0x0001,
+  kBoxAxes     = 0x0002,
+  kTicks       = 0x0004,
+  kIntTicks    = 0x0010,
+  kExtTicks    = 0x0020,
+  kMajTicks    = 0x0040,
+  kMinTicks    = 0x0080,
+  kLabels      = 0x1000,
+  kGridOn      = 0x2000,
+  kAxesDflt    = kStdAxes | kTicks | kLabels,       // Axes trace par defaut
+  kAxesNone    = 0                                  // Pas de trace d axe  
+};
+
+
+class PIDrawer {
+public:
+                     PIDrawer();
+  virtual           ~PIDrawer();
+
+  virtual void       SetLimits(double xmin, double xmax, double ymin, double ymax,
+                               int axrl=kAxeDirSame, int ayud=kAxeDirSame);
+
+  virtual void       DrawAxes(PIGraphicUC* g);
+  virtual void       SetAxesFlags(unsigned int flags=kAxesNone);
+    
+  virtual void       Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax); 
+   
+  virtual void       AppendTextInfo(string& info, double xmin, double ymin, double xmax, double ymax);
+
+  virtual void       Refresh();      // Recalcule les limites et reaffiche
+  virtual void       UpdateLimits();   // Calcule et change les limites  
+
+  inline double      XMin() const {return xMin;}
+  inline double      XMax() const {return xMax;}
+  inline double      YMin() const {return yMin;}
+  inline double      YMax() const {return yMax;}
+
+  void                GetAxesConfig(int& xa, int& ya);
+  inline unsigned int GetAxesFlags() { return(axesFlags); }
+  
+  inline PIGraphicUC*    GetGraphicUC() { return(mGrUC); }
+
+  inline int          LimitsFixed() const {return limitsFixed;}
+  inline void         FreeLimits() {limitsFixed = 0;}
+
+// Changement des attributs graphiques
+  virtual void       SetColAtt(PIColors fg=PI_NotDefColor, 
+                               PIColors bg=PI_NotDefColor);
+  virtual void       SetLineAtt(PILineAtt lat=PI_NotDefLineAtt);
+  virtual void       SetFontAtt(PIFontSize fsz=PI_NotDefFontSize,
+                                PIFontAtt fat=PI_NotDefFontAtt);
+  virtual void       SetMarkerAtt(int sz=-1, PIMarker mrk=PI_NotDefMarker);
+  virtual void       SetColMapId(CMapId cid=CMAP_OTHER);
+
+  void               SelGraAtt(PIGraphicUC* g);
+
+// Acces aux attributs graphiques
+  inline PIColors    GetFgColAtt()  { return(mFCol); }
+  inline PIColors    GetBgColAtt()  { return(mBCol); }
+  inline PILineAtt   GetLineAtt()   { return(mLAtt); }
+  inline PIFontSize  GetFontSz()    { return(mFSz);  }
+  inline PIFontAtt   GetFontAtt()   { return(mFAtt); }
+  inline int         GetMarkerSz()  { return(mMSz);  }
+  inline PIMarker    GetMarker()    { return(mMrk);  } 
+  inline CMapId      GetColMapId()  { return(mCmapid); }
+
+
+//  --- Methode static ----
+//  Calcul des Distances optimales des subdivisions 
+  static void        BestTicks(double rmin,double rmax,int nticks,double& majt);
+
+//  Les objets/methodes suivants devraient etre protected     
+//  Pb avec acces depuis PIBaseWdgGen (Reza 11/07/97) 
+  virtual  PIGraphicUC*  SetDrwWdg(PIBaseWdgGen* drw, int x0, int y0, int dx, int dy, PIGraphicGen* g);
+
+//  Je declare en public a cause de cxx - Reza 11/07/97 
+  struct DrwBWId { int id; PIBaseWdgGen* wdg; };
+  
+protected:
+  friend class PIBaseWdgGen;
+  virtual void       Attach(PIBaseWdgGen*, int id);
+  virtual void       Detach(PIBaseWdgGen*, int id);
+
+  void CalcTicks();
+
+  void DrawHTicks(PIGraphicUC* g, double y, double tickUp, double tickDown, double xBeg, double xStep);
+  void DrawVTicks(PIGraphicUC* g, double x, double tickLeft, double tickRight, double yBeg, double yStep);
+  void DrawHLabels(PIGraphicUC* g, double y, double xBeg, double xStep, int just=0);
+  void DrawVLabels(PIGraphicUC* g, double x, double yBeg, double yStep, int just=0);
+  void DrawGrid(PIGraphicUC* g);
+
+  
+  double xMin, xMax, yMin, yMax;  // Valeurs en unites user
+  int xW0, yW0, xWd, yWd;        // Origine/largeur ds la fenetre de trace
+  bool   aXdir, aYdir;           // Sens des axes horiz, vertical 
+  int aXFlg, aYFlg;
+
+  double xFirstMajTick, xFirstMinTick;
+  double yFirstMajTick, yFirstMinTick;
+  double xMajTickStep, xMinTickStep;
+  double yMajTickStep, yMinTickStep;
+  double xMajTickLen,  xMinTickLen;
+  double yMajTickLen,  yMinTickLen;
+  
+  int limitsFixed;
+  unsigned int axesFlags;
+  
+  PIBaseWdgGen* mBWdg;
+  PIGraphicUC* mGrUC;
+
+  list<DrwBWId>  mBWdgList;
+  bool mDndfg;
+
+//  Gestion d attributs graphiques associes a chaque drawer
+  PIColors           mFCol, mBCol;
+  PILineAtt          mLAtt;
+  PIFontSize         mFSz;
+  PIFontAtt          mFAtt;
+  int                mMSz;
+  PIMarker           mMrk;  
+  CMapId             mCmapid;
+  
+};
+
+
+//  Classe avec gestion d une liste d elements a tracer 
+
+class PIElDrawer : public PIDrawer 
+{
+public:
+  enum { PIDEL_Line = 1, PIDEL_Text = 2,
+         PIDEL_Rect = 3, PIDEL_FRect = 4, 
+         PIDEL_Circ = 5, PIDEL_FCirc = 6 } ; 
+
+                     PIElDrawer();
+  virtual           ~PIElDrawer();
+
+  virtual void	     SetTitles(const char* tt=NULL, const char* tb=NULL);
+  virtual void       SetTitles(string const & tt, string const & tb);
+
+  virtual void       Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax); 
+
+  inline int         ElAddLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, 
+                               PIColors c=PI_NotDefColor)
+    { return( ElAdd(PIDEL_Line, x1, y1, x2, y2, NULL, c) ); }  
+  inline int         ElAddText(PIGrCoord x, PIGrCoord y, const char* s, PIColors c=PI_NotDefColor)
+    { return( ElAdd(PIDEL_Text, x, y, 0, 0, s, c) ); }  
+  inline int         ElAddRect(PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy, 
+                               PIColors c=PI_NotDefColor)
+    { return( ElAdd(PIDEL_Rect, x, y, dx, dy, NULL, c) ); }  
+  inline int         ElAddFRect(PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy,
+                               PIColors c=PI_NotDefColor)
+    { return( ElAdd(PIDEL_FRect, x, y, dx, dy, NULL, c) ); }  
+  inline int         ElAddCirc(PIGrCoord x, PIGrCoord y, PIGrCoord r, PIColors c=PI_NotDefColor)
+    { return( ElAdd(PIDEL_Circ, x, y, r, r, NULL, c) ); }  
+  inline int         ElAddFCirc(PIGrCoord x, PIGrCoord y, PIGrCoord r, PIColors c=PI_NotDefColor)
+    { return( ElAdd(PIDEL_FCirc, x, y, r, r, NULL, c) ); }  
+
+  void               ElDel(int id);
+  void               ElDelAll();
+
+protected:
+  int                ElAdd(int typ, PIGrCoord x, PIGrCoord y, PIGrCoord dx, PIGrCoord dy, 
+                           const char* s, PIColors c=PI_NotDefColor);
+#ifdef __DECCXX
+public:
+#endif
+  struct DrwEl{
+    int eid, etyp;
+    PIGrCoord ex,ey;
+    PIGrCoord edx,edy;
+    string es;
+    PIColors col;
+  };
+#ifdef __DECCXX
+protected:
+#endif
+  typedef list<DrwEl> DrwElList;
+
+  DrwElList mElist;
+  int mEn;
+
+  string titleT, titleB;       // Titre Haut - Bas
+
+};
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pidrawwin.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pidrawwin.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pidrawwin.cc	(revision 464)
@@ -0,0 +1,28 @@
+#include "pidrawwin.h"
+
+PIDrawWindow::PIDrawWindow(PIMsgHandler* par, const char *nom,
+                               PIWindowKind k, int sx, int sy, int px, int py)
+:PIWindow(par, nom, k, sx, sy, px, py)
+{
+   mDrawWdg = new PIScDrawWdg(this, nom, sx-20, sy-20, 10, 10);
+   mDrawWdg->SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_fixed);   
+}
+
+
+PIDrawWindow::~PIDrawWindow()
+{
+  delete mDrawWdg;
+}
+
+void
+PIDrawWindow::AddScDrawer(PIDrawer* d, bool ad)
+{
+  mDrawWdg->AddScDrawer(d, ad);
+}
+
+void
+PIDrawWindow::SetAxesFlags(int flags)
+{
+  mDrawWdg->SetAxesFlags(flags);
+}
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pidrawwin.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pidrawwin.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pidrawwin.h	(revision 464)
@@ -0,0 +1,26 @@
+#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, const char *nom, 
+                                PIWindowKind k=PIWK_normal, int sx=10, int sy=10, 
+                                int px=0, int py=0);
+                ~PIDrawWindow();
+                
+ virtual void    AddScDrawer(PIDrawer*, bool ad=false);                
+ virtual void    SetAxesFlags(int flags=-1);
+ inline PIScDrawWdg * DrawWdg() { return mDrawWdg; }
+private:
+  PIScDrawWdg*   mDrawWdg;
+};
+
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pidrwtools.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pidrwtools.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pidrwtools.cc	(revision 464)
@@ -0,0 +1,472 @@
+// 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"
+#include "pi3ddrw.h"
+
+
+PIDrwTools* PIDrwTools::cwdrwt = NULL;
+PIBaseWdgGen* PIDrwTools::mCurBW = NULL;
+
+/* --Methode-- */
+void PIDrwTools::ShowPIDrwTools() 
+{
+if (cwdrwt == NULL)  cwdrwt = new PIDrwTools(PIApplicationGetApp());
+cwdrwt->Show();
+}
+
+/* --Methode-- */
+void PIDrwTools::SetCurrentBaseWdg(PIBaseWdgGen* cbw)
+{
+if (mCurBW == cbw) return;
+mCurBW = cbw;
+if (cwdrwt)  { 
+  if (mCurBW != NULL)  { 
+    cwdrwt->mNDr = mCurBW->NbDrawers()-1;
+    if (cwdrwt->mNDr < 0)  cwdrwt->mNDr = 0;
+    }
+  else cwdrwt->mNDr = 0;
+  char buff[32];
+  sprintf(buff,"%d", cwdrwt->mNDr);
+  cwdrwt->mNlb->SetLabel(buff);  
+  }
+}
+/* --Methode-- */
+PIBaseWdgGen* PIDrwTools::GetCurrentBaseWdg()
+{
+return(mCurBW);
+}
+
+/* --Methode-- */
+PIDrwTools::PIDrwTools(PIApplication* par)
+: PIWindow((PIMsgHandler*)par, "PIDrawerTools", PIWK_normal, 240, 240, 150, 150)
+{
+int bsx, bsy, spx, spy;
+
+// On definit la taille a partir de la taille par defaut des composantes 
+// PIApplicationPrefCompSize(bsx, bsy);
+par->PrefCompSz(bsx, bsy);
+spx = bsx/10;
+spy = bsy/4;
+
+int wszx = 5*spx+3.5*bsx; 
+int wszy = (7+3*0.85)*(spy+bsy);
+SetSize(wszx, wszy);
+
+int cpx = spx*2;
+int cpy = spy*2;
+int csx = cpx;
+int csy = cpy;
+mLab[0] = new PILabel(this, "X Min Max", 1.25*bsx, bsy, cpx, cpy);
+cpy += spy+bsy; 
+mLab[1] = new PILabel(this, "Y Min Max", 1.25*bsx, bsy, cpx, cpy);
+mLab[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mLab[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+cpy = spy*2;
+cpx += spx+1.25*bsx; 
+mText[0] = new PIText(this, "x_min_max", 2.25*bsx, bsy, cpx, cpy);
+mText[0]->SetText("-1.0  1.0");
+cpy += spy+bsy; 
+mText[1] = new PIText(this, "y_min_max", 2.25*bsx, bsy, cpx, cpy);
+mText[1]->SetText("-1.0  1.0");
+mText[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mText[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+cpx = spx+0.25*bsx;
+cpy += spy+bsy; 
+mCkb[0] = new PICheckBox(this,"X-RtoL", 2000, bsx, bsy, cpx, cpy);
+cpx += spx+bsx; 
+mCkb[1] = new PICheckBox(this,"Y-UpDn", 2000, bsx, bsy, cpx, cpy);
+cpx += spx+bsx; 
+mCkb[2] = new PICheckBox(this,"Grid", 2000, bsx, bsy, cpx, cpy);
+mCkb[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mCkb[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mCkb[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+cpy += spy+bsy; 
+cpx = spx+0.25*bsx;;
+mBut[0] = new PIButton(this, "SetAxes", 2600, bsx*1.5, bsy, cpx, cpy);
+cpx += bsx*1.5+3*spx;
+mBut[1] = new PIButton(this, "AutoLimits", 2700, bsx*1.5, bsy, cpx, cpy);
+mBut[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mBut[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+int offy = cpy+bsy+spy*2;
+
+//  Option-Menu  Marker, Line, couleur, etc...
+cpx = 2*spx;
+cpy += 3*spy+bsy;
+
+int bsyo = bsy;  
+int spyo = spy; 
+bsy = 0.85*bsy;   spy = 0.85*spy;
+
+mOpt[0] = new PIOptMenu(this, "bwt-opt-0", bsx*1.75, bsy, cpx, cpy);
+mOpt[0]->AppendItem("Def.Col", 100);
+mOpt[0]->AppendItem("Black", 101);
+mOpt[0]->AppendItem("White", 102);
+mOpt[0]->AppendItem("Grey", 103);
+mOpt[0]->AppendItem("Red", 104);
+mOpt[0]->AppendItem("Blue", 105);
+mOpt[0]->AppendItem("Green", 106);
+mOpt[0]->AppendItem("Yellow", 107);
+mOpt[0]->AppendItem("Magenta", 108);
+mOpt[0]->AppendItem("Cyan", 109);
+mOpt[0]->AppendItem("Turquoise", 110);
+mOpt[0]->AppendItem("NavyBlue", 111);
+mOpt[0]->AppendItem("Orange", 112);
+mOpt[0]->AppendItem("SiennaRed", 113);
+mOpt[0]->AppendItem("Purple", 114);
+mOpt[0]->AppendItem("LimeGreen", 115);
+mOpt[0]->AppendItem("Gold", 116);
+mOpt[0]->SetValue(100);
+mOpt[0]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+
+cpx += spx+1.75*bsx; 
+mOpt[1] = new PIOptMenu(this, "bwt-opt-1", bsx*1.75, bsy, cpx, cpy);
+mOpt[1]->AppendItem("No.CMap", 200);
+mOpt[1]->AppendItem("Grey32", 201);
+mOpt[1]->AppendItem("GreyInv32", 202);
+mOpt[1]->AppendItem("ColRJ32", 203);
+mOpt[1]->AppendItem("ColBR32", 204);
+mOpt[1]->AppendItem("ColRV32", 205);
+mOpt[1]->AppendItem("Grey128", 206);
+mOpt[1]->AppendItem("GreyInv128", 207);
+mOpt[1]->AppendItem("ColRJ128", 208);
+mOpt[1]->AppendItem("ColBR128", 209);
+mOpt[1]->AppendItem("Col16", 210);
+mOpt[1]->SetValue(200);
+mOpt[1]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+
+
+cpx = 2*spx;
+cpy += spy+bsy;
+mOpt[2] = new PIOptMenu(this, "bwt-opt-2", bsx*1.75, bsy, cpx, cpy);
+mOpt[2]->AppendItem("Def.Mrk", 300);
+mOpt[2]->AppendItem("Mrk Dot(.)", 301);
+mOpt[2]->AppendItem("Mrk Plus(+)", 302);
+mOpt[2]->AppendItem("Mrk Cross(x)", 303);
+mOpt[2]->AppendItem("Mrk Circle", 304);
+mOpt[2]->AppendItem("Mrk FCircle", 305);
+mOpt[2]->AppendItem("Mrk Box", 306);
+mOpt[2]->AppendItem("Mrk FBox", 307);
+mOpt[2]->AppendItem("Mrk Triangle", 308);
+mOpt[2]->AppendItem("Mrk FTriangle", 309);
+mOpt[2]->AppendItem("Mrk Star", 310);
+mOpt[2]->AppendItem("Mrk FStar", 311);
+mOpt[2]->SetValue(300);
+mOpt[2]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+
+cpx += spx+1.75*bsx; 
+mOpt[3] = new PIOptMenu(this, "bwt-opt-3", bsx*1.75, bsy, cpx, cpy);
+mOpt[3]->AppendItem("Mrk 1 pt", 401);
+mOpt[3]->AppendItem("Mrk 3 pt", 403);
+mOpt[3]->AppendItem("Mrk 5 pt", 405);
+mOpt[3]->AppendItem("Mrk 7 pt", 407);
+mOpt[3]->AppendItem("Mrk 9 pt", 409);
+mOpt[3]->AppendItem("Mrk 11 pt", 411);
+mOpt[3]->AppendItem("Mrk 13 pt", 413);
+mOpt[3]->AppendItem("Mrk 15 pt", 415);
+mOpt[3]->SetValue(405);
+mOpt[3]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+
+cpx = 2*spx;
+cpy += spy+bsy;
+mOpt[4] = new PIOptMenu(this, "bwt-opt-4", bsx*1.75, bsy, cpx, cpy);
+mOpt[4]->AppendItem("Def.Font", 500);
+mOpt[4]->AppendItem("Normal-Font", 511);
+mOpt[4]->AppendItem("Bold", 512);
+mOpt[4]->AppendItem("Ital", 513);
+mOpt[4]->AppendItem("Small-Font", 521);
+mOpt[4]->AppendItem("Small-Bold", 522);
+mOpt[4]->AppendItem("Small-Ital", 523);
+mOpt[4]->AppendItem("Big-Font", 531);
+mOpt[4]->AppendItem("Big-Bold", 532);
+mOpt[4]->AppendItem("Big-Ital", 533);
+mOpt[4]->AppendItem("Huge-Font", 541);
+mOpt[4]->AppendItem("Huge-Bold", 542);
+mOpt[4]->AppendItem("Huge-Ital", 543);
+mOpt[4]->SetValue(500);
+mOpt[4]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+
+cpx += spx+1.75*bsx; 
+mOpt[5] = new PIOptMenu(this, "bwt-opt-5", bsx*1.75, bsy, cpx, cpy);
+mOpt[5]->AppendItem("Def.Line", 600);
+mOpt[5]->AppendItem("Thin-Line", 601);
+mOpt[5]->AppendItem("Normal-Line", 602);
+mOpt[5]->AppendItem("Thick-Line", 603);
+mOpt[5]->AppendItem("ThinDashed", 604);
+mOpt[5]->AppendItem("Dashed-Line", 605);
+mOpt[5]->AppendItem("ThickDashed", 606);
+mOpt[5]->AppendItem("ThinDotted", 607);
+mOpt[5]->AppendItem("Dotted-Line", 608);
+mOpt[5]->AppendItem("ThickDotted", 609);
+mOpt[5]->SetValue(600);
+mOpt[5]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+
+cpx = 2*spx;
+cpy += spy+bsyo;
+bsy = bsyo; spy = spyo;
+mButdr[0] = new PIButton(this, "-", 3501, bsy, bsy, cpx, cpy);
+cpx += bsy+0.25*spy;
+mNlb = new PILabel(this,"NumDr", bsy, bsy, cpx, cpy);
+mNlb->SetLabel("0");
+mNDr = 0;
+cpx += bsy+0.25*spy;
+mButdr[1] = new PIButton(this, "+", 3502, bsy, bsy, cpx, cpy);
+mButdr[0]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+mButdr[1]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+mNlb->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+
+cpx = wszx-1.7*bsx-3*spx;
+mButcf[0] = new PIButton(this, "GetAtt", 2800, 0.85*bsx, bsy, cpx, cpy);
+cpx += 0.85*bsx+spx;
+mButcf[1] = new PIButton(this, "SetAtt", 2900, 0.85*bsx, bsy, cpx, cpy);
+mButcf[0]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+mButcf[1]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+
+cpx = spx+0.25*bsx;;
+cpy += spy+bsy;
+mButcf[2] = new PIButton(this, "Refresh", 3000, bsx*1.5, bsy, cpx, cpy);
+mButcf[2]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+cpx += bsx*1.5+3*spx;
+mButcf[3] = new PIButton(this, "Dismiss", 3777, bsx*1.5, bsy, cpx, cpy);
+mButcf[2]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+mButcf[3]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+
+cwdrwt = this;
+
+}
+
+/* --Methode-- */
+PIDrwTools::~PIDrwTools()
+{
+if (cwdrwt == this)  cwdrwt = NULL;
+int i;
+for(i=0; i<2; i++)
+  {
+  delete mLab[i];
+  delete mBut[i];
+  delete mText[i];
+  delete mButcf[i];
+  }
+
+for(i=0; i<3; i++) { delete mCkb[i];   delete mButcf[i]; }
+delete mButcf[3];
+for(i=0; i<6; i++)  delete mOpt[i];
+delete mNlb;
+}
+
+//  Declaration des differents attributs graphiques 
+static PIColors cols[17] = { PI_NotDefColor, 
+                     PI_Black, PI_White, PI_Grey, 
+                     PI_Red, PI_Blue, PI_Green, 
+                     PI_Yellow, PI_Magenta, 
+                     PI_Cyan , PI_Turquoise, PI_NavyBlue, 
+                     PI_Orange, PI_SiennaRed, PI_Purple, 
+                     PI_LimeGreen, PI_Gold };
+
+static PIMarker mrk[12] = { PI_NotDefMarker, PI_DotMarker, 
+                            PI_PlusMarker, PI_CrossMarker,
+                            PI_CircleMarker, PI_FCircleMarker,
+                            PI_BoxMarker, PI_FBoxMarker,
+                            PI_TriangleMarker, PI_FTriangleMarker,
+                            PI_StarMarker, PI_FStarMarker };
+static PILineAtt line[10] = { PI_NotDefLineAtt, PI_ThinLine, PI_NormalLine, PI_ThickLine, 
+                              PI_ThinDashedLine, PI_DashedLine, PI_ThickDashedLine, 
+                              PI_ThinDottedLine, PI_DottedLine, PI_ThickDottedLine };
+
+static PIFontAtt fntatt[4] = { PI_NotDefFontAtt, PI_RomanFont, PI_BoldFont, PI_ItalicFont };
+static PIFontSize fntsz[5] = { PI_NotDefFontSize, PI_NormalSizeFont, PI_SmallSizeFont, 
+                               PI_BigSizeFont, PI_HugeSizeFont };
+static CMapId cmap[11] = {  CMAP_OTHER, CMAP_GREY32, CMAP_GREYINV32,
+                            CMAP_COLRJ32, CMAP_COLBR32, CMAP_COLRV32,  
+                            CMAP_GREY128, CMAP_GREYINV128, CMAP_COLRJ128, CMAP_COLBR128, CMAP_COL16 };
+
+/* --Methode-- */
+void PIDrwTools::Show()
+{
+PIWindow::Show();
+char buff[92]; 
+mNDr = 0;
+
+if (mCurBW != NULL)  { 
+  mNDr = mCurBW->NbDrawers()-1;
+  if (mNDr < 0)  mNDr = 0;
+  }
+
+UpdateAttFromDrawer();
+
+mCkb[0]->SetState(false);
+mCkb[1]->SetState(false);
+mCkb[2]->SetState(false);
+
+if ((mCurBW != NULL) && ( mCurBW->kind() == PIScDrawWdg::ClassId ) ) {
+  PIScDrawWdg* scd = ( PIScDrawWdg*)mCurBW;
+  sprintf(buff, "%g  %g", scd->XMin(), scd->XMax());
+  mText[0]->SetText(buff);
+  sprintf(buff, "%g  %g", scd->YMin(), scd->YMax());
+  mText[1]->SetText(buff);
+  int xa, ya;
+  scd->GetAxesConfig(xa, ya);
+  if (xa & kAxeDirRtoL) mCkb[0]->SetState(true);
+  if (ya & kAxeDirUpDown)  mCkb[1]->SetState(true);
+  if (scd->GetAxesFlags() & kGridOn) mCkb[2]->SetState(true);
+  }
+else {
+  mText[0]->SetText("-1.0  1.0");
+  mText[1]->SetText("-1.0  1.0");
+  }
+sprintf(buff, "%d", mNDr);
+mNlb->SetLabel(buff);
+
+
+
+return;
+}
+
+/* --Methode-- */
+void PIDrwTools::UpdateAttFromDrawer()
+{
+
+PIDrawer* dr = NULL;
+
+mOpt[0]->SetValue(100);
+mOpt[1]->SetValue(200);
+mOpt[2]->SetValue(300);
+mOpt[3]->SetValue(405);
+mOpt[4]->SetValue(500);
+mOpt[5]->SetValue(600);
+
+if ( (mCurBW != NULL) && (mCurBW->NbDrawers() > 0) ) 
+  dr = mCurBW->GetDrawer(mNDr);
+
+if (!dr)  return;
+int jj,kk;
+PIColors fc = dr->GetFgColAtt();
+for(kk=0; kk<17; kk++) 
+  if (fc == cols[kk])  { mOpt[0]->SetValue(100+kk);  break; }    
+CMapId cmi = dr->GetColMapId();
+for(kk=0; kk<11; kk++)
+  if (cmi == cmap[kk]) { mOpt[1]->SetValue(200+kk);  break; }  
+PIMarker mk = dr->GetMarker();   
+for(kk=0; kk<12; kk++) 
+  if (mk == mrk[kk])   { mOpt[2]->SetValue(300+kk);  break; }
+kk = dr->GetMarkerSz();
+if (kk < 1)  kk = 1;
+if (kk > 15) kk = 15;
+if (kk%2 == 0) kk++;
+mOpt[3]->SetValue(400+kk);
+PIFontAtt fat = dr->GetFontAtt();
+PIFontSize fsz = dr->GetFontSz();
+for(kk=0; kk<4; kk++)
+  if (fat ==  fntatt[kk]) break;
+for(jj=0; jj<5; jj++) 
+  if (fsz == fntsz[jj])  break;
+
+if (kk >= 4) kk = 3;
+if (jj >= 5) jj = 4;
+mOpt[4]->SetValue(500+jj*10+kk);
+PILineAtt lat = dr->GetLineAtt();
+for(kk=0; kk<10; kk++)
+  if (lat == line[kk])   { mOpt[5]->SetValue(600+kk);  break; }
+
+return;
+}
+
+/* --Methode-- */
+void PIDrwTools::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
+{
+
+msg = UserMsg(msg);
+if (msg == 3777)  { Hide(); return; }
+
+if (mCurBW == NULL)   return;
+
+char strg[64];
+double xmin, xmax, ymin, ymax;
+int axrl = kAxeDirLtoR;
+int ayud = kAxeDirDownUp;
+int k, kk, kkk;
+
+switch (msg) {
+
+  case 2600 :
+    sscanf(mText[0]->GetText().c_str(), "%lg %lg" , &xmin, &xmax);
+    sscanf(mText[1]->GetText().c_str(), "%lg %lg" , &ymin, &ymax);
+    if (mCkb[0]->GetState())  axrl = kAxeDirRtoL ;
+    if (mCkb[1]->GetState())  ayud = kAxeDirUpDown;
+    if ( mCurBW->kind() == PIScDrawWdg::ClassId ) { 
+      ((PIScDrawWdg*)mCurBW)->SetLimits(xmin, xmax, ymin, ymax, axrl, ayud);
+      unsigned int flags = ((PIScDrawWdg*)mCurBW)->GetAxesFlags();
+      if (mCkb[2]->GetState()) ((PIScDrawWdg*)mCurBW)->SetAxesFlags(flags | kGridOn);
+      else  ((PIScDrawWdg*)mCurBW)->SetAxesFlags(flags & ~kGridOn);
+      }
+    else mCurBW->SetDefaultDrawerLimits(xmin, xmax, ymin, ymax, axrl, ayud);
+    mCurBW->Refresh();
+    break;
+
+  case 2700 :
+    if ( mCurBW->kind() == PIScDrawWdg::ClassId ) ((PIScDrawWdg*)mCurBW)->UpdateLimits();
+    else if ( mCurBW->kind() == PIDraw3DWdg::ClassId) ((PIDraw3DWdg*)mCurBW)->Update3DView();
+    break;
+
+  case 2800 :
+    UpdateAttFromDrawer();
+    break;
+
+  case 2900 :
+  case 3000 :
+    {
+    PIDrawer* drw = mCurBW->GetDrawer(mNDr);
+    if (drw == NULL)  return;
+    k = mOpt[0]->GetValue()-100;
+    if ( (k < 0) || (k > 16) )  k = 0;
+    drw->SetColAtt(cols[k]);
+    k = mOpt[1]->GetValue()-200;
+    if ( (k < 0) || (k > 10) )  k = 0;
+    drw->SetColMapId(cmap[k]);
+    k =  mOpt[2]->GetValue()-300;
+    if ( (k < 0) || (k > 11) )  k = 0;
+    kk =  mOpt[3]->GetValue()-400;
+    if ( (kk < 1) || (kk > 27) )  kk = 1;
+    drw->SetMarkerAtt(kk, mrk[k]);
+    k =  (mOpt[4]->GetValue()-500);
+    kk = k/10;   kkk = k%10;
+    drw->SetFontAtt(fntsz[kk], fntatt[kkk]);
+    k =  mOpt[5]->GetValue()-600;
+    if ( (k < 0) || (k > 9) )  k = 0;
+    drw->SetLineAtt(line[k]);
+    if (msg == 2900) drw->Refresh();
+    else mCurBW->Refresh();
+    }
+    break;        
+
+  case 3501 :
+  case 3502 :
+    if (msg == 3501) {  mNDr--;   if (mNDr < 0)  mNDr = 0; }
+    else { mNDr++;  if (mNDr >= mCurBW->NbDrawers())  mNDr--; }
+    sprintf(strg, "%d", mNDr);
+    mNlb->SetLabel(strg);
+    /*   On ne change pas les options choisies   Reza+cmv 2/10/98  
+    mOpt[0]->SetValue(100);
+    mOpt[1]->SetValue(200);
+    mOpt[2]->SetValue(300);
+    mOpt[3]->SetValue(405);
+    mOpt[4]->SetValue(500);
+    mOpt[5]->SetValue(600);
+    */
+    break;
+
+  default :
+    break;
+  }
+
+return;
+}
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pidrwtools.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pidrwtools.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pidrwtools.h	(revision 464)
@@ -0,0 +1,53 @@
+// 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 PISTDWDG_H
+#include PIOPTMENU_H
+#include PIWIN_H
+#include PIAPP_H
+#include "pibwdggen.h"
+
+// --------- fenetre de dialogue pour modifs axes et options des Drawers ----------
+// --------------------------------------------------------------------------------
+
+
+class PIDrwTools : public PIWindow 
+{
+public :
+  PIDrwTools(PIApplication* par);
+  ~PIDrwTools();
+  virtual void  Show();
+
+  static PIDrwTools* curlutw;
+  static void ShowPIDrwTools();
+  static void SetCurrentBaseWdg(PIBaseWdgGen* cbw);
+  static PIBaseWdgGen* GetCurrentBaseWdg();
+
+protected:
+  virtual void  UpdateAttFromDrawer();
+  virtual void  Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+
+private:
+// Pour changer les axes
+  PILabel* mLab[2];
+  PIButton* mBut[2];
+  PIText* mText[2];
+  PICheckBox* mCkb[3];
+// Pour couleur, fontes, etc 
+  PIOptMenu* mOpt[6];
+  PILabel* mNlb;
+  PIButton* mButdr[2];
+  PIButton* mButcf[4];
+  int mNDr;
+  int mtyp, msz;
+//
+  static PIBaseWdgGen* mCurBW;
+  static PIDrwTools* cwdrwt;
+};
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pierrdisp.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pierrdisp.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pierrdisp.cc	(revision 464)
@@ -0,0 +1,105 @@
+#include "pierrdisp.h"
+#include "utils.h"
+
+
+PIErrorBox::PIErrorBox(PIContainerGen* par, int sx, int sy,
+	     int px, int py)
+: PIBaseWdg(par, "Error Message", sx, sy, px, py)
+{
+  currErrText = "";
+  state = 0;
+}
+
+PIErrorBox::~PIErrorBox()
+{
+}
+
+void
+PIErrorBox::Draw()
+{
+  if (currErrText == "") {
+    SelBackground();
+    EraseWindow();
+  } else {
+    switch(state) {
+    case 0:
+      EraseWindow();
+      SelForeground(PI_Red);
+      DrawFBox(0,0,1000,1000);
+      SelForeground(PI_Black);
+      break;
+    default:
+      SelBackground();
+      SelForeground();
+    }
+    SelFont(PI_BigSizeFont, PI_BoldFont);
+    DrawString(20,30,(char*)currErrText.c_str());
+  }
+}
+
+void
+PIErrorBox::Cycle()
+{
+  state = (state + 1) % 2;
+}
+
+
+
+
+PIErrorDisplay::PIErrorDisplay(PIContainerGen* par, int sx, int sy,
+			       int px, int py)
+: PIContainer(par, "Error Display", sx, sy, px, py), PIPeriodX(1)
+{
+  currErrId = 0;
+
+  errorBox  = new PIErrorBox(this, 150, 80, 0, 0);
+  ackButton = new PIButton(this, "OK", 5000, 40, 20, 155, 20);
+  updButton = new PIButton(this, "Upd", 5001, 40, 20, 155, 50);
+  Start();
+}
+
+PIErrorDisplay::~PIErrorDisplay()
+{
+  delete updButton;
+  delete ackButton;
+  delete errorBox;
+}
+
+void
+PIErrorDisplay::Process(PIMessage msg, PIMsgHandler *sender, void *data)
+{
+msg = UserMsg(msg);
+  switch(msg) {
+  case 5000:
+    // On valide
+    if (currErrId) 
+      AcqAckError(currErrId);
+    UpdData();
+    break;
+  case 5001:
+    UpdData();
+    break;
+    
+  default:
+    PIContainer::Process(msg, sender, data);
+  }
+}
+
+void
+PIErrorDisplay::UpdData()
+{
+  currErrId = 0;
+  char tache[80];
+  char msg[200];
+  int code;
+  int severite;
+  int rc = AcqGetNextError(&currErrId, tache, &code, &severite, msg);
+  if (rc)
+    errorBox->SetText("");
+  else
+    errorBox->SetText(string(tache) + " : (" + itos(code) + "/" +
+		     itos(severite) +") " + msg);
+  errorBox->Draw();
+}
+
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pierrdisp.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pierrdisp.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pierrdisp.h	(revision 464)
@@ -0,0 +1,48 @@
+// This may look like C code, but it is really -*- C++ -*-
+#ifndef PIERRDISP_H_SEEN
+#define PIERRDISP_H_SEEN
+
+#include "pisysdep.h"
+#include PIBWDG_H
+#include PISTDWDG_H
+#include PICONT_H
+#include PIPERIOD_H
+
+#include "errorhandlerc.h"
+
+class PIErrorBox : public PIBaseWdg {
+public:
+  PIErrorBox(PIContainerGen* par, int sx=100, int sy = 50,
+	     int px=0, int py=0);
+  ~PIErrorBox();
+
+  void Draw();
+  
+  void SetText(string const& txt) {currErrText = txt;}
+  void Cycle();
+
+protected:
+  string currErrText;
+  int           state;     // Cycle decoratif en couleurs violentes...  
+};
+
+class PIErrorDisplay : public PIContainer, public PIPeriodic {
+public:
+  
+  PIErrorDisplay(PIContainerGen* par, int sx=150, int sy=50,
+		 int px=0, int py=0);
+  virtual      ~PIErrorDisplay();
+  
+  void          UpdData();
+  void          Process(PIMessage msg, PIMsgHandler *sender, void *data);
+  void          DoPeriodic() {UpdData();}
+protected:
+  int           currErrId;
+
+  PIErrorBox*   errorBox;
+  PIButton*     ackButton;
+  PIButton*     updButton;   // TEMPORAIRE
+};
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pievthandler.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pievthandler.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pievthandler.cc	(revision 464)
@@ -0,0 +1,141 @@
+// Module PI : Peida Interactive      PIEventHandler
+// Classe Gestionnaire d'evenements (Ecran/Clavier/Souris)
+//                                    R.Ansari  12/98 
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "pievthandler.h"
+
+//++
+// Class	PIEventHandler
+// Lib		PI
+// include	pievthandler.h
+//
+//	Classe fournissant les services nécessaires à la création de
+//	gestionnaire d'événements écran-clavier-souris.
+//--
+//++
+// Links	Parents
+// PIMsgHandler
+//--
+//++
+// Links	Voir aussi
+// PIWdg
+//--
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+// PIEventHandler(PIMsgHandler* par=NULL, PIMessage msg = 0)
+//	Constructeur. "par" est le gestionnaire de message parent, et
+//	"msg" le message associé.
+//
+// void	  SetMsg(PIMessage msg = 0)
+//	Modification du message associé.
+// PIMessage  Msg() 
+//	Renvoie le message associé.
+//--
+
+
+
+/* --Methode-- */
+PIEventHandler::PIEventHandler(PIMsgHandler* par, PIMessage msg)
+	: PIMsgHandler(par)
+{
+SetMsg(msg);
+curwdg = NULL;
+event = PIEvent_None;
+posx = posy = 0;
+key = 0;
+keymod = PIKM_Blank;
+evttime = 0;
+}
+
+/* --Methode-- */
+PIEventHandler::~PIEventHandler()
+{
+}
+
+//++
+// Titre	Traitement des événements
+//--
+//++
+// void Draw(PIGraphic* g, int x0, int y0, int dx, int dy)
+//	Méthode spécialisée appelée pour retracer le contenu 
+//	d'une partie de l'objet "PIWdg" auquel est attaché l'objet
+//	"PIEventHandler". "PIGraphic* g" fournit les services de 
+//	tracé graphique et "(x0, y0), "dx * dy" définissent le 
+//	rectangle à retracer. L'implementation par défaut ne 
+//	fait rien.
+//
+// void ProcessEvent()
+//	Cette méthode est appelée pour le traitement de tous 
+//	les autres types d'événements. L'implementation par défaut 
+//	ne fait rien. 
+//--
+
+
+/* --Methode-- */
+void PIEventHandler::Draw(PIGraphic*, int, int, int, int)
+{
+return;
+}
+
+/* --Methode-- */
+void PIEventHandler::ProcessEvent()
+{
+return;
+}
+
+/* --Methode-- */
+void PIEventHandler::SetCurrentWdg(PIWdg* wdg)
+{
+curwdg = wdg;
+}
+
+
+//++
+// Titre	Description de l'événement
+//--
+//++
+// PIWdg*  CurrentWdg()
+//	L'objet "PIWdg" source de l'événement.
+// PIEventMask EventType()
+//	Type de l'événement :
+//|	PIEvent_Draw 
+//|	PIEvent_Resize , PIEvent_Enter , PIEvent_Leave
+//|	PIEvent_ButxPress , PIEvent_ButxRelease  (x=1,2,3)
+//|	PIEvent_PtrMove , PIEvent_PtrxMove (x=1,2,3)
+//|	PIEvent_Keyboard
+//
+// int GetPosX()
+//	Position X de la souris
+// int GetPosY()
+//	Position Y de la souris
+// int GetKey()
+//	Code touche du clavier. Code ASCII des caractères ordinaires, ou l'une des constantes:
+//|	PIK_Return , PIK_Enter
+//|	PIK_BackSpace , PIK_Delete
+//|	PIK_Tab , PIK_Escape
+//|	PIK_Up , PIK_Down
+//|	PIK_Right , PIK_Left
+//|	PIK_Previous , PIK_Next
+//
+// PIKeyModifier GetKeyMod()
+//	Code d'une des touches <Shift>, <Alt>, <Cntl> si appuyée en même temps.
+//|	PIKM_Blank , PIKM_Shift , PIKM_Alt , PIKM_Cntl
+//
+// unsigned long GetEventTime()
+//	Temps de l'action en millisecondes.
+//--
+
+/* --Methode-- */
+void PIEventHandler::SetEventInfo(PIEventMask evt, int px, int py, 
+                                  int k, PIKeyModifier km, unsigned long tm)
+{
+event = evt;
+posx = px; posy = py;
+key = k;
+keymod = km;
+evttime = tm;
+}
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pievthandler.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pievthandler.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pievthandler.h	(revision 464)
@@ -0,0 +1,85 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive      PIEventHandler
+// Classe Gestionnaire d'evenements (Ecran/Clavier/Souris) 
+//                                    R.Ansari  12/98 
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIEVTHANDLER_H_SEEN
+#define PIEVTHANDLER_H_SEEN
+
+#include "pisysdep.h"
+#include "pimsghandler.h"
+#include PIWDG_H
+#include PIGRAPHIC_H
+
+
+// ....  KeyModifier (<Shift>, <Control> , <Alt>) and special key values ....
+enum PIKeyModifier { PIKM_Blank = 0, PIKM_Shift = 1, PIKM_Alt = 2, PIKM_Cntl = 4 } ; 
+
+enum PIKeyValues { PIK_Return = 0xFF0D, PIK_Enter = 0xFF8D , 
+                   PIK_BackSpace = 0xFF08, PIK_Delete = 0xFFFF,
+                   PIK_Tab = 0xFF09, PIK_Escape = 0xFF1B, 
+                   PIK_Up = 0xFF52, PIK_Down = 0xFF54, 
+                   PIK_Right = 0xFF53, PIK_Left = 0xFF51,
+                   PIK_Previous = 0xFF55, PIK_Next = 0xFF56  } ; 
+
+// .......... Event Mask values ..........
+enum PIEventMask {
+     PIEvent_None	  =  0,                  //
+     PIEvent_Draw         =  1 << 0,             // ReDraw window
+     PIEvent_Resize       =  1 << 1,             // window resized
+     PIEvent_Enter        =  1 << 2,             // Pointer entered window
+     PIEvent_Leave        =  1 << 3,             // Pointer leaved window
+     PIEvent_But1Press    =  1 << 4,             // Button-1 Press
+     PIEvent_But1Release  =  1 << 5,             // Button-1 Release
+     PIEvent_But2Press    =  1 << 6,             // Button-2 Press
+     PIEvent_But2Release  =  1 << 7,             // Button-2 Release
+     PIEvent_But3Press    =  1 << 8,             // Button-3 Press
+     PIEvent_But3Release  =  1 << 9,             // Button-3 Release
+     PIEvent_PtrMove      =  1 << 14,            // Pointer moved
+     PIEvent_Ptr1Move     =  1 << 15,            // Pointer moved with button-1
+     PIEvent_Ptr2Move     =  1 << 16,            // Pointer moved with button-2
+     PIEvent_Ptr3Move     =  1 << 17,            // Pointer moved with button-3
+     PIEvent_Keyboard     =  1 << 20             // key-pressed Keyboard
+} ;
+
+
+// -----------------  Class PIEventHandler  -----------------------
+class PIEventHandler : public PIMsgHandler
+{
+public:
+			PIEventHandler(PIMsgHandler* par=NULL, PIMessage msg = 0);
+			~PIEventHandler();
+
+  inline  void		SetMsg(PIMessage msg = 0) { myMsg=msg; }
+  inline  PIMessage	Msg() { return (myMsg); }
+
+  virtual void		Draw(PIGraphic* g, int x0, int y0, int dx, int dy);
+  virtual void		ProcessEvent();
+
+  virtual  void		SetCurrentWdg(PIWdg* wdg);
+  inline  PIWdg*	CurrentWdg() { return(curwdg); }
+
+  virtual void		SetEventInfo(PIEventMask evt, int px, int py, 
+                                     int k, PIKeyModifier km, unsigned long tm);
+  inline  PIEventMask	EventType() { return(event); }
+  inline  int		GetPosX() { return(posx); }  
+  inline  int		GetPosY() { return(posy); }  
+  inline  int		GetKey() { return(key); }
+  inline  PIKeyModifier GetKeyMod() { return(keymod); }
+  inline  unsigned long GetEventTime() { return(evttime); }
+
+protected:
+  PIMessage	myMsg;	       // associated user message
+
+  PIWdg*	curwdg;        // Current PIWdg, where event originated
+  PIEventMask	event;	       // event type
+  int		posx, posy;    // Pointer Position  
+  int		key;	       // Pressed key-code 
+  PIKeyModifier keymod;	       // Pressed key-modifier (shift, Cntl, ...)
+  unsigned long evttime;       // Event-time in ms  
+};
+
+
+
+#endif  
Index: /tags/V_LaSilla191199/SophyaPI/PI/pifilechogen.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pifilechogen.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pifilechogen.cc	(revision 464)
@@ -0,0 +1,73 @@
+// Module PI : Peida Interactive     PIFileChooser
+// Selecteur de fichier                    96-97
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "pifilechogen.h"
+
+
+/************* PIFileChooserGen ************/
+
+//++
+// Class	PIFileChooser
+// Lib		PI
+// include	pifilechogen.h
+//
+//	Composant graphique de type sélecteur de fichier, permettant de choisir 
+//	un nom de fichier et de naviguer dans les répertoires.
+//	"PIFileChooserGen" définit l'interface (classe virtuelle pure). Les objets 
+//	instanciés doivent être de la classe "PIFileChooser" déclarée dans le fichier
+//	entête "PIFILECHO_H". Le message associé à l'objet est envoyé completé 
+//	avec "PIMsg_OK" si un nom de fichier a été choisi. la variable "data"
+//	est alors un pointeur sur une chaîne de caractères ("char *"), 
+//	contenant le nom complet du fichier. Si aucun fichier n'a été 
+//	sélectionné, le message de l'objet est completé avec "PIMsg_Cancel" et 
+//	le "datä contient le pointeur "NULL".
+//--
+//++
+// Links	Parents
+// PIWdg
+//--
+//++
+// Titre	Constructeur et méthodes
+//--
+//++
+// PIFileChooser(PIMsgHandler* par, const char* nom, PIMessage msg)
+//	Création d'un objet sélecteur de fichier, avec le message "msg".
+// void  Show()
+//	Affiche la fenêtre de sélection des fichiers
+// void  AcceptNewFile(bool acc)
+//	Active ("acc=true") ou désactive la possibilité de spécifier
+//	un nouveau fichier.
+// void  SetPath(string const&)
+//	Définit le chemin d'accès (répertoire) choisi par défaut
+// void  SetFileName(string const&) 
+//	Nom de fichier sélectionné par défaut
+// string  GetPath()
+//	Retourne le chemin d'accès. NON IMPLEMENTE EN X/MOTIF (06/98)
+// string  GetFileName()
+//	Retourne le nom complet du fichier sélectionné. 
+//--
+
+
+PIFileChooserGen::PIFileChooserGen(PIMsgHandler* par, const char* nom, PIMessage msg)
+: PIWdg(NULL, nom)
+{
+SetMsg(msg);
+SetMsgParent(par);
+}
+
+PIFileChooserGen::~PIFileChooserGen()
+{}
+
+void PIFileChooserGen::Show()
+{
+return;
+}
+
+
+void PIFileChooserGen::AcceptNewFile(bool)
+{
+return;
+}
+
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pifilechogen.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pifilechogen.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pifilechogen.h	(revision 464)
@@ -0,0 +1,34 @@
+#ifndef PIFILCHOGEN_H_SEEN
+#define PIFILCHOGEN_H_SEEN
+
+#include "pisysdep.h"
+#include PIWDG_H
+
+class PIFileChooserGen : public PIWdg {
+public:
+  enum {ClassId = 2100};
+
+                     PIFileChooserGen(PIMsgHandler* par, const char* nom, PIMessage msg);
+  virtual            ~PIFileChooserGen();
+
+  virtual void       Show();
+
+  virtual void       AcceptNewFile(bool acc);
+  virtual void       SetPath(string const&) = 0;
+  virtual void       SetFileName(string const&) = 0;
+
+  virtual string     GetPath() = 0;
+  virtual string     GetFileName() = 0;
+
+  virtual long       kind() {return ClassId; }
+
+protected:
+
+};
+
+
+#endif
+
+
+
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pifilechomac.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pifilechomac.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pifilechomac.cc	(revision 464)
@@ -0,0 +1,123 @@
+#include "pifilechomac.h"
+
+string PathNameFromDirID(long dirID, short vRefNum);
+
+string PIGetFileName(string dir);
+string PIGetExistingFileName(string dir);
+
+string PIGetFileName(string dir)
+{
+  StandardFileReply reply;
+  
+  
+  string fName;
+  int i = dir.rfind(':');
+  if (i == string::npos)
+    fName = dir;
+  else if (i == dir.length())
+    fName = "";
+  else
+    fName = dir.substr(i+1);
+    
+  LStr255 defaultName(fName.c_str());
+  
+  StandardPutFile("\pSave as:",defaultName,&reply);
+  
+  if (!reply.sfGood) return "";
+  
+  string directory = PathNameFromDirID(reply.sfFile.parID,reply.sfFile.vRefNum);
+  p2cstr(reply.sfFile.name);
+  
+//  return directory + '/' + (char*)reply.sfFile.name;
+  return directory + ':' + (char*)reply.sfFile.name;
+}
+
+string PIGetExistingFileName(string /*dir*/)
+{
+  StandardFileReply reply;
+  SFTypeList typeList;
+  
+  StandardGetFile(NULL,-1,typeList,&reply);
+  
+  if (!reply.sfGood) return "";
+  
+  string directory = PathNameFromDirID(reply.sfFile.parID,reply.sfFile.vRefNum);
+  p2cstr(reply.sfFile.name);
+  
+//  return directory + '/' + (char*)reply.sfFile.name;
+  return directory + ':' + (char*)reply.sfFile.name;
+}
+
+
+string PathNameFromDirID(long dirID, short vRefNum)
+{
+	DirInfo 	block;
+	Str255		directoryName;
+	OSErr		err;
+
+	string fullPathName = "";
+
+	block.ioDrParID = dirID;
+	block.ioNamePtr = directoryName;
+	do {
+			block.ioVRefNum = vRefNum;
+			block.ioFDirIndex = -1;
+			block.ioDrDirID = block.ioDrParID;
+			err = PBGetCatInfoSync(CInfoPBPtr(&block));
+			p2cstr(directoryName);
+			if (fullPathName != "") fullPathName = ':' + fullPathName;
+			fullPathName =  ((char*)directoryName + fullPathName);
+//			fullPathName = '/' + ((char*)directoryName + fullPathName);
+	} while (block.ioDrDirID != 2);
+	return fullPathName;
+}
+
+
+PIFileChooserMac::PIFileChooserMac(PIMsgHandler* par, char* nom, PIMessage msg)
+: PIFileChooserGen(par, nom, msg)
+{
+  mAccNew = false;
+  mFileName = "";
+}
+
+PIFileChooserMac::~PIFileChooserMac()
+{}
+
+void
+PIFileChooserMac::Show()
+{
+  if (mAccNew)
+    mFileName = PIGetFileName("");
+  else
+    mFileName = PIGetExistingFileName("");
+
+// Envoyer un message....
+  if (mFileName == "")
+    Send(Msg(), PIMsg_Cancel, NULL);
+  else
+    Send(Msg(), PIMsg_OK, (void *) (GetFileName().c_str()));
+}
+
+void
+PIFileChooserMac::AcceptNewFile(bool acc)
+{
+  mAccNew = acc;
+}
+
+void
+PIFileChooserMac::SetPath(string const& /*path*/) {}
+void
+PIFileChooserMac::SetFileName(string const& /*fname*/) {}
+
+string
+PIFileChooserMac::GetPath()
+{
+  return "";
+}
+
+string
+PIFileChooserMac::GetFileName()
+{
+  return mFileName;
+}
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pifilechomac.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pifilechomac.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pifilechomac.h	(revision 464)
@@ -0,0 +1,33 @@
+#ifndef PIFILECHOMAC_H_SEEN
+#define PIFILECHOMAC_H_SEEN
+
+#include <string>
+#include "pisysdep.h"
+#include "pifilechogen.h"
+
+class PIFileChooserMac : public PIFileChooserGen {
+public:
+
+                   PIFileChooserMac(PIMsgHandler* par, char* nom, PIMessage msg);
+  virtual          ~PIFileChooserMac();
+
+  virtual void     Show();
+
+  virtual void     AcceptNewFile(bool acc);
+  virtual void     SetPath(string const& path);
+  virtual void     SetFileName(string const& fname);
+
+  virtual string   GetPath();
+  virtual string   GetFileName();
+
+protected:
+  bool             mAccNew;
+  string           mFileName;
+};
+
+typedef PIFileChooserMac     PIFileChooser ;
+
+#define FILESEP ':'
+
+#endif
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pifilechox.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pifilechox.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pifilechox.cc	(revision 464)
@@ -0,0 +1,173 @@
+#include<stdio.h>
+#include<string.h>
+
+#include "pisysdep.h"
+
+#include "piapplx.h"
+#include "pifilechox.h"
+
+
+/************* PIFileChooserX ************/
+#include <X11/Shell.h>
+#include <Xm/FileSB.h>
+
+// Pour ces sal... de XmString  (ds piwdgx.cc)
+int CStrFrXmStr(XmString xms, char* buff, int nmx);
+
+// Fonctions privees (CallBack)
+//static void filesel_okact(Widget w, XtPointer *usd, XtPointer *calld);
+static void filesel_cancelact(Widget w, XtPointer *usd, XtPointer *calld);
+
+/* Nouvelle-Fonction */
+void  filesel_okact(Widget /*w*/, XtPointer *usd, 
+                    XmFileSelectionBoxCallbackStruct *calld)
+{
+PIFileChooserX *pif;
+pif = (PIFileChooserX *) usd ;
+pif->mSt = 1;
+pif->MWin()->UnManage();
+//pif->Send(pif->Msg(), (void *) (pif->GetFileName().c_str()));
+CStrFrXmStr(calld->value, pif->mFName, 512); 
+pif->Send( pif->Msg(), PIMsg_OK, (void *) pif->mFName);
+return;
+}
+
+/* Nouvelle-Fonction */
+void  filesel_cancelact(Widget /*w*/, XtPointer *usd, XtPointer */*calld*/)
+{
+PIFileChooserX *pif;
+pif = (PIFileChooserX *) usd ;
+pif->mSt = 0;
+pif->mFName[0] = '\0';
+pif->MWin()->UnManage();
+pif->Send(pif->Msg(), PIMsg_Cancel, NULL);
+return;
+}
+
+static int PIFC_SzX, PIFC_SzY;
+/* --Methode-- */
+PIFileChooserX::PIFileChooserX(PIMsgHandler* par, const char* nom, PIMessage msg)
+: PIFileChooserGen(par, nom, msg)
+{
+SysDWdg wdg;
+
+mWin = NULL;
+
+int sx, sy;
+PIApplicationPrefCompSize(sx, sy);
+PIFC_SzX = sx*6;  PIFC_SzY = sy*10;
+mWin = new PIWdgX(NULL, nom, PIFC_SzX, PIFC_SzY, 200, 200);
+mWin->CreateXtWdg(nom, topLevelShellWidgetClass, NULL, PIFC_SzX, PIFC_SzY, 200, 200);
+
+mSt = 0;
+mFName[0] = mFName[511] = '\0';
+
+CreateXtWdg(nom, xmFileSelectionBoxWidgetClass, mWin->XtWdg(), sx, sy, 0, 0);
+XtAddCallback(XtWdg(), XmNokCallback, 
+              (XtCallbackProc)filesel_okact, (XtPointer)this);
+XtAddCallback(XtWdg(), XmNcancelCallback, 
+              (XtCallbackProc)filesel_cancelact, (XtPointer)this);
+// Pour avoir une version simplifiee 
+/* wdg = XmFileSelectionBoxGetChild(XtWdg(),XmDIALOG_DIR_LIST);
+XtUnmanageChild(wdg);
+wdg = XmFileSelectionBoxGetChild(XtWdg(),XmDIALOG_DIR_LIST_LABEL);
+XtUnmanageChild(wdg);
+*/
+wdg = XmFileSelectionBoxGetChild(XtWdg(),XmDIALOG_HELP_BUTTON);
+XtUnmanageChild(wdg);
+
+fnl = XmFileSelectionBoxGetChild(XtWdg(),XmDIALOG_SELECTION_LABEL);
+fnw = XmFileSelectionBoxGetChild(XtWdg(),XmDIALOG_TEXT);
+
+Arg warg[2];
+XtSetArg(warg[0], XmNfileTypeMask, XmFILE_REGULAR);
+XtSetValues(XtWdg(), warg, 1);
+
+AcceptNewFile(false);
+Manage();
+}
+
+/* --Methode-- */
+PIFileChooserX::~PIFileChooserX()
+{
+delete mWin;
+}
+
+/* --Methode-- */
+void PIFileChooserX::AcceptNewFile(bool acc)
+{
+if (acc) 
+  {
+  mWin->SetSize( PIFC_SzX, PIFC_SzY*1.25);
+  XtManageChild(fnl);  XtManageChild(fnw); 
+  }
+else 
+  { 
+  mWin->SetSize( PIFC_SzX, PIFC_SzY*1.1);
+  XtUnmanageChild(fnl); XtUnmanageChild(fnw); 
+  }
+}
+
+/* --Methode-- */
+void PIFileChooserX::Show()
+{
+mWin->Manage();
+}
+
+/* --Methode-- */
+void PIFileChooserX::SetPath(string const& path)
+{
+XmString xmstr;
+xmstr = XmStringLtoRCreate((char *)path.c_str(), XmSTRING_DEFAULT_CHARSET);
+Arg warg[2];
+XtSetArg(warg[0], XmNdirectory, xmstr); 
+XtSetValues(XtWdg(), warg, 1);
+XmStringFree(xmstr);
+return;
+}
+
+/* --Methode-- */
+void PIFileChooserX::SetFileName(string const& fname)
+{
+XmString xmstr;
+xmstr = XmStringLtoRCreate((char *)fname.c_str(), XmSTRING_DEFAULT_CHARSET);
+Arg warg[2];
+XtSetArg(warg[0], XmNtextString, xmstr); 
+XtSetValues(XtWdg(), warg, 1);
+XmStringFree(xmstr);
+return;
+}
+
+
+/* --Methode-- */
+string PIFileChooserX::GetFileName()
+{
+
+if (mSt)
+  {
+  XmString xmstr;
+  Arg warg[2];
+
+  XtSetArg(warg[0], XmNtextString, &xmstr);
+  XtGetValues(XtWdg(), warg, 1);
+  CStrFrXmStr(xmstr, mFName, 512); 
+  string s(mFName);
+  XmStringFree(xmstr);
+  return(s);
+  }
+else
+  {
+  mFName[0] = '\0';
+  string s(mFName);
+  return(s);
+  }
+}
+
+/* --Methode-- */
+string PIFileChooserX::GetPath()
+{
+printf("PIFileChooserX::GetPath() not implemented ! \n");
+string s("");
+return(s);
+}
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pifilechox.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pifilechox.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pifilechox.h	(revision 464)
@@ -0,0 +1,41 @@
+#ifndef PIFILCHOX_H_SEEN
+#define PIFILCHOX_H_SEEN
+
+#include "pisysdep.h"
+#include "pifilechogen.h"
+
+#include PIWIN_H
+
+class PIFileChooserX : public PIFileChooserGen {
+public:
+
+                   PIFileChooserX(PIMsgHandler* par, const char* nom, PIMessage msg);
+  virtual          ~PIFileChooserX();
+
+  virtual void     Show();
+
+  virtual void     AcceptNewFile(bool acc);
+  virtual void     SetPath(string const& path);
+  virtual void     SetFileName(string const& fname);
+
+  virtual string   GetPath();
+  virtual string   GetFileName();
+
+  inline PIWdg *   MWin() { return mWin; }
+
+//  Je les declare ici, en public, a cause des callback
+  int mSt;
+  char mFName[512];     
+
+protected:
+  PIWdg * mWin;
+  SysDWdg  fnw, fnl;
+};
+
+typedef PIFileChooserX     PIFileChooser ;
+
+#define FILESEP '/'
+
+
+#endif
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pifontgen.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pifontgen.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pifontgen.cc	(revision 464)
@@ -0,0 +1,85 @@
+// Module PI : Peida Interactive     PIFontGen 
+// LAL (Orsay) / IN2P3-CNRS          R. Ansari  99
+
+// Classe generique de gestion de fonte - (Ne peut etre instancie)
+
+#include "pigraphgen.h"
+
+
+//++
+// Class	PIFont
+// Lib		PI
+// include	pifontgen.h
+//
+//	Classe de base fournissant les services de gestion de fontes
+//	La classe virtuelle pure PIFontGen définit l'interface. Les
+//	objets instanciés doivent être de la classe "PIFont"
+//	("PIFontX", "PIFontMac", ...)
+//
+//	Des constantes de type enum sont définies pour l'identification
+//	des types de fontes *PIFontName* , de l'attribut *PIFontAtt* 
+//	et de la taille *PIFontSize*.
+//	* PIFontName :
+//|	PI_DefaultFont , PI_CourierFont , PI_SymbolFont
+//	* PIFontSize :
+//|	PI_SmallSizeFont , PI_NormalSizeFont , PI_BigSizeFont, PI_HugeSizeFont
+//	* PIFontAtt :	
+//|	PI_RomanFont , PI_BoldFont , PI_ItalicFont 
+//--
+
+//++
+// Titre	Constructeurs
+//--
+//++
+// PIFont(PIFontName fn = PI_DefaultFont)
+//	Constructeur  pour fonte "fn". Constructeur par défaut.
+// PIFont(int npt, PIFontName fn = PI_DefaultFont, PIFontAtt fa = PI_RomanFont)
+//	Constructeur avec spécification de taille en points (pixels).
+// PIFont(PIFont const & fnt)
+//	Constructeur de copie
+// PIFont & operator = (PIFont const & fnt) 
+//	Opérateur égal.
+// bool operator == (PIFont const & fnt) 
+//	Opérateur test d'égalité.
+//--
+
+/* --Methode-- */
+PIFontGen::PIFontGen(PIFontName fn)
+{
+}
+
+/* --Methode-- */
+PIFontGen::PIFontGen(int npt, PIFontName fn, PIFontAtt fa)
+{
+}
+
+/* --Methode-- */
+PIFontGen::~PIFontGen()
+{
+}
+
+//++
+// Titre	Méthodes
+//--
+
+//++
+// void  SetFont(PIFontName fn)
+//	Changement de fonte.
+// void  SetFontAtt(PIFontAtt fa)
+//	Changement d'attribut de fonte
+// void  SetFontSz(PIFontSize fs)
+//	Changement de taille de fonte
+// void  SetFontSzPt(int npt)
+//	Changement de taille de fonte - Spécification de taille en points (pixels)
+// PIFontName  GetFontName()
+//	Retourne le type (nom) de fonte
+// PIFontAtt  GetFontAtt()
+//	Retourne l'attribut de fonte
+// int  GetFontSize()
+//	Retourne la taille de fonte en points (pixels)
+// int GetFontHeight(int& asc, int& desc) 
+//	Renvoie la hauteur des caractères, ainsi que la taille au dessus
+//	et en-dessous de la ligne de base ("asc , desc").
+// int GetStringWidth(char const* s)
+//	Renvoie la largeur occupé par le texte "char * s" en points/pixels
+//--
Index: /tags/V_LaSilla191199/SophyaPI/PI/pifontgen.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pifontgen.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pifontgen.h	(revision 464)
@@ -0,0 +1,43 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive     PIFont 
+// LAL (Orsay) / IN2P3-CNRS              R. Ansari  99
+
+#ifndef PIFONTGEN_H_SEEN
+#define PIFONTGEN_H_SEEN
+
+#include "pisysdep.h"
+
+enum PIFontName { PI_DefaultFont = 0, PI_CourierFont = 1, PI_HelveticaFont = 2, 
+                  PI_TimesFont = 3, PI_SymbolFont = 4};
+
+enum PIFontSize { PI_NotDefFontSize = -1, 
+                  PI_SmallSizeFont = 1, PI_NormalSizeFont = 2, 
+                  PI_BigSizeFont = 3, PI_HugeSizeFont = 4 };
+
+enum PIFontAtt { PI_NotDefFontAtt = -1,
+                 PI_RomanFont = 1, PI_BoldFont = 2, PI_ItalicFont = 4 };
+
+class PIFontGen
+{
+public:
+		PIFontGen(PIFontName fn = PI_DefaultFont);
+		PIFontGen(int npt, PIFontName fn = PI_DefaultFont, 
+                          PIFontAtt fa = PI_RomanFont);
+// PIFont doit avoir un constructeur de copie, et l'operateur egal de defini
+// ainsi que l'operateur test d'egalite
+  virtual	~PIFontGen();
+
+  virtual void		SetFont(PIFontName fn)		= 0;
+  virtual void		SetFontAtt(PIFontAtt fa)	= 0;
+  virtual void		SetFontSz(PIFontSize fs)	= 0;
+  virtual void		SetFontSzPt(int npt)		= 0;
+
+  virtual PIFontName    GetFontName()			= 0;
+  virtual PIFontAtt     GetFontAtt()			= 0;
+  virtual int		GetFontSize()			= 0;
+
+  virtual int		GetFontHeight(int& asc, int& desc)	= 0;
+  virtual int		GetStringWidth(char const* s)		= 0;
+};
+
+#endif      // PIFONTGEN_H_SEEN
Index: /tags/V_LaSilla191199/SophyaPI/PI/pifontmac.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pifontmac.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pifontmac.cc	(revision 464)
@@ -0,0 +1,185 @@
+// Module PI : Peida Interactive     PIFontMac
+// Gestion de fontes - Implementation Mac    
+// DAPNIA/SPP     E. Aubourg 1999
+
+#include <stdio.h>
+
+#include "pisysdep.h"
+#include "pifontmac.h"
+#include PIWDG_H
+
+#include "UDrawingState.h"
+
+/* --Methode-- */
+PIFontMac::PIFontMac(PIFontName fn)
+  : PIFontGen(fn)
+{
+  SelectFont(fn, PI_RomanFont, PI_NormalSizeFont);
+}
+
+/* --Methode-- */
+PIFontMac::PIFontMac(int npt, PIFontName fn, PIFontAtt fa)
+  : PIFontGen(npt, fn, fa)
+{
+  SelectFontPt(fn, fa, npt);
+}
+
+/* --Methode-- */
+PIFontMac::PIFontMac(PIFontMac const & fnt)
+  : PIFontGen(fnt.mFName)
+{
+  SelectFontPt(fnt.mFName, fnt.mFAtt, fnt.mFSize);
+}
+
+/* --Methode-- */
+PIFontMac::~PIFontMac()
+{
+}
+
+/* --Methode-- */
+PIFontMac & PIFontMac::operator = (PIFontMac const & fnt)
+{
+  SelectFontPt(fnt.mFName, fnt.mFAtt, fnt.mFSize);
+  return(*this);
+}
+
+/* --Methode-- */
+bool PIFontMac::operator == (PIFontMac const & fnt)
+{
+  if ((fnt.mFName == mFName) && (fnt.mFAtt == mFAtt) && (fnt.mFSize == mFSize)) 
+    return(true);
+  else 
+    return(false);
+}
+
+/* --Methode-- */
+void PIFontMac::SetFont(PIFontName fn)
+{
+  SelectFontPt(fn, mFAtt, mFSize);
+}
+
+/* --Methode-- */
+void PIFontMac::SetFontAtt(PIFontAtt fa)
+{
+  SelectFontPt(mFName, fa, mFSize);
+}
+
+/* --Methode-- */
+void PIFontMac::SetFontSz(PIFontSize fs)
+{
+  SelectFont(mFName, mFAtt, fs);
+}
+
+/* --Methode-- */
+void PIFontMac::SetFontSzPt(int npt)
+{
+  SelectFontPt(mFName, mFAtt, npt);
+}
+
+/* --Methode-- */
+PIFontName PIFontMac::GetFontName()
+{
+  return(mFName);
+}
+
+/* --Methode-- */
+PIFontAtt PIFontMac::GetFontAtt()
+{
+  return(mFAtt);
+}
+
+/* --Methode-- */
+int PIFontMac::GetFontSize()
+{
+  return(mFSize);
+}
+
+/* --Methode-- */
+void PIFontMac::Apply()
+{
+  ::TextFont(mFNum);
+  ::TextSize(mFSize);
+  ::TextFace(mFStyle);
+}
+
+/* --Methode-- */
+int PIFontMac::GetFontHeight(int& asc, int& desc)
+{
+  StTextState saver;
+  Apply();
+  ::FontInfo finfo;
+  GetFontInfo(&finfo);
+  asc = finfo.ascent;
+  desc = finfo.descent;
+  return(asc+desc);
+}
+
+/* --Methode-- */
+int PIFontMac::GetStringWidth(char const* s)
+{
+  StTextState saver;
+  Apply();
+  return(::TextWidth(s, 0, strlen(s)));
+}
+
+
+#define NMAXFONTSZ    7
+#define NMAXFONTATT   3
+#define NMAXFONTTYP   5
+
+/*  Variables globales pour la gestion des fontes  */
+static const int fontSizes[4] = {8,12,18,24};
+
+/* --Methode-- */
+void PIFontMac::SelectFont(PIFontName fn, PIFontAtt fa, PIFontSize fs)
+{
+  if (fs < 0 || fs >=4) fs = PI_NormalSizeFont;
+  int isz = fontSizes[fs];
+  SelectFontPt(fn, fa, isz);
+}
+
+/* --Methode-- */
+void PIFontMac::SelectFontPt(PIFontName fn, PIFontAtt fa, int npt)
+{
+  if ((fn == mFName) && (fa == mFAtt) && (npt == mFSize)) return;
+  mFName = fn;
+  mFAtt  = fa;
+  mFSize = npt;
+  
+  switch (fa) {
+    case PI_RomanFont :
+      mFStyle = 0;
+      break;
+    case PI_BoldFont :
+      mFStyle = bold;
+      break;
+    case PI_ItalicFont :
+      mFStyle = italic;
+      break;
+    default :
+      mFStyle = 0;
+      break;
+  }
+
+  switch (fn) {
+	  case PI_DefaultFont :
+	    mFNum = 0;
+	    break;
+	  case PI_CourierFont :
+	    GetFNum("\pCourier", &mFNum);
+	    break;
+	  case PI_HelveticaFont :
+	    GetFNum("\pHelvetica", &mFNum);
+	    break;
+	  case PI_TimesFont :
+	    GetFNum("\pTimes", &mFNum);
+	    break;
+	  case PI_SymbolFont :
+	    GetFNum("\pSymbol", &mFNum);
+	    break;
+	  default :
+	    mFNum = 0;
+	    break;
+  }
+}
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pifontmac.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pifontmac.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pifontmac.h	(revision 464)
@@ -0,0 +1,51 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive     PIFontMac
+// DAPNIA/SPP          E. Aubourg  99
+
+#ifndef PIFONTMAC_H_SEEN
+#define PIFONTMAC_H_SEEN
+
+#include "pisysdep.h"
+#include "pifontgen.h"
+
+
+class PIFontMac : public PIFontGen 
+{
+public :
+		PIFontMac(PIFontName fn = PI_DefaultFont);
+		PIFontMac(int npt, PIFontName fn = PI_DefaultFont, 
+                        PIFontAtt fa = PI_RomanFont);
+		PIFontMac(PIFontMac const & fnt);
+  virtual	~PIFontMac();
+
+  virtual PIFontMac & operator = (PIFontMac const & fnt);
+  virtual bool operator == (PIFontMac const & fnt);
+
+  virtual void		SetFont(PIFontName fn);
+  virtual void		SetFontAtt(PIFontAtt fa);
+  virtual void		SetFontSz(PIFontSize fs);
+  virtual void		SetFontSzPt(int npt);
+
+  virtual PIFontName    GetFontName();
+  virtual PIFontAtt     GetFontAtt();
+  virtual int		GetFontSize();
+
+  virtual int		GetFontHeight(int& asc, int& desc);
+  virtual int		GetStringWidth(char const* s);
+  
+  virtual void      Apply();
+
+protected:
+  void           SelectFont(PIFontName fn, PIFontAtt fa, PIFontSize fs);
+  void           SelectFontPt(PIFontName fn, PIFontAtt fa, int npt);
+
+  PIFontName mFName;
+  PIFontAtt  mFAtt;
+  int        mFSize;
+  short      mFNum;
+  int        mFStyle;
+};
+
+typedef PIFontMac PIFont;
+
+#endif      // PIFONTMAC_H_SEEN
Index: /tags/V_LaSilla191199/SophyaPI/PI/pifontx.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pifontx.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pifontx.cc	(revision 464)
@@ -0,0 +1,374 @@
+// Module PI : Peida Interactive     PIFontX
+// Gestion de fontes - Implementation X11    
+// LAL (Orsay) / IN2P3-CNRS     R. Ansari  97-99
+
+#include <stdio.h>
+
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+
+#include "pisysdep.h"
+#include "pifontx.h"
+#include PIWDG_H
+
+
+/* --Methode-- */
+PIFontX::PIFontX(PIFontName fn)
+  : PIFontGen(fn) , mFSize(-1) 
+{
+GlInit();
+SelectFont(fn, PI_RomanFont, PI_NormalSizeFont);
+}
+
+/* --Methode-- */
+PIFontX::PIFontX(int npt, PIFontName fn, PIFontAtt fa)
+  : PIFontGen(npt, fn, fa), mFSize(-1) 
+{
+GlInit();
+SelectFontPt(fn, fa, npt);
+}
+
+/* --Methode-- */
+PIFontX::PIFontX(PIFontX const & fnt)
+  : PIFontGen(fnt.mFName), mFSize(-1) 
+{
+GlInit();
+SelectFontPt(fnt.mFName, fnt.mFAtt, fnt.mFSize);
+}
+
+/* --Methode-- */
+PIFontX::~PIFontX()
+{
+}
+
+/* --Methode-- */
+PIFontX & PIFontX::operator = (PIFontX const & fnt)
+{
+SelectFontPt(fnt.mFName, fnt.mFAtt, fnt.mFSize);
+return(*this);
+}
+
+/* --Methode-- */
+bool PIFontX::operator == (PIFontX const & fnt)
+{
+if ((fnt.mFName == mFName) && (fnt.mFAtt == mFAtt) && (fnt.mFSize == mFSize)) 
+  return(true);
+else return(false);
+}
+
+/* --Methode-- */
+void PIFontX::SetFont(PIFontName fn)
+{
+SelectFontPt(fn, mFAtt, mFSize);
+}
+
+/* --Methode-- */
+void PIFontX::SetFontAtt(PIFontAtt fa)
+{
+SelectFontPt(mFName, fa, mFSize);
+}
+
+/* --Methode-- */
+void PIFontX::SetFontSz(PIFontSize fs)
+{
+SelectFont(mFName, mFAtt, fs);
+}
+
+/* --Methode-- */
+void PIFontX::SetFontSzPt(int npt)
+{
+SelectFontPt(mFName, mFAtt, npt);
+}
+
+/* --Methode-- */
+PIFontName PIFontX::GetFontName()
+{
+return(mFName);
+}
+
+/* --Methode-- */
+PIFontAtt PIFontX::GetFontAtt()
+{
+return(mFAtt);
+}
+
+/* --Methode-- */
+int PIFontX::GetFontSize()
+{
+return(mFSize);
+}
+
+/* --Methode-- */
+int PIFontX::GetFontHeight(int& asc, int& desc)
+{
+char a[2];
+XCharStruct  ovr;
+int hd, fa, fd;
+XTextExtents(mFSt, a, 0, &hd, &fa, &fd, &ovr);
+asc = fa; desc = fd; 
+return(fa+fd);
+}
+
+/* --Methode-- */
+int PIFontX::GetStringWidth(char const* s)
+{
+return(XTextWidth(mFSt, s, strlen(s)));
+}
+
+
+#define NMAXFONTSZ    7
+#define NMAXFONTATT   3
+#define NMAXFONTTYP   5
+
+/*  Variables globales pour la gestion des fontes  */
+static XFontStruct * fntst[NMAXFONTSZ][NMAXFONTATT][NMAXFONTTYP];
+static int fntsz[NMAXFONTSZ] = {8,10,12,14,18,24,36};
+static int SmallFontIndex = 1; 
+static int NormalFontIndex = 3;
+static int BigFontIndex = 5;
+static int HugeFontIndex = 6;
+static  PIFontAtt fntatt[NMAXFONTATT] = { PI_RomanFont, PI_BoldFont, PI_ItalicFont };
+static  PIFontName fntname[NMAXFONTTYP] = { PI_DefaultFont, PI_CourierFont, PI_HelveticaFont, 
+                                            PI_TimesFont, PI_SymbolFont};  
+static XFontStruct * defnt = NULL;
+
+/* --Methode-- */
+void PIFontX::SelectFont(PIFontName fn, PIFontAtt fa, PIFontSize fs)
+{
+int isz;
+switch (fs) {
+  case PI_SmallSizeFont:
+    isz = fntsz[SmallFontIndex];
+    break;
+  case PI_NormalSizeFont:
+    isz = fntsz[NormalFontIndex];
+    break;
+  case PI_BigSizeFont:
+    isz = fntsz[BigFontIndex];
+    break;
+  case PI_HugeSizeFont:
+    isz = fntsz[HugeFontIndex];
+    break;
+  default:
+    isz = fntsz[NormalFontIndex];
+    break;
+  }
+
+SelectFontPt(fn, fa, isz);
+return;
+}
+
+/* --Methode-- */
+void PIFontX::SelectFontPt(PIFontName fn, PIFontAtt fa, int npt)
+{
+if ( (mFSize > 0) && (fn == mFName) && (fa == mFAtt) && (npt == mFSize) )   return;
+int dsz,i,isel, j, k;
+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; }
+  }
+i = isel;
+j = 0;
+switch (fa) {
+  case PI_RomanFont :
+    j = 0;
+    break;
+  case PI_BoldFont :
+    j = 1;
+    break;
+  case PI_ItalicFont :
+    j = 2;
+    break;
+  default :
+    j = 0;
+    break;
+  }
+
+k = 0;
+switch (fn)
+ {
+  case PI_DefaultFont :
+    k = 0;
+    break;
+  case PI_CourierFont :
+    k = 1;
+    break;
+  case PI_HelveticaFont :
+    k = 2;
+    break;
+  case PI_TimesFont :
+    k = 3;
+    break;
+  case PI_SymbolFont :
+    k = 4;
+    break;
+  default :
+    k = 0;
+    break;
+  }
+LoadFontSt(i, j, k);
+return;
+}
+
+
+// Le bazar pour recuperer des resources de .Xdefault et autres 
+typedef struct 
+  {
+  String fntFam[5];
+  } myAppData;
+static myAppData  apd;
+
+static XtResource resources[] = {
+  { "fontFamilyName", "FontFamilyName", XtRString, sizeof(String),
+    /*XtOffset(apd, fntFam[0])*/ 0, XtRString, "*-courier" } ,
+  { "courierfontFamilyName", "CourierfontFamilyName", XtRString, sizeof(String),
+    sizeof(String) , XtRString, "*-courier" } ,
+  { "helveticafontFamilyName", "HelveticafontFamilyName", XtRString, sizeof(String),
+    2*sizeof(String) , XtRString, "*-helvetica" } ,
+  { "timesfontFamilyName", "TimesfontFamilyName", XtRString, sizeof(String),
+    3*sizeof(String) , XtRString, "*-times" } ,
+  { "symbolfontFamilyName", "SymbolfontFamilyName", XtRString, sizeof(String),
+    4*sizeof(String) , XtRString, "*-symbol" }
+};
+ 
+static char * fnbi_b[4] = { "medium-r-normal", "bold-r-normal", 
+                          "medium-o-normal", "medium-i-normal" };
+
+static char * fnbi[3];
+
+/* --Methode-- */
+void PIFontX::LoadFontSt(int isz, int jat, int kfn)
+{
+
+if (!fntst[isz][jat][kfn])  // Il faut charger la fonte
+  {
+  char buff[256];
+  int count,k;
+  Display * mdsp = PIXDisplay();
+  char **list;
+
+  for (k=0; k<5; k++)  {  // Recherche de la fonte pour tailles croissantes
+    sprintf(buff,"-%s-%s-*-%d-*-*-*-*-*-*-*", apd.fntFam[kfn], fnbi[jat], fntsz[isz]+k);
+    list = XListFonts(mdsp, buff, 10, &count);
+    XFreeFontNames(list);
+    if (count > 0)  break;
+    }
+  // certaines fontes n'ont pas de version  bold ou italique
+  if ( (count == 0) && (jat > 0) ) {
+    for (k=0; k<5; k++)  {  // Recherche de la fonte pour tailles croissantes
+      sprintf(buff,"-%s-%s-*-%d-*-*-*-*-*-*-*", apd.fntFam[kfn], fnbi[0], fntsz[isz]+k);
+      list = XListFonts(mdsp, buff, 10, &count);
+      XFreeFontNames(list);
+      if (count > 0)  break;
+      }
+    }
+  if (count > 0) 
+    fntst[isz][jat][kfn] = XLoadQueryFont(mdsp, buff);
+  else
+    { printf("PIFontX::LoadFontSt/ Pb font %s - Using default \n", buff);    
+    fntst[isz][jat][kfn] = defnt; }
+  }
+
+mFAtt = fntatt[jat];
+mFSize = fntsz[isz];
+mFName = fntname[kfn];
+mFSt = fntst[isz][jat][kfn];
+return;
+}
+
+
+static bool fgfntinitdone = false ;   // Flag init done
+/* --Methode-- */
+void PIFontX::GlInit()
+{
+if (fgfntinitdone) return;
+fgfntinitdone = true;
+
+Display * mdsp = PIXDisplay();
+
+char buff[256];
+int i,j,k,count;
+char **list;
+
+
+XtGetApplicationResources(PIXtTopWdg(), &apd, resources, 
+                          XtNumber(resources), NULL, 0);
+sprintf(buff,"-%s-*-*-*-*-*-*-*-*-*-*-*-*", apd.fntFam[0]);
+list = XListFonts(mdsp, buff, 15, &count);
+XFreeFontNames(list);
+if (count < 5)
+  { 
+  printf("PIFontX::Init %d fonts found for %s , switching to courier\n",
+         count, apd.fntFam[0]);
+  apd.fntFam[0] = "*-courier";
+  }
+sprintf(buff,"-%s-%s-*-*-*-*-*-*-*-*-*", apd.fntFam[0], fnbi_b[0]);
+list = XListFonts(mdsp, buff, 10, &count);
+XFreeFontNames(list);
+if (count < 2) fnbi[0] = "*-*-*";
+else  fnbi[0] = fnbi_b[0];
+sprintf(buff,"-%s-%s-*-*-*-*-*-*-*-*-*", apd.fntFam[0], fnbi_b[1]);
+list = XListFonts(mdsp, buff, 10, &count);
+XFreeFontNames(list);
+if (count < 2) fnbi[1] = "*-*-*";
+else  fnbi[1] = fnbi_b[1];
+sprintf(buff,"-%s-%s-*-*-*-*-*-*-*-*-*", apd.fntFam[0], fnbi_b[2]);
+list = XListFonts(mdsp, buff, 10, &count);
+XFreeFontNames(list);
+fnbi[2] = fnbi_b[2];
+if (count < 2) 
+  {
+  sprintf(buff,"-%s-%s-*-*-*-*-*-*-*-*-*", apd.fntFam[0], fnbi_b[3]);
+  list = XListFonts(mdsp, buff, 10, &count);
+  XFreeFontNames(list);
+  fnbi[2] = fnbi_b[3];
+  }
+if (count < 2) fnbi[2] = "*-*-*";
+
+sprintf(buff,"-*-fixed-*-*-*-*-12-*-*-*-*-*-*-*");
+list = XListFonts(mdsp, buff, 10, &count);
+XFreeFontNames(list);
+if (count < 1) 
+  {  
+  sprintf(buff,"fixed");
+  list = XListFonts(mdsp, buff, 10, &count);
+  XFreeFontNames(list);
+  }
+if (count < 1) 
+  {  
+  strcpy(buff,"");
+  list = XListFonts(mdsp, buff, 10, &count);
+  XFreeFontNames(list);
+  printf("PIFontX::Init/ Erreur, no font found ... \n");
+  defnt = NULL;
+  }
+else defnt = XLoadQueryFont(mdsp, buff);
+
+for (i=0; i<NMAXFONTSZ; i++)
+  for (j=0; j<NMAXFONTATT; j++)  
+    for (k=0; k<NMAXFONTTYP; k++)  fntst[i][j][k] = NULL;
+
+// Choix des trois tailles de fontes standard en fonction de 
+// la taille de fonte par defaut des composantes standard
+int szx, szy, szf;
+PIXtAppCtx(szx, szy, szf);
+int kkk, kkj, kksel, kkdsz = 9999;  
+kksel = NMAXFONTSZ/2;
+for(kkk=NMAXFONTSZ-1; kkk>=0; kkk--) {
+  kkj = szf - fntsz[kkk];   if (kkj < 0)  kkj = -kkj;
+  if (kkj < kkdsz)  {  kksel = kkk;  kkdsz = kkj; }
+  }
+if (kksel == NMAXFONTSZ-1)  kksel = NMAXFONTSZ-2;
+NormalFontIndex = kksel;
+SmallFontIndex = (kksel > 1) ? kksel-2 : 0 ;
+BigFontIndex =  (kksel < NMAXFONTSZ-2) ? kksel+2 :  NMAXFONTSZ-1;
+HugeFontIndex = NMAXFONTSZ-1;
+
+// printf("PIFontX::Init()-DBG- FontIndex= %d %d %d (SzF=%d) \n", 
+//       SmallFontIndex, NormalFontIndex, BigFontIndex, szf);
+
+return;
+}
Index: /tags/V_LaSilla191199/SophyaPI/PI/pifontx.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pifontx.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pifontx.h	(revision 464)
@@ -0,0 +1,54 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive     PIFontX
+// LAL (Orsay) / IN2P3-CNRS          R. Ansari  99
+
+
+#ifndef PIFONTX_H_SEEN
+#define PIFONTX_H_SEEN
+
+#include "pisysdep.h"
+#include "pifontgen.h"
+
+
+class PIFontX : public PIFontGen 
+{
+public :
+		PIFontX(PIFontName fn = PI_DefaultFont);
+		PIFontX(int npt, PIFontName fn = PI_DefaultFont, 
+                        PIFontAtt fa = PI_RomanFont);
+		PIFontX(PIFontX const & fnt);
+  virtual	~PIFontX();
+
+  virtual PIFontX & operator = (PIFontX const & fnt);
+  virtual bool operator == (PIFontX const & fnt);
+
+  virtual void		SetFont(PIFontName fn);
+  virtual void		SetFontAtt(PIFontAtt fa);
+  virtual void		SetFontSz(PIFontSize fs);
+  virtual void		SetFontSzPt(int npt);
+
+  virtual PIFontName    GetFontName();
+  virtual PIFontAtt     GetFontAtt();
+  virtual int		GetFontSize();
+
+  virtual int		GetFontHeight(int& asc, int& desc);
+  virtual int		GetStringWidth(char const* s);
+
+// En public pour PIGraphicX
+  inline Font		GetXFontId() { return(mFSt->fid); }
+
+protected:
+  void           SelectFont(PIFontName fn, PIFontAtt fa, PIFontSize fs);
+  void           SelectFontPt(PIFontName fn, PIFontAtt fa, int npt);
+  void           LoadFontSt(int isz, int jat, int kfn);
+  static void    GlInit();
+
+  PIFontName mFName;
+  PIFontAtt mFAtt;
+  int mFSize;
+  XFontStruct *mFSt;
+};
+
+typedef PIFontX PIFont;
+
+#endif      // PIFONTX_H_SEEN
Index: /tags/V_LaSilla191199/SophyaPI/PI/pigfname.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pigfname.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pigfname.h	(revision 464)
@@ -0,0 +1,12 @@
+#ifndef PIGFNAME_H_SEEN
+#define PIGFNAME_H_SEEN
+
+#include "machdefs.h"
+#include <string>
+
+string PIGetFileName(string = "");
+string PIGetExistingFileName(string = "");
+
+
+#endif
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pigraph3d.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pigraph3d.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pigraph3d.cc	(revision 464)
@@ -0,0 +1,491 @@
+// Module PI : Peida Interactive     PIGraphic3D
+// Trace graphiques 3D               R. Ansari  06/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include <stdio.h>
+#include <math.h>
+#include "pigraph3d.h"
+
+#ifndef M_PI_2
+#define M_PI_2 (M_PI/2)
+#endif
+
+//++
+// Class	PIGraphic3D
+// Lib		PI
+// include	pigraph3d.h
+//
+//   	Classe fournissant les services de tracé graphique 
+//	en coordonnées utilisateur, et quelques primitives de tracé 3D
+//--
+//++
+// Links	Parent
+// PIGraphicUC
+//--
+
+//++
+// Titre	Constructeurs, méthodes
+//--
+//++
+// PIGraphic3D(PIGraphicGen* g, PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+//	Constructeur d'un objet "PIGraph3D" à partir d'un "PIGraphic* g". L'espace
+//	de travail du nouvel objet "PIGraphic" correspond au rectangle défini par
+//	"(x0,y0)" , "dx,dy" du "PIGraphic" de départ.
+// 
+// int  kind()
+//	Renvoie le type ("= PI_3DGraphics")
+//--
+
+/* --Methode-- */
+PIGraphic3D::PIGraphic3D(PIGraphicGen* g, PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+        : PIGraphicUC(g, x0, y0, dx, dy)
+{
+  int i,j;
+  for(i=0; i<3; i++) 
+    for(j=0; j<3; j++)  RE[i][j] = 0.;
+  RE[0][0] = RE[1][1] = RE[2][2] = 1.;
+  xO = yC = 0.; zO = -10.;
+  xC = yC = zC = 0.;
+  tO = fO = pO = 0.; 
+  daxO = dayO = 0.25;
+  lCO = 10.;  dlCO = 0.2;  
+  sO = false;
+}
+
+/* --Methode-- */
+PIGraphic3D::~PIGraphic3D()
+{
+}
+
+/* --Methode-- */
+int PIGraphic3D::kind() 
+{
+  return PI_3DGraphics; 
+}
+
+//++
+// Titre	Système de coordonnées 3D et projection
+//	Le système de coordonnées 3D est défini par la position de l'observateur (caméra),
+//	la direction de visée ou la position du centre du champ, 
+//	l'ouverture angulaire de la caméra selon les deux 
+//	axes de la projection (X,Y), eventuellement un angle correspondant à la rotation
+//	du plan image ("psi"). Les angles d'Euler ("teta", "phi", "psi" ) sont utilisés
+//	dans la définition du système de coordonnées et la projection est de type 
+//	perspective. 
+//
+//	Les coordonnées utilisateur définissant le plan image ("PIGraphicUC") vont de 
+//	X: "-dax , +dax"   Y : "-day , +day".  
+//--
+
+//++
+// void  Set3DCS_Obs(double xo, double yo, double zo, double teta, double phi, double psi, -
+//                  double dax, double day, double co, double dco=0.2)
+//	Définition du système de projection 3D à l'aide de la position de l'observateur 
+//	et de la direction de visée.
+//|	xo,yo,zo : Position de l'observateur (camera)
+//|	teta,phi : Direction de visee
+//|	psi : rotation du plan image
+//|	dax , day : Ouverture du plan image selon les deux axes = Xmax,Ymax / Z
+//|	co : distance au centre du champ
+//|	dco : profondeur de champ 
+//
+// void  Set3DCS(double xc, double yc, double zc, double xo, double yo, double zo, -
+//               double dax, double day, double dco=0.2, double psi=0.)
+//	Définition du système de projection 3D à partir de la position de l'observateur et 
+//	du centre du champ.
+//|	xc,yc,zc : Position du centre du champ
+//|	xo,yo,zo : Position de l'observateur (camera)
+//|	dax , day : Ouverture du plan image selon les deux axes = Xmax,Ymax / Z
+//|	dco : profondeur de champ 
+//|	psi : rotation du plan image
+//--
+
+#if defined(__KCC__) 
+#ifndef M_PI
+#define M_PI            3.14159265358979323846  /* pi */
+#endif
+#ifndef M_PI_2
+#define M_PI_2          1.57079632679489661923  /* pi/2 */
+#endif
+#endif
+
+static double deuxpi = 2*M_PI;
+
+/* --Methode-- */
+void PIGraphic3D::Set3DCS_Obs(double xo, double yo, double zo, double teta, double phi, double psi, 
+                              double dax, double day, double co, double dco)
+{
+  sO = true;
+  xO = xo;  yO = yo;  zO = zo;
+  while (teta < 0.)  teta += deuxpi;
+  while (teta > deuxpi)  teta -= deuxpi;
+  if (teta > M_PI)  { teta = M_PI-teta;  phi = phi+M_PI; }
+  while (phi < 0.)  phi += deuxpi;
+  while (phi > deuxpi) phi -= deuxpi;
+  tO = teta;  fO = phi;  pO = psi;
+  if (dax < 0.) dax = -dax;
+  if (day < 0.) day = -day;
+  daxO = dax;  dayO = day;
+  lCO = co;   dlCO = dco;
+// Si on ne met  kAxeDirLtoR, le repere semble etre ds le sens inverse -> kAxeDirRtoL  , Reza 16/10/98
+  SetUCS(-dax, dax, -day, day, kAxeDirRtoL, kAxeDirDownUp);
+  double ct = cos((double)tO);
+  double st = sin((double)tO);
+// (Teta,Phi) = Direction de visee 
+// Les angles d'Euler correspondants sont Teta, Phi+Pi/2
+// Le Pi/2 vient que les rotations d'euler se font dans l'ordre
+//  Autour de oZ d'angle Phi, autour de oN (nouvel axe X) d'angle Teta
+//  Autour du nouvel axe Z (x3) d'angle Psi
+  double cf = cos((double)fO+M_PI_2);
+  double sf = sin((double)fO+M_PI_2);
+  double cp = cos((double)pO);
+  double sp = sin((double)pO);
+  RE[0][0] = cf*cp-sf*ct*sp;     RE[0][1] = sf*cp+cf*ct*sp;      RE[0][2] = st*sp;
+  RE[1][0] = -cf*sp-sf*ct*cp;    RE[1][1] = -sf*sp+cf*ct*cp;     RE[1][2] = st*cp;
+  RE[2][0] = sf*st;              RE[2][1] = -cf*st;              RE[2][2] = ct;
+  cf = cos((double)fO);
+  sf = sin((double)fO);
+  zC = ct*lCO+zO;
+  xC = st*cf*lCO+xO;
+  yC = st*sf*lCO+yO;
+}
+
+/* --Methode-- */
+void PIGraphic3D::Set3DCS(double xc, double yc, double zc, double xo, double yo, double zo, 
+                          double dax, double day, double dco, double psi)
+{
+  sO = false;
+  xO = xo;  yO = yo;  zO = zo;
+  xC = xc;  yC = yc;  zC = zc;
+  double dx,dy,dz;
+// On calcule le vecteur  OC  Observateur -> Centre du champ, ca nous donne donc teta,phi de visee
+  dx = xc-xo;  dy = yc-yo;  dz = zc-zo;
+  if (dax < 0.) dax = -dax;
+  if (day < 0.) day = -day;
+  daxO = dax;  dayO = day;  
+// Si on ne met  kAxeDirLtoR, le repere semble etre ds le sens inverse -> kAxeDirRtoL  , Reza 16/10/98
+  SetUCS(-dax, dax, -day, day, kAxeDirRtoL, kAxeDirDownUp);
+  lCO = sqrt(dx*dx+dy*dy+dz*dz);
+  if (lCO < 1.e-6) {
+    printf("PIGraphic3D::Set3DCS()/Warning : Length(CO) = %g -> CS par defaut \n", lCO);
+    int i,j;
+    for(i=0; i<3; i++) 
+      for(j=0; j<3; j++)  RE[i][j] = 0.;
+    RE[0][0] = RE[1][1] = RE[2][2] = 1.;
+    xO = yC = 0.; zO = -10.;
+    xC = yC = zC = 0.;
+    tO = fO = pO = 0.; 
+    daxO = dayO = 0.25;
+    lCO = 10.;  dlCO = 0.2;      
+    return;
+  }
+  dlCO = dco;
+  double lxy = sqrt(dx*dx+dy*dy);
+  double ct,st,cf,sf;
+  ct = dz/lCO;
+  st = sqrt(1-ct*ct);
+  pO = psi;
+  tO = acos(ct);
+  if (lxy < 1.e-6) { fO = 0.;  cf = 0.;  }
+  else {  cf = dx/lxy;  fO = acos(cf);  if (dy < 0.)  fO = deuxpi-fO;   }
+// (Teta,Phi) = Direction de visee 
+// Les angles d'Euler correspondants sont Teta, Phi+Pi/2
+// Le Pi/2 vient que les rotations d'euler se font dans l'ordre
+//  Autour de oZ d'angle Phi, autour de oN (nouvel axe X) d'angle Teta
+//  Autour du nouvel axe Z (x3) d'angle Psi
+  cf = cos((double)fO+M_PI_2);
+  sf = sin((double)fO+M_PI_2);
+  double cp = cos((double)psi);
+  double sp = sin((double)psi);
+  RE[0][0] = cf*cp-sf*ct*sp;     RE[0][1] = sf*cp+cf*ct*sp;      RE[0][2] = st*sp;
+  RE[1][0] = -cf*sp-sf*ct*cp;    RE[1][1] = -sf*sp+cf*ct*cp;     RE[1][2] = st*cp;
+  RE[2][0] = sf*st;              RE[2][1] = -cf*st;              RE[2][2] = ct;
+}
+
+//++
+// bool Get3DCS(double& xc, double& yc, double& zc, double& xo, double& yo, double& zo, -
+//             double& teta, double& phi, double& psi, double& dax, double& day, double& co, double& dco);
+//	Renvoie les paramètres de définition du système de projection 3D.
+//	"Rc= true" si défini par  "Set3DCS_Obs()"
+//	
+// void  RotateObserver(double teta, double phi, double psi=0., bool rel=true)
+//	Positionne l'observateur (la caméra) en maintenant la position  
+//	du centre de champ fixe. Si "rel=false" : "teta, phi" determine la nouvelle
+//	direction de visée. Si "rel=false" : la direction de visée est tournée
+//	de l'angle "teta,phi". 
+// void  RotateObject(double teta, double phi, bool rel=true)
+//	Repostionne le centre du champ en maintenant la position de l'observateur fixe.
+//	Si "rel=false" : "teta, phi" determine la nouvelle direction de visée.
+//	Si "rel=false" : la direction de visée est tournée de l'angle "teta,phi". 
+// 
+// void  ZoomInOut(double fco, double fdax, double fday, bool rel=true)
+//	Eloigne ou approche l'observateur et modifie l'ouverture du plan image.
+//	si "real=true" : "fco, fdax, fday" sont des facteurs multiplicatifs
+//	par rapport aux valeurs actuelles, sinon des valeurs absolues. 
+//|	fco : distance observateur - centre du champ
+//|	fdax, fday : ouverture du plan image
+//--
+
+/* --Methode-- */
+bool PIGraphic3D::Get3DCS(double& xc, double& yc, double& zc, double& xo, double& yo, double& zo, 
+                          double& teta, double& phi, double& psi, double& dax, double& day, double& co, double& dco)
+{
+  xc = xC;  yc = yC;  zc = zC;
+  xo = xO;  yo = yO;  zo = zO;
+  teta = tO;  phi = fO;  psi = pO;
+  dax = daxO;   day = dayO;
+  co = lCO;     dco = dlCO;
+  return(sO);
+}
+
+
+/* --Methode-- */
+void PIGraphic3D::RotateObserver(double teta, double phi, double psi, bool rel)
+// Positionne l'observateur (la camera) de maniere a ce que la direction de 
+// visee soit tO=teta, pO=phi (rel=false) / tO+=teta pO+=phi (rel=true) 
+// en conservant le centre de champ fixe  
+{
+  if (rel) {
+    teta += tO;
+    phi += fO;
+    psi += pO;
+    }
+  while (teta < 0.)  teta += deuxpi;
+  while (teta > deuxpi)  teta -= deuxpi;
+  if (teta > M_PI)  { teta = M_PI-teta;  phi = phi+M_PI; }
+  double xo,yo,zo; 
+  zo = -cos((double)teta)*lCO+zC;
+  xo = -sin((double)teta)*cos((double)phi)*lCO+xC;
+  yo = -sin((double)teta)*sin((double)phi)*lCO+yC;
+  Set3DCS(xC,yC,zC, xo,yo,zo, daxO, dayO, dlCO, psi);
+}
+
+/* --Methode-- */
+void PIGraphic3D::RotateObject(double teta, double phi, bool rel)
+// Positionne l'objet (centre du champ) de maniere a ce que la direction de 
+// visee soit tO=teta, pO=phi (rel=false) / tO+=teta pO+=phi (rel=true) 
+// en conservant la position de l'observateur fixe.  
+{
+  if (rel) {
+    teta += tO;
+    phi += fO;
+    }
+  while (teta < 0.)  teta += deuxpi;
+  while (teta > deuxpi)  teta -= deuxpi;
+  if (teta > M_PI)  { teta = M_PI-teta;  phi = phi+M_PI; }
+  double xc,yc,zc; 
+  zc = cos((double)teta)*lCO+zO;
+  xc = sin((double)teta)*cos((double)phi)*lCO+xO;
+  yc = sin((double)teta)*sin((double)phi)*lCO+yO;
+  Set3DCS(xc,yc,zc, xO,yO,zO, daxO, dayO, dlCO, pO);
+}
+
+/* --Methode-- */
+void PIGraphic3D::ZoomInOut(double fco, double fdax, double fday, bool rel)
+{
+  if (fco < 0.001) fco = 1.;
+  if (fdax < 0.001) fdax = 1.;
+  if (fday < 0.001) fday = 1.;
+  double dl;
+  if (rel) {
+    dl = fco*lCO;  
+    fdax *= daxO;
+    fday *= dayO;
+  }
+  else dl = fco; 
+  double xo,yo,zo; 
+  if (dl < 1.e-5) dl = 1.e-5;
+  zo = zC-cos((double)tO)*dl;
+  xo = xC-sin((double)tO)*cos((double)fO)*dl;
+  yo = yC-sin((double)tO)*sin((double)fO)*dl;
+  Set3DCS(xC,yC,zC, xo,yo,zo, fdax, fday, dlCO, pO);
+//  Set3DCS_Obs(xo, yo, zo, tO, fO, pO, daxO*fda, dayO*fda, dl, dlCO);
+}
+
+/* --Methode-- */
+void PIGraphic3D::C3DC2ObsCS(double x, double y, double z, double& xp, double& yp, double& zp)
+{
+  double xc, yc, zc;
+  xc = x-xO;   yc = y-yO;    zc = z-zO;
+  xp = RE[0][0]*xc+RE[0][1]*yc+RE[0][2]*zc;
+  yp = -RE[1][0]*xc+RE[1][1]*yc+RE[1][2]*zc;  
+  zp = RE[2][0]*xc+RE[2][1]*yc+RE[2][2]*zc;
+}
+
+/* --Methode-- */
+void PIGraphic3D::Proj3DC2GrC(double x, double y, double z, double& xpix, double& ypix)
+{
+  double xc, yc, zc;
+  double xp, yp, zp;
+  xc = x-xO;   yc = y-yO;    zc = z-zO;
+  xp = RE[0][0]*xc+RE[0][1]*yc+RE[0][2]*zc;   
+  yp = RE[1][0]*xc+RE[1][1]*yc+RE[1][2]*zc;
+  zp = RE[2][0]*xc+RE[2][1]*yc+RE[2][2]*zc;
+  if ((zp>-1.e-6) && (zp < 1.e-6))   // Protection Divide/0
+    { xpix = ypix = 0.;   return; }
+  xpix = (double)(xOrg + (xp/zp)*xScale);
+  ypix = (double)(yOrg + (yp/zp)*yScale);
+//  printf("-DBG-Proj3DC2GrC() %g %g %g -> %g %g %g -> %g %g %g -> (%g %g)\n", x,y,z,xc,yc,zc,xp,yp,zp,xp/zp,yp/zp);
+//  printf("-DBG- ... (%g %g %g - %g %g) %g %g - %g %g -> %g %g \n", xO,yO,zO, tO,fO, xOrg, yOrg,xScale,yScale ,xpix,ypix);
+}
+
+//++
+// Titre	Primitives de tracé 3D
+//--
+//++
+// void  DrawString3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0, char* s)
+//	Tracé de chaîne de caractères à la position "(x0,y0,z0)"
+// void  DrawOpaqueString3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0, char* s)
+//	Tracé de chaîne opaque à la position "(x0,y0,z0)"
+// void  DrawLine3D(PIGrCoord x1, PIGrCoord y1, PIGrCoord z1, -
+//                  PIGrCoord x2, PIGrCoord y2, PIGrCoord z2)
+//	Tracé d'une ligne entre les deux points "(x1,y1,z1)" et "(x2,y2,z2)"
+// void  DrawPolygon3D(PIGrCoord *x, PIGrCoord *y, PIGrCoord *z, int n)
+//	Tracé de contour de polygone - sommets définis par le tableau 
+//	"(x[i],y[i],z[i])" , "i=0..n-1"
+// void  DrawFPolygon3D(PIGrCoord *x, PIGrCoord *y, PIGrCoord *z, int n)
+//	Tracé de polygone - "(x[i],y[i],z[i])" , "i=0..n-1"
+// void  DrawMarker3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0)
+//	Tracé d'un signe (marker) au point "(x0,y0,z0)"
+// void  DrawMarkers3D(PIGrCoord *x, PIGrCoord *y, PIGrCoord *z, int n)
+//	Tracé de signes (marker) aux points "(x[i],y[i],z[i])" , "i=0..n-1"
+//--
+
+/* --Methode-- */
+void PIGraphic3D::DrawString3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0, const char* s)
+{
+  if (!mGrC) return;
+  double xf, yf;
+  Proj3DC2GrC(x0, y0, z0, xf, yf);
+  mGrC->DrawString(xf, yf, s);
+  return;
+}
+
+/* --Methode-- */
+void PIGraphic3D::DrawOpaqueString3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0, const char* s)
+{
+  if (!mGrC) return;
+  double xf, yf;
+  Proj3DC2GrC(x0, y0, z0, xf, yf);
+  mGrC->DrawOpaqueString(xf, yf, s);
+  return;
+}
+
+/* --Methode-- */
+void PIGraphic3D::DrawLine3D(PIGrCoord x1, PIGrCoord y1, PIGrCoord z1, 
+                             PIGrCoord x2, PIGrCoord y2, PIGrCoord z2)
+{
+  if (!mGrC) return;
+  double xf1, yf1, xf2, yf2;
+  Proj3DC2GrC(x1, y1, z1, xf1, yf1);
+  Proj3DC2GrC(x2, y2, z2, xf2, yf2);
+//  printf("-DBG-DrawLine3D() : %g %g %g -> %g %g | %g %g %g -> %g %g\n", 
+//         (double)x1, (double)y1, (double)z1, xf1, yf1, 
+//         (double)x2, (double)y2, (double)z2, xf2, yf2 );
+  mGrC->DrawLine(xf1, yf1, xf2, yf2);
+}
+
+#define NMXMULTP  30   // Pour multipoint sans new
+
+/* --Methode-- */
+void PIGraphic3D::DrawPolygon3D(PIGrCoord *x, PIGrCoord *y, PIGrCoord *z, int n)
+{
+  PIGrCoord xc[NMXMULTP], yc[NMXMULTP];
+  PIGrCoord *pxc, *pyc;
+  int i;
+  double xf, yf;
+ 
+  if (!mGrC) return;
+  if (n <= 0)  return;
+
+  if (n > NMXMULTP) { pxc = new PIGrCoord[n];  pyc = new PIGrCoord[n];  }
+  else { pxc = xc;  pyc = yc; }
+  for(i=0; i<n; i++) {
+    Proj3DC2GrC(x[i], y[i], z[i], xf, yf);
+    pxc[i] = xf;  pyc[i] = yf; 
+  }
+  mGrC->DrawPolygon(pxc, pyc, n, false);
+  if (n > NMXMULTP) { delete[] pxc;  delete[] pyc; }
+  return;
+}
+
+
+/* --Methode-- */
+void PIGraphic3D::DrawFPolygon3D(PIGrCoord *x, PIGrCoord *y, PIGrCoord *z, int n)
+{
+  PIGrCoord xc[NMXMULTP], yc[NMXMULTP];
+  PIGrCoord *pxc, *pyc;
+  int i;
+  double xf, yf;
+ 
+  if (!mGrC) return;
+  if (n <= 0)  return;
+
+  if (n > NMXMULTP) { pxc = new PIGrCoord[n];  pyc = new PIGrCoord[n];  }
+  else { pxc = xc;  pyc = yc; }
+  for(i=0; i<n; i++) {
+    Proj3DC2GrC(x[i], y[i], z[i], xf, yf);
+    pxc[i] = xf;  pyc[i] = yf; 
+  }
+  mGrC->DrawFPolygon(pxc, pyc, n, false);
+  if (n > NMXMULTP) { delete[] pxc;  delete[] pyc; }
+  return;
+}
+
+/* --Methode-- */
+void PIGraphic3D::DrawMarker3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0)
+{
+  if (!mGrC) return;
+  double xf, yf;
+  Proj3DC2GrC(x0, y0, z0, xf, yf);
+  mGrC->DrawMarker(xf, yf);
+  return;
+}
+
+/* --Methode-- */
+void PIGraphic3D::DrawMarkers3D(PIGrCoord *x, PIGrCoord *y, PIGrCoord *z, int n)
+{
+  PIGrCoord xc[NMXMULTP], yc[NMXMULTP];
+  PIGrCoord *pxc, *pyc;
+  int i;
+  double xf, yf;
+ 
+  if (!mGrC) return;
+  if (n <= 0)  return;
+
+  if (n > NMXMULTP) { pxc = new PIGrCoord[n];  pyc = new PIGrCoord[n]; }
+  else { pxc = xc;  pyc = yc; }
+  for(i=0; i<n; i++) {
+    Proj3DC2GrC(x[i], y[i], z[i], xf, yf);
+    pxc[i] = xf;  pyc[i] = yf; 
+  }
+  mGrC->DrawMarkers(pxc, pyc, n);
+  if (n > NMXMULTP) { delete[] pxc;  delete[] pyc; }
+  return;
+}
+
+
+//  Methode pour debugger 
+/* --Methode-- */
+void PIGraphic3D::PrintCS()
+{
+if (sO)  printf("PIGraphic3D::PrintCS() : Set3DCS_Obs(...) \n");
+else  printf("PIGraphic3D::PrintCS() : Set3DCS(...) \n");
+printf("C: %g %g %g ->O: %g %g %g - T,P= %g %g %g lCO= %g %g  |  %g %g - %g %g \n", 
+        xC,yC,zC, xO, yO, zO, tO, fO, pO, lCO, dlCO, xOrg, xScale, yOrg, yScale ); 
+printf("RE[3][3]=  %g %g %g | %g %g %g | %g %g %g\n", 
+        RE[0][0], RE[0][1], RE[0][2], RE[1][0], RE[1][1], RE[1][2], RE[2][0], RE[2][1], RE[2][2]); 
+double x,y,z,xp,yp,zp, xpix, ypix;
+x = xC, y = yC, z= zC;
+C3DC2ObsCS(x, y, z, xp, yp, zp);
+Proj3DC2GrC(x, y, z, xpix, ypix);
+printf("C -> %g %g %g -> %g %g \n", xp, yp, zp, xpix, ypix); 
+x = xC+1, y = yC, z= zC;
+C3DC2ObsCS(x, y, z, xp, yp, zp);
+Proj3DC2GrC(x, y, z, xpix, ypix);
+printf("C+(1,0,0) -> %g %g %g -> %g %g ", xp, yp, zp, xpix, ypix); 
+x = xC, y = yC+1, z= zC+1;
+C3DC2ObsCS(x, y, z, xp, yp, zp);
+Proj3DC2GrC(x, y, z, xpix, ypix);
+printf("C+(0,1,1) -> %g %g %g -> %g %g \n", xp, yp, zp, xpix, ypix); 
+}
Index: /tags/V_LaSilla191199/SophyaPI/PI/pigraph3d.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pigraph3d.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pigraph3d.h	(revision 464)
@@ -0,0 +1,56 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive     PIGraphic3D
+// Trace graphiques 3D               R. Ansari  06/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIGRAPHIC3D_H_SEEN
+#define PIGRAPHIC3D_H_SEEN
+
+#include "pisysdep.h"
+#include "pigraphuc.h"
+
+
+class PIGraphic3D : public PIGraphicUC 
+{
+public:
+                     PIGraphic3D(PIGraphicGen* g, PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual           ~PIGraphic3D();
+
+  virtual int        kind();
+
+//  Definition du systeme de projection 3D-2D
+  virtual void       Set3DCS_Obs(double xo, double yo, double zo, double teta, double phi, double psi, 
+                                 double dax, double day, double co, double dco=0.2);
+  virtual void       Set3DCS(double xc, double yc, double zc, double xo, double yo, double zo, 
+                             double dax, double day, double dco=0.2, double psi=0.);
+  virtual bool       Get3DCS(double& xc, double& yc, double& zc, double& xo, double& yo, double& zo,  
+                             double& teta, double& phi, double& psi, double& dax, double& day, double& co, double& dco);
+
+  virtual void       PrintCS();  // Pour debugger
+  virtual void       RotateObserver(double teta, double phi, double psi=0., bool rel=true);
+  virtual void       RotateObject(double teta, double phi, bool rel=true);
+  virtual void       ZoomInOut(double fco, double fdax, double fday, bool rel=true);
+
+  virtual void       C3DC2ObsCS(double x, double y, double z, double& xp, double& yp, double& zp);
+  virtual void       Proj3DC2GrC(double x, double y, double z, double& xpix, double& ypix);
+  
+  virtual void       DrawString3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0, const char* s);
+  virtual void       DrawOpaqueString3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0, const char* s);
+  virtual void       DrawLine3D(PIGrCoord x1, PIGrCoord y1, PIGrCoord z1, 
+                                PIGrCoord x2, PIGrCoord y2, PIGrCoord z2);
+  virtual void       DrawPolygon3D(PIGrCoord *x, PIGrCoord *y, PIGrCoord *z, int n);  
+  virtual void       DrawFPolygon3D(PIGrCoord *x, PIGrCoord *y, PIGrCoord *z, int n);  
+  virtual void       DrawMarker3D(PIGrCoord x0, PIGrCoord y0, PIGrCoord z0);
+  virtual void       DrawMarkers3D(PIGrCoord *x, PIGrCoord *y, PIGrCoord *z, int n);
+  
+protected:
+  double xO, yO, zO;  // Position observateur = camera
+  double xC, yC, zC;  // Position centre du champ
+  double tO,fO,pO;    // Orientation observateur (Teta, Phi, Psi, Angles d Euler)
+  double daxO, dayO;  // Demi-ouverture de la camera suivant les deux axes de projection (xp/zp, yp/zp) 
+  double lCO, dlCO;   // Distance Camera-Centre du champ et profondeur de champ 
+  double RE[3][3];    // Matrice de rotation  
+  bool sO;            // Vrai si fait par Set3DCS_Obs()
+};
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pigraphgen.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pigraphgen.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pigraphgen.cc	(revision 464)
@@ -0,0 +1,382 @@
+// Module PI : Peida Interactive     PIGraphic 
+// Primitives de trace graphiques    R. Ansari  97
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+// Classe generique de trace graphique de base (Ne peut etre instancie)
+
+#include "pigraphgen.h"
+
+//++
+// Class	PIGraphic
+// Lib		PI
+// include	pigraphgen.h
+//
+//   	Classe de base fournissant les services de tracé graphique.
+//   	La classe PIGraphicGen définit l'interface à travers des méthodes
+//   	virtuelles pures. Les objets instanciés doivent être de la classe
+//   	"PIGraphicWin" ou "PIGraphicUC" ou ...
+//   	La classe "PIGraphicWin" a une implementation dépendante du système 
+//   	utilisé (Mac, XWindow, ...). 
+//   	Un type particulier *PIGrCoord* est défini pour la spécification 
+//	des coordonnées graphiques. 
+//--
+//++
+// Links	Voir aussi
+// PIGrCoord
+// PIFont
+// PIColorMap
+//--
+
+//++
+// Titre	Constructeurs
+//--
+//++
+// PIGraphic()
+//	Constructeur utilisé par les classes dérivées.
+// PIGraphic(PIWdg* wdg)
+//	Constructeur pour les *PIGraphicWin*. Objet "PIGraphic" capable 
+//	de tracer dans un "PIWdg".
+// PIGraphic(PIScreenBuffer* grb)
+//	Constructeur pour objet "PIGraphic" capable de tracer dans un 
+//	buffer graphique.
+//--
+//++
+//--
+// Titre	Méthodes
+//++
+// int  kind()
+//	Renvoie le type de l'objet "PIGraphic" .
+//	* PI_UnknownGraphics : Objet PIGraphic de type inconnue.
+//	* PI_ScrBufferGraphics : Objet PIGraphic associé à un "GraphicBuffer"
+//	* PI_ScrWindowGraphics : Objet PIGraphic associé à une fenêtre sur l'écran (PIWdg)
+//	* PI_PSFileGraphics : Objet PIGraphic à un fichier PostScript (pour impression papier)
+//	* PI_UCGraphics : Objet PIGraphic travaillant dans un système de coordonnées utilisateur.
+//	* PI_3DGraphics : Objet PIGraphic fournissant des méthodes de tracé en coordonnées 3-D
+// void  GetGrSpace(PIGrCoord& xmin, PIGrCoord& xmax, PIGrCoord& ymin, PIGrCoord& ymax)
+//	Renvoie les limites de l'espace graphique - Coordonnées fenêtre pour un PIGraphicWin, 
+//	Limites définies par l'utilisateur pour un PIGraphicUC
+// void  Erase(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy) 
+//	Efface le rectangle défini par le coin "x0,y0", de longeur et de largeur "dx,dy"
+//	en utilisant la couleur d'arrière plan (Background)
+//--
+
+
+/* --Methode-- */
+PIGraphicGen::PIGraphicGen()
+{
+myWdg = NULL;
+myGrb = NULL;
+}
+
+/* --Methode-- */
+PIGraphicGen::PIGraphicGen(PIWdg* wdg)
+{
+myWdg = wdg;
+myGrb = NULL;
+}
+
+/* --Methode-- */
+PIGraphicGen::PIGraphicGen(PIScreenBuffer* grb)
+{
+myWdg = NULL;
+myGrb = grb;
+}
+
+/* --Methode-- */
+PIGraphicGen::~PIGraphicGen()
+{
+}
+/* --Methode-- */
+int PIGraphicGen::kind() 
+{
+return PI_UnknownGraphics ;
+}
+
+
+/* --Methode-- */
+void PIGraphicGen::GetGrSpace(PIGrCoord& xmin, PIGrCoord& xmax, PIGrCoord& ymin, PIGrCoord& ymax)
+{
+xmin = ymin = 0;  
+xmax = ymax = 0;
+if (myWdg) {
+  xmax = myWdg->XSize();
+  ymax = myWdg->YSize();
+  }
+}
+
+//++ 
+// Titre	Tracés de texte
+//--
+//++
+// void  DrawString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0)
+//	Trace la chaîne de caractères "s" à la position "x,y", 
+//	en utilisant la couleur d'avant-plan (Foreground)
+// void  DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0) 
+//	Trace la chaîne de caractères "s" à la position "x,y" . La couleur d'
+//	arrière-plan est utilisée pour remplir la zone rectangulaire occupée par
+//	le tracé de texte.
+//--
+
+//++ 
+// Titre	Tracés de lignes et de figures géometriques
+//--
+//++
+// void  DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2)
+//	Trace une ligne entre les points de coordonnées "(x1,y1)" et "(x2,y2)", 
+//	en utilisant la couleur d'avant-plan (Foreground)
+// void  DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+//	Tracé du contour d'un rectangle défini par la position du coin "(x0,y0)"
+//	et de taille "dx,dy" avec la couleur d'avant-plan.
+// void  DrawFBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+//	Tracé d'un rectangle plein, défini par la position du coin "(x0,y0)"
+//	et de taille "dx,dy" avec la couleur d'avant-plan.
+// void  DrawCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r)  
+//	Tracé du contour d'un cercle centré en "(x0,y0)", de rayon "r"
+// void  DrawFCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r)  
+//	Tracé d'un cercle plein centré en "(x0,y0)", de rayon "r"
+// void  DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+//	Tracé d'une ellipse incluse dans le rectangle "(x0,y0)" , "dx,dy"
+// void  DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+//	Tracé d'une ellipse pleine incluse dans le rectangle "(x0,y0)" , "dx,dy"
+// void  DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true)
+//	Tracé du contour d'un polygone défini par le tableau des "n" points "x,y".
+//	Si "cinc==true", les coordonnées seront considérées comme relatives
+//	à la position du point "(x[0], y[0])". Dans le cas contraire, chaque couple
+//	"(x[i], y[i])" représentera les coordonnées absolues d'un coin du polygone.
+// void  DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true)
+//	Tracé d'un polygone plein de la couleur d'avant-plan.
+// void  DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, double degdeb, double degfin)
+//	Tracé d'un arc de cercle ou d'ellipse, inclu dans le "(x0,y0)" , "dx,dy" 
+//	entre les angles (en degré) "degdeb" - "degfin" 
+// void  DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, double degdeb, double degfin)
+//	Tracé d'un arc plein, inclu dans le "(x0,y0)" , "dx,dy" 
+//	entre les angles (en degré) "degdeb" - "degfin" 
+//--
+
+//++ 
+// Titre	Tracés de signes
+//--
+//++
+// void  DrawMarker(PIGrCoord x0, PIGrCoord y0)  
+//	Tracé d'un signe au point "(x0,y0)". Le choix du signe tracé s'effectue
+//	à travers la méthode "SelMarker()"
+// void  DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n)
+//	Tracé de "n" signes aux points "(x[i],y[i])"
+//--
+
+//++
+// Titre	Tracé d'images (pixmap)
+//--
+//++
+// void  DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix, int sx, int sy, PIColorMap* cmap)
+//	Tracé d'un pixmap dans un rectangle positionné en "(x,y)". Le tableau des pixels
+//	"pix", de taille "sx,sy" représente les index dans la table de couleur "cmap".
+//--
+
+//++
+// Titre	Modifications des attributs graphiques	
+//--
+//++
+// void  SelForeground(PIColors col=PI_Black)
+//	Choix de la couleur de tracé d'avant-plan
+//|	PI_Black , PI_White,  PI_Grey , PI_Red , PI_Blue , PI_Green ,  
+//|	PI_Yellow , PI_Magenta , PI_Cyan , PI_Turquoise , PI_NavyBlue , 
+//|	PI_Orange , PI_SiennaRed , PI_Purple , PI_LimeGreen , PI_Gold ,
+//|	PI_ColorAllBits0 , PI_ColorAllBits1
+// void  SelBackground(PIColors col=PI_White)
+//	Choix de la couleur d'arrière-plan
+// void  SelForeground(PIColorMap& cmap, int cid) 
+//	Choix de la couleur de tracé d'avant-plan: Couleur numéro "cid" de la table de couleur "cmap"
+// void  SelBackground(PIColorMap& cmap, int cid)
+//	Choix de la couleur d'arrière-plan: Couleur numéro "cid" de la table de couleur "cmap"
+// void  SelGOMode(PIGOMode mod=PI_GOCopy) 
+//	Choix du mode de tracé graphique: "PI_GOCopy" ou "PI_GOXOR" ou 	"PI_GOInvert"
+// void  SelLine(PILineAtt att=PI_NormalLine)
+//	Choix du type de ligne pour le tracé des lignes et contours
+//|	PI_NormalLine, PI_ThinLine , PI_ThickLine
+//|	PI_DashedLine, PI_ThinDashedLine, PI_ThickDashedLine
+//|	PI_DottedLine, PI_ThinDottedLine, PI_ThickDottedLine
+// void  SelMarker(int msz=3, PIMarker mrk=PI_DotMarker) 
+//	Choix de la taille et du type de signe pour "DrawMarker() / DrawMarkers()"
+//|	PI_DotMarker , PI_PlusMarker , PI_CrossMarker
+//|	PI_CircleMarker , PI_FCircleMarker , PI_BoxMarker , PI_FBoxMarker
+//|	PI_TriangleMarker , PI_FTriangleMarker , PI_StarMarker , PI_FStarMarker
+//	(Les "StarMaker" ne sont pas encore implémentés  11/98) 
+//--
+
+//++
+// Titre	Changement de fontes
+//--
+//++
+// void  SelFont(PIFont & fnt)
+//	Choix de fonte courant.
+// void  SelFont(PIFontSize sz=PI_NormalSizeFont, PIFontAtt att=PI_RomanFont)
+//	Changement de taille et attribut de fonte
+//|	PI_SmallSizeFont , PI_NormalSizeFont , PI_BigSizeFont, PI_HugeSizeFont
+//|	PI_RomanFont , PI_BoldFont , PI_ItalicFont 
+// void  SelFontSzPt(int npt=12, PIFontAtt att=PI_RomanFont)
+//	Choix de taille de fonte avec spécification de taille en points 
+//	(pixels sur l'écran)
+// 
+//--
+
+//++
+// Titre	Sélection de la zone de tracé (clip)	
+//--
+//++
+// void  SetClipRectangle(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+//	Limite la zone de tracé permise au rectangle "(x0,y0)", "dx,dy"
+// void  ClearClipRectangle() 
+//	Supprime si nécéssaire la limitation de la zone de tracé.	
+//--
+
+//++
+// Titre	Accès aux attributs graphiques
+//--
+//++
+// PIColors  GetForeground()
+//	Renvoie la couleur de tracé d'avant-plan courante. 
+//	("PI_ColorFromMap" si défini à partir d'une table de couleur
+// PIColors  GetBackground()
+//	Renvoie la couleur d'arrière-plan courante.
+// PIGOMode  GetGOMode()
+//	Renvoie le mode de tracé graphique courante.
+// PIFontAtt GetFontAtt()
+//	Renvoie les attributs de la fonte courante.
+// int GetFontSize() 
+//	Renvoie la taille de la fonte courante.
+// PILineAtt GetLineAtt() 
+//	Renvoie le type de ligne courant
+// PIMarker  GetMarker() 
+//	Renvoie le type de signe (Marker) courant
+// int GetMarkerSize()
+//	Renvoie la taille des signes (Marker) pour le marker courant
+// PIFont  GetFont()
+//	Retourne une copie de l'objet "PIFont" courant.
+// PIGrCoord  GetFontHeight(PIGrCoord& asc, PIGrCoord& desc);
+//	Renvoie la hauteur des caractères, ainsi que la taille au dessus
+//	et en-dessous de la ligne de base ("asc , desc") pour la fonte courante
+//	dans le système de coordonnées courant (Fenêtre ou UC).
+// PIGrCoord CalcStringWidth(char const* s)
+//	Renvoie la largeur occupé par un texte s'il était affiché dans le 
+//	système de coordonnées courant (Fenêtre ou UC).
+//--
+
+/* --Methode-- */
+PIGrCoord PIGraphicGen::GetFontHeight(PIGrCoord& asc, PIGrCoord& desc)
+{
+int t,a,d;
+t = myFont.GetFontHeight(a, d);
+asc = a;   desc = d;
+return(t);
+}
+
+/* --Methode-- */
+PIGrCoord PIGraphicGen::CalcStringWidth(char const* s)
+{
+return (myFont.GetStringWidth(s));
+}
+
+//++
+// Titre	Sauvegarde et rappel des attributs graphiques
+//--
+//++
+// void  SaveGraphicAtt()
+//	Sauvegarde des attributs graphiques courants
+// void  RestoreGraphicAtt()
+//	Utilisation de l'ensemble des attributs graphiques sauvegardés par un appel
+//	à "SaveGraphicAtt()"
+//--
+
+
+/* --Methode-- */
+void PIGraphicGen::SaveGraphicAtt()
+{
+  sFCol = GetForeground();
+  sBCol = GetBackground();
+  sGOm = GetGOMode();
+  sFont = GetFont();   
+  sLAtt = GetLineAtt();
+  sMrk = GetMarker();   
+  sMrkSz = GetMarkerSize();
+  return;
+}
+
+/* --Methode-- */
+void PIGraphicGen::RestoreGraphicAtt()
+{
+  SelForeground(sFCol);
+  SelBackground(sBCol);
+  SelGOMode(sGOm);
+  SelFont(sFont);
+  SelLine(sLAtt);
+  SelMarker(sMrkSz, sMrk);
+  return;
+}
+
+
+
+
+//++
+// Class	PIGrCoord
+// Lib		PI
+// include	pigraphgen.h
+//
+//   	Classe utilisé pour la spécifiaction de coordonnées graphique.
+//	Des constructeurs et des méthodes de conversion à partir 
+//	et vers des "int", "float" et "double" sont définis.
+//	L'objet conserve le type effectif de l'argument lors de la 
+//	création ou de la dernière affectation.
+// 
+//|	PIGrCoord gco;
+//|	gco = 3.141596 ; 
+//|	int ic = gco;     // ic -> 3
+//|	float fc = gco;   // fc -> 3.141596
+//--
+//++
+// Links	Voir aussi
+// PIGraphic
+//--
+
+//++
+// Titre	Constructeurs
+//--
+//++
+// 
+// PIGrCoord() 
+//	Constructeur par défaut ("intVal=floatVal=0")
+// PIGrCoord(int a)
+//	Constructeur à partir de l'entier "a"
+// PIGrCoord(float a) 
+//	Constructeur à partir de la valeur flottante "a"
+// PIGrCoord(double a) 
+//	Constructeur à partir de la valeur flottante double précision "a"
+//--
+//++
+// Titre	Opérateurs de conversion
+//--
+//++
+// operator int() 
+//	Conversion en entier "int"
+// operator short() 
+//	Conversion en entier "short"
+// operator unsigned int() 
+//	Conversion en entier non signé "unsigned int"
+// operator unsigned short() 
+//	Conversion en entier non signé "unsigned short"
+// operator float() 
+//	Conversion en réél "float"
+// operator double() 
+//	Conversion en réél "double"
+//--
+//++
+// Titre	Opérateurs d'affectation
+//--
+//++
+// PIGrCoord& operator= (int a) 
+//	Affectation à partir de valeur entière "int"
+// PIGrCoord& operator= (float a) 
+//	Affectation à partir de valeur réélle "float"
+// PIGrCoord& operator= (double a) 
+//	Affectation à partir de valeur réélle double précision "double"
+//--
Index: /tags/V_LaSilla191199/SophyaPI/PI/pigraphgen.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pigraphgen.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pigraphgen.h	(revision 464)
@@ -0,0 +1,163 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive     PIGraphic 
+// Primitives de trace graphiques    R. Ansari  97
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIGRAPHICGEN_H_SEEN
+#define PIGRAPHICGEN_H_SEEN
+
+#include "pisysdep.h"
+
+#include PIWDG_H
+#include PICMAP_H
+#include PIFONT_H
+
+
+enum PIColors  { PI_ColorFromMap = -4, PI_NotDefColor = -1, 
+                 PI_Black = 0, PI_White = 1,  PI_Grey = 2,
+                 PI_Red = 3, PI_Blue = 4, PI_Green = 5,  
+                 PI_Yellow = 6, PI_Magenta = 7, 
+                 PI_Cyan = 8, PI_Turquoise = 9, PI_NavyBlue = 10, 
+                 PI_Orange = 11, PI_SiennaRed = 12, PI_Purple = 13,  
+                 PI_LimeGreen = 14, PI_Gold = 15,
+                 PI_ColorAllBits0 = 16, PI_ColorAllBits1 = 17 };
+
+
+enum PILineAtt { PI_NotDefLineAtt = -1,
+                 PI_NormalLine = 0, PI_ThinLine = 1, PI_ThickLine = 2 ,
+                 PI_DashedLine = 64, PI_ThinDashedLine = 65, PI_ThickDashedLine = 66 ,
+                 PI_DottedLine = 128, PI_ThinDottedLine = 129, PI_ThickDottedLine = 130 };
+
+enum PIMarker  { PI_NotDefMarker = -1,
+                 PI_DotMarker = 0, PI_PlusMarker=1, PI_CrossMarker=2,  
+                 PI_CircleMarker=3, PI_FCircleMarker=4,
+                 PI_BoxMarker=5, PI_FBoxMarker=6,
+                 PI_TriangleMarker=7, PI_FTriangleMarker=8,
+                 PI_StarMarker=9, PI_FStarMarker=10 };
+
+enum PIGOMode { PI_GOCopy = 0, PI_GOXOR = 1, PI_GOInvert = 2 }; 
+
+
+//  Classe pour gerer indifferement des coordonnees double ou int 
+class PIGrCoord {
+public:
+  inline PIGrCoord() { iv = 0; dv = 0.;}
+  inline PIGrCoord(int a) { iv = a; dv = (double)a;}
+  inline PIGrCoord(float a) { iv = (int)a; dv = (double)a;}
+  inline PIGrCoord(double a) { iv = (int)a; dv = a;}
+  inline PIGrCoord(PIGrCoord const & gc) { iv = gc.iv;  dv = gc.dv; }
+  inline operator int() { return(iv); }
+  inline operator short() { return((short)iv); }
+  inline operator unsigned int() { return((unsigned int)iv); }
+  inline operator unsigned short() { return((unsigned short)iv); }
+  inline operator float() { return((float)dv); }
+  inline operator double() { return(dv); }
+  inline PIGrCoord& operator= (int a) { iv = a; dv = (double)a; return(*this); }
+  inline PIGrCoord& operator= (float a) { iv = (int)a; dv = (double)a; return(*this); }
+  inline PIGrCoord& operator= (double a) { iv = (int)a; dv = a; return(*this); }
+  inline PIGrCoord& operator= (PIGrCoord const & gc) { iv = gc.iv; dv = gc.dv;  return(*this); }
+  int iv;
+  double dv;
+};
+
+enum PIGraphicsType { PI_UnknownGraphics = 0, 
+                      PI_ScrWindowGraphics = 2, PI_ScrBufferGraphics = 3, 
+                      PI_PSFileGraphics = 8, 
+                      PI_UCGraphics = 32, PI_3DGraphics = 36 };
+
+// Classe generique de trace graphique de base :
+
+class PIGraphicGen
+{
+public:
+                     PIGraphicGen();
+                     PIGraphicGen(PIWdg* wdg);
+                     PIGraphicGen(PIScreenBuffer* grb);
+  virtual           ~PIGraphicGen();
+
+  virtual int        kind();
+
+//  Espace des coordonnees
+  virtual void       GetGrSpace(PIGrCoord& xmin, PIGrCoord& xmax, PIGrCoord& ymin, PIGrCoord& ymax); 
+
+//  Trace graphiques
+  virtual void       Erase(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)     = 0;
+  virtual void       DrawString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0)        = 0;
+  virtual void       DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0)  = 0;
+  virtual void       DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2)  = 0;
+  virtual void       DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)   = 0;
+  virtual void       DrawFBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)  = 0;
+  virtual void       DrawCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r)               = 0;
+  virtual void       DrawFCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r)              = 0;
+  virtual void       DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)  = 0;
+  virtual void       DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy) = 0;
+  virtual void       DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true)    = 0;  
+  virtual void       DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true)   = 0;  
+  virtual void       DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
+                             double degdeb, double degfin)                             = 0;
+  virtual void       DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 
+                              double degdeb, double degfin)                            = 0;
+  virtual void       DrawMarker(PIGrCoord x0, PIGrCoord y0)                            = 0;
+  virtual void       DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n)                    = 0;
+  virtual void       DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix, 
+                                int sx, int sy, PIColorMap* cmap)              = 0;
+
+// Modifications attributs graphiques
+  virtual void       SelForeground(PIColors col=PI_Black)                      = 0;
+  virtual void       SelBackground(PIColors col=PI_White)                      = 0;
+  virtual void       SelForeground(PIColorMap& cmap, int cid)                  = 0;
+  virtual void       SelBackground(PIColorMap& cmap, int cid)                  = 0;
+  virtual void       SelGOMode(PIGOMode mod=PI_GOCopy)                         = 0;
+  virtual void       SelLine(PILineAtt att=PI_NormalLine)                      = 0;
+  virtual void       SelMarker(int msz=3, PIMarker mrk=PI_DotMarker)           = 0;
+// Modifications de fonte
+  virtual void	     SelFont(PIFont & fnt)				       = 0; 
+  virtual void       SelFont(PIFontSize sz=PI_NormalSizeFont, 
+                             PIFontAtt att=PI_RomanFont)		       = 0;
+  virtual void       SelFontSzPt(int npt=12, PIFontAtt att=PI_RomanFont)       = 0; 
+
+// Selection de zone de trace (clip)
+  virtual void       SetClipRectangle(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)  = 0;
+  virtual void       ClearClipRectangle()                                      = 0;
+
+// Acces aux attributs graphiques 
+  virtual PIColors   GetForeground()    = 0;
+  virtual PIColors   GetBackground()    = 0;
+  virtual PIGOMode   GetGOMode()        = 0;
+  virtual PILineAtt  GetLineAtt()       = 0;
+  virtual PIMarker   GetMarker()        = 0;
+  virtual int        GetMarkerSize()    = 0;
+
+// Acces a la fonte et ses attributs
+  inline  PIFont     GetFont() { return (myFont) ; }
+  virtual PIGrCoord  GetFontHeight(PIGrCoord& asc, PIGrCoord& desc);
+  virtual PIGrCoord  CalcStringWidth(char const* s);
+
+// Sauvegarde des attributs graphiques 
+  virtual void       SaveGraphicAtt();
+  virtual void       RestoreGraphicAtt();
+
+protected:
+// Pour Save/Restore des attributs graphiques 
+  PIWdg* myWdg;
+  PIScreenBuffer* myGrb;
+
+  PIFont myFont;
+  PIColors  sFCol, sBCol;
+  PIGOMode sGOm;
+  PIFont sFont;
+  PILineAtt sLAtt;
+  int sFSize;
+  PIMarker sMrk;
+  int sMrkSz;
+};
+
+typedef PIGraphicGen PIGraphic;
+
+// hierarchie apparente
+//   PIGraphic               ( == Gen, mais pas visible de l'utilisateur).
+//     PIGraphicWin   ( == X ou Mac)
+//     PIGraphicPS
+//     PIGraphicUC
+
+#endif      // PIGRAPHGEN_H_SEEN
Index: /tags/V_LaSilla191199/SophyaPI/PI/pigraphics.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pigraphics.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pigraphics.h	(revision 464)
@@ -0,0 +1,16 @@
+PIGraphics : = 0 sauf save et restore a reprendre de pibwdggen.cc
+
+Toutes methodes de trace et de selection.
+kind : retourne window, ps ou autre
+
+constructeur sans argument.
+
+->  PIGraphicsWinGen     rien de plus  sauf kind = window
+           constructeur prend un PIWdg
+     -> PIGraphicsWinMac 
+     -> PIGraphicsWinX
+
+->  PIGraphicsPS -> constructeur accepte un PSFile.
+
+
+=> toutes coords en float dans les draw
Index: /tags/V_LaSilla191199/SophyaPI/PI/pigraphmac.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pigraphmac.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pigraphmac.cc	(revision 464)
@@ -0,0 +1,525 @@
+#include <stdio.h>
+
+#include "pigraphmac.h"
+#include "UDrawingState.h"
+
+
+
+// #define DEBUG_PIBWDGX     Flag pour impression de debug etc ...
+
+/* --Methode-- */
+PIGraphicMac::PIGraphicMac(PIWdg* wdg)
+: PIGraphicGen(wdg)
+{
+  mPane = wdg->mPane;
+}
+
+/* --Methode-- */
+PIGraphicMac::~PIGraphicMac()
+{
+}
+
+/* --Methode-- */
+void PIGraphicMac::Erase(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+  if (mPane->FocusDraw()) {
+    Rect theRect = {(int)y0, (int)x0, (int)y0+(int)dy, (int)x0+(int)dx};
+    ::EraseRect(&theRect);
+  }
+}
+
+/* --Methode-- */
+void PIGraphicMac::DrawString(PIGrCoord x, PIGrCoord y, char const* s, int /*pos*/)
+{
+  if (!mPane->FocusDraw()) {
+    ::MoveTo(x, y);
+    LStr255 ps = s;
+    StTextState saver;
+    myFont.Apply();
+    ::DrawString(ps);
+  }
+}
+
+/* --Methode-- */
+void PIGraphicMac::DrawOpaqueString(PIGrCoord x, PIGrCoord y, char const* s, int /*pos*/)
+{
+  if (mPane->FocusDraw()) {
+    ::MoveTo(x, y);
+    LStr255 ps = s;
+    StTextState saver;
+    myFont.Apply();
+	Rect box;
+	box.left = x;
+	box.bottom = y;
+	int iWidth = TextWidth(s,0,strlen(s));
+	box.right = box.left + iWidth;
+	int z;
+	box.top = box.bottom + myFont.GetFontHeight(z,z);
+    ::TETextBox(s,strlen(s),&box,teForceLeft);
+  }
+}
+
+ 
+/* --Methode-- */
+void PIGraphicMac::DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2)
+{
+  if (mPane->FocusDraw()) {
+    ::MoveTo(x1,y1);
+    ::LineTo(x2,y2);
+  }
+}
+
+
+/* --Methode-- */
+void PIGraphicMac::DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+  if (mPane->FocusDraw()) {
+    Rect r = {y0, x0, (int)y0+(int)dy, (int)x0+(int)dx};
+    if (r.top  > r.bottom) swap(r.top,  r.bottom);
+    if (r.left > r.right)  swap(r.left, r.right);
+    r.right++; r.bottom++;
+    ::FrameRect(&r);
+  }
+}
+
+/* --Methode-- */
+void PIGraphicMac::DrawFBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+  if (mPane->FocusDraw()) {
+    Rect r = {y0, x0, (int)y0+(int)dy, (int)x0+(int)dx};
+    if (r.top  > r.bottom) swap(r.top,  r.bottom);
+    if (r.left > r.right)  swap(r.left, r.right);
+    r.right++; r.bottom++;
+    ::PaintRect(&r);
+  }
+}
+
+/* --Methode-- */
+void PIGraphicMac::DrawCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r)
+{
+  if (mPane->FocusDraw()) {
+    Rect rr = {(int)y0-(int)r, (int)x0-(int)r, (int)y0+(int)r, (int)x0+(int)r};
+    if (rr.top  > rr.bottom) swap(rr.top,  rr.bottom);
+    if (rr.left > rr.right)  swap(rr.left, rr.right);
+    ::FrameOval(&rr);
+  }
+}
+
+/* --Methode-- */
+void PIGraphicMac::DrawFCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r)
+{
+  if (mPane->FocusDraw()) {
+    Rect rr = {(int)y0-(int)r, (int)x0-(int)r, (int)y0+(int)r, (int)x0+(int)r};
+    if (rr.top  > rr.bottom) swap(rr.top,  rr.bottom);
+    if (rr.left > rr.right)  swap(rr.left, rr.right);
+    ::PaintOval(&rr);
+  }
+}
+
+/* --Methode-- */
+void PIGraphicMac::DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+  if (mPane->FocusDraw()) {
+    Rect rr = {(int)y0-(int)dy, (int)x0-(int)dx, (int)y0+(int)dy, (int)x0+(int)dx};
+    if (rr.top  > rr.bottom) swap(rr.top,  rr.bottom);
+    if (rr.left > rr.right)  swap(rr.left, rr.right);
+    ::FrameOval(&rr);
+  }
+}
+
+/* --Methode-- */
+void PIGraphicMac::DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+  if (mPane->FocusDraw()) {
+    Rect rr = {(int)y0-(int)dy, (int)x0-(int)dx, (int)y0+(int)dy, (int)x0+(int)dx};
+    if (rr.top  > rr.bottom) swap(rr.top,  rr.bottom);
+    if (rr.left > rr.right)  swap(rr.left, rr.right);
+    ::PaintOval(&rr);
+  }
+}
+
+
+/* --Methode-- */
+void PIGraphicMac::DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc)
+{
+  PolyHandle h = MakePoly(x,y,n);
+  if (h) {
+    ::FramePoly(h);
+    ::KillPoly(h);
+  }
+  
+}
+
+/* --Methode-- */
+void PIGraphicMac::DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc)
+{
+  PolyHandle h = MakePoly(x,y,n);
+  if (h) {
+    ::PaintPoly(h);
+    ::KillPoly(h);
+  }
+}
+
+
+/* --Methode-- */
+void PIGraphicMac::DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 
+                         double degdeb, double degfin)
+{
+  if (mPane->FocusDraw()) {
+    Rect rr = {(int)y0-(int)dy, (int)x0-(int)dx, (int)y0+(int)dy, (int)x0+(int)dx};
+    if (rr.top  > rr.bottom) swap(rr.top,  rr.bottom);
+    if (rr.left > rr.right)  swap(rr.left, rr.right);
+    ::FrameArc(&rr, degdeb, degfin-degdeb);
+  }
+}
+
+/* --Methode-- */
+void PIGraphicMac::DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 
+                         double degdeb, double degfin)
+{
+  if (mPane->FocusDraw()) {
+    Rect rr = {(int)y0-(int)dy, (int)x0-(int)dx, (int)y0+(int)dy, (int)x0+(int)dx};
+    if (rr.top  > rr.bottom) swap(rr.top,  rr.bottom);
+    if (rr.left > rr.right)  swap(rr.left, rr.right);
+    ::PaintArc(&rr, degdeb, degfin-degdeb);
+  }
+}
+
+
+/* --Methode-- */
+PolyHandle PIGraphicMac::MakePoly(PIGrCoord *x, PIGrCoord *y, int n)
+{
+  if (mPane->FocusDraw()) {
+    PolyHandle h = ::OpenPoly();
+    ::MoveTo(x[0], y[0]);
+    for (int i=1; i<n; i++) {
+      ::LineTo(x[i], y[i]);
+    }
+    ::MoveTo(x[0], y[0]);
+    ClosePoly();
+    return h;
+  }
+  return NULL;
+}
+
+
+/* --Methode-- */
+void PIGraphicMac::DrawMarker(PIGrCoord x0, PIGrCoord y0)
+{
+int hmsz = mMrkSz/2;
+int dmsz = mMrkSz-hmsz;
+PIGrCoord x[4],y[4];
+PILineAtt clatt;
+
+if (mMrk == PI_DotMarker) {
+  ::MoveTo( x0, y0);
+  ::Line(0,0);
+}
+
+else
+  {
+  clatt = mLAtt;
+  SelLine(PI_ThinLine);
+  switch (mMrk)
+    {
+    case  PI_PlusMarker :
+      DrawLine((int)x0-hmsz, y0, (int)x0+dmsz, y0);
+      DrawLine(x0, (int)y0-hmsz, x0, (int)y0+dmsz);
+      break;
+    case  PI_CrossMarker :
+      DrawLine((int)x0-hmsz, (int)y0-hmsz, (int)x0+dmsz, (int)y0+dmsz);
+      DrawLine((int)x0-hmsz, (int)y0+dmsz, (int)x0+dmsz, (int)y0-hmsz);
+      break;  
+    case PI_CircleMarker :
+      DrawCircle(x0, y0, hmsz);
+      break;
+    case PI_FCircleMarker :
+      DrawFCircle(x0, y0, hmsz);
+      break;
+    case PI_BoxMarker :
+      DrawBox((int)x0-hmsz, (int)y0-hmsz, mMrkSz, mMrkSz);
+      break;
+    case PI_FBoxMarker :
+      DrawFBox((int)x0-hmsz, (int)y0-hmsz, mMrkSz, mMrkSz);
+      break;
+    case  PI_TriangleMarker :
+      x[1] = mMrkSz; y[1] = 0; x[2] = -hmsz; y[2] = -mMrkSz; 
+      x[3] = -dmsz; y[3] = +mMrkSz; x[0] = (int)x0-hmsz; y[0] = (int)y0+hmsz;  
+      DrawPolygon(x, y, 4);
+      break;
+    case  PI_FTriangleMarker :
+      x[1] = mMrkSz; y[1] = 0; x[2] = -hmsz; y[2] = -mMrkSz; 
+      x[3] = -dmsz; y[3] = +mMrkSz; x[0] = (int)x0-hmsz; y[0] = (int)y0+hmsz;  
+      DrawFPolygon(x, y, 4);
+      break;
+    default :
+      ::MoveTo( x0, y0);
+      ::Line(0,0);
+      break;
+    }
+  SelLine(clatt);
+  }
+return;
+}
+
+/* --Methode-- */
+void PIGraphicMac::DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n)
+{
+int i;
+
+if (n <= 0)  return;
+for(i=0; i<n; i++) DrawMarker(x[i], y[i]);
+}
+
+
+/* --Methode-- */
+void PIGraphicMac::DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix, 
+                            int sx, int sy, PIColorMap* cmap)
+{
+  Rect	frame;
+  SetRect(&frame, 0, 0, sx, sy);
+  Rect dstFrame;
+  SetRect(&dstFrame, x, y, sx, sy);
+  GWorldPtr gWorld;
+  ThrowIfOSErr_(NewGWorld(&gWorld, 8, &frame, cmap->GetCTab(), nil, 0));
+  PixMapHandle pmh = GetGWorldPixMap(gWorld);
+  ::LockPixels (pmh);
+  Ptr pmap = GetPixBaseAddr(pmh);
+  memcpy(pmap, pix, sx*sy);
+  ::ForeColor (blackColor);
+  ::BackColor (whiteColor);
+  ::CopyBits((BitMap *) (*pmh),
+				&mPane->GetMacPort()->portBits,
+				&frame, &dstFrame, srcCopy, nil);
+  ::UnlockPixels (pmh);
+  DisposeGWorld(gWorld);
+}
+
+
+
+/* --Methode-- */
+void PIGraphicMac::SelForeground(PIColors col)
+{
+  if (mPane->FocusDraw()) {
+    long color;
+    switch (col) {
+      case PI_Black:
+        color = blackColor;
+        break;
+      case PI_White:
+        color = whiteColor;
+        break;
+      case PI_Red:
+        color = redColor;
+        break;
+      case PI_Blue:
+        color = blueColor;
+        break;
+      case PI_Green:
+        color = greenColor;
+        break;
+      case PI_Yellow:
+        color = yellowColor;
+        break;
+      default:
+        color = blackColor;
+    }
+    ::ForeColor(color);
+    mFCol = col;
+  }
+}
+
+/* --Methode-- */
+void PIGraphicMac::SelBackground(PIColors col)
+{
+  if (mPane->FocusDraw()) {
+    long color;
+    switch (col) {
+      case PI_Black:
+        color = blackColor;
+        break;
+      case PI_White:
+        color = whiteColor;
+        break;
+      case PI_Red:
+        color = redColor;
+        break;
+      case PI_Blue:
+        color = blueColor;
+        break;
+      case PI_Green:
+        color = greenColor;
+        break;
+      case PI_Yellow:
+        color = yellowColor;
+        break;
+      default:
+        color = blackColor;
+    }
+    mBCol = col;
+    ::BackColor(color);
+  }
+}
+
+/* --Methode-- */
+void PIGraphicMac::SelForeground(PIColorMap& cmap, int cid)
+{
+  if (mPane->FocusDraw()) {
+    PIColor picol = cmap.GetColor(cid);
+    RGBColor qdCol;
+ 
+    qdCol.red   = picol.red;
+    qdCol.green = picol.green;
+    qdCol.blue  = picol.blue;
+
+    ::RGBForeColor(&qdCol);
+  }
+}
+
+/* --Methode-- */
+void PIGraphicMac::SelBackground(PIColorMap& cmap, int cid)
+{
+  if (mPane->FocusDraw()) {
+    PIColor picol = cmap.GetColor(cid);
+    RGBColor qdCol;
+ 
+    qdCol.red   = picol.red;
+    qdCol.green = picol.green;
+    qdCol.blue  = picol.blue;
+
+    ::RGBBackColor(&qdCol);
+  }
+}
+
+/* --Methode-- */
+void PIGraphicMac::SelGOMode(PIGOMode mod)
+{
+if (mod == mGOm)  return;
+  if (mPane->FocusDraw())
+    switch (mod)
+    {
+      case PI_GOCopy :
+        ::PenMode(patCopy);
+        mGOm = mod;
+        break;
+      case PI_GOXOR :
+        ::PenMode(patXor);
+        mGOm = mod;
+        break;
+    }
+return;
+}
+
+
+/* --Methode-- */
+void PIGraphicMac::SelFontSzPt(int npt, PIFontAtt att)
+{
+  myFont.SetFontSzPt(npt);
+  myFont.SetFontAtt(att);
+}
+
+/* --Methode-- */
+void PIGraphicMac::SelFont(PIFontSize sz, PIFontAtt att)
+{
+  myFont.SetFontSz(sz);
+  myFont.SetFontAtt(att);
+}
+
+/* --Methode-- */
+void PIGraphicMac::SelFont(PIFont & fnt)
+{
+  myFont = fnt;
+}
+
+
+/* --Methode-- */
+void PIGraphicMac::SelLine(PILineAtt att)
+{
+  if (mPane->FocusDraw()) {
+    switch(att) {
+      case PI_NormalLine:
+        ::PenSize(1,1);
+        break;
+      case PI_ThinLine:
+        ::PenSize(1,1);  // Mettre en pointille, ou bien commentaire pour Laser ?
+        break;
+      case PI_ThickLine:
+        ::PenSize(2,2);
+        break;
+    }
+  }
+  mLAtt = att;
+}
+
+
+/* --Methode-- */
+void PIGraphicMac::SelMarker(int msz, PIMarker mrk)
+{
+if (msz > 1)  { mMrk = mrk;  mMrkSz = msz; }
+else  { mMrk = PI_DotMarker;  mMrkSz = 1; }
+return;
+}
+
+
+/* --Methode-- */
+void PIGraphicMac::SetClipRectangle(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+//$CHECK
+}
+
+/* --Methode-- */
+void PIGraphicMac::ClearClipRectangle()
+{ 
+//$CHECK
+}
+
+/* --Methode-- */
+PIColors  PIGraphicMac::GetForeground() 
+{
+return (mFCol);
+}
+
+/* --Methode-- */
+PIColors  PIGraphicMac::GetBackground() 
+{
+return (mBCol);
+}
+
+
+/* --Methode-- */
+PIGOMode   PIGraphicMac::GetGOMode()
+{
+return (mGOm);
+}
+
+/* --Methode-- */
+PIFontAtt  PIGraphicMac::GetFontAtt()
+{
+return (myFont.GetFontAtt());
+}
+
+/* --Methode-- */
+int        PIGraphicMac::GetFontSize()
+{
+return (myFont.GetFontSize());
+}
+
+/* --Methode-- */
+PILineAtt  PIGraphicMac::GetLineAtt()
+{
+return (mLAtt);
+}
+
+/* --Methode-- */
+PIMarker   PIGraphicMac::GetMarker()
+{
+return (mMrk);
+}
+
+/* --Methode-- */
+int        PIGraphicMac::GetMarkerSize()
+{
+return (mMrkSz);
+}
+
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pigraphmac.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pigraphmac.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pigraphmac.h	(revision 464)
@@ -0,0 +1,89 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive     PIGraphicMac
+// Trace graphiques- Implementation Mac  E. Aubourg 99
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIGRAPHICMAC_H_SEEN
+#define PIGRAPHICMAC_H_SEEN
+
+#include "pisysdep.h"
+#include "pigraphgen.h"
+
+class PIGraphicMac : public PIGraphicGen
+{
+public:
+                     PIGraphicMac(PIWdg* wdg);
+  virtual           ~PIGraphicMac();
+
+//  Trace graphiques
+  virtual void       Erase(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0);
+  virtual void       DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0);
+  virtual void       DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2);
+  virtual void       DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawFBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r);
+  virtual void       DrawFCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r);
+  virtual void       DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true);  
+  virtual void       DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true);  
+  virtual void       DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
+                             double degdeb, double degfin);
+  virtual void       DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 
+                              double degdeb, double degfin);
+  virtual void       DrawMarker(PIGrCoord x0, PIGrCoord y0);
+  virtual void       DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n);
+  virtual void       DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix, 
+                                int sx, int sy, PIColorMap* cmap);
+
+// Modifications attributs graphiques
+  virtual void       SelForeground(PIColors col=PI_Black);
+  virtual void       SelBackground(PIColors col=PI_White);
+  virtual void       SelForeground(PIColorMap& cmap, int cid);
+  virtual void       SelBackground(PIColorMap& cmap, int cid);
+  virtual void       SelGOMode(PIGOMode mod=PI_GOCopy);
+  virtual void	     SelFont(PIFont & fnt);
+  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       SelMarker(int msz=3, PIMarker mrk=PI_DotMarker);
+
+// Selection de zone de trace (clip)
+  virtual void       SetClipRectangle(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       ClearClipRectangle();
+
+// Acces aux attributs graphiques 
+  virtual PIColors   GetForeground();
+  virtual PIColors   GetBackground();
+  virtual PIGOMode   GetGOMode();
+  virtual PIFontAtt  GetFontAtt();
+  virtual int        GetFontSize();
+  virtual PILineAtt  GetLineAtt();
+  virtual PIMarker   GetMarker();
+  virtual int        GetMarkerSize();
+
+  //virtual int        GetFontHeight(int& asc, int& desc);
+  //virtual PIGrCoord  CalcStringWidth(char const* s);
+
+// Sauvegarde des attributs graphiques 
+ // virtual void       SaveGraphicAtt();
+ // virtual void       RestoreGraphicAtt();
+
+protected:
+  LPane* mPane;
+  
+  PolyHandle         MakePoly(PIGrCoord *x, PIGrCoord *y, int n);
+
+  PIColors  mFCol, mBCol;
+  PIGOMode  mGOm;
+  PILineAtt mLAtt;
+  PIMarker  mMrk;
+  int       mMrkSz;
+
+};
+
+typedef PIGraphicMac PIGraphicWin;
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pigraphps.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pigraphps.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pigraphps.cc	(revision 464)
@@ -0,0 +1,502 @@
+// Module PI : Peida Interactive     PIGraphicPS
+// Trace graphiques en PostScript    R. Ansari  97
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include <stdio.h>
+
+#include "pigraphps.h"
+
+//++
+// Class	PIGraphicPS
+// Lib		PI
+// include	pigraphps.h
+//
+//   	Classe les services de tracé graphique avec sortie PostScript
+//	Toutes les méthodes de tracé de "PIGraphic" sont redéfinies pour
+//	produire du PostScript 
+//--
+//++
+// Links	Parent
+// PIGraphic
+//--
+//++
+// Links	Voir aussi
+// PSFile
+//--
+
+//++
+// Titre	Constructeurs, méthodes
+//--
+//++
+// PIGraphicPS(PSFile * psf, double x0, double y0, double dx, double dy)
+//	Création d'un objet "PIGraphicPS" à partir d'un objet "PSFIle* psf".
+//	"(x0, y0)" détermine l'origine du nouveau bloc rectangulaire sur 
+//	la page et "dx, dy" l'extension du bloc. 
+// PIGraphicPS(PSFile * psf, PIWdg* wdg, double ofx, double ofy)
+//	Création d'un objet "PIGraphicPS" à partir d'un objet "PSFIle* psf"
+//|	x0 = wdg->XPos()+ofx    y0 = wdg->YPos()+ofy
+//|	dx = wdg->XSize()       dy = wdg->YSize()
+//
+// int kind()
+//	 Renvoie le type ("= PI_PSFileGraphics")
+//--
+
+/* --Methode-- */
+PIGraphicPS::PIGraphicPS(PSFile * psf, PIWdg* wdg, double ofx, double ofy)
+: PIGraphicGen()
+{
+BuildFromPSFile(psf, (double)wdg->XPos()+ofx, (double)wdg->YPos()+ofy, 
+                     (double)wdg->XSize(), (double)wdg->YSize() );  
+}
+
+/* --Methode-- */
+PIGraphicPS::PIGraphicPS(PSFile * psf, double x0, double y0, double dx, double dy)
+: PIGraphicGen()
+{
+BuildFromPSFile(psf, x0, y0, dx, dy);
+}
+
+/* --Methode-- */
+PIGraphicPS::~PIGraphicPS()
+{
+mPSOut->EndBloc();
+}
+
+/* --Methode-- */
+int PIGraphicPS::kind()
+{
+return PI_PSFileGraphics; 
+}
+
+
+/* --Methode-- */
+void PIGraphicPS::BuildFromPSFile(PSFile * psf, double x0, double y0, double dx, double dy)
+{
+mPSOut = psf;
+
+mGOm = PI_GOCopy;
+
+mFCol = mBCol = PI_Grey;
+SelForeground(PI_Black);
+SelBackground(PI_White);
+mLAtt = PI_ThinLine;
+SelLine();
+// mFAtt = PI_BoldFont;  mFSize = 0;  $CHECK$ Plus besoin 
+SelFont();
+SelMarker(1, PI_DotMarker);
+
+if (psf) psf->NewBloc(x0, y0, dx, dy, dx, dy);
+mXmin = mYmin = 0.;
+mXmax = dx;  mYmax = dy;
+mFCfMap.red = mFCfMap.blue = mFCfMap.blue = 0;
+mBCfMap = mFCfMap; 
+}
+
+/* --Methode-- */
+void PIGraphicPS::GetGrSpace(PIGrCoord& xmin, PIGrCoord& xmax, PIGrCoord& ymin, PIGrCoord& ymax)
+{
+xmin = ymin = 0;  
+xmax = mXmax; ymax = mYmax;
+}
+
+/* --Methode-- */
+void PIGraphicPS::Erase(PIGrCoord, PIGrCoord, PIGrCoord, PIGrCoord)
+{
+// A Faire ??? $CHECK$ 
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::DrawString(PIGrCoord x, PIGrCoord y, const char* s, int /*pos*/)
+{
+if(mPSOut)
+  //  mPSOut->DrawString((double)x,(double)y,s,mFCol,mFAtt,mFSize); /* $CHECK$ PIFontSize ?? */
+  mPSOut->DrawString((double)x,(double)y,s,mFCol, myFont.GetFontName(),
+                     myFont.GetFontAtt(),  myFont.GetFontSize());
+// Calculez la taille de la boite occupe par la fonte
+//  myFont.GetFontHeight(int& asc, int& desc)  Tres proche de myFont.GetFontSize() en principe
+//  myFont.GetStringWidth(char const* s)  Largeur occupe par la chaine
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int /*pos*/)
+{
+if(mPSOut)
+  //  mPSOut->DrawString((double)x,(double)y,s,mFCol,mFAtt,mFSize); /* $CHECK$ PIFontSize ?? */
+  mPSOut->DrawString((double)x,(double)y,s,mFCol, myFont.GetFontName(), 
+                     myFont.GetFontAtt(),  myFont.GetFontSize());
+// Idem taille ici 
+return;
+}
+
+ 
+/* --Methode-- */
+void PIGraphicPS::DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2)
+{
+if(mPSOut)
+  mPSOut->DrawLine((double)x1,(double)y1,(double)x2,(double)y2,mFCol,mLAtt);
+return;
+}
+
+
+/* --Methode-- */
+void PIGraphicPS::DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+if(mPSOut)
+  mPSOut->DrawBox((double)x0,(double)y0,(double)dx,(double)dy,mFCol,mLAtt);
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::DrawFBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+if(mPSOut)
+  mPSOut->DrawFBox((double)x0,(double)y0,(double)dx,(double)dy, mFCol, mFCol, mLAtt);
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::DrawCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r)
+{
+if(mPSOut)
+  mPSOut->DrawCircle((double)x0,(double)y0,(double)r,mFCol,mLAtt);
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::DrawFCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r)
+{
+if(mPSOut)
+  mPSOut->DrawFCircle((double)x0,(double)y0,(double)r,mFCol,mFCol,mLAtt);
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+// $CHECK$ Reza/ Nicolas  12 Nov 98 - A faire
+}
+
+/* --Methode-- */
+void PIGraphicPS::DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+// $CHECK$ Reza/ Nicolas  12 Nov 98 - A faire
+}
+
+/* --Methode-- */
+void PIGraphicPS::DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc)
+{
+int i;
+double *xtmp;
+double *ytmp;
+
+if(! mPSOut) return;
+
+xtmp = new double[n];
+ytmp = new double[n];
+for(i = 0 ; i < n ; i++) {xtmp[i] = (double)x[i] ; ytmp[i] = (double)y[i] ; }
+//double xoff,yoff;
+//if (cinc) { xoff=yoff=0.; }   // Coord en mode incremental
+//else { xoff = (double)x[0];  yoff = (double)y[0]; }   //   Coord en mode absolu
+//xtmp[0] = (double)x[0];
+//ytmp[0] = (double)y[0];
+//for(i=1;i<n;i++) {
+//  xtmp[i] = (double)x[i]-xoff;
+//  ytmp[i] = (double)y[i]-yoff;
+//}
+mPSOut->DrawPolygon(xtmp,ytmp,n,mFCol,mLAtt,cinc);
+delete[] xtmp;
+delete[] ytmp;
+
+return;
+}
+
+
+/* --Methode-- */
+void PIGraphicPS::DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc)
+{
+int i;
+double *xtmp;
+double *ytmp;
+
+if(! mPSOut) return;
+
+xtmp = new double[n];
+ytmp = new double[n];
+for(i = 0 ; i < n ; i++) {xtmp[i] = (double)x[i] ; ytmp[i] = (double)y[i] ; }
+//double xoff,yoff;
+//if (cinc) { xoff=yoff=0.; }   // Coord en mode incremental
+//else { xoff = (double)x[0];  yoff = (double)y[0]; }   //   Coord en mode absolu
+//xtmp[0] = (double)x[0];
+//ytmp[0] = (double)y[0];
+//for(i=1;i<n;i++) {
+//  xtmp[i] = (double)x[i]-xoff;
+//  ytmp[i] = (double)y[i]-yoff;
+//}
+mPSOut->DrawFPolygon(xtmp,ytmp,n,mFCol,mFCol,mLAtt,cinc);
+delete[] xtmp;
+delete[] ytmp;
+
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,double degdeb, double degfin)
+{
+// $CHECK$ Reza/ Nicolas  12 Nov 98 - A faire
+}
+
+/* --Methode-- */
+void PIGraphicPS::DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,double degdeb, double degfin)
+{
+// $CHECK$ Reza/ Nicolas  12 Nov 98 - A faire
+}
+
+/* --Methode-- */
+void PIGraphicPS::DrawMarker(PIGrCoord x0, PIGrCoord y0)
+{
+if(mPSOut)
+  mPSOut->DrawMarker((double)x0,(double)y0,mMrk,mFCol,mMrkSz);
+// $CHECK$ Ajouter starmarker
+// /* Coordonnees pour une etoile a 5 branches */
+// double pio5 = M_PI/2.5;  
+// double pio52 = pio5/2.;
+// double cpi2 = M_PI/2.-pio5;  
+// double re = 1.2;  // Rayon externe
+// double ri = 0.5; //  rayon interne pour rext=1.2
+// for(int k=0; k<5; k++) {
+//  starcoordx[2*k] = cos(k*pio5+cpi2)*re;
+//  starcoordy[2*k] = -sin(k*pio5+cpi2)*re;
+//  starcoordx[2*k+1] = cos(k*pio5+pio52+cpi2)*ri;
+//  starcoordy[2*k+1] = -sin(k*pio5+pio52+cpi2)*ri;
+//  }
+
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n)
+{
+int i;
+double *xtmp;
+double *ytmp;
+
+if( !mPSOut)  return;
+
+xtmp = new double[n];
+ytmp = new double[n];
+for(i=0;i<n;i++){
+  xtmp[i] = (double)x[i];
+  ytmp[i] = (double)y[i];
+}
+mPSOut->DrawMarkers(xtmp,ytmp,n,mMrk,mFCol, mMrkSz);
+delete[] xtmp;
+delete[] ytmp;
+
+return;
+}
+
+
+/* --Methode-- */
+void PIGraphicPS::DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix, 
+                            int sx, int sy, PIColorMap* cmap)
+{
+if ( (sx < 1) || (sy < 1) )  return;
+if ((pix == NULL) || (cmap == NULL)) return;
+if(mPSOut) 
+  mPSOut->Image((double)x, (double)y, (double)sx, (double)sy, sx, sy, pix, cmap);
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::SelForeground(PIColors col)
+{
+mFCol = col;
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::SelBackground(PIColors col)
+{
+mBCol = col;
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::SelForeground(PIColorMap& cmap, int cid)
+{
+// A Faire Voir Nicolas  
+mFCfMap = cmap.GetColor(cid);
+mFCol = PI_ColorFromMap;
+mPSOut->SelForeground(cmap, cid) ; 
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::SelBackground(PIColorMap& cmap, int cid)
+{
+// A Faire Voir Nicolas  
+mBCfMap = cmap.GetColor(cid);
+mBCol = PI_ColorFromMap;
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::SelGOMode(PIGOMode mod)
+{
+mGOm = mod;
+return;
+}
+/* --Methode-- */
+void PIGraphicPS::SelFont(PIFont & fnt)
+{
+//  $CHECK$   -  Reza 13/06/99
+if (myFont == fnt)  return;
+myFont = fnt;
+  // C'est peu-etre mieux 
+  // SelFontSzPt(fnt.GetFontSize(), fnt.GetFontAtt());
+}
+
+
+static int fntsz[5] = {8,10,12,14,16};
+
+/* --Methode-- */
+void PIGraphicPS::SelFont(PIFontSize sz, PIFontAtt att)
+{
+//  $CHECK$   -  Reza 13/06/99
+PIFont fnt(myFont.GetFontName());
+fnt.SetFontAtt(att);
+fnt.SetFontSz(sz);
+SelFont(fnt);
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::SelFontSzPt(int npt, PIFontAtt att)
+{
+//  $CHECK$   -  Reza 13/06/99
+PIFont fnt(npt, myFont.GetFontName(), att);
+SelFont(fnt);
+}
+
+
+
+/* --Methode-- */
+void PIGraphicPS::SelLine(PILineAtt att)
+{
+mLAtt = att;
+return;
+}
+
+
+/* --Methode-- */
+void PIGraphicPS::SelMarker(int msz, PIMarker mrk)
+{
+if (msz > 1)  { mMrk = mrk;  mMrkSz = msz; }
+else  { mMrk = PI_DotMarker;  mMrkSz = 1; }
+return;
+}
+
+
+/* --Methode-- */
+void PIGraphicPS::SetClipRectangle(PIGrCoord /*x0*/, PIGrCoord /*y0*/, PIGrCoord /*dx*/, PIGrCoord /*dy*/)
+{
+/*  $CHECK$  A FAIRE , voir Nicolas  */
+return;
+}
+
+/* --Methode-- */
+void PIGraphicPS::ClearClipRectangle()
+{ 
+/*  $CHECK$  A FAIRE , voir Nicolas  */
+return;
+}
+
+/* --Methode-- */
+PIColors  PIGraphicPS::GetForeground() 
+{
+return (mFCol);
+}
+
+/* --Methode-- */
+PIColors  PIGraphicPS::GetBackground() 
+{
+return (mBCol);
+}
+
+
+/* --Methode-- */
+PIGOMode   PIGraphicPS::GetGOMode()
+{
+return (mGOm);
+}
+
+
+/* --Methode-- */
+PILineAtt  PIGraphicPS::GetLineAtt()
+{
+return (mLAtt);
+}
+
+/* --Methode-- */
+PIMarker   PIGraphicPS::GetMarker()
+{
+return (mMrk);
+}
+
+/* --Methode-- */
+int        PIGraphicPS::GetMarkerSize()
+{
+return (mMrkSz);
+}
+
+/* --Methode-- 
+int        PIGraphicPS::GetFontHeight(int& asc, int& desc)   
+{
+  $CHECK$  A refaire , voir Nicolas  
+asc = mFSize; desc = 0; 
+return(asc+desc);
+} 
+*/
+
+
+/* --Methode-- 
+PIGrCoord PIGraphicPS::CalcStringWidth(char const* s)
+{
+return((double)(mFSize*strlen(s)*0.5));   
+//  facteur 0.5 ad hoc $CHECK$  Voir Nicolas 
+}
+*/
+ 
+
+/* --Methode-- */
+void PIGraphicPS::SaveGraphicAtt()
+{  
+// Pour optimier l'implementation de PIBaseWdgGen
+sFCol = mFCol;    sBCol = mBCol;
+sGOm = mGOm;
+sFont = myFont; 
+sMrk = mMrk;   sMrkSz = mMrkSz;
+return;
+}
+
+
+/* --Methode-- */
+void PIGraphicPS::RestoreGraphicAtt()
+{
+  if (sFCol != PI_ColorFromMap) SelForeground(sFCol);  
+// else    A faire Nicolas  
+  if (sBCol != PI_ColorFromMap) SelBackground(sBCol);
+// else    A faire Nicolas  
+  SelGOMode(sGOm);
+  SelFont(sFont);
+  SelLine(sLAtt);
+  SelMarker(sMrkSz, sMrk);
+  return;
+}
+
+
+
+
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pigraphps.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pigraphps.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pigraphps.h	(revision 464)
@@ -0,0 +1,93 @@
+#ifndef PIGRAPHICPS_H_SEEN
+#define PIGRAPHICPS_H_SEEN
+
+#include "pisysdep.h"
+#include "pigraphgen.h"
+#include "psfile.h"
+
+class PIGraphicPS : public PIGraphicGen
+{
+public:
+                     PIGraphicPS(PSFile * psf, PIWdg* wdg, double ofx=0., double ofy=0.);
+                     PIGraphicPS(PSFile * psf, double x0, double y0, double dx, double dy);
+  virtual           ~PIGraphicPS();
+
+  virtual int        kind();
+
+//  Espace des coordonnees
+  virtual void       GetGrSpace(PIGrCoord& xmin, PIGrCoord& xmax, PIGrCoord& ymin, PIGrCoord& ymax); 
+
+//  Trace graphiques
+  virtual void       Erase(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0);
+  virtual void       DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0);
+  virtual void       DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2);
+  virtual void       DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawFBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r);
+  virtual void       DrawFCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r);
+  virtual void       DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true);  
+  virtual void       DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true);  
+  virtual void       DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
+                             double degdeb, double degfin);
+  virtual void       DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 
+                              double degdeb, double degfin);
+  virtual void       DrawMarker(PIGrCoord x0, PIGrCoord y0);
+  virtual void       DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n);
+  virtual void       DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix, 
+                                int sx, int sy, PIColorMap* cmap);
+
+// Modifications attributs graphiques
+  virtual void       SelForeground(PIColors col=PI_Black);
+  virtual void       SelBackground(PIColors col=PI_White);
+  virtual void       SelForeground(PIColorMap& cmap, int cid);
+  virtual void       SelBackground(PIColorMap& cmap, int cid);
+  virtual void       SelGOMode(PIGOMode mod=PI_GOCopy);
+  virtual void       SelLine(PILineAtt att=PI_NormalLine);
+  virtual void       SelMarker(int msz=3, PIMarker mrk=PI_DotMarker);
+
+  virtual void       SelFont(PIFont & fnt);
+  virtual void       SelFont(PIFontSize sz=PI_NormalSizeFont, 
+                             PIFontAtt att=PI_RomanFont);
+  virtual void       SelFontSzPt(int npt=12, PIFontAtt att=PI_RomanFont);
+
+// Selection de zone de trace (clip)
+  virtual void       SetClipRectangle(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       ClearClipRectangle();
+
+// Acces aux attributs graphiques 
+  virtual PIColors   GetForeground();
+  virtual PIColors   GetBackground();
+  virtual PIGOMode   GetGOMode();
+  virtual PILineAtt  GetLineAtt();
+  virtual PIMarker   GetMarker();
+  virtual int        GetMarkerSize();
+
+  //  virtual PIGrCoord  GetFontHeight(PIGrCoord& asc, PIGrCoord& desc);
+  //  virtual PIGrCoord  CalcStringWidth(char const* s);
+
+// Sauvegarde des attributs graphiques 
+  virtual void       SaveGraphicAtt();
+  virtual void       RestoreGraphicAtt();
+
+protected:
+  void           BuildFromPSFile(PSFile * psf, double x0, double y0, double dx, double dy);
+
+  PSFile * mPSOut;  /* Fichier PostScript */
+  double mXmin, mYmin;
+  double mXmax, mYmax;
+
+  PIColors  mFCol, mBCol;
+  PIColor  mFCfMap, mBCfMap;
+  PIGOMode mGOm;
+//  PIFontAtt mFAtt;  Plus besoin Reza + NR 07/08/99
+  PILineAtt mLAtt;
+//  int mFSize;    Plus besoin Reza + NR 07/08/99
+  PIMarker mMrk;
+  int mMrkSz;
+};
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pigraphuc.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pigraphuc.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pigraphuc.cc	(revision 464)
@@ -0,0 +1,762 @@
+// Module PI : Peida Interactive     PIGraphicUC 
+// Trace graphiques User-Coordinates    R. Ansari  97
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "machdefs.h"
+#include <iostream.h>
+#include "pigraphuc.h"
+
+#include <math.h>
+//  Pour la declaration de finite() isnan() ...
+#if defined(SunOS)
+#include <ieeefp.h>
+#endif
+
+//++
+// Class	PIGraphicUC
+// Lib		PI
+// include	pigraphuc.h
+//
+//   	Classe fournissant les services de tracé graphique 
+//	en coordonnées utilisateur.
+//	Toutes les méthodes de tracé de "PIGraphic" sont redéfinies pour 
+//	accepter les arguments en système de coordonnées utilisateur.
+//--
+//++
+// Links	Parent
+// PIGraphic
+//--
+
+// Pour echanger deux valeurs PIGrCoord
+static inline void dbl_swap(double& a, double& b) { double tmp = a; a = b; b = tmp; }
+
+//++
+// Titre	Constructeurs, méthodes
+//--
+//++
+// PIGraphicUC(PIGraphicGen* g, PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+//	Constructeur d'un objet "PIGraphUC" à partir d'un "PIGraphicGen* g". L'espace
+//	de travail du nouvel objet "PIGraphic" correspond au rectangle défini par
+//	"(x0,y0)" , "dx,dy" du "PIGraphic" de départ.
+// 
+// int  kind()
+//	Renvoie le type ("= PI_UCGraphics")
+// void SetBaseGraphic(PIGraphicGen* g, PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+//	Permet de modifier l'objet "PIGraphic" de départ et l'espace graphique correspondant.
+//
+// void  SelFontSz(PIGrCoord sz, PIFontAtt att=PI_RomanFont)
+//	Sélection de fonte avec la taille exprimée en coordonnées utilisateur
+// void  SelMarkerSz(PIGrCoord msz, PIMarker mrk=PI_DotMarker)
+//	Sélection de marker avec la taille exprimée en coordonnées utilisateur
+//--
+
+/* --Methode-- */
+PIGraphicUC::PIGraphicUC(PIGraphicGen* g, PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+  : PIGraphicGen()
+{
+  mGrC = g;
+  xW0 = x0;  yW0 = y0; 
+  xWd = dx;  yWd = dy; 
+  aXdir = false;  // Vrai si Axe X de Droite vers Gauche 
+  aYdir = false;  // Vrai si Axe Y de Haut vers Bas
+  SetUCS(0., 1., 0., 1., kAxeDirLtoR, kAxeDirDownUp);
+  clip = true;  
+}
+
+/* --Methode-- */
+PIGraphicUC::~PIGraphicUC()
+{
+}
+
+/* --Methode-- */
+int PIGraphicUC::kind() 
+{
+return PI_UCGraphics; 
+}
+
+
+/* --Methode-- */
+void PIGraphicUC::SetBaseGraphic(PIGraphicGen* g, PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+  mGrC = g;
+  xW0 = x0;  yW0 = y0; 
+  xWd = dx;  yWd = dy; 
+  SetUCS(xMin, xMax, yMin, yMax, kAxeDirSame, kAxeDirSame);
+}
+
+/* --Methode-- */
+void PIGraphicUC::GetGrSpace(PIGrCoord& xmin, PIGrCoord& xmax, PIGrCoord& ymin, PIGrCoord& ymax)
+{
+xmin = xMin;  ymin = yMin;  
+xmax = xMax;  ymax = yMax;
+}
+
+//++
+// Titre	Système de coordonnées utilisateur
+//--
+//++
+// void       SetUCS(double xmin, double xmax, double ymin, double ymax, -
+// int axrl=kAxeDirSame, int ayud=kAxeDirSame)
+//	Définit le système de coordonnées utilisateur. Axe X de "xmin" à "xmax" , 
+//	Axe Y de "ymin" à "ymax". "axrl", "ayud" définit le sens des axes 
+//	sur la fenêtre :
+//|	kAxeDirSame : Pas de changement de sens
+//|	kAxeDirLtoR : Axe X croissant de gauche à droite   
+//|	kAxeDirRtoL : Axe X croissant de droite à gauche 
+//|	kAxeDirDownUp : Axe Y croissant de Bas vers Haut
+//|	kAxeDirUpDown : Axe Y croissant de Haut vers Bas
+//|	kAxeDirAuto : Sens determine a partir de la valeur relative de xmin, xmax, ymin, ymax
+//|	              xmin < xmax : kAxeDirLtoR   -  xmax < xmin : kAxeDirRtoL
+//|	              ymin < ymax : kAxeDirDownUp -  ymax < ymin : kAxeDirUpDown
+//	Par défaut : "xmin=ymin=0." , "ymin=ymax=0." , "kAxeDirLtoR" , "kAxeDirDownUp"
+// 
+// void  UC2GrC(double x, double y, double& xpix, double& ypix)
+//	Transformation de coordonnées utilisateur "(x,y)" en coordoonnées 
+//	de l'espace graphic de départ "(xpix, ypix)"
+// void  GrC2UC(double xpix, double ypix, double& x, double& y)
+//	Transformation de coordonnées de l'espace graphic de départ. en coordonnées utilisateur.
+// void  DUC2GrC(double dx, double dy, double& dxpix, double& dypix)
+//	Transformation de distances selon X,Y en coordonnées utilisateur "dx, dy" en distance
+//	dans l'espace graphique de départ "dxpix , dypix".
+// void  DGrC2UC(double dxpix, double dypix, double& dx, double& dy)
+//	Transformation de distances selon X,Y dans l'espace graphique de départ en distance
+//	dans l'espace de  coordonnées utilisateur.
+//--
+
+/* --Methode-- */
+void PIGraphicUC::SetUCS(double xmin, double xmax, double ymin, double ymax,
+                         int axrl, int ayud)
+{
+
+  if (axrl == kAxeDirAuto) {
+    double ff;
+    if (xmax < xmin)  { axrl = kAxeDirRtoL;   ff=xmin;  xmin=xmax;  xmax=ff; }
+    else  axrl = kAxeDirLtoR;
+  }
+  if (ayud == kAxeDirAuto) {
+    double ff;
+    if (ymax < ymin)  { ayud = kAxeDirUpDown;   ff=ymin;  ymin=ymax;  ymax=ff; }
+    else  ayud = kAxeDirDownUp;
+  }
+
+  if (xmax <= xmin  || ymax <= ymin) {
+    cerr << "PIGraphicUC::SetUCS() Error - xmax <= xmin  || ymax <= ymin ! " << endl;
+    return; 
+    }
+#if defined(OSF1) || defined(SunOS) || (defined(Linux) && !defined(__KCC__) )
+  if (!finite(xmin) || !finite(xmax) || !finite(ymin) || !finite(ymax)) {
+    cerr << "PIGraphicUC::SetUCS() Error - Non finite value for x/ymin-max ! " << endl;
+    return; 
+    }
+#endif
+  if (axrl == kAxeDirLtoR)  aXdir = false;
+  else if (axrl == kAxeDirRtoL)  aXdir = true;
+  if (ayud == kAxeDirDownUp)  aYdir = false;
+  else if (ayud == kAxeDirUpDown)  aYdir = true;
+  xMin = xmin;
+  xMax = xmax;
+  yMin = ymin;
+  yMax = ymax;
+
+  xScale = xWd/(xMax-xMin);
+  if (xScale < 1.e-19)  xScale = 1.e-19;  // Protection 
+  if (aXdir)  { 
+    xScale = -xScale;
+    xOrg   = -xMax * xScale;
+  }
+  else xOrg   = -xMin * xScale;
+  xOrg += xW0;
+
+  yScale = yWd/(yMax-yMin);
+  if (yScale < 1.e-19)  yScale = 1.e-19;  // Protection 
+  if (!aYdir) {
+    yScale = -yScale;
+    yOrg   = -yMax  * yScale;
+    }
+  else yOrg   = -yMin * yScale;
+  yOrg += yW0;
+  return;
+}
+
+
+/* --Methode-- */
+void PIGraphicUC::UC2GrC(double x, double y, double& xpix, double& ypix)
+{
+  xpix = (double)(xOrg + x*xScale);  
+  ypix = (double)(yOrg + y*yScale);  
+}
+
+/* --Methode-- */
+void PIGraphicUC::GrC2UC(double xpix, double ypix, double& x, double& y)
+{
+  x = (xpix-xOrg)/xScale;
+  y = (ypix-yOrg)/yScale;
+}
+
+/* --Methode-- */
+void PIGraphicUC::DUC2GrC(double dx, double dy, double& dxpix, double& dypix)
+{
+  dxpix = dx*xScale;
+  if (dxpix < 0)  dxpix = -dxpix;
+  dypix = dy*yScale;
+  if (dypix < 0)  dypix = -dypix;
+}
+
+/* --Methode-- */
+void PIGraphicUC::DGrC2UC(double dxpix, double dypix, double& dx, double& dy)
+{
+  dx = dxpix/xScale;
+  dy = dypix/yScale;
+  if (dx < 0.) dx = -dx;
+  if (dy < 0.) dy = -dy;
+}
+
+/* --Methode-- */
+void PIGraphicUC::Erase(PIGrCoord xc, PIGrCoord yc, PIGrCoord dxc, PIGrCoord dyc)
+{
+  if (!mGrC) return;
+  double x, y, dx, dy;
+  x = xc;  dx = dxc;
+  y = yc;  dy = dyc;
+  if (clip) {
+    if (dx < 0) {
+      x = x+dx;
+      dx = -dx;
+    }
+    if (dy < 0) {
+      y = y+dy;
+      dy = -dy;
+    }
+    if (x > xMax || x+dx < xMin || y > yMax || y+dy < yMin) return;
+    if (x < xMin) {
+      dx -= (xMin-x);
+      x = xMin;
+    }
+    if (y < yMin) {
+      dy -= (yMin-y);
+      y = yMin;
+    }
+    if (x+dx > xMax)
+      dx = (xMax-x);
+    if (y+dy > yMax)
+      dy = (yMax-y);
+  }
+
+  double xf, yf, xf2, yf2;
+  UC2GrC(x, y, xf, yf);
+  UC2GrC(x+dx, y+dy, xf2, yf2);
+  if (xf2 < xf)  dbl_swap(xf, xf2);
+  if (yf2 < yf)  dbl_swap(yf, yf2);
+  mGrC->Erase(xf, yf, xf2-xf, yf2-yf);
+}
+
+/* --Methode-- */
+void PIGraphicUC::DrawString(PIGrCoord x, PIGrCoord y, const char* s, int pos)
+{
+  if (!mGrC) return;
+  double xf, yf;
+  UC2GrC(x, y, xf, yf);
+  mGrC->DrawString(xf, yf, s, pos);  
+}
+
+/* --Methode-- */
+void PIGraphicUC::DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int pos)
+{
+  if (!mGrC) return;
+  double xf, yf;
+  UC2GrC(x, y, xf, yf);
+  mGrC->DrawOpaqueString(xf, yf, s, pos);  
+}
+
+/* --Methode-- */
+void PIGraphicUC::DrawLine(PIGrCoord xc1, PIGrCoord yc1, PIGrCoord xc2, PIGrCoord yc2)
+{
+  
+  if (!mGrC) return;
+  double x1, y1, x2, y2;
+  x1 = xc1;  y1 = yc1;
+  x2 = xc2;  y2 = yc2;
+  if (clip) {
+    if (x2 < xMin && x1 < xMin) return;
+    if (x2 > xMax && x1 > xMax) return;
+    if (y1 < yMin && y2 < yMin) return;
+    if (y1 > yMax && y2 > yMax) return;
+    if (x2 < x1) {
+      dbl_swap(x1,x2);
+      dbl_swap(y1,y2);
+    }
+    if (x2>xMax) {
+      y2 = y1 + (y2-y1)/(x2-x1)*(xMax-x1);
+      x2 = xMax;
+    }
+    if (x1<xMin) {
+      y1 = y2 + (y1-y2)/(x1-x2)*(xMin-x2);
+      x1 = xMin;
+    }
+    if (y2 < y1) {
+      dbl_swap(x1,x2);
+      dbl_swap(y1,y2);
+    }
+    if (y2>yMax) {
+      x2 = x1 + (x2-x1)/(y2-y1)*(yMax-y1);
+      y2 = yMax;
+    }
+    if (y1<yMin) {
+      x1 = x2 + (x1-x2)/(y1-y2)*(yMin-y2);
+      y1 = yMin;
+    }
+  }
+
+  double xf1, yf1, xf2, yf2;
+  UC2GrC(x1, y1, xf1, yf1);
+  UC2GrC(x2, y2, xf2, yf2);
+  mGrC->DrawLine(xf1, yf1, xf2, yf2);
+
+}  
+
+
+/* --Methode-- */
+void PIGraphicUC::DrawBox(PIGrCoord xc, PIGrCoord yc, PIGrCoord dxc, PIGrCoord dyc)
+{
+  if (!mGrC) return;
+  double x, y, dx, dy;
+  x = xc;  dx = dxc;
+  y = yc;  dy = dyc;
+  if (clip) {
+    if (dx < 0) {
+      x = x+dx;
+      dx = -dx;
+    }
+    if (dy < 0) {
+      y = y+dy;
+      dy = -dy;
+    }
+    if (x > xMax || x+dx < xMin || y > yMax || y+dy < yMin) return;
+    if (x < xMin) {
+      dx -= (xMin-x);
+      x = xMin;
+    }
+    if (y < yMin) {
+      dy -= (yMin-y);
+      y = yMin;
+    }
+    if (x+dx > xMax)
+      dx = (xMax-x);
+    if (y+dy > yMax)
+      dy = (yMax-y);
+  }
+
+  double xf, yf, xf2, yf2;
+  UC2GrC(x, y, xf, yf);
+  UC2GrC(x+dx, y+dy, xf2, yf2);
+  if (xf2 < xf)  dbl_swap(xf, xf2);
+  if (yf2 < yf)  dbl_swap(yf, yf2);
+  mGrC->DrawBox(xf, yf, xf2-xf, yf2-yf);
+}  
+
+/* --Methode-- */
+void PIGraphicUC::DrawFBox(PIGrCoord xc, PIGrCoord yc, PIGrCoord dxc, PIGrCoord dyc)
+{
+  if (!mGrC) return;
+  double x, y, dx, dy;
+  x = xc;  dx = dxc;
+  y = yc;  dy = dyc;
+  if (clip) {
+    if (dx < 0) {
+      x = x+dx;
+      dx = -dx;
+    }
+    if (dy < 0) {
+      y = y+dy;
+      dy = -dy;
+    }
+    if (x > xMax || x+dx < xMin || y > yMax || y+dy < yMin) return;
+    if (x < xMin) {
+      dx -= (xMin-x);
+      x = xMin;
+    }
+    if (y < yMin) {
+      dy -= (yMin-y);
+      y = yMin;
+    }
+    if (x+dx > xMax)
+      dx = (xMax-x);
+    if (y+dy > yMax)
+      dy = (yMax-y);
+  }
+
+  double xf, yf, xf2, yf2;
+  UC2GrC(x, y, xf, yf);
+  UC2GrC(x+dx, y+dy, xf2, yf2);
+  if (xf2 < xf)  dbl_swap(xf, xf2);
+  if (yf2 < yf)  dbl_swap(yf, yf2);
+  mGrC->DrawFBox(xf, yf, xf2-xf, yf2-yf);
+}  
+
+/* --Methode-- */
+void PIGraphicUC::DrawCircle(PIGrCoord x, PIGrCoord y, PIGrCoord r)
+{
+  if (!mGrC) return;
+
+  double xf, yf, rf,rfy;
+  UC2GrC(x, y, xf, yf);
+  DUC2GrC(r,r,rf,rfy);
+  rf = 0.5*(rf+rfy);
+  mGrC->DrawCircle(xf, yf, rf);
+}  
+
+/* --Methode-- */
+void PIGraphicUC::DrawFCircle(PIGrCoord x, PIGrCoord y, PIGrCoord r)
+{
+  if (!mGrC) return;
+
+  double xf, yf, rf, rfy;
+  UC2GrC(x, y, xf, yf);
+  DUC2GrC(r,r,rf,rfy);
+  rf = 0.5*(rf+rfy);
+  mGrC->DrawFCircle(xf, yf, rf);
+}
+
+/* --Methode-- */
+void PIGraphicUC::DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+  if (!mGrC) return;
+
+  double xf, yf, dxf, dyf;
+  UC2GrC(x0, y0, xf, yf);
+  DUC2GrC(dx, dy, dxf, dyf);
+  mGrC->DrawOval(xf, yf, dxf, dyf);
+}
+
+/* --Methode-- */
+void PIGraphicUC::DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+  if (!mGrC) return;
+
+  double xf, yf, dxf, dyf;
+  UC2GrC(x0, y0, xf, yf);
+  DUC2GrC(dx, dy, dxf, dyf);
+  mGrC->DrawFOval(xf, yf, dxf, dyf);
+}
+
+#define NMXMULTP  30   // Pour multipoint sans new
+
+/* --Methode-- */
+void PIGraphicUC::DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc)
+{
+  PIGrCoord xc[NMXMULTP], yc[NMXMULTP];
+  PIGrCoord *pxc, *pyc;
+  int i;
+  double xf, yf;
+ 
+  if (!mGrC) return;
+  if (n <= 0)  return;
+
+  if (n > NMXMULTP) { pxc = new PIGrCoord[n];  pyc = new PIGrCoord[n]; }
+  else { pxc = xc;  pyc = yc; }
+  for(i=0; i<n; i++) {
+    UC2GrC(x[i], y[i], xf, yf);
+    pxc[i] = xf;  pyc[i] = yf; 
+  }
+  mGrC->DrawPolygon(pxc, pyc, n, cinc);
+  if (n > NMXMULTP) { delete[] pxc;  delete[] pyc; }
+  return;
+}
+  
+/* --Methode-- */
+void PIGraphicUC::DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc)
+{
+  PIGrCoord xc[NMXMULTP], yc[NMXMULTP];
+  PIGrCoord *pxc, *pyc;
+  int i;
+  double xf, yf;
+ 
+  if (!mGrC) return;
+  if (n <= 0)  return;
+
+  if (n > NMXMULTP) { pxc = new PIGrCoord[n];  pyc = new PIGrCoord[n]; }
+  else { pxc = xc;  pyc = yc; }
+  for(i=0; i<n; i++) {
+    UC2GrC(x[i], y[i], xf, yf);
+    pxc[i] = xf;  pyc[i] = yf; 
+  }
+  mGrC->DrawFPolygon(pxc, pyc, n, cinc);
+  if (n > NMXMULTP) { delete[] pxc;  delete[] pyc; }
+  return;
+}
+
+
+/* --Methode-- */
+void PIGraphicUC::DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
+                          double degdeb, double degfin)
+{
+  if (!mGrC) return;
+
+  double xf, yf, dxf, dyf;
+  UC2GrC(x0, y0, xf, yf);
+  DUC2GrC(dx, dy, dxf, dyf);
+  mGrC->DrawArc(xf, yf, dxf, dyf, degdeb, degfin);
+}
+/* --Methode-- */
+void PIGraphicUC::DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
+                           double degdeb, double degfin)
+{
+  if (!mGrC) return;
+
+  double xf, yf, dxf, dyf;
+  UC2GrC(x0, y0, xf, yf);
+  DUC2GrC(dx, dy, dxf, dyf);
+  mGrC->DrawFArc(xf, yf, dxf, dyf, degdeb, degfin);
+}
+
+/* --Methode-- */
+void PIGraphicUC::DrawMarker(PIGrCoord x0, PIGrCoord y0)
+{
+  if (!mGrC) return;
+  double xf, yf;
+  UC2GrC(x0, y0, xf, yf);
+  mGrC->DrawMarker(xf, yf);
+  return;
+}
+
+/* --Methode-- */
+void PIGraphicUC::DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n)
+{
+  PIGrCoord xc[NMXMULTP], yc[NMXMULTP];
+  PIGrCoord *pxc, *pyc;
+  int i;
+  double xf, yf;
+ 
+  if (!mGrC) return;
+  if (n <= 0)  return;
+
+  if (n > NMXMULTP) { pxc = new PIGrCoord[n];  pyc = new PIGrCoord[n]; }
+  else { pxc = xc;  pyc = yc; }
+  for(i=0; i<n; i++) {
+    UC2GrC(x[i], y[i], xf, yf);
+    pxc[i] = xf;  pyc[i] = yf; 
+  }
+  mGrC->DrawMarkers(pxc, pyc, n);
+  if (n > NMXMULTP) { delete[] pxc;  delete[] pyc; }
+  return;
+}
+
+/* --Methode-- */
+void PIGraphicUC::DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix,
+                        int sx, int sy, PIColorMap* cmap)
+{
+  if (!mGrC) return;
+  if ( (sx < 1) || (sy < 1) )  return;
+  if ((pix == NULL) || (cmap == NULL)) return; 
+  double xf,yf;
+  UC2GrC(x, y, xf, yf);
+  mGrC->DrawPixmap(xf, yf, pix, sx, sy, cmap);
+}
+
+
+
+/* --Methode-- */
+void PIGraphicUC::SelForeground(PIColors col)
+{
+  if (!mGrC) return;
+  mGrC->SelForeground(col);
+  return;  
+}
+
+
+/* --Methode-- */
+void PIGraphicUC::SelBackground(PIColors col)
+{
+  if (!mGrC) return;
+  mGrC->SelBackground(col);
+  return;  
+}
+
+/* --Methode-- */
+void PIGraphicUC::SelForeground(PIColorMap& cmap, int cid)
+{
+  if (!mGrC) return;
+  mGrC->SelForeground(cmap, cid);
+  return;  
+}
+
+
+/* --Methode-- */
+void PIGraphicUC::SelBackground(PIColorMap& cmap, int cid)
+{
+  if (!mGrC) return;
+  mGrC->SelBackground(cmap, cid);
+  return;  
+}
+
+/* --Methode-- */
+void PIGraphicUC::SelGOMode(PIGOMode mod)
+{
+  if (!mGrC) return;
+  mGrC->SelGOMode(mod);
+  return;  
+}
+
+/* --Methode-- */
+void PIGraphicUC::SelFont(PIFont & fnt)
+{
+  if (!mGrC) return;
+  mGrC->SelFont(fnt);
+  myFont = mGrC->GetFont();
+  return;  
+}
+
+/* --Methode-- */
+void PIGraphicUC::SelFont(PIFontSize sz, PIFontAtt att)
+{
+  if (!mGrC) return;
+  mGrC->SelFont(sz, att);
+  myFont = mGrC->GetFont();
+  return;  
+}
+
+/* --Methode-- */
+void PIGraphicUC::SelFontSzPt(int npt, PIFontAtt att)
+{
+  if (!mGrC) return;
+  mGrC->SelFontSzPt(npt, att);
+  myFont = mGrC->GetFont();
+  return;  
+}
+
+
+/* --Methode-- */
+void PIGraphicUC::SelLine(PILineAtt att)
+{
+  if (!mGrC) return;
+  mGrC->SelLine(att);
+  return;  
+}
+
+/* --Methode-- */
+void PIGraphicUC::SelMarker(int msz, PIMarker mrk)
+{
+  if (!mGrC) return;
+  mGrC->SelMarker( msz, mrk);
+}
+
+/* --Methode-- */
+void PIGraphicUC::SelFontSz(PIGrCoord sz, PIFontAtt att)
+{
+  if (!mGrC) return;
+  double fx, fy;
+  DUC2GrC((double)sz, (double)sz, fx, fy);
+  int npt = (int)fy;
+  if (npt < 6) npt = 6;
+  if (npt > 127) npt = 127;
+  mGrC->SelFontSzPt(npt, att);
+  myFont = mGrC->GetFont();
+}
+
+
+/* --Methode-- */
+void PIGraphicUC::SelMarkerSz(PIGrCoord sz, PIMarker mrk)
+{
+  if (!mGrC) return;
+  double fx, fy;
+  DUC2GrC((double)sz, (double)sz, fx, fy);
+  int isz = int(0.5*(fx+fy+1));
+  mGrC->SelMarker( isz, mrk);
+}
+
+/* --Methode-- */
+void PIGraphicUC::SetClipRectangle(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+  /* $CHECK$  A faire Reza 08/02/97  */
+return;
+}
+/* --Methode-- */
+void PIGraphicUC::ClearClipRectangle()
+{
+  /* $CHECK$  A faire Reza 08/02/97  */
+return;
+}
+
+/* --Methode-- */
+PIColors PIGraphicUC::GetForeground()
+{
+  if (!mGrC) return(PI_NotDefColor);
+  return(mGrC->GetForeground());
+}
+
+/* --Methode-- */
+PIColors PIGraphicUC::GetBackground()
+{
+  if (!mGrC) return(PI_NotDefColor);
+  return(mGrC->GetBackground());
+}
+
+/* --Methode-- */
+PIGOMode PIGraphicUC::GetGOMode()
+{
+  if (!mGrC) return(PI_GOCopy);
+  return(mGrC->GetGOMode());
+}
+
+
+/* --Methode-- */
+PILineAtt PIGraphicUC::GetLineAtt()
+{
+  if (!mGrC) return(PI_NotDefLineAtt);
+  return(mGrC->GetLineAtt());
+}
+
+/* --Methode-- */
+PIMarker PIGraphicUC::GetMarker()
+{
+  if (!mGrC) return(PI_NotDefMarker);
+  return(mGrC->GetMarker());
+}
+
+/* --Methode-- */
+int PIGraphicUC::GetMarkerSize()
+{
+  if (!mGrC) return(0);
+  return(mGrC->GetMarkerSize());
+}
+/* --Methode-- */
+PIGrCoord PIGraphicUC::GetFontHeight(PIGrCoord& asc, PIGrCoord& desc)
+{
+  asc = desc = 0;
+  if (!mGrC) return(0);
+  int h,a,d;
+  double fh, fa, fd, x;
+  h = myFont.GetFontHeight(a, d) ;
+  DGrC2UC(0., h, x, fh);
+  DGrC2UC(0., a, x, fa);
+  DGrC2UC(0., d, x, fd);
+  asc = a;  desc = d;
+  return(fh);
+}
+
+
+/* --Methode-- */
+PIGrCoord PIGraphicUC::CalcStringWidth(char const* s)
+{
+  if (!mGrC) return(0.);
+  double dx = myFont.GetStringWidth(s);
+  double dxx, dxy;
+  DGrC2UC(dx, dx, dxx, dxy);
+  return(dxx);
+}
+
+
+/* --Methode-- */
+void PIGraphicUC::SaveGraphicAtt()
+{
+  if (!mGrC) return;
+  mGrC->SaveGraphicAtt();
+}
+
+/* --Methode-- */
+void PIGraphicUC::RestoreGraphicAtt()
+{
+  if (!mGrC) return;
+  mGrC->RestoreGraphicAtt();
+}
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pigraphuc.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pigraphuc.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pigraphuc.h	(revision 464)
@@ -0,0 +1,121 @@
+// Module PI : Peida Interactive     PIGraphicUC 
+// Trace graphiques User-Coordinates    R. Ansari  97
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIGRAPHICUC_H_SEEN
+#define PIGRAPHICUC_H_SEEN
+
+#include "pisysdep.h"
+#include "pigraphgen.h"
+
+enum {
+  kAxeDirSame     = 0,
+  kAxeDirLtoR     = 1,
+  kAxeDirRtoL     = 2,
+  kAxeDirDownUp   = 4,
+  kAxeDirUpDown   = 8,
+  kAxeDirAuto     = 255
+};
+
+class PIGraphicUC : public PIGraphicGen
+{
+public:
+                     PIGraphicUC(PIGraphicGen* g, PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual           ~PIGraphicUC();
+
+  virtual int        kind();
+
+  virtual void       SetBaseGraphic(PIGraphicGen* g, PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+
+//  Espace des coordonnees
+  virtual void       GetGrSpace(PIGrCoord& xmin, PIGrCoord& xmax, PIGrCoord& ymin, PIGrCoord& ymax);
+
+//  Definition des coordonnees utilisateur
+  virtual void       SetUCS(double xmin, double xmax, double ymin, double ymax,
+                            int axrl=kAxeDirSame, int ayud=kAxeDirSame);     
+
+//  Trace graphiques
+  virtual void       Erase(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0);
+  virtual void       DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0);
+  virtual void       DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2);
+  virtual void       DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawFBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r);
+  virtual void       DrawFCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r);
+  virtual void       DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true);  
+  virtual void       DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true); 
+  virtual void       DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
+                             double degdeb, double degfin);
+  virtual void       DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 
+                              double degdeb, double degfin);
+ 
+  virtual void       DrawMarker(PIGrCoord x0, PIGrCoord y0);
+  virtual void       DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n);
+  virtual void       DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix, 
+                                int sx, int sy, PIColorMap* cmap);
+
+// Modifications attributs graphiques
+  virtual void       SelForeground(PIColors col=PI_Black);
+  virtual void       SelBackground(PIColors col=PI_White);
+  virtual void       SelForeground(PIColorMap& cmap, int cid);
+  virtual void       SelBackground(PIColorMap& cmap, int cid);
+  virtual void       SelGOMode(PIGOMode mod=PI_GOCopy);
+  virtual void       SelLine(PILineAtt att=PI_NormalLine);
+  virtual void       SelMarker(int msz=3, PIMarker mrk=PI_DotMarker);
+
+// Modification de fonte
+  virtual void       SelFont(PIFont & fnt);
+  virtual void       SelFont(PIFontSize sz=PI_NormalSizeFont, 
+                             PIFontAtt att=PI_RomanFont);
+  virtual void       SelFontSzPt(int npt=12, PIFontAtt att=PI_RomanFont);
+//  Fonctions specifiques a PIGraphicUC :
+  virtual void       SelFontSz(PIGrCoord sz, PIFontAtt att=PI_RomanFont);
+  virtual void       SelMarkerSz(PIGrCoord msz, PIMarker mrk=PI_DotMarker);
+
+// Selection de zone de trace (clip)
+  virtual void       SetClipRectangle(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       ClearClipRectangle();
+
+// Acces aux attributs graphiques 
+  virtual PIColors   GetForeground();
+  virtual PIColors   GetBackground();
+  virtual PIGOMode   GetGOMode();
+  virtual PILineAtt  GetLineAtt();
+  virtual PIMarker   GetMarker();
+  virtual int        GetMarkerSize();
+
+  virtual PIGrCoord  GetFontHeight(PIGrCoord& asc, PIGrCoord& desc);
+  virtual PIGrCoord  CalcStringWidth(char const* s);
+
+
+// Sauvegarde des attributs graphiques 
+  virtual void       SaveGraphicAtt();
+  virtual void       RestoreGraphicAtt();
+
+//  Transformation des ccordonnees
+  virtual void       UC2GrC(double x, double y, double& xpix, double& ypix);
+  virtual void       GrC2UC(double xpix, double ypix, double& x, double& y);
+  virtual void       DUC2GrC(double dx, double dy, double& dxpix, double& dypix);
+  virtual void       DGrC2UC(double dxpix, double dypix, double& dx, double& dy);
+
+  void   NoClip() {clip = false; }
+  void   Clip() {clip = true; }
+  inline PIGraphicGen*  BaseGraphic() { return(mGrC); }
+
+protected:
+
+  PIGraphicGen* mGrC;
+
+  double xMin, xMax, yMin, yMax; // Valeurs en unites user
+  double xOrg, yOrg;             // Position en pixels de (0.0, 0.0)
+  double xScale, yScale;         // Pixels par unites graphiques
+  double xW0, yW0, xWd, yWd;        // Origine/largeur ds la fenetre de trace
+  bool   aXdir, aYdir;           // Sens des axes horiz, vertical 
+  bool   clip;
+};
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pigraphx.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pigraphx.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pigraphx.cc	(revision 464)
@@ -0,0 +1,725 @@
+// Module PI : Peida Interactive     PIGraphicX
+// Trace graphiques- Implementation X11  R. Ansari  97
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include <stdio.h>
+#include <math.h>
+
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+
+#include "pigraphx.h"
+
+
+/*  Variables globales pour modifier les GC  */
+#define NMAXCOL  18
+static  PIXColor colpix[NMAXCOL];
+
+/*  GC pour DrawPixmap   */
+static GC dpxgc;
+
+// #define DEBUG_PIBWDGX     Flag pour impression de debug etc ...
+
+/* --Methode-- */
+PIGraphicX::PIGraphicX(PIWdg* wdg)
+: PIGraphicGen(wdg)
+{
+
+GlInit();
+
+if (MyWdg()) {
+  mDisp = XtDisplay(MyWdg());       // Structure Display X associe
+  mWId = XtWindow(MyWdg());   // Le drawable X
+  }
+else mDisp = PIXDisplay();       // Structure Display X associe
+
+XGCValues  xgv;
+xgv.function = GXcopy;
+xgv.plane_mask = ~0;
+mDefGC = XCreateGC (PIXDisplay(), XtWindow(PIXtTopWdg()), GCFunction | GCPlaneMask, &xgv);
+
+Init();
+}
+
+/* --Methode-- */
+PIGraphicX::PIGraphicX(PIScreenBuffer* grb)
+: PIGraphicGen(grb)
+{
+GlInit();
+
+mDisp = PIXDisplay();       // Structure Display X associe
+mWId = grb->XScrBuffer();
+
+XGCValues  xgv;
+xgv.function = GXcopy;
+xgv.plane_mask = ~0;
+mDefGC = XCreateGC (mDisp, mWId, GCFunction | GCPlaneMask, &xgv);
+Init();
+}
+
+
+/* --Methode-- */
+void PIGraphicX::Init()
+{
+mGOm = PI_GOCopy;
+mFCol = mBCol = PI_Grey;
+SelForeground(PI_Black);
+SelBackground(PI_White);
+mLAtt = PI_ThinLine;
+ XSetFont(mDisp, DefGC(), myFont.GetXFontId());  // Pour initialiser la fonte ds le GC 
+SelLine();
+SelMarker(1, PI_DotMarker);  
+mFCfMap = colpix[PI_Black];  mBCfMap = colpix[PI_White];
+}
+
+/* --Methode-- */
+PIGraphicX::~PIGraphicX()
+{
+XFreeGC(mDisp, mDefGC);
+}
+
+/* --Methode-- */
+int PIGraphicX::kind()
+{
+if (myWdg != NULL) return (PI_ScrWindowGraphics);
+else if (myGrb != NULL) return (PI_ScrBufferGraphics);
+else return(PI_UnknownGraphics);
+}
+
+/* --Methode-- */
+void PIGraphicX::TerminateInit()
+{
+if (MyWdg() == NULL)  { fprintf(stderr, "BUG/PIGraphicX::TerminateInit() for NULL Wdg \n"); return; }
+mDisp = XtDisplay(MyWdg());       // Structure Display X associe
+mWId = XtWindow(MyWdg());   // Le drawable X
+}
+
+/* --Methode-- */
+void PIGraphicX::Erase(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+XClearArea (mDisp,mWId, (int)x0, (int)y0, (int)dx, (int)dy, False );
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::DrawString(PIGrCoord x, PIGrCoord y, const char* s, int /*pos*/)
+{
+XDrawString (XtDisplay (MyWdg()),mWId, 
+                  DefGC(), (int)x, (int)y, s, strlen(s));
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int /*pos*/)
+{
+XDrawImageString (XtDisplay (MyWdg()),mWId, 
+                  DefGC(), (int)x, (int)y, s, strlen(s));
+return;
+}
+
+ 
+/* --Methode-- */
+void PIGraphicX::DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2)
+{
+XDrawLine(XtDisplay (MyWdg()), mWId, DefGC(), (int)x1, (int)y1, (int)x2, (int)y2);
+return;
+}
+
+
+/* --Methode-- */
+void PIGraphicX::DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+int ix0 = x0;
+int iy0 = y0;
+int idx = dx;
+int idy = dy;
+if (idx < 0)  { ix0 += idx;  idx = -idx; }
+if (idy < 0)  { iy0 += idy;  idy = -idy; }
+XDrawRectangle(XtDisplay (MyWdg()), mWId, 
+               DefGC(), ix0, iy0, idx, idy);
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::DrawFBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+int ix0 = x0;
+int iy0 = y0;
+int idx = dx;
+int idy = dy;
+if (idx < 0)  { ix0 += idx;  idx = -idx; }
+if (idy < 0)  { iy0 += idy;  idy = -idy; }
+XFillRectangle(XtDisplay (MyWdg()), mWId, 
+               DefGC(), ix0, iy0, idx, idy);
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::DrawCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r)
+{
+XDrawArc(XtDisplay (MyWdg()), mWId, DefGC(),
+         (int)x0-(int)r, (int)y0-(int)r, 2*(int)r, 2*(int)r, 0, 360*64);
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::DrawFCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r)
+{
+XFillArc(XtDisplay (MyWdg()), mWId, DefGC(),
+         (int)x0-(int)r, (int)y0-(int)r, 2*(int)r, 2*(int)r, 0, 360*64);
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+XDrawArc(XtDisplay (MyWdg()), mWId, DefGC(),
+         (int)x0, (int)y0, (int)dx, (int)dy, 0, 360*64);
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+XFillArc(XtDisplay (MyWdg()), mWId, DefGC(),
+         (int)x0, (int)y0, (int)dx, (int)dy, 0, 360*64);
+return;
+}
+
+// Pour les fonctions de trace avec un plusieurs coordonnees
+#define NMXXPOINTS  30 
+
+/* --Methode-- */
+void PIGraphicX::DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc)
+{
+XPoint multipoint[NMXXPOINTS];
+XPoint *pxp;
+int i;
+
+if (n <= 0)  return;
+if (n > NMXXPOINTS)  pxp = new XPoint[n];
+else pxp = multipoint;
+for(i=0; i<n; i++)  { pxp[i].x = x[i];  pxp[i].y = y[i]; } 
+int mode = CoordModeOrigin;
+if (cinc) mode =  CoordModePrevious;
+XDrawLines(mDisp, mWId, DefGC(), pxp, n, mode);
+if (n > NMXXPOINTS)  delete[] pxp;
+
+return;
+}
+
+
+/* --Methode-- */
+void PIGraphicX::DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc)
+{
+XPoint multipoint[NMXXPOINTS];
+XPoint *pxp;
+int i;
+
+if (n <= 0)  return;
+if (n > NMXXPOINTS)  pxp = new XPoint[n];
+else pxp = multipoint;
+for(i=0; i<n; i++)  { pxp[i].x = x[i];  pxp[i].y = y[i]; } 
+int mode = CoordModeOrigin;
+if (cinc) mode =  CoordModePrevious;
+XFillPolygon(XtDisplay (MyWdg()), mWId, DefGC(), pxp, n, 
+                        Complex, mode);
+if (n > NMXXPOINTS)  delete[] pxp;
+
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 
+                         double degdeb, double degfin)
+{
+XDrawArc(XtDisplay (MyWdg()), mWId, DefGC(),
+         (int)x0, (int)y0, (int)dx, (int)dy, (int)(degdeb*64.), (int)(degfin*64.));
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 
+                         double degdeb, double degfin)
+{
+XFillArc(XtDisplay (MyWdg()), mWId, DefGC(),
+         (int)x0, (int)y0, (int)dx, (int)dy, (int)(degdeb*64.), (int)(degfin*64.));
+return;
+}
+
+// Coordonnees pour tracer une etoile a 5 branches 
+static float starcoordx[10], starcoordy[10];
+
+/* --Methode-- */
+void PIGraphicX::DrawMarker(PIGrCoord x0, PIGrCoord y0)
+{
+float hmsz = mMrkSz/2;
+float dmsz = mMrkSz-hmsz;
+PIGrCoord x[11],y[11];
+int k;
+PILineAtt clatt;
+
+if (mMrk == PI_DotMarker)
+  XDrawPoint(mDisp, mWId, DefGC(), (int)x0, (int)y0);
+
+else  {
+  clatt = mLAtt;
+  SelLine(PI_ThinLine);
+  switch (mMrk) {
+    case  PI_PlusMarker :
+      DrawLine((float)x0-hmsz, y0, (float)x0+dmsz, y0);
+      DrawLine(x0, (float)y0-hmsz, x0, (float)y0+dmsz);
+      break;
+    case  PI_CrossMarker :
+      DrawLine((float)x0-hmsz, (float)y0-hmsz, (float)x0+dmsz, (float)y0+dmsz);
+      DrawLine((float)x0-hmsz, (float)y0+dmsz, (float)x0+dmsz, (float)y0-hmsz);
+      break;  
+    case PI_CircleMarker :
+      DrawCircle(x0, y0, hmsz);
+      break;
+    case PI_FCircleMarker :
+      DrawFCircle(x0, y0, hmsz);
+      break;
+    case PI_BoxMarker :
+      DrawBox((float)x0-hmsz, (float)y0-hmsz, mMrkSz, mMrkSz);
+      break;
+    case PI_FBoxMarker :
+      DrawFBox((float)x0-hmsz, (float)y0-hmsz, mMrkSz, mMrkSz);
+      break;
+    case  PI_TriangleMarker :
+      x[1] = mMrkSz; y[1] = 0; x[2] = -hmsz; y[2] = -mMrkSz; 
+      x[3] = -dmsz; y[3] = +mMrkSz; x[0] = (float)x0-hmsz; y[0] = (float)y0+hmsz;  
+      DrawPolygon(x, y, 4);
+      break;
+    case  PI_FTriangleMarker :
+      x[1] = mMrkSz; y[1] = 0; x[2] = -hmsz; y[2] = -mMrkSz; 
+      x[3] = -dmsz; y[3] = +mMrkSz; x[0] = (float)x0-hmsz; y[0] = (float)y0+hmsz;  
+      DrawFPolygon(x, y, 4);
+      break;
+    case  PI_StarMarker :
+    case  PI_FStarMarker :
+      for(k=0; k<10; k++) {
+        x[k] = (int)(starcoordx[k]*(float)mMrkSz+(float)x0+0.5);
+        y[k] = (int)(starcoordy[k]*(float)mMrkSz+(float)y0+0.5);
+        }
+      x[10] = x[0];   y[10] = y[0];
+      if (mMrk == PI_StarMarker)  DrawPolygon(x, y, 11, false);
+      else DrawFPolygon(x, y, 11, false);
+      break;
+    default :
+      XDrawPoint(mDisp, mWId, DefGC(), x0, y0);
+      break;
+    }
+  SelLine(clatt);
+  }
+
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n)
+{
+int i;
+if (n <= 0)  return;
+if (mMrk == PI_DotMarker)
+  {
+  XPoint multipoint[NMXXPOINTS];
+  XPoint *pxp;
+  if (n > NMXXPOINTS)  pxp = new XPoint[n];
+  else pxp = multipoint;
+  for(i=0; i<n; i++)  { pxp[i].x = x[i];  pxp[i].y = y[i]; } 
+  XDrawPoints(mDisp, mWId, DefGC(), pxp, n, CoordModeOrigin);
+  if (n > NMXXPOINTS)  delete[] pxp;  
+  }
+else for(i=0; i<n; i++) DrawMarker(x[i], y[i]);
+
+return;
+}
+
+
+/* --Methode-- */
+void PIGraphicX::DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix, 
+                            int sx, int sy, PIColorMap* cmap)
+{
+Window xw;
+Display * mdsp;
+int scr;
+int depth;
+int pad;
+int i,j;
+XImage * ximg;
+
+if ( (sx < 1) || (sy < 1) )  return;
+if ((pix == NULL) || (cmap == NULL)) return; 
+
+  
+xw = mWId;
+mdsp = PIXDisplay();
+scr = PIXScreen();
+
+depth = DefaultDepth(mdsp,scr);
+pad = (depth > 8) ? 32 : 8;
+ximg = XCreateImage (mdsp,DefaultVisual(mdsp,scr),
+                     depth,ZPixmap,0,NULL, sx, sy, pad,0);
+if (ximg == NULL)  return;
+ximg->data = new char [sy*ximg->bytes_per_line];
+if (ximg->data == NULL)  
+  { XFree(ximg); return; }
+
+for(j=0; j<sy; j++)
+  for(i=0; i<sx; i++)
+    { XPutPixel(ximg, i, j, cmap->Color(*pix) );  pix++; }
+
+XPutImage(mdsp, xw, dpxgc, ximg, 0, 0, (int)x, (int)y, sx, sy);
+
+delete[] ximg->data;
+XFree(ximg); 
+return;
+}
+
+
+
+/* --Methode-- */
+void PIGraphicX::SelForeground(PIColors col)
+{
+if (col == mFCol)  return;
+if ( (col < 0) || (col >= NMAXCOL))  return;
+XSetForeground(mDisp, DefGC(), colpix[col]); 
+mFCol = col;  
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::SelBackground(PIColors col)
+{
+if (col == mBCol)  return;
+if ( (col < 0) || (col >= NMAXCOL))  return;
+XSetBackground(mDisp, DefGC(), colpix[col]); 
+mBCol = col;  
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::SelForeground(PIColorMap& cmap, int cid)
+{
+SelectFCol(cmap.Color(cid));
+}
+
+/* --Methode-- */
+void PIGraphicX::SelBackground(PIColorMap& cmap, int cid)
+{
+SelectBCol(cmap.Color(cid));
+}
+
+/* --Methode-- */
+void PIGraphicX::SelGOMode(PIGOMode mod)
+{
+if (mod == mGOm)  return;
+switch (mod)
+  {
+  case PI_GOCopy :
+    XSetFunction(mDisp, DefGC(), GXcopy);
+    mGOm = mod;
+    break;
+  case PI_GOXOR :
+    XSetFunction(mDisp, DefGC(), GXxor);
+    mGOm = mod;
+    break;
+  case PI_GOInvert :
+    XSetFunction(mDisp, DefGC(), GXinvert);
+    mGOm = mod;
+    break;
+  }
+return;
+}
+
+
+/* --Methode-- */
+void PIGraphicX::SelFont(PIFont & fnt)
+{
+if (myFont == fnt)  return;
+myFont = fnt;
+XSetFont(mDisp, DefGC(), myFont.GetXFontId());
+}
+
+/* --Methode-- */
+void PIGraphicX::SelFont(PIFontSize sz, PIFontAtt att)
+{
+PIFont fnt(myFont.GetFontName());
+fnt.SetFontAtt(att);
+fnt.SetFontSz(sz);
+SelFont(fnt);
+}
+
+/* --Methode-- */
+void PIGraphicX::SelFontSzPt(int npt, PIFontAtt att)
+{
+PIFont fnt(npt, myFont.GetFontName(), att);
+SelFont(fnt);
+}
+
+
+
+/* --Methode-- */
+void PIGraphicX::SelLine(PILineAtt att)
+{
+unsigned int lt=0;
+int lstyle=LineSolid;
+char dash[2]= {3,3};   
+
+if (att == mLAtt)  return;
+
+switch (att)
+  {
+  case PI_NormalLine :
+    lt = 2;
+    lstyle = LineSolid;
+    break;
+  case PI_ThickLine :
+    lt = 4;
+    lstyle = LineSolid;
+    break;
+  case  PI_ThinLine :
+    lt = 0;
+    lstyle = LineSolid;
+    break;
+
+  case PI_DashedLine :
+    lt = 2;
+    lstyle = LineOnOffDash;
+    dash[0] = dash[1] = 6;  
+    break;
+  case PI_ThickDashedLine :
+    lt = 4;
+    lstyle = LineOnOffDash;
+    dash[0] = dash[1] = 6;  
+    break;
+  case  PI_ThinDashedLine :
+    lt = 0;
+    lstyle = LineOnOffDash;
+    dash[0] = dash[1] = 6;  
+    break;
+
+  case PI_DottedLine :
+    lt = 2;
+    lstyle = LineOnOffDash;
+    dash[0] = 2; dash[1] = 6;  
+    break;
+  case PI_ThickDottedLine :
+    lt = 4;
+    lstyle = LineOnOffDash;
+    dash[0] = 2; dash[1] = 6;  
+    break;
+  case  PI_ThinDottedLine :
+    lt = 0;
+    lstyle = LineOnOffDash;
+    dash[0] = 2; dash[1] = 6;  
+    break;
+
+  default:
+    lt = 0;
+    lstyle=LineSolid;
+    break;
+  }
+
+if (lstyle != LineSolid) 
+  XSetDashes( mDisp, DefGC(), 0, dash, 2);
+  
+XSetLineAttributes(mDisp, DefGC(), lt, lstyle, CapButt, JoinMiter);
+mLAtt = att;
+return;
+}
+
+
+/* --Methode-- */
+void PIGraphicX::SelMarker(int msz, PIMarker mrk)
+{
+if (msz > 1)  { mMrk = mrk;  mMrkSz = msz; }
+else  { mMrk = PI_DotMarker;  mMrkSz = 1; }
+return;
+}
+
+
+/* --Methode-- */
+void PIGraphicX::SetClipRectangle(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy)
+{
+XRectangle xr;
+xr.x = x0;  xr.y = y0;
+xr.width = dx;  xr.height = dy;
+XSetClipRectangles(mDisp, DefGC(), 0, 0, &xr, 1, Unsorted);
+XSetClipRectangles(mDisp, dpxgc, 0, 0, &xr, 1, Unsorted);
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::ClearClipRectangle()
+{ 
+XSetClipMask(mDisp, DefGC(), None);
+XSetClipMask(mDisp, dpxgc, None);
+return;
+}
+
+/* --Methode-- */
+PIColors  PIGraphicX::GetForeground() 
+{
+return (mFCol);
+}
+
+/* --Methode-- */
+PIColors  PIGraphicX::GetBackground() 
+{
+return (mBCol);
+}
+
+
+/* --Methode-- */
+PIGOMode   PIGraphicX::GetGOMode()
+{
+return (mGOm);
+}
+
+/* --Methode-- */
+PIFontAtt  PIGraphicX::GetFontAtt()
+{
+return (mFAtt);
+}
+
+/* --Methode-- */
+int        PIGraphicX::GetFontSize()
+{
+return (mFSize);
+}
+
+/* --Methode-- */
+PILineAtt  PIGraphicX::GetLineAtt()
+{
+return (mLAtt);
+}
+
+/* --Methode-- */
+PIMarker   PIGraphicX::GetMarker()
+{
+return (mMrk);
+}
+
+/* --Methode-- */
+int        PIGraphicX::GetMarkerSize()
+{
+return (mMrkSz);
+}
+
+
+/* --Methode-- */
+void PIGraphicX::SaveGraphicAtt()
+{  
+// Pour optimier l'implementation de PIBaseWdgGen
+sFCol = mFCol;    sBCol = mBCol;
+sGOm = mGOm;
+sFont = myFont;   
+sMrk = mMrk;   sMrkSz = mMrkSz;
+sFCfMap = mFCfMap; sBCfMap = mBCfMap; 
+return;
+}
+
+/* --Methode-- */
+void PIGraphicX::RestoreGraphicAtt()
+{
+  if (sFCol != PI_ColorFromMap) SelForeground(sFCol);
+  else SelectFCol(sFCfMap);
+  if (sBCol != PI_ColorFromMap) SelBackground(sBCol);
+  else SelectBCol(sBCfMap);
+  SelGOMode(sGOm);
+  SelFont(sFont);
+  SelLine(sLAtt);
+  SelMarker(sMrkSz, sMrk);
+  return;
+}
+
+
+/* --Methode-- */
+unsigned long PIGraphicX::GetPixelValueforColor(PIColors col)
+{
+if ( (col < 0) || (col >= NMAXCOL))  return(0);
+return(colpix[col]); 
+}
+
+
+static bool fggrcx = false ;  // Flag init done
+
+
+/* --Methode-- */
+void PIGraphicX::GlInit()
+{
+if (fggrcx)  return;
+fggrcx = true;
+
+Display *mdsp;
+int scr;
+XColor exact,mycol;
+Colormap  cmap;
+
+mdsp = PIXDisplay();
+scr = XDefaultScreen(mdsp);
+
+/*  Les couleurs  */
+cmap = XDefaultColormap (mdsp, scr);
+
+for(int i=0; i<NMAXCOL; i++)  colpix[i] = XWhitePixel(mdsp, scr);
+colpix[PI_Black] = XBlackPixel(mdsp, scr);
+colpix[PI_White] = XWhitePixel(mdsp, scr);
+colpix[PI_ColorAllBits0] = 0;
+colpix[PI_ColorAllBits1] = ~colpix[PI_ColorAllBits0];
+if ( XAllocNamedColor (mdsp, cmap, "LightGray", &mycol, &exact) )
+  colpix[PI_Grey] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "red", &mycol, &exact) )
+  colpix[PI_Red] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "blue", &mycol, &exact) )
+  colpix[PI_Blue] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "green", &mycol, &exact) )
+  colpix[PI_Green] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "yellow", &mycol, &exact) )
+  colpix[PI_Yellow] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "magenta", &mycol, &exact) )
+  colpix[PI_Magenta] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "cyan", &mycol, &exact) )
+  colpix[PI_Cyan] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "turquoise", &mycol, &exact) )
+  colpix[PI_Turquoise] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "NavyBlue", &mycol, &exact) )
+  colpix[PI_NavyBlue] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "orange", &mycol, &exact) )
+  colpix[PI_Orange] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "sienna", &mycol, &exact) )
+  colpix[PI_SiennaRed] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "purple", &mycol, &exact) )
+  colpix[PI_Purple] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "LimeGreen", &mycol, &exact) )
+  colpix[PI_LimeGreen] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "gold", &mycol, &exact) )
+  colpix[PI_Gold] = mycol.pixel;
+
+
+/*  le GC pour DrawPixmap  */
+XGCValues  xgv;
+xgv.function = GXcopy;
+xgv.plane_mask = ~0;
+dpxgc = XCreateGC(mdsp, DefaultRootWindow(mdsp), GCFunction | GCPlaneMask, &xgv);
+
+/* Coordonnees pour une etoile a 5 branches */
+double pio5 = M_PI/2.5;  
+double pio52 = pio5/2.;
+double cpi2 = M_PI/2.-pio5;  
+double re = 1.2;  // Rayon externe
+double ri = 0.5; //  rayon interne pour rext=1.2
+for(int k=0; k<5; k++) {
+  starcoordx[2*k] = cos(k*pio5+cpi2)*re;
+  starcoordy[2*k] = -sin(k*pio5+cpi2)*re;
+  starcoordx[2*k+1] = cos(k*pio5+pio52+cpi2)*ri;
+  starcoordy[2*k+1] = -sin(k*pio5+pio52+cpi2)*ri;
+  }
+
+}
+
+
+
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pigraphx.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pigraphx.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pigraphx.h	(revision 464)
@@ -0,0 +1,111 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive     PIGraphicX
+// Trace graphiques- Implementation X11  R. Ansari  97
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIGRAPHICX_H_SEEN
+#define PIGRAPHICX_H_SEEN
+
+#include "pisysdep.h"
+#include "pigraphgen.h"
+
+class PIGraphicX : public PIGraphicGen
+{
+public:
+                     PIGraphicX(PIWdg* wdg);
+                     PIGraphicX(PIScreenBuffer* grb);
+  virtual           ~PIGraphicX();
+
+  virtual int        kind();
+
+//  Trace graphiques
+  virtual void       Erase(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0);
+  virtual void       DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0);
+  virtual void       DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2);
+  virtual void       DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawFBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r);
+  virtual void       DrawFCircle(PIGrCoord x0, PIGrCoord y0, PIGrCoord r);
+  virtual void       DrawOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawFOval(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       DrawPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true);  
+  virtual void       DrawFPolygon(PIGrCoord *x, PIGrCoord *y, int n, bool cinc=true);  
+  virtual void       DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
+                             double degdeb, double degfin);
+  virtual void       DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 
+                              double degdeb, double degfin);
+  virtual void       DrawMarker(PIGrCoord x0, PIGrCoord y0);
+  virtual void       DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n);
+  virtual void       DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix, 
+                                int sx, int sy, PIColorMap* cmap);
+
+// Modifications attributs graphiques
+  virtual void       SelForeground(PIColors col=PI_Black);
+  virtual void       SelBackground(PIColors col=PI_White);
+  virtual void       SelForeground(PIColorMap& cmap, int cid);
+  virtual void       SelBackground(PIColorMap& cmap, int cid);
+  virtual void       SelGOMode(PIGOMode mod=PI_GOCopy);
+  virtual void       SelLine(PILineAtt att=PI_NormalLine);
+  virtual void       SelMarker(int msz=3, PIMarker mrk=PI_DotMarker);
+
+// Modifications de fonte
+  virtual void	     SelFont(PIFont & fnt);
+  virtual void       SelFont(PIFontSize sz=PI_NormalSizeFont, 
+                             PIFontAtt att=PI_RomanFont);
+  virtual void       SelFontSzPt(int npt=12, PIFontAtt att=PI_RomanFont);
+
+// Selection de zone de trace (clip)
+  virtual void       SetClipRectangle(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy);
+  virtual void       ClearClipRectangle();
+
+// Acces aux attributs graphiques 
+  virtual PIColors   GetForeground();
+  virtual PIColors   GetBackground();
+  virtual PIGOMode   GetGOMode();
+  virtual PIFontAtt  GetFontAtt();
+  virtual int        GetFontSize();
+  virtual PILineAtt  GetLineAtt();
+  virtual PIMarker   GetMarker();
+  virtual int        GetMarkerSize();
+
+// Sauvegarde des attributs graphiques 
+  virtual void       SaveGraphicAtt();
+  virtual void       RestoreGraphicAtt();
+
+//  Pour recuperer le pixcol d une couleur  (pour X) 
+  PIXColor           GetPixelValueforColor(PIColors col);
+//  Pour initialiser mWId apres creation de fenetre
+  virtual void	     TerminateInit();
+
+protected:
+  static void    GlInit();
+  void           Init();
+  void           SelectFont(int isz, int jat);
+  inline  GC     DefGC() { return mDefGC; }
+  inline SysDWdg MyWdg()  {return(myWdg->XtWdg()); }
+  inline void    SelectBCol(PIXColor col) 
+    {XSetBackground(mDisp, DefGC(), col);  mBCol = PI_ColorFromMap; mBCfMap = col; }
+  inline void    SelectFCol(PIXColor col) 
+    {XSetForeground(mDisp, DefGC(), col);  mFCol = PI_ColorFromMap; mFCfMap = col; }
+
+//  Structure et identificateur XWindow  associe
+  GC mDefGC;
+  Display* mDisp;  // Display X associe
+  Drawable mWId;   // Identificateur Window/Drawable X
+
+  PIColors  mFCol, mBCol;
+  PIGOMode mGOm;
+  PIFontAtt mFAtt;
+  PILineAtt mLAtt;
+  int mFSize;
+  XFontStruct *mFSt;
+  PIMarker mMrk;
+  int mMrkSz;
+  PIXColor mFCfMap, mBCfMap;
+  PIXColor sFCfMap, sBCfMap;
+};
+
+typedef PIGraphicX PIGraphicWin;
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/piimage.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piimage.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piimage.cc	(revision 464)
@@ -0,0 +1,1368 @@
+// Module PI : Peida Interactive     PIImage
+// Affichage d'image            R. Ansari  05/95
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+//                        Refonte   Reza   10/95
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "piimage.h"
+#include "piimgtools.h"
+#include "pidrwtools.h"
+#include "piscdrawwdg.h"
+#include PIAPP_H
+
+//++
+// Class	PIImage
+// Lib		PI
+// include	piimage.h
+//
+//   	Classe pour la l'affichage et la manipulation d'images.
+//	Peut contrôler un PIPixmap pour l'affichage d'une zone
+//	agrandie (zoom) et un PIPixmap pour l'affichage de toute
+//	l'image (réduite). Peut aussi gerer une fenetre de coupes.
+//	Utilise les adaptateur de tableaux 2D manipuler le
+//	contenu des images ("P2DArrayAdapter").
+//
+//	* Bouton-1 : Envoie le message "PIMsg_Active" et affiche
+//	les coordonnées courantes et la valeur du pixel, 
+//	et positionne le pavé.
+//	* Bouton-2 : Permet de définir une zone de l'image et repositionne le pavé.
+//	* Bouton-3 : Permet de déplacer l'image dans la fenêtre
+//
+//	Gestion du clavier :
+//	* <Alt>O : Affichage de la fenêtre de contrôle des paramètres de visualisation.
+//	* <Alt>G : Affichage de la fenêtre de changement des attributs graphiques
+//	* <Alt>R : Rafraîchit l'affichage.
+//	* <Alt>V : Copier/*Coller* Ajout du texte du buffer copier/coller
+//	sur l'objet à la position courante.
+//	* <Alt>C : *Copier*/Coller Permet de copier le contenu de la zone sélectionnée
+//	de l'image sous forme texte.
+//	* <Alt>P : Active/désactive l'affichage de l'indicateur de la postion du pavé
+//	* <Alt>X : Active/désactive l'affichage des coupes X,Y
+//	* <Alt>Z : Supprime les textes et signes ajoutés au dessin.
+//	* Touches Curseurs : déplace la pavé.
+//--
+//++
+// Links	Parents
+// PIPixmap
+//--
+
+//++
+// Titre	Constructeurs, méthodes
+//--
+//++
+//  PIImage(PIContainerGen *par, const char *nom=NULL, int sx=0, int sy=0, int px=0, int py=0)
+//	Créateur
+//  
+//--
+
+// --------------------------------------------------------------------------------
+// ----------------------------- Classe PIImage -----------------------------------
+// --------------------------------------------------------------------------------
+// Variable globale pour la gestion de l'image courante 
+PIImage* PIImage::cur_piimage = NULL;
+/* --Methode-- */
+PIImage* PIImage::CurrentPIImage() 
+{ 
+return(cur_piimage); 
+}
+
+/* --Methode-- */
+void PIImage::SetCurrentPIImage(PIImage* curimg) 
+{ 
+cur_piimage = curimg;
+}
+
+/* --Methode-- */
+PIImage::PIImage(PIContainerGen *par, const char *nom,
+   int sx, int sy, int px, int py) :
+  PIPixmap(par, nom, sx, sy, px, py)
+{
+
+img = NULL;
+aisup = false;
+curshow = true;
+winovis = true;     // $CHECK$ Reza A enlever si possible 17/6/96
+
+
+zow = NULL;   // Widget zoom
+gvw = NULL;   // widget vue globale
+cmvw = NULL;  // widget ColorMapView
+// Fenetre transient et Label pour affichage de l'info (texte PixVal)
+int tx, ty;
+PIApplicationPrefCompSize(tx, ty);
+tx *= 5;    ty = (int)(ty*0.8);
+trtw = new PIWindow(this, "PixVal", PIWK_transient, tx, ty, 0, 0);
+trtw->SetAutoDelChilds(true);
+trtlb = new PILabel(trtw, "PixVal", tx, ty, 0, 0);
+trtlb->SetBinding(PIBK_fixed,PIBK_fixed, PIBK_fixed,PIBK_fixed);
+ustrtw = atrtw = false;
+if ((sx < 300) || (sy < 150) ) atrtw = true;
+showinfo = false;
+
+// Fenetre et ScDrawWdg pour les coupes
+selcuts = 3;
+cutwin = NULL;
+cutscw = NULL; 
+
+gpixm = zpixm = pixm = NULL;
+xsgpxm = xszpxm = xspxm = 0;
+ysgpxm = yszpxm = yspxm = 0;
+lut = NULL; 
+offx = offy = 0;
+xpav = ypav = 0;
+xpv0 = ypv0 = 0;
+xszpav = yszpav = 1;
+xmv0 = ymv0 = -1;
+dxmv = dymv = 0;
+xcurs = ycurs = -1;
+cuhsz = 8;  cuvsz = 8;
+cucol = PI_Yellow; culat = PI_NormalLine; 
+zoom = 1;
+zmgv = 1;
+
+mdrw = new PIElDrawer();
+gvdrw = new PIElDrawer();
+AddDrawer(mdrw, true, false, false);
+
+SetLut(0., 32000., kLutType_Lin, 0, false);
+SetColMapId(CMAP_COLRJ32);
+// pour le copier-coller
+cpbuffer = NULL;
+cpbuflen = 0;
+
+SetBackgroundColor(PI_Black);
+
+ActivateKeyboard();
+ActivateButton(1);
+ActivateMove(1);
+ActivateButton(2);
+ActivateMove(2);
+ActivateButton(3);
+ActivateMove(3);
+
+cur_piimage = this;
+}
+
+/* --Methode-- */
+PIImage::~PIImage()
+{
+if (pixm) delete pixm;
+if (zpixm) delete zpixm;
+if (zow) 
+  {
+  zow->SetPixmap(NULL,0,0);
+  zow->EraseWindow();
+  }
+if (gpixm) delete gpixm;
+if (gvw) 
+  {
+  gvw->SetPixmap(NULL,0,0);
+  gvw->EraseWindow();
+  gvw->SetMsg(0); gvw->SetMsgParent(NULL); 
+  gvw->SetUserData(NULL, 0); 
+  }
+if (cmvw)  cmvw->SetColMap(NULL, 1., -1., true);
+if (cutwin)  delete cutwin;
+if (lut) delete lut;
+delete mdrw;
+delete gvdrw;
+if (aisup && img)  delete img;   // Suppression automatique d'image
+delete trtw;
+if (cpbuffer)  delete[] cpbuffer;
+if (this == cur_piimage)  cur_piimage = NULL;
+}
+
+/* --Methode-- */
+void PIImage::Process(PIMessage msg, PIMsgHandler* sender, void* data)
+{
+
+if ((ModMsg(msg) == PIMsg_Close) && (sender == cutwin)) {
+  cutwin->Hide();
+  delete cutwin;
+  cutwin = NULL;
+  cutscw = NULL;
+  }
+else if (UserMsg(msg) == (Msg()+626))
+  {
+  if (ModMsg(msg) == PIMsg_Click) 
+    { int* pxy=(int *)data;   SetPave(pxy[0]*zmgv, pxy[1]*zmgv); }
+  if (ModMsg(msg) == PIMsg_Resize)
+    { ComputeGloVPixmap();   SetGloVPixmap(); }
+  }
+else ReSend(msg, sender, data);
+return;
+}
+
+/* --Methode-- */
+void PIImage::SetImage(P2DArrayAdapter *pim, bool ad, bool refr)
+{
+
+offx = offy = 0;
+xpav = ypav = 0;
+xszpav = yszpav = 1;
+img = pim;
+if (gpixm) delete gpixm;
+gpixm = NULL;
+xsgpxm = ysgpxm = 0;
+zmgv = 1;
+
+if (img)  {
+//  SetSize(img->XSize(), img->YSize());
+  CenterPave();
+  double min=1., max=-1., moy, sig;
+  int nbnul, nbsat;
+  img->CheckDyn(min, max, moy, sig, nbnul, nbsat);
+  SetLut(min, max, kLutType_Lin, 1, refr);
+  aisup = ad;
+  }
+else aisup = false;
+return;
+}
+
+/* --Methode-- */
+void PIImage::ChangeAxesConfiguration(bool ix, bool iy, bool xy, bool refr)
+{
+if (!img) return;
+bool invx, invy, exy;
+img->GetAxesConfiguration(invx, invy, exy);
+if (ix)  invx = !invx;
+if (iy)  invy = !invy;
+if (xy)  exy = !exy;
+img->ConfigureAxes(invx, invy, exy);
+ComputeGloVPixmap();
+if (refr) Apply();
+}
+
+/* --Methode-- */
+void PIImage::SetZoomWin(PIPixmap * zw, bool refr) 
+{
+zow = zw;
+if (zow && refr && img)
+  ComputeZoomPixmap();
+return;
+}
+
+/* --Methode-- */
+void PIImage::SetGloVWin(PIPixmap * zw, bool refr) 
+{
+gvw = zw;
+if (gvw && img)  
+  { ComputeGloVPixmap();
+  if (refr) SetGloVPixmap(); } 
+return;
+}
+
+/* --Methode-- */
+void PIImage::SetCMapWin(PICMapView * cw, bool refr)
+{
+cmvw = cw;
+if (cmvw && refr) cmvw->SetColMap(cmap, Lut()->Min(), Lut()->Max(), true);
+}
+
+
+/* --Methode-- */
+void PIImage::UseInfoWin(bool trw)
+{
+ustrtw = trw;
+}
+
+/* --Methode-- */
+void PIImage::ShowInfo(bool si)
+{
+if (showinfo == si) return;
+showinfo = si;
+if (showinfo && img)  { 
+  char buff[256];
+  double x,y;
+  img->Coord(xpav, ypav, x, y);
+  sprintf(buff," X= %g , Y= %g  Pix= %g (%d,%d)      ", 
+          x, y , (*img)(xpav, ypav), xpav, ypav );
+  DrawInfo(mWGrC, buff);
+  }
+else DrawInfo(mWGrC, NULL);
+}
+
+/* --Methode-- */
+void PIImage::ShowCursor(bool sc)
+{
+if (curshow == sc) return;
+curshow = sc;
+if (curshow)  DrawCursor(mWGrC);
+else DrawCursor(mWGrC, -1, -1);
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::ShowCuts(bool cuts)
+{
+if (cuts) {
+  if (cutwin) { cutwin->Show(); return; }
+  int tpx, tpy;
+  GetScreenPos(tpx, tpy);
+  string nom = Nom() + "-Cuts";
+  int sx, sy;
+  int ssx, ssy;
+  PIApplicationScreenSize(ssx, ssy);
+  if ( (ssx > 1000) && (ssy > 1000) ) { sx = 400;  sy = 250; }
+  else { sx = 300; sy = 200; }
+  cutwin = new PIWindow(this, nom.c_str(), PIWK_normal, sx, sy, tpx, tpy+YSize()+10);
+  cutwin->SetAutoDelChilds(true);
+  nom += "_ScWdg";
+  cutscw = new PIScDrawWdg(cutwin, nom.c_str(), sx, sy, 0, 0);
+  cutscw->SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_fixed);
+  cutarrx = new PIImg1DArrAdapter();
+  cutarry = new PIImg1DArrAdapter();
+  cutarrd = new PIImg1DArrAdapter();
+  cutarra = new PIImg1DArrAdapter();
+  PIYfXDrawer * drw;
+  string dum = "";
+  drw = new PIYfXDrawer(cutarrx, NULL, true);
+    drw->SetColAtt(PI_Red);
+    drw->SetMarkerAtt(5, PI_CrossMarker);
+    drw->SetLineAtt(PI_ThinLine);
+    cutscw->AddScDrawer(drw, true);
+    dum += "Red: X, ";
+  drw = new PIYfXDrawer(cutarry, NULL, true);
+    drw->SetColAtt(PI_Blue);
+    drw->SetMarkerAtt(5, PI_TriangleMarker);
+    drw->SetLineAtt(PI_ThinLine);
+    cutscw->AddScDrawer(drw, true);
+    dum += "Blue: Y, ";
+  drw = new PIYfXDrawer(cutarrd, NULL, true);
+    drw->SetColAtt(PI_Green);
+    drw->SetMarkerAtt(5, PI_PlusMarker);
+    drw->SetLineAtt(PI_ThinLine);
+    cutscw->AddScDrawer(drw, true);
+    dum += "Green: XY, ";
+  drw = new PIYfXDrawer(cutarra, NULL, true);
+    drw->SetColAtt(PI_Orange);
+    drw->SetMarkerAtt(5, PI_BoxMarker);
+    drw->SetLineAtt(PI_ThinLine);
+    cutscw->AddScDrawer(drw, true);
+    dum += "Orange: -XY";
+  cutscw->SetTitles(dum.c_str());
+  UpdateCuts();
+  cutwin->Show();
+  }
+else {
+  if (!cutwin)  return;
+  cutwin->Hide();
+  delete cutwin;
+  cutwin = NULL;
+  cutscw = NULL;
+  }
+}
+
+/* --Methode-- */
+void PIImage::SelectCuts(unsigned xyda)
+// choix des cuts pour le display:
+// 1=axe des (X), 2=axe des (Y), 4=diag (X,Y), 8=anti-diag (X,-Y)
+{
+selcuts = xyda;
+if(!(selcuts&15)) selcuts = 3;
+UpdateCuts();
+}
+
+/* --Methode-- */
+void PIImage::SetLut(double min, double max, int typlut, int lauto, bool refr)
+{
+if (lut) delete(lut);
+if (lauto && img) 
+  {
+  int nbsig = lauto;  
+  double fracmax = 1. - 0.05*nbsig;
+  img->ComputeLut_PicHisto(min, max, nbsig, fracmax);
+  }
+
+lut = new LUT(min, max, NbCol(), typlut);
+
+ComputeGloVPixmap();
+if (refr) Apply();
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::SetLut(LUT *clut, bool refr)
+{
+LUT * olut = lut;
+lut = new LUT(clut->Min(), clut->Max(), NbCol(), clut->Type());
+if (olut) delete olut;
+
+ComputeGloVPixmap();
+if (refr) Apply();
+return;
+}
+
+/* --Methode-- */
+void PIImage::SetZoomF(float fzm, bool refr)
+{
+int zm;
+
+if (fzm < 0.01) return;
+if (fzm < 1.)  zm = (int)(-(1./fzm));
+else zm = (int)(fzm+0.25);
+SetZoom(zm, refr);
+return;
+}
+
+/* --Methode-- */
+void PIImage::SetZoom(int zm, bool refr)
+{
+if ((zm == 0) || (zm == -1) )  zoom = 1;
+else if (zm > 20)  zoom = 20;
+else if (zm < -20) zoom = -20;
+else zoom = zm;
+if (img)
+  { SetOffsetFromPave();
+  if (refr) Apply(); }
+return;
+}
+
+/* --Methode-- */
+float PIImage::GetZoomF()
+{
+if (zoom >= 1)  return((float)zoom);
+else return(-1./(float)zoom);
+}
+
+
+/* --Methode-- */
+void PIImage::SetOffset(int ox, int oy, bool refr)
+{
+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;
+CenterPave();
+if (refr) Apply();
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::SetPave(int x, int y, bool refr, bool cent)
+{
+int xc, yc;
+
+if (img == NULL)  
+  { offx = offy = 0; 
+  xpav = ypav = 0; 
+  return; }
+
+if ( (x >= (img->XSize()-1)) || ( x < 0)  ||
+     (y >= (img->YSize()-1)) || ( y < 0)  ) return;
+
+if ( (x == xpav) && (y == ypav) )  return;
+xpav = x;  ypav = y;
+
+if ( PosImg2W(xpav,ypav,&xc, &yc) || cent)  // Il faut recenter l'image
+  { SetOffsetFromPave();  
+  if (refr) Apply(true);  }
+else if (refr)
+  { Apply(false);  if (curshow)  DrawCursor(mWGrC);  }
+
+return;
+}
+
+/* --Methode-- */
+void PIImage::SetColMap(PIColorMap* cmp, bool refr)
+{
+if (!cmp)  return;
+int cmapid = cmp->Type();
+if ( (cmapid == CMAP_GREY32) || (cmapid == CMAP_GREYINV32) || 
+     (cmapid == CMAP_GREY128) || (cmapid == CMAP_GREYINV128))  mdrw->SetColAtt(PI_Red);
+else mdrw->SetColAtt(PI_Turquoise);
+PIPixmap::SetColMap(cmp, refr);
+if (refr) { xcurs =  ycurs = -1; }
+if (zow)  zow->SetColMap(cmp, refr);
+if (gvw)  gvw->SetColMap(cmp, refr);
+if (cmvw) cmvw->SetColMap(cmap, Lut()->Min(), Lut()->Max(), refr);
+return;
+}
+
+/* --Methode-- */
+void PIImage::SetColMapId(CMapId cmapid, bool refr)
+{
+if ( (cmapid == CMAP_GREY32) || (cmapid == CMAP_GREYINV32) || 
+     (cmapid == CMAP_GREY128) || (cmapid == CMAP_GREYINV128))  mdrw->SetColAtt(PI_Red);
+else mdrw->SetColAtt(PI_Turquoise);
+PIPixmap::SetColMapId(cmapid, refr);
+if (zow)  zow->SetColMapId(cmapid, refr);
+if (gvw)  gvw->SetColMapId(cmapid, refr);
+if (cmvw) cmvw->SetColMapId(cmapid, Lut()->Min(), Lut()->Max(), refr);
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::Apply(bool mw)
+{
+if (img == NULL)  return;
+if (mw)  {  
+  ComputePixmap();
+  Send(Msg(), PIMsg_Active);
+  cur_piimage = this;
+  PIDrwTools::SetCurrentBaseWdg(this);
+  }
+else {
+  char buff[256];
+  double x,y;
+  img->Coord(xpav, ypav, x, y);
+  sprintf(buff," X= %g , Y= %g  Pix= %g (%d,%d)      ", 
+          x, y , (*img)(xpav, ypav), xpav, ypav );
+  if (ustrtw || atrtw)  trtlb->SetLabel((string)buff);
+  else DrawInfo(mWGrC, buff);
+  }
+if (zow != NULL)   ComputeZoomPixmap();
+if (cutwin) UpdateCuts();
+if (gvw != NULL)
+  if ( (gvw->UserData() != this) || (mw) )  SetGloVPixmap();
+if (cmvw) cmvw->SetColMap(cmap, Lut()->Min(), Lut()->Max(), true);
+  
+return;
+}
+
+/* --Methode-- */
+void PIImage::Resize()
+{
+// printf("PIImage::Resize\n");
+// On bascule sur la fenetre transient pour l'affichage des valeurs si fenetre trop petite
+if ((XSize() < 300) || (YSize() < 150) ) atrtw = true;  
+else atrtw = false;
+PIPixmap::Resize();
+CenterPave();
+Apply();
+return;
+}
+
+/* --Methode-- */
+void PIImage::Draw(PIGraphic* g, int x0, int y0, int dx, int dy)
+{
+PIPixmap::Draw(g, x0, y0, dx, dy);
+xcurs = ycurs = -1;
+winovis = false;    // $CHECK$ Reza A enlever si possible 17/6/96
+if (curshow) {
+  int xc,yc;
+  PosImg2W(xpav, ypav, &xc, &yc);
+  if ((xc >= x0) && (xc < x0+dx) && 
+      (yc >= y0) && (yc < y0+dy) )  DrawCursor(g, xc, yc);
+  }
+
+if (showinfo && img) {
+  char buff[256];
+  double x,y;
+  img->Coord(xpav, ypav, x, y);
+  sprintf(buff," X= %g , Y= %g  Pix= %g (%d,%d)      ", 
+        x, y , (*img)(xpav, ypav), xpav, ypav );
+  DrawInfo(mWGrC, buff); 
+  }
+
+return;
+}
+
+/* --Methode-- */
+void PIImage::Keyboard(int key, PIKeyModifier kmod)
+{
+cur_piimage = this;
+if (kmod == PIKM_Alt) {
+  if      (key == 'R' || key == 'r') Apply(true);  // Pour tout rafraichir  
+  else if (key == 'V' || key == 'v') RequestSelection();  // Pour coller (copier/coller)  
+  else if (key == 'Z' || key == 'z') { mdrw->ElDelAll();  Refresh(); } // Pour supprimer tous les signes 
+  else if (key == 'O' || key == 'o') PIImgTools::ShowPIImgTools();   // Fentre LUT et options 
+  else if (key == 'G' || key == 'g') {   // Fentre attributs graphiques 
+    PIDrwTools::SetCurrentBaseWdg(this);
+    PIDrwTools::ShowPIDrwTools();   // Fentre axes et options de trace
+    }
+  else if (key == 'P' || key == 'p') {   // Activation/desactivation affichage curseur
+    bool sc = !curshow;
+    ShowCursor(sc);
+    }
+  else if (key == 'X' || key == 'x') {   // Activation/desactivation affichage coupes X,Y 
+    bool cut = (cutwin == NULL) ? true : false; 
+    ShowCuts(cut);
+    }
+// ----  Le copier ---- 
+  else if ((key == 'C' || key == 'c') && img) { 
+    // On limite la taille a 48x48
+    int i1 = XPave();  
+    int i2 = ( XSzPave() < 48 ) ? i1+XSzPave() : i1+48;
+    int j1 = YPave();  
+    int j2 = ( YSzPave() < 48 ) ? j1+YSzPave() : i1+48;
+    if ( ( (i2-i1) < 1 ) || ((j2-j1) < 1) ) return;
+    if (!ClaimSelection())  return;  // On n'a pas pu prendre possession de la zone d'echange
+    if (cpbuffer)  delete[] cpbuffer;
+    cpbuflen = (j2-j1)*(i2-i1+2)*12+(j2-j1)+128;
+    cpbuffer = new char[cpbuflen];
+    sprintf(cpbuffer,"PIImage: Pave(%dx%d) en (%d, %d) MaxCopie= 48x48 \n", 
+            XSzPave(), YSzPave(), i1, j1);
+    int i,j;
+    int l = strlen(cpbuffer);
+    for(j=j1; j<j2; j++) {
+      sprintf(cpbuffer+l,"L %3d:",j);
+      l += 6;
+      for(i=i1; i<i2; i++) { sprintf(cpbuffer+l," %10g", (*img)(i, j));  l += 11; }
+      cpbuffer[l] = '\n';  l++;
+      }
+    cpbuffer[l] = '\0';
+    cpbuflen = l+1;
+    }
+  }
+
+
+else if (kmod == PIKM_Blank) {
+  switch (key) {
+    case PIK_Up :
+      SetPave(xpav, ypav-1, true, false);
+      break;
+    case PIK_Down :
+      SetPave(xpav, ypav+1, true, false);
+      break;
+    case PIK_Left :
+      SetPave(xpav-1, ypav, true, false);
+      break;
+    case PIK_Right :
+      SetPave(xpav+1, ypav, true, false);
+      break;
+    default :
+      break;
+  }
+}
+
+}
+
+
+/* --Methode-- */
+void PIImage::But1Press(int x, int y)
+{
+int xp, yp;
+
+Send(Msg(), PIMsg_Active);
+cur_piimage = this;
+PIDrwTools::SetCurrentBaseWdg(this);
+if (img == NULL)  return;
+if ( PosW2Img(x, y, &xp, &yp) )  return;
+SelPointerShape(PI_CrossPointer);
+xpav = xp;  ypav = yp;
+if (ustrtw || atrtw) ShowTrTxW();
+Apply(false);
+if (curshow)  DrawCursor(mWGrC, -1,-1);
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::Ptr1Move(int x, int y)
+{
+int xp, yp;
+if (img == NULL)  return;
+if ( PosW2Img(x, y, &xp, &yp) )  return;
+xpav = xp;  ypav = yp;
+Apply(false);
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::But1Release(int /*x*/,  int /*y*/)
+{
+SelPointerShape(PI_ArrowPointer);
+if (curshow)  DrawCursor(mWGrC);
+if (ustrtw || atrtw) trtw->Hide();
+else if (!showinfo) DrawInfo(mWGrC, NULL);
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::But2Press(int x, int y)
+{
+
+Send(Msg(), PIMsg_Active);
+cur_piimage = this;
+PIDrwTools::SetCurrentBaseWdg(this);
+if (img == NULL)  return;
+if ( PosW2Img(x, y, &xpv0, &ypv0) )  {  xmv0 = -1;  return; }
+xmv0 = x;  ymv0 = y;  dxmv = dymv = 0;
+if (curshow)  DrawCursor(mWGrC,-1,-1);
+mWGrC->SelGOMode(PI_GOXOR);
+PIColors xc;
+if ((GetColMapId() == CMAP_COLRJ32) || (GetColMapId() == CMAP_COLRJ128))  xc = PI_Yellow;
+else  xc = PI_ColorAllBits1;
+mWGrC->SelForeground(xc);
+mWGrC->SelLine(PI_NormalLine);
+if (ustrtw || atrtw) ShowTrTxW();
+return;
+}
+
+/* --Methode-- */
+void PIImage::Ptr2Move(int x, int y)
+{
+int xp, yp;
+if (img == NULL)  return;
+if (xmv0 < 0)  return;
+if ( PosW2Img(x, y, &xp, &yp) )  return;
+mWGrC->DrawBox(xmv0, ymv0, dxmv, dymv);
+dxmv = x-xmv0;  dymv = y-ymv0;
+mWGrC->DrawBox(xmv0, ymv0, dxmv, dymv);
+
+ {
+ char buff[256];  
+ double x,y;
+ img->Coord(xp, yp, x, y);
+ sprintf(buff," X= %g , Y= %g  Pix= %g  (C= %d,%d)   ", 
+         x, y , (*img)(xp, yp),  (xp+xpv0)/2, (yp+ypv0)/2 );
+ if (ustrtw || atrtw) trtlb->SetLabel((string)buff);
+ else DrawInfo(mWGrC, buff);
+ }
+
+return;
+}
+
+/* --Methode-- */
+void PIImage::But2Release(int x, int y)
+{
+int xp2, yp2;
+
+if (img == NULL)  return;
+if (xmv0 < 0)  return;
+mWGrC->DrawBox(xmv0, ymv0, dxmv, dymv);
+mWGrC->SelGOMode(PI_GOCopy);
+mWGrC->SelForeground(PI_White);
+if ( PosW2Img(x, y, &xp2, &yp2) )  
+  PosW2Img(xmv0+dxmv, ymv0+dymv, &xp2, &yp2);
+xpav = (xpv0+xp2)/2;
+ypav = (ypv0+yp2)/2;
+xszpav = xp2-xpv0;
+yszpav = yp2-ypv0;
+if (xszpav < 0)  xszpav = -xszpav;
+if (yszpav < 0)  yszpav = -yszpav;
+
+Apply(false);
+if (curshow)  DrawCursor(mWGrC);
+if (ustrtw || atrtw) trtw->Hide();
+else if (!showinfo) DrawInfo(mWGrC, NULL);
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::But3Press(int x, int y)
+{
+int xp, yp;
+
+Send(Msg(), PIMsg_Active);
+cur_piimage = this;
+PIDrwTools::SetCurrentBaseWdg(this);
+if (img == NULL)  return;
+if ( PosW2Img(x, y, &xp, &yp) )  { xmv0 = -1;  return; }
+if (curshow)  DrawCursor(mWGrC,-1,-1);
+if (ustrtw || atrtw) ShowTrTxW();
+SelPointerShape(PI_TDLRArrowPointer);
+xmv0 = xp;
+ymv0 = yp;
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::Ptr3Move(int x, int y)
+{
+int xp, yp;
+if (img == NULL)  return;
+if (xmv0 < 0)  return;
+if ( PosW2Img(x, y, &xp, &yp) )  return;
+
+char buff[256];
+sprintf(buff," DelX= %d , DelY= %d    ", xp-xmv0, yp-ymv0);
+if (ustrtw || atrtw) trtlb->SetLabel((string)buff);
+else DrawInfo(mWGrC, buff);
+}
+
+/* --Methode-- */
+void PIImage::But3Release(int x, int y)
+{
+int xp, yp;
+
+SelPointerShape(PI_ArrowPointer);
+if (ustrtw || atrtw) trtw->Hide();
+if (img == NULL)  return;
+if (xmv0 < 0)  return;
+if ( PosW2Img(x, y, &xp, &yp) )  return;
+
+offx -= (xp-xmv0);
+offy -= (yp-ymv0);
+
+if (offx < 0)  offx = 0;
+if (offy < 0)  offy = 0;
+if (offx >= img->XSize())  offx = img->XSize();
+if (offy >= img->YSize())  offy = img->YSize();
+xpav = xmv0;  ypav = ymv0;
+xmv0 = ymv0 = -1;
+Apply();
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::PasteSelection(unsigned int typ, void *pdata, unsigned int l)
+{
+if (!img) return;
+if (typ != PICP_string) return;
+int ll = (l<256) ? l+1 : 256;
+char pc[256];
+strncpy(pc, (char*)pdata, ll-1);  pc[ll-1] = '\0';
+double fx, fy;
+img->Coord(xpav, ypav, fx, fy); 
+mdrw->ElAddText(fx, fy, pc );
+mdrw->Refresh();
+}
+
+/* --Methode-- */
+void * PIImage::ProvideSelection(unsigned int& typ, unsigned int& len)
+{
+typ = PICP_string;
+len = cpbuflen;
+return(cpbuffer);
+}
+
+/* --Methode-- */
+void PIImage::SelectionLost()
+{
+if (cpbuffer)  delete[] cpbuffer;
+cpbuffer = NULL;
+cpbuflen = 0;
+return;
+}
+
+
+
+/* --Methode-- */
+void PIImage::ComputePixmap()
+{
+unsigned int xwsz, ywsz;
+
+if (img == NULL)  return;
+xwsz = XSize();
+ywsz = YSize();
+
+pixm = img->ComputePixmap(lut, offx, offy, zoom, xwsz, ywsz, pixm, &xspxm, &yspxm);
+int xw1, yw1, xw2, yw2;
+xw1 = (xwsz-xspxm)/2;
+if (xw1 < 0) xw1 = 0;
+yw1 = (ywsz-yspxm)/2;
+if (yw1 < 0) yw1 = 0;
+xw2 = xspxm+xw1;
+yw2 = yspxm+yw1;
+SetDefaultDrawRectangle(xw1, yw1, xw2, yw2, false);
+// printf("--DBG-- ComputePixmap() %d %d $ %d %d :: %d %d , %d %d \n", xwsz, ywsz, xspxm, yspxm, xw1, yw1, xw2, yw2);
+int x1,y1, x2,y2;
+ofx = xw1;  ofy = yw1;
+PosW2Img(xw1, yw1, &x1, &y1);
+PosW2Img(xw2, yw2, &x2, &y2);
+double fx1,fy1, fx2, fy2; 
+img->Coord(x1,y1, fx1, fy2);  // fy1 et fy2 echange expres pour utiliser kAxeDirAuto  
+img->Coord(x2,y2, fx2, fy1);  // En effet Image de haut vers bas, Axes de bas vers haut par defaut 
+SetDefaultDrawerLimits(fx1, fx2, fy1, fy2, kAxeDirAuto, kAxeDirAuto);
+// printf("--DBG2-- ComputePixmap() %g %g  %g %g  \n", fx1, fx2, fy1, fy2);
+xcurs = ycurs = -1;
+SetPixmap(pixm, xspxm, yspxm, true, xw1, yw1); 
+// Refresh();
+return; 
+}
+
+
+/* --Methode-- */
+void PIImage::ComputeZoomPixmap()
+{
+unsigned int xwsz, ywsz;
+int lofx, lofy;
+int zm;
+
+if (zow == NULL)  return;
+if (img == NULL)  return;
+
+xwsz = zow->XSize();
+ywsz = zow->YSize();
+
+zm = zoom+4;
+if ( (zm==-1) || (zm == 0) ) zm = 1;
+if (zm > 0)
+  {
+  lofx = xpav-(xwsz/2/zm);
+  lofy = ypav-(ywsz/2/zm);
+  }
+else 
+  {
+  lofx = xpav+(xwsz*zm/2);
+  lofy = ypav+(ywsz*zm/2);
+  }
+if (lofx < 0)  lofx = 0;
+if (lofy < 0)  lofy = 0;
+
+zpixm = img->ComputePixmap(lut, lofx, lofy, zm, xwsz, ywsz, zpixm, &xszpxm, &yszpxm);
+zow->SetColMap(cmap, false);
+zow->SetPixmap(zpixm, xszpxm, yszpxm); 
+zow->SetUserData((void *)this, 0);
+// zow->Refresh();
+return; 
+
+}
+
+
+/* --Methode-- */
+void PIImage::ComputeGloVPixmap()
+{
+unsigned int xwsz, ywsz;
+int zmx,zmy;
+
+if (gvw == NULL)  return;
+if (img == NULL)  return;
+
+xwsz = gvw->XSize();
+ywsz = gvw->YSize();
+
+zmx = img->XSize()/xwsz;
+zmy = img->YSize()/ywsz;
+
+if (zmx < zmy)   zmx = zmy;
+if (zmx < 1)  zmx = 1;
+zmgv = zmx;
+if (zmx > 1)  zmx = -zmx;
+gpixm = img->ComputePixmap(lut, 0, 0, zmx, xwsz, ywsz, gpixm, &xsgpxm, &ysgpxm);
+// printf("DEBUG-ComputeGloVPixmap()  %d-%d , (%d,%d) , %d-%d \n", xwsz, ywsz, zmx, zmy, xsgpxm, ysgpxm);
+return;
+}
+
+/* --Methode-- */
+void PIImage::SetGloVPixmap()
+{
+float zm;
+int x,y, dx,dy;
+
+int xw1, yw1, xw2, yw2;
+xw1 = (gvw->XSize()-xsgpxm)/2;
+if (xw1 < 0) xw1 = 0;
+yw1 = (gvw->YSize()-ysgpxm)/2;
+if (yw1 < 0) yw1 = 0;
+xw2 = xsgpxm+xw1;
+yw2 = ysgpxm+yw1;
+
+if (zoom > 0) zm = zmgv*zoom;
+else zm = (float)zmgv/(float)(-zoom);
+x = offx/zmgv+1+xw1;
+y = offy/zmgv+1+yw1;
+dx =  (int) ( (float)XSize()/zm-1. );  
+dy =  (int) ( (float)YSize()/zm-1. );  
+
+gvw->DeleteDrawers();
+gvdrw->ElDelAll();
+gvdrw->SetLimits(xw1, xw2, yw1, yw2, kAxeDirLtoR, kAxeDirUpDown);
+int cmapid = cmap->Type();
+if ( (cmapid == CMAP_GREY32) || (cmapid == CMAP_GREYINV32) || 
+     (cmapid == CMAP_GREY128) || (cmapid == CMAP_GREYINV128)) gvdrw->SetColAtt(PI_Red); 
+else gvdrw->SetColAtt(PI_Yellow);
+gvdrw->SetLineAtt(PI_NormalLine);
+gvdrw->ElAddRect(x,y,dx,dy);
+gvw->AddDrawer(gvdrw, xw1, yw1, xw2, yw2, false); 
+gvw->SetColMap(cmap, false);
+gvw->SetPixmap(gpixm, xsgpxm, ysgpxm, true, xw1, yw1); 
+gvw->SetUserData((void *)this, 0);
+gvw->SetMsg(Msg()+626);
+gvw->SetMsgParent(this);
+
+return; 
+}
+
+/* --Methode-- */
+void PIImage::UpdateCuts()
+{
+if (!cutwin || !img) return;
+
+int hsx, hsy, hsmin;
+P2DArrayAdapter * img0=NULL;
+hsx = XSzPave()/2;
+hsy = YSzPave()/2;
+hsmin = (hsx<hsy)? hsx: hsy;
+if(selcuts&1) img0=img; else img0=NULL;
+  cutarrx->SetData(img0, 1, 2*hsx+1, XPave(), YPave());
+if(selcuts&2) img0=img; else img0=NULL;
+  cutarry->SetData(img0, 2, 2*hsy+1, XPave(), YPave());
+if(selcuts&4) img0=img; else img0=NULL;
+  cutarrd->SetData(img0, 4, 2*hsmin+1, XPave(), YPave());
+if(selcuts&8) img0=img; else img0=NULL;
+  cutarra->SetData(img0, 8, 2*hsmin+1, XPave(), YPave());
+
+double x1,y1,x2,y2;
+img->Coord(XPave()-hsx, YPave()-hsy, x1, y1);
+img->Coord(XPave()+hsx, YPave()+hsy, x2, y2);
+  if(x1<x2) cutarrx->DefineXCoordinate(-cutarrx->Size()/2,  1.);
+    else    cutarrx->DefineXCoordinate( cutarrx->Size()/2, -1.);
+  if(y1<y2) cutarry->DefineXCoordinate(-cutarry->Size()/2,  1.);
+    else    cutarry->DefineXCoordinate( cutarry->Size()/2, -1.);
+img->Coord(XPave()-hsmin, YPave()-hsmin, x1, y1);
+img->Coord(XPave()+hsmin, YPave()+hsmin, x2, y2);
+  if(x1<x2) cutarrd->DefineXCoordinate(-cutarrd->Size()/2,  1.);
+    else    cutarrd->DefineXCoordinate( cutarrd->Size()/2, -1.);
+  if(x1<x2) cutarra->DefineXCoordinate(-cutarra->Size()/2,  1.);
+    else    cutarra->DefineXCoordinate( cutarra->Size()/2, -1.);
+
+// On calcule les limites :
+double xmin=0., xmax=0., ymin=0., ymax=0.; bool vue=false;
+if(cutarrx->Size()) {
+  if(!vue) vue=true;
+  xmax=cutarrx->Size()/2.+1.; xmin=-xmax; 
+}
+if(cutarry->Size()) {
+  if(!vue)
+    {vue=true; xmax=cutarry->Size()/2.+1.; xmin=-xmax;}
+  else if(cutarry->Size()>xmax)
+    {xmax=cutarry->Size()/2.+1.; xmin=-xmax;}
+}
+if(cutarrd->Size()) {
+  if(!vue)
+    {vue=true; xmax=cutarrd->Size()/2.+1.; xmin=-xmax;}
+  else if(cutarrd->Size()>xmax)
+    {xmax=cutarrd->Size()/2.+1.; xmin=-xmax;}
+}
+if(cutarra->Size()) {
+  if(!vue)
+    {vue=true; xmax=cutarra->Size()/2.+1.; xmin=-xmax;}
+  else if(cutarra->Size()>xmax)
+    {xmax=cutarra->Size()/2.+1.; xmin=-xmax;}
+}
+
+int i; double cv; vue = false;
+if(cutarrx->Size()) {
+  vue=true; ymax=ymin=cutarrx->Value(0);
+  for(i=0; i<cutarrx->Size(); i++) {
+    cv = cutarrx->Value(i);
+    if (cv < ymin)  ymin = cv;
+    if (cv > ymax)  ymax = cv;
+  }
+}
+if(cutarry->Size()) {
+  if(!vue) {vue=true; ymax=ymin=cutarry->Value(0);}
+  for(i=0; i<cutarry->Size(); i++) {
+    cv = cutarry->Value(i);
+    if (cv < ymin)  ymin = cv;
+    if (cv > ymax)  ymax = cv;
+  }
+}
+if(cutarrd->Size()) {
+  if(!vue) {vue=true; ymax=ymin=cutarrd->Value(0);}
+  for(i=0; i<cutarrd->Size(); i++) {
+    cv = cutarrd->Value(i);
+    if (cv < ymin)  ymin = cv;
+    if (cv > ymax)  ymax = cv;
+  }
+}
+if(cutarra->Size()) {
+  if(!vue) {vue=true; ymax=ymin=cutarra->Value(0);}
+  for(i=0; i<cutarra->Size(); i++) {
+    cv = cutarra->Value(i);
+    if (cv < ymin)  ymin = cv;
+    if (cv > ymax)  ymax = cv;
+  }
+}
+ymin -= 0.05*(ymax-ymin);
+ymax += 0.05*(ymax-ymin);
+cutscw->SetLimits(xmin, xmax, ymin, ymax);
+//cutscw->UpdateLimits();
+cutscw->Refresh();
+//printf("UpdateCuts()-DBG X: %d  -> %g  , Y: %d -> %g \n", cutarrx->Size(), cutarrx->Value(0),
+//       cutarry->Size(), cutarry->Value(0));
+}
+
+/* --Methode-- */
+void PIImage::DrawCursor(PIGraphic* g) 
+{
+int xc, yc;
+if (PosImg2W(xpav, ypav, &xc, &yc)) DrawCursor(g, -1, -1);
+else DrawCursor(g, xc, yc);
+return;
+}
+
+ 
+/* --Methode-- */
+void PIImage::DrawCursor(PIGraphic* g, int xc, int yc)
+{
+
+if (winovis)  return;      // $CHECK$ Reza A enlever si possible 17/6/96
+//printf("DBG-DrawCursor(g, %d, %d) \n", xc, yc);
+int cmapid = cmap->Type();
+if ( (xcurs>=0) && (ycurs>=0) ) {
+  if (g->kind() == PI_PSFileGraphics ) {
+    g->SelGOMode(PI_GOCopy);
+    if ( (cmapid == CMAP_GREY32) || (cmapid == CMAP_GREYINV32) ||
+         (cmapid == CMAP_GREY128) || (cmapid == CMAP_GREYINV128) )  g->SelForeground(PI_Red);
+    else  g->SelForeground(PI_Yellow);
+    }
+  else  {
+    g->SelGOMode(PI_GOXOR);
+    //    g->SelGOMode(PI_GOInvert);
+    g->SelForeground(cucol);
+    }
+  g->SelLine(culat);
+  //  On efface le curseur precedant ou on le trace ds le postscript
+  g->DrawLine(xcurs-cuhsz, ycurs, xcurs-4, ycurs);
+  g->DrawLine(xcurs+4, ycurs, xcurs+cuhsz, ycurs);
+  g->DrawLine(xcurs, ycurs-cuvsz, xcurs, ycurs-4);
+  g->DrawLine(xcurs, ycurs+4, xcurs, ycurs+cuvsz);
+  //  printf("DrawCursor/Erase() %d %d - %d %d -> %d %d \n", xcurs, ycurs, cuhsz, cuvsz, xc, yc);
+  }
+
+if (g->kind() == PI_PSFileGraphics )  { 
+  g->SelLine(PI_NormalLine);
+  g->SelForeground(PI_White);  
+  return;
+  }
+
+if ((xc >= 0) && (yc >= 0)) 
+  {
+  g->SelGOMode(PI_GOXOR);
+  //  g->SelGOMode(PI_GOInvert);
+  // Nouvelle epaisseur de trait du curseur
+  if (zoom < -2) culat = PI_ThinLine;
+  else if (zoom < 4) culat = PI_NormalLine;
+  else culat = PI_ThickLine;
+  g->SelLine(culat);
+
+  // couleur  de trait du curseur
+  if ((cmapid == CMAP_COLRJ32) || (cmapid == CMAP_COLRJ128))  cucol = PI_Yellow;
+  else  cucol = PI_ColorAllBits1;
+  g->SelForeground(cucol);
+
+  // Nouveau taille du curseur
+  cuhsz = xszpav/2;  cuvsz = yszpav/2;
+  if (zoom > 0)  { cuhsz = xszpav*zoom/2;  cuvsz = yszpav*zoom/2; }
+  else { cuhsz = xszpav/(-zoom*2);  cuvsz = yszpav/(-zoom*2); }
+  if ( cuhsz < 10) cuhsz = 10;
+  if ( cuvsz < 10) cuvsz = 10;
+
+  xcurs = xc;   ycurs = yc;
+
+  g->DrawLine(xcurs-cuhsz, ycurs, xcurs-4, ycurs);
+  g->DrawLine(xcurs+4, ycurs, xcurs+cuhsz, ycurs);
+  g->DrawLine(xcurs, ycurs-cuvsz, xcurs, ycurs-4);
+  g->DrawLine(xcurs, ycurs+4, xcurs, ycurs+cuvsz);
+  //  printf("DrawCursor() %d %d - %d %d \n", xcurs, ycurs, cuhsz, cuvsz);
+  }
+else { 
+  xcurs = ycurs = -1; cuhsz = cuvsz = 10; 
+  cucol = PI_Yellow; culat = PI_NormalLine; 
+  }
+
+g->SelGOMode(PI_GOCopy);
+g->SelLine(PI_NormalLine);
+g->SelForeground(PI_White);
+return;
+}
+
+ 
+/* --Methode-- */
+void PIImage::DrawInfo(PIGraphic* g, char* txt)
+{
+g->SelFont(PI_NormalSizeFont, PI_RomanFont);
+if (txt) { 
+  PIColors fgc = g->GetForeground();
+  PIGOMode gm = g->GetGOMode();
+  g->SelGOMode(PI_GOCopy);
+  int cmapid = cmap->Type();
+  if ( (cmapid == CMAP_GREY32) || (cmapid == CMAP_GREYINV32) || 
+       (cmapid == CMAP_GREY128) || (cmapid == CMAP_GREYINV128))  g->SelForeground(PI_Red);
+  else g->SelForeground(PI_Turquoise);
+//  g->SelForeground(PI_White);
+  g->SelBackground(PI_Black);
+  g->DrawOpaqueString(20, YSize()-5, txt);
+  g->SelGOMode(gm);
+  g->SelForeground(fgc);
+  }
+else {
+  int a,d,h;
+  h = g->GetFont().GetFontHeight(a, d);
+  if (g->kind() != PI_PSFileGraphics )   PIPixmap::Draw(g, 0, YSize()-10-h, XSize(), h+10); 
+  }
+return;
+}
+
+/* --Methode-- */
+void PIImage::ShowTrTxW()
+{
+if (trtw) 
+  {
+  int tpx, tpy;
+  GetScreenPos(tpx, tpy);
+  tpy -= (trtw->YSize()+5);
+  if (tpy < 0)  tpy = 0;
+  trtw->SetPos(tpx, tpy);
+  trtw->Show();  
+  }
+
+return;
+}
+
+/* --Methode-- */
+int PIImage::PosW2Img(int xiw, int yiw, int * xp, int * yp)
+{
+if (!img) { *xp = *yp = 0;  return(1); }
+xiw -= ofx;  yiw -= ofy;   // Offset d'affichage du pixmap
+if (zoom > 0)
+  {
+  *xp = xiw/zoom+offx;
+  *yp = yiw/zoom+offy;
+  }
+else
+  {
+  *xp = offx-xiw*zoom;
+  *yp = offy-yiw*zoom;
+  }
+
+if ( (*xp >= 0) && (*xp < img->XSize() ) &&
+     (*yp >= 0) && (*yp < img->YSize() )  )   return(0);
+else return(1);
+}
+
+
+/* --Methode-- */
+int PIImage::PosImg2W(int xp, int yp, int * xiw, int * yiw)
+{
+if (!img) { *xiw = *yiw = -1;  return(1); }
+if (zoom > 0)
+  {
+  *xiw = (xp-offx)*zoom+(zoom/2);
+  *yiw = (yp-offy)*zoom+(zoom/2);
+  }
+else
+  {
+  *xiw = (offx-xp)/zoom;
+  *yiw = (offy-yp)/zoom;
+  }
+
+*xiw += ofx;  *yiw += ofy;    // Offset d'affichage du pixmap
+if (*xiw > XSize())  *xiw = -1;
+if (*yiw > YSize())  *yiw = -1;
+
+if ((*xiw < 0) || (*yiw < 0))  return(1);
+else return(0);
+}
+
+
+/* --Methode-- */
+void PIImage::SetOffsetFromPave()
+{
+if (!img) { offx = offy = 0; return; }
+if (zoom > 0)
+  {
+  offx = xpav-XSize()/2/zoom;
+  offy = ypav-YSize()/2/zoom;
+  }
+else
+  {
+  offx = xpav+XSize()/2*zoom;
+  offy = ypav+YSize()/2*zoom;
+  }
+
+if (offx < 0)  offx = 0;
+if (offx >= (img->XSize()-1))  offx = img->XSize()-2;
+if (offy < 0)  offy = 0;
+if (offy >= (img->YSize()-1))  offy = img->YSize()-2;
+
+return;
+}
+
+/* --Methode-- */
+void PIImage::CenterPave()
+{
+int xwsz, ywsz;
+
+if (zoom > 0)
+  { xwsz = XSize()/zoom;  
+  ywsz = YSize()/zoom;  }
+else
+  { xwsz = -(XSize()*zoom); 
+  ywsz = -(YSize()*zoom); }
+
+if (img) {   
+  if (xwsz > (img->XSize()-offx)) xwsz = (img->XSize()-offx);
+  if (ywsz > (img->YSize()-offy)) ywsz = (img->YSize()-offy);
+  }
+xpav = offx+xwsz/2; 
+ypav = offx+ywsz/2;
+xszpav = ((xwsz+ywsz)/15) ;
+if (xszpav < 1) xszpav = 1;
+yszpav = xszpav; 
+
+return;
+}
+
+
+//---------------------------------------------------------------------------------
+//-------  On definit une classe ArrayAdapter pour les donnees des coupes  --------
+//---------------------------------------------------------------------------------
+
+/* --Methode-- */
+PIImage::PIImg1DArrAdapter::PIImg1DArrAdapter() : P1DArrayAdapter(0) 
+{
+data = NULL;
+fgaxyda = 1;
+off1 = off2 = 0;
+}
+
+/* --Methode-- */
+void PIImage::PIImg1DArrAdapter::SetData(P2DArrayAdapter* d, unsigned short axyda
+                                        ,int sz,int o1,int o2)
+// axyda&1 axe (X), axyda&2 axe (Y), axyda&4 diag (X,Y), axyda&8 anti-diag (X,-Y)
+{
+data = d; mSize = 0;
+fgaxyda = axyda;
+if(!data) return;
+if (o1 < 0)  o1 = 0;
+if (o2 < 0)  o2 = 0;
+if (o1 >= d->XSize()) o1 = d->XSize()-1; 
+if (o2 >= d->YSize()) o2 = d->YSize()-1; 
+off1 = o1;
+off2 = o2;
+if ((sz%2) == 0)  sz++;
+if (sz < 0) sz = 1;
+mSize = sz;
+}
+
+/* --Methode-- */
+double PIImage::PIImg1DArrAdapter::Value(int i)
+{
+if (!data) return(0.);
+int j,k;
+if (fgaxyda&1) {          // Axe X
+  j = off1-mSize/2+i;
+  if (j<0) j=0; if(j>=data->XSize()) j=data->XSize()-1;
+  return((*data)(j,off2));
+  }
+else if (fgaxyda&2) {     // Axe Y
+  k = off2-mSize/2+i;
+  if(k<0) k=0; if(k>=data->YSize()) k=data->YSize()-1;
+  return((*data)(off1,k));
+  }
+else if (fgaxyda&4) {     // Axe XY
+  j = off1-mSize/2+i;
+  k = off2-mSize/2+i;
+  if(j<0) j=0; if(j>=data->XSize()) j=data->XSize()-1;
+  if(k<0) k=0; if(k>=data->YSize()) k=data->YSize()-1;
+  return((*data)(j,k));
+  }
+else if (fgaxyda&8) {     // Axe -XY
+  j = off1-mSize/2+i;
+  k = off2+mSize/2-i;
+  if(j<0) j=0; if(j>=data->XSize()) j=data->XSize()-1;
+  if(k<0) k=0; if(k>=data->YSize()) k=data->YSize()-1;
+  return((*data)(j,k));
+  }
+return(0.);
+}
Index: /tags/V_LaSilla191199/SophyaPI/PI/piimage.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piimage.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piimage.h	(revision 464)
@@ -0,0 +1,195 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive     PIImage
+// Affichage d image            R. Ansari  05/95
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIIMAGE_H_SEEN
+#define PIIMAGE_H_SEEN
+
+#include "parradapter.h"
+
+#include "pisysdep.h"
+
+#include "pidrawer.h"
+#include PIPIXMAP_H
+#include PISTDWDG_H
+#include PIWIN_H
+#include "picmapview.h"
+
+class PIScDrawWdg;
+
+class PIImage : public PIPixmap
+{
+
+public:
+  enum {ClassId = 5150};
+
+//  Les methodes 
+
+  PIImage(PIContainerGen *par, const char *nom=NULL, 
+           int sx=0, int sy=0, int px=0, int py=0);
+  ~PIImage();
+
+  virtual long    kind() {return ClassId; }
+
+//  Tableau des pixels et changement de configuration des axes 
+  void SetImage(P2DArrayAdapter* pim, bool ad = true, bool refr=true);
+  void ChangeAxesConfiguration(bool ix, bool iy, bool xy, bool refr=true);
+  inline void   SetDrawAxesFlags(unsigned int flags=kBoxAxes | kExtTicks | kLabels)
+                       { mdrw->SetAxesFlags(flags); mdrw->Refresh(); }
+
+// Fenetre de Zoom, Vue globale, ColorMap, text, ...
+  void SetZoomWin(PIPixmap * zw, bool refr=false);
+  void SetGloVWin(PIPixmap * zw, bool refr=false);
+  void SetCMapWin(PICMapView * cw, bool refr=false);
+
+  void UseInfoWin(bool trw=false);
+  void ShowInfo(bool si=true); 
+  void ShowCursor(bool sc=true); 
+
+  void ShowCuts(bool cuts=true);
+  void SelectCuts(unsigned xyda=3);
+
+//  Gestion du choix de LUT, facteur d agrandissement, table de couleur
+  void SetLut(double min, double max, int typlut=kLutType_Lin,
+              int lauto=0, bool refr=true);
+  void SetLut(LUT *clut, bool refr=true);
+
+  void SetZoom(int zm, bool refr=true);
+  void SetZoomF(float fzm, bool refr=true);
+  float GetZoomF();
+
+// Changement de table de couleur
+  virtual void SetColMap(PIColorMap* cmp, bool refr=true);
+  virtual void SetColMapId(CMapId cmapid, bool refr=true);
+
+// Positionnement image - pave
+  void SetOffset(int ox, int oy, bool refr=true);
+  void SetPave(int x, int y, bool refr=true, bool cent=true);
+
+// Acces aux informations
+  inline P2DArrayAdapter * Image() { return(img); }
+  inline LUT *     Lut() { return(lut); }
+  inline int XPave() { return(xpav); } ;
+  inline int YPave() { return(ypav); } ;
+
+  inline int XSzPave() { return(xszpav); }
+  inline int YSzPave() { return(yszpav); }
+
+  inline PIElDrawer* MyElDrawer() { return (mdrw); }
+
+// Rafraichissement des widgets auxiliaires (zoom, ...)
+  void Apply(bool mw=true);
+
+// Gestion du trace et des evenements 
+  virtual void Resize();
+  virtual void Draw(PIGraphic* g, int x0, int y0, int dx, int dy);
+
+  virtual void Keyboard(int key, PIKeyModifier kmod);
+  virtual void But1Press(int x, int y);
+  virtual void But1Release(int x, int y);
+  virtual void Ptr1Move(int x, int y);
+  virtual void But2Press(int x, int y);
+  virtual void But2Release(int x, int y);
+  virtual void Ptr2Move(int x, int y);
+  virtual void But3Press(int x, int y);
+  virtual void But3Release(int x, int y);
+  virtual void Ptr3Move(int x, int y);
+
+// Gestion du copier-coller
+  virtual void   PasteSelection(unsigned int typ, void *pdata, unsigned int l);
+  virtual void*  ProvideSelection(unsigned int& typ, unsigned int& len);
+  virtual void   SelectionLost();
+
+//  Pour acces par les ImgTools (LutWind, ...)
+  static PIImage* CurrentPIImage();
+  static void SetCurrentPIImage(PIImage* curimg);
+
+//  On definit une classe ArrayAdapter pour les donnees des coupes 
+  class PIImg1DArrAdapter : public P1DArrayAdapter {
+  public :
+	             PIImg1DArrAdapter();
+     virtual double  Value(int i);
+     virtual void    SetData(P2DArrayAdapter* d, unsigned short axyda, int sz, int o1, int o2);
+  protected :
+    P2DArrayAdapter* data;
+    unsigned short fgaxyda;
+    int off1, off2;
+  };
+
+protected:
+  virtual void    Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+  void ComputePixmap();
+  void ComputeZoomPixmap();
+  void ComputeGloVPixmap();
+  void SetGloVPixmap();
+  void UpdateCuts();
+
+  void DrawCursor(PIGraphic* g);
+  void DrawCursor(PIGraphic* g, int xc, int yc);
+  void DrawInfo(PIGraphic* g, char* txt);
+
+  void ShowTrTxW();
+
+  int PosW2Img(int xiw, int yiw, int * xp, int * yp);
+  int PosImg2W(int xp, int yp, int * xiw, int * yiw);
+
+  void SetOffsetFromPave();
+  void CenterPave();
+
+// Les donnees 
+  P2DArrayAdapter * img;
+  bool aisup;     // Flag de suppression automatique de img
+  bool curshow;
+  bool winovis;   // $CHECK$ Reza A enlever si possible 17/6/96
+// Tableau des pixels principal  
+  unsigned char * pixm;
+  int xspxm, yspxm;
+  LUT * lut;
+  int offx, offy;
+  PIElDrawer* mdrw;
+// Fenetre de zoom
+  int zoom;
+  PIPixmap * zow;
+  unsigned char * zpixm;
+  int xszpxm, yszpxm;
+// Fenetre pour l'image entiere  
+  int zmgv;
+  PIPixmap * gvw;
+  unsigned char * gpixm;
+  int xsgpxm, ysgpxm;
+  PIElDrawer* gvdrw;
+// Fenetre d'affichage du ColMap
+  PICMapView* cmvw;
+// Fenetre/champ de texte
+  PILabel * trtlb;
+  PIWindow * trtw;
+  bool ustrtw, atrtw;
+  bool showinfo;
+// Le pave et le curseur
+  int xpav, ypav;
+  int xpv0, ypv0;
+  int xmv0, ymv0;
+  int dxmv, dymv;
+  int xcurs, ycurs;  // Position curseur
+  int cuhsz, cuvsz;  // Taille vertical, horizontal curseur
+  PILineAtt culat;   // Attribut de ligne du curseur  
+  PIColors cucol;    // Attribut de couleur du curseur
+  int xszpav, yszpav;
+// Pour gerer une fenetre pour les coupes en X,Y
+  unsigned short selcuts;
+  PIWindow * cutwin;
+  PIScDrawWdg * cutscw;
+  PIImg1DArrAdapter * cutarrx; 
+  PIImg1DArrAdapter * cutarry; 
+  PIImg1DArrAdapter * cutarrd; 
+  PIImg1DArrAdapter * cutarra; 
+
+// buffer pour copier-coller
+  char* cpbuffer;
+  int cpbuflen;
+//  PIImage courante 
+  static PIImage* cur_piimage;
+};
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/piimgtools.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piimgtools.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piimgtools.cc	(revision 464)
@@ -0,0 +1,409 @@
+// 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 "piimage.h"
+
+// ------ Menu des options et fenetre de dialogue pour changement de LUT --------
+
+PIImgTools* PIImgTools::curlutw = NULL;
+/* --Methode-- */
+void PIImgTools::ShowPIImgTools() 
+{
+if (curlutw == NULL)  curlutw = new PIImgTools(PIApplicationGetApp());
+curlutw->Show();
+}
+
+/* --Methode-- */
+PIImgTools::PIImgTools(PIApplication* par)
+: PIWindow((PIMsgHandler*)par, "PIImageTools", PIWK_normal, 240, 240, 150, 150)
+{
+int bsx, bsy, spx, spy;
+
+// On definit la taille a partir de la taille par defaut des composantes 
+// PIApplicationPrefCompSize(bsx, bsy);
+par->PrefCompSz(bsx, bsy);
+spx = bsx/10;
+spy = bsy/4;
+
+// int wszx = 8*spx+3*bsx+2*bsy; 
+int wszx = 8*spx+3.5*bsx; 
+int wszy = (10+4)*spy+9*bsy;
+SetSize(wszx, wszy);
+
+int cpx = spx*2;
+int cpy = spy*2;
+int csx = cpx;
+int csy = cpy;
+mLab[0] = new PILabel(this, "MinPixel", bsx, bsy, cpx, cpy);
+cpy += spy+bsy; 
+mLab[1] = new PILabel(this, "MaxPixel", bsx, bsy, cpx, cpy);
+mLab[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mLab[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+cpy = spy*2;
+cpx += spx+bsx; 
+mText[0] = new PIText(this, "MinVal", 1.5*bsx, bsy, cpx, cpy);
+mText[0]->SetText("1");
+cpy += spy+bsy; 
+mText[1] = new PIText(this, "MaxVal", 1.5*bsx, bsy, cpx, cpy);
+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);
+cpy += spy+bsy; 
+cpx = spx*2;
+mOlb[0] = new PILabel(this, "LutType", bsx, bsy, cpx, cpy);
+mOlb[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += spx+bsx; 
+mOpt[0] = new PIOptMenu(this, "imglut-opt-1", 1.5*bsx, bsy, cpx, cpy);
+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);
+
+cpy += spy+bsy; 
+cpx = spx*2;
+mOlb[1] = new PILabel(this, "AutoLut", bsx, bsy, cpx, cpy);
+mOlb[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += spx+bsx; 
+mOpt[1] = new PIOptMenu(this, "imglut-opt-2", 1.5*bsx, bsy, cpx, cpy);
+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);
+
+cpy += 2*spy+bsy; 
+cpx = 3*spx+0.2*bsx;
+mBut[0] = new PIButton(this, "Apply", 2500, bsx*1.6, bsy, cpx, cpy);
+// mBut[0] = new PIButton(this, "Apply", 2500, bsx, bsy, cpx, cpy);
+mBut[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += bsx*1.6+2*spx;
+// cpx += bsx+2*spx;
+mBut[1] = new PIButton(this, "Dismiss", 2600,  bsx*1.6, bsy, cpx, cpy);
+// mBut[1] = new PIButton(this, "Dismiss", 2600, bsx, bsy, cpx, cpy);
+mBut[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+int offy = cpy+bsy+spy*3;
+// printf("-DBG- PIImgTools()  SzX,Y= %d %d , ButPos= %d %d (off=%d)\n", wszx, wszy, cpx, cpy, offy);
+
+// cpx = 4*spx+2.75*bsx;
+cpx = wszx-bsx-3*spx;
+cpy = 2*spy;
+mSc[0] = new PIScale(this, "sc-offset-lut", 2700, kSDirDownUp, 0.5*bsx, 4.5*bsy, cpx, cpy); 
+cpx += 0.50*bsx+spx;
+mSc[1] = new PIScale(this, "sc-dyn-lut", 2800, kSDirDownUp, 0.55*bsx, 4.5*bsy, cpx, cpy); 
+mSc[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mSc[0]->SetMinMax(-50, 50);
+mSc[0]->SetValue(0);
+mSc[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mSc[1]->SetMinMax(-50, 50);
+mSc[1]->SetValue(0);
+
+//  Option-Menu  Couleur/Zoom
+cpx = 3*spx;
+cpy = offy;
+mOptzc[0] = new PIOptMenu(this, "imglut-opt-3", bsx*1.75, bsy, cpx, cpy);
+mOptzc[0]->AppendItem("Grey32", 201);
+mOptzc[0]->AppendItem("GreyInv32", 202);
+mOptzc[0]->AppendItem("ColRJ32", 203);
+mOptzc[0]->AppendItem("ColBR32", 204);
+mOptzc[0]->AppendItem("ColRV32", 205);
+mOptzc[0]->AppendItem("Grey128", 206);
+mOptzc[0]->AppendItem("GreyInv128", 207);
+mOptzc[0]->AppendItem("ColRJ128", 208);
+mOptzc[0]->AppendItem("ColBR128", 209);
+mOptzc[0]->AppendItem("Col16", 210);
+mOptzc[0]->SetValue(203);
+mOptzc[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+cpx += bsx*1.75+2*spx;
+mOptzc[1] = new PIOptMenu(this, "imglut-opt-4", bsx*1.75, bsy, cpx, cpy);
+mOptzc[1]->AppendItem("Agr. x10", 110);
+mOptzc[1]->AppendItem("Agr. x 8", 108);
+mOptzc[1]->AppendItem("Agr. x 6", 106);
+mOptzc[1]->AppendItem("Agr. x 5", 105);
+mOptzc[1]->AppendItem("Agr. x 4", 104);
+mOptzc[1]->AppendItem("Agr. x 3", 103);
+mOptzc[1]->AppendItem("Agr. x 2", 102);
+mOptzc[1]->AppendItem("Zoom x 1", 101);
+mOptzc[1]->AppendItem("Red. / 2", 98);
+mOptzc[1]->AppendItem("Red. / 3", 97);
+mOptzc[1]->AppendItem("Red. / 4", 96);
+mOptzc[1]->AppendItem("Red. / 5", 95);
+mOptzc[1]->AppendItem("Red. / 6", 94);
+mOptzc[1]->AppendItem("Red. / 8", 92);
+mOptzc[1]->AppendItem("Red. /10", 90);
+mOptzc[1]->SetValue(101);
+mOptzc[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+cpy += spy+bsy;
+cpx = 4*spx+0.875*bsx;
+mOptCut = new PIOptMenu(this, "Cut", bsx*1.75, bsy, cpx, cpy);
+mOptCut->AppendItem("Cut X",301);
+mOptCut->AppendItem("Cut Y",302);
+mOptCut->AppendItem("CutXY",303);
+mOptCut->AppendItem("Cut D",304);
+mOptCut->AppendItem("Cut A",308);
+mOptCut->AppendItem("CutDA",312);
+mOptCut->AppendItem("CutAll",315);
+mOptCut->SetValue(303);
+mOptCut->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+int pbsx = bsy;
+int pbsy = bsy;
+int pspx = spy/2;
+int pspy = spy;
+
+cpx = 2*spx;
+cpy += bsy+spy;
+mButsz[0] = new PIButton(this, "1x1", 3201,  pbsx, pbsy, cpx, cpy);
+mButsz[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += pbsx+pspx;
+mButsz[1] = new PIButton(this, "1x2", 3202,  pbsx, pbsy, cpx, cpy);
+mButsz[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += pbsx+pspx;
+mButsz[2] = new PIButton(this, "1x4", 3204,  pbsx, pbsy, cpx, cpy);
+mButsz[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += pbsx+pspx;
+mButsz[3] = new PIButton(this, "1/2", 3198,  pbsx, pbsy, cpx, cpy);
+mButsz[3]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += pbsx+pspx;
+mButsz[4] = new PIButton(this, "1/4", 3196,  pbsx, pbsy, cpx, cpy);
+mButsz[4]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+//cpx += pbsx+10*pspx;
+cpx = wszx-3.0*pbsx-2*spx-pspx;
+mButoa[0] = new PIButton(this, "+Info", 5311,  1.5*pbsx, pbsy, cpx, cpy);
+mButoa[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += 1.5*pbsx+pspx;
+mButoa[1] = new PIButton(this, "-Info", 5312,  1.5*pbsx, pbsy, cpx, cpy);
+mButoa[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+
+cpx = 2*spx;
+cpy += pbsy+pspy;
+mButcax[0] = new PIButton(this, "-X", 5201,  pbsx, pbsy, cpx, cpy);
+mButcax[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += pbsx+pspx;
+mButcax[1] = new PIButton(this, "-Y", 5202,  pbsx, pbsy, cpx, cpy);
+mButcax[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += pbsx+pspx;
+mButcax[2] = new PIButton(this, "X-Y", 5203, pbsx, pbsy, cpx, cpy);
+mButcax[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+// cpx += 1.5*pbsx+pspx+10*pspx;
+cpx = wszx-4.5*pbsx-2*spx-2*pspx;
+mButoa[2] = new PIButton(this, "-All", 5300,  1.5*pbsx, pbsy, cpx, cpy);
+mButoa[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += 1.5*pbsx+pspx;
+mButoa[3] = new PIButton(this, "+Curs", 5321,  1.5*pbsx, pbsy, cpx, cpy);
+mButoa[3]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += 1.5*pbsx+pspx;
+mButoa[4] = new PIButton(this, "+Axe", 5331,  1.5*pbsx, pbsy, cpx, cpy);
+mButoa[4]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+curlutw = this;
+
+}
+
+/* --Methode-- */
+PIImgTools::~PIImgTools()
+{
+if (curlutw == this)  curlutw = NULL;
+int i;
+for(i=0; i<2; i++)
+  {
+  delete mLab[i];
+  delete mBut[i];
+  delete mText[i];
+  delete mOpt[i];
+  delete mOlb[i];
+  delete mSc[i];
+  delete mOptzc[i];
+  }
+for(i=0; i<5; i++)  delete mButsz[i];
+for(i=0; i<3; i++)  delete mButcax[i];
+for(i=0; i<5; i++)  delete mButoa[i];
+delete mOptCut;
+}
+
+/* --Methode-- */
+void PIImgTools::Show()
+{
+char buff[32];
+PIImage *mpii;
+PIWindow::Show();
+mpii = PIImage::CurrentPIImage();
+if (mpii == NULL)  return;
+min_lut = mpii->Lut()->Min();
+max_lut = mpii->Lut()->Max();
+sprintf(buff,"%g", min_lut);
+mText[0]->SetText(buff);
+sprintf(buff,"%g", max_lut);
+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);
+mSc[0]->SetValue(0);
+mSc[1]->SetValue(0);
+mOptzc[0]->SetValue(203);
+mOptzc[1]->SetValue(101);
+mOptCut->SetValue(303);
+return;
+}
+
+
+/* --Methode-- */
+void PIImgTools::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
+{
+double min, max, del;
+int lauto, typ;
+int typlut[2] = {kLutType_Lin, kLutType_Log} ; 
+
+msg = UserMsg(msg);
+
+if (msg == 2600)  { this->Hide();  return; }
+PIImage* mpii = PIImage::CurrentPIImage();
+if (mpii == NULL)  return;
+
+switch (msg)
+  {
+  case 2500:
+  case 2700 :
+  case 2800 :
+    {
+    min = atof(mText[0]->GetText().c_str());
+    max = atof(mText[1]->GetText().c_str());
+    if (msg == 2700) {
+      del = max_lut-min_lut;
+      min = min_lut+(double)mSc[0]->GetValue()/100*del;
+      max = max_lut+(double)mSc[0]->GetValue()/100*del;
+    }
+    if (msg == 2800) {
+      del = max_lut-min_lut;
+      min = min_lut-(double)mSc[1]->GetValue()/100.*del*0.5;
+      max = max_lut+(double)mSc[1]->GetValue()/100.*del*0.5;
+    }
+    if ( (msg == 2700) || (msg == 2800) ) {
+      char buff[92];
+      sprintf(buff,"%g", min);
+      mText[0]->SetText(buff);
+      sprintf(buff,"%g", max);
+      mText[1]->SetText(buff);
+      lauto = 0;
+    }
+    else 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);
+    if (msg == 2500) { 
+      min_lut = min;   max_lut = max;
+      mSc[0]->SetValue(0);
+      mSc[1]->SetValue(0);
+      }
+//    ((PIImage::CurrentPIImage())->Lut())->Print();
+    }
+    break;
+
+  case 3201 :
+  case 3202 :
+  case 3204 :
+  case 3198 :
+  case 3196 :
+    {
+    PIImage* pimg = PIImage::CurrentPIImage();
+    int zm = msg-3200;
+    pimg->SetZoom(zm, false);
+    int sx, sy, snx, sny;
+    sx = pimg->XSize();
+    sy = pimg->YSize();
+    if (zm > 0)
+      {
+      snx = pimg->Image()->XSize()*zm;
+      sny = pimg->Image()->YSize()*zm;
+      }
+    else 
+      {
+      snx = pimg->Image()->XSize()/(-zm);
+      sny = pimg->Image()->YSize()/(-zm);
+      }
+    if ((snx != sx) || (sny != sy))
+      {
+      int szinc[2];
+      pimg->SetOffset(0, 0, false);
+      szinc[0] = snx-sx;   szinc[1] = sny-sy;
+      pimg->Send(pimg->Msg(), PIMsg_ResizeRequest, szinc);  
+      }
+    else   pimg->SetOffset(0, 0);
+    
+    }
+    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 :
+    mpii->SetDrawAxesFlags(kAxesNone);
+    mpii->ShowCursor(false);
+    mpii->MyElDrawer()->ElDelAll();
+    mpii->Refresh();
+    break;
+
+  case 5311 :
+    mpii->ShowInfo(true);
+    break;
+
+  case 5312 :
+    mpii->ShowInfo(false);
+    break;
+
+  case 5321 :
+    mpii->ShowCursor(true);
+    break;
+
+  case 5331 :
+    mpii->SetDrawAxesFlags();
+    break;
+
+  default:
+//    printf("PIImgTools::Process Msg %d received \n", (int)msg);
+    break;
+  }
+
+
+CMapId cmap[10] =  { CMAP_GREY32, CMAP_GREYINV32, CMAP_COLRJ32,
+                      CMAP_COLBR32, CMAP_COLRV32, CMAP_GREY128,
+                      CMAP_GREYINV128, CMAP_COLRJ128, CMAP_COLBR128,
+                      CMAP_COL16 };
+
+if ((msg <= 110) && (msg >= 90))  // Zoom
+  PIImage::CurrentPIImage()->SetZoom((int)(msg-100), true);
+else if ((msg > 200) && (msg < 211)) // Changement de couleur 
+  PIImage::CurrentPIImage()->SetColMapId(cmap[msg-201], true);
+
+// Cuts
+if(301<=msg && msg<=315) {
+  PIImage::CurrentPIImage()->SelectCuts((unsigned short) (msg-300));
+}
+
+return;
+}
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/piimgtools.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piimgtools.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piimgtools.h	(revision 464)
@@ -0,0 +1,51 @@
+// 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 PIOPTMENU_H
+#include PIWIN_H
+#include PIAPP_H
+
+// ------ fenetre de dialogue pour changement de LUT et options de PIImage --------
+// --------------------------------------------------------------------------------
+
+class PIImgTools : public PIWindow {
+public :
+  PIImgTools(PIApplication* par);
+  ~PIImgTools();
+  virtual void  Show();
+
+  static PIImgTools* curlutw;
+  static void ShowPIImgTools();
+protected:
+  virtual void  Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+
+private:
+// Pour changer la LUT
+  PILabel* mLab[2];
+  PIButton* mBut[2];
+  PIText* mText[2];
+  PIOptMenu* mOpt[2];
+  PILabel* mOlb[2];
+  PIScale* mSc[2];
+  float min_lut,max_lut;
+// Pour la couleur et le zoom
+  PIOptMenu* mOptzc[2];
+// Pour expand et compress
+  PIButton* mButsz[5];
+// Config axes 
+  PIButton* mButcax[3];
+// Options show/hide
+  PIButton* mButoa[5];
+// Options Cuts
+  PIOptMenu* mOptCut;
+};
+
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pilistgen.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pilistgen.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pilistgen.cc	(revision 464)
@@ -0,0 +1,82 @@
+// Module PI : Peida Interactive     PIList
+// Liste                                     96-97
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "pilistgen.h"
+
+//++
+// Class	PIList
+// Lib		PI
+// include	pilistgen.h
+//
+//	Composant graphique de type liste, permettant d'afficher une liste 
+//	d'éléments, qui peuvent être sélectionnés à l'aide du pointeur (souris). 
+//	"PIListGen" définit l'interface (classe virtuelle pure). Les objets 
+//	instanciés doivent être de la classe "PIList" déclarée dans le fichier
+//	entête "PILIST_H". Lors de la sélection d'un des éléments, 
+//	le message correspondant complété par "PIMsg_Select" est envoyé.
+//	Le modifier "PIMsg_ClearSel" est appliqué lorsque d'une dé-sélection.
+//--
+//++
+// Links	Parents
+// PIWdg
+//--
+
+//++
+// Titre	Constructeur
+//--
+//++
+// PIListGen(PIContainerGen* par, const char* nom, int sx=100, int sy=100, int px=0, int py=0)
+//	Création d'un objet liste (PIList). 
+//--
+
+//++
+// Titre	Ajout et suppression d'éléments
+//--
+//++
+// void  AppendItem(char* nom, PIMessage msg)
+//	Ajoute un élément à la liste.
+// void  DeleteItem(const char *item)
+//	Supprime l'élément "item" de la liste.
+// void  DeleteItemMsg(PIMessage msg)
+//	Supprime l'élément identifié par le message "msg" de la liste.
+// void  DeleteAllItems()
+//	Supprime tous les éléments
+// int	GetNbItems()
+//	Renvoie le nombre d'éléments de la liste
+// PIMessage  GetItemMsg(int n)
+//	Renvoie le message de l'élément "n"
+// string  GetItem(int n)
+//	Renvoie le texte de l'élément "n"
+//--
+//++
+// Titre	Gestion des sélections
+//--
+//++
+// void  SetMultipleSelect(bool ms=false)
+//	Active ("ms=true") ou désactive la possibilité de sélection multiple.
+// int   GetNbSelection()
+//	Renvoie le nombre d'éléments sélectionnés.
+// PIMessage  GetSelection(int num=0)
+//	Renvoie le message correspondant à la sélection numéro "n". L'ordre 
+//	dans lequel les sélections sont retournées est indéfini.
+// string   GetSelectionStr(int num=0)
+//	Renvoie la chaîne de caractères correspondant à l'élément sélectionné 
+//	numéro "n".
+// void  SelectItem(const char* item)
+//	Permet de sélectionner l'élément "item".
+// void  SelectItemMsg(PIMessage msg)
+//	Permet de sélectionner l'élément identifié par le message "msg".
+// void  ClearSelItem(const char* item)
+//	Efface la sélection pour l'élément "item".
+// void  ClearSelItemMsg(PIMessage msg)
+//	Efface la sélection pour l'élément identifié par le message "msg".
+//--
+
+PIListGen::PIListGen(PIContainerGen *par, const char *nom,
+                     int sx, int sy, int px, int py)
+: PIWdg(par, nom, sx, sy, px, py)
+{}
+
+PIListGen::~PIListGen()
+{}
Index: /tags/V_LaSilla191199/SophyaPI/PI/pilistgen.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pilistgen.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pilistgen.h	(revision 464)
@@ -0,0 +1,42 @@
+#ifndef PILISTGEN_H_SEEN
+#define PILISTGEN_H_SEEN
+
+#include "pisysdep.h"
+#include PIWDG_H
+
+
+class PIListGen : public PIWdg {
+public:
+  enum {ClassId = 1110};
+
+	             PIListGen(PIContainerGen* par, const char* nom,
+                               int sx=100, int sy=100, int px=0, int py=0);
+	             ~PIListGen();
+				   
+  virtual void	     AppendItem(const char * item, PIMessage msg)=0;
+  virtual void       DeleteItem(const char *item)=0;
+  virtual void       DeleteItemMsg(PIMessage msg)=0;
+  virtual void	     DeleteAllItems()=0;
+  
+  virtual int	     GetNbItems()=0;
+  virtual PIMessage  GetItemMsg(int n)=0;
+  virtual string     GetItem(int n)=0;
+
+  virtual void       SetMultipleSelect(bool ms=false)=0;
+
+  virtual int        GetNbSelection()=0;
+  virtual PIMessage  GetSelection(int num=0)=0;
+  virtual string     GetSelectionStr(int num=0)=0;
+
+  virtual void       SelectItem(const char * item)=0;
+  virtual void       SelectItemMsg(PIMessage msg)=0;
+  virtual void       ClearSelItem(const char * item)=0;
+  virtual void       ClearSelItemMsg(PIMessage msg)=0;
+
+  virtual long       kind() {return ClassId; }
+
+protected:
+}; 
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pilistmac.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pilistmac.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pilistmac.cc	(revision 464)
@@ -0,0 +1,92 @@
+#include<stdio.h>
+
+#include "pilistmac.h"
+
+
+
+
+/* --Methode-- */
+PIListMac::PIListMac(PIContainerGen* par, char* nom,
+                 int sx, int sy, int px, int py)
+: PIListGen(par, nom, sx, sy, px, py)
+{
+  delete mPane;
+  mPane = mPIPPList = new PIPPList(mPaneInfo, mViewInfo, this);
+  Manage();
+}
+
+/* --Methode-- */
+PIListMac::~PIListMac()
+{
+}
+
+
+/* --Methode-- */
+void PIListMac::AppendItem(const char * item, PIMessage msg)
+{
+  mPIPPList->AppendItem(item, msg);
+}
+
+/* --Methode-- */
+void PIListMac::DeleteItem(const char * item)
+{
+  mPIPPList->DeleteItem(item);
+}
+
+/* --Methode-- */
+void PIListMac::DeleteItemMsg(PIMessage msg)
+{
+  mPIPPList->DeleteItem(msg);
+}
+
+
+/* --Methode-- */
+void PIListMac::SetMultipleSelect(bool ms)
+{
+  mPIPPList->SetMultipleSelect(ms);
+}
+
+/* --Methode-- */
+int PIListMac::GetNbSelection()
+{
+  return mPIPPList->GetNbSel();
+}
+
+/* --Methode-- */
+PIMessage PIListMac::GetSelection(int num)
+{
+  return mPIPPList->GetSelMsg(num);
+}
+
+/* --Methode-- */
+string PIListMac::GetSelectionStr(int num)
+{
+  return mPIPPList->GetSelStr(num);
+}
+
+/* --Methode-- */
+void PIListMac::SelectItem(const char * item)
+{
+  mPIPPList->SelectItem(item);
+}
+
+/* --Methode-- */
+void PIListMac::SelectItemMsg(PIMessage msg)
+{
+  mPIPPList->SelectItem(msg);
+}
+
+
+/* --Methode-- */
+void PIListMac::ClearSelItem(const char * item)
+{
+  mPIPPList->ClearSelItem(item);
+}
+
+/* --Methode-- */
+void PIListMac::ClearSelItemMsg(PIMessage msg)
+{
+  mPIPPList->ClearSelItem(msg);
+}
+
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pilistmac.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pilistmac.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pilistmac.h	(revision 464)
@@ -0,0 +1,40 @@
+#ifndef PILISTMAC_H_SEEN
+#define PILISTMAC_H_SEEN
+
+#include "pilistgen.h"
+#include "pipplist.h"
+
+class PIListMac : public PIListGen {
+public:
+	             PIListMac(PIContainerGen* par, char* nom,
+                             int sx=100, int sy=100, int px=0, int py=0);
+	             ~PIListMac();
+				   
+  virtual void	     AppendItem(const char * item, PIMessage msg);
+  virtual void       DeleteItem(const char *item);
+  virtual void       DeleteItemMsg(PIMessage msg);
+  virtual void	     DeleteAllItems();
+
+  virtual int	       GetNbItems();
+  virtual PIMessage  GetItemMsg(int n);
+  virtual string     GetItem(int n);
+
+  virtual void       SetMultipleSelect(bool ms=false);
+
+  virtual int        GetNbSelection();
+  virtual PIMessage  GetSelection(int num=0);
+  virtual string     GetSelectionStr(int num=0);
+
+  virtual void       SelectItem(const char * item);
+  virtual void       SelectItemMsg(PIMessage msg);
+  virtual void       ClearSelItem(const char * item);
+  virtual void       ClearSelItemMsg(PIMessage msg);
+
+
+protected:
+  PIPPList* mPIPPList;
+};
+
+typedef PIListMac        PIList;
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pilistx.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pilistx.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pilistx.cc	(revision 464)
@@ -0,0 +1,422 @@
+#include<stdio.h>
+
+#include "pilistx.h"
+#include "picontainerx.h"
+
+#include <Xm/Xm.h>
+#include <Xm/List.h>
+
+
+/************* PIListX ************/
+
+// Pour ces sal... de XmString  (ds piwdgx.cc)
+int CStrFrXmStr(XmString xms, char* buff, int nmx);
+
+// Fonction prive (CallBack)
+static void list_action(Widget w, XtPointer *usd, XmListCallbackStruct *isel);
+
+/* Nouvelle-Fonction */
+void  list_action(Widget /*w*/, XtPointer *usd, XmListCallbackStruct *isel)
+{
+PIListX *pil;
+
+pil = (PIListX *)usd ;
+//  printf("list_action/Debug: reason=%d itemPos= %d \n", 
+//          isel->reason, isel->item_position);
+pil->ToggleSel(isel->item_position-1, true);
+return;
+}
+
+
+#define NBITEMB  20
+#define NBISELB  5
+
+
+/* --Methode-- */
+PIListX::PIListX(PIContainerGen* par, const char* nom,
+                 int sx, int sy, int px, int py)
+: PIListGen(par, nom, sx, sy, px, py)
+{
+
+mNItem = mNItemMax = 0;
+mMess = NULL;  mSel = NULL;
+mNbSel = mNSelMax = 0;
+mSelNum = NULL;
+ 
+Arg  warg[7];
+int n = 0;
+XtSetArg(warg[n], XmNlistSizePolicy, XmCONSTANT);  n++;
+XtSetArg(warg[n], XmNscrollBarDisplayPolicy, XmAS_NEEDED);  n++;
+// **ATTENTION** Il vaut mieux creer avec les bonnes tailles au depart Reza 09/99 
+//     .....   C'est fait par CreateXtWdg( ... )
+XtSetArg(warg[n],XmNwidth,sx);  n++;
+XtSetArg(warg[n],XmNheight,sy);  n++;
+XtSetArg(warg[n],XmNx,px);  n++;
+XtSetArg(warg[n],XmNy,py);  n++;
+mlist = XmCreateScrolledList(((PIWdgX *)par)->XtWdg(), (char *)nom, warg, n);  // const_cast
+XtManageChild(mlist);
+XtWdg() = XtParent(mlist);
+wmis = k_wmi_normal ;
+stmng = 0;
+
+// **ATTENTION** A ne pas oublier , fait par CreateXtWdg Reza 09/99 
+SetBinding(PIBK_free, PIBK_free, PIBK_free, PIBK_free);
+par->ChildAdd(this);
+
+//XtAddCallback(mlist, XmNdefaultActionCallback,
+//              list_action, (XtPointer)this);
+XtAddCallback(mlist, XmNmultipleSelectionCallback,
+              (XtCallbackProc)list_action, (XtPointer)this);
+XtAddCallback(mlist, XmNsingleSelectionCallback,
+              (XtCallbackProc)list_action, (XtPointer)this);
+
+SetMultipleSelect(false);
+Manage();
+}
+
+/* --Methode-- */
+PIListX::~PIListX()
+{
+
+if (mNItemMax > 0)  
+  {
+    //  XtFree((char *)mItems);
+  delete[] mMess;
+  delete[] mSel;
+  }  
+if (mNSelMax > 0)  delete[] mSelNum;
+}
+
+
+/* --Methode-- */
+void PIListX::AppendItem(const char * item, PIMessage msg)
+{
+
+if (mNItem >= mNItemMax)
+  {
+  PIMessage *mso;
+  bool *slo;
+  int i;
+
+  mso = mMess;
+  slo = mSel;
+  mNItemMax += NBITEMB;
+  mMess = new PIMessage[mNItemMax];
+  mSel = new bool[mNItemMax];
+  for(i=0; i<mNItem; i++)   
+    {  mMess[i] = mso[i];  mSel[i] = slo[i]; }
+
+  delete[] mso;
+  delete[] slo;
+  }
+
+mMess[mNItem] = msg;
+mSel[mNItem] = false;
+mNItem++;
+
+#if defined(__DECCXX) || defined(__KCC__) || defined(__aCC__)
+XmString xms = XmStringCreate(const_cast<char *>(item), XmSTRING_DEFAULT_CHARSET);
+#else
+XmString xms = XmStringCreate((char *)(item), XmSTRING_DEFAULT_CHARSET);
+#endif
+XmListAddItem(mlist, xms, 0);
+XmStringFree(xms);
+return;
+}
+
+/* --Methode-- */
+void PIListX::DeleteItem(const char * item)
+{
+int n;
+if ((n=GetNumItem(item)) < 0)  return;
+DelItem(n);
+return;
+}
+
+/* --Methode-- */
+void PIListX::DeleteItemMsg(PIMessage msg)
+{
+int n;
+if ((n=GetNumItemMsg(msg)) < 0)  return;
+DelItem(n);
+return;
+}
+
+/* --Methode-- */
+void PIListX::DeleteAllItems()
+{
+int nmax = mNItem;
+bool mng = IfManaged();
+if (mng) UnManage();
+for(int i=0; i<nmax; i++) DelItem(0);
+if (mng) Manage();
+}
+
+/* --Methode-- */
+int PIListX::GetNbItems()
+{
+return(mNItem);
+}
+
+/* --Methode-- */
+PIMessage PIListX::GetItemMsg(int n)
+{
+return(ItemMsg(n));
+}
+
+/* --Methode-- */
+string PIListX::GetItem(int n)
+{
+return(ItemStr(n));
+}
+
+/* --Methode-- */
+void PIListX::SetMultipleSelect(bool ms)
+{
+Arg  warg[2];
+
+mMultSel = ms;
+if (ms)
+  XtSetArg(warg[0], XmNselectionPolicy, XmMULTIPLE_SELECT);  
+else
+  XtSetArg(warg[0], XmNselectionPolicy, XmSINGLE_SELECT);  
+
+XtSetValues(mlist, warg, 1);
+}
+
+/* --Methode-- */
+int PIListX::GetNbSelection()
+{
+return(mNbSel);
+}
+
+/* --Methode-- */
+PIMessage PIListX::GetSelection(int num)
+{
+if ( (num < 0) || (num >= mNbSel) ) return(0); 
+return(ItemMsg(mSelNum[num]));
+}
+
+/* --Methode-- */
+string PIListX::GetSelectionStr(int num)
+{
+if ( (num < 0) || (num >= mNbSel) ) return(""); 
+string s(ItemStr(mSelNum[num]));
+return(s);
+}
+
+/* --Methode-- */
+void PIListX::SelectItem(const char * item)
+{
+int n;
+if ((n=GetNumItem(item)) < 0)  return;
+if ((!mMultSel) && (mNbSel > 0))
+  if  (mSelNum[0] != n)  ClrSItem(mSelNum[0], false, true);  
+SelItem(n, false, true);
+return;
+}
+
+/* --Methode-- */
+void PIListX::SelectItemMsg(PIMessage msg)
+{
+int n;
+if ((n=GetNumItemMsg(msg)) < 0)  return;
+if ((!mMultSel) && (mNbSel > 0))
+  if  (mSelNum[0] != n)  ClrSItem(mSelNum[0], false, true);  
+SelItem(n, false, true);
+return;
+}
+
+
+/* --Methode-- */
+void PIListX::ClearSelItem(const char * item)
+{
+int n;
+if ((n=GetNumItem(item)) < 0)  return;
+ClrSItem(n, false, true);
+return;
+}
+
+/* --Methode-- */
+void PIListX::ClearSelItemMsg(PIMessage msg)
+{
+int n;
+if ((n=GetNumItemMsg(msg)) < 0)  return;
+ClrSItem(n, false, true);
+return;
+}
+
+
+/* --Methode-- */
+void PIListX::ToggleSel(int n, bool smg)
+{
+if ( (n < 0) || (n >= mNItem))  return;
+if (mSel[n])  ClrSItem(n,smg); 
+else
+  {
+  if ((!mMultSel) && (mNbSel > 0))  ClrSItem(mSelNum[0], smg);
+  SelItem(n, smg);
+  }
+}
+
+
+/* --Methode-- */
+PIMessage PIListX::ItemMsg(int n)
+{
+if ( (n < 0) || (n >= mNItem))  return(0);
+else return(mMess[n]);
+}
+
+/* --Methode-- */
+char * PIListX::ItemStr(int n)
+{
+Arg  warg[2];
+XmString *xmst=NULL;
+
+if ( (n < 0) || (n >= mNItem))  { mSItem[0] = '\0'; return(mSItem); }
+mSItem[0] = '\0';
+XtSetArg(warg[0], XmNitems, &xmst);  
+XtGetValues(mlist, warg, 1);
+CStrFrXmStr(xmst[n], mSItem, 320);
+return(mSItem);
+}
+
+/* --Methode-- */
+int PIListX::GetNumItem(const char *it)
+{
+for(int i=0; i<mNItem; i++)
+  if (strcmp(ItemStr(i), it) == 0)  return(i);
+return(-1);
+}
+
+/* --Methode-- */
+int PIListX::GetNumItemMsg(PIMessage msg)
+{
+for(int i=0; i<mNItem; i++)
+  if (mMess[i] == msg)   return(i);  
+return(-1);
+}
+
+
+
+/* --Methode-- */
+void PIListX::DelItem(int n)
+{
+int i;
+
+if ((n < 0) || (n > mNItem))  return;
+
+ClrSItem(n);
+for(i=n; i<mNItem-1; i++)
+  { mMess[i] = mMess[i+1];  mSel[i] = mSel[i+1]; }
+mNItem--;
+
+if (mNItem < (mNItemMax-NBITEMB-1))
+  {
+    //  XmString *ito;
+  PIMessage *mso;
+  bool *slo;
+
+  //  ito = mItems;
+  mso = mMess;
+  slo = mSel;
+  mNItemMax -= NBITEMB;
+  mMess = new PIMessage[mNItemMax];
+  mSel = new bool[mNItemMax];
+  //  mItems = (XmString *) XtMalloc(sizeof(XmString)*mNItemMax);
+  for(i=0; i<mNItem; i++)   
+    { // mItems[i] = ito[i];
+    mMess[i] = mso[i];  mSel[i] = slo[i]; }
+
+  //  XtFree((char *)mItems);
+  delete[] mso;
+  delete[] slo;
+  }
+
+XmListDeletePos(mlist, n+1);
+return;
+}
+
+
+/* --Methode-- */
+bool PIListX::SelItem(int n, bool smg, bool cxw)
+{
+int i;
+
+if ((n < 0) || (n > mNItem))  return(false);
+if (mSel[n])  return(false);
+
+mSel[n] = true;
+if (mNbSel >= mNSelMax)
+  {
+  int * osel;
+  osel = mSelNum;
+  mNSelMax += NBISELB;
+  mSelNum = new int[mNSelMax];
+  for(i=0; i<mNbSel; i++)  mSelNum[i] = osel[i];
+  if (osel)  delete[] osel;
+  }
+
+mSelNum[mNbSel] = n; 
+mNbSel++;
+if (smg)  
+  Send(mMess[n], PIMsg_Select); 
+if (cxw)
+  XmListSelectPos(mlist, n+1, FALSE);
+return(true);
+}
+
+
+
+
+/* --Methode-- */
+bool PIListX::ClrSItem(int n, bool smg, bool cxw)
+{
+int i;
+if ((n < 0) || (n > mNItem))  return(false);
+if (!mSel[n])  return(false);
+mSel[n] = false;
+
+mNbSel --;
+if (smg)  
+  Send(mMess[n], PIMsg_ClearSel); 
+if (cxw)
+  XmListDeselectPos(mlist, n+1);
+
+if (mSelNum) delete[] mSelNum;
+if (mNbSel <= 0)
+  { mNSelMax = mNbSel = 0;  mSelNum = NULL; }
+else
+  {
+  mNSelMax = (mNbSel+NBISELB)/NBISELB;
+  mSelNum = new int[mNSelMax];
+  mNbSel =  0;
+  for(i=0; i<mNItem; i++)
+    if (mSel[i]) { mSelNum[mNbSel] = i; mNbSel++; }
+  }
+
+return(true);
+} 
+
+
+/* --Methode-- 
+    A Supprimer .....
+void PIListX::ChangeSel()
+{
+XmString *xmst;
+int n;
+
+n=0;
+XtSetArg(warg[n], XmNselectedItems, &xmst);  n++;
+XtGetValues(mlist, warg, n);
+if (xmst)  XtFree(xmst);
+xmst =  (XmString *) XtMalloc(sizeof(XmString)*mNbSel);
+for(i=0; i<mNbSel; i++)
+  xmst[i] = mItems[mSelNum[i]];
+n=0;
+XtSetArg(warg[n], XmNselectedItems, xmst);  n++;
+XtSetArg(warg[n], XmNselectedItemCount, mNbSel);  n++;
+XtSetValues(mlist, warg, n);
+return;
+}
+   .....  */
Index: /tags/V_LaSilla191199/SophyaPI/PI/pilistx.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pilistx.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pilistx.h	(revision 464)
@@ -0,0 +1,57 @@
+#ifndef PILISTX_H_SEEN
+#define PILISTX_H_SEEN
+
+#include "pilistgen.h"
+
+class PIListX : public PIListGen {
+public:
+	             PIListX(PIContainerGen* par, const char* nom,
+                             int sx=100, int sy=100, int px=0, int py=0);
+	             ~PIListX();
+				   
+  virtual void	     AppendItem(const char * item, PIMessage msg);
+  virtual void       DeleteItem(const char *item);
+  virtual void       DeleteItemMsg(PIMessage msg);
+  virtual void	     DeleteAllItems();
+
+  virtual int	     GetNbItems();
+  virtual PIMessage  GetItemMsg(int n);
+  virtual string     GetItem(int n);
+
+  virtual void       SetMultipleSelect(bool ms=false);
+
+  virtual int        GetNbSelection();
+  virtual PIMessage  GetSelection(int num=0);
+  virtual string     GetSelectionStr(int num=0);
+
+  virtual void       SelectItem(const char * item);
+  virtual void       SelectItemMsg(PIMessage msg);
+  virtual void       ClearSelItem(const char * item);
+  virtual void       ClearSelItemMsg(PIMessage msg);
+
+// Mis en public pour Callback Xt
+  virtual void       ToggleSel(int n, bool smg=false);
+
+protected:
+  PIMessage          ItemMsg(int n);
+  char *             ItemStr(int n);
+  int                GetNumItem(const char * nom);
+  int                GetNumItemMsg(PIMessage msg);
+  void               DelItem(int n);
+  bool               SelItem(int n, bool smg=false, bool cxw=false);
+  bool               ClrSItem(int n, bool smg=false, bool cxw=false);
+
+int mNItem, mNItemMax;
+PIMessage * mMess;
+bool * mSel;
+int mNbSel, mNSelMax;
+int * mSelNum;
+bool mMultSel;
+char mSItem[320];
+
+SysDWdg mlist;
+};
+
+typedef PIListX        PIList;
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pimak
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pimak	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pimak	(revision 464)
@@ -0,0 +1,143 @@
+CC := gcc
+CXX := g++
+# General setup GNU Makefile for EROS. To be included in all makefiles.  
+# Define  makefile variables according to CPU
+# MACHEROSD = `uname | sed 's/-//'`   i.e. { AIX HPUX OSF1 ULTRIX }
+# 
+# Makefile variables set are:
+# - Path to Exec, Include, Libs, Objs directories (from EROSBASEREP env. var.)
+#     i.e. variables LIB, OBJ, EXE, INC 
+#---------------------------------------------------------------------------
+
+# define MACHEROS from uname
+MACHEROS := $(shell echo `uname`)
+# define the -D option
+MACHEROSD := $(shell echo `uname | sed 's/-//'`)
+
+#-
+#-     Optimization option different for HP...
+ifeq (${MACHEROS},HP-UX)
+  O := +O
+else
+  O := -O
+endif
+#-
+#-   Define Makefile paths
+#-  
+ PP  := ${EROSBASEREP}/${MACHEROS}/
+ LIB := ${PP}/Libs/
+ SLB := ${PP}/ShLibs/
+ OBJ := ${PP}/Objs/
+ EXE := ${PP}/Exec/
+ INC := ${EROSBASEREP}/Include/
+ CCI := ${INC}/CInc/
+ CXI := ${INC}/CxxInc/
+#--
+
+#-
+#-    Define default compilation flags
+#--
+ifeq (${MACHEROS},HP-UX)                                    
+  CFLAGS   :=  -Aa
+  FFLAGS   :=  -Aa -I${INC} -D${MACHEROSD}  
+  CPPFLAGS :=  -I${INC} -D${MACHEROSD} \
+               -D_INCLUDE_POSIX_SOURCE -D_INCLUDE_XOPEN_SOURCE
+else
+  FFLAGS   :=  -I${INC} -D${MACHEROSD}  
+  CPPFLAGS :=  -I${INC} -D${MACHEROSD}
+endif
+AR       := ar
+ARFLAGS  := -rcs
+
+ifeq ($(CC), gcc)
+CFLAGS       := -g -O -Wall -Wpointer-arith \
+                -Wmissing-prototypes -Wsynth -I$(INC)
+//CXXFLAGS     := $(CFLAGS) -fno-implicit-templates -I$(CXI)
+CXXFLAGS     := $(CFLAGS) -I$(CXI)
+endif
+
+#- redefine implicit rule. Les .o sont dans $(OBJ).
+$(OBJ)%.o:%.c
+	$(COMPILE.c) -o $@ $<
+
+$(OBJ)%.o:%.cc
+	$(COMPILE.cc) -o $@ $<
+
+$(OBJ)%.o:%.f
+	$(COMPILE.f) -o $@ $< 
+
+#OSF1
+#LDFC est f77
+#LDFCFLAGS est rien
+
+#parfois
+#LDFC est cc
+#LDFCFLAGS est -ltruc
+
+#------------------------------------------------- End of Makefile.h ------- 
+all : piapp piapp_nosh
+
+piapp : $(EXE)piapp $(SLB)piup.so 
+ 
+piapp_nosh : $(EXE)piapp_nosh
+ 
+
+$(EXE)piapp  : $(OBJ)pidemo.o $(SLB)libPI.so $(SLB)libOuIm.so \
+               $(SLB)liberosc.so $(SLB)libStarReco.so 
+	cc -call_shared -o $(EXE)piapp $(OBJ)pidemo.o \
+              -L$(SLB) -lPI -lOuIm -lerosc -lStarReco \
+              -lgcxx -lXm -lXt -lX11 -lm  
+
+$(EXE)piapp_nosh  : $(OBJ)pidemo_nosh.o $(LIB)libPI.a $(LIB)libStarReco.a  \
+               $(LIB)libOutils.a $(LIB)libImages.a $(LIB)libmath.a $(LIB)libdiv.a 
+	g++ -o $(EXE)piapp_nosh $(OBJ)pidemo_nosh.o \
+              -L$(LIB) -lPI -lStarReco -lImages -lOutils -lmath -ldiv \
+              -lXm -lXt -lX11 -lm 
+ 
+$(SLB)piup.so : $(OBJ)piup_def.o \
+                $(SLB)libOuIm.so $(SLB)liberosc.so 
+	ld -shared -o $(SLB)piup.so -all $(OBJ)piup_def.o \
+        -none -L$(SLB) -lOuIm -lerosc -lgcxx -lm -lc
+
+$(OBJ)pidemo_nosh.o: pidemo.cc pidemo.h
+	g++ -g -O -c -Wall -Wpointer-arith \
+            -Wmissing-prototypes -Wsynth -I$(INC) -I$(CXI) \
+            -D C_NO_SHLIBS -o $(OBJ)pidemo_nosh.o pidemo.cc
+
+$(OBJ)pidemo.o: ./pidemo.cc \
+ $(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 pidemo.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 \
+ $(INC)piup.h
+$(OBJ)piup_def.o: piup_def.cc  piup.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 
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pimenubargen.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pimenubargen.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pimenubargen.cc	(revision 464)
@@ -0,0 +1,54 @@
+// Module PI : Peida Interactive     PIMenubar
+// Barre de menu                        96-97
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "pimenubargen.h"
+
+#include PIAPP_H
+
+//++
+// Class	PIMenubar
+// Lib		PI
+// include	pimenubargen.h
+//
+//	Composant graphique de type Barre des menus . 
+//	"PIMenubarGen" définit l'interface (classe virtuelle pure). Les objets 
+//	instanciés doivent être de la classe "PIMenubar" déclarée dans le fichier
+//	entête "PIMENUBAR_H". 
+//--
+//++
+// Links	Parents
+// PIWdg
+//--
+//++
+// Links	Voir aussi
+// PIMenu
+//--
+
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+// PIMenubar(PIApplicationGen* par, const char* nom)
+//	Création d'un objet Menubar.
+// void  AppendMenu(PIMenu* pdm)
+//	Rajoute un menu à la barre de menu. Le menu sera affiché avec un titre identique à son nom.
+// void  RemoveMenu(PIMenu* pdm)
+//	Supprime le menu "pdm" de la barre de menu, sans le détruire (delete).
+// void  SetSensitivity(PIMenu* pdm, bool sens=true)
+//	Permet de rendre sensible ("sens=true") ou insensible un menu. Le titre d'un menu
+//	insensible est affiché, mais ne peut être séléctionné.
+// bool  IsSensitive(PIMenu* pdm)
+//	Indique si le menu "pdm" est sensible ou pas.
+//--
+
+PIMenubarGen::PIMenubarGen(PIApplicationGen* par, const char* nom)
+: PIWdg(NULL, nom)
+{
+SetMsgParent(par);
+}
+
+PIMenubarGen::~PIMenubarGen()
+{}
+
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pimenubargen.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pimenubargen.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pimenubargen.h	(revision 464)
@@ -0,0 +1,24 @@
+#ifndef PIMBARGEN_H_SEEN
+#define PIMBARGEN_H_SEEN
+
+#include "pisysdep.h"
+#include PIMENU_H
+
+class PIApplicationGen;
+
+class PIMenubarGen : public PIWdg {
+public:
+  enum {ClassId = 2600};
+
+	            PIMenubarGen(PIApplicationGen* par, const char* nom);
+	            ~PIMenubarGen();
+				   
+  virtual void      AppendMenu(PIMenu *pdm)=0;
+  virtual void      RemoveMenu(PIMenu *pdm)=0;
+  virtual void      SetSensitivity(PIMenu *pdm, bool sens=true)=0;
+  virtual bool      IsSensitive(PIMenu *pdm)=0;
+
+  virtual long      kind() {return ClassId; }
+};
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pimenubarmac.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pimenubarmac.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pimenubarmac.cc	(revision 464)
@@ -0,0 +1,36 @@
+#include "pimenubarmac.h"
+#include "pippmenubar.h"
+#include <LMenuBar.h>
+
+PIMenubarMac::PIMenubarMac(PIApplicationGen* par, char* nom)
+:PIMenubarGen(par, nom)
+{
+	new PIPPMenuBar();
+}
+
+PIMenubarMac::~PIMenubarMac()
+{}
+
+void
+PIMenubarMac::AppendMenu(PIMenu *pdm)
+{
+  LMenuBar::GetCurrentMenuBar()->InstallMenu(pdm->macMenu, InstallMenu_AtEnd);
+}
+
+void
+PIMenubarMac::RemoveMenu(PIMenu *pdm)
+{
+  LMenuBar::GetCurrentMenuBar()->RemoveMenu(pdm->macMenu);
+}
+
+void
+PIMenubarMac::SetSensitivity(PIMenu *pdm, bool sens)
+{
+
+}
+
+bool
+PIMenubarMac::IsSensitive(PIMenu *pdm)
+{
+  return true;
+}
Index: /tags/V_LaSilla191199/SophyaPI/PI/pimenubarmac.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pimenubarmac.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pimenubarmac.h	(revision 464)
@@ -0,0 +1,20 @@
+#ifndef PIMBARMAC_H_SEEN
+#define PIMBARMAC_H_SEEN
+
+#include "pimenubargen.h"
+
+class PIMenubarMac : public PIMenubarGen {
+ public:
+	            PIMenubarMac(PIApplicationGen* par, char* nom);
+	           ~PIMenubarMac();
+	           
+  virtual void      AppendMenu(PIMenu *pdm);
+  virtual void      RemoveMenu(PIMenu *pdm);
+  virtual void      SetSensitivity(PIMenu *pdm, bool sens=true);
+  virtual bool      IsSensitive(PIMenu *pdm);
+
+};
+
+typedef PIMenubarMac   PIMenubar;
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pimenubarx.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pimenubarx.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pimenubarx.cc	(revision 464)
@@ -0,0 +1,112 @@
+#include<stdio.h>
+
+#include "pimenubarx.h"
+#include PIAPP_H
+
+#include <Xm/Xm.h>
+#include <Xm/RowColumn.h>
+#include <Xm/PushB.h>
+#include <Xm/ToggleB.h>
+#include <Xm/CascadeB.h>
+
+/************* PIMenubarX ************/
+
+#define NBITEMB  10
+
+/* --Methode-- */
+PIMenubarX::PIMenubarX(PIApplicationGen* par, const char* nom)
+: PIMenubarGen(par, nom)
+{
+mNItem = 0;  mNItemMax = NBITEMB; 
+mMbb = new _pimbxit_[mNItemMax];
+
+Arg warg[3];
+int n = 0;
+
+XtSetArg(warg[n],XmNx,0);  n++;
+XtSetArg(warg[n],XmNy,0);  n++;
+
+XtWdg() = XmCreateMenuBar( ((PIApplicationX *)par)->MBCont()->XtWdg(), 
+                           (char *)nom, warg, n);   // const_cast
+
+wmis = k_wmi_normal ;
+stmng = 0;
+
+// SetPos(0,0);
+SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_free);
+((PIApplicationX *)par)->MBCont()->ChildAdd(this);
+
+Manage();
+}
+
+
+/* --Methode-- */
+PIMenubarX::~PIMenubarX()
+{
+for(int i=0; i<mNItem; i++)
+  XtDestroyWidget(mMbb[i].itb);
+delete[] mMbb ;
+}
+
+/* --Methode-- */
+void PIMenubarX::AppendMenu(PIMenu *pdm)
+{
+_pimbxit_ *buto;
+Arg  wargs[2];
+
+if (mNItem >= mNItemMax)
+  {
+  buto = mMbb;
+  mNItemMax += NBITEMB;
+  mMbb = new _pimbxit_[mNItemMax];
+  for(int i=0; i<mNItem; i++)   mMbb[i] = buto[i];
+  delete[] buto;
+  }
+XtSetArg(wargs[0], XmNsubMenuId, pdm->XtWdg());
+mMbb[mNItem].itb = XtCreateManagedWidget(pdm->Nom().c_str(), xmCascadeButtonWidgetClass, 
+                                         this->XtWdg(), wargs, 1) ;
+mMbb[mNItem].pdm = pdm;
+mNItem++;
+
+pdm->SetMsgParent(this);
+return;
+}
+
+/* --Methode-- */
+void PIMenubarX::RemoveMenu(PIMenu *pdm)
+{
+int i,j;
+for(i=0; i<mNItem; i++) 
+  if ( mMbb[i].pdm == pdm ) { 
+    XtDestroyWidget(mMbb[i].itb);
+    for(j=i; j<mNItem-1; j++) mMbb[j] = mMbb[j+1]; 
+    mNItem--;  break;  
+    }
+return;
+}
+
+/* --Methode-- */
+void PIMenubarX::SetSensitivity(PIMenu *pdm, bool sens)
+{
+int i;
+for(i=0; i<mNItem; i++) 
+  if ( mMbb[i].pdm == pdm ) { 
+    if (sens) XtSetSensitive(mMbb[i].itb, TRUE);
+    else XtSetSensitive(mMbb[i].itb, FALSE);
+    break;  
+    }
+return;
+}
+
+/* --Methode-- */
+bool PIMenubarX::IsSensitive(PIMenu *pdm)
+{
+int i;
+for(i=0; i<mNItem; i++) 
+  if ( mMbb[i].pdm == pdm ) { 
+    if (XtIsSensitive(mMbb[i].itb) == TRUE)  return(true);
+    else return(false);
+    break; 
+    }
+return(false);
+}
Index: /tags/V_LaSilla191199/SophyaPI/PI/pimenubarx.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pimenubarx.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pimenubarx.h	(revision 464)
@@ -0,0 +1,32 @@
+#ifndef PIMBARX_H_SEEN
+#define PIMBARX_H_SEEN
+
+#include "pimenubargen.h"
+
+struct _pimbxit_ 
+{
+SysDWdg itb;
+PIMenu *pdm;
+};
+
+class PIMenubarX : public PIMenubarGen {
+ public:
+	            PIMenubarX(PIApplicationGen* par, const char* nom);
+	            ~PIMenubarX();
+
+  virtual void	    AppendMenu(PIMenu *pdm);
+  virtual void      RemoveMenu(PIMenu *pdm);
+  virtual void      SetSensitivity(PIMenu *pdm, bool sens=true);
+  virtual bool      IsSensitive(PIMenu *pdm);
+
+ protected:
+
+int mNItem, mNItemMax;
+_pimbxit_ *mMbb;
+};
+
+
+typedef PIMenubarX     PIMenubar;
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pimenugen.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pimenugen.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pimenugen.cc	(revision 464)
@@ -0,0 +1,123 @@
+// Module PI : Peida Interactive     PIMenu
+// Menu                                     96-97
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "pimenugen.h"
+
+//++
+// Class	PIMenu
+// Lib		PI
+// include	pimenugen.h
+//
+//	Composant graphique de type menu. 
+//	"PIMenuGen" définit l'interface (classe virtuelle pure). Les objets 
+//	instanciés doivent être de la classe "PIMenu" déclarée dans le fichier
+//	entête "PIMENUBAR_H". Lors de la séléction d'une des options du menu
+//	Le message correspondant complété par "PIMsg_Click" est envoyé à l'objet
+//	par "SendSelf()".
+//--
+//++
+// Links	Parents
+// PIWdg
+//--
+//++
+// Links	Voir aussi
+// PIMenubar
+//--
+
+
+
+//++
+// Titre	Constructeur
+//--
+//++
+// PIMenu(PIWdg* par, const char* nom, PIMenuType pdpu=k_UTMenu)
+//	Création d'un objet Menubar. "pdpu" peut prendre les valeurs
+//	"k_UTMenu", "k_PopupMenu", "k_PulldownMenu". Un menu de type
+//	"PulldownMenu" est destiné à être accroché à un Menubar ou
+//	comme sous-menu d'un autre menu. Si l'objet parent est de type
+//	"PIMenu" ou "PIMenubar", un PulldownMenu est créé par défaut. Un 
+//	menu de type PopupMenu est créé dans les autres cas.
+// PIMenuType MType() 
+//	Renvoie le type du menu : "k_PopupMenu" ou  "k_PulldownMenu".
+//--
+
+//++
+// Titre	Ajout et suppression des options du menu
+//--
+//
+//++
+// void  AppendItem(const char* nom, PIMessage msg, char* sc=NULL)
+//	Permet d'ajouter une option au menu. Un raccourci clavier peut être spécifié
+//	par "sc".
+// void  AppendCheckItem(const char* nom, PIMessage msg, char* sc=NULL)
+//	Permet d'ajouter une option avec état ON/OFF au menu.
+// void	 AppendPDMenu(PIMenu* pdm, char* sc=NULL)
+//	Ajoute un menu déroulant comme sous-menu.
+// void  DeleteItem(const char* nom)
+//	Permet de supprimer une option du menu identifiée par le titre ("nom").
+//	Si le nom désigne un menu déroulant, celui-ci n'est pas détruit (par "delete").
+// void  DeleteItemMsg(PIMessage msg)
+//	Permet de supprimer une option du menu identifiée par le message ("msg").
+// void  DeleteItemNum(int n)
+//	Suppression de l'option numéro "n".
+//--
+//++
+// Titre	Gestion des options 
+//--
+//++
+// void  SetSensitivity(const char* nom, bool sens=true)
+//	Rend sensible ("sens=true") ou insensible l'option du menu identifiée par "nom".
+//	Une option insensible est affichée, mais ne peut être sélectionnée.
+// void  SetSensitivityMsg(PIMessage msg, bool sens=true)
+//	Rend sensible ("sens=true") ou insensible l'option du menu identifiée par le message "msg".
+// void  SetSensitivityNum(int n, bool sens=true)
+//	Rend sensible ("sens=true") ou insensible l'option numéro "n".
+// bool  IsSensitive(const char* nom)
+//	Indique si l'option "nom" est sensible ou pas.
+// bool  IsSensitiveMsg(PIMessage msg)
+//	Indique si l'option identifiée par le message "msg" est sensible ou pas.
+// bool  IsSensitiveNum(int n)
+//	Indique si l'option numéro "n" est sensible ou pas.
+//--
+//++
+// Titre	Options à état (CheckItem)
+//	Le champ "data" de "Send()/SendSelf()" contient un pointeur sur une variable
+//	de type bool, indiquant l'état (On/Off) de l'option, lors de la séléction des
+//	options à état ("CheckItem"). Les méthodes suivantes ne s'appliquent qu'aux 
+//	options de type CheckItem.
+//--
+//++
+// void  SetState(const char* nom, bool st=false)
+//	Change l'état de l'option "nom".
+// void  SetStateMsg(PIMessage msg, bool st=false)
+//	Change l'état de l'option identifiée par le message "msg".
+// void  SetStateNum(int n, bool st=false)
+//	Change l'état de l'option numéro "n".
+// bool GetState(const char* nom)
+//	Renvoie l'état de l'option "nom".
+// bool GetStateMsg(PIMessage msg)
+//	Renvoie l'état de l'option identifiée par le message "msg".
+// bool GetStateNum(int n)
+//	Renvoie l'état de l'option numéro "n".
+//--
+
+//++
+// Titre	Affichage des PopupMenu
+//--
+//++
+// void  Show()
+//	Affiche le menu (de type "k_PopupMenu" uniquement) à la position courante du pointeur.
+// void  Show(PIWdg* w, int px, int py)
+//	Affiche le menu (de type "k_PopupMenu" uniquement) à la position "px,py" de l'objet "w". 
+//--
+
+PIMenuGen::PIMenuGen(PIWdg* par, const char* nom, PIMenuType pdpu)
+: PIWdg(NULL, nom) , mMTyp(pdpu)
+{
+SetMsgParent(par);
+}
+
+PIMenuGen::~PIMenuGen()
+{}
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pimenugen.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pimenugen.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pimenugen.h	(revision 464)
@@ -0,0 +1,52 @@
+#ifndef PIMENUGEN_H_SEEN
+#define PIMENUGEN_H_SEEN
+
+#include "pisysdep.h"
+#include PIWDG_H
+
+enum PIMenuType { k_UTMenu = 0, k_PopupMenu = 1, k_PulldownMenu = 2 };
+
+
+class PIMenuGen : public PIWdg {
+public:
+  enum {ClassId = 2500};
+
+	          PIMenuGen(PIWdg* par, const char* nom, PIMenuType pdpu=k_UTMenu);
+	          ~PIMenuGen();
+				   
+  virtual void	  AppendItem(const char* nom, PIMessage msg, char* sc=NULL)=0;
+  virtual void	  AppendCheckItem(const char* nom, PIMessage msg, char* sc=NULL)=0;
+  virtual void	  AppendPDMenu(PIMenuGen *pdm, char* sc=NULL)=0;
+
+  virtual void    DeleteItem(const char *nom)=0;
+  virtual void    DeleteItemMsg(PIMessage msg)=0;
+  virtual void    DeleteItemNum(int n)=0;
+
+  virtual void    SetSensitivity(const char *nom, bool sens=true)=0; 
+  virtual void    SetSensitivityMsg(PIMessage msg, bool sens=true)=0; 
+  virtual void    SetSensitivityNum(int n, bool sens=true)=0;
+
+  virtual bool    IsSensitive(const char *nom)=0;
+  virtual bool    IsSensitiveMsg(PIMessage msg)=0;
+  virtual bool    IsSensitiveNum(int n)=0;
+
+  virtual void    SetState(const char *nom, bool st=false)=0; 
+  virtual void    SetStateMsg(PIMessage msg, bool st=false)=0; 
+  virtual void    SetStateNum(int n, bool st=false)=0;
+ 
+  virtual bool    GetState(const char *nom)=0; 
+  virtual bool    GetStateMsg(PIMessage msg)=0; 
+  virtual bool    GetStateNum(int n)=0; 
+
+  virtual void    Show()=0;
+  virtual void    Show(PIWdg *w, int px, int py)=0;
+
+  virtual long    kind() {return ClassId; }
+  virtual PIMenuType MType() { return  mMTyp; }
+
+protected:
+  PIMenuType mMTyp;
+}; 
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pimenumac.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pimenumac.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pimenumac.cc	(revision 464)
@@ -0,0 +1,215 @@
+#include <LString.h>
+#include "pimenumac.h"
+#include <algorithm>
+#include <iostream>
+
+int PIMenuMac::lastId = 1024;
+vector<PIMenuMac::menuInfo> mMenuInfos;
+
+/* --Methode-- */
+PIMenuMac::PIMenuMac(PIWdg* par, const char *nom, PIMenuType pdpu) 
+: PIMenuGen(par, nom, pdpu)
+{
+   macMenu = new LMenu(lastId, LStr255(nom));
+   menuInfo info;
+   info.mId = lastId;
+   info.pimenu = this;
+   mMenuInfos.push_back(info);
+   lastId++;
+}
+
+
+/* --Methode-- */
+PIMenuMac::~PIMenuMac()
+{
+  LMenuBar::GetCurrentMenuBar()->RemoveMenu(macMenu);
+  mMenuInfos.erase(mMenuInfos.begin() + GetMenuNum());
+  delete macMenu;
+}
+
+/* --Methode-- */
+void PIMenuMac::AppendItem(const char* nom, PIMessage msg, char* sc)
+{
+  AddItem(nom, msg, 0, sc, NULL);
+}
+
+/* --Methode-- */
+void PIMenuMac::AppendCheckItem(const char* nom, PIMessage msg, char* sc)
+{
+  AddItem(nom, msg, 1, sc, NULL);
+}
+
+/* --Methode-- */
+void PIMenuMac::AppendPDMenu(PIMenuGen *pdm, char* sc)
+{
+  if (pdm->MType() !=  k_PulldownMenu) {
+    cerr << "PIMenuX::AppendPDMenu()/Erreur: PullDownMenu seulement ... " << endl;
+    return;
+  }
+  AddItem(NULL, pdm->Msg(), 2, sc, (PIMenuMac*)pdm);
+}
+
+/* --Methode-- */
+void PIMenuMac::AddItem(const char* nom, PIMessage msg, int tog, char* sc, PIMenuMac *pdm)
+{
+  macMenu->InsertCommand("\ptemp", -2000, 1000);
+  MenuHandle mh = GetMacMenuHandle();
+  short i = ::CountMenuItems(mh);
+  LStr255 titre(nom);
+  ::SetMenuItemText(mh, i, titre);
+
+  // Gestion menus hiérarchiques
+  if (tog == 2 && pdm != NULL) {
+    ::SetItemCmd(mh, i, hMenuCmd);
+    ::SetItemMark(mh, i, pdm->GetMacMenuID());
+  }
+  // Le menu hierarchique sera "insere" au moment de l'insertion dans la
+  // menubar...
+  
+  itemInfo info;
+  info.pimsg  = msg;
+  info.name   = nom;
+  mItemInfos.push_back(info);
+}
+
+/* --Methode-- */
+int PIMenuMac::GetItemNum(const char *nom)
+{
+  int j=0;
+  for (vector<itemInfo>::iterator i = mItemInfos.begin(); i != mItemInfos.end(); i++,j++)
+    if ((*i).name == nom) return j;
+  return(-1);
+}
+
+/* --Methode-- */
+int PIMenuMac::GetItemNumMsg(PIMessage msg)
+{
+  int j=0;
+  for (vector<itemInfo>::iterator i = mItemInfos.begin(); i != mItemInfos.end(); i++,j++)
+    if ((*i).pimsg == msg) return j;
+  return(-1);
+}
+
+/* --Methode-- */
+int PIMenuMac::GetMenuNum()
+{
+  int j=0;
+  for (vector<menuInfo>::iterator i = mMenuInfos.begin(); i != mMenuInfos.end(); i++,j++)
+    if ((*i).pimenu == this) return j;
+  return(-1);
+}
+
+/* --Methode-- */
+int PIMenuMac::GetMenuNum(short menuId)
+{
+  int j=0;
+  for (vector<menuInfo>::iterator i = mMenuInfos.begin(); i != mMenuInfos.end(); i++,j++)
+    if ((*i).mId == menuId) return j;
+  return(-1);
+}
+
+/* --Methode-- */
+PIMenu* PIMenuMac::GetMenu(short menuId)
+{
+  int j=0;
+  for (vector<menuInfo>::iterator i = mMenuInfos.begin(); i != mMenuInfos.end(); i++,j++)
+    if ((*i).mId == menuId) return (*i).pimenu;
+  return(NULL);
+}
+
+
+/* --Methode-- */
+void
+PIMenuMac::SetStateNum(int n, bool st)
+{
+  if (n<0 || n >= mItemInfos.size()) return; // $CHECK$ exception ?
+  ::CheckItem(macMenu->GetMacMenuH(), n, st);
+}
+
+/* --Methode-- */
+void
+PIMenuMac::SetStateMsg(PIMessage msg, bool st)
+{
+  int i = GetItemNumMsg(msg);
+  if (i>=0)
+    SetStateNum(i, st);
+}
+
+/* --Methode-- */
+void
+PIMenuMac::SetState(const char* nom, bool st)
+{
+  int i = GetItemNum(nom);
+  if (i>=0)
+    SetStateNum(i, st);
+}
+
+void
+PIMenuMac::DeleteItemNum(int n)
+{
+  if (n<0 || n >= mItemInfos.size()) return; // $CHECK$ exception ?
+  macMenu->RemoveItem(n+1);
+  mItemInfos.erase(mItemInfos.begin()+n);
+}
+
+void
+PIMenuMac::DeleteItemMsg(PIMessage msg)
+{
+  int i = GetItemNumMsg(msg);
+  if (i>=0)
+    DeleteItemNum(i);
+}
+
+void
+PIMenuMac::DeleteItem(const char* nom)
+{
+  int i = GetItemNum(nom);
+  if (i>=0)
+    DeleteItemNum(i);
+}
+
+void
+PIMenuMac::ItemSelected(int item)
+{
+  if (item<0 || item >= mItemInfos.size()) return; // $CHECK$ exception ?
+  Send(mItemInfos[item].pimsg, PIMsg_Click, (void*) mItemInfos[item].name.c_str());
+}
+
+string
+PIMenuMac::GetMenuItemText(int item)
+{
+  if (item<0 || item >= mItemInfos.size()) return ""; // $CHECK$ exception ?
+  return mItemInfos[item].name;
+}
+
+PIMessage
+PIMenuMac::GetMenuItemMsg(int item)
+{
+  if (item<0 || item >= mItemInfos.size()) return -1; // $CHECK$ exception ?
+  return mItemInfos[item].pimsg;
+}
+
+
+
+void
+PIMenuMac::Show()
+{}
+
+void
+PIMenuMac::Show(PIWdg *w, int px, int py)
+{}
+
+
+MenuHandle
+PIMenuMac::GetMacMenuHandle()
+{
+  return macMenu->GetMacMenuH();
+}
+
+ResIDT
+PIMenuMac::GetMacMenuID()
+{
+  return macMenu->GetMenuID();
+}
+
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pimenumac.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pimenumac.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pimenumac.h	(revision 464)
@@ -0,0 +1,78 @@
+#ifndef PIMENUMAC_H_SEEN
+#define PIMENUMAC_H_SEEN
+
+#include "pimenugen.h"
+#include <LMenu.h>
+#include <vector>
+#include <list>
+
+// Menu general
+class PIMenuMac : public PIMenuGen {
+public:
+					PIMenuMac(PIWdg* par, const char* nom, PIMenuType pdpu=k_UTMenu);
+				   ~PIMenuMac();
+				   
+  virtual void	  AppendItem(const char* nom, PIMessage msg, char* sc=NULL);
+  virtual void	  AppendCheckItem(const char* nom, PIMessage msg, char* sc=NULL);
+  virtual void	  AppendPDMenu(PIMenuGen *pdm, char* sc=NULL);
+
+  virtual void    DeleteItem(const char *nom);
+  virtual void    DeleteItemMsg(PIMessage msg);
+  virtual void    DeleteItemNum(int n);
+
+  virtual void    SetSensitivity(const char *nom, bool sens=true); 
+  virtual void    SetSensitivityMsg(PIMessage msg, bool sens=true); 
+  virtual void    SetSensitivityNum(int n, bool sens=true);
+
+  virtual bool    IsSensitive(const char *nom);
+  virtual bool    IsSensitiveMsg(PIMessage msg);
+  virtual bool    IsSensitiveNum(int n);
+
+  virtual void    SetState(const char *nom, bool st=false); 
+  virtual void    SetStateMsg(PIMessage msg, bool st=false); 
+  virtual void    SetStateNum(int n, bool st=false);
+ 
+  virtual bool    GetState(const char *nom); 
+  virtual bool    GetStateMsg(PIMessage msg); 
+  virtual bool    GetStateNum(int n); 
+
+  virtual void    Show();
+  virtual void    Show(PIWdg *w, int px, int py);
+
+  LMenu*          GetPPMenu() {return macMenu;}
+  void            ItemSelected(int item);
+  string          GetMenuItemText(int item);
+  PIMessage       GetMenuItemMsg(int item);	
+protected:
+	LMenu*          macMenu;
+	struct menuInfo {
+	  short      mId;
+	  PIMenuMac* pimenu;
+	};
+	struct itemInfo {
+	  PIMessage  pimsg;
+	  string     name;
+	};
+	static vector<menuInfo> mMenuInfos;
+	vector<itemInfo> mItemInfos;
+	static int      lastId;
+	
+	friend class    PIMenubarMac;
+	friend class    PIOptMenuMac;
+	friend class    PIPPOptMenu;
+	friend class    PIPPMenuBar;
+	MenuHandle      GetMacMenuHandle();
+	ResIDT          GetMacMenuID();
+	
+    int             GetItemNum(const char* nom);
+	int             GetItemNumMsg(PIMessage msg);
+	int             GetMenuNum();
+	static int      GetMenuNum(short menuId);
+	static PIMenuMac*  GetMenu(short menuId);
+    void            AddItem(const char* nom, PIMessage msg, int tog, char* sc, PIMenuMac *pdm);
+};
+
+
+typedef PIMenuMac      PIMenu;
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pimenux.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pimenux.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pimenux.cc	(revision 464)
@@ -0,0 +1,477 @@
+#include<stdio.h>
+#include<iostream.h>
+
+#include "pisysdep.h"
+#include PIMENUBAR_H
+
+#include <Xm/Xm.h>
+#include <Xm/RowColumn.h>
+#include <Xm/PushB.h>
+#include <Xm/ToggleB.h>
+#include <Xm/CascadeB.h>
+
+/************* PIMenuX ************/
+
+// Quand on cree les menus comme fils du Top-Widget, ca rentre en 
+// conflit avec certaains Window-Manager ...
+// La fonction suivante permet de bypasser ce probleme- Le createur d'application
+// X doit donc appeler la fonction ci-dessous pour initialiser menuXTopWdg
+//                                               Reza 4/11/97
+static SysDWdg menuXTopWdg = NULL;
+void SetTopWdgForMenuX(SysDWdg mtw) {
+  menuXTopWdg = mtw;
+}
+
+// Pour ces sal... de XmString  (ds piwdgx.cc)
+int CStrFrXmStr(XmString xms, char* buff, int nmx);
+
+
+// Fonction prive (CallBack)
+static void menu_action(Widget w, XtPointer usd, XtPointer calld);
+static void menu_toggle_action(Widget w, XtPointer usd, XmToggleButtonCallbackStruct* calld);
+
+/* Nouvelle-Fonction */
+void  menu_action(Widget /*w*/, XtPointer usd, XtPointer /*calld*/)
+{
+PIMenuX *pim;
+_pimxit_ *cusd;
+
+cusd = ( _pimxit_ *)usd ;
+pim = (PIMenuX *) (cusd->pmen);
+// pim->Hide();
+pim->SendSelf(cusd->msg, PIMsg_Click );
+#ifdef DEBUG_PIMenuX
+printf("%%%Debug_menu_action: Msg= %d  %lx\n", (int)cusd->msg, (long)pim);
+#endif
+return;
+}
+
+// Variable globale pour Toggle Item's  Send(..., ..., data); 
+static bool toggmenbut = false;
+
+/* Nouvelle-Fonction */
+void  menu_toggle_action(Widget /*w*/, XtPointer usd, XmToggleButtonCallbackStruct* calld)
+{
+PIMenuX *pim;
+_pimxit_ *cusd;
+
+cusd = ( _pimxit_ *)usd ;
+pim = (PIMenuX *) (cusd->pmen);
+if (calld->set == True)  cusd->togstate = toggmenbut = true;
+else  cusd->togstate = toggmenbut = false;
+pim->SendSelf(cusd->msg, PIMsg_DataChanged, (void *)(&toggmenbut));
+return;
+}
+
+
+
+#define NBITEMB  10
+
+/* --Methode-- */
+PIMenuX::PIMenuX(PIWdg* par, const char *nom, PIMenuType pdpu) 
+: PIMenuGen(par, nom, pdpu)
+{
+mNItem = 0;  mNItemMax = NBITEMB; 
+mBut = new _pimxit_[mNItemMax];
+
+SysDWdg tw;
+if (par == NULL) { 
+  tw = menuXTopWdg;
+  if (tw == NULL) tw = PIXtTopWdg(); 
+}
+else  tw = par->XtWdg();
+// Si le type de menu pdpu n'est pas specifie, on le decide 
+// en fonction du type de l'objet parent 
+if (pdpu == k_UTMenu) {
+  if  ( (par->kind() == PIMenu::ClassId) || (par->kind() == PIMenubar::ClassId) )  pdpu = k_PulldownMenu ;
+  else pdpu = k_PopupMenu ;
+}
+if (pdpu == k_PopupMenu)
+  XtWdg() = XmCreatePopupMenu( tw, (char *)nom, NULL, 0);   // const_cast
+else 
+  XtWdg() = XmCreatePulldownMenu( tw, (char *)nom, NULL, 0); // const_cast
+
+mMTyp = pdpu;
+wmis = k_wmi_normal ;
+stmng = 0;
+}
+
+/* --Methode-- */
+PIMenuX::~PIMenuX()
+{
+// for(int i=0; i<mNItem; i++)
+//  XtDestroyWidget(mBut[i].itb); Le destroy est fait par le widget menu lui-meme
+delete[] mBut ;
+}
+
+
+/* --Methode-- */
+void PIMenuX::AppendItem(const char* nom, PIMessage msg, char* sc)
+{
+AddItem(nom, msg, 0, sc, NULL);
+}
+
+/* --Methode-- */
+void PIMenuX::AppendCheckItem(const char* nom, PIMessage msg, char* sc)
+{
+AddItem(nom, msg, 1, sc, NULL);
+}
+
+/* --Methode-- */
+void PIMenuX::AppendPDMenu(PIMenuGen *pdm, char* sc)
+{
+if (pdm->MType() !=  k_PulldownMenu) {
+  cerr << "PIMenuX::AppendPDMenu()/Erreur: PullDownMenu seulement ... " << endl;
+  return;
+  }
+AddItem(NULL, pdm->Msg(), 2, sc, (PIMenuX*)pdm);
+}
+
+/* --Methode-- */
+void PIMenuX::DeleteItem(const char *nom)
+{
+DeleteItemNum(GetNumItem(nom));
+}
+
+/* --Methode-- */
+void PIMenuX::DeleteItemMsg(PIMessage msg)
+{
+DeleteItemNum(GetNumItemMsg(msg));
+}
+
+/* --Methode-- */
+void PIMenuX::SetSensitivity(const char *nom, bool sens)
+{
+SetSensitivityNum(GetNumItem(nom), sens);
+}
+
+/* --Methode-- */
+void PIMenuX::SetSensitivityMsg(PIMessage msg, bool sens)
+{
+SetSensitivityNum(GetNumItemMsg(msg), sens);
+}
+
+/* --Methode-- */
+bool PIMenuX::IsSensitive(const char *nom)
+{
+return(IsSensitiveNum(GetNumItem(nom)) );
+}
+
+/* --Methode-- */
+bool PIMenuX::IsSensitiveMsg(PIMessage msg)
+{
+return(IsSensitiveNum(GetNumItemMsg(msg)) ); 
+}
+
+/* --Methode-- */
+bool PIMenuX::IsSensitiveNum(int n)
+{
+if ((n < 0) || (n >= mNItem))  return(false);
+if (XtIsSensitive(mBut[n].itb) == TRUE)  return(true);
+else return(false);
+}
+
+/* --Methode-- */
+void PIMenuX::SetSensitivityNum(int n, bool sens)
+{
+if ((n < 0) || (n >= mNItem))  return;
+if (sens) XtSetSensitive(mBut[n].itb, TRUE);
+else XtSetSensitive(mBut[n].itb, FALSE);
+}
+
+/* --Methode-- */
+void PIMenuX::DeleteItemNum(int n)
+{
+if ((n < 0) || (n >= mNItem))  return;
+XtDestroyWidget(mBut[n].itb);
+for(int i=n; i<mNItem-1; i++)
+  {
+  String cbckn;
+  XtCallbackProc cbproc;
+  if (mBut[i+1].toggpdm < 2) {
+    if (mBut[i+1].toggpdm == 1)    // ToggleItem 
+      { cbckn = XmNvalueChangedCallback;  cbproc = (XtCallbackProc)menu_toggle_action; }
+    else { cbckn = XmNactivateCallback;  cbproc = menu_action; }
+
+    XtRemoveCallback(mBut[i+1].itb, cbckn, cbproc, (XtPointer)(mBut+i+1));
+    mBut[i] = mBut[i+1];
+    XtAddCallback(mBut[i].itb, cbckn, cbproc, (XtPointer)(mBut+i));
+    }
+  else mBut[i] = mBut[i+1]; 
+  }
+mNItem--;
+}
+
+
+/* --Methode-- */
+void PIMenuX::SetState(const char *nom, bool st)
+{
+SetStateNum(GetNumItem(nom), st);
+}
+
+/* --Methode-- */
+void PIMenuX::SetStateMsg(PIMessage msg, bool st)
+{
+SetStateNum(GetNumItemMsg(msg), st);
+}
+
+/* --Methode-- */
+void PIMenuX::SetStateNum(int n, bool st)
+{
+if ((n < 0) || (n >= mNItem))  return;
+if (mBut[n].toggpdm != 1 ) return;  // Pas un toggle-item
+Arg warg[2];
+if (st) XtSetArg(warg[0],XmNset, True);
+else XtSetArg(warg[0],XmNset, False);
+XtSetValues(mBut[n].itb, warg, 1);
+mBut[n].togstate = st;
+return;
+}
+
+/* --Methode-- */
+bool PIMenuX::GetState(const char *nom)
+{
+return( GetStateNum(GetNumItem(nom)) );
+}
+
+/* --Methode-- */
+bool PIMenuX::GetStateMsg(PIMessage msg)
+{
+return( GetStateNum(GetNumItemMsg(msg)) );
+}
+
+/* --Methode-- */
+bool PIMenuX::GetStateNum(int n) 
+{
+if ((n < 0) || (n >= mNItem))  return(false);
+if (mBut[n].toggpdm != 1 ) return(false); 
+return(mBut[n].togstate); 
+}
+
+
+
+
+/* --Methode-- */
+char* PIMenuX::ItemName(int n)
+{
+if ( (n < 0) || (n >= mNItem))  { mSItem[0] = '\0'; return(mSItem); }
+else return (ItemNameWdg(mBut[n].itb));
+}
+
+
+/* --Methode-- */
+char* PIMenuX::ItemNameWdg(SysDWdg itw)
+{
+XmString xmstr;
+Arg warg[2];
+
+XtSetArg(warg[0], XmNlabelString, &xmstr);
+XtGetValues(itw, warg, 1);
+if (xmstr)
+  {
+  CStrFrXmStr(xmstr, mSItem, 96);
+  XmStringFree(xmstr);
+  }
+else mSItem[0] = '\0';
+
+return(mSItem);
+}
+
+
+/* --Methode-- */
+PIMessage PIMenuX::ItemMsg(int n)
+{
+if ( (n < 0) || (n >= mNItem))  return(0);
+else return(mBut[n].msg);
+}
+
+
+
+/* --Methode-- */
+int PIMenuX::GetNumItem(const char *nom)
+{
+
+for(int i=0; i<mNItem; i++)
+  if (strcmp(ItemName(i),nom) == 0)  return(i);
+return(-1);
+}
+
+/* --Methode-- */
+int PIMenuX::GetNumItemMsg(PIMessage msg)
+{
+for(int i=0; i<mNItem; i++)
+  if (mBut[i].msg == msg)   return(i);  
+return(-1);
+}
+
+/* --Methode-- */
+SysDWdg PIMenuX::GetItemWdg(int n)
+{
+if ((n<0) || (n>=mNItem))  return(NULL);
+else return(mBut[n].itb);
+}
+
+
+/* --Methode-- */
+void PIMenuX::AddItem(const char* nom, PIMessage msg, int tog, char* sc, PIMenuX *pdm)
+{
+_pimxit_ *buto;
+SysDWdgClass wdgcl;
+String cbckn;
+XtCallbackProc cbproc;
+Arg  warg[2];
+int n=0;
+
+
+if (mNItem >= mNItemMax)  {
+  buto = mBut;
+  mNItemMax += NBITEMB;
+  mBut = new _pimxit_[mNItemMax];
+  for(int i=0; i<mNItem; i++)    {
+    if (buto[i].toggpdm < 2) {  // Pas de Cascade Menu
+      if (buto[i].toggpdm == 1)  // ToggleItem
+        { cbckn = XmNvalueChangedCallback;  cbproc = (XtCallbackProc)menu_toggle_action; }
+      else { cbckn = XmNactivateCallback;  cbproc = menu_action; }
+      XtRemoveCallback(buto[i].itb, cbckn, cbproc, (XtPointer)(buto+i));
+      mBut[i] = buto[i];
+      XtAddCallback(mBut[i].itb, cbckn, cbproc, (XtPointer)(mBut+i));
+      }
+    else mBut[i] = buto[i]; 
+    }
+  delete[] buto;
+  }
+
+if (tog < 2) {  // Pas de Cascade Menu
+  if (tog == 1) {   // Toggle-Item 
+    cbckn = XmNvalueChangedCallback;  cbproc = (XtCallbackProc)menu_toggle_action;
+    wdgcl = xmToggleButtonWidgetClass;  
+    XtSetArg(warg[0],XmNset, False); n = 1; }
+  else {
+    cbckn = XmNactivateCallback;  cbproc = menu_action;
+    wdgcl = xmPushButtonWidgetClass;  n = 0; }
+
+  mBut[mNItem].itb = XtCreateManagedWidget(nom, wdgcl, this->XtWdg(), warg, n) ; 
+  XtAddCallback(mBut[mNItem].itb, cbckn, cbproc, (XtPointer)(mBut+mNItem));
+  }
+else {    // Creation Cascade-Menu
+  XtSetArg(warg[0], XmNsubMenuId, pdm->XtWdg());
+  mBut[mNItem].itb = XtCreateManagedWidget(pdm->Nom().c_str(), xmCascadeButtonWidgetClass, 
+                                           XtWdg(), warg, 1) ;
+  pdm->SetMsgParent(this);
+  }
+
+if (sc)  // Raccourci clavier 
+  {
+  char acc[16];
+  XmString xmstr;
+  n=0;
+  sprintf(acc,"Ctrl/%c", sc[0]);
+  xmstr = XmStringLtoRCreate(acc, XmSTRING_DEFAULT_CHARSET);
+  XtSetArg(warg[n], XmNacceleratorText, xmstr); n++;
+  sprintf(acc,"Ctrl<Key>%c", sc[0]);
+  XtSetArg(warg[n], XmNaccelerator, acc); n++;
+  XtSetValues(mBut[mNItem].itb, warg, n);  
+  XmStringFree(xmstr);
+  }
+
+#ifdef DEBUG_PIMenuX
+printf("DBG>> %d (%d) %lx \n", mNItem, mNItemMax, (long)(mBut+mNItem));
+#endif
+mBut[mNItem].pmen = this;
+mBut[mNItem].msg = msg;
+mBut[mNItem].toggpdm = tog;
+mBut[mNItem].togstate = false;
+mNItem++;
+return;
+}
+
+
+
+/* --Methode-- 
+void PIMenuX::Check()
+{
+printf("#Debug_CHECK: %d %d %d %d \n",XSize(), YSize(), XPos(), YPos() );  
+for(int i=0; i<mNItem; i++)
+  printf("##Debug_CHECK: %d %d %ld %lx %lx %lx \n", i, (int)mBut[i].toggpdm, 
+         (long) mBut[i].msg, (long) mBut[i].itb, 
+         (long) mBut[i].pmen, long (mBut+i));
+return;
+}
+*/
+
+
+
+
+void PIMenuX::Show()
+{
+if (MType() !=  k_PopupMenu) {
+  cerr << "PIMenuX::Show()/Erreur: PopupMenu seulement ... " << endl;
+  return;
+  }
+
+// XEvent  mevt;
+XButtonEvent evt;
+
+// XPeekEvent(PIXDisplay(), &mevt);
+// evt = mevt.xbutton; 
+evt.type = ButtonPress;
+evt.display = PIXDisplay();
+evt.window = XtWindow(PIXtTopWdg());
+evt.root = DefaultRootWindow(evt.display);
+evt.serial = PIXGetLastEventSerial(); 
+evt.time = PIXGetLastEventTime();
+evt.send_event = False;
+evt.same_screen = XQueryPointer(evt.display, evt.window, &(evt.root), 
+                    &(evt.subwindow), &(evt.x_root), &(evt.y_root), 
+                    &(evt.x), &(evt.y), &(evt.state));
+ 
+#ifdef DEBUG_PIMenuX
+printf("XXDbg_Show : %d %d %d - %d %d \n", (int)evt.same_screen, 
+       (int)evt.x_root, (int)evt.y_root, (int)evt.x, (int)evt.y);
+#endif
+
+if (evt.same_screen) XmMenuPosition(XtWdg(), &evt);
+Manage();     
+}
+
+/* --Methode-- */
+void PIMenuX::Show(PIWdg *w, int px, int py)
+{
+if (MType() !=  k_PopupMenu) {
+  cerr << "PIMenuX::Show(w, px, py)/Erreur: PopupMenu seulement ... " << endl;
+  return;
+  }
+// 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 = PIXGetLastEventSerial(); 
+evt.time = PIXGetLastEventTime();
+evt.send_event = False;
+evt.same_screen = True;
+XmMenuPosition(XtWdg(), &evt);
+// SetPos(xr, yr);
+Manage();
+return;    
+}
+
+
+
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pimenux.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pimenux.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pimenux.h	(revision 464)
@@ -0,0 +1,73 @@
+#ifndef PIMENUX_H_SEEN
+#define PIMENUX_H_SEEN
+
+#include "pimenugen.h"
+
+
+class PIMenuX ;
+
+struct _pimxit_ 
+{
+SysDWdg itb;
+PIMenuX *pmen;
+PIMessage msg;
+int toggpdm;      // 0= Normal Item, 1, Toggle Item,  2= PDMenu
+bool togstate;    // true , false pour toggle items  
+};
+
+
+
+class PIMenuX : public PIMenuGen {
+public:
+	          PIMenuX(PIWdg* par, const char* nom, PIMenuType pdpu=k_UTMenu);
+	          ~PIMenuX();
+				   
+  virtual void	  AppendItem(const char* nom, PIMessage msg, char* sc=NULL);
+  virtual void	  AppendCheckItem(const char* nom, PIMessage msg, char* sc=NULL);
+  virtual void	  AppendPDMenu(PIMenuGen *pdm, char* sc=NULL);
+
+  virtual void    DeleteItem(const char *nom);
+  virtual void    DeleteItemMsg(PIMessage msg);
+  virtual void    DeleteItemNum(int n);
+
+  virtual void    SetSensitivity(const char *nom, bool sens=true); 
+  virtual void    SetSensitivityMsg(PIMessage msg, bool sens=true); 
+  virtual void    SetSensitivityNum(int n, bool sens=true);
+
+  virtual bool    IsSensitive(const char *nom);
+  virtual bool    IsSensitiveMsg(PIMessage msg);
+  virtual bool    IsSensitiveNum(int n);
+
+  virtual void    SetState(const char *nom, bool st=false); 
+  virtual void    SetStateMsg(PIMessage msg, bool st=false); 
+  virtual void    SetStateNum(int n, bool st=false);
+ 
+  virtual bool    GetState(const char *nom); 
+  virtual bool    GetStateMsg(PIMessage msg); 
+  virtual bool    GetStateNum(int n); 
+
+  virtual void    Show();
+  virtual void    Show(PIWdg *w, int px, int py);
+
+
+// Pour usage prive et par OptionMenu, ...
+  PIMessage       ItemMsg(int n);
+  int             GetNumItem(const char *nom);
+  int             GetNumItemMsg(PIMessage msg);
+  SysDWdg         GetItemWdg(int n);
+  char*           ItemName(int n);
+  char*           ItemNameWdg(SysDWdg itw);
+
+protected:
+        void      AddItem(const char* nom, PIMessage msg, int tog, char* sc, PIMenuX *pdm);
+
+int mNItem, mNItemMax;
+_pimxit_  * mBut;
+char mSItem[96];
+};
+
+
+typedef PIMenuX        PIMenu;
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pimsghandler.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pimsghandler.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pimsghandler.cc	(revision 464)
@@ -0,0 +1,101 @@
+//  Classe de gestionnaire de message pour programme graphique interactive
+//
+//                  E.Aubourg , R. Ansari  01-06/96
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "pimsghandler.h"
+
+//++
+// Class	PIMsgHandler
+// Lib		PI
+// include	pimsghandler.h
+//
+//   	Classe de gestionnaire de message de Peida Interactive (PI)
+//	Les message ("PIMessage") sont des entiers non signés
+//	("unsigned long"). 
+//	Chaque PIMsgHandler se trouve dans une organisation 
+//	hiérarchique où il dépend d'un
+//	PIMsgHandler père à qui il reporte les messages, et peut
+//	avoir lui-même un ou plusieurs PIMsgHandler qui sont sous sa 
+//	dépendance. Un message ("PIMessage") est constitué de deux 
+//	parties, une partie à la disposition de l'utilisateur ("UserMsg()")
+//	et une partie sous contrôle du code PI ("ModMsg()"), 
+//	qui peut spécifie si nécéssaire la raison de déclenchement 
+//	d'envoi du message. 
+//--
+
+//++
+// Titre	Constructeur
+//--
+//++
+// PIMsgHandler(PIMsgHandler* par=NULL)
+//	Création d'un PIMsgHandler dépendant hiérarchiquement du parent "par"
+//--
+
+PIMsgHandler::PIMsgHandler(PIMsgHandler* par)
+: msgParent(par)
+{}
+
+PIMsgHandler::~PIMsgHandler()
+{}
+
+
+//++
+// Titre	Traitement des messages
+//--
+
+//++
+// PIMessage  UserMsg(PIMessage msg)
+//	Décode et renvoie la partie utilisateur d'un PIMessage
+// PIMessage  ModMsg(PIMessage msg)
+//	Décode et renvoie la partie *modifier* d'un PIMessage
+// PIMessage  BuildMsg(PIMessage um, PIMsgMod mm) 
+//	Code les deux parties (user "um", modifier "mm") d'un message
+//	dans un PIMessage.
+// void  SetMsgParent(PIMsgHandler* par)
+//	Modifie l'organisation hiérarchique, en assignant un nouveau père.
+// void	 Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL)
+//	Cette méthode virtuelle est appelée quand un message "msg"
+//	est reçue par l'objet gestionnaire. "sender" est l'expéditeur
+//	du message, et "data" est un argument optionnel supplémentaire.
+//	La signification et contenu de "data" dépend de l'expéditeur
+//	et du contexte. Par défaut, la méthode "Process(...)" renvoie
+//	le message au PIMsgHandler père, sans altérer l'identité
+//	de l'expéditeur. (méthode "ReSend(...)"). C'est une méthode 
+//	non public (protected) destinée être redéfinie par les classes
+//	héritières.
+// void  Send(PIMessage msg, PIMsgMod mm=0, void* data=NULL)
+//	Envoie le message "msg" avec le modifier "mm", et l'argument 
+//	optionnel "data" au parent, déclenchant ainsi l'execution
+//	de la méthode "Process(...)" du père.
+// void  SendSelf(PIMessage msg, PIMsgMod mm=0, void* data=NULL)
+//	Envoie le message "msg" avec le modifier "mm", et l'argument 
+//	optionnel "data" à l'objet lui-même, déclenchant ainsi l'execution
+//	de la méthode "Process(...)" de l'objet.
+//--
+
+void
+PIMsgHandler::Process(PIMessage msg, PIMsgHandler* sender, void* data)
+{
+	ReSend(msg, sender, data);
+}
+
+void
+PIMsgHandler::Send(PIMessage msg, PIMsgMod mm,  void* data)
+{
+//	Process(msg, this, data);  $CHECK$  Reza 12/06/96
+// Send par defaut appelle le process du parent $CHECK$
+if (msgParent)
+  msgParent->Process(BuildMsg(msg, mm), this, data);
+
+}
+
+void
+PIMsgHandler::ReSend(PIMessage msg, PIMsgHandler* sender, void* data)
+{
+  if (msgParent)
+    msgParent->Process(msg, sender, data);
+}
+
+
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pimsghandler.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pimsghandler.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pimsghandler.h	(revision 464)
@@ -0,0 +1,67 @@
+#ifndef PIMSGHANDLER_H_SEEN
+#define PIMSGHANDLER_H_SEEN
+
+/* Classe de gestion de messages */
+
+#include "machdefs.h"
+#include <stdlib.h>
+
+
+enum {
+ // Les messages reserves systeme (PI)   les 8 premiers bits
+ // Messages user, les bits restants
+	PIMsg_Active        = 1,
+        PIMsg_Close         = 2,
+        PIMsg_Resize        = 3,
+        PIMsg_ResizeRequest = 4,
+
+	PIMsg_Click         = 21,
+        PIMsg_Press         = 22,
+        PIMsg_Release       = 23,
+        PIMsg_Drag          = 24,
+        PIMsg_Drop          = 25,
+        PIMsg_Copy          = 26,
+        PIMsg_Paste         = 27,
+        PIMsg_Cut           = 28,
+
+	PIMsg_OK            = 21,
+	PIMsg_Cancel        = 22,
+	PIMsg_Help          = 23,
+
+	PIMsg_DataChanged   = 31,
+        PIMsg_Select        = 32,
+        PIMsg_ClearSel      = 33
+
+};
+
+
+// Definition de type pour les messages - Il est peu probable que le typedef change ...
+//                                      Reza 17/10/96
+typedef unsigned long PIMessage;
+typedef unsigned char PIMsgMod;
+
+class PIMsgHandler {
+public:
+			     PIMsgHandler(PIMsgHandler* par=NULL);
+	virtual 	     ~PIMsgHandler();
+	
+	virtual void	     SetMsgParent(PIMsgHandler* par) {msgParent = par;}
+
+	virtual void         Send(PIMessage msg, PIMsgMod mm=0, void* data=NULL);
+	inline  void         SendSelf(PIMessage msg, PIMsgMod mm=0, void* data=NULL)
+                                  { Process(BuildMsg(msg, mm), this, data); }
+
+        inline  PIMessage    UserMsg(PIMessage msg) { return (msg >> 8); }
+        inline  PIMessage    ModMsg(PIMessage msg) { return (msg & 0xFF); }
+	inline  PIMessage    BuildMsg(PIMessage um, PIMsgMod mm) 
+                        	  { return ((um << 8) | mm); }
+
+protected:
+	virtual void	ReSend(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+	virtual void	Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+
+private:
+	PIMsgHandler*     msgParent;
+};
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pimsgmac.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pimsgmac.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pimsgmac.h	(revision 464)
@@ -0,0 +1,8 @@
+#include <PP_Types.h>
+
+const MessageT msg_Btn1    msg_Click;
+const MessageT msg_Btn2    10001;
+const MessageT msg_Btn3    10002;
+const MessageT msg_Move1   10003;
+const MessageT msg_Move2   10004;
+const MessageT msg_Move3   10005;
Index: /tags/V_LaSilla191199/SophyaPI/PI/pioptmenugen.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pioptmenugen.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pioptmenugen.cc	(revision 464)
@@ -0,0 +1,12 @@
+#include "pioptmenugen.h"
+
+
+PIOptMenuGen::PIOptMenuGen(PIContainerGen* par, const char* nom, int sx, int sy, int px, int py)
+: PIWdg(par, nom, sx, sy, px, py) // Attention au const !
+{
+}
+
+PIOptMenuGen::~PIOptMenuGen()
+{}
+
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pioptmenugen.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pioptmenugen.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pioptmenugen.h	(revision 464)
@@ -0,0 +1,30 @@
+#ifndef PIOPTMENGEN_H_SEEN
+#define PIOPTMENGEN_H_SEEN
+
+#include "pisysdep.h"
+#include PIMENU_H
+
+class PIOptMenuGen : public PIWdg {
+public:
+  enum {ClassId = 1100};
+
+	             PIOptMenuGen(PIContainerGen* par, const char* nom, int sx=50, int sy=15, int px=0, int py=0);
+	             ~PIOptMenuGen();
+				   
+  virtual long       kind() {return ClassId; }
+
+  inline  PIMenu*    Menu() {return mMen; }     // Renvoie un pointeur sur le menu associe 
+  inline  void       AppendItem(const char* nom, PIMessage msg) 
+                                   { mMen->AppendItem(nom, msg); }
+
+  virtual string     GetValueStr() = 0;         // Option choisie
+  virtual PIMessage  GetValue() = 0;            // Message correspondant a l option choisie
+  virtual void       SetValueStr(string & s) = 0;
+  virtual void       SetValue(PIMessage msg) = 0;
+
+protected:
+  PIMenu* mMen;
+
+};
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pioptmenumac.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pioptmenumac.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pioptmenumac.cc	(revision 464)
@@ -0,0 +1,85 @@
+#include "pioptmenumac.h"
+#include "pippoptmenu.h"
+
+/* --Methode-- */
+PIOptMenuMac::PIOptMenuMac(PIContainerGen* par, char const* nom,
+                     int sx, int sy, int px, int py)
+: PIOptMenuGen(par, nom, sx, sy, px, py)
+{
+  delete mPane;
+  
+  char buff[128];
+  strncpy(buff, nom, 64);
+  strcat(buff,"_Menu");
+  mMen = new PIMenu((PIWdg*)par, buff, k_PopupMenu);
+  mMen->SetMsgParent(this);
+  LStr255 titre("");
+  
+  StTextState textState;
+  ::TextFont(systemFont);
+  ::TextSize(12);
+  ::TextFace(0);
+  int titleWidth = ::StringWidth(titre);
+  
+  mPane = new PIPPOptMenu(mPaneInfo, msg_Click, 0, 200, titleWidth+5, popupMenuProc/*+popupVariableWidth*/, 130, titre, 0, 1);
+  
+  ((PIPPOptMenu*)mPane)->SetMenu(mMen);
+  ((LStdPopupMenu*)mPane)->AddListener(this);
+  
+  Manage();
+}
+
+/* --Methode-- */
+PIOptMenuMac::~PIOptMenuMac()
+{
+  delete mMen;
+}
+
+/* --Methode-- */
+void PIOptMenuMac::Process(PIMessage msg, PIMsgHandler* sender, void* data)
+{
+if (sender == mMen)   {
+  SetValue(UserMsg(msg));
+  ReSend(msg, this, NULL);
+}
+return;
+}
+
+void
+PIOptMenuMac::ListenToMessage(MessageT /*inMessage*/, void *)
+{
+//  if (inMessage == msg_Click)
+  int n = ((LStdPopupMenu*)mPane)->GetValue()-1;
+  mMen->ItemSelected(n);
+  mStext = mMen->GetMenuItemText(n);
+  mSmsg  = mMen->GetMenuItemMsg(n);
+}
+
+/* --Methode-- */
+void PIOptMenuMac::SetValueStr(string & s)
+{
+  int n;
+  n=mMen->GetItemNum((char *)s.c_str());
+  if (n < 0)  return;  
+
+  StopListening();
+  ((LStdPopupMenu*)mPane)->SetValue(n+1);
+  StartListening();
+  mStext = s;
+  mSmsg  = mMen->GetMenuItemMsg(n);
+}
+
+/* --Methode-- */
+void PIOptMenuMac::SetValue(PIMessage msg)
+{
+  int n;
+  n=mMen->GetItemNumMsg(msg);
+  if (n < 0)  return;
+  
+  StopListening();
+  ((LStdPopupMenu*)mPane)->SetValue(n+1);
+  StartListening();
+  mStext = mMen->GetMenuItemText(n);
+  mSmsg  = msg;
+}
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pioptmenumac.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pioptmenumac.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pioptmenumac.h	(revision 464)
@@ -0,0 +1,29 @@
+#ifndef PIOPTMENMAC_H_SEEN
+#define PIOPTMENMAC_H_SEEN
+
+#include "pioptmenugen.h"
+
+class PIOptMenuMac : public PIOptMenuGen {
+public:
+	                PIOptMenuMac(PIContainerGen* par, const char* nom,  
+                               int sx=10, int sy=10, int px=0, int py=0);
+	               ~PIOptMenuMac();
+
+  virtual void      Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+				   
+  virtual void	    ListenToMessage(MessageT inMessage, void *ioParam);
+  virtual string    GetValueStr() { return(mStext); }
+  virtual PIMessage GetValue()    { return(mSmsg); } 
+  virtual void      SetValueStr(string & s);
+  virtual void      SetValue(PIMessage msg);
+  
+
+protected:
+  string    mStext;
+  PIMessage mSmsg;
+};
+
+
+typedef PIOptMenuMac  PIOptMenu ;
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pioptmenux.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pioptmenux.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pioptmenux.cc	(revision 464)
@@ -0,0 +1,150 @@
+#include<stdio.h>
+
+#include <Xm/Xm.h>
+#include <Xm/PushB.h>
+
+#include "pisysdep.h"
+#include "pioptmenux.h"
+#include "piapplx.h"
+
+
+/************* PIOptionMenuX ************/
+static int rsx=0, rsy=0;
+
+/* Nouvelle-Fonction */
+static void mouse_handler_optmenux (Widget wdgp, XtPointer ud, 
+                                    XEvent* evt, Boolean* cont){
+*cont = FALSE ; 
+// printf("---  mouse_handler_optmenux ud = %lx ----- EvtType=%d (%d) \n", (long)ud, evt->type, Expose );
+if ( evt->type == Expose ) {
+  PIOptMenuX* opm = (PIOptMenuX*) ud;
+  Display* dis = PIXDisplay();
+  Window w = XtWindow(opm->XtWdg()) ;
+  XFillRectangle(dis, w, opm->myGC(), rsy, (opm->YSize()-rsy)/2, rsy, rsy); 
+  }
+else if ( (evt->type == ButtonPress) && (evt->xbutton.button == 1))  { 
+  PIXSetLastEventTimeSerial(evt->xbutton.time,  evt->xbutton.serial);
+  PIOptMenuX* opm = (PIOptMenuX*) ud;
+  opm->Menu()->Show(opm, rsy/2, opm->YSize());
+  }
+}
+
+
+/* --Methode-- */
+PIOptMenuX::PIOptMenuX(PIContainerGen* par, const char* nom, int sx, int sy, int px, int py)
+: PIOptMenuGen(par, nom, sx, sy, px, py)
+{
+mSmsg = 0;
+mStext = "";
+
+if (rsx == 0) { 
+  PIApplicationPrefCompSize(rsx, rsy);
+  rsy = rsy/3-2; 
+  }
+Arg warg[10];
+int n = 0;
+CreateXtWdg(nom, xmPushButtonWidgetClass, NULL, sx, sy, px, py);
+XtSetArg(warg[n],XmNhighlightThickness, 0);  n++;
+XtSetArg(warg[n], XmNrecomputeSize, FALSE); n++;
+XtSetArg(warg[n],XmNnavigationType,XmNONE);  n++;
+XtSetArg(warg[n],XmNtraversalOn,FALSE);  n++;
+XtSetArg(warg[n],XmNmarginLeft,rsy*3);  n++;
+XtSetValues(XtWdg(), warg, n);
+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);
+mgc = 0;
+char buff[128];
+strncpy(buff, nom, 64);
+strcat(buff,"_Menu");
+mMen = new PIMenu((PIWdg*)par, buff, k_PopupMenu);
+mMen->SetMsgParent(this);
+Manage();
+}
+
+
+/* --Methode-- */
+PIOptMenuX::~PIOptMenuX()
+{
+delete mMen;
+}
+
+/* --Methode-- */
+void PIOptMenuX::FinishCreate()
+{
+PIWdgX::FinishCreate();
+// printf("PIOptMenuX::FinishCreate()/DBG  %s \n", Nom().c_str());
+if (mSmsg == 0)  SetValue(mMen->ItemMsg(0)); 
+}
+
+/* --Methode-- */
+void PIOptMenuX::Process(PIMessage msg, PIMsgHandler* sender, void* data)
+{
+// printf("PIOptMenuX::Process Msg= %d Sender= %lx \n", (int)msg, (long)sender);
+if (sender == mMen)   {
+  SetValue(UserMsg(msg));
+  ReSend(msg, this, NULL);
+}
+return;
+}
+
+
+/* --Methode-- */
+void PIOptMenuX::SetValueStr(string & s)
+{
+int n;
+Arg warg[2];
+n=mMen->GetNumItem((char *)s.c_str());
+if (n < 0)  return;  
+
+XtSetArg(warg[0], XmNmenuHistory, mMen->GetItemWdg(n));
+XtSetValues(XtWdg(), warg, 1);
+mStext = s;
+mSmsg  = mMen->ItemMsg(n);
+
+SetLabel(mStext);
+
+return;
+}
+
+/* --Methode-- */
+void PIOptMenuX::SetValue(PIMessage msg)
+{
+int n;
+Arg warg[2];
+n=mMen->GetNumItemMsg(msg);
+if (n < 0)  return;
+  
+XtSetArg(warg[0], XmNmenuHistory, mMen->GetItemWdg(n));
+XtSetValues(XtWdg(), warg, 1);
+mStext = mMen->ItemName(n);
+mSmsg  = msg;
+SetLabel(mStext);
+return;
+}
+
+/* --Methode-- */
+void PIOptMenuX::SetLabel(string const& lab)
+{
+XmString xmstr;
+xmstr = XmStringLtoRCreate((char *)lab.c_str(), XmSTRING_DEFAULT_CHARSET);
+int n=0;
+Arg warg[2];
+
+XtSetArg(warg[n], XmNlabelString, xmstr); n++;
+XtSetValues(XtWdg(), warg, n);
+XmStringFree(xmstr);
+return;
+}
+
+/* --Methode-- */
+void PIOptMenuX::createmygc()
+{
+unsigned long fgc = 0;
+Arg warg[2];
+XtSetArg(warg[0], XmNforeground, &fgc);
+XtGetValues(XtWdg(), warg, 1);
+mgc = XCreateGC(PIXDisplay(), XtWindow(XtWdg()), 0, NULL); 
+XSetForeground(PIXDisplay(), mgc, fgc);
+}
Index: /tags/V_LaSilla191199/SophyaPI/PI/pioptmenux.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pioptmenux.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pioptmenux.h	(revision 464)
@@ -0,0 +1,38 @@
+#ifndef PIOPTMENX_H_SEEN
+#define PIOPTMENX_H_SEEN
+
+#include "pisysdep.h"
+#include "pioptmenugen.h"
+#include PISTDWDG_H
+
+class PIOptMenuX : public PIOptMenuGen {
+public:
+	            PIOptMenuX(PIContainerGen* par, const char* nom, int sx=50, int sy=15, int px=0, int py=0);
+	            ~PIOptMenuX();
+
+  virtual void	    FinishCreate(); 
+
+  virtual void      Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+				   
+  virtual string    GetValueStr() { return(mStext); }
+  virtual PIMessage GetValue()    { return(mSmsg); } 
+  virtual void      SetValueStr(string & s);
+  virtual void      SetValue(PIMessage msg);
+
+
+//  Pour utilisation privee dans call-back, .... 
+  virtual void       SetLabel(string const&);
+  inline  GC        myGC() {if (mgc == 0) createmygc();  return(mgc); }  
+
+protected:
+  string   mStext;
+  PIMessage mSmsg;
+//  SysDWdg mLabel;
+  GC mgc;
+  void              createmygc();
+};
+
+
+typedef PIOptMenuX  PIOptMenu ;
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/piperiodgen.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piperiodgen.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piperiodgen.h	(revision 464)
@@ -0,0 +1,26 @@
+// This may look like C code, but it is really -*- C++ -*-
+#ifndef PIPERIODGEN_H
+#define PIPERIODGEN_H
+
+#include <list.h>
+
+class PIPeriodGen;
+typedef list<PIPeriodGen*> PIPeriodList;
+
+class PIPeriodGen {
+public:
+  PIPeriodGen(int dT) : dt(dT) {} // dt en secondes
+  virtual ~PIPeriodGen() {}
+
+  virtual void DoPeriodic()=0;
+
+  virtual void Start()=0;
+  virtual void Stop()=0;
+
+protected:
+  int dt;
+};
+
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/piperiodmac.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piperiodmac.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piperiodmac.cc	(revision 464)
@@ -0,0 +1,36 @@
+#include "piperiodmac.h"
+
+
+
+/* --Methode-- */
+PIPeriodMac::PIPeriodMac(int dt, UsPeriodicAction act, void * usp)
+: Periodic(dt, act, usp), mLastTick(-1)
+{
+}
+
+/* --Methode-- */
+PIPeriodMac::~PIPeriodMac()
+{
+}
+
+/* --Methode-- */
+void PIPeriodMac::Start(int dt)
+{
+  StartRepeating();
+  if (dt > 0)  { mDt = dt; mDtms = 1000*dt;}
+}
+
+/* --Methode-- */
+void PIPeriodMac::Stop()
+{
+  StopRepeating();
+}
+
+/* --Methode-- */
+void PIPeriodMac::SpendTime(const EventRecord&)
+{
+  long ticks = ::TickCount();
+  if ((ticks - mLastTick) * 1000. / 60. < mDtms) return;
+  mLastTick = ticks;
+  DoPeriodic();
+}
Index: /tags/V_LaSilla191199/SophyaPI/PI/piperiodmac.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piperiodmac.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piperiodmac.h	(revision 464)
@@ -0,0 +1,22 @@
+// This may look like C code, but it is really -*- C++ -*-
+#ifndef PIPERIODMAC_H
+#define PIPERIODMAC_H
+
+#include "periodic.h"
+#include "LPeriodical.h"
+
+class PIPeriodMac : public Periodic, public LPeriodical {
+public:
+  PIPeriodMac(int dt, UsPeriodicAction act=NULL, void * usp=NULL);
+  ~PIPeriodMac();
+
+  virtual void Start(int dt=-1);
+  virtual void Stop();
+  virtual void SpendTime(const EventRecord&);
+protected:
+  long mLastTick;
+};
+
+typedef PIPeriodMac PIPeriodic;
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/piperiodx.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piperiodx.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piperiodx.cc	(revision 464)
@@ -0,0 +1,52 @@
+#include "piwdgx.h"
+#include "piperiodx.h"
+
+/* Nouvelle-Fonction */
+static void xttimer_action(XtPointer usd, XtIntervalId * /*tid*/)
+{
+PIPeriodX * pip;
+XtIntervalId id;
+pip = (PIPeriodX *)usd;
+pip->DoPeriodic();
+int szx, szy, szf;
+XtAppContext * appctx = PIXtAppCtx(szx, szy, szf);
+id = XtAppAddTimeOut(*appctx, pip->Intervalms(), xttimer_action, pip);
+pip->SetTimerId(id);
+return;
+}
+
+
+/* --Methode-- */
+PIPeriodX::PIPeriodX(int dt, UsPeriodicAction act, void * usp)
+: Periodic(dt, act, usp)
+{
+}
+
+/* --Methode-- */
+PIPeriodX::~PIPeriodX()
+{
+if (mFgact) Stop();
+}
+
+/* --Methode-- */
+void PIPeriodX::Start(int dt)
+{
+if (mFgact) return;
+if (dt > 0)  { mDt = dt;  mDtms = dt*1000; }
+
+int szx,szy,szf;
+XtAppContext * appctx = PIXtAppCtx(szx, szy, szf);
+mTId = XtAppAddTimeOut(*appctx, Intervalms(), xttimer_action, this);
+mFgact = true;
+return;
+}
+
+void
+PIPeriodX::Stop()
+{
+if(mFgact)
+  XtRemoveTimeOut(mTId);
+mFgact = false;
+return;
+}
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/piperiodx.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piperiodx.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piperiodx.h	(revision 464)
@@ -0,0 +1,24 @@
+// This may look like C code, but it is really -*- C++ -*-
+#ifndef PIPERIODX_H
+#define PIPERIODX_H
+
+#include <X11/Intrinsic.h>
+#include "periodic.h"
+
+class PIPeriodX : public Periodic {
+public:
+  PIPeriodX(int dt, UsPeriodicAction act=NULL, void * usp=NULL);
+  ~PIPeriodX();
+
+  virtual void Start(int dt=-1);
+  virtual void Stop();
+
+  inline void SetTimerId(XtIntervalId id) {mTId=id; }
+
+protected:
+XtIntervalId mTId;
+};
+
+typedef PIPeriodX PIPeriodic;
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pipixmapgen.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pipixmapgen.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pipixmapgen.cc	(revision 464)
@@ -0,0 +1,152 @@
+// Module PI : Peida Interactive     PIPixmap
+// Classe de base pour affichage de pixmap  Reza 96
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "pipixmapgen.h"
+
+// --------- Methodes de la classe PIPixMap  ----------
+//++
+// Class	PIPixmap
+// Lib		PI
+// include	pipixmapgen.h
+//
+//   	Classe pour la gestion optimisée des pixmap.
+//	Un pixmap est un tableau d'index dans une table de couleurs.
+//	Cette classe gére actuellement des pixmaps avec des index
+//	codés sur 8 bits (256 couleurs).
+//	Pour des raisons d'optimisation, cette classe a une 
+//	implémentation spécifique pour chaque plateforme.
+//	La classe "PIPixmapGen" définit l'interface, et ne doit pas 
+//	être instanciée directement.  Les objets instanciés sont de la 
+//	classes "PIPixmap" et le fichier entête correspondant est "PIPIXMAP_H"
+//	défini dans "pisysdep.h".
+//--
+//++
+// Links	Parents
+// PIBaseWdg
+//--
+//++
+// Links	Voir aussi
+// PIColorMap
+//--
+
+//++
+// Titre	Constructeur, Pixmap
+//--
+//++
+// PIPixmapGen(PIContainerGen *par, const char *nom, int sx=10, int sy=10, int px=0, int py=0)
+//	Constructeur - Création d'un "PIPIxmap".
+// long  kind() 
+//	Retourne le type ("=PIPixmap::ClassId")
+// void  SetPixmap(unsigned char *pix, int sx, int sy, bool refr=true, int ox=0, int oy=0)
+//	Associe un tableau d'index "pix" de taille "sx * sy".
+//	(ox,oy)" définissent  l'offset d'affichage.
+//	Si "refr=true", la méthode "Refresh()" est appelée.
+//--
+//++
+// Titre	Gestion de la table de couleur
+//--
+//++
+// void  SetColMap(PIColorMap* cmp, bool refr=true)
+//	Change la table de couleur associée.
+//	Si "refr=true", la méthode "Refresh()" est appelée.
+// void  SetColMapId(CMapId cmapid, bool refr=true)
+//	Change la table de couleur associée, à l'aide d'un identificateur
+//	de table de couleur standard. ("CMapId cmapid").
+//	Si "refr=true", la méthode "Refresh()" est appelée.
+// PIColorMap* GetColMap()
+//	Retourne la table de couleur associée.
+// CMapId GetColMapId() 
+//	Retourne l'identificateur de la table de couleur associée.
+// int NbCol()
+//	Retourne le nombre de couleurs de la table de couleur associée.
+//--
+
+//++
+// Titre	Actions
+//--
+//++
+// void  But1Press(int x, int y)
+//	L'action sur le bouton 1 déclenche l'envoi d'un message
+//	avec le modifier PIMsg_Click. La position du bouton-press
+//	est stocké. (- Offset affichage)
+// int  XPPos() 
+//	Position X du click - Offset Affichage pixmap
+// int  YPPos() 
+//	Position Y du click - Offset Affichage pixmap
+//--
+
+/* --Methode-- */
+PIPixmapGen::PIPixmapGen(PIContainerGen  *par, const char *nom,
+                     int sx, int sy, int px, int py) :
+PIBaseWdg(par, nom, sx, sy, px, py)
+{
+pixmap = NULL;
+nx = ny = 0;
+ofx = ofy = 0;
+mPpos[0] = mPpos[0] = 0;
+cmap = new PIColorMap(CMAP_GREY32);
+ActivateButton(1);
+}
+
+
+/* --Methode-- */
+PIPixmapGen::~PIPixmapGen()
+{
+delete cmap;
+}
+
+/* --Methode-- */
+void PIPixmapGen::SetPixmap(unsigned char *pix, int sx, int sy, bool refr, int ox, int oy)
+{
+pixmap = pix; 
+if (pixmap)
+  {
+  if (sx < 0)  sx = 0;
+  if (sy < 0)  sy = 0;
+  if (ox < 0)  ox = 0;
+  if (oy < 0)  oy = 0;
+  nx = sx; ny = sy;
+  ofx = ox;  ofy = oy;
+  }
+else { ofx = ofy = nx = ny = 0; }
+if (refr) Refresh();   
+}
+
+/* --Methode-- */
+void PIPixmapGen::SetColMap(PIColorMap* cmp, bool refr)
+{
+if (!cmp)  return;
+if ( (cmp->Type() == cmap->Type()) && (cmp->Type() != CMAP_OTHER) ) return;
+if (cmap) delete cmap;
+cmap = new PIColorMap(*cmp);
+if (refr)  Refresh();  
+}
+
+/* --Methode-- */
+void PIPixmapGen::SetColMapId(CMapId cmapid, bool refr)
+{
+if (!cmap || (cmap->Type() != cmapid) || (cmapid == CMAP_OTHER) ) {  
+  if (cmap) delete cmap;
+  cmap = new PIColorMap(cmapid);
+  }
+if (refr)  Refresh();  
+}
+
+
+/* --Methode-- */
+void  PIPixmapGen::But1Press(int x, int y)
+{
+mPpos[0] = x-ofx;  mPpos[1] = y-ofy;  
+if (Msg())  Send(Msg(), PIMsg_Click, mPpos);
+return;
+}
+
+
+
+// Fin des methodes de la classe 
+
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pipixmapgen.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pipixmapgen.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pipixmapgen.h	(revision 464)
@@ -0,0 +1,52 @@
+/* Fonctions interface XWindow pour affichage d'images */
+
+#ifndef PIPIXMAP_H_SEEN
+#define PIPIXMAP_H_SEEN
+
+#include "pisysdep.h"
+
+#include PIBWDG_H
+#include PICMAP_H
+
+#include <list>
+
+class PIPixmapGen : public PIBaseWdg
+{
+public:
+  enum {ClassId = 5100};
+
+                PIPixmapGen(PIContainerGen *par, const char *nom,
+                         int sx=10, int sy=10, int px=0, int py=0);
+  virtual       ~PIPixmapGen();
+
+  virtual long  kind() {return ClassId; }
+
+  virtual void  SetPixmap(unsigned char *pix, int sx, int sy, 
+                          bool refr=true, int ox=0, int oy=0);
+
+  virtual void  SetColMap(PIColorMap* cmp, bool refr=true);
+  virtual void  SetColMapId(CMapId cmapid, bool refr=true);
+
+  inline PIColorMap* GetColMap() { return cmap; }
+  inline CMapId GetColMapId() { return ((CMapId)cmap->Type()); }; 
+  inline int    NbCol() { return(cmap->NCol()); };
+
+  virtual void  But1Press(int x, int y);
+  inline  int   XPPos() { return mPpos[0]; }
+  inline  int   YPPos() { return mPpos[1]; }
+
+protected:
+  unsigned char *pixmap;
+  int nx, ny;
+  int ofx, ofy;
+  PIColorMap* cmap;
+
+  int mPpos[2];
+};  
+  
+
+
+
+#endif   /* PIPIXMAP_H_SEEN */
+
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pipixmapmac.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pipixmapmac.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pipixmapmac.cc	(revision 464)
@@ -0,0 +1,102 @@
+#include "pipixmapmac.h"
+
+PIPixmapMac::PIPixmapMac(PIContainerGen *par, char *nom,
+                         int sx, int sy, int px, int py)
+: PIPixmapGen(par,nom,sx,sy,px,py), mGWorld(NULL)
+{}
+
+
+PIPixmapMac::~PIPixmapMac()
+{}
+
+
+/* --Methode-- */
+void PIPixmapMac::SetPixmap(unsigned char *pix, int sx, int sy, bool refr, int ox, int oy)
+{
+  if (nx != sx || ny != sy)
+    if (mGWorld) {
+      DisposeGWorld(mGWorld);
+      mGWorld = NULL;
+    }
+  PIPixmapGen::SetPixmap(pix, sx, sy, refr);
+}
+
+void
+PIPixmapMac::Resize()
+{
+  Refresh();
+}
+
+void
+PIPixmapMac::Refresh()
+{
+	PIPixmapGen::Refresh();
+}
+
+void
+PIPixmapMac::DrawOff()
+{
+  if (mGWorld) {
+    DisposeGWorld(mGWorld);
+    mGWorld = NULL;
+  }
+  
+  if (!cmap) return;
+  if (!pixmap) return;
+  if (nx == 0 || ny == 0) return;
+  
+  Rect	frame;
+  SetRect(&frame, 0, 0, XSize(), YSize());
+
+  
+  ThrowIfOSErr_(NewGWorld(&mGWorld, 8, &frame, cmap->mCTab, nil, 0));
+
+    // Lock down Pixels that we are drawing to so that memory will not
+	// move
+	::LockPixels (mGWorld->portPixMap);
+
+ 	// Draw
+	PixMapHandle	pMap;
+	unsigned char	*pixP;
+	
+	pMap = GetGWorldPixMap(mGWorld);
+	for (int y=frame.top; y<frame.bottom; y++) {
+		pixP = (unsigned char *) GetPixBaseAddr(pMap) + y * ((**pMap).rowBytes & 0x7FFF);
+		for(int x = frame.left ; x < frame.right ; x++)
+			pixP[x] = (x<nx && y<ny) ? pixmap[x + y*nx]+2 : 0;
+	}
+			
+	// Now unlock Pixels.
+	::UnlockPixels (mGWorld->portPixMap);
+	
+	mPane->FocusDraw();
+//	SetPalette(mPane->GetMacPort(),cmap->mPalette, true);
+//	PIPixmapGen::Refresh();
+}
+
+void
+PIPixmapMac::Draw(PIGraphic* g,int,int,int,int)
+{
+  Draw(g);
+}
+
+void
+PIPixmapMac::Draw(PIGraphic* g)
+{
+  DrawOff();
+  if (!mGWorld) return;
+  mPane->FocusDraw();
+  Rect	paneFrame;
+  mPane-> CalcLocalFrameRect(paneFrame);
+  Rect	offsFrame;
+  SetRect(&offsFrame, 0, 0, paneFrame.right-paneFrame.left, paneFrame.bottom-paneFrame.top);
+  ::LockPixels (mGWorld->portPixMap);
+  ::ForeColor (blackColor);
+  ::BackColor (whiteColor);
+  ::CopyBits((BitMap *) (*(GetGWorldPixMap(mGWorld))),
+				&mPane->GetMacPort()->portBits,
+				&offsFrame, &paneFrame, srcCopy, nil);
+  ::UnlockPixels (mGWorld->portPixMap);
+  DisposeGWorld(mGWorld);
+  mGWorld = 0;
+}
Index: /tags/V_LaSilla191199/SophyaPI/PI/pipixmapmac.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pipixmapmac.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pipixmapmac.h	(revision 464)
@@ -0,0 +1,26 @@
+#ifndef PIPIXMAPMAC_H_SEEN
+#define PIPIXMAPMAC_H_SEEN
+
+#include "pipixmapgen.h"
+
+class PIPixmapMac : public PIPixmapGen {
+
+public:
+                PIPixmapMac(PIContainerGen *par, char *nom,
+                         int sx=10, int sy=10, int px=0, int py=0);
+  virtual      ~PIPixmapMac();
+
+  virtual void  SetPixmap(unsigned char *pix, int sx, int sy, bool refr=true, int ox=0, int oy=0);
+  virtual void  Draw(PIGraphic* g);
+  virtual void  Draw(PIGraphic* g, int x0, int y0, int dx, int dy);
+  virtual void	Refresh();
+  virtual void	DrawOff();
+  virtual void  Resize();
+protected:
+  GWorldPtr 	mGWorld;
+};
+
+typedef PIPixmapMac PIPixmap;
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pipixmapx.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pipixmapx.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pipixmapx.cc	(revision 464)
@@ -0,0 +1,174 @@
+#include <stdio.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+
+#include "pipixmapx.h"
+
+static  GC    mygc;
+
+/* --Methode-- */
+PIPixmapX::PIPixmapX(PIContainerGen *par, const char *nom,
+                         int sx, int sy, int px, int py)
+: PIPixmapGen(par,nom,sx,sy,px,py) 
+{
+Init();
+AllocXImg();
+}
+
+
+/* --Methode-- */
+PIPixmapX::~PIPixmapX()
+{
+delete[] myximg->data;
+XFree(myximg); 
+}
+
+/* --Methode-- */
+void PIPixmapX::Refresh()
+{
+int i,j;
+unsigned char *pp;
+
+if (pixmap)
+  {
+  for(j=0; j<ny; j++)
+    {
+    pp = pixmap+j*nx;
+    for(i=0; i<nx; i++)
+      { XPutPixel(myximg, i, j, cmap->Color(*pp) );  pp++; }
+    }
+  }
+
+for(j=ny; j<YSize(); j++)
+  for(i=nx; i<XSize(); i++)
+     XPutPixel(myximg, i, j, 0 );
+
+PIBaseWdgX::Refresh();
+}
+
+
+/* --Methode-- */
+void PIPixmapX::Resize()
+{
+delete[] myximg->data;
+XFree(myximg); 
+AllocXImg();
+if (Msg())  Send(Msg(), PIMsg_Resize, mPpos);
+}
+
+/*DEL07 --Methode-- 
+void PIPixmapX::Draw(PIGraphicGen* g)
+{
+if (!pixmap)  return;
+if (!g) return; 
+if (g->kind() == PI_PSFileGraphics ) {
+    g->DrawPixmap(ofx, ofy, pixmap, nx, ny, cmap);
+    //  Il faut faire quelque chose Sinon ??! 
+  }
+else  Draw(g, 0, 0, XSize(), YSize());
+}
+*/
+
+/* --Methode-- */
+void PIPixmapX::Draw(PIGraphic* g, int x0, int y0, int dx, int dy)
+{
+
+if (!g) return; 
+if ((myximg == NULL) || (cmap == NULL)) return;
+
+if (g->kind() == PI_PSFileGraphics ) {
+  if (pixmap) g->DrawPixmap(ofx, ofy, pixmap, nx, ny, cmap);
+  return;
+  }
+
+Window xw = XtWindow(XtWdg());
+Display * mdsp = PIXDisplay();
+
+int mx, my, ox, oy;
+
+if (x0 < 0)  x0 = 0;
+if (y0 < 0)  y0 = 0;
+mx = nx+ofx;   my = ny+ofy;
+if (dx > (XSize()-x0)) dx = XSize()-x0;
+if (dy > (YSize()-y0)) dy = YSize()-y0;
+if ((dx <= 0) || (dy <= 0))  return;
+
+if ( (mx < x0 ) || (my < y0) )
+  { XClearArea(mdsp, xw, x0, y0, dx, dy, False);  return; }
+
+ox = oy = 0;  
+
+if (ofx > x0)
+  { XClearArea(mdsp, xw, x0, y0, ofx-x0, dy, False);   
+  dx -= (ofx-x0);  x0 = ofx;  ox = 0; }
+else  ox = x0-ofx;
+if (ofy > y0)
+  { XClearArea(mdsp, xw, x0, y0, dx, ofy-y0, False);  
+  dy -= (ofy-y0);  y0 = ofy;  oy = 0; }
+else  oy = y0-ofy;
+ 
+if (mx < (x0+dx))
+  { XClearArea(mdsp, xw, mx, y0, x0+dx-mx, dy, False);  dx = mx-x0; }
+if (my < (y0+dy))
+  { XClearArea(mdsp, xw, x0, my, dx, y0+dy-my, False);  dy = my-y0; }
+ 
+XPutImage(mdsp, xw, mygc, myximg, ox, oy, x0, y0, dx, dy);
+XFlush(mdsp);
+return;
+ 
+}
+
+static bool fgxpxm = false;
+
+
+/* --Methode-- */
+void PIPixmapX::Init()
+{
+XGCValues       values;
+XtGCMask        mask;
+
+if (fgxpxm)  return; 
+fgxpxm = true;
+
+
+mask = GCFunction | GCPlaneMask;
+// mask = GCForeground | GCBackground;
+values.function = GXcopy;
+values.plane_mask = ~0;
+// values.foreground = WhitePixel(mdsp, scr);
+// values.background = BlackPixel(mdsp, scr);
+mygc = XtGetGC(XtWdg(), mask, &values);
+
+return;
+}
+
+
+/* --Methode-- */
+void PIPixmapX::AllocXImg()
+{
+Display * mdsp;
+int scr;
+int depth;
+int pad;
+int i,j;
+
+mdsp = PIXDisplay();
+scr = PIXScreen();
+
+depth = DefaultDepth(mdsp,scr);
+pad = (depth > 8) ? 32 : 8;
+myximg = XCreateImage (mdsp,DefaultVisual(mdsp,scr),
+           depth,ZPixmap,0,NULL, XSize(), YSize(), pad,0);
+if (myximg == NULL)  return;
+myximg->data = new char [YSize()*myximg->bytes_per_line];
+if (myximg->data == NULL)  
+  { XFree(myximg); myximg = NULL;  return; } 
+
+for(j=0; j<YSize(); j++)
+  for(i=0; i<XSize(); i++)
+    XPutPixel(myximg, i, j, 0 );
+
+return;
+}
Index: /tags/V_LaSilla191199/SophyaPI/PI/pipixmapx.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pipixmapx.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pipixmapx.h	(revision 464)
@@ -0,0 +1,27 @@
+#ifndef PIPIXMAPX_H_SEEN
+#define PIPIXMAPX_H_SEEN
+
+#include "pipixmapgen.h"
+
+class PIPixmapX : public PIPixmapGen {
+
+public:
+                PIPixmapX(PIContainerGen *par, const char *nom,
+                         int sx=10, int sy=10, int px=0, int py=0);
+  virtual      ~PIPixmapX();
+
+  virtual void  Refresh();
+  virtual void  Resize();
+  virtual void  Draw(PIGraphic* g, int x0, int y0, int dx, int dy);
+
+
+protected:
+  void          Init();
+  void          AllocXImg();
+  XImage * myximg;  
+};
+
+typedef PIPixmapX PIPixmap;
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pippapplmac.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pippapplmac.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pippapplmac.cc	(revision 464)
@@ -0,0 +1,41 @@
+#include "pippapplmac.h"
+#include "piupdattachment.h"
+#include "pippmenubar.h"
+#include "pippwindowmac.h"
+#include <LClipboard.h>
+
+PIPPApplMac::PIPPApplMac()
+:LApplication()
+{
+  RegisterClass_(PIPPWindowMac);
+  AddAttachment(new LClipboard);
+}
+
+
+PIPPApplMac::~PIPPApplMac()
+{}
+
+void
+PIPPApplMac::AdjustCursor(const EventRecord &inMacEvent)
+{
+  PIUpdAttachment::hit = false;
+  LApplication::AdjustCursor(inMacEvent);
+  if (!PIUpdAttachment::hit) {
+    if (PIUpdAttachment::lastCursPane)
+       PIUpdAttachment::lastCursPane->myWdg->Leave();
+    PIUpdAttachment::lastCursPane = NULL;
+  }   
+}
+
+void
+PIPPApplMac::MakeMenuBar()
+{
+	//new PIPPMenuBar();
+}
+
+
+
+// $CHECK$
+// Gerer AllowSubRemoval, qui envoie un evenement a l'application PI.
+// Eventuellement avoir des fenetres qui se cachent lors d'un close et d'autres
+// qui se detruisent ??
Index: /tags/V_LaSilla191199/SophyaPI/PI/pippapplmac.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pippapplmac.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pippapplmac.h	(revision 464)
@@ -0,0 +1,11 @@
+#include <LApplication.h>
+
+class PIPPApplMac : public LApplication {
+public:
+						PIPPApplMac();
+	virtual				~PIPPApplMac();
+
+	void MakeMenuBar();
+	virtual void			AdjustCursor	(const EventRecord &inMacEvent);
+};
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pipplist.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pipplist.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pipplist.cc	(revision 464)
@@ -0,0 +1,198 @@
+#include "pipplist.h"
+#include <LTableMonoGeometry.h>
+#include <LTableSingleSelector.h>
+#include <LTableMultiSelector.h>
+#include <LTableArrayStorage.h>
+#include <LComparator.h>
+
+class CellMsgComparator : public LComparator {
+public:
+	virtual Int32		Compare(
+								const void*			inItemOne,
+								const void* 		inItemTwo,
+								Uint32				/*inSizeOne*/,
+								Uint32				/*inSizeTwo*/) const
+	{return ((PIPPListCell*)inItemOne)->msg == ((PIPPListCell*)inItemTwo)->msg;}
+};
+
+static CellMsgComparator cellMsgComparator;
+
+class CellStrComparator : public LComparator {
+public:
+	virtual Int32		Compare(
+								const void*			inItemOne,
+								const void* 		inItemTwo,
+								Uint32				/*inSizeOne*/,
+								Uint32				/*inSizeTwo*/) const
+	{return ((PIPPListCell*)inItemOne)->str == ((PIPPListCell*)inItemTwo)->str;}
+};
+
+static CellStrComparator cellStrComparator;
+
+
+PIPPList::PIPPList(PIMsgHandler* h)
+: mHndl(h)
+{
+  InitPPList();
+}
+
+PIPPList::PIPPList(
+    const SPaneInfo& inPaneInfo,
+    const SViewInfo& inViewInfo,
+    PIMsgHandler* h)
+: LTableView(inPaneInfo, inViewInfo), mHndl(h)
+{
+  InitPPList();
+}
+
+void PIPPList::InitPPList()
+{
+  SetTableGeometry(new LTableMonoGeometry(this, 10, 16));
+  SetTableSelector(tss=new LTableSingleSelector(this)); 
+  mArray = new LArray(sizeof(PIPPListCell)),
+  SetTableStorage(new LTableArrayStorage(this, mArray));
+  tms = new LTableMultiSelector(this);
+  LTableView::InsertCols(1, 0, nil, 0, Refresh_No);
+}
+
+PIPPList::~PIPPList()
+{
+  SetTableSelector(nil);
+  delete tss;
+  delete tms;
+}
+
+
+void PIPPList::AppendItem(string const& str, PIMessage msg)
+{
+  PIPPListCell cell;
+  cell.str=str;
+  cell.msg=msg;
+  InsertRows(1, -1, &cell, sizeof(cell), Refresh_Yes);
+}
+
+STableCell PIPPList::FindStr(string const& str)
+{
+  PIPPListCell cell;
+  cell.str = str;
+  cell.msg = 0;
+  mArray->SetComparator(&cellStrComparator);
+  STableCell tcell;
+  FindCellData(tcell, &cell, sizeof(cell));
+  return tcell;
+}
+
+STableCell PIPPList::FindMsg(PIMessage msg)
+{
+  PIPPListCell cell;
+  cell.str = "";
+  cell.msg = msg;
+  mArray->SetComparator(&cellMsgComparator);
+  STableCell tcell;
+  FindCellData(tcell, &cell, sizeof(cell));
+  return tcell;
+}
+
+void PIPPList::DeleteItem(string const& str)
+{
+  STableCell tcell = FindStr(str);
+  RemoveRows(1, tcell.row, Refresh_Yes);
+}
+
+void PIPPList::DeleteItem(PIMessage msg)
+{
+  STableCell tcell = FindMsg(msg);
+  RemoveRows(1, tcell.row, Refresh_Yes);
+}
+
+
+void PIPPList::SetMultipleSelect(bool ms);
+  
+int PIPPList::GetNbSel()
+{
+  int n = 0;
+  for (TableIndexT j=1; j<=mRows; j++) {
+    STableCell cell;
+    cell.row = j;
+    cell.col = 1;
+    if (CellIsSelected(cell)) n++;
+  }
+  return n; 
+}
+
+PIMessage PIPPList::GetSelMsg(int i)
+{
+  int n = 0;
+  for (TableIndexT j=1; j<=mRows; j++) {
+    STableCell cell;
+    cell.row = j;
+    cell.col = 1;
+    if (CellIsSelected(cell)) n++;
+    if (n == i) {
+       PIPPListCell ppcell;
+       UInt32 sz = sizeof(ppcell);
+       GetCellData(cell, &ppcell, sz);
+       return ppcell.msg;
+    }
+  }
+  return 0; 
+}
+
+string PIPPList::GetSelStr(int i)
+{
+  int n = 0;
+  for (TableIndexT j=1; j<=mRows; j++) {
+    STableCell cell;
+    cell.row = j;
+    cell.col = 1;
+    if (CellIsSelected(cell)) n++;
+    if (n == i) {
+       PIPPListCell ppcell;
+       UInt32 sz = sizeof(ppcell);
+       GetCellData(cell, &ppcell, sz);
+       return ppcell.str;
+    }
+  }
+  return ""; 
+}
+void PIPPList::SelectItem(string const& str)
+{
+  STableCell cell = FindStr(str);
+  SelectCell(cell);
+}
+
+void PIPPList::SelectItem(PIMessage msg)
+{
+  STableCell cell = FindMsg(msg);
+  SelectCell(cell);
+}
+
+void PIPPList::ClearSelItem(string const& str)
+{
+  STableCell cell = FindStr(str);
+  UnselectCell(cell);
+}
+
+void PIPPList::ClearSelItem(PIMessage msg)
+{
+  STableCell cell = FindMsg(msg);
+  UnselectCell(cell);
+}
+
+void PIPPList::SetMultipleSelect(bool ms)
+{
+  if (ms)
+    SetTableSelector(tms);
+  else
+    SetTableSelector(tss); 
+}
+
+void
+PIPPList::ClickCell(
+	const STableCell&		inCell,
+	const SMouseDownEvent&	inMouseDown)
+{
+  if (GetClickCount() == 2) {
+	
+  }
+}
Index: /tags/V_LaSilla191199/SophyaPI/PI/pipplist.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pipplist.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pipplist.h	(revision 464)
@@ -0,0 +1,52 @@
+#pragma once
+
+#include <string>
+#include <LTableView.h>
+#include "pimsghandler.h"
+
+class LArray;
+
+struct PIPPListCell {
+   string 	   str;
+   PIMessage   msg;
+};
+
+class PIPPList : public LTableView {
+public:
+
+  PIPPList(PIMsgHandler* hndl);
+  PIPPList(
+    const SPaneInfo& inPaneInfo,
+    const SViewInfo& inViewInfo,
+    PIMsgHandler* hndl);
+  virtual ~PIPPList();
+
+  void       AppendItem(string const& str, PIMessage msg);
+  void       DeleteItem(string const& str);
+  void       DeleteItem(PIMessage msg);  
+
+  void       SetMultipleSelect(bool ms);
+  
+  int        GetNbSel();
+  PIMessage  GetSelMsg(int i);
+  string     GetSelStr(int i);
+  
+  void       SelectItem(string const& str);
+  void       SelectItem(PIMessage msg);
+  void       ClearSelItem(string const& str);
+  void       ClearSelItem(PIMessage msg);
+  
+protected:
+  LTableSelector* tss;
+  LTableSelector* tms;
+  LArray*         mArray;
+  PIMsgHandler*   mHndl;
+
+  virtual void    ClickCell(
+                       const STableCell        &inCell,
+                       const SMouseDownEvent   &inMouseDown);
+
+  void InitPPList();
+  STableCell  FindMsg(PIMessage msg);
+  STableCell  FindStr(string const& str);
+};
Index: /tags/V_LaSilla191199/SophyaPI/PI/pippmenubar.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pippmenubar.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pippmenubar.cc	(revision 464)
@@ -0,0 +1,44 @@
+#include "pippmenubar.h"
+
+PIPPMenuBar::PIPPMenuBar()
+: LMenuBar(MBAR_Initial)
+{
+
+}
+
+PIPPMenuBar::~PIPPMenuBar()
+{}
+
+CommandT
+PIPPMenuBar::MenuCommandSelection(
+	const EventRecord	&inMouseEvent,
+	Int32				&outMenuChoice) const
+{
+	outMenuChoice = ::MenuSelect(inMouseEvent.where);
+	
+	int menuId = HiWord(outMenuChoice);
+	int menuItem = LoWord(outMenuChoice)-1; // Dans PI les menu items commencent a 0
+	
+	PIMenuMac* menu = PIMenuMac::GetMenu(menuId);
+	if (menu)
+	  menu->ItemSelected(menuItem);
+	
+	return cmd_Nothing;
+}
+
+CommandT
+PIPPMenuBar::FindKeyCommand(
+	const EventRecord	&inKeyEvent,
+	Int32				&outMenuChoice) const
+{
+	char	theChar = inKeyEvent.message & charCodeMask;
+	outMenuChoice = ::MenuKey(theChar);
+	int menuId = HiWord(outMenuChoice);
+	int menuItem = LoWord(outMenuChoice)-1; // Dans PI les menu items commencent a 0
+	
+	PIMenuMac* menu = PIMenuMac::GetMenu(menuId);
+	if (menu)
+	  menu->ItemSelected(menuItem);
+	
+	return cmd_Nothing;
+}
Index: /tags/V_LaSilla191199/SophyaPI/PI/pippmenubar.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pippmenubar.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pippmenubar.h	(revision 464)
@@ -0,0 +1,21 @@
+#ifndef PIPPMENUBAR_H_SEEN
+#define PIPPMENUBAR_H_SEEN
+
+#include <LMenuBar.h>
+#include "pimenumac.h"
+
+class PIPPMenuBar : public LMenuBar {
+public:
+                           PIPPMenuBar();
+                          ~PIPPMenuBar();
+
+	virtual CommandT	   MenuCommandSelection(const EventRecord &inMouseEvent,
+								Int32 &outMenuChoice) const;
+
+	virtual CommandT	FindKeyCommand(
+								const EventRecord	&inKeyEvent,
+								Int32				&outMenuChoice) const;
+};
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pippoptmenu.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pippoptmenu.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pippoptmenu.cc	(revision 464)
@@ -0,0 +1,67 @@
+#include "pippoptmenu.h"
+
+PIPPOptMenu::PIPPOptMenu(
+	const SPaneInfo	&inPaneInfo,
+	MessageT		inValueMessage,
+	Int16			inTitleOptions,
+	ResIDT			inMENUid,
+	Int16			inTitleWidth,
+	Int16			inPopupVariation,
+	ResIDT			inTextTraitsID,
+	Str255			inTitle,
+	OSType			inResTypeMENU,
+	Int16			inInitialMenuItem)
+		: LStdPopupMenu(inPaneInfo, inValueMessage, inTitleOptions,
+				inMENUid, inTitleWidth, inPopupVariation, inTextTraitsID,
+				inTitle, inResTypeMENU, inInitialMenuItem)
+{
+}
+
+
+
+PIPPOptMenu::PIPPOptMenu(
+	const SPaneInfo	&inPaneInfo,
+	MessageT		inValueMessage,
+	Int32			inMaxValue,
+	ResIDT			inTextTraitsID,
+	ControlHandle	inMacControlH)
+		: LStdPopupMenu(inPaneInfo, inValueMessage, inMaxValue,
+						inTextTraitsID, inMacControlH)
+{
+}
+
+
+
+PIPPOptMenu::PIPPOptMenu(
+	LStream	*inStream)
+		: LStdPopupMenu(inStream)
+{	
+}
+
+void
+PIPPOptMenu::HotSpotResult(
+	Int16	inHotSpot)
+{
+		BroadcastMessage(msg_ThumbDragged, (void*) this);
+}
+
+void
+PIPPOptMenu::SetMenu(PIMenu* pdm)
+{
+  // On va changer la resource de menu au passage...
+  InsertMenu(pdm->GetMacMenuHandle(), hierMenu);
+  PopupPrivateDataHandle	dataH =
+		(PopupPrivateDataHandle) (**GetMacControl()).contrlData;
+  (**dataH).mHandle = pdm->GetMacMenuHandle();
+  (**dataH).mID = pdm->GetMacMenuID();
+  
+  //InitStdPopupMenu(1);
+  
+  mValue = 1;
+  mMinValue = 1;
+  mMaxValue = ::CountMItems(pdm->GetMacMenuHandle());
+
+  ::SetControlValue(mMacControlH, mValue);
+  ::SetControlMinimum(mMacControlH, mMinValue);
+  ::SetControlMaximum(mMacControlH, mMaxValue);
+}
Index: /tags/V_LaSilla191199/SophyaPI/PI/pippoptmenu.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pippoptmenu.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pippoptmenu.h	(revision 464)
@@ -0,0 +1,36 @@
+#include "LStdControl.h"
+#include "pisysdep.h"
+#include PIMENU_H
+
+// Redefinir HotSpotResult pour envoyer un message au PIOptMenuMac (qui est un listener)
+// qui va envoyer une action.
+
+class PIPPOptMenu : public LStdPopupMenu {
+public:
+	enum { class_ID = 'PPop' };
+					PIPPOptMenu(
+							const SPaneInfo		&inPaneInfo,
+							MessageT			inValueMessage,
+							Int16				inTitleOptions,
+							ResIDT				inMENUid,
+							Int16				inTitleWidth,
+							Int16				inPopupVariation,
+							ResIDT				inTextTraitsID,
+							Str255				inTitle,
+							OSType				inResTypeMENU,
+							Int16				inInitialMenuItem);
+					PIPPOptMenu(
+							const SPaneInfo		&inPaneInfo,
+							MessageT			inValueMessage,
+							Int32				inMaxValue,
+							ResIDT				inTextTraitsID,
+							ControlHandle		inMacControlH);
+					PIPPOptMenu(
+							LStream				*inStream);
+							
+					void SetMenu(PIMenu* pdm);
+protected:
+	virtual void		HotSpotResult(
+								Int16			inHotSpot);
+
+};
Index: /tags/V_LaSilla191199/SophyaPI/PI/pippviewadapter.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pippviewadapter.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pippviewadapter.cc	(revision 464)
@@ -0,0 +1,128 @@
+#include "pippviewadapter.h"
+#include "piupdattachment.h"
+
+
+PIPPViewAdapter::PIPPViewAdapter()	
+:LView()
+{
+	::SetRect(&piBindings, 0, 0, 0, 0);
+}
+
+PIPPViewAdapter::PIPPViewAdapter(	
+	const PIPPViewAdapter& inOriginal)
+:LView(inOriginal)
+{
+	::SetRect(&piBindings, 0, 0, 0, 0);
+}
+PIPPViewAdapter::PIPPViewAdapter(
+	const SPaneInfo		&inPaneInfo,
+	const SViewInfo		&inViewInfo)
+:LView(inPaneInfo, inViewInfo)
+{
+	::SetRect(&piBindings, 0, 0, 0, 0);
+}
+
+void PIPPViewAdapter::SetBinding(PIBindingKind left, PIBindingKind top, 
+                                  PIBindingKind right, PIBindingKind bottom)
+{
+  piBindings.left   = left;
+  piBindings.right  = right;
+  piBindings.top    = top;
+  piBindings.bottom = bottom;
+}
+
+bool PIPPViewAdapter::GetBinding(PIBindingKind& left, PIBindingKind& top, 
+                                  PIBindingKind& right, PIBindingKind& bottom)
+{
+  left   = (PIBindingKind)piBindings.left;
+  right  = (PIBindingKind)piBindings.right;
+  top    = (PIBindingKind)piBindings.top;
+  bottom = (PIBindingKind)piBindings.bottom;
+  
+  return false;
+}
+
+
+void PIPPViewAdapter::AdaptToSuperFrameSize(
+	Int32				inSurrWidthDelta,
+	Int32				inSurrHeightDelta,
+	Boolean				inRefresh)
+{
+  SDimension16 parSize;
+  GetSuperView()->GetFrameSize(parSize);
+  
+  SDimension16 oldParSize = parSize;
+  oldParSize.width -= inSurrWidthDelta;
+  oldParSize.height -= inSurrHeightDelta;
+  
+  SPoint32 myLoc;
+  GetFrameLocation(myLoc);
+  SPoint32	superImageLoc = {0, 0};
+	
+  if (mSuperView != nil) {
+    mSuperView->GetImageLocation(superImageLoc);
+  }
+  myLoc.h -= superImageLoc.h;
+  myLoc.v -= superImageLoc.v;
+  
+  SDimension16 mySize;
+  GetFrameSize(mySize);
+    
+  SPoint32 myXLoc = myLoc;
+  myXLoc.h += mySize.width;
+  myXLoc.v += mySize.height;
+  
+  if (piBindings.left == PIBK_elastic) {
+     myLoc.h = parSize.width * ((float)myLoc.h / (float)oldParSize.width);
+  }
+ 
+  if (piBindings.top == PIBK_elastic) {
+     myLoc.v = parSize.height * ((float)myLoc.v / (float)oldParSize.height);
+  }
+  
+  if (piBindings.right == PIBK_fixed) {
+     myXLoc.h += inSurrWidthDelta;
+  } else
+  if (piBindings.right == PIBK_elastic) {
+     myXLoc.h = parSize.width * ((float)myXLoc.h / (float)oldParSize.width);
+  }  
+ 
+  if (piBindings.bottom == PIBK_fixed) {
+     myXLoc.v += inSurrHeightDelta;
+  } else
+  if (piBindings.bottom == PIBK_elastic) {
+     myXLoc.v = parSize.height * ((float)myXLoc.v / (float)oldParSize.height);
+  }
+  
+  
+  if (piBindings.left == PIBK_free) {
+    myLoc.h = myXLoc.h - mySize.width;
+  }   
+  if (piBindings.top == PIBK_free) {
+    myLoc.v = myXLoc.v - mySize.height;
+  }   
+  if (piBindings.right == PIBK_free) {
+    myXLoc.h = myLoc.h + mySize.width;
+  }   
+  if (piBindings.bottom == PIBK_free) {
+    myXLoc.v = myLoc.v + mySize.height;
+  }
+  
+  mySize.width = myXLoc.h - myLoc.h;
+  mySize.height = myXLoc.v - myLoc.v;
+  
+  ResizeFrameTo(mySize.width, mySize.height, inRefresh);
+  ResizeFrameTo(mySize.width, mySize.height, inRefresh);
+  PlaceInSuperImageAt(myLoc.h, myLoc.v, inRefresh);
+}
+
+void
+PIPPViewAdapter::ResizeFrameBy(
+	Int16		inWidthDelta,
+	Int16		inHeightDelta,
+	Boolean		inRefresh)
+{
+  LView::ResizeFrameBy(inWidthDelta,inHeightDelta,inRefresh);
+  ExecuteAttachments(msg_Resize, NULL);
+}
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pippviewadapter.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pippviewadapter.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pippviewadapter.h	(revision 464)
@@ -0,0 +1,30 @@
+#pragma once
+
+#include <LView.h>
+#include "piwdggen.h"
+
+class PIPPViewAdapter : public LView {
+public:
+						PIPPViewAdapter();
+						PIPPViewAdapter(	
+								const PIPPViewAdapter	&inOriginal);
+						PIPPViewAdapter(
+								const SPaneInfo		&inPaneInfo,
+								const SViewInfo		&inViewInfo);
+
+	virtual void        SetBinding(PIBindingKind left, PIBindingKind top, 
+                                   PIBindingKind right, PIBindingKind bottom);
+	bool                GetBinding(PIBindingKind& left, PIBindingKind& top, 
+                                   PIBindingKind& right, PIBindingKind& bottom);
+	virtual void		AdaptToSuperFrameSize(
+								Int32				inSurrWidthDelta,
+								Int32				inSurrHeightDelta,
+								Boolean				inRefresh);
+	virtual void		ResizeFrameBy(
+								Int16				inWidthDelta,
+								Int16				inHeightDelta,
+								Boolean				inRefresh);
+								
+protected:
+	Rect				piBindings;
+};
Index: /tags/V_LaSilla191199/SophyaPI/PI/pippwindowmac.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pippwindowmac.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pippwindowmac.cc	(revision 464)
@@ -0,0 +1,107 @@
+#include "pippwindowmac.h"
+
+
+// ---------------------------------------------------------------------------
+//		¥ PIPPWindowMac
+// ---------------------------------------------------------------------------
+//	Default Constructor
+
+PIPPWindowMac::PIPPWindowMac()
+{
+  myPIWindow = NULL;
+}
+
+
+// ---------------------------------------------------------------------------
+//		¥ PIPPWindowMac(SWindowInfo&)
+// ---------------------------------------------------------------------------
+//	Construct Window from the data in a struct
+
+PIPPWindowMac::PIPPWindowMac(
+	const SWindowInfo	&inWindowInfo)
+:LWindow(inWindowInfo)
+{
+  myPIWindow = NULL;
+}
+
+
+// ---------------------------------------------------------------------------
+//		¥ PIPPWindowMac(ResIDT, Uint32, LCommander*)
+// ---------------------------------------------------------------------------
+//	Construct a Window from a WIND Resource with the specified attributes
+//	and SuperCommander
+
+PIPPWindowMac::PIPPWindowMac(
+	ResIDT		inWINDid,
+	Uint32		inAttributes,
+	LCommander	*inSuperCommander)
+:LWindow(inWINDid, inAttributes, inSuperCommander)
+{
+  myPIWindow = NULL;
+}
+
+
+// ---------------------------------------------------------------------------
+//		¥ PIPPWindowMac
+// ---------------------------------------------------------------------------
+//	Construct a Window from input parameters
+
+PIPPWindowMac::PIPPWindowMac(
+	LCommander		*inSuperCommander,
+	const Rect		&inGlobalBounds,
+	ConstStringPtr	inTitle,
+	Int16			inProcID,
+	Uint32			inAttributes,
+	WindowPtr		inBehind,
+	void			*inStorage)
+:LWindow(inSuperCommander, inGlobalBounds, inTitle,
+inProcID, inAttributes, inBehind, inStorage)
+{
+  myPIWindow = NULL;
+}
+
+
+// ---------------------------------------------------------------------------
+//		¥ PIPPWindowMac(LStream*)
+// ---------------------------------------------------------------------------
+//	Construct Window from the data in a stream
+
+PIPPWindowMac::PIPPWindowMac(
+	LStream	*inStream)
+:LWindow(inStream)
+{
+  myPIWindow = NULL;
+}
+
+
+// ---------------------------------------------------------------------------
+//		¥ ~PIPPWindowMac
+// ---------------------------------------------------------------------------
+//	Destructor
+
+PIPPWindowMac::~PIPPWindowMac()
+{
+}
+
+void
+PIPPWindowMac::AttemptClose()
+{
+  myPIWindow->Process(myPIWindow->BuildMsg(myPIWindow->Msg(),PIMsg_Close), myPIWindow, NULL) ;
+}
+
+
+const MessageT	msg_Resize			= 817;
+const MessageT	msg_Move			= 818;
+
+void PIPPWindowMac::DoSetPosition(Point inPosition)
+{
+    ExecuteAttachments(msg_Move, NULL);
+    LWindow::DoSetPosition(inPosition);
+}
+
+void PIPPWindowMac::DoSetBounds(const Rect &inBounds)
+{
+    ExecuteAttachments(msg_Resize, NULL);
+    LWindow::DoSetBounds(inBounds);
+}
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pippwindowmac.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pippwindowmac.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pippwindowmac.h	(revision 464)
@@ -0,0 +1,37 @@
+#include <LWindow.h>
+#include "piwindowmac.h"
+
+class PIPPWindowMac : public LWindow {
+public:
+	enum { class_ID = 'pwin' };
+	
+						PIPPWindowMac();
+						PIPPWindowMac(
+								const SWindowInfo	&inWindowInfo);
+						PIPPWindowMac(
+								ResIDT				inWINDid,
+								Uint32				inAttributes,
+								LCommander			*inSuperCommander);
+								
+						PIPPWindowMac(
+								LCommander			*inSuperCommander,
+								const Rect			&inGlobalBounds,
+								ConstStringPtr		inTitle,
+								Int16				inProcID,
+								Uint32				inAttributes,
+								WindowPtr			inBehind,
+								void				*inStorage = nil);
+								
+						PIPPWindowMac(
+								LStream				*inStream);
+	virtual				~PIPPWindowMac();
+
+	virtual void		DoSetPosition(
+								Point				inPosition);
+	virtual void		DoSetBounds(
+								const Rect			&inBounds);
+								
+	virtual void		AttemptClose();
+								
+	PIWindow* myPIWindow;
+};
Index: /tags/V_LaSilla191199/SophyaPI/PI/piscdrawwdg.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piscdrawwdg.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piscdrawwdg.cc	(revision 464)
@@ -0,0 +1,631 @@
+// Module PI : Peida Interactive     PIScDrawWdg
+// Gestionnaire Drawer-2D  E.Aubourg, R. Ansari  96-98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "machdefs.h"
+#include <iostream.h>
+
+#include "piscdrawwdg.h"
+#include "pidrwtools.h"
+#include "parradapter.h"
+
+//++
+// Class	PIScDrawWdg
+// Lib		PI
+// include	piscdrawwdg.h
+//
+//   	Classe pour la l'affichage et la manipulation d'un ensemble
+//	de *Drawer* avec la gestion de zoom (agrandissement).
+//	* Bouton-1 : Envoie le message "PIMsg_Active" et affiche
+//	les coordonnées courantes (User-Coordinates)
+//	* Bouton-2 : Permet de définir un rectangle pour le zoom.
+//	* Bouton-3 : Permet de définir un rectangle pour le texte info.
+//
+//	Gestion du clavier :
+//	* <Alt>O : Active/Affiche les  contrôles de paramètres spécifiques 
+//	(Par défaut, action identique à <Alt>G)
+//	* <Alt>G : Affichage de la fenêtre de changement des attributs graphiques
+//	* <Alt>R : Rafraîchit l'affichage.
+//	* <Alt>M : Active/Désactive l'affichage d'une réticule de mesure (Bouton-1)
+//	* <Alt>V : Copier/*Coller* Ajout du texte du buffer copier/coller
+//	sur l'objet à la position courante.
+//	* <Alt>I : Affiche et met a jour la fenetre Texte-Info .
+//	* <Alt>Z : Supprime les textes et signes ajoutés au dessin.
+//--
+//++
+// Links	Parents
+// PIBaseWdg
+//--
+//++
+// Links	Voir aussi
+// PIDrawer
+//--
+
+static inline void dbl_swap(double& a, double& b) { double tmp = a; a = b; b = tmp;  } 
+
+//++
+// Titre	Constructeurs, méthodes
+//--
+//++
+//  PIScDrawWdg(PIContainerGen *par, const char *nom, int sx=100, int sy=100, int px=0, int py=0)
+//	Constructeur. Contient uniquement le traceur de base, responsable du tracé
+//	des axes et des éléments ajoutés (textes, ...)
+// long  kind()
+//	Renvoie le type ("=PIScDrawWdg::ClassId")
+// void SetLimits(double xmin, double xmax, double ymin, double ymax, -
+//           int axrl=kAxeDirSame, int ayud=kAxeDirSame, bool tmp=false)
+//	Définit les limites de coordonnées.
+// void	 UpdateLimits()
+//	Recalcule les limites de coordonnées à partir du premier Drawer.
+// void  SetAxesFlags(unsigned int flags=kAxesDflt)
+//	Définit les attributs des axes.
+// int  AddScDrawer(PIDrawer*, bool ad=false)
+//	Ajoute un Drawer.
+//--
+
+
+PIScDrawWdg::PIScDrawWdg(PIContainerGen *par, const char *nom,
+                         int sx, int sy, int px, int py)
+:PIBaseWdg(par, nom, sx, sy, px, py)
+{
+  mFgReticule = false;
+  mCPosX = mCPosY = 0;
+  mPPos[0] = mPPos[1] = 0.;
+  mPSz[0] = mPSz[1] = 0.;
+
+  mBDrw = new PIElDrawer;
+  SetLimits(-1.,1.,-1.,1.,kAxeDirLtoR,kAxeDirDownUp);
+  SetAxesFlags(kBoxAxes | kExtTicks | kLabels);  
+  FreeLimits();
+  xEndDrag = yEndDrag = xBegDrag = yBegDrag = 0;
+  SetDefaultDrawRectangle(0.12, 0.12, 0.88, 0.88, true);
+//  SetDefaultDrawRectangle(0.12, 0.08, 0.88, 0.92, true);
+  AddDrawer(mBDrw, true, false, false);
+
+//  Pour afficher les coordonnees courante (click-bouton-1)  
+  mTrlb = mTxw = NULL;
+  mTrW = NULL;
+  SetTextWin(NULL);
+
+//  Affichage eventuelle d'infos-texte
+  mInfoW = NULL;
+  mInfoTxt = NULL;
+
+  ActivateKeyboard();
+  ActivateButton(1);    // Pour pouvoir activer la fenetre et coordonnees
+  ActivateMove(1);      //    "         "         "        "
+  ActivateButton(2);    //  Pour gerer le zoom
+  ActivateMove(2);      //    "         "
+  ActivateButton(3);    //  Pour definir la zone info-texte
+  ActivateMove(3);      //    "         "
+
+}
+
+PIScDrawWdg::~PIScDrawWdg()
+{
+  delete mBDrw;
+  if (mTrW)  delete mTrW;
+  if (mInfoW) delete mInfoW;
+}
+
+void 
+PIScDrawWdg::Keyboard(int key, PIKeyModifier kmod)
+{
+if (kmod == PIKM_Alt) {
+  if      (key == 'R' || key == 'r')  Refresh(); // rafraichir l'affichage
+  else if (key == 'M' || key == 'm') mFgReticule = !mFgReticule; // reticule de mesure 
+  else if (key == 'V' || key == 'v') RequestSelection();  // Pour coller (copier/coller)  
+  else if (key == 'Z' || key == 'z') { mBDrw->ElDelAll();  Refresh(); } // Pour supprimer tous les signes 
+  else if (key == 'O' || key == 'o') ActivateSpecializedControls();
+  else if (key == 'G' || key == 'g') { 
+    PIDrwTools::SetCurrentBaseWdg(this);
+    PIDrwTools::ShowPIDrwTools();   // Fentre axes et options de trace
+    }
+  else if (key == 'I' || key == 'i') UpdateInfoWindow();  // Fenetre Text-Info 
+  }
+}
+void 
+PIScDrawWdg::PasteSelection(unsigned int typ, void *pdata, unsigned int l)
+{
+if (typ != PICP_string) return;
+int ll = (l<256) ? l+1 : 256;
+char pc[256];
+strncpy(pc, (char*)pdata, ll-1);  pc[ll-1] = '\0';
+mBDrw->ElAddText(mPPos[0], mPPos[1], pc );
+mBDrw->Refresh();
+}
+
+void
+PIScDrawWdg::SetLimits(double xmin, double xmax, double ymin, double ymax,
+                       int axrl, int ayud, bool tmp)
+{
+  if (xmax <= xmin || ymax <= ymin)
+    return; // $CHECK$ exception ?
+  SetDefaultDrawerLimits(xmin, xmax, ymin, ymax, axrl, ayud);
+  mBDrw->SetLimits(xmin, xmax, ymin, ymax, axrl, ayud);
+  mPPos[0] = 0.5*(XMin()+XMax());
+  mPPos[1] = 0.5*(YMin()+YMax());
+  mPSz[0] = 0.05*(XMax()+XMin());
+  mPSz[1] = 0.05*(YMax()+YMin());
+  if (!tmp) {
+    xMinS = xmin;
+    xMaxS = xmax;
+    yMinS = ymin;
+    yMaxS = ymax;
+  }
+}
+  
+void
+PIScDrawWdg::UpdateLimits()
+{
+  if (NbDrawers() < 2)  return;
+  PIDrawer* d = GetDrawer(1);
+  if (d == NULL) return;
+  d->UpdateLimits();
+  SetLimits(d->XMin(), d->XMax(), d->YMin(), d->YMax()); 
+  Refresh();
+  return;  
+}
+
+int 
+PIScDrawWdg::AddScDrawer(PIDrawer* d, bool ad)
+{
+  if (d == NULL)  return(-1);
+  if (! LimitsFixed() ) {  //  On met a jour les limites 
+    d->UpdateLimits();
+    SetLimits(d->XMin(), d->XMax(), d->YMin(), d->YMax());
+  }
+  return(AddDrawer(d, true, ad));
+}
+
+
+void
+PIScDrawWdg::SetTextWin(PILabel * tw, bool trw, int tx, int ty)
+{
+mTxw = tw;
+if (trw)
+  {
+  if (mTrW)  mTrW->SetSize(tx, ty);
+  else
+    {
+    mTrW = new PIWindow(this, "Point", PIWK_transient, tx, ty, 0, 0);
+    mTrW->SetAutoDelChilds(true);
+    mTrlb = new PILabel(mTrW, "PointCoord", tx, ty, 0, 0);
+    mTrlb->SetBinding(PIBK_fixed,PIBK_fixed, PIBK_fixed,PIBK_fixed);
+    }
+  }
+else
+  if (mTrW) { delete mTrW; mTrW = NULL;  mTrlb = NULL; }
+
+return;
+}
+
+
+
+// Gestion affichage coordonnees du point 
+
+string   
+PIScDrawWdg::GetClickText(double x, double y) 
+// Donne le texte a afficher pour position x,y  
+{
+  char buff[128];
+  sprintf(buff, "X= %g  Y= %g",  x, y);
+  //  sprintf(buff, "%.3f,%.3f ",  x, y);
+  return((string)buff);
+}
+
+void
+PIScDrawWdg::ActivateSpecializedControls()
+// Par défaut affiche la fenetres des attributs graphiques et axes
+{
+  PIDrwTools::SetCurrentBaseWdg(this);
+  PIDrwTools::ShowPIDrwTools();   // Fentre axes et options de trace
+}
+
+void
+PIScDrawWdg::UpdateInfoWindow()
+{
+
+if (mInfoW == NULL) { // Creation de la fenetre info
+  string nom = Nom() + "-Info";
+  int tpx, tpy;
+  GetScreenPos(tpx, tpy);
+  int sx, sy;
+  int ssx, ssy;
+  PIApplicationScreenSize(ssx, ssy);
+  if ( (ssx > 1000) && (ssy > 1000) ) { sx = 400;  sy = 200; }
+  else { sx = 300; sy = 160; }
+  mInfoW = new PIWindow(this, nom.c_str(), PIWK_normal,  sx, sy, tpx, tpy+YSize()+10);
+  mInfoW->SetAutoDelChilds(true);
+  nom = Nom() + "-InfoText";
+  mInfoTxt = new PIText(mInfoW, nom.c_str(), true, true, sx, sy, 0, 0);
+  mInfoTxt->SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_fixed);
+  mInfoTxt->SetMutiLineMode(true);
+  mInfoTxt->SetTextEditable(false);
+  }
+
+//  Boucle sur tous les drawers :
+vector<BWDrwId>::iterator it;
+char buff[128];
+sprintf(buff, "Info: NDrawer= %d - Pos=%g %g  (Sz=%g,%g) \n", (int)mDrwList.size()-1, 
+        mPPos[0], mPPos[1], mPSz[0], mPSz[1] );
+double xmin, ymin, xmax, ymax;
+xmin = mPPos[0] - 0.5*mPSz[0];
+xmax = mPPos[0] + 0.5*mPSz[0];
+ymin = mPPos[1] - 0.5*mPSz[1];
+ymax = mPPos[1] + 0.5*mPSz[1];
+
+string info = buff;
+int k=0;
+for(it = mDrwList.begin(); it != mDrwList.end(); it++) {
+  if ((*it).drw == mBDrw )  continue;
+  k++;
+  sprintf(buff," --------- Drawer %d ----------- \n", k); 
+  info += buff; 
+  (*it).drw->AppendTextInfo(info, xmin, ymin, xmax, ymax);
+  }
+
+mInfoW->Show();
+mInfoTxt->Manage();
+mInfoTxt->SetText(info);
+}
+
+// .............................
+// Bouton-1 : Position courante 
+
+void
+PIScDrawWdg::But1Press(int x, int y)
+{
+  UpdateText(x, y);
+  if (mTrW)
+    { 
+    int tpx, tpy;
+    GetScreenPos(tpx, tpy);       
+    tpy -= (mTrW->YSize()+5);
+    if (tpy < 0)  tpy = 0;
+    mTrW->SetPos(tpx, tpy);
+    mTrW->Show();
+    }
+  if (mFgReticule) { // On trace une reticule
+    cForCol = mWGrC->GetForeground();
+    cGOmod  = mWGrC->GetGOMode();
+    cLatt = mWGrC->GetLineAtt();
+    mWGrC->SelForeground(PI_Magenta);
+    mWGrC->SelGOMode(PI_GOXOR);
+    mWGrC->SelLine(PI_ThinLine);
+    mWGrC->DrawLine(x, 0, x, YSize());
+    mWGrC->DrawLine(0, y, XSize(), y);
+    mCPosX = x;   mCPosY = y;
+    char buff[64];
+    sprintf(buff,"%g , %g", mPPos[0], mPPos[1]);
+    mWGrC->DrawString(x+10, y-10, buff); 
+    }
+  else SelPointerShape(PI_CrossPointer);
+
+  Send(Msg(), PIMsg_Active);
+  PIDrwTools::SetCurrentBaseWdg(this);
+}
+
+void
+PIScDrawWdg::Ptr1Move(int x, int y)
+{
+  char buff[64];
+  if (mFgReticule) { // On trace une reticule
+    mWGrC->DrawLine(mCPosX, 0, mCPosX, YSize());
+    mWGrC->DrawLine(0, mCPosY, XSize(), mCPosY);
+    sprintf(buff,"%g , %g", mPPos[0], mPPos[1]);
+    mWGrC->DrawString(mCPosX+10, mCPosY-10, buff); 
+    mWGrC->DrawLine(x, 0, x, YSize());
+    mWGrC->DrawLine(0, y, XSize(), y);
+    mCPosX = x;   mCPosY = y;
+    }  
+  UpdateText(x, y);  // Met a jour mPPos
+  if (mFgReticule) {
+    sprintf(buff,"%g , %g", mPPos[0], mPPos[1]);
+    mWGrC->DrawString(x+10, y-10, buff); 
+    }
+}
+
+void
+PIScDrawWdg::But1Release(int x, int y)
+{
+  UpdateText(x, y);
+  if (mFgReticule) { // On efface la reticule
+    mWGrC->DrawLine(mCPosX, 0, mCPosX, YSize());
+    mWGrC->DrawLine(0, mCPosY, XSize(), mCPosY);
+    char buff[64];
+    sprintf(buff,"%g , %g", mPPos[0], mPPos[1]);
+    mWGrC->DrawString(mCPosX+10, mCPosY-10, buff); 
+    mWGrC->SelForeground(cForCol);
+    mWGrC->SelGOMode(cGOmod);
+    mWGrC->SelLine(cLatt); 
+    mCPosX = mCPosY = 0;
+    }
+  else SelPointerShape(PI_ArrowPointer);
+  if (mTrW)  mTrW->Hide();
+}
+
+void
+PIScDrawWdg::UpdateText(int xp, int yp)
+{
+
+  double dx, dy;
+  mBDrw->GetGraphicUC()->GrC2UC(xp, yp, dx, dy); 
+  mPPos[0] = dx;  mPPos[1] = dy; 
+  
+  string ctxt =  GetClickText(dx, dy);
+//DEBUG  char buff[32];    sprintf(buff, " %d:%d",xp,yp); ctxt += buff;
+  if (mTxw)
+    mTxw->SetLabel(ctxt);
+  if (mTrlb)
+    mTrlb->SetLabel(ctxt);
+  return;
+
+}
+
+// .............................
+// Bouton-2 Gestion du zoom 
+
+void
+PIScDrawWdg::But2Press(int x, int y)
+{
+  xEndDrag = xBegDrag = x;
+  yEndDrag = yBegDrag = y;
+  cForCol = mWGrC->GetForeground();
+  cGOmod  = mWGrC->GetGOMode();
+  cPointer = GetPointerShape();
+  cLatt = mWGrC->GetLineAtt();
+  SelPointerShape(PI_CrossPointer);
+  mWGrC->SelForeground(PI_Magenta);
+  mWGrC->SelGOMode(PI_GOXOR);
+  mWGrC->SelLine(PI_ThinLine);
+  Send(Msg(), PIMsg_Active);
+  PIDrwTools::SetCurrentBaseWdg(this);
+}
+
+void
+PIScDrawWdg::But2Release(int /*x*/, int /*y*/)
+{
+
+  mWGrC->DrawBox(xBegDrag, yBegDrag, xEndDrag-xBegDrag, yEndDrag-yBegDrag);
+
+  mWGrC->SelForeground(cForCol);
+  mWGrC->SelGOMode(cGOmod);
+  SelPointerShape(cPointer); 
+  mWGrC->SelLine(cLatt); 
+
+  //  Pour rendre le changement de zoom moins delicat $REZA - 05/99$  
+  int dxd = xEndDrag-xBegDrag;
+  if (dxd < 0) dxd = -dxd;
+  int dyd = yEndDrag-yBegDrag;
+  if (dyd < 0) dyd = -dyd;
+  //  if (xBegDrag == xEndDrag || yBegDrag == yEndDrag) // $REZA - 05/99$  
+  if ( (dxd < 5) || (dyd < 5) )    // $REZA - 05/99$  
+    SetLimits(xMinS, xMaxS, yMinS, yMaxS, kAxeDirSame, kAxeDirSame );
+  else {
+    double xl,yl,xh,yh;
+    mBDrw->GetGraphicUC()->GrC2UC(xBegDrag, yBegDrag, xl, yl);
+    mBDrw->GetGraphicUC()->GrC2UC(xEndDrag, yEndDrag, xh, yh);
+    if (xl > xh) dbl_swap(xl, xh);
+    if (yl > yh) dbl_swap(yl, yh);
+    SetLimits(xl,xh,yl,yh, kAxeDirSame, kAxeDirSame, true);
+  }
+  
+  Refresh();
+}
+
+void
+PIScDrawWdg::Ptr2Move(int x, int y)
+{
+  mWGrC->DrawBox(xBegDrag, yBegDrag, xEndDrag-xBegDrag, yEndDrag-yBegDrag);
+  xEndDrag = x;
+  yEndDrag = y;
+  mWGrC->DrawBox(xBegDrag, yBegDrag, xEndDrag-xBegDrag, yEndDrag-yBegDrag);
+}
+
+
+// .............................
+// Bouton-3 : Gestion de definition de la taille de rectangle Text-Info
+
+void
+PIScDrawWdg::But3Press(int x, int y)
+{
+  xEndDrag = xBegDrag = x;
+  yEndDrag = yBegDrag = y;
+  cForCol = mWGrC->GetForeground();
+  cGOmod  = mWGrC->GetGOMode();
+  cPointer = GetPointerShape();
+  cLatt = mWGrC->GetLineAtt();
+  SelPointerShape(PI_CrossPointer);
+  mWGrC->SelForeground(PI_Magenta);
+  mWGrC->SelGOMode(PI_GOXOR);
+  mWGrC->SelLine(PI_ThinLine);
+  Send(Msg(), PIMsg_Active);
+  PIDrwTools::SetCurrentBaseWdg(this);
+}
+
+void
+PIScDrawWdg::But3Release(int /*x*/, int /*y*/)
+{
+
+  mWGrC->DrawBox(xBegDrag, yBegDrag, xEndDrag-xBegDrag, yEndDrag-yBegDrag);
+
+  mWGrC->SelForeground(cForCol);
+  mWGrC->SelGOMode(cGOmod);
+  SelPointerShape(cPointer); 
+  mWGrC->SelLine(cLatt); 
+
+  double xl,yl,xh,yh;
+  mBDrw->GetGraphicUC()->GrC2UC(xBegDrag, yBegDrag, xl, yl);
+  mBDrw->GetGraphicUC()->GrC2UC(xEndDrag, yEndDrag, xh, yh);
+  if (xl > xh) dbl_swap(xl, xh);
+  if (yl > yh) dbl_swap(yl, yh);
+  mPPos[0] = 0.5*(xl+xh);
+  mPPos[1] = 0.5*(yl+yh);
+  mPSz[0] = xh-xl;
+  mPSz[1] = yh-yl;
+  mCPosX =  0.5*(xBegDrag+xEndDrag);
+  mCPosY =  0.5*(yBegDrag+yEndDrag);
+
+  return;
+}
+
+void
+PIScDrawWdg::Ptr3Move(int x, int y)
+{
+  mWGrC->DrawBox(xBegDrag, yBegDrag, xEndDrag-xBegDrag, yEndDrag-yBegDrag);
+  xEndDrag = x;
+  yEndDrag = y;
+  mWGrC->DrawBox(xBegDrag, yBegDrag, xEndDrag-xBegDrag, yEndDrag-yBegDrag);
+}
+
+
+// --------------------------------------------------------------------------
+// --------------------------------------------------------------------------
+// --------------------------------------------------------------------------
+// ----------------------------------------------------------
+//  Classe de trace de points/fonctions Y=f(X)
+//  Trace Y=ay->Value() = f(X= ax->Value()) si ax et ay != NULL
+//  Trace Y=ax->Value() = f(X= ax->X())  si ay == NULL
+// ----------------------------------------------------------
+// --------------------------------------------------------------------------
+
+/* --Methode-- */
+PIYfXDrawer::PIYfXDrawer(P1DArrayAdapter* ax, P1DArrayAdapter* ay, bool ad)
+    : PIDrawer()
+{
+  mAdDO = ad;
+  mAx = ax;
+  mAy = ay;
+} 
+
+/* --Methode-- */
+PIYfXDrawer::~PIYfXDrawer()
+{
+  if (mAdDO && mAx)  delete mAx;
+  if (mAdDO && mAy)  delete mAy;
+}
+
+/* --Methode-- */
+void PIYfXDrawer::UpdateLimits()
+{
+  if ((mAx == NULL))  mSz = 0;
+  else {
+    if (!mAy)  mSz = mAx->Size();
+    else   mSz = (mAx->Size() < mAy->Size()) ? mAx->Size() :  mAy->Size();
+    }
+  if (mSz <= 0)  return;
+  double xmin, xmax, ymin, ymax;
+  int i=0;
+  double cv;
+  if (mAy) {
+    xmin = xmax = mAx->Value(0);
+    ymin = ymax = mAy->Value(0);
+    for(i=1; i<mSz; i++) {
+      cv = mAx->Value(i); 
+      if (cv < xmin)  xmin = cv;
+      if (cv > xmax)  xmax = cv;
+      cv = mAy->Value(i); 
+      if (cv < ymin)  ymin = cv;
+      if (cv > ymax)  ymax = cv;
+      }
+    }
+  else {
+    xmin = xmax = mAx->X(0);
+    ymin = ymax = mAx->Value(0);
+    for(i=1; i<mSz; i++) {
+      cv = mAx->X(i); 
+      if (cv < xmin)  xmin = cv;
+      if (cv > xmax)  xmax = cv;
+      cv = mAx->Value(i); 
+      if (cv < ymin)  ymin = cv;
+      if (cv > ymax)  ymax = cv;
+      }
+    }
+
+  double dx, dy;
+  dx = 0.02*(xmax-xmin);
+  dy = 0.02*(ymax-ymin);
+
+  SetLimits(xmin-dx, xmax+dx, ymin-dy, ymax+dy);
+  SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
+}
+
+
+/* --Methode-- */
+void PIYfXDrawer::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
+{
+  double xp,yp;
+  int i;
+
+  if ((mAx == NULL))  mSz = 0;
+  else {
+    if (!mAy)  mSz = mAx->Size();
+    else   mSz = (mAx->Size() < mAy->Size()) ? mAx->Size() :  mAy->Size();
+    }
+  if (mSz <= 0)  return;
+
+//  Trace des markers 
+  if ( (mMrk != PI_NotDefMarker) ||  (mLAtt == PI_NotDefLineAtt) ) {
+    for(i=0; i<mSz; i++) {
+      if (mAy) { xp = mAx->Value(i); yp = mAy->Value(i); }
+      else { xp = mAx->X(i);  yp = mAx->Value(i); }
+      if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) )  continue;
+      g->DrawMarker(xp, yp);
+    }
+  }
+
+  if (mLAtt == PI_NotDefLineAtt)    return;
+
+// Trace des lignes 
+  double xp2, yp2;
+  if (mAy) { xp2 = mAx->Value(0); yp2 = mAy->Value(0); }
+  else { xp2 = mAx->X(0);  yp2 = mAx->Value(0); }
+  for(i=1; i<mSz; i++) {
+    xp = xp2; yp = yp2;
+    if (mAy) { xp2 = mAx->Value(i); yp2 = mAy->Value(i); }
+    else { xp2 = mAx->X(i);  yp2 = mAx->Value(i); }
+    if ( ((xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax)) &&
+         ((xp2 < xmin) || (xp2 > xmax) || (yp2 < ymin) || (yp2 > ymax)) )  continue;
+    g->DrawLine(xp, yp, xp2, yp2);
+  }
+}
+
+
+//================================================================
+// PIFuncDrawer
+// Classe de traceur de fonction  double = f(fouble)
+//================================================================
+
+/* --Methode-- */
+PIFuncDrawer::PIFuncDrawer(PIFuncDrawer::FUNC f)
+: mFunc(f)
+{}
+
+/* --Methode-- */
+PIFuncDrawer::~PIFuncDrawer()
+{
+}
+
+/* --Methode-- */
+void
+PIFuncDrawer::Draw(PIGraphicUC* g, double /*xmin*/, double/*ymin*/, double/*xmax*/, double/*ymax*/)
+{
+  PIGrCoord x1, x2, y1, y2;
+  g->GetGrSpace(x1, x2, y1, y2);
+  double xMax = x2;
+  double xMin = x1;
+  double yMax = y2;
+  double yMin = y1;
+  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) 
+           g->DrawLine(xOld, yOld, x, y);
+    xOld = x;
+    yOld = y;
+  }
+}
Index: /tags/V_LaSilla191199/SophyaPI/PI/piscdrawwdg.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piscdrawwdg.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piscdrawwdg.h	(revision 464)
@@ -0,0 +1,147 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive  PIScDrawWdg PIYfXDrawer
+// Gestionnaire Drawer-2D  E.Aubourg, R. Ansari  96-98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PISCDRAWWDG_H
+#define PISCDRAWWDG_H
+
+#include "pisysdep.h"
+#include PIBWDG_H
+#include PISTDWDG_H
+#include PIWIN_H
+#include "pidrawer.h"
+
+
+// PIScDrawWdg, Gestionnaire de traceur 2D 
+
+class PIScDrawWdg : public PIBaseWdg {
+public:
+  enum {ClassId = 5300};
+
+                     PIScDrawWdg(PIContainerGen *par, const char *nom,
+                                   int sx=100, int sy=100, int px=0, int py=0);
+  virtual            ~PIScDrawWdg();
+
+  virtual long       kind() {return ClassId; }
+  
+  virtual void       SetLimits(double xmin, double xmax, double ymin, double ymax, 
+                               int axrl=kAxeDirSame, int ayud=kAxeDirSame, bool tmp=false);
+  virtual void	     UpdateLimits();  // Calcule et change les limites a partir de Drawer-No-1 
+
+  inline void        SetAxesFlags(unsigned int flags=kBoxAxes | kExtTicks | kLabels) 
+                                  { mBDrw->SetAxesFlags(flags); }
+  inline void	     SetTitles(const char* tt=NULL, const char* tb=NULL)
+                            { mBDrw->SetTitles(tt, tb); }
+  inline void	     SetTitles(string const & tt, string const & tb)
+                            { mBDrw->SetTitles(tt, tb); }
+
+  int                AddScDrawer(PIDrawer*, bool ad=false);   // Ajoute un Drawer en auto 
+  inline PIElDrawer* BaseDrawer() { return mBDrw; };
+
+// Configuration et limites des axes 
+  inline unsigned int GetAxesFlags() { return(mBDrw->GetAxesFlags()); }
+  inline void         GetAxesConfig(int& xa, int& ya) { mBDrw->GetAxesConfig(xa, ya); }
+
+  inline double XMin() const {return mBDrw->XMin();}
+  inline double XMax() const {return mBDrw->XMax();}
+  inline double YMin() const {return mBDrw->YMin();}
+  inline double YMax() const {return mBDrw->YMax();}
+
+  inline double XPPos() const { return mPPos[0]; }
+  inline double YPPos() const { return mPPos[1]; }
+
+  int    LimitsFixed() const {return mBDrw->LimitsFixed();}
+  void   FreeLimits() { mBDrw->FreeLimits(); }
+    
+
+  virtual string     GetClickText(double x, double y); // Donne le texte a afficher pour position x,y
+  virtual void	     ActivateSpecializedControls();   // Pour activer des controles specifiques
+
+  virtual void       UpdateInfoWindow();    // Affiche et met a jour la fenetre info texte
+                                            // concernant le petit pave autour de la pos. courante 
+
+  void               SetTextWin(PILabel * tw, bool trw=true, int tx=300, int ty=30);
+
+  virtual void       But1Press(int x, int y);
+  virtual void       But1Release(int x, int y);
+  virtual void       Ptr1Move(int x, int y);
+
+  virtual void       But2Press(int x, int y);
+  virtual void       But2Release(int x, int y);
+  virtual void       Ptr2Move(int x, int y);
+  
+  virtual void       But3Press(int x, int y);
+  virtual void       But3Release(int x, int y);
+  virtual void       Ptr3Move(int x, int y);
+
+  virtual void       Keyboard(int key, PIKeyModifier kmod);
+  virtual void       PasteSelection(unsigned int typ, void *pdata, unsigned int l);
+  
+protected:
+  double xMinS, xMaxS, yMinS, yMaxS; // Sauvegarde pour zoom
+  double mPPos[2];               // Position courante (user coordinates)
+  double mPSz[2];                // Taille courant du pave info 
+  int mCPosX, mCPosY;              // Position click souris X,Y
+  bool mFgReticule;                // Controle l'affiche d'une réticule (Bouton-1)
+
+  PIElDrawer* mBDrw;
+  
+  int xBegDrag, yBegDrag;
+  int xEndDrag, yEndDrag;
+  PIColors cForCol;
+  PIGOMode cGOmod;  
+  PIPointer cPointer;
+  PILineAtt cLatt;
+  PILabel * mTxw;  
+  PILabel * mTrlb;
+  PIWindow * mTrW;
+
+// Fenetre pour l'affichage des informations 
+  PIWindow * mInfoW;
+  PIText * mInfoTxt;
+
+
+private:
+  void  UpdateText(int xp, int yp);
+};
+
+
+// ----------------------------------------------------------
+// Classe de traceur de points/fonction Y=F(x)
+// Trace Y=ay->Value() = f(X= ax->Value()) si ax et ay != NULL
+// Trace Y=ax->Value() = f(X= ax->X())  si ay == NULL
+ 
+class P1DArrayAdapter;
+class PIYfXDrawer : public PIDrawer {
+public:
+                     PIYfXDrawer(P1DArrayAdapter* ax, P1DArrayAdapter* ay, bool ad);
+  virtual           ~PIYfXDrawer();
+  
+  virtual void       Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
+  virtual void       UpdateLimits();
+  
+       
+protected:
+  P1DArrayAdapter* mAx;
+  P1DArrayAdapter* mAy;
+  int mSz;
+  bool mAdDO;
+};
+
+// ----------------------------------------------------------
+// Classe de traceur de fonction  double = f(fouble)
+// ----------------------------------------------------------
+
+class PIFuncDrawer : public PIDrawer {
+public:
+  typedef double(*FUNC)(double);
+                     PIFuncDrawer(FUNC);
+  virtual           ~PIFuncDrawer();
+  
+  virtual void       Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
+protected:
+  FUNC               mFunc;
+};
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pistdwdggen.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pistdwdggen.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pistdwdggen.cc	(revision 464)
@@ -0,0 +1,287 @@
+#include "pistdwdggen.h"
+
+/************* PILabelGen ************/
+
+//++
+// Class	PILabel
+// Lib		PI
+// include	pistdwdggen.h
+//
+//	Composant graphique simple permettant d'afficher une étiquette (texte).
+//	"PILabelGen" définit l'interface (classe virtuelle pure). Les objets 
+//	instanciés doivent être de la classe "PILabel" déclarée dans le fichier
+//	entête "PISTDWDG_H".
+//--
+//++
+// Links	Parents
+// PIWdg
+//--
+
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+// PILabel(PIContainerGen* par, const char* nom, int sx=10, int sy=10, int px=0, int py=0)
+//	Création d'un objet PILabel ayant un contenu (étiquette) identique à "nom".
+// void SetLabel(string const& lab)
+//	Modifie l'étiquette affichée par l'objet 
+//--
+
+
+
+
+PILabelGen::PILabelGen(PIContainerGen *par, const char *nom,
+                         int sx, int sy, int px, int py)
+: PIWdg(par, nom, sx, sy, px, py)
+{}
+
+PILabelGen::~PILabelGen()
+{}
+
+/************* PIButtonGen ************/
+//++
+// Class	PIButton
+// Lib		PI
+// include	pistdwdggen.h
+//
+//	Composant graphique de type bouton .
+//	"PIButtonGen" définit l'interface (classe virtuelle pure). Les objets 
+//	instanciés doivent être de la classe "PIButton" déclarée dans le fichier
+//	entête "PISTDWDG_H". Lors de l'activation, le message de l'objet complété
+//	par le modifier "PIMsg_Click" est envoyé ("Send()"). Le champ "data" 
+//	contient le pointeur "NULL".
+//--
+//++
+// Links	Parents
+// PIWdg
+//--
+
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+// PIButton(PIContainerGen* par, const char* nom, PIMessage msg, int sx=10, int sy=10, int px=0, int py=0)
+//	Création d'un objet PIButton avec une étiquette identique à "nom".
+// void SetLabel(string const& lab)
+//	Modifie l'étiquette affichée par l'objet bouton.
+//--
+
+
+
+PIButtonGen::PIButtonGen(PIContainerGen *par, const char *nom, PIMessage msg,
+                         int sx, int sy, int px, int py)
+: PIWdg(par, nom, sx, sy, px, py)
+{
+SetMsg(msg);
+}
+
+PIButtonGen::~PIButtonGen()
+{}
+
+
+
+/************* PITextGen ************/
+//++
+// Class	PIText
+// Lib		PI
+// include	pistdwdggen.h
+//
+//	Composant graphique de type champ texte.
+//	"PITextGen" définit l'interface (classe virtuelle pure). Les objets 
+//	instanciés doivent être de la classe "PIText" déclarée dans le fichier
+//	entête "PISTDWDG_H". Si un message non nul a été associé a l'objet 
+//	par "PIWdg::SetMsg(PIMessage msg)", le message correspondant complété
+//	par le modifier "PIMsg_DataChanged" est envoyé ("Send()") lors de 
+//	de la validation du champ texte (touche Retour-Chariot). Le champ "data" 
+//	contient le pointeur "NULL".
+//--
+//++
+// Links	Parents
+// PIWdg
+//--
+
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+//  PIText(PIContainerGen* par, const char* nom, int sx=10, int sy=10, int px=0, int py=0)
+//	Création d'un objet PIText.
+//  PIText(PIContainerGen* par, const char* nom, bool vsb, bool hsb, -
+//  int sx=10, int sy=10, int px=0, int py=0)
+//	Création d'un objet PIText multiligne, muni d'ascenseurs 
+//	Vertical si "vsb == true", horizontal si "hsb == true".
+// void SetText(string const& txt)
+//	Modifie  le contenu du champ texte.
+// string  GetText() const
+//	Renvoie le contenu du champ texte.
+// void  SetMutiLineMode(bool mlm=false)
+//	Active ("mlm=true") ou désactive ("mlm=false") la possibilité d'édition multiligne.
+// void  SetTextEditable(bool te=true)
+//	Permet de rendre le contenu du champ texte non-éditable ("te=false")
+//--
+
+PITextGen::PITextGen(PIContainerGen *par, const char *nom,
+                         int sx, int sy, int px, int py)
+: PIWdg(par, nom, sx, sy, px, py)
+{}
+
+PITextGen::PITextGen(PIContainerGen *par, const char *nom, bool vsb, bool hsb, 
+                         int sx, int sy, int px, int py)
+: PIWdg(par, nom, sx, sy, px, py)
+{}
+
+PITextGen::~PITextGen()
+{}
+
+
+
+
+/************* PICheckBoxGen ************/
+
+PICheckBoxGen::PICheckBoxGen(PIContainerGen *par, const char *nom, PIMessage msg,
+                         int sx, int sy, int px, int py)
+: PIWdg(par, nom, sx, sy, px, py)
+{
+SetMsg(msg);
+}
+
+PICheckBoxGen::~PICheckBoxGen()
+{}
+
+//++
+// Class	PICheckBox
+// Lib		PI
+// include	pistdwdggen.h
+//
+//	Composant graphique de type CheckBox.
+//	"PICheckBoxGen" définit l'interface (classe virtuelle pure). Les objets 
+//	instanciés doivent être de la classe "PICheckBox" déclarée dans le fichier
+//	entête "PISTDWDG_H". Lors du changement d'état, le message de l'objet  
+//	complété par le modifier "PIMsg_DataChanged" est envoyé ("Send()").
+//	Le champ "data" contient un pointeur sur une variable de type "bool"
+//	qui contient l'état de l'objet lors de l'appel à "Send()".
+//--
+//++
+// Links	Parents
+// PIWdg
+//--
+
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+// PICheckBox(PIContainerGen* par, const char* nom,  PIMessage msg, int sx=10, int sy=10, int px=0, int py=0);
+//	Création d'un objet PICheckBox.
+// void SetState(bool st=false)
+//	Modifie l'état de l'objet.
+// bool GetState()
+//	Renvoie l'état de l'objet.
+//--
+
+
+/************* PIScaleGen ************/
+//++
+// Class	PIScale
+// Lib		PI
+// include	pistdwdggen.h
+//
+//	Composant graphique de type échelle ou curseur. (La valeur représentée 
+//	par l'objet peut être modifiée à l'aide d'un curseur).
+//	"PIScaleGen" définit l'interface (classe virtuelle pure). Les objets 
+//	instanciés doivent être de la classe "PIScale" déclarée dans le fichier
+//	entête "PISTDWDG_H". Lors du changement de valeur, le message de l'objet  
+//	complété par le modifier "PIMsg_DataChanged" est envoyé ("Send()").
+//	Le champ "data" contient un pointeur sur une variable de type "int"
+//	qui contient la valeur associée  à l'objet lors de l'appel à "Send()".
+//--
+//++
+// Links	Parents
+// PIWdg
+//--
+
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+// PIScale(PIContainerGen* par, const char* nom, PIMessage msg, int dir=kSDirLtoR, int sx=100, int sy=10, int px=0, int py=0)
+//	Création d'un objet PIScale. "dir" indique la direction et le sens d'affichage et peut
+//	prendre les valeurs "kSDirLtoR" (gauche à droite), "kSDirRtoL" (droite à gauche),
+//	"kSDirDownUp" (bas vers haut) et "kSDirUpDown" (de haut en bas).
+// void  SetMinMax(int min, int max)
+//	Modifie les valeurs extrêmes de l'échelle. L'objet est créé avec des bornes par défaut de 1 à 100.
+// void GetMinMax(int& min, int& max)
+//	Renvoie les valeurs extrêmes de l'échelle.
+// void SetValue(int v)
+//	Modifie la valeur courante de l'échelle.
+// int GetValue()
+//	Renvoie la valeur courante de l'échelle.
+//--
+
+
+PIScaleGen::PIScaleGen(PIContainerGen *par, const char *nom, PIMessage msg, 
+                       int /*dir*/, int sx, int sy, int px, int py)
+: PIWdg(par, nom, sx, sy, px, py) 
+{
+SetMsg(msg);
+}
+
+PIScaleGen::~PIScaleGen()
+{}
+
+/************* PIScrollBarGen ************/
+//++
+// Class	PIScrollBar
+// Lib		PI
+// include	pistdwdggen.h
+//
+//	Composant graphique de type ascenseur. 
+//	"PIScrollBarGen" définit l'interface (classe virtuelle pure). Les objets 
+//	instanciés doivent être de la classe "PIScrollBar" déclarée dans le fichier
+//	entête "PISTDWDG_H". Lors du changement de valeur, le message de l'objet  
+//	complété par le modifier "PIMsg_DataChanged" est envoyé ("Send()").
+//	La méthode "ActivateDrag()" permet d'activer l'envoi de message en 
+//	cours de déplacement du curseur. Dans ce cas, le modifier 
+//	"PIMsg_Drag" est appliqué.
+//	Le champ "data" contient un pointeur sur une variable de type "int"
+//	qui contient la position courante du curseur.
+//--
+//++
+// Links	Parents
+// PIWdg
+//--
+
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+// PIScrollBar(PIContainerGen* par, const char* nom, PIMessage msg, int dir=kSDirUpDown, int sx=10, int sy=100, int px=0, int py=0)
+//	Création d'un objet PIScrollBar. "dir" indique la direction et le sens d'affichage et peut
+//	prendre les valeurs "kSDirLtoR" (gauche à droite), "kSDirRtoL" (droite à gauche),
+//	"kSDirDownUp" (bas vers haut) et "kSDirUpDown" (de haut en bas).
+// void  ActivateDrag(bool acd=false)
+//	Active ("acd=true") ou désactive ("mlm=false") l'envoi de messages lors du mouvement du curseur.
+// void SetMinMax(int min, int max)
+//	Modifie les valeurs extrêmes de l'ascenseur. L'objet est créé avec des bornes par défaut de 1 à 100.
+//	La valeur "max" correspond à la position extrême taille du curseur comprise ("max=posmax+taille").
+// void GetMinMax(int& min, int& max)
+//	Renvoie les valeurs extrêmes de l'ascenseur. 
+// void SetValue(int v)
+//	Modifie la position courante de l'ascenseur.
+// int GetValue()
+//	Renvoie la position courante de l'ascenseur.
+// void  SetSlSize(int sz)
+//	Modifie la taille de l'ascenseur.
+// int  GetSlSize()
+//	Renvoie la taille de l'ascenseur.
+//--
+
+PIScrollBarGen::PIScrollBarGen(PIContainerGen *par, const char *nom, PIMessage msg, 
+                       int /*dir*/, int sx, int sy, int px, int py)
+: PIWdg(par, nom, sx, sy, px, py) 
+{
+SetMsg(msg);
+}
+
+PIScrollBarGen::~PIScrollBarGen()
+{}
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pistdwdggen.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pistdwdggen.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pistdwdggen.h	(revision 464)
@@ -0,0 +1,135 @@
+#ifndef PISTDWDGGEN_H_SEEN
+#define PISTDWDGGEN_H_SEEN
+
+
+#include "pisysdep.h"
+#include PIWDG_H
+
+class PILabelGen : public PIWdg {
+public:
+  enum {ClassId = 1001};
+
+                     PILabelGen(PIContainerGen* par, const char* nom,
+                                 int sx=10, int sy=10, int px=0, int py=0);
+  virtual            ~PILabelGen();
+
+  virtual long       kind() {return ClassId; }
+  virtual void       SetLabel(string const&)=0;
+};
+
+//  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 = 1010};
+
+                     PIButtonGen(PIContainerGen* par, const char* nom, 
+                                 PIMessage msg = PIMsg_Click,
+                                 int sx=10, int sy=10, int px=0, int py=0);
+  virtual            ~PIButtonGen();
+
+  virtual long       kind() {return ClassId; }
+  virtual void       SetLabel(string const&)=0;
+  virtual void       ActivatePress(bool acp=false)=0;
+
+};
+
+
+class PITextGen : public PIWdg
+{
+public:
+
+  enum {ClassId = 1020};
+
+  		     PITextGen(PIContainerGen* par, const char* nom,
+         		       int sx=10, int sy=10, int px=0, int py=0);
+  		     PITextGen(PIContainerGen* par, const char* nom, bool vsb, bool hsb,
+         		       int sx=100, int sy=100, int px=0, int py=0);
+  virtual	     ~PITextGen();
+  virtual void       SetText(string const&) = 0;
+  virtual string     GetText() const = 0;
+
+  virtual void       SetMutiLineMode(bool mlm=false) = 0;
+  virtual void       SetTextEditable(bool te=true) = 0;
+
+  virtual long       kind() {return ClassId; }
+};
+
+
+
+class PICheckBoxGen : public PIWdg
+{
+public:
+
+  enum {ClassId = 1030};
+
+                     PICheckBoxGen(PIContainerGen* par, const char* nom, 
+                                  PIMessage msg = PIMsg_Click,
+                                  int sx=10, int sy=10, int px=0, int py=0);
+  virtual            ~PICheckBoxGen()=0;
+  virtual void       SetState(bool st=false)=0;
+  virtual bool       GetState()=0;
+  
+  virtual long       kind() {return ClassId; }
+
+protected:
+
+};
+
+// Definition choix de la direction et sens pour Scale et Scroll-bar
+enum {
+  kSDirLtoR     = 1,
+  kSDirRtoL     = 2,
+  kSDirDownUp   = 4,
+  kSDirUpDown   = 8
+};
+
+class PIScaleGen : public PIWdg
+{
+public:
+  enum {ClassId = 1040};
+
+                     PIScaleGen(PIContainerGen* par, const char* nom, 
+                                PIMessage msg = PIMsg_DataChanged, int dir=kSDirLtoR, 
+                                int sx=100, int sy=10, int px=0, int py=0);
+  virtual            ~PIScaleGen();
+
+  virtual void       SetMinMax(int min, int max) = 0;
+  virtual void       GetMinMax(int& min, int& max) = 0;
+  virtual void       SetValue(int val) = 0;
+  virtual int        GetValue() = 0; 
+
+  virtual long       kind() {return ClassId; }
+
+protected:
+
+};
+
+class PIScrollBarGen : public PIWdg
+{
+public:
+  enum {ClassId = 1050};
+
+                     PIScrollBarGen(PIContainerGen* par, const char* nom, 
+                                    PIMessage msg=PIMsg_DataChanged, int dir=kSDirUpDown,
+                                    int sx=10, int sy=100, int px=0, int py=0);
+  virtual            ~PIScrollBarGen();
+
+  virtual void       ActivateDrag(bool acd=false) = 0;
+  virtual void       SetMinMax(int min, int max) = 0;
+  virtual void       GetMinMax(int& min, int& max) = 0;
+  virtual void       SetValue(int val) = 0;
+  virtual int        GetValue() = 0; 
+  virtual void       SetSlSize(int sz) = 0;
+  virtual int        GetSlSize() = 0;
+
+  virtual long       kind() {return ClassId; }
+
+protected:
+
+};
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pistdwdgmac.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pistdwdgmac.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pistdwdgmac.cc	(revision 464)
@@ -0,0 +1,344 @@
+#include "pistdwdgmac.h"
+#include <LString.h>
+#include <PP_Messages.h>
+
+/************* PILabelMac ************/
+#include <LCaption.h>
+
+PILabelMac::PILabelMac(PIContainerGen *par, char *nom,
+                         int sx, int sy, int px, int py)
+: PILabelGen(par, nom, sx, sy, px, py)
+{
+  delete mPane;
+  LStr255 titre(nom);
+  mPane = new LCaption(mPaneInfo, titre, 130);
+}
+
+PILabelMac::~PILabelMac()
+{}
+
+
+/************* PIButtonMac ************/
+#include <LStdControl.h>
+
+PIButtonMac::PIButtonMac(PIContainerGen *par, char *nom, PIMessage msg,
+                         int sx, int sy, int px, int py)
+: PIButtonGen(par, nom, msg, sx, sy, px, py)
+{
+  delete mPane;
+  LStr255 titre(nom);
+  mPane = new LStdButton(mPaneInfo, msg_Click, 130, titre);
+  ((LStdButton*)mPane)->AddListener(this);
+}
+
+PIButtonMac::~PIButtonMac()
+{}
+
+void
+PIButtonMac::SetLabel(string const& str)
+{
+  LStr255 sstr(str.c_str());
+  ((LStdButton*)mPane)->SetDescriptor(sstr);
+}
+
+
+void
+PIButtonMac::ListenToMessage(MessageT inMessage, void *)
+{
+  if (inMessage == msg_Click)
+    Send(myMsg, PIMsg_Press);
+}
+
+
+/************* PITextMac ************/
+#include <LEditField.h>
+
+PITextMac::PITextMac(PIContainerGen *par, const char *nom,
+                         int sx, int sy, int px, int py)
+: PITextGen(par, nom, sx, sy, px, py)
+{
+  delete mPane;
+  LStr255 titre(nom);
+  mPane = new LEditField(mPaneInfo, titre, 130, 255, true, true, NULL, LCommander::GetTopCommander());
+}
+
+PITextMac::PITextMac(PIContainerGen *par, const char *nom,
+                     bool vsb, bool hsb,
+                     int sx, int sy, int px, int py)
+: PITextGen(par, nom, vsb, hsb, sx, sy, px, py)
+{
+  delete mPane;
+  LStr255 titre(nom);
+  mPane = new LEditField(mPaneInfo, titre, 130, 255, true, true, NULL, LCommander::GetTopCommander());
+}
+
+
+PITextMac::~PITextMac()
+{}
+
+void
+PITextMac::SetText(string const& s)
+{
+  SetLabel(s);
+}
+
+string
+PITextMac::GetText() const
+{
+  Str255 desc;
+  mPane->GetDescriptor(desc);
+  p2cstr(desc);
+  return (char*) desc;
+}
+
+/* --Methode-- */
+void PITextMac::SetMutiLineMode(bool /*mlm*/)
+{
+return;
+}
+
+/* --Methode-- */
+void PITextMac::SetTextEditable(bool te)
+{
+if (te)
+  { mPane->Enable(); }
+else
+  { mPane->Disable(); }
+return;
+}
+
+/************* PIScaleMac ************/
+static ControlActionUPP	sSBarAction = nil;
+
+
+PIScaleMac::PIScaleMac(PIContainerGen* par, char* nom, PIMessage msg,
+                       bool horiz, int sx, int sy, int px, int py)
+: PIScaleGen(par, nom, msg, horiz, sx, sy, px, py)
+{
+  delete mPane;
+  LStr255 titre(nom);
+  mPane = new LStdControl(mPaneInfo, msg_Click, 1, 1, 10,
+						  scrollBarProc, 130, titre, (Int32) this);
+  ((LStdControl*)mPane)->AddListener(this);
+  
+  if (sSBarAction == nil) {	// Allocate UPP if necessary
+	sSBarAction = NewControlActionProc((ProcPtr) SBarAction);
+  }
+  ((LStdControl*)mPane)->SetActionProc(sSBarAction);
+}
+
+PIScaleMac::~PIScaleMac()
+{}
+
+void
+PIScaleMac::ListenToMessage(MessageT inMessage, void *)
+{
+  if (inMessage == msg_ThumbDragged)
+    Send(myMsg, PIMsg_DataChanged);
+}
+
+void
+PIScaleMac::SetMinMax(int min, int max)
+{
+  ((LStdControl*)mPane)->SetMinValue(min);
+  ((LStdControl*)mPane)->SetMaxValue(max);
+}
+
+void
+PIScaleMac::GetMinMax(int &min, int &max)
+{
+  min = ((LStdControl*)mPane)->GetMinValue();
+  max = ((LStdControl*)mPane)->GetMaxValue();
+}
+
+void
+PIScaleMac::SetValue(int val)
+{
+  StopListening();
+  ((LStdControl*)mPane)->SetValue(val);
+  StartListening();
+}
+
+int
+PIScaleMac::GetValue()
+{
+  return ((LStdControl*)mPane)->GetValue();
+}
+
+pascal void
+PIScaleMac::SBarAction(
+	ControlHandle	inMacControl,
+	Int16			inPart)
+{
+	PIScaleMac		*theScroller =
+							(PIScaleMac *) GetControlReference(inMacControl);
+	theScroller->HandleScroll(inPart);
+}
+
+void
+PIScaleMac::HandleScroll(
+	const Int16		inPart)
+{
+    int delta;
+	switch (inPart) {				// Determine how much to scroll
+	
+		case kControlUpButtonPart:	// Scroll left one unit
+			delta = -1;
+			break;
+			
+		case kControlDownButtonPart:	// Scroll right one unit
+			delta = 1;
+			break;
+			
+		case kControlPageUpPart:		// Scroll left by Frame width
+										//   less one unit of overlap
+			delta = -10;
+			break;
+			
+		case kControlPageDownPart:		// Scroll right by Frame width
+										//   less one unit of overlap
+			delta = 10;
+			break;
+	}
+	
+	if (delta != 0) {
+	    SetValue(GetValue()+delta);
+	}
+}
+
+/************* PIScrollBarMac ************/
+static ControlActionUPP	sSBarAction2 = nil;
+
+
+PIScrollBarMac::PIScrollBarMac(PIContainerGen* par, char* nom, PIMessage msg,
+                       bool vert, int sx, int sy, int px, int py)
+: PIScrollBarGen(par, nom, msg, vert, sx, sy, px, py)
+{
+  delete mPane;
+  LStr255 titre(nom);
+  mPane = new LStdControl(mPaneInfo, msg_Click, 1, 1, 10,
+						  scrollBarProc, 130, titre, (Int32) this);
+  ((LStdControl*)mPane)->AddListener(this);
+  
+  if (sSBarAction2 == nil) {	// Allocate UPP if necessary
+	sSBarAction2 = NewControlActionProc((ProcPtr) SBarAction);
+  }
+  ((LStdControl*)mPane)->SetActionProc(sSBarAction2);
+}
+
+PIScrollBarMac::~PIScrollBarMac()
+{}
+
+void
+PIScrollBarMac::ListenToMessage(MessageT inMessage, void *)
+{
+  if (inMessage == msg_ThumbDragged)
+    Send(myMsg, PIMsg_DataChanged);
+}
+
+void
+PIScrollBarMac::SetMinMax(int min, int max)
+{
+  ((LStdControl*)mPane)->SetMinValue(min);
+  ((LStdControl*)mPane)->SetMaxValue(max);
+}
+
+void
+PIScrollBarMac::GetMinMax(int &min, int &max)
+{
+  min = ((LStdControl*)mPane)->GetMinValue();
+  max = ((LStdControl*)mPane)->GetMaxValue();
+}
+
+
+void
+PIScrollBarMac::SetValue(int val)
+{
+  StopListening();
+  ((LStdControl*)mPane)->SetValue(val);
+  StartListening();
+}
+
+int
+PIScrollBarMac::GetValue()
+{
+  return ((LStdControl*)mPane)->GetValue();
+}
+
+pascal void
+PIScrollBarMac::SBarAction(
+	ControlHandle	inMacControl,
+	Int16			inPart)
+{
+	PIScrollBarMac		*theScroller =
+							(PIScrollBarMac *) GetControlReference(inMacControl);
+	theScroller->HandleScroll(inPart);
+}
+
+void
+PIScrollBarMac::HandleScroll(
+	const Int16		inPart)
+{
+    int delta;
+	switch (inPart) {				// Determine how much to scroll
+	
+		case kControlUpButtonPart:	// Scroll left one unit
+			delta = -1;
+			break;
+			
+		case kControlDownButtonPart:	// Scroll right one unit
+			delta = 1;
+			break;
+			
+		case kControlPageUpPart:		// Scroll left by Frame width
+										//   less one unit of overlap
+			delta = -10;
+			break;
+			
+		case kControlPageDownPart:		// Scroll right by Frame width
+										//   less one unit of overlap
+			delta = 10;
+			break;
+	}
+	
+	if (delta != 0) {
+	    SetValue(GetValue()+delta);
+	}
+}
+
+/************* PICheckBoxMac ************/
+#include <LStdControl.h>
+
+PICheckBoxMac::PICheckBoxMac(PIContainerGen *par, char *nom, PIMessage msg,
+                         int sx, int sy, int px, int py)
+: PICheckBoxGen(par, nom, msg, sx, sy, px, py)
+{
+  delete mPane;
+  LStr255 titre(nom);
+  mPane = new LStdCheckBox(mPaneInfo, msg_Click, 0, 130, titre);
+  ((LStdCheckBox*)mPane)->AddListener(this);
+}
+
+PICheckBoxMac::~PICheckBoxMac()
+{}
+
+void
+PICheckBoxMac::ListenToMessage(MessageT inMessage, void *)
+{
+  if (inMessage == msg_Click)
+    Send(myMsg, PIMsg_DataChanged);
+}
+
+void
+PICheckBoxMac::SetState(bool st)
+{
+  StopListening();
+  ((LStdCheckBox*)mPane)->SetValue(st ? 1 : 0);
+  StartListening();
+}
+ 
+bool
+PICheckBoxMac::GetState()
+{
+  return ((LStdCheckBox*)mPane)->GetValue();
+}
Index: /tags/V_LaSilla191199/SophyaPI/PI/pistdwdgmac.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pistdwdgmac.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pistdwdgmac.h	(revision 464)
@@ -0,0 +1,109 @@
+#ifndef PISTDWDGMAC_H_SEEN
+#define PISTDWDGMAC_H_SEEN
+
+#include "pistdwdggen.h"
+
+
+class PILabelMac : public PILabelGen
+{
+public:
+                     PILabelMac(PIContainerGen *par, char *nom,
+                                 int sx=10, int sy=10, int px=0, int py=0);
+  virtual           ~PILabelMac();
+  virtual void       SetLabel(string const&);
+};
+
+class PIButtonMac : public PIButtonGen
+{
+public:
+                     PIButtonMac(PIContainerGen *par, char *nom, PIMessage msg = PIMsg_Click,
+                                 int sx=10, int sy=10, int px=0, int py=0);
+  virtual           ~PIButtonMac();
+  virtual void       SetLabel(string const&);
+  virtual void	     ListenToMessage(MessageT inMessage, void *ioParam);
+  virtual void       ActivatePress(bool=false) {}
+};
+
+class PITextMac : public PITextGen
+{
+public:
+                     PITextMac(PIContainerGen *par, const char *nom,
+                               int sx=10, int sy=10, int px=0, int py=0);
+                     PITextMac(PIContainerGen *par, const char *nom,
+                               bool vsb, bool hsb,
+                               int sx=10, int sy=10, int px=0, int py=0);
+  virtual           ~PITextMac();
+
+  virtual void       SetMutiLineMode(bool mlm=false);
+  virtual void       SetTextEditable(bool te=true);
+
+  virtual void       SetText(string const&);
+  virtual string     GetText() const;
+};
+
+class PIScaleMac : public PIScaleGen
+{
+public:
+                     PIScaleMac(PIContainerGen* par, char* nom, 
+                                PIMessage msg=PIMsg_DataChanged, bool horiz=true,
+                                int sx=100, int sy=10, int px=0, int py=0);
+                    ~PIScaleMac();
+
+  virtual void       SetMinMax(int min, int max);
+  virtual void       GetMinMax(int& min, int& max);
+  virtual void       SetValue(int val);
+  virtual int        GetValue(); 
+  virtual void	     ListenToMessage(MessageT inMessage, void *ioParam);
+  virtual void	     HandleScroll(const Int16 inPart);
+  
+protected:
+  static pascal void SBarAction(ControlHandle inMacControl,
+								Int16 inPart);
+};
+
+class PIScrollBarMac : public PIScrollBarGen
+{
+public:
+                     PIScrollBarMac(PIContainerGen* par, char* nom, 
+                                PIMessage msg=PIMsg_DataChanged, bool vert=true,
+                                int sx=100, int sy=10, int px=0, int py=0);
+                    ~PIScrollBarMac();
+
+  virtual void       ActivateDrag(bool /*acd*/=false) {};
+  virtual void       SetMinMax(int min, int max);
+  virtual void       GetMinMax(int& min, int& max);
+  virtual void       SetValue(int val);
+  virtual int        GetValue(); 
+  virtual void	     ListenToMessage(MessageT inMessage, void *ioParam);
+  virtual void	     HandleScroll(const Int16 inPart);
+  virtual void       SetSlSize(int sz) {msz = sz;}
+  virtual int        GetSlSize() {return msz;}
+protected:
+  static pascal void SBarAction(ControlHandle inMacControl,
+								Int16 inPart);
+  int msz;
+};
+
+
+class PICheckBoxMac : public PICheckBoxGen
+{
+public:
+                     PICheckBoxMac(PIContainerGen* par, char* nom, 
+                                   PIMessage msg = PIMsg_Click,
+                                   int sx=10, int sy=10, int px=0, int py=0);
+  virtual           ~PICheckBoxMac();
+  virtual void	     ListenToMessage(MessageT inMessage, void *ioParam);
+  virtual void       SetState(bool st=false);
+  virtual bool       GetState();
+};
+
+
+ 
+typedef PILabelMac   PILabel;
+typedef PIButtonMac  PIButton;
+typedef PITextMac    PIText;
+typedef PIScaleMac   PIScale;
+typedef PIScrollBarMac PIScrollBar;
+typedef PICheckBoxMac PICheckBox;
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pistdwdgx.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pistdwdgx.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pistdwdgx.cc	(revision 464)
@@ -0,0 +1,706 @@
+#include<stdlib.h>
+#include<string.h>
+
+#include "pisysdep.h"
+#include PISTDWDG_H
+
+#include "picontainerx.h"
+
+// ------- Pb de gestion du focus-keyboard  Motif-PIBaseWdg -------
+// ** Note du 26/02/98 - Reza 
+// Je desactive pour le moment XmNnavigationType et XmNtraversalOn
+// afin d'ameliorer la gestion du focus-keyboard entre Widget Motif
+// et objet Peida - Cela semble avoir un effet secondaire - 
+// Il faut que la souris reste dans le widget Text pour taper dedans
+// ** Note du 30/04/98 - Reza
+// J'ai modifie le mecanisme de gestion des evenements pour PIBaseWdg
+// en passant par un EventHandler - Le probleme de gestion du 
+// focus-keyboard n'a pour autant pas ete resolu
+// Je reactive XmNtraversalOn pour les PIText - Le probleme 
+// d'attribution du focus-keyboard au PIBaseWdg reste si on 
+// met PIText et un PIBaseWdg ds un meme conteneur
+
+
+/************* PILabelX ************/
+#include <Xm/Label.h>
+
+
+/* --Methode-- */
+PILabelX::PILabelX(PIContainerGen *par, const char *nom,
+                   int sx, int sy, int px, int py)
+: PILabelGen(par, nom, sx, sy, px, py)
+{
+Arg warg[3];
+int n = 0;
+CreateXtWdg(nom, xmLabelWidgetClass, NULL, sx, sy, px, py);
+SetBorderWidth(0);
+XtSetArg(warg[n], XmNrecomputeSize, FALSE); n++;
+XtSetArg(warg[n],XmNnavigationType,XmNONE);  n++;
+XtSetArg(warg[n],XmNtraversalOn,FALSE);  n++;
+XtSetValues(XtWdg(), warg, n);
+Manage();
+}
+
+/* --Methode-- */
+PILabelX::~PILabelX()
+{}
+
+/* --Methode-- */
+void PILabelX::SetLabel(string const& lab)
+{
+XmString xmstr;
+xmstr = XmStringLtoRCreate((char *)lab.c_str(), XmSTRING_DEFAULT_CHARSET);
+int n=0;
+Arg warg[2];
+
+XtSetArg(warg[n], XmNlabelString, xmstr); n++;
+XtSetValues(XtWdg(), warg, n);
+XmStringFree(xmstr);
+return;
+}
+
+
+/************* PIButtonX ************/
+#include <Xm/PushB.h>
+#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 */
+void  button_action(Widget , XtPointer *usd, XtPointer *)
+{
+PIButtonX *pib;
+pib = (PIButtonX *) usd ;
+pib->Send(pib->Msg(),PIMsg_Click,NULL);
+return;
+}
+
+/* Nouvelle-Fonction */
+void  button_press(Widget, XtPointer *usd, XmAnyCallbackStruct *calld)
+{
+PIButtonX *pib;
+pib = (PIButtonX *) usd ;
+pib->Send(pib->Msg(),PIMsg_Press,NULL);
+pib->myevt = *(calld->event);
+pib->myevt.type = pib->myevt.xbutton.type = ButtonRelease;
+pib->myevt.xbutton.serial += 10;
+PIXSetLastEventTimeSerial(calld->event->xbutton.time,  calld->event->xbutton.serial);
+
+return;
+}
+
+
+/* --Methode-- */
+PIButtonX::PIButtonX(PIContainerGen *par, const char *nom, PIMessage msg, 
+                     int sx, int sy, int px, int py)
+: PIButtonGen(par, nom, msg, sx, sy, px, py)
+{
+
+Arg  warg[6];
+int n = 0;
+
+XtSetArg(warg[n],XmNhighlightThickness, 0);  n++;
+XtSetArg(warg[n], XmNrecomputeSize, FALSE);  n++;
+XtSetArg(warg[n],XmNnavigationType,XmNONE);  n++;
+XtSetArg(warg[n],XmNtraversalOn,FALSE);  n++;
+CreateXtWdg(nom, xmPushButtonWidgetClass, NULL, sx, sy, px, py);
+
+/*
+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, 
+              (XtCallbackProc)button_action, (XtPointer)this);
+
+mAcP = false;
+SetBorderWidth(0);
+Manage();
+}
+
+/* --Methode-- */
+PIButtonX::~PIButtonX()
+{}
+
+/* --Methode-- */
+void PIButtonX::SetLabel(string const& lab)
+{
+XmString xmstr;
+xmstr = XmStringLtoRCreate((char *)lab.c_str(), XmSTRING_DEFAULT_CHARSET);
+int n=0;
+Arg warg[2];
+
+XtSetArg(warg[n], XmNlabelString, xmstr); n++;
+XtSetValues(XtWdg(), warg, n);
+XmStringFree(xmstr);
+return;
+}
+
+/* --Methode-- */
+void PIButtonX::ActivatePress(bool acp)
+{
+if (mAcP == acp)  return; 
+    
+if (mAcP)
+  XtRemoveCallback(XtWdg(), XmNarmCallback, 
+                   (XtCallbackProc)button_press, (XtPointer)this);
+else 
+  XtAddCallback(XtWdg(), XmNarmCallback, 
+                (XtCallbackProc)button_press, (XtPointer)this);
+mAcP = acp;
+return;
+}       
+
+
+/* --Methode-- */
+void PIButtonX::ReleaseButton()
+{
+XPutBackEvent(myevt.xbutton.display, &myevt);
+return;
+}
+
+
+/************* PITextX ************/
+#include <Xm/Text.h>
+
+/* --Methode-- */
+PITextX::PITextX(PIContainerGen *par, const char *nom,
+                 int sx, int sy, int px, int py)
+: PITextGen(par, nom, sx, sy, px, py)
+{
+Arg warg[3];
+int n = 0;
+CreateXtWdg(nom, xmTextWidgetClass, NULL, sx, sy, px, py);
+mtext = XtWdg();
+XtSetArg(warg[n],XmNnavigationType,XmNONE);  n++;
+// XtSetArg(warg[n],XmNtraversalOn,FALSE);  n++;
+XtSetValues(mtext, warg, n);
+SetMutiLineMode(false);
+SetTextEditable(true);
+Manage();
+}
+
+/* --Methode-- */
+PITextX::PITextX(PIContainerGen *par, const char *nom, bool vsb, bool hsb,
+                 int sx, int sy, int px, int py)
+: PITextGen(par, nom, vsb, hsb, sx, sy, px, py)
+{
+Arg warg[10];
+int n = 0;
+XtSetArg(warg[n],XmNeditMode, XmMULTI_LINE_EDIT);  n++; 
+XtSetArg(warg[n],XmNscrollBarDisplayPolicy, XmSTATIC); n++;
+XtSetArg(warg[n],XmNnavigationType,XmNONE);  n++;
+if (vsb) 
+  XtSetArg(warg[n],XmNscrollHorizontal, True); n++;
+if (hsb)
+  XtSetArg(warg[n],XmNscrollVertical, True); n++;
+
+// **ATTENTION** Il vaut mieux creer avec les bonnes tailles au depart Reza 09/99 
+//     .....   C'est fait par CreateXtWdg( ... )
+
+XtSetArg(warg[n],XmNwidth,sx);  n++;
+XtSetArg(warg[n],XmNheight,sy);  n++;
+XtSetArg(warg[n],XmNx,px);  n++;
+XtSetArg(warg[n],XmNy,py);  n++;
+
+// XtSetArg(warg[n],XmNtraversalOn,FALSE);  n++;
+
+mtext = XmCreateScrolledText(((PIWdgX *)par)->XtWdg(), (char *)nom, warg, n);   // const_cast
+XtManageChild(mtext);
+XtWdg() = XtParent(mtext); 
+
+// XtWdg() = mtext;   Modif Reza 09/99
+// SetSize(sx, sy);
+// SetPos(px, py);
+
+wmis = k_wmi_normal ;
+stmng = 0;
+
+// **ATTENTION** A ne pas oublier , fait par CreateXtWdg Reza 09/99 
+SetBinding(PIBK_free, PIBK_free, PIBK_free, PIBK_free);
+par->ChildAdd(this);
+
+SetTextEditable(true);
+Manage();
+}
+
+/* --Methode-- */
+PITextX::~PITextX()
+{}
+
+/* --Methode-- */
+void PITextX::SetText(string const& s)
+{
+XmTextSetString(mtext, (char *)s.c_str());
+return;
+}
+
+/* --Methode-- */
+string PITextX::GetText() const
+{
+char *txtb;
+txtb = XmTextGetString(mtext);
+string s(txtb);
+XtFree(txtb);
+return(s);
+}
+
+/* --Methode-- */
+void PITextX::SetMutiLineMode(bool mlm)
+{
+Arg  warg[2];
+int n = 0;
+
+if (mlm)
+  { XtSetArg(warg[n],XmNeditMode, XmMULTI_LINE_EDIT);  n++; }
+else
+  { XtSetArg(warg[n],XmNeditMode, XmSINGLE_LINE_EDIT);  n++; }
+
+XtSetValues(mtext, warg, n);
+return;
+}
+
+/* --Methode-- */
+void PITextX::SetTextEditable(bool te)
+{
+Arg  warg[2];
+int n = 0;
+
+if (te)
+  { XtSetArg(warg[n],XmNeditable, TRUE);  n++; }
+else
+  { XtSetArg(warg[n],XmNeditable, FALSE);  n++; }
+
+XtSetValues(mtext, warg, n);
+return;
+}
+
+// Fonction privee (CallBack)
+static void text_action(Widget w, XtPointer *usd, XtPointer *calld);
+
+void  text_action(Widget, XtPointer *usd, XtPointer *)
+{
+PIText *pit;
+
+pit = (PIText *) usd ;
+pit->Send(pit->Msg(), PIMsg_DataChanged, NULL);
+}
+
+
+/* --Methode-- */
+void PITextX::SetMsg(PIMessage msg)
+{
+
+if (Msg() && !msg)
+  XtRemoveCallback(mtext, XmNactivateCallback, 
+                   (XtCallbackProc)text_action, (XtPointer)this);
+if (!Msg() && msg)
+  XtAddCallback(mtext, XmNactivateCallback, 
+                (XtCallbackProc)text_action, (XtPointer)this);
+
+PIWdg::SetMsg(msg);
+}
+
+
+/************* PICheckBoxX ************/
+#include <Xm/ToggleB.h>
+
+// Fonction prive (CallBack)
+static void toggb_action(Widget w, XtPointer *usd, XmToggleButtonCallbackStruct* calld);
+
+//  Variable globale d'etat de checkbox pour Send(...)
+static bool toggb_state = false;
+
+/* Nouvelle-Fonction */
+void  toggb_action(Widget , XtPointer *usd, XmToggleButtonCallbackStruct* calld)
+{
+PICheckBoxX *picb;
+picb = (PICheckBoxX *) usd ;
+if (calld->set == True)   picb->mSt = true;
+else picb->mSt = false;
+toggb_state = picb->mSt;
+picb->Send(picb->Msg(), PIMsg_DataChanged, (void *)(&toggb_state));
+return;
+}
+
+/* --Methode-- */
+PICheckBoxX::PICheckBoxX(PIContainerGen *par, const char *nom, PIMessage msg,
+                         int sx, int sy, int px, int py)
+: PICheckBoxGen(par, nom, msg, sx, sy, px, py)
+{
+CreateXtWdg(nom, xmToggleButtonWidgetClass, NULL, sx, sy, px, py);
+XtAddCallback(XtWdg(), XmNvalueChangedCallback,
+             (XtCallbackProc) toggb_action, (XtPointer)this);
+Arg warg[4];
+int n = 0;
+XtSetArg(warg[n],XmNhighlightThickness, 0); n++;
+XtSetArg(warg[n],XmNnavigationType,XmNONE);  n++;
+XtSetArg(warg[n],XmNtraversalOn,FALSE);  n++;
+XtSetValues(XtWdg(), warg, n);
+SetState(false);
+Manage();
+}
+
+
+/* --Methode-- */
+PICheckBoxX::~PICheckBoxX()
+{}
+
+
+/* --Methode-- */
+void PICheckBoxX::SetState(bool st)
+{
+Arg warg[2];
+mSt = st;
+if (st) XtSetArg(warg[0],XmNset, True);
+else XtSetArg(warg[0],XmNset, False);
+XtSetValues(XtWdg(), warg, 1);
+return;
+}
+
+/* --Methode-- */
+bool PICheckBoxX::GetState()
+{
+return(mSt);
+}
+
+
+/************* PIScaleX ************/
+#include <Xm/Scale.h>
+
+// Fonction prive (CallBack)
+static void scale_action(Widget w, XtPointer *usd, 
+                         XmScaleCallbackStruct *calld);
+// Variable globale pour contenir valeur de Scale a l'appel de Send;
+static int scale_value=0;
+ 
+void  scale_action(Widget, XtPointer *usd, 
+                         XmScaleCallbackStruct *calld)
+{
+PIScale *pis;
+
+pis = (PIScale *) usd ;
+pis->CBSetVal(calld->value);
+scale_value = calld->value;
+pis->Send(pis->Msg(), PIMsg_DataChanged, (void *)(&scale_value));
+return;
+}
+
+/* --Methode-- */
+PIScaleX::PIScaleX(PIContainerGen *par, const char *nom, PIMessage msg,
+                   int dir, int sx, int sy, int px, int py)
+: PIScaleGen(par, nom, msg, dir, sx, sy, px, py)
+{
+int n=0;
+Arg warg[8];
+XtSetArg(warg[n], XmNshowValue, TRUE); n++;
+XtSetArg(warg[n],XmNnavigationType,XmNONE);  n++;
+XtSetArg(warg[n],XmNtraversalOn,FALSE);  n++;
+if (dir == kSDirLtoR) {
+  XtSetArg(warg[n], XmNorientation, XmHORIZONTAL); n++;
+  XtSetArg(warg[n], XmNprocessingDirection, XmMAX_ON_RIGHT); n++;
+  }
+else if (dir == kSDirRtoL) {
+  XtSetArg(warg[n], XmNorientation, XmHORIZONTAL); n++;
+  XtSetArg(warg[n], XmNprocessingDirection, XmMAX_ON_LEFT); n++;
+  }
+else if (dir == kSDirDownUp) {
+  XtSetArg(warg[n], XmNorientation, XmVERTICAL); n++;
+  XtSetArg(warg[n], XmNprocessingDirection, XmMAX_ON_TOP); n++;
+  }
+else { // kSDirUpDown
+  XtSetArg(warg[n], XmNorientation, XmVERTICAL); n++;
+  XtSetArg(warg[n], XmNprocessingDirection, XmMAX_ON_BOTTOM); n++;
+  }
+// Il ne faut pas attribuer une valeur a XmNscaleWidth et XmNscaleHeight
+// Elles sont calculees automatiquement et repondent alors correctement aux resize
+// (Il faut laisser donc leur valeur par defaut=0)   Reza 28/10/98 
+// XtSetArg(warg[n], XmNscaleWidth, sx); n++;
+// XtSetArg(warg[n], XmNscaleHeight, sy); n++;
+// XtSetArg(warg[n], XmNstringDirection, XmSTRING_DIRECTION_R_TO_L); n++;
+CreateXtWdg(nom, xmScaleWidgetClass, NULL, sx, sy, px, py, warg, n);
+
+SetMinMax(1, 100);
+SetValue(1);
+
+XtAddCallback(XtWdg(), XmNvalueChangedCallback, 
+             (XtCallbackProc) scale_action, (XtPointer)this);
+Manage();
+}
+
+/* --Methode-- */
+PIScaleX::~PIScaleX()
+{}
+
+/* --Methode-- */
+void PIScaleX::SetMinMax(int min, int max)
+{
+if (min >= max)  max = min+10;
+if (mVal < min)  mVal = min;
+if (mVal > max)  mVal = max;
+int n=0;
+Arg warg[3];
+XtSetArg(warg[n], XmNminimum, min); n++;
+XtSetArg(warg[n], XmNmaximum, max); n++;
+XtSetArg(warg[n], XmNvalue, mVal); n++;
+XtSetValues(XtWdg(), warg, n);
+mMin = min;   mMax = max;
+return;
+}
+
+/* --Methode-- */
+void PIScaleX::GetMinMax(int& min, int& max)
+{
+min = mMin;   max = mMax;
+return;
+}
+
+/* --Methode-- */
+void PIScaleX::SetValue(int val)
+{
+int n=0;
+if (val < mMin)  val = mMin;
+if (val > mMax)  val = mMax;
+Arg warg[2];
+XtSetArg(warg[n], XmNvalue, val); n++;
+XtSetValues(this->sdw, warg, n);
+return;
+}
+
+/* --Methode-- */
+int  PIScaleX::GetValue()
+{
+int val;
+int n=0;
+Arg warg[2];
+XtSetArg(warg[n], XmNvalue, &val); n++;
+XtGetValues(this->sdw, warg, n);
+mVal = val;
+return(mVal);
+}
+
+/* --Methode-- */
+void  PIScaleX::CBSetVal(int val)
+{
+mVal = val;
+return;
+}
+
+
+
+/************* PIScrollBarX ************/
+
+#include <Xm/ScrollBar.h>
+
+// Fonction prive (CallBack)
+static void scrollbar_action(Widget w, XtPointer *usd, 
+                             XmScrollBarCallbackStruct *calld);
+static void scrollbar_drag(Widget w, XtPointer *usd, 
+                           XmScrollBarCallbackStruct *calld);
+// Variable globale pour contenir valeur de Scale a l'appel de Send;
+static int scroll_value=0;
+
+void  scrollbar_action(Widget, XtPointer *usd, 
+                       XmScrollBarCallbackStruct *calld)
+{
+PIScrollBar *pis;
+
+pis = (PIScrollBar *) usd ;
+pis->CBSetVal(calld->value);
+pis->Send(pis->Msg(), PIMsg_DataChanged, (void *)(&scroll_value));
+return;
+}
+
+void  scrollbar_drag(Widget, XtPointer *usd, 
+                       XmScrollBarCallbackStruct *calld)
+{
+PIScrollBar *pis;
+
+pis = (PIScrollBar *) usd ;
+pis->CBSetVal(calld->value);
+pis->Send(pis->Msg(), PIMsg_Drag, (void *)(&scroll_value));
+return;
+}
+
+/* --Methode-- */
+PIScrollBarX::PIScrollBarX(PIContainerGen *par, const char *nom, PIMessage msg,
+                           int dir, int sx, int sy, int px, int py)
+: PIScrollBarGen(par, nom, msg, dir, sx, sy, px, py)
+{
+int n=0;
+Arg warg[6];
+
+XtSetArg(warg[n],XmNnavigationType,XmNONE);  n++;
+XtSetArg(warg[n],XmNtraversalOn,FALSE);  n++;
+if (dir == kSDirLtoR) {
+  XtSetArg(warg[n], XmNorientation, XmHORIZONTAL); n++;
+  XtSetArg(warg[n], XmNprocessingDirection, XmMAX_ON_RIGHT); n++;
+  }
+else if (dir == kSDirRtoL) {
+  XtSetArg(warg[n], XmNorientation, XmHORIZONTAL); n++;
+  XtSetArg(warg[n], XmNprocessingDirection, XmMAX_ON_LEFT); n++;
+  }
+else if (dir == kSDirDownUp) {
+  XtSetArg(warg[n], XmNorientation, XmVERTICAL); n++;
+  XtSetArg(warg[n], XmNprocessingDirection, XmMAX_ON_TOP); n++;
+  }
+else { // kSDirUpDown
+  XtSetArg(warg[n], XmNorientation, XmVERTICAL); n++;
+  XtSetArg(warg[n], XmNprocessingDirection, XmMAX_ON_BOTTOM); n++;
+  }
+CreateXtWdg(nom, xmScrollBarWidgetClass, NULL, sx, sy, px, py, warg, n);
+mAcD = false;
+mVal = -1;
+mMin = mMax = 0;
+mSz = 10;
+mDir = dir;
+SetMinMax(1, 100);
+SetSlSize(10);
+SetValue(1);
+XtAddCallback(XtWdg(), XmNvalueChangedCallback, 
+             (XtCallbackProc) scrollbar_action, (XtPointer)this);
+Manage();
+}
+
+/* --Methode-- */
+PIScrollBarX::~PIScrollBarX()
+{}
+
+
+/* --Methode-- */
+void PIScrollBarX::ActivateDrag(bool acd)
+{
+if (mAcD == acd)  return; 
+    
+if (mAcD)
+  XtRemoveCallback(XtWdg(), XmNdragCallback, 
+                   (XtCallbackProc)scrollbar_drag, (XtPointer)this);
+else 
+  XtAddCallback(XtWdg(), XmNdragCallback, 
+                (XtCallbackProc)scrollbar_drag, (XtPointer)this);
+mAcD = acd;
+return;
+}       
+
+/* --Methode-- */
+void PIScrollBarX::SetMinMax(int min, int max)
+{
+if (min >= max)  max = min+100;
+if (mVal < min)  mVal = min;
+if (mVal > max-mSz)  mVal = max-mSz;
+//DBG printf("PIScrollBarX::SetMinMax(%d %d )  %d  Sz=%d \n", min, max, mVal, mSz);
+int n=0;
+Arg warg[3];
+XtSetArg(warg[n], XmNminimum, min); n++;
+XtSetArg(warg[n], XmNmaximum, max); n++;
+XtSetArg(warg[n], XmNvalue, mVal); n++;
+XtSetValues(XtWdg(), warg, n);
+mMin = min;   mMax = max;
+//DBG printf("--OUT-OF-- PIScrollBarX::SetMinMax(%d %d )  %d  Sz=%d \n", min, max, mVal, mSz);
+return;
+}
+
+/* --Methode-- */
+void PIScrollBarX::GetMinMax(int& min, int& max)
+{
+min = mMin;   max = mMax;
+return;
+}
+
+/* --Methode-- */
+void PIScrollBarX::SetValue(int val)
+{
+int n=0;
+if (val < mMin)  val = mMin;
+if (val > mMax-mSz)  val = mMax-mSz;
+Arg warg[2];
+//DBG printf("PIScrollBarX::SetValue(%d -> %d) \n", val, val0);
+XtSetArg(warg[n], XmNvalue, val); n++;
+XtSetValues(this->sdw, warg, n);
+mVal = val;
+//DBG printf("--OUT-OF---PIScrollBarX::SetValue(%d -> %d) \n", val, val0);
+return;
+}
+
+/* --Methode-- */
+int  PIScrollBarX::GetValue()
+{
+int val;
+int n=0;
+Arg warg[2];
+XtSetArg(warg[n], XmNvalue, &val); n++;
+XtGetValues(this->sdw, warg, n);
+mVal = val;
+return(mVal);
+}
+
+/* --Methode-- */
+void PIScrollBarX::SetSlSize(int sz)
+{
+int n=0;
+Arg warg[4];
+int szl;
+
+szl = mMax-mMin;
+if (sz > szl)  sz = szl;
+szl /= 100;
+if (szl < 1)  szl = 1;
+if (sz < szl)  sz = szl;
+szl = sz/10;
+if (szl < 1)  szl = 1;
+//DBG printf("PIScrollBarX::SetSlSize(%d ) \n", sz);
+XtSetArg(warg[n], XmNsliderSize, sz); n++;
+XtSetArg(warg[n], XmNpageIncrement, sz); n++;
+XtSetArg(warg[n], XmNincrement, szl); n++;
+if (mVal < mMin)  mVal = mMin;
+if (mVal > mMax-sz)  mVal = mMax-sz;
+XtSetArg(warg[n], XmNvalue, mVal); n++;
+XtSetValues(this->sdw, warg, n);
+//DBG printf("---OUT-OF---PIScrollBarX::SetSlSize(%d ) -> mVal= %d (cv1,2=%d %d)\n", sz,mVal, cv1, cv2);
+mSz = sz;
+return;
+}
+
+/* --Methode-- */
+int  PIScrollBarX::GetSlSize()
+{
+int sz;
+int n=0;
+Arg warg[2];
+XtSetArg(warg[n], XmNsliderSize, &sz); n++;
+XtGetValues(this->sdw, warg, n);
+mSz = sz;
+return(mSz);
+}
+
+
+/* --Methode-- */
+void  PIScrollBarX::CBSetVal(int val)
+{
+mVal = val;
+scroll_value = mVal;
+//DBG printf("PIScrollBarX::CBSetVal(%d) %d -> %d \n", mDir, val, mVal);
+return;
+}
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pistdwdgx.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pistdwdgx.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pistdwdgx.h	(revision 464)
@@ -0,0 +1,127 @@
+#ifndef PISTDWDGX_H_SEEN
+#define PISTDWDGX_H_SEEN
+
+#include "pistdwdggen.h"
+
+
+class PILabelX : public PILabelGen
+{
+public:
+                     PILabelX(PIContainerGen *par, const char *nom,
+                                 int sx=10, int sy=10, int px=0, int py=0);
+  virtual            ~PILabelX();
+  virtual void       SetLabel(string const&);
+  
+};
+
+class PIButtonX : public PIButtonGen
+{
+public:
+                     PIButtonX(PIContainerGen *par, const char *nom, 
+                               PIMessage msg = PIMsg_Click,
+                               int sx=10, int sy=10, int px=0, int py=0);
+  virtual            ~PIButtonX();
+
+  virtual void       ActivatePress(bool acp=false);
+  virtual void       SetLabel(string const&);
+
+  void               ReleaseButton();   // Fonction a utiliser avec attention
+
+  XEvent myevt;   // Attention - Pour usage interne 
+
+protected :
+  bool mAcP;
+};
+
+
+class PITextX : public PITextGen
+{
+public:
+                     PITextX(PIContainerGen *par, const char *nom, 
+                                  int sx=10, int sy=10, int px=0, int py=0);
+  		     PITextX(PIContainerGen* par, const char* nom, bool vsb, bool hsb,
+         		     int sx=100, int sy=100, int px=0, int py=0);
+  virtual            ~PITextX();
+  virtual void       SetText(string const&);
+  virtual string     GetText() const;
+
+  virtual void       SetMutiLineMode(bool mlm=false);
+  virtual void       SetTextEditable(bool te=true);
+
+  virtual void       SetMsg(PIMessage msg=0);
+
+protected:
+
+SysDWdg mtext;  
+};
+
+
+class PICheckBoxX : public PICheckBoxGen
+{
+public:
+                     PICheckBoxX(PIContainerGen *par, const char *nom, 
+                                 PIMessage msg=PIMsg_Click,
+                                 int sx=10, int sy=10, int px=0, int py=0);
+  virtual            ~PICheckBoxX();
+
+  virtual void       SetState(bool st=false);
+  virtual bool       GetState();
+
+  bool mSt;          // Etat du bouton, en public a cause du Callback
+};
+
+
+
+class PIScaleX : public PIScaleGen
+{
+public:
+                     PIScaleX(PIContainerGen* par, const char* nom, 
+                              PIMessage msg=PIMsg_DataChanged, int dir=kSDirLtoR, 
+                              int sx=100, int sy=10, int px=0, int py=0);
+  virtual            ~PIScaleX();
+
+  virtual void       SetMinMax(int min, int max);
+  virtual void       GetMinMax(int& min, int& max);
+  virtual void       SetValue(int val);
+  virtual int        GetValue(); 
+
+  virtual void       CBSetVal(int val);   // A ne pas utiliser (pour Callback Xt)
+protected: 
+  int mVal, mMin, mMax;
+};
+
+
+
+class PIScrollBarX : public PIScrollBarGen
+{
+public:
+                     PIScrollBarX(PIContainerGen* par, const char* nom, 
+                                  PIMessage msg = PIMsg_DataChanged, int dir=kSDirUpDown,
+                                  int sx=10, int sy=100, int px=0, int py=0);
+                     ~PIScrollBarX();
+
+  virtual void       ActivateDrag(bool acd=false);
+  virtual void       SetMinMax(int min, int max);
+  virtual void       GetMinMax(int& min, int& max);
+  virtual void       SetValue(int val);
+  virtual int        GetValue(); 
+  virtual void       SetSlSize(int sz);
+  virtual int        GetSlSize();
+
+  virtual void       CBSetVal(int val);   // A ne pas utiliser (pour Callback Xt)
+
+protected: 
+  int mVal, mMin, mMax, mSz, mDir;
+  bool mAcD;
+};
+
+
+typedef PILabelX       PILabel;
+typedef PIButtonX      PIButton;
+typedef PITextX        PIText;
+typedef PICheckBoxX    PICheckBox;
+typedef PIScaleX       PIScale;
+typedef PIScrollBarX   PIScrollBar;
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pistzwin.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pistzwin.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pistzwin.cc	(revision 464)
@@ -0,0 +1,373 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive  - Zone/Stack Layout
+// PIStackLayout , PIZone Layout , PIStackWindow , PIZoneWindow
+//                             R. Ansari  08/98
+
+#include <stdio.h>
+
+#include "pistzwin.h"
+#include "psfile.h"
+
+// -------------- Classe PIStackLayout --------------
+
+//++
+// Class	PIStackLayout
+// Lib		PI
+// include	pistzwin.h
+//
+//	Classe de gestionnaire de "PIWdg" dans un conteneur avec un seul 
+//	"PIWdg" visible à un moment donné. Permet d'empiler plusieurs
+//	objet dans une fenêtre, et passer de l'un à l'autre.
+//--
+//++
+// Links	Parent
+// PILayoutMgr
+//--
+
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+// PIStackLayout()
+// 	Constructeur
+// PIWdg*  CurrentWdg() 
+//	Retourne l'objet "PIWdg" visible au moment de l'appel.
+// int NumCurrentWdg()
+//	Retourne le numéro de l'objet "PIWdg" visible au moment de l'appel.
+// void  DispNext()
+//	Affiche l'objet "PIWdg" suivant.
+// void  DispWdgNum(int n)
+//	Affiche l'objet "PIWdg" numéro "n".
+//--
+
+/* --Methode-- */
+PIStackLayout::PIStackLayout()
+	: PILayoutMgr()
+{
+mCurdisp = -1;
+}
+
+/* --Methode-- */
+PIStackLayout::~PIStackLayout()
+{
+}
+
+/* --Methode-- */
+void PIStackLayout::ChildAdd(PIWdg* child)
+{
+int k;
+for(k=0; k<NbChilds(); k++) GetChild(k)->UnManage();
+PILayoutMgr::ChildAdd(child);
+child->Manage();
+mCurdisp = NbChilds()-1;
+return;
+}
+
+/* --Methode-- */
+void PIStackLayout::ChildDel(PIWdg* child)
+{
+int k;
+for(k=0; k<NbChilds(); k++) GetChild(k)->UnManage();
+PILayoutMgr::ChildDel(child);
+if (NbChilds() > 0) {
+  mCurdisp--;
+  if (mCurdisp < 0)  mCurdisp = 0;
+  if (mCurdisp > NbChilds()) mCurdisp = NbChilds()-1; 
+  GetChild(mCurdisp)->Manage();
+  }
+else mCurdisp = -1;
+return;
+}
+
+/* --Methode-- */
+void PIStackLayout::DispNext()
+{
+if (NbChilds() < 1) return;
+int n = (mCurdisp+1)%NbChilds();
+DispWdgNum(n);
+}
+
+/* --Methode-- */
+void PIStackLayout::DispWdgNum(int n)
+{
+if ( (n < 0) || (n >= NbChilds()) )  return;
+for(int k=0; k<NbChilds(); k++) GetChild(k)->UnManage();
+mCurdisp = n;
+GetChild(mCurdisp)->Manage();
+return;
+}
+
+
+// -------------- Classe PIStackWindow --------------
+
+// Fonction de l'objet PIPeriodic de PIStackWindow
+static void myadperpact(void* a);
+
+void myadperpact(void* a)
+{
+((PIStackWindow*)a)->DispNext();
+}
+
+//++
+// Class	PIStackWindow
+// Lib		PI
+// include	pistzwin.h
+//
+//	Classe de fenêtre ("PIWindow") avec le "PIStackLayout".
+//	Le "PILayoutMgr" ne peut être changé.
+//--
+//++
+// Links	Parent
+// PIWindow
+//--
+//++
+// Links	Voir aussi
+// PIStackLayout
+//--
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+// PIStackWindow(PIMsgHandler* par, const char* nom, PIWindowKind k=PIWK_normal, int sx=100, int sy=100, int px=0, int py=0)
+// 	Constructeur - identique à celui de "PIWindow"
+// void  DispNext()
+//	Affichage du "PIWdg" suivant.
+// PIWdg* CurrentWdg()
+//	Retourne l'objet "PIWdg" courant.
+// void  StartAutoDisp(int dtms=1000)
+//	Démarre  l'affichage cyclique automatique avec l'intervalle en temps 
+//	"dtms" spécifié en millisecondes.
+// void  StopAutoDisp()
+//	Arrête l'affichage cyclique automatique.
+// void  PSPrint(PSFile *psf, int ofx=0, int ofy=0)
+//	Rajoute tous les "PIWdg" associés à la fenêtre à l'objet
+//	"PSFile" (fichier PostScript), un objet par page.
+//--
+
+/* --Methode-- */
+PIStackWindow::PIStackWindow(PIMsgHandler* par, const char* nom, PIWindowKind k,
+                             int sx, int sy, int px, int py)
+        : PIWindow(par, nom, k, sx, sy, px, py) , mPerad(1)
+{
+mPerad.SetAction(myadperpact, this);
+delete layout;
+layout = new PIStackLayout;
+layout->SetContainer(this); 
+} 
+
+
+/* --Methode-- */
+PIStackWindow::~PIStackWindow()
+{
+mPerad.Stop();
+Hide();
+}
+
+/* --Methode-- */
+void PIStackWindow::SetLayoutMgr(PILayoutMgr*)
+{
+fprintf(stderr, "PIStackWindow::SetLayoutMgr() - LayoutMgr cannot be changed \n");
+return;
+}
+
+/* --Methode-- */
+void PIStackWindow::PSPrint(PSFile *psf, int ofx, int ofy)
+{
+if (!psf) return;
+int k;
+for(k=0; k<NbChilds(); k++) { 
+  psf->NewPage((double)XSize(), (double)YSize(),PI_Auto);
+  GetChild(k)->PSPrint(psf, ofx, ofy);
+  }
+}
+
+
+/* --Methode-- */
+void PIStackWindow::StartAutoDisp(int dtms)
+{
+mPerad.SetIntervalms(dtms);
+mPerad.Start();
+}
+
+/* --Methode-- */
+void PIStackWindow::StopAutoDisp()
+{
+mPerad.Stop();
+}
+
+//-------------------- Classe PIZoneLayout ------------------------------
+//++
+// Class	PIZoneLayout
+// Lib		PI
+// include	pistzwin.h
+//
+//	Classe de gestionnaire de "PIWdg" dans un conteneur, 
+//	divisé en cellule horizotale-verticale.
+//	En cas d'ajout d'un objet dans une cellule déjà occupée,
+//	l'objet est supprimé si "SetAutoDelChilds(true)", 
+//	sinon "UnManage()" est appelé pour cet objet.
+//--
+//++
+// Links	Parent
+// PILayoutMgr
+//--
+
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+// PIZoneLayout(int nzx, int nzy)
+// 	Constructeur. Subdivision en "nzx" cellules horizontales,
+//	"nzy" cellules verticales.
+// void SetZone(int nzx, int nzy)
+//	Modification du découpage en cellules.
+// void  NbZone(int& nzx, int& nzy)
+//	Retourne le nombre de cellules verticale-horizontale.
+// PIWdg* NextChildPosSize(int& px, int& py, int& sx, int& sy)
+//	Retourne la position et la taille d'un eventuel objet "PIWdg"
+//	ajouté. Retourne le "PIWdg" actuellement dans cette cellule.
+//-- 
+
+/* --Methode-- */
+PIZoneLayout::PIZoneLayout(int nzx, int nzy)
+	: PILayoutMgr()
+{
+mZWdg = NULL;
+SetZone(nzx, nzy);
+}
+
+/* --Methode-- */
+PIZoneLayout::~PIZoneLayout()
+{
+delete[] mZWdg;
+}
+
+
+/* --Methode-- */
+void PIZoneLayout::SetZone(int nzx, int nzy)
+{
+int i;
+if (mZWdg) {
+  for(i=0; i<mZx*mZy; i++) 
+    if (mZWdg[i]) delete mZWdg[i];  
+  delete[]  mZWdg;
+  }
+
+if (nzx < 1) nzx = 1;
+if (nzy < 1) nzy = 1;
+if (nzx > 50) nzx = 50;
+if (nzx > 50) nzx = 50;
+mZx = nzx;  mZy = nzy;   mZc = 0;
+
+mZWdg = new PIWdg*[nzx*nzy];
+for(i=0; i<mZx*mZy; i++) mZWdg[i] = NULL; 
+}
+
+
+/* --Methode-- */
+void PIZoneLayout::ChildAdd(PIWdg * child)
+{
+if (!child) return;
+int nx = mZc%mZx;
+int ny = mZc/mZx;
+PILayoutMgr::ChildAdd(child);
+child->SetBinding(PIBK_free,PIBK_free,PIBK_free, PIBK_free);
+int sx = mCont->XSize()/mZx;
+int sy = mCont->YSize()/mZy;
+child->SetPos(nx*sx, ny*sy);
+child->SetSize(sx, sy);
+child->SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic, PIBK_elastic);
+child->LockBinding();
+//  Il faut faire le delete a cet endroit, sinon probleme avec widget motif XmForm  Reza 18/08/98
+if (mZWdg[mZc])  { 
+  if (mACSup) delete mZWdg[mZc]; 
+  else mZWdg[mZc]->UnManage();
+  }
+mZWdg[mZc] = child;
+mZc = (mZc+1)%(mZx*mZy);
+}
+
+/* --Methode-- */
+void PIZoneLayout::ChildDel(PIWdg * child)
+{
+if (!child)  return;
+int k;
+for(k=0; k<mZx*mZy; k++) 
+  if (mZWdg[k] == child) mZWdg[k] = NULL;  
+PILayoutMgr::ChildDel(child);
+return;
+}
+
+/* --Methode-- */
+void PIZoneLayout::NbZone(int& nzx, int& nzy)
+{
+nzx = mZx;   nzy = mZy;
+}
+
+/* --Methode-- */
+PIWdg* PIZoneLayout::NextChildPosSize(int& px, int& py, int& sx, int& sy)
+{
+sx = mCont->XSize()/mZx;
+sy = mCont->YSize()/mZy;
+int nx = mZc%mZx;
+int ny = mZc/mZx;
+px = nx*sx;  py = ny*sy;
+return ((PIWdg*)mZWdg[mZc]);
+}
+
+
+//-------------------- Classe PIZoneWindow ------------------------------
+//++
+// Class	PIZoneWindow
+// Lib		PI
+// include	pistzwin.h
+//
+//	Classe de fenêtre ("PIWindow") avec le "PIZoneLayout".
+//	Le "PILayoutMgr" ne peut être changé.
+//--
+//++
+// Links	Parent
+// PIWindow
+//--
+//++
+// Links	Voir aussi
+// PIZoneLayout
+//--
+//++
+// Titre	Constructeur, méthodes
+//--
+//++
+// PIZoneWindow(PIMsgHandler* par, const char* nom, PIWindowKind k=PIWK_normal, -
+//              int nzx=1, int nzy=1, int sx=100, int sy=100, int px=0, int py=0)
+// 	Constructeur avec spécification de nombre de cellules horizontal "nzx", vertical "nzy".
+// void  SetZone(int nzx, int nzy)
+//	Modification du découpage en cellules.
+// void NbZone(int& nzx, int& nzy)
+//	Retourne le nombre de cellules verticale-horizontale.
+// PIWdg* NextChildPosSize(int& px, int& py, int& sx, int& sy)
+//	Appel à " PIZoneLayout::NextChildPosSize(...) "
+//--
+
+/* --Methode-- */
+PIZoneWindow::PIZoneWindow(PIMsgHandler* par, const char* nom, PIWindowKind k,
+                           int nzx, int nzy, int sx, int sy, int px, int py)
+        : PIWindow(par, nom, k, sx, sy, px, py)
+{
+delete layout;
+layout = new PIZoneLayout(nzx, nzy);
+layout->SetContainer(this); 
+}
+
+/* --Methode-- */
+PIZoneWindow::~PIZoneWindow()
+{
+Hide();
+}
+
+/* --Methode-- */
+void PIZoneWindow::SetLayoutMgr(PILayoutMgr*)
+{
+fprintf(stderr, "PIZoneWindow::SetLayoutMgr() - LayoutMgr cannot be changed \n");
+return;
+}
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pistzwin.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pistzwin.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pistzwin.h	(revision 464)
@@ -0,0 +1,95 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive  PIStackWindow  PIZoneWindow
+//                             R. Ansari  08/98
+
+#ifndef PISTZWIN_H_SEEN
+#define PISTZWIN_H_SEEN
+
+#include "pisysdep.h"
+#include PIWIN_H
+#include PIPERIODIC_H
+
+// ----------------------- Classe PIStackLayout ----------------------------
+// Pour Fenetre de type empilement , tout widget occupe la totalite 
+// de la fenetre - Un seul des widget visible (active) a chaque moment
+
+class PIStackLayout : public PILayoutMgr {
+public:
+		PIStackLayout();
+  virtual 	~PIStackLayout();
+
+  virtual void  ChildAdd(PIWdg* child);
+  virtual void  ChildDel(PIWdg* child);
+
+  inline PIWdg*  CurrentWdg() { return(GetChild(mCurdisp)); }
+  inline int    NumCurrentWdg() { return(mCurdisp); } 
+  virtual void  DispNext();
+  virtual void  DispWdgNum(int n);
+
+protected:
+  int mCurdisp;
+};
+		
+// ----------------------- Classe PIStackWindow ----------------------------
+//                    Fenetre avec un PIStackLayout
+
+class PIStackWindow : public PIWindow {
+public:
+		PIStackWindow(PIMsgHandler* par, const char* nom, PIWindowKind k=PIWK_normal,
+                              int sx=100, int sy=100, int px=0, int py=0);
+  virtual	~PIStackWindow();
+
+  virtual void  SetLayoutMgr(PILayoutMgr* nlay);
+  virtual void  PSPrint(PSFile *psf, int ofx=0, int ofy=0);
+
+  inline  void  DispNext() { ((PIStackLayout*)layout)->DispNext(); }
+  inline  PIWdg* CurrentWdg() { return( ((PIStackLayout*)layout)->CurrentWdg() ); }
+
+  virtual void  StartAutoDisp(int dtms=1000);
+  virtual void  StopAutoDisp();
+
+protected:
+  PIPeriodic mPerad;
+};
+
+// ----------------------- Classe PIZoneLayout ----------------------------
+// Pour fenetre avec nzx*nzy zone d affichage - Les nouveaux widgets dans chaque
+// zone viennent remplacer les anciennes - Ceux-ci sont detruits automatiquement
+
+
+class PIZoneLayout : public PILayoutMgr {
+public:
+		PIZoneLayout(int nzx=1, int nzy=1);
+  virtual 	~PIZoneLayout();
+
+  virtual void  ChildAdd(PIWdg* child);
+  virtual void  ChildDel(PIWdg* child);
+  virtual void  SetZone(int nzx, int nzy);
+  virtual void  NbZone(int& nzx, int& nzy);
+  virtual PIWdg* NextChildPosSize(int& px, int& py, int& sx, int& sy);
+
+protected:
+  int mZx, mZy, mZc;
+  PIWdg** mZWdg;
+};
+
+// ----------------------- Classe PIZoneWindow ----------------------------
+//                    Fenetre avec un PIZoneLayout 
+ 
+class PIZoneWindow : public PIWindow {
+public:
+		PIZoneWindow(PIMsgHandler* par, const char* nom, PIWindowKind k=PIWK_normal,
+                             int nzx=1, int nzy=1, int sx=100, int sy=100, int px=0, int py=0);
+  virtual	~PIZoneWindow();
+
+  virtual void  SetLayoutMgr(PILayoutMgr* nlay);
+
+  inline  void  SetZone(int nzx, int nzy) { ((PIZoneLayout*)layout)->SetZone(nzx, nzy); }
+  inline  void  NbZone(int& nzx, int& nzy)  { ((PIZoneLayout*)layout)->NbZone(nzx, nzy); }
+  inline PIWdg* NextChildPosSize(int& px, int& py, int& sx, int& sy)
+                { return ( ((PIZoneLayout*)layout)->NextChildPosSize(px, py, sx, sy) ); }
+
+protected:
+};
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pisurfdr.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pisurfdr.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pisurfdr.cc	(revision 464)
@@ -0,0 +1,255 @@
+#include <math.h>
+#include "pisurfdr.h"
+
+/* --Methode-- */
+PISurfaceDrawer::PISurfaceDrawer(P2DArrayAdapter* arr, bool asxy, bool asz, bool ad)
+{
+  mArr = arr;  mAda = ad;
+  mScx = mScy = mScz = 1.;
+  mZmin = 0.; mZmax = 1.;
+  mLut = NULL;
+  if (arr == NULL)  return;
+  arr->XYfromxy(0,0,mXmin, mYmin);
+  arr->XYfromxy(arr->XSize(),arr->YSize(),mXmax, mYmax);
+  double scm=1.;
+  if (asxy)  { 
+    mScy = (mXmax-mXmin)/(mYmax-mYmin);
+    scm = mXmax-mXmin;
+    }
+  else scm =  ((mXmax-mXmin) > (mYmax-mYmin)) ? (mXmax-mXmin)  : (mYmax-mYmin);
+  int i,j;   double cv;
+  mZmin = mZmax = arr->Value(0,0);
+  for(i=0; i<arr->XSize(); i++) 
+    for(j=0; j<arr->YSize(); j++) {
+      cv  = arr->Value(i,j);
+      if (cv < mZmin) mZmin = cv;
+      if (cv > mZmax) mZmax = cv;
+    }
+  if ((mZmax-mZmin) <= 1.e-19)  mZmax = mZmin + 1.e-19;
+  if (asz) mScz = scm/(mZmax-mZmin);
+//  printf("PISurfaceDrawer::PISurfaceDrawer Min/Max: %g,%g  %g,%g  %g,%g  Sc: %g %g %g \n",
+//          mXmin, mXmax, mYmin, mYmax, mZmin, mZmax, mScx, mScy, mScz);
+  double zmin = mZmin; 
+  double zmax = mZmax;
+  double dzz = (mZmax-mZmin)*0.05;
+  mLut = new LUT(zmin-dzz*2, zmax-dzz, 256);
+}
+
+/* --Methode-- */
+PISurfaceDrawer::~PISurfaceDrawer()
+{
+  if (mAda) delete mArr;
+  if (mLut) delete mLut;
+}
+
+/* --Methode-- */
+void PISurfaceDrawer::UpdateLimits()
+{
+  if (mArr == NULL)  return;
+  double xmin, xmax, ymin, ymax, zmin, zmax;
+  xmin = mXmin*mScx;  xmax = mXmax*mScx;
+  ymin = mYmin*mScy;  ymax = mYmax*mScy;
+  zmin = mZmin*mScz;  zmax = mZmax*mScz;
+// Centre du champ en C = (xmin+xmax)/2., (ymin+ymax)/2  (zmin+zmax)*0.5
+// Distance D = Max(xmax-xmin,ymin-ymax)*2
+// Observateur en O = X+D, Yc+2*D 
+  double D = xmax-xmin;
+  if (D < (ymax-ymin))  D = ymax-ymin;
+  D *= 1.4;
+  
+  Set3DView((xmin+xmax)/2., (ymin+ymax)/2, zmin+(zmax-zmin)*0.40, 
+            (xmin+xmax)/2.+D , (ymin+ymax)/2.-2.5*D , zmin+(zmax-zmin)*0.85, 0.25, 0.25);  
+  
+  x3Min = xmin;   x3Max = xmax;
+  y3Min = ymin;   y3Max = ymax;
+  z3Min = zmin-0.05*(zmax-zmin);   z3Max = zmax+0.05*(zmax-zmin);
+
+//  printf("PISurfaceDrawer::UpdateLimits() : %g-%g  %g-%g  %g-%g (%g) \n", xmin,xmax,ymin,ymax,zmin,zmax,D);
+//  printf("PISurfaceDrawer::UpdateLimits() :  %g %g %g <<- %g %g %g \n", 
+//         (xmin+xmax)/2., (ymin+ymax)/2, zmin+(zmax-zmin)*0.40, 
+//         (xmin+xmax)/2.+D , (ymin+ymax)/2.+2.*D , zmin+(zmax-zmin)*0.60 );
+
+}
+
+
+typedef struct   /*  structures pour trier en ZP les facettes */
+  { double dp;  double zh;  int ij;  } ZPSORT;
+/* Nouvelle-Fonction */
+static int ijzpsort(const void * sp1, const void * sp2)
+/*  Fonctions de tri des etoiles en flux ds un starlist */
+{
+  ZPSORT* p1 = (ZPSORT*)sp1;   
+  ZPSORT* p2 = (ZPSORT*)sp2;  
+  if (p1->dp > p2->dp)  return(-1);
+  else if (p1->dp < p2->dp)  return(1);
+  return(0);
+}
+
+/* --Methode-- */
+void PISurfaceDrawer::DrawAxes(PIGraphicUC* g)
+{
+  if (axesFlags == kAxesNone) return;
+#if defined(CC_HAS_RTTI_SUPPORT)
+  PIGraphic3D* g3 = dynamic_cast<PIGraphic3D*>(g);
+#else
+  PIGraphic3D* g3 = (PIGraphic3D*)(g);
+#endif
+  Draw3DBoxe(g3, XMin3(), XMax3(), YMin3(), YMax3(), ZMin3(), ZMax3(),
+                 mXmin, mXmax, mYmin, mYmax, mZmin-0.05*(mZmax-mZmin), mZmax+0.05*(mZmax-mZmin));
+}
+
+/* --Methode-- */
+void PISurfaceDrawer::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
+{
+// On trace les axes - En attendant de faire mieux - Reza 8/12/98
+  if (axesFlags != kAxesNone)  DrawAxes(g);
+
+  if (mArr == NULL)  return;
+
+#if defined(CC_HAS_RTTI_SUPPORT)
+  PIGraphic3D* g3 = dynamic_cast<PIGraphic3D*>(g);
+#else
+  PIGraphic3D* g3 = (PIGraphic3D*)(g);
+#endif
+
+  g3->SelBackground(PI_White);
+//  g3->Erase(xmin, ymin, xmax-xmin, ymax-ymin);
+
+  int xsz = mArr->XSize();
+  int ysz = mArr->YSize();
+
+  ZPSORT* ijzp = new ZPSORT[xsz*ysz];
+  double* xw = new double[(xsz+1)*(ysz+1)];
+  double* yw = new double[(xsz+1)*(ysz+1)];
+  double* zw = new double[(xsz+1)*(ysz+1)];
+
+  double dx,dy;   // taille du bin 
+  dx = (mXmax-mXmin)*mScx/xsz; 
+  dy = (mYmax-mYmin)*mScy/ysz;
+ 
+  int i1,j1;
+  int i,j,k,l;
+  double x,y,z,xp,yp,zp;
+
+  k = 0;
+  for(i=0; i<xsz; i++) 
+    for(j=0; j<ysz; j++) { 
+      ijzp[k].ij = j*xsz+i; 
+      mArr->XYfromxy(i,j,x,y);
+      x *= mScx; x += dx/2.;
+      y *= mScy; y += dy/2.;
+      ijzp[k].zh = mArr->Value(i,j);
+      z = ijzp[k].zh * mScz;
+      g3->C3DC2ObsCS(x,y,z,xp,yp,zp);
+      ijzp[k].dp = zp; 
+      k++;
+
+// Calcul de la projection du coin de la facette
+      x -= dx/2.;   y -= dy/2.;
+      i1 = (i>0) ? i-1 : 0;
+      j1 = (j>0) ? j-1 : 0;
+      z = mArr->Value(i,j) + mArr->Value(i1,j) + mArr->Value(i1,j1) +  mArr->Value(i,j1);
+      z = z/4.*mScz;        
+//      g3->Proj3DC2GrC(x,y,z, xw[j*(xsz+1)+i], yw[j*(xsz+1)+i]);
+      xw[j*(xsz+1)+i] = x;      yw[j*(xsz+1)+i] = y;    zw[j*(xsz+1)+i] = z;    
+    }
+
+  j = ysz;
+  for(i=0; i<xsz; i++) {
+     mArr->XYfromxy(i,j-1,x,y);
+     x *= mScx; 
+     y *= mScy; y += dy;
+     i1 = (i>0) ? i-1 : 0;
+     j1 = j-1;
+     z = mArr->Value(i,j-1) + mArr->Value(i1,j-1) + mArr->Value(i1,j1) +  mArr->Value(i,j1);
+     z = z/4.*mScz;
+//     g3->Proj3DC2GrC(x,y,z, xw[j*(xsz+1)+i], yw[j*(xsz+1)+i]);     
+     xw[j*(xsz+1)+i] = x;      yw[j*(xsz+1)+i] = y;   zw[j*(xsz+1)+i] = z;   
+  }
+  i = xsz;
+  for(j=0; j<ysz; j++) {
+     mArr->XYfromxy(i-1,j,x,y);
+     x *= mScx; x += dx;
+     y *= mScy; 
+     i1 = i-1;
+     j1 = (j>0) ? j-1 : 0;
+     z = mArr->Value(i-1,j) + mArr->Value(i1,j) + mArr->Value(i1,j1) +  mArr->Value(i-1,j1);
+     z = z/4.*mScz;
+//     g3->Proj3DC2GrC(x,y,z, xw[j*(xsz+1)+i], yw[j*(xsz+1)+i]);     
+     xw[j*(xsz+1)+i] = x;      yw[j*(xsz+1)+i] = y;   zw[j*(xsz+1)+i] = z;   
+  }
+  i = xsz;  j = ysz;
+  mArr->XYfromxy(i-1,j-1,x,y);
+  i1 = i-1;   j1 = j-1;
+  x *= mScx; x += dx;
+  y *= mScy; y += dy;
+  z = mArr->Value(i-1,j-1) + mArr->Value(i1,j-1) + mArr->Value(i1,j1) +  mArr->Value(i-1,j1);
+  z = z/4.*mScz;
+//  g3->Proj3DC2GrC(x,y,z, xw[j*(xsz+1)+i], yw[j*(xsz+1)+i]);     
+  xw[j*(xsz+1)+i] = x;      yw[j*(xsz+1)+i] = y;    zw[j*(xsz+1)+i] = z;   
+
+// On trie par ordre de distance zp de projection / observateur, du plus loin au plus proche
+  qsort(ijzp,(size_t) k,sizeof(ZPSORT),ijzpsort);
+
+  PIGrCoord xg[5],yg[5],zg[5];
+  PIColors fgc; 
+
+
+  if (mCmapid == CMAP_OTHER) {   // Trace avec des lignes
+    if (mLAtt == PI_NotDefLineAtt)    g3->SelLine(PI_ThinLine);
+    fgc = ( mFCol == PI_NotDefColor ) ? PI_Black : mFCol;
+    for(l=0;l<k;l++) {
+      i =  ijzp[l].ij%xsz;
+      j =  ijzp[l].ij/xsz;
+      xg[4] = xg[0] = xw[i+j*(xsz+1)];    yg[4] = yg[0] = yw[i+j*(xsz+1)];  
+      zg[4] = zg[0] =   zw[i+j*(xsz+1)];
+      xg[1] = xw[i+1+j*(xsz+1)];          yg[1] = yw[i+1+j*(xsz+1)];   
+      zg[1] = zw[i+1+j*(xsz+1)];   
+      xg[2] = xw[i+1+(j+1)*(xsz+1)];      yg[2] = yw[i+1+(j+1)*(xsz+1)];
+      zg[2] = zw[i+1+(j+1)*(xsz+1)];
+      xg[3] = xw[i+(j+1)*(xsz+1)];        yg[3] = yw[i+(j+1)*(xsz+1)];  
+      zg[3] = zw[i+(j+1)*(xsz+1)]; 
+// On efface derriere 
+      g3->SelForeground(PI_White);
+//      g3->BaseGraphic()->DrawFPolygon(xg,yg,5);
+      g3->DrawFPolygon3D(xg,yg,zg,5);
+// On trace 
+      g3->SelForeground(fgc);
+//      g3->BaseGraphic()->DrawPolygon(xg,yg,5);
+      g3->DrawPolygon3D(xg,yg,zg,5);
+    }
+  }
+  else {   // Trace avec niveaux de couleur
+    PIColorMap* cmap = new PIColorMap(mCmapid);
+    PIColors fgc; 
+    if ( (mCmapid == CMAP_GREY32) || (mCmapid == CMAP_GREYINV32) || 
+         (mCmapid == CMAP_GREY128)  || (mCmapid == CMAP_GREYINV128) )
+      fgc = ( mFCol == PI_NotDefColor ) ? PI_Red : mFCol;
+    else  fgc = ( mFCol == PI_NotDefColor ) ? PI_Black : mFCol;
+    for(l=0;l<k;l++) {
+      i =  ijzp[l].ij%xsz;
+      j =  ijzp[l].ij/xsz;
+      xg[4] = xg[0] = xw[i+j*(xsz+1)];    yg[4] = yg[0] = yw[i+j*(xsz+1)];  
+      zg[4] = zg[0] =   zw[i+j*(xsz+1)];
+      xg[1] = xw[i+1+j*(xsz+1)];          yg[1] = yw[i+1+j*(xsz+1)];   
+      zg[1] = zw[i+1+j*(xsz+1)];   
+      xg[2] = xw[i+1+(j+1)*(xsz+1)];      yg[2] = yw[i+1+(j+1)*(xsz+1)];
+      zg[2] = zw[i+1+(j+1)*(xsz+1)];
+      xg[3] = xw[i+(j+1)*(xsz+1)];        yg[3] = yw[i+(j+1)*(xsz+1)];  
+      zg[3] = zw[i+(j+1)*(xsz+1)]; 
+// On efface derriere 
+      g3->SelForeground(*cmap, mLut->ApplyFast(ijzp[l].zh));
+      g3->DrawFPolygon3D(xg,yg,zg,5);
+// On trace 
+      if (mLAtt == PI_NotDefLineAtt)   continue;
+      g3->SelForeground(fgc);
+      g3->DrawPolygon3D(xg,yg,zg,5);
+    }
+      
+  }
+
+  delete[] ijzp;
+  delete[] xw; 
+  delete[] yw;
+  delete[] zw;
+}
Index: /tags/V_LaSilla191199/SophyaPI/PI/pisurfdr.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pisurfdr.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pisurfdr.h	(revision 464)
@@ -0,0 +1,32 @@
+// Module PI : Peida Interactive PISurfaceDrawer
+// Drawer et DrawWidget 3D       R. Ansari 06/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PISURFDRW_H_SEEN
+#define PISURFDRW_H_SEEN
+
+#include "parradapter.h"
+#include "pi3ddrw.h"
+
+// Trace d une surface defini par Z=f(x,y)  travers un tableau 
+class PISurfaceDrawer : public PIDrawer3D {
+public :
+  			PISurfaceDrawer(P2DArrayAdapter* arr, bool asxy=false, bool asz=true, bool ad = true);
+  			~PISurfaceDrawer();
+
+  virtual void 		UpdateLimits();   // Calcule et change la vue-3D
+
+  virtual void 		Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax); 
+  virtual void       	DrawAxes(PIGraphicUC* g);
+
+protected :
+  P2DArrayAdapter* mArr;
+  bool mAda;
+  double mScz, mScx, mScy;
+  double mXmin, mXmax;
+  double mYmin, mYmax;
+  double mZmin, mZmax;
+  LUT* mLut;
+};
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pisysdep.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pisysdep.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pisysdep.h	(revision 464)
@@ -0,0 +1,53 @@
+#ifndef PISYSDEP_SEEN
+#define PISYSDEP_SEEN
+
+#include "machdefs.h"
+
+#ifdef __MWERKS__         // Macintosh
+
+  #define PIWDG_H  "piwdgmac.h"
+  #define PICONT_H "picontainermac.h"
+  #define PIWIN_H  "piwindowmac.h"
+  #define PISTDWDG_H "pistdwdgmac.h"
+  #define PIMENU_H "pimenumac.h"
+  #define PIMENUBAR_H "pimenubarmac.h"
+  #define PIOPTMENU_H "pioptmenumac.h"
+  #define PIFILECHO_H "pifilechomac.h"
+  #define PILIST_H "pilistmac.h"
+
+  #define PIAPP_H "piapplmac.h"
+  #define PIPERIODIC_H "piperiodmac.h"
+  
+  #define PIFONT_H "pifontmac.h"
+  #define PIGRAPHIC_H "pigraphmac.h"
+  #define PICMAPNTV_H "picmapmac.h"
+  #define PICMAP_H "picmap.h"
+
+  #define PIBWDG_H "pibwdgmac.h"
+  #define PIPIXMAP_H "pipixmapmac.h"
+
+#else                  // XWindow
+  #define PIWDG_H  "piwdgx.h"
+  #define PICONT_H "picontainerx.h"
+  #define PIWIN_H  "piwindowx.h"
+  #define PISTDWDG_H "pistdwdgx.h"
+  #define PIMENU_H "pimenux.h"
+  #define PIMENUBAR_H "pimenubarx.h"
+  #define PIOPTMENU_H "pioptmenux.h"
+  #define PIFILECHO_H "pifilechox.h"
+  #define PILIST_H "pilistx.h"
+
+  #define PIAPP_H "piapplx.h"
+  #define PIPERIODIC_H "piperiodx.h"
+
+  #define PIFONT_H "pifontx.h"
+  #define PIGRAPHIC_H "pigraphx.h"
+  #define PICMAPNTV_H "picmapx.h"
+  #define PICMAP_H "picmap.h"
+
+  #define PIBWDG_H "pibwdgx.h"
+  #define PIPIXMAP_H "pipixmapx.h"
+
+#endif
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/pitestapp.xx
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pitestapp.xx	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pitestapp.xx	(revision 464)
@@ -0,0 +1,247 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "pisysdep.h"
+
+#include PIAPP_H
+#include PIWIN_H 
+#include PIMENU_H 
+#include PIOPTMENU_H 
+// #include PIMENUBAR_H 
+#include PISTDWDG_H 
+#include PIBWDG_H 
+
+#include PIPIXMAP_H 
+
+#include PIFILECHO_H 
+
+#include "ex_dessin.h"
+
+
+int SysBeep(int n)
+{
+for(int i=0; i<n; i++)  putchar('\007');
+return(0);
+}
+/*
+class PITestWindow : public PIWindow {
+public:
+	PITestWindow(PIMsgHandler *par);
+	~PITestWindow() {}
+
+    PIText text;
+    PIButton bouton;
+    PIButton bouton2, bouton3;
+    PILabel label;
+    PIScale scl;
+    PIPUMenu  * menu;
+
+};
+*/
+
+class PITestApp : public PIApplication {
+public:
+	PITestApp(int sx, int sy);
+	~PITestApp();
+
+	virtual void	Process(long msg, PIMsgHandler* sender, void* data=NULL);
+
+//    PIMenubar * menb;
+    PIPDMenu  *m[3];
+    PICheckBox * ckb;
+    PIText * text;
+    PIButton * bouton;
+    PIButton * bouton2, * bouton3, * bouton4;
+    PILabel * label;
+    PIScale * scl;
+    PIPUMenu  * menu;
+    PIPDMenu * pdm;
+    PIOptMenu * opt;
+
+};
+
+
+/*
+PITestWindow::PITestWindow(PIMsgHandler *par)
+: PIWindow(par, "Peida", PIWK_normal, 200, 200, 50, 50),
+  text(this, "TEXTE", 100, 30, 20,10),
+  label(this, "Label", 100, 20, 20,60),
+  bouton(this, "OK", 66, 40, 20, 20, 100),
+  bouton2(this, "Image", 133, 40, 20, 80, 100),
+  bouton3(this, "Menu", 555, 40, 20, 140, 100),
+  scl(this, "Scale", 88, 5, 45, 100, 20, 10, 130)
+{
+  menu = new PIPUMenu((PIMsgHandler *)this, "myMenu");
+  menu->AppendItem("DoIt-1", 4401);
+  menu->AppendItem("DoIt-2", 4402);
+  menu->AppendItem("DoIt-25", 4425);
+  menu->AppendItem("DoIt-26", 4426);
+  menu->AppendItem("Check-33", 4433);
+  menu->AppendItem("Check-33", 4433);
+
+  label.SetBorderWidth(3);
+  FinishCreate();
+}
+
+*/
+
+PITestApp::PITestApp(int sx, int sy)
+: PIApplication(sx, sy)
+{
+//   menb = new PIMenubar(this, "MyMenubar");
+   m[0] = new PIPDMenu((PIMsgHandler *)Menubar(),"File");
+   m[0]->AppendItem("Open", 10101);
+   m[0]->AppendItem("Close", 10102);
+   m[0]->AppendItem("New", 10103);
+   m[0]->AppendItem("Quit", 10104);
+   m[1] = new PIPDMenu((PIMsgHandler *)Menubar(),"Edit");
+   m[1]->AppendItem("Copier", 10201);
+   m[1]->AppendItem("Coller", 10202);
+   m[1]->AppendItem("Couper", 10203);
+   m[2] = new PIPDMenu((PIMsgHandler *)Menubar(),"Operation");
+   m[2]->AppendItem("AddItem", 10301);
+   m[2]->AppendItem("DelItemName", 10302);
+   m[2]->AppendItem("DelItemMsg", 10303);
+
+   AppendMenu(m[0]);
+   AppendMenu(m[1]);   
+   AppendMenu(m[2]);
+
+  ckb = new PICheckBox(this->MainWin(), "CheckBox", 166, 60, 20, 10, 10);
+  text = new PIText(this->MainWin(), "TEXTE", 100, 30, 20,40);
+  label  = new PILabel(this->MainWin(), "Label", 140, 20, 20,80);
+  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);
+  bouton4 = new PIButton(this->MainWin(), "Menu", 555, 40, 25, 200, 120);
+  scl = new PIScale(this->MainWin(), "Scale", 88, 5, 45, 100, 20, 10, 150);
+
+  menu = new PIPUMenu((PIMsgHandler *)this, "myMenu");
+  menu->AppendItem("DoIt-1", 4401);
+  menu->AppendItem("DoIt-2", 4402);
+  menu->AppendItem("DoIt-25", 4425);
+  menu->AppendItem("DoIt-26", 4426);
+  menu->AppendItem("Check-33", 4433);
+  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);
+
+  printf("Debug_PITestApp::PITestApp() MenBarSizeX,Y= %d %d \n", 
+         Menubar()->XSize(), Menubar()->YSize());
+
+}
+
+PITestApp::~PITestApp()
+{
+  delete ckb;
+  delete text;
+  delete label;
+  delete bouton;
+  delete bouton2;
+  delete bouton3;
+  delete bouton4;
+  delete scl;
+  delete menu;
+  delete m[0]; delete m[1]; delete m[2];
+//  delete menb;
+
+}
+
+static PIWindow * wp3, *wp2, *wp4;
+static PIPixmap * pxm;
+static unsigned char  pixels[25000];
+static PIFileChooser *pfc;
+static bool  fgpxm = false;
+static bool  fgt = false;
+
+void
+PITestApp::Process(long msg, PIMsgHandler* sender, void* data)
+{
+  static int x = 0;
+  static numsg=8800;
+
+//   SysBeep(1);
+  char truc[100];
+  sprintf(truc,"< %ld - %d (%d)>",msg,x++, ((PIWdgGen *)sender)->kind());
+  this->label->SetLabel(truc);
+  if (msg == 133)
+    {
+    if (!fgpxm)  { wp3->Show();  fgpxm = true; }
+    for (int i=0; i<25000; i++)  pixels[i] = random()%32;
+    if ((x % 3) == 0)  pxm->SetColMap(CMAP_GREY32);
+    if ((x % 3) == 1)  pxm->SetColMap(CMAP_COLRJ32);
+    if ((x % 3) == 2)  pxm->SetColMap(CMAP_COLBR32);
+    pxm->Refresh();
+    }
+  if (msg == 233)
+    {
+    if (fgt) { wp2->Hide();  fgt = false; }
+    else { wp2->Show();  fgt = true; }
+    }
+//  if (msg == 555)   (this->menu)->Show(); 
+
+  if (msg == 10104)  Stop();
+  if (msg == 10101)  { pfc->AcceptNewFile(false); pfc->Show(); }
+  if (msg == 10103)  { pfc->AcceptNewFile(true); pfc->Show(); }
+
+  if (msg == 10301)  
+   { numsg++;    m[1]->AppendItem(text->GetText().c_str(), numsg); }
+  if (msg == 10302)  { m[1]->DeleteItem(text->GetText().c_str()); }
+  if (msg == 10303)  { m[1]->DeleteItemMsg(atol(text->GetText().c_str())); }
+
+  if (msg == 555)  wp4->Show();
+  if ( (msg == 6001) || (msg == 6002) )  wp4->Hide();
+
+  if ((msg > 8000) && data) printf("PITestApp::MenubarReturn: %s \n", data);
+  if (msg == 5000)  
+    { if (data) printf("PITestApp::Process(5000) : %s \n", (char *)data); 
+    else printf("PITestApp::Process(5000) (data=NULL) \n");  }
+  if (msg == 66) ckb->SetState(true);
+  if ((msg / 100) == 56) printf("PITestApp::Process(%d) : %s \n", (int)msg, (char *)data); 
+
+}
+
+int main()
+{
+  PITestApp * app;
+  app = new PITestApp(300, 200);
+
+  wp2 = new PIWindow(app, "Window-2", PIWK_normal,  150, 150, 250, 250);
+  ExBWdg bw(wp2, "BWdg", 150, 150, 0, 0);
+//  bw.SetBinding(false, true, true, false);
+//  bw.ActivateButton(1);
+//  bw.ActivatePtrCross();
+//  bw.ActivateKeyboard();
+
+  wp4 = new PIWindow(app, "Window-4", PIWK_dialog,  120, 120, 350, 350);
+  PIButton bt1(wp4, "OK", 6001, 40, 20, 10, 80);
+  PIButton bt2(wp4, "Cancel", 6002, 40, 20, 60, 80);
+  PILabel  lb1(wp4, "Mat_00", 30, 20, 10, 10);
+  PIText  tx1(wp4, "A00", 50, 20, 50, 10);  
+  PILabel  lb2(wp4, "Mat_11", 30, 20, 10, 40);
+  PIText  tx2(wp4, "A11", 50, 20, 50, 40);  
+
+  wp3 = new PIWindow(app, "Window-3", PIWK_normal, 200, 200, 350, 350);
+  pxm = new PIPixmap(wp3, "myPixmap", 150, 150, 10, 10);
+  
+  pxm->SetBinding(true, true, true, true);
+  pxm->SetPixmap(pixels, 150, 150);
+
+  //  wp4 = new PIWindow(app, "Open...", PIWK_dialog, 300, 300, 400, 400);
+
+  pfc = new PIFileChooser(app,"FileChooser", 5000); 
+  pfc->SetPath("/users/eros/ansari/Images++");
+
+
+//  Int32 ioNumber = 100;
+  app->Run();
+  delete app;
+  exit(0);
+}
Index: /tags/V_LaSilla191199/SophyaPI/PI/piup.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piup.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piup.cc	(revision 464)
@@ -0,0 +1,61 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "ctimer.h"
+#include "imageop.h"
+
+#include "piup.h"
+
+RzImage * PIUserProc_1(ImageR4& myimg, int xp, int yp, int dx, int dy,
+                       char * arg1, char * arg2)
+{
+printf("**** PIUserProc_1 Pave[%d*%d] en (%d,%d) %s %s  Filtrage passe-bas 3*3 \n",
+       dx, dy, xp, yp, arg1, arg2);
+ImageR4 filt(3,3);
+ImageR4 * 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.1;
+filt(1,1) = 0.2;
+
+filt.PrintImage();
+out = new ImageR4(myimg.XSize(), myimg.YSize());
+TIMEF ;
+FilterImage(&myimg, out, &filt); 
+return((RzImage*)out);
+}
+ 
+RzImage * PIUserProc_2(ImageR4& myimg, int xp, int yp, int dx, int dy,
+                       char * arg1, char * arg2)
+{
+printf("**** PIUserProc_2 Pave[%d*%d] en (%d,%d) %s %s  Ombre 3*3 \n",
+       dx, dy, xp, yp, arg1, arg2);
+printf(" PIUserProc_2(%d %d %s %s)  Ombre 3*3 \n", xp, yp, arg1, arg2);
+ImageR4 filt(3,3);
+ImageR4 * 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.PrintImage();
+out = new ImageR4(myimg.XSize(), myimg.YSize());
+TIMEF ;
+FilterImage(&myimg, out, &filt); 
+return((RzImage*)out);
+}
+
+ 
+RzImage * PIUserProc_3(ImageR4& , int xp, int yp, int dx, int dy,
+                       char * arg1, char * arg2)
+{
+printf("PIUserProc_3 Pave[%d,%d] en (%d %d) %s %s ne fait rien !\n", 
+       dx, dy, xp, yp, arg1, arg2);
+return(NULL);
+}
Index: /tags/V_LaSilla191199/SophyaPI/PI/piup.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piup.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piup.h	(revision 464)
@@ -0,0 +1,10 @@
+#include "cimage.h"
+extern "C" {
+RzImage * PIUserProc_1(ImageR4& myimg, int xp, int yp, int dx, int dy,
+                       char * arg1, char * arg2);
+RzImage * PIUserProc_2(ImageR4& myimg, int xp, int yp, int dx, int dy,
+                       char * arg1, char * arg2);
+RzImage * PIUserProc_3(ImageR4& myimg, int xp, int yp, int dx, int dy, 
+                       char * arg1, char * arg2);
+}
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/piup_def.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piup_def.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piup_def.cc	(revision 464)
@@ -0,0 +1,33 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "ctimer.h"
+#include "imageop.h"
+
+#include "piup.h"
+
+RzImage * PIUserProc_1(ImageR4 & , int xp, int yp, int dx, int dy,
+                       char * arg1, char * arg2)
+{
+printf("PIUserProc_1/Dummy Pave[%d,%d] en (%d %d) %s %s ne fait rien !\n", 
+       dx, dy, xp, yp, arg1, arg2);
+return(NULL);
+}
+ 
+RzImage * PIUserProc_2(ImageR4 & , int xp, int yp, int dx, int dy,
+                       char * arg1, char * arg2)
+{
+printf("PIUserProc_2/Dummy Pave[%d,%d] en (%d %d) %s %s ne fait rien !\n", 
+       dx, dy, xp, yp, arg1, arg2);
+return(NULL);
+}
+ 
+RzImage * PIUserProc_3(ImageR4 & , int xp, int yp, int dx, int dy,
+                       char * arg1, char * arg2)
+{
+printf("PIUserProc_3/Dummy Pave[%d,%d] en (%d %d) %s %s ne fait rien !\n", 
+       dx, dy, xp, yp, arg1, arg2);
+return(NULL);
+}
+ 
Index: /tags/V_LaSilla191199/SophyaPI/PI/piupdattachment.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piupdattachment.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piupdattachment.cc	(revision 464)
@@ -0,0 +1,104 @@
+#include "piupdattachment.h"
+//const MessageT	msg_MouseUp			= 819;
+
+PIUpdAttachment* PIUpdAttachment::lastCursPane = NULL;
+bool PIUpdAttachment::hit = false;
+int PIUpdAttachment::down = 0;
+
+PIUpdAttachment::PIUpdAttachment(PIBaseWdgMac* wdg)
+: LAttachment(), myWdg(wdg)
+{
+  myGraphic = (PIGraphicMac*) wdg->WindowGraphic();
+}
+
+PIUpdAttachment::~PIUpdAttachment()
+{
+  if (lastCursPane == this) lastCursPane = NULL;
+  delete myGraphic;
+}
+
+void PIUpdAttachment::ExecuteSelf(MessageT msg, void* data)
+{
+  if (myWdg)
+    switch(msg) {
+      case msg_DrawOrPrint:
+        myWdg->Draw(myGraphic,0,0,999999,999999);
+ 		break;
+      case msg_Resize:
+        myWdg->Resize();
+ 		break;
+      case msg_Move:
+//        myWdg->Move();
+        break;
+//      case cmd_Close: {
+//        delete myWdg;
+//        break;
+//      }
+      case msg_Click: {
+        SMouseDownEvent* evt = (SMouseDownEvent*) data;
+        EventModifiers mod = evt->macEvent.modifiers;
+        if ((mod & cmdKey) && (mod & optionKey))
+          { myWdg->But3Press(evt->whereLocal.h,evt->whereLocal.v); down = 3;}
+        else if (mod & cmdKey)
+          { myWdg->But2Press(evt->whereLocal.h,evt->whereLocal.v); down = 2;}
+        else
+          { myWdg->But1Press(evt->whereLocal.h,evt->whereLocal.v); down = 1;}
+ 		break;
+ 		}
+ 	  case msg_KeyPress: {
+ 	    EventRecord* evt = (EventRecord*) data;
+ 	    PIKeyModifier kmod = PIKM_Blank;
+ 	    if (evt->modifiers & shiftKey)
+ 	      kmod = (PIKeyModifier) (kmod | PIKM_Shift);
+ 	      //kmod |= PIKM_Shift;  // Ca devrait passer !!!
+ 	    if (evt->modifiers & optionKey)
+ 	      kmod = (PIKeyModifier) (kmod | PIKM_Alt);
+ 	    if (evt->modifiers & controlKey)
+ 	      kmod = (PIKeyModifier) (kmod | PIKM_Cntl);
+ 	    myWdg->Keyboard(evt->message & charCodeMask, kmod);
+ 	    break;
+ 	    }
+ 	  case msg_AdjustCursor: {
+ 	    EventRecord* evt = (EventRecord*) data;
+ 	    if (lastCursPane != this) {
+ 	      if (lastCursPane)
+ 	        lastCursPane->myWdg->Leave();
+ 	      myWdg->Enter();
+ 	      lastCursPane = this;
+ 	    }
+ 	    hit = true;
+ 	    SetExecuteHost(!myWdg->AdjustCursor());
+ 	    // Est-ce un move, i.e. le bouton est-il toujours appuye depuis le dernier MouseDown ?
+ 	    if (::StillDown() && down) {
+ 	      Point pt = evt->where;
+ 	      myWdg->mPane->GlobalToPortPoint(pt);
+ 	      myWdg->mPane->PortToLocalPoint(pt);
+ 	      if (lastPt.h != pt.h || lastPt.v != pt.v) {
+ 	        lastPt = pt;
+            EventModifiers mod = evt->modifiers;
+            if ((mod & cmdKey) && (mod & optionKey))
+              myWdg->Ptr3Move(pt.h,pt.v);
+            else if (mod & cmdKey)
+              myWdg->Ptr2Move(pt.h,pt.v);
+            else
+              myWdg->Ptr1Move(pt.h,pt.v);
+          }
+ 	    } else if (down) {  // A changer le jour ou les attachements recoivent les mouseup.
+ 	      Point pt = evt->where;
+ 	      myWdg->mPane->GlobalToPortPoint(pt);
+ 	      myWdg->mPane->PortToLocalPoint(pt);
+          EventModifiers mod = evt->modifiers;
+          //if ((mod & cmdKey) && (mod & optionKey))
+          if (down == 3)
+            myWdg->But3Release(pt.h,pt.v);
+          //else if (mod & cmdKey)
+          else if (down == 2)
+            myWdg->But2Release(pt.h,pt.v);
+          else
+            myWdg->But1Release(pt.h,pt.v);
+ 	      down = 0;
+        }
+ 	    break;
+ 	    }
+    }
+}
Index: /tags/V_LaSilla191199/SophyaPI/PI/piupdattachment.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piupdattachment.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piupdattachment.h	(revision 464)
@@ -0,0 +1,28 @@
+
+#include <LAttachment.h>
+
+#include "pibwdgmac.h"
+
+const MessageT	msg_Resize			= 817;
+const MessageT	msg_Move			= 818;
+
+class PIUpdAttachment : public LAttachment {
+public:
+  PIUpdAttachment(PIBaseWdgMac* wdg);
+  ~PIUpdAttachment();
+  
+protected:
+ virtual void	ExecuteSelf(
+							MessageT		inMessage,
+							void			*ioParam);
+
+ PIBaseWdgMac* myWdg;
+ PIGraphicMac* myGraphic;
+ 
+ friend class PIPPApplMac;
+ static PIUpdAttachment* lastCursPane;
+ static bool hit;
+ static int down;
+ Point lastPt;
+};
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/piusmak
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piusmak	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piusmak	(revision 464)
@@ -0,0 +1,39 @@
+include  $(EROSBASEREP)/Include/MakefileUser.h
+
+%.o:%.cc
+	$(COMPILE.cc) -o $@ $<
+LIBF =  $(SLB)libpeida.so $(SLB)liberosc.so
+LIBS = -L$(SLB) -lpeida -lerosc
+
+#-------------------------------------------------------- 
+all : piup.so
+
+clean:
+	rm -f user.o user.so piup.so
+
+piup.so : user.so
+	cp -p user.so piup.so
+
+user.so : user.o $(LIBF)
+ifeq (${MACHEROS},Linux)
+	$(LINK.cc) -shared -o user.so --whole-archive user.o --nowhole-archive $(LIBS) -lm -lc
+endif
+ifeq (${MACHEROS},OSF1)
+ifeq ($(CXX), cxx)
+	$(LINK.cc) -shared -o user.so -all user.o -none $(LIBS) -lm -lc
+endif
+ifeq ($(CXX), g++)
+	ld -shared -o user.so -all user.o -none $(LIBS) -L$(GLB) -lg++ -lstdc++ -lm -lc
+endif
+endif
+
+user.o: user.cc  $(INC)piup.h \
+ $(INC)perrors.h \
+ $(INC)exceptions.h \
+ $(INC)defs.h \
+ $(INC)cimage.h \
+ $(INC)rzimage.h \
+ $(INC)rzvect.h \
+ $(INC)machine.h \
+ $(INC)datatypes.h \
+ $(INC)utils.h $(INC)peida.h 
Index: /tags/V_LaSilla191199/SophyaPI/PI/piversion.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piversion.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piversion.h	(revision 464)
@@ -0,0 +1,6 @@
+#ifndef PIVERSION_H_SEEN
+#define PIVERSION_H_SEEN
+
+#define PI_VERSIONNUMBER  2.5
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/piwdggen.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piwdggen.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piwdggen.cc	(revision 464)
@@ -0,0 +1,389 @@
+//  Classe de base pour les objets correspondant a une fenetre 
+//  dans les programmes graphiques interactives
+//
+//                  E.Aubourg , R. Ansari  96 - 98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "piwdggen.h"
+#include "picontainergen.h"
+#include "pievthandler.h"
+#include "psfile.h"
+
+//++
+// Class	PIWdg
+// Lib		PI
+// include	piwdggen.h
+//
+//   	Classe de base pour tout objets correspondant à une fenêtre
+//	à l'écran, ayant donc une représentation graphique et 
+//	pouvant jouer un rôle dans la hiérarchie des objets interactif. 
+//	*PIWdg* hérite de *PIMsgHandler*, avec une hiérarchie correspondant
+//	par défaut à celles des PIWdg. La classe "PIWdg" est une des 
+//	classes de PI qui ont une implementation dépendante du systeme utilisé
+//	(Mac, XWindow, ...). La classe "PIWdgGen" est la classe qui
+//	définit l'interface, et ne doit pas être instanciée directement
+//	(Méthodes virtuelles pures). Les objets instanciés sont de la 
+//	classes "PIWdg" et le fichier entête correspondant est "PIWDG_H"
+//	défini dans "pisysdep.h"
+//--
+//++
+// Links	Parents
+// PIMsgHandler
+//--
+//++
+// Links	Voir aussi
+// PIEventHandler
+//--
+
+//++
+// Titre	Constructeur
+//--
+//++
+// PIWdg(PIContainerGen *par, const char *nom, int sx=10, int sy=10, int px=0, int py=0)
+//	Création d'un objet contenu dans l'objet *PIContainer* "par", de
+//	taille "sx,sy", se trouvant à la position "px,py" avec le nom "nom"
+// long kind()
+//	Renvoie le type de la classe de l'objet ("=PIWdgGen::ClassId") pour cette classe
+//	de base. Doit être redéfinie par les classes dérivées.
+//--  
+
+
+//++
+// Titre	Taille, position
+//--
+//++
+// void  PSPrint(PSFile *psf, int ofx=0, int ofy=0)
+//	Méthode virtuelle qui doit être redéfinie pour chacune des classes filles.
+//	produit une représentation graphique de l'objet en Postscript.
+// SetSize(int sx, int sy)
+//	Modifie la taille de l'objet.
+// SetPos(int px, int py)
+//	Modifie la position de l'objet.
+// int  XSize()  YSize()
+//	Renvoient la taille (X,Y) de l'objet.
+// int  XPos()  YPos()
+//	Renvoient la position (X,Y) de l'objet.
+// void  GetScreenPos(int & spx, int & spy)
+//	Renvoie la position de l'objet sur l'écran.
+//--
+//++
+// Titre	Gestion des accrochages (Binding)
+//--
+//++
+// void  SetBinding(PIBindingKind left, PIBindingKind top, PIBindingKind right, PIBindingKind bottom)
+//	Permet de contrôler le comportement de l'objet en cas de changement de taille 
+//	du conteneur parent. La position de chaque bord peut être sans contrainte ("PIBK_free")
+//	attachée à une distance fixe par rapport au bord opposé du conteneur ("PIBK_fixed"), 
+//	ou à une position proportionnelle à la taille du conteneur parent. ("PIBK_elastic") 
+// bool  GetBinding((PIBindingKind& left, PIBindingKind& top, PIBindingKind& right, PIBindingKind& bottom)
+//	Permet de connaitre l'état des accrochages. Retourne "true" si les accrochages ont été
+//	verrouillé (appel à "LockBinding()"), "false" sinon.
+// void  LockBinding()
+//	Verrouille l'état des accrochages. Appel à "SetBinding()" sera alors sans effet.
+//	Permet à certains *LayouMgr* d'imposer une contrôle strict.
+// void  UnLockBinding()
+//	Deverrouille les accrochages.
+//--
+
+//++
+// Titre	Etat de l'objet
+//	L'objet peut se trouver dans l'état actif ou inactif. Cet état est contrôlé par les 
+//	méthodes "Manage(), UnManage()". L'objet ne se trouve effectivement dans l'état 
+//	actif que si son conteneur parent est lui même actif.
+//	L'objet peut aussi être affichés, mais insensible aux actions utilisateur
+//	(clavier, souris, ...). Cette sensibilité est controlée par les 
+//	méthodes  "SetSensitive(), SetUnSensitive()".
+//--
+//++
+// void  Manage()  UnManage()
+//	Change l'état de l'objet (actif, inactif)
+// bool  IfManaged()  IfVisible()
+//	indique si l'objet est actif , visible	
+// void  SetSensitive() SetUnSensitive()
+//	Rend l'objet sensible/ insensible aux actions utilisateurs (clavier, souris, ...)
+//	L'état visuel de l'objet peut être modifié en conséquence.
+// bool  IfSensitive() 
+//	indique si l'objet est répond aux sollicitations utilisateur.
+//--
+
+//++
+// Titre	Rafraîchissement de la fenêtre
+//--
+//++
+// void  Refresh()
+//	L'appel à cette méthode permet de retracer le contenu de la 
+//	fenêtre et des "Drawer" associés.
+//--
+
+//++
+// Titre	Méthodes
+//--
+
+//++
+// void SetMsg(PIMessage msg = 0)
+//	Modifie la valeur du message associé à l'objet.
+// PIMessage  Msg()
+//	Renvoie le message associé à l'objet.
+// string  Nom()
+//	Renvoie le nom associé à l'objet.
+// PIWdg*  Parent()
+//	Renvoie le conteneur parent de l'objet.
+// void  SetUserData( void * p, int fg = 0)
+//	Associe un pointeur de données à la disposition de l'utilisateur 
+//	("void* p") à l'objet, ainsi qu'une valeur ("int fg")
+// void* UserData()
+//	Renvoie le pointeur de données user de l'objet. (NULL par défaut)
+// int  UserFlag()
+//	Renvoie la valeur "int" user de l'objet.
+//--
+
+//++
+// Titre	Gestion du copier/coller
+//	L'ensemble des méthodes de gestion de copier/coller sont décrites ici. Les méthodes
+//	"SelectionLost()", "ProvideSelection()", et "PasteSelection()" doivent être 
+//	redéfinies par les classes héritières de *PIWdg* implémentant la fonctionalité
+//	copier/coller. Le mécanisme copier/coller entre objets d'une même application,
+//	ainsi qu'entre différentes applications. Dans les opérations de copier/coller,
+//	il existe un PIWdg ou une application source des données et un PIWdg ou 
+//	une application destinatire.
+//--
+
+//++
+// bool  ClaimSelection(int typ=PICP_string)
+//	Cette méthode doit être appelée par l'objet "PIWdg" source quand celui-ci veut 
+//	s'approprier la zone d'échange de données (Selection) pour le copier/coller. "typ" indique 
+//	le type de données que peut fournir l'objet. Le type "PICP_string" (suite de caractères)
+//	est le seul type supporté actuellement. La valeur de retour est "true" si 
+//	la zone d'échange est attribué a l'objet. Cette méthode ne doit en principe pas 
+//	être redéfinie par les classes héritières de *PIWdg*.
+// void  SelectionLost()
+//	Cette méthode est appelée quand l'objet "PIWdg" source qui possede la zone d'échange 
+//	(Selection) perd celle-ci, suite par exemple à la demande d'un autre objet. Cette méthode 
+//	doit être redéfinies par les classes qui implémentent la fonctionalité et ne doit 
+//	doit pas être appelée directement.
+// int  RequestSelection(int typ=PICP_string)
+//	Cette méthode doit être appelée par l'objet "PIWdg" destinatire quand celui-ci souhaite 
+//	obtenir les données de la zone d'échange (Selection). "typ" indique les types de données 
+//	acceptables par l'objet. La valeur de retour indique le type qui sera fourni
+//	(à l'appel de "PasteSelection()"). Cette méthode ne doit en principe pas 
+//	être redéfinie par les classes héritières de *PIWdg*.
+// void* ProvideSelection(int& typ, int& len)  
+//	Cette méthode est appelée quand l'objet "PIWdg" source, qui possede la zone d'échange 
+//	(Selection) doit  fournir les données correspondantes à la sélection. Renvoie le pointeur 
+//	de la zone mémoire correspondante, sa longueur ("len") et le type ("typ") des données.
+//	cette zone mémoire appartient à l'objet, et ne doit être modifié tant que 
+//	la méthode "SelectionTransferEnd()" n'a été appelé.
+// void  SelectionTransferEnd()
+//	Cette méthode est appelé une fois que l'objet ou l'application destinataire 
+//	des données de sélection a fini de traiter l'opération de copie. l'objet PIWdg 
+//	source peut alors détruire ou modifier les données correspondantes à l'échange.
+// void  PasteSelection(int typ, void *pdata, int l)
+//	Cette méthode est appelée après l'appel à "RequestSelection()" pour l'objet 
+//	destinataire. "typ" indique le type des données dans "pdata", et "l" la longeur. 
+//	La zone mémoire "pdata" n'appartient pas à l'objet destinataire et ne doit pas 
+//	être modifié par celui-ci. Une copie doit être effectué si cesCette méthode  données devaient
+//	être utilisées après la sortie de "PasteSelection()".
+//--
+
+/* --Methode-- */
+PIWdgGen::PIWdgGen(PIContainerGen *par, const char*, int, int, int, int)
+: PIMsgHandler(par)
+{
+parent = par;
+bindingLock = false;
+SetMsg(0);
+SetUserData(NULL, 0);
+//  ChildAdd() doit etre appele par la classe qui implemente le widget
+// if (par)  par->ChildAdd(this);   //  On previent le container parent  
+return;
+}
+
+
+/* --Methode-- */
+PIWdgGen::~PIWdgGen()
+{
+//  ChildDel() doit etre appele par la classe qui implemente le widget
+// if (parent)  parent->ChildDel(this);   //  On previent le container parent 
+list<EvHand>::iterator it;
+for(it= mDHlist.begin(); it != mDHlist.end(); it++) 
+  if ((*it).ad) delete (*it).evh;
+for(it= mEHlist.begin(); it != mEHlist.end(); it++) 
+  if ((*it).ad) delete (*it).evh;
+}
+
+/* --Methode-- */
+void PIWdgGen::SetMsg(PIMessage msg)
+{
+myMsg = msg;
+}
+
+/* --Methode-- */
+void PIWdgGen::GetScreenPos(int & spx, int & spy)
+/*  Renvoie la position de la fenetre par rapport a l'ecran */
+{
+PIWdgGen * wc;
+spx = 0;  spy = 0;
+wc = this;
+
+while (wc) 
+  { spx += wc->XPos();  
+  spy += wc->YPos();  wc = wc->Parent();
+  }
+return;
+}
+
+/* --Methode-- */
+void PIWdgGen::LockBinding()
+{
+bindingLock = true;
+}
+
+/* --Methode-- */
+void PIWdgGen::UnLockBinding()
+{
+bindingLock = false;
+}
+
+/* --Methode-- */
+void PIWdgGen::PSPrint(PSFile *psf, int ofx, int ofy)
+{
+char str[256];
+
+if (!psf) return;
+psf->NewBloc((double)ofx+XPos(), (double)ofy+YPos(), (double)XSize(), (double)YSize(),
+             (double)XSize(), (double)YSize());
+psf->DrawBox(0., 0., (double)XSize(), (double)YSize());
+sprintf(str,"PIWdgGen::PSPrint() Kind=%ld Name= %s", kind(), Nom().c_str());
+// N.R. 07/08/99 FontName specifie dans DrawString() 
+psf->DrawString(12., 12., str, PI_Black, PI_DefaultFont, PI_RomanFont, 10);
+psf->EndBloc();
+
+return;
+}
+
+//++
+// Titre	Gestion des Draw/Event Handler
+//	Les objets de la classe "PIWdg" peuvent gérer des objets "PIEventHandler" 
+//	qui peuvent prendre en charge une partie du traitement des événements
+//	clavier-souris-écran.
+//--
+
+//++
+// void AddDrawHandler(PIEventHandler* drwh, bool ad=false)
+//	Ajout d'un objet gestionnaire d'événements, responsable du tracé du contenu de la fenêtre.
+//	La méthode "Draw(PIGraphic* g, ...)" sera appelé pour rafraîchir le contenu de la fenêtre.
+// void RemoveDrawHandler(PIEventHandler* drwh)
+//	Suppression d'un objet gestionnaire de tracé. Toutes les réferences sonnt supprimées en cas 
+//	d' enregistrement multiple.
+// void AddEventHandler(PIEventHandler* evh, unsigned long evtmask, bool ad=false)
+//	Ajout d'un objet gestionnaire d'événements. La variable "evtmask" détermine pour
+//	quels types d'événements, la méthode "Process()" du gestionnaire est appelée.
+//|	PIEvent_Resize   (Non implementé en version X11 , 12/98)
+//|	PIEvent_Enter , PIEvent_Leave
+//|	PIEvent_ButxPress, PIEvent_ButxRelease (x=1,2,3)
+//|	PIEvent_PtrMove , PIEvent_PtrxMove (x=1,2,3)
+//|	PIEvent_Keyboard
+//
+// void RemoveEventHandler(PIEventHandler* evh)
+//	Suppression d'un gestionnaire d'événements. Toutes les réferences sonnt supprimées en cas
+//	d' enregistrement multiple, même avec différents masques d'événements.
+//--
+
+/* --Methode-- */
+void PIWdgGen::AddDrawHandler(PIEventHandler* drwh, bool ad)
+{
+EvHand eh;
+eh.evh = drwh; eh.mask = PIEvent_Draw;  eh.ad = ad;
+mDHlist.push_back(eh);
+}
+
+/* --Methode-- */
+void PIWdgGen::RemoveDrawHandler(PIEventHandler* drwh)
+{
+list<EvHand>::iterator it;
+bool found = true;
+while (found) {
+  found = false;
+  for(it= mDHlist.begin(); it != mDHlist.end(); it++) 
+    if ((*it).evh == drwh) { mDHlist.erase(it); found = true; break; }
+  }
+}
+
+/* --Methode-- */
+void PIWdgGen::AddEventHandler(PIEventHandler* evh, unsigned long evtmask, bool ad)
+{
+EvHand eh;
+eh.evh = evh; eh.mask = evtmask;  eh.ad = ad;
+mEHlist.push_back(eh);
+}
+
+/* --Methode-- */
+void PIWdgGen::RemoveEventHandler(PIEventHandler* evh)
+{
+list<EvHand>::iterator it;
+bool found = true;
+while (found) {
+  found = false;
+  for(it= mEHlist.begin(); it != mEHlist.end(); it++) 
+    if ((*it).evh == evh) { mEHlist.erase(it); found = true; break; }
+  }
+}
+
+
+/* --Methode-- 
+string PIWdgGen::kindstr()
+{
+char b[5];
+string s;
+
+b[0] = (char) (kind()&0x000000FF);
+b[1] = (char) ((kind()&0x0000FF00) / 0x100);
+b[2] = (char) ((kind()&0x00FF0000) / 0x10000);
+b[3] = (char) ((kind()&0xFF000000) / 0x1000000);
+b[4] = '\0';
+s = b;
+return(s);
+}
+*/
+
+//++
+// Class	PIScreenBuffer
+// Lib		PI
+// include	piwdggen.h
+//
+//	Classe de tampon de dessin hors écran. Permet la copie du contenu des pixels
+//	depuis et vers des objets "PIWdg", ainsi que depuis et vers d'autres tampon
+//	d'écran. Un objet "PIGraphic" peut-être instancié pour fournir les services
+//	de dessin dans un "PIScreenBuffer"
+//--
+//++
+// Links	Voir aussi
+// PIWdg
+// PIGraphic
+//--
+
+//++
+// Titre	Constructeurs, méthodes
+//--
+//++
+// PIScreenBuffer(int sx, int sy)
+//	Constructeur, création d'un tampon de taille "sx * sy" pixels.
+// int  XSize()
+//	Renvoie la taille en X.
+// int  YSize()
+//	Renvoie la taille en Y.
+//
+//	Pour les opérations de copie, le rectangle source est défini par
+//	la position du coin haut-gauche "(ox,oy)" et la taille "dx * dy" en pixels.
+//	La copie s'effectue sur l'objet destination à partir de l'offset "(x,y)".
+//
+// void CopyFromWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y)
+//	Copie depuis l'objet "PIWdg* wdg".
+// void CopyToWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y)
+//	Copie vers l'objet "PIWdg* wdg".
+// void CopyFrom(PIScreenBuffer* grb, int ox, int oy, int dx, int dy, int x, int y)
+//	Copie depuis l'objet "PIScreenBuffer* grb"
+//--
Index: /tags/V_LaSilla191199/SophyaPI/PI/piwdggen.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piwdggen.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piwdggen.h	(revision 464)
@@ -0,0 +1,139 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive      PIWdgGen
+//                                    Reza 10/95            
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIWDG_H_SEEN
+#define PIWDG_H_SEEN
+
+#include "machdefs.h"
+#include "pimsghandler.h"
+
+#include <string>
+#include <list>
+
+
+void PIBeep();
+
+// Les differents types d accrochage aux containers  
+
+enum PIBindingKind {    
+  PIBK_free = 0,
+  PIBK_fixed = 1,
+  PIBK_elastic = 2
+};
+
+enum PICopyPasteKind {    // Pour gerer les types d objets echange en copier/coller
+  PICP_string = 1
+};
+
+class PSFile;
+class PIContainerGen;
+class PIEventHandler;
+
+//  -------------------- Classe PIWdgGen -----------------------
+class PIWdgGen : public PIMsgHandler
+{
+public:
+  enum {ClassId = 100};
+
+                         PIWdgGen(PIContainerGen *par, const char *nom,
+                                   int sx=10, int sy=10, int px=0, int py=0);
+  virtual               ~PIWdgGen();
+  virtual void		 FinishCreate()=0; // apres avoir installe les sous-vues
+
+  virtual long           kind() {return ClassId; }
+//  string               kindstr();
+
+  inline PIContainerGen* Parent() { return( parent ); }
+
+  inline void         	 SetUserData( void * p, int fg = 0) {pdata=p; flag=fg; }
+  inline void*       	 UserData() { return (pdata); };
+  inline void const* 	 UserData() const { return (pdata); };
+  inline int         	 UserFlag() { return(flag); };
+
+
+  virtual void           SetMsg(PIMessage msg = 0);
+  inline  PIMessage      Msg() { return (myMsg); }
+
+  virtual void           SetSize(int sx, int sy)=0;
+  virtual void           SetPos(int px, int py)=0;
+  virtual void           SetBorderWidth(int bw)=0;
+
+//  Gestion des accrochages (binding) aux containers
+  virtual void           SetBinding(PIBindingKind left, PIBindingKind top, 
+                                    PIBindingKind right, PIBindingKind bottom)      =0;
+  virtual bool           GetBinding(PIBindingKind& left, PIBindingKind& top, 
+                                    PIBindingKind& right, PIBindingKind& bottom)    =0;
+  virtual void		 LockBinding();
+  virtual void		 UnLockBinding();
+
+  virtual int            XSize()=0;
+  virtual int            YSize()=0;
+  virtual int            XPos()=0;
+  virtual int            YPos()=0;
+
+  virtual string         Nom()=0;
+  virtual void           GetScreenPos(int & spx, int & spy);
+
+// Pour activer, desactiver un composant graphique (PIWdg)
+  virtual void           Manage()=0;
+  virtual void           UnManage()=0;
+  virtual bool           IfManaged()=0;
+  virtual bool           IsVisible()=0;
+
+//  Fonction qui doit etre appelee pour rafraichir la fenetre 
+  virtual void       	 Refresh()=0;
+
+//  Pour rendre un composant graphique (PIWdg) sensible/insensible 
+//  aux actions utilisateur (souris, clavier, ...)
+  virtual void           SetSensitive()=0;
+  virtual void           SetUnSensitive()=0;
+  virtual bool           IfSensitive()=0;
+
+  virtual void           PSPrint(PSFile *psf, int ofx=0, int ofy=0);
+
+//  Gestion de copier-coller
+  virtual bool           ClaimSelection(unsigned int typ=PICP_string)                     = 0;
+  virtual void           SelectionLost()                                                  = 0;
+  virtual unsigned int   RequestSelection(unsigned int typ=PICP_string)                   = 0;
+  virtual void*          ProvideSelection(unsigned int& typ, unsigned int& len)           = 0;
+  virtual void           SelectionTransferEnd()                                           = 0;
+  virtual void           PasteSelection(unsigned int typ, void *pdata, unsigned int l)    = 0;
+
+//  Copie depuis un PIWdgGen
+  virtual void		 CopyFrom(PIWdgGen* wdg, int ox, int oy, int dx, int dy, int x, int y) = 0;
+
+//  Gestion des EventHandler
+  virtual void		 AddDrawHandler(PIEventHandler* drwh, bool ad=false);
+  virtual void		 RemoveDrawHandler(PIEventHandler* drwh);
+  virtual void		 AddEventHandler(PIEventHandler* evh, unsigned long evtmask, bool ad=false);
+  virtual void		 RemoveEventHandler(PIEventHandler* evh);
+
+// !! Devrait etre protected - mis ici a cause de cxx  Reza 12/98
+  struct EvHand { PIEventHandler* evh; unsigned long mask;  bool ad; };
+protected:
+  PIContainerGen*        parent;
+  PIMessage              myMsg;
+  list<EvHand>		 mDHlist;
+  list<EvHand>		 mEHlist;
+  bool			 bindingLock;
+private:
+  int flag;
+  void * pdata;
+};
+
+// ---- La classe PIScreenBuffer doit se conformer a l'interface suivante
+// class PIScreenBuffer {
+// public :
+//  			PIScreenBuffer(int sx, int sy);
+//  virtual		~PIScreenBuffer();
+//  virtual int         XSize();
+//  virtual int         YSize();
+//  virtual  void 	CopyFromWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y);
+//  virtual  void 	CopyToWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y);
+//  virtual  void 	CopyFrom(PIScreenBuffer* grb, int ox, int oy, int dx, int dy, int x, int y);
+// };
+  
+
+#endif/* PIWDG_H_SEEN */
Index: /tags/V_LaSilla191199/SophyaPI/PI/piwdgmac.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piwdgmac.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piwdgmac.cc	(revision 464)
@@ -0,0 +1,332 @@
+#include "piwdgmac.h"
+#include "pisysdep.h"
+
+#include PICONT_H
+
+#include <LView.h>
+#include <LString.h>
+
+void PIBeep()
+{
+  ::SysBeep(1);
+}
+
+
+PIWdgMac::PIWdgMac(PIContainerGen *par, char *nom,
+                   int sx, int sy, int px, int py)
+:PIWdgGen(par, nom, sx, sy, px, py), mNom(nom)
+{
+  mAdapterPaneInfo.paneID    = 0;
+  mAdapterPaneInfo.width     = sx;
+  mAdapterPaneInfo.height    = sy;
+  mAdapterPaneInfo.visible   = true;
+  mAdapterPaneInfo.enabled   = true;
+  mAdapterPaneInfo.bindings.left =
+    mAdapterPaneInfo.bindings.top =
+    mAdapterPaneInfo.bindings.right =
+    mAdapterPaneInfo.bindings.bottom = false;
+  mAdapterPaneInfo.left      = px;
+  mAdapterPaneInfo.top       = py;
+  mAdapterPaneInfo.userCon   = 0;
+  mAdapterPaneInfo.superView = par ? (LView*) (((PIContainerMac*)(par))->mPane) : NULL;
+
+  mAdapterViewInfo.imageSize.width = sx;
+  mAdapterViewInfo.imageSize.height = sy;
+  mAdapterViewInfo.scrollPos.h = 
+    mAdapterViewInfo.scrollPos.v = 
+    mAdapterViewInfo.scrollUnit.h = 
+    mAdapterViewInfo.scrollUnit.v = 0;
+  mAdapterViewInfo.reconcileOverhang = 0;
+
+  mAdapter = new PIPPViewAdapter(mAdapterPaneInfo, mAdapterViewInfo);
+
+  mPaneInfo.paneID    = 'PIWD';
+  mPaneInfo.width     = sx;
+  mPaneInfo.height    = sy;
+  mPaneInfo.visible   = true;
+  mPaneInfo.enabled   = true;
+  mPaneInfo.bindings.left =
+    mPaneInfo.bindings.top =
+    mPaneInfo.bindings.right =
+    mPaneInfo.bindings.bottom = true;
+  mPaneInfo.left      = 0;
+  mPaneInfo.top       = 0;
+  mPaneInfo.userCon   = 'PIWD';
+  mPaneInfo.superView = mAdapter;
+
+  mViewInfo.imageSize.width = sx;
+  mViewInfo.imageSize.height = sy;
+  mViewInfo.scrollPos.h = 
+    mViewInfo.scrollPos.v = 
+    mViewInfo.scrollUnit.h = 
+    mViewInfo.scrollUnit.v = 0;
+  mViewInfo.reconcileOverhang = 0;
+  
+  mPane = new LView(mPaneInfo, mViewInfo);
+  ((LView*)mAdapter)->CalcPortOrigin();
+  ((LView*)mPane)->CalcPortOrigin();
+}
+
+
+PIWdgMac::~PIWdgMac()
+{
+  delete mPane;
+  delete mAdapter;
+}
+
+void
+PIWdgMac::FinishCreate()
+{
+  mPane->FinishCreate();
+}
+
+void
+PIWdgMac::ListenToMessage(MessageT /*inMessage*/, void */*ioParam*/)
+{
+
+}
+
+void
+PIWdgMac::SetLabel(string const& lab)
+{
+  LStr255 titre(lab.c_str());
+  mPane->SetDescriptor(titre);
+}
+
+void
+PIWdgMac::SetSize(int sx, int sy)
+{
+  if (mAdapter)
+   mAdapter->ResizeFrameTo(sx, sy, true);
+  else
+   mPane->ResizeFrameTo(sx, sy, true);
+}
+
+void
+PIWdgMac::SetPos(int px, int py)
+{
+  if (mAdapter)
+   mAdapter->MoveBy(px-XPos(), py-YPos(), false);
+  else
+   mPane->MoveBy(px-XPos(), py-YPos(), false);
+}
+
+void
+PIWdgMac::SetBinding(PIBindingKind left, PIBindingKind top, 
+                     PIBindingKind right, PIBindingKind bottom)
+{
+  if (mAdapter)  
+    mAdapter->SetBinding(left, top, right, bottom);
+  //else
+  //  mPane->SetBinding(left, top, right, bottom);
+}
+
+bool
+PIWdgMac::GetBinding(PIBindingKind& left, PIBindingKind& top, 
+                     PIBindingKind& right, PIBindingKind& bottom)
+{
+  if (mAdapter)  
+    mAdapter->GetBinding(left, top, right, bottom);
+  //else
+  //  mPane->SetBinding(left, top, right, bottom);
+  return false;
+}
+
+void PIWdgMac::Refresh()
+{
+  if (mPane) mPane->Refresh();
+  if (mAdapter) mAdapter->Refresh();
+}
+
+
+int
+PIWdgMac::XSize()
+{ 
+  SDimension16 outSize;
+  mPane->GetFrameSize(outSize);
+  return outSize.width;
+}
+
+int
+PIWdgMac::YSize()
+{ 
+  SDimension16 outSize;
+  mPane->GetFrameSize(outSize);
+  return outSize.height;
+}
+
+int
+PIWdgMac::XPos()
+{
+  SPoint32 p;
+  mPane->GetFrameLocation(p);
+  return p.h;
+}
+
+int
+PIWdgMac::YPos()
+{
+  SPoint32 p;
+  mPane->GetFrameLocation(p);
+  return p.v;
+}
+
+
+bool 
+PIWdgMac::IsVisible()    // $CHECK$  REZA a verifier  01/12/97
+{
+if (mPane->IsVisible())  return(true);
+else return(false);
+}
+
+
+// Gestion de Copier/Coller
+#include <LClipboard.h>
+/* --Methode-- */
+// COPY
+bool PIWdgMac::ClaimSelection(unsigned int)
+{
+  unsigned int l;
+  char* txt = SelectionString(l);
+  LClipboard::GetClipboard()->SetData('TEXT',txt,l,true);
+  delete[] txt;
+  return (true);
+}
+
+/* --Methode-- */
+void PIWdgMac::SelectionLost()
+{
+}
+
+/* --Methode-- */
+// PASTE
+unsigned int PIWdgMac::RequestSelection(unsigned int)
+{
+  Handle h = NewHandle(0);
+  Int32 l = LClipboard::GetClipboard()->GetData('TEXT', h);
+  if (l) {
+    CopyFromSelection(*h, l);
+  }
+  return 1;
+}
+
+/* --Methode-- */
+void PIWdgMac::CopyFromSelection(char * sv, int l)
+{
+char* buff = new char[l+2];
+strncpy(buff, sv, l);
+buff[l] = '\0';
+printf("PIWdgMac::RequestSelection() L=%d [%s] \n", l, buff);
+delete buff;
+return;
+}
+
+/* --Methode-- */
+void PIWdgMac::PasteSelection(unsigned int, void *buff, unsigned int l)
+{
+  CopyFromSelection((char*) buff, l);
+}
+
+/* --Methode-- */
+char* PIWdgMac::SelectionString(unsigned int& len)
+{
+char *rs = new char[60];
+strcpy(rs, "Test-of-PIWdgMac::SelectionString()");
+len = strlen(rs);
+return(rs);
+}
+
+
+/* --Methode-- */
+void* PIWdgMac::ProvideSelection(unsigned int&, unsigned int& len)
+{
+  return SelectionString(len);
+}
+
+/* --Methode-- */
+void PIWdgMac::SelectionTransferEnd()
+{
+}
+
+/* --Methode-- */
+void PIWdgMac::Manage()
+{
+  if (mAdapter) mAdapter->Show();
+  mPane->Show();
+}
+
+/* --Methode-- */
+void PIWdgMac::UnManage()
+{
+  mPane->Hide();
+  if (mAdapter) mAdapter->Hide();
+}
+
+/* --Methode-- */
+bool PIWdgMac::IfManaged()
+{
+  return(mPane->IsVisible());
+}
+
+
+// -------- La classe PIScreenBuffer ----------
+/* --Methode-- */
+PIScreenBuffer::PIScreenBuffer(int sx, int sy)
+{
+  if (sx < 1) sx = 1;
+  if (sy < 1) sy = 1;
+  Rect bounds = {0,0,sy,sx};
+  mGWorld = new LGWorld(bounds);
+}
+/* --Methode-- */
+PIScreenBuffer::~PIScreenBuffer()
+{
+  delete mGWorld; 
+}
+
+/* --Methode-- */
+int PIScreenBuffer::XSize()
+{
+  Rect bounds;
+  mGWorld->GetBounds(bounds);
+  return bounds.right - bounds.left;
+}
+
+/* --Methode-- */
+int PIScreenBuffer::YSize()
+{
+  Rect bounds;
+  mGWorld->GetBounds(bounds);
+  return bounds.bottom - bounds.top;
+}
+
+/* --Methode-- */
+void PIScreenBuffer::CopyFromWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y)
+{
+  mGWorld->BeginDrawing();
+  LPane* pane = wdg->GetPane();
+  Rect srcRect = {oy, ox, oy+dy, ox+dx};
+  Rect destRect = {y, x, y+dy, x+dx};
+  CopyBits(&pane->GetMacPort()->portBits,&GrafPtr(mGWorld->GetMacGWorld())->portBits,&srcRect,&destRect,srcCopy,NULL);
+  mGWorld->EndDrawing();
+}
+
+/* --Methode-- */
+void PIScreenBuffer::CopyToWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y)
+{
+  LPane* pane = wdg->GetPane();
+  Rect srcRect = {oy, ox, oy+dy, ox+dx};
+  Rect destRect = {y, x, y+dy, x+dx};
+  CopyBits(&GrafPtr(mGWorld->GetMacGWorld())->portBits,&pane->GetMacPort()->portBits,&srcRect,&destRect,srcCopy,NULL);
+}
+
+/* --Methode-- */
+void PIScreenBuffer::CopyFrom(PIScreenBuffer* grb, int ox, int oy, int dx, int dy, int x, int y)
+{
+
+  mGWorld->BeginDrawing();
+  Rect srcRect = {oy, ox, oy+dy, ox+dx};
+  Rect destRect = {y, x, y+dy, x+dx};
+  CopyBits(&GrafPtr(grb->mGWorld->GetMacGWorld())->portBits,&GrafPtr(mGWorld->GetMacGWorld())->portBits,&srcRect,&destRect,srcCopy,NULL);
+  mGWorld->EndDrawing();
+}
Index: /tags/V_LaSilla191199/SophyaPI/PI/piwdgmac.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piwdgmac.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piwdgmac.h	(revision 464)
@@ -0,0 +1,106 @@
+#ifndef PIWDG_MAC_SEEN
+#define PIWDG_MAC_SEEN
+
+#include "piwdggen.h"
+#include "pippviewadapter.h"
+#include <LPane.h>
+#include <LListener.h>
+
+class PIWdgMac : public PIWdgGen, public LListener {
+public:
+  
+                         PIWdgMac(PIContainerGen *par, char *nom,
+                                   int sx=10, int sy=10, int px=0, int py=0);
+  virtual                ~PIWdgMac();
+  virtual void			 FinishCreate(); // apres avoir installe les sous-vues
+                                       
+  virtual void	         ListenToMessage(MessageT inMessage, void *ioParam);
+  virtual void           SetLabel(string const&);
+
+  virtual void           SetSize(int sx, int sy);
+  virtual void           SetPos(int px, int py);
+  virtual void           SetBorderWidth(int /*bw*/) {}
+  
+  virtual void           SetBinding(PIBindingKind left, PIBindingKind top, 
+                                    PIBindingKind right, PIBindingKind bottom);
+  virtual bool           GetBinding(PIBindingKind& left, PIBindingKind& top, 
+                                    PIBindingKind& right, PIBindingKind& bottom);
+  virtual int            XSize();
+  virtual int            YSize();
+  virtual int            XPos();
+  virtual int            YPos();
+  virtual string         Nom()  { return mNom; }
+
+// Pour activer, desactiver un composant graphique (PIWdg)
+  virtual void           Manage();
+  virtual void           UnManage();
+  virtual bool           IfManaged();
+  virtual bool           IsVisible();
+  
+//  Fonction qui doit etre appelee pour rafraichir la fenetre 
+  virtual void       	 Refresh();
+  
+//  Pour rendre un composant graphique (PIWdg) sensible/insensible 
+//  aux actions utilisateur (souris, clavier, ...)
+  virtual void           SetSensitive();
+  virtual void           SetUnSensitive();
+  virtual bool           IfSensitive();
+
+//  Gestion de copier-coller
+  virtual bool           ClaimSelection(unsigned int typ=PICP_string);
+  virtual void           SelectionLost();
+  virtual unsigned int   RequestSelection(unsigned int typ=PICP_string);
+  virtual void*          ProvideSelection(unsigned int& typ, unsigned int& len);
+  virtual void           PasteSelection(unsigned int typ, void *, unsigned int l);
+  virtual void           CopyFromSelection(char *, int l);
+  virtual char*          SelectionString(unsigned int& len);
+  virtual void           SelectionTransferEnd();
+
+//  Copie depuis un PIWdgGen
+  virtual void		 CopyFrom(PIWdgGen* wdg, int ox, int oy, int dx, int dy, int x, int y);
+
+//  Gestion des EventHandler
+  virtual void		 AddDrawHandler(PIEventHandler* drwh, bool ad=false);
+  virtual void		 RemoveDrawHandler(PIEventHandler* drwh);
+  virtual void		 AddEventHandler(PIEventHandler* evh, unsigned long evtmask, bool ad=false);
+  virtual void		 RemoveEventHandler(PIEventHandler* evh);
+
+
+  LPane*                 GetPane() {return mPane;}
+  
+protected:
+  LPane*				 mPane;
+  PIPPViewAdapter*       mAdapter;
+  SPaneInfo				 mAdapterPaneInfo;
+  SViewInfo				 mAdapterViewInfo;
+  SPaneInfo				 mPaneInfo;
+  SViewInfo				 mViewInfo;
+  string                 mNom;
+  
+  friend class PIGraphicMac;
+};
+
+typedef PIWdgMac PIWdg;
+
+// -------- La classe PIScreenBuffer ----------
+
+#include <UGWorld.h>
+
+class PIScreenBuffer {
+public :
+                 PIScreenBuffer(int sx, int sy);
+  virtual       ~PIScreenBuffer();
+
+  virtual int       XSize();
+  virtual int       YSize();
+  virtual void      CopyFromWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y);
+  virtual void      CopyToWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y);
+  virtual void      CopyFrom(PIScreenBuffer* grb, int ox, int oy, int dx, int dy, int x, int y);
+
+protected :
+  LGWorld* mGWorld;
+};
+
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/piwdgx.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piwdgx.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piwdgx.cc	(revision 464)
@@ -0,0 +1,1127 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/IntrinsicP.h>
+#include <X11/Shell.h>
+#include <X11/Core.h>
+#include <X11/CoreP.h>
+
+#include <X11/keysym.h>
+
+#include <Xm/Xm.h>       // A cause des container XmForm 
+#include <Xm/Form.h>     // Idem 
+
+#include "piwdgx.h"
+#include "picontainerx.h"
+#include "pievthandler.h"
+
+
+// #define DEBUG_PIWdgX
+
+// Quelques variables statiques globales, Connection Display, Top Widget Xt, AppContext Xt ...
+// et leurs fonctions d'acces 
+static SysDWdg  top = NULL;
+static Display * dpy = NULL;
+static GC defgc;
+// static char appname[64];
+static char appclass[64];
+static XtAppContext appctx;
+static int appSzX = 10;
+static int appSzY = 10;
+static int appSzFont = 10;
+static XFontStruct * stdfnt = NULL;
+
+// Variable globale Widget qui possede la selection pour le copier-coller
+static PIWdgX* curselwdg = NULL;    // Le PIWdg qui possede la selection
+
+/* Nouvelle-Fonction */
+XtAppContext* PIXtAppCtx(int& szx, int& szy, int& szf)
+{
+szx = appSzX;  szy = appSzY;
+szf = appSzFont;
+return(&appctx);
+}
+
+/* Nouvelle-Fonction */
+SysDWdg   PIXtTopWdg()
+{
+return (top);
+}
+
+/* Nouvelle-Fonction */
+Display * PIXDisplay()
+{
+return(dpy);
+}
+
+/* Nouvelle-Fonction */
+void PIBeep()
+{
+XBell(dpy, 0);
+return;
+}
+
+/* Nouvelle-Fonction */
+int CStrFrXmStr(XmString xms, char* buff, int nmx)
+/*  Pour recuperer le contenu d'un string Motif  */
+{
+int n,l,m;
+XmStringContext cntx;
+char *txs;
+XmStringDirection dir;
+XmStringCharSet cset;
+Boolean sep;
+
+if (nmx < 2)  return(0);
+n = 0;  m = nmx-1;  buff[0] = buff[m] = '\0';
+XmStringInitContext (&cntx, xms);
+while (m > 0)
+  {
+  if (XmStringGetNextSegment( cntx, &txs, &cset, &dir, &sep) )
+    {
+    l = strlen(txs);
+    if (m < l)  txs[m] = '\0';
+    strcpy(buff+n, txs);
+    n += l;   m -= l;
+    if (sep)  m = -2;
+    XtFree(txs);
+    }
+  else m = -1;
+  }
+
+return(n);
+} 
+
+
+/* --Methode-- */
+PIWdgX::PIWdgX(int narg, char *arg[])
+:PIWdgGen(NULL, "PITopLevel")  
+{
+if (top == NULL)  InitXt(narg, arg);
+sdw = top;
+wmis =  k_wmi_appshell;
+stmng = false;
+finishDone = false;
+mBKleft =  mBKright =  mBKtop =  mBKbottom = PIBK_free;
+#ifdef DEBUG_PIWdgX
+printf("Debug_PIWdgX::PIWdgX(int , char * [])  this=%lx  top=%lx \n", (long)this, (long)sdw);
+#endif
+}
+
+
+
+/* --Methode-- */
+PIWdgX::PIWdgX(PIContainerGen *par, const char *nom, 
+               int sx, int sy, int px, int py)
+:PIWdgGen(par, nom, sx, sy, px, py) 
+{
+sdw = NULL;
+wmis = k_wmi_unknown;
+finishDone = false;
+mBKleft =  mBKright =  mBKtop =  mBKbottom = PIBK_free;
+}
+
+/* --Methode-- */
+int PIWdgX::CreateXtWdg(const char *nom, SysDWdgClass wdgcl, SysDWdg pwdg,
+                        int sx, int sy, int px, int py, Arg* oarg, int na)
+{
+Arg  wargs[20];
+int n=0;
+
+#ifdef DEBUG_PIWdgX
+printf("Debug_PIWdgX::CreateXtWdg(%s) Getting in \n");
+#endif
+
+if (pwdg == NULL)
+  {
+  if (parent == NULL)
+    {
+    if (top == NULL)  InitXt();
+    pwdg = top;
+    }
+  // else pwdg = ((PIContainerX *)parent)->sdw;
+  else pwdg = ((PIWdgX *)parent)->sdw;
+  }
+
+n=0;
+if ((sx >= 0) && (sy >= 0))
+  {
+  XtSetArg(wargs[n],XtNwidth,sx);  n++;
+  XtSetArg(wargs[n],XtNheight,sy);  n++;
+  }
+XtSetArg(wargs[n],XtNx,px);  n++;
+XtSetArg(wargs[n],XtNy,py);  n++;
+
+if (na > 16) { printf("PIWdgX::CreateXtWdg()/Warning: na=%d > Max=16 \n", na);  na = 16; }
+for(int kk=0; kk<na; kk++) { wargs[n] = oarg[kk]; n++; }
+
+if (wdgcl == NULL)  wdgcl = coreWidgetClass;
+
+if ( (wdgcl == topLevelShellWidgetClass) || 
+     (wdgcl == transientShellWidgetClass) ||
+     (wdgcl == overrideShellWidgetClass) )
+  {
+  sdw = XtCreatePopupShell(nom, wdgcl, pwdg, wargs, n);
+  }
+else
+  {
+  sdw = XtCreateWidget(nom, wdgcl, pwdg, wargs, n);
+  }
+
+if (wdgcl == topLevelShellWidgetClass)  wmis = k_wmi_toplevel;
+else if (wdgcl == transientShellWidgetClass)  wmis = k_wmi_transient;
+else if (wdgcl == overrideShellWidgetClass)  wmis = k_wmi_override;
+else wmis = k_wmi_normal ;
+
+stmng = false;
+#ifdef DEBUG_PIWdgX
+printf("Debug_PIWdgX::CreateXtWdg(%s) this=%lx sdw=%lx pere=%lx wmis=%d\n", nom, 
+       (long)this, (long)sdw, (long)pwdg, wmis);
+#endif
+
+SetBinding(PIBK_free, PIBK_free, PIBK_free, PIBK_free);
+if (parent) parent->ChildAdd(this);
+return(0);
+}
+
+
+/* --Methode-- */
+PIWdgX::~PIWdgX()
+{
+#ifdef DEBUG_PIWdgX
+printf("Debug_PIWdgX::~PIWdgX()  %lx %lx \n", (long)this, (long)sdw);
+#endif
+if (parent) parent->ChildDel(this);
+UnManage();
+if (curselwdg == this)  { SelectionLost(); curselwdg = NULL; }
+if (sdw)  { 
+// Pour gerer la double structure en Widget des PIWindowX
+  if (wmis == k_wmi_normal) XtDestroyWidget(sdw);
+  else if (wmis == k_wmi_cascade) { 
+    SysDWdg pwdg = XtParent(sdw);
+    XtDestroyWidget(sdw);
+    if (pwdg) XtDestroyWidget(pwdg);
+    }
+  }
+}
+
+
+/* --Methode-- */
+void PIWdgX::FinishCreate()
+{
+// appele par la fenetre mere, apres XtRealize()
+if (finishDone) { 
+  fprintf(stderr, "BUG/PIWdgX::FinishCreate() multiple call \n"); 
+  return; 
+  }
+finishDone = true;
+return;
+}
+
+
+/* --Methode-- */
+void PIWdgX::Manage()
+{
+#ifdef DEBUG_PIWdgX
+printf("Debug_PIWdgX::Manage  this=%lx  sdw=%lx \n", (long)this, (long)sdw);
+#endif
+if (!sdw)  return;
+if (wmis != k_wmi_appshell)  XtManageChild(sdw);
+else if (!XtIsRealized(sdw))  XtRealizeWidget(sdw);  
+stmng = true;
+return;
+}
+
+/* --Methode-- */
+void PIWdgX::UnManage()
+{
+#ifdef DEBUG_PIWdgX
+printf("Debug_PIWdgX::UnManage  this=%lx sdw=%lx \n", (long)this, (long)sdw);
+#endif
+if (!sdw)  return;
+if (wmis != k_wmi_appshell) 
+  XtUnmanageChild(sdw);
+stmng = false;
+return;
+}
+
+/* --Methode-- */
+bool PIWdgX::IfManaged()
+{
+return(stmng);
+}
+
+/* --Methode-- */
+bool PIWdgX::IsVisible()
+{
+if ( (XtIsRealized(XtWdg())) &&  
+   ( (this->XtWdg())->core.visible) )  return(true);
+else return(false);       
+}
+
+/* --Methode-- */
+void PIWdgX::Refresh()
+{
+if (XtIsRealized(XtWdg()))
+  XClearArea(XtDisplay(XtWdg()), XtWindow(XtWdg()), 0, 0, 0, 0, True);
+}
+
+/* --Methode-- */
+void PIWdgX::SetSensitive()
+{
+XtSetSensitive(XtWdg(), TRUE);
+}
+
+/* --Methode-- */
+void PIWdgX::SetUnSensitive()
+{
+XtSetSensitive(XtWdg(), FALSE);
+}
+
+/* --Methode-- */
+bool PIWdgX::IfSensitive()
+{
+if (XtIsSensitive(XtWdg()) == TRUE)  return(true);
+else return(false);
+}
+
+/* --Methode-- */
+void PIWdgX::SetSize(int sx, int sy)
+{
+#ifdef DEBUG_PIWdgX
+printf("Debug_PIWdgX::SetSize  this=%lx  sdw=%lx \n", (long)this, (long)sdw);
+#endif
+
+if (!sdw)  return;
+/*
+Arg  wargs[2];
+XtSetArg(wargs[0],XtNwidth,sx); 
+XtSetArg(wargs[1],XtNheight,sy); 
+XtSetValues(this->sdw, wargs, 2);
+*/
+XtResizeWidget(sdw, sx, sy, BorderWidth());
+
+return;
+} 
+
+/* --Methode-- */
+void PIWdgX::SetPos(int px, int py)
+{
+if (!sdw)  return;
+/*
+Arg  wargs[2];
+XtSetArg(wargs[0],XtNx,px);  
+XtSetArg(wargs[1],XtNy,py);  
+XtSetValues(this->sdw, wargs, 2);
+*/
+XtMoveWidget(sdw, px, py);
+
+return;
+} 
+
+ 
+/* --Methode-- */
+void PIWdgX::SetBinding(PIBindingKind left, PIBindingKind top, 
+                        PIBindingKind right, PIBindingKind bottom)
+{
+if (bindingLock) return;
+mBKleft = left;  mBKright = right;
+mBKtop = top;  mBKbottom = bottom;
+BindWdgtoParent();
+}
+
+
+/* *** ATTENTION *** La constante ci-dessous PIXMFORMFRACBASE
+   doit etre identique ds piwdgx.cc  picontainerx.cc et piwindowx.cc
+   ***************************************************************** */
+#define PIXMFORMFRACBASE 1000
+
+/* --Methode-- */
+void PIWdgX::BindWdgtoParent()
+{
+if (bindingLock) return;
+if (!sdw)  return;
+if (!parent)  return;
+
+
+PIBindingKind left, top, right, bottom;
+left = mBKleft;  right = mBKright;
+top = mBKtop;  bottom = mBKbottom;
+
+int fbase = PIXMFORMFRACBASE ;  // Valeur de XmNfractionBase des XmForm ds PIContainerX
+int frpos = 0;
+float frac;
+Arg  wargs[9];
+int n=0;
+
+// printf(" DEBUG_SetBinding: C-Sz= %d %d - Sz=%d %d , Pos= %d %d \n",  parent->XSize(),
+// parent->YSize(), XSize(), YSize(), XPos(), YPos());
+switch (left)
+  {
+  case PIBK_free : 
+    XtSetArg(wargs[n],XmNleftAttachment, XmATTACH_NONE);  n++;
+    break;
+  case PIBK_fixed :
+    XtSetArg(wargs[n],XmNleftAttachment, XmATTACH_FORM);  n++;
+    XtSetArg(wargs[n],XmNleftOffset, XPos() );  n++;
+    break;
+  case PIBK_elastic :
+    XtSetArg(wargs[n],XmNleftAttachment, XmATTACH_POSITION);  n++;
+    frac = (float)(XPos())/(float)parent->XSize() ;
+    frpos = frac*fbase;
+    XtSetArg(wargs[n],XmNleftPosition, frpos );  n++;
+    break;
+  default :
+    left = PIBK_free;
+    XtSetArg(wargs[n],XmNleftAttachment, XmATTACH_NONE);  n++;
+    break;    
+  }
+ 
+switch (top)
+  {
+  case PIBK_free : 
+    XtSetArg(wargs[n],XmNtopAttachment, XmATTACH_NONE);  n++;
+    break;
+  case PIBK_fixed :
+    XtSetArg(wargs[n],XmNtopAttachment, XmATTACH_FORM);  n++;
+    XtSetArg(wargs[n],XmNtopOffset, YPos() );  n++;
+    break;
+  case PIBK_elastic :
+    XtSetArg(wargs[n],XmNtopAttachment, XmATTACH_POSITION);  n++;
+    frac = (float)(YPos())/(float)parent->YSize() ;
+    frpos = frac*fbase;
+    XtSetArg(wargs[n],XmNtopPosition, frpos );  n++;
+    break;
+  default :
+    top = PIBK_free;
+    XtSetArg(wargs[n],XmNtopAttachment, XmATTACH_NONE);  n++;
+    break;
+  }
+  
+switch (right) 
+  {
+  case PIBK_free : 
+    XtSetArg(wargs[n],XmNrightAttachment, XmATTACH_NONE);  n++;
+    break;
+  case PIBK_fixed :
+    XtSetArg(wargs[n],XmNrightAttachment, XmATTACH_FORM);  n++;
+    XtSetArg(wargs[n],XmNrightOffset, parent->XSize()-(XSize()+XPos()) );  n++;
+    break;
+  case PIBK_elastic :
+    XtSetArg(wargs[n],XmNrightAttachment, XmATTACH_POSITION);  n++;
+    frac = (float)(XPos()+XSize())/(float)parent->XSize() ;
+    frpos = frac*fbase;
+    XtSetArg(wargs[n],XmNrightPosition, frpos );  n++;
+    break;
+  default : 
+    right = PIBK_free;
+    XtSetArg(wargs[n],XmNrightAttachment, XmATTACH_NONE);  n++;
+    break;
+
+  }
+
+switch (bottom) 
+  {
+  case PIBK_free : 
+    XtSetArg(wargs[n],XmNbottomAttachment, XmATTACH_NONE);  n++;
+    break;
+  case PIBK_fixed :
+    XtSetArg(wargs[n],XmNbottomAttachment, XmATTACH_FORM);  n++;
+    XtSetArg(wargs[n],XmNbottomOffset, parent->YSize()-(YSize()+YPos()) );  n++;
+    break;
+  case PIBK_elastic :
+    XtSetArg(wargs[n],XmNbottomAttachment, XmATTACH_POSITION);  n++;
+    frac = (float)(YPos()+YSize())/(float)parent->YSize() ;
+    frpos = frac*fbase;
+    XtSetArg(wargs[n],XmNbottomPosition, frpos );  n++;
+    break;
+  default :
+    bottom =  PIBK_free;
+    XtSetArg(wargs[n],XmNbottomAttachment, XmATTACH_NONE);  n++;
+    break;
+  }
+
+// Widget bwd = (XtParent(this->sdw) == parent->XtWdg()) ? this->sdw : XtParent(this->sdw);
+XtSetValues(this->sdw, wargs, n);
+// printf(" Out_SetBinding: C-Sz= %d %d - Sz=%d %d , Pos= %d %d \n",  parent->XSize(),
+// parent->YSize(), XSize(), YSize(), XPos(), YPos());
+
+return;
+}
+
+/* --Methode-- */
+bool PIWdgX::GetBinding(PIBindingKind& left, PIBindingKind& top, 
+                        PIBindingKind& right, PIBindingKind& bottom)
+{
+left = mBKleft;  right = mBKright;
+top = mBKtop;  bottom = mBKbottom;
+return(bindingLock);
+}
+
+/* --Methode-- */
+void PIWdgX::SetBorderWidth(int bw)
+{
+if (!sdw)  return;
+
+Arg  wargs[2];
+int n=0;
+
+XtSetArg(wargs[n],XtNborderWidth,bw);  n++;
+XtSetValues(this->sdw, wargs, n);
+return;
+}
+
+
+/* --Methode-- */
+int PIWdgX::XSize()
+{
+if (!sdw)  return(-1);
+else return((int)this->sdw->core.width);
+}
+
+/* --Methode-- */
+int PIWdgX::YSize()
+{
+if (!sdw)  return(-1);
+else return((int)this->sdw->core.height);
+}
+
+/* --Methode-- */
+int PIWdgX::XPos()
+{
+if (!sdw)  return(-1);
+else return((int)this->sdw->core.x);
+}
+
+/* --Methode-- */
+int PIWdgX::YPos()
+{
+if (!sdw)  return(-1);
+else return((int)this->sdw->core.y);
+}
+
+
+/* --Methode-- */
+int PIWdgX::BorderWidth()
+{
+if (!sdw)  return(-1);
+Arg  wargs[2];
+int bw;
+XtSetArg(wargs[0],XtNborderWidth, &bw);  
+XtGetValues(this->sdw, wargs, 1);
+return(bw);
+}
+
+/* --Methode-- */
+string PIWdgX::Nom()
+{
+return(XtName(this->sdw));
+}
+
+/* --Methode-- */
+void PIWdgX::GetScreenPos(int & spx, int & spy)
+{
+PIWdgX * wc;
+Display *mdsp;
+Window w, rw, pw, *cw;
+unsigned int ncw;
+Status st;
+int x,y;
+unsigned int bw, l, h, d;
+
+spx = 0;  spy = 0;
+wc = this;
+
+while (wc)
+  { spx += wc->XPos();
+  spy += wc->YPos();  wc = (PIWdgX *)wc->Parent();
+  }
+
+mdsp = XtDisplay(XtWdg());
+w = XtWindow(XtWdg());
+ncw = 0;
+st = XQueryTree(mdsp, w, &rw, &pw, &cw, &ncw);
+if (st) 
+  { XFree(cw);
+  if (pw == rw)  return; }
+
+while (st && (pw != rw))  
+  {
+  w = pw;
+  st = XQueryTree(mdsp, w, &rw, &pw, &cw, &ncw); 
+  if (st)   XFree(cw);
+  XGetGeometry(mdsp, w, &rw, &x, &y, &l, &h, &bw, &d);  
+  spy += y;  spx += x;
+  }  
+return;
+}
+
+
+// Ressources X si non definis 
+static const String fallback_res[26] = {
+"PeidaInt*default*background:                 LightGrey" ,
+"PeidaInt*background:                         LightGrey" ,
+"PeidaInt*bottomShadowColor:                  Black" ,
+"PeidaInt*default*bottomShadowColor:          Black" , 
+"PeidaInt*Foreground:                         Black",
+"PeidaInt*default*Foreground:                 Black",
+"PeidaInt*topShadowColor:                     White",
+"PeidaInt*default*topShadowColor:             White",
+"PeidaInt*borderColor:                        Black",
+"PeidaInt*XmLabel.borderWidth:                0",
+"PeidaInt*XmScrollBar*background:             LightGrey",
+"PeidaInt*XmDrawingArea*background:           Black",
+"PeidaInt*XmPushButton*borderWidth:           0",
+"PeidaInt*XmText*shadowThickness:             2",
+"PeidaInt*XmText*highlightThickness:          0",
+"PeidaInt*XmText*marginHeigt:                 0",
+"PeidaInt*XmText*marginWidth:                 3",
+// "PeidaInt*DefMenubar*XtNwidth:                250",
+// "PeidaInt*DefMenubar*XtNheight:               30",
+"PeidaInt*fontList:           -*-courier-bold-r-normal-*-12-*-*-*-*-*-ISO8859-1",
+"PeidaInt*default*fontList:   -*-courier-bold-r-normal-*-12-*-*-*-*-*-ISO8859-1",
+"PeidaInt*fontFamilyName:                     *-courier",    // Pas de blanc apres le nom de font
+"PeidaInt*courierfontFamilyName:              *-courier",    //           "        " 
+"PeidaInt*helveticafontFamilyName:            *-helvetica",  //           "        " 
+"PeidaInt*timesfontFamilyName:                *-times",      //           "        " 
+"PeidaInt*symbolfontFamilyName:               *-symbol",     //           "        " 
+"PeidaInt*XmToggleButton*selectColor:         Red",
+NULL
+};
+
+
+/* --Methode-- */
+int PIWdgX::InitXt(int narg, char *arg[])
+{
+if (top != NULL)  return(0);
+// Initialisation ...  
+int n;
+const char *pc = (const char *)"PIWdgX";
+char **ppc;
+if (narg > 0)  { n = narg, ppc = arg; }
+else { ppc = const_cast<char **>(&pc); n = 1; }
+//  strncpy(appname, ppc[0], 63); appname[63] = '\0';
+strncpy(appclass,"PeidaInt",63);  appclass[63] = '\0';     
+//-----  XtAppInitialize obsolete (X11/R6 , remplace par XtOpenApplication   -  Reza 14/06/99  -----
+//  top = XtAppInitialize(&appctx, appclass, NULL, 0, &n, ppc, 
+//                      const_cast<String*>(fallback_res), NULL, 0 );
+//BUG ? - DEL top = XtVaAppInitialize(&appctx, appclass, NULL, 0, &n, ppc, const_cast<String*>(fallback_res));
+top = XtOpenApplication(&appctx, appclass, NULL, 0, &n, ppc, const_cast<String*>(fallback_res), 
+                          applicationShellWidgetClass, NULL, 0);
+if (top == NULL) {
+  fprintf(stderr, "PIWdgX::InitXt()/ Error XtVaAppInitialize() -> Exit \n");
+  exit(9);
+  }
+dpy = XtDisplay(top);
+if (dpy == NULL)  {
+  fprintf(stderr, "PIWdgX::InitXt()/ Error XtVaAppInitialize()/DisplayConnection -> Exit \n");
+  exit(9);
+  }
+
+/*  le GC pour les XCopyArea */
+XGCValues  xgv;
+xgv.function = GXcopy;
+xgv.plane_mask = ~0;
+defgc = XCreateGC (dpy, DefaultRootWindow(dpy), GCFunction | GCPlaneMask, &xgv); 
+
+// On va recuperer la fonte par defaut des composantes Motif
+XtResource res[] = {
+  { (char *)"fontList", (char *)"FontList", XtRString, sizeof(String),
+    0, XtRString, "-*-courier-bold-*-*-*-*-*-*-*-*-*-*-*" }
+};
+
+String fntname;
+XtGetApplicationResources(top, &fntname, res, XtNumber(res), NULL, 0);
+// scr = XDefaultScreen(dpy);
+// printf("-DBG-F= %s \n", fntname);
+int count;
+char **list;
+char buff[256];
+strcpy(buff, fntname);
+list = XListFonts(dpy, buff, 15, &count);
+if (count < 1)  { 
+  strcpy(buff,"-*-*-*-*-*-*-*-*-*-*-*-*-*-*" );
+  XFreeFontNames(list);
+  list = XListFonts(dpy, buff, 15, &count);
+  }
+stdfnt = XLoadQueryFont(dpy, buff);
+char * myfntname = "???";
+// Recherche du champ taille en pixel de la fonte : apres le 7eme tiret
+int mySzFont = 12;
+if (count > 0) {
+  myfntname = list[0];
+  int kt = 0;
+  int kdx = 0;
+  char * pcf = list[0];
+  //  printf("DBG-X1 : %s \n ", pcf);
+  while (kt < 7)  {
+    if (pcf[kdx] == '-')  kt++;
+    if (pcf[kdx] == '\0')  break;
+    kdx++;
+    }
+  //  printf("DBG-X2 : %s \n ", pcf+kdx);
+  int iii = 0;
+  while ( (pcf[kdx+iii] != '-') && (pcf[kdx+iii] != '\0') )
+     { buff[iii] = pcf[kdx+iii];  iii++; }
+  buff[iii] = '\0';
+  mySzFont = atoi(buff);
+  //  printf("*DBG*X3* %s -> %d \n", buff, mySzFont);
+}
+// On calcule la taille de la chaine CANCEL (6 caracteres)
+char a[2];
+XCharStruct  ovr;
+int hd, fa, fd, len;  // direction, font-ascent, font-descent len("CANCEL")
+XTextExtents(stdfnt, a, 0, &hd, &fa, &fd, &ovr);
+len = XTextWidth(stdfnt, "CANCEL", 6);
+appSzY = (float)(fa+fd)*1.5+8;  // pour les shadow  $CHECK$ - a ameliorer peut-etre 
+appSzX = (float)len*1.5;
+appSzFont =  mySzFont ;
+// Taille X multiple de 5 pixels, Y mult 2 pixels 
+if ( (appSzX % 5) != 0 )   appSzX = 5*(appSzX/5 + 1);
+if ( (appSzY % 2) != 0 )   appSzY = 2*(appSzY/2 + 1);
+if(appSzY < 10) appSzY = 10;
+if(appSzX < 30) appSzX = 30;
+
+// printf("PIWdgX::InitXt(Font=%s- %d %d , %d ) SzX,Y= %d %d - FSz= %d \n", myfntname, fa,fd,len,appSzX, appSzY, appSzFont);
+XFreeFontNames(list);
+return(0);
+}
+
+/* .................................................................*/
+/* ................... Gestion de Copier/Coller ....................*/
+/* .................................................................*/
+
+// Les Call-Backs Xt
+
+static Boolean forXt_ConvertSelection(Widget w, Atom* sel, Atom *targ, Atom* typ,
+                                   XtPointer* value, unsigned long* len, int* format);
+
+static void forXt_LoseSelection(Widget w, Atom* sel);
+static void forXt_DoneSelection(Widget w, Atom* sel, Atom *targ);
+static void forXt_SelectionValue(Widget w, XtPointer usd, Atom* sel, Atom* typ, 
+                                 XtPointer value, unsigned long* len, int* format );
+
+static unsigned int curseltype = PICP_string; // Type de selcetion qu'il peut fournir
+static unsigned int reqseltype = PICP_string; // Type de selection demande
+static unsigned int provseltype = PICP_string; // Type de selection fourni
+
+/* Nouvelle-Fonction */
+Boolean forXt_ConvertSelection(Widget w, Atom* sel, Atom *targ, Atom* typ,
+                                   XtPointer* value, unsigned long* len, int* format)
+{
+if (*targ != XA_STRING)  return(FALSE);
+if (!curselwdg)  return(FALSE);
+unsigned int ll = 0;
+unsigned int styp = reqseltype;
+*value = curselwdg->ProvideSelection(styp, ll);
+*len=ll;
+*typ = XA_STRING;
+*format = 8;
+provseltype = (styp != 0) ? styp : PICP_string;
+return(TRUE);
+}
+
+/* Nouvelle-Fonction */
+void forXt_LoseSelection(Widget w, Atom* sel)
+{
+if (curselwdg)  curselwdg->SelectionLost();
+curselwdg = NULL; curseltype = PICP_string; 
+}
+
+/* Nouvelle-Fonction */
+void forXt_DoneSelection(Widget w, Atom* sel, Atom *targ)
+{
+if (curselwdg)  curselwdg->SelectionTransferEnd();
+}
+
+/* Nouvelle-Fonction */
+void forXt_SelectionValue(Widget w, XtPointer usd, Atom* sel, Atom* typ, 
+                                 XtPointer value, unsigned long* len, int* format )
+{
+if ( (value != NULL) && (*len > 0) ) 
+  ((PIWdgX*)usd)->PasteSelection(provseltype, (void*)value, (*len)) ;
+}
+
+
+
+// Gestion de Copier/Coller
+/* --Methode-- */
+bool PIWdgX::ClaimSelection(unsigned int typ)
+// Pour prendre possession du buffer copier/coller
+{
+if (XtOwnSelection(XtWdg(), XA_PRIMARY, PIXGetLastEventTime(), forXt_ConvertSelection, 
+                   forXt_LoseSelection, forXt_DoneSelection) ) {
+#ifdef DEBUG_PIWdgX
+  printf("PIWdgX::ClaimSelection(%d) - OK  (Wdg= %lx)\n", typ, (unsigned long)this);
+#endif
+  curselwdg = this;
+  curseltype = (typ != 0) ? typ : PICP_string;
+  return (true);
+}
+else {
+#ifdef DEBUG_PIWdgX
+  printf("PIWdgX::ClaimSelection() - Probleme (Wdg= %lx)\n", (unsigned long)this);
+#endif
+  curselwdg = NULL;
+  curseltype = PICP_string;
+  return (false);
+}
+}
+
+/* --Methode-- */
+void PIWdgX::SelectionLost()
+// Appele quand le PIWdg perd la possession du buffer copier/coller
+{
+return;
+}
+
+/* --Methode-- */
+unsigned int PIWdgX::RequestSelection(unsigned int typ)
+{
+// Pour demander le contenu du buffer de copier/coller
+#ifdef DEBUG_PIWdgX
+printf("PIWdgX::RequestSelection(%d) (Wdg= %lx - %lx) \n", typ,  
+        (unsigned long)this, (unsigned long)curselwdg);
+#endif
+reqseltype = (typ != 0) ? typ : PICP_string;
+XtGetSelectionValue(XtWdg(), XA_PRIMARY, XA_STRING, forXt_SelectionValue, 
+                    (XtPointer)this, PIXGetLastEventTime());
+return(reqseltype);
+}
+
+static char* rs = NULL;
+
+/* --Methode-- */
+void* PIWdgX::ProvideSelection(unsigned int& typ, unsigned int& len)
+// Le widget doit fournier une l zone memoire contenant la selection
+// en un type donne
+// Renvoie le pointeur de cette zone, sa taille et son typ
+{
+rs = new char[128];
+sprintf(rs, "Test-of-PIWdgX::ProvideSelection(%d)- %lx", typ,(long)rs);
+len = strlen(rs);
+return(rs);
+}
+
+/* --Methode-- */
+void PIWdgX::SelectionTransferEnd()
+{
+delete[] rs;
+}
+
+
+/* --Methode-- */
+void PIWdgX::PasteSelection(unsigned int typ, void *buff, unsigned int l)
+{
+// Methode appele apres que le widget ait fait RequestSelection
+// Le typ de donnees fourni ainsi que les donnees et leur taille 
+// sont en argument 
+#ifdef DEBUG_PIWdgX
+char* mbuff = new char[l+1];
+strncpy(mbuff, (char *)buff, l);
+mbuff[l] = '\0';
+printf("PIWdgX::PasteSelection(%d, %lx, %d) [%s] \n", typ, (long)buff, l, mbuff);
+delete[] mbuff;
+#endif
+return;
+}
+
+//  Copie depuis un PIWdgGen
+void PIWdgX::CopyFrom(PIWdgGen* wdg, int ox, int oy, int dx, int dy, int x, int y)
+{
+PIWdgX* wx = (PIWdgX*)wdg;
+XCopyArea(XtDisplay(XtWdg()), XtWindow(wx->XtWdg()), XtWindow(XtWdg()), defgc, ox, oy, 
+          (unsigned int)dx, (unsigned int)dy, x, y);
+}
+
+
+// Declaration de l' EventHandler Xt
+static void evthandler_piwdgx (Widget wdgp, XtPointer, XEvent* evt, Boolean* cont);
+
+
+/* --Methode-- */
+void PIWdgX::AddDrawHandler(PIEventHandler* drwh, bool ad)
+{
+PIWdgGen::AddDrawHandler(drwh, ad);
+XtInsertEventHandler( XtWdg(), ExposureMask, FALSE, evthandler_piwdgx, this, XtListTail);
+}
+
+/* --Methode-- */
+void PIWdgX::RemoveDrawHandler(PIEventHandler* drwh)
+{
+PIWdgGen::RemoveDrawHandler(drwh);
+if (mEHlist.size() <= 0) XtRemoveEventHandler( XtWdg(), ExposureMask, FALSE, evthandler_piwdgx, this);
+}
+
+/* --Methode-- */
+void PIWdgX::AddEventHandler(PIEventHandler* evh, unsigned long evtmask, bool ad)
+{
+PIWdgGen::AddEventHandler(evh, evtmask, ad);
+EventMask mask = 0;
+// if (evtmask & PIEvent_Resize)  pas traite pour le moment
+if (evtmask & PIEvent_Enter)  mask |= EnterNotify;
+if (evtmask & PIEvent_Leave)  mask |= LeaveNotify;
+if (evtmask & PIEvent_But1Press)  mask |= ButtonPressMask;
+if (evtmask & PIEvent_But1Release)  mask |= ButtonReleaseMask;
+if (evtmask & PIEvent_But2Press)  mask |= ButtonPressMask;
+if (evtmask & PIEvent_But2Release)  mask |= ButtonReleaseMask;
+if (evtmask & PIEvent_But3Press)  mask |= ButtonPressMask;
+if (evtmask & PIEvent_But3Release)  mask |= ButtonReleaseMask;
+if (evtmask & PIEvent_PtrMove)  mask |= PointerMotionHintMask;
+if (evtmask & PIEvent_Ptr1Move)  mask |= (PointerMotionHintMask | Button1MotionMask);
+if (evtmask & PIEvent_Ptr2Move)  mask |= (PointerMotionHintMask | Button2MotionMask);
+if (evtmask & PIEvent_Ptr3Move)  mask |= (PointerMotionHintMask | Button3MotionMask);
+if (evtmask & PIEvent_Keyboard)  mask |= KeyPressMask;
+printf("PIWdgX::AddEventHandler() Mask = %lx \n", (long)mask);
+XtInsertEventHandler( XtWdg(), mask, FALSE, evthandler_piwdgx, this, XtListTail);
+}
+
+/* --Methode-- */
+void PIWdgX::RemoveEventHandler(PIEventHandler* evh)
+{
+PIWdgGen::RemoveEventHandler(evh);
+if (mEHlist.size() > 0) return; 
+EventMask mask = EnterNotify;
+mask |= LeaveNotify;
+mask |= ButtonPressMask;
+mask |= ButtonRelease;
+mask |= ButtonPressMask;
+mask |= ButtonRelease;
+mask |= ButtonPressMask;
+mask |= ButtonRelease;
+mask |= PointerMotionHintMask;
+mask |= (PointerMotionHintMask | Button1MotionMask);
+mask |= (PointerMotionHintMask | Button2MotionMask);
+mask |= (PointerMotionHintMask | Button3MotionMask);
+mask |= KeyPressMask;
+XtRemoveEventHandler( XtWdg(), mask, FALSE, evthandler_piwdgx, this);
+}
+
+/* --Methode-- */
+void PIWdgX::CallDrawHandlers(int x0, int y0, int dx, int dy)
+{
+PIGraphicWin* g = new PIGraphicWin(this);
+PIEventHandler* eh;
+list<EvHand>::iterator it;
+for(it= mDHlist.begin(); it != mDHlist.end(); it++) { 
+  eh = (*it).evh;
+  eh->SetCurrentWdg(this);
+  eh->SetEventInfo(PIEvent_Draw, x0, y0, 0, PIKM_Blank, 0);
+  g->SaveGraphicAtt();
+  eh->Draw(g, x0, y0, dx, dy);
+  g->RestoreGraphicAtt();
+  }
+delete g;
+}
+
+/* --Methode-- */
+void PIWdgX::CallEventHandlers(unsigned long evt, int px, int py,
+                               int k, int km, unsigned long tm)
+{
+PIEventHandler* eh;
+list<EvHand>::iterator it;
+for(it= mEHlist.begin(); it != mEHlist.end(); it++) {
+  if (!((*it).mask & evt))  continue; 
+  eh = (*it).evh;
+  eh->SetCurrentWdg(this);
+  eh->SetEventInfo((PIEventMask)evt, px, py, k, (PIKeyModifier)km, tm);
+  eh->ProcessEvent();
+  }
+}
+
+
+// -------   Event Handler Xt ----------
+/* Nouvelle-Fonction */
+void evthandler_piwdgx (Widget wdgp, XtPointer usd, 
+                             XEvent* evt, Boolean* cont)
+{
+
+*cont = true ; 
+PIWdgX* wx = (PIWdgX*)usd;
+PIEventMask evm = PIEvent_None;
+PIKeyModifier kmod = PIKM_Blank;
+
+switch (evt->type) {
+  case Expose :
+    wx->CallDrawHandlers(evt->xexpose.x , evt->xexpose.y , evt->xexpose.width , evt->xexpose.height);
+    break;
+  case EnterNotify : 
+    wx->CallEventHandlers(PIEvent_Enter, evt->xcrossing.x, evt->xcrossing.y, 0, 
+                          PIKM_Blank, evt->xcrossing.time);
+    PIXSetLastEventTimeSerial(evt->xcrossing.time, evt->xcrossing.serial);
+    break;
+
+  case LeaveNotify : 
+    wx->CallEventHandlers(PIEvent_Leave, evt->xcrossing.x, evt->xcrossing.y, 0, 
+                          PIKM_Blank, evt->xcrossing.time);
+    PIXSetLastEventTimeSerial(evt->xcrossing.time, evt->xcrossing.serial);
+  break;
+
+  case ButtonPress :
+    if  (evt->xbutton.state & ShiftMask)   
+      kmod = (PIKeyModifier) (kmod | PIKM_Shift);
+    if  (evt->xbutton.state & ControlMask) 
+      kmod = (PIKeyModifier) (kmod | PIKM_Cntl);
+    if  (evt->xbutton.state & Mod1Mask)    
+      kmod = (PIKeyModifier) (kmod | PIKM_Alt);
+    if (evt->xbutton.button == 1) evm = PIEvent_But1Press;
+    else if (evt->xbutton.button == 2) evm = PIEvent_But2Press;
+    else if (evt->xbutton.button == 3) evm = PIEvent_But3Press;
+    wx->CallEventHandlers(evm, evt->xbutton.x, evt->xbutton.y, 0, 
+                          kmod, evt->xbutton.time);
+    PIXSetLastEventTimeSerial(evt->xbutton.time, evt->xbutton.serial);
+  break;
+
+  case ButtonRelease :
+    if  (evt->xbutton.state & ShiftMask)   
+      kmod = (PIKeyModifier) (kmod | PIKM_Shift);
+    if  (evt->xbutton.state & ControlMask) 
+      kmod = (PIKeyModifier) (kmod | PIKM_Cntl);
+    if  (evt->xbutton.state & Mod1Mask)    
+      kmod = (PIKeyModifier) (kmod | PIKM_Alt);
+    if (evt->xbutton.button == 1) evm = PIEvent_But1Release;
+    else if (evt->xbutton.button == 2) evm = PIEvent_But2Release;
+    else if (evt->xbutton.button == 3) evm = PIEvent_But3Release;
+
+    wx->CallEventHandlers(evm, evt->xbutton.x, evt->xbutton.y, 0, 
+                          kmod, evt->xbutton.time);
+    PIXSetLastEventTimeSerial(evt->xbutton.time, evt->xbutton.serial);
+  break;
+
+  case MotionNotify :
+    {
+    int xw, yw, xr, yr;
+    unsigned int key_but;
+    Window rw, cw;
+    if ( evt->xmotion.is_hint == NotifyHint ) { 
+      if (!XQueryPointer( XtDisplay(wdgp), evt->xmotion.window, &rw, &cw,
+                  &xr, &yr, &xw, &yw, &key_but) ) break ;
+      }
+    else { key_but =  evt->xmotion.state ; xw = evt->xmotion.x;  yw = evt->xmotion.y; }
+    if  (key_but & Button1Mask ) evm = PIEvent_Ptr1Move;
+    else  if (key_but & Button2Mask ) evm = PIEvent_Ptr2Move;
+    else  if (key_but & Button3Mask ) evm = PIEvent_Ptr3Move;
+    else if ( !(key_but & (Button4Mask|Button5Mask)) )  evm = PIEvent_PtrMove;
+
+    if  (key_but & ShiftMask)   kmod = (PIKeyModifier) (kmod | PIKM_Shift);
+    if  (key_but & ControlMask) kmod = (PIKeyModifier) (kmod | PIKM_Cntl);
+    if  (key_but & Mod1Mask)    kmod = (PIKeyModifier) (kmod | PIKM_Alt);
+
+    wx->CallEventHandlers(evm, xw, yw, 0, kmod, evt->xbutton.time);
+    PIXSetLastEventTimeSerial(evt->xmotion.time, evt->xmotion.serial);    
+    }
+  break;
+
+  case KeyPress :
+    {
+    XComposeStatus cs;
+    KeySym key;
+    char buf[10];
+    int i,nc,rkey;
+
+  
+    kmod = PIKM_Blank;
+    nc = XLookupString(&(evt->xkey), buf, 10, &key, &cs);
+
+    if  (evt->xkey.state & ShiftMask)   
+      kmod = (PIKeyModifier) (kmod | PIKM_Shift);
+    if  (evt->xkey.state & ControlMask) 
+      kmod = (PIKeyModifier) (kmod | PIKM_Cntl);
+    if  (evt->xkey.state & Mod1Mask)    
+      kmod = (PIKeyModifier) (kmod | PIKM_Alt);
+    switch (key) {
+      case XK_Return :
+        rkey = PIK_Return;
+      break;
+      case XK_KP_Enter :
+        rkey = PIK_Enter;
+      break;
+      case XK_Up :
+        rkey = PIK_Up;
+      break;
+      case XK_Down :
+        rkey = PIK_Down;
+      break;
+      case XK_Left :
+        rkey = PIK_Left;
+      break;
+      case XK_Right :
+        rkey = PIK_Right;
+      break;
+      case XK_Prior :
+        rkey = PIK_Previous;
+      break;
+      case XK_Next :
+        rkey = PIK_Next;
+      break;
+      default :
+        rkey = 0;
+      break;
+    }
+    if (rkey > 0)  wx->CallEventHandlers(PIEvent_Keyboard, evt->xkey.y, evt->xkey.x, 
+                                         rkey, kmod, evt->xkey.time);
+    else for(i=0; i<nc; i++)  
+            wx->CallEventHandlers(PIEvent_Keyboard, evt->xkey.y, evt->xkey.x, 
+                                 (int)(buf[i]), kmod, evt->xkey.time);
+    PIXSetLastEventTimeSerial(evt->xkey.time, evt->xkey.serial);    
+
+  }
+  break;
+}
+
+return;
+}
+
+
+// -------- La classe PIScreenBuffer ----------
+/* --Methode-- */
+PIScreenBuffer::PIScreenBuffer(int sx, int sy)
+{
+if (sx < 1) sx = 1;
+if (sy < 1) sy = 1;
+mSx = sx;  mSy = sy;
+Display * dsx = PIXDisplay();
+Window rw = DefaultRootWindow(dsx);
+xScrbuff = XCreatePixmap(dsx, rw, sx, sy, DefaultDepth(dsx, DefaultScreen(dsx)) );
+}
+/* --Methode-- */
+PIScreenBuffer::~PIScreenBuffer()
+{
+XFreePixmap(PIXDisplay(),xScrbuff); 
+}
+
+/* --Methode-- */
+int PIScreenBuffer::XSize()
+{
+return(mSx);
+}
+
+/* --Methode-- */
+int PIScreenBuffer::YSize()
+{
+return(mSx);
+}
+
+/* --Methode-- */
+void PIScreenBuffer::CopyFromWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y)
+{
+XCopyArea(XtDisplay(wdg->XtWdg()), XtWindow(wdg->XtWdg()), XScrBuffer(), defgc, ox, oy, 
+          (unsigned int)dx, (unsigned int)dy, x, y);
+}
+
+/* --Methode-- */
+void PIScreenBuffer::CopyToWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y)
+{
+XCopyArea(XtDisplay(wdg->XtWdg()), XScrBuffer(), XtWindow(wdg->XtWdg()), defgc, ox, oy, 
+          (unsigned int)dx, (unsigned int)dy, x, y);
+}
+
+/* --Methode-- */
+void PIScreenBuffer::CopyFrom(PIScreenBuffer* grb, int ox, int oy, int dx, int dy, int x, int y)
+{
+
+XCopyArea(PIXDisplay(), grb->XScrBuffer(), XScrBuffer(), defgc, ox, oy, 
+          (unsigned int)dx, (unsigned int)dy, x, y);
+}
Index: /tags/V_LaSilla191199/SophyaPI/PI/piwdgx.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piwdgx.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piwdgx.h	(revision 464)
@@ -0,0 +1,146 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive      PIWdgX
+//                                    Reza 10/95            
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIWDG_X_SEEN
+#define PIWDG_X_SEEN
+
+#include <X11/Xlib.h>
+#include <X11/Intrinsic.h>
+
+#include "piwdggen.h"
+
+typedef Widget SysDWdg;
+typedef WidgetClass SysDWdgClass;
+
+
+class PIWdgX : public PIWdgGen 
+{
+public:
+// Les methodes ...
+  		  PIWdgX(int narg=0, char *arg[]=NULL);
+  		  PIWdgX(PIContainerGen *par, const char *nom, 
+         		 int sx=10, int sy=10, int px=0, int py=0);
+
+  virtual 	 ~PIWdgX();
+
+  virtual void	 FinishCreate(); // apres avoir installe les sous-vues
+
+  virtual void   SetSize(int sx, int sy);
+  virtual void   SetPos(int px, int py);
+
+  virtual void   SetBinding(PIBindingKind left, PIBindingKind top, 
+                            PIBindingKind right, PIBindingKind bottom);
+  virtual bool   GetBinding(PIBindingKind& left, PIBindingKind& top, 
+                            PIBindingKind& right, PIBindingKind& bottom);
+
+  virtual int    XSize();
+  virtual int    YSize();
+  virtual int    XPos();
+  virtual int    YPos();
+
+  virtual string Nom();  
+  virtual void   GetScreenPos(int & spx, int & spy);
+
+  virtual void   Manage();
+  virtual void   UnManage();
+  virtual bool   IfManaged();
+  virtual bool   IsVisible();
+
+//  Fonction qui doit etre appelee pour rafraichir la fenetre 
+  virtual void       	 Refresh();
+
+//  Pour rendre un composant graphique (PIWdg) sensible/insensible 
+  virtual void           SetSensitive();
+  virtual void           SetUnSensitive();
+  virtual bool           IfSensitive();
+
+//  Gestion de copier-coller
+  virtual bool           ClaimSelection(unsigned int typ=PICP_string);
+  virtual void           SelectionLost();
+  virtual unsigned int   RequestSelection(unsigned int typ=PICP_string);
+  virtual void*          ProvideSelection(unsigned int& typ, unsigned int& len);
+  virtual void           SelectionTransferEnd();
+  virtual void           PasteSelection(unsigned int typ, void *, unsigned int l);
+
+//  Copie depuis un PIWdgGen
+  virtual void		 CopyFrom(PIWdgGen* wdg, int ox, int oy, int dx, int dy, int x, int y);
+
+//  Gestion des EventHandler
+  virtual void		 AddDrawHandler(PIEventHandler* drwh, bool ad=false);
+  virtual void		 RemoveDrawHandler(PIEventHandler* drwh);
+  virtual void		 AddEventHandler(PIEventHandler* evh, unsigned long evtmask, bool ad=false);
+  virtual void		 RemoveEventHandler(PIEventHandler* evh);
+
+// En public, pour permettre l'acces depuis call-back Xt
+  virtual void		 CallDrawHandlers(int x0, int y0, int dx, int dy); 
+  virtual void		 CallEventHandlers(unsigned long evt, int px, int py,
+                                           int k, int km, unsigned long tm);
+
+//  Usage limite a a la version X11
+  inline SysDWdg XtWdg() const {return(sdw); }; 
+  inline SysDWdg& XtWdg() {return(sdw); }; 
+  int 		CreateXtWdg(const char *nom, SysDWdgClass wdgcl=NULL, SysDWdg pwdg=NULL,
+                  int sx=10, int sy=10, int px=0, int py=0, Arg* oarg=NULL, int na=0);
+  int   	BorderWidth();
+  void  	SetBorderWidth(int bw);
+
+protected:
+// Attache effectivement le widget au container
+// Parent - Doit etre appele ds FinishCreate  
+  virtual void		BindWdgtoParent();  
+
+// Definit le type de Widget, en particulier pour la gestion des feneteres de haut niveau
+// k_wmi_cascade : Widget cree en cascade d'un autre (Exemple pour PIWIndowX)
+  enum WmIntState { k_wmi_unknown=0,
+                    k_wmi_normal=1, k_wmi_toplevel=2, 
+                    k_wmi_transient=3, k_wmi_override=4,
+                    k_wmi_appshell=5, k_wmi_cascade=6 };
+
+  int 		InitXt(int narg=0, char *arg[]=NULL); 
+
+  SysDWdg sdw;
+  WmIntState wmis;
+  bool stmng;
+  bool finishDone;  // FinishCreate appele
+  PIBindingKind mBKleft, mBKright, mBKtop, mBKbottom;
+};
+
+typedef PIWdgX PIWdg;
+
+// -------- La classe PIScreenBuffer ----------
+class PIScreenBuffer {
+public :
+  			PIScreenBuffer(int sx, int sy);
+  virtual		~PIScreenBuffer();
+
+  virtual int         	XSize();
+  virtual int         	YSize();
+  virtual  void 	CopyFromWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y);
+  virtual  void 	CopyToWdg(PIWdg* wdg, int ox, int oy, int dx, int dy, int x, int y);
+  virtual  void 	CopyFrom(PIScreenBuffer* grb, int ox, int oy, int dx, int dy, int x, int y);
+
+//  Acces au Drawable X 
+  inline Pixmap		XScrBuffer() { return(xScrbuff); }
+protected :
+  Pixmap xScrbuff;
+  int mSx, mSy;
+};
+
+
+// Utile pour avoir acces au Display et Screen X ...
+SysDWdg   PIXtTopWdg();
+XtAppContext* PIXtAppCtx(int& szx, int& szy, int& szf);
+Display * PIXDisplay();
+#define  PIXScreen()  DefaultScreen(PIXDisplay()) 
+Time PIXGetLastEventTime();
+unsigned long PIXGetLastEventSerial();
+void PIXSetLastEventTimeSerial(Time t, unsigned long ser);
+void PIXGetLastEventInfo(unsigned int& st, Time& t);
+
+
+#endif/* PIWDGX_SEEN */
+
+
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/piwindowgen.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piwindowgen.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piwindowgen.cc	(revision 464)
@@ -0,0 +1,110 @@
+//  Classe de base pour les fenêtre de premier niveau
+//  dans les programmes graphiques interactives
+//
+//                  E.Aubourg , R. Ansari  96 - 98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "piwindowgen.h"
+#include "psfile.h"
+
+//++
+// Class	PIWindow
+// Lib		PI
+// include	piwindowgen.h
+//
+//	Classe de conteneur (dérivant de *PIContainer") spécialisée pour 
+//	la création des fenêtres de premier niveau, gérée par l'application
+//	"WindowManager". La classe "PIWindow" a  implementation dépendante 
+//	du systeme utilisé (Mac, XWindow, ...). La classe "PIWindowGen" est 
+//	la classe qui définit l'interface, et ne pas doit être instanciée 
+//	directement (Méthodes virtuelles pures). Les objets instanciés sont 
+//	de la classes "PIWindow" et le fichier entête correspondant est 
+//	"PIWIN_H" défini dans "pisysdep.h"
+//--
+//++
+// Links	Parents
+// PIContainer
+//--
+//++
+// Titre	Constructeur
+//--
+//++
+// PIWindowGen(PIMsgHandler* par, const char *nom, PIWindowKind k=PIWK_normal, int sx=10, int sy=10, int px=0, int py=0)
+//	Création d'une fenêtre de haut niveau. La variable "PIWindowKind k"  contrôle
+//	le comportement de l'objet vis à vis de l'application WindowManager. Le comportement
+//	exacte, ainsi que l'apparence graphique dépend de la plateforme et du WindowManager
+//	utilisés. "par" est le l'objet "PIMsgHandler" dont dépend la fenêtre, en général un objet
+//	de la classe "PIApplication". "nom" désigne le nom, "sx,sy" la taille et 
+//	"px,py" la position de l'objet.
+//	- "PIWK_normal" : fenêtre ordinaire
+//	- "PIWK_floating" : fenêtre qui reste en avant plan 
+//	- "PIWK_dialog" : fenêtre de dialogue 
+//	- "PIWK_transient" : fenêtre apparaissant an avant plan, sans barre de contrôle 
+// long kind()
+//	Renvoie le type de la classe de l'objet ("=PIWindowGen::ClassId") pour cette classe.
+//--
+
+//++
+// Titre	Méthodes
+//--
+//++
+// void  AutoHideOnClose(bool ahc=true)
+//	Contrôle le comportement par défaut de l'objet quand la fenêtre est fermée
+//	à travers le WindowManager. si "ahc=true", "Hide()" est appelé. 
+//	Le message de l'objet avec le qualificatif "PIMsg_Closë est transmis
+//	au "PIMsgHandler" parent.
+// void  PSPrint(PSFile *psf, int ofx=0, int ofy=0)
+//	Définit une nouvelle page et appelle la méthode "PSPrint()" pour tous les
+//	objets "PIWdg" contenus dans la fenêtre.
+//--
+
+
+/* --Methode-- */
+PIWindowGen::PIWindowGen(PIMsgHandler *par, const char *nom, PIWindowKind k, 
+                         int sx, int sy, int px, int py)
+: PIContainer(NULL, nom, sx, sy, px, py), mWtyp(k)
+{
+  SetMsgParent(par);
+  AutoHideOnClose();
+}
+
+
+/* --Methode-- */
+PIWindowGen::~PIWindowGen()
+{}
+
+/* --Methode-- */
+void PIWindowGen::PSPrint(PSFile *psf, int ofx, int ofy)
+{
+if (!psf) return;
+//int ori;
+//ori = (XSize() > YSize()) ? LANDSCAPE : PORTRAIT ;
+psf->NewPage((float)XSize(), (float)YSize(),PI_Auto);
+PIContainerGen::PSPrint(psf, ofx, ofy);
+}
+
+
+/* --Methode-- */
+void PIWindowGen::Process(PIMessage msg, PIMsgHandler* sender, void* data)
+/*  On intercepte le message Active, et Close avant de les renvoyer */
+/*  avec un message ActiveWdg de la part de la fenetre              */
+{
+if (ModMsg(msg) == PIMsg_ResizeRequest) { 
+  // On change la taille de la fenetre - data est un pointeur sur entier
+  // data[0] represente l'increment (positif ou negatif) en X, data[1] en Y
+  int* nsz = (int*) data;
+  SetSize(XSize()+nsz[0], YSize()+nsz[1]);
+  return;
+  }
+else if ((msg == BuildMsg(Msg(), PIMsg_Close)) && (sender == this) && mAHC) {
+  Hide();   // Action par defaut en cas de MsgClose.
+  ReSend(msg, sender, data);
+  }
+else if (ModMsg(msg) == PIMsg_Active) {
+  ReSend(msg, sender, data);
+  PIWdg * sndw = dynamic_cast<PIWdg *>(sender);
+  if (sndw && (sndw->kind() != PIWindowGen::ClassId))  Send(Msg(),PIMsg_Active);
+  }
+else ReSend(msg, sender, data);
+return;  
+}
Index: /tags/V_LaSilla191199/SophyaPI/PI/piwindowgen.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piwindowgen.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piwindowgen.h	(revision 464)
@@ -0,0 +1,36 @@
+#ifndef PIWINDOWGEN_H_SEEN
+#define PIWINDOWGEN_H_SEEN
+
+#include "pisysdep.h"
+
+#include PICONT_H
+
+enum PIWindowKind {
+  PIWK_normal = 0,
+  PIWK_dialog = 1,
+  PIWK_transient = 2,
+  PIWK_floating = 3
+};
+
+class PIWindowGen : public PIContainer {
+public:
+  enum {ClassId = 1550};
+		    PIWindowGen(PIMsgHandler* par, const char *nom, PIWindowKind k=PIWK_normal,
+                                int sx=10, int sy=10, int px=0, int py=0);
+  virtual           ~PIWindowGen();
+
+  virtual long      kind() {return ClassId; }
+
+  virtual void      PSPrint(PSFile *psf, int ofx=0, int ofy=0);
+
+  inline  void      AutoHideOnClose(bool ahc=true) { mAHC = ahc; }
+
+  virtual void      Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+  
+protected:  
+  PIWindowKind	       mWtyp;
+  bool                 mAHC;
+};
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/piwindowmac.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piwindowmac.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piwindowmac.cc	(revision 464)
@@ -0,0 +1,91 @@
+#include "piwindowmac.h"
+#include "pippwindowmac.h"
+
+PIWindowMac::PIWindowMac(PIMsgHandler *par, char *nom, PIWindowKind k, int sx, int sy, int px, int py)
+: PIWindowGen(par, nom, k, sx, sy, px, py), finalized(false)
+{
+	delete mPane;
+	delete mAdapter;
+	mAdapter = NULL;
+	mWindowInfo.WINDid = 1000+k;
+	mWindowInfo.attributes = windAttr_EraseOnUpdate |
+	                         windAttr_Targetable |
+	                         windAttr_Enabled;
+	switch (k) {
+	 case PIWK_normal:
+	  mWindowInfo.attributes |= windAttr_Regular | 
+	                            windAttr_TitleBar |
+	                            windAttr_SizeBox |
+	                            windAttr_CloseBox |
+	                            windAttr_Resizable;
+	  mWindowInfo.layer = windLayer_Regular;
+	  break;
+	 case PIWK_dialog:
+	  mWindowInfo.attributes |= windAttr_Modal;
+	  mWindowInfo.layer = windLayer_Modal;
+	  break;
+	 case PIWK_floating:
+	  mWindowInfo.attributes |= windAttr_Floating |
+	                            windAttr_HideOnSuspend;
+	  mWindowInfo.layer = windLayer_Floating;
+	  break;
+	}
+	mWindowInfo.minimumWidth = 30;
+	mWindowInfo.minimumHeight = 30;
+	mWindowInfo.maximumWidth = 32000;
+	mWindowInfo.maximumHeight = 32000;
+	mWindowInfo.standardSize.width = sx;
+	mWindowInfo.standardSize.height = sy;
+	mWindowInfo.userCon = 0;
+	
+	//mPane = new LWindow(mWindowInfo);
+	mPane = LWindow::CreateWindow(1000+k,LCommander::GetTopCommander());
+    ((PIPPWindowMac*)mPane)->myPIWindow = this; 
+	Rect r = {py, px, py+sy, px+sx};
+    ((LWindow*) mPane)->DoSetBounds(r);
+    SetLabel(nom);
+    //((LWindow*) mPane)->SetSuperCommander(LCommander::GetTopCommander());
+}
+
+
+PIWindowMac::~PIWindowMac()
+{}
+
+
+void PIWindowMac::Show()
+{
+  if (!finalized) {
+    FinishCreate();
+    finalized = true;
+  }
+  PIWindowGen::Show();
+}
+
+void
+PIWindowMac::SetSize(int sx, int sy)
+{
+   ((LWindow*) mPane)->ResizeWindowTo(sx, sy);
+}
+
+void
+PIWindowMac::SetPos(int px, int py)
+{
+   ((LWindow*) mPane)->MoveWindowBy(px-XPos(), py-YPos());
+}
+
+int
+PIWindowMac::XPos()
+{
+	Rect	theBounds;
+	((LWindow*) mPane)->GetGlobalBounds(theBounds);
+    return theBounds.left;
+}
+
+int
+PIWindowMac::YPos()
+{
+	Rect	theBounds;
+	((LWindow*) mPane)->GetGlobalBounds(theBounds);
+    return theBounds.top;
+}
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/piwindowmac.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piwindowmac.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piwindowmac.h	(revision 464)
@@ -0,0 +1,26 @@
+#ifndef PIWINDOWMAC_H_SEEN
+#define PIWINDOWMAC_H_SEEN
+
+#include "piwindowgen.h"
+#include "pisysdep.h"
+#include <LWindow.h>
+
+class PIWindowMac : public PIWindowGen {
+public:
+                         PIWindowMac(PIMsgHandler *par, char *nom, PIWindowKind k=PIWK_normal,
+                                   int sx=10, int sy=10, int px=0, int py=0);
+  virtual                ~PIWindowMac();
+  virtual void           Show();
+  virtual void           SetSize(int sx, int sy);
+  virtual void           SetPos(int px, int py);
+  virtual int            XPos();
+  virtual int            YPos();
+
+protected:
+  SWindowInfo			  mWindowInfo;
+  Boolean				  finalized;
+};
+
+typedef PIWindowMac PIWindow;
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PI/piwindowx.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piwindowx.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piwindowx.cc	(revision 464)
@@ -0,0 +1,179 @@
+#include <stdio.h>
+
+#include "piwindowx.h"
+
+#include <X11/Xlib.h>
+
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/IntrinsicP.h>
+#include <X11/Shell.h>
+#include <Xm/Form.h>
+
+/* Fonctions (Callback et action) pour traiter le message Close de WM  */
+
+/* Nouvelle-Fonction */
+static void popdwn_cb(Widget /*w*/, XtPointer *usd,  XtPointer * )
+{
+PIWindowX * dw = (PIWindowX *) usd;
+dw->Process(dw->BuildMsg(dw->Msg(),PIMsg_Close), dw, NULL) ;
+}
+
+
+/* Nouvelle-Fonction */
+static int fgactl = 0;
+
+static void CloseWindow (Widget w, XEvent*, String*,Cardinal*)
+{
+XtCallCallbacks(w,  XtNpopdownCallback, NULL);
+}
+
+/* *** ATTENTION *** La constante ci-dessous PIXMFORMFRACBASE
+   doit etre identique ds piwdgx.cc  picontainerx.cc et piwindowx.cc
+   ***************************************************************** */
+#define PIXMFORMFRACBASE 1000
+
+
+/* --Methode-- */
+PIWindowX::PIWindowX(PIMsgHandler *par, const char *nom, PIWindowKind k, 
+                     int sx, int sy, int px, int py)
+: PIWindowGen(par, nom, k, -1, -1, 0, 0)
+{
+XtTranslations trans;
+
+pwm = new PIWdgX(NULL, nom, sx, sy, px, py);
+
+switch (k)
+  {
+  case PIWK_normal :
+  case PIWK_floating :
+    pwm->CreateXtWdg(nom, topLevelShellWidgetClass, NULL, sx, sy, px, py);
+    break;
+  case PIWK_dialog :
+    pwm->CreateXtWdg(nom, transientShellWidgetClass, NULL, sx, sy, px, py);
+    break;
+  case PIWK_transient :
+    pwm->CreateXtWdg(nom, overrideShellWidgetClass, NULL, sx, sy, px, py);
+    break;
+  }
+
+
+/*  Il faut "attraper" l'action close, genere par le window-manager       */
+/*  2 actions sont necessaires, installation d'une action (CloseWindow()) */
+/*  et j'utilise ensuite un callback ds CloseWindow()                     */
+/*  Il faut aussi desactiver l'action de destruction du widget par defaut */
+/*  (XtSetArg(warg, XmNdeleteResponse, ...                                */
+/*  Attention, voir la fonction Show(), pour l'appel a XSetWMProptocols() */
+/*  Pour une fenetre donnee, on peut recuperer les Map, UnMap, Destroy,   */
+/*  etc... il faut appeler XtAddEventHandler( w, Mask, ...)               */
+/*    Mask =  StructureNotifyMask | SubstructureNotifyMask                */
+
+
+
+if ((k == PIWK_normal) || (k == PIWK_floating) || (k == PIWK_dialog))
+  { 
+  if (k == PIWK_dialog)  AutoHideOnClose(false);
+  /* XtAddEventHandler(pwm->XtWdg(), StructureNotifyMask | SubstructureNotifyMask, 
+                  FALSE, wmaction_evthandler, this);*/
+
+  XtAddCallback(pwm->XtWdg(), XtNpopdownCallback,
+                (XtCallbackProc)popdwn_cb, (XtPointer)this);
+
+  if (fgactl == 0) 
+    { 
+    XtActionsRec desact = {(char *)"CloseWindow" ,CloseWindow};
+    int szx, szy, szf;
+    XtAppContext * appctx = PIXtAppCtx(szx, szy, szf);
+    XtAppAddActions(*appctx, &desact, 1);  fgactl = 1; 
+    }
+
+  trans = XtParseTranslationTable("<Message>WM_PROTOCOLS:CloseWindow()");
+  XtOverrideTranslations(pwm->XtWdg() , trans);
+  Arg warg[2];
+  XtSetArg(warg[0], XmNdeleteResponse, XmDO_NOTHING);
+  XtSetValues(pwm->XtWdg(), warg, 1);
+  }
+
+CreateXtWdg(nom, xmFormWidgetClass, pwm->XtWdg(), sx, sy, 0, 0);
+int fbase = 1000 ;  // Valeur de XmNfractionBase des XmForm ds PIContainerX
+Arg  wargs[2];
+int n=0;
+XtSetArg(wargs[n],XmNfractionBase, fbase);  n++;
+XtSetValues(XtWdg(), wargs, n);
+
+wmis = k_wmi_cascade;
+}
+
+/* --Methode-- */
+PIWindowX::~PIWindowX()
+{
+Hide();
+delete pwm;
+}
+
+/* --Methode-- */
+void PIWindowX::BindWdgtoParent()
+{
+// On ne doit rien faire pour les fenetres 
+return;
+}
+
+/* --Methode-- */
+void PIWindowX::SetSize(int sx, int sy)
+{
+pwm->SetSize(sx, sy);
+PIWdgX::SetSize(sx, sy);
+return;
+}
+
+/* --Methode-- */
+void PIWindowX::SetPos(int px, int py)
+{
+pwm->SetPos(px, py);
+PIWdgX::SetPos(px, py);
+return;
+}
+
+
+/* --Methode-- */
+void PIWindowX::Show()
+{
+int fgr = 0;
+Display *mdsp;
+
+mdsp = XtDisplay(pwm->XtWdg());
+
+PIContainerGen::Show();
+// Manage();  $CHECK$ Ca ne doit plus etre necessaire Reza 9/7/97
+if (!XtIsRealized(pwm->XtWdg()))  fgr = 1;
+pwm->Manage();
+if (fgr) 
+  {
+  Atom wmd;
+  if ((mWtyp == PIWK_normal) || (mWtyp == PIWK_floating) || (mWtyp == PIWK_dialog))
+    { 
+    wmd = XInternAtom(mdsp, "WM_DELETE_WINDOW",False);
+    XSetWMProtocols(mdsp, XtWindow(pwm->XtWdg()), &wmd, 1);
+    }
+  else 
+    XSetTransientForHint(mdsp, XtWindow(PIXtTopWdg()), XtWindow(pwm->XtWdg()));
+  //  Pour faire les actions sur les fenetres X, sinon fenetre pas cree 
+  PIContainerGen::FinishCreate();
+  }
+
+// XRaiseWindow est necessaire, sinon la fenetre passe des fois derriere ...
+//if (mWtyp == PIWK_transient)  
+  XRaiseWindow(mdsp, XtWindow(pwm->XtWdg()));
+ 
+return;
+}
+
+/* --Methode-- */
+void PIWindowX::Hide()
+{
+PIWindowGen::Hide();
+// UnManage();  $CHECK$ Ca ne doit plus etre necessaire Reza 9/7/97
+pwm->UnManage();
+}
+
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/piwindowx.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/piwindowx.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/piwindowx.h	(revision 464)
@@ -0,0 +1,28 @@
+#ifndef PIWINDOWX_H_SEEN
+#define PIWINDOWX_H_SEEN
+
+#include "piwindowgen.h"
+#include "pisysdep.h"
+
+
+class PIWindowX : public PIWindowGen {
+public:
+                         PIWindowX(PIMsgHandler *par, const char *nom, PIWindowKind k=PIWK_normal,
+                                   int sx=10, int sy=10, int px=0, int py=0);
+  virtual                ~PIWindowX();
+  
+  virtual void           SetSize(int sx, int sy);
+  virtual void           SetPos(int px, int py);  
+
+  virtual void           Show();
+  virtual void           Hide();
+
+protected:
+  virtual void		 BindWdgtoParent();  
+  PIWdgX   *pwm;
+
+};
+
+typedef PIWindowX PIWindow;
+
+#endif   /* PIWINDOWX_H_SEEN  */
Index: /tags/V_LaSilla191199/SophyaPI/PI/pixtbase.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pixtbase.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pixtbase.cc	(revision 464)
@@ -0,0 +1,331 @@
+#include <stdio.h>
+
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+
+#include <X11/IntrinsicP.h>
+#include <X11/CoreP.h>
+
+#include <X11/keysym.h>
+
+#include "pixtbaseP.h"
+#include "pixtbase.h"
+
+// #define DEBUG_PIXTB
+
+ 
+//  ------- Pb de gestion du focus-keyboard  Motif-PIBaseWdg -------
+// ** Note 30/04/98  Reza
+// Il y un probleme d'attribution du focus-keyboard entre Widget Motif et
+// PIBaseWdg (Widget PIXtBase) les Attributs XmNnavigationType et XmNtraversalOn
+// ont ete desactives pour les StdWdgX - Le probleme n'a pas pu etre resolu
+// meme en attribuant les attributs  XmNnavigationType XmNtraversalOn 
+// (et XmNsensitive) a PIXtBase, ni en utilisant 
+// XSetInputFocus(XtDisplay (wdgp), XtWindow(wdgp), RevertToParent, evt->xbutton.time)
+// Solution pour le moment :
+//  XmNnavigationType =XmNONE et XmNtraversalOn=FALSE pour les PIStdWdgX 
+// sauf pour PIText ou XmNtraversalOn=TRUE
+
+
+/*  Construction du widget Xt PIXtBase   */
+
+static void     init_class_pixtbase(void);
+
+static void     init_pixtbase    (Widget, Widget, ArgList, Cardinal*);
+static void     destroy_pixtbase (Widget);
+static void     resize_pixtbase  (Widget);
+static void     expose_pixtbase  (Widget, XEvent*, Region);
+
+
+// Si on ne veut pas utiliser XtInheritAcceptFocus
+// static Boolean  acceptfocus_pixtbase   (Widget, Time* ); 
+
+
+static XtResource resources[] ={
+  {PIXNobject ,(char *)"Object", XtRPointer, sizeof(XtRPointer),
+   XtOffset(PIXtBaseWidget,  pixtbase.objet), XtRImmediate, (XtPointer)0},
+};
+
+
+PIXtBaseClassRec  piXtBaseClassRec = {
+/* Core Class Part */
+{
+
+(WidgetClass) &coreClassRec,    /* pointer to superclass ClassRec   */
+(char*)"PIXtBase",         	/* widget resource class name       */
+sizeof(PIXtBaseRec),	        /* size in bytes of widget record   */
+init_class_pixtbase,            /* class_initialize                 */
+NULL, 			        /* dynamic initialization           */
+FALSE,       		        /* has class been initialized?      */
+init_pixtbase,                  /* initialize                       */
+NULL,			        /* notify that initialize called    */
+XtInheritRealize,               /* XCreateWindow for widget         */
+// actions,     		/* widget semantics name to proc map*/
+// XtNumber(actions),           /* number of entries in actions     */
+NULL,                           /* widget semantics name to proc map*/
+0,                              /* number of entries in actions     */
+resources,                      /* resources             */
+XtNumber(resources),            /* resources             */
+NULLQUARK,		        /* resource class quarkified        */
+TRUE,			        /* compress MotionNotify for widget */
+TRUE,			        /* compress Expose events for widget*/
+TRUE,			        /* compress enter and leave events  */
+TRUE,			        /* select for VisibilityNotify      */
+destroy_pixtbase,	        /* free data for subclass pointers  */
+resize_pixtbase,                /* geom manager changed widget size */
+expose_pixtbase,       	        /* rediplay window                  */
+NULL,		                /* set subclass resource values     */
+NULL,			        /* notify that set_values called    */
+XtInheritSetValuesAlmost,       /* set_values got "Almost" geo reply*/
+NULL,		                /* notify that get_values called    */
+XtInheritAcceptFocus,           /* assign input focus to widget     */
+// acceptfocus_pixtbase,           /* assign input focus to widget     */
+XtVersion,	                /* version of intrinsics used       */
+NULL,		                /* list of callback offsets         */
+// translations,	        /* state machine                    */
+NULL,                           /* state machine                    */
+XtInheritQueryGeometry,         /* return preferred geometry        */
+XtInheritDisplayAccelerator,    /* display your accelerator         */
+NULL		                /* pointer to extension record      */
+}
+/* PIXtBase */
+,{   NULL }
+
+};
+
+WidgetClass piXtBaseWidgetClass = (WidgetClass) &piXtBaseClassRec;
+
+
+/*  Last XEvent Serial Number and Time-Stamp , and Key-state */
+static Time last_time_xevt = 0;
+static unsigned long last_serial_xevt = 0;
+static unsigned int  last_state_xevt = 0;
+
+
+Time PIXGetLastEventTime() { return(last_time_xevt); }
+unsigned long PIXGetLastEventSerial() { return(last_serial_xevt); }
+void PIXSetLastEventTimeSerial(Time t, unsigned long ser) 
+{ last_time_xevt = t;  last_serial_xevt = ser; }
+void PIXGetLastEventInfo(unsigned int& st, Time& t)
+{ st = last_state_xevt;  t = last_time_xevt; }
+
+/* Nouvelle-Fonction */
+static void init_class_pixtbase()
+{
+#ifdef DEBUG_PIXTB
+puts("Debug_init_class_pixtbase() ");
+#endif
+return;
+}
+
+/* Nouvelle-Fonction */
+static void init_pixtbase (Widget request, Widget wdg,
+                          ArgList /*args*/, Cardinal* /*narg*/)
+{
+PIXtBaseWidget wdgp;
+wdgp = (PIXtBaseWidget)wdg;
+
+if(request->core.width<=0)  wdgp->core.width  = 10;
+if(request->core.height<=0) wdgp->core.height = 10;
+// get_GCs (wdgp);
+#ifdef DEBUG_PIXTB
+printf("Debug_init_pixtbase: Wdg=%lx Object= %lx  narg=%d \n", 
+(long)wdgp, (long)(wdgp->pixtbase.objet), (int)(*narg));
+#endif
+return;
+}
+
+/* Nouvelle-Fonction */
+static void destroy_pixtbase (Widget /*wdgp*/)
+{
+#ifdef DEBUG_PIXTB
+printf("Debug_destroy_pixtbase: Wdg= %lx Object= %lx \n", (long)wdgp, 
+(long)(((PIXtBaseWidget)wdgp)->pixtbase.objet) );
+#endif
+// free_GCs((PIXtBaseWidget)wdgp);
+//    $CHECK$ Reza  21/11/97
+// J'ai l'impression que cette fonction n'est pas appellee au moment 
+// de destruction du Widget - Par contre la fonction leave est appelee
+// si l'action correspondante a ete enregistree ?!
+}
+
+
+/* Nouvelle-Fonction */
+static void resize_pixtbase (Widget wdgp)
+{
+#ifdef DEBUG_PIXTB
+printf("Debug_resize_pixtbase: Wdg=%lx Object= %lx \n", (long)wdgp, 
+(long)(((PIXtBaseWidget)wdgp)->pixtbase.objet) );
+#endif
+if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 
+  (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Resize();
+return;
+}
+
+/* Nouvelle-Fonction */
+static void expose_pixtbase (Widget  wdgp, XEvent* /*event*/, Region region)
+{
+#ifdef DEBUG_PIXTB
+printf("Debug_expose_pixtbase: Wdg=%lx Object= %lx \n", (long)wdgp, 
+(long)(((PIXtBaseWidget)wdgp)->pixtbase.objet) );
+#endif
+if (!(wdgp->core.visible))  return;
+if ( ((PIXtBaseWidget)wdgp)->pixtbase.objet ) 
+  {
+  XRectangle  xrec;
+  int x0, y0, dx, dy;
+  XClipBox(region, &xrec);
+  x0 = xrec.x;  y0 = xrec.y;
+  dx = xrec.width;  dy = xrec.height;
+  (((PIXtBaseWidget)wdgp)->pixtbase.objet)->eXposeProcess(x0, y0, dx, dy);
+  }
+return;
+}
+
+/* Nouvelle-Fonction 
+static Boolean  acceptfocus_pixtbase   (Widget wdgp , Time* )
+{
+// printf("acceptfocus_pixtbase() %lx %x \n",  ((PIXtBaseWidget)wdgp)->pixtbase.myeventmask, ShiftMask );
+if (  ((PIXtBaseWidget)wdgp)->pixtbase.myeventmask & ShiftMask  )  return TRUE;
+else return FALSE;
+}
+*/
+
+/* -------- Fonction de traitement des evenements --------- */
+/* Nouvelle-Fonction */
+void event_handler_pixtbase (Widget wdgp, XtPointer /*closure*/, 
+                             XEvent* evt, Boolean* cont)
+{
+
+*cont = true ; 
+switch (evt->type) {
+  case EnterNotify : 
+#ifdef DEBUG_PIXTB
+    printf("Debug_enter_pixtbase: Wdg=%lx Object= %lx \n", (long)wdgp, 
+           (long)(((PIXtBaseWidget)wdgp)->pixtbase.objet) );
+#endif
+    last_time_xevt = evt->xcrossing.time;
+    last_serial_xevt = evt->xcrossing.serial;
+    last_state_xevt = evt->xcrossing.state;
+//    if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 
+    (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Enter();
+  break;
+
+  case LeaveNotify : 
+#ifdef DEBUG_PIXTB
+    printf("Debug_leave_pixtbase: Wdg=%lx Object= %lx \n", (long)wdgp, 
+           (long)(((PIXtBaseWidget)wdgp)->pixtbase.objet) );
+#endif
+    last_time_xevt = evt->xcrossing.time;
+    last_serial_xevt = evt->xcrossing.serial;
+    last_state_xevt = evt->xcrossing.state;
+//    if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 
+       (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Leave();
+  break;
+
+  case ButtonPress :
+    last_time_xevt = evt->xbutton.time;
+    last_serial_xevt = evt->xbutton.serial;
+    last_state_xevt = evt->xbutton.state;
+    if ( (evt->xbutton.button == 1) && ( ((PIXtBaseWidget)wdgp)->pixtbase.myeventmask & Button1Mask) )
+      (((PIXtBaseWidget)wdgp)->pixtbase.objet)->But1Press(evt->xbutton.x, evt->xbutton.y);
+    else  if ( (evt->xbutton.button == 2) && ( ((PIXtBaseWidget)wdgp)->pixtbase.myeventmask & Button2Mask) )
+      (((PIXtBaseWidget)wdgp)->pixtbase.objet)->But2Press(evt->xbutton.x, evt->xbutton.y);
+    else  if ( (evt->xbutton.button == 3)  && ( ((PIXtBaseWidget)wdgp)->pixtbase.myeventmask & Button3Mask) )
+      (((PIXtBaseWidget)wdgp)->pixtbase.objet)->But3Press(evt->xbutton.x, evt->xbutton.y);
+  break;
+
+  case ButtonRelease :
+    last_time_xevt = evt->xbutton.time;
+    last_serial_xevt = evt->xbutton.serial;
+    last_state_xevt = evt->xbutton.state;
+    if ( (evt->xbutton.button == 1) && ( ((PIXtBaseWidget)wdgp)->pixtbase.myeventmask & Button1Mask) )
+      (((PIXtBaseWidget)wdgp)->pixtbase.objet)->But1Release(evt->xbutton.x, evt->xbutton.y);
+    else  if ( (evt->xbutton.button == 2) && ( ((PIXtBaseWidget)wdgp)->pixtbase.myeventmask & Button2Mask) )
+      (((PIXtBaseWidget)wdgp)->pixtbase.objet)->But2Release(evt->xbutton.x, evt->xbutton.y);
+    else  if ( (evt->xbutton.button == 3)  && ( ((PIXtBaseWidget)wdgp)->pixtbase.myeventmask & Button3Mask) )
+      (((PIXtBaseWidget)wdgp)->pixtbase.objet)->But3Release(evt->xbutton.x, evt->xbutton.y);
+  break;
+
+  case MotionNotify :
+    {
+    int xw, yw, xr, yr;
+    unsigned int key_but;
+    Window rw, cw;
+    if ( evt->xmotion.is_hint == NotifyHint ) { 
+      if (!XQueryPointer( XtDisplay(wdgp), evt->xmotion.window, &rw, &cw,
+                  &xr, &yr, &xw, &yw, &key_but) ) break ;
+      }
+    else { key_but =  evt->xmotion.state ; xw = evt->xmotion.x;  yw = evt->xmotion.y; }
+//    if  ( !(key_but & ( Button1Mask | Button2Mask | Button3Mask ) ) ) break;
+      last_time_xevt = evt->xmotion.time;
+      last_serial_xevt = evt->xmotion.serial;
+      last_state_xevt = evt->xmotion.state;
+      if  (key_but & Button1Mask ) 
+        (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Ptr1Move(xw, yw);
+      else  if (key_but & Button2Mask ) 
+        (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Ptr2Move(xw, yw);
+      else  if (key_but & Button3Mask ) 
+        (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Ptr3Move(xw, yw);
+      else if ( !(key_but & (Button4Mask|Button5Mask)) ) 
+        (((PIXtBaseWidget)wdgp)->pixtbase.objet)->PtrMove(xw, yw);
+    }
+  break;
+
+  case KeyPress :
+    {
+    XComposeStatus cs;
+    KeySym key;
+    char buf[10];
+    int i,nc,rkey;
+    PIKeyModifier kmod;
+  
+    kmod = PIKM_Blank;
+    nc = XLookupString(&(evt->xkey), buf, 10, &key, &cs);
+
+    if  (evt->xkey.state & ShiftMask)   
+      kmod = (PIKeyModifier) (kmod | PIKM_Shift);
+    if  (evt->xkey.state & ControlMask) 
+      kmod = (PIKeyModifier) (kmod | PIKM_Cntl);
+    if  (evt->xkey.state & Mod1Mask)    
+      kmod = (PIKeyModifier) (kmod | PIKM_Alt);
+    switch (key) {
+      case XK_Return :
+        rkey = PIK_Return;
+      break;
+      case XK_KP_Enter :
+        rkey = PIK_Enter;
+      break;
+      case XK_Up :
+        rkey = PIK_Up;
+      break;
+      case XK_Down :
+        rkey = PIK_Down;
+      break;
+      case XK_Left :
+        rkey = PIK_Left;
+      break;
+      case XK_Right :
+        rkey = PIK_Right;
+      break;
+      case XK_Prior :
+        rkey = PIK_Previous;
+      break;
+      case XK_Next :
+        rkey = PIK_Next;
+      break;
+      default :
+        rkey = 0;
+      break;
+    }
+    if (rkey > 0)  (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Keyboard(rkey, kmod);
+    else for(i=0; i<nc; i++)  
+      (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Keyboard((int)(buf[i]), kmod);
+  }
+  break;
+}
+
+return;
+}
+
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/pixtbase.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pixtbase.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pixtbase.h	(revision 464)
@@ -0,0 +1,19 @@
+/* Widget Xt pour construction Widget C++  Interface Public  */
+/*                                    Reza 10/95             */
+
+#ifndef PIXTBASE_H_SEEN
+#define PIXTBASE_H_SEEN
+
+#include <X11/Intrinsic.h>
+ 
+typedef struct _PIXtBaseClassRec * PIXtBaseWidgetClass;
+typedef struct _PIXtBaseRec      * PIXtBaseWidget;
+
+#define PIXNobject      "mypiobject"
+
+extern WidgetClass piXtBaseWidgetClass;
+
+void event_handler_pixtbase (Widget wdgp, XtPointer closure, 
+                             XEvent* evt, Boolean* cont);
+
+#endif /* PIXTBASE_H_SEEN */
Index: /tags/V_LaSilla191199/SophyaPI/PI/pixtbaseP.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/pixtbaseP.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/pixtbaseP.h	(revision 464)
@@ -0,0 +1,41 @@
+/* Widget Xt pour affichage d'image   Declaration privee  */
+/*                                      Reza 10/95        */
+
+
+#ifndef PIXTBASEP_H_SEEN
+#define PIXTBASEP_H_SEEN
+
+#include "pibwdgx.h"
+
+typedef struct
+{
+   void * mumble;   /* No new procedures */
+} PIXtBaseClassPart;
+
+
+typedef struct _RzXBaseClassRec
+{
+CoreClassPart		core_class;
+PIXtBaseClassPart	pixtbase_class;
+} PIXtBaseClassRec;
+
+typedef struct
+{
+PIBaseWdgX  * objet; 
+unsigned long myeventmask;
+} PIXtBasePart;
+
+
+typedef struct _PIXtBaseRec
+{
+CorePart		core;
+PIXtBasePart		pixtbase;
+} PIXtBaseRec;
+
+extern PIXtBaseClassRec piXtBaseClassRec;
+
+
+#endif /* PIXTBASEP_H_SEEN */
+
+
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/psfile.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/psfile.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/psfile.cc	(revision 464)
@@ -0,0 +1,1081 @@
+/*
+ *   PSFile.cc
+ *   
+ *   19/06/96
+ *
+ *   Modification le 01/03/96
+ *    - fusion psfile.cc - psdict.cc
+ *
+ *
+ *   07/08/99 : Gestion des fontes ; ajout Times/Helvetica/Symbol 
+ *              
+ * 
+ *
+ *
+ */
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <time.h>
+
+#include "psfile.h"
+
+//++
+// Class	PSFile
+// Lib		PI
+// include	psfile.h
+//
+//   	Classe encapsulant un fichier PostScript, fournissant des primitives
+//	graphiques produisant du code PostScript.
+//--
+//++
+// Links	Voir aussi
+// PIGraphicPS
+//--
+
+
+
+/* En cm */
+#define  MIN_SIZE_IN_PAGE  2.
+
+/*
+ *  Dictionnaire PIDict
+ *
+ *  Contient les fonctions suivantes : 
+ *
+ *
+ */
+#define PIDICT_PAR   \
+  \
+  PI_Landscape, PI_Portrait,\
+  \
+  PI_ColorFromMap, PI_Black, PI_White, PI_Grey, PI_Red, PI_Blue,\
+  PI_Green, PI_Yellow, PI_Magenta, PI_NotDefColor,\
+  PI_Cyan, PI_Turquoise, PI_NavyBlue,\
+  PI_Orange, PI_SiennaRed, PI_Purple,\
+  PI_LimeGreen, PI_Gold,\
+  \
+  PI_RomanFont, PI_BoldFont, PI_ItalicFont, PI_NotDefFontAtt,\
+  PI_SmallSizeFont, PI_NormalSizeFont, PI_BigSizeFont, PI_NotDefFontSize, \
+  \
+  PI_NormalLine, PI_ThinLine, PI_ThickLine, PI_NotDefLineAtt
+
+#define PIDICT       "\
+/$PIDict 50 dict def\n\
+$PIDict begin $PIDict /mtrx matrix put /Landscape %d def /Portrait %d def\n\
+%% Couleurs et fontes courantes\n\
+/C%-2d  {ur    ug    ub    setrgbcolor} bind def %% PI_ColorFromMap\n\
+/C%-2d  {0.0   0.0   0.0   setrgbcolor} bind def %% PI_Black\n\
+/C%-2d  {0.996 0.996 0.996 setrgbcolor} bind def %% PI_White\n\
+/C%-2d  {0.824 0.824 0.824 setrgbcolor} bind def %% PI_Grey\n\
+/C%-2d  {0.996 0.0   0.0   setrgbcolor} bind def %% PI_Red\n\
+/C%-2d  {0.0   0.0   0.996 setrgbcolor} bind def %% PI_Blue\n\
+/C%-2d  {0.0   0.996 0.0   setrgbcolor} bind def %% PI_Green\n\
+/C%-2d  {0.996 0.996 0.0   setrgbcolor} bind def %% PI_Yellow\n\
+/C%-2d  {0.996 0.0   0.996 setrgbcolor} bind def %% PI_Magenta\n\
+/C%-2d  {}                              bind def %% PI_NotDefColor\n\
+/C%-2d  {0.0   0.996 0.996 setrgbcolor} bind def %% PI_Cyan\n\
+/C%-2d  {0.250 0.875 0.813 setrgbcolor} bind def %% PI_Turquoise\n\
+/C%-2d  {0.0   0.0   0.500 setrgbcolor} bind def %% PI_NavyBlue\n\
+/C%-2d  {0.996 0.644 0.0   setrgbcolor} bind def %% PI_Orange\n\
+/C%-2d  {0.625 0.320 0.176 setrgbcolor} bind def %% PI_SiennaRed\n\
+/C%-2d  {0.625 0.125 0.937 setrgbcolor} bind def %% PI_Purple\n\
+/C%-2d  {0.195 0.800 0.195 setrgbcolor} bind def %% PI_LimeGreen\n\
+/C%-2d  {0.996 0.840 0.0   setrgbcolor} bind def %% PI_Gold\n\
+/F%-2d  {/Courier   findfont} bind def           %% PI_RomanFont\n\
+/F%-2d  {/Courier-Bold    findfont} bind def     %% PI_BoldFont\n\
+/F%-2d  {/Courier-Italic  findfont} bind def     %% PI_ItalicFont\n\
+/F%-2d  {}\
+                        bind def       %% PI_NotDefFontAtt\n\
+/FS {scalefont setfont} bind def\n\
+%%/FS%-2d {8  scalefont setfont} bind def          %% PI_SmallSizeFont\n\
+%%/FS%-2d {12 scalefont setfont} bind def          %% PI_NormalSizeFont\n\
+%%/FS%-2d {16 scalefont setfont} bind def          %% PI_BigSizeFont\n\
+/FS%-2d {}                     bind def          %% PI_NotDefFontSize\n\
+/L%-2d  {1    slw} bind def                      %% PI_NormalLine\n\
+/L%-2d  {0.5  slw} bind def                      %% PI_ThinLine\n\
+/L%-2d  {3    slw} bind def                      %% PI_ThickLine\n\
+/L%-2d  {}         bind def                      %% PI_NotDefLineAtt\n\
+\
+%% Conversion\n\
+/cm   {28.3 mul}   bind def  %% cm --> points\n\
+/Ux   {$Cvrtx mul} bind def  %% Unites utilisateur /x --> points\n\
+/Uy   {$Cvrty mul} bind def  %% Unites utilisateur /y --> points\n\
+\
+%% Pages et Blocs\n\
+/newref  {%% Dx Dy Tx Ty X0 Y0 newref\n\
+translate 3 -1 roll cm div 28.3 mul /$Cvrty exch def\n\
+exch cm div 28.3 mul /$Cvrtx exch def} bind def\n\
+/NewPage {%% Dx Dy orientation NewPage\n\
+/$PageEnteredState save def 1 -1 scale Portrait eq {w cm h cm 0 h cm neg\n\
+newref} { -90 rotate h cm w cm 0 0 newref} ifelse} bind def\n\
+/EndPage { %% EndPage\n\
+$PageEnteredState restore} bind def\n\
+/NewBloc { %% Dx Dy Tx Ty X0 Y0 NewBloc\n\
+/$BlocEnteredState save def newref} bind def\n\
+/EndBloc { %% EndBloc\n\
+$BlocEnteredState restore} bind def\n\
+\
+%% Trace\n\
+/n  {newpath} bind def    /c  {closepath} bind def\n\
+/gs {gsave}  bind def     /gr {grestore} bind def\n\
+/m  {moveto} bind def     /l  {lineto} bind def\n\
+/s  {stroke} bind def     /f  {fill}   bind def\n\
+/sc {scale}  bind def     /S  {gs 1 -1 sc show gr} bind def \n\
+/slw {setlinewidth} bind def\n\
+/ff {findfont} bind def   /sf {setfont} bind def /scf {scalefont} bind def\n\
+/rl {rlineto} bind def    /tr {translate} bind def\n\
+%% Tx Ty X0 Y0 box\n\
+/box {tr 0 3 1 roll neg exch 0 0 3 index neg 0 0 m rl rl rl c} bind def\n\
+%% R X0 Y0 circle\n\
+/circle {tr dup 0 m 0 0 3 -1 roll 0 380 arc} bind def\n\
+%% DrawEllipse pompee sur transfig\n\
+/ellipse {/endangle exch def /startangle exch def /yrad exch def\n\
+/xrad exch def /y exch def /x exch def /savematrix mtrx currentmatrix def\n\
+x y tr xrad yrad sc 0 0 1 startangle endangle arc\n\
+closepath savematrix setmatrix } def\n\
+\
+%% Gestion des images\n\
+%% ColorImage, pompee sur xv (qui les avait pompees sur xgrab)\n\
+/colorimage where   %% do we know about 'colorimage'?\n\
+  { pop }           %% yes: pop off the 'dict' returned\n\
+  {                 %% no:  define one\n\
+    /colortogray {  %% define an RGB->I function\n\
+      /rgbdata exch store    %% call input 'rgbdata'\n\
+      rgbdata length 3 idiv\n\
+      /npixls exch store\n\
+      /rgbindx 0 store\n\
+      0 1 npixls 1 sub {\n\
+        grays exch\n\
+        rgbdata rgbindx       get 20 mul    %% Red\n\
+        rgbdata rgbindx 1 add get 32 mul    %% Green\n\
+        rgbdata rgbindx 2 add get 12 mul    %% Blue\n\
+        add add 64 idiv      %% I = .5G + .31R + .18B\n\
+        put\n\
+        /rgbindx rgbindx 3 add store\n\
+      } for\n\
+      grays 0 npixls getinterval\n\
+    } bind def\n\
+    /mergeprocs { %% def\n\
+      dup length 3 -1 roll dup length dup 5 1 roll 3 -1 roll add\n\
+      array cvx dup 3 -1 roll 0 exch putinterval dup 4 2 roll\n\
+      putinterval } bind def\n\
+    /colorimage {\n\
+      pop pop     %% remove 'false 3' operands\n\
+      {colortogray} mergeprocs image} bind def\n\
+  } ifelse          %% end of 'false' case\n\
+\
+%% GetRGB\n\
+/GetRGB { %% ImageStr --> RGBStr\n\
+  /ImageData exch store\n\
+  %% Pour chaque element de ImageData,\n\
+  %% On va chercher les valeurs RGB correspondantes\n\
+  0 1 Taille 1 sub {\n\
+    /i      exch store  %% On met a jour l'indice de parcours\n\
+    ImageData i get     %% Recupere la Indice e val dans la chaine ImData\n\
+    ColorMap exch get   %% On recupere la valeur RGB Correspondante\n\
+    aload pop           %% On met tout ca dans la pile\n\
+    %% Maintenant, on va mettre tout ca dans la chaine RGBStr\n\
+    RGBStr i 3 mul 2 add 3 -1 roll put\n\
+    RGBStr i 3 mul 1 add 3 -1 roll put\n\
+    RGBStr i 3 mul       3 -1 roll put\n\
+    } for\n\
+  RGBStr 0 Taille 3 mul getinterval %% On renvoie la chaine RGB\n\
+} bind def\n\
+end\n\
+"
+
+
+
+/* 
+ *  Les PIMarkers sont definis et geres commes des fontes
+ *
+ *
+ */
+#define PIMARKERS_PAR  PI_DotMarker, PI_PlusMarker, PI_CrossMarker,\
+  PI_CircleMarker, PI_FCircleMarker, PI_BoxMarker, PI_FBoxMarker,\
+  PI_TriangleMarker, PI_FTriangleMarker, PI_StarMarker, PI_FStarMarker
+
+#define PIMARKERS  "\
+%% Definition de la fonte $PIMarkers\n\
+/$PIMarkers 26 dict def\n\
+$PIMarkers begin\n\
+/FontType 3 def\n\
+/FontMatrix [0.001 0 0 0.001 -0.375 -0.375] def\n\
+/FontBBox   [0 0 1000 1000] def\n\
+/Encoding 256 array def\n\
+0 1 255 {Encoding exch /.notdef put} for\n\
+Encoding  %d /PIDot       put %% PI_DotMarker\n\
+Encoding  %d /PIPlus      put %% PI_PlusMarker\n\
+Encoding  %d /PICross     put %% PI_CrossMarker\n\
+Encoding  %d /PICircle    put %% PI_CircleMarker\n\
+Encoding  %d /PIFCircle   put %% PI_FCircleMarker\n\
+Encoding  %d /PIBox       put %% PI_BoxMarker\n\
+Encoding  %d /PIFBox      put %% PI_FBoxMarker\n\
+Encoding  %d /PITriangle  put %% PI_TriangleMarker\n\
+Encoding  %d /PIFTriangle put %% PI_FTriangleMarker\n\
+Encoding  %d /PIStar      put %% PI_StarMarker\n\
+Encoding  %d /PIFStar     put %% PI_FStarMarker\n\
+/CharProcs 26 dict def\n\
+$PIDict begin\n\
+CharProcs begin\n\
+/.notdef     {} def\n\
+/PIDot       {100 375 375 circle f} bind def\n\
+/PIPlus      {0 375 m 750 375 l 375 0 m 375 750 l s} bind def\n\
+/PICross     {0 0 m 750 750 l 750 0 m 0 750 l s} bind def\n\
+/PICircle    {375 375 375 circle s} bind def\n\
+/PIFCircle   {375 375 375 circle f} bind def\n\
+/PIBox       {0 0 m 750 0 l 750 750 l 0 750 l c s} bind def\n\
+/PIFBox      {0 0 m 750 0 l 750 750 l 0 750 l c f} bind def\n\
+/PITriangle  {0 750 m 375 0 l 750 750 l c s} bind def\n\
+/PIFTriangle {0 750 m 375 0 l 750 750 l c f} bind def\n\
+/PIStar      {} def\n\
+/PIFStar     {} def\n\
+end %%$PIDict\n\
+end %%$CharProcs\n\
+/BuildChar {\n\
+1000 0      %% Largeur \n\
+0 0 750 750 %% Bounding Box\n\
+setcachedevice \n\
+exch begin\n\
+Encoding exch get\n\
+CharProcs exch get\n\
+end exec} def\n\
+end\n\
+/PIMarkers $PIMarkers definefont pop\n\
+save\n\
+"
+
+/* Dimensions des divers formats */
+  struct PaperSize {
+      double width ;
+      double height ;
+  };
+struct PaperSize PaperSizeTable[] = {
+    { 0.0,  0.0},    /* PI_NotDefFormat */
+    {21.0, 29.7},    /* PI_A4 */
+    {29.7, 42.0},    /* PI_A3 */
+    {14.8, 21.0}     /* PI_A5 ? */
+} ;
+
+
+double cm2pt(double x);
+
+
+/* Fonction WriteHeader */
+#define END_PROLOG_PAR  PAGE_WIDTH, PAGE_HEIGHT
+#define END_PROLOG  "/NewFile { %%%% w h NewFile (--> h et w en cm <--)\n\
+$PIDict begin /PIMarkers ff 14 scf sf /h exch def /w exch def \n\
+/$PIEnteredState save def} bind def\n\
+/EndFile {$PIEnteredState restore end} bind def\n\
+%%%%EndProlog\n\n\
+"
+
+#define HEADER     "\
+%%%%Title: %s\n\
+%%%%Creator: PSFile (N.R. 07/08/99)\n\
+%%%%CreationDate: %s\
+%%%%Pages: (atend)\n\
+%%%%EndComments\n\n\
+"
+
+//++
+// Titre	Constructeurs
+//--
+//++
+// PSFile (const char * FileName, double sc = 1.0)
+//	Créateur pour fichier Encapsulated Postscript
+// PSFile (const char * FileName, PIOrientation orientation, -
+//         PIPaperSize paperSize= PI_A4, -
+//         double marginX = 5.0, double marginY = 5.0 )
+//	Créateur pour fichier Postscript
+//--
+
+/* 
+ *   PostScript encapsule...
+ * 
+ *   Attention la bounding Box ne sera specifiee 
+ *     qu'au premier NewPage() --> definie dans 
+ *     le champ "Trailer" 
+ *
+ */
+PSFile::PSFile(const char * FileName, double sc) 
+    : mPSFileName(FileName==NULL? "unnamed.eps" : const_cast<char *>(FileName)),
+      Tw (-1.), Th(-1.),         /* Non specifies pour du eps  */
+      WMargin (-1), HMargin(-1), /* Non specifiees en eps  */ 
+      isEPS(1),
+      scale(sc),                 /* Defaut : 1. */
+      mPaperSize(PI_NotDefPaperSize), /* Non specifiee en eps */
+      PageCounter(0),            /* Fichier vide */
+      FileEmpty(1),              /* Fichier vide */
+      currentPage(NULL),
+      currentBloc(NULL),
+      mDrawColor(PI_Black),
+      mFillColor(PI_Black),
+      mFontAtt(PI_RomanFont),
+      mFontSize(0),
+      mFontName(PI_DefaultFont), 
+      mLineAtt(PI_NormalLine),
+      mMarker(PI_DotMarker),
+      setFontDone(true)
+{
+    char*  date = new (char[64] ) ; 
+    time_t timer ; 
+
+    /* Ouverture du fichier en mode w+ */
+    if ( (mPSFile = fopen(FileName, "w+")) == NULL){
+	  perror (FileName);
+	  return;
+    }
+
+    /* Ecriture du Header  */
+    fprintf(mPSFile, "%%!PS-Adobe-2.0 EPSF-2.0\n");
+    fprintf(mPSFile, "%%%%BoundingBox: ");
+    /* 
+     * Les dimensions de la BB seront notees ici lors du 
+     * premier appel a NewPage
+     *
+     * C'est laid... si qqn a une meilleure idee...
+     */
+    boundingBox = ftell(mPSFile) ; 
+    fprintf(mPSFile, "                       \n");
+
+    time(&timer) ; 
+    date = ctime(&timer) ; 
+    fprintf(mPSFile, HEADER, mPSFileName, date) ; /* titre, date etc... */
+    fprintf(mPSFile, PIDICT, PIDICT_PAR) ;        /* Dictionnaire */
+    fprintf(mPSFile, PIMARKERS, PIMARKERS_PAR) ;  /* Fonte "PIMARKERS" */
+    //    fprintf(mPSFile, END_PROLOG) ;
+    /* Aucun format n'est specifie ici ... */
+    fprintf(mPSFile, "$PIDict begin /PIMarkers ff 14 scf sf\n") ;
+    fprintf(mPSFile, "/FState save def\n%%%%EndProlog\n\n") ;
+}
+
+
+
+/*
+ *  PostScript simple...
+ *
+ *
+ */
+PSFile::PSFile(const char *FileName,
+	       PIOrientation orientation,
+	       PIPaperSize   paperSize,
+	       double marginX, double marginY)
+ :  mPSFileName (FileName == NULL ? "unnamed.ps" : const_cast<char *>(FileName)),
+    Tw(PaperSizeTable[paperSize].width),  /* Format papier utilise */
+    Th(PaperSizeTable[paperSize].height), /*                       */
+    WMargin(marginX),
+    HMargin(marginY),
+    isEPS(0),
+    scale(0.),
+    PageCounter(0),  /* Fichier vide */
+    FileEmpty(1),    /*              */
+    currentPage(NULL),
+    currentBloc(NULL),
+    mDrawColor(PI_Black),
+    mFillColor(PI_Black),
+    mFontAtt(PI_RomanFont),
+    mFontSize(0),
+    mFontName(PI_DefaultFont),
+    mLineAtt(PI_NormalLine),
+    mMarker(PI_DotMarker), 
+    setFontDone(true)
+{
+    char * date = new(char[64]) ; 
+    time_t timer ; 
+
+    /* Ouverture du fichier, en mode w+ (tout est ecrase) */
+    if ( (mPSFile = fopen(FileName, "w+")) == NULL){
+	  perror (FileName);
+	  return;
+    }
+
+    /* Format et orientation */
+
+    /* Ecriture du Header  */
+    fprintf(mPSFile, "%%!PS-Adobe-2.0\n") ;
+    time(&timer) ; 
+    date = ctime(&timer) ; 
+    fprintf(mPSFile, HEADER, mPSFileName, date) ; /* titre, date etc... */
+    fprintf(mPSFile, PIDICT, PIDICT_PAR) ;        /* Dictionnaire */
+    fprintf(mPSFile, PIMARKERS, PIMARKERS_PAR) ;  /* Fonte "PIMARKERS" */
+    fprintf(mPSFile, "$PIDict begin /PIMarkers ff 14 scf sf\n") ;
+    fprintf(mPSFile, "/FState save def\n%%%%EndProlog\n\n") ;
+}
+
+
+/* 
+ * Destructeur
+ *
+ */
+PSFile::~PSFile () {
+
+    /* On ferme tout ce qui ne l'est pas */
+    if (currentBloc) PSFile::EndBloc();
+    if (currentPage) PSFile::EndPage();
+
+    /* Si le fichier est vide, on le detruit */
+    if (FileEmpty) remove(mPSFileName);
+
+    /* On ecrit le "Trailer" et on ferme */
+    else {
+	/* On restore l'etat initial */
+	fprintf(mPSFile,"FState restore\n") ;
+	fprintf(mPSFile, "%%%%Trailer\n%%%%Pages: %d\n%%%%EOF\n", 
+		PageCounter) ;
+	fclose (mPSFile);
+    }
+}
+
+
+int   PSFile::IsEPS(){
+
+    return(isEPS);
+}
+
+
+const char* PSFile::GetFileName() {
+
+    return(mPSFileName);
+}
+
+PIColors PSFile::GetDrawColor() {
+
+    return(mDrawColor);
+}
+
+PIColors PSFile::GetFillColor() {
+
+    return(mFillColor);
+}
+
+PIFontAtt PSFile::GetFontAtt() {
+
+    return(mFontAtt);
+}
+
+// N.R. 07/08/99 return val PIFontSize --> int 
+int PSFile::GetFontSize() {
+
+    return(mFontSize);
+}
+
+PILineAtt PSFile::GetLineAtt() {
+
+    return(mLineAtt);
+}
+
+PIMarker PSFile::GetMarker() {
+
+    return(mMarker);
+}
+
+void  PSFile::NewPage(double Dx, double Dy, PIOrientation orientation) {
+
+double  tw, th; /* largeur & hauteur corrigees des marges */
+
+    /* On ferme ce qui doit l'etre ... */
+    if (currentPage) PSFile::EndPage();
+
+    currentPage = new (Page) ; 
+
+    /* Initialisations */
+    currentPage->num = ++PageCounter;
+    currentPage->BlocCounter = 0;
+    currentPage->Dx = Dx;
+    currentPage->Dy = Dy;
+    currentPage->orientation = orientation ;
+
+    /* Position du debut AVANT D'ECRIRE! */
+    currentPage->begin  = ftell(mPSFile);
+
+    /* On ecrit dans le fichier */
+    fprintf(mPSFile, "%%%%Page: %d %d\n", PageCounter, PageCounter) ;
+    fprintf(mPSFile, "/PState save def 1 -1 scale\n");
+
+    /* 
+     *  Si eps : Portrait || Auto == on laisse tel que
+     *           Landscape == on tourne de -90 degres
+     */
+    if(isEPS) {
+	if( (orientation == PI_Portrait) || (orientation == PI_Auto) )
+	    fprintf(mPSFile,
+		    "%.2f %.2f %.2f %.2f %.2f %.2f newref\n",
+		    Dx, Dy, Dx*scale, Dy*scale, 0., -Dy*scale);
+	else
+	    if(orientation==PI_Landscape)
+		fprintf(mPSFile, 
+			"-90 rotate %.2f %.2f %.2f %.2f %.2f %.2f newref\n",
+			Dx, Dy, Dx*scale, Dy*scale, 0., 0.);
+	    else
+		fprintf(stderr, "Orientation Error ; Page : %d\n",
+			currentPage->num) ; 
+    /* 
+     * On specifie la bb 
+     * (Si non encore fait par un appel precedent a NewPage() ) 
+     */
+	if(boundingBox) {
+	    currentPage->tmp = ftell(mPSFile) ;
+	    fseek(mPSFile,boundingBox,SEEK_SET) ;
+	    if( (orientation == PI_Portrait) || (orientation == PI_Auto) )
+		fprintf(mPSFile, "%d %d %d %d", 0, 0, 
+			(int)(Dx*scale), (int)(Dy*scale) ) ; 
+	    else
+		fprintf(mPSFile, "%d %d %d %d", 0, 0, 
+			(int)(Dy*scale), (int)(Dx*scale) ) ;
+	    fseek(mPSFile,currentPage->tmp,SEEK_SET) ;
+	    boundingBox = 0 ; 
+	} /* BB */
+    } /* EPS */
+    /*
+     * Si ps : 
+     *   - soustraction marges --> rectangle utile.
+     *   - Si PI_Auto : On fait au mieux pour minimiser le 
+     *      redimensionnement...
+     *   - Si PI_Portrait, on ne fait rien, sauf 
+     *      peut-etre un redimensionnement pour rentrer dans les marges
+     *   - Si PI_Landscape, on tourne de -90 degres.
+     */
+    else {
+        // Si marges <= 0 on les met a 2cm
+        if(WMargin<=0) WMargin = 2. ; 
+        if(HMargin<=0) HMargin = 2. ; 
+	/* Eviter image reduite a un point...ou moins... */
+	if((tw = Tw - 2*WMargin) < (Tw/10)) {
+	    WMargin = (0.45)*Tw ;
+	    tw = Tw/10;
+	}
+	if((th = Th - 2*HMargin)< (Th/10)) {
+	    HMargin = (0.45)*Th ;
+	    th = Th/10;
+	}
+	/* Portrait ou Landscape ? */
+	if(orientation == PI_Auto) 
+	    if( ((tw < th) && (Dx < 1.2*Dy)) ||
+		((tw > th) && (Dx > Dy) )) 
+		currentPage->orientation = PI_Portrait ;
+	    else 
+		currentPage->orientation = PI_Landscape ;
+
+	if(currentPage->orientation == PI_Portrait) {
+	  //	    if( (tw/Dx) < (th/Dy) ) 
+	  //		scale = tw/Dx ;
+	  //                scale = tw/Tw ; 
+	  //	    else 
+	  //		scale = th/Dy;
+	  //                scale = th/Th;
+	  //	    fprintf(mPSFile, 
+	  //		    "%.2f %.2f %.2f cm %.2f cm %.2f cm %.2f cm newref\n",
+	  //		    Dx, Dy, 
+	  //		    Dx*scale, Dy*scale, 
+	  //		    Tw*scale, Th*scale, 
+	  //		    0.5*(Tw-tw), -0.5*(Th+th)) ;
+            scale = (tw/Dx)<(th/Dy) ? tw/Dx : th/Dy ; 
+            tw = scale*Dx ; th = scale*Dy ; 
+	    fprintf(mPSFile, 
+		    "%.2f %.2f %.2f cm %.2f cm %.2f cm %.2f cm newref\n",
+		    Dx, Dy, 
+		    tw, th, 
+		    0.5*(Tw-tw), -0.5*(Th+th)) ;
+	}
+	if(currentPage->orientation == PI_Landscape) {
+	    /* Idem avec X<->Y */
+//	    if( (th/Dx) < (th/Dy) ) 
+//		scale = th/Dx;
+//                scale = th/Tw;
+//	    else
+//		scale = tw/Dy ;
+//                scale = tw/Th;
+//	    fprintf(mPSFile,
+//	       "-90 rotate %.2f %.2f %.2f cm %.2f cm %.2f cm %.2f cm newref\n",
+//	       Dx, Dy,
+//	       Dx*scale, Dy*scale, 
+//	       Th*scale, Tw*scale, 
+//	       0.5*(Th-th), 0.5*(Tw-tw));
+
+            scale = (th/Dx)<(tw/Dy) ? th/Dx : tw/Dy ; 
+            th = scale*Dx ; tw = scale*Dy ; 
+	    fprintf(mPSFile,
+	       "-90 rotate %.2f %.2f %.2f cm %.2f cm %.2f cm %.2f cm newref\n",
+	       Dx, Dy,
+	       th, tw,
+	       0.5*(Th-th), 0.5*(Tw-tw));
+	}
+    } /* End if .ps */
+currentPage->tmp = ftell(mPSFile);
+}
+
+
+
+void  PSFile::EndPage() {
+
+    /* Si rien a fermer, on s'en va */
+    if ( ! currentPage ) return;
+
+    /* Si un bloc non ferme, on appelle EndBloc */
+    if ( currentBloc ) PSFile::EndBloc();
+    
+    /* Si la page est vide, on la detruit */
+    if (currentPage->tmp == ftell(mPSFile)) {
+	fseek(mPSFile, currentPage->begin, SEEK_SET);
+	delete(currentPage) ;
+	PageCounter--;
+    }
+    /* Sinon, fin page + empilage */
+    else {
+	//	it = mPageList.end(); it--;
+	fprintf(mPSFile,"PState restore  showpage\n");
+	fprintf(mPSFile,"%%>EndPage %d\n\n\n", currentPage->num);
+	currentPage->end = ftell(mPSFile);
+	mPageList.push_back(*currentPage); /* Pourquoi PageList ? */
+	FileEmpty = 0;
+    }
+    currentPage = NULL;
+}
+
+
+void  PSFile::NewBloc(double x0, double y0, double Tx, double Ty,
+			      double Dx, double Dy){
+
+    /* Si pas de page, on s'en va */
+    if ( ! currentPage ) return;
+
+    /* On ferme le bloc precedent (Pas de Bloc-gigognes ! ) */
+    if (currentBloc) PSFile::EndBloc();
+
+    currentBloc = new (Bloc) ; 
+    /* On remplit currentBloc */
+    currentBloc->num = ++(currentPage->BlocCounter);
+    currentBloc->X0 = x0;
+    currentBloc->Y0 = y0;
+    currentBloc->Tx = Tx;
+    currentBloc->Ty = Ty;
+    currentBloc->Dx = Dx;
+    currentBloc->Dy = Dy;
+    currentBloc->begin = ftell(mPSFile);
+
+    /* On met a jour le fichier */
+    fprintf(mPSFile, "%%>BeginBloc %d\n", currentBloc->num);
+    fprintf(mPSFile, "%.2f %.2f %.2f Ux %.2f Uy %.2f Ux %.2f Uy NewBloc\n",
+	    currentBloc->Dx, currentBloc->Dy,
+	    currentBloc->Tx, currentBloc->Ty,
+	    currentBloc->X0, currentBloc->Y0);
+    currentBloc->tmp = ftell(mPSFile) ;
+}
+
+
+void  PSFile::EndBloc() {
+
+    /* On verifie qu'un bloc ouvert existe bien */
+    if ( ! currentBloc ) return;
+
+    /* Si le bloc est vide, on le detruit */
+    if (currentBloc->tmp == ftell(mPSFile)) {
+	fseek(mPSFile, currentBloc->begin, SEEK_SET) ; 
+	currentPage->BlocCounter-- ; 
+    }
+    /* Sinon, Ok met a jour le fichier */
+    else { 
+	fprintf(mPSFile, "EndBloc\n"); 
+	fprintf(mPSFile, "%%>EndBloc %d\n", currentBloc->num); 
+	currentBloc->end = ftell(mPSFile) ; 
+	currentPage->mBlocList.push_back(*currentBloc) ; 
+	//	PageEmpty = 0; 
+    } 
+    /* Flags */
+    currentBloc = NULL ; 
+}
+
+void PSFile::SelForeground(PIColorMap& cmap, int cid)
+{
+  mDrawColor = PI_ColorFromMap ; 
+  PIColor tmp = cmap.GetColor(cid) ; 
+  fprintf(mPSFile, "/ur %.3f def /ug %.3f def /ub %.3f def \n", 
+          (double)(tmp.red)/65535., 
+          (double)(tmp.green)/65535., 
+          (double)(tmp.blue)/65535.) ; 
+}
+
+
+void PSFile::SelBackground(PIColorMap& cmap, int cid)
+{
+  mDrawColor = PI_ColorFromMap ; 
+}
+
+
+void  PSFile::DrawString  (double x,  double y, const char *s, 
+			   PIColors DrawColor, 
+			   PIFontName FontName, 
+			   PIFontAtt FontAtt, 
+			   int FontSize) {
+    int change = 0;
+
+    /* Couleurs */
+    if ( (DrawColor != PI_NotDefColor) && (DrawColor != mDrawColor) ) {
+	mDrawColor = DrawColor;
+	fprintf(mPSFile, "C%d ", mDrawColor) ; 
+    }
+    /* Choix des fontes */
+    if ( (FontAtt != PI_NotDefFontAtt) && (FontAtt != mFontAtt) ) {
+      printf("PSFile::DrawString(%s) : FontAtt a change : %d %d \n", s, mFontAtt, FontAtt) ; 
+      mFontAtt = FontAtt;
+      change = 1;
+    }
+    if ( (FontSize != PI_NotDefFontSize) && (FontSize != mFontSize) ) {
+      printf("PSFile::DrawString(%s) : FontSize a change : %d %d \n", s, mFontSize, FontSize) ; 
+      mFontSize = (PIFontSize) FontSize;  // $CHECK$ EA ajoute le cast un peu au pif
+      change = 1;
+    }
+    if( (FontName != mFontName) ) {
+      printf("PSFile::DrawString(%s) : FontName a change : %d %d \n", s, mFontName, FontName) ; 
+      mFontName = (PIFontName) FontName ; 
+      change = 1 ; 
+    }
+    if (change) { 
+      string fname ; 
+      switch(mFontName) {
+      case PI_DefaultFont:
+      case PI_CourierFont:
+	fprintf(mPSFile, "/Courier") ; 
+	break ; 
+      case PI_HelveticaFont:
+	fprintf(mPSFile, "/Helvetica") ; 
+	break ; 
+      case PI_TimesFont:
+	fprintf(mPSFile, "/Times") ; 
+	break ; 
+      case PI_SymbolFont:
+	fprintf(mPSFile, "/Symbol ") ; 
+	break ; 
+      } // endsw 
+      
+      switch(mFontAtt) {
+      case PI_NotDefFontAtt:
+      case PI_RomanFont:
+	fprintf(mPSFile, " ") ; 
+	break ; 
+      case PI_BoldFont:
+	if(mFontName != PI_SymbolFont) fprintf(mPSFile, "-Bold ") ; 
+	break ; 
+      case PI_ItalicFont:
+	if(mFontName != PI_SymbolFont) fprintf(mPSFile, "-Italic ") ; 
+	break ; 
+      } // endsw 
+      fprintf(mPSFile, " ff %d FS ", FontSize) ; 
+    }
+    
+    
+    fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) S gr\n", x, y, s) ; 
+    setFontDone = true ; 
+}
+
+
+void  PSFile::DrawLine    (double x1, double y1, double x2, double y2, 
+			   PIColors DrawColor,
+			   PILineAtt LineAtt) {
+
+  int lw = 0 ; 
+
+  switch(LineAtt) {
+    case PI_NotDefLineAtt:
+      break ; 
+    case PI_NormalLine:
+      lw = 2. ; 
+      break ; 
+    case PI_ThinLine:
+      lw = 1 ; 
+      break ; 
+    case PI_ThickLine:
+      lw = 4 ;
+      break ; 
+  } 
+
+    /* Line Att */
+    if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {
+        mLineAtt = LineAtt;
+	fprintf(mPSFile, "%d slw ", lw) ; 
+    }
+
+    /* Couleurs */
+    if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) {
+	mDrawColor = DrawColor;
+	fprintf(mPSFile, "C%d ", mDrawColor);
+    }
+
+    /* Dessin */
+    fprintf(mPSFile, "n %.2f Ux %.2f Uy m %.2f Ux %.2f Uy l s\n",
+	    x1, y1, x2, y2) ;
+}
+
+
+
+void  PSFile::DrawBox(double x0, double y0, double Tx, double Ty, 
+		      PIColors  DrawColor,
+		      PILineAtt LineAtt) {
+
+    /* Changement couleurs ? */
+    if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) {
+	mDrawColor = DrawColor;
+	fprintf(mPSFile, "C%d ", mDrawColor) ; 
+    }
+
+    /* Line Att */
+    if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {
+        mLineAtt = LineAtt;
+	fprintf(mPSFile, "%d slw ", mLineAtt) ; 
+    }
+
+    /* On dessine */
+    fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy box s gr\n",
+	    Tx, Ty, x0, y0) ; 
+}
+
+
+void  PSFile::DrawFBox(double x0, double y0, double Tx, double Ty, 
+		   PIColors DrawColor,
+		   PIColors FillColor, 
+		   PILineAtt LineAtt) {
+
+    /* Line Att */
+    if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {
+        mLineAtt = LineAtt;
+	fprintf(mPSFile, "%d slw ", mLineAtt) ; 
+    }
+
+    /* Dessin du fond */
+    if ( (FillColor != PI_NotDefColor) || (FillColor != mFillColor) )
+	mFillColor = FillColor;
+    fprintf(mPSFile, "C%d ", mFillColor) ; 
+    fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy box f gr\n",
+	    Tx, Ty, x0, y0) ; 
+    
+    /* Dessin du contour (s'il y a lieu) */
+    if ( (DrawColor != PI_NotDefColor) && (FillColor != DrawColor) )
+	mDrawColor = DrawColor;
+    fprintf(mPSFile, "C%d ", mDrawColor) ; 
+    fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy box s gr\n",
+	    Tx, Ty, x0, y0) ;
+}
+
+
+void  PSFile::DrawCircle  (double x0, double y0, double r, 
+			   PIColors DrawColor,
+			   PILineAtt LineAtt) {
+
+    /* Couleurs */
+    if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) {
+	mDrawColor = DrawColor;
+	fprintf(mPSFile, "C%d ", mDrawColor); 
+    }
+
+    /* Line Att */
+    if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {
+        mLineAtt = LineAtt;
+	fprintf(mPSFile, "%d slw ", mLineAtt); 
+    }
+
+    /* Dessin */
+    fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy 0 360 ellipse s gr\n",
+	    x0, y0, r, r) ;
+}
+
+
+void  PSFile::DrawFCircle (double x0, double y0, double r,
+		   PIColors DrawColor,
+		   PIColors FillColor, 
+		   PILineAtt LineAtt) {
+
+    /* Line Att */
+    if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {
+        mLineAtt = LineAtt;
+	fprintf(mPSFile, "%d slw ", mLineAtt) ; 
+    }
+
+    /* Dessin du fond */
+    if ( (FillColor != PI_NotDefColor) || (FillColor != mFillColor) ){
+	mFillColor = FillColor;
+	fprintf(mPSFile, "C%d ", mFillColor) ;
+    }
+    fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy \
+                      0 360 ellipse f gr\n",
+	    x0, y0, r, r);
+    fprintf(mPSFile, "C%d ", mDrawColor) ;
+
+    /* Dessin du contour (s'il y a lieu) */
+    if ( (DrawColor != PI_NotDefColor) && (FillColor != DrawColor) ) {
+	mDrawColor = DrawColor;
+	fprintf(mPSFile, "C%d ", mDrawColor); 
+	fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy 0 360 ellipse s gr\n",
+		x0, y0, r, r) ;
+    }
+}
+
+
+// Les coordonnees sont supposees etre en mode incremental .
+void  PSFile::DrawPolygon (double *x, double *y, int n,
+		   PIColors DrawColor, 
+		   PILineAtt LineAtt, bool cinc) {
+
+    /* Line Att */
+    if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {
+        mLineAtt = LineAtt;
+	fprintf(mPSFile, "%d slw ", mLineAtt) ; 
+    }
+
+    /* Couleur */
+    if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) {
+	mDrawColor = DrawColor;
+	fprintf(mPSFile, "C%d ", mDrawColor) ;
+    }
+    
+    /* On dessine ; ici*/
+    fprintf(mPSFile, "%.2f Ux %.2f Uy m\n", x[0], y[0]);
+
+    const char* cmd ; 
+    if(cinc == true) cmd = "%.2f Ux %.2f Uy rl\n" ; 
+    else             cmd = "%.2f Ux %.2f Uy l\n" ; 
+
+    for(int i = 1; i<n; i++) 
+      fprintf(mPSFile, cmd, x[i], y[i]);
+    fprintf(mPSFile, "c s\n");
+}
+
+
+void  PSFile::DrawFPolygon(double *x, double *y, int n,
+		   PIColors DrawColor,
+		   PIColors FillColor,
+		   PILineAtt LineAtt, bool cinc) {
+
+    /* Line Att */
+    if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {
+        mLineAtt = LineAtt;
+	fprintf(mPSFile, "%d slw ", mLineAtt) ; 
+    }
+
+    const char* cmd ; 
+    if(cinc == true) cmd = "%.2f Ux %.2f Uy rl\n" ; 
+    else             cmd = "%.2f Ux %.2f Uy l\n" ; 
+
+    /* Dessin du fond... */
+    if ( (FillColor != PI_NotDefColor) || (FillColor != mFillColor) ) 
+	mFillColor = FillColor;
+    fprintf(mPSFile, "C%d ", mFillColor) ;
+    fprintf(mPSFile, "%.2f Ux %.2f Uy m\n", x[0], y[0]);
+    int i;
+    for(i = 1; i<n; i++) 
+	fprintf(mPSFile, cmd, x[i], y[i]);
+    fprintf(mPSFile, "c f\n");
+
+    /* ...puis du contour (s'il y a lieu) */
+    if ( (DrawColor != PI_NotDefColor) && (DrawColor != FillColor) )
+	mDrawColor = DrawColor;
+    fprintf(mPSFile, "C%d ", mDrawColor) ;
+    fprintf(mPSFile, "%.2f Ux %.2f Uy m\n", x[0], y[0]);
+    for(i = 1; i<n; i++) 
+      fprintf(mPSFile, cmd, x[i], y[i]);
+    fprintf(mPSFile, "c s\n");
+}
+
+
+
+void  PSFile::DrawMarker  (double x0, double y0,
+			   PIMarker MrkType,   
+			   PIColors DrawColor,
+			   int MarkerSize) {
+    /* Couleurs */
+    if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) {
+	mDrawColor = DrawColor;
+	fprintf(mPSFile, "C%d ", mDrawColor) ; 
+    }
+
+    /* Marker */
+    if (MrkType != PI_NotDefMarker)
+	mMarker = MrkType;
+
+    if(MarkerSize != mMarkerSize || setFontDone) {
+	mMarkerSize = MarkerSize ;
+	fprintf(mPSFile, "/PIMarkers ff %d scf sf\n", mMarkerSize) ; 
+        setFontDone = false ; 
+    }
+    /* Dessin */
+    fprintf(mPSFile, "%.2f Ux %.2f Uy m (\\%#o) show\n", x0, y0, mMarker) ;
+}
+
+/*
+ * Pas d'options pour specifier la taille des Markers ?
+ *
+ */
+void  PSFile::DrawMarkers (double *x0, double *y0, int n,
+			   PIMarker MrkType,
+			   PIColors DrawColor,
+			   int MarkerSize) {
+    /* Couleurs */
+    if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) {
+	mDrawColor = DrawColor;
+	fprintf(mPSFile, "C%d ", mDrawColor) ; 
+    }    
+
+    /* Marker */
+    if (MrkType != PI_NotDefMarker)
+	mMarker = MrkType;
+
+    if(MarkerSize != mMarkerSize || setFontDone) {
+	mMarkerSize = MarkerSize ;
+	fprintf(mPSFile, "/PIMarkers ff %d scf sf\n", mMarkerSize) ; 
+        setFontDone = false ; 
+    }
+    /* Dessin */
+    for(int i = 0; i<n; i++)
+	fprintf(mPSFile, "%.2f Ux %.2f Uy m (\\%#o) show\n", x0[i], y0[i], mMarker) ; 
+}
+
+void PSFile::Image(double x0, double y0, double Tx, double Ty,
+		   int Nx, int Ny,
+		   unsigned char *Pict, 
+		   PIColorMap *mMap) {
+
+    int i, j;
+
+    /* Buffers PostScript */
+    fprintf(mPSFile, "/Taille %d def\n", Nx);
+    fprintf(mPSFile, "/ImStr Taille string def\n");
+    fprintf(mPSFile, "/RGBStr Taille 3  mul string def\n");
+
+    /* Ecriture ColorMap */
+    fprintf(mPSFile, "/ColorMap %02d array def\n", mMap->NCol() );
+    for(i = 0; i < mMap->NCol(); i++) {
+	fprintf(mPSFile, "ColorMap %d [16#%02X 16#%02X 16#%02X] put\n",
+		i,
+		(int)(mMap->GetColor(i).red/256),
+		(int)(mMap->GetColor(i).green/256),
+		(int)(mMap->GetColor(i).blue/256));
+    }
+    /* Emplacement de l'image */
+    fprintf(mPSFile, "gs %.2f Ux %.2f Uy tr %.2f Ux %.2f Uy sc\n", x0, y0, Tx, Ty);
+    /* Nbr pix-X, Nbr pix-Y bits/pixels */
+    fprintf(mPSFile, "%d %d 8\n", Nx, Ny);
+    /* Matrice de passage */
+    fprintf(mPSFile, "[%d 0 0 %d 0 0]", Nx, Ny);
+    /* Fonction colorimage */
+    fprintf(mPSFile, "{currentfile ImStr readhexstring pop GetRGB}\
+false 3 colorimage\n\n");
+    /* Data */
+    for(i = 0; i < Ny; i++) {
+	for(j = 0; j<Nx-1; j++ )
+	    fprintf(mPSFile, "%02X", Pict[i*Nx+j]);
+    fprintf(mPSFile, "%02X\n", Pict[i*Nx+j]);
+    }
+    /* Un petit grestore ...*/
+    fprintf(mPSFile, "gr\n");
+}
+
+/* 
+ *  Conversion
+ *
+ */
+
+double cm2pt(double x) {
+    return (x*28.35);
+}
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/psfile.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/psfile.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/psfile.h	(revision 464)
@@ -0,0 +1,206 @@
+#ifndef PSFILE_H_SEEN
+#define PSFILE_H_SEEN
+
+/*
+ *  PSFile.h
+ * 
+ *  14/06/96, 19/06/96
+ *
+ *  Gestion des fichier .ps et .eps
+ *
+ *     - L'unite de mesure est lUnite Courante (UC)
+ *        Au depart, 1UC == 1cm 
+ *     - Les reperes sont orientes a la maniere XWindow
+ * 
+ *  17/02/97 : modification des constructeurs(1-->eps,2-->ps)
+ *             ajout du type enum orientation
+ *
+ */
+
+#include "machdefs.h"
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef __mac__
+#include <stat.h>
+#endif
+#include "pisysdep.h"
+#include "pifontgen.h"
+
+#include "pigraphgen.h"      // Types enumeres repris de Peida:PIFontSize...
+#include PICMAP_H
+
+#include <list>
+
+enum PIPaperSize { PI_A4 = 1, PI_A3 = 2, PI_A5 = 3, PI_NotDefPaperSize = 0};
+
+enum PIOrientation { PI_Landscape = 0, PI_Portrait = 1, PI_Auto = 2 } ;
+
+
+/*
+ *#define PAGE_WIDTH   21.0    == 595 points 
+ *#define PAGE_HEIGHT  29.7    == 842 points 
+ *#define PORTRAIT  1
+ *#define LANDSCAPE 0
+ */
+
+
+
+/* Valable pour une page, ou un bloc */
+/*typedef struct {
+ *  double X0;          Coordonnes sommet NO  
+ *  double Y0;           en unites courantes  
+ *  double Tx;          Format                
+ *  double Ty;           en unites courantes  
+ *  double Dx;          Coord sommet SE       
+ *  double Dy;           en unites courantes  
+ *  int orientation;   LANDSCAPE OU PORTRAIT 
+ *} Format;
+ */
+
+/*
+ *typedef struct{
+ *    char *Name;
+ *    int  Tx;     En 1/72e de pouce  !! 
+ *    int  Ty;     unite naturelle de ps 
+ *} PIMedia;
+ */
+
+
+
+class PSFile{
+
+public:
+    /* Production fichier eps */
+    PSFile (const char * FileName, double sc = 1.0);
+    /* Production fichier ps  */
+    PSFile (const char * FileName, PIOrientation orientation, 
+	    PIPaperSize paperSize= PI_A4, 
+	    double marginX = 5.0, double marginY = 5.0 ) ;
+
+    virtual      ~PSFile();
+
+    virtual int     IsEPS();
+    virtual const char*   GetFileName();
+
+
+    /*    virtual Format* GetFormat(); */
+    /* Attributs graphiques */
+    virtual PIColors    GetDrawColor();
+    virtual PIColors    GetFillColor();
+    virtual PIFontAtt   GetFontAtt();
+    virtual int         GetFontSize();
+    virtual PILineAtt   GetLineAtt();
+    virtual PIMarker    GetMarker();
+
+    virtual void  NewPage(double Dx, double Dy, PIOrientation orientation);
+    virtual void  EndPage();
+    virtual void  NewBloc(double x0, double y0, double Tx, double Ty,
+			  double Dx, double Dy);
+    virtual void  EndBloc();
+
+    virtual void SelForeground(PIColorMap& cmap, int cid) ; 
+    virtual void SelBackground(PIColorMap& cmap, int cid) ; 
+
+    /* Trace */
+    virtual void  DrawString  (double x,  double y, const char *s, 
+			       PIColors DrawColor  = PI_NotDefColor, 
+			       PIFontName FontName = PI_DefaultFont,
+			       PIFontAtt FontAtt   = PI_NotDefFontAtt, 
+			       int FontSize        = 8);
+    virtual void  DrawLine    (double x1, double y1, double x2, double y2, 
+			       PIColors DrawColor  = PI_NotDefColor,
+			       PILineAtt LineAtt   = PI_NotDefLineAtt);
+    virtual void  DrawBox     (double x0, double y0, double Tx, double Ty, 
+			       PIColors DrawColor  = PI_NotDefColor,
+			       PILineAtt LineAtt   = PI_NotDefLineAtt);
+    virtual void  DrawFBox    (double x0, double y0, double Tx, double Ty, 
+			       PIColors DrawColor  = PI_NotDefColor,
+			       PIColors FillColor  = PI_NotDefColor, 
+			       PILineAtt LineAtt   = PI_NotDefLineAtt);
+    virtual void  DrawCircle  (double x0, double y0, double r, 
+			       PIColors DrawColor  = PI_NotDefColor,
+			       PILineAtt LineAtt   = PI_NotDefLineAtt);
+    virtual void  DrawFCircle (double x0, double y0, double r,
+			       PIColors DrawColor  = PI_NotDefColor,
+			       PIColors FillColor  = PI_NotDefColor, 
+			       PILineAtt LineAtt   = PI_NotDefLineAtt);
+    virtual void  DrawPolygon (double *x, double *y, int n,
+			       PIColors DrawColor  = PI_NotDefColor, 
+			       PILineAtt LineAtt   = PI_NotDefLineAtt, 
+                               bool cinc = true);
+    virtual void  DrawFPolygon(double *x, double *y, int n,
+			       PIColors DrawColor  = PI_NotDefColor,
+			       PIColors FillColor  = PI_NotDefColor,
+			       PILineAtt LineAtt   = PI_NotDefLineAtt, 
+                               bool cinc = true);
+    virtual void  DrawMarker  (double x0, double y0, 
+			       PIMarker MrkType    = PI_NotDefMarker, 
+			       PIColors DrawColor  = PI_NotDefColor,
+			       int MarkerSize=14);
+    virtual void  DrawMarkers (double *x0, double *y0, int n,
+			       PIMarker MrkType    = PI_NotDefMarker,
+			       PIColors DrawColor  = PI_NotDefColor,
+			       int MarkerSize=14); 
+
+    virtual void  Image(double x0, double y0, double Tx, double Ty,
+			int Nx, int Ny,
+			unsigned char *pict,
+			PIColorMap *mColorMap);
+
+// Declarations en public - sinon certains compilateurs cxx , aCC, xlC ont des problemes
+    /* Blocs */
+    typedef struct {
+	int    num;
+	char*  label;
+	double  X0, Y0;            /* coordonnees sommet NO */
+	double  Tx, Ty;            /* Format */
+	double  Dx, Dy;            /* Repere utilisateur */
+	long  begin,end,tmp;   /* offsets dans le fichier */
+    } Bloc ;
+    typedef list<Bloc> BlocList;  /* STL */
+
+
+    /* Pages */
+    typedef struct {
+	int num;
+	int BlocCounter;
+	double Dx,Dy;              /* Sommet SE (unites utilisateur) */ 
+	PIOrientation orientation;
+	long  begin, end, tmp;    /* Offsets dans le fichier */
+	BlocList mBlocList;       /* Page == Liste de blocs  */
+    } Page ;
+    typedef list<Page> PageList;  /* STL */
+
+private:
+
+    /* Fichier ps/eps */
+    FILE *   mPSFile;
+    const char *   mPSFileName;
+    double    Tw,Th ;              /* Format, en cm */
+    double    WMargin,HMargin ;    /* Marges minimales */
+    int      isEPS;               /* Vrai si PostScript Encapsule */
+    long     boundingBox;         /* Endroit ou est specifiee la bb */
+    double    scale;              /* boundingbox = Dx*scale ; Dy*scale */
+    PIPaperSize mPaperSize ; 
+    int      PageCounter;         /* nbr pages */
+    int      FileEmpty;
+    Page*    currentPage;        /* Avant empilage */
+    Bloc*    currentBloc;        /* Avant empilage */
+    PageList mPageList;          /* Fichier == Liste de pages */
+
+
+    /* Attributs graphiques, initialises par constructeur */
+    enum PIColors    mDrawColor;  /* Couleur de trace courante */
+    enum PIColors    mFillColor;  /* Couleur de remplissage courante */
+    enum PIFontAtt   mFontAtt; 
+    //    enum PIFontSize  mFontSize; 
+    int              mFontSize; 
+    enum PIFontName  mFontName; 
+    enum PILineAtt   mLineAtt;    /* Epaisseur d une ligne */
+    enum PIMarker    mMarker;     /* Marker courant */
+    int              mMarkerSize; /* Taille (en points) du marker courant */
+    bool setFontDone ; /* Pour forcer la selection de Marker apres DrawString() */
+} ;
+
+
+#endif/* PSFILE_H_SEEN */
Index: /tags/V_LaSilla191199/SophyaPI/PI/so_locations
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/so_locations	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/so_locations	(revision 464)
@@ -0,0 +1,12 @@
+piup.so \
+		:st = .text 0x000003ffbfff0000, 0x0000000000010000:\
+		:st = .data 0x000003ffffff0000, 0x0000000000010000:\
+
+piup_def.so \
+		:st = .text 0x000003ffbffe0000, 0x0000000000010000:\
+		:st = .data 0x000003fffffe0000, 0x0000000000010000:\
+
+user.so \
+		:st = .text 0x000003ffbffd0000, 0x0000000000010000:\
+		:st = .data 0x000003fffffd0000, 0x0000000000010000:\
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/xdispim.c
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/xdispim.c	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/xdispim.c	(revision 464)
@@ -0,0 +1,383 @@
+#if 0
+/* Fonctions interface XWindow pour affichage d'images */
+/*                  Reza   05/95                       */
+
+/*                  LAL (Orsay) / IN2P3-CNRS           */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+
+#include "xdispim.h"
+
+/*  Variables globales pour  */
+
+static int RzXwDispImg = 0;
+static Display * display;
+static int screen;
+static GC defgc;
+static RzXCMap rzxcmap[5];
+static int rzxgcok = 0;
+static Font fonts[5];
+
+static int NbRzXw = 0;
+
+
+/*  Fin des variables globales   */
+
+
+/* Nouvelle-Fonction */
+int RzXInitDisplay(int prtl)
+
+/*   Connection avec un serveur X, et allocation des couleurs    */
+
+{
+Visual* vis;
+
+
+struct rzvisu_struc
+  {
+  int MMsize_x;
+  int MMsize_y;
+  int Pixsize_x;
+  int Pixsize_y;
+  float resol_x;
+  float resol_y;
+  } rzvisu;
+
+
+display = XOpenDisplay ("");
+
+if (display == 0)
+  { printf("RzXInitDisplay_Error: Cannot connect to X-Server \n");
+    return(1); }
+screen = XDefaultScreen(display);
+
+rzvisu.Pixsize_x = DisplayWidth  (display, screen);
+rzvisu.Pixsize_y = DisplayHeight (display, screen);
+rzvisu.MMsize_x = DisplayWidthMM  (display, screen);
+rzvisu.MMsize_y = DisplayHeightMM (display, screen);
+
+rzvisu.resol_x = (float)rzvisu.Pixsize_x*10./(float)rzvisu.MMsize_x;
+rzvisu.resol_y = (float)rzvisu.Pixsize_y*10./(float)rzvisu.MMsize_y;
+
+vis = DefaultVisual(display,screen);
+
+if (prtl > 0)
+  {
+  printf("RzXInitDisplay_Info: Screen size (X,Y) : %d * %d Pix (%d * %d  mm)\n",
+         rzvisu.Pixsize_x,rzvisu.Pixsize_y,
+         rzvisu.MMsize_x,rzvisu.MMsize_y);
+  printf ("... Planes= %d  Cells= %d  depth= %d ", XDisplayPlanes(display, screen) ,
+          XDisplayCells(display, screen), XDefaultDepth(display, screen));
+
+  switch (vis->class)
+    {
+    case PseudoColor :
+      printf (".... Class = %d (PseudoColor) \n",vis->class);
+      break;
+    case DirectColor : 
+      printf (".... Class = %d (DirectColor) \n",vis->class);
+      break;
+    case GrayScale :
+      printf (".... Class = %d (GreyScale) \n",vis->class);
+      break;
+    case StaticColor :
+      printf (".... Class = %d (StaticColor) \n",vis->class);
+      break;
+    case StaticGray :
+      printf (".... Class = %d (StaticGray) \n",vis->class);
+      break;
+    case TrueColor :   
+      printf (".... Class = %d (TrueColor) \n",vis->class);
+      break;
+    default :
+      printf (".... Class = %d (Unknown !) \n",vis->class);
+      break;
+    }
+
+  }
+
+/*  Allocating default CMap */
+RzXAllocCMap(rzxcmap, CMAP_GREY32, prtl);
+RzXAllocCMap(rzxcmap+1, CMAP_COL16, prtl);
+RzXAllocCMap(rzxcmap+2, CMAP_GREYINV32, prtl);
+RzXAllocCMap(rzxcmap+3, CMAP_COLRJ32, prtl);
+rzxcmap[4].typ = -1;  rzxcmap[4].nCol = 0;
+
+if (prtl > 1)
+  printf("...Loading fonts Adobe-Courier Normal/Bold/Ital : \n");
+fonts[0] = XLoadFont(display,
+       "-adobe-courier-medium-r-normal--*-140-*-iso8859-1");
+fonts[1] = XLoadFont(display,
+       "-adobe-courier-bold-r-normal--*-140-*-iso8859-1");
+fonts[2] = XLoadFont(display,
+       "-adobe-courier-medium-o-normal--*-140-*-iso8859-1");
+
+RzXwDispImg = 1;    /*  Variable de controle d'initialisation */
+
+return(0);
+}
+
+/* Nouvelle-Fonction */
+int RzXCheckInitDisp()
+{
+return (RzXwDispImg);
+}
+
+
+/* Nouvelle-Fonction */
+int RzXGetPixDSize()
+/*  Retourne la taille correspondant a depth en Byte ( 8->1) */
+{
+int depth;
+depth = DefaultDepth(display,screen);
+if (depth <= 8)  return(1);
+else if (depth <= 16)  return(2);
+else return(4);
+}
+
+/* Nouvelle-Fonction */
+int RzXDispPixMap(Window xw, unsigned char *pix,  int sizx, int sizy, RzXCMap *cmap)
+{
+int depth;
+XImage * ximg;
+int i,j;
+unsigned char *pp;
+
+depth = DefaultDepth(display,screen);
+ximg = XCreateImage (display,DefaultVisual(display,screen),
+       depth,ZPixmap,0,pix,sizx,sizy,8,0);
+pp = pix;
+for(j=0; j<sizy; j++)
+  for(i=0; i<sizx; i++) 
+    { XPutPixel(ximg, i, j, cmap->colpix[*pp]);  pp++; }
+XRaiseWindow(display, xw);
+XPutImage(display,xw,defgc,ximg,0,0,0,0,sizx, sizy);
+XSync(display,1);
+XFree(ximg);
+
+return(0);
+
+}
+
+
+/* Nouvelle-Fonction */
+RzXCMap * RzXGetCMap(int cmapid)
+{
+int i;
+for(i=0; i<5; i++)
+  if (rzxcmap[i].typ == cmapid)  return(rzxcmap+i);
+if (rzxcmap[4].typ >= 0)  RzXFreeCMap(rzxcmap+4);
+RzXAllocCMap(rzxcmap+4, cmapid, 0);
+return(rzxcmap+4);
+}
+
+
+/*  Definition d' une table de couleurs  R G B   */
+
+static float R_RGB1[16] =
+{0.0,0.00,0.0,0.0,0.0,0.00,0.0,0.6,0.8,1.0,1.00,1.0,0.75,1.0,0.85,1.0};
+static float G_RGB1[16] =
+{0.0,0.00,0.0,0.8,1.0,1.00,1.0,0.8,0.8,1.0,0.75,0.6,0.00,0.0,0.0,0.0};
+static float B_RGB1[16] =
+{0.0,0.75,1.0,1.0,1.0,0.75,0.0,0.0,0.0,0.0,0.00,0.5,0.75,1.0,0.0,0.0};
+
+
+
+/* Nouvelle-Fonction */
+int RzXAllocCMap(RzXCMap *rcmap, int cmapid, int prtl)
+/*  Allocation des tables de couleurs  */
+
+{
+Colormap cmap;
+XColor mycol;
+int nok,i;
+
+cmap = XDefaultColormap (display, screen);
+
+nok = 0;
+
+rcmap->typ = -1;
+
+switch (cmapid)
+  {
+  case CMAP_GREY32 :
+    rcmap->nCol = 32;   nok = 0;
+    for(i=0; i<rcmap->nCol; i++)
+      {
+      mycol.red = mycol.green = mycol.blue = 3535+(i*62000/32);
+      if (XAllocColor(display, cmap, &mycol) )
+        { rcmap->colpix[i] = mycol.pixel;   nok++; }
+      else rcmap->colpix[i] = BlackPixel(display, screen);  
+      }
+    rcmap->typ = CMAP_GREY32;
+    break;
+
+  case CMAP_GREYINV32 :
+    rcmap->nCol = 32;   nok = 0;
+    for(i=0; i<rcmap->nCol; i++)
+      {
+      mycol.red = mycol.green = mycol.blue = 65535-(i*62000/32);
+      if (XAllocColor(display, cmap, &mycol) )
+        { rcmap->colpix[i] = mycol.pixel;   nok++; }
+      else rcmap->colpix[i] = BlackPixel(display, screen);  
+      }
+    rcmap->typ = CMAP_GREYINV32;
+    break;
+
+  case CMAP_COL16 :
+    rcmap->nCol = 16;   nok = 0;
+    for(i=0; i<rcmap->nCol; i++)
+      {
+      mycol.red = (int)(R_RGB1[i]*65535.);
+      mycol.green = (int)(G_RGB1[i]*65535.);
+      mycol.blue =(int)(B_RGB1[i]*65535.) ;
+      if (XAllocColor(display, cmap, &mycol) )
+        { rcmap->colpix[i] = mycol.pixel;   nok++; }
+      else rcmap->colpix[i] = BlackPixel(display, screen);  
+      }
+    rcmap->typ = CMAP_COL16;
+    break;
+
+  case CMAP_COLRJ32 :
+    rcmap->nCol = 32;   nok = 0;
+    for(i=0; i<rcmap->nCol; i++)
+      {
+      if (i < 12) 
+        { mycol.green = mycol.blue = 0;  
+          mycol.red = 21535+(i*4000); }
+      else if (i < 24)
+        { mycol.blue = 0;   mycol.red = 65535;
+          mycol.green = 21535+(i-12)*4000;  }
+      else 
+        { mycol.green = mycol.red = 65535;
+          mycol.blue = 17535+(i-23)*6000; }
+
+      if (XAllocColor(display, cmap, &mycol) )
+        { rcmap->colpix[i] = mycol.pixel;   nok++; }
+      else rcmap->colpix[i] = BlackPixel(display, screen);  
+      }
+    rcmap->typ = CMAP_COLRJ32;
+    break;
+
+  case CMAP_COLBR32 :
+    rcmap->nCol = 32;   nok = 0;
+    for(i=0; i<rcmap->nCol; i++)
+      {
+      if (i < 5) 
+        { mycol.green = mycol.red = 0;  
+          mycol.blue = 5535+i*15000; }
+      else if (i < 10)
+        { mycol.blue = 65535;
+          mycol.green = 5535+(i-5)*9000;
+          mycol.red = 0;  }
+      else if (i < 15)
+        { mycol.blue = 60000-(i-10)*15000;
+          mycol.green = 41535+(i-10)*6000;
+          mycol.red = 0;  }
+      else if (i < 21)
+        { mycol.blue = 0;
+          mycol.green = 65535;
+          mycol.red = 5535+(i-15)*12000;  }
+      else if (i < 27)
+        { mycol.blue = 0;
+          mycol.green = 60000-(i-21)*12000;
+          mycol.red = 65535-(i-21)*2000;  }
+      else 
+        { mycol.blue = 0;
+          mycol.green = 0;
+          mycol.red = 57535+(i-27)*2000; }
+
+      if (XAllocColor(display, cmap, &mycol) )
+        { rcmap->colpix[i] = mycol.pixel;   nok++; }
+      else rcmap->colpix[i] = BlackPixel(display, screen);  
+      }
+    rcmap->typ = CMAP_COLBR32;
+    break;
+
+  case CMAP_COLRV32 :
+    rcmap->nCol = 32;   nok = 0;
+    for(i=0; i<rcmap->nCol; i++)
+      {
+      if (i < 8) 
+        { mycol.green = 15000+(i*5000); mycol.blue = 0;  
+          mycol.red = 15000+(i*5000); }
+      else if (i < 21)
+        { mycol.green = 50000-(i-7)*5000;   
+          if (mycol.green < 0)  mycol.green = 0;
+          mycol.blue = 0;
+          mycol.red = 53535+(i-8)*1000;  }
+      else 
+        { mycol.green = 0;  mycol.red = 65535;
+          mycol.blue = 15535+(i-21)*5000; }
+
+      if (XAllocColor(display, cmap, &mycol) )
+        { rcmap->colpix[i] = mycol.pixel;   nok++; }
+      else rcmap->colpix[i] = BlackPixel(display, screen);  
+      }
+    rcmap->typ = CMAP_COLRV32;
+    break;
+
+  default :
+    printf("RzXAllocCMap_Info: Erreur specification CMapType (%d) \n", cmapid);
+    break;
+  }
+
+for(i=rcmap->nCol; i<256; i++)  rcmap->colpix[i] = 0;
+
+if (prtl)
+  printf("RzXAllocCMap_Info: %d colors allocated for CMap Type %d \n", nok, cmapid);
+
+return(0);
+
+}
+
+/* Nouvelle-Fonction */
+int RzXFreeCMap(RzXCMap *rcmap)
+{
+Colormap cmap;
+int i;
+
+cmap = XDefaultColormap (display, screen);
+XFreeColors(display, cmap, rcmap->colpix,  rcmap->nCol, 0);
+for(i=0; i<rcmap->nCol; i++)  rcmap->colpix[i] = 0;
+rcmap->nCol = 0;
+return(0);
+}
+
+
+/* Nouvelle-Fonction */
+Window RzXNewWin(int sx, int sy, char *title, int posx, int posy)
+
+/*  Creation de fenetre X simple pour mettre une image  */
+{
+XSizeHints hint;
+Window   win;
+
+hint.x = posx;   hint.y = posy;
+hint.width  = sx;  hint.height = sy;
+hint.flags  = PPosition | PSize;
+
+
+win =  XCreateSimpleWindow (display, DefaultRootWindow (display),
+       hint.x, hint.y, hint.width, hint.height, 3,
+       WhitePixel(display, screen), BlackPixel(display, screen) );                        
+
+XSetStandardProperties (display, win, title, title, None, NULL, 0, &hint);
+
+if (!rzxgcok)
+  {
+  defgc = XCreateGC (display, win, 0, 0);
+  rzxgcok = 1;
+  }
+XMapRaised(display,win);
+XSync(display,1);
+
+return(win);
+}
+#endif
+
Index: /tags/V_LaSilla191199/SophyaPI/PI/xdispim.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PI/xdispim.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PI/xdispim.h	(revision 464)
@@ -0,0 +1,36 @@
+/* Fonctions interface XWindow pour affichage d'images */
+
+#ifndef XDISPIM_SEEN
+#define XDISPIM_SEEN
+
+
+#include <X11/Xlib.h>
+
+#define CMAP_GREY32         0
+#define CMAP_COL16          1
+#define CMAP_COLRJ32        2
+#define CMAP_GREYINV32      3
+#define CMAP_COLBR32        4
+#define CMAP_COLRV32        5
+
+struct _RzXCMap_
+  {
+  int typ;
+  int nCol;
+  unsigned long colpix[256];
+  };
+typedef struct _RzXCMap_  RzXCMap;
+
+int RzXInitDisplay(int prtl);
+int RzXCheckInitDisp(void);
+
+int RzXGetPixDSize(void);
+int RzXDispPixMap(Window xw, unsigned char *pix,  int sizx, int sizy, RzXCMap *cmap);
+
+RzXCMap * RzXGetCMap(int cmpaid);
+int RzXAllocCMap(RzXCMap *rcmap, int cmapid, int prtl);
+int RzXFreeCMap(RzXCMap *rcmap);
+
+Window RzXNewWin(int sx, int sy, char *title, int posx, int posy);
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PIext/Makefile
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/Makefile	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/Makefile	(revision 464)
@@ -0,0 +1,577 @@
+MODULECXXREPNAME := PI
+MODULEDECCXXFLAGS := -msg_quiet
+include ../Mgr/Makefile.h
+ 
+all: $(LIB)libPIext.a
+$(LIB)libPIext.a : $(OBJ)nobjmgr.o $(OBJ)piacmd.o $(OBJ)pigfd1.o $(OBJ)pigfd2.o $(OBJ)pihisto.o $(OBJ)pihisto2d.o $(OBJ)piinit.o $(OBJ)pintup3d.o $(OBJ)pintuple.o $(OBJ)pipodrw.o $(OBJ)pisiadw.o $(OBJ)pistdimgapp.o $(OBJ)pistlist.o $(OBJ)servnobjm.o
+	$(AR) $(ARFLAGS)  $@ $? 
+ifeq ($(CXX),cxx)
+	$(CXX) $? $(CPPFLAGS) $(CXXFLAGS) -L$(LIB) -lPIext -lOutils++ -lImages++ -lStarReco++ -lPI -o $(OBJ)xx.x -Hf
+endif 
+ 
+clean:
+	rm -f $(OBJ)nobjmgr.o $(OBJ)piacmd.o $(OBJ)pigfd1.o $(OBJ)pigfd2.o $(OBJ)pihisto.o $(OBJ)pihisto2d.o $(OBJ)piinit.o $(OBJ)pintup3d.o $(OBJ)pintuple.o $(OBJ)pipodrw.o $(OBJ)pisiadw.o $(OBJ)pistdimgapp.o $(OBJ)pistlist.o $(OBJ)servnobjm.o
+ifeq ($(CXX),cxx)
+	cd $(REPM); rm -f *.o
+endif 
+ 
+$(OBJ)nobjmgr.o: nobjmgr.cc $(INC)strutil.h \
+ $(INC)datatypes.h \
+ $(INC)machine.h $(INC)defs.h \
+ $(INC)fitsimage.h \
+ $(INC)cimage.h $(INC)rzimage.h \
+ $(INC)rzvect.h \
+ $(INC)exceptions.h \
+ $(INC)peidainit.h \
+ $(INC)perrors.h \
+ $(INC)ppersist.h \
+ $(INC)pclassids.h \
+ $(INC)dvlist.h \
+ $(INC)fitsheader.h \
+ $(INC)erosio.h $(INC)fitskeys.h \
+ $(INC)erostape.h \
+ $(INC)ptrarray.h \
+ $(INC)voidptrarray.h \
+ $(INC)basearray.h $(INC)peida.h \
+ $(INC)utils.h $(INC)fmath.h \
+ $(INC)array.h $(INC)lockfile.h \
+ $(INC)erostarfile.h \
+ $(INC)xstrstream.h \
+ $(INC)dates.h $(INC)tarlib.h \
+ nobjmgr.h dlftypes.h servnobjm.h $(INC)ctimer.h \
+ $(INC)pdlmgr.h pistdimgapp.h \
+ $(INC)pisysdep.h \
+ $(INC)piapplx.h \
+ $(INC)piapplgen.h \
+ $(INC)pimsghandler.h \
+ $(INC)picontainerx.h \
+ $(INC)picontainergen.h \
+ $(INC)piwdgx.h $(INC)piwdggen.h \
+ $(INC)pimenubarx.h \
+ $(INC)pimenubargen.h \
+ $(INC)pimenux.h \
+ $(INC)pimenugen.h \
+ $(INC)picons.h \
+ $(INC)pistdwdgx.h \
+ $(INC)pistdwdggen.h \
+ $(INC)pibwdgx.h \
+ $(INC)pibwdggen.h \
+ $(INC)picmap.h $(INC)picmapx.h \
+ $(INC)picmapgen.h \
+ $(INC)pigraphx.h \
+ $(INC)pigraphgen.h \
+ $(INC)pigraphuc.h \
+ $(INC)pievthandler.h \
+ $(INC)psfile.h \
+ $(INC)pigraphps.h \
+ $(INC)piwindowx.h \
+ $(INC)piwindowgen.h \
+ $(INC)pioptmenux.h \
+ $(INC)pioptmenugen.h \
+ $(INC)pifilechox.h \
+ $(INC)pifilechogen.h \
+ $(INC)piimage.h \
+ $(INC)parradapter.h $(INC)lut.h \
+ $(INC)pidrawer.h \
+ $(INC)pipixmapx.h \
+ $(INC)pipixmapgen.h \
+ $(INC)picmapview.h \
+ $(INC)pi3ddrw.h \
+ $(INC)pigraph3d.h piacmd.h pisiadw.h \
+ $(INC)pilistx.h \
+ $(INC)pilistgen.h \
+ $(INC)pistzwin.h \
+ $(INC)piperiodx.h \
+ $(INC)periodic.h $(INC)poly.h \
+ $(INC)cvector.h $(INC)matrix.h \
+ $(INC)zfidu.h $(INC)fft.h \
+ $(INC)fct1dfit.h \
+ $(INC)generalfit.h \
+ $(INC)generaldata.h \
+ $(INC)fct2dfit.h pimgadapter.h pipodrw.h \
+ $(INC)histos2.h $(INC)histos.h \
+ pihisto.h $(INC)hisprof.h pihisto2d.h \
+ $(INC)piscdrawwdg.h pintuple.h \
+ $(INC)ntuple.h $(INC)pisurfdr.h \
+ pintup3d.h pigfd1.h pigfd2.h pistlist.h \
+ $(INC)stlist.h $(INC)dynccd.h \
+ $(INC)star.h $(INC)starmacro.h \
+ $(INC)psf.h $(INC)pixelmap.h \
+ $(INC)transfo.h $(INC)imgalig.h
+$(OBJ)piacmd.o: piacmd.cc $(INC)ctimer.h \
+ $(INC)peida.h $(INC)defs.h \
+ $(INC)utils.h $(INC)machine.h \
+ $(INC)perrors.h \
+ $(INC)exceptions.h \
+ $(INC)peidainit.h $(INC)fmath.h \
+ nobjmgr.h $(INC)ppersist.h \
+ $(INC)pclassids.h dlftypes.h piacmd.h \
+ $(INC)pdlmgr.h pistdimgapp.h \
+ $(INC)pisysdep.h \
+ $(INC)piapplx.h \
+ $(INC)piapplgen.h \
+ $(INC)pimsghandler.h \
+ $(INC)picontainerx.h \
+ $(INC)picontainergen.h \
+ $(INC)piwdgx.h $(INC)piwdggen.h \
+ $(INC)pimenubarx.h \
+ $(INC)pimenubargen.h \
+ $(INC)pimenux.h \
+ $(INC)pimenugen.h \
+ $(INC)picons.h \
+ $(INC)pistdwdgx.h \
+ $(INC)pistdwdggen.h \
+ $(INC)pibwdgx.h \
+ $(INC)pibwdggen.h \
+ $(INC)picmap.h $(INC)picmapx.h \
+ $(INC)picmapgen.h \
+ $(INC)pigraphx.h \
+ $(INC)pigraphgen.h \
+ $(INC)pigraphuc.h \
+ $(INC)pievthandler.h \
+ $(INC)psfile.h \
+ $(INC)pigraphps.h \
+ $(INC)piwindowx.h \
+ $(INC)piwindowgen.h \
+ $(INC)pioptmenux.h \
+ $(INC)pioptmenugen.h \
+ $(INC)pifilechox.h \
+ $(INC)pifilechogen.h \
+ $(INC)piimage.h \
+ $(INC)parradapter.h $(INC)lut.h \
+ $(INC)pidrawer.h \
+ $(INC)pipixmapx.h \
+ $(INC)pipixmapgen.h \
+ $(INC)picmapview.h \
+ $(INC)pi3ddrw.h \
+ $(INC)pigraph3d.h pisiadw.h \
+ $(INC)pilistx.h \
+ $(INC)pilistgen.h \
+ $(INC)pistzwin.h \
+ $(INC)piperiodx.h \
+ $(INC)periodic.h $(INC)histos.h \
+ $(INC)cvector.h $(INC)matrix.h \
+ $(INC)histos2.h $(INC)hisprof.h \
+ $(INC)ntuple.h $(INC)dvlist.h \
+ $(INC)generaldata.h \
+ $(INC)poly.h $(INC)psf.h \
+ $(INC)cimage.h $(INC)rzimage.h \
+ $(INC)rzvect.h \
+ $(INC)datatypes.h $(INC)star.h \
+ $(INC)starmacro.h \
+ $(INC)fct1dfit.h \
+ $(INC)generalfit.h \
+ $(INC)fct2dfit.h \
+ $(INC)pixelmap.h $(INC)dynccd.h \
+ pimgadapter.h $(INC)nbmath.h \
+ $(INC)nbtri.h
+$(OBJ)pigfd1.o: pigfd1.cc pigfd1.h $(INC)generaldata.h \
+ $(INC)exceptions.h $(INC)defs.h \
+ $(INC)peidainit.h \
+ $(INC)ppersist.h \
+ $(INC)machine.h $(INC)perrors.h \
+ $(INC)pclassids.h $(INC)poly.h \
+ $(INC)peida.h $(INC)utils.h \
+ $(INC)fmath.h $(INC)cvector.h \
+ $(INC)matrix.h $(INC)pidrawer.h \
+ $(INC)pibwdggen.h \
+ $(INC)pisysdep.h $(INC)piwdgx.h \
+ $(INC)piwdggen.h \
+ $(INC)pimsghandler.h \
+ $(INC)picmap.h $(INC)picmapx.h \
+ $(INC)picmapgen.h \
+ $(INC)pigraphx.h \
+ $(INC)pigraphgen.h \
+ $(INC)pigraphuc.h \
+ $(INC)pievthandler.h \
+ $(INC)psfile.h
+$(OBJ)pigfd2.o: pigfd2.cc pigfd2.h $(INC)generaldata.h \
+ $(INC)exceptions.h $(INC)defs.h \
+ $(INC)peidainit.h \
+ $(INC)ppersist.h \
+ $(INC)machine.h $(INC)perrors.h \
+ $(INC)pclassids.h $(INC)poly.h \
+ $(INC)peida.h $(INC)utils.h \
+ $(INC)fmath.h $(INC)cvector.h \
+ $(INC)matrix.h $(INC)pi3ddrw.h \
+ $(INC)pisysdep.h \
+ $(INC)pidrawer.h \
+ $(INC)pibwdggen.h \
+ $(INC)piwdgx.h $(INC)piwdggen.h \
+ $(INC)pimsghandler.h \
+ $(INC)picmap.h $(INC)picmapx.h \
+ $(INC)picmapgen.h \
+ $(INC)pigraphx.h \
+ $(INC)pigraphgen.h \
+ $(INC)pigraphuc.h \
+ $(INC)pievthandler.h \
+ $(INC)psfile.h \
+ $(INC)pigraph3d.h \
+ $(INC)pibwdgx.h \
+ $(INC)pigraphps.h
+$(OBJ)pihisto.o: pihisto.cc pihisto.h $(INC)histos.h \
+ $(INC)peida.h $(INC)defs.h \
+ $(INC)utils.h $(INC)machine.h \
+ $(INC)perrors.h \
+ $(INC)exceptions.h \
+ $(INC)peidainit.h $(INC)fmath.h \
+ $(INC)cvector.h $(INC)matrix.h \
+ $(INC)ppersist.h \
+ $(INC)pclassids.h \
+ $(INC)pidrawer.h \
+ $(INC)pibwdggen.h \
+ $(INC)pisysdep.h $(INC)piwdgx.h \
+ $(INC)piwdggen.h \
+ $(INC)pimsghandler.h \
+ $(INC)picmap.h $(INC)picmapx.h \
+ $(INC)picmapgen.h \
+ $(INC)pigraphx.h \
+ $(INC)pigraphgen.h \
+ $(INC)pigraphuc.h \
+ $(INC)pievthandler.h \
+ $(INC)psfile.h $(INC)hisprof.h
+$(OBJ)pihisto2d.o: pihisto2d.cc $(INC)piapplgen.h \
+ $(INC)pimsghandler.h \
+ $(INC)pisysdep.h \
+ $(INC)picontainerx.h \
+ $(INC)picontainergen.h \
+ $(INC)piwdgx.h $(INC)piwdggen.h \
+ $(INC)pimenubarx.h \
+ $(INC)pimenubargen.h \
+ $(INC)pimenux.h \
+ $(INC)pimenugen.h \
+ $(INC)picons.h \
+ $(INC)pistdwdgx.h \
+ $(INC)pistdwdggen.h \
+ $(INC)pibwdgx.h \
+ $(INC)pibwdggen.h \
+ $(INC)picmap.h $(INC)picmapx.h \
+ $(INC)picmapgen.h \
+ $(INC)pigraphx.h \
+ $(INC)pigraphgen.h \
+ $(INC)pigraphuc.h \
+ $(INC)pievthandler.h \
+ $(INC)psfile.h $(INC)defs.h \
+ $(INC)pigraphps.h pihisto2d.h \
+ $(INC)pioptmenux.h \
+ $(INC)pioptmenugen.h \
+ $(INC)histos2.h $(INC)peida.h \
+ $(INC)utils.h $(INC)machine.h \
+ $(INC)perrors.h \
+ $(INC)exceptions.h \
+ $(INC)peidainit.h $(INC)fmath.h \
+ $(INC)histos.h $(INC)cvector.h \
+ $(INC)matrix.h $(INC)ppersist.h \
+ $(INC)pclassids.h \
+ $(INC)piscdrawwdg.h \
+ $(INC)piwindowx.h \
+ $(INC)piwindowgen.h \
+ $(INC)pidrawer.h \
+ $(INC)nbrandom.h
+$(OBJ)piinit.o: piinit.cc $(INC)defs.h piinit.h \
+ $(INC)imaginit.h \
+ $(INC)outilsinit.h \
+ $(INC)peidainit.h
+$(OBJ)pintup3d.o: pintup3d.cc pintup3d.h $(INC)ntuple.h \
+ $(INC)ppersist.h $(INC)defs.h \
+ $(INC)machine.h $(INC)perrors.h \
+ $(INC)exceptions.h \
+ $(INC)peidainit.h \
+ $(INC)pclassids.h \
+ $(INC)dvlist.h $(INC)pi3ddrw.h \
+ $(INC)pisysdep.h \
+ $(INC)pidrawer.h \
+ $(INC)pibwdggen.h \
+ $(INC)piwdgx.h $(INC)piwdggen.h \
+ $(INC)pimsghandler.h \
+ $(INC)picmap.h $(INC)picmapx.h \
+ $(INC)picmapgen.h \
+ $(INC)pigraphx.h \
+ $(INC)pigraphgen.h \
+ $(INC)pigraphuc.h \
+ $(INC)pievthandler.h \
+ $(INC)psfile.h \
+ $(INC)pigraph3d.h \
+ $(INC)pibwdgx.h \
+ $(INC)pigraphps.h
+$(OBJ)pintuple.o: pintuple.cc pintuple.h $(INC)ntuple.h \
+ $(INC)ppersist.h $(INC)defs.h \
+ $(INC)machine.h $(INC)perrors.h \
+ $(INC)exceptions.h \
+ $(INC)peidainit.h \
+ $(INC)pclassids.h \
+ $(INC)dvlist.h $(INC)pidrawer.h \
+ $(INC)pibwdggen.h \
+ $(INC)pisysdep.h $(INC)piwdgx.h \
+ $(INC)piwdggen.h \
+ $(INC)pimsghandler.h \
+ $(INC)picmap.h $(INC)picmapx.h \
+ $(INC)picmapgen.h \
+ $(INC)pigraphx.h \
+ $(INC)pigraphgen.h \
+ $(INC)pigraphuc.h \
+ $(INC)pievthandler.h \
+ $(INC)psfile.h
+$(OBJ)pipodrw.o: pipodrw.cc pipodrw.h $(INC)pidrawer.h \
+ $(INC)pibwdggen.h \
+ $(INC)pisysdep.h $(INC)piwdgx.h \
+ $(INC)piwdggen.h \
+ $(INC)pimsghandler.h \
+ $(INC)picmap.h $(INC)picmapx.h \
+ $(INC)picmapgen.h \
+ $(INC)pigraphx.h \
+ $(INC)pigraphgen.h \
+ $(INC)pigraphuc.h \
+ $(INC)pievthandler.h \
+ $(INC)psfile.h $(INC)defs.h \
+ $(INC)parradapter.h \
+ $(INC)machine.h $(INC)lut.h \
+ $(INC)cvector.h $(INC)matrix.h \
+ $(INC)peida.h $(INC)utils.h \
+ $(INC)perrors.h \
+ $(INC)exceptions.h \
+ $(INC)peidainit.h $(INC)fmath.h \
+ $(INC)ppersist.h \
+ $(INC)pclassids.h \
+ $(INC)histos2.h $(INC)histos.h \
+ $(INC)generalfit.h \
+ $(INC)generaldata.h \
+ $(INC)poly.h
+$(OBJ)pisiadw.o: pisiadw.cc $(INC)machine.h \
+ $(INC)defs.h $(INC)perrors.h \
+ $(INC)exceptions.h \
+ $(INC)peidainit.h \
+ $(INC)ctimer.h $(INC)peida.h \
+ $(INC)utils.h $(INC)fmath.h \
+ $(INC)nbmath.h pistdimgapp.h \
+ $(INC)pisysdep.h \
+ $(INC)piapplx.h \
+ $(INC)piapplgen.h \
+ $(INC)pimsghandler.h \
+ $(INC)picontainerx.h \
+ $(INC)picontainergen.h \
+ $(INC)piwdgx.h $(INC)piwdggen.h \
+ $(INC)pimenubarx.h \
+ $(INC)pimenubargen.h \
+ $(INC)pimenux.h \
+ $(INC)pimenugen.h \
+ $(INC)picons.h \
+ $(INC)pistdwdgx.h \
+ $(INC)pistdwdggen.h \
+ $(INC)pibwdgx.h \
+ $(INC)pibwdggen.h \
+ $(INC)picmap.h $(INC)picmapx.h \
+ $(INC)picmapgen.h \
+ $(INC)pigraphx.h \
+ $(INC)pigraphgen.h \
+ $(INC)pigraphuc.h \
+ $(INC)pievthandler.h \
+ $(INC)psfile.h \
+ $(INC)pigraphps.h \
+ $(INC)piwindowx.h \
+ $(INC)piwindowgen.h \
+ $(INC)pioptmenux.h \
+ $(INC)pioptmenugen.h \
+ $(INC)pifilechox.h \
+ $(INC)pifilechogen.h \
+ $(INC)piimage.h \
+ $(INC)parradapter.h $(INC)lut.h \
+ $(INC)pidrawer.h \
+ $(INC)pipixmapx.h \
+ $(INC)pipixmapgen.h \
+ $(INC)picmapview.h \
+ $(INC)pi3ddrw.h \
+ $(INC)pigraph3d.h nobjmgr.h \
+ $(INC)ppersist.h \
+ $(INC)pclassids.h dlftypes.h piacmd.h \
+ $(INC)pdlmgr.h pisiadw.h \
+ $(INC)pilistx.h \
+ $(INC)pilistgen.h \
+ $(INC)pistzwin.h \
+ $(INC)piperiodx.h \
+ $(INC)periodic.h servnobjm.h
+$(OBJ)pistdimgapp.o: pistdimgapp.cc $(INC)machine.h \
+ $(INC)defs.h $(INC)strutil.h \
+ $(INC)timing.h $(INC)perrors.h \
+ $(INC)exceptions.h \
+ $(INC)peidainit.h \
+ $(INC)ctimer.h $(INC)peida.h \
+ $(INC)utils.h $(INC)fmath.h \
+ $(INC)psighand.h $(INC)cimage.h \
+ $(INC)rzimage.h $(INC)rzvect.h \
+ $(INC)datatypes.h \
+ $(INC)ppersist.h \
+ $(INC)pclassids.h \
+ $(INC)dvlist.h pistdimgapp.h \
+ $(INC)pisysdep.h \
+ $(INC)piapplx.h \
+ $(INC)piapplgen.h \
+ $(INC)pimsghandler.h \
+ $(INC)picontainerx.h \
+ $(INC)picontainergen.h \
+ $(INC)piwdgx.h $(INC)piwdggen.h \
+ $(INC)pimenubarx.h \
+ $(INC)pimenubargen.h \
+ $(INC)pimenux.h \
+ $(INC)pimenugen.h \
+ $(INC)picons.h \
+ $(INC)pistdwdgx.h \
+ $(INC)pistdwdggen.h \
+ $(INC)pibwdgx.h \
+ $(INC)pibwdggen.h \
+ $(INC)picmap.h $(INC)picmapx.h \
+ $(INC)picmapgen.h \
+ $(INC)pigraphx.h \
+ $(INC)pigraphgen.h \
+ $(INC)pigraphuc.h \
+ $(INC)pievthandler.h \
+ $(INC)psfile.h \
+ $(INC)pigraphps.h \
+ $(INC)piwindowx.h \
+ $(INC)piwindowgen.h \
+ $(INC)pioptmenux.h \
+ $(INC)pioptmenugen.h \
+ $(INC)pifilechox.h \
+ $(INC)pifilechogen.h \
+ $(INC)piimage.h \
+ $(INC)parradapter.h $(INC)lut.h \
+ $(INC)pidrawer.h \
+ $(INC)pipixmapx.h \
+ $(INC)pipixmapgen.h \
+ $(INC)picmapview.h \
+ $(INC)pi3ddrw.h \
+ $(INC)pigraph3d.h nobjmgr.h dlftypes.h piacmd.h \
+ $(INC)pdlmgr.h pisiadw.h \
+ $(INC)pilistx.h \
+ $(INC)pilistgen.h \
+ $(INC)pistzwin.h \
+ $(INC)piperiodx.h \
+ $(INC)periodic.h pihisto2d.h \
+ $(INC)histos2.h $(INC)histos.h \
+ $(INC)cvector.h $(INC)matrix.h \
+ $(INC)piscdrawwdg.h \
+ $(INC)piimgtools.h \
+ $(INC)pidrwtools.h
+$(OBJ)pistlist.o: pistlist.cc pistlist.h $(INC)stlist.h \
+ $(INC)machine.h $(INC)defs.h \
+ $(INC)exceptions.h \
+ $(INC)peidainit.h \
+ $(INC)perrors.h $(INC)dynccd.h \
+ $(INC)ppersist.h \
+ $(INC)pclassids.h $(INC)star.h \
+ $(INC)starmacro.h $(INC)psf.h \
+ $(INC)peida.h $(INC)utils.h \
+ $(INC)fmath.h $(INC)cimage.h \
+ $(INC)rzimage.h $(INC)rzvect.h \
+ $(INC)datatypes.h \
+ $(INC)dvlist.h $(INC)fct1dfit.h \
+ $(INC)generalfit.h \
+ $(INC)matrix.h $(INC)cvector.h \
+ $(INC)generaldata.h \
+ $(INC)poly.h $(INC)fct2dfit.h \
+ $(INC)pixelmap.h \
+ $(INC)transfo.h $(INC)zfidu.h \
+ $(INC)imgalig.h \
+ $(INC)fitsimage.h \
+ $(INC)fitsheader.h \
+ $(INC)erosio.h $(INC)fitskeys.h \
+ $(INC)erostape.h \
+ $(INC)strutil.h \
+ $(INC)ptrarray.h \
+ $(INC)voidptrarray.h \
+ $(INC)basearray.h $(INC)array.h \
+ $(INC)lockfile.h \
+ $(INC)erostarfile.h \
+ $(INC)xstrstream.h \
+ $(INC)dates.h $(INC)tarlib.h \
+ $(INC)pidrawer.h \
+ $(INC)pibwdggen.h \
+ $(INC)pisysdep.h $(INC)piwdgx.h \
+ $(INC)piwdggen.h \
+ $(INC)pimsghandler.h \
+ $(INC)picmap.h $(INC)picmapx.h \
+ $(INC)picmapgen.h \
+ $(INC)pigraphx.h \
+ $(INC)pigraphgen.h \
+ $(INC)pigraphuc.h \
+ $(INC)pievthandler.h \
+ $(INC)psfile.h
+$(OBJ)servnobjm.o: servnobjm.cc $(INC)strutil.h \
+ $(INC)datatypes.h \
+ $(INC)machine.h $(INC)defs.h \
+ nobjmgr.h $(INC)ppersist.h \
+ $(INC)perrors.h \
+ $(INC)exceptions.h \
+ $(INC)peidainit.h \
+ $(INC)pclassids.h dlftypes.h servnobjm.h \
+ $(INC)ctimer.h $(INC)peida.h \
+ $(INC)utils.h $(INC)fmath.h \
+ $(INC)pdlmgr.h pistdimgapp.h \
+ $(INC)pisysdep.h \
+ $(INC)piapplx.h \
+ $(INC)piapplgen.h \
+ $(INC)pimsghandler.h \
+ $(INC)picontainerx.h \
+ $(INC)picontainergen.h \
+ $(INC)piwdgx.h $(INC)piwdggen.h \
+ $(INC)pimenubarx.h \
+ $(INC)pimenubargen.h \
+ $(INC)pimenux.h \
+ $(INC)pimenugen.h \
+ $(INC)picons.h \
+ $(INC)pistdwdgx.h \
+ $(INC)pistdwdggen.h \
+ $(INC)pibwdgx.h \
+ $(INC)pibwdggen.h \
+ $(INC)picmap.h $(INC)picmapx.h \
+ $(INC)picmapgen.h \
+ $(INC)pigraphx.h \
+ $(INC)pigraphgen.h \
+ $(INC)pigraphuc.h \
+ $(INC)pievthandler.h \
+ $(INC)psfile.h \
+ $(INC)pigraphps.h \
+ $(INC)piwindowx.h \
+ $(INC)piwindowgen.h \
+ $(INC)pioptmenux.h \
+ $(INC)pioptmenugen.h \
+ $(INC)pifilechox.h \
+ $(INC)pifilechogen.h \
+ $(INC)piimage.h \
+ $(INC)parradapter.h $(INC)lut.h \
+ $(INC)pidrawer.h \
+ $(INC)pipixmapx.h \
+ $(INC)pipixmapgen.h \
+ $(INC)picmapview.h \
+ $(INC)pi3ddrw.h \
+ $(INC)pigraph3d.h piacmd.h pisiadw.h \
+ $(INC)pilistx.h \
+ $(INC)pilistgen.h \
+ $(INC)pistzwin.h \
+ $(INC)piperiodx.h \
+ $(INC)periodic.h $(INC)histos.h \
+ $(INC)cvector.h $(INC)matrix.h \
+ $(INC)histos2.h $(INC)ntuple.h \
+ $(INC)dvlist.h $(INC)hisprof.h \
+ $(INC)generaldata.h \
+ $(INC)poly.h $(INC)cimage.h \
+ $(INC)rzimage.h $(INC)rzvect.h \
+ $(INC)stlist.h $(INC)dynccd.h \
+ $(INC)star.h $(INC)starmacro.h \
+ $(INC)psf.h $(INC)fct1dfit.h \
+ $(INC)generalfit.h \
+ $(INC)fct2dfit.h \
+ $(INC)pixelmap.h \
+ $(INC)transfo.h $(INC)zfidu.h \
+ $(INC)imgalig.h \
+ $(INC)fitsimage.h \
+ $(INC)fitsheader.h \
+ $(INC)erosio.h $(INC)fitskeys.h \
+ $(INC)erostape.h \
+ $(INC)ptrarray.h \
+ $(INC)voidptrarray.h \
+ $(INC)basearray.h $(INC)array.h \
+ $(INC)lockfile.h \
+ $(INC)erostarfile.h \
+ $(INC)xstrstream.h \
+ $(INC)dates.h $(INC)tarlib.h
Index: /tags/V_LaSilla191199/SophyaPI/PIext/basexecut.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/basexecut.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/basexecut.cc	(revision 464)
@@ -0,0 +1,1114 @@
+#include "piacmd.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include "basexecut.h"
+
+#include "pdlmgr.h"
+#include "ctimer.h"
+// #include "dlftypes.h"
+
+#include "pistdimgapp.h"
+#include "nobjmgr.h"
+#include "servnobjm.h"
+
+#include "histos.h"
+#include "histos2.h"
+#include "hisprof.h"
+#include "ntuple.h"
+#include "generaldata.h"
+#include "cvector.h"
+
+
+
+/* --Methode-- */
+PIABaseExecutor::PIABaseExecutor(PIACmd* piac, NamedObjMgr* omg, PIStdImgApp* app)
+{
+mpiac = piac;
+mObjMgr = omg; 
+mImgApp = app;
+dynlink = NULL;
+RegisterCommands();
+}
+
+PIABaseExecutor::~PIABaseExecutor()
+{
+}
+
+
+ 
+/* --Methode-- */
+int PIABaseExecutor::Execute(string& kw, vector<string>& tokens)
+{
+Services2NObjMgr* srvo = mObjMgr->GetServiceObj();
+// >>>>> Chargement de modules
+if (kw == "loadmodule") {
+  if (tokens.size() < 2) { cout << "Usage: loadmodule fnameso modulename" << endl;  return(0); }
+  mpiac->LoadModule(tokens[0], tokens[1]);
+  }
+// >>>>>>>>>>> Fenetre graphique , changement d'attributs graphiques 
+else if (kw == "zone") {
+  while (tokens.size() < 2) tokens.push_back("1");
+  int nx, ny;
+  nx = ny = 1;
+  nx = atoi(tokens[0].c_str());    ny = atoi(tokens[1].c_str());
+  mObjMgr->SetGraphicWinZone(nx, ny, false);
+  }  
+else if (kw == "newwin") {
+  if (tokens.size() < 2) { cout << "Usage: newwin nx ny" << endl;  return(0); }
+  int nx, ny;
+  nx = ny = 1;
+  nx = atoi(tokens[0].c_str());    ny = atoi(tokens[1].c_str());
+  mObjMgr->SetGraphicWinZone(nx, ny, true);
+  }  
+else if (kw == "stacknext") mImgApp->StackWinNext(); 
+else if (kw == "gratt") {
+  if (tokens.size() < 1) { cout << "Usage: gratt attributes_list (att=def->defaut)" << endl;  return(0); }
+  mObjMgr->SetGraphicAttributes(tokens[0]); 
+  }
+else if (kw == "setxylimits") {
+  if (tokens.size() < 4) { cout << "Usage: setxylimits xmin xmax ymin ymax" << endl;  return(0); }
+  double xmin = atof(tokens[0].c_str());
+  double xmax = atof(tokens[1].c_str());
+  double ymin = atof(tokens[2].c_str());
+  double ymax = atof(tokens[3].c_str());
+  mImgApp->SetXYLimits(xmin, xmax, ymin, ymax);
+  }
+else if (kw == "addtext") {
+  if (tokens.size() < 4) { cout << "Usage: addtext x y colfontatt txt" << endl;  return(0); }
+  double xp = atof(tokens[0].c_str());
+  double yp = atof(tokens[1].c_str());
+  bool fgsr = true;
+  string txt = tokens[3];
+  for(int k=4; k<tokens.size(); k++) txt += (' ' + tokens[k]);
+  int opt = mObjMgr->GetServiceObj()->DecodeDispOption(tokens[2], fgsr);
+  mImgApp->AddText(txt, xp, yp);
+  if (fgsr) mImgApp->RestoreGraphicAtt(); 
+  }
+  
+// >>>>>>>>>>> Link dynamique de fonctions C++
+else if (kw == "link" ) {
+  if (tokens.size() < 2) { cout << "Usage: link fnameso f1 [f2 f3]" << endl;  return(0); }
+  string sph = "";
+  for(int gg=0; gg<5; gg++)   tokens.push_back(sph);
+  int rc = LinkUserFuncs(tokens[0], tokens[1], tokens[2], tokens[3]);
+  if (rc == 0)  cout << "PIABaseExecutor: Link from " << tokens[0] << " OK " << endl;
+}
+else if (kw == "call" ) {
+  if (tokens.size() < 1) { cout << "Usage: call userf [arg1 arg2 ...]" << endl;  return(0); }
+  UsFmap::iterator it = usfmap.find(tokens[0]);
+  if (it == usfmap.end()) {
+    cerr << "PIABaseExecutor: No User Function " << tokens[0] << endl;
+    return(0);
+  }
+  cout << "PIABaseExecutor: Call " << tokens[0] << "( ... )" << endl;
+// on est oblige de faire un cast  etant donne qu'on 
+// utilise donc des DlFunction  (Reza 20/08/98)  voir commentaire ds .h (pb g++)
+  DlUserProcFunction fuf = (DlUserProcFunction)(*it).second;
+//   On redirige la sortie sur le terminal 
+  bool red = mImgApp->HasRedirectedStdOutErr();
+  mImgApp->RedirectStdOutErr(false);
+  TRY {
+    tokens.erase(tokens.begin());
+    fuf(tokens);
+  }  CATCH(merr) {
+    fflush(stdout); 
+    cout << endl; 
+    cerr << endl;
+    string es = PeidaExc(merr);
+    cerr << "PIABaseExecutor: Call UserFunc  Exception :" << merr << es;
+    }
+  mImgApp->RedirectStdOutErr(red);
+}
+
+// >>>>>>>>>>> lecture/ecriture des objets, gestion des objets 
+else if (kw == "openfits" ) {
+  if (tokens.size() < 1) { cout << "Usage: openfits file " << endl;  return(0); }
+  else { string nomobj = "";  mObjMgr->ReadFits(tokens[0], nomobj); }
+}
+else if (kw == "savefits" ) {
+  if (tokens.size() < 2) { cout << "Usage: savefits nameobj filename " << endl;  return(0); }
+  else mObjMgr->SaveFits(tokens[0], tokens[1]);
+}
+else if (kw == "openppf" ) {
+  if (tokens.size() < 1) { cout << "Usage: openppf file " << endl; return(0); }
+  mObjMgr->ReadAll(tokens[0]);  
+}
+else if (kw == "saveobjs" ) {
+  if (tokens.size() < 2) { cout << "Usage: saveobjs patt filename " << endl; return(0); }
+  mObjMgr->SaveObjects(tokens[0], tokens[1]);  
+}
+else if (kw == "saveall" ) {
+  if (tokens.size() < 1) { cout << "Usage: saveall file " << endl; return(0); }
+  mObjMgr->SaveAll(tokens[0]);  
+}
+else if (kw == "print" ) {
+  if (tokens.size() < 1) { cout << "Usage: print nameobj " << endl; return(0); }
+  mObjMgr->PrintObj(tokens[0]);  
+}
+else if ( (kw == "rename" ) || (kw == "mv") )  {
+  if (tokens.size() < 2) { cout << "Usage: rename nameobj namenew" << endl; return(0); }
+  mObjMgr->RenameObj(tokens[0], tokens[1]);  
+}
+else if ( (kw == "del" ) || (kw == "rm") ) {
+  if (tokens.size() < 1) { cout << "Usage: del nameobj " << endl; return(0); }
+  mObjMgr->DelObj(tokens[0]);  
+}
+else if (kw == "delobjs" ) {
+  if (tokens.size() < 1) { cout << "Usage: delobjs nomobjpattern (*,?) " << endl; return(0); }
+  mObjMgr->DelObjects(tokens[0]);  
+}
+else if ( (kw == "listobjs") || (kw == "ls") )    { 
+  if  (tokens.size() < 1)  tokens.push_back("*");
+  mObjMgr->ListObjs(tokens[0]);
+}
+// Gestion des repertoires
+else if (kw == "mkdir" ) {
+  if (tokens.size() < 1) { cout << "Usage: mkdir dirname [true]" << endl; return(0); }
+  bool crd = mObjMgr->CreateDir(tokens[0]);  
+  if ( crd && (tokens.size() > 1) && (tokens[1] == "true") )
+    mObjMgr->SetKeepOldDirAtt(tokens[0], true);
+  }
+else if (kw == "rmdir" ) {
+  if (tokens.size() < 1) { cout << "Usage: rmdir dirname " << endl; return(0); }
+  mObjMgr->DeleteDir(tokens[0]);  
+  }
+else if (kw == "cd")   { 
+  if  (tokens.size() < 1)  tokens.push_back("home");
+  mObjMgr->SetCurrentDir(tokens[0]);
+  }
+else if (kw == "pwd") { 
+  string dirn;
+  mObjMgr->GetCurrentDir(dirn);
+  cout << "CurrentDirectory: " << dirn << endl;
+  }  
+else if (kw == "listdirs")   { 
+  if  (tokens.size() < 1)  tokens.push_back("*");
+  mObjMgr->ListDirs(tokens[0]);
+  }
+
+// >>>>>>>>>>> Creation d'histos 1D-2D
+else if (kw == "newh1d") {
+  if (tokens.size() < 4) { cout << "Usage: newh1d name xmin xmax nbin" << endl; return(0); }
+  int nbx;
+  float xmin, xmax;
+  nbx = 100;
+  xmin = 0.;  xmax = 1.;
+  nbx = atoi(tokens[3].c_str());
+  xmin = atof(tokens[1].c_str());   xmax = atof(tokens[2].c_str());
+  Histo* h = new Histo(xmin, xmax, nbx);
+  mObjMgr->AddObj(h, tokens[0]);
+  }
+else if (kw == "newh2d") {
+  if (tokens.size() < 7) { 
+    cout << "Usage: newh2d name xmin xmax nbinx ymin ymax nbiny" << endl; 
+    return(0); 
+    }
+  int nbx, nby;
+  float xmin, xmax;
+  float ymin, ymax;
+  nbx = nby = 50;
+  xmin = 0.;  xmax = 1.;
+  ymin = 0.;  ymax = 1.;
+  nbx = atoi(tokens[3].c_str());
+  nby = atoi(tokens[6].c_str());
+  xmin = atof(tokens[1].c_str());   xmax = atof(tokens[2].c_str());
+  ymin = atof(tokens[4].c_str());   ymax = atof(tokens[5].c_str());
+  Histo2D* h = new Histo2D(xmin, xmax, nbx, ymin, ymax, nby);
+  mObjMgr->AddObj(h, tokens[0]);
+  }
+else if (kw == "newprof") {
+  if (tokens.size() < 4)
+    { cout << "Usage: newprof name xmin xmax nbin [ymin ymax]" << endl; return(0); }
+  int nbx;
+  float xmin, xmax, ymin = 1., ymax = -1.;
+  if(tokens.size() > 5)
+    {ymin = atof(tokens[4].c_str());   ymax = atof(tokens[5].c_str());}
+  nbx = 100;
+  xmin = 0.;  xmax = 1.;
+  nbx = atoi(tokens[3].c_str());
+  xmin = atof(tokens[1].c_str());   xmax = atof(tokens[2].c_str());
+  HProf* h = new HProf(xmin, xmax, nbx, ymin, ymax);
+  mObjMgr->AddObj(h, tokens[0]);
+  }
+
+// Creation de NTuple
+else if (kw == "newnt") {
+  if(tokens.size() < 2)
+    {cout<<"Usage: newnt name v1 v2 ... vn / newnt name nvar"<<endl; return(0);}
+  vector<string> varname;
+  int nvar = 0;
+  const char *c = tokens[1].c_str();
+  if(isdigit(c[0])) {
+    nvar = atoi(tokens[1].c_str());
+    if(nvar<=0 || nvar>=10000)
+      {cout<<"newnt name nvar : nvar must be an positive integer<10000"<<endl;
+       return(0);}
+    for(int i=0;i<nvar;i++) {
+      char str[16]; sprintf(str,"%d",i);
+      string dum = "v"; dum += str;
+      varname.push_back(dum.c_str());
+    }
+  } else if( islower(c[0]) || isupper(c[0]) ) {
+    for(int i=1;i<tokens.size();i++) {
+      varname.push_back(tokens[i].c_str());
+      nvar++;
+    }
+  } else {
+    cout<<"newnt name v1 v2 ... vn : name vi must begin by a letter"<<endl
+        <<"newnt name nvar : nvar must be an positive integer"<<endl;
+    return(0);
+  }
+  char **noms = new char*[nvar];
+  for(int i=0;i<nvar;i++) noms[i] = (char *)varname[i].c_str();
+  NTuple* nt = new NTuple(nvar,noms);
+  delete [] noms;
+  mObjMgr->AddObj(nt,tokens[0]);
+  }
+
+// Creation de GeneralFitData
+else if (kw == "newgfd") {
+  if (tokens.size() < 3)
+    { cout << "Usage: newgfd nvar nalloc [errx(0/1)]" << endl; return(0); }
+  int nvar, nalloc, errx=0;
+  if (tokens.size() > 3)
+    { errx = atoi(tokens[3].c_str()); if(errx>0) errx=1; else errx = 0;}
+  nvar = atoi(tokens[1].c_str()); nalloc = atoi(tokens[2].c_str());
+  if(nvar>0 && nalloc>0) {
+    GeneralFitData* gfd = new GeneralFitData(nvar,nalloc,errx);
+    mObjMgr->AddObj(gfd, tokens[0]);
+    }
+  }
+
+// Creation/remplissage de vecteur et de matrice
+else if (kw == "newvec") {
+  if (tokens.size() < 2) { 
+    cout << "Usage: newvec name size [f(i) dopt] " << endl; return(0); 
+    }
+  int n = atoi(tokens[1].c_str());
+  double xmin, xmax;
+  xmin = 0.;  xmax = n;
+  if (tokens.size() < 3)  { 
+    Vector* v = new Vector(n);
+    mObjMgr->AddObj(v, tokens[0]);
+    }
+  else {
+    if (tokens.size() < 4)  tokens.push_back("");
+    mObjMgr->GetServiceObj()->PlotFunc(tokens[2], tokens[0], xmin, xmax, n, tokens[3]); 
+    }
+  }
+else if (kw == "newmtx") {
+  if (tokens.size() < 3) { 
+    cout << "Usage: newvec name sizeX(Col) sizeY(Lines) [f(i,j) dopt] " << endl; return(0); 
+    }
+  int nx = atoi(tokens[1].c_str());
+  int ny = atoi(tokens[2].c_str());
+  double xmin, xmax, ymin, ymax;
+  xmin = 0.;  xmax = nx;
+  ymin = 0.;  ymax = ny;
+  if (tokens.size() < 4)  {
+    Matrix* mtx = new Matrix(ny,nx);
+    mObjMgr->AddObj(mtx, tokens[0]);
+    }
+  else {
+    if (tokens.size() < 5)  tokens.push_back("n");
+    mObjMgr->GetServiceObj()->PlotFunc2D(tokens[3], tokens[0], xmin, xmax, ymin, ymax, 
+                                         nx, ny, tokens[4]);
+    }
+  }
+
+// Copie d'objets
+else if (kw == "copy") {
+  if(tokens.size()<2) { 
+    cout<<"Usage: copy name_from  name_to"<<endl;return(0); 
+  }
+  mObjMgr->CopyObj(tokens[0],tokens[1]);
+}
+
+
+// >>>>>>>>>>>  Affichage des objets 
+else if ( (kw == "disp") || (kw == "surf") || (kw == "imag") ) {
+  if (tokens.size() < 1) { cout << "Usage: disp/surf/imag nameobj [opt]" << endl; return(0); }
+  string opt = "n";
+  if (tokens.size() > 1)  opt = tokens[1];
+  if (kw == "disp") mObjMgr->DisplayObj(tokens[0], opt);
+  else if (kw == "surf")  mObjMgr->DisplaySurf3D(tokens[0], opt);
+  else if (kw == "imag")  mObjMgr->DisplayImage(tokens[0], opt);
+  }
+
+else if (kw == "nt2d") {
+  if (tokens.size() < 5) { cout << "Usage: nt2d nameobj varx vary errx erry opt" << endl; return(0); }
+  string opt = "n";
+  if (tokens.size() > 5)  opt = tokens[5];
+  string ph = "";
+  mObjMgr->DisplayNT(tokens[0],tokens[1],tokens[2], ph, tokens[3], tokens[4], ph, opt);
+  }
+else if (kw == "nt2dw") {
+  if (tokens.size() < 6) { cout << "Usage: nt2dw nameobj varx vary varz errx erry opt" << endl; return(0); }
+  string opt = "n";
+  if (tokens.size() > 6)  opt = tokens[6];
+  string ph = "";
+  mObjMgr->DisplayNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], ph, opt, false);
+  }
+else if (kw == "nt3d") {
+  if (tokens.size() < 7) { cout << "Usage: nt3d nameobj varx vary varz errx erry errz opt" << endl; return(0); }
+  string opt = "n";
+  if (tokens.size() > 7)  opt = tokens[7];
+  mObjMgr->DisplayNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], tokens[6], opt, true);
+  }
+
+// Obsolete : ne pas virer SVP, cmv 26/7/99
+else if (kw == "gfd2d") {
+  cout<<"----- gfd2d OBSOLETE: utilisez nt2d -----"<<endl;
+  if(tokens.size()<2)
+    {cout<<"Usage: gfd2d nomobj numvarx erreur=(x y xy) opt"<<endl;
+     return(0);}
+  string numvary = "";
+  string err = "";
+  string opt = "n";
+  if(tokens.size()>2) err = tokens[2];
+  if(tokens.size()>3) opt = tokens[3];
+  mObjMgr->DisplayGFD(tokens[0],tokens[1],numvary,err,opt);
+  }
+else if (kw == "gfd3d") {
+  cout<<"----- gfd3d OBSOLETE: utilisez nt3d -----"<<endl;
+  if(tokens.size()<3)
+    {cout<<"Usage: gfd3d nameobj numvarx numvary erreur=(x y z xy xz yz xyz) opt"<<endl;
+     return(0);}
+  string err = "";
+  string opt = "n";
+  if(tokens.size()>3) err = tokens[3];
+  if(tokens.size()>4) opt = tokens[4];
+  mObjMgr->DisplayGFD(tokens[0],tokens[1],tokens[2],err,opt);
+  }
+
+// >>>>>>>>>>>  Trace de fonctions 
+else if ( (kw == "func") ) {
+  if (tokens.size() < 4) { cout << "Usage: func f(x) xmin xmax npt [opt]" << endl; return(0); }
+  string opt = "";
+  if (tokens.size() > 4)  opt = tokens[4];
+  int np;
+  double xmin, xmax;
+  np = 100;
+  xmin = 0.;  xmax = 1.;
+  np = atoi(tokens[3].c_str());
+  xmin = atof(tokens[1].c_str());   xmax = atof(tokens[2].c_str());
+  string nom = "";
+  mObjMgr->GetServiceObj()->PlotFunc(tokens[0], nom, xmin, xmax, np, opt); 
+  }
+else if ( (kw == "funcff") ) {
+  if (tokens.size() < 5) { cout << "Usage: funcff C-filename f(x)-name xmin xmax npt [opt]" << endl; return(0); }
+  string opt = "";
+  if (tokens.size() > 5)  opt = tokens[5];
+  int np;
+  double xmin, xmax;
+  np = 100;
+  xmin = 0.;  xmax = 1.;
+  np = atoi(tokens[4].c_str());
+  xmin = atof(tokens[2].c_str());   xmax = atof(tokens[3].c_str());
+  string nom = "";
+  mObjMgr->GetServiceObj()->PlotFuncFrCFile(tokens[0], tokens[1], nom, xmin, xmax, np, opt); 
+  }
+else if ( (kw == "func2d") ) {
+  if (tokens.size() < 7) {
+    cout << "Usage: func2d f(x,y) xmin xmax nptx ymin ymax npty [opt]" << endl;
+    return(0);
+    }
+  int npx, npy;
+  double xmin, xmax;
+  double ymin, ymax;
+  npx = npy = 50;
+  xmin = 0.;  xmax = 1.;
+  ymin = 0.;  ymax = 1.;
+  npx = atoi(tokens[3].c_str());
+  npy = atoi(tokens[6].c_str());
+  xmin = atof(tokens[1].c_str());   xmax = atof(tokens[2].c_str());
+  ymin = atof(tokens[4].c_str());   ymax = atof(tokens[5].c_str());
+  string opt = "";
+  if (tokens.size() > 7)  opt = tokens[7];
+  string nom = "";
+  mObjMgr->GetServiceObj()->PlotFunc2D(tokens[0], nom, xmin, xmax, ymin, ymax, npx, npy, opt);
+  }
+else if ( (kw == "func2dff") ) {
+  if (tokens.size() < 8) {
+    cout << "Usage: func2d C-filename F(x,y)-name xmax nptx ymin ymax npty [opt]" << endl;
+    return(0);
+    }
+  int npx, npy;
+  double xmin, xmax;
+  double ymin, ymax;
+  npx = npy = 50;
+  xmin = 0.;  xmax = 1.;
+  ymin = 0.;  ymax = 1.;
+  npx = atoi(tokens[4].c_str());
+  npy = atoi(tokens[7].c_str());
+  xmin = atof(tokens[2].c_str());   xmax = atof(tokens[3].c_str());
+  ymin = atof(tokens[5].c_str());   ymax = atof(tokens[6].c_str());
+  string opt = "";
+  if (tokens.size() > 8)  opt = tokens[8];
+  string nom = "";
+  mObjMgr->GetServiceObj()->PlotFunc2DFrCFile(tokens[0], tokens[1], nom, xmin, xmax, ymin, ymax, npx, npy, opt);
+  }
+
+// >>>>>>>>>>>  Trace d'expressions de N_Tuple, StarList, etc ...
+else if (kw == "plot2d" ) {
+  if (tokens.size() < 3) {
+    cout << "Usage: plot2d nameobj expx expy [expcut opt loop_par]" << endl;
+    return(0); 
+    }
+  string errx = ""; string erry = ""; 
+  if (tokens.size() < 4) tokens.push_back("1");
+  while (tokens.size() < 6) tokens.push_back("");
+  srvo->DisplayPoints2D(tokens[0],tokens[1],tokens[2],errx,erry,tokens[3],tokens[4],tokens[5]);
+  }
+
+else if (kw == "plot2de" ) {  // Plot2D avec les erreurs 
+  if (tokens.size() < 5) {
+    cout << "Usage: plot2de nameobj expx expy experrx experry [expcut opt loop_par]" << endl;
+    return(0); 
+    }
+  if (tokens.size() < 6) tokens.push_back("1");
+  while (tokens.size() < 8) tokens.push_back("");
+  srvo->DisplayPoints2D(tokens[0],tokens[1],tokens[2],tokens[3],tokens[4],
+                        tokens[5],tokens[6],tokens[7]);
+  }
+
+else if (kw == "plot2dw" ) {   // Plot2d avec poids
+  if (tokens.size() < 4) { 
+    cout << "Usage: plot2dw nomobj expx expy expwt [expcut opt loop_par]" << endl;
+    return(0); 
+    }
+  if (tokens.size() < 5) tokens.push_back("1");
+  while (tokens.size() < 7) tokens.push_back("");
+  srvo->DisplayPoints2DW(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], tokens[5], tokens[6]);
+  }
+else if (kw == "plot3d" ) {  
+  if (tokens.size() < 4) { 
+    cout << "Usage: plot3d nomobj expx expy expz [expcut opt loop_par]" << endl;
+    return(0); 
+    }
+  if (tokens.size() < 5) tokens.push_back("1");
+  while (tokens.size() < 7) tokens.push_back("");
+  srvo->DisplayPoints3D(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], tokens[5], tokens[6]);
+  }
+
+else if (kw == "projh1d" ) {
+  if (tokens.size() < 3) { 
+    cout << "Usage: projh1d nomh1 nomobj expx [expwt expcut opt loop_par]" << endl;
+    return(0);
+    }
+  if (tokens.size() < 4) tokens.push_back("1.");
+  if (tokens.size() < 5) tokens.push_back("1");
+  while (tokens.size() < 7) tokens.push_back("");
+  srvo->ProjectH1(tokens[1], tokens[2], tokens[3], tokens[4], tokens[0], tokens[5], tokens[6] );
+  }
+
+
+// Projection dans histogrammes
+else if (kw == "projh2d" ) {
+  if (tokens.size() < 4) { 
+    cout << "Usage: projh2d nomh2 nomobj expx expy [expwt expcut opt loop_par]" << endl;
+    return(0);
+    }
+  if (tokens.size() < 5) tokens.push_back("1.");
+  if (tokens.size() < 6) tokens.push_back("1");
+  while (tokens.size() < 8) tokens.push_back("");
+  srvo->ProjectH2(tokens[1], tokens[2], tokens[3], tokens[4], tokens[5], tokens[0],
+                  tokens[6], tokens[7] );
+  }
+
+else if (kw == "projprof" ) {
+  if (tokens.size() < 4) { 
+    cout << "Usage: projprof nomprof nomobj expx expy [expwt expcut opt loop_par]" << endl;
+    return(0);
+    }
+  if (tokens.size() < 5) tokens.push_back("1.");
+  if (tokens.size() < 6) tokens.push_back("1");
+  while (tokens.size() < 8) tokens.push_back("");
+  srvo->ProjectHProf(tokens[1], tokens[2], tokens[3], tokens[4], tokens[5], tokens[0],
+                    tokens[6], tokens[7] );
+  }
+
+// Projection dans vector/matrix
+else if (kw == "fillvec" ) {
+  if (tokens.size() < 4) { 
+    cout << "Usage: fillvec nomvec nomobj expx expv [expcut opt loop_par]" << endl;
+    return(0);
+    }
+  if (tokens.size() < 5) tokens.push_back("1");
+  while (tokens.size() < 7) tokens.push_back("");
+  srvo->FillVect(tokens[1], tokens[2], tokens[3], tokens[4], tokens[0], tokens[5], tokens[6] );
+  }
+
+else if (kw == "fillmtx" ) {
+  if (tokens.size() < 5) { 
+    cout << "Usage: fillmtx nommtx nomobj expx expy expv [expcut opt loop_par]" << endl;
+    return(0);
+    }
+  if (tokens.size() < 6) tokens.push_back("1");
+  while (tokens.size() < 8) tokens.push_back("");
+  srvo->FillMatx(tokens[1], tokens[2], tokens[3], tokens[4], tokens[5], tokens[0],
+                    tokens[6], tokens[7] );
+  }
+
+// Remplissage NTuple,Vecteurs, ... , boucle de NTuple
+else if (kw == "ntfrascii" ) {
+  if(tokens.size() < 2) { 
+    cout<<"Usage: ntfrascii nt_name file_name [def_init_val]"<<endl;
+    return(0);
+    }
+  double def_val = 0.;
+  if(tokens.size()>=3) def_val = atof(tokens[2].c_str());
+  srvo->NtFromASCIIFile(tokens[0],tokens[1],def_val);
+  }
+
+else if (kw == "fillnt" ) {
+  if (tokens.size() < 5) { 
+    cout << "Usage: fillnt nameobj expx expy expz expt [expcut ntname loop_par]" << endl;
+    return(0);
+    }
+  while (tokens.size() < 8) tokens.push_back("");
+  srvo->FillNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], tokens[6], tokens[7] );
+  }
+
+else if (kw == "ntloop" ) {
+  if (tokens.size() < 3) { 
+    cout << "Usage: ntloop nameobj fname funcname [ntname loop_par ]" << endl;
+    return(0);
+    }
+  while (tokens.size() < 5) tokens.push_back("");
+  srvo->FillNTFrCFile(tokens[0],tokens[1], tokens[2], tokens[3], tokens[4]);
+  }
+
+else if (kw == "ntexpcfile" ) {
+  if (tokens.size() < 3) { 
+    cout << "Usage: ntexpcfile nameobj fname funcname" << endl;
+    return(0);
+    }
+  srvo->PrepareNTExpressionCFile(tokens[0],tokens[1], tokens[2]);
+  }
+
+else if (kw == "exptovec" ) {
+  if (tokens.size() < 3) { 
+    cout << "Usage: exptovec nomvec nameobj expx [expcut opt loop_par]" << endl;
+    return(0);
+    }
+  while (tokens.size() < 6) tokens.push_back("");
+  srvo->ExpressionToVector(tokens[1],tokens[2],tokens[3],tokens[0],tokens[4],tokens[5]);
+  }
+
+else if (kw == "fillgd1" ) {
+  if (tokens.size() < 5) {
+    cout << "Usage: fillgd1 nomgfd nomobj expx expy experry [expcut loop_par] " << endl;
+    return(0);
+    }
+  if (tokens.size() < 6) tokens.push_back("1");
+  if (tokens.size() < 7) tokens.push_back("");
+  string expy = "";
+  srvo->FillGFD(tokens[1],tokens[2], expy, tokens[3], tokens[4], tokens[5], tokens[0]);
+  }
+
+else if (kw == "fillgd2" ) {
+  if (tokens.size() < 6) {
+    cout << "Usage: fillgd2 nomgfd nomobj expx expy expz experrz [expcut loop_par]" << endl;
+    return(0);
+    }
+  if (tokens.size() < 7) tokens.push_back("1");
+  if (tokens.size() < 8) tokens.push_back("");
+  srvo->FillGFD(tokens[1],tokens[2],tokens[3], tokens[4], tokens[5], tokens[6], tokens[0], tokens[7]);
+  }
+
+
+
+else  { 
+  cerr << "PIABaseExecutor::Do() Erreur - Commande " << kw << " inconuue ! " << endl;    
+  return(-1);
+  }
+
+return(0);
+}
+
+// Fonction pour enregistrer le Help des Widgets et Windows de piapp 
+static void RegisterPIGraphicsHelp(PIACmd* piac);
+
+/* --Methode-- */
+void PIABaseExecutor::RegisterCommands()
+{
+string kw, usage;
+kw = "loadmodule";
+usage = "To load and initialize modules \n  Usage: loadmodule fnameso modulename";
+usage += "\n  Related commands: link";  
+mpiac->RegisterCommand(kw, usage, this, "External Modules");
+kw = "link";
+usage = "Dynamic linking of compiled user functions \n  Usage: link fnameso f1 [f2 f3]";
+usage += "\n  fnameso: Shared-object file name, f1,f2,f3 : User function names ";
+usage += "\n  Related commands: call loadmodule";  
+mpiac->RegisterCommand(kw, usage, this, "External Modules");
+kw = "call";
+usage = "Dynamically linked user function call \n Usage: call userf [arg1 arg2 ...]";
+usage += "\n  User function : f(vector<string>& args)";
+usage += "\n  Related commands: link";  
+mpiac->RegisterCommand(kw, usage, this, "External Modules");
+
+kw = "zone";
+usage = "To Divide the Graphic window \n  Usage: zone [nx=1 ny=1]";
+usage += "\n  Related commands: newwin";  
+mpiac->RegisterCommand(kw, usage, this, "Graphics");
+kw = "newwin";
+usage = "To Create a New Graphic window, with zones \n  Usage: newwin nx ny";
+usage += "\n  Related commands: zone";  
+mpiac->RegisterCommand(kw, usage, this, "Graphics");
+kw = "stacknext";
+usage = "Displays the next widget on stack window \n  Usage: stacknext";
+mpiac->RegisterCommand(kw, usage, this, "Graphics");
+
+kw = "gratt";
+usage = "To change default graphic options \n  Usage: gratt att_list \n";
+usage += "att_list=def back to default values, Example: gratt red,circlemarker5";
+usage += "\n ------------------ Graphic attribute list ------------------ \n";
+usage += ">> Colors: defcol black white grey red blue green yellow magenta cyan \n";
+usage += "           turquoise navyblue orange siennared purple limegreen gold \n";
+usage += ">> Lines:  defline normalline thinline thickline dashedline thindashedline \n";
+usage += "           thickdashedline dottedline thindottedline thickdottedline \n";
+usage += ">> Fonts:  deffont normalfont boldfont italicfont smallfont smallboldfont \n";
+usage += "           smallitalicfont bigfont bigboldfont bigitalicfont \n";
+usage += "           hugefont  hugeboldfont hugeitalicfont \n";
+usage += ">> Marker: dotmarker<T>  plusmarker<T>  crossmarker<T> circlemarker <T> \n";
+usage += "           fcirclemarker<T> boxmarker<T> fboxmarker<T> trianglemarker<T> \n";
+usage += "           ftrianglemarker<T>  starmarker<T>  fstarmarker<T> \n";
+usage += "   with <T> = 1 3 5 7 9 , Example fboxmarker5 , plusmarker9 ... \n";
+usage += ">> ColorTables: defcmap  grey32  greyinv32  colrj32  colbr32 \n";
+usage += "                grey128  greyinv128  colrj128  colbr128 \n";
+usage += ">> ZoomFactors: defzoom zoomx1 zoomx2 zoomx3 zoomx4 zoomx5 \n";
+usage += "                               zoom/2 zoom/3 zoom/4 zoom/5 \n";
+usage += ">> Axes:  stdaxes=defaxes=boxaxes  simpleaxes boxaxesgrid \n";
+usage += "          fineaxes  grid=fineaxesgrid \n"; 
+usage += ">> XYLimits : xylimits  -> Forces X-Y limits in 2-D plots \n";
+usage += ">> DisplayWindow: next same win stack \n";
+usage += "   Related commands: setxylimits";  
+mpiac->RegisterCommand(kw, usage, this, "Graphics");
+
+kw = "setxylimits";
+usage = "Define 2-D plot limits \n Usage: setxylimits xmin xmax ymin ymax";
+usage += "\n  Related commands: gratt";  
+mpiac->RegisterCommand(kw, usage, this, "Graphics");
+
+kw = "addtext";
+usage = "Adds a text string to the current graphic object";
+usage += "\n at the specified position (Gr-Object Coordinate) with graphic attribute specification";
+usage += "\n  Usage: addtext x y ColFontAtt TextString";
+usage += "\n  Related commands: gratt";  
+mpiac->RegisterCommand(kw, usage, this, "Graphics");
+
+RegisterPIGraphicsHelp(mpiac);
+
+kw = "openfits";
+usage = "Loads a FITS file into an Image<T> \n Usage: openfits filename";
+usage += "\n  Related commands: savefits openppf";  
+mpiac->RegisterCommand(kw, usage, this, "FileIO");
+kw = "savefits";
+usage = "Save an object into a FITS file \n Usage: savefits nameobj filename";
+usage += "\n  Related commands: openfits saveall";  
+mpiac->RegisterCommand(kw, usage, this, "FileIO");
+kw = "openppf";
+usage = "Reads all objects from a PPF file \n Usage: openppf filename";
+usage += "\n  Related commands: saveall openfits";  
+mpiac->RegisterCommand(kw, usage, this, "FileIO");
+kw = "saveobjs";
+usage = "Saves objects with names matching a pattern (x?y*) into a PPF file \n";
+usage += "Usage: saveall nameobjpattern filename";
+usage += "\n  Related commands: saveall openppf savefits";  
+mpiac->RegisterCommand(kw, usage, this, "FileIO");
+kw = "saveall";
+usage = "Saves all objects into a PPF file \n Usage: saveall filename";
+usage += "\n  Related commands: saveobj openppf savefits";  
+mpiac->RegisterCommand(kw, usage, this, "FileIO");
+kw = "ntfrascii";
+usage = "Fills an existing NTuple from ASCII table file";
+usage += "\n Usage: ntfrascii nt_name file_name [def_init_val]";
+usage += "\n  Related commands: ntloop fillnt ";
+mpiac->RegisterCommand(kw, usage, this, "FileIO");
+
+
+kw = "print";
+usage = "Prints an object \n Usage: print nameobj";
+mpiac->RegisterCommand(kw, usage, this, "FileIO");
+
+kw = "mkdir";
+usage = "Create a directory";
+usage += "\n Usage: mkdir dirname [true]";
+usage += "\n if second argument==true, the directory's KeepOld attribute is set to true";
+mpiac->RegisterCommand(kw, usage, this, "Object Management");
+kw = "rmdir";
+usage = "Removes an empty directory";
+usage += "\n Usage: remove dirname";
+mpiac->RegisterCommand(kw, usage, this, "Object Management");
+kw = "cd";
+usage = "Change current directory";
+usage += "\n Usage: cd [dirname]";
+mpiac->RegisterCommand(kw, usage, this, "Object Management");
+kw = "pwd";
+usage = "Prints current directory";
+usage += "\n Usage: pwd";
+mpiac->RegisterCommand(kw, usage, this, "Object Management");
+kw = "listdirs";
+usage = "Prints the list of directories";
+usage += "\n Usage: listdirs [patt=*] \n patt : * , ? ";
+mpiac->RegisterCommand(kw, usage, this, "Object Management");
+kw = "listobjs";
+usage = "Prints the list of objects (Alias: ls)";
+ usage += "\n Usage: listobjs [patt=*] \n patt : /*/x?y* ... ";
+mpiac->RegisterCommand(kw, usage, this, "Object Management");
+kw = "rename";
+usage = "Rename an object (Alias: mv) \n Usage: rename nameobj namenew";
+usage += "\n  Related commands: del delobjs";  
+mpiac->RegisterCommand(kw, usage, this, "Object Management");
+kw = "copy";
+usage = "Copy objects \n";
+usage +="  Usage: copy name_from name_to";
+usage += "\n  Related commands: new...";  
+mpiac->RegisterCommand(kw, usage, this, "Object Management");
+kw = "del";
+usage = "Deletes an object (Alias: rm) \n Usage: del nameobj";
+usage += "\n  Related commands: delobjs  rename";  
+mpiac->RegisterCommand(kw, usage, this, "Object Management");
+kw = "delobjs";
+usage = "Delete a set of objects with names matching a pattern (x?y*)";
+usage += "\n Usage: delobjs nameobjpattern \n";
+usage += "\n  Related commands: del rename";  
+mpiac->RegisterCommand(kw, usage, this, "Object Management");
+
+kw = "newh1d";
+usage = "Creates a 1D histogramm \n Usage: newh1d name xmin xmax nbin";
+usage += "\n  Related commands: newh2d  newprof newnt  newgfd ";  
+mpiac->RegisterCommand(kw, usage, this, "Objects");
+kw = "newh2d";
+usage = "Creates a 2D histogramm \n Usage: newh2d name xmin xmax nbinx ymin ymax nbiny";
+usage += "\n  Related commands: newh1d  newprof newnt  newgfd ";  
+mpiac->RegisterCommand(kw, usage, this, "Objects");
+kw = "newprof";
+usage = "Creates a profile histogramm \n Usage: newprof name xmin xmax nbin [ymin ymax]";
+usage += "\n  Related commands: newh1d  newh2d newnt newgfd ";  
+mpiac->RegisterCommand(kw, usage, this, "Objects");
+kw = "newnt";
+usage = "Creates a ntuple \n Usage: newnt name v1 v2 v3 .. vn";
+usage += "\n        newnt name nvar";  
+usage += "\n  Related commands: newh1d  newh2d newprof newgfd ";  
+mpiac->RegisterCommand(kw, usage, this, "Objects");
+kw = "newgfd";
+usage = "Creates GeneralFit Data object \n Usage: newgfd nvar nalloc [errx(0/1)]";
+usage += "\n  Related commands: newh1d  newh2d  newprof newnt ";  
+mpiac->RegisterCommand(kw, usage, this, "Objects");
+kw = "newvec";
+usage = "Creates (and optionaly fills) a vector \n Usage: newvec name size [f(i) [dopt] ] ";
+usage += "\n  Related commands: newmtx";  
+mpiac->RegisterCommand(kw, usage, this, "Objects");
+kw = "newmtx";
+usage = "Creates (and optionaly fills) a matrix \n";
+usage +="  Usage: newvec name sizeX(Col) sizeY(Lines) [f(i,j) [dopt] ] ";
+usage += "\n  Related commands: newvec";  
+mpiac->RegisterCommand(kw, usage, this, "Objects");
+
+kw = "disp";
+usage = "Displays an object \n Usage: disp nameobj [graphic_attributes]";
+usage += "\n  Related commands: surf nt2d nt3d ";  
+mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
+kw = "imag";
+usage = "Displays an object as an image \n Usage: imag nameobj [graphic_attributes]";
+usage += "\n  Related commands: disp surf nt2d nt3d ";  
+mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
+kw = "surf";
+usage = "Displays an object as a 3D surface \n Usage: surf nameobj [graphic_attributes]";
+usage += "\n  Related commands: disp nt2d nt3d ";  
+mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
+kw = "nt2d";
+usage = "Displays Points (X-Y) [with error-bars] from an NTuple ";
+usage += "\n Usage : nt2d nameobj varx vary [errx erry] [graphic_attributes]";
+usage += "\n  Related commands: disp  surf  nt2dw nt3d  gfd2d ";  
+mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
+kw = "nt2dw";
+usage = "Displays Points (X-Y) with weight [with error-bars] from an NTuple ";
+usage += "\n Usage : nt2d nameobj varx vary varz [errx erry] [graphic_attributes]";
+usage += "\n  Related commands: disp  surf  nt2d nt3d  gfd2d ";  
+mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
+kw = "nt3d";
+usage = "Displays 3D-Points (X-Y-Z) [with error-bars] from an NTuple ";
+usage += "\n Usage : nt3d nameobj varx vary varz [errx erry errz] [graphic_attributes]";
+usage += "\n  Related commands: disp  surf  nt2d nt2dw  gfd3d ";  
+usage += "\n  Related commands: disp  surf  nt2d nt2dw ";  
+mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
+
+// Ceci est maintenant obsolete, on garde pour info.
+kw = "gfd2d";
+usage = "Displays Points (X-Y) with error-bars from a GeneralFit Data ";
+usage += "\n Usage : gfd2d nameobj numvarx erreur=(x y xy) [graphic_attributes]";
+usage += "\n  Related commands: gfd3d nt2d nt3d ";
+usage += "\n  ----- OBSOLETE: utilisez nt2d -----";
+mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
+kw = "gfd3d";
+usage = "Displays 3D-Points (X-Y-Z) with error-bars from a GeneralFit Data ";
+usage += "\n Usage : gfd3d nameobj numvarx numvary erreur=(x y z xy xz yz xyz) [graphic_attributes]";
+usage += "\n  Related commands: gfd2d nt2d nt3d ";  
+usage += "\n  ----- OBSOLETE: utilisez nt3d -----";
+mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
+
+kw = "func";
+usage = "Displays a function y=f(x) (Fills a vector with function values)";
+usage += "\n Usage: func f(x) xmin xmax npt [graphic_attributes]";
+usage += "\n  Related commands: funcff func2d func2dff ";  
+mpiac->RegisterCommand(kw, usage, this, "Func Plot");
+kw = "funcff";
+usage = "Displays a function y=f(x) from a C-file (Fills a vector with function values)";
+usage += "\n Usage: funcff C-FileName FunctionName xmin xmax npt [graphic_attributes]";
+usage += "\n  Related commands: func func2d func2dff ";  
+mpiac->RegisterCommand(kw, usage, this, "Func Plot");
+kw = "func2d";
+usage = "Displays a function z=f(x,y) (Fills a matrix with function values)";
+usage += "\n Usage: func2d f(x,y) xmin xmax nptx ymin ymax npty [graphic_attributes]";
+usage += "\n  Related commands: func";  
+mpiac->RegisterCommand(kw, usage, this, "Func Plot");
+kw = "func2dff";
+usage = "Displays a function z=f(x,y) from a C-file (Fills a matrix with function values)";
+usage += "\n Usage: func2dff C-FileName FunctionName xmin xmax nptx ymin ymax npty [graphic_attributes]";
+usage += "\n  Related commands: func funcff func2d ";  
+mpiac->RegisterCommand(kw, usage, this, "Func Plot");
+
+kw = "ObjectExpressions";
+usage = "Any mathematical expression (math.h) with object variables can be used";
+usage += "\n  ------ Object Variable names (double) -------- ";
+usage += "\nNTuple varnames - Histo1D/HProf: i,x,val,err - Histo2D: i,j,x,y,val,err";
+usage += "\nVector: i,val - Matrix: i,j,val - Image: x=i,y=j, pix=val";
+usage += "\nLoop parameters can be specified as I1[:I2[:DI]] for(int i=I1; i<I2; i+=DI)"; 
+usage += "\nThe default Cut() expression in true (=1) for all"; 
+usage += "\n  Related commands: plot2d plot2de plot2dw plot3d "; 
+usage += "\n        projh1d projh2d  projprof fillvec fillmtx "; 
+usage += "\n        fillnt fillgd1 fillgd2 ntloop exptovec ... ";
+mpiac->RegisterCommand(kw, usage, NULL, "Expr. Plotting");
+kw = "plot2d";
+usage = "Plots (2D) Y=g(Object) vs. X=f(Object) --- Object Variable names (double) :";
+usage += "\n Usage: plot2d nameobj f_X() g_Y() [f_Cut() graphic_attributes loop_param]";
+usage += "\n  Related commands: plot2de plot2dw plot3d ObjectExpressions ..."; 
+mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
+kw = "plot2de";
+usage = "Plots (2D) Y=g(Object) vs. X=f(Object) with error bars eX/Y=f_ErrX/Y(Object) ";
+usage += "\n Usage: plot2de nameobj f_X() g_Y() f_ErrX() f_ErrY() [f_Cut() graphic_attributes loop_param]";
+usage += "\n  Related commands: plot2d plot2dw plot3d ObjectExpressions ..."; 
+mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
+kw = "plot2dw";
+usage = "Plots (2D) Y=g(Object) vs. X=f(Object) with Weight W=h(Object) ";
+usage += "\n Usage: plot2dw nameobj f_X() g_Y() h_Wt() [Cut() graphic_attributes loop_param]";
+usage += "\n  Related commands: plot2d plot2dw plot3d ObjectExpressions ..."; 
+mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
+kw = "plot3d";
+usage = "Plots (3D) Z=h(Object) vs. Y=g(Object) vs. X=f(Object) vs ";
+usage += "\n Usage: plot3d nameobj f_X() g_Y() h_Z() [Cut() graphic_attributes loop_param]";
+usage += "\n  Related commands: plot2d plot2dw plot2de plot3d ObjectExpressions ..."; 
+mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
+
+kw = "projh1d";
+usage = "Projects X=f(Object) with weight WT=h(Object) into a 1D histogram ";
+usage += "\n Usage: projh1d nameh1d nameobj f_X() [h_WT()=1. Cut() graphic_attributes loop_param]";
+usage += "\n   Histo1D nameh1d is created if necessary ";
+usage += "\n  Related commands: projh2d projprof ObjectExpressions ..."; 
+mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
+kw = "projh2d";
+usage = "Projects (X=f(Object),Y=g(Object)) with weight WT=h(Object) into a 2D histogram ";
+usage += "\n Usage: projh2d nameh2d nameobj f_X() g_Y() [h_WT()=1. Cut() graphic_attributes loop_param]";
+usage += "\n   Histo2D nameh2d is created if necessary ";
+usage += "\n  Related commands: projh1d projprof ObjectExpressions ..."; 
+mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
+kw = "projprof";
+usage = "Projects (X=f(Object),Y=g(Object)) with weight WT=h(Object) into a profile histogram ";
+usage += "\n Usage: projh2d nameprof nameobj f_X() g_Y() [h_WT()=1. Cut() graphic_attributes loop_param]";
+usage += "\n   HProf nameprof is created if necessary ";
+usage += "\n  Related commands: projh1d projh2d ObjectExpressions ..."; 
+mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
+kw = "fillvec";
+usage = "Fills a Vector V((int)(f_X(Object)+0.5)) =  h_V(Object) ";
+usage += "\n Usage: fillvec namevec nameobj f_X() h_V() [Cut() graphic_attributes loop_param]";
+usage += "\n  Related commands: fillmtx fillnt ObjectExpressions ..."; 
+mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
+kw = "fillmtx";
+usage = "Fills a Matrix M(Line=g_Y(Object)+0.5, Col=f_X(Object)+0.5)) =  h_V(Object) ";
+usage += "\n Usage: fillvec namevec nameobj f_X() g_Y() h_V() [Cut() graphic_attributes loop_param]";
+usage += "\n  Related commands: fillvec fillnt ObjectExpressions ..."; 
+mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
+
+kw = "fillnt";
+usage = "Creates and Fills an NTuple(x,y,z,t) with (X=f(Object),Y=g(...),Z=h(...),T=k(...))";
+usage += "\n Usage: fillnt nameobj f_X() g_Y() h_Z() k_T() [Cut() nameNt loop_param]";
+usage += "\n  Related commands: ntloop plot2d projh1d projh2d projprof ";
+usage += "\n  Related commands: fillvec fillmtx ntloop exptovec fillgd1 fillgd2 ObjectExpressions ..."; 
+mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
+
+kw = "ntloop";
+usage = "Loops over an Object NTupleInterface calling a function from a C-file \n";
+usage += "and optionaly fills an NTuple(x,y,z,t) with (X=f(Object),Y=g(...),Z=h(...),T=k(...))";
+usage += "\n Usage: ntloop nameobj CFileName FuncName [NtupleName loop_param]";
+usage += "\n  Related commands: fillvec fillmtx fillnt fillgd1 fillgd2 exptovec ObjectExpressions ..."; 
+usage += "\n  Related commands: ntexpcfile fillnt";
+mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
+
+kw = "ntexpcfile";
+usage = "Creates a C-File with declarations suitable to be used for ntloop";
+usage += "\n Usage: ntexpcfile nameobj CFileName FuncName ";
+usage += "\n  Related commands: ntloop";
+mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
+
+kw = "exptovec";
+usage = "Creates and Fills a Vector with X=f(Object)";
+usage += "\n Usage: exptovec namevec nameobj f_X() [Cut() graphic_attributes loop_param]";
+usage += "\n  Related commands: ntloop fillnt ObjectExpressions ..."; 
+mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
+kw = "fillgd1";
+usage = "Creates and Fills a GeneralFitData with (X=f(Object), Y=g(...), ErrY=h(...))";
+usage += "\n Usage: fillgd1 namegfd nameobj f_X() g_Y() h_ErrY() [Cut() loop_param]";
+usage += "\n  Related commands: ntloop fillnt ObjectExpressions ..."; 
+mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
+kw = "fillgd2";
+usage = "Creates and Fills a GeneralFitData with (X=f(Object), Y=g(...), Z=h(...)) ErrZ=k(...)";
+usage += "\n Usage: fillgd1 namegfd nameobj f_X() g_Y() h_Z() k_ErrZ() [Cut() loop_param]";
+usage += "\n  Related commands: ntloop fillnt ObjectExpressions ..."; 
+mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
+
+}
+
+/* --Methode-- */
+int PIABaseExecutor::LinkUserFuncs(string& fnameso, string& func1, string& func2, string& func3)
+//                          string& func4, string& func5)
+{
+string cmd;
+
+if (dynlink) delete dynlink;    dynlink = NULL;
+usfmap.clear();
+
+dynlink = new PDynLinkMgr(fnameso, true);
+if (dynlink == NULL) { 
+  string sn = fnameso; 
+  cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur ouverture SO " << sn << endl; 
+  return(2); 
+  }
+
+int nok=0;
+// on utilise donc des DlFunction  (Reza 20/08/98)  voir commentaire ds .h (pb g++)
+// DlUserProcFunction f = NULL;
+DlFunction f = NULL;
+if ((func1.length() < 1) || (func1 == "-") || (func1 == ".") )  goto fin;
+// f = (DlUserProcFunction)  dlsym(dlhandle, func1.c_str());
+f = dynlink->GetFunction(func1);
+if (f) { nok++;  usfmap[func1] = f; }
+else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func1 << endl;
+
+if ((func2.length() < 1) || (func2 == "-") || (func2 == ".") )  goto fin;
+// f = (DlUserProcFunction)  dlsym(dlhandle, func2.c_str());
+f = dynlink->GetFunction(func2);
+if (f) { nok++;  usfmap[func2] = f; }
+else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func2 << endl;
+
+if ((func3.length() < 1) || (func3 == "-") || (func3 == ".") )  goto fin;
+// f = (DlUserProcFunction)  dlsym(dlhandle, func3.c_str());
+f = dynlink->GetFunction(func3);
+if (f) { nok++;  usfmap[func3] = f; }
+else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func3 << endl;
+
+/*  Pb compile g++ 2.7.2 
+if ((func4.length() < 1) || (func4 == "-") || (func4 == ".") )  goto fin;
+// f = (DlUserProcFunction)  dlsym(dlhandle, func4.c_str());
+f = dynlink->GetFunction(func4);
+if (f) { nok++;  usfmap[func4] = f; }
+else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func4 << endl;
+
+if ((func5.length() < 1) || (func5 == "-") || (func5 == ".") )  goto fin;
+// f = (DlUserProcFunction)  dlsym(dlhandle, func5.c_str());
+f = dynlink->GetFunction(func5);
+if (f) { nok++;  usfmap[func5] = f; }
+else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func5 << endl;
+*/
+fin:
+if (nok < 1) { if (dynlink) delete dynlink;    dynlink = NULL;  return(3); }
+else return(0);
+}
+
+/* Nouvelle-Fonction */
+void RegisterPIGraphicsHelp(PIACmd* piac)
+{
+string kw,grp,usage;
+
+grp = "Graphics";
+
+kw = "PIImage";
+usage = "Manages the display of a 2-D array (P2DArrayAdapter) as an image \n";
+usage += "and controls a zoom widget, as well as a global image view widget \n";
+usage += ">>>> Mouse controls : \n";
+usage += "o Button-1: Display current coordinates and pixel value\n";
+usage += "  Position the cursor an refresh the zoom widget\n";
+usage += "o Button-2: Defines an image zone and positions the cursor \n";
+usage += "o Button-3: Moves the viewed portion of the array inside the window \n";
+usage += ">>>> Keyboard controls : \n";
+usage += "o <Alt>R : Refresh display \n";
+usage += "o <Alt>O : Shows the PIImageTools (image display parameter controls) \n";
+usage += "o <Alt>G : Show the PIDrawerTools (Graphic attributes of overlayed graphics (Drawers)) \n";
+usage += "o <Alt>V : Copy/Paste / Text paste at the current cursor position \n";
+usage += "o <Alt>C : Copy/Paste / Copies the selected regions content as text in the copy/paste buffer \n";
+usage += "o <Alt>X : Show/Hide the Cut Window \n";
+usage += "o <Alt>Z : Removes signs overlayed on image (Drawer 0) \n";
+usage += "o Cursor keys : Moves the image cursor \n";
+piac->RegisterHelp(kw, usage, grp);
+
+kw = "PIScDrawWdg";
+usage = "Manages display of 2-D drawers with interactive zoom \n";
+usage += ">>>> Mouse controls : \n";
+usage += "o Button-1: Display current coordinates \n";
+usage += "o Button-2: Defines a rectangle for zoom \n";
+usage += "o Button-3: Defines a rectangle for Text-Info (<Alt>I) \n";
+usage += ">>>> Keyboard controls : \n";
+usage += "o <Alt>R : Refresh display \n";
+usage += "o <Alt>O : Displays a specific control window (default: PIDrawerTools) \n";
+usage += "           Specific controls for 2-D histograms \n";
+usage += "o <Alt>G : Show the PIDrawerTools (Graphic attributes of displayed Drawers) \n";
+usage += "           Drawer 0 manages the axes, as well as the added text \n";
+usage += "o <Alt>V : Copy/Paste / Text paste at the current position \n";
+usage += "o <Alt>Z : Removes added signs (text) to Drawer 0 \n";
+usage += "o <Alt>I : Shows (or updates) a text info window on the selected rectangle\n";
+usage += "o <Alt>M : Activate/Deactivate a measurement cursor on Button-1";
+usage += "o Cursor keys : Moves the image cursor \n";
+piac->RegisterHelp(kw, usage, grp);
+
+kw = "PIDraw3DWdg";
+usage = "Manages display of 3-D objects (drawers)  \n";
+usage += ">>>> Mouse controls : \n";
+usage += "o Button-2: Rotates the observer (camera) around object \n";
+usage += "o Shift-Button-2: Rotates object with camera fixed \n";
+usage += "  The object rotation mode can be assigned to Button-2 with <Alt>S \n";
+usage += "o Button-3: Zoom control (Camera distance And/Or view angle) \n";
+usage += ">>>> Keyboard controls : \n";
+usage += "o <Alt>R : Resets the 3-D view and refreshes the display \n";
+usage += "o <Alt>G : Show the PIDrawerTools (Graphic attributes of displayed Drawers) \n";
+usage += "o <Alt>O : = <Alt>G \n";
+usage += "o <Alt>V : Copy/Paste / Text paste at the current position (Drawer 0)\n";
+usage += "o <Alt>Z : Removes added signs (text) to Drawer 0 \n";
+usage += "o <Alt>A : Activate/Deactivate axes drawing \n";
+usage += "o <Alt>S : Activate/Deactivate object rotation mode on Button-2 \n";
+piac->RegisterHelp(kw, usage, grp);
+
+kw = "Windows";
+usage = "Objects can be displayed in different windows, or overlayed on the \n";
+usage += "previous display. The graphics attributes next,win,stack,same control \n";
+usage += "the display window. \n";
+usage += "o GraphicWindow : This is the default mode (gr_att=next)\n";
+usage += "  Graphic windows can be divided int zones. Object is displayed \n";
+usage += "  in the next available position, removing a previously displayed \n";
+usage += "  widget if necessary \n";
+usage += "o Window : An object is displayed in its own window (gr_att= win) \n";
+usage += "o StackWindow : multpile widgets can be stacked in a StackWindow (gr_att= stack) \n";
+usage += "  A single widget is displayed a any time. Different widgets in a StackWindow \n";
+usage += "  can be displayed using the stacknext command, as well as the StackTools item \n";
+usage += "  in the Tools menu (from Menubar). An automatic cyclic display mode can also \n";
+usage += "  be activated using the StackTools menu (Blink) \n";
+usage += "o Most objects can be also be displayed, overlayed on the last displayed widget (gr_att= same) \n";
+usage += "\n  Related commands: newwin zone stacknext gratt";  
+piac->RegisterHelp(kw, usage, grp);
+ 
+}
Index: /tags/V_LaSilla191199/SophyaPI/PIext/basexecut.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/basexecut.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/basexecut.h	(revision 464)
@@ -0,0 +1,34 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Classe executeur de commande de base pour piapp
+//                                   Reza 05/99
+// LAL-IN2P3/CNRS
+
+#ifndef PIABaseExecutor_H_SEEN
+#define PIABaseExecutor_H_SEEN
+
+#include "piacmd.h"
+
+class PIABaseExecutor : public CmdExecutor {
+public :
+		PIABaseExecutor(PIACmd* piac, NamedObjMgr* omg, PIStdImgApp* app);
+  virtual	~PIABaseExecutor();
+  virtual int	Execute(string& keyw, vector<string>& args);
+
+protected :
+  void		RegisterCommands();
+//  Link dynamique de fonction user
+  int 		LinkUserFuncs(string& fnameso, string& func1, string& func2, string& func3);
+//                            string& func4, string& func5);   compil avec g++ 2.7.2
+  PIACmd* mpiac;
+  NamedObjMgr* mObjMgr;
+  PIStdImgApp* mImgApp;
+// g++ n'arrive pas a avaler ca (lignes trop longues)  on utilise donc des DlFunction  (Reza 20/08/98)
+// typedef map<string, DlUserProcFunction, less<string> > UsFmap;
+  typedef map<string, DlFunction, less<string> > UsFmap;
+  PDynLinkMgr* dynlink;
+  UsFmap usfmap;
+
+};
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PIext/dlftypes.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/dlftypes.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/dlftypes.h	(revision 464)
@@ -0,0 +1,31 @@
+// This may look like C code, but it is really -*- C++ -*-
+// typedef pour link dynamique de piapp  
+// Reza                     Juillet,Aout 98
+// LAL-IN2P3/CNRS
+
+#ifndef DLFTPES_H_SEEN
+#define DLFTYPES_H_SEEN
+
+#include "machdefs.h"
+#include <string>
+#include <vector>
+
+// ------------ Fonctions pour trace de fonctions --------------
+typedef double (* DlFunctionOfX) (double x);
+typedef double (* DlFunctionOfXY) (double x, double y);
+// ---- Fonctions pour trace d'expressions d'objets ------------
+typedef int (* PlotExprFunc) (double* x, double* rx, double* ry, double* rz, double* rt);
+typedef int (* NTLoopExprFunc) (double* x, double* rx, double* ry, double* rz, 
+                                double* rt, int n, int nmax);
+
+// ---------- Fonctions UserFit ----------------
+typedef double (* DlUserFitFunc)(double const*, double const*);
+typedef double (* DlUserFitFuncDer)(double const*, double const*, double*);
+
+// ---------- Fonctions User et gestion de modules chargeables ----
+typedef void (* DlUserProcFunction) (vector<string>& args);
+typedef void (* DlFunction) ();
+typedef void (* DlModuleInitEndFunction) ();
+
+#endif
+
Index: /tags/V_LaSilla191199/SophyaPI/PIext/exclude
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/exclude	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/exclude	(revision 464)
@@ -0,0 +1,2 @@
+modrecst.cc
+userfitfunex.c
Index: /tags/V_LaSilla191199/SophyaPI/PIext/nobjmgr.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/nobjmgr.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/nobjmgr.cc	(revision 464)
@@ -0,0 +1,1239 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include <typeinfo>
+#include <iostream.h>
+#include <string>
+#include <list>
+#include <map>
+
+#include "strutil.h"
+#include "datatypes.h"
+
+#include "nobjmgr.h"
+#include "servnobjm.h"
+#include "nomgadapter.h"
+#include "pistdimgapp.h"
+
+
+// EVOL-PLANCK
+#ifdef SANS_EVOLPLANCK
+#include "fitsimage.h"  
+#endif
+
+#include "pisurfdr.h"
+#include "pipodrw.h"
+
+#include "pintuple.h"
+#include "pintup3d.h"
+#include "pigfd1.h"
+#include "pigfd2.h"
+
+
+//++
+// Class	NamedObjMgr
+// Lib		PI
+// include	nobjmgr.h
+//
+//	Cette classe fournit les services nécéssaires à la gestion des objets
+//	(l'ensemble des objets PPersist de PEIDA++) au sein du programme
+//	d'analyse interactive *piapp* . Elle constitue en outre l'interface
+//	entre les fonctions utilisateur et l'application graphique.
+//--
+//++
+// Links	Voir aussi
+// PIStdImgApp
+// Services2NObjMgr
+// PIACmd
+//--
+
+
+// ..................................................................
+// ......  Gestion des objets nommes, variables globales ............
+struct nobj_diritem {
+  int id;                 // Directory Id
+  int nobj;               // Number of objects in directory
+  bool lock;              // True -> directory locked, No Add, del or rename
+  bool keepold;           // True -> When duplicate object name, old object moved to /old
+};
+
+typedef map<string, nobj_diritem, less<string> > NObjDirList;
+
+struct nobj_item {
+  AnyDataObj* obj;             // Object pointer
+  NObjMgrAdapter* obja;        // Object adapter pointer
+  int oid;                     // object Id
+  int dirid;                   // Directory Id
+  list<int> wrsid;             // List of Window Resource Id (Drawer, PIBaseWdg, ...) 
+                               // (for PIStdImgApp)
+  bool operator==(nobj_item const& b) const
+    { return (this->obj ==  b.obj); }
+};
+
+typedef map<string, nobj_item, less<string> > NObjList;
+
+static NObjDirList* myDirs = NULL;
+static NObjList* myObjs = NULL;
+static int fgOInit = 0;
+static int myNObj = 0;
+static int myDirId = 0;
+static string* currDir;
+
+static PIStdImgApp* myImgApp=NULL;
+static Services2NObjMgr* servnobjm=NULL;
+
+static string* TmpDir;  // Repertoire pour les compilations / link dynamique
+
+
+// Pour completer le nom de l'objet avec le nom du repertoire
+static void RemoveSpacesFromName(string & nom);
+static bool CheckDirName(string & nom);
+static int  ParseObjectName(string & nom, string & nomrep, string & nomobj);
+// ..................................................................
+
+//++
+// Titre	Constructeurs
+//--
+//++
+// NamedObjMgr()
+//	Constructeur. Les différents instantiation de la classe "NamedObjMgr" 
+//	dans une même application créent des objets qui travaillent sur la même
+//	liste d'objets. Les objets de cette classe ne possedent en effet pas
+//	de variables membres. 
+//--
+
+/* --Methode-- */
+NamedObjMgr::NamedObjMgr()
+{
+if (fgOInit == 0) { 
+  myNObj = 0;
+  myDirId = 0;
+  myDirs = new NObjDirList;
+  myObjs = new NObjList;  
+  currDir = new string("home");
+  string dirn = "home";
+  CreateDir(dirn);
+  SetKeepOldDirAtt(dirn, true);
+  dirn = "tmp";
+  CreateDir(dirn);
+  SetKeepOldDirAtt(dirn, false);
+  dirn = "func";
+  CreateDir(dirn);
+  SetKeepOldDirAtt(dirn, false);
+  dirn = "old";
+  CreateDir(dirn);
+  SetKeepOldDirAtt(dirn, false);
+  dirn = "home";
+  SetCurrentDir(dirn);
+  myDirId = 50;
+  char* varenv;
+  TmpDir = new string("");
+  if ( (varenv=getenv("PEIDA_TMP")) != NULL )  (*TmpDir) = varenv; 
+  else if ( (varenv=getenv("TMPDIR")) != NULL )  (*TmpDir) = varenv; 
+  int l = (*TmpDir).length();
+  if ( (l>0) && ((*TmpDir)[l-1] != '/') )  (*TmpDir) += '/';
+  servnobjm = new Services2NObjMgr(this, (*TmpDir));
+  }
+fgOInit++;
+}
+
+  
+/* --Methode-- */
+NamedObjMgr::~NamedObjMgr()
+{
+fgOInit--;
+if (fgOInit == 0)  delete myObjs;
+}
+
+//++
+// Titre	Méthodes
+//--
+//++
+// void SetImgApp(PIStdImgApp* app)
+//	Spécifie l'objet "PIStdImgApp" associé.
+// PIStdImgApp* GetImgApp()
+//	Accès à l'objet "PIStdImgApp" associé.
+//--
+
+/* --Methode-- */
+void NamedObjMgr::SetImgApp(PIStdImgApp* app)
+{
+myImgApp = app;
+servnobjm->SetImgApp(app);
+
+NObjDirList::iterator it;
+string cn;
+for(it= myDirs->begin(); it != myDirs->end(); it++) {
+  cn = '/' + (*it).first;
+  (myImgApp->ObjMgrW())->AddDirectory(cn.c_str(), (*it).second.id);
+  }
+}
+
+
+static bool verbeux = false;  // true -> plus de message (creation/suppression d'objets)
+void NamedObjMgr::SetVerbose(bool fg)
+{
+verbeux = fg;
+}
+
+/* --Methode-- */
+PIStdImgApp* NamedObjMgr::GetImgApp()
+{
+return(myImgApp);
+}
+
+/* --Methode-- */
+Services2NObjMgr* NamedObjMgr::GetServiceObj()
+{
+return(servnobjm);
+}
+
+/* --Methode-- */
+bool NamedObjMgr::CreateDir(string & dirname)
+{
+if ( !CheckDirName(dirname) ) {
+  cout << "NamedObjMgr::CreateDir( " << dirname << ") Error - Invalid name !" << endl;
+  return(false); 
+  }
+NObjDirList::iterator it = myDirs->find(dirname);
+if (it != myDirs->end()) {
+  cout << "NamedObjMgr::CreateDir( " << dirname << ") Error - Existing directory !" << endl;
+  return(false);
+  }
+myDirId++;
+nobj_diritem di;
+di.id = myDirId;
+di.nobj = 0;
+di.lock = false;
+di.keepold = false;
+(*myDirs)[dirname] = di;
+if (myImgApp)  { 
+  string str = '/' + dirname;
+  (myImgApp->ObjMgrW())->AddDirectory(str.c_str(), myDirId);
+  }
+if (verbeux) cout << "NamedObjMgr::CreateDir() " << dirname << " Created " << endl;
+return(true);
+}
+
+/* --Methode-- */
+bool NamedObjMgr::DeleteDir(string & dirname)
+{
+if ( !CheckDirName(dirname) ) {
+  cout << "NamedObjMgr::DeleteDir( " << dirname << ") Error - Invalid name !" << endl;
+  return(false); 
+  }
+NObjDirList::iterator it = myDirs->find(dirname);
+if (it == myDirs->end()) {
+  cout << "NamedObjMgr::DeleteDir( " << dirname << ") Error - No such directory !" << endl;
+  return(false);
+  }
+if ((*it).second.nobj > 0) {
+  cout << "NamedObjMgr::DeleteDir() " << dirname << " not empty ! " << endl;
+  return(false);
+  }
+if ((*it).second.lock ) {
+  cout << "NamedObjMgr::DeleteDir() " << dirname << " locked ! " << endl;
+  return(false);
+  }
+if ((*it).second.id < 50) {
+  cout << "NamedObjMgr::DeleteDir() " << dirname << " cannot be deleted ! " << endl;
+  return(false);
+  }
+
+if (myImgApp)  
+  (myImgApp->ObjMgrW())->DelDirectory((*it).second.id);
+myDirs->erase(it);
+if (verbeux) cout << "NamedObjMgr::DeleteDir() " << dirname << " deleted " << endl;  
+return(true);
+}
+
+/* --Methode-- */
+void NamedObjMgr::LockDir(string & dirname)
+{
+if ( !CheckDirName(dirname) ) return;
+NObjDirList::iterator it = myDirs->find(dirname);
+if (it == myDirs->end()) return;
+(*it).second.lock = true;
+if (verbeux) cout << "NamedObjMgr::LockDir() " << dirname << " Locked " << endl;
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::UnlockDir(string & dirname)
+{
+if ( !CheckDirName(dirname) ) return;
+NObjDirList::iterator it = myDirs->find(dirname);
+if (it == myDirs->end()) return;
+(*it).second.lock = true;
+if (verbeux) cout << "NamedObjMgr::UnlockDir() " << dirname << " Unlocked " << endl;
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::SetKeepOldDirAtt(string & dirname, bool keepold)
+{
+if ( !CheckDirName(dirname) ) return;
+NObjDirList::iterator it = myDirs->find(dirname);
+if (it == myDirs->end()) return;
+(*it).second.keepold = keepold;
+if (!verbeux) return;
+cout << "NamedObjMgr::SetKeepOldDirAtt() " << dirname << "  ->  ";
+if ( keepold ) cout << " True " << endl;
+else cout << " False " << endl;
+return;
+}
+
+
+/* --Methode-- */
+bool NamedObjMgr::SetCurrentDir(string & dirname)
+{
+if ( !CheckDirName(dirname) ) {
+  cout << "NamedObjMgr::SetCurrentDir( " << dirname << ") Error - Invalid name !" << endl;
+  return(false); 
+  }
+NObjDirList::iterator it = myDirs->find(dirname);
+if (it == myDirs->end()) {
+  cout << "NamedObjMgr::SetCurrentDir( " << dirname << ") Error - No such directory !" << endl;
+  return(false);
+  }
+*currDir = dirname;
+if (verbeux) cout << "NamedObjMgr::SetCurrentDir() -> " << dirname << endl;
+return(true);
+}
+
+/* --Methode-- */
+void NamedObjMgr::GetCurrentDir(string & dirname)
+{
+dirname = *currDir;
+}
+
+/* --Methode-- */
+void NamedObjMgr::ListDirs(string & patt)
+{
+NObjDirList::iterator it;
+string cn;
+cout << "NamedObjMgr::ListDirs( " << patt << " ) " << endl;
+int k = 0;
+for(it= myDirs->begin(); it != myDirs->end(); it++) {
+  cn = (*it).first;
+  if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
+  k++;
+  cout << k << "- " << (*it).first;
+  if ( (*it).second.lock )  cout << "  Locked " ;
+  if ( (*it).second.keepold )   cout << "  KeepOld " ;
+  cout << "  (Id= " << (*it).second.id << " NbObj= " << (*it).second.nobj << ")" << endl;
+   
+  }
+}
+
+/* --Methode-- */
+void NamedObjMgr::GetDirList(string & patt, vector<string>& lstd)
+{
+NObjDirList::iterator it;
+string cn;
+for(it= myDirs->begin(); it != myDirs->end(); it++) {
+  cn = (*it).first;
+  if (csh_parse(cn.c_str(), patt.c_str()) == 0) continue;
+  lstd.push_back(cn);
+  }
+}
+
+/* --Methode-- */
+void NamedObjMgr::CleanDir(string & dirname)
+{
+if ( !CheckDirName(dirname) ) {
+  cout << "NamedObjMgr::CleanDir( " << dirname << ") Error - Invalid name !" << endl;
+ // return(false);  $CHECK$ illegal return value in void function
+  }
+NObjDirList::iterator itr = myDirs->find(dirname);
+if (itr == myDirs->end()) {
+  cout << "NamedObjMgr::CleanDir( " << dirname << ") Error - No such directory !" << endl;
+ // return(false);  $CHECK$ illegal return value in void function
+  }
+
+int did = (*itr).second.id;
+NObjList::iterator it;  
+list<int>::iterator iwr;
+bool nodisp = true;
+list<string> odel;
+for(it = myObjs->begin(); it != myObjs->end(); it++) {
+  if ((*it).second.dirid != did) continue;
+  nodisp = true;
+  if (myImgApp) 
+    for(iwr=(*it).second.wrsid.begin(); iwr != (*it).second.wrsid.end(); iwr++) 
+      if (myImgApp->CheckWRsId(*iwr)) { nodisp = false; break; }
+  if (nodisp) odel.push_back((*it).first);
+  }
+list<string>::iterator ii;
+for(ii=odel.begin(); ii != odel.end(); ii++)  DelObj(*ii,true);
+}
+
+
+
+//++
+// Titre	Gestion de la liste des objets
+//--
+//++
+// void AddObj(AnyDataObj* obj, string& nom)
+//	Ajoute l'objet "obj" à la liste, identifié par "nom".
+//	Si un objet de même nom existe, l'ancien objet est renommé en concaténant 
+//	un numéro à son nom.
+// void DelObj(string const& nom, bool fgd=true)
+//	Supprime l'objet "nom" de la liste. L'objet est détruit si "fgd==true"	("delete obj")
+// void DelObjects(string const& patt, bool fgd=true)
+//	Supprime l'ensemble des objets dont le nom correspond au patron "patt".
+//	Le patron peut contenir les caractères "*" et "?" . Les objets sont détruits si "fgd==true"
+// AnyDataObj*  GetObj(string const& nom) 
+//	Retourne l'objet identifié par "nom" dans la liste. Retourne "NULL" si "nom" n'est 
+//	pas dans la liste.
+// void  RenameObj(string const& nom, string& nomnew)
+//	Change le nom d'un objet dans la liste.
+// void  CopyObj(string const& nom, string& nomcp)
+//	Copy l'objet "nom" de la liste dans l'objet "nomcp" de la liste.
+//--
+
+
+/* --Methode-- */
+bool NamedObjMgr::AddObj(AnyDataObj* obj, string & nom, bool crd)
+{
+
+if (obj == NULL)  return(false);
+// On verifie si l'objet est deja dans la liste 
+NObjList::iterator it;
+for(it = myObjs->begin(); it != myObjs->end(); it++) {
+  if ((*it).second.obj == obj) {
+    cout << "NamedObjMgr::AddObj() Object already present with name " << (*it).first << endl;
+    return(false);
+    }
+  }
+string nobj;
+string nrep;
+char buff[32];
+int did = ParseObjectName(nom, nrep, nobj);
+if (did == 0) {
+  if (!crd) {
+    cout << "NamedObjMgr::AddObj() No " << nrep << " Directory " << endl;
+    return(false);
+    }
+  else { CreateDir(nrep);  did =  myDirId; }
+  }
+
+// Si c'est le repertoire /func, on nettoie
+if (nrep == "func")  {
+  CleanDir(nrep);
+  }
+
+myNObj++;
+if (nobj.length() < 1) { 
+  sprintf(buff,"O%d", myNObj);
+  nobj = buff;
+  }
+
+nom = '/' + nrep + '/' + nobj;  
+NObjDirList::iterator itr = myDirs->find(nrep);
+if ((*itr).second.lock) {
+  cout << "NamedObjMgr::AddObj() " << nrep << " Locked Directory " << endl;
+  return(false);
+  }
+it = myObjs->find(nom);
+if (it != myObjs->end()) { // l'objet existe deja
+  if (nrep == "func") {  // Dans /func , on garde les objets affiches, donc del. par Clean
+    sprintf(buff, "%d", (*it).second.oid); 
+    string nomnew = "/func/" + nobj + buff;
+    RenameObj(nom, nomnew);
+    }                              
+  else if ( (*itr).second.keepold ) { // On met l'ancien objet dans /old
+    string on,od;
+//    ParseObjectName((*it).first, od, on); 
+    sprintf(buff, "%d", (*it).second.oid);
+    string nomnew = "/old/" + nobj + buff;
+    RenameObj(nom, nomnew);
+    }
+  else {  // Sinon, on remplace l'objet
+    cout << "NamedObjMgr::AddObj() - Replacing " << nom << endl;
+    DelObj(nom);
+    }
+  }
+
+nobj_item no;
+no.obj = obj;
+no.obja = servnobjm->GetAdapter(obj);  // L'adaptateur
+no.oid =  myNObj;
+no.dirid = did;
+(*myObjs)[nom] = no;
+
+(*itr).second.nobj++;
+
+if (verbeux) cout << "NamedObjMgr::AddObj()  Object " << nom << " ( "  
+     << typeid(*obj).name() << " ) added (Total= " << myObjs->size() << ")" << endl;  
+return(true);
+}
+
+/* --Methode-- */
+bool NamedObjMgr::RenameObj(string & nom, string& nomnew)
+{
+string n1,r1,n2,r2;
+int dids = ParseObjectName(nom, r1, n1);
+NObjDirList::iterator itr1 = myDirs->find(r1);
+int did = ParseObjectName(nomnew, r2, n2);
+NObjDirList::iterator itr2 = myDirs->find(r2);
+
+if (did == 0) {
+  cout << "NamedObjMgr::RenameObj() Error - No " << r2 << " directory !" << endl;
+  return(false);
+  }
+nom = '/' + r1 + '/' + n1;
+nomnew = '/' + r2 + '/' + n2;
+NObjList::iterator it1 = myObjs->find(nom);
+if (it1 == myObjs->end()) {
+  cout << "NamedObjMgr::RenameObj() Error -  No " << nom << " object !" << endl;
+  return(false);
+  }
+NObjList::iterator it2 = myObjs->find(nomnew);
+if (it2 != myObjs->end()) {
+  cout << "NamedObjMgr::RenameObj() Error -  Object " << nomnew << " exist !" << endl;
+  return(false);
+  }
+
+if ( (*itr1).second.lock || (*itr2).second.lock ) {
+  cout << "NamedObjMgr::RenameObj() Error - Source or destination directory locked !" 
+       << endl;
+  return(false);  
+  }
+
+
+nobj_item no = (*it1).second;
+no.dirid = did;
+myObjs->erase(it1);
+NObjDirList::iterator itr = myDirs->find(r1);
+(*itr).second.nobj--;
+(*myObjs)[nomnew] = no;
+itr = myDirs->find(r2);
+(*itr).second.nobj++;
+if (verbeux) 
+  cout << "NamedObjMgr::RenameObj() - Object " << nom << " renamed to " << nomnew << endl;
+return(true);
+}
+
+/* --Methode-- */
+bool NamedObjMgr::CopyObj(string & nom, string& nomcp)
+{
+if(nomcp.length()<=0)
+  {cout<<"NamedObjMgr::CopyObj() Error, copied obj name "<<nomcp<<" not valid"<<endl;
+  return(false);}
+NObjMgrAdapter* obnom = GetObjAdapter(nom);
+if(obnom==NULL)
+  {cout<<"NamedObjMgr::CopyObj() Error -  No "<<nom<<" object !"<<endl;
+  return(false);}
+AnyDataObj* obnomcp = obnom->GetCopyObj();
+if(obnomcp==NULL) return(false);
+if(! AddObj(obnomcp,nomcp) ) {delete obnomcp; return(false);}
+return true;
+}
+
+/* --Methode-- */
+bool NamedObjMgr::DelObj(string & nom, bool fgd)
+{
+string n1,r1;
+ParseObjectName(nom, r1, n1);
+nom = '/' + r1 + '/' + n1;
+NObjList::iterator it = myObjs->find(nom);
+if (it == myObjs->end()) return(false); 
+NObjDirList::iterator itr = myDirs->find(r1);
+if ( (*itr).second.lock  ) {
+  cout << "NamedObjMgr::DelObj() Error - Locked directory " << r1 << endl;
+  return(false);
+  }
+list<int>::iterator ii;
+if (myImgApp) {
+//DBG  cerr << " *DBG* NamedObjMgr::DelObj Sz= " << (*it).second.wrsid.size() << endl; 
+  for(ii=(*it).second.wrsid.begin(); ii != (*it).second.wrsid.end(); ii++) 
+      myImgApp->DelWRsId((*ii));
+}
+delete (*it).second.obja;  // destruction de l'adaptateur 
+if (fgd) delete (*it).second.obj;
+
+myObjs->erase(it);
+(*itr).second.nobj--;
+
+if (!verbeux) return(true);  
+if (fgd) cout << "NamedObjMgr::DelObj()  Object " << nom << " deleted (Total= " << myObjs->size() << ")" << endl;
+else  cout << "NamedObjMgr::DelObj()  Object " << nom << " removed (Total= " << myObjs->size() << ")" << endl;
+return(true);  
+}
+
+/* --Methode-- */
+bool NamedObjMgr::DelObj_Id(int oid)
+{
+NObjList::iterator it;
+string nom;
+bool of = false;
+for(it = myObjs->begin(); it != myObjs->end(); it++) 
+  if ( (*it).second.oid == oid ) { 
+    of = true;  nom = (*it).first;
+    break;
+  }
+if (of) return(DelObj(nom, true));
+else return(false);
+}
+
+/* --Methode-- */
+void NamedObjMgr::DelObjects(string & patt, bool fgd)
+{
+string n1,r1;
+ParseObjectName(patt, r1, n1);
+patt = '/' + r1 + '/' + n1;
+NObjList::iterator it;  
+list<string> odel;
+string cn;
+for(it = myObjs->begin(); it != myObjs->end(); it++) {
+  cn = (*it).first;
+  if (csh_parse(cn.c_str(), patt.c_str()) != 0)  odel.push_back(cn);
+  }
+list<string>::iterator ii;
+for(ii=odel.begin(); ii != odel.end(); ii++)  DelObj(*ii, fgd);
+}
+
+/* --Methode-- */
+AnyDataObj* NamedObjMgr::GetObj(string & nom)
+{
+string n1,r1;
+ParseObjectName(nom, r1, n1);
+nom = '/' + r1 + '/' + n1;
+NObjList::iterator it = myObjs->find(nom);
+if (it == myObjs->end()) return(NULL); 
+return((*it).second.obj);
+}
+
+/* --Methode-- */
+NObjMgrAdapter* NamedObjMgr::GetObjAdapter(string & nom)
+{
+string n1,r1;
+ParseObjectName(nom, r1, n1);
+nom = '/' + r1 + '/' + n1;
+NObjList::iterator it = myObjs->find(nom);
+if (it == myObjs->end()) return(NULL); 
+return((*it).second.obja);
+}
+
+/* --Methode-- */
+void NamedObjMgr::ListObjs(string & patt)
+{
+int k;
+AnyDataObj* obj=NULL;
+string ctyp;
+char strg[256];
+
+string n1,r1;
+ParseObjectName(patt, r1, n1);
+patt = '/' + r1 + '/' + n1;
+ cout << "NamedObjMgr::ListObjs( " << patt << " ) TotNObjs= " << myObjs->size() << "\n" ;
+NObjList::iterator it;  k = 0;
+string cn;
+for(it = myObjs->begin(); it != myObjs->end(); it++) {
+  cn = (*it).first;
+  if (csh_parse(cn.c_str(), patt.c_str()) == 0)  continue;
+  obj = (*it).second.obj;
+  ctyp = typeid(*obj).name();
+  sprintf(strg, "%2d/ %16s : %s", k, typeid(*obj).name(), ((*it).first).c_str()); 
+  ctyp = strg;
+  cout << ctyp << "\n" ;
+  k++;
+}
+cout << endl;
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::GetObjList(string & patt, vector<string> &lst)
+{
+string n1,r1;
+if (patt.length() < 1)  return;
+bool fgr = (patt[0] == '/') ? true : false;
+ParseObjectName(patt, r1, n1);
+patt = '/' + r1 + '/' + n1;
+NObjList::iterator it;
+string cn;
+for(it = myObjs->begin(); it != myObjs->end(); it++) {
+  cn = (*it).first;
+  if (csh_parse(cn.c_str(), patt.c_str()) == 0)  continue;
+  if (fgr) lst.push_back(cn);
+  else {
+    ParseObjectName(cn, r1, n1);
+    lst.push_back(n1);
+    }
+  }
+}
+
+//++
+// Titre	Entrées-Sorties (I/O) sur les objets
+//--
+//++
+// void  ReadObj(PInPersist& s, int num=-1)
+//	Lit l'objet à partir avec le tag numéro "num" dans le flot "PInPersist s"
+//	et l'ajoute à la liste. Si "num" est négatif, tous les objets présents
+//	sur le flot "s" sont créés et ajoutés à la liste.
+// void  ReadObj(string const & nomppf, string nobj="")
+//	Lit le premier objet à partir du fichier PPF "nomppf". L'objet est ajouté
+//	à la liste avec le nom "nobj". Si "nobj" est une chaîne vide, un nom est 
+//	composé à partir du nom de fichier. 
+//--
+
+/* --Methode-- */
+void NamedObjMgr::ReadObj(string const & flnm, string & nobj)
+{
+PPersist* obj=NULL;
+bool ok = true;
+
+TRY{
+  PInPersist pis(flnm);
+  obj = PPersistMgr::ReadObject(pis);
+  if (obj == NULL) ok = false;
+}  CATCH(merr) 
+  { printf("NamedObjMgr::ReadObj()/Error Exception= %ld (%s) \n", 
+    (long)merr, PeidaExc(merr));  ok = false; } ENDTRY;
+
+if (!ok)  return;
+if (nobj.length()<1)  nobj = servnobjm->FileName2Name(flnm);
+AddObj(obj->DataObj(), nobj, true);
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::ReadObj(PInPersist& s, int num)
+{
+int_4 i, cid, key, ln; // $CHECK$ int -> int_4 a cause de TagKey
+int n0, n1;
+bool ok = true;
+PPersist* obj=NULL;
+string nom;
+
+int nread = 0;
+if ( (s.NbTags() < 1) || (num >= s.NbTags()) ) {
+  if (num >= 0) { 
+    printf("NamedObjMgr::ReadObj(PInPersist, %d) Error! NbTags = %d \n", num, s.NbTags());
+    return;
+  }
+  TRY {
+    obj = PPersistMgr::ReadObject(s);
+    if (obj == NULL)  ok = false;
+  }  CATCH(merr) { 
+    printf("NamedObjMgr::ReadObj()/Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr)); 
+    ok = false; 
+  } ENDTRY;
+  if (!ok)  return;
+  nom = "";
+  AddObj(obj->DataObj(), nom);
+  nread++;
+}
+ 
+if (num < 0) { n0 = 0; n1 = s.NbTags(); } 
+else { n0 = num; n1 = num+1; }
+for(i=n0; i<n1; i++) {
+  key = s.TagKey(i, cid, ln); 
+  if (ln <= 0)  nom = "";
+  else nom = s.TagName(i);
+  s.GotoTag(i);
+  TRY {
+    obj = PPersistMgr::ReadObject(s);
+    if (obj == NULL)  ok = false;
+  }  CATCH(merr) { 
+    printf("NamedObjMgr::ReadObj()/Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr)); 
+    ok = false; 
+  } ENDTRY;
+  if (ok)  { AddObj(obj->DataObj(), nom, true);  nread++; }
+}
+
+cout << "NamedObjMgr::ReadObj(...) " << nread << " Objects read " << endl;
+return;
+}
+/* --Methode-- */
+void NamedObjMgr::ReadAll(string const & flnm)
+{
+bool ok = true;
+PPersist* obj=NULL;
+
+PInPersist* ppin;
+TRY{
+  ppin = new PInPersist(flnm);
+  if (ppin->NbTags() < 1)  obj = PPersistMgr::ReadObject((*ppin));
+  else obj = NULL;
+}  CATCH(merr) 
+  { printf("NamedObjMgr::ReadAll()/Error Exception= %ld (%s) \n", 
+    (long)merr, PeidaExc(merr));  ok = false; } ENDTRY;
+
+if (!ok)  return;
+if (obj) {
+  string nom = servnobjm->FileName2Name(flnm);
+  AddObj(obj->DataObj(), nom);
+  }
+else ReadObj((*ppin), -1);
+delete ppin;
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::ReadFits(string const & flnm, string & nobj)
+{
+bool ok = true;
+RzImage* obj;
+
+TRY{
+//  obj = RzReadFits((char*)flnm.c_str(), ImgOffX, ImgOffY, ImgSizX, ImgSizY, ImgBitSgn);
+#ifdef SANS_EVOLPLANCK 
+  obj = RzReadFits((char*)flnm.c_str());
+#else
+  printf("NamedObjMgr::ReadFITS( NON-Disponible EVOL-PLANCK) \n"); 
+  obj = NULL;
+#endif
+  if (obj == NULL)   ok = false;
+}  CATCH(merr) { 
+  printf("NamedObjMgr::ReadFITS(_Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr)); 
+  ok = false; 
+} ENDTRY;
+if (ok) { 
+  if (nobj.length()<1)  nobj = servnobjm->FileName2Name(flnm);
+  AddObj((AnyDataObj*)obj, nobj);
+}
+return;
+}
+
+
+static int key_for_write = 5000;
+/* --Methode-- */
+void NamedObjMgr::SaveObj(string & nom, POutPersist& s, bool keeppath)
+{
+if (nom.length() < 1) return;
+string nob,rep;
+ParseObjectName(nom, rep, nob);
+nom = '/' + rep + '/' + nob;
+NObjMgrAdapter* obja=NULL;
+string nomf = (keeppath) ? nom : nob;
+obja = GetObjAdapter(nom);
+if (obja == NULL)  return;
+printf("NamedObjMgr::SaveObj(%s, )  (Type=%s) \n",  
+       nom.c_str(), typeid(*(obja->GetDataObj())).name());
+obja->SavePPF(s, nomf);
+return; 
+}
+
+/* --Methode-- */
+void NamedObjMgr::SaveObjects(string & patt, string const& flnm)
+{
+string n1,r1;
+if (patt.length() < 1)  return;
+bool keeppath = (patt[0] == '/') ? true : false;
+ParseObjectName(patt, r1, n1);
+patt = '/' + r1 + '/' + n1;
+
+bool ok = true;
+POutPersist* pout;
+TRY{
+  pout = new POutPersist(flnm);
+}  CATCH(merr) 
+  { printf("NamedObjMgr::SaveObjects()/Error Exception= %ld (%s) \n", 
+    (long)merr, PeidaExc(merr));  ok = false; } ENDTRY;
+if (!ok)  return;
+NObjList::iterator it;
+string cn; 
+for(it = myObjs->begin(); it != myObjs->end(); it++) {
+  cn = (*it).first;
+  if (csh_parse(cn.c_str(), patt.c_str()) == 0)  continue;
+  SaveObj(cn, (*pout), keeppath);
+  }
+delete pout;
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::SaveAll(string const& flnm)
+{
+bool ok = true;
+
+POutPersist* pout;
+TRY{
+  pout = new POutPersist(flnm);
+}  CATCH(merr) 
+  { printf("NamedObjMgr::SaveAll()/Error Exception= %ld (%s) \n", 
+    (long)merr, PeidaExc(merr));  ok = false; } ENDTRY;
+if (!ok)  return;
+NObjList::iterator it;
+string no; 
+for(it = myObjs->begin(); it != myObjs->end(); it++) {
+  no = (*it).first;
+  SaveObj(no, (*pout), true);
+  }
+delete pout;
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::SaveFits(string& nom, string const & flnm)
+{
+NObjMgrAdapter* obja=NULL;
+obja = GetObjAdapter(nom);
+if (obja == NULL)  return;
+obja->SaveFits(flnm);
+return;
+}
+
+
+
+/* --Methode-- */
+void NamedObjMgr::PrintObj(string& nom)
+{
+NObjMgrAdapter* obja=NULL;
+obja = GetObjAdapter(nom);
+if (obja == NULL)  return;
+
+string ctyp = typeid(*obja->GetDataObj()).name();
+cout << "NamedObjMgr::PrintObj(" << nom << ") Type: " << ctyp << endl;
+obja->Print(cout);
+
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::DisplayObj(string& nom, string dopt) 
+{
+NObjMgrAdapter* obja=NULL;
+obja = GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "NamedObjMgr::DisplayObj() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+}
+if (!myImgApp)  return;
+ 
+PIDrawer * dr = NULL;
+P2DArrayAdapter* arr = NULL;
+dr = obja->GetDrawer(dopt);
+if (!dr) arr = obja->Get2DArray(dopt);
+
+if (!dr && !arr) { 
+  string ctyp = typeid(*(obja->GetDataObj())).name();
+  cout << "NamedObjMgr::DisplayObj() Error , Pas de display pour " << ctyp << endl; 
+  return;
+  }
+
+int wrsid = 0;
+bool fgsr = true;
+int opt = servnobjm->DecodeDispOption(dopt, fgsr);
+
+string n1,r1;
+ParseObjectName(nom, r1, n1);
+
+if (dr) { 
+  PIDrawer3D * dr3 = dynamic_cast<PIDrawer3D *>(dr);
+  if(dr3)  wrsid = myImgApp->Disp3DDrawer(dr3, n1, opt);
+  else wrsid = myImgApp->DispScDrawer( dr, n1, opt); 
+  }
+else if (arr) wrsid = myImgApp->DispImage(arr, n1, opt);
+
+if(wrsid != 0) {
+  NObjList::iterator it = myObjs->find(nom);
+  if (it == myObjs->end()) return; 
+  (*it).second.wrsid.push_back(wrsid);
+  }
+if (fgsr) myImgApp->RestoreGraphicAtt(); 
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::DisplayImage(string& nom, string dopt)
+{
+NObjMgrAdapter* obja=NULL;
+obja = GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "NamedObjMgr::DisplayImage() Error , No such object " << nom << endl; 
+  return;
+}
+if (!myImgApp)  return;
+ 
+P2DArrayAdapter* arr = obja->Get2DArray(dopt);
+
+if (!arr) { 
+  string ctyp = typeid(*(obja->GetDataObj())).name();
+  cout << "NamedObjMgr::DisplayImage() Error , Not supported for " << ctyp << endl; 
+  return;
+  }
+
+string n1,r1;
+ParseObjectName(nom, r1, n1);
+
+int wrsid = 0;
+bool fgsr = true;
+int opt = servnobjm->DecodeDispOption(dopt, fgsr);
+wrsid = myImgApp->DispImage(arr, n1, opt);
+
+if(wrsid != 0) {
+  NObjList::iterator it = myObjs->find(nom);
+  if (it == myObjs->end()) return; 
+  (*it).second.wrsid.push_back(wrsid);
+  }
+if (fgsr) myImgApp->RestoreGraphicAtt(); 
+return;
+}
+/* --Methode-- */
+void NamedObjMgr::DisplaySurf3D(string& nom, string dopt)
+{
+NObjMgrAdapter* obja=NULL;
+obja = GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "NamedObjMgr::DisplaySurf3D() Error , No such object " << nom << endl; 
+  return;
+}
+if (!myImgApp)  return;
+ 
+P2DArrayAdapter* arr = obja->Get2DArray(dopt);
+
+if (!arr) { 
+  string ctyp = typeid(*(obja->GetDataObj())).name();
+  cout << "NamedObjMgr::DisplaySurf3D() Error , Not supported " << ctyp << endl; 
+  return;
+  }
+
+if ((arr->XSize() > 250) || (arr->YSize() > 250)) {
+  cout << "NamedObjMgr::DisplaySurf3D() Error , 2D-Array(" <<  arr->XSize() 
+       << "x" << arr->YSize() << ") too big (max=250x250)" << endl; 
+  delete arr;
+  return;
+  }
+
+string n1,r1;
+ParseObjectName(nom, r1, n1);
+
+int wrsid = 0;
+bool fgsr = true;
+int opt = servnobjm->DecodeDispOption(dopt, fgsr);
+PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
+wrsid = myImgApp->Disp3DDrawer(sdr, n1, opt);
+if(wrsid >= 0) {
+  NObjList::iterator it = myObjs->find(nom);
+  if (it == myObjs->end()) return; 
+  (*it).second.wrsid.push_back(wrsid);
+  }
+
+if (fgsr) myImgApp->RestoreGraphicAtt();  
+return; 
+}
+
+/* --Methode-- */
+void NamedObjMgr::DisplayNT(string& nom, string& nmx, string& nmy, string& nmz,
+                            string& erx, string& ery, string& erz, string dopt, bool fg3d)
+{
+AnyDataObj* obj=GetObj(nom);
+if (obj == NULL) {
+  cout << "NamedObjMgr::DisplayNT() Error , No such object " << nom << endl; 
+  return;
+}
+if (!myImgApp)  return; 
+
+NTupleInterface * nt = dynamic_cast<NTupleInterface *>(obj);
+if (nt == NULL) {
+// if (typeid(*obj) != typeid(NTupleInterface)) { 
+  string ctyp = typeid(*obj).name();
+  cout << "NamedObjMgr::DisplayNT() Error , Object not an NTuple " << ctyp << endl; 
+  return;
+  }
+
+int wrsid = 0;
+bool fgsr = true;
+dopt = "defline," + dopt;
+int opt = servnobjm->DecodeDispOption(dopt, fgsr);
+
+string n1,r1;
+ParseObjectName(nom, r1, n1);
+
+if ( fg3d && (nmz.length()>0) )  { // Display 3D
+  PINTuple3D* pin = new PINTuple3D(nt, false);
+  pin->SelectXYZ(nmx.c_str(), nmy.c_str(), nmz.c_str());
+  pin->SelectErrBar(erx.c_str(), ery.c_str(), erz.c_str());
+  string titre = nmz + "%" + nmy + "%" + nmz;
+  wrsid = myImgApp->Disp3DDrawer(pin, n1, opt, titre);  
+}
+else {
+  PINTuple* pin = new PINTuple(nt, false);
+  pin->SelectXY(nmx.c_str(), nmy.c_str());
+  pin->SelectErrBar(erx.c_str(), ery.c_str());
+  if ( nmz.length()>0 ) pin->SelectWt(nmz.c_str());
+  string titre = nmy + "%" + nmx;
+  wrsid = myImgApp->DispScDrawer( (PIDrawer*)pin, n1, opt, titre);
+  }
+
+if(wrsid >= 0) {
+  NObjList::iterator it = myObjs->find(nom);
+  if (it == myObjs->end()) return; 
+  (*it).second.wrsid.push_back(wrsid);
+  }
+
+if (fgsr) myImgApp->RestoreGraphicAtt(); 
+return;
+}
+
+/* --Methode-- cmv 13/10/98 : Obsolete mais ne pas virer SVP */
+void NamedObjMgr::DisplayGFD(string& nom, string& numvarx, string& numvary, string& err, string dopt)
+//	Pour le display 2D ou 3D d'un ``GeneralFitData''.
+//|  nom = nom de l'objet GeneralFitData a representer.
+//|  numvarx = numero (nombre entier) de la 1ere variable d'abscisse.
+//|  numvary = numero (nombre entier) de la 2sd variable d'abscisse (3D).
+//|            Pour le display 2D, numvary="" string vide.
+//|  err = qu'elles erreurs faut il representer ?
+//|      - 2D : x y xy   (display y=f(x))
+//|      - 3D : x y z xy xz yz xzy   (display z=f(x,y))
+//|      Ceci n'est suivi que si on a PI_NotDefLineAtt, sinon toutes
+//|      les barres d'erreurs sont representees.
+//|  opt = options generales pour le display.
+{
+AnyDataObj* obj=GetObj(nom);
+if(obj == NULL)
+  {cout << "NamedObjMgr::DisplayGFD() Error , No such object " << nom << endl; 
+   return;}
+if(!myImgApp) return; 
+if(typeid(*obj) != typeid(GeneralFitData))
+  {string ctyp = typeid(*obj).name();
+   cout<<"NamedObjMgr::DisplayGFD() Error , Object not a GeneralFitData "<<ctyp<<endl; 
+   return;}
+
+// Decodage des options classiques
+bool fgsr = true;
+int opt = servnobjm->DecodeDispOption(dopt, fgsr);
+// Decodage des erreurs a representer
+bool errx=false, erry=false, errz=false;
+if(err.length()>0) {
+  for(int i=0;i<err.length();i++)
+    if     (err[i]=='x' || err[i]=='X') errx = true;
+    else if(err[i]=='y' || err[i]=='Y') erry = true;
+    else if(err[i]=='z' || err[i]=='Z') errz = true;
+}
+// Decodage des numeros de variables en abscisse
+ int numvx=-1, numvy=-1;
+ if(numvarx.length()>0) numvx = atoi(numvarx.c_str());
+ if(numvary.length()>0) numvy = atoi(numvary.c_str());
+ 
+ string n1,r1;
+ ParseObjectName(nom, r1, n1);
+
+ int wrsid = 0;
+ if(numvy>=0) {              // display 3D
+  PIGenFitDat3D* pigfd = new PIGenFitDat3D(((GeneralFitData*)obj),false);
+  pigfd->SelectXY(numvx,numvy);
+  pigfd->SelectErrBar(errx,erry,errz);
+  wrsid = myImgApp->Disp3DDrawer(pigfd,n1,opt);  
+} else {                   // display 2D
+  PIGenFitDat* pigfd = new PIGenFitDat(((GeneralFitData*)obj),false);
+  pigfd->SelectX(numvx);
+  pigfd->SelectErrBar(errx,erry);
+  wrsid = myImgApp->DispScDrawer((PIDrawer*)pigfd,n1,opt);
+}
+
+if(wrsid >= 0) {
+  NObjList::iterator it = myObjs->find(nom);
+  if (it == myObjs->end()) return; 
+  (*it).second.wrsid.push_back(wrsid);
+}
+if (fgsr) myImgApp->RestoreGraphicAtt(); 
+return;
+}
+
+/* --Methode-- 
+void NamedObjMgr::DisplayImage(string& nom, string dopt)
+{
+  cout << "NamedObjMgr::DisplayImage() a faire ! " << endl;
+}
+*/
+
+
+
+
+/* --Methode-- */
+void NamedObjMgr::SetGraphicAttributes(string gratt)
+{
+bool fg = false;
+servnobjm->DecodeDispOption(gratt, fg);
+}
+
+/* --Methode-- */
+void NamedObjMgr::SetGraphicWinZone(int nzx, int nzy, bool fcr)
+{
+if (!myImgApp)  return; 
+if (fcr)  myImgApp->CreateGraphWin(nzx, nzy);
+else myImgApp->SetZone(nzx, nzy);
+}
+
+/* --Methode-- */
+void NamedObjMgr::AddWRsId(string & nom, int wrsid)
+{
+if(wrsid != 0) {
+  NObjList::iterator it = myObjs->find(nom);
+  if (it == myObjs->end()) return; 
+  (*it).second.wrsid.push_back(wrsid);
+  }
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::UpdateObjMgrWindow(int did)
+{
+if (!myImgApp)  return;
+(myImgApp->ObjMgrW())->ClearHelpList();
+
+NObjList::iterator it;  
+string cn;
+for(it = myObjs->begin(); it != myObjs->end(); it++) {
+  if ((*it).second.dirid != did) continue;
+  cn = (*it).first.substr(1);
+  cn = cn.substr(cn.find('/')+1) + "  (T= " + typeid(*((*it).second.obj)).name() + ")" ;
+  (myImgApp->ObjMgrW())->AddObj(cn.c_str());
+  }
+}
+
+
+/* Nouvelle-Fonction */
+void RemoveSpacesFromName(string & nom)
+{
+// on supprime les blancs de debut et de fin 
+size_t p = nom.find_first_not_of(" ");
+if(p>nom.length()) { nom = ""; return; }
+nom = nom.substr(p);
+p = nom.find(' ');
+if(p>nom.length()) p=nom.length();
+nom = nom.substr(0, p);
+}
+
+/* Nouvelle-Fonction */
+bool CheckDirName(string & nom)
+{
+RemoveSpacesFromName(nom);
+if (nom.length() < 1)  return(false); 
+if (nom[0] == '/') nom = nom.substr(1) ;
+size_t p = nom.find('/');
+if (p < nom.length()) nom = nom.substr(0,p);
+if (nom.length() < 1)  return(false); 
+return(true);
+}
+
+/* Nouvelle-Fonction */
+int ParseObjectName(string & nom, string & nomrep, string & nomobj)
+{
+RemoveSpacesFromName(nom);
+// Si le nom ne commence pas par un slash, c'est le repertoire courant 
+if (nom[0] != '/') { nomrep = *currDir;  nomobj = nom; }
+else {
+  string xx = nom.substr(1);
+  size_t p = xx.find('/');
+  if (p < xx.length())  { 
+    nomrep = xx.substr(0,p); 
+    nomobj = xx.substr(p+1);
+    }
+  else {
+    nomrep = xx;
+    nomobj = "";
+    }
+  }
+int rc = 0;
+NObjDirList::iterator it = myDirs->find(nomrep);
+if (it != myDirs->end())  rc = (*it).second.id;
+return(rc);
+}
+
Index: /tags/V_LaSilla191199/SophyaPI/PIext/nobjmgr.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/nobjmgr.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/nobjmgr.h	(revision 464)
@@ -0,0 +1,92 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Classe de gestion d objets nommes pour piapp
+// Reza      Aout 97 , Juillet,Aout 98
+// CEA-DAPNIA      LAL-IN2P3/CNRS
+
+#ifndef NOBJMGR_H_SEEN
+#define NOBJMGR_H_SEEN
+
+#include "machdefs.h"
+#include "anydataobj.h"
+#include "dlftypes.h"
+
+#include <string>
+#include <vector>
+
+class NObjMgrAdapter;
+class PIStdImgApp;
+class Services2NObjMgr;
+
+class NamedObjMgr {
+public:
+// Constructeur et destructeur
+			NamedObjMgr();
+  virtual		~NamedObjMgr();
+
+  virtual void 		SetImgApp(PIStdImgApp* app);
+  virtual void 		SetVerbose(bool fg=false);
+
+
+// Gestion des repertoires
+  virtual bool		CreateDir(string & dirname);
+  virtual bool		DeleteDir(string & dirname);
+  virtual void		LockDir(string & dirname); 
+  virtual void		UnlockDir(string & dirname);
+  virtual void		SetKeepOldDirAtt(string & dirname, bool keepold=false); 
+  virtual bool		SetCurrentDir(string & dirname);
+  virtual void		GetCurrentDir(string & dirname);
+  virtual void		ListDirs(string & patt);
+  virtual void		GetDirList(string & patt, vector<string>& );
+  virtual void		CleanDir(string & dirname);
+
+//  Pour ajouter, supprimer et acceder aux objets 
+  virtual bool		AddObj(AnyDataObj* obj, string & nom, bool crd=false);
+  virtual bool		RenameObj(string & nom, string& nomnew);
+  virtual bool		CopyObj(string & nom, string& nomcp); 
+  virtual bool          DelObj(string & nom, bool fgd=true);
+  virtual void		DelObjects(string & patt, bool fgd=true); 
+  virtual bool          DelObj_Id(int oid);
+  virtual AnyDataObj*	GetObj(string & nom);
+  virtual void          ListObjs(string & patt);  		
+  virtual void          GetObjList(string & patt, vector<string>& );  		
+
+//  Lecture et sauvegarde des objets sur fichier
+  virtual void		ReadObj(PInPersist& s, int num=-1);
+  virtual void		ReadObj(string const & nomppf, string & nobj);
+  virtual void		ReadAll(string const & nomppf);
+  virtual void		ReadFits(string const & flnm, string & nobj);
+  virtual void          SaveObj(string & nom, POutPersist& s, bool keeppath=false);
+  virtual void          SaveObjects(string & patt, string const& nomppf);
+  virtual void          SaveAll(string const& nomppf);
+  virtual void          SaveFits(string & nom, string const & flnm);
+
+// Info sur les objets 
+  virtual void          PrintObj(string & nom);
+
+//  Affichage des objets 
+  virtual void          DisplayObj(string & nom, string dopt="");
+  virtual void          DisplayImage(string & nom, string dopt="");
+  virtual void          DisplaySurf3D(string & nom, string dopt="");
+  virtual void          DisplayNT(string & nom, string& nmx, string& nmy, string& nmz,  
+                                  string& erx, string& ery, string& erz, 
+                                  string dopt="", bool fg3d=false);
+  virtual void          DisplayGFD(string & nom, string& numvarx, string& numvary, 
+                                   string& err, string dopt="");
+
+  virtual void		SetGraphicAttributes(string gratt="");
+  virtual void		SetGraphicWinZone(int nzx, int nzy, bool fcr=false);
+
+// Acces a l'adaptateur
+  virtual NObjMgrAdapter*	GetObjAdapter(string & nom);
+
+// Acces au PIApplication et a la classe de service 
+  virtual PIStdImgApp*		GetImgApp();
+  virtual Services2NObjMgr* 	GetServiceObj();
+
+  virtual void		AddWRsId(string & nom, int wrsid);
+// Pour utilisation par ObjMgrWind
+  virtual void		UpdateObjMgrWindow(int did);
+};
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PIext/nomgadapter.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/nomgadapter.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/nomgadapter.cc	(revision 464)
@@ -0,0 +1,92 @@
+#include "machdefs.h"
+#include <stdlib.h>
+#include <typeinfo>
+#include <iostream.h>
+#include <string>
+#include "nomgadapter.h"
+
+/* --Methode-- */
+NObjMgrAdapter::NObjMgrAdapter(AnyDataObj* o)
+{
+mObj = o;
+}
+
+/* --Methode-- */
+NObjMgrAdapter::~NObjMgrAdapter()
+{
+}
+
+/* --Methode-- */
+NObjMgrAdapter* NObjMgrAdapter::Clone(AnyDataObj* o)
+{
+return(new NObjMgrAdapter(o));
+}
+
+/* --Methode-- */
+AnyDataObj* NObjMgrAdapter::GetDataObj()
+{
+return(mObj);
+}
+
+/* --Methode-- */
+AnyDataObj* NObjMgrAdapter::GetCopyObj()
+{
+string s = typeid(*mObj).name();
+cout << "NObjMgrAdapter::GetCopyObj() - Error : Not supported for " << s << endl;
+return(NULL);
+}
+
+/* --Methode-- */
+void NObjMgrAdapter::ReadFits(string const & )
+{
+string s = typeid(*mObj).name();
+cout << "NObjMgrAdapter::ReadFits() - Error : Not supported for " << s << endl;
+}
+
+/* --Methode-- */
+void NObjMgrAdapter::SaveFits(string const & )
+{
+string s = typeid(*mObj).name();
+cout << "NObjMgrAdapter::SaveFits() - Error : Not supported for " << s << endl;
+}
+
+/* --Methode-- */
+void NObjMgrAdapter::SavePPF(POutPersist&, string const & )
+{
+string s = typeid(*mObj).name();
+cout << "NObjMgrAdapter::SavePPF() - Error : Not supported for " << s << endl;
+}
+
+/* --Methode-- */
+void NObjMgrAdapter::Print(ostream& )
+{
+string s = typeid(*mObj).name();
+cout << "NObjMgrAdapter::Print() - Error : Not supported for " << s << endl;
+}
+
+/* --Methode-- */
+PIDrawer* NObjMgrAdapter::GetDrawer(string &)
+{
+return(NULL);
+}
+
+/* --Methode-- */
+P2DArrayAdapter* NObjMgrAdapter::Get2DArray(string &)
+{
+return(NULL);
+}
+
+/* --Methode-- */
+NTupleInterface* NObjMgrAdapter::GetNTupleInterface(bool& adel)
+{
+string s = typeid(*mObj).name();
+cout << "NObjMgrAdapter::GetNTupleInterface() - Error : Not supported for " << s << endl;
+adel = false;
+return(NULL);
+}
+
+
+
+
+
+
Index: /tags/V_LaSilla191199/SophyaPI/PIext/nomgadapter.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/nomgadapter.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/nomgadapter.h	(revision 464)
@@ -0,0 +1,46 @@
+// This may look like C code, but it is really -*- C++ -*-
+//  Adaptateur pour objets gere par   NamedObjMgr (piapp)
+//                                    Reza 05/99
+//  LAL-IN2P3/CNRS               CEA-DAPNIA      
+
+#ifndef NOMGADAPTER_H_SEEN
+#define NOMGADAPTER_H_SEEN
+
+#include "machdefs.h"
+#include "ppersist.h"
+#include "anydataobj.h"
+#include "pidrawer.h"
+#include "parradapter.h"
+#include "ntupintf.h"
+
+
+// Classe d'adaptateur d'objets de donnees pour la gestion d'objets
+// nommes (NamedObjMgr) de piapp
+
+class NObjMgrAdapter {
+public:
+				NObjMgrAdapter(AnyDataObj* o);
+  virtual			~NObjMgrAdapter();
+
+  virtual NObjMgrAdapter*	Clone(AnyDataObj* o);
+
+  virtual AnyDataObj*		GetDataObj();
+  virtual AnyDataObj*		GetCopyObj();
+
+  virtual void			ReadFits(string const & flnm);
+  virtual void			SaveFits(string const & flnm);
+  virtual void			SavePPF(POutPersist& s, string const & nom);
+
+  virtual void			Print(ostream& os);
+  virtual PIDrawer*		GetDrawer(string& dopt);
+  virtual P2DArrayAdapter*	Get2DArray(string& dopt);
+
+// NTupleInterface* nti = GetNTupleInterface(adel)
+// Retourne un objet de type NTupleInterface (nti), ainsi que adel
+// si adel == true, le programme appelant doit faire delete de nti 
+  virtual NTupleInterface*	GetNTupleInterface(bool& adel);
+protected:
+  AnyDataObj* mObj;
+};
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PIext/nomgfdadapter.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/nomgfdadapter.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/nomgfdadapter.cc	(revision 464)
@@ -0,0 +1,65 @@
+#include "machdefs.h"
+#include <stdlib.h>
+#include <typeinfo>
+#include <iostream.h>
+#include <string>
+
+#include "nomgfdadapter.h"
+#include "pipodrw.h"
+
+//-------------------------------------------------------------------------
+// Class Adaptateur d'objet (Pour NamedObjMgr) d'objet GeneralFitData
+//-------------------------------------------------------------------------
+
+/* --Methode-- */
+NOMAdapter_GeneralFitData::NOMAdapter_GeneralFitData(GeneralFitData* o)
+  : NObjMgrAdapter(o)
+{
+mG = o;
+}
+
+/* --Methode-- */
+NOMAdapter_GeneralFitData::~NOMAdapter_GeneralFitData()
+{
+}
+
+/* --Methode-- */
+NObjMgrAdapter* NOMAdapter_GeneralFitData::Clone(AnyDataObj* o)
+{
+GeneralFitData* g = dynamic_cast<GeneralFitData *>(o);
+if (g) return ( new NOMAdapter_GeneralFitData(g) );
+return ( new NObjMgrAdapter(o) );
+}
+
+/* --Methode-- */
+AnyDataObj* NOMAdapter_GeneralFitData::GetCopyObj()
+{
+return( new GeneralFitData(*mG) );
+}
+
+/* --Methode-- */
+void NOMAdapter_GeneralFitData::SavePPF(POutPersist& pos, string const & nom)
+{
+#ifdef SANS_EVOLPLANCK
+// PEIDA-EROS L'histo est lui-meme PPersist
+string tag = nom;  // A cause de const
+mG->Write(pos,0,tag);
+#else
+string s = typeid(*mObj).name();
+cout<<"NOMAdapter_GeneralFitData::SavePPF() - Error : Not supported for "<<s<<endl;
+#endif
+}
+
+/* --Methode-- */
+void NOMAdapter_GeneralFitData::Print(ostream& os)
+{
+os << *(mG);
+}
+
+/* --Methode-- */
+NTupleInterface* NOMAdapter_GeneralFitData::GetNTupleInterface(bool& adel)
+{
+adel = false;
+return(mG);
+}
+
Index: /tags/V_LaSilla191199/SophyaPI/PIext/nomgfdadapter.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/nomgfdadapter.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/nomgfdadapter.h	(revision 464)
@@ -0,0 +1,34 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Adaptateur d objets (pour NamedObjMgr) pour GeneralFitData
+//                                    cmv 27/7/99
+//  LAL-IN2P3/CNRS               CEA-DAPNIA     
+ 
+#ifndef NOMGFDADAPTER_H_SEEN
+#define NOMGFDADAPTER_H_SEEN
+
+#include "nomgadapter.h"
+#include "generaldata.h"
+
+//-------------------------------------------------------------------------
+// Class Adaptateur d'objet (Pour NamedObjMgr) d'objet GeneralFitData 
+//-------------------------------------------------------------------------
+
+class NOMAdapter_GeneralFitData : public NObjMgrAdapter {
+public:
+			   NOMAdapter_GeneralFitData(GeneralFitData* o = NULL);
+  virtual		   ~NOMAdapter_GeneralFitData();
+
+  virtual NObjMgrAdapter*  Clone(AnyDataObj* o);
+  virtual AnyDataObj*      GetCopyObj();
+
+  virtual void		   SavePPF(POutPersist& s, string const & nom);
+
+  virtual void		   Print(ostream& os);
+  virtual NTupleInterface* GetNTupleInterface(bool& adel);
+
+protected:
+  GeneralFitData* mG;
+};
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PIext/nomhistadapter.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/nomhistadapter.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/nomhistadapter.cc	(revision 464)
@@ -0,0 +1,370 @@
+#include "machdefs.h"
+#include <stdlib.h>
+#include <typeinfo>
+#include <iostream.h>
+#include <string>
+
+#include "nomhistadapter.h"
+#include "pihisto.h"
+#include "pihisto2d.h"
+#include "pipodrw.h"
+
+//-------------------------------------------------------------------------
+// Class Adaptateur d'objet (Pour NamedObjMgr) d'objet Histo / HProf
+//-------------------------------------------------------------------------
+
+/* --Methode-- */
+NOMAdapter_Histo::NOMAdapter_Histo(Histo* o)
+  : NObjMgrAdapter(o)
+{
+mHis = o;
+}
+
+/* --Methode-- */
+NOMAdapter_Histo::~NOMAdapter_Histo()
+{
+}
+
+/* --Methode-- */
+NObjMgrAdapter* NOMAdapter_Histo::Clone(AnyDataObj* o)
+{
+Histo* h = dynamic_cast<Histo *>(o);
+if (h) return ( new NOMAdapter_Histo(h) );
+return ( new NObjMgrAdapter(o) );
+}
+
+/* --Methode-- */
+AnyDataObj* NOMAdapter_Histo::GetCopyObj()
+{
+HProf * hp = dynamic_cast<HProf *>(mHis);
+if (hp == NULL)   return( new Histo(*mHis) );
+else return( new HProf(*hp) );
+}
+
+/* --Methode-- */
+void NOMAdapter_Histo::SavePPF(POutPersist& pos, string const & nom)
+{
+#ifdef SANS_EVOLPLANCK
+// PEIDA-EROS L'histo est lui-meme PPersist
+string tag = nom;  // A cause de const
+mHis->Write(pos,0,tag);
+#else
+string s = typeid(*mObj).name();
+cout << "NOMAdapter_Histo::SavePPF() - Error : Not supported for " << s << endl;
+#endif
+}
+
+/* --Methode-- */
+void NOMAdapter_Histo::Print(ostream& os)
+{
+mHis->Print(60);
+}
+
+/* --Methode-- */
+PIDrawer* NOMAdapter_Histo::GetDrawer(string & dopt)
+{
+if (typeid(*mHis) == typeid(HProf))  dopt = "fcirclemarker5," + dopt;
+else dopt = "thinline," + dopt;
+return( new PIHisto(mHis, false) );
+}
+
+/* --Methode-- */
+NTupleInterface* NOMAdapter_Histo::GetNTupleInterface(bool& adel)
+{
+adel = true;
+return( new NTupInt_Histo(mHis) );
+}
+
+
+// -------------------------------------------------------------
+
+/* --Methode-- */
+NTupInt_Histo::NTupInt_Histo(Histo* h)
+{
+mHis = h;
+}
+
+/* --Methode-- */
+NTupInt_Histo::~NTupInt_Histo()
+{
+}
+
+/* --Methode-- */
+uint_4 NTupInt_Histo::NbLines() const 
+{
+return(mHis->NBins());
+}
+
+/* --Methode-- */
+uint_4 NTupInt_Histo::NbColumns() const
+{
+return(4);
+}
+
+/* --Methode-- */
+r_8* NTupInt_Histo::GetLineD(int k) const
+{
+int i;
+if ((k < 0) || (k >= mHis->NBins())) 
+    for(i=0; i<4; i++)  mRet[i] = 0.;
+else { 
+  mRet[0] = k;  mRet[1] = mHis->BinCenter(k);
+  mRet[2] = (*mHis)(k); mRet[3] = mHis->Error(k); 
+  }
+return(mRet);
+}
+
+/* --Methode-- */
+string NTupInt_Histo::VarList_C(const char* nx) const
+{
+string nomx;
+if (nx) nomx = nx;
+else nomx = "_xh_";
+string vardec = "double i,x,val,err; \n";
+vardec += "i = " + nomx + "[0];  x = " + nomx + "[1]; \n";
+vardec += "val = " + nomx + "[2];  err = " + nomx + "[3]; \n";
+return(vardec);
+}
+
+//-------------------------------------------------------------------------
+// Class Adaptateur d'objet (Pour NamedObjMgr) d'objet Histo2D
+//-------------------------------------------------------------------------
+
+
+/* --Methode-- */
+NOMAdapter_Histo2D::NOMAdapter_Histo2D(Histo2D* o)
+  : NObjMgrAdapter(o)
+{
+mHis = o;
+}
+
+/* --Methode-- */
+NOMAdapter_Histo2D::~NOMAdapter_Histo2D()
+{
+}
+
+/* --Methode-- */
+NObjMgrAdapter* NOMAdapter_Histo2D::Clone(AnyDataObj* o)
+{
+Histo2D* h = dynamic_cast<Histo2D *>(o);
+if (h) return ( new NOMAdapter_Histo2D(h) );
+return ( new NObjMgrAdapter(o) );
+}
+
+/* --Methode-- */
+AnyDataObj* NOMAdapter_Histo2D::GetCopyObj()
+{
+return ( new Histo2D(*mHis) );
+}
+
+/* --Methode-- */
+void NOMAdapter_Histo2D::SavePPF(POutPersist& pos, string const & nom)
+{
+#ifdef SANS_EVOLPLANCK
+// PEIDA-EROS L'histo est lui-meme PPersist
+string tag = nom;  // A cause de const
+mHis->Write(pos,0,tag);
+#else
+string s = typeid(*mObj).name();
+cout << "NOMAdapter_Histo2D::SavePPF() - Error : Not supported for " << s << endl;
+#endif
+}
+
+/* --Methode-- */
+void NOMAdapter_Histo2D::Print(ostream& os)
+{
+mHis->Print();
+}
+
+/* --Methode-- */
+PIDrawer* NOMAdapter_Histo2D::GetDrawer(string & dopt)
+{
+dopt = "thinline," + dopt;
+return( new PIHisto2D(mHis, false) );
+}
+
+/* --Methode-- */
+P2DArrayAdapter* NOMAdapter_Histo2D::Get2DArray(string & dopt)
+{
+return (new POH2DAdapter(mHis, false) );
+}
+
+/* --Methode-- */
+NTupleInterface* NOMAdapter_Histo2D::GetNTupleInterface(bool& adel)
+{
+adel = true;
+return( new NTupInt_Histo2D(mHis) );
+}
+
+
+
+// -------------------------------------------------------------
+
+/* --Methode-- */
+NTupInt_Histo2D::NTupInt_Histo2D(Histo2D* h)
+{
+mHis = h;
+}
+
+/* --Methode-- */
+NTupInt_Histo2D::~NTupInt_Histo2D()
+{
+}
+
+/* --Methode-- */
+uint_4 NTupInt_Histo2D::NbLines() const 
+{
+return(mHis->NBinX()*mHis->NBinY());
+}
+
+/* --Methode-- */
+uint_4 NTupInt_Histo2D::NbColumns() const 
+{
+return(6);
+}
+
+/* --Methode-- */
+r_8* NTupInt_Histo2D::GetLineD(int n) const
+{
+int i,j;
+float f2,f3;
+if ((n < 0) || (n >= mHis->NBinX()*mHis->NBinY())) 
+    for(i=0; i<6; i++)  mRet[i] = 0.;
+else { 
+  i = n%mHis->NBinX();  j = n/mHis->NBinX(); 
+  mRet[0] = i;  mRet[1] = j;
+  mHis->BinCenter(i,j,f2,f3);
+  mRet[2] = f2;  mRet[3] = f3;  
+  mRet[4] =  (*mHis)(i,j);  mRet[5] = mHis->Error(i, j);
+  }
+return(mRet);
+}
+
+/* --Methode-- */
+string NTupInt_Histo2D::VarList_C(const char* nx) const
+{
+string nomx;
+if (nx) nomx = nx;
+else nomx = "_xh_";
+string vardec = "double i,j,x,y,val,err; \n";
+vardec += "i = " + nomx + "[0];  j = " + nomx + "[1]; \n";
+vardec += "x = " + nomx + "[2];  y = " + nomx + "[3]; \n";
+vardec += "val = " + nomx + "[4];  err = " + nomx + "[5]; \n";
+return(vardec);
+}
+
+
+
+//-------------------------------------------------------------------------
+// Class Adaptateur d'objet (Pour NamedObjMgr) d'objet NTuple
+//-------------------------------------------------------------------------
+
+/* --Methode-- */
+NOMAdapter_NTuple::NOMAdapter_NTuple(NTuple* o)
+  : NObjMgrAdapter(o)
+{
+mNt = o;
+}
+
+/* --Methode-- */
+NOMAdapter_NTuple::~NOMAdapter_NTuple()
+{
+}
+
+/* --Methode-- */
+NObjMgrAdapter* NOMAdapter_NTuple::Clone(AnyDataObj* o)
+{
+NTuple* nt = dynamic_cast<NTuple *>(o);
+if (nt) return ( new NOMAdapter_NTuple(nt) );
+return ( new NObjMgrAdapter(o) );
+}
+
+/* --Methode-- */
+AnyDataObj* NOMAdapter_NTuple::GetCopyObj()
+{
+return ( new NTuple(*mNt) );
+}
+
+/* --Methode-- */
+void NOMAdapter_NTuple::SavePPF(POutPersist& pos, string const & nom)
+{
+#ifdef SANS_EVOLPLANCK
+// PEIDA-EROS L'histo est lui-meme PPersist
+string tag = nom;  // A cause de const
+mNt->Write(pos,0,tag);
+#else
+string s = typeid(*mObj).name();
+cout << "NOMAdapter_NTuple::SavePPF() - Error : Not supported for " << s << endl;
+#endif
+}
+
+/* --Methode-- */
+void NOMAdapter_NTuple::Print(ostream& os)
+{
+os << mNt->Info();
+os << *(mNt);
+}
+
+
+/* --Methode-- */
+NTupleInterface* NOMAdapter_NTuple::GetNTupleInterface(bool& adel)
+{
+adel = false;
+return(mNt);
+// return( new NTupInt_NTuple(mNt) );
+}
+
+//-------------------------------------------------------------------------
+// Class Adaptateur d'objet (Pour NamedObjMgr) d'objet XNTuple
+//-------------------------------------------------------------------------
+
+/* --Methode-- */
+NOMAdapter_XNTuple::NOMAdapter_XNTuple(XNTuple* o)
+  : NObjMgrAdapter(o)
+{
+mNt = o;
+}
+
+/* --Methode-- */
+NOMAdapter_XNTuple::~NOMAdapter_XNTuple()
+{
+}
+
+/* --Methode-- */
+NObjMgrAdapter* NOMAdapter_XNTuple::Clone(AnyDataObj* o)
+{
+XNTuple* nt = dynamic_cast<XNTuple *>(o);
+if (nt) return ( new NOMAdapter_XNTuple(nt) );
+return ( new NObjMgrAdapter(o) );
+}
+
+
+/* --Methode-- */
+void NOMAdapter_XNTuple::SavePPF(POutPersist& pos, string const & nom)
+{
+#ifdef SANS_EVOLPLANCK
+// PEIDA-EROS L'histo est lui-meme PPersist
+string tag = nom;  // A cause de const
+mNt->Write(pos,0,tag);
+#else
+string s = typeid(*mObj).name();
+cout << "NOMAdapter_XNTuple::SavePPF() - Error : Not supported for " << s << endl;
+#endif
+}
+
+/* --Methode-- */
+void NOMAdapter_XNTuple::Print(ostream& os)
+{
+// os << mNt->Info();
+mNt->Show(os);
+}
+
+
+/* --Methode-- */
+NTupleInterface* NOMAdapter_XNTuple::GetNTupleInterface(bool& adel)
+{
+adel = false;
+return(mNt);
+}
+
+
Index: /tags/V_LaSilla191199/SophyaPI/PIext/nomhistadapter.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/nomhistadapter.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/nomhistadapter.h	(revision 464)
@@ -0,0 +1,141 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Adaptateur d objets (pour NamedObjMgr) pour Histos/NTuple
+//                                    Reza 05/99
+//  LAL-IN2P3/CNRS               CEA-DAPNIA     
+ 
+#ifndef NOMHISTADAPTER_H_SEEN
+#define NOMHISTADAPTER_H_SEEN
+
+#include "nomgadapter.h"
+#include "histos.h"
+#include "histos2.h"
+#include "hisprof.h"
+#include "ntuple.h"
+#include "xntuple.h"
+
+//-------------------------------------------------------------------------
+// Class Adaptateur d'objet (Pour NamedObjMgr) d'objet Histo / HProf
+//-------------------------------------------------------------------------
+
+class NOMAdapter_Histo : public NObjMgrAdapter {
+public:
+				NOMAdapter_Histo(Histo* h = NULL);
+  virtual			~NOMAdapter_Histo();
+
+  virtual NObjMgrAdapter*	Clone(AnyDataObj* o);
+  virtual AnyDataObj*		GetCopyObj();
+
+  //  virtual void			ReadFits(string const & flnm);
+  //  virtual void			SaveFits(string const & flnm);
+  virtual void			SavePPF(POutPersist& s, string const & nom);
+
+  virtual void			Print(ostream& os);
+  virtual PIDrawer*		GetDrawer(string& dopt);
+  virtual NTupleInterface*	GetNTupleInterface(bool& adel);
+
+protected:
+  Histo* mHis;
+};
+
+// Class Interface NTuple pour Histo / HProf
+class NTupInt_Histo : public NTupleInterface {
+public:
+			NTupInt_Histo(Histo* h);
+  virtual		~NTupInt_Histo();
+  virtual uint_4        NbLines() const ;
+  virtual uint_4        NbColumns() const ;
+  virtual r_8 *         GetLineD(int n) const ;
+  virtual string        VarList_C(const char* nomx=NULL) const ;
+protected:
+  Histo* mHis;
+  mutable r_8 mRet[4];
+};
+
+//-------------------------------------------------------------------------
+// Class Adaptateur d'objet (Pour NamedObjMgr) d'objet Histo2D
+//-------------------------------------------------------------------------
+
+class NOMAdapter_Histo2D : public NObjMgrAdapter {
+public:
+				NOMAdapter_Histo2D(Histo2D* h = NULL);
+  virtual			~NOMAdapter_Histo2D();
+
+  virtual NObjMgrAdapter*	Clone(AnyDataObj* o);
+  virtual AnyDataObj*		GetCopyObj();
+
+  //  virtual void			ReadFits(string const & flnm);
+  //  virtual void			SaveFits(string const & flnm);
+  virtual void			SavePPF(POutPersist& s, string const & nom);
+
+  virtual void			Print(ostream& os);
+  virtual PIDrawer*		GetDrawer(string& dopt);
+  virtual P2DArrayAdapter*      Get2DArray(string& dopt);
+  virtual NTupleInterface*	GetNTupleInterface(bool& adel);
+
+protected:
+  Histo2D* mHis;
+};
+
+// Class Interface NTuple pour Histo2D
+class NTupInt_Histo2D : public NTupleInterface {
+public:
+			NTupInt_Histo2D(Histo2D* h);
+  virtual		~NTupInt_Histo2D();
+  virtual uint_4        NbLines() const ;
+  virtual uint_4        NbColumns() const ;
+  virtual r_8 *         GetLineD(int n) const ;
+  virtual string        VarList_C(const char* nomx=NULL) const ;
+protected:
+  Histo2D* mHis;
+  mutable r_8 mRet[6];
+};
+
+
+//-------------------------------------------------------------------------
+// Class Adaptateur d'objet (Pour NamedObjMgr) d'objet NTuple 
+//-------------------------------------------------------------------------
+
+class NOMAdapter_NTuple : public NObjMgrAdapter {
+public:
+				NOMAdapter_NTuple(NTuple* nt = NULL);
+  virtual			~NOMAdapter_NTuple();
+
+  virtual NObjMgrAdapter*	Clone(AnyDataObj* o);
+  virtual AnyDataObj*		GetCopyObj();
+
+  //  virtual void			ReadFits(string const & flnm);
+  //  virtual void			SaveFits(string const & flnm);
+  virtual void			SavePPF(POutPersist& s, string const & nom);
+
+  virtual void			Print(ostream& os);
+  virtual NTupleInterface*	GetNTupleInterface(bool& adel);
+
+protected:
+  NTuple* mNt;
+};
+
+//-------------------------------------------------------------------------
+// Class Adaptateur d'objet (Pour NamedObjMgr) d'objet XNTuple 
+//-------------------------------------------------------------------------
+
+class NOMAdapter_XNTuple : public NObjMgrAdapter {
+public:
+				NOMAdapter_XNTuple(XNTuple* nt = NULL);
+  virtual			~NOMAdapter_XNTuple();
+
+  virtual NObjMgrAdapter*	Clone(AnyDataObj* o);
+
+  //  virtual void			ReadFits(string const & flnm);
+  //  virtual void			SaveFits(string const & flnm);
+  virtual void			SavePPF(POutPersist& s, string const & nom);
+
+  virtual void			Print(ostream& os);
+  virtual NTupleInterface*	GetNTupleInterface(bool& adel);
+
+protected:
+  XNTuple* mNt;
+};
+
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PIext/nomimagadapter.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/nomimagadapter.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/nomimagadapter.cc	(revision 464)
@@ -0,0 +1,176 @@
+#include "machdefs.h"
+#include <stdlib.h>
+#include <typeinfo>
+#include <iostream.h>
+#include <string>
+
+#include "nomimagadapter.h"
+#include "fitsimage.h"
+#include "pimgadapter.h"
+
+
+//---------------------------------------------------------------
+// Class Adaptateur d'objet (Pour NamedObjMgr) d'objet Image<T> 
+//---------------------------------------------------------------
+
+
+/* --Methode-- */
+template <class T>
+NOMAdapter_Image<T>::NOMAdapter_Image(Image<T> * o)
+  : NObjMgrAdapter(o)
+{
+mImg = o;
+}
+
+/* --Methode-- */
+template <class T>
+NOMAdapter_Image<T>::~NOMAdapter_Image()
+{
+}
+
+/* --Methode-- */
+template <class T>
+NObjMgrAdapter* NOMAdapter_Image<T>::Clone(AnyDataObj* o)
+{
+Image<T>* im = dynamic_cast<Image<T> *>(o);
+if (im) return ( new NOMAdapter_Image<T>(im) );
+return ( new NObjMgrAdapter(o) );
+}
+
+/* --Methode-- */
+template <class T>
+AnyDataObj* NOMAdapter_Image<T>::GetCopyObj()
+{
+FitsImage<T> * fima = dynamic_cast<FitsImage<T> *>(mImg);
+if (fima == NULL)   return( new Image<T>(*mImg ) );
+else return ( new FitsImage<T>(*fima) );
+}
+
+/* --Methode-- */
+template <class T>
+void NOMAdapter_Image<T>::SaveFits(string const & flnm)
+{
+#ifdef SANS_EVOLPLANCK
+FitsImage<T> fim(*mImg, 1);
+fim.Save(flnm);
+#else
+cout << "NOMAdapter_Image<T>::SaveFits() - Error : Not supported for " << s << endl;
+#endif
+}
+
+/* --Methode-- */
+template <class T>
+void NOMAdapter_Image<T>::SavePPF(POutPersist& pos, string const & nom)
+{
+#ifdef SANS_EVOLPLANCK
+// PEIDA-EROS L'histo est lui-meme PPersist
+string tag = nom;  // A cause de const
+mImg->Write(pos,0,tag);
+#else
+string s = typeid(*mObj).name();
+cout << "NOMAdapter_Image<T>::SavePPF() - Error : Not supported for " << s << endl;
+#endif
+}
+
+/* --Methode-- */
+template <class T>
+void NOMAdapter_Image<T>::Print(ostream& os)
+{
+mImg->Print(os);
+}
+
+
+/* --Methode-- */
+template <class T>
+P2DArrayAdapter* NOMAdapter_Image<T>::Get2DArray(string &)
+{
+return ( new ImageAdapter<T>(mImg, false) );
+}
+
+/* --Methode-- */
+template <class T>
+NTupleInterface* NOMAdapter_Image<T>::GetNTupleInterface(bool& adel)
+{
+adel = true;
+return( new NTupInt_Image<T>(mImg) );
+}
+
+
+
+// -------------------------------------------------------------
+
+/* --Methode-- */
+template <class T>
+NTupInt_Image<T>::NTupInt_Image(Image<T>* m)
+{
+mImg = m;
+}
+
+/* --Methode-- */
+template <class T>
+NTupInt_Image<T>::~NTupInt_Image()
+{
+}
+
+/* --Methode-- */
+template <class T>
+uint_4 NTupInt_Image<T>::NbLines() const 
+{
+return( mImg->XSize() * mImg->YSize() );
+}
+
+/* --Methode-- */
+template <class T>
+uint_4 NTupInt_Image<T>::NbColumns() const 
+{
+return(3);
+}
+
+/* --Methode-- */
+template <class T>
+r_8* NTupInt_Image<T>::GetLineD(int n) const 
+{
+int i,j;
+if ((n < 0) || (n >= mImg->XSize() * mImg->YSize() )) 
+    for(i=0; i<3; i++)  mRet[i] = 0.;
+else { 
+  i = n%mImg->XSize();  j = n/mImg->XSize(); 
+  mRet[0] = i;  mRet[1] = j;  mRet[2] = (*mImg)(i,j);
+  }
+return(mRet);
+}
+
+/* --Methode-- */
+template <class T>
+string NTupInt_Image<T>::VarList_C(const char* nx) const 
+{
+string nomx;
+if (nx) nomx = nx;
+else nomx = "_xh_";
+string vardec = "double x,y,pix,i,j,val; \n";
+vardec += "x = i = " + nomx + "[0]; y = j = " + nomx + "[1];  pix = val = " + nomx + "[2]; \n";
+return(vardec);
+}
+
+#ifdef __CXX_PRAGMA_TEMPLATES__
+#pragma define_template NOMAdapter_Image<uint_2>
+#pragma define_template NOMAdapter_Image<int_2>
+#pragma define_template NOMAdapter_Image<int_4>
+#pragma define_template NOMAdapter_Image<r_4>
+#pragma define_template NTupInt_Image<uint_2>
+#pragma define_template NTupInt_Image<int_2>
+#pragma define_template NTupInt_Image<int_4>
+#pragma define_template NTupInt_Image<r_4>
+#endif
+#if defined(__ANSI_TEMPLATES__) || defined(__GNU_TEMPLATES__)
+template class NOMAdapter_Image<uint_2>;
+template class NOMAdapter_Image<int_2>;
+template class NOMAdapter_Image<int_4>;
+template class NOMAdapter_Image<r_4>;
+template class NTupInt_Image<uint_2>;
+template class NTupInt_Image<int_2>;
+template class NTupInt_Image<int_4>;
+template class NTupInt_Image<r_4>;
+#endif
+
+
Index: /tags/V_LaSilla191199/SophyaPI/PIext/nomimagadapter.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/nomimagadapter.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/nomimagadapter.h	(revision 464)
@@ -0,0 +1,56 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Adaptateur d objets (pour NamedObjMgr) pour Histos/NTuple
+//                                    Reza 05/99
+//  LAL-IN2P3/CNRS               CEA-DAPNIA     
+ 
+#ifndef NOMIMAGADAPTER_H_SEEN
+#define NOMIMAGADAPTER_H_SEEN
+
+#include "nomgadapter.h"
+#include "cimage.h"
+
+
+
+//---------------------------------------------------------------
+// Class Adaptateur d'objet (Pour NamedObjMgr) d'objet  Image<T> 
+//---------------------------------------------------------------
+
+template <class T>
+class NOMAdapter_Image : public NObjMgrAdapter {
+public:
+				NOMAdapter_Image(Image<T> * o = NULL);
+  virtual			~NOMAdapter_Image();
+
+  virtual NObjMgrAdapter*	Clone(AnyDataObj* o);
+  virtual AnyDataObj*		GetCopyObj();
+
+  //  virtual void			ReadFits(string const & flnm);
+  virtual void			SaveFits(string const & flnm);
+  virtual void			SavePPF(POutPersist& s, string const & nom);
+
+  virtual void			Print(ostream& os);
+  virtual P2DArrayAdapter*	Get2DArray(string& dopt);
+  virtual NTupleInterface*	GetNTupleInterface(bool& adel);
+
+protected:
+  Image<T> * mImg;
+};
+
+// Class Interface NTuple pour Image
+
+template <class T>
+class NTupInt_Image : public NTupleInterface {
+public:
+			NTupInt_Image(Image<T> * m);
+  virtual		~NTupInt_Image();
+  virtual uint_4        NbLines() const ;
+  virtual uint_4        NbColumns() const ;
+  virtual r_8 *         GetLineD(int n) const ;
+  virtual string        VarList_C(const char* nomx=NULL) const ;
+protected:
+  Image<T> * mImg;
+  mutable r_8 mRet[3];
+};
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PIext/nommatvecadapter.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/nommatvecadapter.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/nommatvecadapter.cc	(revision 464)
@@ -0,0 +1,238 @@
+#include "machdefs.h"
+#include <stdlib.h>
+#include <typeinfo>
+#include <iostream.h>
+#include <string>
+
+#include "nommatvecadapter.h"
+#include "piscdrawwdg.h"
+#include "pipodrw.h"
+
+//---------------------------------------------------------------
+// Class Adaptateur d'objet (Pour NamedObjMgr) d'objet Vector 
+//---------------------------------------------------------------
+
+/* --Methode-- */
+NOMAdapter_Vector::NOMAdapter_Vector(Vector* o)
+  : NObjMgrAdapter(o)
+{
+mVec = o;
+}
+
+/* --Methode-- */
+NOMAdapter_Vector::~NOMAdapter_Vector()
+{
+}
+
+/* --Methode-- */
+NObjMgrAdapter* NOMAdapter_Vector::Clone(AnyDataObj* o)
+{
+Vector* v = dynamic_cast<Vector *>(o);
+if (v) return ( new NOMAdapter_Vector(v) );
+return ( new NObjMgrAdapter(o) );
+}
+
+/* --Methode-- */
+AnyDataObj* NOMAdapter_Vector::GetCopyObj()
+{
+return ( new Vector(*mVec) );
+}
+
+
+/* --Methode-- */
+void NOMAdapter_Vector::SavePPF(POutPersist& pos, string const & nom)
+{
+#ifdef SANS_EVOLPLANCK
+// PEIDA-EROS L'histo est lui-meme PPersist
+string tag = nom;  // A cause de const
+mVec->Write(pos,0,tag);
+#else
+string s = typeid(*mObj).name();
+cout << "NOMAdapter_Vector::SavePPF() - Error : Not supported for " << s << endl;
+#endif
+}
+
+/* --Methode-- */
+void NOMAdapter_Vector::Print(ostream& os)
+{
+os << (*mVec);
+}
+
+/* --Methode-- */
+PIDrawer* NOMAdapter_Vector::GetDrawer(string & dopt)
+{
+dopt = "thinline," + dopt;
+return( new PIYfXDrawer( new POVectorAdapter(mVec, false), NULL, true) );
+}
+
+/* --Methode-- */
+NTupleInterface* NOMAdapter_Vector::GetNTupleInterface(bool& adel)
+{
+adel = true;
+return( new NTupInt_Vector(mVec) );
+}
+
+
+// -------------------------------------------------------------
+
+/* --Methode-- */
+NTupInt_Vector::NTupInt_Vector(Vector* v)
+{
+mVec = v;
+}
+
+/* --Methode-- */
+NTupInt_Vector::~NTupInt_Vector()
+{
+}
+
+/* --Methode-- */
+uint_4 NTupInt_Vector::NbLines() const
+{
+return(mVec->NElts());
+}
+
+/* --Methode-- */
+uint_4 NTupInt_Vector::NbColumns() const 
+{
+return(2);
+}
+
+/* --Methode-- */
+r_8* NTupInt_Vector::GetLineD(int n) const 
+{
+int i;
+if ((n < 0) || (n >= mVec->NElts() )) 
+    for(i=0; i<2; i++)  mRet[i] = 0.;
+else { 
+  mRet[0] = n;  mRet[1] = (*mVec)(n);
+  }
+return(mRet);
+}
+
+/* --Methode-- */
+string NTupInt_Vector::VarList_C(const char* nx) const 
+{
+string nomx;
+if (nx) nomx = nx;
+else nomx = "_xh_";
+string vardec = "double i,val; \n";
+vardec += "i = " + nomx + "[0];  val = " + nomx + "[1]; \n";
+return(vardec);
+}
+
+
+//---------------------------------------------------------------
+// Class Adaptateur d'objet (Pour NamedObjMgr) d'objet Matrix 
+//---------------------------------------------------------------
+
+
+/* --Methode-- */
+NOMAdapter_Matrix::NOMAdapter_Matrix(Matrix* o)
+  : NObjMgrAdapter(o)
+{
+mMtx = o;
+}
+
+/* --Methode-- */
+NOMAdapter_Matrix::~NOMAdapter_Matrix()
+{
+}
+
+/* --Methode-- */
+NObjMgrAdapter* NOMAdapter_Matrix::Clone(AnyDataObj* o)
+{
+Matrix* m = dynamic_cast<Matrix *>(o);
+if (m) return ( new NOMAdapter_Matrix(m) );
+return ( new NObjMgrAdapter(o) );
+}
+
+/* --Methode-- */
+AnyDataObj* NOMAdapter_Matrix::GetCopyObj()
+{
+return ( new Matrix(*mMtx) );
+}
+
+/* --Methode-- */
+void NOMAdapter_Matrix::SavePPF(POutPersist& pos, string const & nom)
+{
+#ifdef SANS_EVOLPLANCK
+// PEIDA-EROS L'histo est lui-meme PPersist
+string tag = nom;  // A cause de const
+mMtx->Write(pos,0,tag);
+#else
+string s = typeid(*mObj).name();
+cout << "NOMAdapter_Matrix::SavePPF() - Error : Not supported for " << s << endl;
+#endif
+}
+
+/* --Methode-- */
+void NOMAdapter_Matrix::Print(ostream& os)
+{
+os << (*mMtx);
+}
+
+
+/* --Methode-- */
+P2DArrayAdapter* NOMAdapter_Matrix::Get2DArray(string &)
+{
+return ( new POMatrixAdapter(mMtx, false) );
+}
+
+/* --Methode-- */
+NTupleInterface* NOMAdapter_Matrix::GetNTupleInterface(bool& adel)
+{
+adel = true;
+return( new NTupInt_Matrix(mMtx) );
+}
+
+
+
+// -------------------------------------------------------------
+
+/* --Methode-- */
+NTupInt_Matrix::NTupInt_Matrix(Matrix* m)
+{
+mMtx = m;
+}
+
+/* --Methode-- */
+NTupInt_Matrix::~NTupInt_Matrix()
+{
+}
+
+/* --Methode-- */
+uint_4 NTupInt_Matrix::NbLines() const
+{
+return( mMtx->NRows()*mMtx->NCol() );
+}
+
+/* --Methode-- */
+uint_4 NTupInt_Matrix::NbColumns() const 
+{
+return(3);
+}
+
+/* --Methode-- */
+r_8* NTupInt_Matrix::GetLineD(int n) const 
+{
+int i,j;
+if ((n < 0) || (n >= mMtx->NRows()*mMtx->NCol() )) 
+    for(i=0; i<3; i++)  mRet[i] = 0.;
+else { 
+  i = n/mMtx->NCol(); j = n%mMtx->NCol(); 
+  mRet[0] = i;  mRet[1] = j;  mRet[2] = (*mMtx)(i,j);
+  }
+return(mRet);
+}
+
+/* --Methode-- */
+string NTupInt_Matrix::VarList_C(const char* nx) const 
+{
+string nomx;
+if (nx) nomx = nx;
+else nomx = "_xh_";
+string vardec = "double i,j,val; \n";
+vardec += "i = " + nomx + "[0]; j = " + nomx + "[1];  val = " + nomx + "[2]; \n";
+return(vardec);
+}
Index: /tags/V_LaSilla191199/SophyaPI/PIext/nommatvecadapter.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/nommatvecadapter.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/nommatvecadapter.h	(revision 464)
@@ -0,0 +1,93 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Adaptateur d objets (pour NamedObjMgr) pour Histos/NTuple
+//                                    Reza 05/99
+//  LAL-IN2P3/CNRS               CEA-DAPNIA     
+ 
+#ifndef NOMMATVECADAPTER_H_SEEN
+#define NOMMATVECADAPTER_H_SEEN
+
+#include "nomgadapter.h"
+#include "matrix.h"
+#include "cvector.h"
+
+//---------------------------------------------------------------
+// Class Adaptateur d'objet (Pour NamedObjMgr) d'objet Vector 
+//---------------------------------------------------------------
+
+class NOMAdapter_Vector : public NObjMgrAdapter {
+public:
+				NOMAdapter_Vector(Vector* v = NULL);
+  virtual			~NOMAdapter_Vector();
+
+  virtual NObjMgrAdapter*	Clone(AnyDataObj* o);
+  virtual AnyDataObj*		GetCopyObj();
+
+  //  virtual void			ReadFits(string const & flnm);
+  //  virtual void			SaveFits(string const & flnm);
+  virtual void			SavePPF(POutPersist& s, string const & nom);
+
+  virtual void			Print(ostream& os);
+  virtual PIDrawer*		GetDrawer(string& dopt);
+  virtual NTupleInterface*	GetNTupleInterface(bool& adel);
+
+protected:
+  Vector* mVec;
+};
+
+// Class Interface NTuple pour Vector
+class NTupInt_Vector : public NTupleInterface {
+public:
+			NTupInt_Vector(Vector* v);
+  virtual		~NTupInt_Vector();
+  virtual uint_4        NbLines() const ;
+  virtual uint_4        NbColumns() const ;
+  virtual r_8 *         GetLineD(int n) const ;
+  virtual string        VarList_C(const char* nomx=NULL) const ;
+protected:
+  Vector* mVec;
+  mutable r_8 mRet[2];
+};
+
+
+
+//---------------------------------------------------------------
+// Class Adaptateur d'objet (Pour NamedObjMgr) d'objet Matrix 
+//---------------------------------------------------------------
+
+class NOMAdapter_Matrix : public NObjMgrAdapter {
+public:
+				NOMAdapter_Matrix(Matrix* m = NULL);
+  virtual			~NOMAdapter_Matrix();
+
+  virtual NObjMgrAdapter*	Clone(AnyDataObj* o);
+  virtual AnyDataObj*		GetCopyObj();
+
+  //  virtual void			ReadFits(string const & flnm);
+  //  virtual void			SaveFits(string const & flnm);
+  virtual void			SavePPF(POutPersist& s, string const & nom);
+
+  virtual void			Print(ostream& os);
+  virtual P2DArrayAdapter*	Get2DArray(string& dopt);
+  virtual NTupleInterface*	GetNTupleInterface(bool& adel);
+
+protected:
+  Matrix* mMtx;
+};
+
+// Class Interface NTuple pour Matrix
+
+class NTupInt_Matrix : public NTupleInterface {
+public:
+			NTupInt_Matrix(Matrix* m);
+  virtual		~NTupInt_Matrix();
+  virtual uint_4        NbLines() const ;
+  virtual uint_4        NbColumns() const ;
+  virtual r_8 *         GetLineD(int n) const ;
+  virtual string        VarList_C(const char* nomx=NULL) const ;
+protected:
+  Matrix* mMtx;
+  mutable r_8 mRet[3];
+};
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PIext/nomstladapter.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/nomstladapter.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/nomstladapter.cc	(revision 464)
@@ -0,0 +1,137 @@
+#include "machdefs.h"
+#include <stdlib.h>
+#include <typeinfo>
+#include <iostream.h>
+#include <string>
+
+#include "nomstladapter.h"
+#include "stlist.h"
+#include "pistlist.h"
+
+
+
+
+//-------------------------------------------------------------------------
+// Class Adaptateur d'objet (Pour NamedObjMgr) d'objet StarList
+//-------------------------------------------------------------------------
+
+/* --Methode-- */
+NOMAdapter_StarList::NOMAdapter_StarList(StarList* o)
+  : NObjMgrAdapter(o)
+{
+mStl = o;
+}
+
+/* --Methode-- */
+NOMAdapter_StarList::~NOMAdapter_StarList()
+{
+}
+
+/* --Methode-- */
+NObjMgrAdapter* NOMAdapter_StarList::Clone(AnyDataObj* o)
+{
+StarList* stl = dynamic_cast<StarList *>(o);
+if (stl) return ( new NOMAdapter_StarList(stl) );
+return ( new NObjMgrAdapter(o) );
+}
+
+
+/* --Methode-- */
+void NOMAdapter_StarList::SavePPF(POutPersist& pos, string const & nom)
+{
+#ifdef SANS_EVOLPLANCK
+// PEIDA-EROS L'objet est lui-meme PPersist
+string tag = nom;  // A cause de const
+mStl->Write(pos,0,tag);
+#else
+string s = typeid(*mStl).name();
+cout << "NOMAdapter_StarList::SavePPF() - Error : Not supported for " << s << endl;
+#endif
+}
+
+/* --Methode-- */
+void NOMAdapter_StarList::Print(ostream& os)
+{
+os << (*mStl);
+}
+
+/* --Methode-- */
+PIDrawer* NOMAdapter_StarList::GetDrawer(string & dopt)
+{
+return(new PIStarList(mStl, false));
+}
+
+
+/* --Methode-- */
+NTupleInterface* NOMAdapter_StarList::GetNTupleInterface(bool& adel)
+{
+adel = true;
+return( new NTupInt_StarList(mStl) );
+}
+
+
+// -------------------------------------------------------------
+
+/* --Methode-- */
+NTupInt_StarList::NTupInt_StarList(StarList* stl)
+{
+mStl = stl;
+}
+
+/* --Methode-- */
+NTupInt_StarList::~NTupInt_StarList()
+{
+}
+
+/* --Methode-- */
+uint_4 NTupInt_StarList::NbLines() const
+{
+return(mStl->NbStars());
+}
+
+/* --Methode-- */
+uint_4 NTupInt_StarList::NbColumns() const 
+{
+return(11);
+}
+
+/* --Methode-- */
+r_8* NTupInt_StarList::GetLineD(int n) const 
+{
+BStar* bst = mStl->Star(n);
+if (bst == NULL)  
+  for(int k=0; k<11; k++)  mRet[k] = -9999.0;
+else {
+  mRet[0] = bst->PosX();
+  mRet[1] = bst->PosY();
+  mRet[2] = bst->Flux();
+  mRet[3] = bst->Fond();
+  mRet[4] = bst->PixMax();
+  mRet[5] = bst->PosXRef();
+  mRet[6] = bst->PosYRef();
+  mRet[7] = bst->FluxRef();
+  mRet[8] = bst->FondRef();
+  mRet[9] = bst->PixMaxRef();
+  mRet[10] = bst->Flags();
+  }
+return(mRet);
+}
+
+/* --Methode-- */
+string NTupInt_StarList::VarList_C(const char* nx) const 
+{
+string nomx;
+if (nx) nomx = nx;
+else nomx = "_xstl_";
+string vardec = "double x,y,flux,fond,pixmax; \n";
+vardec += "double xref,yref,fluxref,fondref,pixmaxref; \n";
+vardec += "double flags; \n"; 
+vardec += "x = " + nomx + "[0];  y = " + nomx + "[1]; \n";
+vardec += "flux = " + nomx + "[2];  fond = " + nomx + "[3]; \n";
+vardec += "pixmax = " + nomx + "[4]; \n";
+vardec += "xref = " + nomx + "[5];  yref = " + nomx + "[6]; \n";
+vardec += "fluxref = " + nomx + "[7];  fondref = " + nomx + "[8]; \n";
+vardec += "pixmaxref = " + nomx + "[9]; \n";
+vardec += "flags = " + nomx + "[10]; \n";
+return(vardec);
+}
Index: /tags/V_LaSilla191199/SophyaPI/PIext/nomstladapter.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/nomstladapter.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/nomstladapter.h	(revision 464)
@@ -0,0 +1,51 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Adaptateur d objets (pour NamedObjMgr) pour Histos/NTuple
+//                                    Reza 05/99
+//  LAL-IN2P3/CNRS               CEA-DAPNIA     
+ 
+#ifndef NOMSTLISTADAPTER_H_SEEN
+#define NOMSTLISTADAPTER_H_SEEN
+
+#include "nomgadapter.h"
+#include "stlist.h"
+
+
+//-------------------------------------------------------------------------
+// Class Adaptateur d'objet (Pour NamedObjMgr) d'objet StarList 
+//-------------------------------------------------------------------------
+
+class NOMAdapter_StarList : public NObjMgrAdapter {
+public:
+				NOMAdapter_StarList(StarList* stl = NULL);
+  virtual			~NOMAdapter_StarList();
+
+  virtual NObjMgrAdapter*	Clone(AnyDataObj* o);
+
+  //  virtual void			ReadFits(string const & flnm);
+  //  virtual void			SaveFits(string const & flnm);
+  virtual void			SavePPF(POutPersist& s, string const & nom);
+
+  virtual void			Print(ostream& os);
+  virtual PIDrawer*		GetDrawer(string& dopt);
+  virtual NTupleInterface*	GetNTupleInterface(bool& adel);
+
+protected:
+  StarList* mStl;
+};
+
+// Class Interface NTuple pour StarList 
+class NTupInt_StarList : public NTupleInterface {
+public:
+			NTupInt_StarList(StarList* stl);
+  virtual		~NTupInt_StarList();
+  virtual uint_4        NbLines() const ;
+  virtual uint_4        NbColumns() const ;
+  virtual r_8 *         GetLineD(int n) const ;
+  virtual string        VarList_C(const char* nomx=NULL) const ;
+protected:
+  StarList* mStl;
+  mutable r_8 mRet[12];
+};
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PIext/pawexecut.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/pawexecut.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/pawexecut.cc	(revision 464)
@@ -0,0 +1,36 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <iostream.h>
+#include <typeinfo>
+
+#include "histos.h"
+#include "histos2.h"
+#include "ntuple.h"
+
+#include "pawexecut.h"
+#include "nobjmgr.h"
+#include "pistdimgapp.h"
+
+PAWExecutor::PAWExecutor(PIACmd *piac, PIStdImgApp* app)
+  : mApp(app)
+{
+string kw, usage;
+string hgrp = "pawCmd";
+kw = "h/op/res";
+usage = "Reset histogram - " ;
+piac->RegisterCommand(kw,usage,this,hgrp);
+}
+
+PAWExecutor::~PAWExecutor()
+{
+}
+
+int PAWExecutor::Execute(string& kw, vector<string>& tokens)
+{
+if(kw == "h/op/res") {
+  cout << " CMV-A faire - h/op/res pas implemente " << endl;
+  return(0);
+  }
+else return(1); 
+}
Index: /tags/V_LaSilla191199/SophyaPI/PIext/pawexecut.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/pawexecut.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/pawexecut.h	(revision 464)
@@ -0,0 +1,26 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Classe d ajustement pour  piapp
+// cmv                            98-99
+// CEA-DAPNIA      LAL-IN2P3/CNRS
+
+#ifndef PAWEXECUTOR_H_SEEN
+#define PAWEXECUTOR_H_SEEN
+
+#include "machdefs.h"
+#include <string>
+#include <vector>
+
+#include "anydataobj.h"
+#include "piacmd.h"
+
+class PAWExecutor : public CmdExecutor {
+public:
+                   PAWExecutor(PIACmd* piac, PIStdImgApp* app);
+  virtual          ~PAWExecutor();
+  virtual int      Execute(string& keyw, vector<string>& args);
+protected:
+  PIStdImgApp* mApp;
+};
+
+#endif
+
Index: /tags/V_LaSilla191199/SophyaPI/PIext/piacmd.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/piacmd.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/piacmd.cc	(revision 464)
@@ -0,0 +1,955 @@
+#include "piacmd.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <math.h>
+
+#include "basexecut.h"
+
+#include "pdlmgr.h"
+#include "ctimer.h"
+// #include "dlftypes.h"
+
+#include "pistdimgapp.h"
+#include "nobjmgr.h"
+#include "piafitting.h"
+#include "pawexecut.h"
+
+#include PISTDWDG_H 
+#include PILIST_H 
+
+// ------------------------------------------------------------
+//         Gestion d'une fenetre d'aide interactive  
+//                    Classe   PIAHelpWind   
+// ------------------------------------------------------------
+
+class PIAHelpWind : public PIWindow {
+public :
+		PIAHelpWind(PIStdImgApp* par, PIACmd* piacmd);
+  virtual	~PIAHelpWind();
+  virtual void  Show();
+  virtual void  Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+  inline  void  AddHelpGroup(const char * hgrp, int gid)
+                    { hgrpom->AppendItem(hgrp, 20000+gid); }
+  inline  void  ClearHelpList() 
+                    { mNitem=0; hitemlist->DeleteAllItems(); }
+  inline  void	AddHelpItem(const char * hitem) 
+		    { mNitem++;  hitemlist->AppendItem(hitem, 100+mNitem); }
+protected :
+  PIStdImgApp* dap;
+  PIACmd* piac;
+  int mNitem;
+  PIList* hitemlist;
+  PIOptMenu* hgrpom;
+  PIButton * mBut;
+  PILabel * mLab;
+  PIText* mTxt;
+};
+
+/* --Methode-- */
+PIAHelpWind::PIAHelpWind(PIStdImgApp *par, PIACmd* piacmd)
+  : PIWindow((PIMsgHandler *)par, "Help-PIApp", PIWK_normal,  400, 300, 100, 350)
+{
+dap = par;
+piac = piacmd;
+mNitem = 0;
+SetMsg(77);
+
+int bsx, bsy;
+int tsx, tsy;
+int spx, spy;
+PIApplicationPrefCompSize(bsx, bsy);
+spx = bsx/6;   spy = bsy/6;
+tsx = 10*bsx+2*spx;  tsy = 7*bsy+3*spy;
+SetSize(tsx,tsy);
+hgrpom = new PIOptMenu(this, "hgrpoptmen", bsx*2.0, bsy, spx/2, spy);
+hgrpom->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+hitemlist = new PIList(this, "hitemlist", bsx*2.0, tsy-3*spy-bsy, spx/2, 2*spy+bsy);
+hitemlist->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+// hitemlist->SetBorderWidth(2);
+mTxt = new PIText(this, "helptext", true, true, bsx*8.0, 6*bsy, bsx*2.0+1.5*spx, spy);
+// mTxt->SetMutiLineMode(true);
+mTxt->SetTextEditable(false);
+mTxt->SetText("");
+mTxt->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mLab = new PILabel(this, "helpitem", bsx*4, bsy, bsx*2.5+2*spx, tsy-spy-bsy);
+mLab->SetBorderWidth(1);
+mLab->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mLab->SetLabel("");
+mBut = new PIButton(this, "Close", 70, bsx, bsy, tsx-bsx*1.5-spx, tsy-spy-bsy);
+mBut->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+}
+
+/* --Methode-- */
+PIAHelpWind::~PIAHelpWind()
+{
+delete hgrpom;
+delete hitemlist;
+delete mTxt;
+delete mLab;
+delete mBut;
+}
+
+/* --Methode-- */
+void PIAHelpWind::Process(PIMessage msg, PIMsgHandler* sender, void* /*data*/)
+{
+PIMessage um = UserMsg(msg);
+if (((um == 77) && (ModMsg(msg) == PIMsg_Close)) || (um == 70) ) {
+  Hide();
+  return;
+  }
+else if ( (um >= 20000) && (sender == hgrpom)) {  // Selection de groupe de Help
+  mTxt->SetText("");
+  mLab->SetLabel("");
+  piac->UpdateHelpList(this, um-20000);
+}
+else if ( (um > 100) && (sender == hitemlist) && (ModMsg(msg) == PIMsg_Select) ) {
+  string s = hitemlist->GetSelectionStr();
+  mTxt->SetText(piac->GetUsage(s));
+  mLab->SetLabel(s);
+  }  
+}
+
+/* --Methode-- */
+void PIAHelpWind::Show()
+{
+hgrpom->SetValue(20000);   // Groupe All
+mTxt->SetText("");
+mLab->SetLabel("");
+piac->UpdateHelpList(this, 0); 
+PIWindow::Show();
+}
+
+// ------------------------------------------------------------
+//         Bloc de commandes (Foreach, ...)    
+//               Classe  PIACmdBloc    
+// ------------------------------------------------------------
+
+class PIACmdBloc {
+public:
+		PIACmdBloc(PIACmd* piac, PIACmdBloc* par, vector<string>& args); 
+		~PIACmdBloc();
+  inline PIACmdBloc*   Parent() { return(parent); }
+  inline bool   CheckOK() { return((typ >= 0) ? true : false); }
+  inline void	AddLine(string& line)  
+    { lines.push_back(line); bloclineid.push_back(lines.size()); }
+  inline void	AddBloc(PIACmdBloc* blk)  
+    { blocs.push_back(blk); bloclineid.push_back(-blocs.size()); }
+  PIACmdBloc*	Execute();
+protected:
+  PIACmd* piacmd;
+  PIACmdBloc* parent;
+  int typ;           // 0 foreach , 1 integer loop, 2 float loop
+  string varname;
+  vector<string> strlist;
+  vector<string> lines;
+  vector<PIACmdBloc *> blocs;
+  vector<int> bloclineid;
+  int i1,i2,di;
+  float f1,f2,df;
+};
+
+/* --Methode-- */
+PIACmdBloc::PIACmdBloc(PIACmd* piac, PIACmdBloc* par, vector<string>& args)
+{
+piacmd = piac;
+parent = par;
+typ = -1;
+i1 = 0;  i2 = -1;  di = 1;
+f1 = 0.; f2 = -1.; df = 1.;
+if ((args.size() < 2) ||  !isalpha((int)args[0][0]) )  return; 
+varname = args[0];
+if (isalpha((int)args[1][0]) ) { // This is a foreach-integer bloc
+  for(int kk=1; kk<args.size(); kk++) strlist.push_back(args[kk]);
+  typ = 0;
+  }
+else { // This is an integer or float loop
+  size_t l = args[1].length();
+  size_t p = args[1].find(':');
+  size_t pp = args[1].find('.');
+  bool fl = (pp < l) ? true : false;  // Float loop or integer loop
+  if (p >= l) return;  // Syntaxe error
+  string a1 = args[1].substr(0, p);
+  string aa = args[1].substr(p+1);
+  p = aa.find(':');
+  string a2, a3;
+  bool hasa3 = false;
+  if (p < aa.length() ) { 
+    a2 = aa.substr(0,p);
+    a3 = aa.substr(p+1);
+    hasa3 = true;
+    }
+  else  a2 = aa; 
+  if (fl) { 
+    typ = 2;
+    f1 = atof(a1.c_str());
+    f2 = atof(a2.c_str());
+    if (hasa3)  df = atof(a3.c_str());
+    else df = 1.;
+    }
+  else { 
+    typ = 1;
+    i1 = atoi(a1.c_str());
+    i2 = atoi(a2.c_str());
+    if (hasa3)  di = atoi(a3.c_str());
+    else di = 1;
+    }
+  }
+}
+
+/* --Methode-- */
+PIACmdBloc::~PIACmdBloc()
+{
+for(int k=0; k<blocs.size(); k++) delete blocs[k];
+}
+
+/* --Methode-- */
+PIACmdBloc* PIACmdBloc::Execute()
+{
+// cout << " DBG * PIACmdBloc::Execute() " << typ << " - " << bloclineid.size() <<
+//      " I1,I2=" << i1 << " , " << i2 << " , " << di << endl;
+string cmd;
+int k=0;
+int kj=0;
+int kk=0;
+char buff[32];
+if (typ == 0)   // foreach string loop
+  for(k=0; k<strlist.size(); k++) {
+    cmd = "set " + varname + " " + strlist[k];
+    piacmd->Interpret(cmd);
+    for(kj=0; kj<bloclineid.size(); kj++) {
+      kk = bloclineid[kj]; 
+      if (kk > 0)  piacmd->Interpret(lines[kk-1]);
+      else blocs[-kk-1]->Execute();
+      }
+  }
+else if (typ == 1)  // Integer loop
+  for(int i=i1; i<i2; i+=di) {
+    k++;
+    if (++k > 9999) {
+      cout << ">>> Maximum PIACmdBloc loop limit (9999) -> break " << endl;
+      break;
+      }
+    sprintf(buff, " %d", i);
+    cmd = "set " + varname + buff;
+    piacmd->Interpret(cmd);
+    for(kj=0; kj<bloclineid.size(); kj++) {
+      kk = bloclineid[kj]; 
+      if (kk > 0)  piacmd->Interpret(lines[kk-1]);
+      else blocs[-kk-1]->Execute();
+      }
+  }
+else if (typ == 2)  // float loop
+  for(float f=f1; f<f2; f+=df) {
+    k++;
+    if (++k > 9999) {
+      cout << ">>> Maximum PIACmdBloc loop limit (9999) -> break " << endl;
+      break;
+      }
+    sprintf(buff, " %g", f);
+    cmd = "set " + varname + buff;
+    piacmd->Interpret(cmd);
+    for(kj=0; kj<bloclineid.size(); kj++) {
+      kk = bloclineid[kj]; 
+      if (kk > 0)  piacmd->Interpret(lines[kk-1]);
+      else blocs[-kk-1]->Execute();
+      }
+  }
+
+return(parent); 
+}
+
+// ------------------------------------------------------------
+//         Classe PIACmd
+// ------------------------------------------------------------
+
+static PIACmd* curpiacmd = NULL;
+/* --Methode-- */
+PIACmd::PIACmd(NamedObjMgr* omg, PIStdImgApp* app)
+{
+mObjMgr = omg; 
+mImgApp = app;
+system("cp history.pic hisold.pic");
+hist.open("history.pic");
+histon = true;
+trace = false;   timing = false;
+gltimer = NULL;
+curblk = NULL;
+felevel = 0;
+
+cmdhgrp["All"] = 0;
+cmdgrpid = 1;
+cmdhgrp["Commands"] = 1;
+helpwin = new PIAHelpWind(app, this);
+helpwin->AddHelpGroup("All", 0);
+helpwin->AddHelpGroup("Commands", 1);
+
+string kw = "piacmd";
+string usage;
+usage = ">>> (piacmd) Interpreter's keywords : \n";
+usage += "  > set varname string   # To set a variable, $varname \n";
+usage += "  > get newvarname varname # To set a newvariable, equal to $varname \n";
+usage += "  > setol varname patt     # Fills varname with object list \n";
+usage += "  > unset varname          # clear variable definition \n";
+usage += "  > echo string            # output string \n";
+usage += "  > alias name string      # define a command alias \n";
+usage += "  > readstdin varname      # reads a line from stdin into $varname \n";
+usage += "  > foreach varname string-list # Loop \n"; 
+usage += "  > foreach varname i1:i2[:di]  # Integer loop  \n"; 
+usage += "  > foreach varname f1:f2[:df]  # Float loop  \n";
+usage += "  > end                         # end loops \n"; 
+usage += "  > listvars      # List of variable names and values \n";
+usage += "  > listalias     # List of alias names and values \n";
+usage += "  > listcommands  # List of all known commands \n";
+usage += "  > exec filename # Execute commands from file \n";
+usage += "  > shell comand_string  # Execute shell command \n";
+usage += "  > help <command_name>  # <command_name> usage info \n"; 
+usage += "  > helpwindow           # Displays help window \n";
+usage += "  > timingon  timingoff traceon  traceoff \n";
+string grp = "Commands";
+RegisterHelp(kw, usage, grp);
+
+basexec = new PIABaseExecutor(this, omg, app);
+fitexec = new PIAFitter(this, app);
+pawexec = new PAWExecutor(this, app);
+AddInterpreter(this);
+curcmdi = this;
+}
+
+/* --Methode-- */
+PIACmd::~PIACmd()
+{
+hist.close();
+if (gltimer) { delete gltimer;  gltimer = NULL; }
+Modmap::iterator it;
+for(it = modmap.begin(); it != modmap.end(); it++) {
+  string name = (*it).first + "_end";
+  DlModuleInitEndFunction fend = (*it).second->GetFunction(name);
+  if (fend) fend();
+  delete (*it).second;
+  }
+delete helpwin;
+if (curpiacmd == this)  curpiacmd = NULL;
+delete basexec;
+delete fitexec;
+delete pawexec;
+}
+
+/* --Methode-- */
+PIACmd* PIACmd::GetInterpreter()
+{
+return(curpiacmd);
+}
+
+/* --Methode-- */
+string PIACmd::Name()
+{
+return("piacmd");
+}
+
+/* --Methode-- */
+void PIACmd::RegisterCommand(string& keyw, string& usage, CmdExecutor * ce, string grp)
+{
+if (!ce) { 
+  RegisterHelp(keyw, usage, grp);
+  return;
+  }
+int gid = CheckHelpGrp(grp);
+cmdex cme;
+cme.group = gid;
+cme.us = usage;
+cme.cex = ce;
+cmdexmap[keyw] = cme;
+}
+
+/* --Methode-- */
+void PIACmd::RegisterHelp(string& keyw, string& usage, string& grp)
+{
+int gid = CheckHelpGrp(grp);
+cmdex cme;
+cme.group = gid;
+cme.us = usage;
+cme.cex = NULL;
+helpexmap[keyw] = cme;
+}
+
+/* --Methode-- */
+int PIACmd::CheckHelpGrp(string& grp)
+{
+int gid=0;
+CmdHGroup::iterator it = cmdhgrp.find(grp);
+if (it == cmdhgrp.end()) {
+  cmdgrpid++;   gid = cmdgrpid;
+  cmdhgrp[grp] = gid;
+  helpwin->AddHelpGroup(grp.c_str(), gid);
+  }
+else gid = (*it).second;
+return(gid);
+}
+
+/* --Methode-- */
+void PIACmd::UpdateHelpList(PIAHelpWind* hw, int gid)
+{
+helpwin->ClearHelpList();
+CmdExmap::iterator it;
+for(it = helpexmap.begin(); it != helpexmap.end(); it++) {
+  if ( (gid != 0) && ((*it).second.group != gid) ) continue;
+  helpwin->AddHelpItem((*it).first.c_str());
+  }
+for(it = cmdexmap.begin(); it != cmdexmap.end(); it++) {
+  if ( (gid != 0) && ((*it).second.group != gid) ) continue;
+  helpwin->AddHelpItem((*it).first.c_str());
+  }
+}
+
+/* --Methode-- */
+void PIACmd::LoadModule(string& fnameso, string& name)
+{
+PDynLinkMgr * dynlink = new PDynLinkMgr(fnameso, false);
+if (dynlink == NULL) {
+  cerr << "PIACmd/LoadModule_Error: Pb opening SO " << fnameso << endl;
+  return;
+  }
+string fname = name + "_init";
+DlModuleInitEndFunction finit = dynlink->GetFunction(fname);
+if (!finit) {
+  cerr << "PIACmd/LoadModule_Error: Pb linking " << fname << endl;
+  return;
+  }
+cout << "PIACmd/LoadModule_Info: Initialisation module" << name 
+     << "  " << fname << "() ..." << endl;
+finit();
+modmap[name] = dynlink;
+return;
+}
+
+/* --Methode-- */
+void PIACmd::AddInterpreter(CmdInterpreter * cl)
+{
+if (!cl) return;
+interpmap[cl->Name()] = cl;}
+
+/* --Methode-- */
+void PIACmd::SelInterpreter(string& name)
+{
+InterpMap::iterator it = interpmap.find(name);
+if (it == interpmap.end())   return;
+curcmdi = (*it).second;
+}
+
+
+//  Pour le decoupage des commandes en lignes 
+typedef vector<string> cmdtok;
+
+/* Fonction */
+static string GetStringFrStdin(PIACmd* piac)
+{
+PIStdImgApp* piapp = piac->GetImgApp();
+if (piapp) {
+  PIBaseWdg* wdg = piapp->CurrentBaseWdg();
+  if (wdg)  wdg->Refresh();
+#ifndef __mac__
+  /* On vide le buffer X-Window */
+  XSync(PIXDisplay(),False);
+#endif
+}
+char buff[128];
+fgets(buff, 128, stdin);
+buff[127] = '\0';
+return((string)buff);
+}
+
+/* --Methode-- */
+int PIACmd::Interpret(string& s)
+{
+int rc = 0;
+cmdtok tokens;
+CmdVarList::iterator it;
+
+// Removing leading blanks
+size_t p,q,q2,l;
+l = s.length();
+if (l < 1)  return(0);
+if (s[0] == '#') return(0); // si c'est un commentaire
+p=s.find_first_not_of(" \t");
+if (p < l) s = s.substr(p);
+// else return(0);
+
+// On enregistre les commandes 
+if (histon) hist << s << endl;   
+
+
+string toks,kw;
+
+// >>>> Substitution d'alias (1er mot)
+p = 0;
+q = s.find_first_of(" \t");
+l = s.length();
+string w1 =  (q < l) ? s.substr(p,q-p) : s.substr(p);
+it = mAliases.find(w1);
+if (it != mAliases.end())  { 
+  s =  (q < l) ? ((*it).second + s.substr(q)) : (*it).second ;
+  l = s.length();
+  p=s.find_first_not_of(" \t");
+  if (p < l) s = s.substr(p);
+  p = 0;
+  q = s.find_first_of(" ");
+  }
+
+// >>>> Separating keyword 
+if (q < l)
+  {  kw = s.substr(p,q-p);  toks = s.substr(q, l-q); }
+else { kw = s.substr(p,l-p);  toks = ""; }
+
+// On verifie si nous sommes dans un bloc 
+if ( (curblk != NULL) && (kw != "foreach") ) { // On est dans un bloc 
+  if (kw != "end")   { curblk->AddLine(s);  return(0); }
+  else { 
+    PIACmdBloc* curb = curblk;
+    curblk = curb->Parent();
+    felevel--;
+    if (curblk  == NULL) { 
+       mImgApp->GetConsole()->SetPrompt("Cmd> ");
+       //       cout << " *DBG* Executing bloc " << endl;
+       curb->Execute();
+       }
+    else  {
+      char prompt[64];
+      sprintf(prompt, "foreach-%d? ", felevel);
+      mImgApp->GetConsole()->SetPrompt(prompt);
+      }
+    return(0);
+    }
+  }
+
+// Nous ne sommes donc pas dans un bloc ....   
+
+// >>>> Variable substitution  
+string s2="";
+p = 0;
+l = s.length();
+string vn;
+while (p < l) {
+  q = s.find('$',p);
+  //  cout << "DBG: " << s2 << " p= " << p << " q= " << q << " L= " << l << endl;
+  if (q > l) break;
+  if ((q>0) && (s[q-1] == '\\')) {   // Escape character \$
+     s2 += (s.substr(p,q-1-p) + '$') ; p = q+1;
+     continue;
+     }
+  if (q >= l-1) {
+      cerr << " Syntax error !!! " << endl;
+      return(0);
+      }
+  vn = "";
+  if ( s[q+1] == '{' ) {  // Variable in the form ${name}
+    q2 = s.find('}',q+1);
+    if (q2 >= l) {
+      cerr << " Syntax error !!! " << endl;
+      return(0);
+      }
+    vn = s.substr(q+2,q2-q-2);
+    q2++;
+    }
+  else if ( s[q+1] == '[' ) {  // Variable in the form $[varname]  -> This is $$varname
+    q2 = s.find(']',q+1);
+    if (q2 >= l) {
+      cerr << " Syntax error !!! " << endl;
+      return(0);
+      }
+    vn = s.substr(q+2,q2-q-2);
+    it =  mVars.find(vn);  
+    if ( (vn.length() < 1) || (it == mVars.end()) ) {
+      cerr << " Error: Undefined variable " << vn << " ! " << endl;
+      return(0);
+      }
+    vn = mVars[vn];
+    q2++;
+    }
+  else { 
+    q2 = s.find_first_of(" .:/,]()$",q+1); 
+    if (q2 > l) q2 = l;
+    vn = s.substr(q+1, q2-q-1); 
+    }
+  it =  mVars.find(vn);  
+  if ( (vn.length() < 1) || (it == mVars.end()) ) {
+    cerr << " Error: Undefined variable " << vn << " ! " << endl;
+    return(0);
+    }
+  s2 += (s.substr(p, q-p) + (*it).second);
+  p = q2;
+  } 
+if (p < l) s2 += s.substr(p);
+
+p = s2.find_first_not_of(" \t");
+if (p < l) s2 = s2.substr(p);
+
+
+// >>>> Separating keyword and tokens 
+q = s2.find(' '); 
+l = s2.length();
+if (q < l)
+  {  kw = s2.substr(0,q);  toks = s2.substr(q, l-q); }
+else { kw = s2;  toks = ""; }
+
+q = 0;
+while (q < l)  {
+  p = toks.find_first_not_of(" \t",q+1); // au debut d'un token
+  if (p>=l) break;
+  q = toks.find_first_of(" \t",p); // la fin du token;
+  string token = toks.substr(p,q-p);
+  tokens.push_back(token);
+  }
+
+
+// Si c'est un foreach, on cree un nouveau bloc
+if (kw == "foreach") {
+  //     cout << " *DBG* We got a foreach... " << endl;
+  PIACmdBloc* bloc = new PIACmdBloc(this, curblk, tokens);
+  if (!bloc->CheckOK()) {
+    cerr << "foreach syntax Error ! " << endl;
+    delete bloc;
+    return(0);
+    }
+  felevel++;
+  if (curblk)  curblk->AddBloc(bloc);
+  else {
+    char prompt[64];
+    sprintf(prompt, "foreach-%d> ", felevel);
+    mImgApp->GetConsole()->SetPrompt(prompt);
+    }
+  curblk = bloc;
+  //  cout << " *DBG* New Bloc created ... " << endl;
+  return(0);
+  }
+
+
+// cout << "PIACmd::Do() DBG  KeyW= " << kw << " NbArgs= " << tokens.size() << endl;
+//  for(int ii=0; ii<tokens.size(); ii++)
+//  cout << "arg[ " << ii << " ] : " << tokens[ii] << endl;
+
+// >>>>>>>>>>> Commande d'interpreteur
+else if (kw == "helpwindow") ShowHelpWindow();
+else if (kw == "help") {
+  if (tokens.size() > 0) cout << GetUsage(tokens[0]) << endl;
+  else {  
+    string kwh = "piacmd";
+    cout << GetUsage(kwh) << endl;
+    }
+  }
+
+else if (kw == "set") {
+  if (tokens.size() < 2) { cout << "PIACmd::Interpret() Usage: set varname string" << endl;  return(0); }
+  if ((tokens[0].length() < 1) || !isalpha((int)tokens[0][0]) ) {
+    cerr << "PIACmd::Interpret()/Error Variable name should start with alphabetic" << endl;
+    return(0);
+    }
+  string xx = tokens[1];
+  for (int kk=2; kk<tokens.size(); kk++)  xx += (' ' + tokens[kk] );
+  mVars[tokens[0]] = xx;
+  }
+
+else if (kw == "getvar") {
+  if (tokens.size() < 2) { cout << "PIACmd::Interpret() Usage: getvar newvarname varname" << endl;  return(0); }
+  it = mVars.find(tokens[1]);
+  if (it == mVars.end()) {
+    cerr << "Error - No " << tokens[1] << " Variable " << endl;
+    return(0);
+    } 
+  if ((tokens[0].length() < 1) || !isalpha((int)tokens[0][0]) ) {
+    cerr << "PIACmd::Interpret()/Error Variable name should start with alphabetic" << endl;
+    return(0);
+    }
+  mVars[tokens[0]] = (*it).second;
+  }
+
+else if (kw == "alias") {
+  if (tokens.size() < 2) { cout << "PIACmd::Interpret() Usage: alias aliasname string" << endl;  return(0); }
+  if ((tokens[0].length() < 1) || !isalpha((int)tokens[0][0]) ) {
+    cerr << "PIACmd::Interpret()/Error alias name should start with alphabetic" << endl;
+    return(0);
+    }
+  string xx = tokens[1];
+  for (int kk=2; kk<tokens.size(); kk++)  xx += (' ' + tokens[kk]);
+  mAliases[tokens[0]] = xx;
+  }
+
+else if (kw == "setol") {
+  if (tokens.size() < 2) { cout << "PIACmd::Interpret() Usage: setol varname objnamepattern" << endl;  return(0); }
+  if ((tokens[0].length() < 1) || !isalpha((int)tokens[0][0]) ) {
+    cerr << "PIACmd::Interpret()/Error Variable name should start with alphabetic" << endl;
+    return(0);
+    }
+  vector<string> ol;
+  mObjMgr->GetObjList(tokens[1], ol);
+  string vol; 
+  if (ol.size() < 1) vol = "";
+  else { 
+     vol = ol[0]; 
+    for (int kk=1; kk<ol.size(); kk++)  vol += (' ' + ol[kk]);
+    }
+  mVars[tokens[0]] = vol;
+  }
+else if (kw == "unset") {
+  if (tokens.size() < 1) { cout << "PIACmd::Interpret() Usage: unset varname" << endl;  return(0); }
+  CmdVarList::iterator it = mVars.find(tokens[0]);
+  if (it != mVars.end())  mVars.erase(it);
+  else cerr << "PIACmd::Interpret() No variable with name " << tokens[0] << endl;
+  }
+else if (kw == "echo") {
+  for (int kk=0; kk<tokens.size(); kk++)  cout << tokens[kk] << " " ;
+  cout << endl;
+  }
+
+else if (kw == "readstdin") {
+  if (tokens.size() < 1) { cout << "PIACmd::Interpret() Usage: readstdin varname" << endl;  return(0); }
+  if ((tokens[0].length() < 1) || !isalpha((int)tokens[0][0]) ) {
+    cerr << "PIACmd::Interpret()/Error Variable name should start with alphabetic" << endl;
+    return(0);
+    }
+  mImgApp->GetConsole()->AddStr(">>> Reading From StdIn \n", PIVA_Magenta);
+  cout << tokens[0] << " ? " << endl;
+  mVars[tokens[0]] = GetStringFrStdin(this);
+  }
+
+else if (kw == "listvars") {
+  cout << "PIACmd::Interpret()  Variable List , VarName = Value \n";
+  CmdVarList::iterator it;
+  for(it = mVars.begin(); it != mVars.end(); it++)  
+    cout << (*it).first << " = " <<  (*it).second << "\n";
+  cout << endl;
+  }
+else if (kw == "listalias") {
+  cout << "PIACmd::Interpret()  Alias List , AliasName = Value \n";
+  CmdVarList::iterator it;
+  for(it = mAliases.begin(); it != mAliases.end(); it++)  
+    cout << (*it).first << " = " <<  (*it).second << "\n";
+  cout << endl;
+  }
+else if (kw == "listcommands") {
+  cout << "---- PIACmd::Interpret()  Command Variable List ----- \n";
+  CmdExmap::iterator it;
+  int kc = 0;
+  for(it = cmdexmap.begin(); it != cmdexmap.end(); it++) {
+    cout << (*it).first << "  ";
+    kc++;
+    if (kc >= 5) { cout << "\n"; kc = 0; }
+    }
+  cout << endl;
+  }
+else if (kw == "traceon")  { cout << "PIACmd::Interpret()  -> Trace ON mode " << endl; trace = true; }
+else if (kw == "traceoff") { cout << "PIACmd::Interpret()  -> Trace OFF mode " << endl; trace = false; }
+else if (kw == "timingon") { 
+  cout << "PIACmd::Interpret()  -> Timing ON mode " << endl; 
+  if (gltimer)   delete gltimer;   gltimer = new Timer("PIA-CmdInterpreter ");   timing = true; 
+  }
+else if (kw == "timingoff") { 
+  cout << "PIACmd::Interpret()  -> Timing OFF mode " << endl; 
+  if (gltimer)  delete gltimer;  gltimer = NULL;  timing = false; 
+  }
+else if (kw == "exec") {
+  if (tokens.size() < 1) { cout << "PIACmd::Interpret() Usage: exec filename" << endl;  return(0); }
+  ExecFile(tokens[0], tokens);
+  }
+else if (kw == "shell") {
+  if (tokens.size() < 1) { cout << "PIACmd::Interpret() Usage: shell cmdline" << endl;  return(0); }
+  system(toks.c_str());
+  }
+//  Execution d'une commande enregistree
+else rc = ExecuteCommand(kw, tokens);
+
+if (timing)  gltimer->Split();
+return(rc);
+}
+
+/* --Methode-- */
+int PIACmd::ExecuteCommandLine(string& line)
+{
+cmdtok tokens;
+if (line.length() < 1)  return(0);
+
+string toks,kw;
+size_t p = line.find_first_not_of(" ");
+line = line.substr(p);
+p = 0;
+size_t q = line.find_first_of(" ");
+size_t l = line.length();
+
+if (q < l)
+  {  kw = line.substr(p,q-p);  toks = line.substr(q, l-q); }
+else { kw = line.substr(p,l-p);  toks = ""; }
+
+q = 0;
+while (q < l)  {
+  p = toks.find_first_not_of(" ",q+1); // au debut d'un token
+  if (p>=l) break;
+  q = toks.find_first_of(" ",p); // la fin du token;
+  string token = toks.substr(p,q-p);
+  tokens.push_back(token);
+  }
+
+return(ExecuteCommand(kw, tokens));  
+}
+
+/* --Methode-- */
+int PIACmd::ExecuteCommand(string& keyw, vector<string>& args)
+{
+  int rc = -1;
+  CmdExmap::iterator it = cmdexmap.find(keyw);
+  if (it == cmdexmap.end())  cout << "No such command : " << keyw << " ! " << endl;
+  else { 
+    if ((*it).second.cex) rc = (*it).second.cex->Execute(keyw, args);
+    else cout << "Dont know how to execute " << keyw << " ? " << endl;
+    }
+  return(rc);
+}
+
+/* --Methode-- */
+int PIACmd::ExecFile(string& file, vector<string>& args)
+{
+char line_buff[512];
+FILE *fip;
+
+if ( (fip = fopen(file.c_str(),"r")) == NULL ) {
+  if (file.find('.') >= file.length()) {
+    cout << "PIACmd::Exec(): Error opening file " << file << endl;
+    file += ".pic";
+    cout << "                Trying file " << file << endl;
+    fip = fopen(file.c_str(),"r");
+    }
+  }
+
+if(fip == NULL) {
+  cerr << "PIACmd::Exec() Error opening file " << file << endl;
+  hist << "##! PIACmd::Exec() Error opening file " << file << endl;
+  return(0);
+  }
+
+// hist << "### Executing commands from " << file << endl;
+
+// Setting $0 ... $99 variables 
+int k;
+CmdVarList::iterator it;
+char buff[32];
+// First, we clear all previous values
+string vn="#";
+it = mVars.find(vn);
+if (it != mVars.end())  mVars.erase(it);
+for(k=0; k<99; k++) {   
+  sprintf(buff,"%d",k);
+  vn = buff;
+  it = mVars.find(vn);
+  if (it != mVars.end())  mVars.erase(it);
+  }
+// We then set them
+vn="#";
+sprintf(buff,"%d",(int)args.size());
+mVars[vn] = buff;
+for(k=0; k<args.size(); k++) {   
+  sprintf(buff,"%d",k);
+  vn = buff;
+  mVars[vn] = args[k];
+  }
+
+if (trace) { 
+  mImgApp->GetConsole()->AddStr("### Executing commands from ", PIVA_Magenta);
+  mImgApp->GetConsole()->AddStr(file.c_str(), PIVA_Magenta);
+  mImgApp->GetConsole()->AddStr("\n", PIVA_Magenta);
+  }
+
+histon = false; 
+while (fgets(line_buff,511,fip) != NULL)
+  {
+  if (trace) mImgApp->GetConsole()->AddStr(line_buff, PIVA_Magenta);
+  line_buff[strlen(line_buff)-1] = '\0';   /*  LF/CR de la fin */
+  string line(line_buff);
+  Interpret(line);
+  }
+histon = true; 
+
+// hist << "### End of Exec( " << file << " ) " << endl;
+if (trace) { 
+  mImgApp->GetConsole()->AddStr("### End of Exec( ", PIVA_Magenta);
+  mImgApp->GetConsole()->AddStr(file.c_str(), PIVA_Magenta);
+  mImgApp->GetConsole()->AddStr(" ) \n", PIVA_Magenta);
+  }
+
+return(0);
+}
+
+
+static string* videstr = NULL;
+/* --Methode-- */
+string& PIACmd::GetUsage(const string& kw)
+{
+bool fndok = false;
+CmdExmap::iterator it = cmdexmap.find(kw);
+if (it == cmdexmap.end()) {
+  it = helpexmap.find(kw);
+  if (it != helpexmap.end())  fndok = true;
+  }
+  else  fndok = true; 
+if (fndok)   return( (*it).second.us ); 
+// Keyword pas trouve
+if (videstr == NULL) videstr = new string("");
+*videstr =  "Nothing known about " + kw + " ?? ";
+return(*videstr);
+ 
+}
+
+/* --Methode-- */
+void PIACmd::ShowHelpWindow()
+{
+helpwin->Show();
+}
+
+/* --Methode-- */
+void PIACmd::HelptoLaTex(string const & fname)
+{
+FILE *fip;
+if ((fip = fopen(fname.c_str(), "w")) == NULL)   { 
+  cout << "PIACmd::HelptoLaTex_Error: fopen( " << fname << endl; 
+  return;
+  }
+
+fputs("% ----- Liste des groupes de Help ----- \n",fip);
+fputs("List of {\\bf piapp} on-line Help groups: \n", fip);
+fputs("\\begin{itemize} \n",fip);
+CmdHGroup::iterator it;
+for(it = cmdhgrp.begin(); it != cmdhgrp.end(); it++) 
+  fprintf(fip,"\\item {\\bf %s } \n", (*it).first.c_str());
+
+fputs("\\end{itemize} \n",fip);
+
+fputs("% ----- Liste des commandes dans chaque groupe ----- \n",fip);
+fputs("\\newpage \n",fip);
+CmdExmap::iterator ite;
+int gid;
+for(it = cmdhgrp.begin(); it != cmdhgrp.end(); it++) {
+  gid = (*it).second;
+  if (gid == 0)  continue;
+  fprintf(fip,"\\subsection{%s} \n", (*it).first.c_str());
+  for(ite = helpexmap.begin(); ite != helpexmap.end(); ite++) {
+    if ((*ite).second.group != gid)  continue;
+    fprintf(fip,"{ \\Large $ \\star \\star \\star $ }  Help item {\\bf \\Large %s } \n", 
+            (*ite).first.c_str());
+    fputs("\\begin{verbatim} \n",fip);
+    fprintf(fip,"%s\n", (*ite).second.us.c_str());
+    fputs("\\end{verbatim} \n",fip);
+    }
+  for(ite = cmdexmap.begin(); ite != cmdexmap.end(); ite++) {
+    if ((*ite).second.group != gid)  continue;
+    fprintf(fip,"{ \\Large $ \\star \\star \\star $ }  Command {\\bf \\Large %s } \n", 
+            (*ite).first.c_str());
+    fputs("\\begin{verbatim} \n",fip);
+    fprintf(fip,"%s\n", (*ite).second.us.c_str());
+    fputs("\\end{verbatim} \n",fip);
+    }
+}
+
+fclose(fip);
+return;
+}
+
+
+
Index: /tags/V_LaSilla191199/SophyaPI/PIext/piacmd.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/piacmd.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/piacmd.h	(revision 464)
@@ -0,0 +1,136 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Classe interpreteur de commande pour piapp 
+// Reza      Aout 97 , Juillet,Aout 98
+// LAL-IN2P3/CNRS
+
+#ifndef PIACMD_H_SEEN
+#define PIACMD_H_SEEN
+
+#include "machdefs.h"
+#include <iostream.h>
+#include <fstream.h>
+#include <string>
+#include <vector>
+#include <map>
+#include <functional>
+
+#include "dlftypes.h"
+
+
+// Classe definissant l'interface pour un executeur de commande
+class CmdExecutor {
+public:
+  virtual	~CmdExecutor() {} ;
+  // keyw : Le mot cle associe , args: Arguments de la commande
+  virtual int	Execute(string& keyw, vector<string>& args)=0;
+};
+
+// Classe definissant l'interface pour un interpreteur de commande
+class CmdInterpreter {
+public:
+  virtual		~CmdInterpreter() {} ;
+  virtual string	Name()=0;
+  virtual int		Interpret(string& line)=0;
+};
+
+
+
+// Forward declaration of some classes ...
+class NamedObjMgr;
+class PIStdImgApp;
+class Timer;
+class PDynLinkMgr;
+
+class PIAHelpWind; // Fenetre d'aide en ligne 
+class PIACmdBloc;
+
+// ---------------------------------------------------------------------
+// Classe Interpreteur de commande, gestionnaire de module chargeable,
+// et de fonctions dynamiquement linke pour PIStdImgApp
+// Permet de gerer plusieurs Interpreter differents 
+// ---------------------------------------------------------------------
+
+
+class PIACmd : public CmdInterpreter  {
+public:
+  static PIACmd*	GetInterpreter();
+
+			PIACmd(NamedObjMgr* omg, PIStdImgApp* app);
+  virtual		~PIACmd();
+  virtual string	Name();
+
+  virtual void		RegisterCommand(string& keyw, string& usage, CmdExecutor * ce, 
+                                        string grp="Command");
+  virtual void		RegisterHelp(string& keyw, string& usage, string& grp);
+  virtual void		LoadModule(string& fnameso, string& name);
+
+  virtual void		AddInterpreter(CmdInterpreter * cl);
+  virtual void		SelInterpreter(string& name);
+
+  virtual int		Interpret(string& line);
+  virtual int		ExecuteCommandLine(string& line);
+  virtual int		ExecuteCommand(string& keyw, vector<string>& args);
+  virtual int		ExecFile(string& file, vector<string>& args);
+
+  virtual string&	GetUsage(const string& kw);
+  virtual void		ShowHelpWindow();
+
+  virtual void 		HelptoLaTex(string const & flnm);
+
+  inline  CmdInterpreter* CurrentInterpreter() { return(curcmdi); }
+  inline  CmdExecutor*    BaseExecutor()  { return(basexec); }
+  inline  PIStdImgApp*    GetImgApp() { return(mImgApp); }
+
+//   Pour utilisation par PIAHelpWind uniquement 
+  virtual void		UpdateHelpList(PIAHelpWind* hw, int gid);
+
+protected:
+  virtual int		CheckHelpGrp(string& grp);
+
+  NamedObjMgr* mObjMgr;
+  PIStdImgApp* mImgApp;
+
+  CmdInterpreter* curcmdi;
+  CmdExecutor* basexec;
+  CmdExecutor* fitexec;
+  CmdExecutor* pawexec;
+
+// Pour enregistrer la liste de commandes et leurs executeurs et le help
+  struct cmdex {int group; string us; CmdExecutor * cex; } ;
+  typedef map<string, int, less<string> > CmdHGroup;   // Liste des groupes de commandes
+  CmdHGroup cmdhgrp;
+  int cmdgrpid;                                     // Numero de groupe courant
+  typedef map<string, cmdex, less<string> > CmdExmap;
+  CmdExmap cmdexmap;
+  CmdExmap helpexmap;                               // Pour les helps sans commande
+
+// Pour garder la liste des modules 
+  typedef map<string, PDynLinkMgr* , less<string> > Modmap;
+  Modmap modmap;
+
+// Pour garder la liste des interpreteur
+  typedef map<string, CmdInterpreter*, less<string> > InterpMap;
+  InterpMap interpmap;
+ 
+//  Pour stocker les variables definies par l'interpreteur
+  typedef map<string, string, less<string> > CmdVarList;
+  CmdVarList mVars;     // Liste des variables 
+  CmdVarList mAliases;  // Liste des alias 
+
+  PIACmdBloc * curblk;  // Bloc de commande courant (foreach, ...)
+  int felevel;          // foreah level 
+
+  ofstream hist;       //  History file 
+  bool histon;        //  True ->  history file
+  bool trace;          // Trace flag
+  bool timing;         // Display CPU Time
+  Timer* gltimer;      // pour Display CPU Time
+
+// Fenetre d'aide interactive 
+  PIAHelpWind* helpwin;
+
+};
+
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PIext/piafitting.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/piafitting.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/piafitting.cc	(revision 464)
@@ -0,0 +1,1482 @@
+//CMVBUG reste pb suivant sous Linux-egcs (OSF1-cxx c'est ok):
+//openppf cmvwppf.ppf
+//fitw h1g g2 p:4500,45,10,900
+//delobjs h1g
+//clic sur FIT  -> OK
+//clic sur FIT 2sd fois -> core dump!!!
+//
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <iostream.h>
+#include <typeinfo>
+
+#include "strutil.h"
+#include "nbtri.h"
+#include "generalfit.h"
+#include "fct1dfit.h"
+#include "fct2dfit.h"
+#include "matrix.h"
+#include "cvector.h"
+#include "ntuple.h"
+#include "cimage.h"
+#include "histos.h"
+#include "histos2.h"
+#include "ntuple.h"
+#include "hisprof.h"
+
+#include "piafitting.h"
+#include "nobjmgr.h"
+#include "pistdimgapp.h"
+
+////////////////////////////////////////////////////////////////////
+////---------- Classe de fenetre de fit interactive ------------////
+////////////////////////////////////////////////////////////////////
+class PIAFitterWind :  public PIWindow {
+public :
+		PIAFitterWind(PIStdImgApp* par, PIAFitter* fiter);
+  virtual	~PIAFitterWind();
+  virtual void  Show();
+  virtual void  Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+  void SetState(void);
+protected :
+  PIStdImgApp* mDap;
+  PIAFitter*   mFitter;
+  PILabel**    lab; int nlab;
+  PIText**     txt; int ntxt;
+  PIButton**   but; int nbut;
+  PICheckBox** ckb; int nckb;
+  PIOptMenu**  pom; int npom;
+  bool ReFillGData;
+  int saveI1,saveI2, saveJ1, saveJ2;
+  double ErrValue;
+};
+
+////////////////////////////////////////////////////////////////////////
+//| --------------- Fit Lineaire a 1 et 2 dimensions ---------------
+//| Syntaxe:
+//| fitlin nom pnn [o:.aa,bb,cc, o;dd,ee,ff o:gg,hh,jj,kk etc...]
+//| avec:
+//| nom  : cf commentaire ordre "fit"
+//| pnn  : fit polynome degre nn avec classe Poly (lineaire) 1D ou 2D
+//| o:aa,...,bb : cf commentaires ordre "fit"
+//|
+////////////////////////////////////////////////////////////////////////
+//| --------------- Fit d'objets a 1 et 2 dimensions ---------------
+//|                 avec interface d'aide graphique
+//| Syntaxe:
+//| fitw nom func
+//|     [p:p1,p2,...,pn s:s1,s2,...,sn m:m1,m2,...,mn M:M1,mM2,...,Mn f:f1,...,fn]
+//|     [o:.aa,bb,cc, o;dd,ee,ff o:gg,hh,jj,kk etc...]
+//| cf commentaire ordre "fit"
+//|
+////////////////////////////////////////////////////////////////////////
+//| --------------- Fit d'objets a 1 et 2 dimensions ---------------
+//| Syntaxe:
+//| fit nom func
+//|     [p:p1,p2,...,pn s:s1,s2,...,sn m:m1,m2,...,mn M:M1,mM2,...,Mn f:f1,...,fn]
+//|     [o:.aa,bb,cc, o;dd,ee,ff o:gg,hh,jj,kk etc...]
+//|----- OBJET -----
+//| nom  : nom de l'objet qui peut etre:
+//|        fit-1D:  Vector,Histo1D,HProf ou GeneraFitData(1D)
+//|        fit-2D:  Matrix,Histo2D,Image<T> ou GeneraFitData(2D)
+//|
+//|----- FUNCTION -----
+//| func : pnn : fit polynome degre nn avec GeneralFit (non-lineaire) 1D ou 2D
+//|      : gnn : fit gaussienne (hauteur) + polynome de degre nn 1D
+//|      : g   : fit gaussienne (hauteur) 1D
+//|      : enn : fit exponentielle + polynome de degre nn 1D
+//|      : e   : fit exponentielle 1D
+//|      : Gnn : fit gaussienne (volume) + polynome de degre nn 1D
+//|      : G   : fit gaussienne (volume) 1D
+//|      :     : fit gaussienne+fond (volume) 2D
+//|      : Gi  : fit gaussienne+fond integree (volume) 2D
+//|      : d   : fit DL de gaussienne+fond (volume) 2D
+//|      : di  : fit DL de gaussienne+fond integree (volume) 2D
+//|      : D   : fit DL de gaussienne+fond avec coeff variable p6 (volume) 2D
+//|      : Di  : fit DL de gaussienne+fond integree avec coeff variable p6 (volume) 2D
+//|      : M   : fit Moffat+fond (expos=p6) (volume) 2D
+//|      : Mi  : fit Moffat+fond integree (expos=p6) (volume) 2D
+//|      : Autre : fonction definie par l'utilisateur (cf commentaires ci apres)
+//|
+//|----- INIT PARAMETRES ET ETAT DU FIT -----
+//| p    : p1,...,pn : valeur d'initialisation des parametres (def=0)
+//| s    : s1,...,sn : valeur des steps de depart (def=1)
+//| m    : m1,...,mn : valeur des minima (def=1)
+//| M    : M1,...,Mn : valeur des maxima (def=-1) (max<=min : pas de limite)
+//| f    : f1,...,fn : si >=1 parametre fixe sinon libre (def=0)
+//| - Remarque: si pi,si,mi ou Mi = '!' la valeur correspondante n'est pas changee
+//|
+//|----- OPTIONS -----
+//| o    : options "o:Eaa.b,eaa.b,f,r,caa.b,Xaa.b"
+//|      F : initialisation a partir des resultats et de l'etat du fit precedent
+//|          (option non prioritaire sur les definitions p:,s:,m:,M:,f:o:)
+//|      a : initialisation automatique des parametres du fit (si disponible)
+//|          (option non prioritaire sur les definitions p:,s:,m:,M:,f:o:
+//|           et sur l'initialisation pa l'option "F")
+//|      f : generation d'un Objet identique contenant la fonction fittee
+//|      r : generation d'un Objet identique contenant les residus
+//|      Xaa.b : aa.b valeur du DXi2 d'arret (def=1.e-3)
+//|      Naa : aa nombre maximum d'iterations (def=100)
+//|      la : niveau "a" de print: a=niveau de print Fit1/2D
+//|      da : niveau "a" de debug: a=niveau de GeneralFit
+//|      Ii1/i2 : numeros des bins X de l'histos utilises pour le fit [i1,i2]
+//|2D    Jj1/j2 : numeros des bins Y de l'histos utilises pour le fit [j1,j2]
+//|    - L'erreur est celle associee a l'objet (si elle existe),
+//|      elle est mise a 1 sinon, sauf si E... ou e... est precise:
+//|      Eaa.b : si |val|>=1 erreur = aa.b*sqrt(|val|)
+//|              si |val|<1  erreur = aa.b
+//|              si aa.b <=0 alors aa.b=1.0
+//|              E seul est equivalent a E1.0
+//|      eaa.b : erreur = aa.b
+//|              si aa.b <=0 alors aa.b=1.0
+//|              e seul est equivalent a e1.0
+//|      xaa.b : demande de centrage: on fit x-aa.b au lieu de x)
+//|      x : demande de centrage: on fit x-xc au lieu de x
+//|          avec xc=abscisse du milieu de l'histogramme
+//|          Actif pour  exp+poly 1D, poly 1D
+//|          Pour gauss+poly 1D, xc est le centre de la gaussienne.
+//|2D    yaa.b et y : idem "xaa.b et x" mais pour y
+//|
+////////////////////////////////////////////////////////////////////////
+//| --------------- Def des fcts de fit par l'utilisateur ---------------
+//| Pour definir une fonction parametree utilisateur:
+//| Un exemple de fichier contenant des fonctions a fitter: PIext/userfitfunex.c
+//| > crfitfil nom_fichier nom_fonction nvar npar
+//|     pour creer un squelette de fichier C contenant la fonction a fitter
+//|            nom_fichier : nom du fichier ou est le code de la fonction
+//|                          c'est un fichier C de nom blabla.c
+//|            nom_fonction : nom de la fonction ex: gauss2
+//|            nvar : nombre de variables x[] (1D=1, 2D=2, etc...)
+//|            npar : nombre de parametre p[]
+//|   - La fonction est donc F(x[];p[]), soit par ex:
+//|            double gauss2(double const* x,double const* p)
+//|   - L'utilisateur a la possibilite de donner egalement la fonction
+//|     retournant les derivees de la fonction par rapport aux parametres
+//|            double gauss2_der(double const* x,double const* p,double* dp)
+//|     ou dp[i] = dF(x[];p[])/dp[i]
+//|     Par convention, cette fonction a le meme nom suivi de "_der"
+//| > crfitfun nom_fichier nom_fonction nvar npar
+//|     Permet de compiler le fichier "nom_fichier" et de linker
+//|     la fonction "nom_fonction"
+//|   - Un meme fichier peut contenir plusieurs fonctions a fitter
+//|
+////////////////////////////////////////////////////////////////////////
+
+/* --Methode-- */
+PIAFitter::PIAFitter(PIACmd *piac, PIStdImgApp* app)
+: mApp(app), FWindFit(NULL)
+, mNObj(""), mObj(NULL), mGData(NULL)
+, mNPar(0), mNVar(0),  mNBinX(0), mNBinY(0), mNData(0)
+, mPar(1), mStep(1), mMin(1), mMax(1), mFix(1)
+, mParSave(1), mStepSave(1), mMinSave(1), mMaxSave(1), mFixSave(1)
+, mFit(NULL)
+, mV(NULL), mH(NULL), mM(NULL), mH2(NULL), mIm(NULL), mG(NULL)
+, mFunction(NULL), mFName(""), mFunc(NULL)
+, mDlUFunc(NULL), mNameFitFunc(""), mFitFunc(NULL), mFitFuncDer(NULL)
+, mUFNVar(0), mUFNPar(0)
+{
+// Init et Set des options
+mPar=0.; mStep=1.; mMin=1.; mMax=-1.; mFix=0.;
+mParSave=0.; mStepSave=1.; mMinSave=1.; mMaxSave=-1.; mFixSave=0.;
+ResetOptions();
+mOptSave = mOpt;
+
+// enregistrement des ordres de fit
+string kw, usage;
+
+kw = "fit";
+usage = "Fitting function to DataObjects (Histo, Histo2D, Vector, ...)";
+usage += "\n Usage: fit nomobj func [Options]";
+usage += "\n [p:p1,...,pn s:s1,...,sn m:m1,...,mn M:M1,...,Mn o:... o:...]";
+piac->RegisterCommand(kw,usage,this,"Fitting");
+
+kw = "fitw";
+usage = "Fitting function to DataObjects with Interactive Window Help";
+usage += "\n Usage: fitw nomobj func [Options]";
+usage += "\n [p:p1,...,pn s:s1,...,sn m:m1,...,mn M:M1,...,Mn o:... o:...]";
+piac->RegisterCommand(kw,usage,this,"Fitting");
+
+kw = "fitlin";
+usage = "Linear Fitting of Polynoms to DataObjects";
+usage += "\n Usage: fitlin nomobj func [o:... o:...]";
+piac->RegisterCommand(kw,usage,this,"Fitting");
+
+kw = "crfitfun";
+usage = "Creation et link de function utilisateur pour le fit";
+usage += "\n Usage: crfitfun file func nvar npar";
+piac->RegisterCommand(kw,usage,this,"Fitting");
+
+kw = "crfitfil";
+usage = "Creation de fichier C pour function utilisateur du fit";
+usage += "\n Usage: crfitfil file func nvar npar";
+piac->RegisterCommand(kw,usage,this,"Fitting");
+}
+
+/* --Methode-- */
+PIAFitter::~PIAFitter()
+{
+if(mFit != NULL)      {delete mFit;      mFit=NULL;}
+if(mFunction != NULL) {delete mFunction; mFunction=NULL;}
+if(mFunc != NULL)     {delete mFunc;     mFunc=NULL;}
+if(mGData != NULL)    {delete mGData;    mGData=NULL;}
+if(FWindFit != NULL)  {delete FWindFit;  FWindFit=NULL;}
+if (mDlUFunc != NULL) {delete mDlUFunc;  mDlUFunc=NULL;}
+}
+
+/* --Methode-- */
+void PIAFitter::ResetDPointer(void)
+// Reset des pointeurs sur les donnees
+{
+mNObj = ""; mObj=NULL;
+mV=NULL; mH=NULL; mM=NULL; mH2=NULL; mIm=NULL; mG=NULL;
+}
+
+/* --Methode-- */
+void PIAFitter::ResetOptions(void)
+// Reset des options
+{
+mOpt.okres = mOpt.okfun = false;
+mOpt.polcx = mOpt.polcy = 0;
+mOpt.xc = mOpt.yc = 0.;
+mOpt.stc2 = 1.e-3;
+mOpt.nstep = 100;
+mOpt.err_e = mOpt.err_E = -1.;
+mOpt.lp = 1; mOpt.lpg = 0;
+mOpt.i1 = mOpt.j1 = mOpt.i2 = mOpt.j2 = -1;
+mOpt.fromlastfit = false;
+mOpt.autoinifit = false;
+}
+
+/* --Methode-- */
+void PIAFitter::DecodeOptions(string opt)
+// Decodage des options a partir des chaines de caracteres
+{
+ResetOptions();
+if(opt.length()<=0) return;
+
+size_t p,q; string dum;
+opt = "," + opt + ",";
+
+if(strstr(opt.c_str(),",F,"))  // init options/param a partir du fit precedent
+  {mOpt = mOptSave; mOpt.fromlastfit = true;}
+if(strstr(opt.c_str(),",a,")) mOpt.autoinifit = true; // init auto par fit
+if(strstr(opt.c_str(),",r,")) mOpt.okres = true;  // residus
+if(strstr(opt.c_str(),",f,")) mOpt.okfun = true;  // fonction fittee
+if(strstr(opt.c_str(),",x")) { // Demande de centrage (fit X=x-xc)
+  mOpt.polcx = 2; // Le centrage est calcule automatiquement
+  p = opt.find(",x"); q = opt.find_first_of(',',p+1);
+  dum = opt.substr(p,q-p);
+  if(dum.length()>2) {
+    sscanf(dum.c_str(),",x%lf",&mOpt.xc);
+    mOpt.polcx = 1; // Le centrage est fixe par la valeur lue
+  }
+}
+if(strstr(opt.c_str(),",y")) { // Demande de centrage (fit Y=y-yc)
+  mOpt.polcy = 2; // Le centrage est calcule automatiquement
+  p = opt.find(",y"); q = opt.find_first_of(',',p+1);
+  dum = opt.substr(p,q-p);
+  if(dum.length()>2) {
+    sscanf(dum.c_str(),",y%lf",&mOpt.yc);
+    mOpt.polcy = 1; // Le centrage est fixe par la valeur lue
+  }
+}
+if(strstr(opt.c_str(),",E")) { // Erreurs imposees a "sqrt(val)" ou "aa.b*sqrt(val)"
+  p = opt.find(",E"); q = opt.find_first_of(',',p+1);
+  dum = opt.substr(p,q-p);
+  if(dum.length()>2) sscanf(dum.c_str(),",E%lf",&mOpt.err_E);
+  if(mOpt.err_E<=0.) mOpt.err_E = 1.;  //mOpt.err_e=-1.;
+}
+if(strstr(opt.c_str(),",e")) { // Erreurs imposees a "1" ou "aa.b"
+  p = opt.find(",e"); q = opt.find_first_of(',',p+1);
+  dum = opt.substr(p,q-p);
+  if(dum.length()>2) sscanf(dum.c_str(),",e%lf",&mOpt.err_e);
+  if(mOpt.err_e<=0.) mOpt.err_e = 1.;  //mOpt.err_E=-1.;
+}
+if(strstr(opt.c_str(),",X")) { // Valeur du StopChi2
+  p = opt.find(",X"); q = opt.find_first_of(',',p+1);
+  dum = opt.substr(p,q-p);
+  if(dum.length()>2) sscanf(dum.c_str(),",X%lf",&mOpt.stc2);
+}
+if(strstr(opt.c_str(),",N")) { // Nombre maximum d'iterations
+  p = opt.find(",N"); q = opt.find_first_of(',',p+1);
+  dum = opt.substr(p,q-p);
+  if(dum.length()>2) sscanf(dum.c_str(),",N%d",&mOpt.nstep);
+}
+if(strstr(opt.c_str(),",l")) { // niveau de print
+  p = opt.find(",l"); q = opt.find_first_of(',',p+1);
+  dum = opt.substr(p,q-p);
+  if(dum.length()>2) sscanf(dum.c_str(),",l%d",&mOpt.lp);
+}
+if(strstr(opt.c_str(),",d")) { // niveau de debug du fit
+  p = opt.find(",d"); q = opt.find_first_of(',',p+1);
+  dum = opt.substr(p,q-p);
+  if(dum.length()>2) sscanf(dum.c_str(),",d%d",&mOpt.lpg);
+}
+if(strstr(opt.c_str(),",I")) { // intervalle de fit selon X
+  p = opt.find(",I"); q = opt.find_first_of(',',p+1);
+  dum = opt.substr(p,q-p);
+  if(dum.length()>2) sscanf(dum.c_str(),",I%d/%d",&mOpt.i1,&mOpt.i2);
+}
+if(strstr(opt.c_str(),",J")) { // intervalle de fit selon Y
+  p = opt.find(",J"); q = opt.find_first_of(',',p+1);
+  dum = opt.substr(p,q-p);
+  if(dum.length()>2) sscanf(dum.c_str(),",J%d/%d",&mOpt.j1,&mOpt.j2);
+}
+
+return;
+}
+
+/* --Methode-- */
+void PIAFitter::DecodeObject(string obj)
+// Decodage de l'objet a fitter
+{
+NamedObjMgr omg;
+AnyDataObj* mobj = omg.GetObj(obj);
+if(mobj == NULL)
+  {cout<<"PIAFitter::DecodeObject Error , Pas d'objet de nom "<<obj<<endl;
+   return;}
+
+// Reset
+ResetDPointer();
+mNVar = mNBinX = mNBinY = mNData = 0;
+
+mObj = mobj; mNObj = obj;
+string ctyp = typeid(*mObj).name();
+
+// 1D
+if (typeid(*mObj) == typeid(Vector)) {
+  mNVar = 1;
+  mV = (Vector*) mObj; mNBinX = mV->NElts(); mNBinY = 1;
+  }
+else if ( (typeid(*mObj) == typeid(HProf)) || (typeid(*mObj) == typeid(Histo)) ) {
+  mNVar = 1;
+  mH = (Histo*)  mObj; mNBinX = mH->NBins(); mNBinY = 1;
+  }
+// 2D
+else if (typeid(*mObj) == typeid(Matrix)) {
+  mNVar = 2;
+  mM = (Matrix*) mObj; mNBinX = mM->NCol(); mNBinY =mM->NRows();
+  }
+else if (typeid(*mObj) == typeid(Histo2D)) {
+  mNVar = 2;
+  mH2 = (Histo2D*) mObj; mNBinX = mH2->NBinX(); mNBinY = mH2->NBinY();
+  }
+else if (typeid(*mObj) == typeid(GeneralFitData)) {
+  mG = (GeneralFitData*) mObj; mNBinX = mG->NData(); mNBinY = 1;
+  if(     mG->NVar()==1) mNVar = 1;
+  else if(mG->NVar()==2) mNVar = 2;
+  else
+     {cout<<"PIAFitter::DecodeObject Error: \n"
+         <<" GeneralFitData ne peut avoir que 1 ou 2 variables d'abscisse: "
+         <<((GeneralFitData*) mObj)->NVar()<<endl;
+     return;}
+  }
+else if (dynamic_cast<RzImage*>(mObj)) {
+  mNVar = 2;
+  mIm = (RzImage*) mObj; mNBinX = mIm->XSize(); mNBinY = mIm->YSize();
+  }
+else {
+  cout<<"PIAFitter::DecodeObject Error , Objet n'est pas un "
+      <<"Histo1D/HProf/Vector/Histo2D/Image/Matrix/GeneralFitData "<<ctyp<<endl;
+  return;
+  }
+
+mNData = mNBinX*mNBinY;
+if(mNData<=0) {
+  cout<<"L'objet a "<<mNBinX<<","<<mNBinY<<" bins ("<<mNData<<")"<<endl;
+  return;
+}
+
+return;
+}
+
+/* --Methode-- */
+void PIAFitter::CheckOptions(void)
+// Check consistence des choix des options
+// ATTENTION: cette methode a besoin que l'objet a fitter soit deja lu
+{
+if(mOpt.lp<0) mOpt.lp = 0;
+if(mOpt.lpg<0) mOpt.lpg = 0;
+mOpt.i1 = (mOpt.i1<0||mOpt.i1>=mNBinX)? 0: mOpt.i1;
+mOpt.i2 = (mOpt.i2<0||mOpt.i2>=mNBinX||mOpt.i2<=mOpt.i1)? mNBinX-1: mOpt.i2;
+if(mNVar>=2) {
+  mOpt.j1 = (mOpt.j1<0||mOpt.j1>=mNBinY)? 0: mOpt.j1;
+  mOpt.j2 = (mOpt.j2<0||mOpt.j2>=mNBinY||mOpt.j2<=mOpt.j1)? mNBinY-1: mOpt.j2;
+} else mOpt.j2 = mOpt.j1 = 0;
+if(mOpt.polcx==2) {
+  if(mV||mM)   mOpt.xc = (mOpt.i2-mOpt.i1+1)/2.;
+  else if(mH)  mOpt.xc = (mH->XMin()+mH->XMax())/2.;
+  else if(mH2) mOpt.xc = (mH2->XMin()+mH2->XMax())/2.;
+  else if(mG)  {double mini,maxi; mG->GetMinMax(2,mini,maxi); mOpt.xc=(mini+maxi)/2.;}
+  else if(mIm) {mOpt.xc = mIm->XOrg() * mIm->XPxSize()*(mOpt.i2-mOpt.i1+1)/2.;}
+}
+if(mOpt.polcy==2 && mNVar>=2) {
+  if(mM)  mOpt.yc = (mOpt.j2-mOpt.j1+1)/2.;
+  if(mH2) mOpt.yc = (mH2->YMin()+mH2->YMax())/2.;
+  if(mG)  {double mini,maxi; mG->GetMinMax(12,mini,maxi); mOpt.yc=(mini+maxi)/2.;}
+  if(mIm) {mOpt.yc = mIm->YOrg() * mIm->YPxSize()*(mOpt.j2-mOpt.j1+1)/2.;}
+}
+if(mOpt.err_e>0.) mOpt.err_E=-1.;
+if(mOpt.err_E>0.) mOpt.err_e =-1.;
+if(mOpt.stc2<=0.) mOpt.stc2 = 1.e-3;
+if(mOpt.nstep<2) mOpt.nstep = 100;
+
+return;
+}
+
+/* --Methode-- */
+void PIAFitter::PrintOptions(void)
+// Print des options
+{
+cout<<"Fit["<<mNBinX<<","<<mNBinY<<"] ("<<mNData<<") dim="<<mNVar<<":"
+    <<" Int=["<<mOpt.i1<<","<<mOpt.i2<<"],["<<mOpt.j1<<","<<mOpt.j2<<"]"<<endl
+    <<" Cent="<<mOpt.polcx<<","<<mOpt.polcy<<","<<mOpt.xc<<"+x"<<","<<mOpt.yc<<"+y"
+    <<" TypE="<<mOpt.err_e<<","<<mOpt.err_E
+    <<" StpX2="<<mOpt.stc2<<" Nstep="<<mOpt.nstep<<endl
+    <<" Init.LFit="<<mOpt.fromlastfit<<" AutoIni.Fit="<<mOpt.autoinifit
+    <<" lp,lpg="<<mOpt.lp<<","<<mOpt.lpg<<endl;
+return;
+}
+
+/* --Methode-- */
+void PIAFitter::FillGData(void)
+// Fill generalfitdata pour le fit
+// ATTENTION: cette methode a besoin que les options soient decodees et checkees
+{
+if(mNData<=0) return;
+if(mGData!=NULL) {delete mGData; mGData=NULL;}
+mGData = new GeneralFitData(mNVar,mNData,0);
+
+for(int i=mOpt.i1;i<=mOpt.i2;i++) for(int j=mOpt.j1;j<=mOpt.j2;j++) {
+  double x,y=0.,f,e;
+
+  if(mV)
+    {x= (double) i; f=(*mV)(i); e=1.;}
+  else if(mH)
+    {x=mH->BinCenter(i); f=(*mH)(i); e=(mH->HasErrors())?mH->Error(i):1.;}
+  else if(mM)
+    {x=(double) i; y=(double) j; f=(*mM)(j,i); e=1.;}
+  else if(mH2)
+    {float xf,yf; mH2->BinCenter(i,j,xf,yf); x=(double)xf; y=(double)yf;
+     f=(*mH2)(i,j); e=(mH2->HasErrors())?mH2->Error(i,j):1.;}
+  else if(mIm)
+    {x=mIm->XOrg()+(i+0.5)*mIm->XPxSize(); y=mIm->YOrg()+(j+0.5)*mIm->YPxSize();
+     f=mIm->DValue(i,j); e=1.;}
+  else if(mG&&mNVar==1) {x= mG->X(i); f=mG->Val(i); e=mG->EVal(i);}
+  else if(mG&&mNVar==2) {x= mG->X(i); y=mG->Y(i); f=mG->Val(i); e=mG->EVal(i);}
+  else x=y=f=e=0.;
+
+  // Gestion des erreurs a utiliser
+  if(mOpt.err_e>0.) e=mOpt.err_e;
+  else if(mOpt.err_E>0.) {e=(f<-1.||f>1.)?mOpt.err_E*sqrt(fabs(f)):mOpt.err_E;}
+
+  // Remplissage de generalfitdata
+  if(mFName[0]=='p') {x -= mOpt.xc; if(mNVar>=2) y -= mOpt.yc;}
+  if(mNVar==1)      mGData->AddData1(x,f,e);
+  else if(mNVar==2) mGData->AddData2(x,y,f,e);
+}
+
+if(mGData->NData()<=0) {
+  cout<<"Pas de donnees dans GeneralFitData: "<<mGData->NData()<<endl;
+  return;
+}
+
+if(mOpt.lpg>1) {
+  mGData->PrintStatus();
+  mGData->PrintData(0);
+  mGData->PrintData(mGData->NData()-1);
+}
+
+return;
+}
+
+/* --Methode-- */
+void PIAFitter::DecodeFunction(string func)
+// Fonction a fitter
+// ATTENTION: cette methode a besoin que les donnees soient lues
+{
+if(func.length()<=0)
+  {cout<<"PIAFitter::DecodeFunction Donnez un nom de fonction a fitter."<<endl;
+   return;}
+if(mFunction!=NULL) {delete mFunction; mFunction=NULL;}
+if(mFunc    !=NULL) {delete mFunc;     mFunc=NULL;}
+mNPar=0; mFName = "";
+
+if(func == mNameFitFunc) { // Fonction utilisateur
+  mFunc = new GeneralFunc(mUFNVar,mUFNPar,mFitFunc,mFitFuncDer);
+  mNPar = mUFNPar;
+  cout<<"Fonction utilisateur nvar="<<mUFNVar<<", npar="<<mNPar<<endl;
+} else if(func[0]=='p' && mNVar==1) { //polynome
+  int degre=0; if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
+  cout<<"Fit polynome 1D de degre "<<degre<<endl;
+  Polyn1D* myf = new Polyn1D(degre,mOpt.xc);
+  mFunction = myf; mNPar = mFunction->NPar(); mFName = func;
+
+} else if(func[0]=='e' && mNVar==1) { //exponentielle
+  int degre=-1; if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
+  cout<<"Fit d'exponentielle+polynome 1D de degre "<<degre<<endl;
+  Exp1DPol* myf;
+  if(degre>=0) myf = new Exp1DPol((unsigned int)degre,mOpt.xc);
+       else    myf = new Exp1DPol(mOpt.xc);
+  mFunction = myf; mNPar = mFunction->NPar(); mFName = func;
+
+} else if(func[0]=='g' && mNVar==1) { //gaussienne en hauteur
+  int degre=-1; if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
+  cout<<"Fit de Gaussienne_en_hauteur+polynome 1D de degre "<<degre<<endl;
+  Gauss1DPol* myf;
+  if(degre>=0) myf = new Gauss1DPol((unsigned int)degre,((mOpt.polcx)?true:false));
+  else { bool bfg = (mOpt.polcx)?true:false;   myf = new Gauss1DPol(bfg); }
+  mFunction = myf; mNPar = mFunction->NPar(); mFName = func;
+
+} else if(func[0]=='G' && mNVar==1) { //gaussienne en volume
+  int degre=-1; if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
+  cout<<"Fit de Gaussienne_en_volume+polynome 1D de degre "<<degre<<endl;
+  GaussN1DPol* myf;
+  if(degre>=0) myf = new GaussN1DPol((unsigned int)degre,((mOpt.polcx)?true:false));
+  else  { bool bfg = (mOpt.polcx)?true:false;   myf = new GaussN1DPol(bfg); }
+  mFunction = myf; mNPar = mFunction->NPar(); mFName = func;
+
+} else if(func[0]=='p' && mNVar==2) { //polynome 2D
+  int degre=0; if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
+  cout<<"Fit polynome 2D de degre "<<degre<<endl;
+  Polyn2D* myf = new Polyn2D(degre,mOpt.xc,mOpt.yc);
+  mFunction = myf; mNPar = mFunction->NPar(); mFName = func;
+
+} else if(func[0]=='G' && mNVar==2) { //gaussienne+fond en volume
+  int integ=0; if(func.length()>1) if(func[1]=='i') integ=1;
+  cout<<"Fit de Gaussienne+Fond 2D integ="<<integ<<endl;
+  if(integ) {GauRhInt2D* myf = new GauRhInt2D; mFunction = myf;}
+    else    {GauRho2D*   myf = new GauRho2D;   mFunction = myf;}
+  mNPar = mFunction->NPar(); mFName = func;
+
+} else if(func[0]=='d' && mNVar==2) { //DL gaussienne+fond en volume
+  int integ=0; if(func.length()>1) if(func[1]=='i') integ=1;
+  cout<<"Fit de DL de Gaussienne+Fond 2D integ="<<integ<<endl;
+  if(integ) {GdlRhInt2D* myf = new GdlRhInt2D; mFunction = myf;}
+    else    {GdlRho2D*   myf = new GdlRho2D;   mFunction = myf;}
+  mNPar = mFunction->NPar(); mFName = func;
+
+} else if(func[0]=='D' && mNVar==2) { //DL gaussienne+fond avec coeff variable p6 en volume
+  int integ=0; if(func.length()>1) if(func[1]=='i') integ=1;
+  cout<<"Fit de DL de Gaussienne+Fond avec coeff variable (p6) 2D integ="<<integ<<endl;
+  if(integ) {Gdl1RhInt2D* myf = new Gdl1RhInt2D; mFunction = myf;}
+    else    {Gdl1Rho2D*   myf = new Gdl1Rho2D;   mFunction = myf;}
+  mNPar = mFunction->NPar(); mFName = func;
+
+} else if(func[0]=='M' && mNVar==2) { //Moffat+fond (volume)
+  int integ=0; if(func.length()>1) if(func[1]=='i') integ=1;
+  cout<<"Fit de Moffat+Fond (expos=p6) 2D integ="<<integ<<endl;
+  if(integ) {MofRhInt2D* myf = new MofRhInt2D; mFunction = myf;}
+    else    {MofRho2D*   myf = new MofRho2D;   mFunction = myf;}
+   mNPar = mFunction->NPar(); mFName = func;
+
+} else {
+  cout<<"Fonction "<<func<<" inconnue pour la dim "<<mNVar<<endl;
+  return;
+}
+
+return;
+}
+
+/* --Methode-- */
+void PIAFitter::ReSetParam(void)
+// Pour (re)dimensionner les tableaux des parametres
+// ATTENTION: cette methode a besoin que la fonction soit connue
+{
+if(mNPar==0) return;
+mPar.Realloc(mNPar);  mPar=0.;
+mStep.Realloc(mNPar); mStep=1.;
+mMin.Realloc(mNPar);  mMin=1.;
+mMax.Realloc(mNPar);  mMax=-1.;
+mFix.Realloc(mNPar);  mFix=0.;
+return;
+}
+
+/* --Methode-- */
+void PIAFitter::AutoIniFit(void)
+// Initialisation automatique des parametres du fit
+{
+if(mFunc) { // Fonction utilisateur
+  cout<<"PIAFitter::AutoIniFit : Fonction utilisateur, pas d'init auto"<<endl;
+} else if(mFName[0]=='p' && mNVar==1) { //poly 1D
+  cout<<"PIAFitter::AutoIniFit : Auto Init type polynome 1D"<<endl;
+  IniFitP1ou2D();
+
+} else if(mFName[0]=='g' && mNVar==1) { //gauss en haut 1D
+  cout<<"PIAFitter::AutoIniFit : Auto Init type gauss_haut+pol 1D"<<endl;
+  IniFitGhP1D();
+
+} else if(mFName[0]=='G' && mNVar==1) { //gauss en vol 1D
+  cout<<"PIAFitter::AutoIniFit : Auto Init type gauss_vol+pol 1D"<<endl;
+  IniFitGvP1D();
+
+} else if(mFName[0]=='p' && mNVar==2) { //poly 2D
+  cout<<"PIAFitter::AutoIniFit : Auto Init type polynome 2D"<<endl;
+  IniFitP1ou2D();
+
+} else if((mFName[0]=='G'||mFName[0]=='d') && mNVar==2) { //gauss+fond en vol
+  cout<<"PIAFitter::AutoIniFit : Auto Init type gauss_vol+fond 2D"<<endl;
+  IniFitGv2D();
+
+} else if(mFName[0]=='D' && mNVar==2) { //DLgauss+fond en vol 2D
+  cout<<"PIAFitter::AutoIniFit : Auto Init type DLgauss_vol+fond 2D"<<endl;
+  IniFitGv2D();
+  Vector dum(mNPar);
+  dum = mPar;  mPar(6)=0.5;   mPar(7)=dum(6);
+  dum = mStep; mStep(6)=0.05; mStep(7)=dum(6);
+  dum = mMin;  mMin(6)=0.;    mMin(7)=dum(6);
+  dum = mMax;  mMax(6)=10.;   mMax(7)=dum(6);
+  dum = mFix;  mFix(6)=1.1;   mFix(7)=dum(6);
+
+} else if(mFName[0]=='M' && mNVar==2) { //Moffat+fond en vol 2D
+  cout<<"PIAFitter::AutoIniFit : Auto Init type moffat_vol+fond 2D"<<endl;
+  IniFitGv2D();
+  Vector dum(mNPar);
+  dum = mPar;  mPar(6)=2.5;   mPar(7)=dum(6);
+  dum = mStep; mStep(6)=0.05; mStep(7)=dum(6);
+  dum = mMin;  mMin(6)=1.2;   mMin(7)=dum(6);
+  dum = mMax;  mMax(6)=10.;   mMax(7)=dum(6);
+  dum = mFix;  mFix(6)=1.1;   mFix(7)=dum(6);
+
+} else {
+  cout<<"PIAFitter::AutoIniFit : Fonction "<<mFName
+      <<", \n  pas d'init auto en dim "<<mNVar<<endl;
+  return;
+}
+
+return;
+}
+
+/* --Methode-- */
+void PIAFitter::InitParFromLastFit(void)
+// Initialisation du fit a partir des resultats du fit precedent
+// (Les arguments de la ligne de commande sont prioritaires)
+// ATTENTION: cette methode a besoin que la fonction soit connue
+{
+if(mNPar==0) return;
+int n = mParSave.NElts();
+if(n==0) return;
+
+for(int i=0;i<mNPar;i++) {
+  if(i>=n) break;
+  mPar(i)  = mParSave(i);
+  mStep(i) = mStepSave(i);
+  mMin(i)  = mMinSave(i);
+  mMax(i)  = mMaxSave(i);
+  mFix(i)  = mFixSave(i);
+}
+
+return;
+}
+
+/* --Methode-- */
+void PIAFitter::DecodeParam(string par,string step,string min,string max,string fix)
+// Decodage des parametres
+// ATTENTION: cette methode a besoin que la fonction soit connue
+//                            et que les options soient decodees
+{
+if(mNPar==0) return;
+ReSetParam();
+if(mOpt.autoinifit)  AutoIniFit();
+if(mOpt.fromlastfit) InitParFromLastFit();
+Vector* v=NULL; string* s=NULL;
+for(int j=0;j<5;j++) {
+  if(j==0) {v=&mPar; s=&par;} else if(j==1) {v=&mStep; s=&step;}
+  else if(j==2) {v=&mMin; s=&min;} else if(j==3) {v=&mMax; s=&max;}
+  else if(j==4) {v=&mFix; s=&fix;}
+  if(s->length()>0) *s += ",";
+  for(int i=0;i<mNPar;i++) {
+    if(s->length()<=0) break;
+    if((*s)[0]!='!') sscanf(s->c_str(),"%lf",&(*v)(i));
+    size_t p = s->find_first_of(',') + 1;
+    if(p>=s->length()) *s = ""; else *s = s->substr(p);
+  }
+}
+return;
+}
+
+/* --Methode-- */
+int PIAFitter::DoFit(void)
+// Fit avec generalfit
+{
+if(mNPar==0) return -1000;
+if((mFunction==NULL && mFunc==NULL) || mGData==NULL) {
+  cout<<"PIAFitter::DoFit error: mFunction,mFunc="<<mFunction<<","<<mFunc
+      <<" mGData="<<mGData<<endl;
+  return -1001;
+}
+// classe GeneraFit
+if(mFit != NULL) {delete mFit; mFit= NULL;}
+if(mFunction)    mFit = new GeneralFit(mFunction);
+  else if(mFunc) mFit = new GeneralFit(mFunc);
+if(!mFit) return(-1002);
+
+// Options et Set de GeneralFit
+mFit->SetDebug(mOpt.lpg);
+mFit->SetData(mGData);
+mFit->SetStopChi2(mOpt.stc2);
+mFit->SetMaxStep(mOpt.nstep);
+{for(int i=0;i<mNPar;i++) {
+  char str[10];
+  sprintf(str,"P%d",i);
+  mFit->SetParam(i,str,mPar(i),mStep(i),mMin(i),mMax(i));
+  if((int)(mFix(i)+0.001)>=1.) mFit->SetFix(i);
+}}
+if(mOpt.lp>1) mFit->PrintFit();
+
+// Fit
+mParSave = mPar;
+mStepSave = mStep; mMinSave = mMin; mMaxSave = mMax; mFixSave = mFix;
+mOptSave = mOpt;
+double c2r = -1.;
+int rcfit = mFit->Fit();
+if(mOpt.lp>0) mFit->PrintFit();
+if(rcfit>0) {
+  c2r = mFit->GetChi2Red();
+  cout<<"C2r_Reduit = "<<c2r<<" nstep="<<mFit->GetNStep()<<" rc="<<rcfit<<endl;
+  for(int i=0;i<mNPar;i++) mParSave(i)=mFit->GetParm(i);
+} else {
+  cout<<"echec Fit, rc = "<<rcfit<<"  nstep="<<mFit->GetNStep()<<endl;
+  mFit->PrintFitErr(rcfit);
+}
+
+return rcfit;
+}
+
+/* --Methode-- */
+void PIAFitter::FitFunRes(void)
+// Mise a disposition des resultats (fonction fitee et residus)
+{
+if(mFit && (mOpt.okres||mOpt.okfun)) {
+  NamedObjMgr omg;
+  string nomres = mNObj + "_res";
+  string nomfun = mNObj + "_fun";
+  if(mV) {
+    if(mOpt.okres) {Vector* ob = mV->FitResidus(*mFit);  if(ob) omg.AddObj(ob,nomres);}
+    if(mOpt.okfun) {Vector* ob = mV->FitFunction(*mFit); if(ob) omg.AddObj(ob,nomfun);}
+  } else if(mH) {
+    if(mOpt.okres) {Histo* ob = mH->FitResidus(*mFit);  if(ob) omg.AddObj(ob,nomres);}
+    if(mOpt.okfun) {Histo* ob = mH->FitFunction(*mFit); if(ob) omg.AddObj(ob,nomfun);}
+  } else if(mM) {
+    if(mOpt.okres) {Matrix* ob = mM->FitResidus(*mFit);  if(ob) omg.AddObj(ob,nomres);}
+    if(mOpt.okfun) {Matrix* ob = mM->FitFunction(*mFit); if(ob) omg.AddObj(ob,nomfun);}
+  } else if(mH2) {
+    if(mOpt.okres)
+      {Histo2D* ob = mH2->FitResidus(*mFit);  if(ob) omg.AddObj(ob,nomres);}
+    if(mOpt.okfun)
+      {Histo2D* ob = mH2->FitFunction(*mFit); if(ob) omg.AddObj(ob,nomfun);}
+  } else if(mIm) {
+    if(mOpt.okres) {
+      RzImage* ob = mIm->FitResidus(*mFit);  
+      if(ob) {ImageR4* rob = new ImageR4(*ob); omg.AddObj(rob,nomres); delete ob;}
+    }
+    if(mOpt.okfun) {
+      RzImage* ob = mIm->FitFunction(*mFit);
+      if(ob) {ImageR4* rob = new ImageR4(*ob); omg.AddObj(rob,nomfun); delete ob;}
+    }
+  } else if(mG) {
+    if(mOpt.okres)
+      {GeneralFitData* ob = mG->FitResidus(*mFit);  if(ob) omg.AddObj(ob,nomres);}
+    if(mOpt.okfun)
+      {GeneralFitData* ob = mG->FitFunction(*mFit); if(ob) omg.AddObj(ob,nomfun);}
+  }
+}
+return;
+}
+
+/* --Methode-- */
+void PIAFitter::LinFit(void)
+// Fit lineaire de polynomes
+{
+if(mFName.length()<=0)
+  {cout<<"PIAFitter::LinFit Donnez un nom de fonction a fitter."<<endl;
+   return;}
+if(!mGData)
+  {cout<<"PIAFitter::LinFit pas de Data."<<endl; return;}
+if(mFName[0]!='p') 
+  {cout<<"PIAFitter::LinFit fonction non prevue "<<mFName<<endl;
+   return;}
+int degre = 0;
+if(mFName.length()>1) sscanf(mFName.c_str()+1,"%d",&degre);
+
+if(mNVar==1) {  // Fit lineaire de polynome 1D
+  cout<<"Fit (lineaire) 1D polynome de degre "<<degre<<endl;
+  Poly p1(0);
+  double c2rl = mGData->PolFit(0,p1,degre);
+  cout<<"C2r_lineaire = "<<c2rl<<endl;
+  if(mOpt.lp>0) cout<<p1<<endl;
+} else if(mNVar==2) {  // Fit lineaire de polynome 2D
+  cout<<"Fit (lineaire) polynome 2D de degre "<<degre<<endl;
+  Poly2 p2(0);
+  double c2rl = mGData->PolFit(0,1,p2,degre);
+  cout<<"C2r_lineaire = "<<c2rl<<endl;
+  if(mOpt.lp>0) cout<<p2<<endl;
+}
+
+return;
+}
+
+/* --Methode-- */
+void PIAFitter::LinkFitFunc(string const& fname, string const& funcname
+                           ,int nvar,int npar)
+// Compilation et link dynamique de la fonction a fitter
+{
+if(nvar<1 || npar<1) return;
+if(mDlUFunc != NULL) {delete mDlUFunc;  mDlUFunc=NULL;}
+mFitFunc = NULL; mFitFuncDer = NULL; 
+mUFNVar= mUFNPar = 0; mNameFitFunc = "";
+
+// On compile le fichier C, on fabrique un .so et on l'ouvre
+mDlUFunc = PDynLinkMgr::BuildFromCFile(fname);
+if(mDlUFunc == NULL)
+  {cerr<<"PIAFitter::LinkFitFunc() Erreur building .so "<<endl; return;}
+
+// On recupere la fonction de fit
+mFitFunc = (DlUserFitFunc) mDlUFunc->GetFunction(funcname);
+if(mFitFunc == NULL)  // Probleme, on n'a pas trouve etc ... 
+  {cerr<<"PIAFitter::LinkFitFunc() Erreur linking function"<<funcname<<endl;
+   delete mDlUFunc; mDlUFunc = NULL; return;}
+
+// On recupere la fonction des derivees
+string fnameder = funcname+"_der";
+mFitFuncDer = (DlUserFitFuncDer) mDlUFunc->GetFunction(fnameder);
+if(mFitFuncDer == NULL)
+  {cout<<"PIAFitter::LinkFitFunc() No derive for"<<fnameder<<endl;}
+
+// Variables et pointeurs definissant le link a la fonction utilisateur
+mNameFitFunc = funcname;
+mUFNVar = nvar;
+mUFNPar = npar;
+cout<<"PIAFitter::LinkFitFunc() UserFitFunc="<<mNameFitFunc
+    <<" NVar="<<mUFNVar<<" NPar="<<mUFNPar<<endl;
+
+return;
+}
+
+/* --Methode-- */
+void PIAFitter::PrepareFitFuncCFile(string const& fname, string const& funcname
+                                   , int nvar, int npar)
+// Pour ecrire un squelette des fichier C avec pour une fonction a fitter
+{
+if(fname.length()<=0 || funcname.length()<=0 || nvar<=0 || npar <=0) {
+  cerr<<"PIAFitter::PrepareFitFuncCFile: error "
+      <<" nvar="<<nvar<<" npar="<<npar<<endl
+      <<" file_name="<<fname<<" func_name="<<funcname<<endl
+      <<" ---- No File Created ! ----"<<endl;
+  return;
+}
+
+FILE* fip = fopen(fname.c_str(),"w");
+if(fip==NULL)
+  {cerr<<"PIAFitter::PrepareFitFuncCFile: error opening file for writing\n"
+       <<fname<<endl; return;}
+
+fprintf(fip,"#include <stdio.h>\n#include <stdlib.h>\n#include <math.h>\n\n");
+fprintf(fip,"/* - many functions can be written in this file: */\n");
+fprintf(fip,"/*   here is an exemple for creation of function %s */\n\n"
+       ,funcname.c_str());
+fprintf(fip,"double %s(double const* x,double const* p)\n",funcname.c_str());
+fprintf(fip,"/* Function : F(x[0-%d];p[0-%d]) */\n",nvar-1,npar-1);
+fprintf(fip,"/* variables  x1=x[0],x2=x[1],...,x%d=x[%d] */\n",nvar,nvar-1);
+fprintf(fip,"/* parameters p1=p[0],p2=p[1],...,p%d=p[%d] */\n",nvar,nvar-1);
+fprintf(fip,"{\n  val = F(x[];p[]);\n  return(val);\n}\n\n");
+string fder = funcname + "_der";
+fprintf(fip,"/* That function is optional */\n");
+fprintf(fip,"/*\n");
+fprintf(fip,"double %s(double const* x,double const* p,double* dp)\n",fder.c_str());
+fprintf(fip,"{\n");
+for(int i=0;i<npar;i++) fprintf(fip,"  dp[%d] = dF(x[];p[])/dp[%d]\n",i,i);
+fprintf(fip,"  val = F(x[];p[]);\n  return(val);\n}\n\n");
+fprintf(fip,"*/\n");
+
+fclose(fip);
+}
+
+/* --Methode-- */
+int PIAFitter::Execute(string& kw, vector<string>& tokens)
+// Execution des commandes de fit : "fit" et "fitw"
+{
+////// Les commandes pour creer les fonctions de fit utilisateur
+if(kw == "crfitfil") {
+  if (tokens.size() < 4)
+    {cout<<"Usage:crfitfil filename funcname nvar npar"<<endl;return(-1);}
+  int nvar = atoi(tokens[2].c_str()), npar = atoi(tokens[3].c_str());
+  PrepareFitFuncCFile(tokens[0],tokens[1],nvar,npar);
+  return(0);
+} else if (kw == "crfitfun") {
+  if (tokens.size() < 4)
+    {cout<<"Usage:crfitfun filename funcname nvar npar"<<endl;return(-1);}
+  int nvar = atoi(tokens[2].c_str()), npar = atoi(tokens[3].c_str());
+  LinkFitFunc(tokens[0],tokens[1],nvar,npar);
+  return(0);
+}
+
+////// Les commandes pour fitter
+if(tokens.size() < 2) {
+  cout
+  <<"Usage:fit  nomobj func [Options]\n"
+  <<" ou   fitw nomobj func [Options]\n"
+  <<" avec Options: [p:p1,...,pn s:s1,...,sn m:m1,...,mn \n"
+  <<"                M:M1,...,Mn f:f1,...,fn o:.,.,. o:.,.,.]\n"
+  <<" ou   fitlin nomobj func [o:.,.,. o:.,.,.]\n";
+  return(-1);
+}
+
+// decodage des arguments de la commande
+string mSp,mSs,mSm,mSM,mSf,mSo;
+mSp=""; mSs=""; mSm=""; mSM=""; mSf=""; mSo="";
+if(tokens.size()>2)
+  for(int ip=2;ip<(int)tokens.size();ip++) {
+    if(tokens[ip].length()<=2) continue;
+    const char *c = tokens[ip].c_str();
+    if(c[1]!=':') continue;
+    if(c[0]=='p')      mSp=c+2;
+    else if(c[0]=='s') mSs=c+2;
+    else if(c[0]=='m') mSm=c+2;
+    else if(c[0]=='M') mSM=c+2;
+    else if(c[0]=='f') mSf=c+2;
+    else if(c[0]=='o') {mSo += ","; mSo += c+2;}
+  }
+
+// Execution des commandes
+DecodeOptions(mSo);
+DecodeObject(tokens[0]);
+CheckOptions();
+if(mOpt.lp>0) PrintOptions();
+FillGData();
+DecodeFunction(tokens[1]);
+DecodeParam(mSp,mSs,mSm,mSM,mSf);
+if (kw == "fit") {
+  int rc = DoFit();
+  if(rc>=0) FitFunRes();
+} else if (kw == "fitlin") {
+  LinFit();
+} else if (kw == "fitw") {
+  if(FWindFit!=NULL) {delete FWindFit; FWindFit=NULL;}
+  FWindFit = new PIAFitterWind(mApp,this);
+  FWindFit->Show();
+}
+
+return(0);
+}
+
+/* --Methode-- */
+void PIAFitter::IniFitP1ou2D(void)
+{
+if(mNPar==0) return;
+mPar=0.; mStep=1.; mMin=1.; mMax=-1.; mFix=0.;
+if(!mGData) return;
+double mean,sigma;
+int rc = mGData->GetMeanSigma(0,mean,sigma);
+if(rc<=0) return;
+mPar(0) = mean;
+return;
+}
+
+void PIAFitter::IniFitGhP1D(void)
+{
+if(mNPar==0) return;
+mPar=0.; mStep=1.; mMin=1.; mMax=-1.; mFix=0.;
+if(mNVar!=1 || mNPar<3) return;
+double h,v,x0,y0,sx,sy,f;
+int rc = IniFitGaus(*mGData,h,v,x0,y0,sx,sy,f);
+if(rc!=0) return;
+mPar(0)=h;  mStep(0)=h/1000.;
+mPar(1)=x0; mStep(1)=sx/10.;
+mPar(2)=sx; mStep(2)=sx/10.; mMin(2)=0.; mMax(2)=20.*sx; 
+if(mNPar>3) {mPar(3)=f; mStep(3)=f/1000.;} else mPar(0)=h+f;
+}
+
+void PIAFitter::IniFitGvP1D(void)
+{
+if(mNPar==0) return;
+mPar=0.; mStep=1.; mMin=1.; mMax=-1.; mFix=0.;
+if(mNVar!=1 || mNPar<3) return;
+double h,v,x0,y0,sx,sy,f;
+int rc = IniFitGaus(*mGData,h,v,x0,y0,sx,sy,f);
+if(rc!=0) return;
+mPar(0)=v;  mStep(0)=v/1000.;
+mPar(1)=x0; mStep(1)=sx/10.;
+mPar(2)=sx; mStep(2)=sx/10.; mMin(2)=0.; mMax(2)=20.*sx; 
+if(mNPar>3) {mPar(3)=f; mStep(3)=f/1000.;} else mPar(0)=v+mNData*f;
+}
+
+void PIAFitter::IniFitGv2D(void)
+{
+if(mNPar==0) return;
+mPar=0.; mStep=1.; mMin=1.; mMax=-1.; mFix=0.;
+if(mNVar!=2 || mNPar<6) return;
+double h,v,x0,y0,sx,sy,f;
+int rc = IniFitGaus(*mGData,h,v,x0,y0,sx,sy,f);
+if(rc!=0) return;
+mPar(0)=v;  mStep(0)=v/1000.;
+mPar(1)=x0; mStep(1)=sx/10.;
+mPar(2)=y0; mStep(2)=sy/10.;
+mPar(3)=sx; mStep(3)=sx/10.; mMin(3)=0.;  mMax(3)=20.*sx; 
+mPar(4)=sy; mStep(4)=sy/10.; mMin(4)=0.;  mMax(4)=20.*sy; 
+mPar(5)=0.; mStep(5)=0.005;  mMin(5)=-1.; mMax(5)=1.; 
+if(mNPar>6) {mPar(6)=f; mStep(6)=f/1000.;} else mPar(0)=v+mNData*f;
+}
+
+int PIAFitter::IniFitGaus(GeneralFitData& g,double& h,double& v
+    ,double& x0,double& y0,double& sx,double& sy,double& f)
+// Pour initialiser une gaussienne 1D ou 2D
+// return code =0 si OK
+{
+h=v=x0=y0=sx=sy=f=0.;
+if(!&g) return(-1);
+int nvar = g.NVar();
+int ndata = g.NData();
+if(nvar<1 || 2<nvar || ndata<=0) return(-2);
+
+// X et Y ordonnees croissant
+double *X=NULL, *Y=NULL;
+X = new double[ndata];
+if(nvar==2) Y = new double[ndata];
+{for(int i=0;i<ndata;i++) {X[i] = g.X(i); if(Y) Y[i] = g.Y(i);}}
+qsort(X,(size_t) ndata,sizeof(double),qSort_Dble);
+if(Y) qsort(Y,(size_t) ndata,sizeof(double),qSort_Dble);
+
+// determination des zones externes=[0,1/3] et [2/3,1]
+//            et des zones internes=[1/3,2/3]
+int k1=ndata/3,k2=2*ndata/3;
+double xmin,xmax, ymin=-1.,ymax=1.;
+xmin = X[k1]; xmax = X[k2];
+if(Y) {ymin = Y[k1]; ymax = Y[k2];}
+
+// recherche des parametres
+double nb=0, nc=0;
+{for(int i=0;i<ndata;i++) {
+   double val,x,y=0.;
+   x = g.X(i); if(Y) y = g.Y(i); val = g.Val(i);
+   if(xmin<x && x<xmax && ymin<y && y<ymax) { // c'est le centre
+     if(nc==0 || val>h) {h=val; x0=x; y0=y;}
+     v += val; nc++;
+   } else {f += val; nb++;} // c'est le bord
+
+}}
+if(nb==0 || nc==0) {delete [] X; if(Y) delete [] Y; return(-3);}
+
+// Calcul des parametres
+f /= (double) nb; h -= f; v -= f*nc;
+sx = (xmax-xmin)/2.; if(Y) sy = (ymax-ymin)/2.; 
+
+delete [] X; if(Y) delete [] Y;
+return(0);
+}
+
+
+////////////////////////////////////////////////////////////////////
+////---------- Classe de fenetre de fit interactive ------------////
+////////////////////////////////////////////////////////////////////
+
+/* --Methode-- */
+PIAFitterWind::PIAFitterWind(PIStdImgApp* par, PIAFitter* fiter)
+: PIWindow((PIMsgHandler*)par, "PIAFitter", PIWK_normal, 240, 240, 150, 150)
+, mDap(par), mFitter(fiter), ReFillGData(false)
+, saveI1(0), saveI2(0), saveJ1(0), saveJ2(0), ErrValue(1.)
+{
+COMPATIBLE_ASSERT(mFitter);
+int npar = mFitter->mNPar;
+
+// Alloc de la taille
+nlab = 13+npar;   lab = new PILabel*[nlab];    {for(int i=0;i<nlab;i++) lab[i]=NULL;}
+ntxt = 10+4*npar; txt = new PIText*[ntxt];     {for(int i=0;i<ntxt;i++) txt[i]=NULL;}
+nbut = 6;         but = new PIButton*[nbut];   {for(int i=0;i<nbut;i++) but[i]=NULL;}
+nckb = 2+npar;    ckb = new PICheckBox*[nckb]; {for(int i=0;i<nckb;i++) ckb[i]=NULL;}
+npom = 3;         pom = new PIOptMenu*[npom];  {for(int i=0;i<npom;i++) pom[i]=NULL;}
+
+// On definit la taille a partir de la taille par defaut des composantes
+// bsx,bsy = environ 6 lettres
+int bsx,bsy;
+par->PrefCompSz(bsx, bsy);
+int spx = (bsx>=10) ? bsx/10 : 1;  // intervalle entre lettres X
+int spy = (bsy>=6) ? bsy/6 : 1;    // intervalle entre lettres Y
+
+int wszx = (5*bsx+5*spx)+spx;
+int wszy = 8*(bsy+spy)+npar*(bsy+spy)+2*spy;
+SetSize(wszx, wszy);
+int cpx,cpy;
+
+// new ligne
+cpx = spx; cpy = spy;
+string dum = "Object: "+mFitter->mNObj+" , Fun: ";
+if(mFitter->mFunc) dum+=mFitter->mNameFitFunc; else dum+=mFitter->mFName;
+lab[0] = new PILabel(this,dum.c_str(),4*bsx,bsy,cpx,cpy);
+lab[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+// new ligne
+cpx = spx; cpy += bsy+spy;
+but[0] = new PIButton(this,"Fr.Last",111,bsx,bsy,cpx,cpy);
+but[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += bsx+spx;
+but[1] = new PIButton(this,"Default",222,bsx,bsy,cpx,cpy);
+but[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += bsx+spx;
+ckb[0] = new PICheckBox(this,"Gen Fun",1001,bsx,bsy,cpx,cpy);
+ckb[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += bsx+2*spx;
+ckb[1] = new PICheckBox(this,"Res",1002,bsx,bsy,cpx,cpy);
+ckb[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+// new ligne
+cpx = spx; cpy += bsy+spy;
+pom[0] = new PIOptMenu(this,"Err def",1.5*bsx,bsy,cpx,cpy);
+  pom[0]->AppendItem("Err def",2101);
+  pom[0]->AppendItem("Err cste",2102);
+  pom[0]->AppendItem("Err sqrt",2103);
+  pom[0]->SetValue(2101);
+pom[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += int(1.5*bsx+spx);
+txt[0] = new PIText(this,"",bsx,bsy,cpx,cpy);
+txt[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += bsx+spx;
+lab[1] = new PILabel(this,"Prt,dbg",bsx,bsy,cpx,cpy);
+lab[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += bsx+spx;
+txt[1] = new PIText(this,"",bsx,bsy,cpx,cpy);
+txt[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+// new ligne
+cpx = spx; cpy += bsy+spy;
+lab[2] = new PILabel(this,"Stop Xi2",1.25*bsx,bsy,cpx,cpy);
+lab[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += int(1.25*bsx+spx);
+txt[2] = new PIText(this,"",bsx,bsy,cpx,cpy);
+txt[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += bsx+spx;
+lab[3] = new PILabel(this,"Iter",bsx, bsy, cpx, cpy);
+lab[3]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += bsx+spx;
+txt[3] = new PIText(this,"",bsx,bsy,cpx,cpy);
+txt[3]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+// new ligne
+cpx = spx; cpy += bsy+spy;
+lab[4] = new PILabel(this,"Range X",bsx,bsy,cpx,cpy);
+lab[4]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += bsx+spx;
+txt[4] = new PIText(this,"",0.75*bsx,bsy,cpx,cpy);
+txt[4]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += int(0.75*bsx+spx);
+txt[5] = new PIText(this,"",0.75*bsx,bsy,cpx,cpy);
+txt[5]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += int(0.75*bsx+spx);
+lab[5] = new PILabel(this,"Y",bsx/2,bsy,cpx,cpy);
+lab[5]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += int(bsx/2.+spx);
+txt[6] = new PIText(this,"",0.75*bsx,bsy,cpx,cpy);
+txt[6]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += int(0.75*bsx+spx);
+txt[7] = new PIText(this,"",0.75*bsx,bsy,cpx,cpy);
+txt[7]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+// new ligne
+cpx = spx; cpy += bsy+spy;
+lab[6] = new PILabel(this,"Cent",bsx/2,bsy,cpx,cpy);
+lab[6]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += int(bsx/2.+spx);
+pom[1] = new PIOptMenu(this,"X.No",1.25*bsx,bsy,cpx,cpy);
+  pom[1]->AppendItem("X.No",2001);
+  pom[1]->AppendItem("X.Value",2002);
+  pom[1]->AppendItem("X.Auto",2003);
+  pom[1]->SetValue(2001);
+pom[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += int(1.25*bsx+spx);
+txt[8] = new PIText(this,"",bsx,bsy,cpx,cpy);
+txt[8]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += bsx+spx;
+pom[2] = new PIOptMenu(this,"Y.No",1.25*bsx,bsy,cpx,cpy);
+  pom[2]->AppendItem("Y.No",2011);
+  pom[2]->AppendItem("Y.Value",2012);
+  pom[2]->AppendItem("Y.Auto",2013);
+  pom[2]->SetValue(2011);
+pom[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += int(1.25*bsx+spx);
+txt[9] = new PIText(this,"",bsx,bsy,cpx,cpy);
+txt[9]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+// new ligne
+cpx = spx; cpy += bsy+spy;
+but[2] = new PIButton(this, "Dismiss",777,bsx,bsy,cpx,cpy);
+but[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += bsx+spx;
+but[3] = new PIButton(this, "Check",666,bsx,bsy,cpx,cpy);
+but[3]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += bsx+spx;
+but[4] = new PIButton(this, "Fit",333,bsx,bsy,cpx,cpy);
+but[4]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += bsx+spx;
+but[5] = new PIButton(this, "Ini Auto",444,bsx,bsy,cpx,cpy);
+but[5]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+// new ligne
+cpx = spx; cpy += bsy+spy;
+lab[7] = new PILabel(this,"Par",bsx/2,bsy,cpx,cpy);
+lab[7]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += int(bsx/2.+spx);
+lab[8] = new PILabel(this,"Fx",bsx/3,bsy,cpx,cpy);
+lab[8]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += int(bsx/3.+spx);
+lab[9] = new PILabel(this,"Init",bsx,bsy,cpx,cpy);
+lab[9]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += bsx+spx;
+lab[10] = new PILabel(this,"Step",bsx,bsy,cpx,cpy);
+lab[10]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += bsx+spx;
+lab[11] = new PILabel(this,"Min",bsx,bsy,cpx,cpy);
+lab[11]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+cpx += bsx+spx;
+lab[12] = new PILabel(this,"Max",bsx,bsy,cpx,cpy);
+lab[12]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+// new lines: Parametres (npar lignes)
+if(npar>0) {
+  for(int i=0;i<npar;i++) {
+    cpx = spx; cpy += bsy+spy;
+    char str[8]; sprintf(str,"P%d",i);
+    lab[13+i] = new PILabel(this,str,bsx/2,bsy,cpx,cpy);
+    lab[13+i]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+    cpx += int(bsx/2.+spx);
+    // Attention pas de message entre 1500 et 2000 (permet 500 parametres!)
+    ckb[2+i] = new PICheckBox(this,"",1500+i,bsx/3,bsy,cpx,cpy+spy);
+    ckb[2+i]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+    cpx+=int(bsx/3.+spx);
+    for(int j=0;j<4;j++) {
+      txt[10+4*i+j] = new PIText(this,"",bsx,bsy,cpx,cpy);
+      txt[10+4*i+j]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+      cpx += bsx+spx;
+    }
+  }
+}
+
+return;
+}
+
+/* --Methode-- */
+PIAFitterWind::~PIAFitterWind()
+{
+int i;
+for(i=0;i<nlab;i++) if(lab[i]) {delete lab[i]; lab[i]=NULL;}
+for(i=0;i<ntxt;i++) if(txt[i]) {delete txt[i]; txt[i]=NULL;}
+for(i=0;i<nbut;i++) if(but[i]) {delete but[i]; but[i]=NULL;}
+for(i=0;i<nckb;i++) if(ckb[i]) {delete ckb[i]; ckb[i]=NULL;}
+for(i=0;i<npom;i++) if(pom[i]) {delete pom[i]; pom[i]=NULL;}
+if(lab) {delete lab; lab=NULL; nlab=0;}
+if(txt) {delete txt; txt=NULL; ntxt=0;}
+if(but) {delete but; but=NULL; nbut=0;}
+if(ckb) {delete ckb; ckb=NULL; nckb=0;}
+if(pom) {delete pom; pom=NULL; npom=0;}
+}
+
+/* --Methode-- */
+void PIAFitterWind::Show()
+{
+//mDap->SetBlocked();
+SetState();
+PIWindow::Show();
+return;
+}
+
+/* --Methode-- */
+void PIAFitterWind::SetState(void)
+// Ecriture et positionnement des ckb et txt
+{
+int npar = mFitter->mNPar;
+
+// Les check-boxes
+ckb[0]->SetState(mFitter->mOpt.okfun);
+ckb[1]->SetState(mFitter->mOpt.okres);
+if(npar>0)
+  for(int i=0;i<npar;i++) ckb[2+i]->SetState((mFitter->mFix(i)>=1.)?true:false);
+
+// Les champs textes
+char str[128]; string dum;
+sprintf(str,"%f",ErrValue); dum=str; txt[0]->SetText(dum);
+sprintf(str,"%d,%d",mFitter->mOpt.lp,mFitter->mOpt.lpg); dum=str; txt[1]->SetText(dum);
+sprintf(str,"%f",mFitter->mOpt.stc2);  dum=str; txt[2]->SetText(dum);
+sprintf(str,"%d",mFitter->mOpt.nstep); dum=str; txt[3]->SetText(dum);
+sprintf(str,"%d",mFitter->mOpt.i1);    dum=str; txt[4]->SetText(dum);
+sprintf(str,"%d",mFitter->mOpt.i2);    dum=str; txt[5]->SetText(dum);
+sprintf(str,"%d",mFitter->mOpt.j1);    dum=str; txt[6]->SetText(dum);
+sprintf(str,"%d",mFitter->mOpt.j2);    dum=str; txt[7]->SetText(dum);
+sprintf(str,"%f",mFitter->mOpt.xc);    dum=str; txt[8]->SetText(dum);
+sprintf(str,"%f",mFitter->mOpt.yc);    dum=str; txt[9]->SetText(dum);
+if(npar>0) {
+  for(int i=0;i<npar;i++) {
+    sprintf(str,"%f",mFitter->mPar(i));  dum=str; txt[10+4*i+0]->SetText(dum);
+    sprintf(str,"%f",mFitter->mStep(i)); dum=str; txt[10+4*i+1]->SetText(dum);
+    sprintf(str,"%f",mFitter->mMin(i));  dum=str; txt[10+4*i+2]->SetText(dum);
+    sprintf(str,"%f",mFitter->mMax(i));  dum=str; txt[10+4*i+3]->SetText(dum);
+  }
+}
+
+return;
+}
+
+/* --Methode-- */
+void PIAFitterWind::Process(PIMessage msg, PIMsgHandler* sender, void* data)
+{
+int lp = (mFitter->mOpt.lp>2)?1:0;;
+int npar = mFitter->mNPar;
+
+// Decodage des messages, init et dismiss
+msg = UserMsg(msg);
+if(msg ==777) {
+  if(lp) cout<<"Dismiss"<<endl;
+  //mDap->SetReady();
+  Hide();
+  return;
+}
+
+// L'objet existe t-il encore?
+NamedObjMgr omg;
+if(omg.GetObj(mFitter->mNObj) == NULL) {
+  cout<<"PIAFitterWind::Process Error , Pas d'objet de nom "
+      <<mFitter->mNObj<<endl;
+  mFitter->ResetDPointer(); return;
+}
+
+// On recupere les champs textes
+string dum; char str[128];
+// Attention gestion du type d'erreur
+dum=txt[0]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' ');
+  sscanf(str,"%lf",&ErrValue); if(ErrValue<=0.) ErrValue=1.;
+  if(mFitter->mOpt.err_e>0. ) mFitter->mOpt.err_e = ErrValue;
+  if(mFitter->mOpt.err_E>0. ) mFitter->mOpt.err_E = ErrValue;
+dum=txt[1]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' ');
+  sscanf(str,"%d,%d",&(mFitter->mOpt.lp),&(mFitter->mOpt.lpg));
+dum=txt[2]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' ');
+  sscanf(str,"%lf",&(mFitter->mOpt.stc2));
+dum=txt[3]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' ');
+  sscanf(str,"%d",&(mFitter->mOpt.nstep));
+// Attention si les valeurs de mOpt.i1/.i2/.j1/.j2 ont ete changees
+dum=txt[4]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' ');
+  sscanf(str,"%d",&(mFitter->mOpt.i1));
+dum=txt[5]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' ');
+  sscanf(str,"%d",&(mFitter->mOpt.i2));
+dum=txt[6]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' ');
+  sscanf(str,"%d",&(mFitter->mOpt.j1));
+dum=txt[7]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' ');
+  sscanf(str,"%d",&(mFitter->mOpt.j2));
+  if(saveI1!=mFitter->mOpt.i1 || saveI2!=mFitter->mOpt.i2 ||
+     saveJ1!=mFitter->mOpt.j1 || saveJ2!=mFitter->mOpt.j2 ) {
+    if(lp)
+      cout<<"Range changed: I("<<saveI1<<","<<saveI2
+          <<") -> I("<<mFitter->mOpt.i1<<","<<mFitter->mOpt.i2
+          <<")  ou   J("<<saveJ1<<","<<saveJ2
+          <<") -> J("<<mFitter->mOpt.j1<<","<<mFitter->mOpt.j2
+          <<")"<<endl;
+    ReFillGData = true;
+    saveI1=mFitter->mOpt.i1; saveI2=mFitter->mOpt.i2;
+    saveJ1=mFitter->mOpt.j1; saveJ2=mFitter->mOpt.j2;
+  }
+dum=txt[8]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' ');
+  sscanf(str,"%lf",&(mFitter->mOpt.xc));
+dum=txt[9]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' ');
+  sscanf(str,"%lf",&(mFitter->mOpt.yc));
+
+if(npar>0) {
+  for(int i=0;i<npar;i++) {
+    dum=txt[10+4*i+0]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' ');
+      sscanf(str,"%lf",&(mFitter->mPar(i)));
+    dum=txt[10+4*i+1]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' ');
+      sscanf(str,"%lf",&(mFitter->mStep(i)));
+    dum=txt[10+4*i+2]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' ');
+      sscanf(str,"%lf",&(mFitter->mMin(i)));
+    dum=txt[10+4*i+3]->GetText(); strcpy(str,dum.c_str()); strip(str,'B',' ');
+      sscanf(str,"%lf",&(mFitter->mMax(i)));
+  }
+}
+
+// Decodage des messages, suite
+if(msg ==666) {
+  if(lp) cout<<"Check"<<endl;
+  mFitter->CheckOptions();
+  if(ReFillGData) mFitter->FillGData();
+  ReFillGData = false;
+  if(mFitter->mFit) mFitter->mFit->PrintStatus();
+}
+else if(msg ==111) {
+  if(lp) cout<<"Update from last"<<endl;
+  mFitter->ResetOptions();
+  mFitter->mOpt = mFitter->mOptSave;
+  mFitter->ReSetParam();
+  mFitter->InitParFromLastFit();
+  ReFillGData = true;
+}
+else if(msg ==222) {
+  if(lp) cout<<"Default options/par"<<endl;
+  mFitter->ResetOptions();
+  mFitter->ReSetParam();
+  ReFillGData = true;
+}
+else if(msg ==333) {
+  if(lp) cout<<"Do the fit"<<endl;
+  mFitter->CheckOptions();
+  if(ReFillGData) mFitter->FillGData();
+  ReFillGData = false;
+  int rc = mFitter->DoFit();
+  if(rc>=0) mFitter->FitFunRes();
+}
+else if(msg ==444) {
+  if(lp) cout<<"Automatic initialisation"<<endl;
+  mFitter->AutoIniFit();
+}
+else if(msg==1001) {
+  if(ckb[0]->GetState()) {
+    if(lp) cout<<"Gen fitted function"<<endl;
+    mFitter->mOpt.okfun = true;
+  } else if(!ckb[0]->GetState()) {
+    if(lp) cout<<"No Gen fitted function"<<endl;
+    mFitter->mOpt.okfun = false;
+  }
+}
+else if(msg==1002) {
+  if(ckb[1]->GetState()) {
+    if(lp) cout<<"Gen fitted residus"<<endl;
+    mFitter->mOpt.okres = true;
+  } else if(!ckb[1]->GetState()) {
+    if(lp) cout<<"No Gen fitted residus"<<endl;
+    mFitter->mOpt.okres = false;
+  }
+}
+else if(2101<=msg && msg<=2103) {
+  mFitter->mOpt.err_e = mFitter->mOpt.err_E = -1.;
+  if(msg==2102)      mFitter->mOpt.err_e = ErrValue;
+  else if(msg==2103) mFitter->mOpt.err_E = ErrValue;
+  if(lp) cout<<"Err_cste="<<mFitter->mOpt.err_e
+             <<" Err_sqrt="<<mFitter->mOpt.err_E
+             <<" ErrValue="<<ErrValue<<endl;
+  ReFillGData = true;
+}
+else if(2001<=msg && msg<=2003) {
+  mFitter->mOpt.polcx = msg-2001;
+  if(lp) cout<<"Centrage X polcx="<<mFitter->mOpt.polcx
+             <<" xc="<<mFitter->mOpt.xc<<endl;
+  ReFillGData = true;
+}
+else if(2011<=msg && msg<=2013) {
+  mFitter->mOpt.polcy = msg-2011;
+  if(lp) cout<<"Centrage Y polcy="<<mFitter->mOpt.polcy
+             <<" yc="<<mFitter->mOpt.yc<<endl;
+  ReFillGData = true;
+}
+else if(msg>=1500 && msg<2000) {
+  int ip = msg-1500;
+  if(ckb[2+ip]->GetState()) {
+    if(lp) cout<<"Fix Param "<<ip<<endl;
+    mFitter->mFix(ip) = 1.001;
+  } else if(!ckb[2+ip]->GetState()) {
+    if(lp) cout<<"Not Fix Param "<<ip<<endl;
+    mFitter->mFix(ip) = 0.;
+  }
+}
+
+mFitter->CheckOptions();
+SetState();
+if(mFitter->mOpt.lp>1) mFitter->PrintOptions();
+
+return;
+}
Index: /tags/V_LaSilla191199/SophyaPI/PIext/piafitting.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/piafitting.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/piafitting.h	(revision 464)
@@ -0,0 +1,103 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Classe d ajustement pour  piapp 
+// cmv                            98-99
+// CEA-DAPNIA      LAL-IN2P3/CNRS
+
+#ifndef PIAFITTING_H_SEEN
+#define PIAFITTING_H_SEEN
+
+#include "machdefs.h"
+#include <string>
+#include <vector>
+
+#include "anydataobj.h"
+
+#include "pdlmgr.h"
+#include "dlftypes.h"
+#include "piacmd.h"
+#include "cvector.h"
+
+class PIStdImgApp;
+class PIAFitterWind;
+class GeneralFunction; class GeneralFunc; class GeneralFit;
+class GeneralFitData;
+class Histo; class Matrix; class Histo2D; class RzImage;
+
+class PIAFitter : public CmdExecutor {
+public :
+  PIAFitter(PIACmd* piac, PIStdImgApp* app);
+  virtual ~PIAFitter();
+  virtual int Execute(string& keyw, vector<string>& args);
+  virtual void LinkFitFunc(string const& fname, string const& funcname
+                          ,int nvar,int npar);
+  virtual void PrepareFitFuncCFile(string const& fname, string const& funcname
+                                  ,int nvar,int npar);
+
+friend class PIAFitterWind;
+
+protected :
+
+typedef struct DFOptions {
+  bool okres, okfun;
+  int polcx,polcy; double xc,yc;
+  double err_e, err_E;
+  double stc2;
+  int nstep;
+  int lp,lpg;
+  int i1,i2,j1,j2;
+  bool fromlastfit,autoinifit;
+} DFOPTIONS ;
+
+void ResetDPointer(void);
+void ResetOptions(void);
+void DecodeOptions(string opt);
+void DecodeObject(string obj);
+void CheckOptions(void);
+void PrintOptions(void);
+void FillGData(void);
+void DecodeFunction(string func);
+void ReSetParam(void);
+void AutoIniFit(void);
+void InitParFromLastFit(void);
+void DecodeParam(string par,string step,string min,string max,string fix);
+int  DoFit(void);
+void FitFunRes(void);
+void LinFit(void);
+
+// pour initialiser les parametres du fit
+void IniFitP1ou2D(void);
+void IniFitGhP1D(void);
+void IniFitGvP1D(void);
+void IniFitGv2D(void);
+static int IniFitGaus(GeneralFitData& g,double& h,double& v
+       ,double& x0,double& y0,double& sx,double& sy,double& f);
+
+// Graphique
+PIStdImgApp* mApp; // Do not delete
+PIAFitterWind* FWindFit; // Fenetre de config interactive
+// Objet a fitter
+string mNObj; AnyDataObj* mObj; // Do not delete
+// Structure de data pour le fit, parametres et options
+GeneralFitData* mGData;
+int mNPar,mNVar,mNBinX,mNBinY,mNData;
+Vector mPar; Vector mStep; Vector mMin; Vector mMax; Vector mFix;
+Vector mParSave; Vector mStepSave; Vector mMinSave; Vector mMaxSave; Vector mFixSave;
+GeneralFit* mFit;
+DFOPTIONS mOpt;
+DFOPTIONS mOptSave;
+// Possibles objets a fitter
+Vector* mV; Histo* mH; // Do not delete
+Matrix* mM; Histo2D* mH2; RzImage* mIm; // Do not delete
+GeneralFitData* mG; // Do not delete
+// Gestion des fonctions de fit predefinies
+GeneralFunction* mFunction; string mFName;
+// Gestion de fonction de fit definie par l'utilisateur
+GeneralFunc* mFunc;
+PDynLinkMgr* mDlUFunc;
+string mNameFitFunc;
+DlUserFitFunc mFitFunc;
+DlUserFitFuncDer mFitFuncDer;
+int mUFNVar, mUFNPar; 
+};
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PIext/piaversion.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/piaversion.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/piaversion.h	(revision 464)
@@ -0,0 +1,6 @@
+#ifndef PIAPPVERSION_H_SEEN
+#define PIAPPVERSION_H_SEEN
+
+#define PIAPP_VERSIONNUMBER  2.4
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PIext/pigfd1.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/pigfd1.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/pigfd1.cc	(revision 464)
@@ -0,0 +1,79 @@
+// Cette classe est maintenant obsolete: generaldata <==> ntuple pour le dessin
+
+#include <stdio.h>
+#include "pigfd1.h"
+
+ 
+/* --Methode-- */
+PIGenFitDat::PIGenFitDat(GeneralFitData* gfd, bool ad)
+: PIDrawer(), mGFD(gfd), mAdDO(ad), VarX(0), ErrX(false), ErrY(false)
+{
+SelectX(0);
+SelectErrBar(false,false);
+}
+
+PIGenFitDat::~PIGenFitDat()
+{
+if(mAdDO && mGFD)  delete mGFD;
+}
+
+/* --Methode-- */
+void  PIGenFitDat::SelectX(int varx)
+{
+VarX = -1;
+if(mGFD == NULL) return;
+if(varx<0 || varx>=mGFD->NVar()) return;
+VarX = varx;
+}
+
+/* --Methode-- */
+void  PIGenFitDat::SelectErrBar(bool erbx,bool erby)
+{
+ErrX = erbx; ErrY = erby;
+if(mGFD == NULL) {ErrX = ErrY = false; return;}
+if(!mGFD->HasXErrors()) ErrX = false;
+}
+
+/* --Methode-- */
+void PIGenFitDat::UpdateLimits()
+{
+if(!mGFD) return;
+if(mGFD->NData()<=0) return;
+if(VarX<0) return;
+double dx, dy;
+double xmin=9.e19, xmax=-9.e19, ymin=9.e19, ymax=-9.e19;
+mGFD->GetMnMx(10*VarX+2,xmin,xmax);
+mGFD->GetMnMx(0,ymin, ymax);
+if(xmax<=xmin) xmax = xmin+1.;
+if(ymax<=ymin) ymax = ymin+1.;
+dx = 0.02*(xmax-xmin);
+dy = 0.02*(ymax-ymin);
+SetLimits((double)xmin-dx,(double)xmax+dx,(double)ymin-dy,(double)ymax+dy);
+SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
+}
+
+/* --Methode-- */
+void PIGenFitDat::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
+{
+if (!mGFD) return;
+if(mGFD->NData()<=0) return;
+if(VarX<0) return;
+// On plotte les barre d'erreurs ligne demandee explicitement
+if(mLAtt!=PI_NotDefLineAtt) SelectErrBar(true,true);
+double xp,yp,er;
+for (int i=0; i<mGFD->NData(); i++) {
+  xp = mGFD->Absc(VarX,i);
+  yp = mGFD->Val(i);
+  if(xp<xmin || xp>xmax || yp<ymin || yp>ymax)  continue;
+  if(ErrX) {
+    er = mGFD->EAbsc(VarX,i);
+    if(er>0.) g->DrawLine(xp-er,yp,xp+er,yp);
+  }
+  if(ErrY) {
+    er = mGFD->EVal(i);
+    if(er>0.) g->DrawLine(xp,yp-er,xp,yp+er);
+  }
+  g->DrawMarker(xp, yp); 
+}
+return;
+}
Index: /tags/V_LaSilla191199/SophyaPI/PIext/pigfd1.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/pigfd1.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/pigfd1.h	(revision 464)
@@ -0,0 +1,28 @@
+// Cette classe est maintenant obsolete: generaldata <==> ntuple pour le dessin
+
+#ifndef PIGFD1_H
+#define PIGFD1_H
+
+#include "generaldata.h"
+#include "pidrawer.h"
+
+class PIGenFitDat : public PIDrawer {
+public:
+                     PIGenFitDat(GeneralFitData* gfd, bool ad);
+  virtual           ~PIGenFitDat();
+  
+  virtual void       Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
+  virtual void       UpdateLimits();
+  
+          void       SelectX(int varx);
+          void       SelectErrBar(bool erbx,bool erby);
+       
+protected:
+  GeneralFitData* mGFD;
+  bool mAdDO;
+  int VarX;          // numero de variable X ds le GeneralFitData
+  bool ErrX,ErrY;    // Erreur en X et Y ?
+};
+
+#endif
+
Index: /tags/V_LaSilla191199/SophyaPI/PIext/pigfd2.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/pigfd2.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/pigfd2.cc	(revision 464)
@@ -0,0 +1,107 @@
+// Cette classe est maintenant obsolete: generaldata <==> ntuple pour le dessin
+
+#include <stdio.h>
+#include "pigfd2.h"
+
+/* --Methode-- */
+PIGenFitDat3D::PIGenFitDat3D(GeneralFitData* gfd, bool ad)
+: PIDrawer3D(), mGFD(gfd), mAdDO(ad)
+, VarX(0), VarY(1), ErrX(false), ErrY(false), ErrZ(false)
+{
+SelectXY(0,1);
+SelectErrBar(false,false,false);
+}
+
+PIGenFitDat3D::~PIGenFitDat3D()
+{
+if(mAdDO && mGFD)  delete mGFD;
+}
+
+/* --Methode-- */
+void  PIGenFitDat3D::SelectXY(int varx,int vary)
+{
+VarX = VarY = -1;
+if(mGFD == NULL) return;
+if(varx<0 || varx>=mGFD->NVar()) return;
+if(vary<0 || vary>=mGFD->NVar()) return;
+VarX = varx; VarY = vary;
+}
+
+/* --Methode-- */
+void  PIGenFitDat3D::SelectErrBar(bool erbx,bool erby,bool erbz)
+{
+ErrX = erbx; ErrY = erby; ErrZ = erbz;
+if(mGFD == NULL) {ErrX = ErrY = ErrZ = false; return;}
+if(!mGFD->HasXErrors()) ErrX = ErrY = false;
+}
+
+/* --Methode-- */
+void PIGenFitDat3D::UpdateLimits()
+{
+if(!mGFD) return;
+if(mGFD->NData()<=0) return;
+if(VarX<0 || VarY<0) return;
+double xmin=9.e19, xmax=-9.e19, ymin=9.e19, ymax=-9.e19, zmin=9.e19, zmax=-9.e19;
+mGFD->GetMnMx(10*VarX+2,xmin,xmax);
+mGFD->GetMnMx(10*VarY+2,ymin,ymax);
+mGFD->GetMnMx(0,zmin, zmax);
+if(xmax<=xmin) xmax = xmin+1.;
+if(ymax<=ymin) ymax = ymin+1.;
+if(zmax<=zmin) zmax = zmin+1.;
+// Voir commentaires pintuple3d.cc
+double D = xmax-xmin;
+if (D < (ymax-ymin))  D = ymax-ymin;
+D *= 1.4;
+Set3DView((xmin+xmax)/2., (ymin+ymax)/2, (zmin+zmax)/2., 
+          (xmin+xmax)/2.+D , (ymin+ymax)/2.-2.5*D , zmin+(zmax-zmin)*0.85, 0.25, 0.25);  
+
+x3Min = xmin;    x3Max = xmax;
+y3Min = ymin;    y3Max = ymax;
+z3Min = zmin;    z3Max = zmax;
+
+}
+
+/* --Methode-- */
+void PIGenFitDat3D::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
+{
+// On trace les axes - En attendant de faire mieux - Reza 8/12/98
+if (axesFlags != kAxesNone)  DrawAxes(g);
+
+if (!mGFD) return;
+if(mGFD->NData()<=0) return;
+if(VarX<0 || VarY<0) return;
+
+// On plotte les barre d'erreurs ligne demandee explicitement
+if(mLAtt!=PI_NotDefLineAtt) SelectErrBar(true,true,true);
+
+#if defined(CC_HAS_RTTI_SUPPORT)
+PIGraphic3D* g3 = dynamic_cast<PIGraphic3D*>(g);
+#else
+PIGraphic3D* g3 = (PIGraphic3D*)(g);
+#endif
+
+if (mLAtt == PI_NotDefLineAtt)  g3->SelLine(PI_ThinLine);
+
+double xp,yp,zp,er;
+for (int i=0; i<mGFD->NData(); i++) {
+  xp = mGFD->Absc(VarX,i);
+  yp = mGFD->Absc(VarY,i);
+  zp = mGFD->Val(i);
+  if(ErrX) {
+    er = mGFD->EAbsc(VarX,i);
+    if(er>0.) g3->DrawLine3D(xp-er,yp,zp,xp+er,yp,zp);
+  }
+  if(ErrY) {
+    er = mGFD->EAbsc(VarY,i);
+    g3->DrawLine3D(xp,yp-er,zp,xp,yp+er,zp);
+  }
+  if(ErrZ) {
+    er = mGFD->EVal(i);
+    g3->DrawLine3D(xp,yp,zp-er,xp,yp,zp+er);
+  }
+  g3->DrawMarker3D(xp,yp,zp); 
+}
+
+return;
+}
+
Index: /tags/V_LaSilla191199/SophyaPI/PIext/pigfd2.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/pigfd2.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/pigfd2.h	(revision 464)
@@ -0,0 +1,29 @@
+// Cette classe est maintenant obsolete: generaldata <==> ntuple pour le dessin
+
+#ifndef PIGFD2_H
+#define PIGFD2_H
+
+#include "generaldata.h"
+#include "pi3ddrw.h"
+
+class PIGenFitDat3D : public PIDrawer3D {
+public:
+                     PIGenFitDat3D(GeneralFitData* gfd, bool ad);
+  virtual           ~PIGenFitDat3D();
+  
+  virtual void       Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
+  virtual void       UpdateLimits();
+  
+          void       SelectXY(int varx,int vary);
+          void       SelectErrBar(bool erbx,bool erby,bool erbz);
+
+       
+protected:
+  GeneralFitData* mGFD;
+  bool mAdDO;
+  int VarX,VarY;         // numero de variable X,Y ds le GeneralFitData
+  bool ErrX,ErrY,ErrZ;   // Erreur en X,Y et Z?
+};
+
+#endif
+
Index: /tags/V_LaSilla191199/SophyaPI/PIext/pihisto.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/pihisto.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/pihisto.cc	(revision 464)
@@ -0,0 +1,119 @@
+#include <stdio.h>
+#include <typeinfo>
+
+#include "pihisto.h"
+#include "hisprof.h"
+
+PIHisto::PIHisto(Histo* histo, bool ad)
+: PIDrawer(), mHisto(histo)
+{
+  mAdDO = ad;     // Flag pour suppression automatique de mHisto
+}
+
+PIHisto::~PIHisto()
+{
+  if (mAdDO) delete mHisto;
+}
+
+void
+PIHisto::UpdateLimits()
+{
+  if (!mHisto)  return;
+  float hmin = mHisto->VMin();
+  float hmax = mHisto->VMax()+0.2*(mHisto->VMax()-mHisto->VMin());
+  // si HBProf min,max calcules en tenant compte des erreurs
+  if( typeid(*mHisto) == typeid(HProf) ) {
+    float v1,v2;
+    for (int i=1; i<mHisto->NBins(); i++) {
+      v1 = (*mHisto)(i) - mHisto->Error(i);
+      v2 = (*mHisto)(i) + mHisto->Error(i);
+      if(v1<hmin) hmin = v1;
+      if(v2>hmax) hmax = v2;
+    }
+    v1 = 0.1*(hmax-hmin);
+    hmin -= v1;   hmax += v1;
+  }
+  if(hmax<=hmin) hmax += 1.;
+  SetLimits(mHisto->XMin(), mHisto->XMax(), hmin, hmax);
+  SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
+}
+
+void
+PIHisto::Draw(PIGraphicUC* g, double /*xmin*/, double /*ymin*/, double /*xmax*/, double /*ymax*/)
+{
+  bool oktrace = false;
+  if (!mHisto)  return;  
+
+  if (mMrk != PI_NotDefMarker ||  ( typeid(*mHisto) == typeid(HProf) ) )  {
+    // Marqeurs definis OU HBProf => marqueurs+Erreurs si il y en a
+    if (mLAtt == PI_NotDefLineAtt) g->SelLine(PI_ThinLine);
+    double x1,y1, x2,y2;
+    double bw = mHisto->BinWidth();
+    for (int i=0; i<mHisto->NBins(); i++) {
+      if(mHisto->Error(i)>0.) {
+        // barres d'erreur verticales
+        x1 = x2 = mHisto->BinCenter(i);
+        y1 = (*mHisto)(i) - mHisto->Error(i);
+        y2 = (*mHisto)(i) + mHisto->Error(i);
+        g->DrawLine(x1,y1, x1, y2);
+        // limites de barres d'erreurs (horizontales)
+        x1 -= bw/3.;  x2 += bw/3.;
+        g->DrawLine(x1,y1, x2, y1);
+        g->DrawLine(x1,y2, x2, y2);
+      }
+      // le marqueur
+      x1 = mHisto->BinCenter(i);
+      y1 = (*mHisto)(i);
+      g->DrawMarker(x1,y1);
+    }
+    oktrace = true;
+  }
+  if (mLAtt != PI_NotDefLineAtt) {
+    double x1,y1, x2, y2;
+    x1 = mHisto->BinLowEdge(0);
+    y1 = 0;
+    for (int i=0; i<mHisto->NBins(); i++) {
+      x2 = x1;
+      y2 = (*mHisto)(i);
+      g->DrawLine(x1,y1, x2, y2);
+      y1 = y2;
+      x2 = mHisto->BinHighEdge(i);
+      g->DrawLine(x1,y1, x2, y2);
+      x1 = x2;
+    }
+    y2 = 0; g->DrawLine(x1,y1, x2, y2);
+    oktrace = true;
+  }
+  if( !oktrace ) {
+    for(int i=0; i<mHisto->NBins(); i++) {
+      double left   = mHisto->BinLowEdge(i);
+      double width  = mHisto->BinWidth();
+      double bottom = 0;
+      double height = (*mHisto)(i);
+      g->DrawFBox(left,bottom,width,height);
+      g->DrawLine(left, bottom, left, bottom + height); // Au moins une ligne...
+    }
+  }
+  // A faire a la fin - DrawStats change l'attribut de ligne 
+  DrawStats(g);
+}
+
+void
+PIHisto::DrawStats(PIGraphicUC* g)
+{
+  if (!mHisto) return;
+  //  if (mLAtt == PI_NotDefLineAtt)  g->SelLine(PI_ThinLine);
+  g->SelLine(PI_ThinLine);
+  double cellHeight = (YMax() - YMin()) * 0.05;
+  double cellWidth  = (XMax() - XMin()) * 0.23;
+  g->DrawLine(XMax() - cellWidth, YMax(),
+                       XMax() - cellWidth, YMax() - cellHeight);
+  g->DrawLine(XMax() - cellWidth, YMax() - cellHeight,
+                       XMax()            , YMax() - cellHeight);
+  char label[50];
+  sprintf(label, "N = %.6g", mHisto->NData());
+  g->SelFontSz((YMax() - YMin())/30);
+  g->DrawString(XMax() - cellWidth*0.9, YMax() - cellHeight*0.8, label);
+                       
+}
+
Index: /tags/V_LaSilla191199/SophyaPI/PIext/pihisto.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/pihisto.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/pihisto.h	(revision 464)
@@ -0,0 +1,21 @@
+#ifndef PIHISTO_H
+#define PIHISTO_H
+
+#include "histos.h"
+#include "pidrawer.h"
+
+class PIHisto : public PIDrawer {
+public:
+                     PIHisto(Histo* histo, bool ad=false);
+  virtual           ~PIHisto();
+  virtual void       Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
+  virtual void       UpdateLimits();
+  virtual void       DrawStats(PIGraphicUC* g);
+  inline  Histo*     Histogram() { return(mHisto); }
+
+protected:
+  Histo* mHisto;
+  bool mAdDO;
+};
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PIext/pihisto2d.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/pihisto2d.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/pihisto2d.cc	(revision 464)
@@ -0,0 +1,794 @@
+#include <stdio.h>
+#include "piapplgen.h"
+#include "pihisto2d.h"
+#include "nbrandom.h"
+
+static int dbg = 0;
+
+//++
+// Class	PIHisto2D,PIH2DWdg,H2WinArg
+// Lib	PI
+// include	pihisto2d.h
+//
+//	Classes de dessin des histogrammes a 2 dimensions.
+//--
+
+//++
+// Titre	Dessin d'un histogramme 2D.
+//--
+
+//++
+PIHisto2D::PIHisto2D(Histo2D* histo, bool ad)
+//
+//	Createur d'une classe de dessin pour l'histogramme 2D histo.
+//--
+: PIDrawer(), mHisto(histo)
+{
+mAdDO = ad;     // Flag pour suppression automatique de mHisto  
+
+mLogScale = 10.;
+mFPoints = 0.5;
+
+UseColors();
+UseDisplay();
+UseDyn();
+UseFrac();
+}
+
+//++
+PIHisto2D::~PIHisto2D()
+//
+//	Destructeur.
+//--
+{
+if(mAdDO) delete mHisto;
+}
+
+//++
+void PIHisto2D::UseColors(bool fg, CMapId cmap)
+//
+//	Choix de la couleur si fg=true avec la color map cmap.
+//	(pour la couleur cmap cf picmap.h).
+//      Independamment du choix du display, la dynamique est
+//      codee sur la color map donnant ainsi une double
+//      information. Par exemple, carres de tailles variables
+//      en couleur. Cette option est incontournable dans le cas
+//      d'un display par des carres de taille fixe.
+//--
+{
+mFgCol = fg; mCmap = cmap;
+}
+
+//++
+void PIHisto2D::UseScale(unsigned short type,float logscale)
+//
+//	Pour changer les echelles (lineaire ou logarithmique)
+//| Type = 0 : echelle lineaire
+//|      = 1 : echelle log10
+//| -**- Explication du codage en type=0 (lineaire) :
+//|   1. [hmin,hmax] -> [0,1]
+//|           h      ->   f = (h-hmin)/(hmax-hmin)
+//|   2. codage de f=[0,1] sur la dynamique du display choisi
+//| -**- Explication du codage en type=1 (logarithmique base 10) :
+//|   1. map lineaire entre 0 et 1:
+//|      [hmin,hmax] -> [0,1]
+//|           h      ->   f = (h-hmin)/(hmax-hmin)
+//|   2. transformation logarithmique de base 10 :
+//|      [0,1] -> [0,1]
+//|        f   -> lf = log10(1.+f*(logscale-1))/log10(logscale)
+//|   3. codage de lf=[0,1] sur la dynamique du display choisi
+//--
+{
+if(type==0) mTypScal = 0;
+if(type==1) {
+  mTypScal = 1;
+  if(logscale>1.) mLogScale = logscale;
+} else mTypScal = 0;
+}
+
+//++
+void PIHisto2D::UseDisplay(unsigned short type, float fnpt)
+//
+//	Type de Display
+//| Type = 0 : carres de tailles variables
+//| Type = 1 : nuages de points
+//|            Le nombre de points a utiliser est fnpt*N
+//|            ou N est le nombre de pixels ecran contenu
+//|            dans un bin de l'histogramme.
+//| Type = 2 : code a la "hbook2" " .+123...9AB...YZ*"
+//|            (cf detail PIHisto2D::HPrint2)
+//| Type = 3 : carres de taille fixe (couleur).
+//--
+{
+if(fnpt<0.) fnpt=0; else if(fnpt>1.) fnpt=1.;
+if(type==0)        mTypDisp = 0;
+else if(type==1) { mTypDisp = 1; mFPoints = fnpt;}
+else if(type==2)   mTypDisp = 2;
+else if(type==3)   mTypDisp = 3;
+else               mTypDisp = 1;
+}
+
+//++
+void PIHisto2D::UseDyn(float hmin, float hmax)
+//
+//	Gestion de la dynamique a representer:
+//|  La dynamique va etre transformee de [hmin,hmax] vers [0,1] selon
+//|  [hmin,hmax] -> [0,1]
+//|       h      ->   f = (h-hmin)/(hmax-hmin)
+//|  Par la suite selon ce qui est demande, f va coder le display ou etre
+//|  transforme en une autre echelle [0,1].
+//|  Si hmax<=hmin, ils sont forces a la dynamique totale de l'histo2D.
+//--
+{
+if(hmin>=hmax) {hmin = mHisto->VMin(); hmax = mHisto->VMax();}
+if(hmin>=hmax) hmax = hmin+1.;
+mHMin = hmin; mHMax = hmax;
+}
+
+//++
+void PIHisto2D::UseFrac(float frmin, float frmax)
+//
+//	Pour definir la fraction de la dynamique a dessiner:
+//| Certains type de display (f=[0,1] cf PIHisto2D::UseDyn),
+//|  - on ne dessine rien si f <= frmin dans les cas de display avec
+//|    des nuages de points ou des carres de tailles variables.
+//|    Pour un display "a la hbook2" on force frmin = 0.
+//|  - frmax n'est utilise que pour la representation avec
+//|    des carres de tailles variables: c'est la taille
+//|    maximum que peut avoir le carre exprimee en unite
+//|    de la taille du bin (ex: si frmax=0.8 le carre
+//|    le + grand qui pourra etre dessine dans un bin
+//|    aura une taille egale a 0.8*(taille du bin)).
+//--
+{
+if(frmax<=0. || frmax>1.) frmax = 1.;
+if(frmin>=frmax) {frmin=0.1; frmax=0.9;}
+mFracMin = frmin; mFracMax = frmax;
+}
+
+//++
+void PIHisto2D::Print(int lp)
+//
+//	Print de l'etat des options du display.
+//--
+{
+printf("PIHisto2D::Print FgCol=%d Cmap=%d TypScal=%d TypDisp=%d (FPoints=%g)\n"
+      ,(int)mFgCol,(int)mCmap,mTypScal,mTypDisp,mFPoints);
+printf("                 Dyn=%g,%g Frac=%g,%g LogSc=%g H=%lx\n"
+      ,mHMin,mHMax,mFracMin,mFracMax,mLogScale,(long)mHisto);
+if(lp<1) return;
+mHisto->PrintStatus();
+}
+
+//++
+void PIHisto2D::UpdateLimits()
+//
+//	Definition des tailles graphiques en fonction
+//	des caracteristiques de l'histogramme a dessiner.
+//--
+{
+  if(!mHisto) return;
+  SetLimits(mHisto->XMin(), mHisto->XMax(), mHisto->YMin() , mHisto->YMax());
+  SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
+}
+
+//++
+void PIHisto2D::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
+//
+//	Dessin de l'histogramme.
+//|  Code de dessin selon choix des options:
+//|  (detail voir UseColors UseScale UseDisplay UseDyn UseFrac)
+//|  [hmin,hmax] -> [0,1] [[ -> re-codage log10 entre [0,1] ]] -> f=[0,1]
+//|  Puis selon display:
+//|  0 carres variables : if(f>fracmin) taille carre = f*fracmax *taille_du_bin
+//|  1 nuage de points  : if(f>fracmin) npoints = f*PerPt *npoints_ecran_dans_bin
+//|  2 code hbook2      : if(f>0) map de f=]0,1] dans ".+...Z*"
+//|  3 carres fixes     : couleur = lut[f*nombre_d_entree_dans_la_lut]
+//--
+{
+if(!mHisto) return;
+// Caracteristiques histogramme
+double dx = mHisto->WBinX(),dy = mHisto->WBinY();
+double p1dx,p1dy;
+g->DGrC2UC(1.f,1.f,p1dx,p1dy);
+
+// Gamme a representer entre [0,1] mais >=fracmin et scale fracmax
+float fracmin=FMin(), fracmax=FMax();
+float llscale = (float) log10((double)LogScale());
+
+// gestion Couleurs.
+PIColorMap* cmap=NULL;
+PIColors coul = g->GetForeground();
+int ncol = 0;
+if (mFgCol) {
+  cmap = new PIColorMap(mCmap); ncol = cmap->NCol();
+  if(mTypDisp==3) fracmin=-1.;
+}
+
+// gestion epaisseur de ligne
+if (mLAtt == PI_NotDefLineAtt)  g->SelLine(PI_ThinLine);
+
+// gestion Markers ou plot avec des points.
+PIMarker Mk = g->GetMarker();
+int MkSz = g->GetMarkerSize();
+int npt = 1;
+if(mTypDisp==1) {
+  g->SelMarker(1,PI_DotMarker);
+  npt = (int) ((float)NPixBin(g)*FPoints()); if(npt<=0) npt = 2;
+}
+
+// gestion Font.
+PIFontAtt FontAtt = g->GetFont().GetFontAtt();
+int FontSize = g->GetFont().GetFontSize();
+if(mTypDisp==2) {
+  double dxg,dyg,dg;
+  g->DUC2GrC(dx,dy,dxg,dyg);
+  dg =(dxg<dyg) ? dxg : dyg;
+  int npix = (int) (dg*0.9); if(npix<8) npix = 8;
+  //printf("PIHisto2D::Draw_Font H dx=%g dy=%g, G dx=%g dy=%g, npix = %g,%d\n"
+  //      ,dx,dy,dxg,dyg,dg,npix);
+  g->SelFontSzPt(npix,PI_RomanFont);
+  fracmin = 0;
+}
+
+// Print();
+
+// Plot de l'histogramme
+for (int i=0; i<mHisto->NBinX(); i++)
+for (int j=0; j<mHisto->NBinY(); j++) {
+
+  float left0,bottom0;
+  mHisto->BinLowEdge(i,j,left0,bottom0);
+
+  // Gestion de la dynamique a dessiner
+  float frac = ((*mHisto)(i,j)-HMin())/(HMax()-HMin());
+  if(frac<0.) continue;
+  if(mTypScal==1) {              // echelle log10
+    frac = log10(1.+frac*(LogScale()-1.))/llscale;
+    if(frac<0.) continue;
+  }
+  if(frac<=fracmin) continue;
+  if(frac>1.) frac = 1.;
+  float fracred = frac * fracmax;
+
+  // Gestion de la couleur
+  int icol = 0;
+  if (cmap) {
+    icol = int( (float) ncol*frac );
+    if(icol>=ncol) icol = ncol-1; else if(icol<0) icol=0;
+    g->SelForeground(*cmap,icol);
+  }
+
+// Pour ne pas dessiner en dehors des axes 
+  if ( (left0+dx/2. < xmin) || (left0+dx/2. > xmax) || 
+         (bottom0+dy/2. < ymin) || (bottom0+dy/2. > ymax) ) continue;
+
+  // Dessin proprement dit selon le choix graphique.
+  if(mTypDisp==0) {
+    //..... carres de tailles variables
+    double left   = left0   + 0.5*(1.-fracred)*dx, width  = fracred*dx;
+    double bottom = bottom0 + 0.5*(1.-fracred)*dy, height = fracred*dy;
+    if (cmap) g->DrawFBox(left,bottom,width,height);
+    else      g->DrawBox(left,bottom,width,height);
+  } else if(mTypDisp==1) {
+    //..... nuage de points .....
+    int ipt  = int( (float) npt *frac );
+    for(int k=0;k<ipt;k++) {
+      double x = left0 + frand01()*dx;
+      double y = bottom0 + frand01()*dy;
+      g->DrawMarker(x,y);
+    }
+  } else if(mTypDisp==2) {
+    //..... type hbook2/hprint .+23-Z*
+    char c[2];
+    c[0] = HPrint2(frac); c[1]='\0';
+    double x = left0 + dx/2.;
+    double y = bottom0 + dy/2.;
+    g->DrawString(x,y,c);
+  } else if(mTypDisp==3) {
+    //..... carres de tailles fixes (avec gestion de continuite)
+    if (cmap) g->DrawFBox(left0,bottom0,dx+p1dx,dy+p1dy);
+    else      g->DrawBox(left0,bottom0,dx+p1dx,dy+p1dy);
+  }
+
+}
+
+// Remise dans les conditions ulterieures pour la suite du graphique.
+g->SelMarker(MkSz,Mk);
+g->SelForeground(coul);
+g->SelFontSzPt(FontSize,FontAtt);
+if (cmap) delete cmap;
+
+// Fin du dessin, ecriture de la statistique.
+DrawStats(g);
+}
+
+//++
+void PIHisto2D::DrawStats(PIGraphicUC* g)
+//
+//	Dessin des informations statistiques de l'histogramme.
+//--
+{
+  // Une boite dans le coin superieur droit
+  if (mLAtt == PI_NotDefLineAtt)  g->SelLine(PI_ThinLine);
+  double cellHeight = (YMax() - YMin()) * 0.05;
+  double cellWidth  = (XMax() - XMin()) * 0.23;
+  g->DrawLine(XMax() - cellWidth, YMax(),
+                       XMax() - cellWidth, YMax() - cellHeight);
+  g->DrawLine(XMax() - cellWidth, YMax() - cellHeight,
+                       XMax()            , YMax() - cellHeight);
+  char label[50];
+  sprintf(label, "N = %.6g", mHisto->NData());
+  g->SelFontSz((YMax() - YMin())/30);
+  g->DrawString(XMax() - cellWidth*0.9, YMax() - cellHeight*0.8, label);
+  printf("H[%d,%d] Dynamique: [%g,%g] Frac [%g,%g]\n"
+        ,mHisto->NBinX(),mHisto->NBinY(),HMin(),HMax(),FMin(),FMax());
+}
+
+//++
+char PIHisto2D::HPrint2(float f)
+//
+//	Codage des valeurs en caracteres (fct privee).
+//| f entre [0,1] mappee entre valeur=[0,37]
+//| si <0 alors =0, si >1 alors 1
+//| Display 4   ==> 4<=valeur<5
+//|         C   ==> 12<=valeur<13
+//|             ==> valeur<=0
+//|         *   ==> valeur>=1
+//|         .   ==> 0<valeur<1
+//|------------------------------------------
+//|            C1111111111222222222233333333
+//|  C01234567890123456789012345678901234567
+//| " .+23456789ABCDEFGHIJKLMNOPQRSTUVWXYZ*"
+//|------------------------------------------
+//--
+{
+char str[39] = " .+23456789ABCDEFGHIJKLMNOPQRSTUVWXYZ*";
+int i;
+if(f<=0.) i = 0;
+else if(f>=1.) i = 37;
+else { i = (int) (f*36.); i++;}
+if(i<0) i=0; else if (i>=38) i = 37;
+return str[i];
+}
+
+//++
+int PIHisto2D::NPixBin(PIGraphicUC* g)
+//
+//	Nombre de pixels ecran dans un bin d'histogramme
+//	(fct privee).
+//--
+{
+double dx = mHisto->WBinX(),dy = mHisto->WBinY();
+double dxg,dyg;
+g->DUC2GrC(dx,dy,dxg,dyg);
+int np = (int) dxg * (int) dyg;
+//printf("PIHisto2D::NPixBin H dx=%g dy=%g, G dx=%g dy=%g, np = %d\n"
+//      ,dx,dy,dxg,dyg,np);
+return np;
+}
+
+
+/////////////////////////////////////////////////////////////////
+//  Classe PIH2DWdg
+/////////////////////////////////////////////////////////////////
+//++
+// Titre	Widget de dessin d'un histogramme 2D.
+//--
+
+static H2WinArg* h2dWinArg=NULL;
+static int nb_h2dWinArg = 0;
+
+//++
+PIH2DWdg::PIH2DWdg(PIContainerGen *par, const char *nom, int sx, int sy, int px, int py)
+//
+//	Createur d'un Widget de dessin d'histogramme 2D.
+//	Le menu pour choisir les options d'affichage apparait
+//	suite au clic du bouton-3 de la souris (cf H2WinArg::H2WinArg).
+//--
+: PIScDrawWdg(par,nom,sx,sy,px,py)
+{
+if (!h2dWinArg) h2dWinArg = new H2WinArg(this);
+nb_h2dWinArg++;
+if(dbg) printf("PIH2DWdg::PIH2DWdg %lx h2dWinArg=%lx %d\n"
+              ,(long)this,(long)h2dWinArg,nb_h2dWinArg);
+mPih = NULL;
+// Pour afficher le menu option de trace
+ActivateButton(3);
+}
+
+//++
+PIH2DWdg::~PIH2DWdg()
+//
+//	Destructeur.
+//--
+{
+nb_h2dWinArg--;
+if (nb_h2dWinArg == 0) {
+  h2dWinArg->Hide();
+  delete h2dWinArg;
+  h2dWinArg=NULL;
+}
+if(dbg) printf("PIH2DWdg::~PIH2DWdg h2dWinArg=%lx %d\n"
+              ,(long)h2dWinArg,nb_h2dWinArg);
+if (mPih) delete mPih;
+}
+
+//++
+void PIH2DWdg::SetHisto(Histo2D* histo)
+//
+//	Pour connecter un histogramme 2D au Widget.
+//--
+{
+if (!histo) return;
+if (mPih)  delete mPih;
+mPih = new PIHisto2D(histo, true);
+AddScDrawer(mPih);
+if(dbg) printf("PIH2DWdg::SetHisto mPih=%lx\n",(long)mPih);
+}
+
+//++
+void PIH2DWdg::SetPIHisto(PIHisto2D* pih2)
+//
+//	Pour connecter un traceur (Drawer) d'histo 2D au Widget.
+//--
+{
+if (!pih2) return;
+if (mPih)  delete mPih;
+mPih = pih2;
+AddScDrawer(mPih);
+if(dbg) printf("PIH2DWdg::SetPIHisto mPih=%lx\n",(long)mPih);
+}
+
+//++
+string  PIH2DWdg::GetClickText(double x, double y)
+//
+//	Quand on click (and drag) le bouton-1, affichage
+//	des positions x,y et de la valeur du bin de l'histogramme 2D.
+//--
+{
+int i,j;
+char str[128];
+
+if ((!mPih) || (!mPih->Histogram())) {
+  sprintf(str,"X=%g Y=%g ???",x,y);
+  return((string)str);
+}
+
+Histo2D* h = mPih->Histogram();
+
+h->FindBin(x,y,i,j);
+if(i<0 || i>=h->NBinX() || j<0 || j>=h->NBinY())
+  sprintf(str,"x= %g y= %g ???",x,y);
+else sprintf(str,"x= %g y= %g v= %g",x,y,(*h)(i,j));
+
+return((string)str);
+}
+
+//++
+void PIH2DWdg::ActivateSpecializedControls()
+//	Pour activer les contrôles spécifiques pour l'affichage Histo-2D	
+//--
+{
+h2dWinArg->SetPIH2DWdg(this);
+h2dWinArg->SetMsgParent((PIMsgHandler*)this);
+if(!h2dWinArg->Visible()) h2dWinArg->Show();
+}
+
+//++
+void PIH2DWdg::But3Press(int x, int y)
+//
+//	Gestion de l'utilisation du bouton-3 de la souris.
+//	Un seul objet est cree pour tous les histogrammes 2D.
+//	Il est connecte a un histogramme donnee par l'action du
+//	du bouton-3 de la souris dans la fenetre contenant
+//	le dessin de l'histogramme (cf H2WinArg::H2WinArg).
+//--
+{
+ActivateSpecializedControls();
+if(dbg) printf("PIH2DWdg::But3Press(%d,%d) h2dWinArg=%lx\n"
+              ,x,y,(long)h2dWinArg);
+}
+
+
+/////////////////////////////////////////////////////////////////
+//  Classe H2WinArg
+/////////////////////////////////////////////////////////////////
+//++
+// Titre	Fenetre de dialogue pour le choix des options..
+//--
+
+//++
+H2WinArg::H2WinArg(PIH2DWdg *par)
+//
+//	Creation de la fenetre de gestion des parametres
+//	des dessins des histogrammes 2D. Cette fenetre de
+//	dialogue est partagee par tous les widget de dessin
+//	des histogrammes 2D. Pour la faire apparaitre pour la
+//	faire apparaitre la premiere fois, cliquez avec le bouton
+//	numero 3 de la souris (bouton de droite) dans la fenetre
+//	de dessin de l'histogramme. Si elle est deja presente,
+//	pour la connecter a une autre fenetre de dessin cliquez avec
+//	le meme bouton dans cette fenetre.
+//--
+//++
+//| - Menu 1: Choix du type de display
+//|     Carres variables, nuages de points, caracteres a la hbook2
+//|     et carres de tailles fixe (couleur ou niveauz de gris).
+//| - Menu 2: Choix du type d'echelle
+//|     Lineaire ou logarithmique
+//| - Menu 3: Choix de la couleur
+//|     noir et blanc, niveau de gris et couleurs diverses.
+//| - Champ texte Dyn: Pour donner la dynamique, si min>=max
+//|     alors prend le min et le max de l'histogramme
+//| - Champ texte Frac: fraction mini et maxi
+//|     (cf PIHisto2D::UseFrac)
+//| - Champ texte LogScal: niveau de scaling pour le choix d'une
+//|     echelle logarithmique (cf PIHisto2D::UseScale)
+//--
+//++
+//| - Curseur interactif PerPt: pourcentage de points a dessiner
+//|     dans chaque bin (cf PIHisto2D::UseDisplay)
+//| - Bouton Apply: dessiner avec les options affichees
+//| - Bouton Dismiss: fermeture de la fenetre de dialogue.
+//| - Bouton Get: re-prendre les valeurs de display stoquees
+//|     pour un histogramme donne.
+//| - Bouton Print: Imprimer les caracteristiques du display
+//|     et de l'histogramme.
+//--
+: PIWindow((PIMsgHandler *)par, "Options", PIWK_dialog,250,260,150,150)
+{
+string sdum;
+if(dbg) printf("H2WinArg::H2WinArg %lx par=%lx\n",(long)this,(long)par);
+
+mH2Wdg = NULL;
+
+// Valeurs par defaut
+mFgCol    = false;
+mCmap     = CMAP_GREYINV32;
+mTypScal  = 0;
+mTypDisp  = 0;
+mFPoints  = 0.5;
+mHMin     = 1.;
+mHMax     = -1.;
+mFracMin  = 0.1;
+mFracMax  = 0.9;
+mLogScale = 10.;
+
+// Taille automatique
+int bsx, bsy;
+PIApplicationPrefCompSize(bsx, bsy);  // environ 6 lettres
+int spx = (bsx>=10) ? bsx/10 : 1;  // intervalle entre lettres X
+int spy = (bsy>=5) ? bsy/5 : 1;    // intervalle entre lettres Y
+int wszx = 5*spx+bsx+int(2.5*bsx); // Taille fenetre en X
+int wszy = 11*spy+8.5*bsy;           // Taille fenetre en Y
+SetSize(wszx, wszy);
+
+// menus bar
+  int cpx = 2*spx, cpy = 2*spy;
+mOPop[0] = new PIOptMenu(this, "optmen-h2d-1" ,2*bsx,bsy,cpx,cpy);
+mOPop[0]->AppendItem("Carres Var."  , 6101);
+mOPop[0]->AppendItem("....."        , 6102);
+mOPop[0]->AppendItem(".+12..Z*"     , 6103);
+mOPop[0]->AppendItem("Carres Pleins", 6104);
+sdum = "Carres Var."; mOPop[0]->SetValueStr(sdum);
+mOPop[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+  cpy += bsy+spy;
+mOPop[1] = new PIOptMenu(this, "optmen-h2d-2",2*bsx,bsy,cpx,cpy);
+mOPop[1]->AppendItem("Lineaire", 6201);
+mOPop[1]->AppendItem("Log10"   , 6202);
+sdum = "Lineaire"; mOPop[1]->SetValueStr(sdum);
+mOPop[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+  cpy += bsy+spy;
+mOPop[2] = new PIOptMenu(this, "optmen-h2d-3",2*bsx,bsy,cpx,cpy);
+mOPop[2]->AppendItem("Black&White", 6301);
+mOPop[2]->AppendItem("Grey32"    , 6302);
+mOPop[2]->AppendItem("GreyInv32" , 6303);
+mOPop[2]->AppendItem("ColRJ32"   , 6304);
+mOPop[2]->AppendItem("ColBR32"   , 6305);
+mOPop[2]->AppendItem("ColRV32"   , 6306);
+mOPop[2]->AppendItem("Grey128"   , 6307);
+mOPop[2]->AppendItem("GreyInv128", 6308);
+mOPop[2]->AppendItem("ColRJ128"  , 6309);
+mOPop[2]->AppendItem("ColBR128"  , 6310);
+mOPop[2]->AppendItem("Col16"     , 6311);
+sdum = "Black&White"; mOPop[2]->SetValueStr(sdum);
+mOPop[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+// Labels et zone de saisie texte
+  cpy += 2*(bsy+spy);
+mLab[0] = new PILabel(this, "     Dyn: ",bsx,bsy,cpx,cpy); 
+mLab[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mText[0] = new PIText(this, "Dynamique" ,int(2.5*bsx),bsy,cpx+bsx+spx,cpy);
+mText[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+  cpy += bsy+spy;
+mLab[1] = new PILabel(this, "    Frac: ",bsx,bsy,cpx,cpy);
+mLab[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mText[1] = new PIText(this, "Fraction"  ,int(2.5*bsx),bsy,cpx+bsx+spx,cpy);
+mText[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+  cpy += bsy+spy;
+mLab[2] = new PILabel(this, " LogScal: ",bsx,bsy,cpx,cpy);
+mLab[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mText[2] = new PIText(this, "LogScale"  ,int(2.5*bsx),bsy,cpx+bsx+spx,cpy);
+mText[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+SetText();
+
+// Labels et curseur mobile
+cpy += bsy+spy;
+mLab[3] = new PILabel(this, "   PerPt: ",bsx,bsy,cpx,cpy+0.25*bsy);
+mLab[3]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mPScal = new PIScale(this,"FracPoints",6401,kSDirLtoR
+                        ,int(2.5*bsx),1.25*bsy,cpx+bsx+spx,cpy);
+mPScal->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mPScal->SetMinMax(0,100);
+int imfp = mFPoints*100.f; mPScal->SetValue(imfp);
+
+// Boutons
+  cpx = 2*bsx+5*spx, cpy = 2*spy;
+mBut[0] = new PIButton(this, "Apply",  6001,bsx,bsy,cpx,cpy);
+mBut[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+  cpy += bsy+spy;
+mBut[1] = new PIButton(this, "Dismiss",6002,bsx,bsy,cpx,cpy);
+mBut[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+  cpy += bsy+spy;
+mBut[2] = new PIButton(this, "Get"  ,  6003,bsx,bsy,cpx,cpy);
+mBut[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+  cpy += bsy+spy;
+mBut[3] = new PIButton(this, "Print",  6004,bsx,bsy,cpx,cpy);
+mBut[3]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+// FinishCreate();
+}
+
+//++
+H2WinArg::~H2WinArg()
+//
+//	Destructeur.
+//--
+{
+int i;
+if(dbg) printf("H2WinArg::~H2WinArg %lx\n",(long)this);
+for(i=0;i<3;i++) delete mOPop[i];
+for(i=0;i<4;i++) delete mBut[i];
+for(i=0;i<4;i++) delete mLab[i];
+for(i=0;i<3;i++) delete mText[i];
+delete mPScal;
+}
+
+//++
+void H2WinArg::SetText()
+//
+//	Gestion des fenetres de saisie de texte.
+//--
+{
+string sdum;
+char str[256];
+sprintf(str,"%g %g",mHMin,mHMax);
+mText[0]->SetText(str);
+sprintf(str,"%g %g",mFracMin,mFracMax);
+mText[1]->SetText(str);
+sprintf(str,"%g",mLogScale);
+mText[2]->SetText(str);
+
+if(mTypDisp==0)      { sdum="Carres Var.";   mOPop[0]->SetValueStr(sdum);}
+else if(mTypDisp==1) { sdum=".....";         mOPop[0]->SetValueStr(sdum);}
+else if(mTypDisp==2) { sdum=".+12..Z*";      mOPop[0]->SetValueStr(sdum);}
+else if(mTypDisp==3) { sdum="Carres Pleins"; mOPop[0]->SetValueStr(sdum);}
+
+if(mTypScal==0)      { sdum="Lineaire"; mOPop[1]->SetValueStr(sdum);}
+else if(mTypScal==1) { sdum="Log10";    mOPop[1]->SetValueStr(sdum);}
+
+if(!mFgCol)                       { sdum="Black&White";mOPop[2]->SetValueStr(sdum);}
+else {
+  if(mCmap==CMAP_GREY32)          { sdum="Grey32";     mOPop[2]->SetValueStr(sdum);}
+  else if(mCmap==CMAP_GREYINV32)  { sdum="GreyInv32";  mOPop[2]->SetValueStr(sdum);}
+  else if(mCmap==CMAP_COLRJ32)    { sdum="ColRJ32";    mOPop[2]->SetValueStr(sdum);}
+  else if(mCmap==CMAP_COLBR32)    { sdum="ColBR32";    mOPop[2]->SetValueStr(sdum);}
+  else if(mCmap==CMAP_COLRV32)    { sdum="ColRV32";    mOPop[2]->SetValueStr(sdum);}
+  else if(mCmap==CMAP_GREY128)    { sdum="Grey128";    mOPop[2]->SetValueStr(sdum);}
+  else if(mCmap==CMAP_GREYINV128) { sdum="GreyInv128"; mOPop[2]->SetValueStr(sdum);}
+  else if(mCmap==CMAP_COLRJ128)   { sdum="ColRJ128";   mOPop[2]->SetValueStr(sdum);}
+  else if(mCmap==CMAP_COLBR128)   { sdum="ColBR128";   mOPop[2]->SetValueStr(sdum);}
+  else if(mCmap==CMAP_COL16)      { sdum="Col16";      mOPop[2]->SetValueStr(sdum);}
+}
+
+if(dbg)printf("H2WinArg::SetText\n");
+}
+
+//++
+void H2WinArg::GetText()
+//
+//	Gestion des fenetres de saisie de texte.
+//--
+{
+sscanf(mText[0]->GetText().c_str(),"%g %g",&mHMin,&mHMax);
+sscanf(mText[1]->GetText().c_str(),"%g %g",&mFracMin,&mFracMax);
+sscanf(mText[2]->GetText().c_str(),"%g",&mLogScale);
+if(dbg) printf("H2WinArg::GetText\n");
+}
+
+//++
+void H2WinArg::SetPIH2DWdg(PIH2DWdg* h2wdg)
+//
+//	Connexion du widget de representation d'un histogramme 2D
+//	avec la fenetre de gestion des parametres.
+//--
+{
+mH2Wdg = h2wdg;
+if(dbg) printf("H2WinArg::SetPIH2DWdg mH2Wdg = %lx\n",(long)mH2Wdg);
+}
+
+//++
+void H2WinArg::Process(PIMessage msg, PIMsgHandler* sender, void*)
+//
+//	Gestions des messages.
+//--
+{
+if(dbg) printf("PIH2DWdg::Process(%d-%d , %lx ...) \n"
+              ,(int)UserMsg(msg),(int)ModMsg(msg), (long)sender);
+
+if(!mH2Wdg) return;
+PIHisto2D* mpih = mH2Wdg->GetPIHisto();
+if(!mpih) return;
+
+int opt = UserMsg(msg);
+     if (opt == 6101) { mTypDisp = 0; }
+else if (opt == 6102) { mTypDisp = 1; }
+else if (opt == 6103) { mTypDisp = 2; }
+else if (opt == 6104) { mTypDisp = 3; }
+
+else if (opt == 6201) { mTypScal = 0; }
+else if (opt == 6202) { mTypScal = 1; }
+
+else if (opt == 6301) { mFgCol = false; }
+else if (opt == 6302) { mFgCol = true;  mCmap = CMAP_GREY32; }
+else if (opt == 6303) { mFgCol = true;  mCmap = CMAP_GREYINV32; }
+else if (opt == 6304) { mFgCol = true;  mCmap = CMAP_COLRJ32; }
+else if (opt == 6305) { mFgCol = true;  mCmap = CMAP_COLBR32; }
+else if (opt == 6306) { mFgCol = true;  mCmap = CMAP_COLRV32; }
+else if (opt == 6307) { mFgCol = true;  mCmap = CMAP_GREY128; }
+else if (opt == 6308) { mFgCol = true;  mCmap = CMAP_GREYINV128; }
+else if (opt == 6309) { mFgCol = true;  mCmap = CMAP_COLRJ128; }
+else if (opt == 6310) { mFgCol = true;  mCmap = CMAP_COLBR128; }
+else if (opt == 6311) { mFgCol = true;  mCmap = CMAP_COL16; }
+
+else if (opt == 6401) mFPoints = mPScal->GetValue()/100.;
+
+else if (opt==6001) {
+  GetText();
+  mpih->UseColors(mFgCol, mCmap);
+  mpih->UseScale(mTypScal,mLogScale);
+  mpih->UseDisplay(mTypDisp,mFPoints);
+  mpih->UseDyn(mHMin,mHMax);
+  mpih->UseFrac(mFracMin,mFracMax);
+  mH2Wdg->Refresh();  // On rafraichit le dessin (tout le PIScDrawWdg)
+}
+else if (opt==6002) {
+  this->Hide();
+}
+else if (opt==6003) {
+  mFgCol    = mpih->Color();
+  mCmap     = mpih->ColMap();
+  mTypScal  = mpih->TypScale();
+  mTypDisp  = mpih->TypDisplay();
+  mFPoints  = mpih->FPoints();
+  mHMin     = mpih->HMin();
+  mHMax     = mpih->HMax();
+  mFracMin  = mpih->FMin();
+  mFracMax  = mpih->FMax();
+  mLogScale = mpih->LogScale();
+  SetText();
+}
+else if (opt==6004) {
+  mpih->Print(2);
+}
+
+if(dbg) {
+  printf("H2WinArg::Process opt=%d col=%d,%d scal=%d disp=%d npt=%g\n"
+        ,opt,(int) mFgCol,(int) mCmap,mTypScal,mTypDisp,mFPoints);
+  printf("                  min,max= %g,%g frac= %g,%g logsc= %g\n"
+        ,mHMin,mHMax,mFracMin,mFracMax,mLogScale);
+}
+
+}
Index: /tags/V_LaSilla191199/SophyaPI/PIext/pihisto2d.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/pihisto2d.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/pihisto2d.h	(revision 464)
@@ -0,0 +1,109 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PIext :   PIHisto2D PIH2DWdg 
+// Traceur Histo-2D    C. Magneville 97-98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIHISTO2D_H
+#define PIHISTO2D_H
+
+#include "pisysdep.h"
+#include PIMENU_H 
+#include PIMENUBAR_H 
+#include PIOPTMENU_H
+
+#include "histos2.h"
+#include "piscdrawwdg.h"
+
+////////////////////////////////////////////////////////////////////
+class PIHisto2D : public PIDrawer {
+public:
+                     PIHisto2D(Histo2D* histo, bool ad=false);
+  virtual            ~PIHisto2D();
+          void       UseColors(bool fg=false, CMapId cmap=CMAP_GREYINV32);
+          void       UseScale(unsigned short type=0,float logscale=10.);
+          void       UseDisplay(unsigned short type=0, float fnpt=0.5);
+          void       UseDyn(float hmin=1., float hmax=-1.);
+          void       UseFrac(float frmin=0.1, float frmax=0.9);
+          void       Print(int lp=0);
+  virtual void       Draw(PIGraphicUC* g,double xmin,double ymin,double xmax,double ymax);
+  virtual void       UpdateLimits();
+  virtual void       DrawStats(PIGraphicUC* g);
+
+  inline Histo2D*       Histogram() { return(mHisto); }
+  inline bool           Color() { return(mFgCol); }
+  inline CMapId         ColMap() { return(mCmap); }
+  inline unsigned short TypScale() { return(mTypScal); }
+  inline unsigned short TypDisplay() { return(mTypDisp); }
+  inline float          FPoints() { return(mFPoints); }
+  inline float          HMax() { return(mHMax);}
+  inline float          HMin() { return(mHMin);}
+  inline float          FMax() { return(mFracMax);}
+  inline float          FMin() { return(mFracMin);}
+  inline float          LogScale() { return(mLogScale);}
+
+protected:
+  int NPixBin(PIGraphicUC* g);
+  char HPrint2(float f);
+
+  Histo2D* mHisto;
+  bool mAdDO;
+  bool mFgCol;
+  CMapId mCmap;
+  unsigned short mTypScal;
+  unsigned short mTypDisp;
+  float mFPoints;
+  float mHMin,mHMax;
+  float mFracMin,mFracMax;
+  float mLogScale;
+};
+
+////////////////////////////////////////////////////////////////////
+class PIH2DWdg : public PIScDrawWdg {
+public:
+                     PIH2DWdg(PIContainerGen *par, const char *nom, int sx=300, int sy=300, 
+                              int px=0, int py=0);
+                     ~PIH2DWdg();
+
+  void               SetHisto(Histo2D* histo);
+  void               SetPIHisto(PIHisto2D* pih2);
+  inline PIHisto2D*  GetPIHisto() {return mPih;}
+
+  virtual string     GetClickText(double x, double y); 
+  virtual void	     ActivateSpecializedControls();   // Pour activer des controles specifiques
+  virtual void       But3Press(int x, int y);
+
+protected:
+  PIHisto2D*  mPih;
+
+};
+
+////////////////////////////////////////////////////////////////////
+class H2WinArg : public PIWindow {
+public :
+               H2WinArg(PIH2DWdg *par);
+               ~H2WinArg();
+          void SetPIH2DWdg(PIH2DWdg* h2wdg);
+          void SetText();
+          void GetText();
+  virtual void Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+
+protected:
+  PIH2DWdg  * mH2Wdg;
+
+  PIOptMenu * mOPop[3];
+  PIButton  * mBut[4];
+  PILabel   * mLab[4];
+  PIText    * mText[3];
+  PIScale   * mPScal;
+
+  bool mFgCol;
+  CMapId mCmap;
+  unsigned short mTypScal;
+  unsigned short mTypDisp;
+  float mFPoints;
+  float mHMin,mHMax;
+  float mFracMin,mFracMax;
+  float mLogScale;
+};
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PIext/piinit.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/piinit.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/piinit.cc	(revision 464)
@@ -0,0 +1,57 @@
+#include "machdefs.h"
+#include "piinit.h"
+#include "nobjmgr.h"
+#include "servnobjm.h"
+#include "nomhistadapter.h"
+#include "nomgfdadapter.h"
+#include "nommatvecadapter.h"
+#include "nomimagadapter.h"
+#include "fitsimage.h"
+#include "nomstladapter.h"
+
+int PIAppInitiator::FgInit = 0;
+
+PIAppInitiator::PIAppInitiator(PIStdImgApp * app)
+ : PeidaOutilsInitiator()
+{
+  FgInit++;
+  if (FgInit > 1)  return;
+
+  Services2NObjMgr* serv = app->ObjMgr()->GetServiceObj();
+
+  serv->RegisterClass(new Histo, new NOMAdapter_Histo );
+  serv->RegisterClass(new HProf, new NOMAdapter_Histo );
+  serv->RegisterClass(new Histo2D, new NOMAdapter_Histo2D );
+  serv->RegisterClass(new NTuple, new NOMAdapter_NTuple );
+  serv->RegisterClass(new XNTuple, new NOMAdapter_XNTuple );
+  char* varenv=NULL;
+  if ( (varenv=getenv("PEIDA_TMP")) == NULL )   varenv=getenv("TMPDIR") ;
+  if (varenv)  XNTuple::SetSwapPath(varenv);
+
+  serv->RegisterClass(new GeneralFitData, new NOMAdapter_GeneralFitData );
+
+  serv->RegisterClass(new Vector, new NOMAdapter_Vector );
+  serv->RegisterClass(new Matrix, new NOMAdapter_Matrix );
+
+  serv->RegisterClass(new Image<uint_2>, new  NOMAdapter_Image<uint_2> );
+  serv->RegisterClass(new Image<int_2>, new  NOMAdapter_Image<int_2> );
+  serv->RegisterClass(new Image<int_4>, new  NOMAdapter_Image<int_4> );
+  serv->RegisterClass(new Image<r_4>, new  NOMAdapter_Image<r_4> );
+ 
+  serv->RegisterClass(new FitsImage<uint_2>, new  NOMAdapter_Image<uint_2> );
+  serv->RegisterClass(new FitsImage<int_2>, new  NOMAdapter_Image<int_2> );
+  serv->RegisterClass(new FitsImage<int_4>, new  NOMAdapter_Image<int_4> );
+  serv->RegisterClass(new FitsImage<r_4>, new  NOMAdapter_Image<r_4> );
+
+  serv->RegisterClass(new StarList, new NOMAdapter_StarList );
+
+}
+
+PIAppInitiator::~PIAppInitiator()
+{
+  FgInit--;
+/*  if (FgInit == 0)
+    {
+    }  */
+}
+
Index: /tags/V_LaSilla191199/SophyaPI/PIext/piinit.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/piinit.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/piinit.h	(revision 464)
@@ -0,0 +1,18 @@
+#ifndef PIINIT_H_SEEN
+#define PIINIT_H_SEEN
+
+#include "outilsinit.h"
+#include "pistdimgapp.h"
+
+// Classe d initialisation pour le module PI de PEIDA
+
+class PIAppInitiator : public PeidaOutilsInitiator {
+private:
+  static int FgInit;
+public:
+  		PIAppInitiator(PIStdImgApp *);
+ virtual	~PIAppInitiator();
+};
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PIext/pimgadapter.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/pimgadapter.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/pimgadapter.h	(revision 464)
@@ -0,0 +1,38 @@
+#ifndef PIMGADAPTER_SEEN
+#define PIMGADAPTER_SEEN
+
+#include "cimage.h"
+#include "parradapter.h"
+
+class RzImageAdapter : public P2DArrayAdapter {
+public:
+                  RzImageAdapter(RzImage* rzi, bool ad=false) :
+                    P2DArrayAdapter(rzi->XSize(), rzi->YSize())
+                    { aDel = ad; mImg = rzi; 
+                    DefineXYCoordinates(rzi->XOrg(), rzi->YOrg(), 1., 1. ); }
+
+  virtual 	  ~RzImageAdapter() { if (aDel) delete mImg; }
+  virtual double  Value(int ix, int iy) { return mImg->FValue(ix, iy); }
+
+protected :
+  bool aDel;
+  RzImage* mImg;
+};
+
+template <class T> 
+class ImageAdapter : public P2DArrayAdapter {
+public:
+                  ImageAdapter(Image<T>* img, bool ad=false) :
+                    P2DArrayAdapter(img->XSize(), img->YSize())
+                    { aDel = ad; mImg = img; 
+                    DefineXYCoordinates(img->XOrg(), img->YOrg(), 1., 1. ); }
+
+  virtual 	  ~ImageAdapter() { if (aDel) delete mImg; }
+  virtual double  Value(int ix, int iy) { return((*mImg)(ix, iy)); }
+
+protected :
+  bool aDel;
+  Image<T>* mImg;
+};
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PIext/pintup3d.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/pintup3d.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/pintup3d.cc	(revision 464)
@@ -0,0 +1,135 @@
+#include <stdio.h>
+#include "pintup3d.h"
+
+ 
+/* --Methode-- */
+PINTuple3D::PINTuple3D(NTupleInterface* nt, bool ad)
+: PIDrawer3D()
+{
+  mNT = nt;
+  mAdDO = ad; 
+  SelectXYZ(NULL, NULL, NULL);
+  SelectErrBar();
+}
+
+PINTuple3D::~PINTuple3D()
+{
+  if (mAdDO && mNT)  delete mNT;
+}
+
+/* --Methode-- */
+void  PINTuple3D::SelectXYZ(const char* px, const char* py, const char* pz)
+{
+string name;
+if (mNT == NULL)  xK = yK = zK = -1;
+if (px == NULL) xK = -1;
+else { name = px; xK = mNT->ColumnIndex(name); }
+if (py == NULL) yK = -1;
+else { name = py; yK = mNT->ColumnIndex(name); }
+if (pz == NULL) zK = -1;
+else { name = pz; zK = mNT->ColumnIndex(name); }
+}
+
+/* --Methode-- */
+void  PINTuple3D::SelectErrBar(const char* erbx, const char* erby, const char* erbz)
+{
+string name;
+if (mNT == NULL)  xebK = yebK = zebK = -1;
+if (erbx == NULL) xebK = -1;
+else { name = erbx;  xebK = mNT->ColumnIndex(name); }
+if (erby == NULL) yebK = -1;
+else { name = erby;  yebK = mNT->ColumnIndex(name); }
+if (erbz == NULL) zebK = -1;
+else { name = erbz;  zebK = mNT->ColumnIndex(name); }
+}
+
+
+/* --Methode-- */
+void PINTuple3D::UpdateLimits()
+{
+  if (!mNT) return; 
+  if (mNT->NbLines() <= 0)  return;
+  if ( (xK < 0) || (yK < 0)  || (zK < 0) )   return;
+
+  // Commencer par trouver nos limites
+  double xmin, xmax, ymin, ymax, zmin, zmax;
+  xmin = ymin = 9.e19;
+  xmax = ymax = -9.e19;
+  zmax = zmax = -9.e19;
+  mNT->GetMinMax(xK, xmin, xmax);
+  mNT->GetMinMax(yK, ymin, ymax);
+  mNT->GetMinMax(zK, zmin, zmax);
+
+// Centre du champ en C = (xmin+xmax)/2., (ymin+ymax)/2  (zmin+zmax)*0.5
+// Distance D = Max(xmax-xmin,ymin-ymax)*2
+// Observateur en O = X+D, Yc+2*D 
+  double D = xmax-xmin;
+  if (D < (ymax-ymin))  D = ymax-ymin;
+  D *= 1.4;
+  
+  Set3DView((xmin+xmax)/2., (ymin+ymax)/2, (zmin+zmax)/2., 
+            (xmin+xmax)/2.+D , (ymin+ymax)/2.-2.5*D , zmin+(zmax-zmin)*0.85, 0.25, 0.25);  
+
+  x3Min = xmin;  // - 0.05*(xmax-xmin);
+  x3Max = xmax;  // + 0.05*(xmax-xmin);
+  y3Min = ymin;  // - 0.05*(ymax-ymin);
+  y3Max = ymax;  // + 0.05*(ymax-ymin);
+  z3Min = zmin;  // - 0.05*(zmax-zmin);
+  z3Max = zmax;  // + 0.05*(zmax-zmin);
+
+//  printf("PINTuple3D::UpdateLimits() : %g .. %g  %g .. %g  %g .. %g (%g) \n", xmin,xmax,ymin,ymax,zmin,zmax,D);
+//  printf("PINTuple3D::UpdateLimits() :  %g %g %g << %g %g %g \n", 
+//         (xmin+xmax)/2., (ymin+ymax)/2, (zmin+zmax)*0.5, 
+//         (xmin+xmax)/2.+D , (ymin+ymax)/2.+2.*D , zmin+(zmax-zmin)*0.1);
+}
+
+
+/* --Methode-- */
+void PINTuple3D::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
+{
+double xp,yp,zp,xer,yer,zer;
+double xl,yl,zl;
+int nok;
+
+// On trace les axes - En attendant de faire mieux - Reza 8/12/98
+if (axesFlags != kAxesNone)  DrawAxes(g);
+
+if (!mNT) return;
+if ( (xK < 0) || (yK < 0) || (zK < 0) )  return;
+
+#if defined(CC_HAS_RTTI_SUPPORT)
+PIGraphic3D* g3 = dynamic_cast<PIGraphic3D*>(g);
+#else
+PIGraphic3D* g3 = (PIGraphic3D*)(g);
+#endif
+
+if (mLAtt == PI_NotDefLineAtt)  g3->SelLine(PI_ThinLine);
+
+nok = 0;  
+xp = yp = zp = xl = yl = zl = 0;
+for (int i=0; i<mNT->NbLines(); i++) {
+  xl = xp;  yl = yp;  zl = zp;
+  xp = mNT->GetCell(i, xK);
+  yp = mNT->GetCell(i, yK);
+  zp = mNT->GetCell(i, zK);
+  if ( (i > 0) && (mLAtt != PI_NotDefLineAtt) )   // On relie les points ...
+    g3->DrawLine3D(xl, yl, zl, xp, yp, zp);
+  nok++;
+  g3->DrawMarker3D(xp, yp, zp); 
+  if ( xebK >= 0 ) {
+    xer = mNT->GetCell(i, xebK);
+    g3->DrawLine3D(xp-xer, yp, zp, xp+xer, yp, zp);
+  }
+  if ( yebK >= 0 ) {
+    yer = mNT->GetCell(i, yebK);
+    g3->DrawLine3D(xp, yp-yer, zp, xp, yp+yer, zp);
+  }
+  if ( zebK >= 0 ) {
+    zer = mNT->GetCell(i, zebK);
+    g3->DrawLine3D(xp, yp, zp-zer, xp, yp, zp+zer);
+  }
+}
+
+return;
+}
+
Index: /tags/V_LaSilla191199/SophyaPI/PIext/pintup3d.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/pintup3d.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/pintup3d.h	(revision 464)
@@ -0,0 +1,31 @@
+#ifndef PINTUPLE3D_H
+#define PINTUPLE3D_H
+
+#include "ntupintf.h"
+#include "pi3ddrw.h"
+
+class PINTuple3D : public PIDrawer3D {
+public:
+                     PINTuple3D(NTupleInterface* nt, bool ad=false);
+  virtual           ~PINTuple3D();
+  
+  virtual void       Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
+  virtual void       UpdateLimits();
+  
+          void       SelectXYZ(const char* px, const char* py, const char* pz);
+          void       SelectErrBar(const char* erbx=NULL, const char* erby=NULL, const char* erbz=NULL);
+
+       
+protected:
+  NTupleInterface* mNT;
+  bool mAdDO;
+  int xK, yK, zK;           // Index du nom de variable en X/Y/Z ds le ntuple
+  int xebK, yebK, zebK;     // Index du nom de variable en ErrBarX/Y/Z ds le ntuple
+
+};
+
+#endif
+
+
+
+
Index: /tags/V_LaSilla191199/SophyaPI/PIext/pintuple.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/pintuple.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/pintuple.cc	(revision 464)
@@ -0,0 +1,163 @@
+#include <stdio.h>
+#include "pintuple.h"
+
+ 
+/* --Methode-- */
+PINTuple::PINTuple(NTupleInterface* nt, bool ad)
+: PIDrawer()
+{
+  mNT = nt;
+  mAdDO = ad; 
+  SelectXY(NULL, NULL);
+  SelectWt(NULL, 1);
+  SelectErrBar();
+}
+
+PINTuple::~PINTuple()
+{
+  if (mAdDO && mNT)  delete mNT;
+}
+
+/* --Methode-- */
+void  PINTuple::SelectXY(const char* px, const char* py)
+{
+string name;
+if (mNT == NULL)  xK = yK = -1;
+if (px == NULL) xK = -1;
+else { name = px; xK = mNT->ColumnIndex(name); }
+if (py == NULL) yK = -1;
+else { name = py; yK = mNT->ColumnIndex(name); }
+}
+
+/* --Methode-- */
+void  PINTuple::SelectWt(const char* pw, int nbins)
+{
+nWbins = (nbins > 0) ? nbins : 10;
+if (pw == NULL) wK = -1;  
+else { string name = pw;   wK = mNT->ColumnIndex(name);  }
+ 
+if (wK >= 0) mNT->GetMinMax(wK, wMin, wMax);
+else  { wMin = 0.; wMax = 1.; }
+}
+
+/* --Methode-- */
+void  PINTuple::SelectErrBar(const char* erbx, const char* erby)
+{
+string name;
+if (mNT == NULL)  xebK = yebK = -1;
+if (erbx == NULL) xebK = -1;
+else { name = erbx;  xebK = mNT->ColumnIndex(name); }
+if (erby == NULL) yebK = -1;
+else { name = erby;  yebK = mNT->ColumnIndex(name); }
+}
+
+
+/* --Methode-- */
+void PINTuple::UpdateLimits()
+{
+  if (!mNT) return;
+  if (mNT->NbLines() <= 0)  return;
+  if ( (xK < 0) || (yK < 0) )   return;
+
+  // Commencer par trouver nos limites
+  double dx, dy;
+  double xmin, xmax, ymin, ymax;
+  xmin = ymin = 9.e19;
+  xmax = ymax = -9.e19;
+  mNT->GetMinMax(xK, xmin, xmax);
+  mNT->GetMinMax(yK, ymin, ymax);
+    
+  dx = 0.02*(xmax-xmin);
+  dy = 0.02*(ymax-ymin);
+  
+  SetLimits(xmin-dx, xmax+dx, ymin-dy, ymax+dy);
+  SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
+}
+
+
+/* --Methode-- */
+void PINTuple::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
+{
+double xp,yp,xer,yer,wp;
+double xl,yl;
+int nok;
+
+if (!mNT) return;
+if ( (xK < 0) || (yK < 0) )  return;
+if (mLAtt == PI_NotDefLineAtt)  g->SelLine(PI_ThinLine);
+
+//  Pour tracer des markers avec taille fonction de Wt (poids)
+double dw = (wMax-wMin)/nWbins;
+if (dw < 1.e-19) dw = 1.e19;
+int msz,sz;
+
+PIMarker mrk;
+if (wK >= 0)  mrk = (mMrk != PI_NotDefMarker) ? mMrk : PI_CircleMarker;
+else   mrk = (mMrk != PI_NotDefMarker) ? mMrk : PI_DotMarker;
+msz = mMSz;
+if (msz < 1) msz = 1;
+g->SelMarker(msz, mrk);
+
+nok = 0;  
+xp = yp = xl = yl = 0;
+for (int i=0; i<mNT->NbLines(); i++) {
+  xl = xp;  yl = yp; 
+  xp = mNT->GetCell(i, xK);
+  yp = mNT->GetCell(i, yK);
+  if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) )  continue;
+  if ( (i > 0) && (mLAtt != PI_NotDefLineAtt) )   // On relie les points ...
+    g->DrawLine(xl, yl, xp, yp);
+  nok++;
+  if ( xebK >= 0 ) {
+    xer = mNT->GetCell(i, xebK);
+    if(xer>0.) g->DrawLine(xp-xer, yp, xp+xer, yp);
+  }
+  if ( yebK >= 0 ) {
+    yer = mNT->GetCell(i, yebK);
+    if(yer>0.) g->DrawLine(xp, yp-yer, xp, yp+yer);
+  }
+  if (wK >= 0) { // Taille de marker en fonction du poids
+    wp = mNT->GetCell(i, wK);
+    sz = (int)((wp-wMin)/dw);
+    if (sz < 0) sz = 0;
+    if (sz > nWbins)  sz = nWbins;
+    sz += msz;
+    if (sz < 2)  g->SelMarker(sz, PI_DotMarker);
+    else g->SelMarker(sz, mrk);
+  }
+  g->DrawMarker(xp, yp); 
+}
+
+/*
+sprintf(buff, "NTuple:  NEntry= %d  NDisp= %d", (int)mNT->NEntry(), nok);
+g->BaseGraphic()->DrawString(15,15,buff);
+*/
+return;
+}
+
+/* --Methode-- */
+void PINTuple::AppendTextInfo(string& info, double xmin, double ymin, double xmax, double ymax)
+{
+if (!mNT) return;
+if ( (xK < 0) || (yK < 0) )  return;
+
+int ncnt = 0;
+double xp,yp;
+char buff[128];
+sprintf(buff,"PINTuple: NLines= %d  NCol= %d \n", mNT->NbLines(),  mNT->NbColumns());
+info += buff;
+info += mNT->LineHeaderToString();
+for (int i=0; i<mNT->NbLines(); i++) {
+  xp = mNT->GetCell(i, xK);
+  yp = mNT->GetCell(i, yK);
+  if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) )  continue;
+  ncnt++;
+  if (ncnt > 101) continue;
+  info += mNT->LineToString(i);
+  }
+if (ncnt >= 101) info += " .... \n";
+sprintf(buff," %d points inside selected region \n", ncnt);
+info += buff;
+// printf("PINTuple::AppendTextInfo()-DBG %g %g %g %g - %d\n", xmin, ymin, xmax, ymax, ncnt); 
+return;
+}
Index: /tags/V_LaSilla191199/SophyaPI/PIext/pintuple.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/pintuple.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/pintuple.h	(revision 464)
@@ -0,0 +1,40 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Module PI : Peida Interactive  PINTuple et PINTupleWdg
+// Traceur d objet de type NTupleInterface
+
+#ifndef PINTUPLE_H
+#define PINTUPLE_H
+
+#include "ntupintf.h"
+#include "pidrawer.h"
+
+class PINTuple : public PIDrawer {
+public:
+                     PINTuple(NTupleInterface* nt, bool ad);
+  virtual           ~PINTuple();
+  
+  virtual void       Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
+  virtual void       UpdateLimits();
+  
+  virtual void       SelectXY(const char* px, const char* py);
+  virtual void       SelectWt(const char* pw=NULL, int nbins=10);
+  virtual void       SelectErrBar(const char* erbx=NULL, const char* erby=NULL);
+
+  virtual void       AppendTextInfo(string& info, double xmin, double ymin, double xmax, double ymax);
+       
+protected:
+  NTupleInterface* mNT;
+  bool mAdDO;
+  int xK, yK;          // Index du nom de variable en X/Y ds le ntuple
+  int xebK, yebK;      // Index du nom de variable en ErrBarX/Y ds le ntuple
+  int wK;              // Index du nom de variable poids
+  double wMin, wMax;        // Valeurs de poids min/max
+  int nWbins;               // Nombre de bins pour le poids (Wt)
+
+};
+
+#endif
+
+
+
+
Index: /tags/V_LaSilla191199/SophyaPI/PIext/pipodrw.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/pipodrw.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/pipodrw.cc	(revision 464)
@@ -0,0 +1,128 @@
+//  Adaptateurs et Drawers divers pour Outils PEIDA++
+//                             R. Ansari  06-08/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include "pipodrw.h"
+#include "generalfit.h"
+
+
+//================================================================
+// PIGFFDrawer
+//================================================================
+
+PIGFFDrawer::PIGFFDrawer(GeneralFunction* f)
+: mFunc(f), mNParms(f->NPar()), mParms(new double[mNParms])
+{
+  ASSERT(f->NVar() == 1);
+}
+
+PIGFFDrawer::~PIGFFDrawer()
+{
+  delete[] mParms;
+}
+
+void
+PIGFFDrawer::SetParms(double const* p)
+{
+  for (int i=0; i<mNParms; i++)
+    mParms[i] = p[i];
+}
+
+
+void
+PIGFFDrawer::Draw(PIGraphicUC* g, double /*xmin*/, double/*ymin*/, double/*xmax*/, double/*ymax*/)
+{
+  PIGrCoord x1, x2, y1, y2;
+  g->GetGrSpace(x1, x2, y1, y2);
+  double xMax = x2;
+  double xMin = x1;
+  double yMax = y2;
+  double yMin = y1;
+  double xStep = (xMax - xMin)/100;
+  double xOld = xMin;
+  double yOld = 0;
+//  double yOld = f->Value(&xMin, mParms);
+  for (double x = xMin+xStep; x<xMax; x+=xStep) {
+   double y = 0; // $CHECK$
+//    double y = f->Value(&x, mParms);
+    if (y>yMin && yOld>yMin && 
+        y<yMax && yOld<yMax) 
+           g->DrawLine(xOld, yOld, x, y);
+    xOld = x;
+    yOld = y;
+  }
+}
+
+// ----------------------------------------------------------
+// Adaptateur de vecteurs Peida++ a P1DArrayAdapter
+// ----------------------------------------------------------
+
+/* --Methode-- */
+POVectorAdapter::POVectorAdapter(Vector* v, bool ad)
+        : P1DArrayAdapter(v->NElts())
+{
+aDel = ad; mVec = v;
+}
+
+/* --Methode-- */
+POVectorAdapter::~POVectorAdapter()
+{
+if (aDel) delete mVec;
+}
+
+/* --Methode-- */
+double POVectorAdapter::Value(int i)
+{ 
+return((*mVec)(i)); 
+}
+
+// ----------------------------------------------------------
+// Adaptateur d'Histo-2D Peida++ a P2DArrayAdapter
+// ----------------------------------------------------------
+
+/* --Methode-- */
+POH2DAdapter::POH2DAdapter(Histo2D* h2d, bool ad)
+        : P2DArrayAdapter(h2d->NBinX(), h2d->NBinY())
+{
+aDel = ad; mH2d = h2d;
+DefineXYCoordinates(h2d->XMin(), h2d->YMin(), h2d->WBinX(), h2d->WBinY() );
+}
+
+/* --Methode-- */
+POH2DAdapter::~POH2DAdapter()
+{
+if (aDel)  delete mH2d;
+}
+
+/* --Methode-- */
+double POH2DAdapter::Value(int ix, int iy)
+{
+return((*mH2d)(ix, iy));
+}
+
+// ----------------------------------------------------------
+// Adaptateur de matrice Peida++ a P2DArrayAdapter
+// Attention  Y: Lignes (rows)  X: Colonnes
+// ----------------------------------------------------------
+
+/* --Methode-- */
+POMatrixAdapter::POMatrixAdapter(Matrix* mtx, bool ad)
+        : P2DArrayAdapter(mtx->NCol(), mtx->NRows())
+{
+aDel = ad; mMtx = mtx;
+}
+
+/* --Methode-- */
+POMatrixAdapter::~POMatrixAdapter()
+{
+if (aDel)  delete mMtx;
+}
+
+/* --Methode-- */
+double POMatrixAdapter::Value(int ix, int iy)
+{
+// Attention MatrixAdapter(X=Colonne, Y= Row) = Matrix(row, col)  
+return((*mMtx)(iy, ix));
+}
+
+
Index: /tags/V_LaSilla191199/SophyaPI/PIext/pipodrw.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/pipodrw.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/pipodrw.h	(revision 464)
@@ -0,0 +1,71 @@
+// This may look like C code, but it is really -*- C++ -*-
+//  Adaptateurs et Drawers divers pour Outils PEIDA++
+//                             R. Ansari  06-08/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIPODRW_H_SEEN
+#define PIPODRW_H_SEEN
+
+#include "pidrawer.h"
+#include "parradapter.h"
+#include "cvector.h"
+#include "matrix.h"
+#include "histos2.h"
+
+
+class GeneralFunction;
+class PIGFFDrawer : public PIDrawer {
+public:
+                     PIGFFDrawer(GeneralFunction*);
+  virtual           ~PIGFFDrawer();
+  
+  virtual void       Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
+  virtual void       SetParms(double const*);
+protected:
+  GeneralFunction*    mFunc;
+  int                 mNParms;
+  double*             mParms;
+};
+
+
+// Adaptateur de vecteurs Peida++ a P1DArrayAdapter
+class POVectorAdapter : public P1DArrayAdapter {
+public :
+                  POVectorAdapter(Vector* v, bool ad=false);
+  virtual         ~POVectorAdapter();
+  virtual double  Value(int i);
+
+protected:
+  bool aDel;
+  Vector* mVec;
+};
+
+// Adaptateur d'Histo-2D Peida++ a P2DArrayAdapter
+class POH2DAdapter :  public P2DArrayAdapter {
+public :
+                  POH2DAdapter(Histo2D* h2d, bool ad=false);
+  virtual         ~POH2DAdapter();
+
+  virtual double  Value(int ix, int iy);   
+
+protected:
+  bool aDel;
+  Histo2D* mH2d;
+};
+
+// Adaptateur de matrice Peida++ a P2DArrayAdapter
+// Attention MatrixAdapter(X=Colonne, Y= Row) = Matrix(row, col)  
+class POMatrixAdapter :  public P2DArrayAdapter {
+public :
+                  POMatrixAdapter(Matrix* mtx, bool ad=false);
+  virtual         ~POMatrixAdapter();
+
+  virtual double  Value(int ix, int iy);   
+
+protected:
+  bool aDel;
+  Matrix* mMtx;
+};
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PIext/pisiadw.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/pisiadw.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/pisiadw.cc	(revision 464)
@@ -0,0 +1,284 @@
+#include "machdefs.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <typeinfo>
+
+#include "perrors.h"
+#include "ctimer.h"
+
+#include "nbmath.h"
+
+#include "pistdimgapp.h"
+#include "nobjmgr.h"
+#include "servnobjm.h"
+
+
+
+/* ........................................................... */
+/*  Classe ObjMgrWind  interface de gestion d'objets nommes    */
+/* ........................................................... */
+
+/* --Methode-- */
+ObjMgrWind::ObjMgrWind(PIStdImgApp *par)
+: PIWindow((PIMsgHandler *)par, "objmgr", PIWK_dialog, 
+           400, 300, 250, 250)
+{
+int i;
+dap = par;
+
+int bsx, bsy;
+int tsx, tsy;
+int spx, spy;
+// On definit la taille a partir de la taille par defaut des composantes 
+PIApplicationPrefCompSize(bsx, bsy);
+spx = bsx/4;   spy = bsy/4;
+tsx = 4.0*bsx+3*spx;  tsy = 6*bsy+7*spy;
+SetSize(tsx,tsy);
+dirlist = new PIOptMenu(this, "dirlist", 2.5*bsx, bsy, spx+0.25*bsx, spy); 
+dirlist->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+objlist = new PIList(this, "objlist", 3*bsx, tsy-3*spy-bsy, spx, 2*spy+bsy);
+objlist->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+// objlist->SetBorderWidth(2);
+
+int py = spy;
+int px = 2*spx+3*bsx;
+mBut[0] = new PIButton(this, "SetCurDir", 10, bsx, bsy, px, py);   py += (bsy+spy);
+mBut[1] = new PIButton(this, "Display", 20, bsx, bsy, px, py);   py += (bsy+spy);
+mBut[2] = new PIButton(this, "Print",   30, bsx, bsy, px, py);   py += (bsy+spy);
+mBut[3] = new PIButton(this, "SavePPF", 40, bsx, bsy, px, py);   py += (bsy+spy);
+mBut[4] = new PIButton(this, "Delete",  50, bsx, bsy, px, py);   py += (bsy+spy);
+mBut[5] = new PIButton(this, "Dismiss", 90, bsx, bsy, px, py);   py += (bsy+spy);
+
+for(i=0; i<6; i++)
+  mBut[i]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+// FinishCreate(); pas necessaire ?
+}
+
+/* --Methode-- */
+ObjMgrWind::~ObjMgrWind()
+{
+int i;
+delete dirlist;
+delete objlist;
+for(i=0; i<6; i++)  delete mBut[i];
+}
+
+/* --Methode-- */
+void ObjMgrWind::Show()
+{
+dap->SetBlocked();
+string cdir;
+dap->ObjMgr()->GetCurrentDir(cdir);
+cdir = '/' + cdir;
+dirlist->SetValueStr(cdir);
+dap->ObjMgr()->UpdateObjMgrWindow(dirlist->GetValue()-30000);
+PIWindow::Show();
+return;
+}
+
+/* --Methode-- */
+void ObjMgrWind::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
+{
+
+  // PIMessage ssg = ModMsg(msg);
+msg = UserMsg(msg);
+if (msg == 90)  {
+  dap->SetReady();
+  this->Hide();
+  return;
+  }
+else if (msg >= 30000) {
+  dap->ObjMgr()->UpdateObjMgrWindow(msg-30000);
+  return;
+  }
+else if (msg == 10) {
+  string cdir = dirlist->GetValueStr();
+  dap->ObjMgr()->SetCurrentDir(cdir);
+  return;
+  }
+
+string nom = "";
+if ( (msg == 20) || (msg == 30) || (msg == 40) || (msg == 50) ) {
+  string sel = objlist->GetSelectionStr();
+  //  size_t p = sel.find_first_not_of(" \t");
+  //  if (p<0) p = 0;
+  size_t l = sel.length(); 
+  size_t q = sel.find_first_of(" \t");
+  if (q > l)   q = l; 
+  nom = dirlist->GetValueStr() + '/' + sel.substr(0, q);
+  }
+
+NamedObjMgr* om = dap->ObjMgr();
+if (om == NULL)  return;
+if (nom.length() < 1)  return;
+
+switch (msg)
+  {
+  case 20:
+    om->DisplayObj(nom);
+    break;
+  case 30:
+    om->PrintObj(nom);
+    break;
+  case 40:
+    if (dap->mPpfout)  om->SaveObj(nom, *(dap->mPpfout), false);
+    break;
+  case 50:
+    om->DelObj(nom);
+    objlist->DeleteItemMsg(objlist->GetSelection());
+    //    dap->ObjMgr()->UpdateObjMgrWindow(dirlist->GetValue()-30000);
+    break;
+
+  default:    
+    //    printf("DEBUG/ObjMgrW::Process %d %d \n", (int)msg, (int)ssg); 
+    break;
+  }
+    
+return;
+}
+
+
+/* ........................................................... */
+/*  Classe PPInMgrWind  interface de gestion d'objets nommes    */
+/* ........................................................... */
+
+/* --Methode-- */
+PPInMgrWind::PPInMgrWind(PIStdImgApp *par)
+: PIWindow((PIMsgHandler *)par, "PPF-FileManager", PIWK_dialog, 
+           400, 300, 250, 250)
+{
+int i;
+dap = par;
+
+int bsx, bsy;
+int tsx, tsy;
+int spx, spy;
+// On definit la taille a partir de la taille par defaut des composantes 
+PIApplicationPrefCompSize(bsx, bsy);
+spx = bsx/4;   spy = bsy/3;
+bsx *= 1.25;
+ttx = tsx = 3*bsx+8*spx;   tty = tsy = 7*bsy+5*spy;
+SetSize(tsx,tsy);
+
+mLab[0] = new PILabel(this, "filename", tsx-spx, bsy-spy, spx/2, spy/2);
+mLab[0]->SetLabel("");
+mLab[0]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic,PIBK_elastic);
+mLab[0]->SetBorderWidth(1);
+
+polx = spx/2;  poly = bsy+1.5*spy;
+tolx = tsx-spx;   toly = tsy-2*bsy-5*spy;
+int py = tsy-2*spy-bsy;
+int px = 2*spx;
+mBut[0] = new PIButton(this, "Read", 2500, bsx, bsy, px, py);   px += (bsx+2*spx);
+mBut[1] = new PIButton(this, "ReadAll", 2600, bsx, bsy, px, py);   px += (bsx+2*spx);
+mBut[2] = new PIButton(this, "Close", 2700, bsx, bsy, px, py);   px += (bsx+2*spx);
+
+for(i=0; i<3; i++)
+  mBut[i]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+  
+objlist = NULL;
+mLab[1] = NULL;
+mPin = NULL;
+
+//   FinishCreate(); pas necessaire 
+}
+
+/* --Methode-- */
+PPInMgrWind::~PPInMgrWind()
+{
+int i;
+if (objlist) delete objlist;
+delete mLab[0];
+for(i=0; i<3; i++)  delete mBut[i];
+}
+
+/* --Methode-- */
+void PPInMgrWind::SetFile(string flnm)
+{
+char strg[128];
+char* nom;
+char  noms[32];
+int i, cid, key, ln;
+
+bool ok = true;
+
+TRY {
+  mPin = new PInPersist(flnm);
+}  CATCH(merr) 
+  { printf("ObjMgrWind::SetFile Exception= %ld (%s) \n", (long)merr, PeidaExc(merr)); 
+  ok = false; } ENDTRY;
+
+if (!ok) { mPin = NULL;  dap->SetReady(); return; }
+
+if (mPin->NbTags() < 1) {
+  delete mPin;   mPin = NULL;
+  string no="";
+  dap->ObjMgr()->ReadObj(flnm,no);
+  return;
+}
+
+if (objlist)  delete objlist;
+SetSize(ttx,tty);
+mLab[0]->SetLabel(flnm);
+objlist = new PIList(this, "infileobjlist", tolx, toly, polx, poly);
+objlist->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+objlist->SetBorderWidth(2);
+
+
+for(i=0; i<mPin->NbTags(); i++) {
+  key = mPin->TagKey(i, cid, ln);  // $CHECK$ non-const & reference initialized to temporary, car int -> long&
+  if (ln <= 0)  nom = "?";
+  else { strncpy(noms, mPin->TagName(i).c_str(), 31);  noms[31] = '\0'; nom = noms; }
+  sprintf(strg, "%s  (T=%s, Key=%d)",  nom, dap->ObjMgr()->GetServiceObj()->PClassIdToClassName(cid), key);
+  //  sprintf(strg, "%s  (T=%s, Key=%d)",  nom, " DataObject ?", key);  Attention SANS_EVOLPLANCK
+  objlist->AppendItem(strg, 5000+i);
+}
+
+}
+
+/* --Methode-- */
+void PPInMgrWind::Show()
+{
+if (mPin == NULL)   return;
+dap->SetBlocked();
+PIWindow::Show();
+return;
+}
+
+/* --Methode-- */
+void PPInMgrWind::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
+{
+
+int sel;
+msg = UserMsg(msg);
+
+if (msg == 2700)  {
+  delete mPin;  mPin = NULL;
+  delete objlist; objlist = NULL;
+  dap->SetReady();
+  this->Hide();
+  return;
+}
+
+NamedObjMgr* om = dap->ObjMgr();
+switch (msg)
+  {
+  case 2500:
+    sel = (PIMessage)objlist->GetSelection() - 5000;
+    if (sel >= 0) om->ReadObj((*mPin), sel);
+    break;
+  case 2600:
+    om->ReadObj((*mPin), -1);
+    dap->SetReady();
+    this->Hide();
+    break;
+
+  default:    
+    break;
+  }
+    
+return;
+}
Index: /tags/V_LaSilla191199/SophyaPI/PIext/pisiadw.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/pisiadw.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/pisiadw.h	(revision 464)
@@ -0,0 +1,67 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Classe de fenetre pour gestion d'objet et PPF-In
+// Reza      Aout 97 , Juillet,Aout 98, Ete 99
+// CEA-DAPNIA      LAL-IN2P3/CNRS
+
+#ifndef PISIADW_H_SEEN
+#define PISIADW_H_SEEN
+
+#include <string.h>
+
+#include "pisysdep.h"
+
+#include PIAPP_H
+#include PIWIN_H 
+#include PIMENU_H 
+#include PIOPTMENU_H 
+#include PISTDWDG_H 
+#include PILIST_H 
+
+
+class PIStdImgApp;
+
+
+
+/* --------------------------------------------------------------------------- */
+class ObjMgrWind : public PIWindow {
+public :
+  ObjMgrWind(PIStdImgApp *par);
+  ~ObjMgrWind();
+  virtual void  Show();
+  virtual void  Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+  inline  void  AddDirectory(const char * dir, int did)
+                    { dirlist->AppendItem(dir, 30000+did); }
+  inline  void  DelDirectory(int did)
+                    { dirlist->Menu()->DeleteItemMsg(30000+did); }
+  inline  void  ClearHelpList() 
+                    { mNitem=0; objlist->DeleteAllItems(); }
+  inline  void	AddObj(const char * objn) 
+		    { mNitem++;  objlist->AppendItem(objn, 100+mNitem); }
+private:
+  PIStdImgApp* dap;
+  PIOptMenu* dirlist;
+  int mNitem;
+  PIList* objlist;
+  PIButton * mBut[6];
+};
+
+/* --------------------------------------------------------------------------- */
+class PPInMgrWind :  public PIWindow {
+public:
+   PPInMgrWind(PIStdImgApp *par);
+   ~PPInMgrWind();
+   virtual void  Show();
+   virtual void  Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+   void SetFile(string flnm);
+private:
+  PIStdImgApp* dap;
+  PIList* objlist;
+  PILabel * mLab[2];
+  PIButton* mBut[3];
+  PInPersist* mPin;
+  int tolx, toly, polx, poly;  // Taille et position de  objlist
+  int ttx, tty;   // Taille globale par defaut
+
+};
+ 
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PIext/pistdimgapp.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/pistdimgapp.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/pistdimgapp.cc	(revision 464)
@@ -0,0 +1,1316 @@
+#include "machdefs.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <typeinfo>
+
+#include <string>
+#include <vector>
+
+#include "strutil.h"
+#include "timing.h"
+#include "perrors.h"
+#include "ctimer.h"
+
+#include "psighand.h"
+
+#include "cimage.h" // pour pouvoir faire extract 
+
+#include "pistdimgapp.h"
+#include "pihisto2d.h"
+#include "psfile.h"
+#include "piimgtools.h"
+#include "pidrwtools.h"
+
+#include "pistzwin.h"
+
+#include "piinit.h"
+#include "piversion.h"
+#include "piaversion.h"
+
+
+static char ImgDir[256];
+static char WorkDir[256];
+
+
+/* ........................................................... */
+/*                    Classe PIStdImgApp                         */
+/* ........................................................... */
+
+/* --Methode-- */
+PIStdImgApp::PIStdImgApp(int narg, char* arg[])
+: PIApplication(420, 320, narg, arg)
+{
+
+// Les menus
+m[0] = new PIMenu(Menubar(),"Fichier");
+m[0]->AppendItem("Help", 10100);
+m[0]->AppendItem("Open-Fits", 10120);
+m[0]->AppendItem("Open-PPF", 10130);
+m[0]->AppendItem("Close", 10110);
+m[0]->AppendItem("delete", 10111);
+// m[0]->AppendItem("Options", 10101);
+m[0]->AppendItem("Exit", 10105);
+
+m[1] = new PIMenu(Menubar(),"Objets");
+m[1]->AppendItem("ObjectManager", 10201);
+m[1]->AppendItem("OpenOutPPF", 10220);
+m[1]->AppendItem("CloseOutPPF", 10230);
+
+m[2] = new PIMenu(Menubar(),"Tools");
+m[2]->AppendItem("Show ImageTools", 10301);
+m[2]->AppendItem("Show DrawerTools", 10302);
+m[2]->AppendItem("Ext.Pave", 10304);
+m[2]->AppendItem("Ext.Pave+Org", 10305);
+m[2]->SetSensitivityMsg(10305, false);
+m[2]->AppendItem("Cuts X,Y", 10306);
+m[2]->SetSensitivityMsg(10306, false);
+mc = new PIMenu(m[2], "StackTools");
+mc->AppendItem("DispNext", 10320);
+mc->AppendItem("Blink 0.5s", 10321);
+mc->AppendItem("Blink 1s", 10322);
+mc->AppendItem("Blink 2s", 10324);
+mc->AppendItem("Stop Blink", 10329);
+mc->AppendItem("RemoveCurrent", 10330);
+m[2]->AppendPDMenu(mc);
+m[2]->SetSensitivity("StackTools", false);
+
+m[3] = new PIMenu(Menubar(),"Window");
+m[3]->AppendItem("StackWindow", 10400);
+m[3]->AppendItem("Window", 10411);
+m[3]->AppendItem("Window 2x1", 10421);
+m[3]->AppendItem("Window 1x2", 10412);
+m[3]->AppendItem("Window 2x2", 10422);
+m[3]->AppendItem("Window 3x1", 10431);
+m[3]->AppendItem("Window 3x3", 10433);
+
+m[4] = new PIMenu(Menubar(),"PostScript");
+m[4]->AppendItem("OpenPS", 10501);
+m[4]->AppendItem("ClosePS", 10505);
+m[4]->AppendItem("Window->PS", 10511);
+m[4]->AppendItem("Image->PS", 10515);
+m[4]->AppendItem("Window->EPS", 10512);
+m[4]->AppendItem("Image->EPS", 10516);
+m[4]->SetSensitivityMsg(10515, false);
+m[4]->SetSensitivityMsg(10516, false);
+
+m[5] = new PIMenu(Menubar(),"Special");
+m[5]->AppendItem("CloseAll", 10601);
+m[5]->AppendCheckItem("Red.Out/Err", 10602);
+m[5]->AppendCheckItem("Catch SigFPE", 10603);
+m[5]->AppendCheckItem("Catch SigSEGV", 10604);
+m[5]->AppendCheckItem("ObjMgr Verb", 10605);
+
+m[6] = new PIMenu(Menubar(),"Modules");
+
+AppendMenu(m[0]);
+AppendMenu(m[1]);
+AppendMenu(m[2]);
+AppendMenu(m[3]);
+AppendMenu(m[4]);
+AppendMenu(m[5]);
+// AppendMenu(m[6]);  Menu Modules vide pour le moment 
+
+int scsx, scsy;
+ScreenSz(scsx, scsy);
+if (scsy <= 600)  mFgScSz = 0;
+else if (scsy <= 800)  mFgScSz = 1;
+else if (scsy <= 1024)  mFgScSz = 2;
+else   mFgScSz = 3;
+int msx = 420+mFgScSz*60;
+int msy = 320+mFgScSz*40;
+MainWin()->SetSize(msx, msy);
+
+int bss = 100+mFgScSz*15;
+gimv = new PIPixmap(MainWin(), "GloV", bss, bss, 5, 5);
+gimv->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_free, PIBK_free); 
+zoom = new PIPixmap(MainWin(), "Zoom", bss, bss, bss+10, 5);
+zoom->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_free, PIBK_free); 
+cmapv = new PICMapView(MainWin(), "CMapView", msx-10, 14+mFgScSz*2, 5, bss+10); 
+cmapv->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_free); 
+
+int cpy = bss+10+14+mFgScSz*2+5;
+
+// Creation d'une console avec gestion des commandes  
+mCons = new PIConsole(MainWin(), "Console", 30200, 512, 132, msx, msy-cpy, 0, cpy );
+mCons->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_fixed); 
+mCons->AcceptCmd(true, 50);
+redirecout = false;
+// RedirectStdOutErr(true);  pas par defaut 
+
+char buff[128];
+mCons->AddStr("  ............  starting piapp .............\n", PIVA_Blue );
+sprintf(buff, "Version: piapp=%g  PI=%g  PEIDA=%g \n", (double)PIAPP_VERSIONNUMBER, 
+              (double)PI_VERSIONNUMBER, (float)PeidaVersion());
+mCons->AddStr(buff, PIVA_Blue );
+mCons->AddStr("  ..........................................\n", PIVA_Blue );
+// PrintPeidaVersion();
+
+ 
+mObjMgr = new NamedObjMgr;
+mCmd = new PIACmd(mObjMgr, this);
+
+// Pas trop de message de la part de NamedObjMgr
+m[5]->SetStateMsg(10605, false);
+mObjMgr->SetVerbose(false);
+
+char* varenv;
+ImgDir[0] = WorkDir[0] = '\0';
+if ( (varenv=getenv("PEIDA_IMAGES")) != NULL )   strncpy(ImgDir, varenv, 256);
+if ( (varenv=getenv("PEIDA_WORK")) != NULL )  strncpy(WorkDir, varenv, 256);
+
+pfc = new PIFileChooser(this,"FileChooser", 5000); 
+
+mObjmgrw = new ObjMgrWind(this);
+mPpinmgrw = new PPInMgrWind(this);
+
+// Attention : A faire apres creation de ObjMgrWind !!! 
+mObjMgr->SetImgApp(this);
+
+// Gestion des feneteres widgets et drawers
+mWId = mDId = mBWId = 0;
+mCurWin = NULL;  
+mCurWdg = NULL;
+mLastWdg = NULL;
+mGrW = NULL;
+mStW = NULL;
+mGrIdx = mStIdx = -1;
+
+mFCMsg = 0;
+mFgCWImg = false;
+
+// Gestion fichiers PS
+num_eps = 0;
+name_ps = "";
+name_ps = "pia.ps";
+mpsfile = new PSFile(name_ps.c_str(),PI_Portrait, PI_A4, 2., 2.);
+
+// Gestion OUT-PPF
+mPpfout = NULL;
+name_outppf = "";
+
+// Attributs graphiques courants
+mFCol = mBCol = PI_NotDefColor;
+mLAtt = PI_NotDefLineAtt;
+mFSz = PI_NotDefFontSize;
+mFAtt = PI_NotDefFontAtt;
+mMSz = -1;
+mMrk = PI_NotDefMarker;
+mCmapid = CMAP_OTHER;
+mZoom = 0;
+mAxesFlags = kBoxAxes | kExtTicks | kLabels;
+mXmin = mYmin = -1.;
+mXmax = mYmax = 1;
+SaveGraphicAtt();
+
+// Initialisation 
+PIAppInitiator * piai = new PIAppInitiator(this);
+SetReady();
+}
+
+/* --Methode-- */
+PIStdImgApp::~PIStdImgApp()
+{
+int i;
+
+delete mc;
+for(i=0; i<7; i++)  
+  if (m[i]) delete m[i];
+
+WindMList::iterator it;
+for(it = mWList.begin(); it != mWList.end(); it++)  delete (*it).second;
+
+delete mObjMgr;
+delete mCmd;
+
+delete zoom;
+delete gimv;
+delete cmapv;
+
+delete pfc;
+
+delete mCons;
+
+delete mObjmgrw;
+delete mPpinmgrw;
+
+// Les fichiers 
+if (mpsfile) delete mpsfile;
+if (mPpfout) delete mPpfout;
+
+}  
+
+/* --Methode-- */
+void PIStdImgApp::Process(PIMessage msg, PIMsgHandler* sender, void* data)
+{
+PIWdg *sndw;
+PIMessage tmsg, smm;
+
+tmsg = msg;
+msg = UserMsg(msg);
+smm = ModMsg(tmsg);
+
+//printf("SuperDebug: msg=%d Mod=%d  State=%d\n", (int)msg, (int)smm, (int)GetState());
+if  ((GetState()) && (msg != mFCMsg)) { PIBeep(); return; }
+
+//   Messages active-window
+if (smm == PIMsg_Active)
+  {
+  sndw = dynamic_cast<PIWdg *>(sender);
+  switch(sndw->kind())
+    {
+    case PIWindow::ClassId :
+      mCurWin = dynamic_cast<PIWindow *>(sndw);
+      break;
+
+    case PIScDrawWdg::ClassId :
+    case PIDraw3DWdg::ClassId :
+      mCurWdg = dynamic_cast<PIBaseWdg *>(sender);
+//      cerr << "*DBG11* ImgTools -> NonSensitive " << sndw->kind() << endl;
+      if (mFgCWImg) {
+//        cerr << "*DBG* ImgTools -> NonSensitive " << endl;
+        m[2]->SetSensitivityMsg(10305, false);
+        m[2]->SetSensitivityMsg(10306, false);
+        m[4]->SetSensitivityMsg(10515, false);
+        m[4]->SetSensitivityMsg(10516, false);
+        mFgCWImg = false;
+        }
+      break;
+    case PIImage::ClassId :
+      mCurWdg = dynamic_cast<PIBaseWdg *>(sender);
+      if (!mFgCWImg) {
+//        cerr << "*DBG* ImgTools -> Sensitive " << endl;
+        m[2]->SetSensitivityMsg(10305, true);
+        m[2]->SetSensitivityMsg(10306, true);
+        m[4]->SetSensitivityMsg(10515, true);
+        m[4]->SetSensitivityMsg(10516, true);
+        mFgCWImg = true;
+        }
+      break;
+      /*
+    default :
+      mCurWdg = NULL;
+      if (mFgCWImg) {
+        m[2]->SetSensitivityMsg(10305, false);
+        m[2]->SetSensitivityMsg(10306, false);
+        m[4]->SetSensitivityMsg(10515, false);
+        m[4]->SetSensitivityMsg(10516, false);
+        mFgCWImg = false;
+        }
+      break;
+      */
+    }
+  }
+//  Message window-close
+else if (smm == PIMsg_Close)
+  {
+  sndw = (PIWdg *)sender;
+  if(sndw->kind() == PIWindow::ClassId)
+    {
+    mCurWin = (PIWindow *)sender;
+    if (mCurWin == mStW) m[2]->SetSensitivity("StackTools", false); 
+    DeleteWindow(mCurWin);
+    }
+  else  
+    printf("PIStdImgApp/Bug ? CloseMsd received from NonWindow (%d %d %lx) \n",
+           (int)tmsg,  (int)sndw->kind(), (long)sender);       
+  }
+
+// Traitement des messages des menus 
+else if ( (msg >= 10100) && (msg < 10200) )  MBProcess1(msg, sender, data);
+else if ( (msg >= 10200) && (msg < 10300) )  MBProcess2(msg, sender, data);
+else if ( (msg >= 10300) && (msg < 10400) )  MBProcess3(msg, sender, data);
+else if ( (msg >= 10400) && (msg < 10500) )  MBProcess4(msg, sender, data);
+else if ( (msg >= 10500) && (msg < 10600) )  MBProcess5(msg, sender, data);
+else if ( (msg >= 10600) && (msg < 10700) )  MBProcess6(msg, sender, data);
+else if ( msg == 30200  ) {    // Objet PIConsole 
+  string s = mCons->GetCmdString();
+  string s2 = "\nExecuting " + s + "\n";
+  mCons->AddStr(s2.c_str(), PIVA_Blue, true);
+  SetBusy();
+  TRY {
+    mCmd->Interpret(s);
+    }  CATCH(merr) { 
+    fflush(stdout); 
+    cout << endl; 
+    cerr << endl;
+    string es = PeidaExc(merr);
+    cerr << "PIStdImgApp::Process()/ Cmd->Do() Exception :" << es << " (" << merr << ")" << endl ;    
+  }
+
+  SetReady();
+  }
+
+else printf("PIStdImgApp::Process() BUG?? Msg %d (%d-%d) \n", 
+            (int)tmsg,(int)msg,(int)smm);
+
+
+return;
+}
+
+/* --Methode-- */
+void PIStdImgApp::SetReady()
+{
+mCons->SetSensitive();
+gimv->SetSensitive();
+PIApplication::SetReady();
+}
+
+/* --Methode-- */
+void PIStdImgApp::SetBusy()
+{
+mCons->SetUnSensitive();
+gimv->SetUnSensitive();
+PIApplication::SetBusy();
+}
+
+/* --Methode-- */
+void PIStdImgApp::SetBlocked()
+{
+mCons->SetUnSensitive();
+gimv->SetUnSensitive();
+PIApplication::SetBlocked();
+}
+
+
+/* --Methode-- */
+int PIStdImgApp::DispImage(P2DArrayAdapter* nouv, string const & name, int opt, int oid)
+{
+PIImage* pii;
+PIWindow* win;
+int sx, sy, px, py, flag;
+
+if (nouv == NULL)
+  {
+  printf("PIStdImgApp::DispImage_Error  Cannot Display  NULL image \n");
+  return(-1);
+  }
+
+if ( (nouv->XSize() <= 0)  || (nouv->YSize() <= 0))
+  {
+  printf("PIStdImgApp::DispImage_Error Pb Size Sz=%d*%d  \n", 
+          nouv->XSize(), nouv->YSize());
+  return(-1);
+  }
+
+int zm = 1;
+if (mZoom == 0) {  // Facteur de zoom auto 
+  zm = (nouv->XSize() > nouv->YSize()) ? nouv->XSize() :  nouv->YSize();
+  zm = (zm >= 250) ? 250/zm : 1;
+  }
+else zm = mZoom;
+
+if (zm == 0)  zm = 1;
+if (zm < -10)  zm = -10; 
+if (zm > 10)  zm = 10;
+
+if (zm > 0)  { sx = nouv->XSize()*zm;  sy = nouv->YSize()*zm; }
+else  { 
+  sx = (int)((float)nouv->XSize()*(-1./float(zm)));  
+  sy = (int)((float)nouv->YSize()*(-1./float(zm))); 
+  } 
+if (sx > 400+mFgScSz*100) sx = 400+mFgScSz*100;
+if (sy > 400+mFgScSz*100) sy = 400+mFgScSz*100;
+px = py = 0;
+win = GetWindow(opt, sx, sy, px, py, flag, (char *)name.c_str());
+pii = new PIImage(win, (char *)name.c_str(), sx, sy, px,py);
+pii->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+pii->SetZoomWin(zoom, false);
+pii->SetGloVWin(gimv, false);
+pii->SetCMapWin(cmapv, false);
+pii->SetZoom(zm, false);
+if ( mCmapid != CMAP_OTHER ) pii->SetColMapId(mCmapid, false);
+pii->ShowCursor(true);
+pii->SetUserData(NULL, oid);
+pii->SetImage(nouv, true);
+// printf("!!DBG!! PIImage Pos= %d %d  Size= %d %d \n", pii->XPos(), pii->YPos(), pii->XSize(), pii->YSize()   );
+mCurWin = win;
+mCurWdg = pii;
+mLastWdg = pii;
+mBWId++;
+mBWList[mBWId] = pii;
+return(mBWId); 
+}
+
+
+/* --Methode-- */
+int PIStdImgApp::DispScDrawer(PIDrawer* scd, string const & name, int opt, string title, int oid)
+{
+if (scd == NULL)
+  {
+  printf("PIStdImgApp::DispScDrawer_Error  Cannot Add NULL ScDrawer \n");
+  return(-1);
+  }
+
+// Changement d'attributs graphiques courants du drawer
+if (mFCol != PI_NotDefColor) scd->SetColAtt(mFCol, mBCol);
+if (mLAtt != PI_NotDefLineAtt) scd->SetLineAtt(mLAtt);
+if ( (mFSz != PI_NotDefFontSize) && (mFAtt != PI_NotDefFontAtt) ) scd->SetFontAtt(mFSz, mFAtt); 
+if ( (mMrk != PI_NotDefMarker) && (mMSz >= 0) ) scd->SetMarkerAtt(mMSz, mMrk);
+if ( mCmapid != CMAP_OTHER ) scd->SetColMapId(mCmapid);
+
+if ( (opt == Disp_Same) && (mLastWdg) ) {
+  if (mLastWdg->kind() == PIScDrawWdg::ClassId)  ((PIScDrawWdg*)mLastWdg)->AddScDrawer(scd, true);
+  else mLastWdg->AddDrawer(scd, true, true, true);
+  scd->Refresh();
+  mDId++;
+  mDrwList[mDId] = scd;
+  return(-mDId);   
+}
+else if (opt == Disp_Same)  opt = Disp_Next;
+
+PIWindow* win;
+PIScDrawWdg* scw;
+int sx, sy, px, py, flag;
+sx = 200+mFgScSz*100;
+sy = 200+mFgScSz*100;
+win = GetWindow(opt, sx, sy, px, py, flag, (char *)name.c_str());
+if (typeid(*scd) != typeid(PIHisto2D)) 
+   scw = new PIScDrawWdg(win, (char *)name.c_str(), sx, sy, px, py);
+else scw = new PIH2DWdg(win, (char *)name.c_str(), sx, sy, px, py);
+scw->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+scw->SetUserData(NULL, oid);
+if (mFXYlim)  // Forcage limites XY 
+  scw->SetLimits(mXmin, mXmax, mYmin, mYmax);
+scw->SetAxesFlags(mAxesFlags);
+
+if (typeid(*scd) != typeid(PIHisto2D)) scw->AddScDrawer(scd, true);
+else ((PIH2DWdg*)scw)->SetPIHisto((PIHisto2D*)scd);
+//   Titre du plot
+if (title.length() <= 0)  title = name;  string t2="";   
+scw->SetTitles(title, t2);    
+// scw->Refresh();   ? Pas necessaire  Reza 19/08/98, 05/05/99 $CHECK$ 
+mCurWin = win;
+mCurWdg = scw;
+mLastWdg = scw;
+mBWId++;
+mBWList[mBWId] = scw;
+return(mBWId); 
+}
+
+/* --Methode-- */
+int PIStdImgApp::Disp3DDrawer(PIDrawer3D* dr3, string const & name, int opt, string title, int oid)
+{
+if (dr3 == NULL)
+  {
+  printf("PIStdImgApp::Disp3DDrawer_Error  Cannot Add NULL 3DDrawer \n");
+  return(-1);
+  }
+
+// Changement d'attributs graphiques courants du drawer
+if (mFCol != PI_NotDefColor) dr3->SetColAtt(mFCol, mBCol);
+if (mLAtt != PI_NotDefLineAtt) dr3->SetLineAtt(mLAtt);
+if ( (mFSz != PI_NotDefFontSize) && (mFAtt != PI_NotDefFontAtt) ) dr3->SetFontAtt(mFSz, mFAtt); 
+if ( (mMrk != PI_NotDefMarker) && (mMSz >= 0) ) dr3->SetMarkerAtt(mMSz, mMrk);
+if ( mCmapid != CMAP_OTHER ) dr3->SetColMapId(mCmapid);
+
+if ( (opt == Disp_Same) && (mLastWdg) ) {
+  if (mLastWdg->kind() == PIDraw3DWdg::ClassId)  ((PIDraw3DWdg*)mLastWdg)->AddDrawer3D(dr3, true);
+  else mLastWdg->AddDrawer(dr3, true, true, true);
+  dr3->Refresh();
+  mDId++;
+  mDrwList[mDId] = dr3;
+  return(-mDId);   
+}
+else if (opt == Disp_Same)  opt = Disp_Next;
+
+PIWindow* win;
+int sx, sy, px, py, flag;
+sx = 200+mFgScSz*100;
+sy = 200+mFgScSz*100;
+win = GetWindow(opt, sx, sy, px, py, flag, (char *)name.c_str());
+PIDraw3DWdg* wd3 = new PIDraw3DWdg(win, (char *)name.c_str(), sx, sy, px, py);
+wd3->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
+wd3->SetUserData(NULL, oid);
+wd3->AddDrawer3D(dr3, true);
+//   Titre du plot
+if (title.length() <= 0)  title = name;  string t2="";   
+wd3->SetTitles(title, t2);    
+// wd3->Refresh();   ?Pas necessaire   $CHECK$ 05/05/99
+mCurWin = win;
+mCurWdg = wd3;
+mLastWdg = wd3;
+mBWId++;
+mBWList[mBWId] = wd3;
+return(mBWId); 
+}
+
+/* --Methode-- */
+void PIStdImgApp::AddText(string const & txt, double xp, double yp)
+{
+if (!mLastWdg)  return;
+PIElDrawer *eld=NULL;
+PIScDrawWdg* sdw=NULL;
+PIDraw3DWdg* w3d=NULL;
+PIImage* imgw;
+switch(mLastWdg->kind()) {
+  case PIScDrawWdg::ClassId :
+    sdw = dynamic_cast<PIScDrawWdg *>(mLastWdg);
+    if (sdw) eld = sdw->BaseDrawer();
+    break;
+  case PIDraw3DWdg::ClassId :
+    w3d = dynamic_cast<PIDraw3DWdg *>(mLastWdg);
+    if (w3d) eld = w3d->BaseDrawer();
+    break;
+  case PIImage::ClassId :
+    imgw = dynamic_cast<PIImage *>(mLastWdg);
+    if (imgw) eld = imgw->MyElDrawer();
+    break;
+  default :
+    break;
+  }
+if (eld) { 
+  if ( (mFSz != PI_NotDefFontSize) && (mFAtt != PI_NotDefFontAtt) )     eld->SetFontAtt(mFSz, mFAtt); 
+  eld->ElAddText(xp,yp,txt.c_str(),mFCol);
+  eld->Refresh();
+  }
+}
+
+/* --Methode-- */
+void PIStdImgApp::CreateGraphWin(int nx, int ny, int sx, int sy)
+{
+if (nx < 1)  nx = 1;
+if (ny < 1)  ny = 1;
+if (nx > 8)  nx = 8;    
+if (ny > 8)  ny = 8;
+if ( (sx < 50) && (sy < 50) )   sx = sy = 400+mFgScSz*100; 
+char buff[64];
+mWId++;
+int px, py; 
+MainWin()->GetScreenPos(px, py);
+sprintf(buff, "PI-GraphicWin (%d)",mWId);
+PIZoneWindow* win = new PIZoneWindow(this,  buff, PIWK_normal, nx, ny, sx, sy, px+MainWin()->XSize()+30, 0);
+win->SetUserData(NULL, ny*10+nx);  // UserFlag= nY*10 + nX  
+mWList[mWId*10+1] = (PIWindow*)win;
+win->SetAutoDelChilds(true);
+// win->Show();
+mGrW = win; 
+mGrIdx = 0;
+}
+
+/* --Methode-- */
+void PIStdImgApp::CreateStackWin(int sx, int sy)
+{
+if ( (sx < 50) && (sy < 50) )   sx = sy = 300+mFgScSz*100; 
+char buff[64];
+mWId++;
+int px, py; 
+MainWin()->GetScreenPos(px, py);
+sprintf(buff, "PI-StackWin (%d)",mWId); 
+PIStackWindow* win = new PIStackWindow(this,  buff, PIWK_normal, sx, sy, px+MainWin()->XSize()+30, 100);
+win->SetUserData(NULL, 9999);  // UserFlag= 9999 
+mWList[mWId*10+2] = (PIWindow*)win;
+win->SetAutoDelChilds(true);
+// win->Show();
+mStW = win;
+m[2]->SetSensitivity("StackTools", true); 
+mStIdx = 0;
+}
+
+/* --Methode-- */
+PIWindow* PIStdImgApp::GetWindow(int typ, int& sx, int& sy, int& px, int& py, int& flag, char * nom)
+{
+PIWindow* rw;
+
+switch (typ) {
+  case Disp_Next :  // Fenetre graphique courante
+    {
+    if (mGrW == NULL) CreateGraphWin();
+    int nx, ny;
+    mGrW->NbZone(nx, ny);
+    PIWdg* nw = mGrW->NextChildPosSize(px, py, sx, sy);
+//    cerr << "**DBG** PIStdImgApp::GetWindow() DispNext : nw = " << (long)nw << endl;
+    if (nw) DeleteBaseWidget((PIBaseWdg*)nw, false, false);
+    flag = mGrIdx;
+    mGrIdx = (mGrIdx+1)%(nx*ny);
+    rw = mGrW;
+    break;
+    }
+
+  case Disp_Stack :  // Fenetre de type stack (empilement)
+    {
+    if (mStW == NULL) CreateStackWin(sx, sy);
+    px = py = 0;
+    sx = mStW->XSize();
+    sy = mStW->YSize();
+    flag = mStIdx;
+    mStIdx++;
+    rw = mStW;
+    }
+    break;
+
+  default :      // Fenetre ordinaire
+    {
+    int pwx, pwy; 
+    MainWin()->GetScreenPos(pwx, pwy);
+    if ( (sx < 50) && (sy < 50) )   sx = sy = 300+mFgScSz*100; 
+    rw = new PIWindow(this,  nom, PIWK_normal, sx, sy, pwx+MainWin()->XSize()+30, 300);
+    rw->SetUserData(NULL, 0);  // UserFlag= 0 
+    mWId++;
+    mWList[mWId*10] = rw;
+    rw->SetAutoDelChilds(true);
+    //    rw->Show();
+    px = py = 0;
+    flag = 0;
+    break;
+    }
+  }
+
+rw->Show();
+mCurWin = rw;
+return(rw);
+}
+
+/* --Methode-- */
+void PIStdImgApp::SetZone(int nzx, int nzy)
+{
+if (!mGrW) CreateGraphWin(nzx, nzy);
+else { 
+  int k;
+  PIWdg* cwd;
+  for(k=0; k<mGrW->NbChilds(); k++) {
+    if ((cwd = mGrW->GetChild(k)) == NULL)  continue; 
+    DeleteBaseWidget((PIBaseWdg*)cwd, false, false);
+    }
+  mGrW->SetZone(nzx, nzy);
+  }
+}
+
+/* --Methode-- */
+void PIStdImgApp::StackWinNext()
+{
+if (mStW)  mStW->DispNext();
+}
+
+/* --Methode-- */
+void PIStdImgApp::DeleteWindow(PIWindow* w)
+{
+if (w == NULL)  return;
+w->Hide();
+bool ownwindow=false;  // To Check if this is one of our windows
+WindMList::iterator it;
+for(it = mWList.begin(); it != mWList.end(); it++) 
+  if ((*it).second == w)  { mWList.erase(it);  ownwindow = true; break; }
+if (w == mGrW) { mGrW = NULL;  mGrIdx = -1; }
+if (w == mStW) { mStW = NULL;  mStIdx = -1; m[2]->SetSensitivity("StackTools", false); }
+if (w == mCurWin) mCurWin = NULL;
+
+if (!ownwindow) return; // We do nothing if this is not a window we have created ...
+
+int k;
+PIWdg* cwd;
+for(k=0; k<w->NbChilds(); k++) {
+  if ((cwd = w->GetChild(k)) == NULL)  continue; 
+  DeleteBaseWidget((PIBaseWdg*)cwd,false,false);
+  }
+delete w;
+return;
+}
+
+/* --Methode-- */
+void PIStdImgApp::DeleteBaseWidget(PIBaseWdg* w, bool dw, bool dwin)
+{
+if (w == NULL)  return;
+BWMList::iterator it;
+for(it = mBWList.begin(); it != mBWList.end(); it++) 
+  if ((*it).second == w)  { mBWList.erase(it);  break; }
+int k;
+PIDrawer* drw;
+for(k=0; k<w->NbDrawers(); k++) {
+  if ((drw = w->GetDrawer(k)) == NULL)  continue; 
+  DrwMList::iterator itt;
+  for(itt = mDrwList.begin(); itt != mDrwList.end(); itt++) 
+    if ((*itt).second == drw)  { mDrwList.erase(itt);  break; }
+  }
+
+if (w == mCurWdg) {  
+  mCurWdg = NULL;
+  if (mFgCWImg) {
+    m[4]->SetSensitivityMsg(10515, false);
+    m[4]->SetSensitivityMsg(10516, false);
+    mFgCWImg = false;
+    }
+  }
+
+if (w == mLastWdg)  mLastWdg = NULL;
+
+PIWdg* pw=NULL;
+if (dwin)  pw = (PIWdg*)(w->Parent());
+//DBG printf("DeleteBaseWidget(%lx)-DBG kind = %d - %d %d \n", (long)w, w->kind(), (int)dw, (int)dwin); 
+if (dw) delete w;
+if (pw && (pw->kind() == PIWindow::ClassId )) {
+ PIWindow* pww = (PIWindow*) pw;
+ if ((pww != (PIWindow*)mGrW) && (pww != (PIWindow*)mStW) && (pww->NbChilds()==0)) 
+    DeleteWindow((PIWindow*)pw);
+ } 
+return;
+}
+
+
+
+/* --Methode-- */
+void PIStdImgApp::DelWRsId(int k)
+{
+//DBG cerr << "-DBG- PIStdImgApp::DelWRsId(" << k << ")" << endl; 
+if (k > 0) { // C'est un BaseWidget
+  BWMList::iterator it;
+  it  = mBWList.find(k);
+  if (it == mBWList.end())  return;
+  PIBaseWdg* wd = (*it).second;
+//DBG cerr << "-DBG- PIStdImgApp::DelWRsId Deleting BaseWidget " << (long)(wd) << endl ; 
+  DeleteBaseWidget(wd, true, true);
+  }
+else {  // C'est un drawer
+  DrwMList::iterator it;
+  it  = mDrwList.find(-k);
+  if (it == mDrwList.end())  return;
+  delete (*it).second;  
+  mDrwList.erase(it);
+//  cerr << "+DBG+ PIStdImgApp::DelWRsId Deleting Drawer " << (long)((*it).second) << endl ; 
+  }
+}
+/* --Methode-- */
+bool PIStdImgApp::CheckWRsId(int k)
+{
+if (k > 0) { // C'est un BaseWidget
+  BWMList::iterator it;
+  it  = mBWList.find(k);
+  if (it == mBWList.end())  return(false);
+  else return(true);
+  }
+else {  // C'est un drawer
+  DrwMList::iterator it;
+  it  = mDrwList.find(-k);
+  if (it == mDrwList.end())  return(false);
+  else return(true);
+  }
+}
+
+
+/* --Methode-- */
+void PIStdImgApp::RedirectStdOutErr(bool fg)
+{
+if (fg) { 
+  RedirectOutStream(mCons);
+  RedirectErrStream(mCons);
+  m[5]->SetStateMsg(10602, true);
+  redirecout = true;
+  }
+else {
+  RedirectOutStream(NULL);
+  RedirectErrStream(NULL);
+  m[5]->SetStateMsg(10602, false);
+  redirecout = false;
+  }
+return;
+}
+
+/* --Methode-- */
+void PIStdImgApp::CatchSignals(bool fgfpe, bool fgsegv)
+{    
+PeidaConfigureSignalhandling(fgfpe, fgsegv, true, true);  
+m[5]->SetStateMsg(10603, fgfpe);
+m[5]->SetStateMsg(10604, fgsegv);
+}
+
+/* --Methode-- */
+void PIStdImgApp::CloseAllWindows()
+{
+WindMList::iterator it;
+for(it = mWList.begin(); it != mWList.end(); it++)   delete (*it).second;
+mWList.clear();
+mBWList.clear();
+mDrwList.clear(); 
+mGrW = NULL;
+mStW = NULL;
+mCurWin = NULL;
+mCurWdg = NULL;
+mLastWdg = NULL;
+m[4]->SetSensitivityMsg(10515, false);
+m[4]->SetSensitivityMsg(10516, false);
+}
+
+/* --Methode-- */
+void PIStdImgApp::MBProcess1(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
+{
+
+  switch(msg)
+    {
+    case 10100 :
+      mCmd->ShowHelpWindow();
+      break;
+
+    case 10120 :
+      pfc->SetPath(ImgDir);
+      pfc->AcceptNewFile(false);
+      mFCMsg = 10125; 
+      pfc->SetMsg(mFCMsg);
+      SetBlocked();
+      pfc->Show();
+      break;
+
+    case 10125 :
+      SetBusy();
+      if (data)  { 
+        string nomobj="";
+        ObjMgr()->ReadFits(pfc->GetFileName(), nomobj);
+        ObjMgr()->DisplayObj(nomobj, "win");
+      }
+      mFCMsg = 0;
+      SetReady();
+      break;
+
+    case 10130 :
+      pfc->SetPath(WorkDir);
+      pfc->AcceptNewFile(false); 
+      mFCMsg = 10135; 
+      pfc->SetMsg(mFCMsg);
+      SetBlocked();
+      pfc->Show();
+      break;
+
+    case 10135 :
+      mFCMsg = 0;
+      if (data)  { 
+        PPInMgrW()->SetFile(pfc->GetFileName());
+        PPInMgrW()->Show();
+      }
+      SetReady();
+      break;
+
+    case 10110 :
+      DeleteWindow(mCurWin);
+      break;
+        
+    case 10111 :
+      if (mCurWdg) {
+        int oid = mCurWdg->UserFlag();
+        DeleteBaseWidget(mCurWdg);
+        mObjMgr->DelObj_Id(oid);
+        }
+      break;
+
+    case 10105:
+      Stop();
+      break;
+
+  }
+return;
+}
+
+
+
+/* --Methode-- */
+void PIStdImgApp::MBProcess2(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
+{
+
+switch (msg)  { 
+  case 10201 :
+     ObjMgrW()->Show();
+     break;
+
+  case 10220 :
+     pfc->SetPath(WorkDir);
+     pfc->AcceptNewFile(true);
+     mFCMsg = 10225;
+     pfc->SetMsg(mFCMsg);
+     SetBlocked();
+     pfc->Show();
+     break;
+
+   case 10225 :
+     SetBusy();
+     if (data) {
+       if (mPpfout) {  
+         printf("PIStdImg/Info: Closing POutPersist-File %s \n", name_outppf.c_str());
+         delete mPpfout;  
+       }
+       name_outppf = pfc->GetFileName();
+       mPpfout = NULL;
+       printf("PIStdImg/Info: Opening POutPersist-File %s \n", name_outppf.c_str());
+       mPpfout = new POutPersist(name_outppf);
+    }
+    mFCMsg = 0;
+    SetReady();
+    break;
+
+  case 10230 :
+    if (!mPpfout)  break;
+    printf("PIStdImg/Info: Closing POutPersist-File %s \n", name_outppf.c_str());
+    delete mPpfout;  
+    name_outppf = "";
+    mPpfout = NULL;
+    break;
+
+
+  default:
+    cerr << "PIStdImgApp::MBProcess2() BUG?? Msg= " <<  msg << endl;    
+    break;
+}
+
+return;
+}
+
+/* --Methode-- */
+void PIStdImgApp::MBProcess3(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
+{
+
+switch (msg)  { 
+  case 10301 :
+    PIImgTools::ShowPIImgTools();
+    break; 
+  case 10302 :
+    PIDrwTools::ShowPIDrwTools();
+    break;
+
+  case 10304 :
+  case 10305 :
+    {
+    PIImage* curpimg = NULL;
+    if (!mCurWdg)  return;
+    if (mCurWdg->kind() != PIImage::ClassId)  return;
+    curpimg = (PIImage*)mCurWdg;
+    if (curpimg == NULL)   return;
+    P2DArrayAdapter* img = curpimg->Image();
+    if (img == NULL) return;
+    int dx = curpimg->XSzPave();
+    int dy = curpimg->YSzPave();  
+    int x0 = curpimg->XPave()-dx/2;
+    int y0 = curpimg->YPave()-dy/2;
+    if (x0 < 0)  x0 = 0;
+    if (y0 < 0)  y0 = 0;
+    int x1 = x0+dx;
+    int y1 = y0+dy;
+    if (x1 > img->XSize()) x1 = img->XSize();
+    if (y1 > img->YSize()) y1 = img->YSize();
+    dx = x1-x0;  dy = y1-y0;
+    ImageR4* pim = new ImageR4(dx, dy); 
+    int ii, jj;
+    for(jj=0; jj<dy; jj++) 
+      for(ii=0; ii<dx; ii++) (*pim)(ii,jj) = (*img)(ii+x0, jj+y0);
+    if (msg == 10305) {  // Calcul des coordonnees du sous-pave
+      double xc1, yc1;
+      img->Coord(x0, y0, xc1, yc1);
+      pim->SetOrg((int)xc1, (int)yc1);
+    }
+    string nom = mCurWdg->Nom() + "_pave";
+    ObjMgr()->AddObj(pim, nom);
+    ObjMgr()->DisplayObj(nom, "w");
+    break;
+    }
+
+  case 10306 :
+    {
+    PIImage* curpimg = NULL;
+    if (!mCurWdg)  return;
+    if (mCurWdg->kind() != PIImage::ClassId)  return;
+    curpimg = (PIImage*)mCurWdg;
+    if (curpimg == NULL)   return;
+    curpimg->ShowCuts(true);
+    break;
+    }
+
+  case 10320 :
+    if (mStW)  mStW->DispNext();
+    break;
+
+  case 10321 :
+  case 10322 :
+  case 10324 :
+//  case 10328 :
+    if (mStW) mStW->StartAutoDisp((msg-10320)*500);
+    break;
+
+  case 10329 :
+    if (mStW) mStW->StopAutoDisp();
+    break;
+
+  case 103330 :
+    if (mStW) {
+      PIWdg* cw =  mStW->CurrentWdg();
+      if (cw) DeleteBaseWidget((PIBaseWdg*)cw);
+      }
+    break;
+
+  default:
+    cerr << "PIStdImgApp::MBProcess3() BUG?? Msg= " <<  msg << endl;    
+    break;
+  }
+return;
+}
+
+/* --Methode-- */
+void PIStdImgApp::MBProcess4(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
+{
+
+switch (msg)  { 
+
+  case 10400 :
+    CreateStackWin();
+    break;
+
+  case 10411 :
+    CreateGraphWin(1,1);
+    break;
+  case 10421 :
+    CreateGraphWin(1,2);
+    break;
+  case 10412 :
+    CreateGraphWin(2,1);
+    break;
+  case 10422 :
+    CreateGraphWin(2,2);
+    break;
+  case 10431 :
+    CreateGraphWin(1,3);
+    break;
+  case 10433 :
+    CreateGraphWin(3,3);
+    break;
+
+  default:
+    cerr << "PIStdImgApp::MBProcess4() BUG?? Msg= " <<  msg << endl;    
+    break;
+  }
+return;
+}
+
+
+/* --Methode-- */
+void PIStdImgApp::MBProcess5(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
+{
+char nomps[64],strg[512];
+PSFile *mps;
+int sxt, syt, syo, syo1, sx[4], sy[4];
+
+switch (msg)
+  { 
+  case 10501 :
+     pfc->SetPath(WorkDir);
+     pfc->AcceptNewFile(true); 
+     mFCMsg = 10525; 
+     pfc->SetMsg(mFCMsg);
+     SetBlocked();
+     pfc->Show();
+     break;
+
+   case 10525 :
+     SetBusy();
+     if (data) {
+       if (mpsfile) {  
+         printf("PIStdImg/Info: Closing PS-File %s \n", name_ps.c_str());
+         delete mpsfile;  
+         }
+        name_ps = pfc->GetFileName();
+        printf("PIStdImg/Info: Opening PS-File %s \n", name_ps.c_str());
+        mpsfile = new PSFile(name_ps.c_str(), PI_Portrait, PI_A4, 2., 2.);
+        }
+      mFCMsg = 0;
+      SetReady();
+      break;
+
+  case 10505 :
+    if (!mpsfile)  break;
+    printf("PIStdImg/Info: Closing PS-File %s \n", name_ps.c_str());
+    delete mpsfile;
+    mpsfile = NULL;
+    name_ps = "";
+    break;
+
+  case 10511 :     // Window -> PS
+  case 10512 :     // Window -> EPS 
+    if (CurrentWindow() == NULL)  break;
+    if (msg == 10512) 
+      { 
+      num_eps++;
+      sprintf(nomps,"pia%d.eps", num_eps);
+      printf("PIStdImg/Info: Creating EPSFile %s (CurWin-> EPS) \n", nomps);
+      mps = new PSFile(nomps);
+      }
+    else {
+      if (mpsfile == NULL) {
+        name_ps = "pia.ps";
+        mpsfile = new PSFile(name_ps.c_str(), PI_Portrait, PI_A4, 0., 0.);
+        printf("PIStdImg/Info: File PS %s opened \n", name_ps.c_str());
+      }
+      printf("PIStdImg/Info: CurWin-> PSFile %s\n", name_ps.c_str());      
+      mps = mpsfile; 
+      }
+    CurrentWindow()->PSPrint(mps,0,0);
+
+    if (msg == 10512)   delete mps;   // fichier eps
+    break;
+
+  case 10515 :    // Image -> PS
+  case 10516 :    // Image -> EPS 
+     {
+     PIImage* curpimg = NULL;
+     if (!mCurWdg)  return;
+     if (mCurWdg->kind() != PIImage::ClassId)  return;
+     curpimg = (PIImage*)mCurWdg;
+     if (curpimg == NULL)   return;
+     if (msg == 10516) 
+      { 
+      num_eps++;
+      sprintf(nomps,"pia%d.eps", num_eps);
+      printf("PIStdImg/Info: Creating EPSFile %s (CurImage-> EPS)\n", nomps);
+      mps = new PSFile(nomps);
+      }
+    else {
+      if (mpsfile == NULL) {
+        name_ps = "pia.ps";
+        mpsfile = new PSFile(name_ps.c_str(),PI_Portrait, PI_A4, 2., 2.);
+        printf("PIStdImg/Info: File PS %s opened \n", name_ps.c_str());
+      }
+      printf("PIStdImg/Info: CurImage-> PSFile %s\n", name_ps.c_str());       
+      mps = mpsfile; 
+      }
+
+    sx[0] = gimv->XSize(); 
+    sy[0] = gimv->YSize();
+    sx[1] = zoom->XSize(); 
+    sy[1] = zoom->YSize();
+    sx[2] = cmapv->XSize(); 
+    sy[2] = cmapv->YSize();
+    sx[3] = curpimg->XSize(); 
+    sy[3] = curpimg->YSize();
+    if (sy[1] > sy[0])  { syo1 = sy[1]+50;  syo = sy[1]+sy[2]+60; }
+    else  { syo1 = sy[0]+50;  syo = sy[0]+sy[2]+60; }
+    syt = sy[3]+syo;
+    sxt = sx[3];
+    if (sxt < (sx[0]+sx[1]+20))  sxt = sx[0]+sx[1]+20;
+    if (sxt < sx[2])  sxt = sx[2];
+
+    // Pour ecrire le titre 
+    mps->NewPage((float)sxt, (float)syt, PI_Portrait);
+    mps->NewBloc(0,0, (float)sxt, 30., (float)sxt, 30.);
+    sprintf(strg,"Image: %s -  Pave %d %d \n",  curpimg->Nom().c_str(), 
+            curpimg->XPave(),  curpimg->YPave());     
+    mps->DrawString(10., 25., strg, PI_Black, PI_DefaultFont, PI_BoldFont, 20);
+    mps->EndBloc();
+
+    // Les quatre fenetres glovimage, zoom, cmap, image 
+    gimv->PSPrint(mps, -gimv->XPos(), -gimv->YPos()+40);
+    zoom->PSPrint(mps, -zoom->XPos()+sx[0]+20, -zoom->YPos()+40);
+    cmapv->PSPrint(mps, -cmapv->XPos(), -cmapv->YPos()+syo1);
+    curpimg->PSPrint(mps, -curpimg->XPos(), -curpimg->YPos()+syo);
+     
+    if (msg == 10516)   delete mps;    // fichier eps
+    break;
+    }
+
+  default:
+    cerr << "PIStdImgApp::MBProcess5() BUG?? Msg= " <<  msg << endl;    
+    break;
+  }
+
+}
+
+
+/* --Methode-- */
+void PIStdImgApp::MBProcess6(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
+{
+switch (msg)  { 
+  case 10601:
+    CloseAllWindows();
+    break;
+  case 10602:
+    RedirectStdOutErr(*((bool*)data));
+    break;
+  case 10603:
+  case 10604:
+    CatchSignals(m[5]->GetStateMsg(10603), m[5]->GetStateMsg(10604));
+    break;
+  case 10605:
+    mObjMgr->SetVerbose(m[5]->GetStateMsg(10605));
+    break;
+  default:
+    cerr << "PIStdImgApp::MBProcess6() BUG?? Msg= " <<  msg << endl;    
+    break;
+  }
+return;
+}
+
+
+/* --Methode-- */
+void PIStdImgApp::SetColAtt(PIColors fg, PIColors bg)
+{
+  mFCol = fg;
+  mBCol = bg;
+}
+/* --Methode-- */
+void PIStdImgApp::SetLineAtt(PILineAtt lat)
+{
+  mLAtt = lat;
+}
+/* --Methode-- */
+void PIStdImgApp::SetFontAtt(PIFontSize fsz, PIFontAtt fat)
+{
+  mFSz = fsz;
+  mFAtt = fat;
+}
+/* --Methode-- */
+void PIStdImgApp::SetMarkerAtt(int sz, PIMarker mrk)
+{
+  mMSz = sz;
+  mMrk = mrk;
+}
+/* --Methode-- */
+void PIStdImgApp::SetColMapId(CMapId cid)
+{
+  mCmapid = cid;
+}
+/* --Methode-- */
+void PIStdImgApp::SetZoomAtt(int zoom)
+{
+  if ( (zoom > 10) || (zoom < -10) ) zoom = 0;
+  mZoom = zoom;
+}
+/* --Methode-- */
+void PIStdImgApp::SetAxesAtt(unsigned int axfl)
+{
+  mAxesFlags = axfl; 
+}
+/* --Methode-- */
+void PIStdImgApp::SetXYLimits(double xmin, double xmax, double ymin, double ymax)
+{
+  mXmin = xmin;  mXmax= xmax;
+  mYmin = ymin;  mYmax= ymax;
+}
+
+/* --Methode-- */
+void PIStdImgApp::SaveGraphicAtt()
+{
+  mSFCol = mFCol;
+  mSBCol = mBCol;
+  mSLAtt = mLAtt;
+  mSFSz = mFSz;
+  mSFAtt = mFAtt;
+  mSMSz = mMSz;
+  mSMrk = mMrk;
+  mSCmapid = mCmapid;
+  mSZoom = mZoom;
+  mSAxesFlags = mAxesFlags;
+  mSXmin = mXmin;  mSXmax = mXmax;
+  mSYmin = mYmin;  mSYmax = mYmax;
+  mSFXYlim = mFXYlim;
+}
+
+/* --Methode-- */
+void PIStdImgApp::RestoreGraphicAtt()
+{
+  mFCol = mSFCol;
+  mBCol = mSBCol;
+  mLAtt = mSLAtt;
+  mFSz = mSFSz;
+  mFAtt = mSFAtt;
+  mMSz = mSMSz;
+  mMrk = mSMrk;
+  mCmapid = mSCmapid;
+  mZoom = mSZoom;
+  mAxesFlags = mSAxesFlags;
+  mXmin = mSXmin;  mXmax = mSXmax;
+  mYmin = mSYmin;  mYmax = mSYmax;
+  mFXYlim = mSFXYlim;
+}
Index: /tags/V_LaSilla191199/SophyaPI/PIext/pistdimgapp.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/pistdimgapp.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/pistdimgapp.h	(revision 464)
@@ -0,0 +1,177 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Standard Image App      R. Ansari  97-98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PISTIMGAPP_H_SEEN
+#define PISTIMGAPP_H_SEEN
+
+#include <string.h>
+#include <string>
+#include <map>
+#include <functional>
+
+#include "pisysdep.h"
+
+#include PIAPP_H
+#include PIWIN_H 
+#include PIMENU_H 
+#include PIOPTMENU_H 
+
+#include PISTDWDG_H 
+
+#include PIFILECHO_H 
+#include "picons.h"
+
+#include "piimage.h"
+#include "pi3ddrw.h"
+#include "nobjmgr.h"
+#include "piacmd.h"
+#include "pisiadw.h"
+#include "pistzwin.h"
+
+
+enum {Disp_Next=0, Disp_Win=1, Disp_Same=2, Disp_Stack=3};
+
+typedef map<long, PIWindow*, less<long> > WindMList;
+typedef map<long, PIBaseWdg*, less<long> > BWMList;
+typedef map<long, PIDrawer*, less<long> > DrwMList;
+
+class PIStdImgApp : public PIApplication  {
+public:
+     PIStdImgApp(int narg=0, char* arg[]=NULL);
+     ~PIStdImgApp();
+
+     virtual void   Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+     virtual void   SetReady();
+     virtual void   SetBusy(); 
+     virtual void   SetBlocked();
+
+     int  DispImage(P2DArrayAdapter* nouv, string const & name, int opt, int oid=0);
+     int  DispScDrawer(PIDrawer* scd, string const & name, int opt, string title="", int oid=0);
+     int  Disp3DDrawer(PIDrawer3D* scd, string const & name, int opt, string title="", int oid=0);
+
+  //  Fonction d'ajout de texte (provisoire - Aout 99)
+     void AddText(string const & txt, double xp, double yp);
+
+
+     void CreateGraphWin(int nx=1, int ny=1, int sx=0, int sy = 0);
+     void CreateStackWin(int sx=0, int sy = 0);
+     PIWindow * GetWindow(int typ, int& sx, int& sy, int& px, int& py, int& flag, char * nom);
+     void SetZone(int nzx=1, int nzy=1);
+     void StackWinNext();
+
+     void DeleteWindow(PIWindow* w);
+     void DeleteBaseWidget(PIBaseWdg* w, bool dw=true, bool dwin=true);
+     void DelWRsId(int k);
+     bool CheckWRsId(int k);
+     void CloseAllWindows();
+
+     inline NamedObjMgr* ObjMgr() { return mObjMgr; }
+     inline PIACmd* CmdInterpreter() { return mCmd; }
+
+     PIWindow* CurrentWindow() { return (mCurWin); };
+     PIBaseWdg* CurrentBaseWdg() { return (mCurWdg); };
+
+     inline PIPixmap* ZoomW() { return zoom; }
+     inline PIPixmap* GloVW() { return gimv; }
+     inline PICMapView* CMapVW() { return cmapv; }
+     inline PIConsole* GetConsole() { return mCons; }
+
+     inline PIMenu* SpecialMenu() { return m[5]; }
+     inline PIMenu* ModulesMenu() { return m[6]; }
+
+     inline ObjMgrWind* ObjMgrW() { return mObjmgrw; }
+     inline PPInMgrWind* PPInMgrW() { return mPpinmgrw; }
+
+// Redirection ou Non de StdOut/StdErr
+     void  RedirectStdOutErr(bool fg = true);
+     inline bool HasRedirectedStdOutErr() { return(redirecout); }
+// Gestion des signaux
+     void  CatchSignals(bool fgfpe=true, bool fgsegv=true);
+
+//  Gestion d attributs graphiques courants
+     void  SetColAtt(PIColors fg=PI_NotDefColor, 
+                     PIColors bg=PI_NotDefColor);
+     void  SetLineAtt(PILineAtt lat=PI_NotDefLineAtt);
+     void  SetFontAtt(PIFontSize fsz=PI_NotDefFontSize,
+                      PIFontAtt fat=PI_NotDefFontAtt);
+     void  SetMarkerAtt(int sz=-1, PIMarker mrk=PI_NotDefMarker);
+     void  SetColMapId(CMapId cid=CMAP_OTHER);
+     void  SetZoomAtt(int zoom=0);
+     void  SetAxesAtt(unsigned int axfl=kBoxAxes | kExtTicks | kLabels);
+     void  SetXYLimits(double xmin=-1., double xmax=1., double ymin=-1., double ymax=1.);
+     inline void  UseXYLimits(bool fg=false) {  mFXYlim=fg; }
+// Pour sauvegarder-restauration de  l'etat des attributs graphiques
+     void  SaveGraphicAtt();   
+     void  RestoreGraphicAtt();   
+
+// Gestion fichiers PS
+    int num_eps;
+    PSFile *mpsfile;
+    string name_ps;
+
+// Gestion OUT-PPF
+    POutPersist* mPpfout;
+    string name_outppf;    
+
+private:
+    void MBProcess1(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+    void MBProcess2(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+    void MBProcess3(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+    void MBProcess4(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+    void MBProcess5(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+    void MBProcess6(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+
+
+    NamedObjMgr* mObjMgr;
+    PIACmd* mCmd;
+
+    PIMenu* m[7];
+    PIMenu* mc;
+
+    PIPixmap* zoom;
+    PIPixmap* gimv;
+    PICMapView* cmapv;
+
+    PIFileChooser * pfc;
+
+    PIConsole* mCons;
+    bool redirecout;    // true if stdout/err redirected to mCons;
+
+    WindMList mWList;
+    BWMList mBWList;
+    DrwMList mDrwList;
+
+    int mWId,mDId,mBWId;
+
+    PIBaseWdg* mCurWdg;
+    PIBaseWdg* mLastWdg;
+    PIWindow* mCurWin;
+    PIZoneWindow* mGrW;
+    PIStackWindow* mStW;
+    int mGrIdx;
+    int mStIdx;
+
+    ObjMgrWind* mObjmgrw;
+    PPInMgrWind* mPpinmgrw;
+
+//  Gestion d attributs graphiques courants, etat sauvegarde
+    PIColors     mFCol, mBCol, mSFCol, mSBCol;
+    PILineAtt    mLAtt, mSLAtt;
+    PIFontSize   mFSz, mSFSz;
+    PIFontAtt    mFAtt, mSFAtt;
+    int          mMSz, mSMSz;
+    PIMarker     mMrk,mSMrk;  
+    CMapId       mCmapid, mSCmapid;
+    int 	 mZoom, mSZoom;
+    unsigned int mAxesFlags, mSAxesFlags;
+    double	 mXmin, mXmax, mYmin, mYmax;
+    double	 mSXmin, mSXmax, mSYmin, mSYmax;
+    bool	 mFXYlim, mSFXYlim;
+
+    PIMessage mFCMsg;  // Message for processing FileOpen
+    int mFgScSz;   // Dlag ScreenSize
+    bool mFgCWImg; // true -> Current Widget is PIImage
+};
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PIext/pistlist.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/pistlist.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/pistlist.cc	(revision 464)
@@ -0,0 +1,131 @@
+#include <stdio.h>
+#include "pistlist.h"
+
+ 
+/* --Methode-- */
+PIStarList::PIStarList(StarList* stl, bool ad)
+: PIDrawer(), mStL(stl)
+{
+  mAdDO = ad;   
+  if (stl == NULL) return;
+  SetFluxLimits(1., -1.);
+}
+
+PIStarList::~PIStarList()
+{
+  if (mAdDO && mStL)  delete mStL;
+}
+
+/* --Methode-- */
+void  PIStarList::SetFluxLimits(float fmin, float fmax, int nl, bool dispflx, bool refr)
+{
+  if (!mStL)  return;  
+  if (fmin < fmax)  { mFmin = fmin;  mFmax = fmax; }
+  else mStL->CalcFluxLimits(mFmin, mFmax);
+  if (mFmin < 1.e-10)  mFmin = 1.e-10;
+  if (mFmax <= mFmin)  mFmax = 1.5*mFmin;
+  mDLgF = log10((double)mFmax/(double)mFmin);
+  if (mDLgF < 1.e-10)  mDLgF = 1.e-10;
+  mF0 = mFmin;
+  if (nl < 1)  nl = 1;
+  if (nl > 20)  nl = 20;
+  mNLev = nl;  
+  mDspFV = dispflx;
+  if (refr)  Refresh();
+  return;
+}
+
+
+/* --Methode-- */
+void PIStarList::UpdateLimits()
+{
+  if (!mStL) return;
+
+  // Commencer par trouver nos limites
+  double dx, dy;
+  double x1, x2, y1, y2;
+  mStL->CalcXYLimits(x1, x2, y1, y2);
+  
+  dx = 0.02*(x2-x1);
+  dy = 0.02*(y2-y1);
+  
+  SetLimits(x1-dx, x2+dx, y1-dy, y2+dy); 
+  SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
+}
+
+
+/* --Methode-- */
+void PIStarList::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
+{
+BStar *sti;
+double xp,yp;
+float flx;
+int sz;
+char buff[128];
+int nok, nl2;
+
+if (!mStL) return;
+
+int msz = mMSz;
+if (msz < 1) msz = 1;
+PIMarker mrk = (mMrk != PI_NotDefMarker) ? mMrk : PI_FCircleMarker;
+// g->SelFont();
+nok = 0;  nl2 = mNLev*2-1;
+for (int i=0; i<mStL->NbStars(); i++) {
+  sti = mStL->Star(i);
+  if ( !(sti->Nice(BStar::flagOK)) )  continue;
+  flx = sti->Flux();
+  if ( (flx < mFmin) || (flx > mFmax) )  continue;
+  xp = sti->PosX();   yp = sti->PosY();
+  if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) )  continue;
+  nok++;
+  sz = (int)((log10((double)flx/mF0))/mDLgF*(double)nl2-0.01) + msz;
+  if (sz < 2)  g->SelMarker(sz, PI_DotMarker);
+  else g->SelMarker(sz, mrk);
+  g->DrawMarker((double)xp,(double)yp ); 
+  if (mDspFV) {  
+    sprintf(buff," F=%g", flx);
+    double dx,dy;
+    g->DGrC2UC(sz, 4, dx, dy);
+    g->DrawString(xp+dx, yp-dy, buff);
+    } 
+  }
+
+/*
+sprintf(buff, "StarList:  NbStars= %d  NDisp= %d", (int)mStL->NbStars(), nok);
+g->BaseGraphic()->DrawString(15,15,buff);
+sprintf(buff, "FMin= %g  FMax= %g Nl= %d Sz0= %d", mFmin, mFmax, mNLev, mMSz0);
+g->BaseGraphic()->DrawString(15,30,buff);
+*/
+
+}
+
+/* --Methode-- */
+void PIStarList::AppendTextInfo(string& info, double xmin, double ymin, double xmax, double ymax)
+{
+BStar *sti;
+double xp,yp;
+double flx,fnd;
+char buff[128];
+int ncnt = 0;
+sprintf(buff,"PIStarList: NStars \n", mStL->NbStars() );
+info += buff;
+info += "  Num:   XPos       YPos     Flux      Fond \n";
+for (int i=0; i<mStL->NbStars(); i++) {
+  sti = mStL->Star(i);
+  if ( !(sti->Nice(BStar::flagOK)) )  continue;
+  flx = sti->Flux();
+  if ( (flx < mFmin) || (flx > mFmax) )  continue;
+  xp = sti->PosX();   yp = sti->PosY();
+  if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) )  continue;
+  ncnt++;
+  if (ncnt > 101) continue;
+  fnd = sti->Fond();
+  sprintf(buff,"%6d: %8.3g %8.3g %8.3g %8.3g \n", i, xp, yp, flx, fnd); 
+  info += buff;
+  }
+if (ncnt >= 101) info += " .... \n";
+sprintf(buff," %d stars inside selected region \n", ncnt);
+info += buff;
+return;
+}
Index: /tags/V_LaSilla191199/SophyaPI/PIext/pistlist.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/pistlist.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/pistlist.h	(revision 464)
@@ -0,0 +1,32 @@
+#ifndef PISTLIST_H
+#define PISTLIST_H
+
+#include "stlist.h"
+#include "pidrawer.h"
+
+class PIStarList : public PIDrawer {
+public:
+                     PIStarList(StarList* stl, bool ad);
+  virtual           ~PIStarList();
+  
+  virtual void       Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
+  virtual void       UpdateLimits();
+  
+  virtual void       AppendTextInfo(string& info, double xmin, double ymin, double xmax, double ymax);
+
+  void               SetFluxLimits(float min=1., float max=-1., int nl=5, bool dispflx=false, bool refr=false);
+
+  inline StarList*   StList()  { return(mStL); }  
+  inline float       FluxMin() { return(mFmin); }       
+  inline float       FluxMax() { return(mFmax); }
+       
+protected:
+  StarList* mStL;
+  bool mAdDO;
+  float mFmin, mFmax;
+  int mNLev;
+  double mF0, mDLgF;
+  bool mDspFV;
+};
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PIext/servnobjm.cc
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/servnobjm.cc	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/servnobjm.cc	(revision 464)
@@ -0,0 +1,1512 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include <typeinfo>
+#include <iostream.h>
+#include <string>
+#include <list>
+#include <map>
+
+#include "strutil.h"
+
+#include "nobjmgr.h"
+#include "servnobjm.h"
+#include "nomgadapter.h"
+#include "pistdimgapp.h"
+
+#include "fct1dfit.h"
+#include "fct2dfit.h"
+
+#include "matrix.h"
+#include "cvector.h"
+#include "ntuple.h"
+#include "cimage.h"
+#include "fitsimage.h"
+
+#include "histos.h"
+#include "histos2.h"
+#include "ntuple.h"
+#include "hisprof.h"
+
+#include "piscdrawwdg.h"
+#include "pisurfdr.h"
+
+#include "pintuple.h"
+#include "pintup3d.h"
+
+#include "pipodrw.h"
+
+
+
+/* --Methode-- */
+Services2NObjMgr::Services2NObjMgr(NamedObjMgr* omg, string& tmpdir)
+{
+TmpDir = tmpdir;
+PDynLinkMgr::SetTmpDir(tmpdir);
+mImgapp = NULL;
+mOmg = omg;
+dynlink = NULL;
+InitGrAttNames();
+}
+  
+/* --Methode-- */
+Services2NObjMgr::~Services2NObjMgr()
+{
+CloseDLL();
+}
+
+/* --Methode-- */
+void Services2NObjMgr::RegisterClass(AnyDataObj* o, NObjMgrAdapter* oa)
+{
+ObjAdaptList::iterator it;
+for(it = objadaplist.begin(); it != objadaplist.end(); it++) 
+    if (typeid(*o) == typeid(*((*it).obj)))  THROW(dupIdErr);
+
+dataobj_adapter oba;
+oba.obj = o;
+oba.obja = oa;
+objadaplist.push_back(oba);
+}
+
+/* --Methode-- */
+NObjMgrAdapter* Services2NObjMgr::GetAdapter(AnyDataObj* o)
+{
+ObjAdaptList::iterator it;
+for(it = objadaplist.begin(); it != objadaplist.end(); it++) 
+  if (typeid(*o) == typeid(*((*it).obj)))  return((*it).obja->Clone(o));
+return(new NObjMgrAdapter(o));
+}
+
+/* --Methode-- */
+void Services2NObjMgr::PlotFunc(string const & expfunc, string & nom, double xmin, double xmax, int np, string dopt)
+{
+FILE *fip;
+string fname = TmpDir + "func1_pia_dl.c";
+string  cmd;
+int rc;
+
+if (!mImgapp)  return; 
+
+cmd = "rm -f " + fname;
+rc = system(cmd.c_str());
+// printf("PlotFunc_Do> %s  (Rc=%d)\n", cmd.c_str(), rc); 
+
+if ((fip = fopen(fname.c_str(), "w")) == NULL)   { 
+  string sn = fname; 
+  cout << "Services2NObjMgr/PlotFunc_Error: fopen( " << sn << endl; 
+  return; 
+  }
+
+// constitution du fichier a compiler
+fputs("#include <math.h> \n", fip);
+fputs("double func1_pia_dl_func(double x) \n{\n", fip);
+fprintf(fip,"return(%s); \n}\n", expfunc.c_str());
+fclose(fip);
+
+string func = "func1_pia_dl_func";
+DlFunctionOfX f = (DlFunctionOfX) LinkFunctionFromFile(fname, func);
+if (!f) return; 
+PlotFunc(f, nom, xmin, xmax, np, dopt);
+CloseDLL();
+return;
+}
+
+/* --Methode-- */
+void Services2NObjMgr::PlotFunc2D(string const & expfunc, string & nom, double xmin, double xmax, 
+                                  double ymin, double ymax, int npx, int npy, string dopt)
+{
+FILE *fip;
+string fname = TmpDir + "func2_pia_dl.c";
+string cmd;
+int rc;
+
+if (!mImgapp)  return; 
+
+cmd = "rm " + fname;
+rc = system(cmd.c_str());
+// printf("PlotFunc2D_Do> %s  (Rc=%d)\n", cmd.c_str(), rc); 
+
+if ((fip = fopen(fname.c_str(), "w")) == NULL)   { 
+  string sn = fname; 
+  cout << "Services2NObjMgr/PlotFunc2D_Error:  fopen( " << sn << endl; 
+  return; 
+  }
+
+// constitution du fichier a compiler
+fputs("#include <math.h> \n", fip);
+fputs("double func2_pia_dl_func(double x, double y) \n{\n", fip);
+fprintf(fip,"return(%s); \n}\n", expfunc.c_str());
+fclose(fip);
+
+string func = "func2_pia_dl_func";
+DlFunctionOfXY f = (DlFunctionOfXY) LinkFunctionFromFile(fname, func);
+if (!f)  return;
+PlotFunc2D(f, nom, xmin, xmax, ymin, ymax, npx, npy, dopt);
+CloseDLL();
+return;
+}
+
+/* --Methode-- */
+void Services2NObjMgr::PlotFuncFrCFile(string const & fname, string const & func, string & nom, 
+                                       double xmin, double xmax, int np, string dopt)
+{
+DlFunctionOfX f = (DlFunctionOfX) LinkFunctionFromFile(fname, func);
+if (!f) return; 
+PlotFunc(f, nom, xmin, xmax, np, dopt);
+CloseDLL();
+return;
+}
+
+/* --Methode-- */
+void Services2NObjMgr::PlotFunc2DFrCFile(string const & fname, string const & func, string & nom, 
+                                         double xmin, double xmax, double ymin, double ymax, int npx, int npy, string dopt)
+{
+DlFunctionOfXY f = (DlFunctionOfXY) LinkFunctionFromFile(fname, func);
+if (!f)  return;
+PlotFunc2D(f, nom, xmin, xmax, ymin, ymax, npx, npy, dopt);
+CloseDLL();
+return;
+}
+
+/* --Methode-- */
+void Services2NObjMgr::PlotFunc(DlFunctionOfX f, string & nom, double xmin, double xmax, int np, string dopt)
+{
+if (!mImgapp)  return; 
+
+int k;
+if (np < 1) np = 1;
+if (xmax <= xmin) xmax = xmin+1.;
+Vector* vpy = new Vector(np);
+
+double xx;
+double dx = (xmax-xmin)/np;
+TRY {
+  for(k=0; k<np; k++) { xx = xmin+dx*k; (*vpy)(k) = f(xx); }
+} CATCH(merr) {
+  fflush(stdout); 
+  cout << endl; 
+  cerr << endl;
+  string es = PeidaExc(merr);
+  cerr << "Services2NObjMgr::PlotFunc()  Exception :" << merr << es;
+  delete vpy;
+  vpy = NULL;
+  } ENDTRY;
+
+
+if (vpy) {
+  string titre;
+  if (nom.length() < 1) {
+     titre = "Function f(x)";
+     nom = "/func/f_x";
+    }
+  else titre = nom;
+  
+  P1DArrayAdapter* vya = new POVectorAdapter(vpy, false);
+  vya->DefineXCoordinate(xmin, (xmax-xmin)/np);
+  PIYfXDrawer* dr = new   PIYfXDrawer(vya, NULL, true) ; 
+  bool fgsr = true;
+  dopt = "thinline," + dopt;
+  int opt = DecodeDispOption(dopt, fgsr);
+  int rsid = mImgapp->DispScDrawer(dr, titre, opt);
+  if (fgsr) mImgapp->RestoreGraphicAtt(); 
+  if (nom.length() > 0) { 
+    mOmg->AddObj(vpy, nom);
+    mOmg->AddWRsId(nom, rsid);
+    }
+  }
+
+return;
+}
+
+/* --Methode-- */
+void Services2NObjMgr::PlotFunc2D(DlFunctionOfXY f, string & nom, double xmin, double xmax, double ymin, double ymax, 
+                             int npx, int npy, string dopt)
+{
+if (!mImgapp)  return; 
+
+if (npx < 3) npx = 3;
+if (npy < 3) npy = 3;
+if (npx > 250) npx = 250;
+if (npy > 250) npy = 250;
+if (xmax <= xmin) xmax = xmin+1.;
+if (ymax <= ymin) ymax = ymin+1.;
+
+Matrix* mtx = new Matrix(npy, npx);
+
+int i,j;
+double xx, yy;
+double dx = (xmax-xmin)/npx;
+double dy = (ymax-ymin)/npy;
+// printf(" -- DBG -- %d %d , %g %g , %g %g \n", npx, npy, xmin, xmax, ymin, ymax);
+TRY {
+  for(j=0; j<npy; j++) {
+    yy = ymin+dy*j; 
+    for(i=0; i<npx; i++) {
+      xx = xmin+dx*i;
+      (*mtx)(j, i) = f(xx, yy);
+    }
+  }
+} CATCH(merr) {
+  fflush(stdout); 
+  cout << endl; 
+  cerr << endl;
+  string es = PeidaExc(merr);
+  cerr << "Services2NObjMgr::PlotFunc2D()  Exception :" << merr << es;
+  delete mtx;  mtx = NULL;
+  } ENDTRY;
+
+if (mtx) {
+  string titre;
+  if (nom.length() < 1) {
+     titre = "Function f(x,y)";
+     nom = "/func/f2d_xy";
+    }
+  else titre = nom;
+  bool fgsr = true;
+  int opt = DecodeDispOption(dopt, fgsr);
+  P2DArrayAdapter* arr = new POMatrixAdapter(mtx, false);
+  arr->DefineXYCoordinates(xmin, ymin, dx, dy);
+  PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
+  int rsid = mImgapp->Disp3DDrawer(sdr, titre, opt);
+  if (fgsr) mImgapp->RestoreGraphicAtt();
+  if (nom.length() > 0)  { 
+    mOmg->AddObj(mtx, nom);
+    mOmg->AddWRsId(nom, rsid);
+    }
+  }
+
+return;
+}
+
+/* --Methode-- */
+void Services2NObjMgr::DisplayPoints2D(string& nom,  string& expx, string& expy,
+                                       string& experrx, string& experry,
+                                       string& expcut, string dopt, string loop)
+{
+NObjMgrAdapter* obja=NULL;
+obja = mOmg->GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "Services2NObjMgr::DisplayPoints2D() Error , No such object " << nom << endl; 
+  return;
+  }
+if (!mImgapp)  return; 
+
+// Creation NTuple 
+char* ntn[4] = {"expx","expy","expex","expey",};
+NTuple* nt = NULL;
+bool haserr = false;
+
+if ( (experrx.length() > 0 ) && (experry.length() > 0 ) ) {  haserr = true;   nt = new NTuple(4, ntn); }
+else {  haserr = false;  experrx = experry = "0."; nt = new NTuple(2, ntn); }
+
+ComputeExpressions(obja, expx, expy, experrx, experry, expcut, loop, nt, NULL, NULL);
+
+if (nt->NEntry() < 1) {
+  cout << "Services2NObjMgr::DisplayPoints2D() Warning  Zero points satisfy cut !" << endl; 
+  delete nt;
+  return;
+  }
+
+// nt->Show();
+// nt->Print(0,10);
+PINTuple* pin = new PINTuple(nt, true);
+pin->SelectXY(ntn[0], ntn[1]);
+if ( haserr ) pin->SelectErrBar(ntn[2], ntn[3]);
+
+bool fgsr = true;
+dopt = "defline," + dopt;
+int opt = DecodeDispOption(dopt, fgsr);
+string titre =  nom + ":" + expy + "%" + expx;
+mImgapp->DispScDrawer( (PIDrawer*)pin, titre, opt);
+if (fgsr) mImgapp->RestoreGraphicAtt();
+return;
+}
+
+/* --Methode-- */
+void Services2NObjMgr::DisplayPoints3D(string& nom,  string& expx, string& expy, 
+                                       string& expz, string& expcut, string dopt, string loop)
+{
+NObjMgrAdapter* obja=NULL;
+obja = mOmg->GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "Services2NObjMgr::DisplayPoints3D() Error , No such object " << nom << endl; 
+  return;
+  }
+if (!mImgapp)  return; 
+
+char* ntn[3] = {"expx","expy","expz"};
+NTuple* nt = new NTuple(3,ntn);  // Creation NTuple
+
+string expwt = "1.";
+ComputeExpressions(obja, expx, expy, expz, expwt, expcut, loop, nt, NULL, NULL);
+
+if (nt->NEntry() < 1) {
+  cout << "Services2NObjMgr::DisplayPoints3D() Warning  Zero points satisfy cut !" << endl;
+  delete nt;
+  return;
+  }
+nt->Show();
+nt->Print(0,10);
+PINTuple3D* pin = new PINTuple3D(nt, true);
+pin->SelectXYZ(ntn[0], ntn[1], ntn[2]);
+bool fgsr = true;
+dopt = "defline," + dopt;
+int opt = DecodeDispOption(dopt, fgsr);
+
+// Pour plot a partir de DispScDrawer
+// string nomdisp = "_NT3D_";
+// mImgapp->DispScDrawer( (PIDrawer*)pin, nomdisp, opt);
+// Pour plot a partir de Disp3DDrawer
+string titre =  nom + ":" + expy + "%" + expx;
+mImgapp->Disp3DDrawer(pin, titre, opt);
+
+if (fgsr) mImgapp->RestoreGraphicAtt();
+return;
+}
+
+/* --Methode-- */
+void Services2NObjMgr::DisplayPoints2DW(string& nom, string& expx, string& expy, 
+                                        string& expwt, string& expcut, string dopt, string loop)
+{
+NObjMgrAdapter* obja=NULL;
+obja = mOmg->GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "Services2NObjMgr::DisplayPoints2DW() Error , No such object " << nom << endl; 
+  return;
+  }
+if (!mImgapp)  return; 
+
+char* ntn[3] = {"expx","expy","expw"};
+NTuple* nt = new NTuple(3,ntn);  // Creation NTuple
+
+string exp = "1.";
+ComputeExpressions(obja, expx, expy, expwt, exp, expcut, loop, nt, NULL, NULL);
+
+if (nt->NEntry() < 1) {
+  cout << "Services2NObjMgr::DisplayPoints2DW() Warning  Zero points satisfy cut !" << endl;
+  delete nt;
+  return;
+  }
+
+PINTuple* pin = new PINTuple(nt, true);
+pin->SelectXY(ntn[0], ntn[1]);
+pin->SelectWt(ntn[2]);
+
+bool fgsr = true;
+int opt = DecodeDispOption(dopt, fgsr);
+string titre =  nom + ":" + expwt + "_" + expy + "%" + expx ;
+mImgapp->DispScDrawer( (PIDrawer*)pin, titre, opt);
+if (fgsr) mImgapp->RestoreGraphicAtt();
+return;
+}
+
+/* --Methode-- */
+void Services2NObjMgr::ProjectH1(string& nom, string& expx, string& expwt, 
+                                 string& expcut, string& nomh1, string dopt, string loop)
+{
+NObjMgrAdapter* obja=NULL;
+obja = mOmg->GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "Services2NObjMgr::ProjectH1() Error , No such object " << nom << endl; 
+  return;
+  }
+if (!mImgapp)  return; 
+
+Histo* h1 = NULL;
+NTuple* nt = NULL;
+AnyDataObj* oh = NULL; 
+if (nomh1.length() > 0) oh=mOmg->GetObj(nomh1);
+else nomh1 = "/tmp/projh1d";
+if ( (oh != NULL) && (typeid(*oh) == typeid(Histo)) )  h1 = (Histo*)oh;  // Pas de remise a zero ! h1->Zero();
+else {
+  char* ntn[2]= {"hxval", "hwt"};
+  nt = new NTuple(2,ntn);  // Creation NTuple 
+  }
+string expz = "0.";   
+ComputeExpressions(obja, expx, expwt, expz, expwt, expcut, loop, nt, h1, NULL);
+
+if ((!h1) && (!nt)) return;
+if (!h1) {
+  if (nt->NEntry() < 1) {
+    cout << "Services2NObjMgr::ProjectH1() Warning  Zero points satisfy cut !" << endl; 
+    delete nt;
+    return;
+    }
+  double xmin, xmax;
+  nt->GetMinMax(0, xmin, xmax);
+  h1 = new Histo(xmin, xmax, 100);
+  int k;
+  float* xn;
+  for(k=0; k<nt->NEntry(); k++)    {
+    xn = nt->GetVec(k);
+    h1->Add(xn[0], xn[1]);    
+    }
+  delete nt;
+  mOmg->AddObj(h1, nomh1);
+  }
+
+mOmg->DisplayObj(nomh1, dopt);
+return;  
+}
+
+/* --Methode-- */
+void Services2NObjMgr::ProjectH2(string& nom, string& expx, string& expy, string& expwt, 
+                                 string& expcut, string& nomh2, string dopt, string loop)
+{
+NObjMgrAdapter* obja=NULL;
+obja = mOmg->GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "Services2NObjMgr::ProjectH2() Error , No such object " << nom << endl; 
+  return;
+  }
+if (!mImgapp)  return; 
+
+Histo2D* h2 = NULL;
+NTuple* nt = NULL;
+AnyDataObj* oh = NULL;
+if (nomh2.length() > 0)  oh=mOmg->GetObj(nomh2);
+else nomh2 = "/tmp/projh2d";
+if ( (oh != NULL) && (typeid(*oh) == typeid(Histo2D)) )  h2 = (Histo2D*)oh;  // Pas de remise a zero ! h2->Zero();
+else {
+  char* ntn[3]= {"hxval", "hyval", "hwt"};
+  nt = new NTuple(3,ntn);  // Creation NTuple 
+  }
+string expz = "0.";   
+ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, loop, nt, NULL, h2);
+
+if ((!h2) && (!nt)) return;
+if (!h2) {
+  if (nt->NEntry() < 1) {
+    cout << "Services2NObjMgr::ProjectH2() Warning  Zero points satisfy cut !" << endl; 
+    delete nt;
+    return;
+    }
+  double xmin, xmax, ymin, ymax;
+  nt->GetMinMax(0, xmin, xmax);
+  nt->GetMinMax(0, ymin, ymax);
+  h2 = new Histo2D(xmin, xmax, 50, ymin, ymax, 50);
+  int k;
+  float* xn;
+  for(k=0; k<nt->NEntry(); k++)    {
+    xn = nt->GetVec(k);
+    h2->Add(xn[0], xn[1], xn[2]);    
+    }
+  delete nt;
+  mOmg->AddObj(h2, nomh2);
+  }
+
+mOmg->DisplayObj(nomh2, dopt);
+return;  
+
+}
+
+/* --Methode-- cmv 13/10/98 */
+void Services2NObjMgr::ProjectHProf(string& nom, string& expx, string& expy, string& expwt,
+                                    string& expcut, string& nomprof, string dopt, string loop)
+//	Pour remplir un ``GeneralFitData'' a partir de divers objets: 
+//| nom = nom de l'objet a projeter dans un HProf.
+//| expx = expression X de definition du bin.
+//| expy = expression Y a additionner dans le bin.
+//| expwt = expression W du poids a additionner.
+//| expcut = expression du test de selection.
+//| nomprof = nom du HProf engendre (optionnel). Si l'objet n'existe pas
+//|           les limites Xmin,Xmax sont calculees automatiquement.
+//|           sinon ce sont celles de l'objet preexistant.
+//| opt = options generales pour le display.
+{
+NObjMgrAdapter* obja=NULL;
+obja = mOmg->GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "Services2NObjMgr::ProjectHProf() Error , No such object " << nom << endl; 
+  return;
+  }
+if (!mImgapp)  return; 
+
+HProf* hprof = NULL;
+NTuple* nt = NULL;
+AnyDataObj* oh = NULL;
+if (nomprof.length() > 0)  oh=mOmg->GetObj(nomprof);
+else nomprof = "/tmp/projprof";
+if( (oh!=NULL) && (typeid(*oh) == typeid(HProf)) )  hprof = (HProf*)oh;
+else {
+  char* ntn[3]= {"hxval", "hyval", "hwt"};
+  nt = new NTuple(3,ntn);  // Creation NTuple 
+}
+string expz = "0.";
+ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, loop, nt, NULL, NULL, hprof);
+
+if((!hprof) && (!nt)) return;
+if(!hprof) {
+  if (nt->NEntry() < 1) {
+    cout << "Services2NObjMgr::ProjectHProf() Warning  Zero points satisfy cut !" << endl;
+    delete nt;
+    return;
+  }
+  double xmin, xmax;
+  nt->GetMinMax(0, xmin, xmax);
+  hprof = new HProf(xmin, xmax, 100);
+  int k;
+  float* xn;
+  for(k=0; k<nt->NEntry(); k++)    {
+    xn = nt->GetVec(k);
+    hprof->Add(xn[0], xn[1], xn[2]);
+    }
+  delete nt;
+  mOmg->AddObj(hprof, nomprof);
+  }
+hprof->UpdateHisto();
+
+mOmg->DisplayObj(nomprof, dopt);
+return;
+}
+
+
+/* --Methode-- */
+void Services2NObjMgr::FillVect(string& nom, string& expx, string& expv, 
+                                   string& expcut, string& nomvec, string dopt, string loop)
+{
+NObjMgrAdapter* obja=NULL;
+obja = mOmg->GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "Services2NObjMgr::FillVect() Error , No such object: " << nom << endl; 
+  return;
+  }
+if (!mImgapp)  return; 
+
+Vector* v1 = NULL;
+AnyDataObj* ov = NULL; 
+ov=mOmg->GetObj(nomvec);
+if (ov != NULL) v1 = dynamic_cast<Vector *>(ov);
+if (v1 == NULL) {
+  cout << "Services2NObjMgr::FillVect() Error , No such object or not a vector: " << nomvec << endl; 
+  return;
+  }
+
+char* ntn[2]= {"vi", "vv"};
+NTuple* nt = new NTuple(2,ntn);  // Creation NTuple 
+
+string expz = "0.";   
+ComputeExpressions(obja, expx, expv, expz, expz, expcut, loop, nt);
+
+if (!nt) return;
+if (nt->NEntry() < 1) {
+  cout << "Services2NObjMgr::FillVect() Warning  Zero points satisfy cut !" << endl; 
+  delete nt;
+  return;
+  }
+
+  int i,k;
+  double* xn;
+  for(k=0; k<nt->NEntry(); k++)    {
+    xn = nt->GetLineD(k);
+    i = xn[0]+0.5;
+    if ( (i < 0) || i >= v1->NElts() ) continue;
+    (*v1)(i) = xn[1];
+    }
+  delete nt;
+  
+
+mOmg->DisplayObj(nomvec, dopt);
+return;  
+}
+
+/* --Methode-- */
+void Services2NObjMgr::FillMatx(string& nom, string& expx, string& expy, string& expv, 
+                                string& expcut, string& nommtx, string dopt, string loop)
+{
+NObjMgrAdapter* obja=NULL;
+obja = mOmg->GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "Services2NObjMgr::FillMatx() Error , No such objet " << nom << endl; 
+  return;
+  }
+if (!mImgapp)  return; 
+
+Matrix* mtx = NULL;
+AnyDataObj* om = NULL; 
+om=mOmg->GetObj(nommtx);
+if (om != NULL) mtx = dynamic_cast<Matrix *>(om);
+if (mtx == NULL) {
+  cout << "Services2NObjMgr::FillMatx() Error , No such object or not a matrix " << nommtx << endl; 
+  return;
+  }
+
+char* ntn[3]= {"mi", "mj", "mv"};
+NTuple* nt = new NTuple(3,ntn);  // Creation NTuple 
+
+string expz = "0.";   
+ComputeExpressions(obja, expx, expy, expv, expz, expcut, loop, nt);
+
+if (!nt) return;
+if (nt->NEntry() < 1) {
+  cout << "Services2NObjMgr::FillMatx() Warning  Zero points satisfy cut !" << endl; 
+  delete nt;
+  return;
+  }
+
+  int ic, jl, k;
+  double* xn;
+  for(k=0; k<nt->NEntry(); k++)    {
+    xn = nt->GetLineD(k);
+    ic = xn[0]+0.5;
+    jl = xn[1]+0.5;
+    if ( (ic < 0) || ic >= mtx->NCol() ) continue;
+    if ( (jl < 0) || jl >= mtx->NRows() ) continue;
+    (*mtx)(jl, ic) = xn[2];
+    }
+  delete nt;
+  
+
+mOmg->DisplayObj(nommtx, dopt);
+return;  
+
+}
+
+/* --Methode-- */
+void Services2NObjMgr::ExpressionToVector(string& nom, string& expx, string& expcut, 
+                                          string& nomvec, string dopt, string loop)
+{
+NObjMgrAdapter* obja=NULL;
+obja = mOmg->GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "Services2NObjMgr::ExpressionToVector() Error , No such object " << nom << endl; 
+  return;
+  }
+if (!mImgapp)  return; 
+
+NTuple* nt = NULL;
+if (nomvec.length() < 1) nomvec = "/tmp/expvec";
+
+char* ntn[2]= {"vecval", "vecwt"};
+nt = new NTuple(1,ntn);  // Creation NTuple
+ 
+string expwt = "1.";
+string expz = "0.";   
+ComputeExpressions(obja, expx, expz, expz, expwt, expcut, loop, nt, NULL, NULL);
+
+if (!nt) return;
+if (nt->NEntry() < 1) {
+  cout << "Services2NObjMgr::ExpressionToVector() Warning  Zero points satisfy cut !" << endl; 
+  delete nt;
+  return;
+  }
+  
+Vector* vec = new Vector(nt->NEntry());
+int k;
+float* xn;
+for(k=0; k<nt->NEntry(); k++)    {
+  xn = nt->GetVec(k);
+  (*vec)(k) = xn[0];
+  }
+delete nt;
+mOmg->AddObj(vec, nomvec); 
+mOmg->DisplayObj(nomvec, dopt);
+return;  
+}
+
+/* --Methode-- */
+void Services2NObjMgr::NtFromASCIIFile(string& nom,string& filename,double def_val)
+//	Pour remplir un ntuple "nom" existant a partir du fichier
+//	ASCII table "filename". Si il y a plus de variables dans le
+//	ntuple que dans le fichier "filename",
+//	les sur-numeraires sont mises a "def_val" par defaut.
+{
+AnyDataObj* mobj = mOmg->GetObj(nom);
+if(mobj == NULL)
+  {cout<<"NtFromASCIIFile() Error, object "<<nom<<" not existing"<<endl;
+   return;}
+if(typeid(*mobj) != typeid(NTuple))
+  {cout<<"NtFromASCIIFile() Error, object "<<nom<<" not an NTuple"<<endl;
+   return;}
+if (!mImgapp)  return; 
+
+NTuple* nt = (NTuple*) mobj;
+nt->FillFromASCIIFile(filename, def_val);
+return;
+}
+
+/* --Methode-- */
+void Services2NObjMgr::FillNT(string& nom, string& expx, string& expy, string& expz, 
+                              string& expt, string& expcut, string& nomnt, string loop)
+{
+NObjMgrAdapter* obja=NULL;
+obja = mOmg->GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "Services2NObjMgr::FillNT() Error , No such object " << nom << endl; 
+  return;
+  }
+if (!mImgapp)  return; 
+
+bool fgnnt = false;
+NTuple* nt = NULL;
+AnyDataObj* oh = NULL;
+if (nomnt.length() > 0)  oh=mOmg->GetObj(nomnt);
+else nomnt = "/tmp/fillnt";
+if ( (oh != NULL) && (typeid(*oh) == typeid(NTuple)) )  { 
+  nt = (NTuple*)oh;
+  if (nt->NVar() > 10) {
+    cout << "Services2NObjMgr::FillNT() Warning , Max 10 var in NTuple -> new NTuple" << endl;
+    nt = NULL;
+    }
+  }  
+if (nt == NULL) {
+  char* ntn[4]= {"x", "y","z","t"};
+  nt = new NTuple(4,ntn);  // Creation NTuple 
+  fgnnt = true;
+  }
+
+ComputeExpressions(obja, expx, expy, expz, expt, expcut, loop, nt, NULL, NULL);
+
+if (fgnnt) mOmg->AddObj(nt, nomnt);
+return;  
+
+}
+
+/* --Methode-- */
+void Services2NObjMgr::FillNTFrCFile(string & nom, string const & fname, 
+                                     string const & funcname, string & nomnt, string loop)
+{
+if (!mImgapp)  return; 
+
+NObjMgrAdapter* obja=NULL;
+obja = mOmg->GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "Services2NObjMgr::FillNTFrCFile( " << nom << "...) No such object" <<endl;
+  return;
+  }
+bool adel = true;
+NTupleInterface* objnt = obja->GetNTupleInterface(adel);
+if (objnt == NULL)  {
+  cout << "Services2NObjMgr::FillNTFrCFile( " << nom << "...) Not an NTupleInterface !" <<endl;
+  return;
+  }
+
+NTLoopExprFunc f = (NTLoopExprFunc)LinkFunctionFromFile(fname, funcname);
+if (!f) { 
+  cerr << "Services2NObjMgr::FillNTFrCFile Error Creation  NTLoopExprFunc" <<  endl; 
+  if (adel) delete objnt;   // Delete de l'objet NTupleInterface si necessaire
+  return;
+  }
+
+bool fgnnt = false;
+NTuple* nt = NULL;
+if (nomnt.length() > 0) {
+  AnyDataObj* oh = NULL;
+  oh=mOmg->GetObj(nomnt);
+  if ( (oh != NULL) && (typeid(*oh) == typeid(NTuple)) )  { 
+    nt = (NTuple*)oh;
+    if (nt->NVar() > 10) {
+      cout << "Services2NObjMgr::FillNTFrCFile() Warning , Max 10 var in NTuple -> new NTuple" << endl;
+      nt = NULL;
+      }
+    }  
+  if (nt == NULL) {
+    char* ntn[4]= {"x", "y","z","t"};
+    nt = new NTuple(4,ntn);  // Creation NTuple 
+    fgnnt = true;
+    }
+  }
+
+double xnt[10];
+float  fxnt[10];
+
+int i,k;
+for(i=0; i<10; i++) fxnt[i] = xnt[i] = 0.;
+
+
+// $CHECK$ A virer des que possible  - Pb blocage application quand trop d'impression
+// redirige -    On redirige la sortie sur le terminal 
+bool red = mImgapp->HasRedirectedStdOutErr();
+mImgapp->RedirectStdOutErr(false);
+
+int k1,k2,dk;
+k1 = 0;  k2 = objnt->NbLines();  dk = 1;
+DecodeLoopParameters(loop, k1, k2, dk);
+if (k1 < 0) k1 = 0;
+if (k2 < 0) k2 = objnt->NbLines();
+if (k2 > objnt->NbLines()) k2 = objnt->NbLines();
+if (dk <= 0) dk = 1;
+
+TRY  {
+  double* xn;
+  int kmax = k2;
+  for(k=k1; k<kmax; k+=dk)    {
+    xn = objnt->GetLineD(k);
+    if (f(xn, xnt, xnt+1, xnt+2, xnt+3, k, kmax) != 0) {
+      if (nt) { 
+         for(i=0; i<4; i++) fxnt[i] = xnt[i]; 
+         nt->Fill(fxnt);
+         }
+      }
+    }
+ }
+CATCH(merr) {
+  fflush(stdout); 
+  cout << endl; 
+  cerr << endl;
+  string es = PeidaExc(merr);
+  cerr << "Services2NObjMgr::FillNTFrCFile()  Exception :" << merr << es;
+  } ENDTRY;
+
+if (adel) delete objnt;   // Delete de l'objet NTupleInterface si necessaire
+CloseDLL();
+
+// $CHECK$ A virer des que possible  On redirige la sortie sur la fenetre PIConsole 
+mImgapp->RedirectStdOutErr(red);
+
+if (fgnnt) mOmg->AddObj(nt, nomnt);
+return;
+}
+
+/* --Methode-- */
+void Services2NObjMgr::PrepareNTExpressionCFile(string & nom, string const & fname, 
+                                                string const & funcname)
+{
+NObjMgrAdapter* obja=NULL;
+obja = mOmg->GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "Services2NObjMgr::PrepareNTExpressionCFile( " << nom << "...) No such object" <<endl;
+  return;
+  }
+bool adel = true;
+NTupleInterface* objnt = obja->GetNTupleInterface(adel);
+if (objnt == NULL)  {
+  cout << "Services2NObjMgr::PrepareNTExpressionCFile( " << nom 
+       << "...) No NTupleInterface !" <<endl;
+  return;
+  }
+string  vardec = objnt->VarList_C("_xnti_");
+
+FILE *fip;
+if ((fip = fopen(fname.c_str(), "w")) == NULL)   { 
+  cout << "Services2NObjMgr::PrepareNTExpressionCFile()_Error: fopen " << fname << endl; 
+  if (adel) delete objnt;   // Delete de l'objet NTupleInterface si necessaire
+  return; 
+  }
+
+// constitution du fichier des decalarations des variables de l'interface NTuple
+fputs("#include <stdlib.h> \n", fip);
+fputs("#include <stdio.h> \n", fip);
+fputs("#include <math.h> \n\n", fip);
+
+fputs("/* ------ Some random number generators --------- */ \n", fip);
+fputs("#define frand01() ( (float) drand48() ) \n", fip);
+fputs("#define drand01() drand48()  \n", fip);
+fputs("#define rand01()  drand48()  \n", fip);
+fputs("#define frandpm1() ( 2. * frand01() - 1.) \n", fip);
+fputs("#define drandpm1() ( 2. * drand01() - 1.) \n", fip);
+fputs("#define randpm1() ( 2. * drand01() - 1.) \n", fip);
+fputs("double NorRand(void) \n", fip);
+fputs(" { \n double x,A,B; \n LAB10: \n A = drand01(); \n", fip);
+fputs(" if ( A == 0. ) goto LAB10; \n B = drand01(); \n", fip);
+fputs(" x = sqrt(-2.*log(A))*cos(2.*M_PI*B); \n", fip);
+fputs(" return(x); \n } \n", fip);
+fputs("#define GauRand() NorRand() \n", fip);
+fputs("#define gaurand() NorRand() \n\n", fip);
+
+fputs("/* NTupleInterface Variable declaration - Generated by piapp  \n", fip);
+fputs("      -- Services2NObjMgr::PrepareNTExpressionCFile()  --     */ \n\n", fip);
+fprintf(fip,"int %s(double* _xnti_, double* _rx_, double* _ry_, double* _rz_, \n", 
+        funcname.c_str());
+fprintf(fip,"       double* _rt_, int _n_, int _nmax_) \n");
+fprintf(fip, "{ \n %s \n", vardec.c_str());
+fputs("  if (!1) { /* Cut Expression failed */ \n", fip);
+fputs("    *_rx_ = *_ry_ = *_rz_ = *_rt_ = 0.;  return(0);", fip);
+fputs("  } \n  /* Cut expression satisfied */ \n", fip);
+fputs("  *_rx_ = 1.; \n  *_ry_ = 1.; \n  *_rz_ = 1.; \n  *_rt_ = 1.; \n", fip);
+fputs("  return(1); \n} \n", fip);
+
+fclose(fip);
+
+if (adel) delete objnt;   // Delete de l'objet NTupleInterface si necessaire
+return;
+}
+
+/* --Methode-- cmv 13/10/98 */
+void Services2NObjMgr::FillGFD(string& nom, string& expx, string& expy, string& expz,
+                               string& experr, string& expcut, string& nomgfd, string loop)
+//	Pour remplir un ``GeneralFitData'' a partir de divers objets:
+//| nom = nom de l'objet a transcrire selon 1D: Z=f(X) ou 2D: Z=f(X,Y) .
+//|       Vector,Matrix,Histo,HProf,Histo2D,Image<T>,StarList,NTuple,GeneralFitData
+//| expx = expression X du GeneralFitData (1er abscisse)
+//| expy = expression Y du GeneralFitData (2sd abscisse si non "", Z=f(X,Y))
+//| expz = expression Z du GeneralFitData (valeur de l'ordonnee)
+//| experr = expression de l'erreur sur l'ordonnee Z
+//| expcut = expression du test de selection
+//| nomgfd = nom du GeneralFitData engendre (optionnel)
+{
+NObjMgrAdapter* obja=NULL;
+obja = mOmg->GetObjAdapter(nom);
+if (obja == NULL) {
+  cout << "Services2NObjMgr::FillGFD() Error , No such object "<<nom<<endl;
+  return;
+  }
+if(!mImgapp)  return;
+
+// 2D ou 3D?
+int nvar = 2;
+if(expy.length()<=0) {nvar = 1; expy = "0.";}
+
+// Creation NTuple Buffer
+char* ntn[4]= {"x","y","f","e"};
+NTuple*nt = new NTuple(4,ntn);
+
+// Remplissage NTuple buffer
+ComputeExpressions(obja, expx, expy, expz, experr, expcut, loop, nt, NULL, NULL);
+if(nt->NEntry() < 1)
+  {cout<<"Services2NObjMgr::FillGFD() Warning  Zero points satisfy cut !"<<endl; 
+   delete nt; return;}
+
+//Remplissage de la structure GeneraFitData
+if (nt->NEntry() <= 0) {
+  cout<<"Services2NObjMgr::FillGFD() Warning - NData= " << nt->NEntry() << endl;
+  delete nt;
+  return;
+  }
+
+GeneralFitData* gfd = new GeneralFitData(nvar,nt->NEntry(),0);
+int k;
+float* xn;
+for(k=0; k<nt->NEntry(); k++) {
+  xn = nt->GetVec(k);
+  gfd->AddData(xn,xn[2],xn[3]);
+}
+
+// Menage et table d'objets
+delete nt;
+mOmg->AddObj(gfd, nomgfd);
+return;
+}
+
+
+/* --Methode-- */
+void Services2NObjMgr::ComputeExpressions(NObjMgrAdapter* obja, string& expx, 
+                          string& expy, string& expz, string& expt, string& expcut, string& loop, 
+                          NTuple* nt, Histo* h1, Histo2D* h2, HProf* hp)
+{
+if (obja == NULL) return;
+bool adel = true;
+NTupleInterface* objnt = obja->GetNTupleInterface(adel);
+if (objnt == NULL)  return;
+string  vardec = objnt->VarList_C("_zz6qi_");
+
+PlotExprFunc f = LinkExprFunc(vardec, expx, expy, expz, expt, expcut);
+if (!f) { 
+  cerr << "Services2NObjMgr::::ComputeExpressions() Error Creation PlotExprFunc " <<  endl; 
+  if (adel) delete objnt;  // Delete de l'objet NTupleInterface si necessaire
+  return;
+  }
+
+double xnt[10];
+float  fxnt[10];
+
+int i,k;
+for(i=0; i<10; i++) xnt[i] = 0.;
+int k1,k2,dk;
+k1 = 0;  k2 = objnt->NbLines();  dk = 1;
+DecodeLoopParameters(loop, k1, k2, dk);
+if (k1 < 0) k1 = 0;
+if (k2 < 0) k2 = objnt->NbLines();
+if (k2 > objnt->NbLines()) k2 = objnt->NbLines();
+if (dk <= 0) dk = 1;
+TRY  {
+  double* xn;
+  for(k=k1; k<k2; k += dk)    {
+    xn = objnt->GetLineD(k);
+    if (f(xn, xnt, xnt+1, xnt+2, xnt+3) != 0) {
+      if (nt) { 
+         for(i=0; i<4; i++) fxnt[i] = xnt[i]; 
+         nt->Fill(fxnt);
+         }
+      if (h1) h1->Add(xnt[0], xnt[3]);
+      if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
+      if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
+      }
+    }
+ }
+CATCH(merr) {
+  fflush(stdout); 
+  cout << endl; 
+  cerr << endl;
+  string es = PeidaExc(merr);
+  cerr << "Services2NObjMgr::ComputeExpressions()  Exception :" << merr << es;
+  } ENDTRY;
+ 
+
+if (adel) delete objnt;  // Delete de l'objet NTupleInterface si necessaire
+// Fermeture du fichier .so 
+CloseDLL();
+return;
+}
+
+
+/* --Methode-- */
+PlotExprFunc Services2NObjMgr::LinkExprFunc(string& vardec, string& expx, string& expy, 
+                                            string& expz, string& expt, string& cut)
+{
+FILE *fip;
+string fname = TmpDir + "expf_pia_dl.c";
+string cmd;
+int rc;
+
+cmd = "rm -f " + fname;
+rc = system(cmd.c_str());
+//DBG printf("LinkExprFunc_Do> %s  (Rc=%d)\n", cmd.c_str(), rc); 
+
+if ((fip = fopen(fname.c_str(), "w")) == NULL)   { 
+  string sn = fname; 
+  cout << "Services2NObjMgr/LinkExprFunc_Error: fopen( " << sn << endl; 
+  return(NULL); 
+  }
+
+// constitution du fichier a compiler
+fputs("#include <stdlib.h> \n", fip);
+fputs("#include <math.h> \n", fip);
+
+fputs("/* ------ Some random number generators --------- */ \n", fip);
+fputs("#define frand01() ( (float) drand48() ) \n", fip);
+fputs("#define drand01() drand48()  \n", fip);
+fputs("#define rand01()  drand48()  \n", fip);
+fputs("#define frandpm1() ( 2. * frand01() - 1.) \n", fip);
+fputs("#define drandpm1() ( 2. * drand01() - 1.) \n", fip);
+fputs("#define randpm1() ( 2. * drand01() - 1.) \n", fip);
+fputs("double NorRand(void) \n", fip);
+fputs(" { \n double x,A,B; \n LAB10: \n A = drand01(); \n", fip);
+fputs(" if ( A == 0. ) goto LAB10; \n B = drand01(); \n", fip);
+fputs(" x = sqrt(-2.*log(A))*cos(2.*M_PI*B); \n", fip);
+fputs(" return(x); \n } \n", fip);
+fputs("#define GauRand() NorRand() \n", fip);
+fputs("#define gaurand() NorRand() \n\n", fip);
+
+fputs("int expf_pia_dl_func(double* _zz6qi_, double* _rx_6q_, double* _ry_6q_, double* _rz_6q_, double* _rt_6q_) \n{\n", fip);
+fprintf(fip,"%s \n", vardec.c_str());
+fprintf(fip, "if (!(%s)) { *_rx_6q_ = *_ry_6q_ = *_rz_6q_ = *_rt_6q_ = 0.;  return(0); } \n", cut.c_str());
+fprintf(fip, "*_rx_6q_ = %s ; \n", expx.c_str());
+fprintf(fip, "*_ry_6q_ = %s ; \n", expy.c_str());
+fprintf(fip, "*_rz_6q_ = %s ; \n", expz.c_str());
+fprintf(fip, "*_rt_6q_ = %s ; \n", expt.c_str());
+fputs("return(1); \n} \n", fip);
+fclose(fip);
+string func = "expf_pia_dl_func";
+return((PlotExprFunc)LinkFunctionFromFile(fname, func));
+}
+
+
+/* --Methode-- */
+DlFunction Services2NObjMgr::LinkFunctionFromFile(string const & fname, string const & funcname)
+{
+//  Le link dynamique
+CloseDLL();
+dynlink = PDynLinkMgr::BuildFromCFile(fname);
+if (dynlink == NULL) { 
+  cerr << "Services2NObjMgr/LinkFunctionFromFile_Erreur: Erreur creation/Ouverture SO " << endl; 
+  return(NULL); 
+  }
+
+DlFunction retfunc = dynlink->GetFunction(funcname);
+if (retfunc == NULL) { 
+  string sn = funcname; 
+  cerr << "Services2NObjMgr/LinkExprFunc_Erreur: Erreur linking " << sn << endl; 
+  CloseDLL();
+  return(NULL); 
+  }
+else return(retfunc);
+}
+
+/* --Methode-- */
+void Services2NObjMgr::CloseDLL()
+{
+if (dynlink) delete dynlink;   dynlink = NULL;
+}
+
+// Fonction static
+/* --Methode-- */
+void Services2NObjMgr::DecodeLoopParameters(string& loop, int& i1, int& i2, int& di)
+{
+// Decode des paramatres de boucle for(int i=i1; i<i2; i+=di) specifies 
+// sous forme i1[:i2[:di]]
+// cout << "LoopParam() " << loop << " I1=" << i1 << " I2=" << i2 << " DI=" << di; 
+size_t l = loop.length();
+if (l < 1) return;
+size_t p = loop.find(':');
+if (p >= l) { i1 = atoi(loop.c_str()); return; }
+i1 = atoi(loop.substr(0, p).c_str());
+string aa = loop.substr(p+1);
+p = aa.find(':');
+if (p < aa.length() ) { 
+  i2 = atoi(aa.substr(0,p).c_str());
+  di = atoi(aa.substr(p+1).c_str());
+  }
+else i2 = atoi(aa.c_str());
+// cout << "-> I1= " << i1 << " I2= " << i2 << " DI= " << di << endl; 
+return;
+}
+
+/* --Methode-- */
+string Services2NObjMgr::FileName2Name(string const & fn)
+{
+
+char fsep[2] = {FILESEP, '\0'};
+char tsep[2] = {'.', '\0'};
+size_t p = fn.find_last_of(fsep);
+size_t l = fn.length();
+if (p >= l)  p = 0;
+else p++;
+size_t q = fn.find_first_of(tsep,p);
+if (q < p) q = l;
+return(fn.substr(p,q-p));
+}
+
+
+typedef vector<string> GraTok;
+
+/* --Methode-- */
+int Services2NObjMgr::DecodeDispOption(string& gratt, bool& fgsrgr)
+{
+int ropt = Disp_Next;
+if (!mImgapp)  return(ropt); 
+
+for(int i=0; i<gratt.length(); i++) gratt[i] = tolower(gratt[i]);
+
+if (fgsrgr) mImgapp->SaveGraphicAtt();
+
+if ( (gratt == "def") || (gratt == "default") )  {  // Remise aux valeurs par defaut = non defini
+  mImgapp->SetColAtt();
+  mImgapp->SetLineAtt();
+  mImgapp->SetFontAtt();
+  mImgapp->SetMarkerAtt();
+  mImgapp->SetColMapId();
+  mImgapp->SetZoomAtt();
+  mImgapp->SetAxesAtt();
+  mImgapp->SetXYLimits();
+  mImgapp->UseXYLimits();
+  return(ropt);
+  }
+
+// On separe en mots separes par des virgules 
+gratt = ","+gratt;
+size_t p = 0;
+size_t q = 0;
+size_t l = gratt.length();
+string token;
+
+GraTok grt;
+
+while (q < l)  {
+  p = gratt.find_first_not_of(" ,",q+1); // au debut d'un token
+  if (p>=l) break;
+  q = gratt.find_first_of(" ,",p); // la fin du token;
+  token = gratt.substr(p,q-p);
+  grt.push_back(token);
+  }
+
+
+static GrAttNames::iterator it;
+
+int k; 
+bool fgcont = true;
+fgsrgr = false;
+
+for(k=0; k<grt.size(); k++) {
+//  cout << "--DBG--SetGraphicAttributes() " << grt[k] << endl;
+
+ // Decodage option affichage (win, next, etc 
+  fgcont = true;
+  if ( (grt[k] == "win") || (grt[k] == "w") )  ropt =  Disp_Win;
+  else if ( (grt[k] == "same") || (grt[k] == "s") )  ropt = Disp_Same;
+  else  if ( (grt[k] == "stack") || (grt[k] == "st") )  ropt = Disp_Stack;
+  else fgcont = false;
+  if (fgcont)   continue;
+
+  // Utilisation limites X-Y
+  if ( grt[k] == "xylimits" ) { mImgapp->UseXYLimits(true);  fgsrgr = true;  continue; } 
+  // Si c'est une couleur
+  it = GrAcolors.find(grt[k]);
+  if (it != GrAcolors.end())  { mImgapp->SetColAtt((PIColors)((*it).second.a1)); fgsrgr = true; continue; }
+  // Si c'est un attribut de lignes
+  it = GrAlines.find(grt[k]);
+  if (it != GrAlines.end())  { mImgapp->SetLineAtt((PILineAtt)((*it).second.a1));  fgsrgr = true; continue; }
+  // Si c'est un attribut de fontes
+  it = GrAfonts.find(grt[k]);
+  if (it != GrAfonts.end())  { mImgapp->SetFontAtt((PIFontSize)((*it).second.a2), (PIFontAtt)((*it).second.a1) ); 
+                               fgsrgr = true;  continue; }
+  // Si c'est un attribut de markers
+  it = GrAmarkers.find(grt[k]);
+  if (it != GrAmarkers.end())  { mImgapp->SetMarkerAtt((*it).second.a2, (PIMarker)((*it).second.a1) ); 
+                                 fgsrgr = true;  continue; }
+  // Si c'est un colormap
+  it = GrAcmap.find(grt[k]);
+  if (it != GrAcmap.end())  { mImgapp->SetColMapId( (CMapId)((*it).second.a1) ); fgsrgr = true; continue; }  
+  // Si c'est un facteur de zoom
+  it = GrAzoom.find(grt[k]);
+  if (it != GrAzoom.end())  { mImgapp->SetZoomAtt( (*it).second.a1 );  fgsrgr = true; continue; }  
+  // Si c'est un attribut d'axe
+  it = GrAaxes.find(grt[k]);
+  if (it != GrAaxes.end())  { mImgapp->SetAxesAtt( (*it).second.a1 );  fgsrgr = true; continue; }  
+  
+  }  
+
+return(ropt);
+}
+
+
+
+// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+// Initialisation des chaines de caracteres designant les attributs graphiques 
+
+/* --Methode-- */
+void Services2NObjMgr::InitGrAttNames()
+{
+gratt_item gi;
+// Les couleurs
+gi.a2 = 0;
+gi.a1 = PI_NotDefColor;
+GrAcolors["defcol"] = gi;
+gi.a1 = PI_Black;
+GrAcolors["black"] = gi;
+gi.a1 = PI_White;
+GrAcolors["white"] = gi;
+gi.a1 = PI_Grey;
+GrAcolors["grey"] = gi;
+gi.a1 = PI_Red;
+GrAcolors["red"] = gi;
+gi.a1 = PI_Blue;
+GrAcolors["blue"] = gi;
+gi.a1 = PI_Green;
+GrAcolors["green"] = gi;
+gi.a1 = PI_Yellow;
+GrAcolors["yellow"] = gi;
+gi.a1 = PI_Magenta;
+GrAcolors["magenta"] = gi;
+
+gi.a1 = PI_Cyan;
+GrAcolors["cyan"] = gi;
+gi.a1 = PI_Turquoise;
+GrAcolors["turquoise"] = gi;
+gi.a1 = PI_NavyBlue;
+GrAcolors["navyblue"] = gi;
+gi.a1 = PI_Orange;
+GrAcolors["orange"] = gi;
+gi.a1 = PI_SiennaRed;
+GrAcolors["siennared"] = gi;
+gi.a1 = PI_Purple;
+GrAcolors["purple"] = gi;
+gi.a1 = PI_LimeGreen;
+GrAcolors["limegreen"] = gi;
+gi.a1 = PI_Gold;
+GrAcolors["gold"] = gi;
+
+// Les attributs de lignes
+gi.a2 = 0;
+gi.a1 = PI_NotDefLineAtt;
+GrAlines["defline"] = gi;
+gi.a1 = PI_NormalLine;
+GrAlines["normalline"] = gi;
+gi.a1 = PI_ThinLine;
+GrAlines["thinline"] = gi;
+gi.a1 = PI_ThickLine;
+GrAlines["thickline"] = gi;
+gi.a1 = PI_DashedLine;
+GrAlines["dashedline"] = gi;
+gi.a1 = PI_ThinDashedLine;
+GrAlines["thindashedline"] = gi;
+gi.a1 = PI_ThickDashedLine;
+GrAlines["thickdashedline"] = gi;
+gi.a1 = PI_DottedLine;
+GrAlines["dottedline"] = gi;
+gi.a1 = PI_ThinDottedLine;
+GrAlines["thindottedline"] = gi;
+gi.a1 = PI_ThickDottedLine;
+GrAlines["thickdottedline"] = gi;
+
+// Les fontes 
+gi.a2 = PI_NotDefFontSize;
+gi.a1 = PI_NotDefFontAtt;
+GrAfonts["deffont"] = gi;
+
+gi.a2 = PI_NormalSizeFont;
+gi.a1 = PI_RomanFont;
+GrAfonts["normalfont"] = gi;
+gi.a1 = PI_BoldFont;
+GrAfonts["boldfont"] = gi;
+gi.a1 = PI_ItalicFont;
+GrAfonts["italicfont"] = gi;
+gi.a2 = PI_SmallSizeFont;
+gi.a1 = PI_RomanFont;
+GrAfonts["smallfont"] = gi;
+gi.a1 = PI_BoldFont;
+GrAfonts["smallboldfont"] = gi;
+gi.a1 = PI_ItalicFont;
+GrAfonts["smallitalicfont"] = gi;
+gi.a2 = PI_BigSizeFont;
+gi.a1 = PI_RomanFont;
+GrAfonts["bigfont"] = gi;
+gi.a1 = PI_BoldFont;
+GrAfonts["bigboldfont"] = gi;
+gi.a1 = PI_ItalicFont;
+GrAfonts["bigitalicfont"] = gi;
+gi.a2 = PI_HugeSizeFont;
+gi.a1 = PI_RomanFont;
+GrAfonts["hugefont"] = gi;
+gi.a1 = PI_BoldFont;
+GrAfonts["hugeboldfont"] = gi;
+gi.a1 = PI_ItalicFont;
+GrAfonts["hugeitalicfont"] = gi;
+
+
+// Les markers 
+const char* mrkn[11] = { "dotmarker", "plusmarker", "crossmarker", 
+                         "circlemarker", "fcirclemarker", "boxmarker", "fboxmarker", 
+                         "trianglemarker", "ftrianglemarker", "starmarker", "fstarmarker"};
+PIMarker mrk[11] = { PI_DotMarker, PI_PlusMarker, PI_CrossMarker, 
+                     PI_CircleMarker, PI_FCircleMarker, PI_BoxMarker, PI_FBoxMarker, 
+                     PI_TriangleMarker, PI_FTriangleMarker, PI_StarMarker, PI_FStarMarker};
+
+gi.a2 = 0;
+gi.a1 = PI_NotDefMarker;
+GrAmarkers["defmarker"] = gi;
+ 
+for(int j=0; j<11; j++) {
+  string smrk;
+  char buff[16];
+  for(int m=1; m<10; m+=2) {
+    sprintf(buff,"%d",m);
+    smrk = (string)mrkn[j] + (string)buff;
+    gi.a1 = mrk[j];  gi.a2 = m;
+    GrAmarkers[smrk] = gi;
+    }
+  }
+
+// Les tables de couleurs 
+gi.a2 = 0;
+gi.a1 = CMAP_OTHER;
+GrAcmap["defcmap"] = gi;
+gi.a1 = CMAP_GREY32;
+GrAcmap["grey32"] = gi;
+gi.a1 = CMAP_GREYINV32;
+GrAcmap["greyinv32"] = gi;
+gi.a1 = CMAP_COLRJ32;
+GrAcmap["colrj32"] = gi;
+gi.a1 = CMAP_COLBR32;
+GrAcmap["colbr32"] = gi;
+gi.a1 = CMAP_GREY128;
+GrAcmap["grey128"] = gi;
+gi.a1 = CMAP_GREYINV128;
+GrAcmap["greyinv128"] = gi;
+gi.a1 = CMAP_COLRJ128;
+GrAcmap["colrj128"] = gi;
+gi.a1 = CMAP_COLBR128;
+GrAcmap["colbr128"] = gi;
+
+// La valeur de zoom
+gi.a2 = 0;
+gi.a1 = 0;
+GrAzoom["defzoom"] = gi;
+gi.a1 = 1;
+GrAzoom["zoomx1"] = gi;
+gi.a1 = 2;
+GrAzoom["zoomx2"] = gi;
+gi.a1 = 3;
+GrAzoom["zoomx3"] = gi;
+gi.a1 = 4;
+GrAzoom["zoomx4"] = gi;
+gi.a1 = 5;
+GrAzoom["zoomx5"] = gi;
+gi.a1 = -2;
+GrAzoom["zoom/2"] = gi;
+gi.a1 = -3;
+GrAzoom["zoom/3"] = gi;
+gi.a1 = -4;
+GrAzoom["zoom/4"] = gi;
+gi.a1 = -5;
+GrAzoom["zoom/5"] = gi;
+
+// Attributs d'axes
+gi.a2 = 0;
+gi.a1 = (int)(kBoxAxes | kExtTicks | kLabels);
+GrAaxes["stdaxes"] = gi;
+GrAaxes["defaxes"] = gi;
+GrAaxes["boxaxes"] = gi;
+gi.a1 = (int)kAxesDflt;
+GrAaxes["simpleaxes"] = gi;
+gi.a1 = (int)(kBoxAxes | kExtTicks | kLabels | kGridOn);
+GrAaxes["boxaxesgrid"] = gi;
+
+gi.a1 = (int)(kBoxAxes | kTicks | kLabels | kMinTicks | kMajTicks);
+GrAaxes["fineaxes"] = gi;
+ gi.a1 = (int)(kBoxAxes | kTicks | kLabels | kMinTicks | kMajTicks | kGridOn);
+GrAaxes["grid"] = gi;
+GrAaxes["fineaxesgrid"] = gi;
+                
+}
+
+
+// SANS_EVOLPLANCK     Attention !
+#include "pclassids.h"
+
+/* --Methode-- */
+char* Services2NObjMgr::PClassIdToClassName(int cid)
+{
+switch (cid) {
+  case ClassId_Poly1 : 
+    return("Poly1");
+  case ClassId_Poly2 : 
+    return("Poly2");
+  case ClassId_Matrix : 
+    return("Matrix");
+  case ClassId_Vector : 
+    return("Vector");
+
+  case ClassId_DVList : 
+    return("DVList");
+
+  case ClassId_Histo1D : 
+    return("Histo1D");
+  case ClassId_Histo2D : 
+    return("Histo2D");
+  case ClassId_HProf : 
+    return("HProf");
+  case ClassId_NTuple : 
+    return("NTuple");
+  case ClassId_XNTuple : 
+    return("XNTuple");
+  case ClassId_GeneralFitData : 
+    return("GeneralFitData");
+
+  case ClassId_Image : 
+    return("RzImage");
+  case ClassId_Image + kuint_1 : 
+    return("ImageU1");
+  case ClassId_Image + kint_1 : 
+    return("ImageI1");
+  case ClassId_Image + kuint_2 : 
+    return("ImageU2");
+  case ClassId_Image + kint_2 : 
+    return("ImageI2");
+  case ClassId_Image + kuint_4 : 
+    return("ImageU4");
+  case ClassId_Image + kint_4 : 
+    return("ImageI4");
+  case ClassId_Image + kr_4 : 
+    return("ImageR4");
+  case ClassId_Image + kr_8 : 
+    return("ImageR8");
+
+  case ClassId_ZFidu : 
+    return("ZFidu");
+
+  case ClassId_StarList : 
+    return("StarList");
+  case ClassId_Transfo : 
+    return("Transfo");
+  case ClassId_PSF : 
+    return("PSF");
+
+
+// - Ajout objet PPF
+  default:
+    return("AnyDataObj");
+  }
+}  
+
Index: /tags/V_LaSilla191199/SophyaPI/PIext/servnobjm.h
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/servnobjm.h	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/servnobjm.h	(revision 464)
@@ -0,0 +1,138 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Classe de services destinee a NamedObjMgr pour piapp
+// Reza                             Aout 98
+// CEA-DAPNIA      LAL-IN2P3/CNRS
+
+#ifndef SERVNOBJM_H_SEEN
+#define SERVNOBJM_H_SEEN
+
+#include "machdefs.h"
+#include <string>
+#include <list>
+#include <map>
+#include <functional>
+
+#include "pdlmgr.h"
+#include "dlftypes.h"
+#include "anydataobj.h"
+
+class NTuple;
+class Histo;
+class Histo2D;
+class HProf;
+class NamedObjMgr;
+class PIStdImgApp;
+class NObjMgrAdapter;
+
+class Services2NObjMgr {
+public:
+         	Services2NObjMgr(NamedObjMgr* omg, string& tmpdir);
+  virtual	~Services2NObjMgr();
+
+// Pour enregistrer les objets de donnees et leurs adaptateurs
+  void			RegisterClass(AnyDataObj* o, NObjMgrAdapter* oa);
+// Pour recuperer l'adaptateur pour un objet o 
+  NObjMgrAdapter*	GetAdapter(AnyDataObj* o);
+
+  inline void   SetImgApp(PIStdImgApp* app) {mImgapp = app; }
+
+// Trace de fonctions 1-D , 2-D
+  virtual void  PlotFunc(string const & expfunc, string & nom, double xmin, double xmax, 
+                         int np=100, string dopt="");
+  virtual void  PlotFunc2D(string const & expfunc, string & nom, double xmin, double xmax, 
+                           double ymin, double ymax, int npx=50, int npy=50, string dopt="");
+  virtual void  PlotFuncFrCFile(string const & fname, string const & func, string & nom, 
+                                double xmin, double xmax, int np=100, string dopt="");
+  virtual void  PlotFunc2DFrCFile(string const & fname, string const & func, string & nom, 
+                                  double xmin, double xmax, double ymin, double ymax, 
+                                  int npx=50, int npy=50, string dopt="");
+  virtual void  PlotFunc(DlFunctionOfX f, string & nom, double xmin, double xmax, 
+                         int np=100, string dopt="");
+  virtual void  PlotFunc2D(DlFunctionOfXY f, string & nom, double xmin, double xmax, 
+                           double ymin, double ymax, int npx=50, int npy=50, string dopt="");
+
+//  Trace d'expression de NTuple, et d'autres objets
+  virtual void          DisplayPoints2D(string & nom, string& expx, string& expy,
+                                        string& experrx, string& experry, 
+                                        string& expcut, string dopt="", string loop="");
+  virtual void          DisplayPoints3D(string & nom, string& expx, string& expy, string& expz, 
+                                        string& expcut, string dopt="", string loop="");
+  virtual void          DisplayPoints2DW(string & nom, string& expx, string& expy, 
+                                         string& expwt, string& expcut, string dopt="", string loop="");
+//  Projection d'expressions dans histogramme, vecteur/matrices (et trace) 
+  virtual void          ProjectH1(string & nom, string& expx, string& expwt, string& expcut, 
+                                  string& nomh1, string dopt="", string loop="");
+  virtual void          ProjectH2(string & nom, string& expx, string& expy, string& expwt, 
+                                  string& expcut, string& nomh2, string dopt="", string loop="");
+  virtual void          ProjectHProf(string & nom, string& expx, string& expy, string& expwt, 
+                                  string& expcut, string& nomprof, string dopt="", string loop="");
+
+//  Remplissage de vecteurs, ntuples, GFD 
+  virtual void          FillVect(string & nom, string& expx, string& expv, string& expcut, 
+                                  string& nomvec, string dopt="", string loop="");
+  virtual void          FillMatx(string & nom, string& expx, string& expy, string& expv, 
+                                  string& expcut, string& nommtx, string dopt="", string loop="");
+
+  virtual void          ExpressionToVector(string & nom, string& expx, string& expcut, 
+                                           string& nomvec, string dopt="", string loop="");
+  virtual void          NtFromASCIIFile(string& nom,string& filename,double def_val=0.);
+  virtual void          FillNT(string & nom, string& expx, string& expy, string& expz,
+                               string& expt, string& expcut, string& nomnt, string loop=""); 
+  virtual void          FillGFD(string & nom, string& expx, string& expy, string& expz,
+                               string& experr, string& expcut, string& nomgfd, string loop="");
+  virtual void          FillNTFrCFile(string & nom, string const & fname, 
+                                      string const & funcname, string & nomnt, string loop="");
+  virtual void		PrepareNTExpressionCFile(string & nomobj, string const & fname, 
+                                                 string const & funcname);
+
+// Calcul d'expressions d'interface NTuple pour les objets
+  void 		ComputeExpressions(NObjMgrAdapter* obja, string& expx, string& expy, 
+                                   string& expz, string& expt, string& expcut, string& loop,
+                                   NTuple* nt=NULL, Histo* h1=NULL,
+                                   Histo2D* h2=NULL, HProf* hp=NULL);
+  PlotExprFunc  LinkExprFunc(string& vardec, string& expx, string& expy, 
+                             string& expz, string& expt, string& cut);
+  DlFunction    LinkFunctionFromFile(string const & fname, string const & funcname);
+  void 		CloseDLL();  
+
+// Utilitaires divers 
+  static void   DecodeLoopParameters(string& loop, int& i1, int& i2, int& di);
+  int 		DecodeDispOption(string& dopt, bool& fgsrgr);
+  string 	FileName2Name(string const & fn);
+  char* 	PClassIdToClassName(int cid);
+
+protected:
+  void 		InitGrAttNames();
+
+// Pour enregister les objets et leurs adaptateurs pour NamedObjMgr
+  struct dataobj_adapter {
+    AnyDataObj* obj;  NObjMgrAdapter* obja;
+  };
+  typedef list<dataobj_adapter> ObjAdaptList;
+  ObjAdaptList objadaplist;
+
+//   Variables membre , en public pour le moment
+  struct gratt_item {
+    int a1, a2;
+  };
+  typedef map<string, gratt_item, less<string> > GrAttNames;
+  
+//  Pour les changements d'attributs graphiques / de visualisation
+  GrAttNames GrAcolors;
+  GrAttNames GrAlines;
+  GrAttNames GrAmarkers;
+  GrAttNames GrAfonts;
+  GrAttNames GrAcmap;  
+  GrAttNames GrAzoom;  
+  GrAttNames GrAaxes;  
+
+  PDynLinkMgr * dynlink;  // shared-lib lib.so
+  string TmpDir;          // Pour fichiers temporaires
+
+  PIStdImgApp* mImgapp;
+  NamedObjMgr* mOmg;
+  
+};
+
+
+#endif
Index: /tags/V_LaSilla191199/SophyaPI/PIext/userfitfunex.c
===================================================================
--- /tags/V_LaSilla191199/SophyaPI/PIext/userfitfunex.c	(revision 464)
+++ /tags/V_LaSilla191199/SophyaPI/PIext/userfitfunex.c	(revision 464)
@@ -0,0 +1,72 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+/********************************************************************/
+/* fonction de fit "f(x;h,x0,sig,c) = h*exp(-0.5*((x-x0)/sig)^2)+c" */
+/* avec nvar=1 npar=4                                               */
+/*      x = x[0]                                                    */
+/*      p[0]=h, p[1]=x0, p[2]=sig, p[3]=c                           */
+/********************************************************************/
+double gauss1(double const* x,double const* p)
+{
+double xc;
+xc = (x[0]-p[1])/p[2]; xc *= -xc/2.;
+return((xc>=-80.) ? p[0]*exp(xc)+p[3] : p[3]);
+}
+
+/* la definition de cette fonction n'est pas obligatoire */
+/* dp[0] = df(x;h,x0,sig,c)/dh, dp[1] = etc...           */
+double gauss1_der(double const* x,double const* p,double* dp)
+{
+double xc,xc2,e,f;
+xc = (x[0]-p[1])/p[2];
+xc2 = xc*xc;
+e = -xc2/2.;
+if(e>=-80.) e = exp(e); else e = 0.;
+f = p[0]*e;
+dp[0] = e;
+dp[1] = xc  / p[2] *f;
+dp[2] = xc2 / p[2] *f;
+dp[3] = 1.;
+return(f+p[3]);
+}
+
+/********************************************************/
+/* fonction de fit gaussienne 2D avec correlation       */
+/* f(x,y;h,x0,y0,sx,sy,rho,c) =                         */
+/*   h * exp{ -0.5*[ (x-x0)^2/sx^2 + (y-y0)^2/s^2       */
+/*                   -2*rho*(x-x0)*(y-y0)/(sx*sy) ]}    */
+/* avec nvar=2 npar=7                                   */
+/*      x = x[0] et y=x[2]                              */
+/*      p[0]=h, p[1]=x0, p[2]=y0                        */
+/*      p[3]=sx, p[4]=sy, p[5]=rho, p[6]=fond           */
+/********************************************************/
+double gauss2(double const* x,double const* p)
+{
+double ax,ay,a;
+ax = (x[0]-p[1])/p[3];
+ay = (x[1]-p[2])/p[4];
+a  = -(ax*ax+ay*ay-2.*p[5]*ax*ay)/2.;
+return((a>=-80.) ? p[0]*exp(a)+p[6] : p[6]);
+}
+
+/* la definition de cette fonction n'est pas obligatoire */
+/* dp[0] = f(x,y;h,x0,y0,sx,sy,rho,c)/dh, dp[1] = etc... */
+double gauss2_der(double const* x,double const* p,double* dp)
+{
+double ax,ay,a,p0ea;
+ax   = (x[0]-p[1])/p[3];
+ay   = (x[1]-p[2])/p[4];
+a    = -(ax*ax+ay*ay-2.*p[5]*ax*ay)/2.;
+p0ea = (a>=-80.) ? exp(a) : 0.;
+dp[0] = p0ea;
+  p0ea *= p[0];
+dp[1] = (ax-p[5]*ay)/p[3] *p0ea;
+dp[2] = (ay-p[5]*ax)/p[4] *p0ea;
+dp[3] = ax*dp[1];
+dp[4] = ay*dp[2];
+dp[5] = ax*ay *p0ea;
+dp[6] = 1.;
+return(p0ea+p[6]);
+}
