Index: /trunk/SophyaPI/PIext/Makefile
===================================================================
--- /trunk/SophyaPI/PIext/Makefile	(revision 165)
+++ /trunk/SophyaPI/PIext/Makefile	(revision 165)
@@ -0,0 +1,615 @@
+MODULECXXREPNAME := PI
+MODULECXXFLAGS := -msg_quiet
+include ../Mgr/Makefile.h
+ 
+all: $(LIB)libPIext.a
+$(LIB)libPIext.a : $(OBJ)nobjmgr.o $(OBJ)piacmd.o $(OBJ)piapp.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)piapp.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 \
+ 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)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 \
+ 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)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)piapp.o: piapp.cc $(INC)psighand.h \
+ $(INC)defs.h $(INC)dynccd.h \
+ $(INC)machine.h \
+ $(INC)exceptions.h \
+ $(INC)peidainit.h \
+ $(INC)ppersist.h \
+ $(INC)perrors.h \
+ $(INC)pclassids.h \
+ $(INC)timing.h piinit.h \
+ $(INC)imaginit.h \
+ $(INC)outilsinit.h \
+ $(INC)strecinit.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)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)ctimer.h $(INC)peida.h \
+ $(INC)utils.h $(INC)fmath.h \
+ pisiadw.h $(INC)pilistx.h \
+ $(INC)pilistgen.h \
+ $(INC)pistzwin.h \
+ $(INC)piperiodx.h \
+ $(INC)periodic.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)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)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)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)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)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)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)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)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 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)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 \
+ 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)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 \
+ 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)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: /trunk/SophyaPI/PIext/dlftypes.h
===================================================================
--- /trunk/SophyaPI/PIext/dlftypes.h	(revision 165)
+++ /trunk/SophyaPI/PIext/dlftypes.h	(revision 165)
@@ -0,0 +1,23 @@
+// 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 <string>
+#include <vector>
+#if defined(__KCC__)
+using std::string ;
+#include <vector.h>
+#endif
+
+typedef void (* DlFunction) (void);
+typedef double (* DlFunctionOfX) (double x);
+typedef double (* DlFunctionOfXY) (double x, double y);
+typedef int (* PlotExprFunc) (float* x, float* rx, float* ry, float* rz, float* wt);
+typedef void (* DlUserProcFunction) (vector<string>& args);
+
+#endif
+
Index: /trunk/SophyaPI/PIext/nobjmgr.cc
===================================================================
--- /trunk/SophyaPI/PIext/nobjmgr.cc	(revision 165)
+++ /trunk/SophyaPI/PIext/nobjmgr.cc	(revision 165)
@@ -0,0 +1,2057 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include <iostream.h>
+#include <string>
+#include <list>
+#include <map>
+#if defined(__KCC__)
+using std::string ;
+#include <list.h>
+#include <map.h>
+#endif
+
+#include "strutil.h"
+#include "datatypes.h"
+#include "fitsimage.h"
+
+#include "nobjmgr.h"
+#include "servnobjm.h"
+#include "pistdimgapp.h"
+
+#include "pclassids.h"
+#include "poly.h"
+#include "dvlist.h"
+#include "matrix.h"
+#include "cvector.h"
+#include "zfidu.h"
+
+#include "fft.h"
+#include "fct1dfit.h"
+#include "fct2dfit.h"
+
+#include "pimgadapter.h"
+#include "pipodrw.h"
+
+#include "pihisto.h"
+#include "hisprof.h"
+#include "pihisto2d.h"
+#include "pintuple.h"
+#include "pisurfdr.h"  
+#include "pintup3d.h"
+#include "pigfd1.h"
+#include "pigfd2.h"
+
+//  Si le module StarReco++ a ete compile (Pour les StarList, Transfo, etc ...
+#ifndef SANS_StarReco 
+#include "pistlist.h"
+#include "transfo.h"
+#endif
+
+//++
+// Class	NamedObjMgr
+// Lib		PI
+// include	nobjmgr.h
+//
+//	Cette classe fournit les services nécéssaire à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_item {
+  PPersist* obj;
+  int num;
+  list<int> wrsid;
+  bool operator==(nobj_item const& b) const
+    { return (this->obj ==  b.obj); }
+};
+
+typedef map<string, nobj_item, less<string> > NObjList;
+
+static NObjList* myObjs;
+static int fgOInit = 0;
+static int myNObj = 0;
+static string* lastobj = NULL;
+
+static PIStdImgApp* myImgApp=NULL;
+static Services2NObjMgr* servnobjm=NULL;
+
+static string* TmpDir;  // Repertoire pour les compilations / link dynamique
+
+//++
+// 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) { 
+  myObjs = new NObjList;  
+  lastobj = new string(""); 
+  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(NULL, (*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);
+}
+
+/* --Methode-- */
+PIStdImgApp* NamedObjMgr::GetImgApp()
+{
+return(myImgApp);
+}
+
+/* --Methode-- */
+Services2NObjMgr* NamedObjMgr::GetServiceObj()
+{
+return(servnobjm);
+}
+
+//++
+// Titre	Gestion de la liste des objets
+//--
+//++
+// void AddObj(PPersist* 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"
+// PPersist*  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.
+// string  LastObjName()
+//	Renvoie le nom du dernier objet ajouté à la liste
+//--
+
+
+/* --Methode-- */
+void NamedObjMgr::AddObj(PPersist* obj, string& nom)
+{
+
+if (obj == NULL)  return;
+// on supprime les blancs de debut et de fin 
+size_t p = nom.find_first_not_of(" ");
+if(p>nom.length()) {
+  nom = "";
+} else {
+  nom = nom.substr(p);
+  p = nom.find_first_of(" ");
+  if(p>nom.length()) p=nom.length();
+  nom = nom.substr(0, p);
+}
+
+myNObj++;
+if (nom.length() < 1) nom = servnobjm->PClassIdToShortClassName(obj->ClassId());
+NObjList::iterator it = myObjs->find(nom);
+if (it != myObjs->end()) { // l'objet existe deja
+  char strg[16];
+  sprintf(strg, "%d", myNObj);
+  string nomnew = nom + strg;
+  RenameObj(nom, nomnew);
+  }
+
+(*lastobj) = nom;
+nobj_item no;
+no.obj = obj;
+no.num =  myNObj;
+(*myObjs)[(*lastobj)] = no;
+if (myImgApp)  { 
+  string str = (*lastobj) + "    (T= " + servnobjm->PClassIdToClassName(obj->ClassId()) + ")" ;
+  (myImgApp->ObjMgrW())->AddObj(str.c_str(), myNObj+1000);
+}
+ 
+cout << "NamedObjMgr::AddObj()  Object " << (*lastobj) << " ( "  
+     << servnobjm->PClassIdToClassName(obj->ClassId()) << " ) added (Total= " << myObjs->size() << ")" << endl;  
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::DelObj(string const& nom, bool fgd)
+{
+NObjList::iterator it = myObjs->find(nom);
+if (it == myObjs->end()) return; 
+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));
+  (myImgApp->ObjMgrW())->DelObj((*it).second.num+1000);
+}
+if (fgd) delete (*it).second.obj;
+myObjs->erase(it);
+if (fgd) cout << "NamedObjMgr::DelObj()  Object " << nom << " deleted (Total= " << myObjs->size() << ")" << endl;
+else  cout << "NamedObjMgr::DelObj()  Object " << nom << " removed (Total= " << myObjs->size() << ")" << endl;
+return;  
+}
+
+/* --Methode-- */
+void NamedObjMgr::DelObjects(string const& patt, bool fgd)
+{
+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-- */
+PPersist* NamedObjMgr::GetObj(string const& nom)
+{
+NObjList::iterator it = myObjs->find(nom);
+if (it == myObjs->end()) return(NULL); 
+return((*it).second.obj);
+}
+
+/* --Methode-- */
+void NamedObjMgr::RenameObj(string const& nom, string& nomnew)
+{
+PPersist* obj = GetObj(nom);
+if (obj == NULL) return;
+DelObj(nom, false);
+AddObj(obj, nomnew);
+return;
+}
+
+/* --Methode-- */
+string NamedObjMgr::LastObjName()
+{
+return((*lastobj));
+}
+
+//++
+// 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, nobj);
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::ReadObj(PInPersist& s, int num)
+{
+int i, cid, key, ln;
+int n0, n1;
+bool ok = true;
+PPersist* obj=NULL;
+string nom;
+
+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, nom);
+}
+ 
+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, nom);  
+}
+
+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, 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);
+  obj = RzReadFits((char*)flnm.c_str());
+  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((PPersist*)obj, nobj);
+}
+return;
+}
+
+
+static int key_for_write = 5000;
+/* --Methode-- */
+void NamedObjMgr::SaveObj(string const& nom, POutPersist& s)
+{
+PPersist* obj=NULL;
+obj = GetObj(nom);
+if (obj == NULL)  return;
+printf("NamedObjMgr::SaveObj(%s, )  (Type=%s) \n",  
+       nom.c_str(), servnobjm->PClassIdToClassName(obj->ClassId()));
+string nm = nom;  // A cause de const 
+obj->Write(s,  key_for_write, nm);
+key_for_write++;
+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; 
+for(it = myObjs->begin(); it != myObjs->end(); it++) SaveObj((*it).first, (*pout));
+delete pout;
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::SaveFits(string const& nom, string const & flnm)
+{
+PPersist* obj=NULL;
+obj = GetObj(nom);
+if (obj == NULL)  return;
+
+int cid = obj->ClassId();
+if ( (cid < ClassId_Image) && ( cid > ClassId_Image+kr_8) ) {
+  printf("NamedObjMgr::SaveFits(%s, ) Error - Object is NOT an image (type=%s) \n",
+         nom.c_str(), servnobjm->PClassIdToClassName(obj->ClassId()) );
+  return;
+}
+
+RzImage* pim = (RzImage*)obj;
+TRY { 
+  switch (pim->PixelType()) {
+    case kuint_2:
+      {
+      FitsImageU2 imgfits(*pim);
+      imgfits.Save(flnm); 
+      }
+    break;
+    case kint_2:
+      {
+      FitsImageI2 imgfits(*pim);
+      imgfits.Save(flnm); 
+      }
+      break;
+    case kint_4:
+      {
+      FitsImageI4 imgfits(*pim);
+      imgfits.Save(flnm); 
+      }
+      break;
+    case kr_4:
+      {
+      FitsImageR4 imgfits(*pim);
+      imgfits.Save(flnm); 
+      }
+      break;
+    default :
+      printf("NamedObjMgr::SaveObj()/Error Type d'image (%d) NON supporte en FITS \n", 
+             (int)pim->PixelType());
+      break;
+  }
+}  CATCH(merr) { 
+  printf("NamedObjMgr::SaveObj()/Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
+} ENDTRY;
+
+return;
+}
+
+
+/* --Methode-- */
+void NamedObjMgr::ListObjs()
+{
+int k;
+PPersist* obj=NULL;
+string ctyp;
+char strg[256];
+int cid;
+
+cout << "NamedObjMgr::ListObjs() NObjs= " << myObjs->size() << "\n" ;
+NObjList::iterator it;  k = 0;
+for(it = myObjs->begin(); it != myObjs->end(); it++) {
+  obj = (*it).second.obj;
+
+  cid = obj->ClassId();
+  ctyp = servnobjm->PClassIdToClassName(cid);
+  sprintf(strg, "%2d/ %16s : %s", k, servnobjm->PClassIdToClassName(obj->ClassId()), ((*it).first).c_str()); 
+  ctyp = strg;
+  cout << ctyp << "\n" ;
+  k++;
+}
+cout << endl;
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::PrintObj(string const& nom)
+{
+PPersist* obj=GetObj(nom);
+if (obj == NULL) {
+  cout << "NamedObjMgr::PrintObj() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+}
+
+int cid = obj->ClassId();
+string ctyp = servnobjm->PClassIdToClassName(cid);
+
+cout << "NamedObjMgr::PrintObj(" << nom << ") Type: " << ctyp 
+     << "Cid= " << cid << ")" << endl;
+
+int i4dum;
+switch (cid) {
+  case ClassId_Poly1 : 
+    ((Poly*)obj)->Print(cout);
+    break;
+  case ClassId_Poly2 : 
+    ((Poly2*)obj)->Print(cout);
+    break;
+  case ClassId_Matrix : 
+  case ClassId_Vector : 
+    cout << *((Matrix*)obj);
+    break;
+
+  case ClassId_DVList : 
+    ((DVList*)obj)->Print();
+    break;
+
+  case ClassId_Histo1D : 
+    ((Histo*)obj)->Print(60);
+    break;
+  case ClassId_Histo2D : 
+    ((Histo2D*)obj)->Print();
+    break;
+  case ClassId_HProf : 
+    ((HProf*)obj)->Print(60);
+    break;
+  case ClassId_NTuple : 
+    cout << ((NTuple*)obj)->Info();
+    cout << *((NTuple*)obj);
+    break;
+  case ClassId_GeneralFitData : 
+    ((GeneralFitData*)obj)->PrintStatus();
+    i4dum = ((GeneralFitData*)obj)->NData();
+    if(i4dum>0) {
+      ((GeneralFitData*)obj)->PrintData(0);
+      ((GeneralFitData*)obj)->PrintData(i4dum-1);
+    }
+    break;
+
+  case ClassId_Image : 
+  case ClassId_Image + kuint_1 : 
+  case ClassId_Image + kint_1 : 
+  case ClassId_Image + kuint_2 : 
+  case ClassId_Image + kint_2 : 
+  case ClassId_Image + kuint_4 : 
+  case ClassId_Image + kint_4 : 
+  case ClassId_Image + kr_4 : 
+  case ClassId_Image + kr_8 : 
+    ((RzImage*)obj)->Print();
+    break;
+
+  case ClassId_ZFidu : 
+    ((ZFidu*)obj)->Print();
+    break;
+
+#ifndef SANS_StarReco 
+  case ClassId_StarList : 
+    ((StarList*)obj)->Print(10, 1, 50);
+    break;
+  case ClassId_Transfo : 
+    ((Transfo*)obj)->Print(cout);
+    break;
+  case ClassId_PSF : 
+    break;
+
+  case ClassId_Star + BStar_Type : 
+  case ClassId_Star + RzStar_Type : 
+  case ClassId_Star + PSFStar_Type : 
+  case ClassId_Star + MCStar_Type : 
+  case ClassId_Star + CircRFixStar_Type : 
+  case ClassId_Star + PSFDHStar_Type : 
+  case ClassId_Star + PSFSEStar_Type : 
+  case ClassId_Star + MCDHStar_Type : 
+    ((BStar*)obj)->Print(1);
+    break;
+#endif
+
+// - Ajout objet PPF
+  default:
+    break;
+  }
+cout << endl;
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::DisplayObj(string const& nom, string dopt) 
+{
+PPersist* obj=GetObj(nom);
+if (obj == NULL) {
+  cout << "NamedObjMgr::DisplayObj() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+}
+if (!myImgApp)  return;
+ 
+int cid = obj->ClassId();
+string ctyp = servnobjm->PClassIdToClassName(cid);
+
+int wrsid = 0;
+bool fgsr = true;
+// On veut tracer une ligne pour vecteur et histo1D par defaut
+if ( (cid == ClassId_Vector) || (cid == ClassId_Histo1D) )  dopt = "thinline," + dopt;
+else if(cid == ClassId_HProf)  dopt = "fcirclemarker5," + dopt;
+int opt = servnobjm->DecodeDispOption(dopt, fgsr);
+
+switch (cid) {
+  case ClassId_Poly1 : 
+  case ClassId_Poly2 : 
+  case ClassId_DVList : 
+    cout << "NamedObjMgr::DisplayObj() Error , Pas de display pour " << ctyp << endl; 
+    break;
+
+  case ClassId_Matrix : 
+    {
+    wrsid = myImgApp->DispImage(new POMatrixAdapter((Matrix*)obj, false), nom, opt);
+    break;
+    }
+  case ClassId_Vector : 
+    {
+    PIYfXDrawer* dr = new   PIYfXDrawer( new POVectorAdapter((Vector*)obj, false), NULL, true);
+    wrsid = myImgApp->DispScDrawer( (PIDrawer*)dr, nom, opt);    
+    break;
+    }
+  case ClassId_Histo1D : 
+    {
+    PIHisto* pih = new PIHisto(((Histo*)obj), false);
+    wrsid = myImgApp->DispScDrawer( (PIDrawer*)pih, nom, opt);
+    break;
+    }
+  case ClassId_Histo2D : 
+    {
+    PIHisto2D* pih2 = new PIHisto2D(((Histo2D*)obj), false);
+    wrsid = myImgApp->DispScDrawer( (PIDrawer*)pih2, nom, opt, nom, true);
+    break;
+    }
+  case ClassId_HProf : 
+    {
+    PIHisto* pihp = new PIHisto(((Histo*)obj), false);
+    wrsid = myImgApp->DispScDrawer( (PIDrawer*)pihp, nom, opt);
+    break;
+    }
+  case ClassId_GeneralFitData : 
+    {
+    GeneralFitData* gfd = (GeneralFitData*)obj;
+    if(gfd->NVar()==1) {
+      PIGenFitDat* pigfd = new PIGenFitDat(gfd,false);
+      wrsid = myImgApp->DispScDrawer((PIDrawer*)pigfd,nom,opt);
+    } else if(gfd->NVar()==2) {
+      PIGenFitDat3D* pigfd = new PIGenFitDat3D(gfd,false);
+      wrsid = myImgApp->Disp3DDrawer(pigfd,nom,opt);
+    } else {
+      cout<<"NamedObjMgr::DisplayObj() Error , Utilisez DisplayGFD pour GeneralFitData "
+          <<ctyp<<"\n de "<<gfd->NVar()<<" variables (!=1,2)"<<endl; 
+    }
+    break;
+    }
+
+  case ClassId_NTuple : 
+    cout << "NamedObjMgr::DisplayObj() Error , Utilisez DisplayNt pour NTuple " << ctyp << endl; 
+    break;
+
+  case ClassId_Image : 
+  case ClassId_Image + kuint_1 : 
+  case ClassId_Image + kint_1 : 
+  case ClassId_Image + kr_8 : 
+  case ClassId_Image + kuint_4 : 
+    wrsid = myImgApp->DispImage(new RzImageAdapter((RzImage*)obj, false), nom, opt);
+    break;
+  case ClassId_Image + kuint_2 : 
+    wrsid = myImgApp->DispImage(new ImageAdapter<uint_2>((ImageU2*)obj, false), nom, opt);
+    break;
+  case ClassId_Image + kint_2 : 
+    wrsid = myImgApp->DispImage(new ImageAdapter<int_2>((ImageI2*)obj, false), nom, opt);
+    break;
+  case ClassId_Image + kint_4 : 
+    wrsid = myImgApp->DispImage(new ImageAdapter<int_4>((ImageI4*)obj, false), nom, opt);
+    break;
+  case ClassId_Image + kr_4 : 
+    wrsid = myImgApp->DispImage(new ImageAdapter<r_4>((ImageR4*)obj, false), nom, opt);
+    break;
+
+  case ClassId_ZFidu : 
+    {
+    int nx = ((ZFidu*)obj)->XMax() -  ((ZFidu*)obj)->XMin();
+    int ny = ((ZFidu*)obj)->YMax() -  ((ZFidu*)obj)->YMin();
+    if (nx > 1024)  nx = 1024;
+    if (ny > 1024)  ny = 1024;
+    if (nx < 128)  nx = 128;
+    if (ny < 128)  nx = 128;
+    ImageU2* msk = ((ZFidu*)obj)->MakeBadZoneMask(nx, ny);
+    myImgApp->DispImage(new ImageAdapter<uint_2>((ImageU2*)msk, true), nom, opt);
+    break;
+    }
+
+#ifndef SANS_StarReco 
+  case ClassId_StarList : 
+    {
+    PIStarList* pist = new PIStarList(((StarList*)obj), false);
+    wrsid = myImgApp->DispScDrawer( (PIDrawer*)pist, nom, opt);
+    break;
+    }
+
+  case ClassId_Transfo : 
+  case ClassId_PSF : 
+  case ClassId_Star + BStar_Type : 
+  case ClassId_Star + RzStar_Type : 
+  case ClassId_Star + PSFStar_Type : 
+  case ClassId_Star + MCStar_Type : 
+  case ClassId_Star + CircRFixStar_Type : 
+  case ClassId_Star + PSFDHStar_Type : 
+  case ClassId_Star + PSFSEStar_Type : 
+  case ClassId_Star + MCDHStar_Type : 
+    cout << "NamedObjMgr::DisplayObj() Error , Pas de display pour " << ctyp << endl; 
+    break;
+#endif
+
+// - Ajout objet PPF
+  default:
+    break;
+  }
+
+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 const& nom, string& nmx, string& nmy, string& nmz,
+                            string& erx, string& ery, string& erz, string dopt)
+{
+PPersist* obj=GetObj(nom);
+if (obj == NULL) {
+  cout << "NamedObjMgr::DisplayNT() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+}
+if (!myImgApp)  return; 
+
+int cid = obj->ClassId();
+if (cid != ClassId_NTuple) { 
+  string ctyp = servnobjm->PClassIdToClassName(cid);
+  cout << "NamedObjMgr::DisplayNT() Error , Objet n'est pas un NTuple " << ctyp << endl; 
+  return;
+  }
+
+int wrsid = 0;
+bool fgsr = true;
+int opt = servnobjm->DecodeDispOption(dopt, fgsr);
+
+if (nmz.length()>0)  { // Display 3D
+  PINTuple3D* pin = new PINTuple3D(((NTuple*)obj), 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, nom, opt, titre);  
+}
+else {
+  PINTuple* pin = new PINTuple(((NTuple*)obj), false);
+  pin->SelectXY(nmx.c_str(), nmy.c_str());
+  pin->SelectErrBar(erx.c_str(), ery.c_str());
+  string titre = nmy + "%" + nmz;
+  wrsid = myImgApp->DispScDrawer( (PIDrawer*)pin, nom, 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 */
+void NamedObjMgr::DisplayGFD(string const& 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.
+{
+PPersist* obj=GetObj(nom);
+if(obj == NULL)
+  {cout << "NamedObjMgr::DisplayGFD() Error , Pas d'objet de nom " << nom << endl; 
+   return;}
+if(!myImgApp) return; 
+int cid = obj->ClassId();
+if(cid != ClassId_GeneralFitData)
+  {string ctyp = servnobjm->PClassIdToClassName(cid);
+   cout<<"NamedObjMgr::DisplayGFD() Error , Objet n'est pas un 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());
+
+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,nom,opt);  
+} else {                   // Display 2D
+  PIGenFitDat* pigfd = new PIGenFitDat(((GeneralFitData*)obj),false);
+  pigfd->SelectX(numvx);
+  pigfd->SelectErrBar(errx,erry);
+  wrsid = myImgApp->DispScDrawer((PIDrawer*)pigfd,nom,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 const& nom, string dopt)
+{
+  cout << "NamedObjMgr::DisplayImage() a faire ! " << endl;
+}
+*/
+
+
+/* --Methode-- */
+void NamedObjMgr::DisplaySurf3D(string const& nom, string dopt)
+{
+PPersist* obj=GetObj(nom);
+if (obj == NULL) {
+  cout << "NamedObjMgr::DisplaySurf3D() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+}
+if (!myImgApp)  return; 
+
+int cid = obj->ClassId();
+
+
+P2DArrayAdapter* arr=NULL;
+switch (cid) {
+  case ClassId_Matrix : 
+    arr = new POMatrixAdapter((Matrix*)obj, false);
+    break;
+  case ClassId_Histo2D : 
+    arr = new POH2DAdapter((Histo2D*)obj, false);
+    break;
+  case ClassId_Image : 
+  case ClassId_Image + kuint_1 : 
+  case ClassId_Image + kint_1 : 
+  case ClassId_Image + kr_8 : 
+  case ClassId_Image + kuint_4 : 
+    arr = new RzImageAdapter((RzImage*)obj, false);
+    break;
+  case ClassId_Image + kuint_2 : 
+    arr = new ImageAdapter<uint_2>((ImageU2*)obj, false);
+    break;
+  case ClassId_Image + kint_2 : 
+    arr = new ImageAdapter<int_2>((ImageI2*)obj, false);
+    break;
+  case ClassId_Image + kint_4 : 
+    arr = new ImageAdapter<int_4>((ImageI4*)obj, false);
+    break;
+  case ClassId_Image + kr_4 : 
+    arr = new ImageAdapter<r_4>((ImageR4*)obj, false);
+    break;
+
+  default :
+    cout << "NamedObjMgr::DisplaySurf3D() Error , Pas de display pour " << servnobjm->PClassIdToClassName(cid) << endl; 
+    return;
+  }
+
+if (!arr) return;
+if ((arr->XSize() > 250) || (arr->YSize() > 250)) {
+  cout << "NamedObjMgr::DisplaySurf3D() Error , 2D-Array(" <<  arr->XSize() 
+       << "x" << arr->YSize() << ") trop grand (max=250x250)" << endl; 
+  delete arr;
+  return;
+  }
+
+int wrsid = 0;
+bool fgsr = true;
+int opt = servnobjm->DecodeDispOption(dopt, fgsr);
+if (cid == ClassId_Histo2D)  arr->DefineXYCoordinates(0., 0., 1., 1.);
+PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
+wrsid = myImgApp->Disp3DDrawer(sdr, nom, 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::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::DisplayPoints2D(string const& nom,  string& expx, string& expy,
+                                  string& experrx, string& experry,
+                                  string& expcut, string dopt)
+{
+PPersist* obj=GetObj(nom);
+if (obj == NULL) {
+  cout << "NamedObjMgr::DisplayPoints2D() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+}
+if (!myImgApp)  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(2, ntn); }
+else {  haserr = false;  experrx = experry = "0."; nt = new NTuple(2, ntn); }
+
+servnobjm->Nobj_ComputeExpressions(obj, expx, expy, experrx, experry, expcut, nt, NULL, NULL);
+
+if (nt->NEntry() < 1) {
+  cout << "NamedObjMgr::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;
+int opt = servnobjm->DecodeDispOption(dopt, fgsr);
+string titre =  nom + ":" + expy + "%" + expx;
+myImgApp->DispScDrawer( (PIDrawer*)pin, titre, opt);
+if (fgsr) myImgApp->RestoreGraphicAtt();
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::DisplayPoints3D(string const& nom,  string& expx, string& expy, string& expz,
+                                  string& expcut, string dopt)
+{
+PPersist* obj=GetObj(nom);
+if (obj == NULL) {
+  cout << "NamedObjMgr::DisplayPoints3D() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+  }
+if (!myImgApp)  return; 
+
+char* ntn[3] = {"expx","expy","expz"};
+NTuple* nt = new NTuple(3,ntn);  // Creation NTuple
+
+string expwt = "1.";
+servnobjm->Nobj_ComputeExpressions(obj, expx, expy, expz, expwt, expcut, nt, NULL, NULL);
+
+if (nt->NEntry() < 1) {
+  cout << "NamedObjMgr::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;
+int opt = servnobjm->DecodeDispOption(dopt, fgsr);
+
+// Pour plot a partir de DispScDrawer
+// string nomdisp = "_NT3D_";
+// myImgApp->DispScDrawer( (PIDrawer*)pin, nomdisp, opt);
+// Pour plot a partir de Disp3DDrawer
+string titre =  nom + ":" + expy + "%" + expx;
+myImgApp->Disp3DDrawer(pin, titre, opt);
+
+if (fgsr) myImgApp->RestoreGraphicAtt();
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::ProjectH1(string const& nom, string& expx, string& expwt, string& expcut, string& nomh1, string dopt)
+{
+PPersist* obj=GetObj(nom);
+
+if (obj == NULL) {
+  cout << "NamedObjMgr::ProjectH1() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+  }
+if (!myImgApp)  return; 
+
+Histo* h1 = NULL;
+NTuple* nt = NULL;
+PPersist* oh = NULL; 
+if (nomh1.length() > 0) oh=GetObj(nomh1);
+else nomh1 = "H1Proj";
+if ( (oh != NULL) && (oh->ClassId() == ClassId_Histo1D) )  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.";   
+servnobjm->Nobj_ComputeExpressions(obj, expx, expwt, expz, expwt, expcut, nt, h1, NULL);
+
+if ((!h1) && (!nt)) return;
+if (!h1) {
+  if (nt->NEntry() < 1) {
+    cout << "NamedObjMgr::ProjectH1() Warning  Zero points satisfy cut !" << endl; 
+    delete nt;
+    return;
+    }
+  float 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;
+  AddObj(h1, nomh1);
+  }
+
+DisplayObj(nomh1, dopt);
+return;  
+}
+
+/* --Methode-- */
+void NamedObjMgr::ProjectH2(string const& nom, string& expx, string& expy, string& expwt, string& expcut, 
+                            string& nomh2, string dopt)
+{
+PPersist* obj=GetObj(nom);
+
+if (obj == NULL) {
+  cout << "NamedObjMgr::ProjectH2() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+  }
+if (!myImgApp)  return; 
+
+Histo2D* h2 = NULL;
+NTuple* nt = NULL;
+PPersist* oh = NULL;
+if (nomh2.length() > 0)  oh=GetObj(nomh2);
+else nomh2 = "H2Proj";
+if ( (oh != NULL) && (oh->ClassId() == ClassId_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.";   
+servnobjm->Nobj_ComputeExpressions(obj, expx, expy, expwt, expwt, expcut, nt, NULL, h2);
+
+if ((!h2) && (!nt)) return;
+if (!h2) {
+  if (nt->NEntry() < 1) {
+    cout << "NamedObjMgr::ProjectH2() Warning  Zero points satisfy cut !" << endl; 
+    delete nt;
+    return;
+    }
+  float 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;
+  AddObj(h2, nomh2);
+  }
+
+DisplayObj(nomh2, dopt);
+return;  
+
+}
+
+/* --Methode-- cmv 13/10/98 */
+void NamedObjMgr::ProjectHProf(string const& nom, string& expx, string& expy, string& expwt, string& expcut, 
+                              string& nomprof, string dopt)
+//	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.
+{
+PPersist* obj=GetObj(nom);
+
+if (obj == NULL) {
+  cout << "NamedObjMgr::ProjectHProf() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+  }
+if (!myImgApp)  return; 
+
+HProf* hprof = NULL;
+NTuple* nt = NULL;
+PPersist* oh = NULL;
+if (nomprof.length() > 0)  oh=GetObj(nomprof);
+else nomprof = "ProfProj";
+if( (oh!=NULL) && (oh->ClassId()== ClassId_HProf) )  hprof = (HProf*)oh;
+else {
+  char* ntn[3]= {"hxval", "hyval", "hwt"};
+  nt = new NTuple(3,ntn);  // Creation NTuple 
+}
+string expz = "0.";
+servnobjm->Nobj_ComputeExpressions(obj, expx, expy, expwt, expwt, expcut, nt, NULL, NULL, hprof);
+
+if((!hprof) && (!nt)) return;
+if(!hprof) {
+  if (nt->NEntry() < 1) {
+    cout << "NamedObjMgr::ProjectHProf() Warning  Zero points satisfy cut !" << endl;
+    delete nt;
+    return;
+  }
+  float 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;
+  AddObj(hprof, nomprof);
+  }
+hprof->UpdateHisto();
+
+DisplayObj(nomprof, dopt);
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::FillVect(string const& nom, string& expx, string& expcut, string& nomvec, string dopt)
+{
+PPersist* obj=GetObj(nom);
+
+if (obj == NULL) {
+  cout << "NamedObjMgr::FillVect() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+  }
+if (!myImgApp)  return; 
+
+NTuple* nt = NULL;
+if (nomvec.length() < 1) nomvec = "VecFill";
+
+char* ntn[2]= {"vecval", "vecwt"};
+nt = new NTuple(1,ntn);  // Creation NTuple
+ 
+string expwt = "1.";
+string expz = "0.";   
+servnobjm->Nobj_ComputeExpressions(obj, expx, expz, expz, expwt, expcut, nt, NULL, NULL);
+
+if (!nt) return;
+if (nt->NEntry() < 1) {
+  cout << "NamedObjMgr::FillVect() 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;
+AddObj(vec, nomvec); 
+DisplayObj(nomvec, dopt);
+return;  
+}
+
+/* --Methode-- */
+void NamedObjMgr::FillNT(string const& nom, string& expx, string& expy, string& expz, string& expt, 
+                         string& expcut, string& nomnt)
+{
+PPersist* obj=GetObj(nom);
+
+if (obj == NULL) {
+  cout << "NamedObjMgr::FillNT() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+  }
+if (!myImgApp)  return; 
+
+bool fgnnt = false;
+NTuple* nt = NULL;
+PPersist* oh = NULL;
+if (nomnt.length() > 0)  oh=GetObj(nomnt);
+else nomnt = "NTFill";
+if ( (oh != NULL) && (oh->ClassId() == ClassId_NTuple) )  { 
+  nt = (NTuple*)oh;
+  if (nt->NVar() > 10) {
+    cout << "NamedObjMgr::FillNT() Warning , Max 10 var ds 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;
+  }
+
+servnobjm->Nobj_ComputeExpressions(obj, expx, expy, expz, expt, expcut, nt, NULL, NULL);
+
+if (fgnnt) AddObj(nt, nomnt);
+return;  
+
+}
+
+/* --Methode-- cmv 13/10/98 */
+void NamedObjMgr::FillGFD(string const& nom, string& expx, string& expy, string& expz,
+                          string& experr, string& expcut, string& nomgfd)
+//	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)
+{
+PPersist* obj=GetObj(nom);
+if(obj == NULL)
+  {cout<<"NamedObjMgr::FillGFD() Error , Pas d'objet de nom "<<nom<<endl;
+   return;}
+if(!myImgApp)  return;
+
+// 2D ou 3D?
+int nvar = 2;
+if(expy.length()<=0) {nvar = 1; expy = "0.";}
+
+// Que faut-il copier dans GeneralFitData
+int ndata=0;
+int cid = obj->ClassId();
+switch (cid) {
+  case ClassId_Vector :
+    ndata=((Vector*)obj)->NElts();
+    break;
+  case ClassId_Matrix :
+    ndata=((Matrix*)obj)->NCol()*((Matrix*)obj)->NRows();
+    break;
+  case ClassId_Histo1D :
+  case ClassId_HProf : 
+    ndata=((Histo*)obj)->NBins();
+    break;
+  case ClassId_Histo2D :
+    ndata=((Histo2D*)obj)->NBinX()*((Histo2D*)obj)->NBinY();
+    break;
+  case ClassId_Image : 
+  case ClassId_Image + kuint_1 :
+  case ClassId_Image + kint_1 :
+  case ClassId_Image + kr_8 :
+  case ClassId_Image + kuint_4 :
+  case ClassId_Image + kuint_2 :
+  case ClassId_Image + kint_2 :
+  case ClassId_Image + kint_4 :
+  case ClassId_Image + kr_4 :
+    ndata=((RzImage*)obj)->XSize()*((RzImage*)obj)->YSize();
+    break;
+#ifndef SANS_StarReco 
+  case ClassId_StarList : 
+    ndata=((StarList*)obj)->NbStars();
+    break;
+#endif
+  case ClassId_NTuple :
+    ndata=((NTuple*)obj)->NEntry();
+    break;
+  case ClassId_GeneralFitData :
+    ndata=((GeneralFitData*)obj)->NData();
+    break;
+  default :
+    cout<<"FillGFD Erreur: N/A to  "<<servnobjm->PClassIdToClassName(cid)<<endl; 
+    return;
+}
+
+// Nom du GeneralFitData cree.
+if (nomgfd.length() <= 0) nomgfd = "GFDFill";
+// Consistence ndata.
+if(ndata<=0)
+  {cout<<"NamedObjMgr::FillGFD() Warning   ndata="<<ndata<<endl; 
+   return;}
+
+// Creation NTuple Buffer
+char* ntn[4]= {"x","y","f","e"};
+NTuple*nt = new NTuple(4,ntn);
+
+// Remplissage NTuple buffer
+servnobjm->Nobj_ComputeExpressions(obj, expx, expy, expz, experr, expcut, nt, NULL, NULL);
+if(nt->NEntry() < 1)
+  {cout<<"NamedObjMgr::FillGFD() Warning  Zero points satisfy cut !"<<endl; 
+   delete nt; return;}
+
+//Remplissage de la structure GeneraFitData
+GeneralFitData* gfd = new GeneralFitData(nvar,ndata,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;
+AddObj(gfd, nomgfd);
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::PlotFunc(string& expfunc, float xmin, float xmax, int np, string dopt)
+{
+FILE *fip;
+string fname = (*TmpDir) + "func1_pia_dl.c";
+string fnamer = (*TmpDir) + "func1_pia_dl";
+string  cmd;
+int rc;
+
+if (!myImgApp)  return; 
+
+cmd = "rm " + 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 << "NamedObjMgr/PlotFunc_Erreur: Pb. Ouverture " << 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);
+
+DlFunctionOfX f = (DlFunctionOfX) servnobjm->LinkFunctionFromFile(fnamer, "func1_pia_dl_func");
+if (!f) return; 
+PlotFunc(f, xmin, xmax, np, dopt);
+servnobjm->CloseDLL();
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::PlotFunc2D(string& expfunc, float xmin, float xmax, float ymin, float ymax, 
+                             int npx, int npy, string dopt)
+{
+FILE *fip;
+string fname = (*TmpDir) + "func2_pia_dl.c";
+string fnamer = (*TmpDir) + "func2_pia_dl";
+string cmd;
+int rc;
+
+if (!myImgApp)  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 << "NamedObjMgr/PlotFunc2D_Erreur: Pb. Ouverture " << 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);
+
+DlFunctionOfXY f = (DlFunctionOfXY) servnobjm->LinkFunctionFromFile(fnamer, "func2_pia_dl_func");
+if (!f)  return;
+PlotFunc2D(f, xmin, xmax, ymin, ymax, npx, npy, dopt);
+servnobjm->CloseDLL();
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::PlotFunc(DlFunctionOfX f, float xmin, float xmax, int np, string dopt)
+{
+if (!myImgApp)  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 << "NamedObjMgr::PlotFunc()  Exception :" << merr << es;
+  delete vpy;
+  vpy = NULL;
+  } ENDTRY;
+
+
+if (vpy) {
+  string nom = "Func";
+  AddObj(vpy, 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 = servnobjm->DecodeDispOption(dopt, fgsr);
+  int wrsid = myImgApp->DispScDrawer(dr, nom, 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::PlotFunc2D(DlFunctionOfXY f, float xmin, float xmax, float ymin, float ymax, 
+                             int npx, int npy, string dopt)
+{
+if (!myImgApp)  return; 
+
+if (npx < 1) npx = 1;
+if (npy < 1) npy = 1;
+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 << "NamedObjMgr::PlotFunc2D()  Exception :" << merr << es;
+  delete mtx;  mtx = NULL;
+  } ENDTRY;
+
+if (mtx) {
+  string nom = "Func2";
+  AddObj(mtx, nom);
+  DisplaySurf3D(nom, dopt);
+  }
+
+return;
+}
+
+///////////////////// Fit 1D et 2D //////////////////////////
+/* --Function static propre aux routines de fit 1D et 2D-- cmv 13/10/98 */
+struct DFOptions {
+  int okres, okfun;
+  int polcx,polcy; double xc,yc;
+  double err_e, err_E;
+  double stc2;
+  int lp,lpg;
+  int i1,i2,j1,j2;
+};
+typedef struct DFOptions DFOPTIONS;
+static void DecodeFitsOptions(string par,string step,string min,string max,string opt
+                      ,Vector& Par,Vector& Step,Vector& Min,Vector& Max,DFOPTIONS& O);
+void DecodeFitsOptions(string par,string step,string min,string max,string opt
+                      ,Vector& Par,Vector& Step,Vector& Min,Vector& Max,DFOPTIONS& O)
+//| Pour decoder les "string" et remplir les vecteurs du fit (cf commentaires dans Fit1D)
+{
+// set des vecteurs et decodage des string correspondantes
+int NParMax = 100;
+Par.Realloc(NParMax); Step.Realloc(NParMax);
+Min.Realloc(NParMax); Max.Realloc(NParMax);
+{
+  Vector* v; string* s;
+  {for(int i=0;i<NParMax;i++) {Par(i)=0.; Step(i)=1.; Min(i)=1.; Max(i)=-1.;}}
+  for(int j=0;j<4;j++) {
+    if(j==0)      {v=&Par; s=&par;}
+    else if(j==1) {v=&Step; s=&step;}
+    else if(j==2) {v=&Min; s=&min;}
+    else if(j==3) {v=&Max; s=&max;}
+    if(s->length()>0) *s += ",";
+    for(int i=0;i<NParMax;i++) {
+      if(s->length()<=0) break;
+      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);
+    }
+  }
+}
+
+// Decodage de options de opt
+O.okres = O.okfun = 0;
+O.polcx = O.polcy = 0;
+O.xc = O.yc = 0.;
+O.stc2 = 1.e-3;
+O.err_e = O.err_E = -1.;
+O.lp = 1; O.lpg = 0;
+O.i1 = O.j1 = O.i2 = O.j2 = -1;
+
+if(opt.length()<=0) return;
+opt = "," + opt + ",";
+
+if(strstr(opt.c_str(),",r,")) O.okres = 1;  // residus
+if(strstr(opt.c_str(),",f,")) O.okfun = 1;  // fonction fittee
+if(strstr(opt.c_str(),",x")) { // Demande de centrage (fit X=x-xc)
+  O.polcx = 2; // Le centrage est calcule automatiquement
+  size_t p = opt.find(",x");
+  size_t q = opt.find_first_of(',',p+1);
+  string dum = opt.substr(p,q-p);
+  if(dum.length()>2) {
+    sscanf(dum.c_str(),",x%lf",&O.xc);
+    O.polcx = 1; // Le centrage est fixe par la valeur lue
+  }
+}
+if(strstr(opt.c_str(),",y")) { // Demande de centrage (fit Y=y-yc)
+  O.polcy = 2; // Le centrage est calcule automatiquement
+  size_t p = opt.find(",y");
+  size_t q = opt.find_first_of(',',p+1);
+  string dum = opt.substr(p,q-p);
+  if(dum.length()>2) {
+    sscanf(dum.c_str(),",y%lf",&O.yc);
+    O.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)"
+  size_t p = opt.find(",E");
+  size_t q = opt.find_first_of(',',p+1);
+  string dum = opt.substr(p,q-p);
+  if(dum.length()>2) sscanf(dum.c_str(),",E%lf",&O.err_E);
+  if(O.err_E<=0.) O.err_E = 1.;
+  O.err_e=-1.;
+}
+if(strstr(opt.c_str(),",e")) { // Erreurs imposees a "1" ou "aa.b"
+  size_t p = opt.find(",e");
+  size_t q = opt.find_first_of(',',p+1);
+  string dum = opt.substr(p,q-p);
+  if(dum.length()>2) sscanf(dum.c_str(),",e%lf",&O.err_e);
+  if(O.err_e<=0.) O.err_e = 1.;
+  O.err_E=-1.;
+}
+if(strstr(opt.c_str(),",X")) { // Valeur du StopChi2
+  size_t p = opt.find(",X");
+  size_t q = opt.find_first_of(',',p+1);
+  string dum = opt.substr(p,q-p);
+  if(dum.length()>2) sscanf(dum.c_str(),",X%lf",&O.stc2);
+  if(O.stc2<=0.) O.stc2 = 1.e-3;
+}
+if(strstr(opt.c_str(),",l")) { // niveau de print
+  size_t p = opt.find(",l");
+  size_t q = opt.find_first_of(',',p+1);
+  string dum = opt.substr(p,q-p);
+  float ab;
+  if(dum.length()>2) sscanf(dum.c_str(),",l%f",&ab);
+  if(ab<0) ab = 0.;
+  O.lp = (int) ab; O.lpg = (int) 10.*(ab-O.lp);
+}
+if(strstr(opt.c_str(),",I")) { // intervalle de fit selon X
+  size_t p = opt.find(",I");
+  size_t q = opt.find_first_of(',',p+1);
+  string dum = opt.substr(p,q-p);
+  if(dum.length()>2) sscanf(dum.c_str(),",I%d/%d",&O.i1,&O.i2);
+}
+if(strstr(opt.c_str(),",J")) { // intervalle de fit selon Y
+  size_t p = opt.find(",J");
+  size_t q = opt.find_first_of(',',p+1);
+  string dum = opt.substr(p,q-p);
+  if(dum.length()>2) sscanf(dum.c_str(),",J%d/%d",&O.j1,&O.j2);
+}
+return;
+}
+
+/* --Methode-- cmv 13/10/98 */
+void  NamedObjMgr:: Fit12D(string const& nom, string& func,
+                          string par,string step,string min,string max,
+                          string opt)
+//| --------------- Fit d'objets a 1 et 2 dimensions ---------------
+//| nom  : nom de l'objet qui peut etre:
+//|        fit-1D:  Vector,Histo1D,HProf ou GeneraFitData(1D)
+//|        fit-2D:  Matrix,Histo2D,Imagexx ou GeneraFitData(2D)
+//| func : pnn = fit polynome degre nn avec classe Poly (lineaire) 1D ou 2D
+//|      : 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
+//| par  : p1,...,pn valeur d'initialisation des parametres (def=0)
+//| step : s1,...,sn valeur des steps de depart (def=1)
+//| min  : m1,...,mn valeur des minima (def=1)
+//| max  : M1,...,Mn valeur des maxima (def=-1) (max<=min : pas de limite)
+//| opt  : options "Eaa.b,eaa.b,f,r,caa.b,Xaa.b"
+//|       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)
+//|       la.b = niveau "a.b" de print: a=niveau de print Fit1/2D
+//|                                     b=niveau de debug 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 existe, 1 sinon sauf si
+//|       E = erreur prise comme la racine de la valeur a fitter
+//|       Eaa.b = erreur prise aa.b*sqrt(val)
+//|       e = erreur prise egale a 1 pour toutes les valeurs
+//|       eaa.b = erreur prise egale a aa.b
+//|       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
+//|                       gauss+poly 1D (mais xc est le centre de la gaussienne)
+//|2D     yaa.b et y = idem "xaa.b et x" mais pour y
+{
+PPersist* obj=GetObj(nom);
+if (obj == NULL) {
+  cout<<"NamedObjMgr::Fit12D() Error , Pas d'objet de nom "<<nom<<endl;
+  return;
+}
+if (!myImgApp)  return;
+if(func.length()<=0)
+  {cout<<"NamedObjMgr::Fit12D() Donnez un nom de fonction a fitter."<<endl;
+   return;}
+int cid = obj->ClassId();
+string ctyp = servnobjm->PClassIdToClassName(cid);
+
+int ndim = 0, nbinx=0, nbiny=0, ndata = 0;
+Vector* v = NULL; Histo* h = NULL;
+Matrix* m = NULL; Histo2D* h2 = NULL; RzImage* im = NULL;
+GeneralFitData* g = NULL;
+switch (cid) {
+  // 1D
+  case ClassId_Vector :
+    ndim = 1;
+    v = (Vector*) obj; nbinx = v->NElts(); nbiny = 1;
+    break;
+  case ClassId_HProf :
+  case ClassId_Histo1D :
+    ndim = 1;
+    h = (Histo*)  obj; nbinx = h->NBins(); nbiny = 1;
+    break;
+  // 2D
+  case ClassId_Matrix :
+    ndim = 2;
+    m = (Matrix*) obj; nbinx = m->NCol(); nbiny = m->NRows();
+    break;
+  case ClassId_Histo2D :
+    ndim = 2;
+    h2 = (Histo2D*) obj; nbinx = h2->NBinX(); nbiny = h2->NBinY();
+    break;
+  // 1D ou 2D selon
+  case ClassId_GeneralFitData :
+    g = (GeneralFitData*) obj; nbinx = g->NData(); nbiny = 1;
+    if(     g->NVar()==1) ndim = 1;
+    else if(g->NVar()==2) ndim = 2;
+    else {
+      cout<<"GeneralFitData ne peut avoir que 1 ou 2 variables d'abscisse: "
+          <<((GeneralFitData*) obj)->NVar()<<endl; return;}
+    break;
+  case ClassId_Image : 
+  case ClassId_Image + kuint_1 : 
+  case ClassId_Image + kuint_2 : 
+  case ClassId_Image + kint_2 : 
+  case ClassId_Image + kint_4 : 
+  case ClassId_Image + kr_4 :
+  case ClassId_Image + kr_8 : 
+    ndim = 2;
+    im = (RzImage*) obj; nbinx = im->XSize(); nbiny = im->YSize();
+    break;
+  default:
+    cout<<"NamedObjMgr::Fit12D() Error , Objet n'est pas un "
+        <<"Histo1D/HProf/Vector/Histo2D/Image/Matrix/GeneralFitData "<<ctyp<<endl;
+    return;
+    break;
+}
+ndata = nbinx*nbiny;
+if(ndata<=0)
+  {cout<<"L'objet a "<<nbinx<<","<<nbiny<<" bins ("<<ndata<<")"<<endl; return;}
+
+// Decodage des options et des parametres, mise en forme
+Vector Par(1); Vector Step(1); Vector Min(1); Vector Max(1); DFOPTIONS O;
+DecodeFitsOptions(par,step,min,max,opt,Par,Step,Min,Max,O);
+O.i1 = (O.i1<0||O.i1>=nbinx)? 0: O.i1;
+O.i2 = (O.i2<0||O.i2>=nbinx||O.i2<O.i1)? nbinx-1: O.i2;
+if(ndim>=2) {
+  O.j1 = (O.j1<0||O.j1>=nbiny)? 0: O.j1;
+  O.j2 = (O.j2<0||O.j2>=nbiny||O.j2<O.j1)? nbiny-1: O.j2;
+} else O.j2 = O.j1 = 0;
+if(O.polcx==2) {
+  if(v||m)    O.xc = (O.i2-O.i1+1)/2.;
+  else if(h)  O.xc = (h->XMin()+h->XMax())/2.;
+  else if(h2) O.xc = (h2->XMin()+h2->XMax())/2.;
+  else if(g)  {double mini,maxi; g->GetMinMax(2,mini,maxi); O.xc=(mini+maxi)/2.;}
+  else if(im) {O.xc = im->XOrg() * im->XPxSize()*(O.i2-O.i1+1)/2.;}
+}
+if(O.polcy==2 && ndim>=2) {
+  if(m)  O.yc = (O.j2-O.j1+1)/2.;
+  if(h2) O.yc = (h2->YMin()+h2->YMax())/2.;
+  if(g)  {double mini,maxi; g->GetMinMax(12,mini,maxi); O.yc=(mini+maxi)/2.;}
+  if(im) {O.yc = im->YOrg() * im->YPxSize()*(O.j2-O.j1+1)/2.;}
+}
+if(O.lp>0)
+  cout<<"Fit["<<nbinx<<","<<nbiny<<"] ("<<ndata<<") dim="<<ndim<<":"
+      <<" Int=["<<O.i1<<","<<O.i2<<"],["<<O.j1<<","<<O.j2<<"]"<<endl
+      <<" Cent="<<O.polcx<<","<<O.polcy<<","<<O.xc<<"+x"<<","<<O.yc<<"+y"
+      <<" TypE="<<O.err_e<<","<<O.err_E
+      <<" StpX2="<<O.stc2
+      <<" lp,lpg="<<O.lp<<","<<O.lpg<<endl;
+
+///////////////////////////////////
+// Remplissage de GeneralFitData //
+///////////////////////////////////
+GeneralFitData mydata(ndim,ndata,0);
+{for(int i=O.i1;i<=O.i2;i++) for(int j=O.j1;j<=O.j2;j++) {
+  double x,y,f,e;
+
+  if(v)
+    {x= (double) i; f=(*v)(i); e=1.;}
+  else if(h)
+    {x=h->BinCenter(i); f=(*h)(i); e=(h->HasErrors())?h->Error(i):1.;}
+  else if(m)
+    {x=(double) i; y=(double) j; f=(*m)(j,i); e=1.;}
+  else if(h2)
+    {float xf,yf; h2->BinCenter(i,j,xf,yf); x=(double)xf; y=(double)yf;
+     f=(*h2)(i,j); e=(h2->HasErrors())?h2->Error(i,j):1.;}
+  else if(im)
+    {x=im->XOrg()+(i+0.5)*im->XPxSize(); y=im->YOrg()+(j+0.5)*im->YPxSize();
+     f=im->DValue(i,j); e=1.;}
+  else if(g&&ndim==1) {x= g->X(i); f=g->Val(i); e=g->EVal(i);}
+  else if(g&&ndim==2) {x= g->X(i); y= g->Y(i); f=g->Val(i); e=g->EVal(i);}
+  else x=y=f=e=0.;
+
+  // Gestion des erreurs a utiliser
+  if(O.err_e>0.) e=O.err_e;
+  else if(O.err_E>0.) {e=(y<-1.||y>1.)?O.err_E*sqrt(fabs(y)):O.err_E;}
+
+  // Remplissage de generalfit
+  if(func[0]=='p') {x -= O.xc; if(ndim>=2) y -= O.yc;}
+  if(ndim==1)      mydata.AddData1(x,f,e);
+  else if(ndim==2) mydata.AddData2(x,y,f,e);
+}}
+if(mydata.NData()<=0)
+  {cout<<"Pas de donnees dans GeneralFitData: "<<mydata.NData()<<endl;
+   return;}
+if(O.lpg>1) {
+  mydata.PrintStatus();
+  mydata.PrintData(0);
+  mydata.PrintData(mydata.NData()-1);
+}
+
+////////////////////////////////////////////
+// Identification de la fonction a fitter //
+////////////////////////////////////////////
+GeneralFunction* myfunc = NULL;
+if(func[0]=='p' && ndim==1) {
+  // Fit de polynome sans passer par les GeneralFit
+  int degre = 0;
+  if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
+  cout<<"Fit (lineaire) 1D polynome de degre "<<degre<<endl;
+  Poly p1(0);
+  double c2rl = mydata.PolFit(0,p1,degre);
+  cout<<"C2r_lineaire = "<<c2rl<<endl;
+  if(O.lp>0) cout<<p1<<endl;
+  return;
+
+} else if(func[0]=='P' && ndim==1) {
+  // Fit de 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,O.xc);
+  myfunc = myf;
+
+} else if(func[0]=='e' && ndim==1) {
+  // Fit d'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,O.xc);
+       else    myf = new Exp1DPol(O.xc);
+  myfunc = myf;
+
+} else if(func[0]=='g' && ndim==1) {
+  // Fit de 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,((O.polcx)?true:false));
+       else    myf = new Gauss1DPol(((O.polcx)?true:false));
+  myfunc = myf;
+
+} else if(func[0]=='G' && ndim==1) {
+  // Fit de 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,((O.polcx)?true:false));
+       else    myf = new GaussN1DPol(((O.polcx)?true:false));
+  myfunc = myf;
+
+} else if(func[0]=='p' && ndim==2) {
+  // Fit de polynome 2D sans passer par les GeneralFit
+  int degre = 0;
+  if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
+  cout<<"Fit (lineaire) polynome 2D de degre "<<degre<<endl;
+  Poly2 p2(0);
+  double c2rl = mydata.PolFit(0,1,p2,degre);
+  cout<<"C2r_lineaire = "<<c2rl<<endl;
+  if(O.lp>0) cout<<p2<<endl;
+  return;
+
+} else if(func[0]=='P' && ndim==2) {
+  // Fit de 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,O.xc,O.yc);
+  myfunc = myf;
+
+} else if(func[0]=='G' && ndim==2) {
+  // Fit de 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; myfunc = myf;}
+    else    {GauRho2D* myf = new GauRho2D; myfunc = myf;}
+
+} else if(func[0]=='d' && ndim==2) {
+  // Fit de 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; myfunc = myf;}
+    else    {GdlRho2D* myf = new GdlRho2D; myfunc = myf;}
+
+} else if(func[0]=='D' && ndim==2) {
+  // Fit de 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; myfunc = myf;}
+    else    {Gdl1Rho2D* myf = new Gdl1Rho2D; myfunc = myf;}
+
+} else if(func[0]=='M' && ndim==2) {
+  // Fit de 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; myfunc = myf;}
+    else    {MofRho2D* myf = new MofRho2D; myfunc = myf;}
+
+} else {
+  cout<<"Fonction "<<func<<" inconnue pour la dim "<<ndim<<endl;
+  return;
+}
+
+/////////////////////////
+// Fit avec generalfit //
+/////////////////////////
+if(myfunc->NPar()>Par.NElts())
+  {cout<<"Trop de parametres: "<<myfunc->NPar()<<">"<<Par.NElts()<<endl;
+  if(myfunc) delete myfunc; return;}
+GeneralFit myfit(myfunc);
+myfit.SetDebug(O.lpg);
+myfit.SetData(&mydata);
+myfit.SetStopChi2(O.stc2);
+{for(int i=0;i<myfunc->NPar();i++) {
+  char str[10];
+  sprintf(str,"P%d",i);
+  myfit.SetParam(i,str,Par(i),Step(i),Min(i),Max(i));
+}}
+if(O.lp>1) myfit.PrintFit();
+double c2r = (double) myfit.Fit();
+if(O.lp>0) myfit.PrintFit();
+if(c2r>0.) {
+  c2r = myfit.GetChi2Red();
+  cout<<"C2r_Reduit = "<<c2r<<"  nstep="<<myfit.GetNStep()<<endl;
+  Vector ParFit(myfunc->NPar());
+  for(int i=0;i<myfunc->NPar();i++) ParFit(i)=myfit.GetParm(i);
+} else {
+  cout<<"echec Fit, rc = "<<c2r<<"  nstep="<<myfit.GetNStep()<<endl;
+}
+
+// Mise a disposition des resultats
+if(c2r>=0. && myfunc && (O.okres>0||O.okfun>0)) {
+  string nomres = nom + "res";
+  string nomfun = nom + "fun";
+  if(v) {
+    if(O.okres) {Vector* ob = v->FitResidus(myfit);  if(ob) AddObj(ob,nomres);}
+    if(O.okfun) {Vector* ob = v->FitFunction(myfit); if(ob) AddObj(ob,nomfun);}
+  } else if(h) {
+    if(O.okres) {Histo* ob = h->FitResidus(myfit);  if(ob) AddObj(ob,nomres);}
+    if(O.okfun) {Histo* ob = h->FitFunction(myfit); if(ob) AddObj(ob,nomfun);}
+  } else if(m) {
+    if(O.okres) {Matrix* ob = m->FitResidus(myfit);  if(ob) AddObj(ob,nomres);}
+    if(O.okfun) {Matrix* ob = m->FitFunction(myfit); if(ob) AddObj(ob,nomfun);}
+  } else if(h2) {
+    if(O.okres) {Histo2D* ob = h2->FitResidus(myfit);  if(ob) AddObj(ob,nomres);}
+    if(O.okfun) {Histo2D* ob = h2->FitFunction(myfit); if(ob) AddObj(ob,nomfun);}
+  } else if(im) {
+    if(O.okres) {RzImage* ob = im->FitResidus(myfit);  if(ob) AddObj(ob,nomres);}
+    if(O.okfun) {RzImage* ob = im->FitFunction(myfit); if(ob) AddObj(ob,nomfun);}
+  } else if(g) {
+    if(O.okres) {GeneralFitData* ob = g->FitResidus(myfit);  if(ob) AddObj(ob,nomres);}
+    if(O.okfun) {GeneralFitData* ob = g->FitFunction(myfit); if(ob) AddObj(ob,nomfun);}
+  }
+}
+
+// Nettoyage
+if(myfunc) delete myfunc;
+return;
+}
+
+/* --Methode-- */
+void NamedObjMgr::FFT(string const& nom, string dopt)
+{
+PPersist* obj=GetObj(nom);
+if (obj == NULL) {
+  cout << "NamedObjMgr::FFT() Error , Pas d'objet de nom " << nom << endl; 
+  return;
+}
+if (!myImgApp)  return; 
+
+int cid = obj->ClassId();
+if (cid != ClassId_Vector) { 
+  string ctyp = servnobjm->PClassIdToClassName(cid);
+  cout << "NamedObjMgr::FFT() Error , Objet n'est pas un vecteur " << ctyp << endl; 
+  return;
+  }
+
+FFT1 fft( *((Vector*)obj) );
+
+if (fft.NData() < 1)  return;
+
+char* ntn[3] = {"refc", "imfc", "pfc"};
+NTuple* nt = new NTuple(3,ntn);  // Creation NTuple 
+Vector* vf = new Vector(fft.NData()/2);
+
+float xnt[3]; 
+double pf;
+for(int k=0; k<fft.NData()/2; k++) {
+  xnt[0] = fft.ReF(k);  xnt[1] = fft.ImF(k); 
+  pf = (xnt[0]*xnt[0]+xnt[1]*xnt[1]);
+  if (pf >= 0.)  pf = sqrt(pf);  
+  xnt[2] = pf;   (*vf)(k) = pf;
+  nt->Fill(xnt);  
+  }
+
+P1DArrayAdapter* vya = new POVectorAdapter(vf, true);
+// vya->DefineXCoordinate(xmin, xmax);   a determiner
+PIYfXDrawer* dr = new   PIYfXDrawer(vya, NULL, true) ; 
+bool fgsr = true;
+dopt = "thinline," + dopt;
+int opt = servnobjm->DecodeDispOption(dopt, fgsr);
+myImgApp->DispScDrawer(dr, nom, opt);
+if (fgsr) myImgApp->RestoreGraphicAtt(); 
+
+return;
+}
Index: /trunk/SophyaPI/PIext/nobjmgr.h
===================================================================
--- /trunk/SophyaPI/PIext/nobjmgr.h	(revision 165)
+++ /trunk/SophyaPI/PIext/nobjmgr.h	(revision 165)
@@ -0,0 +1,98 @@
+// 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 "ppersist.h"
+#include "dlftypes.h"
+
+class PIStdImgApp;
+class Services2NObjMgr;
+
+class NamedObjMgr {
+public:
+			NamedObjMgr();
+  virtual		~NamedObjMgr();
+
+  virtual void 		SetImgApp(PIStdImgApp* app);
+
+
+//  Pour ajouter, supprimer et acceder aux objets PPersist
+  virtual void		AddObj(PPersist* obj, string& nom);
+  virtual void          DelObj(string const& nom, bool fgd=true);
+  virtual void		DelObjects(string const& patt, bool fgd=true); 
+  virtual PPersist*	GetObj(string const& nom);
+  virtual void		RenameObj(string const& nom, string& nomnew);
+  virtual string        LastObjName();  // Renvoie le nom du dernier objet ajoute
+
+//  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 const& nom, POutPersist& s);
+  virtual void          SaveAll(string const& nomppf);
+  virtual void          SaveFits(string const& nom, string const & flnm);
+
+// Info sur les objets 
+  virtual void          ListObjs();  		
+  virtual void          PrintObj(string const& nom);
+
+//  Affichage des objets 
+  virtual void          DisplayObj(string const& nom, string dopt="");
+  virtual void          DisplaySurf3D(string const& nom, string dopt="");
+  virtual void          DisplayNT(string const& nom, string& nmx, string& nmy, string& nmz,  
+                                  string& erx, string& ery, string& erz, string dopt="");
+  virtual void          DisplayGFD(string const& nom, string& numvarx, string& numvary, string& err, string dopt="");
+// virtual void          DisplayImage(string const& nom, string dopt=""); C'est necessaire ??
+
+  virtual void		SetGraphicAttributes(string gratt="");
+  virtual void		SetGraphicWinZone(int nzx, int nzy, bool fcr=false);
+
+
+//  Trace d'expression de NTuple, et d'autres objets
+  virtual void          DisplayPoints2D(string const& nom, string& expx, string& expy,
+                                        string& experrx, string& experry, 
+                                        string& expcut, string dopt="");
+  virtual void          DisplayPoints3D(string const& nom, string& expx, string& expy, string& expz, 
+                                        string& expcut, string dopt="");
+//  Projection d'expressions dans histogramme (et trace) 
+  virtual void          ProjectH1(string const& nom, string& expx, string& expwt, string& expcut, 
+                                  string& nomh1, string dopt="");
+  virtual void          ProjectH2(string const& nom, string& expx, string& expy, string& expwt, 
+                                  string& expcut, string& nomh2, string dopt="");
+  virtual void          ProjectHProf(string const& nom, string& expx, string& expy, string& expwt, 
+                                  string& expcut, string& nomprof, string dopt="");
+//  Projection d'expression dans vecteurs et dans n-tuple
+  virtual void          FillVect(string const& nom, string& expx, string& expcut, 
+                                 string& nomvec, string dopt="");
+  virtual void          FillNT(string const& nom, string& expx, string& expy, string& expz,
+                               string& expt, string& expcut, string& nomnt); 
+  virtual void          FillGFD(string const& nom, string& expx, string& expy, string& expz,
+                               string& experr, string& expcut, string& nomgfd);
+
+// Trace de fonctions 1-D , 2-D
+  virtual void          PlotFunc(string& expfunc, float xmin, float xmax, int np=100, string dopt="");
+  virtual void          PlotFunc2D(string& expfunc, float xmin, float xmax, float ymin, float ymax, 
+                                   int npx=50, int npy=50, string dopt="");
+  virtual void          PlotFunc(DlFunctionOfX f, float xmin, float xmax, int np=100, string dopt="");
+  virtual void          PlotFunc2D(DlFunctionOfXY f, float xmin, float xmax, float ymin, float ymax, 
+                                   int npx=50, int npy=50, string dopt="");
+
+//   Methodes de fit, a rajouter  (pour CMV , deux methodes H1 H2 ou 1 seule ??) ...
+  virtual void          Fit12D(string const& nom, string& func,
+                              string par,string step,string min,string max,string opt);
+
+//   Calcul de la transforme de Fourier - A titre d'exemple
+  virtual void          FFT(string const& nom, string dopt);   
+
+// Acces au PIApplication et a la classe de service 
+  virtual PIStdImgApp*		GetImgApp();
+  virtual Services2NObjMgr* 	GetServiceObj();
+};
+
+
+#endif
Index: /trunk/SophyaPI/PIext/nomapstr.h
===================================================================
--- /trunk/SophyaPI/PIext/nomapstr.h	(revision 165)
+++ /trunk/SophyaPI/PIext/nomapstr.h	(revision 165)
@@ -0,0 +1,23 @@
+// Include file prive pour NamedObjMgr (nobmgr.cc)
+// LAL-IN2P3/CNRS         DAPNIA-CEA
+//      Reza    Aout 97
+
+#ifndef NOMAPSTR_H_SEEN
+#define NOMAPSTR_H_SEEN
+
+#include <string>
+#include <map>
+
+#include "ppersist.h"
+
+struct nobj_item {
+  PPersist* obj;
+  int num;
+  list<int> wrsid;
+  bool operator==(nobj_item const& b) const         
+    { return (this->obj ==  b.obj); } 
+};
+
+typedef map<string, nobj_item, less<string> > NObjList;
+
+#endif
Index: /trunk/SophyaPI/PIext/piacmd.cc
===================================================================
--- /trunk/SophyaPI/PIext/piacmd.cc	(revision 165)
+++ /trunk/SophyaPI/PIext/piacmd.cc	(revision 165)
@@ -0,0 +1,1070 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include <dlfcn.h>
+
+#include <iostream.h>
+#include <string>
+#include <vector>
+#include <map>
+#if defined(__KCC__)
+using std::string ;
+#include <vector.h>
+#include <map.h>
+#endif
+
+#include "ctimer.h"
+
+#include "nobjmgr.h"
+#include "piacmd.h"
+#include "pistdimgapp.h"
+
+#include "histos.h"
+#include "histos2.h"
+#include "hisprof.h"
+#include "ntuple.h"
+#include "generaldata.h"
+
+
+//  Pour le decoupage des commandes en lignes 
+typedef vector<string> cmdtok;
+
+//  Fonction pour faire le Fit de PSF sur image   
+static int FitPSFImg(cmdtok& tokens);
+static int Photom_Ouv(cmdtok& tokens);
+
+
+/* --Methode-- */
+PIACmd::PIACmd(NamedObjMgr* omg, PIStdImgApp* app)
+{
+if (omg)  { mOmg= false; mObjMgr = omg; }
+else { mObjMgr = new NamedObjMgr;  mOmg = true; }
+mImgApp = app;
+char* varenv;
+TmpDir = "";
+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 += '/';
+system("cp history.pic hisold.pic");
+hist.open("history.pic");
+trace = false;   timing = false;
+gltimer = NULL;
+dlhandle = NULL;
+}
+
+/* --Methode-- */
+PIACmd::~PIACmd()
+{
+if (mOmg)  delete mObjMgr;
+hist.close();
+if (gltimer) { delete gltimer;  gltimer = NULL; }
+}
+
+/* --Methode-- */
+int PIACmd::Exec(string& file)
+{
+char line_buff[512];
+FILE *fip;
+
+if ( (fip = fopen(file.c_str(),"r")) == 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;
+if (trace) { 
+  mImgApp->GetConsole()->AddStr("### Executing commands from ", PIVA_Magenta);
+  mImgApp->GetConsole()->AddStr(file.c_str(), PIVA_Magenta);
+  mImgApp->GetConsole()->AddStr("\n", PIVA_Magenta);
+  }
+
+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);
+  Do(line);
+  }
+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);
+}
+
+/* --Methode-- */
+int PIACmd::Do(string& s)
+{
+
+cmdtok tokens;
+if (s.length() < 1)  return(0);
+
+hist << s << endl;   // On enregistre les commandes 
+
+if (s[0] == '#') {
+  cout << "PIACmd::Do() Comment-Line:" << s << endl;
+  return(0); 
+  } 
+string toks,kw;
+size_t p = s.find_first_not_of(" ");
+s = s.substr(p);
+p = 0;
+size_t q = s.find_first_of(" ");
+size_t l = s.length();
+
+if (q < l)
+  {  kw = s.substr(p,q-p);  toks = s.substr(q, l-q); }
+else { kw = s.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);
+  }
+
+for(int k=0; k<tokens.size(); k++) { // On remplace les $varname par la valeur de la variable
+ if ((tokens[k])[0] != '$')  continue; 
+ CmdVarList::iterator it = mVars.find(tokens[k].substr(1));
+ if (it != mVars.end())  tokens[k] = (*it).second;
+}
+
+// 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
+if (kw == "help") {
+  cout << "\n PIACmd::Do() ----- Help : Liste des commandes ------------ \n";
+  cout << "help  shelp  exec  set  listvars  traceon  traceoff \n"; 
+  cout << "timingon  timingoff  shell \n"; 
+  cout << "link  call    zone  gratt  stacknext \n" ;
+  cout << "openfits  openppf  saveall  listobjs \n"; 
+  cout << "print rename  del delobjs \n";
+  cout << "newh1d  newh2d  newprof newgfd func  func2d \n" ; 
+  cout << "disp  surf  nt2d  nt3d  gfd2d  gfd3d \n" ;
+  cout << "plot2d plot3d  projh1d  projh2d  projprof \n";  
+  cout << "fillvec  fillnt fillgd1 fillgd2  fft fit fitpsf aper\n";
+  cout << "*** Commande sans args -> liste d'arguments\n";
+  cout << "*** dopt: DisplayOption = next/same/win/stack,color,... \n";
+  cout << "*** $varname remplace par la valeur de la variable varname\n" << endl; 
+  }
+
+else if (kw == "shelp" )   {
+  cout << "\n PIACmd::Do() ------------- SHelp ------------ " << endl;
+  cout << "exec filename   --   set varname string  --  clr varname  --  listvars \n"; 
+  cout << "traceon/off  --  timingon/off  --  shell cmdline\n";
+  cout << "link fnameso f1 [f2 f3 f4 f5]  --   call userf [arg1 arg2 ...]\n";
+  cout << "zone nx ny  --  gratt attributes_list  --  stacknext \n";
+  cout << "openfits file -- openppf file -- saveall file -- listobjs --\n";
+  cout << "print nomobj -- rename nomobj nomnew -- del nomobj -- delobjs pattern (*,?) \n";
+  cout << "newh1d nomh xmin xmax nbin  --  newh2d nomh xmin xmax nbinx ymin ymax nbiny\n";
+  cout << "newprof nomh xmin xmax nbin [ymin ymax] \n";
+  cout << "newgfd nomgfd nvar nalloc [errx(0/1)]\n";
+  cout << "func expfunc xmin xmax npt opt\n";
+  cout << "func2d expfunc xmin xmax nptx ymin ymax npty opt\n";
+  cout << "disp nomobj opt  --  surf nomobj opt\n";
+  cout << "nt2d nomobj varx vary errx erry opt\n";
+  cout << "nt3d nomobj varx vary varz errx erry errz dopt\n";
+  cout << "gfd2d nomobj numvarx erreur=(x y xy) opt\n";
+  cout << "gfd3d nomobj numvarx numvary erreur=(x y z xy xz yz xyz) opt\n";
+  cout << "plot2d nomobj expx expy [experrx experry] expcut  dopt\n";
+  cout << "plot3d nomobj expx expy expz expcut dopt\n";
+  cout << "projh1d nomobj expx expwt expcut nomh1 dopt\n";
+  cout << "projh2d nomobj expx expy expwt expcut nomh2 dopt\n";
+  cout << "projprof nomobj expx expy expwt expcut nomprof dopt\n";
+  cout << "fillnt nomobj expx expy expz expt  expcut nomnt dopt\n";
+  cout << "fillvec nomobj expx expcut nomvec dopt\n";
+  cout << "fillgd1 nomobj expx expy experry expcut nomgfd\n";
+  cout << "fillgd2 nomobj expx expy expz experrz expcut nomgfd\n";
+  cout << "fft nomobj dopt\n";
+  cout << "fit nomobj func [p:p1,.,pn s:s1,.,sn m:m1,.,mn M:M1,.,Mn I:i1,i2 o:... o:...]\n";
+  cout << "fitpsf psf_typ [options_fit]\n";
+  cout << "aper fond_typ [options_calcul]\n";
+}
+
+else if (kw == "set") {
+  if (tokens.size() < 2) { cout << "PIACmd::Do() Usage: set varname string" << endl;  return(0); }
+  mVars[tokens[0]] = tokens[1];
+  }
+else if (kw == "clr") {
+  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: clr varname" << endl;  return(0); }
+  CmdVarList::iterator it = mVars.find(tokens[0]);
+  if (it != mVars.end())  mVars.erase(it);
+  else cerr << "PIACmd::Do() Pas de variable de nom " << tokens[0] << endl;
+  }
+else if (kw == "listvars") {
+  cout << "PIACmd::Do()  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 == "traceon")  { cout << "PIACmd::Do()  -> Trace ON mode " << endl; trace = true; }
+else if (kw == "traceoff") { cout << "PIACmd::Do()  -> Trace OFF mode " << endl; trace = false; }
+else if (kw == "timingon") { 
+  cout << "PIACmd::Do()  -> Timing ON mode " << endl; 
+  if (gltimer)   delete gltimer;   gltimer = new Timer("PIA-CmdInterpreter ");   timing = true; }
+else if (kw == "timingoff") { 
+  cout << "PIACmd::Do()  -> Timing OFF mode " << endl; 
+  if (gltimer)  delete gltimer;  gltimer = NULL;  timing = false; }
+else if (kw == "exec") {
+  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: exec filename" << endl;  return(0); }
+  Exec(tokens[0]);
+  }
+else if (kw == "shell") {
+  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: shell cmdline" << endl;  return(0); }
+  system(toks.c_str());
+  }
+
+// >>>>>>>>>>> Fenetre graphique , changement d'attributs graphiques 
+else if (kw == "zone") {
+  if (tokens.size() < 2) { cout << "PIACmd::Do() Usage: zone 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);
+  }  
+else if (kw == "gratt") {
+  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: gratt attributes_list (att=def->defaut)" << endl;  return(0); }
+  mObjMgr->SetGraphicAttributes(tokens[0]); 
+  }
+else if (kw == "stacknext") mImgApp->StackWinNext(); 
+
+// >>>>>>>>>>> Link dynamique de fonctions C++
+else if (kw == "link" ) {
+  if (tokens.size() < 2) { cout << "PIACmd::Do() Usage: link fnameso f1 [f2 f3 f4 f5]" << endl;  return(0); }
+  string sph = "";
+  for(int gg=0; gg<4; gg++)   tokens.push_back(sph);
+  int rc = LinkUserFuncs(tokens[0], tokens[1], tokens[2], tokens[3], tokens[4], tokens[5]);
+  if (rc == 0)  cout << "PIAcmd::Do(): Link from " << tokens[0] << " OK " << endl;
+}
+else if (kw == "call" ) {
+  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: call userf [arg1 arg2 ...]" << endl;  return(0); }
+  UsFmap::iterator it = usfmap.find(tokens[0]);
+  if (it == usfmap.end()) {
+    cerr << "PIAcmd::Do() No User Function " << tokens[0] << endl;
+    return(0);
+  }
+  cout << "PIAcmd::Do() 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;
+  TRY {
+    tokens.erase(tokens.begin());
+    fuf(tokens);
+  }  CATCH(merr) {
+    fflush(stdout); 
+    cout << endl; 
+    cerr << endl;
+    string es = PeidaExc(merr);
+    cerr << "PIACmd::Do() Call UserFunc  Exception :" << merr << es;
+    }
+}
+
+// >>>>>>>>>>> lecture/ecriture des objets, gestion des objets 
+else if (kw == "openfits" ) {
+  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: openfits file " << endl;  return(0); }
+  else mObjMgr->ReadFits(tokens[0]);
+}
+else if (kw == "openppf" ) {
+  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: openppf file " << endl; return(0); }
+  mObjMgr->ReadAll(tokens[0]);  
+}
+else if (kw == "saveall" ) {
+  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: saveall file " << endl; return(0); }
+  mObjMgr->SaveAll(tokens[0]);  
+}
+else if (kw == "print" ) {
+  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: print nomobj " << endl; return(0); }
+  mObjMgr->PrintObj(tokens[0]);  
+}
+else if (kw == "rename" ) {
+  if (tokens.size() < 2) { cout << "PIACmd::Do() Usage: rename nomobj nomnew" << endl; return(0); }
+  mObjMgr->RenameObj(tokens[0], tokens[1]);  
+}
+else if (kw == "del" ) {
+  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: del nomobj " << endl; return(0); }
+  mObjMgr->DelObj(tokens[0]);  
+}
+else if (kw == "delobjs" ) {
+  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: delobjs nomobjpattern (*,?) " << endl; return(0); }
+  mObjMgr->DelObjects(tokens[0]);  
+}
+else if (kw == "listobjs")   mObjMgr->ListObjs();
+
+// >>>>>>>>>>> Creation d'histos 1D-2D
+else if (kw == "newh1d") {
+  if (tokens.size() < 4) { cout << "PIACmd::Do() Usage: newh1d nom 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 << "PIACmd::Do() Usage:newh2d nomh 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 << "PIACmd::Do() Usage: newprof nom 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]);
+  }
+else if (kw == "newgfd") {
+  if (tokens.size() < 3)
+    { cout << "PIACmd::Do() 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]);
+    }
+  }
+
+// >>>>>>>>>>>  Affichage des objets 
+else if ( (kw == "disp") || (kw == "surf") ) {
+  if (tokens.size() < 1) { cout << "PIACmd::Do() Usage: disp nomobj 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 == "nt2d") {
+  if (tokens.size() < 5) { cout << "PIACmd::Do() Usage: nt2d nomobj 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 == "nt3d") {
+  if (tokens.size() < 7) { cout << "PIACmd::Do() Usage: nt3d nomobj 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);
+  }
+
+else if (kw == "gfd2d") {
+  if(tokens.size()<2)
+    {cout<<"PIACmd::Do() 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") {
+  if(tokens.size()<3)
+    {cout<<"PIACmd::Do() Usage: gfd3d nomobj 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 << "PIACmd::Do() Usage: func expr xmin xmax npt opt" << endl; return(0); }
+  string opt = "n";
+  if (tokens.size() > 4)  opt = tokens[4];
+  int np;
+  float 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());
+  mObjMgr->PlotFunc(tokens[0], xmin, xmax, np, opt); 
+  }
+else if ( (kw == "func2d") ) {
+  if (tokens.size() < 7) {
+    cout << "PIACmd::Do() Usage: func2d expr xmin xmax nptx ymin ymax npty opt" << endl;
+    return(0);
+    }
+  int npx, npy;
+  float xmin, xmax;
+  float 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 = "n";
+  if (tokens.size() > 7)  opt = tokens[7];
+  mObjMgr->PlotFunc2D(tokens[0], xmin, xmax, ymin, ymax, npx, npy, opt);
+  }
+
+// >>>>>>>>>>>  Trace d'expressions de N_Tuple, StarList, etc ...
+else if (kw == "plot2d" ) {
+  if (tokens.size() < 4) {
+    cout << "PIACmd::Do() Usage: plot2d nomobj expx expy [experrx experry] expcut opt" << endl;
+    return(0); 
+    }
+  string errx = ""; string erry = ""; string ecut = "1";
+  string opt = "n";
+  if (tokens.size() < 6) { // Plot sans les erreurs
+    ecut = tokens[3];
+    if (tokens.size() > 4)  opt = tokens[4];
+    }
+  else {                 // Plot avec les erreurs
+    errx = tokens[3]; erry = tokens[4]; ecut = tokens[5];
+    if (tokens.size() > 6)  opt = tokens[6];
+    }
+  mObjMgr->DisplayPoints2D(tokens[0],tokens[1],tokens[2],errx,erry,ecut,opt);
+  }
+
+else if (kw == "plot3d" ) {
+  if (tokens.size() < 5) { 
+    cout << "PIACmd::Do() Usage: plot3d nomobj expx expy expz expcut opt" << endl;
+    return(0); 
+    }
+  string opt = "n";
+  if (tokens.size() > 5)  opt = tokens[5];
+  mObjMgr->DisplayPoints3D(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], opt);
+  }
+
+else if (kw == "projh1d" ) {
+  if (tokens.size() < 5) { 
+    cout << "PIACmd::Do() Usage: projh1d nomobj expx expwt expcut nomh1 opt" << endl;
+    return(0);
+    }
+  string opt = "n";
+  if (tokens.size() > 5)  opt = tokens[5];
+  mObjMgr->ProjectH1(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], opt);
+  }
+
+else if (kw == "projh2d" ) {
+  if (tokens.size() < 6) { 
+    cout << "PIACmd::Do() Usage: projh2 nomobj expx expy expwt expcut nomh2 opt" << endl;
+    return(0);
+    }
+  string opt = "n";
+  if (tokens.size() > 6)  opt = tokens[6];
+
+  mObjMgr->ProjectH2(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], opt);
+  }
+
+else if (kw == "projprof" ) {
+  if (tokens.size() < 6) { 
+    cout << "PIACmd::Do() Usage: projprof nomobj expx expy expwt expcut nomprof opt" << endl;
+    return(0);
+    }
+  string opt = "n";
+  if (tokens.size() > 6)  opt = tokens[6];
+
+  mObjMgr->ProjectHProf(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], opt);
+  }
+
+else if (kw == "fillnt" ) {
+  if (tokens.size() < 7) { 
+    cout << "PIACmd::Do() Usage: fillnt nomobj expx expy expz expt expcut nomnt" << endl;
+    return(0);
+    }
+  mObjMgr->FillNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], tokens[6] );
+  }
+
+else if (kw == "fillvec" ) {
+  if (tokens.size() < 4) { 
+    cout << "PIACmd::Do() Usage: fillvec nomobj expx expcut nomvec opt" << endl;
+    return(0);
+    }
+  string opt = "n";
+  if (tokens.size() > 4)  opt = tokens[4];
+  mObjMgr->FillVect(tokens[0],tokens[1],tokens[2], tokens[3], opt);
+  }
+
+else if (kw == "fillgd1" ) {
+  if (tokens.size() < 5) {
+    cout << "PIACmd::Do() Usage: fillgd1 nomobj expx expy experry expcut nomgfd" << endl;
+    return(0);
+    }
+  string nomgfd = "";
+  if (tokens.size() > 5) nomgfd = tokens[5];
+  string expy = "";
+  mObjMgr->FillGFD(tokens[0],tokens[1], expy, tokens[2], tokens[3], tokens[4],nomgfd);
+  }
+
+else if (kw == "fillgd2" ) {
+  if (tokens.size() < 6) {
+    cout << "PIACmd::Do() Usage: fillgd2 nomobj expx expy expz experrz expcut nomgfd" << endl;
+    return(0);
+    }
+  string nomgfd = "";
+  if (tokens.size() > 6) nomgfd = tokens[6];
+  mObjMgr->FillGFD(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5],nomgfd);
+  }
+
+// Calcul TF 
+else if (kw == "fft" ) {
+  if (tokens.size() < 1) { 
+    cout << "PIACmd::Do() Usage: fft nomobj opt" << endl;
+    return(0);
+    }
+  string opt = "n";
+  if (tokens.size() > 1)  opt = tokens[1];
+  mObjMgr->FFT(tokens[0], opt);
+  }
+
+// Fit 1D sur objets 1D. Egalement Fit 2D sur objets 2D.
+else if (kw == "fit") {
+  if (tokens.size() < 2) {
+    cout <<"PIACmd::Do() Usage:fit nomobj func \n"
+         <<" [p:p1,...,pn s:s1,...,sn m:m1,...,mn M:M1,...,Mn o:... o:...]\n";
+    return(0);
+  }
+  string p=""; string s=""; string m=""; string M=""; string O="";
+  if (tokens.size()>2)
+    for(int ip=2;ip<tokens.size();ip++) {
+      if(tokens[ip].length()<=2) continue;
+      const char *c = tokens[ip].c_str();
+      if(c[1]!=':') continue;
+      if(c[0]=='p')      p=c+2;
+      else if(c[0]=='s') s=c+2;
+      else if(c[0]=='m') m=c+2;
+      else if(c[0]=='M') M=c+2;
+      else if(c[0]=='o') {O += ","; O += c+2;}
+    }
+  mObjMgr->Fit12D(tokens[0],tokens[1],p,s,m,M,O);
+}
+
+#ifndef SANS_StarReco 
+// FITPSF sur image
+else if (kw == "fitpsf" ) {
+  if (tokens.size() < 1) { 
+    cout << "PIACmd::Do() Usage: fitpsf psf_typ [options_fit]" << endl;
+    return(0);
+    }
+  FitPSFImg(tokens);
+  }
+
+// Photometrie d'ouvertue sur image 
+else if (kw == "aper" ) {
+  if (tokens.size() < 1) { 
+    cout << "PIACmd::Do() Usage: aper fond_typ [options_calcul]" << endl;
+    return(0);
+    }
+  Photom_Ouv(tokens);
+  }
+#endif
+
+else  { 
+  cerr << "PIACmd::Do() Erreur - Commande " << kw << " inconuue ! " << endl;    
+  return(-1);
+  }
+if (timing)  gltimer->Split();
+
+return(0);
+}
+
+
+
+/* --Methode-- */
+int PIACmd::LinkUserFuncs(string& fnameso, string& func1, string& func2, string& func3, 
+                          string& func4, string& func5)
+{
+string fnamesol = TmpDir + "spiup.so"; 
+string cmd;
+int rc;
+
+if (dlhandle) dlclose(dlhandle);    dlhandle = NULL;
+usfmap.clear();
+cmd = "cp " + fnameso + " " + fnamesol;
+rc = system(cmd.c_str());
+if (rc != 0)  { cerr << "PIACmd::LinkUserFuncs() Error system(" << cmd << ") Rc= " << rc << endl; return(1); }
+
+dlhandle =  dlopen(fnamesol.c_str(), RTLD_NOW);
+if (dlhandle == NULL) { 
+  string sn = fnamesol; 
+  cerr << "PIACmd/LinkUserFuncs_Erreur: Erreur ouverture SO " << sn << endl; 
+  sn = dlerror();
+  cerr << "Loader Error (dlerror()) :" << sn;
+  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 = (DlFunction)  dlsym(dlhandle, func1.c_str());
+if (f) { nok++;  usfmap[func1] = f; }
+else cerr << "PIACmd/LinkUserFuncs_Erreur: Erreur linking " << func1 << endl;
+
+if ((func2.length() < 1) || (func2 == "-") || (func2 == ".") )  goto fin;
+// f = (DlUserProcFunction)  dlsym(dlhandle, func2.c_str());
+f = (DlFunction)  dlsym(dlhandle, func2.c_str());
+if (f) { nok++;  usfmap[func2] = f; }
+else cerr << "PIACmd/LinkUserFuncs_Erreur: Erreur linking " << func2 << endl;
+
+if ((func3.length() < 1) || (func3 == "-") || (func3 == ".") )  goto fin;
+// f = (DlUserProcFunction)  dlsym(dlhandle, func3.c_str());
+f = (DlFunction)  dlsym(dlhandle, func3.c_str());
+if (f) { nok++;  usfmap[func3] = f; }
+else cerr << "PIACmd/LinkUserFuncs_Erreur: Erreur linking " << func3 << endl;
+
+if ((func4.length() < 1) || (func4 == "-") || (func4 == ".") )  goto fin;
+// f = (DlUserProcFunction)  dlsym(dlhandle, func4.c_str());
+f = (DlFunction)  dlsym(dlhandle, func4.c_str());
+if (f) { nok++;  usfmap[func4] = f; }
+else cerr << "PIACmd/LinkUserFuncs_Erreur: Erreur linking " << func4 << endl;
+
+if ((func5.length() < 1) || (func5 == "-") || (func5 == ".") )  goto fin;
+// f = (DlUserProcFunction)  dlsym(dlhandle, func5.c_str());
+f = (DlFunction)  dlsym(dlhandle, func5.c_str());
+if (f) { nok++;  usfmap[func5] = f; }
+else cerr << "PIACmd/LinkUserFuncs_Erreur: Erreur linking " << func5 << endl;
+
+fin:
+if (nok < 1) { dlclose(dlhandle);    dlhandle = NULL; return(3); }
+else return(0);
+}
+
+/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
+/////////////////////////////// Fonctions ///////////////////////////////
+/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
+#ifndef SANS_StarReco 
+# include "psf.h"
+#include "dynccd.h"
+#include "pimgadapter.h"
+#include "nbmath.h"
+#include "nbtri.h"
+
+/* Nouvelle-Fonction    rz + cmv 15/10/98 */
+int FitPSFImg(cmdtok& tokens)
+//	Fit de PSF sur une Image.
+//| tokens[0] = Type de PSF ()
+//|      : G   = fit gaussienne+fond (volume)
+//|      : Gi  = fit gaussienne+fond integree (volume)
+//|      : d   = fit DL de gaussienne+fond (volume)
+//|      : di  = fit DL de gaussienne+fond integree (volume)
+//|      : D   = fit DL de gaussienne+fond avec coeff variable p6 (volume)
+//|      : Di  = fit DL de gaussienne+fond integree avec coeff variable p6 (volume)
+//|      : M   = fit Moffat+fond (expos=p6) (volume)
+//|      : Mi  = fit Moffat+fond integree (expos=p6) (volume)
+//| tokens[1] = options pour le fit ex: l1.0,G2.,R7.,m10.,M65000.,P3.,f,n,r,i,w10/450
+//|      : r = ecriture de l'image des residus (def=non)
+//|      : f = ecriture de l'image de de la PSF fitee (def=non)
+//|      : i = ecriture du pave initial selectionne pour le fit (def=non)
+//|      : n = ecriture de l'image du bruit (def=non)
+//|      : Gaa.bbb = gain en e-/ADU (def=1)
+//|      : Raa.bbb = readout noise en e- (def=0)
+//|      : maa.bbb = limite basse dynamique en ADU (def=-9.e19)
+//|      : Maa.bbb = limite haute dynamique en ADU (def=9.e19)
+//|      : Paa.bbb = valeur du parametre supplementaire pour 
+//|      : la.a = print a=FitPSFImg, b=PSF.Fit PSF.IniFit
+//|      : wa/b = "a" est le facteur de zoom de la fenetre de representation
+//|               des resultats (def=6) et b sa taille maximale (def=500).
+//| Return: 0 si Ok, <0 sinon.
+{
+// Decodage des arguments
+if(tokens.size()<1) return(-1);
+int typ_psf=PSF::psfGaussienne;
+bool wres=false, wpsf=false, wpav=false, wnois=false;
+float gain=1., readout=0., pixmin=-9.e19, pixmax=9.e19;
+int zoom=6, wmax=500;
+float par6=-1.;
+int lp=1, lpg=0;
+string dummy,dum;
+
+if(tokens.size()>=2) {
+  dummy = "," + tokens[1]+ ",";
+  if(strstr(dummy.c_str(),",r,")) wres=true;
+  if(strstr(dummy.c_str(),",f,")) wpsf=true;
+  if(strstr(dummy.c_str(),",i"))  wpav=true;
+  if(strstr(dummy.c_str(),",n"))  wnois=true;
+  if(strstr(dummy.c_str(),",G")) {
+    size_t p = dummy.find(",G"); size_t q = dummy.find_first_of(',',p+1);
+    dum = dummy.substr(p,q-p);
+    if(dum.length()>2) sscanf(dum.c_str(),",G%f",&gain);
+  }
+  if(strstr(dummy.c_str(),",P")) {
+    size_t p = dummy.find(",P"); size_t q = dummy.find_first_of(',',p+1);
+    dum = dummy.substr(p,q-p);
+    if(dum.length()>2) sscanf(dum.c_str(),",P%f",&par6);
+  }
+  if(strstr(dummy.c_str(),",R")) {
+    size_t p = dummy.find(",R"); size_t q = dummy.find_first_of(',',p+1);
+    dum = dummy.substr(p,q-p);
+    if(dum.length()>2) sscanf(dum.c_str(),",R%f",&readout);
+  }
+  if(strstr(dummy.c_str(),",m")) {
+    size_t p = dummy.find(",m"); size_t q = dummy.find_first_of(',',p+1);
+    dum = dummy.substr(p,q-p);
+    if(dum.length()>2) sscanf(dum.c_str(),",m%f",&pixmin);
+  }
+  if(strstr(dummy.c_str(),",M")) {
+    size_t p = dummy.find(",M"); size_t q = dummy.find_first_of(',',p+1);
+    dum = dummy.substr(p,q-p);
+    if(dum.length()>2) sscanf(dum.c_str(),",M%f",&pixmax);
+  }
+  if(strstr(dummy.c_str(),",l")) { // niveau de print
+    size_t p = dummy.find(",l"); size_t q = dummy.find_first_of(',',p+1);
+    dum = dummy.substr(p,q-p);
+    float ab;
+    if(dum.length()>2) sscanf(dum.c_str(),",l%f",&ab);
+    if(ab<0) ab = 0.;
+    lp = (int) ab; lpg = (int) 10.*(ab-lp);
+  }
+  if(strstr(dummy.c_str(),",w")) { // niveau de print
+    size_t p = dummy.find(",w"); size_t q = dummy.find_first_of(',',p+1);
+    dum = dummy.substr(p,q-p);
+    if(dum.length()>2) sscanf(dum.c_str(),",w%d/%d",&zoom,&wmax);
+  }
+}
+
+dummy = "," + tokens[0]+ ",";
+if(strstr(dummy.c_str(),",G,"))        typ_psf=PSF::psfGaussienne;
+else if(strstr(dummy.c_str(),",Gi,"))  typ_psf=PSF::psfGaussInteg;
+else if(strstr(dummy.c_str(),",d,") )  typ_psf=PSF::psfDelGaussienne;
+else if(strstr(dummy.c_str(),",di,"))  typ_psf=PSF::psfDelGaussinteg;
+else if(strstr(dummy.c_str(),",D,") ) {typ_psf=PSF::psfDel1Gaussienne; if(par6<=0.) par6=1.;}
+else if(strstr(dummy.c_str(),",Di,")) {typ_psf=PSF::psfDel1GaussInteg; if(par6<=0.) par6=1.;}
+else if(strstr(dummy.c_str(),",M,") ) {typ_psf=PSF::psfMoffat;         if(par6<=1.) par6=2.5;}
+else if(strstr(dummy.c_str(),",Mi,")) {typ_psf=PSF::psfMoffInteg;      if(par6<=1.) par6=2.5;}
+
+if(gain<=0.) gain=1.; if(readout<0.) readout=0.;
+if(zoom<1) zoom=1; if(zoom>10) zoom=10; // Il semble que le zoom soit limite a 10 !!!
+if(wmax>500) wmax=500;
+if(lp<0) lp=1; if(lpg<0) lpg=0;
+
+// Wigdet,piimage et image courants
+NamedObjMgr omg;
+PIStdImgApp* app = omg.GetImgApp();
+if(app == NULL)
+  {cout<<"Pas de PIStdImgApp*"<<endl; return(-2);}
+PIBaseWdg* curw= app->CurrentBaseWdg() ;
+if(curw == NULL)
+  {cout<<"Pas de PIBaseWdg*"<<endl; return(-3);}
+if(curw->kind() != PIImage::ClassId)
+  {cout<<"Current window not an Image"<<endl; return(-4);}
+PIImage* curpimg = (PIImage*)curw;
+if(curpimg == NULL)
+  {cout<<"Pas de PIImage*"<<endl; return(-5);}
+P2DArrayAdapter* img = curpimg->Image();
+if(img == NULL)
+  {cout<<"Pas de Image*"<<endl; return(-6);}
+string nom = "fitpsf_";
+
+// Definition du pave courant sur la piimage
+int dx = curpimg->XSzPave(), dy = curpimg->YSzPave();  
+int x0 = curpimg->XPave()-dx/2, y0 = curpimg->YPave()-dy/2;
+if(x0<0) x0 = 0; if(y0<0) y0 = 0;
+int x1 = x0+dx, y1 = y0+dy;
+if(x1>img->XSize()) x1=img->XSize(); if(y1>img->YSize()) y1=img->YSize();
+dx = x1-x0;  dy = y1-y0;
+int dxy = (dx>dy)?dx:dy;
+ImageR4* pav = new ImageR4(dx, dy); 
+{for(int j=0;j<dy;j++) for(int i=0;i<dx;i++) (*pav)(i,j)=(*img)(i+x0,j+y0);}
+
+// Bruit sur le pave
+DynCCD mdynccd(kPhotonNoise,pixmin,pixmax,gain,readout);
+ImageR4 *nois = NoiseImage(pav, &mdynccd);
+
+// Print
+int w=2*zoom*dxy+25; if(w>wmax){w=wmax;zoom=(wmax-25)/(2*dxy);if(zoom<1)zoom=1;}
+if(lp>1)
+  {cout<<"FitPSFImg: fun="<<tokens[0]<<","<<typ_psf
+       <<"  Write res="<<wres<<" psf="<<wpsf<<" pav="<<wpav<<" nois="<<wnois
+       <<"  Par6="<<par6<<"  lp="<<lp<<","<<lpg<<endl;
+   mdynccd.Print();
+   cout<<"... dx,y="<<dxy<<" zoom="<<zoom<<" w="<<w<<endl;}
+
+// PSF et Fit
+PSF mypsf(typ_psf,100.0);
+int npar = mypsf.NParm();
+PSFStar mypsfstar(&mypsf);
+if(npar>7) mypsfstar.Parm(6)=(double)par6; // Cas moffat et Dl gauss avec coeff var.
+int rc = mypsfstar.IniFit(*pav,*nois,lpg);
+if(rc != 0)
+  {cout<<"PIDemoApp::FitPSFImg(), Echec IniFit (rc="<<rc<<")"<<endl;
+   delete nois;  delete pav; return(-10); }
+rc = mypsfstar.Fit(*pav,*nois,lpg);
+if(rc != 0)
+  {cout<<"PIDemoApp::FitPSFImg(), Echec Fit (rc="<<rc<<")"<<endl;
+   delete nois;  delete pav; return(-11); }
+if(lp) mypsfstar.Print(2);
+float smax,axisrat,tiltdeg;
+rc = paramga((float) mypsfstar.SigX(),(float) mypsfstar.SigY()
+            ,(float) mypsfstar.Rho(),&smax,&axisrat,&tiltdeg);
+if(rc==0 && lp)
+  printf("...   sa=%g sb=%g (%g) teta=%g\n",smax,smax*axisrat,axisrat,tiltdeg);
+else printf("Erreur paramga \n");
+
+// Creation des pave resultats
+ImageR4* res = new ImageR4(dx, dy);
+ImageR4* psf = new ImageR4(dx, dy);
+CopieImage(*res,*pav); *res -= mypsfstar;
+*psf = 0.; *psf += mypsfstar;
+
+// Si on demande d'ecrire au moins un des resultats (pav,nois,res,psf) => menage!
+bool delobj = (wpav||wnois||wres||wpsf)?true:false;
+
+// Display des resultats, fenetre 2x2 {{pav,nois},{res,psf}}
+app->CreateGraphWin(2,2,w,w); app->SetZoomAtt(zoom);
+dummy = nom+"pav"; dum = dummy+"*"; if(delobj) omg.DelObjects(dum);
+if(wpav) {
+  // Si on veut garder l'objet
+  omg.AddObj(pav,dummy);
+  omg.DisplayObj(omg.LastObjName());
+} else {
+  // "true" pour tuer (delete) de l'objet ImageR4 lors de la destruction de PIImage
+  app->DispImage(new ImageAdapter<r_4>(pav,true),dummy,Disp_Next);
+}
+dummy = nom+"nois"; dum = dummy+"*"; if(delobj) omg.DelObjects(dum);
+if(wnois) {
+  omg.AddObj(nois,dummy);
+  omg.DisplayObj(omg.LastObjName());
+} else {
+  app->DispImage(new ImageAdapter<r_4>(nois,true),dummy,Disp_Next);
+}
+dummy = nom+"res"; dum = dummy+"*"; if(delobj) omg.DelObjects(dum);
+if(wres) {
+  omg.AddObj(res,dummy);
+  omg.DisplayObj(omg.LastObjName());
+} else {
+  app->DispImage(new ImageAdapter<r_4>(res,true),dummy,Disp_Next);
+}
+dummy = nom+"psf"; dum = dummy+"*"; if(delobj) omg.DelObjects(dum);
+if(wpsf) {
+  omg.AddObj(psf,dummy);
+  omg.DisplayObj(omg.LastObjName());
+} else {
+  app->DispImage(new ImageAdapter<r_4>(psf,true),dummy,Disp_Next);
+}
+
+return(0);
+}
+
+/* Nouvelle-Fonction    cmv 16/10/98 */
+int Photom_Ouv(cmdtok& tokens)
+//	Photometrie d'ouverture sur une Image.
+//| tokens[0] = Type de calcul du fond et du flux.
+//|   : b = fond calcule sur les pixels du bord du pave.
+//|   : a = fond sur les pixels autres que ceux servant au calcul du flux.
+//|   : faa.bbb = fond fixe a aa.bbb
+//|   defaut : "b"
+//| tokens[1] = options pour le fit ex: l1.0
+//|      : ra = "a" rayon minimal de scan (def=0)
+//|      : ga = "a" taille de la fenetre glissante pour les extrapolations (def=4)
+//|      : la = "a" niveau de print
+//| tokens[2] = options graphiques
+//| Return: 0 si Ok, <0 sinon.
+{
+// Decodage des arguments
+if(tokens.size()<1) return(-1);
+int typ_fond=1, rmin=0, rmax, npt_gliss=4, lp=0;
+float fondimpos=0., fondbord=0., fondautre;
+string opt="";
+string dummy; string dum;
+
+if(tokens.size()>=3) opt = tokens[2];
+if(tokens.size()>=2) {
+  dummy = "," + tokens[1]+ ",";
+  if(strstr(dummy.c_str(),",r")) {
+    size_t p = dummy.find(",r"); size_t q = dummy.find_first_of(',',p+1);
+    dum = dummy.substr(p,q-p);
+    if(dum.length()>2) sscanf(dum.c_str(),",r%d",&lp);
+  }
+  if(strstr(dummy.c_str(),",g")) {
+    size_t p = dummy.find(",g"); size_t q = dummy.find_first_of(',',p+1);
+    dum = dummy.substr(p,q-p);
+    if(dum.length()>2) sscanf(dum.c_str(),",g%d",&npt_gliss);
+  }
+  if(strstr(dummy.c_str(),",l")) {
+    size_t p = dummy.find(",l"); size_t q = dummy.find_first_of(',',p+1);
+    dum = dummy.substr(p,q-p);
+    if(dum.length()>2) sscanf(dum.c_str(),",l%d",&lp);
+  }
+}
+
+dummy = "," + tokens[0]+ ",";
+if(strstr(dummy.c_str(),",b,"))       typ_fond=1;
+else if(strstr(dummy.c_str(),",a,"))  typ_fond=2;
+else if(strstr(dummy.c_str(),",f"))  {
+  typ_fond=3;
+  size_t p = dummy.find(",f"); size_t q = dummy.find_first_of(',',p+1);
+  dum = dummy.substr(p,q-p);
+  if(dum.length()>2) sscanf(dum.c_str(),",f%f",&fondimpos);
+}
+
+if(rmin<0) rmin=0; if(npt_gliss<=0) npt_gliss=4; if(lp<0) lp=1;
+
+// Wigdet,piimage et image courants
+NamedObjMgr omg;
+PIStdImgApp* app = omg.GetImgApp();
+if(app == NULL)
+  {cout<<"Pas de PIStdImgApp*"<<endl; return(-2);}
+PIBaseWdg* curw= app->CurrentBaseWdg() ;
+if(curw == NULL)
+  {cout<<"Pas de PIBaseWdg*"<<endl; return(-3);}
+if(curw->kind() != PIImage::ClassId)
+  {cout<<"Current window not an Image"<<endl; return(-4);}
+PIImage* curpimg = (PIImage*)curw;
+if(curpimg == NULL)
+  {cout<<"Pas de PIImage*"<<endl; return(-5);}
+P2DArrayAdapter* img = curpimg->Image();
+if(img == NULL)
+  {cout<<"Pas de Image*"<<endl; return(-6);}
+string nom = "ouver_";
+
+// Definition du pave courant sur la piimage
+int xc = curpimg->XPave(), yc = curpimg->YPave();
+int dx = curpimg->XSzPave(), dy = curpimg->YSzPave();
+int dxym = (dx<dy)?dx:dy; if(dxym%2==0) dxym++; rmax = dxym/2;
+if(dxym<3||dxym>img->XSize()||dxym>img->YSize())
+  {cout<<"Pave trop petit/grand: "<<dxym<<endl; return(-10);}
+if(rmin>=rmax)
+  {cout<<"rayon mini="<<rmin<<">= rmax="<<rmax<<endl; return(-11);}
+int x0=xc-rmax, y0=yc-rmax, x1=xc+rmax, y1=yc+rmax;
+if(x0<0||y0<0||x1>=img->XSize()||y1>=img->YSize())
+  {cout<<"Pave hors image"<<endl; return(-12);}
+int ic = rmax, jc = rmax;
+ImageR4* pav = new ImageR4(dxym, dxym);
+{for(int j=-rmax;j<=rmax;j++) for(int i=-rmax;i<=rmax;i++)
+    (*pav)(ic+i,jc+j)=(*img)(xc+i,yc+j);}
+
+// Print
+if(lp>1)
+  cout<<"photom_ouv[typ="<<typ_fond<<"]: pav["<<dx<<","<<dy<<" ("<<dxym
+      <<"] xc,yc="<<xc<<","<<yc<<"] ic,jc="<<ic<<","<<jc<<endl
+      <<"] (fond="<<fondimpos<<") pxmil="<<(*pav)(ic,ic)
+      <<" -> Rph de "<<rmin<<" a "<<rmax<<endl;
+
+// Ouverture des buffers et objets necessaires
+float *p = new float[dxym*dxym];
+r_4 xnt[4];
+NTuple *ntfl=NULL, *ntex=NULL;
+{char* name[4]={"npx","flux","fond","mag"}; ntfl = new NTuple(4,name);}
+{char* name[3]={"k","a","f0"};              ntex = new NTuple(3,name);}
+
+// Calcul du fond sur les pixels du bord du pave
+{
+int nf = 0;
+for(int i=0;i<dxym;i++)   {p[nf]=(*pav)(i,0); nf++; p[nf]=(*pav)(i,dxym-1); nf++;}
+for(int j=1;j<dxym-1;j++) {p[nf]=(*pav)(0,j); nf++; p[nf]=(*pav)(dxym-1,j); nf++;}
+qsort(p,(size_t) nf,sizeof(float),qSort_Float);
+fondbord = (p[nf/2]+p[(nf-1)/2])/2.;
+if(lp>0) cout<<"Fond_Bord: "<<fondbord<<" (avec 1 px au bord="<<nf<<")"<<endl;
+}
+
+// Photometrie d'ouverture variable.
+int rfin = -1;
+for(int r=rmin;r<=rmax;r++) {
+  double sum=0.; int ns=0, nf=0;
+  for(int i=0;i<dxym;i++) for(int j=0;j<dxym;j++) {
+    if(ic-r<=i && i<=ic+r && jc-r<=j && j<=jc+r ) {sum += (*pav)(i,j); ns++;}
+    else {p[nf] = (*pav)(i,j); nf++;}
+  }
+  if(typ_fond==2) {
+    if(nf<2) continue;
+    qsort(p,(size_t) nf,sizeof(float),qSort_Float);
+    fondautre = (p[nf/2]+p[(nf-1)/2])/2.;
+  }
+  double fond=-1.e19;
+  if(typ_fond==3) fond=fondimpos; else if(typ_fond==2) fond=fondautre; else fond=fondbord;
+  rfin = r;
+  xnt[0] = ns;
+  xnt[1] = sum-fond*ns;
+  xnt[2] = fond;
+  xnt[3] = (xnt[1]>0.)? -2.5*log10((double)xnt[1]): -99.;
+  if(lp>0)
+    cout<<"Ouv[r="<<r<<",ns="<<xnt[0]<<",nf="<<nf<<"]: fd="<<xnt[2]
+        <<" fl="<<xnt[1]<<" mag="<<xnt[3]<<endl;
+  ntfl->Fill(xnt);
+}
+delete [] p;
+int nr = ntfl->NEntry();
+if(lp>1) cout<<"Nombre de calculs de flux: "<<nr<<endl;
+if(nr<=0)
+  {cout<<"Pas de flux calcules"<<endl; delete pav; delete ntfl; delete ntex; return(-13);}
+
+cout<<"Ouv[rouv="<<rfin<<",npix="<<xnt[0]<<"]: fond="<<xnt[2]
+    <<" flux="<<xnt[1]<<" mag="<<xnt[3]<<endl;
+
+// Extrapolation: F_mes = F_vrai + npxflux*(Fd_vrai-Fd_mes)
+// On fit F_mes=f(npxflux) sur une fenetre glissante de npt_gliss pts.
+bool ex = false;
+if(nr>=npt_gliss) {
+  ex = true;
+  double *npix = new double[nr], *flux = new double[nr], *err  = new double[nr];
+  for(int i=0;i<nr;i++) { ntfl->GetVec(i,xnt); npix[i]=xnt[0]; flux[i]=xnt[1]; err[i]=1.;}
+  double a,b; int n;
+  for(int k=0;k<=nr-npt_gliss;k++) {
+    n = npt_gliss; FitLin(&npix[k],&flux[k],&err[k],&n,&b,&a);
+    xnt[0]=k; xnt[1]=a; xnt[2]=b; ntex->Fill(xnt);
+    if(lp>1)
+      cout<<"Fit["<<k<<","<<k+npt_gliss-1<<"] f0="<<xnt[2]<<" pente="<<xnt[1]<<endl;
+  }
+  delete [] npix; delete [] flux; delete [] err;
+}
+
+// Display des resultats, fenetre 2x2 {{flux%ns,fond%ns},{f0,pente}}
+if(ex) app->CreateGraphWin(2,2); else app->CreateGraphWin(1,2);
+dummy = nom+"*"; omg.DelObjects(dummy);
+
+dummy=nom+"pav"; omg.AddObj(pav,dummy);
+
+string xd=""; string yd=""; string zd,exd,eyd,ezd;
+dummy=nom+"flux"; omg.AddObj(ntfl,dummy);
+xd="npx"; yd="flux";
+omg.DisplayNT(omg.LastObjName(),xd,yd,zd,exd,eyd,ezd,opt);
+if(typ_fond==2)
+  {xd="npx"; yd="fond"; omg.DisplayNT(omg.LastObjName(),xd,yd,zd,exd,eyd,ezd,opt);}
+if(ex) {
+  dummy=nom+"fit"; omg.AddObj(ntex,dummy);
+  if(typ_fond!=2)
+    {xd="a"; yd="f0"; omg.DisplayNT(omg.LastObjName(),xd,yd,zd,exd,eyd,ezd,opt);}
+  xd = "k"; yd = "f0";
+  omg.DisplayNT(omg.LastObjName(),xd,yd,zd,exd,eyd,ezd,opt);
+  xd = "k"; yd = "a";
+  omg.DisplayNT(omg.LastObjName(),xd,yd,zd,exd,eyd,ezd,opt);
+}
+
+return(0);
+}
+#endif
Index: /trunk/SophyaPI/PIext/piacmd.h
===================================================================
--- /trunk/SophyaPI/PIext/piacmd.h	(revision 165)
+++ /trunk/SophyaPI/PIext/piacmd.h	(revision 165)
@@ -0,0 +1,59 @@
+// 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 "defs.h"
+
+#include <fstream.h>
+#include <string>
+#include <map>
+#if defined(__KCC__)
+using std::string ;
+#include <map.h>
+#endif
+
+#include "ctimer.h"
+#include "dlftypes.h"
+
+class NamedObjMgr;
+class PIStdImgApp;
+
+
+class PIACmd {
+public:
+		PIACmd(NamedObjMgr* omg=NULL, PIStdImgApp* app=NULL);
+		~PIACmd();
+  int		Exec(string& file);
+  int		Do(string& line);
+
+//  Link dynamique de fonction user
+  int 		LinkUserFuncs(string& fnameso, string& func1, string& func2, string& func3,
+                              string& func4, string& func5);
+  NamedObjMgr* mObjMgr;
+  PIStdImgApp* mImgApp;
+  bool mOmg;
+
+//  Pour stocker les variables definies par l'interpreteur
+typedef map<string, string, less<string> > CmdVarList;
+
+  CmdVarList mVars;    // Liste des variables 
+  ofstream hist;       //  History file 
+  bool trace;          // Trace flag
+  bool timing;         // Display CPU Time
+  Timer* gltimer;      // pour Display CPU Time
+
+// 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;
+  void *dlhandle;      // Pour le link dynamique 
+  UsFmap usfmap;
+  string TmpDir;       // Repertoire pour les compilations / link dynamique
+
+
+};
+
+#endif
Index: /trunk/SophyaPI/PIext/piapp.cc
===================================================================
--- /trunk/SophyaPI/PIext/piapp.cc	(revision 165)
+++ /trunk/SophyaPI/PIext/piapp.cc	(revision 165)
@@ -0,0 +1,90 @@
+#include <stdlib.h>
+#include <stdio.h>
+#ifdef OSF1
+#include <dlfcn.h>
+#else
+#define C_NO_SHLIBS
+#endif
+
+#include <string>
+#include "psighand.h"
+#include "dynccd.h"
+
+#include "timing.h"
+#include "piinit.h"
+#ifndef SANS_StarReco 
+#include "strecinit.h"
+#endif
+
+#include "pistdimgapp.h"
+
+
+
+/*  ================================ MAIN() =================================  */
+
+int main(int narg, char *arg[])
+{
+int ofa;
+int fgsig, fgred;
+
+PeidaInteractiveInitiator piinit;
+#ifndef SANS_StarReco 
+PeidaStarRecoInitiator strecinit;
+#endif
+   
+InitTim();
+
+ofa = 1;   
+if (narg > 1)
+  {
+  if (strcmp(arg[1],"-h") == 0) 
+    {
+    puts("\n piapp: Programme d'analyse interactive ");
+    puts("Usage: piapp [-nored] [-nosig]");
+    exit(0);
+    }
+  }
+
+ofa = 1;
+fgred = fgsig = true;
+if (  (narg > 1) && (strcmp(arg[1],"-nored") == 0) )  { fgred=false;  ofa = 2; }
+if (  (narg > 1) && (strcmp(arg[1],"-nosig") == 0) )  { fgsig=false;  ofa = 2; }
+if (  (narg > 2) && (strcmp(arg[2],"-nored") == 0) )  { fgred=false;  ofa = 3; }
+if (  (narg > 2) && (strcmp(arg[2],"-nosig") == 0) )  { fgsig=false;  ofa = 3; }
+
+
+PIStdImgApp * app = new PIStdImgApp(narg-ofa, arg+ofa);
+if (!fgred) app->RedirectStdOutErr(false);
+else app->RedirectStdOutErr(true);
+if (fgsig)  app->CatchSignals(true);
+
+int rc = 0;
+bool cont = true;
+while(cont) {
+  rc = 0;   cont = false;
+  app->SetReady();
+  if (fgred) app->RedirectStdOutErr(true);
+  TRY {
+  app->Run();
+  }  CATCH(merr) {
+     char ans[32],rep;
+     app->Stop();
+     app->RedirectStdOutErr(false);  
+     fflush(stdout); 
+     cout << endl; 
+     cerr << endl;
+     printf("PIStdImg/main() Exception catched ! = %ld (%s) \n", (long)merr, PeidaExc(merr));
+     printf(" exit <CR> , continue c<CR> , close-windows, continue k<cr> ? ");  gets(ans);
+     rc = merr;
+     rep = toupper(ans[0]);  
+     if ((rep != 'C')||(rep != 'K'))  cont = false;
+     else { cont = true; if (rep == 'K') app->CloseAllWindows(); }
+  } ENDTRY;
+}
+
+app->RedirectStdOutErr(false);  
+delete app;
+printf("piapp : Exiting .... Rc= %d \n", rc); 
+exit(rc);
+}
+
Index: /trunk/SophyaPI/PIext/pigfd1.cc
===================================================================
--- /trunk/SophyaPI/PIext/pigfd1.cc	(revision 165)
+++ /trunk/SophyaPI/PIext/pigfd1.cc	(revision 165)
@@ -0,0 +1,77 @@
+#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->GetMinMax(10*VarX+2,xmin,xmax);
+mGFD->GetMinMax(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((float)xmin-dx,(float)xmax+dx,(float)ymin-dy,(float)ymax+dy);
+SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
+}
+
+/* --Methode-- */
+void PIGenFitDat::Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float 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);
+float 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: /trunk/SophyaPI/PIext/pigfd1.h
===================================================================
--- /trunk/SophyaPI/PIext/pigfd1.h	(revision 165)
+++ /trunk/SophyaPI/PIext/pigfd1.h	(revision 165)
@@ -0,0 +1,25 @@
+#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, float xmin, float ymin, float xmax, float 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: /trunk/SophyaPI/PIext/pigfd2.cc
===================================================================
--- /trunk/SophyaPI/PIext/pigfd2.cc	(revision 165)
+++ /trunk/SophyaPI/PIext/pigfd2.cc	(revision 165)
@@ -0,0 +1,95 @@
+#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->GetMinMax(10*VarX+2,xmin,xmax);
+mGFD->GetMinMax(10*VarY+2,ymin,ymax);
+mGFD->GetMinMax(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
+float 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.*D , zmin+(zmax-zmin)*0.2, 0.3, 0.3);  
+}
+
+/* --Methode-- */
+void PIGenFitDat3D::Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax)
+{
+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(__DECCXX) || defined(__KCC__)
+PIGraphic3D* g3 = dynamic_cast<PIGraphic3D*>(g);
+#else
+PIGraphic3D* g3 = (PIGraphic3D*)(g);
+#endif
+
+if (mLAtt == PI_NotDefLineAtt)  g3->SelLine(PI_ThinLine);
+
+float 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: /trunk/SophyaPI/PIext/pigfd2.h
===================================================================
--- /trunk/SophyaPI/PIext/pigfd2.h	(revision 165)
+++ /trunk/SophyaPI/PIext/pigfd2.h	(revision 165)
@@ -0,0 +1,26 @@
+#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, float xmin, float ymin, float xmax, float 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: /trunk/SophyaPI/PIext/pihisto.cc
===================================================================
--- /trunk/SophyaPI/PIext/pihisto.cc	(revision 165)
+++ /trunk/SophyaPI/PIext/pihisto.cc	(revision 165)
@@ -0,0 +1,114 @@
+#include <stdio.h>
+#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( mHisto->ClassId() == HProf::classId ) {
+    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, float /*xmin*/, float /*ymin*/, float /*xmax*/, float /*ymax*/)
+{
+  bool oktrace = false;
+  if (!mHisto)  return;  
+  if (mMrk != PI_NotDefMarker || mHisto->ClassId() == HProf::classId ) {
+    // Marqeurs definis OU HBProf => marqueurs+Erreurs si il y en a
+    if (mLAtt == PI_NotDefLineAtt) g->SelLine(PI_ThinLine);
+    float x1,y1, x2,y2;
+    float 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) {
+    float 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++) {
+      float left   = mHisto->BinLowEdge(i);
+      float width  = mHisto->BinWidth();
+      float bottom = 0;
+      float height = (*mHisto)(i);
+      g->DrawFBox(left,bottom,width,height);
+      g->DrawLine(left, bottom, left, bottom + height); // Au moins une ligne...
+    }
+  }
+  DrawStats(g);
+}
+
+void
+PIHisto::DrawStats(PIGraphicUC* g)
+{
+  if (!mHisto) return;
+  if (mLAtt == PI_NotDefLineAtt)  g->SelLine(PI_ThinLine);
+  float cellHeight = (YMax() - YMin()) * 0.05;
+  float 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: /trunk/SophyaPI/PIext/pihisto.h
===================================================================
--- /trunk/SophyaPI/PIext/pihisto.h	(revision 165)
+++ /trunk/SophyaPI/PIext/pihisto.h	(revision 165)
@@ -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, float xmin, float ymin, float xmax, float ymax);
+  virtual void       UpdateLimits();
+  virtual void       DrawStats(PIGraphicUC* g);
+  inline  Histo*     Histogram() { return(mHisto); }
+
+protected:
+  Histo* mHisto;
+  bool mAdDO;
+};
+
+#endif
Index: /trunk/SophyaPI/PIext/pihisto2d.cc
===================================================================
--- /trunk/SophyaPI/PIext/pihisto2d.cc	(revision 165)
+++ /trunk/SophyaPI/PIext/pihisto2d.cc	(revision 165)
@@ -0,0 +1,757 @@
+#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
+//	(pour la couleur cmap cf picmap.h).
+//--
+{
+mFgCol = fg; mCmap = cmap;
+}
+
+//++
+void PIHisto2D::UseScale(unsigned short type,float logscale)
+//
+//	Pour changer les echelles.
+//| Type = 0 : echelle lineaire
+//|      = 1 : echelle log10
+//| - Explication du codage en type=1 (log10) :
+//|   1-/ map lineaire :
+//|       [0,1] -> [lmin,lmax]
+//|       f     -> F = lmin+f*(lmax-lmin)
+//|   2-/ transformation log10 :
+//|       [lmin,lmax] -> [log10(lmin),log10(lmax)]
+//|       F           -> LF = lg10(F)
+//|   3-/ rescaling entre 0 et 1 :
+//|       [log10(lmin),log10(lmax)] -> [0,1]
+//|       LF -> (LF-log10(lmin))/(log10(lmax)-log10(lmin))
+//|       soit en definissant logscale = lmax/lmin
+//|       LF = log10(1.+f*(logscale-1))/log10(logscale)
+//--
+{
+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 tailles fixes (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].
+//--
+{
+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
+//|    - on limite l'excursion a f*frmax cad [...,frmax]
+//--
+{
+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,float,float, float, float)
+//
+//	Dessin de l'histogramme.
+//--
+{
+if(!mHisto) return;
+// Caracteristiques histogramme
+float dx = mHisto->WBinX(),dy = mHisto->WBinY();
+float 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->GetFontAtt();
+int FontSize = g->GetFontSize();
+if(mTypDisp==2) {
+  float 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);
+  }
+
+  // Dessin proprement dit selon le choix graphique.
+  if(mTypDisp==0) {
+    //..... carres de tailles variables
+    float left   = left0   + 0.5*(1.-fracred)*dx, width  = fracred*dx;
+    float 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++) {
+      float x = left0 + frand01()*dx;
+      float 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';
+    float x = left0 + dx/2.;
+    float 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);
+  float cellHeight = (YMax() - YMin()) * 0.05;
+  float 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).
+//--
+{
+float dx = mHisto->WBinX(),dy = mHisto->WBinY();
+float 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, 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(float x, float 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::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).
+//--
+{
+h2dWinArg->SetPIH2DWdg(this);
+h2dWinArg->SetMsgParent((PIMsgHandler*)this);
+if(!h2dWinArg->Visible()) h2dWinArg->Show();
+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: /trunk/SophyaPI/PIext/pihisto2d.h
===================================================================
--- /trunk/SophyaPI/PIext/pihisto2d.h	(revision 165)
+++ /trunk/SophyaPI/PIext/pihisto2d.h	(revision 165)
@@ -0,0 +1,103 @@
+#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,float xmin,float ymin,float xmax,float 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, 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(float x, float y); 
+  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: /trunk/SophyaPI/PIext/piinit.cc
===================================================================
--- /trunk/SophyaPI/PIext/piinit.cc	(revision 165)
+++ /trunk/SophyaPI/PIext/piinit.cc	(revision 165)
@@ -0,0 +1,25 @@
+#include "defs.h"
+#include "piinit.h"
+
+
+int PeidaInteractiveInitiator::FgInit = 0;
+
+PeidaInteractiveInitiator::PeidaInteractiveInitiator()
+ : PeidaImagesInitiator()
+{
+  FgInit++;
+  if (FgInit > 1)  return;
+  
+} 
+
+PeidaInteractiveInitiator::~PeidaInteractiveInitiator()
+{
+  FgInit--;
+/*  if (FgInit == 0)
+    {
+    }  */
+}
+
+// On met un objet initiator en statique, pour les loaders qui savent 
+// appeler le constructeur des objets statiques   Reza 08/98
+static PeidaInteractiveInitiator  pinteractivexxinit;
Index: /trunk/SophyaPI/PIext/piinit.h
===================================================================
--- /trunk/SophyaPI/PIext/piinit.h	(revision 165)
+++ /trunk/SophyaPI/PIext/piinit.h	(revision 165)
@@ -0,0 +1,19 @@
+#ifndef PIINIT_H_SEEN
+#define PIINIT_H_SEEN
+
+#include "imaginit.h"
+
+// Classe d'initialisation pour le module PI de PEIDA
+
+class PeidaInteractiveInitiator : public PeidaImagesInitiator{
+private:
+  static int FgInit;
+public:
+  		PeidaInteractiveInitiator();
+ virtual	~PeidaInteractiveInitiator();
+};
+
+#undef PeidaInit
+#define PeidaInit() PeidaInteractiveInitiator peidainitiator
+
+#endif
Index: /trunk/SophyaPI/PIext/pimgadapter.h
===================================================================
--- /trunk/SophyaPI/PIext/pimgadapter.h	(revision 165)
+++ /trunk/SophyaPI/PIext/pimgadapter.h	(revision 165)
@@ -0,0 +1,36 @@
+#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; }
+
+  virtual 	  ~RzImageAdapter() { if (aDel) delete mImg; }
+  virtual float   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; }
+
+  virtual 	  ~ImageAdapter() { if (aDel) delete mImg; }
+  virtual float   Value(int ix, int iy) { return((*mImg)(ix, iy)); }
+
+protected :
+  bool aDel;
+  Image<T>* mImg;
+};
+
+#endif
Index: /trunk/SophyaPI/PIext/pintup3d.cc
===================================================================
--- /trunk/SophyaPI/PIext/pintup3d.cc	(revision 165)
+++ /trunk/SophyaPI/PIext/pintup3d.cc	(revision 165)
@@ -0,0 +1,117 @@
+#include <stdio.h>
+#include "pintup3d.h"
+
+ 
+/* --Methode-- */
+PINTuple3D::PINTuple3D(NTuple* 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)
+{
+if (mNT == NULL)  xK = yK = zK = -1;
+if (px == NULL) xK = -1;
+else xK = mNT->IndexNom(px);
+if (py == NULL) yK = -1;
+else yK = mNT->IndexNom(py);
+if (pz == NULL) zK = -1;
+else zK = mNT->IndexNom(pz);
+}
+
+/* --Methode-- */
+void  PINTuple3D::SelectErrBar(const char* erbx, const char* erby, const char* erbz)
+{
+if (mNT == NULL)  xebK = yebK = zebK = -1;
+if (erbx == NULL) xebK = -1;
+else xebK = mNT->IndexNom(erbx);
+if (erby == NULL) yebK = -1;
+else yebK = mNT->IndexNom(erby);
+if (erbz == NULL) zebK = -1;
+else zebK = mNT->IndexNom(erbz);
+}
+
+
+/* --Methode-- */
+void PINTuple3D::UpdateLimits()
+{
+  if (!mNT) return;
+  if (mNT->NEntry() <= 0)  return;
+  if ( (xK < 0) || (yK < 0)  || (zK < 0) )   return;
+
+  // Commencer par trouver nos limites
+  float 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 
+  float 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.*D , zmin+(zmax-zmin)*0.2, 0.3, 0.3);  
+//  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, float xmin, float ymin, float xmax, float ymax)
+{
+float xp,yp,zp,xer,yer,zer;
+int nok;
+
+if (!mNT) return;
+if ( (xK < 0) || (yK < 0) || (zK < 0) )  return;
+
+#if defined(__DECCXX) || defined(__KCC__)
+PIGraphic3D* g3 = dynamic_cast<PIGraphic3D*>(g);
+#else
+PIGraphic3D* g3 = (PIGraphic3D*)(g);
+#endif
+
+if (mLAtt == PI_NotDefLineAtt)  g3->SelLine(PI_ThinLine);
+
+nok = 0;  
+for (int i=0; i<mNT->NEntry(); i++) {
+  xp = mNT->GetVal(i, xK);
+  yp = mNT->GetVal(i, yK);
+  zp = mNT->GetVal(i, zK);
+  nok++;
+  g3->DrawMarker3D(xp, yp, zp); 
+  if ( xebK >= 0 ) {
+    xer = mNT->GetVal(i, xebK);
+    g3->DrawLine3D(xp-xer, yp, zp, xp+xer, yp, zp);
+  }
+  if ( yebK >= 0 ) {
+    yer = mNT->GetVal(i, yebK);
+    g3->DrawLine3D(xp, yp-yer, zp, xp, yp+yer, zp);
+  }
+  if ( zebK >= 0 ) {
+    zer = mNT->GetVal(i, zebK);
+    g3->DrawLine3D(xp, yp, zp-zer, xp, yp, zp+zer);
+  }
+}
+
+return;
+}
+
Index: /trunk/SophyaPI/PIext/pintup3d.h
===================================================================
--- /trunk/SophyaPI/PIext/pintup3d.h	(revision 165)
+++ /trunk/SophyaPI/PIext/pintup3d.h	(revision 165)
@@ -0,0 +1,31 @@
+#ifndef PINTUPLE3D_H
+#define PINTUPLE3D_H
+
+#include "ntuple.h"
+#include "pi3ddrw.h"
+
+class PINTuple3D : public PIDrawer3D {
+public:
+                     PINTuple3D(NTuple* nt, bool ad=false);
+  virtual           ~PINTuple3D();
+  
+  virtual void       Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float 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:
+  NTuple* 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: /trunk/SophyaPI/PIext/pintuple.cc
===================================================================
--- /trunk/SophyaPI/PIext/pintuple.cc	(revision 165)
+++ /trunk/SophyaPI/PIext/pintuple.cc	(revision 165)
@@ -0,0 +1,96 @@
+#include <stdio.h>
+#include "pintuple.h"
+
+ 
+/* --Methode-- */
+PINTuple::PINTuple(NTuple* nt, bool ad)
+: PIDrawer()
+{
+  mNT = nt;
+  mAdDO = ad; 
+  SelectXY(NULL, NULL);
+  SelectErrBar();
+}
+
+PINTuple::~PINTuple()
+{
+  if (mAdDO && mNT)  delete mNT;
+}
+
+/* --Methode-- */
+void  PINTuple::SelectXY(const char* px, const char* py)
+{
+if (mNT == NULL)  xK = yK = -1;
+if (px == NULL) xK = -1;
+else xK = mNT->IndexNom(px);
+if (py == NULL) yK = -1;
+else yK = mNT->IndexNom(py);
+}
+
+/* --Methode-- */
+void  PINTuple::SelectErrBar(const char* erbx, const char* erby)
+{
+if (mNT == NULL)  xebK = yebK = -1;
+if (erbx == NULL) xebK = -1;
+else xebK = mNT->IndexNom(erbx);
+if (erby == NULL) yebK = -1;
+else yebK = mNT->IndexNom(erby);
+}
+
+
+/* --Methode-- */
+void PINTuple::UpdateLimits()
+{
+  if (!mNT) return;
+  if (mNT->NEntry() <= 0)  return;
+  if ( (xK < 0) || (yK < 0) )   return;
+
+  // Commencer par trouver nos limites
+  float dx, dy;
+  float 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, float xmin, float ymin, float xmax, float ymax)
+{
+float xp,yp,xer,yer;
+int nok;
+
+if (!mNT) return;
+if ( (xK < 0) || (yK < 0) )  return;
+if (mLAtt == PI_NotDefLineAtt)  g->SelLine(PI_ThinLine);
+nok = 0;  
+for (int i=0; i<mNT->NEntry(); i++) {
+  xp = mNT->GetVal(i, xK);
+  yp = mNT->GetVal(i, yK);
+  if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) )  continue;
+  nok++;
+  if ( xebK >= 0 ) {
+    xer = mNT->GetVal(i, xebK);
+    if(xer>0.) g->DrawLine(xp-xer, yp, xp+xer, yp);
+  }
+  if ( yebK >= 0 ) {
+    yer = mNT->GetVal(i, yebK);
+    if(yer>0.) g->DrawLine(xp, yp-yer, xp, yp+yer);
+  }
+  g->DrawMarker(xp, yp); 
+}
+
+/*
+sprintf(buff, "NTuple:  NEntry= %d  NDisp= %d", (int)mNT->NEntry(), nok);
+g->BaseGraphic()->DrawString(15,15,buff);
+*/
+return;
+}
+
Index: /trunk/SophyaPI/PIext/pintuple.h
===================================================================
--- /trunk/SophyaPI/PIext/pintuple.h	(revision 165)
+++ /trunk/SophyaPI/PIext/pintuple.h	(revision 165)
@@ -0,0 +1,31 @@
+#ifndef PINTUPLE_H
+#define PINTUPLE_H
+
+#include "ntuple.h"
+#include "pidrawer.h"
+
+class PINTuple : public PIDrawer {
+public:
+                     PINTuple(NTuple* nt, bool ad);
+  virtual           ~PINTuple();
+  
+  virtual void       Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax);
+  virtual void       UpdateLimits();
+  
+          void       SelectXY(const char* px, const char* py);
+          void       SelectErrBar(const char* erbx=NULL, const char* erby=NULL);
+
+       
+protected:
+  NTuple* 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
+
+};
+
+#endif
+
+
+
+
Index: /trunk/SophyaPI/PIext/pipodrw.cc
===================================================================
--- /trunk/SophyaPI/PIext/pipodrw.cc	(revision 165)
+++ /trunk/SophyaPI/PIext/pipodrw.cc	(revision 165)
@@ -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, float /*xmin*/, float/*ymin*/, float/*xmax*/, float/*ymax*/)
+{
+  PIGrCoord x1, x2, y1, y2;
+  g->GetGrSpace(x1, x2, y1, y2);
+  float xMax = x2;
+  float xMin = x1;
+  float yMax = y2;
+  float yMin = y1;
+  float xStep = (xMax - xMin)/100;
+  float xOld = xMin;
+  float yOld = 0;
+//  float yOld = f->Value(&xMin, mParms);
+  for (float x = xMin+xStep; x<xMax; x+=xStep) {
+   float y = 0; // $CHECK$
+//    float 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-- */
+float 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-- */
+float 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-- */
+float POMatrixAdapter::Value(int ix, int iy)
+{
+// Attention MatrixAdapter(X=Colonne, Y= Row) = Matrix(row, col)  
+return((*mMtx)(iy, ix));
+}
+
+
Index: /trunk/SophyaPI/PIext/pipodrw.h
===================================================================
--- /trunk/SophyaPI/PIext/pipodrw.h	(revision 165)
+++ /trunk/SophyaPI/PIext/pipodrw.h	(revision 165)
@@ -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, float xmin, float ymin, float xmax, float 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 float   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 float   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 float   Value(int ix, int iy);   
+
+protected:
+  bool aDel;
+  Matrix* mMtx;
+};
+
+
+#endif
Index: /trunk/SophyaPI/PIext/pisiadw.cc
===================================================================
--- /trunk/SophyaPI/PIext/pisiadw.cc	(revision 165)
+++ /trunk/SophyaPI/PIext/pisiadw.cc	(revision 165)
@@ -0,0 +1,264 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "machine.h"
+
+#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/3;
+tsx = 5*bsx+6*spx;  tsy = 7*bsy+4*spy;
+SetSize(tsx,tsy);
+objlist = new PIList(this, "objlist", tsx-spx, tsy-4*spy-bsy, spx/2, spy/2);
+objlist->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+objlist->SetBorderWidth(2);
+
+int py = tsy-2*spy-bsy;
+int px = spx;
+mBut[0] = new PIButton(this, "Display", 100, bsx, bsy, px, py);   px += (bsx+spx);
+mBut[1] = new PIButton(this, "Print",   200, bsx, bsy, px, py);   px += (bsx+spx);
+mBut[2] = new PIButton(this, "SavePPF", 300, bsx, bsy, px, py);   px += (bsx+spx);
+mBut[3] = new PIButton(this, "Delete",  400, bsx, bsy, px, py);   px += (bsx+spx);
+mBut[4] = new PIButton(this, "Dismiss", 900, bsx, bsy, px, py);   px += (bsx+spx);
+
+for(i=0; i<5; i++)
+  mBut[i]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+
+// FinishCreate(); pas necessaire ?
+}
+
+/* --Methode-- */
+ObjMgrWind::~ObjMgrWind()
+{
+int i;
+delete objlist;
+for(i=0; i<5; i++)  delete mBut[i];
+}
+
+/* --Methode-- */
+void ObjMgrWind::Show()
+{
+dap->SetBlocked();
+PIWindow::Show();
+return;
+}
+
+/* --Methode-- */
+void ObjMgrWind::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
+{
+
+  // PIMessage ssg = ModMsg(msg);
+msg = UserMsg(msg);
+if (msg == 900)  {
+  dap->SetReady();
+  this->Hide();
+  return;
+}
+
+string nom = "";
+if ( (msg == 100) || (msg == 200) || (msg == 300) || (msg == 400) ) {
+  string sel = objlist->GetSelectionStr();
+  //  size_t p = sel.find_first_not_of(" \t");
+  //  if (p<0) p = 0;
+  size_t q = sel.find_first_of(" \t");
+  if (q < 0)   q = sel.length(); 
+  nom = sel.substr(0, q);
+}
+
+NamedObjMgr* om = dap->ObjMgr();
+if (om == NULL)  return;
+if (nom == "")  return;
+
+switch (msg)
+  {
+  case 100:
+    om->DisplayObj(nom);
+    break;
+  case 200:
+    om->PrintObj(nom);
+    break;
+  case 300:
+    if (dap->mPpfout)  om->SaveObj(nom, *(dap->mPpfout));
+    break;
+  case 400:
+    om->DelObj(nom);
+    break;
+
+  case 900:
+    dap->SetReady();
+    Hide();
+    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_fixed, PIBK_elastic,PIBK_fixed);
+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;
+  dap->ObjMgr()->ReadObj(flnm);
+  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); 
+  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);
+  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: /trunk/SophyaPI/PIext/pisiadw.h
===================================================================
--- /trunk/SophyaPI/PIext/pisiadw.h	(revision 165)
+++ /trunk/SophyaPI/PIext/pisiadw.h	(revision 165)
@@ -0,0 +1,59 @@
+#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 AddObj(const char * objid, PIMessage msg) 
+    { objlist->AppendItem(objid, msg); }
+  inline void DelObj(PIMessage msg) 
+    { objlist->DeleteItemMsg(msg); }
+private:
+  PIStdImgApp* dap;
+  PIList* objlist;
+  PIButton * mBut[5];
+};
+
+/* --------------------------------------------------------------------------- */
+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: /trunk/SophyaPI/PIext/pistdimgapp.cc
===================================================================
--- /trunk/SophyaPI/PIext/pistdimgapp.cc	(revision 165)
+++ /trunk/SophyaPI/PIext/pistdimgapp.cc	(revision 165)
@@ -0,0 +1,1146 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <string>
+#include <vector>
+#if defined(__KCC__)
+using std::string ;
+#include <vector.h>
+#endif
+
+#include "machine.h"
+
+#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"
+
+
+//  Il faudra virer ca (?)  Reza 19/08/98 
+// #include "parmst.h"
+// #define  FLAG_MAINGLPARMPIA  1
+// #include "glparmpia.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("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("Extract Pave", 10305);
+m[2]->SetSensitivityMsg(10305, false);
+mc = new PIMenu(m[2], "StackTools");
+mc->AppendItem("DispNext", 10320);
+mc->AppendItem("Blink 1s", 10321);
+mc->AppendItem("Blink 2s", 10322);
+mc->AppendItem("Blink 4s", 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/SEGV", 10603);
+
+AppendMenu(m[0]);
+AppendMenu(m[1]);
+AppendMenu(m[2]);
+AppendMenu(m[3]);
+AppendMenu(m[4]);
+AppendMenu(m[5]);
+
+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);
+// RedirectStdOutErr(true);  pas par defaut 
+
+char buff[128];
+sprintf(buff, "piapp V2.0   ---  PEIDA++ Version %5.3f \n", (float)PeidaVersion());
+mCons->AddStr("  ............  starting piapp .............\n", PIVA_Blue );
+mCons->AddStr(buff, PIVA_Blue );
+mCons->AddStr("  ..........................................\n", PIVA_Blue );
+// PrintPeidaVersion();
+
+ 
+mObjMgr = new NamedObjMgr;
+mObjMgr->SetImgApp(this);
+mCmd = new PIACmd(mObjMgr, this);
+
+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); 
+
+// mCutTC = new CutTools(this, this->MainWin());
+
+mObjmgrw = new ObjMgrWind(this);
+mPpinmgrw = new PPInMgrWind(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;
+SaveGraphicAtt();
+
+SetReady();
+}
+
+/* --Methode-- */
+PIStdImgApp::~PIStdImgApp()
+{
+int i;
+
+for(i=0; i<6; i++)  
+  if (m[i]) delete m[i];
+delete mc;
+
+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 = (PIWdg *)sender;
+  switch(sndw->kind())
+    {
+    case PIWindow::ClassId :
+      mCurWin = (PIWindow *)sender;
+      break;
+
+    case PIScDrawWdg::ClassId :
+    case PIDraw3DWdg::ClassId :
+      mCurWdg = (PIBaseWdg *)sender;
+//      cerr << "*DBG11* ImgTools -> NonSensitive " << sndw->kind() << endl;
+      if (mFgCWImg) {
+//        cerr << "*DBG* ImgTools -> NonSensitive " << endl;
+        m[2]->SetSensitivityMsg(10305, false);
+        m[4]->SetSensitivityMsg(10515, false);
+        m[4]->SetSensitivityMsg(10516, false);
+        mFgCWImg = false;
+        }
+      break;
+    case PIImage::ClassId :
+      mCurWdg = (PIBaseWdg *)sender;
+      if (!mFgCWImg) {
+//        cerr << "*DBG* ImgTools -> Sensitive " << endl;
+        m[2]->SetSensitivityMsg(10305, true);
+        m[4]->SetSensitivityMsg(10515, true);
+        m[4]->SetSensitivityMsg(10516, true);
+        mFgCWImg = true;
+        }
+      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 {
+    CmdInterpreter()->Do(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-- */
+int PIStdImgApp::DispImage(P2DArrayAdapter* nouv, string const & name, int opt)
+{
+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, flag);
+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, bool h2d)
+{
+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 (!h2d) 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, flag);
+if (!h2d) 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 $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)
+{
+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, flag);
+wd3->AddDrawer3D(dr3, true);
+//   Titre du plot
+if (title.length() <= 0)  title = name;  string t2="";   
+wd3->SetTitles(title, t2);    
+// wd3->Refresh();  Pas necessaire   
+mCurWin = win;
+mCurWdg = wd3;
+mLastWdg = wd3;
+mBWId++;
+mBWList[mBWId] = wd3;
+return(mBWId); 
+}
+
+
+/* --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++;
+sprintf(buff, "PI-GraphicWin (%d)",mWId); 
+PIZoneWindow* win = new PIZoneWindow(this,  buff, PIWK_normal, nx, ny, sx, sy, 0, 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++;
+sprintf(buff, "PI-StackWin (%d)",mWId); 
+PIStackWindow* win = new PIStackWindow(this,  buff, PIWK_normal, sx, sy, 0, 0);
+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
+    {
+    if ( (sx < 50) && (sy < 50) )   sx = sy = 300+mFgScSz*100; 
+    rw = new PIWindow(this,  nom, PIWK_normal, sx, sy, 0, 0);
+    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();
+WindMList::iterator it;
+for(it = mWList.begin(); it != mWList.end(); it++) 
+  if ((*it).second == w)  { mWList.erase(it);  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;
+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-- */
+void PIStdImgApp::RedirectStdOutErr(bool fg)
+{
+if (fg) { 
+  RedirectOutStream(mCons);
+  RedirectErrStream(mCons);
+  m[5]->SetStateMsg(10602, true);
+  }
+else {
+  RedirectOutStream(NULL);
+  RedirectErrStream(NULL);
+  m[5]->SetStateMsg(10602, false);
+  }
+return;
+}
+
+/* --Methode-- */
+void PIStdImgApp::CatchSignals(bool fg)
+{    
+PeidaConfigureSignalhandling(fg, fg);  
+m[5]->SetStateMsg(10603, fg);
+}
+
+/* --Methode-- */
+void PIStdImgApp::CloseAllWindows()
+{
+WindMList::iterator it;
+for(it = mWList.begin(); it != mWList.end(); it++)   delete (*it).second;
+mWList.clear();
+mBWList.clear();
+mDrwList.clear(); 
+}
+
+/* --Methode-- */
+void PIStdImgApp::MBProcess1(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
+{
+
+  switch(msg)
+    {
+    case 10120 :
+      pfc->SetPath(ImgDir);
+      pfc->AcceptNewFile(false);
+      mFCMsg = 10125; 
+      pfc->SetMsg(mFCMsg);
+      SetBlocked();
+      pfc->Show();
+      break;
+
+    case 10125 :
+      SetBusy();
+      if (data)  { 
+        ObjMgr()->ReadFits(pfc->GetFileName());
+        ObjMgr()->DisplayObj(ObjMgr()->LastObjName(), "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) {
+        string no = mCurWdg->Nom();
+        DeleteBaseWidget(mCurWdg);
+        mObjMgr->DelObj(no);
+        }
+      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 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);
+    string nom = mCurWdg->Nom() + "_pave";
+    ObjMgr()->AddObj(pim, nom);
+    ObjMgr()->DisplayObj(nom, "w");
+    }
+
+  case 10320 :
+    if (mStW)  mStW->DispNext();
+    break;
+
+  case 10321 :
+  case 10322 :
+  case 10324 :
+//  case 10328 :
+    if (mStW) mStW->StartAutoDisp(msg-10320);
+    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_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:
+    CatchSignals(*((bool*)data));
+    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::SaveGraphicAtt()
+{
+  mSFCol = mFCol;
+  mSBCol = mBCol;
+  mSLAtt = mLAtt;
+  mSFSz = mFSz;
+  mSFAtt = mFAtt;
+  mSMSz = mMSz;
+  mSMrk = mMrk;
+  mSCmapid = mCmapid;
+  mSZoom = mZoom;
+}
+
+/* --Methode-- */
+void PIStdImgApp::RestoreGraphicAtt()
+{
+  mFCol = mSFCol;
+  mBCol = mSBCol;
+  mLAtt = mSLAtt;
+  mFSz = mSFSz;
+  mFAtt = mSFAtt;
+  mMSz = mSMSz;
+  mMrk = mSMrk;
+  mCmapid = mSCmapid;
+  mZoom = mSZoom;
+}
Index: /trunk/SophyaPI/PIext/pistdimgapp.h
===================================================================
--- /trunk/SophyaPI/PIext/pistdimgapp.h	(revision 165)
+++ /trunk/SophyaPI/PIext/pistdimgapp.h	(revision 165)
@@ -0,0 +1,161 @@
+// 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 "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);
+
+     int  DispImage(P2DArrayAdapter* nouv, string const & name, int opt);
+     int  DispScDrawer(PIDrawer* scd, string const & name, int opt, string title="", bool h2d=false);
+     int  Disp3DDrawer(PIDrawer3D* scd, string const & name, int opt, string title="");
+
+     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);
+     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 CutTools*  CutTC()  { return mCutTC; }   A reactiver plus tard ?  Reza 08/98
+
+     inline ObjMgrWind* ObjMgrW() { return mObjmgrw; }
+     inline PPInMgrWind* PPInMgrW() { return mPpinmgrw; }
+
+// Redirection ou Non de StdOut/StdErr
+     void  RedirectStdOutErr(bool fg = true);
+// Gestion des signaux
+     void  CatchSignals(bool fg = 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);
+// 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[6];
+    PIMenu* mc;
+
+    PIPixmap* zoom;
+    PIPixmap* gimv;
+    PICMapView* cmapv;
+
+    PIFileChooser * pfc;
+
+//    CutTools* mCutTC;               // mTCId = 3   A reactiver plus tard ?  Reza 08/98
+//    PIContainer* mTC;   A reactiver plus tard ?  Reza 08/98 
+
+    PIConsole* 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;
+
+    PIMessage mFCMsg;  // Message for processing FileOpen
+    int mFgScSz;   // Dlag ScreenSize
+    bool mFgCWImg; // true -> Current Widget is PIImage
+};
+
+#endif
Index: /trunk/SophyaPI/PIext/pistlist.cc
===================================================================
--- /trunk/SophyaPI/PIext/pistlist.cc	(revision 165)
+++ /trunk/SophyaPI/PIext/pistlist.cc	(revision 165)
@@ -0,0 +1,101 @@
+#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
+  float 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, float xmin, float ymin, float xmax, float ymax)
+{
+BStar *sti;
+float xp,yp,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);
+    float 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);
+*/
+
+}
+
Index: /trunk/SophyaPI/PIext/pistlist.h
===================================================================
--- /trunk/SophyaPI/PIext/pistlist.h	(revision 165)
+++ /trunk/SophyaPI/PIext/pistlist.h	(revision 165)
@@ -0,0 +1,30 @@
+#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, float xmin, float ymin, float xmax, float ymax);
+  virtual void       UpdateLimits();
+  
+  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: /trunk/SophyaPI/PIext/servnobjm.cc
===================================================================
--- /trunk/SophyaPI/PIext/servnobjm.cc	(revision 165)
+++ /trunk/SophyaPI/PIext/servnobjm.cc	(revision 165)
@@ -0,0 +1,791 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include <dlfcn.h>
+
+#include <iostream.h>
+#include <string>
+#include <list>
+#include <map>
+#if defined(__KCC__)
+using std::string ;
+#include <list.h>
+#include <map.h>
+#endif
+
+#include "strutil.h"
+#include "datatypes.h"
+
+#include "nobjmgr.h"
+#include "servnobjm.h"
+#include "pistdimgapp.h"
+
+#include "pclassids.h"
+#include "histos.h"
+#include "histos2.h"
+#include "ntuple.h"
+#include "hisprof.h"
+#include "generaldata.h"
+
+#include "cimage.h"
+#include "cvector.h"
+#include "matrix.h"
+
+//  Si le module StarReco++ a ete compile (Pour les StarList, Transfo, etc ...
+#ifndef SANS_StarReco 
+#include "stlist.h"
+#include "star.h"
+#endif
+
+
+/* --Methode-- */
+Services2NObjMgr::Services2NObjMgr(PIStdImgApp* app, string& tmpdir)
+{
+TmpDir = tmpdir;
+mImgapp = app;
+dlhandle = NULL;
+InitGrAttNames();
+}
+  
+/* --Methode-- */
+Services2NObjMgr::~Services2NObjMgr()
+{
+CloseDLL();
+}
+
+/* --Methode-- */
+void Services2NObjMgr::Nobj_ComputeExpressions(PPersist* obj, string& expx, string& expy, string& expz, 
+                          string& expwt, string& expcut, NTuple* nt, Histo* h1, Histo2D* h2, HProf* hp)
+{
+int cid = obj->ClassId();
+
+string vardec;
+switch (cid) {
+  case ClassId_Vector : 
+    vardec = "double i,val; \n";
+    vardec += "i = _zz61qq_[0];  val = _zz61qq_[1]; \n";
+    break;
+
+  case ClassId_Matrix : 
+    vardec = "double i,j,val; \n";
+    vardec += "i = _zz61qq_[0];  j = _zz61qq_[1];  val = _zz61qq_[2]; \n";
+    break;
+
+  case ClassId_Histo1D : 
+  case ClassId_HProf : 
+    vardec = "double i,x,val,err; \n";
+    vardec += "i = _zz61qq_[0];  x = _zz61qq_[1];  val = _zz61qq_[2];  err = _zz61qq_[3]; \n";
+    break;
+
+  case ClassId_Histo2D : 
+    vardec = "double i,j,x,y,val,err; \n";
+    vardec += "i = _zz61qq_[0];  j = _zz61qq_[1]; \n";  
+    vardec += "x = _zz61qq_[2];  y = _zz61qq_[3]; \n";  
+    vardec += "val = _zz61qq_[4]; err = _zz61qq_[5]; \n";
+    break;
+
+  case ClassId_Image : 
+  case ClassId_Image + kuint_1 : 
+  case ClassId_Image + kint_1 : 
+  case ClassId_Image + kr_8 : 
+  case ClassId_Image + kuint_4 : 
+  case ClassId_Image + kuint_2 : 
+  case ClassId_Image + kint_2 : 
+  case ClassId_Image + kint_4 : 
+  case ClassId_Image + kr_4 : 
+    vardec = "double x,y,pix,i,j,val; \n";
+    vardec += "x = i = _zz61qq_[0];  y = j = _zz61qq_[1];  pix = val = _zz61qq_[2]; \n";
+    break;
+
+#ifndef SANS_StarReco 
+  case ClassId_StarList : 
+    vardec = "double x,y,flux,fond; \n";
+    vardec += "x = _zz61qq_[0];  y = _zz61qq_[1];  flux = _zz61qq_[2];  fond =  _zz61qq_[3]; \n";
+    break;
+#endif
+
+  case ClassId_NTuple :
+    vardec = ((NTuple*)obj)->VarList_C("_zz61qq_");
+    break;
+
+  case ClassId_GeneralFitData :
+    vardec = ((GeneralFitData*)obj)->VarList_C("_zz61qq_");
+    break;
+
+  default :
+    cerr << "NamedObjMgr_ComputeExpressions() Error , N/A to " << PClassIdToClassName(cid) << endl; 
+    return;
+  }
+
+PlotExprFunc f = LinkExprFunc(vardec, expx, expy, expz, expwt, expcut);
+if (!f) { 
+  cerr << "NamedObjMgr_ComputeExpressions() Error Creation PlotExprFunc " <<  endl; 
+  return;
+  }
+
+float x[10], xnt[10];
+
+int i,j,k;
+for(i=0; i<10; i++) x[i] = xnt[i] = 0.;
+
+TRY {                                 
+switch (cid) {
+  case ClassId_Vector :
+    { 
+    Vector* vv = (Vector*)obj;
+    for(k=0; k<vv->NElts(); k++) {
+      x[0] = k;   x[1] = (*vv)(k);
+      if (f(x, xnt, xnt+1, xnt+2, xnt+3) != 0) {
+        if (nt) nt->Fill(xnt);
+        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]);
+        }
+      }
+    }
+    break;
+
+  case ClassId_Matrix : 
+    {
+    Matrix* mm = (Matrix*)obj;
+    for(j=0; j<mm->NCol(); j++)
+      for(i=0; i<mm->NRows(); i++) {
+      x[0] = i; x[1] = j;  x[2] = (*mm)(i,j);
+      if (f(x, xnt, xnt+1, xnt+2, xnt+3) != 0) {
+        if (nt) nt->Fill(xnt);
+        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]);
+        }
+      }
+    }
+    break;
+
+  case ClassId_Histo1D : 
+  case ClassId_HProf : 
+    {
+    Histo* hh = (Histo*)obj;
+    for(k=0; k<hh->NBins(); k++) {
+      x[0] = k;  x[1] = hh->BinCenter(k);   
+      x[2] = (*hh)(k);  x[3] = hh->Error(k);
+      if (f(x, xnt, xnt+1, xnt+2, xnt+3) != 0) {
+        if (nt) nt->Fill(xnt);
+        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]);
+        }
+      }
+    }
+    break;
+
+  case ClassId_Histo2D : 
+    {
+    Histo2D* hh = (Histo2D*)obj;
+    for(j=0; j<hh->NBinY(); j++)
+      for(i=0; i<hh->NBinX(); i++) {
+      x[0] = i;   x[1] = j; 
+      hh->BinCenter(i,j,x[2],x[3]); 
+      x[4] = (*hh)(i,j);  x[5] = hh->Error(i, j);
+      if (f(x, xnt, xnt+1, xnt+2, xnt+3) != 0) {
+        if (nt) nt->Fill(xnt);
+        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]);
+        }
+      }
+    }
+    break;
+
+
+  case ClassId_Image : 
+  case ClassId_Image + kuint_1 : 
+  case ClassId_Image + kint_1 : 
+  case ClassId_Image + kr_8 : 
+  case ClassId_Image + kuint_4 : 
+  case ClassId_Image + kuint_2 : 
+  case ClassId_Image + kint_2 : 
+  case ClassId_Image + kint_4 : 
+  case ClassId_Image + kr_4 :
+    {
+    RzImage* img = (RzImage*)obj; 
+    for(j=0; j<img->YSize(); j++)
+      for(i=0; i<img->XSize(); i++) {
+        x[0] = i;  x[1] = j;  x[2] = img->FValue(i, j);
+        if (f(x, xnt, xnt+1, xnt+2, xnt+3) != 0) {
+          if (nt) nt->Fill(xnt);
+          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]);
+          }
+      }
+    }
+    break;
+
+#ifndef SANS_StarReco 
+  case ClassId_StarList : 
+    {
+    StarList* stl = (StarList*)obj;
+    BStar *sti;
+    for(k=0; k<stl->NbStars(); k++) {
+      sti = stl->Star(k);
+      if ( (!sti) || !(sti->Nice(BStar::flagOK)) )  continue;
+      x[0] = sti->PosX();   x[1] = sti->PosY();
+      x[2] = sti->Flux();   x[3] =  sti->Fond();  
+      if (f(x, xnt, xnt+1, xnt+2, xnt+3) != 0) {
+        if (nt) nt->Fill(xnt);
+        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]);
+        }
+      }
+    }
+    break;
+#endif
+
+  case ClassId_NTuple :
+    {
+    NTuple* ntp = (NTuple*)obj;
+    r_4* xn;
+    for(k=0; k<ntp->NEntry(); k++)    {
+      xn = ntp->GetVec(k);
+      if (f(xn, xnt, xnt+1, xnt+2, xnt+3) != 0) {
+        if (nt) nt->Fill(xnt);
+        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]);
+        }
+      }
+    }
+    break;
+
+  case ClassId_GeneralFitData :
+    {
+    GeneralFitData* data = (GeneralFitData*)obj;
+    r_4* xn;
+    int iok = 2*data->NVar()+2;
+    for(k=0; k<data->NData(); k++) {
+      xn = data->GetVecR4(k);
+      if(xn[iok]<0.001) continue;
+      if (f(xn, xnt, xnt+1, xnt+2, xnt+3) != 0) {
+        if (nt) nt->Fill(xnt);
+        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]);
+      }
+    }
+    }
+    break;
+
+  default :
+    cout << "NamedObjMgr_ComputeExpressions() Erreur: N/A to  " << PClassIdToClassName(cid) << endl; 
+    return;
+  }
+} CATCH(merr) {
+  fflush(stdout); 
+  cout << endl; 
+  cerr << endl;
+  string es = PeidaExc(merr);
+  cerr << "NamedObjMgr_ComputeExpressions()  Exception :" << merr << es;
+  } ENDTRY;
+ 
+
+// Fermeture du fichier .so 
+CloseDLL();
+return;
+}
+
+
+/* --Methode-- */
+PlotExprFunc Services2NObjMgr::LinkExprFunc(string& vardec, string& expx, string& expy, string& expz, 
+                                            string& expwt, string& cut)
+{
+FILE *fip;
+string fname = TmpDir + "expf_pia_dl.c";
+string fnamer = TmpDir + "expf_pia_dl";
+string cmd;
+int rc;
+
+cmd = "rm " + 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 << "NamedObjMgr/LinkExprFunc_Erreur: Pb. Ouverture " << sn << endl; 
+  return(NULL); 
+  }
+
+// constitution du fichier a compiler
+fputs("#include <math.h> \n", fip);
+fputs("int expf_pia_dl_func(float* _zz61qq_, float* _rx_61qq_, float* _ry_61qq_, float* _rz_61qq_, float* _wt_61qq_) \n{\n", fip);
+fprintf(fip,"%s \n", vardec.c_str());
+fprintf(fip, "if (!(%s)) { *_rx_61qq_ = *_ry_61qq_ = *_rz_61qq_ = *_wt_61qq_ = 0.;  return(0); } \n", cut.c_str());
+fprintf(fip, "*_rx_61qq_ = %s ; \n", expx.c_str());
+fprintf(fip, "*_ry_61qq_ = %s ; \n", expy.c_str());
+fprintf(fip, "*_rz_61qq_ = %s ; \n", expz.c_str());
+fprintf(fip, "*_wt_61qq_ = %s ; \n", expwt.c_str());
+fputs("return(1); \n} \n", fip);
+fclose(fip);
+
+return((PlotExprFunc)LinkFunctionFromFile(fnamer, "expf_pia_dl_func"));
+}
+
+
+/* --Methode-- */
+DlFunction Services2NObjMgr::LinkFunctionFromFile(string& fnamer, char* funcname)
+{
+string fname = fnamer + ".c" ;
+string fnameobj = fnamer + ".o" ;
+string fnameso = fnamer + ".so";
+string cmd;
+int rc;
+
+
+// Compilation du fichier
+cmd = "cc -c -o " + fnameobj + " " + fname;
+rc = system(cmd.c_str());
+
+if (rc != 0)  { 
+  printf("LinkFunctionFromFile_Do> %s  (Rc=%d)\n", cmd.c_str(), rc); 
+  return(NULL);
+  }
+#if defined(OSF1) 
+  cmd = "ld -shared -o " + fnameso + " -all " + fnameobj + " -none -lm -lc";
+#else
+  cmd = "ld -shared -o " + fnameso + " " + fnameobj + " -lm -lc";
+#endif
+rc = system(cmd.c_str());
+if (rc != 0 ) { 
+  printf("LinkFunctionFromFile_Do> %s  (Rc=%d)\n", cmd.c_str(), rc); 
+  return(NULL);
+  }
+
+//  Le link dynamique
+CloseDLL();
+dlhandle =  dlopen(fnameso.c_str(), RTLD_NOW);
+if (dlhandle == NULL) { 
+  string sn = fnameso; 
+  cerr << "NamedObjMgr/FunctionFromFile_Erreur: Erreur ouverture SO " << sn << endl; 
+  sn = dlerror();
+  cerr << "Loader Error (dlerror()) :" << sn;
+  return(NULL); 
+  }
+
+DlFunction retfunc = (DlFunction) dlsym(dlhandle, funcname);
+if (retfunc == NULL) { 
+  string sn = funcname; 
+  cerr << "NamedObjMgr/LinkExprFunc_Erreur: Erreur linking " << sn << endl; 
+  CloseDLL();
+  return(NULL); 
+  }
+else return(retfunc);
+}
+
+/* --Methode-- */
+void Services2NObjMgr::CloseDLL()
+{
+if (dlhandle) dlclose(dlhandle);    dlhandle = NULL;
+}
+
+/* --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 q = fn.find_last_of(tsep);
+if (p < 0)  p = 0;
+p++;
+if (q < p) q = fn.length();
+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.substr(0,3) == "def")  {  // Remise aux valeurs par defaut = non defini
+  mImgapp->SetColAtt();
+  mImgapp->SetLineAtt();
+  mImgapp->SetFontAtt();
+  mImgapp->SetMarkerAtt();
+  mImgapp->SetColMapId();
+  mImgapp->SetZoomAtt();
+  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;
+  
+  // 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; }  
+  
+  }  
+
+return(ropt);
+}
+
+/* --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_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");
+
+#ifndef SANS_StarReco 
+  case ClassId_StarList : 
+    return("StarList");
+  case ClassId_Transfo : 
+    return("Transfo");
+  case ClassId_PSF : 
+    return("PSF");
+
+  case ClassId_Star + BStar_Type : 
+    return("BStar");
+  case ClassId_Star + RzStar_Type : 
+    return("RzStar");
+  case ClassId_Star + PSFStar_Type : 
+    return("PSFStar");
+  case ClassId_Star + MCStar_Type : 
+    return("MCStar");
+  case ClassId_Star + CircRFixStar_Type : 
+    return("CircRFixStar");
+  case ClassId_Star + PSFDHStar_Type : 
+    return("PSFDHStar");
+  case ClassId_Star + PSFSEStar_Type : 
+    return("PSFSEStar");
+  case ClassId_Star + MCDHStar_Type : 
+    return("MCDHStar");
+#endif
+
+// - Ajout objet PPF
+  default:
+    return("Unknown");
+  }
+}  
+
+/* --Methode-- */
+char* Services2NObjMgr::PClassIdToShortClassName(int cid)
+{
+switch (cid) {
+  case ClassId_Poly1 : 
+  case ClassId_Poly2 : 
+    return("Poly");
+  case ClassId_Matrix : 
+    return("Mtx");
+  case ClassId_Vector : 
+    return("Vec");
+  case ClassId_DVList : 
+    return("Dvl");
+
+  case ClassId_Histo1D : 
+    return("H1D");
+  case ClassId_Histo2D : 
+    return("H2D");
+  case ClassId_HProf : 
+    return("HPF");
+  case ClassId_NTuple : 
+    return("NT");
+  case ClassId_GeneralFitData : 
+    return("GFD");
+
+  case ClassId_Image : 
+  case ClassId_Image + kuint_1 : 
+  case ClassId_Image + kint_1 : 
+  case ClassId_Image + kuint_2 : 
+  case ClassId_Image + kint_2 : 
+  case ClassId_Image + kuint_4 : 
+  case ClassId_Image + kint_4 : 
+  case ClassId_Image + kr_4 : 
+  case ClassId_Image + kr_8 : 
+    return("Img");
+
+  case ClassId_ZFidu : 
+    return("Fidu");
+
+#ifndef SANS_StarReco 
+  case ClassId_StarList : 
+    return("Stl");
+  case ClassId_Transfo : 
+    return("Tr");
+  case ClassId_PSF : 
+    return("PSF");
+
+  case ClassId_Star + BStar_Type : 
+  case ClassId_Star + RzStar_Type : 
+  case ClassId_Star + PSFStar_Type : 
+  case ClassId_Star + MCStar_Type : 
+  case ClassId_Star + CircRFixStar_Type : 
+  case ClassId_Star + PSFDHStar_Type : 
+  case ClassId_Star + PSFSEStar_Type : 
+  case ClassId_Star + MCDHStar_Type : 
+    return("Star");
+#endif
+
+// - Ajout objet PPF
+  default:
+    return("U");
+  }
+}  
+
+// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+// 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;
+
+// Les fontes (a faire)
+gi.a2 = PI_NotDefFontSize;
+gi.a1 = PI_NotDefFontAtt;
+GrAlines["deffont"] = gi;
+
+gi.a2 = PI_NormalSizeFont;
+gi.a1 = PI_RomanFont;
+GrAlines["normalfont"] = gi;
+gi.a1 = PI_BoldFont;
+GrAlines["boldfont"] = gi;
+gi.a1 = PI_ItalicFont;
+GrAlines["italicfont"] = gi;
+gi.a2 = PI_SmallSizeFont;
+gi.a1 = PI_RomanFont;
+GrAlines["smallfont"] = gi;
+gi.a1 = PI_BoldFont;
+GrAlines["smallboldfont"] = gi;
+gi.a1 = PI_ItalicFont;
+GrAlines["smallitalicfont"] = gi;
+gi.a2 = PI_BigSizeFont;
+gi.a1 = PI_RomanFont;
+GrAlines["bigfont"] = gi;
+gi.a1 = PI_BoldFont;
+GrAlines["bigboldfont"] = gi;
+gi.a1 = PI_ItalicFont;
+GrAlines["bigitalicfont"] = gi;
+
+
+// Les markers 
+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;
+
+// Les tables de couleurs 
+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;
+                 
+}
Index: /trunk/SophyaPI/PIext/servnobjm.h
===================================================================
--- /trunk/SophyaPI/PIext/servnobjm.h	(revision 165)
+++ /trunk/SophyaPI/PIext/servnobjm.h	(revision 165)
@@ -0,0 +1,67 @@
+// 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 "defs.h"
+#include <string>
+
+#include "ctimer.h"
+
+#include "dlftypes.h"
+
+class NTuple;
+class Histo;
+class Histo2D;
+class HProf;
+class PIStdImgApp;
+
+class Services2NObjMgr {
+public:
+         	Services2NObjMgr(PIStdImgApp* app, string& tmpdir);
+		~Services2NObjMgr();
+
+  inline void   SetImgApp(PIStdImgApp* app) {mImgapp = app; }
+
+  void 		Nobj_ComputeExpressions(PPersist* obj, string& expx, string& expy, string& expz, 
+                                        string& expwt, string& expcut,
+                                        NTuple* nt=NULL, Histo* h1=NULL,
+                                        Histo2D* h2=NULL, HProf* hp=NULL);
+  PlotExprFunc  LinkExprFunc(string& vardec, string& expx, string& expy, string& expz, 
+                             string& wt, string& cut);
+  DlFunction    LinkFunctionFromFile(string& fnamer, char* funcname);
+  void 		CloseDLL();  
+
+  char* 	PClassIdToClassName(int cid);
+  char* 	PClassIdToShortClassName(int cid);
+  string 	FileName2Name(string const & fn);
+  int 		DecodeDispOption(string& dopt, bool& fgsrgr);
+
+  void 		InitGrAttNames();
+
+//   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;  
+
+  void* dlhandle;  // shared-lib lib.so
+  string TmpDir;   // Pour le link dynamique
+
+  PIStdImgApp* mImgapp;
+  
+};
+
+
+#endif
