Index: /tags/V_Saclay_110697/SophyaPI/PI/Makefile
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/Makefile	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/Makefile	(revision 50)
@@ -0,0 +1,211 @@
+include ../Mgr/Makefile.h
+ 
+all: $(LIB)libPI.a
+$(LIB)libPI.a : $(OBJ)piapplgen.o $(OBJ)piapplx.o $(OBJ)pibwdggen.o $(OBJ)pibwdgx.o $(OBJ)picmap.o $(OBJ)picmapgen.o $(OBJ)picmapx.o $(OBJ)picontainergen.o $(OBJ)picontainerx.o $(OBJ)pidrawwin.o $(OBJ)pifilechogen.o $(OBJ)pifilechox.o $(OBJ)pihisto.o $(OBJ)piimage.o $(OBJ)pilistgen.o $(OBJ)pilistx.o $(OBJ)pimenubargen.o $(OBJ)pimenubarx.o $(OBJ)pimenugen.o $(OBJ)pimenux.o $(OBJ)pimsghandler.o $(OBJ)pioptmenugen.o $(OBJ)pioptmenux.o $(OBJ)piperiodx.o $(OBJ)pipixmapgen.o $(OBJ)pipixmapx.o $(OBJ)piscdrawwdg.o $(OBJ)pistdwdggen.o $(OBJ)pistdwdgx.o $(OBJ)pistlist.o $(OBJ)piup.o $(OBJ)piwdggen.o $(OBJ)piwdgx.o $(OBJ)piwindowgen.o $(OBJ)piwindowx.o $(OBJ)pixtbase.o $(OBJ)psfile.o
+	$(AR) $(ARFLAGS)  $@ $?
+ 
+$(OBJ)piapplgen.o: piapplgen.cc piapplgen.h pimsghandler.h pisysdep.h \
+ picontainerx.h picontainergen.h piwdgx.h piwdggen.h pimenubarx.h \
+ pimenubargen.h pimenux.h pimenugen.h
+$(OBJ)piapplx.o: piapplx.cc piapplx.h piapplgen.h pimsghandler.h pisysdep.h \
+ picontainerx.h picontainergen.h piwdgx.h piwdggen.h pimenubarx.h \
+ pimenubargen.h pimenux.h pimenugen.h
+$(OBJ)pibwdggen.o: pibwdggen.cc pibwdggen.h pisysdep.h piwdgx.h piwdggen.h \
+ pimsghandler.h psfile.h $(INC)defs.h \
+ pibwdgx.h picmap.h picmapx.h picmapgen.h
+$(OBJ)pibwdgx.o: pibwdgx.cc pibwdgx.h pisysdep.h pibwdggen.h piwdgx.h \
+ piwdggen.h pimsghandler.h pixtbaseP.h pixtbase.h psfile.h \
+ $(INC)defs.h picmap.h picmapx.h picmapgen.h
+$(OBJ)picmap.o: picmap.cc picmap.h pisysdep.h picmapx.h picmapgen.h
+$(OBJ)picmapgen.o: picmapgen.cc picmapgen.h pisysdep.h picmapx.h picmap.h
+$(OBJ)picmapx.o: picmapx.cc piwdgx.h piwdggen.h pimsghandler.h picmapx.h \
+ picmapgen.h pisysdep.h
+$(OBJ)picontainergen.o: picontainergen.cc picontainergen.h pisysdep.h \
+ piwdgx.h piwdggen.h pimsghandler.h
+$(OBJ)picontainerx.o: picontainerx.cc picontainerx.h pisysdep.h \
+ picontainergen.h piwdgx.h piwdggen.h pimsghandler.h
+$(OBJ)pidrawwin.o: pidrawwin.cc pidrawwin.h pisysdep.h piwindowx.h \
+ piwindowgen.h picontainerx.h picontainergen.h piwdgx.h piwdggen.h \
+ pimsghandler.h piscdrawwdg.h pibwdgx.h pibwdggen.h pistdwdgx.h \
+ pistdwdggen.h
+$(OBJ)pifilechogen.o: pifilechogen.cc pifilechogen.h pisysdep.h piwdgx.h \
+ piwdggen.h pimsghandler.h
+$(OBJ)pifilechox.o: pifilechox.cc pisysdep.h pifilechox.h pifilechogen.h \
+ piwdgx.h piwdggen.h pimsghandler.h piwindowx.h piwindowgen.h \
+ picontainerx.h picontainergen.h
+$(OBJ)pihisto.o: pihisto.cc pihisto.h piscdrawwdg.h pisysdep.h pibwdgx.h \
+ pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h pistdwdgx.h \
+ pistdwdggen.h piwindowx.h piwindowgen.h picontainerx.h \
+ picontainergen.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
+$(OBJ)piimage.o: piimage.cc piimage.h $(INC)cimage.h \
+ $(INC)rzimage.h \
+ $(INC)rzvect.h \
+ $(INC)machine.h \
+ $(INC)defs.h \
+ $(INC)exceptions.h \
+ $(INC)peidainit.h \
+ $(INC)perrors.h \
+ $(INC)imaginit.h \
+ $(INC)datatypes.h \
+ $(INC)ppersist.h \
+ $(INC)pclassids.h \
+ $(INC)dvlist.h \
+ $(INC)lut.h pisysdep.h pipixmapx.h \
+ pipixmapgen.h pibwdgx.h pibwdggen.h piwdgx.h piwdggen.h \
+ pimsghandler.h picmap.h picmapx.h picmapgen.h pistdwdgx.h \
+ pistdwdggen.h piwindowx.h piwindowgen.h picontainerx.h \
+ picontainergen.h $(INC)imageop.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)peida.h \
+ $(INC)utils.h \
+ $(INC)fmath.h \
+ $(INC)array.h \
+ $(INC)lockfile.h \
+ $(INC)erostarfile.h \
+ $(INC)dates.h \
+ $(INC)tarlib.h
+$(OBJ)pilistgen.o: pilistgen.cc pilistgen.h pisysdep.h piwdgx.h piwdggen.h \
+ pimsghandler.h
+$(OBJ)pilistx.o: pilistx.cc pilistx.h pilistgen.h pisysdep.h piwdgx.h \
+ piwdggen.h pimsghandler.h picontainerx.h picontainergen.h
+$(OBJ)pimenubargen.o: pimenubargen.cc pimenubargen.h pisysdep.h pimenux.h \
+ pimenugen.h piwdgx.h piwdggen.h pimsghandler.h piapplx.h piapplgen.h \
+ picontainerx.h picontainergen.h pimenubarx.h
+$(OBJ)pimenubarx.o: pimenubarx.cc pimenubarx.h pimenubargen.h pisysdep.h \
+ pimenux.h pimenugen.h piwdgx.h piwdggen.h pimsghandler.h piapplx.h \
+ piapplgen.h picontainerx.h picontainergen.h
+$(OBJ)pimenugen.o: pimenugen.cc pimenugen.h pisysdep.h piwdgx.h piwdggen.h \
+ pimsghandler.h
+$(OBJ)pimenux.o: pimenux.cc pimenux.h pimenugen.h pisysdep.h piwdgx.h \
+ piwdggen.h pimsghandler.h
+$(OBJ)pimsghandler.o: pimsghandler.cc pimsghandler.h
+$(OBJ)pioptmenugen.o: pioptmenugen.cc pioptmenugen.h pisysdep.h \
+ picontainerx.h picontainergen.h piwdgx.h piwdggen.h pimsghandler.h \
+ pimenux.h pimenugen.h
+$(OBJ)pioptmenux.o: pioptmenux.cc pisysdep.h pioptmenux.h pioptmenugen.h \
+ picontainerx.h picontainergen.h piwdgx.h piwdggen.h pimsghandler.h \
+ pimenux.h pimenugen.h pistdwdgx.h pistdwdggen.h
+$(OBJ)piperiodx.o: piperiodx.cc piperiodx.h \
+ $(INC)periodic.h \
+ $(INC)defs.h
+$(OBJ)pipixmapgen.o: pipixmapgen.cc pipixmapgen.h pisysdep.h pibwdgx.h \
+ pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h picmap.h picmapx.h \
+ picmapgen.h
+$(OBJ)pipixmapx.o: pipixmapx.cc pipixmapx.h pipixmapgen.h pisysdep.h \
+ pibwdgx.h pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h picmap.h \
+ picmapx.h picmapgen.h psfile.h $(INC)defs.h
+$(OBJ)piscdrawwdg.o: piscdrawwdg.cc piscdrawwdg.h pisysdep.h pibwdgx.h \
+ pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h pistdwdgx.h \
+ pistdwdggen.h piwindowx.h piwindowgen.h picontainerx.h \
+ picontainergen.h $(INC)generalfit.h \
+ $(INC)exceptions.h \
+ $(INC)defs.h \
+ $(INC)peidainit.h \
+ $(INC)matrix.h \
+ $(INC)peida.h \
+ $(INC)utils.h \
+ $(INC)machine.h \
+ $(INC)perrors.h \
+ $(INC)fmath.h \
+ $(INC)ppersist.h \
+ $(INC)pclassids.h \
+ $(INC)cvector.h
+$(OBJ)pistdwdggen.o: pistdwdggen.cc pistdwdggen.h pisysdep.h piwdgx.h \
+ piwdggen.h pimsghandler.h
+$(OBJ)pistdwdgx.o: pistdwdgx.cc pisysdep.h pistdwdgx.h pistdwdggen.h \
+ piwdgx.h piwdggen.h pimsghandler.h
+$(OBJ)pistlist.o: pistlist.cc pistlist.h piscdrawwdg.h pisysdep.h pibwdgx.h \
+ pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h pistdwdgx.h \
+ pistdwdggen.h piwindowx.h piwindowgen.h picontainerx.h \
+ picontainergen.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)imaginit.h \
+ $(INC)star.h \
+ $(INC)strecinit.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)generalfit.h \
+ $(INC)matrix.h \
+ $(INC)cvector.h \
+ $(INC)transfo.h \
+ $(INC)poly.h \
+ $(INC)zfidu.h
+$(OBJ)piup.o: piup.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 \
+ $(INC)imageop.h \
+ $(INC)cimage.h \
+ $(INC)rzimage.h \
+ $(INC)rzvect.h \
+ $(INC)imaginit.h \
+ $(INC)datatypes.h \
+ $(INC)ppersist.h \
+ $(INC)pclassids.h \
+ $(INC)dvlist.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)dates.h \
+ $(INC)tarlib.h piup.h
+$(OBJ)piwdggen.o: piwdggen.cc piwdggen.h pimsghandler.h picontainergen.h \
+ pisysdep.h piwdgx.h psfile.h $(INC)defs.h \
+ pibwdgx.h pibwdggen.h picmap.h picmapx.h picmapgen.h
+$(OBJ)piwdgx.o: piwdgx.cc piwdgx.h piwdggen.h pimsghandler.h picontainerx.h \
+ pisysdep.h picontainergen.h
+$(OBJ)piwindowgen.o: piwindowgen.cc piwindowgen.h pisysdep.h picontainerx.h \
+ picontainergen.h piwdgx.h piwdggen.h pimsghandler.h psfile.h \
+ $(INC)defs.h pibwdgx.h pibwdggen.h picmap.h \
+ picmapx.h picmapgen.h
+$(OBJ)piwindowx.o: piwindowx.cc piwindowx.h piwindowgen.h pisysdep.h \
+ picontainerx.h picontainergen.h piwdgx.h piwdggen.h pimsghandler.h
+$(OBJ)pixtbase.o: pixtbase.cc pixtbaseP.h pibwdgx.h pisysdep.h pibwdggen.h \
+ piwdgx.h piwdggen.h pimsghandler.h pixtbase.h
+$(OBJ)psfile.o: psfile.cc psfile.h $(INC)defs.h \
+ pisysdep.h pibwdgx.h pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h \
+ picmap.h picmapx.h picmapgen.h
Index: /tags/V_Saclay_110697/SophyaPI/PI/ex_dessin.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/ex_dessin.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/ex_dessin.cc	(revision 50)
@@ -0,0 +1,156 @@
+#include <stdio.h>
+#include <string.h>
+
+#include "ex_dessin.h"
+
+
+
+/* --Methode-- */
+ExBWdg::ExBWdg(PIContainerGen *par, char *nom,
+                       int sx, int sy, int px, int py) 
+: PIBaseWdg(par, nom, sx, sy, px, py)
+
+{
+mmrk = mfnt = nc = 0;
+strcpy(str, "Bonjour");
+for(int i=strlen(str); i<20; i++) str[i] = ' ';
+str[20] = '\0';
+
+ActivateKeyboard();
+ActivateButton(1);
+ActivateButton(2);
+ActivateButton(3);
+}
+
+
+/* --Methode-- */
+ExBWdg::~ExBWdg()
+{
+}
+
+ 
+
+
+/* --Methode-- */
+void ExBWdg::Resize()
+{
+
+}
+
+
+/* --Methode-- */
+void ExBWdg::Draw()
+{
+EraseWindow();
+SelLine(PI_NormalLine);
+DrawBox(10,10, XSize()-20, YSize()-20);
+
+SelLine(PI_ThinLine);
+DrawFBox(20, 20, 20, 20);
+DrawCircle(30, 30, 15);
+
+SelForeground(PI_Red);
+DrawFCircle(70, 30, 15);
+
+SelForeground(PI_Yellow);
+DrawFBox(10, 60, 100, 15);
+
+SelForeground(PI_Black);
+DrawString(20, 90, str);
+
+SelLine(PI_ThinLine);
+DrawLine(10, 120, 40, 120);
+SelLine(PI_NormalLine);
+DrawLine(40, 120, 70, 120);
+SelLine(PI_ThickLine);
+DrawLine(70, 120, 100, 120);
+
+SelForeground(PI_Magenta);
+DrawFCircle(120, 30, 15);
+SelForeground(PI_Grey);
+DrawFCircle(120, 60, 15);
+
+int x[5] = { 20, 35, 50, 65, 80 };
+int y[5] = { 130, 130, 130, 130, 130 };
+
+SelForeground(PI_Black);
+DrawMarkers(x, y, 5);
+return;
+}
+
+
+
+
+/* --Methode-- */
+void ExBWdg::But1Press(int x, int y)
+{
+SelPointerShape(PI_CrossPointer);
+return;
+}
+
+/* --Methode-- */
+void ExBWdg::But1Release(int x, int y)
+{
+SelPointerShape(PI_ArrowPointer);
+return;
+}
+
+/* --Methode-- */
+void ExBWdg::But2Press(int x, int y)
+{
+PIFontAtt att[3] = { PI_RomanFont, PI_BoldFont, PI_ItalicFont};
+PIMarker  pmk[9] = { PI_DotMarker , PI_PlusMarker, PI_CrossMarker,  
+                 PI_CircleMarker, PI_FCircleMarker,
+                 PI_BoxMarker, PI_FBoxMarker,
+                 PI_TriangleMarker, PI_FTriangleMarker };
+
+if (++mfnt > 2)  mfnt = 0;
+if (++mmrk > 8)  mmrk = 0; 
+SelFont(PI_NormalSizeFont, att[mfnt]);
+SelMarker(8, pmk[mmrk]);
+return;
+}
+
+/* --Methode-- */
+void ExBWdg::But2Release(int x, int y)
+{
+Refresh();
+return;
+}
+
+/* --Methode-- */
+void ExBWdg::But3Press(int x, int y)
+{
+SelPointerShape(PI_HandPointer);
+SelForeground(PI_Blue);
+DrawFBox(0, 0, 8, 8);
+return;
+}
+
+/* --Methode-- */
+void ExBWdg::But3Release(int x, int y)
+{
+SelForeground(PI_White);
+DrawFBox(0, 0, 8, 8);
+SelForeground(PI_Black);
+SelPointerShape(PI_ArrowPointer);
+return;
+}
+
+
+
+/* --Methode-- */
+void ExBWdg::Keyboard(int key, PIKeyModifier kmod)
+{
+char buf[4];
+str[nc] = key;
+if (++nc > 15)  nc = 0;
+buf[0] = key;  buf[1] = '\0';
+
+SelFont(PI_BigSizeFont, PI_BoldFont);
+DrawString(20, 75, buf);
+
+return;
+}
+
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/ex_dessin.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/ex_dessin.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/ex_dessin.h	(revision 50)
@@ -0,0 +1,41 @@
+/*  Exemple d'utilisation PIBaseWdg   */
+
+#ifndef EXBWDG_H_SEEN
+#define EXBWDG_H_SEEN
+
+#include "pisysdep.h"
+
+#include PIBWDG_H
+
+class ExBWdg : public PIBaseWdg
+{
+
+public:
+// Les methodes ...
+
+                  ExBWdg(PIContainerGen *par, char *nom,
+                         int sx=10, int sy=10, int px=0, int py=0);
+  virtual         ~ExBWdg();
+
+
+// Traitement des evenements   
+
+  virtual void   Resize();
+  virtual void   Draw();
+
+  virtual void   But1Press(int x, int y);
+  virtual void   But1Release(int x, int y);
+  virtual void   But2Press(int x, int y);
+  virtual void   But2Release(int x, int y);
+  virtual void   But3Press(int x, int y);
+  virtual void   But3Release(int x, int y);
+  virtual void   Keyboard(int key, PIKeyModifier kmod);
+
+protected:
+  int mfnt, mmrk;
+  int nc;
+  char str[21];
+};
+
+
+#endif 
Index: /tags/V_Saclay_110697/SophyaPI/PI/exapp_1.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/exapp_1.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/exapp_1.cc	(revision 50)
@@ -0,0 +1,313 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "ctimer.h"
+#include "strecinit.h"
+
+#include "pidrawwin.h"
+#include "pihisto.h"
+#include "psfile.h"
+
+#include "exapp_1.h"
+
+static int nbhis = 0;
+static void mypact(void *);
+
+/* --Methode-- */
+PITApp::PITApp(int narg, char* arg[])
+: PIApplication(230, 100, narg, arg), mPeriod(1)   // Periode de 1 seconde pour le "timer"
+{
+
+//  Menus, les numeros ds AppendItem sont les numeros de messages
+//  qui seront passes a Process() et permettent d'identifier l'action
+
+//  Creation du premier menu  
+//  Update :
+//  Mis a jour du Label se trouvant ds la fenetre principal avec l'heure
+//  Start, Stop :
+//  Demarrage et Arret d'une fonction Timer (PIPeriodic) pour 
+//  la mise a jour periodique de ce champ
+//  Exit : 
+//  Arret et sortie du programme
+
+m[0] = new PIPDMenu((PIMsgHandler *)Menubar(),"Fichier");
+m[0]->AppendItem("Update", 10101);
+m[0]->AppendItem("Start", 10102);
+m[0]->AppendItem("Stop", 10103);
+m[0]->AppendItem("Exit", 10105);
+// On accroche le menu au Menubar
+AppendMenu(m[0]);
+
+// 2eme Menu
+// Histo :  Creation, affichage d'un histo
+// Args : Affichage d'une fenetre de dialogue avec champs texte
+// Fermeture fenetre histo + suppression d'histo
+
+m[1] = new PIPDMenu((PIMsgHandler *)Menubar(),"Actions");
+m[1]->AppendItem("Histo", 10201);
+m[1]->AppendItem("Args", 10202);
+m[1]->AppendItem("Close", 10203);
+m[1]->AppendItem("PS", 10205);
+// On accroche le menu au Menubar
+AppendMenu(m[1]);
+
+// Creation de deux labels - Un pour l'heure, l'autre pour X-Y 
+// de la fenetre histo
+lab[0] = new PILabel(this->MainWin(), "time", 210, 30, 10, 10);
+lab[1] = new PILabel(this->MainWin(), "info", 210, 30, 10, 50);
+mPeriod.SetAction(mypact);
+
+// Fenetre de dialogue
+mAW = new ArgsWind(this);
+
+mCurW = NULL;    // Fenetre courante
+SetReady();
+}
+
+/* --Methode-- */
+PITApp::~PITApp()
+{
+int i;
+for(i=0; i<2; i++)  { delete lab[i]; delete m[i]; }
+delete mAW;
+}  
+
+/* --Methode-- */
+void PITApp::Process(PIMessage msg, PIMsgHandler* sender, void* /*data*/)
+{
+
+char strg[64];
+
+// Gestion fenetre courante
+if (ModMsg(msg) == PIMsg_Active)
+  {
+  PIWdg *sndw;
+  sndw = (PIWdg *)sender;      
+  if (sndw->kind() ==  PIWindow::ClassId)   mCurW = (PIWindow *)sender;
+  }
+
+else
+  {
+  switch(UserMsg(msg))
+    {
+
+// --------- 1er menu ----------
+    case 10101:     // On met a l'heure
+      mypact(NULL);    
+      break;
+
+    case 10102:
+      mPeriod.Start();   // On demarre la montre 
+      break;
+
+    case 10103:
+      mPeriod.Stop();    // On demarre la montre 
+      break;
+
+    case 10105:          // Sortie d'application
+      Stop();
+      break;
+
+// ----------  2eme menu --------
+
+    case 10201 :        //  Creation, Affichage d'histo
+      PIDrawWindow *  draw;
+      PIHisto *pih;
+      Histo *h;
+      float x;
+
+      SetBusy();    // souris -> montre 
+      // Creation et remplissage d'histo 
+      h = new Histo(0., 200., 100);  
+      for(int i=0; i<100; i++)  
+        { x = (2*i+1.);  h->Add(x, x*(200.-x)); }
+
+      nbhis++;  sprintf(strg, "Histo %d", nbhis);
+      // Creation d'une fenetre de trace 
+      draw = new PIDrawWindow(this, strg, PIWK_normal, 200, 200, 300, 300);
+      // Creation d'un traceur d'histo
+      pih = new PIHisto(h);   
+
+      pih->SetAutoDelHisto(true);   // Histo delete quand window -> close
+      // Accrochage du traceur d'histo a la fenetre de Draw
+      draw->AddDrawer(pih);   
+      // Designation du champ label pour affichage coordonnees quand click souris
+      draw->DrawWdg()->SetTextWin(lab[1]);
+      draw->SetAutoDelChilds(true);  
+      // On affiche  la fenetre 
+      draw->Show();    
+
+      SetReady();    //  souris->pointeur , on n'est plus occupe
+      break;
+
+    case 10202 :     // Apparition de la fenetre de dialogue
+      mAW->Show();
+      break;
+
+    case 10203 :     // Suppression de la fenetre courante
+      if (mCurW)  { mCurW->Hide();  delete mCurW;}
+      lab[1]->SetLabel("");
+      mCurW = NULL;
+      break;
+
+
+    case 10205 :      // Creation fichier PostScript 
+      if(mCurW) {
+        PSFile *mps;
+        printf("Open PSFile (exapp_1.ps) \n");
+	mps = new PSFile("exapp_1.ps",14,10,
+			 mCurW->XSize(),mCurW->YSize());
+	// Contenu fenetre courante ds .ps 
+	mCurW->PSPrint(mps,0,0);
+	delete mps;
+      }
+      break;
+
+    default :
+      printf("PITApp::Process() Msg= %d (%d - %d)??? \n", 
+            (int)msg, (int)UserMsg(msg),(int)ModMsg(msg));
+     break;
+    }
+  }
+return;
+}
+
+/* ........................................................... */
+/*       Classe ArgsWindow  (Appel UserProc Function)      */
+/* ........................................................... */
+
+
+/* --Methode-- */
+ArgsWind::ArgsWind(PIApplication *par)
+: PIWindow((PIMsgHandler *)par, "Args", PIWK_dialog, 260, 200, 150, 150)
+{
+pap = par;
+
+// Creation de champs "labels"
+mLab[0] = new PILabel(this, "FMin Max:", 100, 35, 20, 10); 
+mLab[1] = new PILabel(this, "XMin Max:", 100, 35, 20, 55);
+mLab[2] = new PILabel(this, "YMin Max:", 100, 35, 20, 100);
+
+// Creation de champs textes 
+mText[0] = new PIText(this, "UsArg1", 130, 35, 120, 10);
+mText[0]->SetText("1. -1.");
+mText[1] = new PIText(this, "UsArg2", 130, 35, 120, 55);
+mText[1]->SetText("1. -1.");
+mText[2] = new PIText(this, "UsArg3", 130, 35, 120, 100);
+mText[2]->SetText("1. -1.");
+
+// Creation de bouton d'action 
+//  Attention : Numero de message pour Process()
+mBut[0] = new PIButton(this, "OK", 555, 70, 30, 30, 160);
+mBut[1] = new PIButton(this, "Cancel", 777, 70, 30, 160, 160);
+FinishCreate();
+
+}
+
+/* --Methode-- */
+ArgsWind::~ArgsWind()
+{
+for(int i=0; i<3; i++)
+  {
+  delete mLab[i];
+  delete mText[i];
+  }
+
+delete mBut[0]; 
+delete mBut[1]; 
+}
+
+/* --Methode-- */
+void ArgsWind::SetLabels(char *lab1, char *lab2, char *lab3)
+// Permet de changer les etiquettes (les label)
+{
+mLab[0]->SetLabel(lab1);
+mLab[1]->SetLabel(lab2);
+mLab[2]->SetLabel(lab3);
+}
+
+/* --Methode-- */
+void ArgsWind::SetTexts(char *tx1, char *tx2, char *tx3)
+// Permet de changer les contenu des champs texte
+{
+mText[0]->SetText(tx1);
+mText[1]->SetText(tx2);
+mText[2]->SetText(tx3);
+
+}
+
+/* --Methode-- */
+void ArgsWind::GetTexts(char *tx1, char *tx2, char *tx3)
+// Permet de recuperer les contenus des champs texte
+// ATTENTION : Il faut qu'il y ait assez de place 
+// ds tx1, tx2, tx3 pour que la fonction puisse y copier 
+// les chaines
+{
+strcpy(tx1, mText[0]->GetText().c_str());
+strcpy(tx2, mText[1]->GetText().c_str());
+strcpy(tx3, mText[2]->GetText().c_str());
+
+}
+
+/* --Methode-- */
+void ArgsWind::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
+{
+float xmin, xmax, ymin, ymax;
+float fmin, fmax;
+
+switch (UserMsg(msg))
+  {
+  case 777:   // Bouton cancel - On s'en va 
+    this->Hide();
+    pap->SetReady();
+    break;
+
+  case 555:    // Bouton OK
+// On recupere les textes des 3 champs :
+    for(int i=0; i<3; i++)  
+      printf("ArgsWind::Process() Txt[%d] = %s \n", i, mText[i]->GetText().c_str());
+    sscanf(mText[0]->GetText().c_str(),"%g %g", &fmin, &fmax);
+    sscanf(mText[1]->GetText().c_str(),"%g %g", &xmin, &xmax);
+    sscanf(mText[2]->GetText().c_str(),"%g %g", &ymin, &ymax);
+    
+    printf("... FMin/Max= %g %g  XMin/Max= %g %g YMin/Max= %g %g\n",
+           fmin, fmax, xmin, xmax, ymin, ymax); 
+    this->Hide();
+    pap->SetReady();
+    break;    
+  }
+    
+return;
+}
+
+static PITApp * app;
+
+/* Nouvelle-Fonction */
+void mypact(void *)
+// Fonction pour lire l'heure de la machine et mettre a jour le champ label
+{
+int tm;
+char *s;
+time(&tm);
+s = ctime(&tm);
+// printf("mypact_Info:  %d  (%s)", tm, s);
+app->lab[0]->SetLabel((string)s);
+return;
+}
+
+int main(int narg, char *arg[])
+{
+
+// Initialisation de tout PEIDA (avec StarReco++)
+PeidaStarRecoInitiator InitStar;
+
+app = new PITApp(narg, arg);
+puts("appel de Application.Run() ... ");
+app->Run();
+
+delete app;
+exit(0);
+}
+
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/exapp_1.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/exapp_1.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/exapp_1.h	(revision 50)
@@ -0,0 +1,43 @@
+#include <string.h>
+
+#include "pisysdep.h"
+
+#include PIAPP_H
+#include PIMENU_H 
+#include PISTDWDG_H 
+#include PIWIN_H
+#include "piperiodx.h"  // PIPERIODIC_H
+
+class ArgsWind;
+
+class PITApp : public PIApplication {
+public:
+     PITApp(int narg=0, char* arg[]=NULL);
+     ~PITApp();
+     virtual void   Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+
+// protected :
+     
+  PIPDMenu * m[2];
+  PILabel *lab[2];
+  PIPeriodX mPeriod;
+  PIWindow *mCurW;
+  ArgsWind *mAW;
+};
+
+
+class ArgsWind : public PIWindow {
+public :
+                ArgsWind(PIApplication *par);
+                ~ArgsWind();
+          void  SetLabels(char *lab1, char *lab2, char *lab3);
+          void  SetTexts(char *tx1, char *tx2, char *tx3);
+          void  GetTexts(char *tx1, char *tx2, char *tx3);
+  virtual void  Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+
+private:
+  PIApplication * pap;
+  PILabel  * mLab[3];
+  PIButton * mBut[2];
+  PIText * mText[3];
+  };
Index: /tags/V_Saclay_110697/SophyaPI/PI/exclude
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/exclude	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/exclude	(revision 50)
@@ -0,0 +1,22 @@
+piapplmac.cc
+pibwdgmac.cc
+picmapmac.cc
+picontainermac.cc
+pierrdisp.cc
+pifilechomac.cc
+pimenubarmac.cc
+pimenumac.cc
+pioptmenumac.cc
+pipixmapmac.cc
+pippapplmac.cc
+pippapplmac.cc
+pippmenubar.cc
+pistdwdgmac.cc
+pitestapp.cc
+piupdattachment.cc
+piwdgmac.cc
+piwindowmac.cc
+piup_def.cc
+ex_dessin.cc
+sc_sample.cc
+exapp_1.cc
Index: /tags/V_Saclay_110697/SophyaPI/PI/pi.rsc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pi.rsc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pi.rsc	(revision 50)
@@ -0,0 +1,28 @@
+PeidaInt*background:                         LightGrey
+PeidaInt*default*background:                 LightGrey
+PeidaInt*bottomShadowColor:                  Black
+PeidaInt*default*bottomShadowColor:          Black
+PeidaInt*Foreground:                         Black
+PeidaInt*default*Foreground:                 Black
+PeidaInt*topShadowColor:                     White
+PeidaInt*default*topShadowColor:             White
+PeidaInt*borderColor:                        Black
+
+PeidaInt*XmLabel.borderWidth:                1
+PeidaInt*XmScrollBar*background:             LightBlue
+PeidaInt*XmDrawingArea*background:           Black
+PeidaInt*XmPushButton*borderWidth:           0
+
+PeidaInt*XmText*XmNshadowThickness:          1
+PeidaInt*XmText*XmNhighlightThickness:          2
+
+PeidaInt*DefMenubar*XtNwidth:           250
+PeidaInt*DefMenubar*XtNheight:          30
+
+PeidaInt*fontList:           -*-helvetica-bold-r-normal-*-12-*-*-*-*-*-ISO8859-1
+PeidaInt*default*fontList:    -*-helvetica-bold-r-normal-*-12-*-*-*-*-*-ISO8859-1
+
+# Attention, ne pas mettre de blanc a la fin du nom de fonte
+PeidaInt*fontFamilyName:   *-helvetica
+
+PeidaInt*XmToggleButton*selectColor:                  Red
Index: /tags/V_Saclay_110697/SophyaPI/PI/piapplgen.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piapplgen.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piapplgen.cc	(revision 50)
@@ -0,0 +1,37 @@
+#include "piapplgen.h"
+
+PIApplicationGen::PIApplicationGen()
+:topcont(NULL), menubar(NULL), mState(0)
+{}
+
+PIApplicationGen::~PIApplicationGen()
+{}
+
+
+void PIApplicationGen::AppendMenu(PIPDMenu *pdm)
+{
+if (menubar)
+  menubar->AppendMenu(pdm);
+return;
+}
+
+void PIApplicationGen::SetReady()
+{
+mState = kReadyState;
+}
+
+void PIApplicationGen::SetBusy()
+{
+mState = kBusyState;
+}
+
+void PIApplicationGen::SetBlocked()
+{
+mState = kBlockedState;
+}
+
+int PIApplicationGen::GetState()
+{
+return mState;
+}
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/piapplgen.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piapplgen.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piapplgen.h	(revision 50)
@@ -0,0 +1,35 @@
+#ifndef PIAPPLGEN_H_SEEN
+#define PIAPPLGEN_H_SEEN
+
+#include "pimsghandler.h"
+#include "pisysdep.h"
+#include PICONT_H
+#include PIMENUBAR_H
+
+class PIApplicationGen : public PIMsgHandler {
+public:
+        enum { kReadyState=0, kBusyState=1, kBlockedState=2 };
+
+				  PIApplicationGen();
+	virtual		          ~PIApplicationGen();
+	
+	virtual void              Run()=0;
+	virtual void              Stop()=0;
+
+        virtual void              SetReady();
+        virtual void              SetBusy(); 
+        virtual void              SetBlocked();
+        virtual int               GetState();
+
+
+	virtual PIContainer*      MainWin() {return topcont;}
+        virtual PIMenubar*        Menubar() {return menubar;}
+
+        virtual void              AppendMenu(PIPDMenu *pdm);
+protected:
+    PIContainer               *topcont;
+    PIMenubar                 *menubar;
+    int                       mState;
+};
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/piapplmac.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piapplmac.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piapplmac.cc	(revision 50)
@@ -0,0 +1,80 @@
+
+#include "piapplmac.h"
+#include "pippmenubar.h"
+#include "pippapplmac.h"
+#include "piwindowmac.h"
+
+#include <LApplication.h>
+#include <LGrowZone.h>
+#include <UDrawingState.h>
+#include <UMemoryMgr.h>
+#include <SIOUX.h>
+#include <LAttachment.h>
+
+class PISIOUXAttachment : public LAttachment {
+public:
+  PISIOUXAttachment();
+protected:
+ virtual void	ExecuteSelf(
+							MessageT		inMessage,
+							void			*ioParam);
+};
+
+PISIOUXAttachment::PISIOUXAttachment()
+: LAttachment()
+{}
+
+void PISIOUXAttachment::ExecuteSelf(MessageT msg, void* p)
+{
+  if (msg == msg_Event)
+    mExecuteHost = !SIOUXHandleOneEvent((EventRecord*)p);
+  if (!mExecuteHost)
+    UDesktop::NormalizeWindowOrder();
+}
+
+PIApplicationMac::PIApplicationMac(int sx, int sy, int /*narg*/, char** /*arg*/)
+{
+  SIOUXSettings.initializeTB = false;
+  SIOUXSettings.standalone = false;
+  SIOUXSettings.setupmenus = false;
+  SIOUXSettings.showstatusline = true;
+									// Set Debugging options
+	SetDebugThrow_(debugAction_Alert);
+	SetDebugSignal_(debugAction_Alert);
+
+	InitializeHeap(3);				// Initialize Memory Manager
+									// Parameter is number of Master Pointer
+									//   blocks to allocate
+	
+									// Initialize standard Toolbox managers
+	UQDGlobals::InitializeToolbox(&qd);
+	
+	new LGrowZone(20000);			// Install a GrowZone function to catch
+									//    low memory situations.
+
+	macAppli = new PIPPApplMac;
+	macAppli->AddAttachment(new PISIOUXAttachment);
+	
+    menubar = new PIMenubar(this, "DefMenubar");
+    topcont = new PIWindowMac(this, "TopLevel", PIWindowKind(2), sx, sy, 10, 45);
+}
+
+
+PIApplicationMac::~PIApplicationMac()
+{
+	delete macAppli;
+}
+
+void
+PIApplicationMac::Run()
+{
+    topcont->Show();
+	macAppli->Run();
+}
+
+void
+PIApplicationMac::Stop()
+{
+	macAppli->DoQuit();
+}
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/piapplmac.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piapplmac.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piapplmac.h	(revision 50)
@@ -0,0 +1,21 @@
+#ifndef PIAPPLMAC_H_SEEN
+#define PIAPPLMAC_H_SEEN
+
+#include "piapplgen.h"
+
+class LApplication;
+class PIApplicationMac : public PIApplicationGen {
+public:
+					PIApplicationMac(int sx=200, int sy=30, int narg=0, char *arg[]=NULL);
+	virtual		   ~PIApplicationMac();
+	
+	virtual void    Run();
+	virtual void    Stop();
+	
+//protected:
+	LApplication* macAppli;
+};
+
+typedef PIApplicationMac PIApplication;
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/piapplx.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piapplx.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piapplx.cc	(revision 50)
@@ -0,0 +1,133 @@
+#include <stdio.h>
+#include <X11/cursorfont.h>
+#include "piapplx.h"
+#include "picontainerx.h"
+
+
+#define DEBUG_APPLX
+
+static Cursor a_curs[3];
+static bool a_fgcur=false;
+
+/* --Methode-- */
+PIApplicationX::PIApplicationX(int sx, int sy, int narg, char *arg[])
+: PIApplicationGen()
+{
+int sxt, syt;
+
+#ifdef DEBUG_APPLX
+puts("PIApplicationX::PIApplicationX()_info : App creation");
+#endif
+mStop = true;
+topwdg = new PIWdgX(narg, arg);
+
+intcont = new PIContainerX((PIMsgHandler *)this, topwdg, "MBCont", 
+                            10, 10, 0, 0);
+menubar = new PIMenubar(this, "DefMenubar");
+Menubar()->SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_free);
+sxt = ( sx > Menubar()->XSize() ) ? sx : Menubar()->XSize();
+syt = ( sy > 0 ) ? sy : 0;
+//syt += Menubar()->YSize();
+syt += 40;
+MBCont()->SetSize(sxt, syt);
+if ( (sx > 0) && (sy > 0) )
+  {
+  topcont = new PIContainerX(MBCont(), "TopLevelCont", 
+                             sx, sy, 0, 40);
+  topcont->SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_fixed);
+  topcont->Show();
+  }
+else topcont = MBCont();
+
+MBCont()->Show();
+topwdg->Manage();
+
+if (!a_fgcur)
+  {
+  Display *mdsp;
+  mdsp = XtDisplay (topwdg->XtWdg()); 
+  a_curs[0] = XCreateFontCursor(mdsp, XC_arrow);
+  a_curs[1] = XCreateFontCursor(mdsp, XC_X_cursor);
+  a_curs[2] = XCreateFontCursor(mdsp, XC_watch);
+  }
+
+mState = -1;
+SetReady();
+}
+
+/* --Methode-- */
+PIApplicationX::~PIApplicationX()
+{
+#ifdef DEBUG_APPLX
+puts("PIApplicationX::~PIApplicationX()_info : App delete");
+#endif
+Display *mdsp;
+mdsp = XtDisplay (topwdg->XtWdg()); 
+topwdg->Unmanage();
+delete menubar;
+if (topcont != MBCont())  delete topcont;
+delete intcont;
+delete topwdg;
+XtCloseDisplay(mdsp);
+return;
+}
+
+/* --Methode-- */
+void PIApplicationX::Run()
+{
+XEvent evt;
+#ifdef DEBUG_APPLX
+puts("PIApplicationX::Run()_info : App Run ");
+#endif
+
+topwdg->SetSize(MBCont()->XSize(), MBCont()->YSize());
+
+while (mStop)
+  {
+  XtNextEvent(&evt);
+  XtDispatchEvent(&evt);
+  }
+return;
+}
+
+
+/* --Methode-- */
+void PIApplicationX::SetReady()
+{
+if (mState != kReadyState)
+  {
+  Display * mdsp;
+  mState = kReadyState;
+  mdsp = XtDisplay (topwdg->XtWdg());
+  XDefineCursor(mdsp, XtWindow(topwdg->XtWdg()), a_curs[0]);
+  XFlush(mdsp);
+  }
+}
+
+/* --Methode-- */
+void PIApplicationX::SetBusy()
+{
+if (mState != kBusyState)
+  {
+  Display * mdsp;
+  mState = kBusyState;
+  mdsp = XtDisplay (topwdg->XtWdg());
+//  if ( XtIsRealized(topwdg->XtWdg()) )
+  XDefineCursor(mdsp, XtWindow(topwdg->XtWdg()), a_curs[2]);
+  XFlush(mdsp);
+  }
+return;
+}
+
+/* --Methode-- */
+void PIApplicationX::SetBlocked()
+{
+if (mState != kBlockedState)
+  {
+  Display * mdsp;
+  mState = kBlockedState;
+  mdsp = XtDisplay (topwdg->XtWdg());
+  XDefineCursor(mdsp, XtWindow(topwdg->XtWdg()), a_curs[1]);
+  XFlush(mdsp);
+  }
+}
Index: /tags/V_Saclay_110697/SophyaPI/PI/piapplx.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piapplx.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piapplx.h	(revision 50)
@@ -0,0 +1,31 @@
+#ifndef PIAPPLX_H_SEEN
+#define PIAPPLX_H_SEEN
+
+#include "piapplgen.h"
+#include "piwdgx.h"
+#include "picontainerx.h"
+
+class PIApplicationX : public PIApplicationGen {
+public:
+		  PIApplicationX(int sx=0, int sy=0, 
+                                 int narg=0, char *arg[]=NULL);
+
+  virtual	  ~PIApplicationX();
+	
+  virtual void    Run();
+  virtual void    Stop() { mStop = false; }
+
+  virtual void    SetReady();
+  virtual void    SetBusy(); 
+  virtual void    SetBlocked();
+
+  PIContainer*    MBCont() { return intcont; }
+protected:
+  PIWdg * topwdg;
+  PIContainer * intcont;
+  bool mStop;
+};
+
+typedef PIApplicationX PIApplication;
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/pibwdggen.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pibwdggen.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pibwdggen.cc	(revision 50)
@@ -0,0 +1,132 @@
+#include <stdio.h>
+
+#include "pibwdggen.h"
+#include "psfile.h"
+
+// Les methodes de la classe  PIBWdgGen
+ 
+/* --Methode-- */
+PIBaseWdgGen::PIBaseWdgGen(PIContainerGen *par, char *nom,
+                       int sx, int sy, int px, int py) :
+PIWdg(par, nom, sx, sy, px, py)
+{
+mPSOut=NULL;
+}
+
+
+/* --Methode-- */
+PIBaseWdgGen::~PIBaseWdgGen()
+{
+}
+
+ 
+
+
+/* --Methode-- */
+void PIBaseWdgGen::Enter()
+{
+#ifdef DEBUG_RZXB
+puts("Debug_PIBaseWdgGen::Enter() enter notify ");
+#endif
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::Leave()
+{
+#ifdef DEBUG_RZXB
+puts("Debug_PIBaseWdgGen::Leave() leave notify ");
+#endif
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgGen::But1Press(int /*x*/, int /*y*/)
+{
+Send(Msg(), PIMsg_Active);
+#ifdef DEBUG_RZXB
+printf ("PIBaseWdgGen::But1Press PosX,Y= %d %d \n", x, y);
+#endif
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::But1Release(int /*x*/, int /*y*/)
+{
+#ifdef DEBUG_RZXB
+printf ("PIBaseWdgGen::ButReleasePosX,Y= %d %d \n", x, y);
+#endif
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::But2Press(int /*x*/, int /*y*/)
+{
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::But2Release(int /*x*/, int /*y*/)
+{
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::But3Press(int /*x*/, int /*y*/)
+{
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::But3Release(int /*x*/, int /*y*/)
+{
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgGen::Ptr1Move(int /*x*/, int /*y*/)
+{
+#ifdef DEBUG_RZXB
+printf ("Debug_PIBaseWdgGen::Ptr1Move PosX,Y= %d %d \n", x, y);
+#endif
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::Ptr2Move(int /*x*/, int /*y*/)
+{
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgGen::Ptr3Move(int /*x*/, int /*y*/)
+{
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgGen::Keyboard(int /*key*/, PIKeyModifier /*kmod*/)
+{
+#ifdef DEBUG_RZXB
+printf("PIBaseWdgGen::Keyboard: Key= %d (%c)  Mod= %d \n", key, (char)key, (int)kmod); 
+#endif
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgGen::PSPrint(PSFile * psf, int ofx, int ofy)
+{
+if(!psf) return;
+mPSOut = psf;
+psf->NewBloc((float)(ofx+XPos()), (float)(ofy+YPos()),
+	     (float)XSize(),(float)YSize(),
+	     (float)XSize(),(float)YSize());
+Draw();
+psf->EndBloc();
+mPSOut=NULL;
+}
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/pibwdggen.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pibwdggen.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pibwdggen.h	(revision 50)
@@ -0,0 +1,132 @@
+#ifndef PIBWDGGEN_H_SEEN
+#define PIBWDGGEN_H_SEEN
+
+#include "pisysdep.h"
+#include PIWDG_H
+
+#include "pibwdggen.h"
+
+
+enum PIKeyModifier { PIKM_Blank = 0, PIKM_Shift = 1, PIKM_Alt = 2, PIKM_Cntl = 4 } ; 
+
+enum PIColors  { PI_NotDefColor = -1,
+                 PI_Black = 0, PI_White = 1,  PI_Grey = 2,
+                 PI_Red = 3, PI_Blue = 4, PI_Green = 5,  
+                 PI_Yellow = 6, PI_Magenta =7 }; 
+
+enum PIFontSize { PI_NotDefFontSize = -1, 
+                  PI_SmallSizeFont = 1, PI_NormalSizeFont = 2, PI_BigSizeFont = 3 };
+
+enum PIFontAtt { PI_NotDefFontAtt = -1,
+                 PI_RomanFont = 1, PI_BoldFont = 2, PI_ItalicFont = 4 };
+
+enum PIPaperSize { PI_A4 = 1, PI_A3 = 2, PI_A5 = 3, PI_NotDefPaperSize = 0};
+
+enum PIOrientation { PI_Landscape = 0, PI_Portrait = 1, PI_Auto = 2 } ;
+
+
+enum PILineAtt { PI_NotDefLineAtt = -1,
+                 PI_NormalLine = 0, PI_ThinLine = 1, PI_ThickLine = 2 };
+
+enum PIMarker  { PI_NotDefMarker = -1,
+                 PI_DotMarker = 0, PI_PlusMarker=1, PI_CrossMarker=2,  
+                 PI_CircleMarker=3, PI_FCircleMarker=4,
+                 PI_BoxMarker=5, PI_FBoxMarker=6,
+                 PI_TriangleMarker=7, PI_FTriangleMarker=8,
+                 PI_StarMarker=9, PI_FStarMarker=10 };
+
+enum PIPointer { PI_ArrowPointer = 1, PI_CrossPointer = 2, 
+                 PI_HandPointer = 3, PI_TDLRArrowPointer = 4 };
+
+enum PIGOMode { PI_GOCopy = 0, PI_GOXOR = 1 }; 
+
+class PIBaseWdgGen : public PIWdg
+{
+public:
+  enum {ClassId = 5000};
+
+// Les methodes ...
+
+                     PIBaseWdgGen(PIContainerGen *par, char *nom,
+                                   int sx=10, int sy=10, int px=0, int py=0);
+  virtual            ~PIBaseWdgGen();
+
+  virtual long       kind() {return ClassId; }
+
+//  Activation des evenements   
+  virtual void       ActivatePtrCross()        = 0;
+  virtual void       ActivateButton(int bid)   = 0;
+  virtual void       ActivateMove(int bid)     = 0;
+  virtual void       ActivateKeyboard()        = 0;
+
+//  Trace graphiques
+  virtual void       EraseWindow()             = 0;
+  virtual void       DrawString(int x, int y, char* s, int pos = 0)  = 0;
+  virtual void       DrawLine(int x1, int y1, int x2, int y2)              = 0;
+  virtual void       DrawBox(int x0, int y0, int dx, int dy)               = 0;
+  virtual void       DrawFBox(int x0, int y0, int dx, int dy)              = 0;
+  virtual void       DrawCircle(int x0, int y0, int r)                     = 0;
+  virtual void       DrawFCircle(int x0, int y0, int r)                    = 0;
+  virtual void       DrawPolygon(int *x, int *y, int n)                    = 0;  
+  virtual void       DrawFPolygon(int *x, int *y, int n)                   = 0;  
+  virtual void       DrawMarker(int x0, int y0)                            = 0;
+  virtual void       DrawMarkers(int *x, int *y, int n)                    = 0;
+
+
+
+  virtual int        CalcStringWidth(char const* s)                        = 0;
+
+// Modifications attributs graphiques
+  virtual void       SelForeground(PIColors col=PI_Black)                  = 0;
+  virtual void       SelBackground(PIColors col=PI_White)                  = 0;
+  virtual void       SelGOMode(PIGOMode mod=PI_GOCopy)                     = 0;
+  virtual void       SelFont(PIFontSize sz=PI_NormalSizeFont, 
+                             PIFontAtt att=PI_RomanFont)                   = 0;
+  virtual void       SelFontSzPt(int npt=12, PIFontAtt att=PI_RomanFont)   = 0; 
+  virtual void       SelLine(PILineAtt att=PI_NormalLine)                  = 0;
+  virtual void       SelPointerShape(PIPointer ptr=PI_ArrowPointer)        = 0;
+  virtual void       SelMarker(int msz=3, PIMarker mrk=PI_DotMarker)       = 0;
+
+// Acces aux attributs graphiques 
+  virtual PIColors   GetForeground()    = 0;
+  virtual PIColors   GetBackground()    = 0;
+  virtual PIGOMode   GetGOMode()        = 0;
+  virtual PIFontAtt  GetFontAtt()       = 0;
+  virtual int        GetFontSize()      = 0;
+  virtual PILineAtt  GetLineAtt()       = 0;
+  virtual PIPointer  GetPointerShape()  = 0;
+  virtual PIMarker   GetMarker()        = 0;
+  virtual int        GetMarkerSize()    = 0;
+
+
+//  Fonction qui doit etre appelee pour rafraichir (retracer) tout 
+  virtual void       Refresh()          = 0;
+  
+// Traitement des evenements   
+  virtual void       Resize()           = 0;
+  virtual void       Draw()             = 0;
+  virtual void       Draw(int x0, int y0, int dx, int dy) = 0;
+
+  virtual void       Enter();
+  virtual void       Leave();  
+  virtual void       But1Press(int x, int y);  
+  virtual void       But1Release(int x, int y); 
+  virtual void       But2Press(int x, int y);
+  virtual void       But2Release(int x, int y);
+  virtual void       But3Press(int x, int y);
+  virtual void       But3Release(int x, int y);
+  virtual void       Ptr1Move(int x, int y);
+  virtual void       Ptr2Move(int x, int y);
+  virtual void       Ptr3Move(int x, int y);
+  virtual void       Keyboard(int key, PIKeyModifier kmod);
+
+// PostScript output
+  virtual void       PSPrint(PSFile * psf, int ofx = 0, int ofy = 0); 
+
+protected:
+  PSFile * mPSOut;  /* Fichier PostScript eventuel */
+};
+
+
+#endif /* PIBWDGGEN_H_SEEN */
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/pibwdgmac.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pibwdgmac.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pibwdgmac.cc	(revision 50)
@@ -0,0 +1,548 @@
+#include <stdio.h>
+
+#include <LString.h>
+#include "pibwdgmac.h"
+#include "piupdattachment.h"
+#include <algobase.h>
+#include <string.h>
+
+// Les methodes de la classe  PIBWdgGen
+ 
+/* --Methode-- */
+PIBaseWdgMac::PIBaseWdgMac(PIContainerGen *par, char *nom,
+                       int sx, int sy, int px, int py) :
+PIBaseWdgGen(par, nom, sx, sy, px, py)
+{
+    mPane->AddAttachment(new PIUpdAttachment(this));
+    cursor = NULL;
+}
+
+
+/* --Methode-- */
+PIBaseWdgMac::~PIBaseWdgMac()
+{
+}
+
+
+/* --Methode-- */
+void PIBaseWdgMac::ActivatePtrCross()
+{
+// toujours actif pour le moment
+}
+
+
+/* --Methode-- */
+void PIBaseWdgMac::ActivateButton(int /*bid*/)
+{
+}
+
+/* --Methode-- */
+void PIBaseWdgMac::ActivateMove(int /*bid*/)
+{
+}
+
+
+/* --Methode-- */
+void PIBaseWdgMac::ActivateKeyboard()
+{
+}
+
+/* --Methode-- */
+void PIBaseWdgMac::EraseWindow()
+{
+  if (mPane->FocusDraw()) {
+     GrafPtr p = mPane->GetMacPort();
+     if (p) EraseRgn(p->visRgn);
+//	   Rect r;
+//	   mPane->CalcPortFrameRect(r);
+//       EraseRect(&r);
+  }
+}
+
+/* --Methode-- */
+void PIBaseWdgMac::DrawString(int x, int y, char* s, int /*pos*/)
+{
+  if (mPane->FocusDraw()) {
+    LocalToMacPortPoint(x, y, x, y);
+    ::MoveTo(x, y);
+    LStr255 ps = s;
+    ::TextFont(applFont);
+    ::DrawString(ps);
+  }
+}
+
+
+/* --Methode-- */
+void PIBaseWdgMac::DrawMarker(int x0, int y0)
+{
+int hmsz = mMrkSz/2;
+int dmsz = mMrkSz-hmsz;
+int x[4],y[4];
+PILineAtt clatt;
+
+if (mMrk == PI_DotMarker) {
+    LocalToMacPortPoint(x0, y0, x0, y0);
+  ::MoveTo( x0, y0);
+  ::Line(0,0);
+}
+
+else
+  {
+  clatt = mLAtt;
+  SelLine(PI_ThinLine);
+  switch (mMrk)
+    {
+    case  PI_PlusMarker :
+      DrawLine(x0-hmsz, y0, x0+dmsz, y0);
+      DrawLine(x0, y0-hmsz, x0, y0+dmsz);
+      break;
+    case  PI_CrossMarker :
+      DrawLine(x0-hmsz, y0-hmsz, x0+dmsz, y0+dmsz);
+      DrawLine(x0-hmsz, y0+dmsz, x0+dmsz, y0-hmsz);
+      break;  
+    case PI_CircleMarker :
+      DrawCircle(x0, y0, hmsz);
+      break;
+    case PI_FCircleMarker :
+      DrawFCircle(x0, y0, hmsz);
+      break;
+    case PI_BoxMarker :
+      DrawBox(x0-hmsz, y0-hmsz, mMrkSz, mMrkSz);
+      break;
+    case PI_FBoxMarker :
+      DrawFBox(x0-hmsz, y0-hmsz, mMrkSz, mMrkSz);
+      break;
+    case  PI_TriangleMarker :
+      x[1] = mMrkSz; y[1] = 0; x[2] = -hmsz; y[2] = -mMrkSz; 
+      x[3] = -dmsz; y[3] = +mMrkSz; x[0] = x0-hmsz; y[0] = y0+hmsz;  
+      DrawPolygon(x, y, 4);
+      break;
+    case  PI_FTriangleMarker :
+      x[1] = mMrkSz; y[1] = 0; x[2] = -hmsz; y[2] = -mMrkSz; 
+      x[3] = -dmsz; y[3] = +mMrkSz; x[0] = x0-hmsz; y[0] = y0+hmsz;  
+      DrawFPolygon(x, y, 4);
+      break;
+    default :
+      ::MoveTo( x0, y0);
+      ::Line(0,0);
+      break;
+    }
+  SelLine(clatt);
+  }
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgMac::DrawMarkers(int *x, int *y, int n)
+{
+int i;
+
+if (n <= 0)  return;
+for(i=0; i<n; i++) DrawMarker(x[i], y[i]);
+}
+
+/* --Methode-- */
+int PIBaseWdgMac::CalcStringWidth(char const* s)
+{
+  if (mPane->FocusDraw())
+    ::TextFont(applFont);
+  return ::TextWidth(s,0,strlen(s));
+}
+
+void PIBaseWdgMac::LocalToMacPortPoint(int x, int y, int& xm, int& ym)
+{
+    Point pt = {y,x};
+    //mPane->LocalToPortPoint(pt);
+//	SPoint32 loc;
+//	mPane->GetFrameLocation(loc);
+//    xm = pt.h + loc.h;
+//    ym = pt.v + loc.v;  // Ou bien ne pas utiliser de Pane, que des View ?
+    xm = pt.h;
+    ym = pt.v;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgMac::DrawLine(int x1, int y1, int x2, int y2)
+{
+  if (mPane->FocusDraw()) {
+    int x,y;
+    LocalToMacPortPoint(x1, y1, x, y);
+    ::MoveTo(x,y);
+    LocalToMacPortPoint(x2, y2, x, y);
+    ::LineTo(x,y);
+  }
+}
+
+/* --Methode-- */
+void PIBaseWdgMac::DrawBox(int x0, int y0, int dx, int dy)
+{
+  if (mPane->FocusDraw()) {
+    int x,y;
+    LocalToMacPortPoint(x0, y0, x, y);
+    Rect r = {y, x, y+dy, x+dx};
+    if (r.top  > r.bottom) swap(r.top,  r.bottom);
+    if (r.left > r.right)  swap(r.left, r.right);
+    r.right++; r.bottom++;
+    ::FrameRect(&r);
+  }
+}
+
+
+/* --Methode-- */
+void PIBaseWdgMac::DrawFBox(int x0, int y0, int dx, int dy)
+{
+  if (mPane->FocusDraw()) {
+    int x,y;
+    LocalToMacPortPoint(x0, y0, x, y);
+    Rect r = {y, x, y+dy, x+dx};
+    if (r.top  > r.bottom) swap(r.top,  r.bottom);
+    if (r.left > r.right)  swap(r.left, r.right);
+    r.right++; r.bottom++;
+    ::PaintRect(&r);
+  }
+}
+
+/* --Methode-- */
+void PIBaseWdgMac::DrawCircle(int x0, int y0, int r) 
+{
+  if (mPane->FocusDraw()) {
+    int x,y;
+    LocalToMacPortPoint(x0, y0, x, y);
+    Rect rr = {y-r, x-r, y+r, x+r};
+    if (rr.top  > rr.bottom) swap(rr.top,  rr.bottom);
+    if (rr.left > rr.right)  swap(rr.left, rr.right);
+    ::FrameOval(&rr);
+  }
+}
+
+/* --Methode-- */
+void PIBaseWdgMac::DrawFCircle(int x0, int y0, int r) 
+{
+  if (mPane->FocusDraw()) {
+    int x,y;
+    LocalToMacPortPoint(x0, y0, x, y);
+    Rect rr = {y-r, x-r, y+r, x+r};
+    if (rr.top  > rr.bottom) swap(rr.top,  rr.bottom);
+    if (rr.left > rr.right)  swap(rr.left, rr.right);
+    ::PaintOval(&rr);
+  }
+}
+
+/* --Methode-- */
+void PIBaseWdgMac::DrawPolygon(int *x, int *y, int n)
+{
+  PolyHandle h = MakePoly(x,y,n);
+  if (h) {
+    ::FramePoly(h);
+    ::KillPoly(h);
+  }
+}
+
+
+/* --Methode-- */
+void PIBaseWdgMac::DrawFPolygon(int *x, int *y, int n)
+{
+  PolyHandle h = MakePoly(x,y,n);
+  if (h) {
+    ::PaintPoly(h);
+    ::KillPoly(h);
+  }
+}
+/* --Methode-- */
+PolyHandle PIBaseWdgMac::MakePoly(int *x, int *y, int n)
+{
+  if (mPane->FocusDraw()) {
+    PolyHandle h = ::OpenPoly();
+    int xx,yy;
+    LocalToMacPortPoint(x[0], y[0], xx, yy);
+    ::MoveTo(xx, yy);
+    for (int i=1; i<n; i++) {
+      LocalToMacPortPoint(x[i], y[i], xx, yy);
+      ::LineTo(xx, yy);
+    }
+    LocalToMacPortPoint(x[0], y[0], xx, yy);
+    ::MoveTo(xx, yy);
+    ClosePoly();
+    return h;
+  }
+  return NULL;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgMac::SelForeground(PIColors col) 
+{
+  if (mPane->FocusDraw()) {
+    long color;
+    switch (col) {
+      case PI_Black:
+        color = blackColor;
+        break;
+      case PI_White:
+        color = whiteColor;
+        break;
+      case PI_Red:
+        color = redColor;
+        break;
+      case PI_Blue:
+        color = blueColor;
+        break;
+      case PI_Green:
+        color = greenColor;
+        break;
+      case PI_Yellow:
+        color = yellowColor;
+        break;
+      default:
+        color = blackColor;
+    }
+    ::ForeColor(color);
+    mFCol = col;
+  }
+}
+
+/* --Methode-- */
+void PIBaseWdgMac::SelBackground(PIColors col) 
+{
+  if (mPane->FocusDraw()) {
+    long color;
+    switch (col) {
+      case PI_Black:
+        color = blackColor;
+        break;
+      case PI_White:
+        color = whiteColor;
+        break;
+      case PI_Red:
+        color = redColor;
+        break;
+      case PI_Blue:
+        color = blueColor;
+        break;
+      case PI_Green:
+        color = greenColor;
+        break;
+      case PI_Yellow:
+        color = yellowColor;
+        break;
+      default:
+        color = blackColor;
+    }
+    mBCol = col;
+    ::BackColor(color);
+  }
+}
+
+/* --Methode-- */
+void PIBaseWdgMac::SelGOMode(PIGOMode mod)
+{
+if (mod == mGOm)  return;
+  if (mPane->FocusDraw())
+    switch (mod)
+    {
+      case PI_GOCopy :
+        ::PenMode(patCopy);
+        mGOm = mod;
+        break;
+      case PI_GOXOR :
+        ::PenMode(patXor);
+        mGOm = mod;
+        break;
+    }
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgMac::SelFont(PIFontSize sz, PIFontAtt att)
+{
+  switch(sz) {
+      case PI_SmallSizeFont:
+        SelFontSzPt(9, att);
+        break;
+      case PI_NormalSizeFont:
+        SelFontSzPt(12, att);
+        break;
+      case PI_BigSizeFont:
+        SelFontSzPt(14, att);
+        break;
+  }
+}
+
+/* --Methode-- */
+void PIBaseWdgMac::SelFontSzPt(int npt, PIFontAtt att)
+{
+  if (mPane->FocusDraw()) {
+    ::TextFont(applFont);
+    ::TextSize(npt);
+    switch(att) {
+      case PI_RomanFont:
+        ::TextFace(0);
+        break;
+      case PI_BoldFont:
+        ::TextFace(bold);
+        break;
+      case PI_ItalicFont:
+        ::TextFace(italic);
+        break;
+    }
+  }
+  mFSize = npt;
+  mFAtt  = att;
+}
+
+/* --Methode-- */
+void PIBaseWdgMac::SelLine(PILineAtt att)
+{
+  if (mPane->FocusDraw()) {
+    switch(att) {
+      case PI_NormalLine:
+        ::PenSize(1,1);
+        break;
+      case PI_ThinLine:
+        ::PenSize(1,1);  // Mettre en pointille, ou bien commentaire pour Laser ?
+        break;
+      case PI_ThickLine:
+        ::PenSize(2,2);
+        break;
+    }
+  }
+  mLAtt = att;
+}
+
+/* --Methode-- */
+void PIBaseWdgMac::SelPointerShape(PIPointer ptr)
+{
+  CursHandle c;
+  if (mPane->FocusDraw()) {
+    switch(ptr) {
+      case PI_ArrowPointer:
+        cursor = &qd.arrow;
+        break;
+      case PI_CrossPointer:
+        c = GetCursor(crossCursor);
+        HLock((Handle)c);
+        cursor = c ? *c : NULL;
+        break;
+      case PI_HandPointer:
+        c = GetCursor(128);
+        HLock((Handle)c);
+        cursor = c ? *c : NULL;
+        break;
+    }
+  }
+  mPtrS = ptr;
+}
+
+/* --Methode-- */
+void PIBaseWdgMac::SelMarker(int msz, PIMarker mrk)
+{
+if (msz > 1)  { mMrk = mrk;  mMrkSz = msz; }
+else  { mMrk = PI_DotMarker;  mMrkSz = 1; }
+return;
+}
+
+/* --Methode-- */
+PIColors  PIBaseWdgMac::GetForeground() 
+{
+return (mFCol);
+}
+
+/* --Methode-- */
+PIColors  PIBaseWdgMac::GetBackground() 
+{
+return (mBCol);
+}
+
+
+/* --Methode-- */
+PIGOMode   PIBaseWdgMac::GetGOMode()
+{
+return (mGOm);
+}
+
+/* --Methode-- */
+PIFontAtt  PIBaseWdgMac::GetFontAtt()
+{
+return (mFAtt);
+}
+
+/* --Methode-- */
+int        PIBaseWdgMac::GetFontSize()
+{
+return (mFSize);
+}
+
+/* --Methode-- */
+PILineAtt  PIBaseWdgMac::GetLineAtt()
+{
+return (mLAtt);
+}
+
+/* --Methode-- */
+PIPointer  PIBaseWdgMac::GetPointerShape()
+{
+return (mPtrS);
+}
+
+/* --Methode-- */
+PIMarker   PIBaseWdgMac::GetMarker()
+{
+return (mMrk);
+}
+
+/* --Methode-- */
+int        PIBaseWdgMac::GetMarkerSize()
+{
+return (mMrkSz);
+}
+
+
+
+/* --Methode-- */
+bool PIBaseWdgMac::AdjustCursor()
+{
+  if (cursor) {
+    ::SetCursor(cursor);
+    return true;
+  }
+  return false;
+}
+
+/* --Methode-- */
+void PIBaseWdgMac::Refresh()
+{
+if (mPane->IsVisible())
+  Draw();
+}
+
+/* --Methode-- */
+void PIBaseWdgMac::Resize()
+{
+#ifdef DEBUG_RZXB
+printf ("Debug_PIBaseWdgMac::ReSize %ld %ld NewSize= %d %d\n", 
+         (long)(this), (long)(this->sdw), 
+         (int)this->sdw->core.width, (int)this->sdw->core.height);
+#endif
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgMac::Draw(int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/)
+{
+this->Draw();
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgMac::Draw()
+{
+#ifdef DEBUG_RZXB
+this->PIEraseWindow();
+this->PIDrawFBox(10,10, XSize()*2/3, YSize()*2/3);
+#endif
+return;
+}
+
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/pibwdgmac.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pibwdgmac.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pibwdgmac.h	(revision 50)
@@ -0,0 +1,92 @@
+/* Widget Xt pour affichage d'image  Interface Public    */
+/*                                    Reza 10/95         */
+
+#ifndef PIBWDGMAC_H_SEEN
+#define PIBWDGMAC_H_SEEN
+
+#include "pisysdep.h"
+#include "pibwdggen.h"
+
+
+class PIBaseWdgMac : public PIBaseWdgGen
+{
+public:
+// Les methodes ...
+
+                     PIBaseWdgMac(PIContainerGen *par, char *nom,
+                                   int sx=10, int sy=10, int px=0, int py=0);
+  virtual           ~PIBaseWdgMac();
+
+//  Activation des evenements   
+  virtual void       ActivatePtrCross();
+  virtual void       ActivateButton(int bid);
+  virtual void       ActivateMove(int bid);
+  virtual void       ActivateKeyboard();
+
+//  Trace graphiques
+  virtual void       EraseWindow();
+  virtual void       DrawString(int x, int y, char* s, int pos = 0);
+  virtual void       DrawLine(int x1, int y1, int x2, int y2);
+  virtual void       DrawBox(int x0, int y0, int dx, int dy);
+  virtual void       DrawFBox(int x0, int y0, int dx, int dy);
+  virtual void       DrawCircle(int x0, int y0, int r);
+  virtual void       DrawFCircle(int x0, int y0, int r);
+  virtual void       DrawPolygon(int *x, int *y, int n);  
+  virtual void       DrawFPolygon(int *x, int *y, int n);  
+  virtual void       DrawMarker(int x0, int y0);
+  virtual void       DrawMarkers(int *x, int *y, int n);
+
+  virtual int        CalcStringWidth(char const* s);  
+  
+  virtual void       SelForeground(PIColors col=PI_White);
+  virtual void       SelBackground(PIColors col=PI_Black);
+  virtual void       SelGOMode(PIGOMode mod=PI_GOCopy);
+  virtual void       SelFont(PIFontSize sz=PI_NormalSizeFont, 
+                             PIFontAtt att=PI_RomanFont);
+  virtual void       SelFontSzPt(int npt=12, PIFontAtt att=PI_RomanFont); 
+  virtual void       SelLine(PILineAtt att=PI_NormalLine);
+  virtual void       SelPointerShape(PIPointer ptr=PI_ArrowPointer);
+  virtual void       SelMarker(int msz, PIMarker mrk=PI_DotMarker);
+
+
+// Acces aux attributs graphiques 
+  virtual PIColors   GetForeground();
+  virtual PIColors   GetBackground();
+  virtual PIGOMode   GetGOMode();
+  virtual PIFontAtt  GetFontAtt();
+  virtual int        GetFontSize();
+  virtual PILineAtt  GetLineAtt();
+  virtual PIPointer  GetPointerShape();
+  virtual PIMarker   GetMarker();
+  virtual int        GetMarkerSize();
+
+//  Fonction qui doit etre appelee pour rafraichir (retracer) tout 
+  virtual void       Refresh();
+
+// Traitement des evenements   
+  virtual void       Resize();
+  virtual void       Draw();
+  virtual void       Draw(int x0, int y0, int dx, int dy);
+
+
+protected:
+  friend class       PIUpdAttachment;
+  virtual bool       AdjustCursor();
+  void               LocalToMacPortPoint(int x, int y, int& xm, int& ym);
+  CursPtr            cursor;
+  
+  PolyHandle         MakePoly(int *x, int *y, int n);
+
+  PIColors  mFCol, mBCol;
+  PIGOMode  mGOm;
+  PIPointer mPtrS;
+  PIFontAtt mFAtt;
+  PILineAtt mLAtt;
+  int       mFSize;
+  PIMarker  mMrk;
+  int       mMrkSz;
+};
+
+typedef PIBaseWdgMac PIBaseWdg;
+
+#endif /* RZXBASE_H_SEEN */
Index: /tags/V_Saclay_110697/SophyaPI/PI/pibwdgx.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pibwdgx.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pibwdgx.cc	(revision 50)
@@ -0,0 +1,880 @@
+#include <stdio.h>
+
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/cursorfont.h>
+
+#include <X11/IntrinsicP.h>
+#include <X11/CoreP.h>
+
+#include "pibwdgx.h"
+
+#include "pixtbaseP.h"
+#include "pixtbase.h"
+
+#include "psfile.h"
+
+
+/*  Variables globales pour modifier les GC  */
+#define NMAXFONTSZ  5
+static XFontStruct * fntst[NMAXFONTSZ][3];
+static int fntsz[NMAXFONTSZ] = {8,10,12,14,16};
+static  PIFontAtt fntatt[3] = { PI_RomanFont, PI_BoldFont, PI_ItalicFont }; 
+#define NMAXCOL  10
+static unsigned long colpix[NMAXCOL];
+#define NMAXCURS 5 
+static Cursor curs[NMAXCURS];
+
+
+// #define DEBUG_PIBWDGX     Flag pour impression de debug etc ...
+
+
+/* --Methode-- */
+PIBaseWdgX::PIBaseWdgX(PIContainerGen *par, char *nom,
+                       int sx, int sy, int px, int py) 
+: PIBaseWdgGen(par, nom, sx, sy, px, py)
+
+{
+Arg  wargs[3];
+
+Init();
+
+CreateXtWdg(nom, piXtBaseWidgetClass, NULL, sx, sy, px, py);
+
+XtSetArg(wargs[0],PIXNobject,this); 
+XtSetArg(wargs[1],XtNbackground, colpix[PI_White]);  
+XtSetArg(wargs[2],XtNborderWidth, (Dimension)0);  
+XtSetValues(XtWdg(), wargs, 3);
+
+mDefGC = XCreateGC (PIXDisplay(), XtWindow(PIXtTopWdg()), 0, NULL);
+mGOm = PI_GOCopy;
+
+mFCol = mBCol = PI_Grey;
+SelForeground(PI_Black);
+SelBackground(PI_White);
+mLAtt = PI_ThinLine;
+SelLine();
+mFAtt = PI_BoldFont;  mFSize = 0;
+SelFont();
+mPtrS = PI_CrossPointer;
+SelPointerShape();
+SelMarker(1, PI_DotMarker);
+Manage();
+}
+
+
+/* --Methode-- */
+PIBaseWdgX::~PIBaseWdgX()
+{
+}
+
+ 
+
+/* --Methode-- */
+void PIBaseWdgX::ActivatePtrCross()
+{
+XtTranslations trans;
+trans = XtParseTranslationTable
+        ("<Enter>: enter_pixtbase() \n <Leave>: leave_pixtbase()");
+XtAugmentTranslations(XtWdg(), trans);
+//XtFree((char *)trans);
+
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgX::ActivateButton(int bid)
+{
+XtTranslations trans;
+char strans[256];
+if ((bid<1) || (bid > 3))  return;
+sprintf(strans,"<Btn%dDown>: bud%d_pixtbase() \n <Btn%dUp>: buu%d_pixtbase()",
+        bid, bid, bid, bid);
+trans = XtParseTranslationTable(strans);
+
+XtAugmentTranslations(XtWdg(), trans);
+// XtFree((char *)trans);
+#ifdef DEBUG_PIBWDGX
+printf("PIBaseWdgX::ActivateButton \n%s \n", strans);
+#endif
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::ActivateMove(int bid)
+{
+XtTranslations trans;
+char strans[256];
+if ((bid<1) || (bid > 3))  return;
+sprintf(strans,"<Btn%dMotion>: mov%d_pixtbase()", bid, bid);
+//sprintf(strans,"Button%d <PtrMoved>: mov%d_pixtbase()", bid, bid);
+trans = XtParseTranslationTable(strans);
+
+XtAugmentTranslations(XtWdg(), trans);
+// XtFree((char *)trans);
+#ifdef DEBUG_PIBWDGX
+printf("PIBaseWdgX::ActivateMove \n%s \n", strans);
+#endif
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgX::ActivateKeyboard()
+{
+XtTranslations trans;
+trans = XtParseTranslationTable("<Key>: keyb_pixtbase()");
+XtAugmentTranslations(XtWdg(), trans);
+// XtFree((char *)trans);
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::EraseWindow()
+{
+if(mPSOut) return;
+XClearWindow   (XtDisplay(XtWdg()),XtWindow(XtWdg()) );
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::DrawString(int x, int y, char* s, int pos)
+{
+if(mPSOut){
+mPSOut->DrawString((float)x,(float)y,s,mFCol,mFAtt,mFSize); /* PIFontSize ?? */
+}
+else
+XDrawString (XtDisplay (XtWdg()),XtWindow(XtWdg()), 
+                  DefGC(), x, y, s, strlen(s));
+return;
+}
+
+ 
+/* --Methode-- */
+void PIBaseWdgX::DrawLine(int x1, int y1, int x2, int y2)
+{
+if(mPSOut){
+mPSOut->DrawLine((float)x1,(float)y1,(float)x2,(float)y2,
+		 mFCol,mLAtt);
+}
+else
+XDrawLine(XtDisplay (XtWdg()), XtWindow(XtWdg()), DefGC(), x1, y1, x2, y2);
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgX::DrawBox(int x0, int y0, int dx, int dy)
+{
+if(mPSOut)
+mPSOut->DrawBox((float)x0,(float)y0,(float)dx,(float)dy,mFCol,mLAtt);
+else{
+if (dx < 0)  { x0 += dx;  dx = -dx; }
+if (dy < 0)  { y0 += dy;  dy = -dy; }
+XDrawRectangle(XtDisplay (XtWdg()), XtWindow(XtWdg()), 
+               DefGC(), x0, y0, dx, dy);
+}
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::DrawFBox(int x0, int y0, int dx, int dy)
+{
+if(mPSOut)
+mPSOut->DrawFBox((float)x0,(float)y0,(float)dx,(float)dy);
+else{
+if (dx < 0)  { x0 += dx;  dx = -dx; }
+if (dy < 0)  { y0 += dy;  dy = -dy; }
+XFillRectangle(XtDisplay (XtWdg()), XtWindow(XtWdg()), 
+               DefGC(), x0, y0, dx, dy);
+}
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::DrawCircle(int x0, int y0, int r)
+{
+if(mPSOut)
+mPSOut->DrawCircle((float)x0,(float)y0,(float)r,mFCol,mLAtt);
+else
+XDrawArc(XtDisplay (XtWdg()), XtWindow(XtWdg()), DefGC(),
+         x0-r, y0-r, 2*r, 2*r, 0, 360*64);
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::DrawFCircle(int x0, int y0, int r)
+{
+if(mPSOut)
+mPSOut->DrawFCircle((float)x0,(float)y0,(float)r,mFCol,mFCol,mLAtt);
+else
+XFillArc(XtDisplay (XtWdg()), XtWindow(XtWdg()), DefGC(),
+         x0-r, y0-r, 2*r, 2*r, 0, 360*64);
+return;
+}
+
+// Pour les fonctions de trace avec un plusieurs coordonnees
+#define NMXXPOINTS  30 
+
+/* --Methode-- */
+void PIBaseWdgX::DrawPolygon(int *x, int *y, int n)
+{
+XPoint multipoint[NMXXPOINTS];
+XPoint *pxp;
+int i;
+float *xtmp;
+float *ytmp;
+
+if(mPSOut)
+{
+xtmp = (float*)malloc(n*sizeof(float));
+ytmp = (float*)malloc(n*sizeof(float));
+for(i=0;i<n;i++){
+  xtmp[i] = (float)x[i];
+  ytmp[i] = (float)y[i];
+}
+mPSOut->DrawPolygon(xtmp,ytmp,n,mFCol,mLAtt);
+free(xtmp);
+free(ytmp);
+}
+else {
+if (n <= 0)  return;
+if (n > NMXXPOINTS)  pxp = new XPoint[n];
+else pxp = multipoint;
+for(i=0; i<n; i++)  { pxp[i].x = x[i];  pxp[i].y = y[i]; } 
+XDrawLines(XtDisplay(XtWdg()), XtWindow(XtWdg()), DefGC(), pxp, n, CoordModePrevious);
+if (n > NMXXPOINTS)  delete[] pxp;
+}
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgX::DrawFPolygon(int *x, int *y, int n)
+{
+XPoint multipoint[NMXXPOINTS];
+XPoint *pxp;
+int i;
+float *xtmp;
+float *ytmp;
+
+if(mPSOut)
+{
+xtmp = (float*)malloc(n*sizeof(float));
+ytmp = (float*)malloc(n*sizeof(float));
+for(i=0;i<n;i++){
+  xtmp[i] = (float)x[i];
+  ytmp[i] = (float)y[i];
+}
+mPSOut->DrawFPolygon(xtmp,ytmp,n,mFCol,mFCol,mLAtt);
+free(xtmp);
+free(ytmp);
+}
+else
+{
+if (n <= 0)  return;
+if (n > NMXXPOINTS)  pxp = new XPoint[n];
+else pxp = multipoint;
+for(i=0; i<n; i++)  { pxp[i].x = x[i];  pxp[i].y = y[i]; } 
+XFillPolygon(XtDisplay (XtWdg()), XtWindow(XtWdg()), DefGC(), pxp, n, 
+                        Complex, CoordModePrevious);
+if (n > NMXXPOINTS)  delete[] pxp;
+}
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::DrawMarker(int x0, int y0)
+{
+int hmsz = mMrkSz/2;
+int dmsz = mMrkSz-hmsz;
+int x[4],y[4];
+PILineAtt clatt;
+if(mPSOut)
+mPSOut->DrawMarker((float)x0,(float)y0,mMrk,mFCol,mMrkSz);
+else
+{
+if (mMrk == PI_DotMarker)
+  XDrawPoint(XtDisplay(XtWdg()), XtWindow(XtWdg()), DefGC(), x0, y0);
+
+else
+  {
+  clatt = mLAtt;
+  SelLine(PI_ThinLine);
+  switch (mMrk)
+    {
+    case  PI_PlusMarker :
+      DrawLine(x0-hmsz, y0, x0+dmsz, y0);
+      DrawLine(x0, y0-hmsz, x0, y0+dmsz);
+      break;
+    case  PI_CrossMarker :
+      DrawLine(x0-hmsz, y0-hmsz, x0+dmsz, y0+dmsz);
+      DrawLine(x0-hmsz, y0+dmsz, x0+dmsz, y0-hmsz);
+      break;  
+    case PI_CircleMarker :
+      DrawCircle(x0, y0, hmsz);
+      break;
+    case PI_FCircleMarker :
+      DrawFCircle(x0, y0, hmsz);
+      break;
+    case PI_BoxMarker :
+      DrawBox(x0-hmsz, y0-hmsz, mMrkSz, mMrkSz);
+      break;
+    case PI_FBoxMarker :
+      DrawFBox(x0-hmsz, y0-hmsz, mMrkSz, mMrkSz);
+      break;
+    case  PI_TriangleMarker :
+      x[1] = mMrkSz; y[1] = 0; x[2] = -hmsz; y[2] = -mMrkSz; 
+      x[3] = -dmsz; y[3] = +mMrkSz; x[0] = x0-hmsz; y[0] = y0+hmsz;  
+      DrawPolygon(x, y, 4);
+      break;
+    case  PI_FTriangleMarker :
+      x[1] = mMrkSz; y[1] = 0; x[2] = -hmsz; y[2] = -mMrkSz; 
+      x[3] = -dmsz; y[3] = +mMrkSz; x[0] = x0-hmsz; y[0] = y0+hmsz;  
+      DrawFPolygon(x, y, 4);
+      break;
+    default :
+      XDrawPoint(XtDisplay(XtWdg()), XtWindow(XtWdg()), DefGC(), x0, y0);
+      break;
+    }
+  SelLine(clatt);
+  }
+}
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::DrawMarkers(int *x, int *y, int n)
+{
+int i;
+float *xtmp;
+float *ytmp;
+
+if(mPSOut)
+{
+xtmp = (float*)malloc(n*sizeof(float));
+ytmp = (float*)malloc(n*sizeof(float));
+for(i=0;i<n;i++){
+  xtmp[i] = (float)x[i];
+  ytmp[i] = (float)y[i];
+}
+mPSOut->DrawMarkers(xtmp,ytmp,n,mMrk,mFCol, mMrkSz);
+free(xtmp);
+free(ytmp);
+}
+else
+{
+if (n <= 0)  return;
+if (mMrk == PI_DotMarker)
+  {
+  XPoint multipoint[NMXXPOINTS];
+  XPoint *pxp;
+  if (n > NMXXPOINTS)  pxp = new XPoint[n];
+  else pxp = multipoint;
+  for(i=0; i<n; i++)  { pxp[i].x = x[i];  pxp[i].y = y[i]; } 
+  XDrawPoints(XtDisplay(XtWdg()), XtWindow(XtWdg()), DefGC(), pxp, n, CoordModeOrigin);
+  if (n > NMXXPOINTS)  delete[] pxp;  
+  }
+else for(i=0; i<n; i++) DrawMarker(x[i], y[i]);
+}
+}
+
+/* --Methode-- */
+int PIBaseWdgX::CalcStringWidth(char const* s)
+{
+return(XTextWidth(mFSt, s, strlen(s)));
+}
+
+/* --Methode-- */
+void PIBaseWdgX::SelForeground(PIColors col)
+{
+if (col == mFCol)  return;
+if ( (col < 0) || (col >= NMAXCOL))  return;
+XSetForeground(XtDisplay(XtWdg()), DefGC(), colpix[col]); 
+mFCol = col;
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::SelBackground(PIColors col)
+{
+if (col == mBCol)  return;
+if ( (col < 0) || (col >= NMAXCOL))  return;
+XSetBackground(XtDisplay(XtWdg()), DefGC(), colpix[col]); 
+mBCol = col;
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::SelGOMode(PIGOMode mod)
+{
+if (mod == mGOm)  return;
+switch (mod)
+  {
+  case PI_GOCopy :
+    XSetFunction(XtDisplay(XtWdg()), DefGC(), GXcopy);
+    mGOm = mod;
+    break;
+  case PI_GOXOR :
+    XSetFunction(XtDisplay(XtWdg()), DefGC(), GXxor);
+    mGOm = mod;
+    break;
+  }
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgX::SelFontSzPt(int npt, PIFontAtt att)
+{
+int dsz,i,isel, j;
+
+if ((npt == mFSize) && (att == mFAtt))  return;
+isel = 0;
+dsz = 9999;
+for(i=0; i<NMAXFONTSZ; i++)
+  {
+  j = npt - fntsz[i];   if (j < 0)  j = -j;
+  if (j < dsz)  {  isel = i; dsz = j; }
+  }
+
+j = 0;
+if (att & PI_RomanFont) j = 0;
+if (att & PI_BoldFont) j = 1;
+if (att & PI_ItalicFont) j = 2;
+
+SelectFont(isel, j);
+
+}
+
+/* --Methode-- */
+void PIBaseWdgX::SelFont(PIFontSize sz, PIFontAtt att)
+{
+int i,j;
+switch (sz)
+  {
+  case PI_SmallSizeFont:
+    i = 0;
+    break;
+  case PI_NormalSizeFont:
+    i = 2;
+    break;
+  case PI_BigSizeFont:
+    i = 4;
+    break;
+  default:
+    i=2;
+    break;
+  }
+
+j = 0;
+if (att & PI_RomanFont) j = 0;
+if (att & PI_BoldFont) j = 1;
+if (att & PI_ItalicFont) j = 2;
+
+SelectFont(i, j);
+}
+
+
+
+/* --Methode-- */
+void PIBaseWdgX::SelLine(PILineAtt att)
+{
+unsigned int lt;
+
+if (att == mLAtt)  return;
+
+switch (att)
+  {
+  case PI_NormalLine :
+    lt = 2;
+    break;
+  case PI_ThickLine :
+    lt = 4;
+    break;
+  case  PI_ThinLine :
+    lt = 0;
+    break;
+  default:
+    lt = 0;
+    break;
+  }
+    
+XSetLineAttributes(XtDisplay(XtWdg()), DefGC(), lt, LineSolid, CapButt, JoinMiter);
+mLAtt = att;
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgX::SelPointerShape(PIPointer ptr)  
+{
+if (ptr == mPtrS)  return;
+if ( (ptr < 0) || (ptr >= NMAXCURS))  return;
+if ( XtIsRealized(XtWdg()) )
+  XDefineCursor(XtDisplay (XtWdg()), XtWindow(XtWdg()), curs[ptr]);
+mPtrS = ptr;
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::SelMarker(int msz, PIMarker mrk)
+{
+if (msz > 1)  { mMrk = mrk;  mMrkSz = msz; }
+else  { mMrk = PI_DotMarker;  mMrkSz = 1; }
+return;
+}
+
+/* --Methode-- */
+PIColors  PIBaseWdgX::GetForeground() 
+{
+return (mFCol);
+}
+
+/* --Methode-- */
+PIColors  PIBaseWdgX::GetBackground() 
+{
+return (mBCol);
+}
+
+
+/* --Methode-- */
+PIGOMode   PIBaseWdgX::GetGOMode()
+{
+return (mGOm);
+}
+
+/* --Methode-- */
+PIFontAtt  PIBaseWdgX::GetFontAtt()
+{
+return (mFAtt);
+}
+
+/* --Methode-- */
+int        PIBaseWdgX::GetFontSize()
+{
+return (mFSize);
+}
+
+/* --Methode-- */
+PILineAtt  PIBaseWdgX::GetLineAtt()
+{
+return (mLAtt);
+}
+
+/* --Methode-- */
+PIPointer  PIBaseWdgX::GetPointerShape()
+{
+return (mPtrS);
+}
+
+/* --Methode-- */
+PIMarker   PIBaseWdgX::GetMarker()
+{
+return (mMrk);
+}
+
+/* --Methode-- */
+int        PIBaseWdgX::GetMarkerSize()
+{
+return (mMrkSz);
+}
+
+
+
+/* --Methode-- */
+void PIBaseWdgX::Refresh()
+{
+if ( (XtIsRealized(XtWdg())) &&  
+   (((PIXtBaseWidget)(this->XtWdg()))->core.visible) )        
+  { /* EraseWindow(); */ Draw(); }
+
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgX::Resize()
+{
+#ifdef DEBUG_PIBWDGX
+printf ("PIBaseWdgX::ReSize %ld %ld NewSize= %d %d\n", 
+         (long)(this), (long)(this->XtWdg()), 
+         (int)this->XtWdg()->core.width, (int)this->XtWdg()->core.height);
+#endif
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::Draw(int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/)
+{
+this->Draw();
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::Draw()
+{
+#ifdef DEBUG_PIBWDGX
+this->EraseWindow();
+this->DrawFBox(10,10, XSize()*2/3, YSize()*2/3);
+#endif
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgX::Enter()
+{
+#ifdef DEBUG_PIBWDGX
+puts("PIBaseWdgX::Enter() enter notify ");
+#endif
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::Leave()
+{
+#ifdef DEBUG_PIBWDGX
+puts("PIBaseWdgX::Leave() leave notify ");
+#endif
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgX::But1Press(int x, int y)
+{
+#ifdef DEBUG_PIBWDGX
+printf ("PIBaseWdgX::But1Press PosX,Y= %d %d \n", x, y);
+#endif
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::But1Release(int x, int y)
+{
+Send(Msg(), PIMsg_Active);
+#ifdef DEBUG_PIBWDGX
+printf ("PIBaseWdgX::ButReleasePosX,Y= %d %d \n", x, y);
+#endif
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::But2Press(int /* x */, int /* y */)
+{
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::But2Release(int /* x */, int /* y */)
+{
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::But3Press(int /* x */, int /* y */) 
+{
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::But3Release(int /* x */, int /* y */) 
+{
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgX::Ptr1Move(int  x, int  y ) 
+{
+#ifdef DEBUG_PIBWDGX
+printf ("PIBaseWdgX::Ptr1Move PosX,Y= %d %d \n", x, y);
+#endif
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::Ptr2Move(int /* x */, int /* y */)  
+{
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgX::Ptr3Move(int /* x */, int /* y */)  
+{
+return;
+}
+
+/* --Methode-- */
+void PIBaseWdgX::Keyboard(int key, PIKeyModifier kmod)
+{
+
+#ifdef DEBUG_PIBWDGX
+printf("PIBaseWdgX::Keyboard: Key= %d (%c)  Mod= %d \n", key, (char)key, (int)kmod); 
+XFlush(XtDisplay(this->XtWdg()));
+#endif
+return;
+}
+
+
+static bool fgbwdg = false ;
+
+// Le bazar pour recuperer des resources de .Xdefault et autres 
+typedef struct 
+  {
+  String fntFam;
+  } myAppData;
+static myAppData  apd;
+
+static XtResource resources[] = {
+  { "fontFamilyName", "FontFamilyName", XtRString, sizeof(String),
+    /*XtOffset(apdp, fntFam)*/ 0, XtRString, "*-helvetica" }
+};
+ 
+static char * fnbi_b[4] = { "medium-r-normal", "bold-r-normal", 
+                          "medium-o-normal", "medium-i-normal" };
+
+static XFontStruct * defnt = NULL;
+static char * fnbi[3];
+
+
+/* --Methode-- */
+void PIBaseWdgX::Init()
+{
+char buff[256];
+int i,j,k, count;
+char **list;
+
+if (fgbwdg)  return;
+fgbwdg = true;
+
+Display *mdsp;
+int scr;
+XColor exact,mycol;
+Colormap  cmap;
+
+mdsp = PIXDisplay();
+scr = XDefaultScreen(mdsp);
+
+XtGetApplicationResources(PIXtTopWdg(), &apd, resources, 
+                          XtNumber(resources), NULL, 0);
+sprintf(buff,"-%s-*-*-*-*-*-*-*-*-*-*-*-*", apd.fntFam);
+list = XListFonts(mdsp, buff, 15, &count);
+XFreeFontNames(list);
+if (count < 5)
+  { 
+  printf("PIBaseWdgX::Init %d fonts found for %s , switching to helvetica\n",
+         count, apd.fntFam);
+  apd.fntFam = "*-helvetica";
+  }
+sprintf(buff,"-%s-%s-*-*-*-*-*-*-*-*-*", apd.fntFam, fnbi_b[0]);
+list = XListFonts(mdsp, buff, 10, &count);
+XFreeFontNames(list);
+if (count < 2) fnbi[0] = "*-*-*";
+else  fnbi[0] = fnbi_b[0];
+sprintf(buff,"-%s-%s-*-*-*-*-*-*-*-*-*", apd.fntFam, fnbi_b[1]);
+list = XListFonts(mdsp, buff, 10, &count);
+XFreeFontNames(list);
+if (count < 2) fnbi[1] = "*-*-*";
+else  fnbi[1] = fnbi_b[1];
+sprintf(buff,"-%s-%s-*-*-*-*-*-*-*-*-*", apd.fntFam, fnbi_b[2]);
+list = XListFonts(mdsp, buff, 10, &count);
+XFreeFontNames(list);
+fnbi[2] = fnbi_b[2];
+if (count < 2) 
+  {
+  sprintf(buff,"-%s-%s-*-*-*-*-*-*-*-*-*", apd.fntFam, fnbi_b[3]);
+  list = XListFonts(mdsp, buff, 10, &count);
+  XFreeFontNames(list);
+  fnbi[2] = fnbi_b[3];
+  }
+if (count < 2) fnbi[2] = "*-*-*";
+
+sprintf(buff,"-*-fixed-*-*-*-*-14-*-*-*-*-*-*-*");
+list = XListFonts(mdsp, buff, 10, &count);
+XFreeFontNames(list);
+if (count < 1) 
+  {  
+  sprintf(buff,"fixed");
+  list = XListFonts(mdsp, buff, 10, &count);
+  XFreeFontNames(list);
+  }
+if (count < 1) 
+  {  
+  strcpy(buff,"");
+  list = XListFonts(mdsp, buff, 10, &count);
+  XFreeFontNames(list);
+  printf("PIBaseWdgX::Init/ Erreur, no font found ... \n");
+  defnt = NULL;
+  }
+else defnt = XLoadQueryFont(mdsp, buff);
+
+for (i=0; i<NMAXFONTSZ; i++)
+  for (j=0; j<3; j++)  fntst[i][j] = NULL;
+
+ 
+/*  Les couleurs  */
+cmap = XDefaultColormap (mdsp, scr);
+
+for(i=0; i<NMAXCOL; i++)  colpix[i] = XWhitePixel(mdsp, scr);
+colpix[PI_Black] = XBlackPixel(mdsp, scr);
+colpix[PI_White] = XWhitePixel(mdsp, scr);
+if ( XAllocNamedColor (mdsp, cmap, "LightGray", &mycol, &exact) )
+  colpix[PI_Grey] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "red", &mycol, &exact) )
+  colpix[PI_Red] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "blue", &mycol, &exact) )
+  colpix[PI_Blue] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "green", &mycol, &exact) )
+  colpix[PI_Green] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "yellow", &mycol, &exact) )
+  colpix[PI_Yellow] = mycol.pixel;
+if ( XAllocNamedColor (mdsp, cmap, "magenta", &mycol, &exact) )
+  colpix[PI_Magenta] = mycol.pixel;
+
+curs[0] = XCreateFontCursor(mdsp, XC_X_cursor);
+for(i=1; i<NMAXCURS; i++)  curs[i] = curs[0];
+
+curs[PI_ArrowPointer] =  XCreateFontCursor(mdsp, XC_arrow);
+curs[PI_CrossPointer] =  XCreateFontCursor(mdsp, XC_crosshair);
+curs[PI_HandPointer] =  XCreateFontCursor(mdsp, XC_hand2);
+curs[PI_TDLRArrowPointer] =  XCreateFontCursor(mdsp, XC_fleur);
+
+return;
+}
+
+
+/* --Methode-- */
+void PIBaseWdgX::SelectFont(int isz, int jat)
+{
+
+if (!fntst[isz][jat])  // Il faut charger la fonte
+  {
+  char buff[256];
+  int count,k;
+  Display * mdsp = PIXDisplay();
+  char **list;
+
+  for (k=0; k<5; k++)    // Recherche de la fonte pour tailles croissantes
+    {
+    sprintf(buff,"-%s-%s-*-%d-*-*-*-*-*-*-*", apd.fntFam, fnbi[jat], fntsz[isz]+k);
+    list = XListFonts(mdsp, buff, 10, &count);
+    XFreeFontNames(list);
+    if (count > 0)  break;
+    }
+  if (count > 0)
+    fntst[isz][jat] = XLoadQueryFont(mdsp, buff);
+  else
+    { printf("PIBaseWdgX::SelectFont/ Pb font %s - Using default \n", buff);    
+    fntst[isz][jat] = defnt; }
+  }
+
+mFAtt = fntatt[jat];
+mFSize = fntsz[isz];
+mFSt = fntst[isz][jat];
+XSetFont(XtDisplay(XtWdg()), DefGC(), fntst[isz][jat]->fid);
+return;
+}
Index: /tags/V_Saclay_110697/SophyaPI/PI/pibwdgx.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pibwdgx.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pibwdgx.h	(revision 50)
@@ -0,0 +1,104 @@
+#ifndef PIBWDGX_H_SEEN
+#define PIBWDGX_H_SEEN
+
+#include "pisysdep.h"
+#include "pibwdggen.h"
+
+
+class PIBaseWdgX : public PIBaseWdgGen
+{
+
+public:
+// Les methodes ...
+
+                  PIBaseWdgX(PIContainerGen *par, char *nom,
+                             int sx=10, int sy=10, int px=0, int py=0);
+  virtual         ~PIBaseWdgX();
+
+
+//  Activation des evenements   
+  virtual void   ActivatePtrCross();
+  virtual void   ActivateButton(int bid);
+  virtual void   ActivateMove(int bid);
+  virtual void   ActivateKeyboard();
+
+//  Trace graphiques
+  virtual void   EraseWindow();
+  virtual void   DrawString(int x, int y, char* s, int pos = 0);
+  virtual void   DrawLine(int x1, int y1, int x2, int y2);
+  virtual void   DrawBox(int x0, int y0, int dx, int dy);
+  virtual void   DrawFBox(int x0, int y0, int dx, int dy);
+  virtual void   DrawCircle(int x0, int y0, int r);
+  virtual void   DrawFCircle(int x0, int y0, int r);
+  virtual void   DrawPolygon(int *x, int *y, int n);  
+  virtual void   DrawFPolygon(int *x, int *y, int n);  
+  virtual void   DrawMarker(int x0, int y0);
+  virtual void   DrawMarkers(int *x, int *y, int n);
+
+  virtual int    CalcStringWidth(char const* s);
+
+// Modifications attributs graphiques
+  virtual void   SelForeground(PIColors col=PI_Black);
+  virtual void   SelBackground(PIColors col=PI_White);
+  virtual void   SelGOMode(PIGOMode mod=PI_GOCopy);
+  virtual void   SelFont(PIFontSize sz=PI_NormalSizeFont, 
+                         PIFontAtt att=PI_RomanFont);
+  virtual void   SelFontSzPt(int npt=12, PIFontAtt att=PI_RomanFont);
+  virtual void   SelLine(PILineAtt att=PI_NormalLine);
+  virtual void   SelPointerShape(PIPointer ptr=PI_ArrowPointer);
+  virtual void   SelMarker(int msz, PIMarker mrk=PI_DotMarker);
+  
+
+// Acces aux attributs graphiques 
+  virtual PIColors   GetForeground();
+  virtual PIColors   GetBackground();
+  virtual PIGOMode   GetGOMode();
+  virtual PIFontAtt  GetFontAtt();
+  virtual int        GetFontSize();
+  virtual PILineAtt  GetLineAtt();
+  virtual PIPointer  GetPointerShape();
+  virtual PIMarker   GetMarker();
+  virtual int        GetMarkerSize();
+
+//  Fonction qui doit etre appelee pour rafraichir (retracer) tout 
+  virtual void   Refresh();
+
+// Traitement des evenements   
+  virtual void   Resize();
+  virtual void   Draw();
+  virtual void   Draw(int x0, int y0, int dx, int dy);
+
+  virtual void   Enter();
+  virtual void   Leave();  
+  virtual void   But1Press(int x, int y);
+  virtual void   But1Release(int x, int y);
+  virtual void   But2Press(int x, int y);
+  virtual void   But2Release(int x, int y);
+  virtual void   But3Press(int x, int y);
+  virtual void   But3Release(int x, int y);
+  virtual void   Ptr1Move(int x, int y);
+  virtual void   Ptr2Move(int x, int y);
+  virtual void   Ptr3Move(int x, int y);
+  virtual void   Keyboard(int key, PIKeyModifier kmod);
+
+  inline  GC     DefGC() { return mDefGC; }
+
+protected:
+  void           Init();
+  void           SelectFont(int isz, int jat);
+
+  GC mDefGC;
+  PIColors  mFCol, mBCol;
+  PIGOMode mGOm;
+  PIPointer mPtrS;
+  PIFontAtt mFAtt;
+  PILineAtt mLAtt;
+  int mFSize;
+  XFontStruct *mFSt;
+  PIMarker mMrk;
+  int mMrkSz;
+};
+
+typedef PIBaseWdgX PIBaseWdg;
+
+#endif /* PIBWDGX_H_SEEN */
Index: /tags/V_Saclay_110697/SophyaPI/PI/picmap.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/picmap.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/picmap.cc	(revision 50)
@@ -0,0 +1,52 @@
+#include "picmap.h"
+
+PIColorMap::PIColorMap(CMapId id)
+: PIColorMapNative(id)
+{
+   if (!*maps) { // Il faut allouer les trois maps de depart
+     maps[0] = new PIColorMap(CMAP_GREY32, 0);
+     maps[1] = new PIColorMap(CMAP_GREYINV32, 0);
+     maps[2] = new PIColorMap(CMAP_COLRJ32, 0);
+   }
+   
+   switch (id) {
+     case CMAP_GREY32 : 
+       CopyFrom(maps[0]);
+       break;
+     case CMAP_GREYINV32 : 
+       CopyFrom(maps[1]);
+       break;
+     case CMAP_COLRJ32 : 
+       CopyFrom(maps[2]);
+       break;
+     default:
+       if (!maps[3] || maps[3]->Type() != id) {
+         if (maps[3])
+           {
+           maps[3]->FreeColors();
+           delete maps[3];
+	   }
+         maps[3] = new PIColorMap(id, 0);
+       }
+       CopyFrom(maps[3]);
+   }
+}
+
+
+PIColorMap::PIColorMap(string const& nom, int nCol)
+: PIColorMapNative(nom, nCol)
+{
+  MakeColMap();
+}
+
+PIColorMap::PIColorMap(CMapId id, int i)      // Fait une veritable allocation
+: PIColorMapNative(id,i)
+{
+  MakeColMap();
+}
+
+PIColorMap::~PIColorMap()
+{
+  if (mType == CMAP_OTHER)
+    FreeColors();
+}
Index: /tags/V_Saclay_110697/SophyaPI/PI/picmap.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/picmap.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/picmap.h	(revision 50)
@@ -0,0 +1,18 @@
+#ifndef PICMAP_H_SEEN
+#define PICMAP_H_SEEN
+
+#include "pisysdep.h"
+#include PICMAPNTV_H
+
+
+class PIColorMap : public PIColorMapNative {
+public:
+  PIColorMap(CMapId);
+  PIColorMap(string const& nom, int nCol); 
+  virtual ~PIColorMap();
+protected:
+  PIColorMap(CMapId id, int i);     // Fait une veritable allocation
+};
+
+#endif
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/picmapgen.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/picmapgen.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/picmapgen.cc	(revision 50)
@@ -0,0 +1,169 @@
+#include "picmapgen.h"
+#include <list>
+#include <algorithm>
+#include "pisysdep.h"
+#include PICMAPNTV_H
+#include PICMAP_H
+
+
+
+PIColorMapGen* PIColorMapGen::maps[4] = {NULL,NULL,NULL,NULL};
+
+int PIColorMapGen::nCols[6] = {32,32,32,32,32,16};
+char* PIColorMapGen::noms[6] = {"Grey32","InvGrey32","ColRJ32","ColBR32","ColRV32","Col16"};
+
+PIColorMapGen::PIColorMapGen(CMapId)
+{
+}
+
+void PIColorMapGen::CopyFromGen(PIColorMapGen* m)
+{
+  mNom = m->mNom;
+  mNCol = m->mNCol;
+  mType = m->mType;
+}
+
+
+PIColorMapGen::PIColorMapGen(string const& nom, int nCol)
+{
+  mNom = nom;
+  mNCol = nCol;
+  mType = CMAP_OTHER;
+}
+
+PIColorMapGen::PIColorMapGen(CMapId id, int)
+{
+  if (id < CMAP_GREY32 && id > CMAP_COL16)
+     id = CMAP_GREY32; // BEUARK
+  mNom = noms[id - 1];
+  mNCol = nCols[id - 1];
+  mType = id;
+}
+
+
+PIColorMapGen::~PIColorMapGen()
+{
+}
+
+/*  Definition d' une table de couleurs  R G B   */
+
+static float R_RGB1[16] =
+{0.0,0.00,0.0,0.0,0.0,0.00,0.0,0.6,0.8,1.0,1.00,1.0,0.75,1.0,0.85,1.0};
+static float G_RGB1[16] =
+{0.0,0.00,0.0,0.8,1.0,1.00,1.0,0.8,0.8,1.0,0.75,0.6,0.00,0.0,0.0,0.0};
+static float B_RGB1[16] =
+{0.0,0.75,1.0,1.0,1.0,0.75,0.0,0.0,0.0,0.0,0.00,0.5,0.75,1.0,0.0,0.0};
+
+
+
+void PIColorMapGen::MakeColMap()
+{
+  PIColor mycol;
+  
+  switch (mType)
+  {
+  case CMAP_GREY32 :
+    {for(int i=0; i<mNCol; i++)
+      {
+      mycol.red = mycol.green = mycol.blue = 3535+(i*62000/32);
+      AllocColor(mycol, i);
+      }
+    break;
+    }
+  case CMAP_GREYINV32 :
+    {for(int i=0; i<mNCol; i++)
+      {
+      mycol.red = mycol.green = mycol.blue = 65535-(i*62000/32);
+      AllocColor(mycol, i);
+      }
+    break;
+    }
+  case CMAP_COL16 :
+    {for(int i=0; i<mNCol; i++)
+      {
+      mycol.red = (int)(R_RGB1[i]*65535.);
+      mycol.green = (int)(G_RGB1[i]*65535.);
+      mycol.blue =(int)(B_RGB1[i]*65535.) ;
+      AllocColor(mycol, i);
+      }
+    break;
+    }
+  case CMAP_COLRJ32 :
+    {for(int i=0; i<mNCol; i++)
+      {
+      if (i < 12) 
+        { mycol.green = mycol.blue = 0;  
+          mycol.red = 21535+(i*4000); }
+      else if (i < 24)
+        { mycol.blue = 0;   mycol.red = 65535;
+          mycol.green = 21535+(i-12)*4000;  }
+      else 
+        { mycol.green = mycol.red = 65535;
+          mycol.blue = 17535+(i-23)*6000; }
+
+      AllocColor(mycol, i);
+      }
+    break;
+    }
+  case CMAP_COLBR32 :
+    {for(int i=0; i<mNCol; i++)
+      {
+      if (i < 5) 
+        { mycol.green = mycol.red = 0;  
+          mycol.blue = 5535+i*15000; }
+      else if (i < 10)
+        { mycol.blue = 65535;
+          mycol.green = 5535+(i-5)*9000;
+          mycol.red = 0;  }
+      else if (i < 15)
+        { mycol.blue = 60000-(i-10)*15000;
+          mycol.green = 41535+(i-10)*6000;
+          mycol.red = 0;  }
+      else if (i < 21)
+        { mycol.blue = 0;
+          mycol.green = 65535;
+          mycol.red = 5535+(i-15)*12000;  }
+      else if (i < 27)
+        { mycol.blue = 0;
+          mycol.green = 60000-(i-21)*12000;
+          mycol.red = 65535-(i-21)*2000;  }
+      else 
+        { mycol.blue = 0;
+          mycol.green = 0;
+          mycol.red = 57535+(i-27)*2000; }
+
+      AllocColor(mycol, i);
+      }
+    break;
+    }
+  case CMAP_COLRV32 :
+    {for(int i=0; i<mNCol; i++)
+      {
+      if (i < 8) 
+        { mycol.green = 15000+(i*5000); mycol.blue = 0;  
+          mycol.red = 15000+(i*5000); }
+      else if (i < 21)
+        { mycol.green = 50000-(i-7)*5000;   
+          if (mycol.green < 0)  mycol.green = 0;
+          mycol.blue = 0;
+          mycol.red = 53535+(i-8)*1000;  }
+      else 
+        { mycol.green = 0;  mycol.red = 65535;
+          mycol.blue = 15535+(i-21)*5000; }
+
+      AllocColor(mycol, i);
+      }
+    break;
+    }
+  default :
+    {for(int i=0; i<mNCol; i++)
+      {
+         mycol.green = mycol.red = mycol.blue = 0;
+         AllocColor(mycol, i);
+      }
+    break;
+    }
+  }
+}
+
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/picmapgen.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/picmapgen.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/picmapgen.h	(revision 50)
@@ -0,0 +1,59 @@
+#ifndef PICMAPBASE_H_SEEN
+#define PICMAPBASE_H_SEEN
+
+#include "pisysdep.h"
+#include <string>
+#include <string.h>
+
+
+enum CMapId
+ {
+ CMAP_OTHER       = 0, 
+ CMAP_GREY32      = 1,     // 32 niveaux de gris                    * permanent
+ CMAP_GREYINV32   = 2,     // 32 niveaux gris du blan au noir       * permanent
+ CMAP_COLRJ32     = 3,     // 32 couleurs, du Rouge au Jaune/blanc  * permanent
+ CMAP_COLBR32     = 4,     // 32 couleurs du bleu au rouge
+ CMAP_COLRV32     = 5,     // 32 couleurs 
+ CMAP_COL16       = 6     // 16 Couleurs Arcenciel
+ };
+ 
+
+ 
+struct PIColor {
+  unsigned short red;
+  unsigned short green;
+  unsigned short blue;
+};
+
+class PIColorMapGen {
+public:
+  PIColorMapGen(CMapId);
+  PIColorMapGen(string const& nom, int nCol);  // CMapId : CMAP_OTHER automatiquement
+  virtual ~PIColorMapGen();
+
+  CMapId Type() const       {return mType;}
+  int NCol() const          {return mNCol;}
+  string const& Nom() const {return mNom;}
+
+  virtual PIColor GetColor(int n)=0;
+  virtual void AllocColor(PIColor const& col, int index)=0;
+  virtual void FreeColors()=0;     // Desalloue les couleurs
+protected:
+  PIColorMapGen(CMapId, int);      // Fait une veritable allocation
+  virtual void MakeColMap();       // Alloue la table de couleurs en appelant AllocColor
+  void CopyFromGen(PIColorMapGen*);
+  virtual void CopyFrom(PIColorMapGen*)=0;
+  
+  static int nCols[6];
+  static char* noms[6];
+  
+  static PIColorMapGen* maps[4];
+
+  int    mNCol;
+  CMapId mType;
+  string mNom;
+  
+};
+
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/picmapmac.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/picmapmac.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/picmapmac.cc	(revision 50)
@@ -0,0 +1,97 @@
+#include "picmapmac.h"
+#include <UDebugging.h>
+
+PIColorMapMac::PIColorMapMac(CMapId id)
+: PIColorMapGen(id), mPalette(NULL), mCTab(NULL)
+{
+}
+
+PIColorMapMac::PIColorMapMac(CMapId id, int i)       // Fait une veritable allocation
+: PIColorMapGen(id,i)
+{
+    int n = nCols[id-1];
+	mCTab = (CTabHandle) ::NewHandle(sizeof(long) + 
+				sizeof(short) + sizeof(short) + 
+				256L*sizeof(ColorSpec));
+	(**mCTab).ctFlags = 0;
+	(**mCTab).ctSeed = GetCTSeed();
+	(**mCTab).ctSize = n+2;
+    ColorSpec* sp = (**mCTab).ctTable;
+    sp[0].rgb.red   = 0;
+    sp[0].rgb.green = 0;
+    sp[0].rgb.blue  = 0;
+    sp[0].value     = 0;
+    sp[1].rgb.red   = 65535;
+    sp[1].rgb.green = 65535;
+    sp[1].rgb.blue  = 65535;
+    sp[1].value     = 1;
+}
+
+
+PIColorMapMac::PIColorMapMac(string const& nom, int nCol)
+: PIColorMapGen(nom, nCol)
+{
+	mCTab = (CTabHandle) ::NewHandle(sizeof(long) + 
+				sizeof(short) + sizeof(short) + 
+				256L*sizeof(ColorSpec));
+	(**mCTab).ctFlags = 0;
+	(**mCTab).ctSeed = GetCTSeed();
+	(**mCTab).ctSize = nCol+2;
+    ColorSpec* sp = (**mCTab).ctTable;
+    sp[0].rgb.red   = 0;
+    sp[0].rgb.green = 0;
+    sp[0].rgb.blue  = 0;
+    sp[0].value     = 0;
+    sp[1].rgb.red   = 65535;
+    sp[1].rgb.green = 65535;
+    sp[1].rgb.blue  = 65535;
+    sp[1].value     = 1;
+}
+
+/* --Methode-- */
+PIColor PIColorMapMac::GetColor(int n)
+{
+PIColor picr;
+picr.red = picr.green = picr.blue = 0;
+
+if ((n<0) || (n >= NCol()))   
+  return(picr);
+
+ColorSpec& sp = (**mCTab).ctTable[n+2];
+picr.red   = sp.rgb.red;
+picr.green = sp.rgb.green;
+picr.blue  = sp.rgb.blue;
+
+return(picr);
+}
+
+void PIColorMapMac::AllocColor(PIColor const& col, int index)
+{
+  ColorSpec& sp = (**mCTab).ctTable[index+2];
+  sp.rgb.red   = col.red;
+  sp.rgb.green = col.green;
+  sp.rgb.blue  = col.blue;
+  sp.value     = index+2;
+}
+
+void PIColorMapMac::MakeColMap()
+{
+  PIColorMapGen::MakeColMap();
+  mPalette = NewPalette(mNCol,mCTab,pmTolerant,0);
+}
+
+void PIColorMapMac::FreeColors()
+{
+  Assert_(mPalette);
+  DisposePalette(mPalette);
+  DisposeCTable(mCTab);
+}
+
+void PIColorMapMac::CopyFrom(PIColorMapGen* x)
+{
+  CopyFromGen(x);
+  PIColorMapMac* y = (PIColorMapMac*) x;
+  mPalette = y->mPalette;
+  mCTab = y->mCTab;
+  Assert_(mPalette);
+}
Index: /tags/V_Saclay_110697/SophyaPI/PI/picmapmac.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/picmapmac.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/picmapmac.h	(revision 50)
@@ -0,0 +1,28 @@
+#ifndef PICMAPMAC_H_SEEN
+#define PICMAPMAC_H_SEEN
+
+#include "picmapgen.h"
+#include <Palettes.h>
+
+
+class PIColorMapMac : public PIColorMapGen {
+public:
+  friend class PIColorMapGen;
+  friend class PIPixmapMac;
+  PIColorMapMac(CMapId);
+  PIColorMapMac(string const& nom, int nCol); 
+  virtual PIColor GetColor(int n);
+  virtual void AllocColor(PIColor const& col, int index);
+  virtual void FreeColors();
+  virtual void MakeColMap();
+protected:
+  PIColorMapMac(CMapId id, int i);      // Fait une veritable allocation
+  void CopyFrom(PIColorMapGen*);
+  
+  CTabHandle    mCTab;
+  PaletteHandle mPalette;
+};
+
+typedef PIColorMapMac PIColorMapNative;
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/picmapx.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/picmapx.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/picmapx.cc	(revision 50)
@@ -0,0 +1,162 @@
+#include <stdio.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+
+#include "piwdgx.h"
+#include "picmapx.h"
+
+/* --Methode-- */
+PIColorMapX::PIColorMapX(CMapId id)
+: PIColorMapGen(id) 
+{
+int n = nCols[id-1];
+mColors = new PIXColor[n];
+mColRGB = new PIColor[n];
+for(int i=0; i<n; i++)  
+  { mColors[i] = BlackPixel(PIXDisplay(), PIXScreen());
+  mColRGB[i].red = mColRGB[i].green = mColRGB[i].blue = 0; }
+
+// printf("PIColorMapX::PIColorMapX(CMapId) %d %d \n", mNCol, Type());
+return;
+}
+
+/* --Methode-- */
+PIColorMapX::PIColorMapX(CMapId id, int i)       // Fait une veritable allocation
+: PIColorMapGen(id,i)
+{
+
+int n = nCols[id-1];
+mColors = new PIXColor[n];
+mColRGB = new PIColor[n];
+{for(int i=0; i<n; i++)  
+  { mColors[i] = BlackPixel(PIXDisplay(), PIXScreen());
+  mColRGB[i].red = mColRGB[i].green = mColRGB[i].blue = 0; }
+}// printf("PIColorMapX::PIColorMapX(CMapId, int) %d %d \n", mNCol, Type());
+
+return;
+}
+
+
+/* --Methode-- */
+PIColorMapX::PIColorMapX(string const& nom, int nCol)
+: PIColorMapGen(nom, nCol)
+{
+
+int n = nCol;
+mColors = new PIXColor[n];
+mColRGB = new PIColor[n];
+for(int i=0; i<n; i++)  
+  { mColors[i] = BlackPixel(PIXDisplay(), PIXScreen());
+  mColRGB[i].red = mColRGB[i].green = mColRGB[i].blue = 0; }
+// printf("PIColorMapX::PIColorMapX(nom, nCol) %d %d \n", mNCol, Type());
+
+return;
+
+}
+
+/* --Methode-- */
+PIColorMapX::~PIColorMapX()
+{
+delete[] mColors;
+delete[] mColRGB;
+}
+
+
+/* --Methode-- */
+PIColor PIColorMapX::GetColor(int n)
+{
+PIColor picr;
+picr.red = picr.green = picr.blue = 0;
+
+if ((n<0) || (n >= NCol()))   
+  {
+  PIColor picr;
+  picr.red = picr.green = picr.blue = 0;
+  return(picr);
+  }
+return(mColRGB[n]);
+}
+
+static  Colormap  defxcmap;
+static  xinicmap = 0;
+
+/* --Methode-- */
+void PIColorMapX::AllocColor(PIColor const& col, int index)
+{
+XColor myxcol;
+
+if (!xinicmap)  
+  {
+  defxcmap = XDefaultColormap (PIXDisplay(), PIXScreen());
+  xinicmap = 1;
+  }
+
+if ( (index < 0) || (index > mNCol) )  return;
+
+if ( (col.red == 0) && (col.green == 0) && (col.blue == 0) )
+  {
+  mColors[index] = BlackPixel(PIXDisplay(), PIXScreen());
+  mColRGB[index] = col; 
+  return;
+  }
+
+myxcol.red = col.red; 
+myxcol.blue = col.blue;
+myxcol.green = col.green;
+
+
+if ( XAllocColor(PIXDisplay(), defxcmap, &myxcol) )
+  {
+  mColors[index] = myxcol.pixel;
+  mColRGB[index] = col; 
+//  printf("PIColorMapX::AllocColor()  RGB= %d %d %d \n",
+//         (int) col.red, (int) col.blue, (int) col.green);
+  }
+else  
+  printf("PIColorMapX::AllocColor() Error: Pb Allocation RGB= %d %d %d \n",
+         (int) col.red, (int) col.blue, (int) col.green);
+return;
+}
+
+/* --Methode-- 
+void PIColorMapX::MakeColMap()
+{
+}
+*/
+
+/* --Methode-- */
+void PIColorMapX::FreeColors()
+{
+PIXColor bpix;
+PIColor blc;
+
+if (!xinicmap)  
+  {
+  defxcmap = XDefaultColormap (PIXDisplay(), PIXScreen());
+  xinicmap = 1;
+  }
+
+for (int i=0; i<mNCol; i++)
+  if ( (mColRGB[i].red != 0) && (mColRGB[i].blue != 0) &&  (mColRGB[i].green != 0) )
+    XFreeColors(PIXDisplay(), defxcmap, mColors+i, 1, 0);
+
+bpix = BlackPixel(PIXDisplay(), PIXScreen());
+blc.red = blc.green = blc.blue = 0;
+{for (int i=0; i<mNCol; i++)  
+  { mColors[i] = bpix;   mColRGB[i] = blc; }
+}
+printf("PIColorMapX::FreeColors()  Type= %d mNCol= %d \n",
+       Type(), NCol());
+
+}
+
+/* --Methode-- */
+void PIColorMapX::CopyFrom(PIColorMapGen* x)
+{
+  CopyFromGen(x);
+  for (int i=0; i<mNCol; i++)  
+    { mColors[i] = ((PIColorMapX *)x)->mColors[i];
+    mColRGB[i] = ((PIColorMapX *)x)->mColRGB[i]; }
+}
Index: /tags/V_Saclay_110697/SophyaPI/PI/picmapx.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/picmapx.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/picmapx.h	(revision 50)
@@ -0,0 +1,34 @@
+#ifndef PICMAPX_H_SEEN
+#define PICMAPX_H_SEEN
+
+#include "picmapgen.h"
+
+typedef   unsigned long PIXColor ;
+
+
+class PIColorMapX : public PIColorMapGen {
+public:
+  friend class PIColorMapGen;
+  friend class PIPixmapX;
+
+  PIColorMapX(CMapId);
+  PIColorMapX(string const& nom, int nCol); 
+
+  inline PIXColor  Color(int index) 
+    { return ((index < mNCol) ? mColors[index] : 0); } ;
+
+  virtual PIColor GetColor(int n);
+  virtual void AllocColor(PIColor const& col, int index);
+  virtual void FreeColors();
+//  virtual void MakeColMap();
+protected:
+  PIColorMapX(CMapId id, int i);      // Fait une veritable allocation
+  void CopyFrom(PIColorMapGen*);
+  
+  PIXColor  * mColors;     // La table des couleurs ...
+  PIColor   * mColRGB;     // Composantes RGB  
+};
+
+typedef PIColorMapX PIColorMapNative;
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/picontainergen.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/picontainergen.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/picontainergen.cc	(revision 50)
@@ -0,0 +1,94 @@
+#include "picontainergen.h"
+
+
+#define NCHALGRP 4
+
+/* --Methode-- */
+PIContainerGen::PIContainerGen(PIContainerGen *par, char *nom, 
+                               int sx, int sy, int px, int py)
+: PIWdg(par, nom, sx, sy, px, py) , stvis(0) 
+{
+mNCh = 0;
+mACSup = mPaSup = false;
+mChilds = new (PIWdgGen * [NCHALGRP]);
+mMxCh = NCHALGRP;
+}
+
+
+/* --Methode-- */
+PIContainerGen::~PIContainerGen()
+{
+mPaSup = true;   // Pour prevenir ChildDel()
+if (mACSup)
+  for(int i=0; i<mNCh; i++)  delete mChilds[i];
+delete[] mChilds;
+}
+
+/* --Methode-- */
+void PIContainerGen::PSPrint(PSFile *psf, int ofx, int ofy)
+{
+int i;
+if (!psf)  return;
+if (!Visible())  return;
+for(i=0; i<mNCh; i++)  mChilds[i]->PSPrint(psf, ofx+XPos(), ofy+YPos()); 
+return;
+}
+
+/* --Methode-- */
+void PIContainerGen::Show()
+{
+stvis = 1;
+return;
+}
+
+/* --Methode-- */
+void PIContainerGen::Hide()
+{
+stvis = 0;
+return;
+}
+
+/* --Methode-- */
+int PIContainerGen::Visible()
+{
+return(stvis);
+}
+
+/* --Methode-- */
+void PIContainerGen::ChildAdd(PIWdgGen* child)
+{
+if (child == NULL)  return;
+if (mNCh == mMxCh)
+  {
+  PIWdgGen ** och = mChilds;
+  mChilds = new (PIWdgGen * [mMxCh+NCHALGRP]);
+  for(int i=0; i<mNCh; i++)  mChilds[i] = och[i];
+  delete[] och;
+  mMxCh += NCHALGRP;
+  }  
+mChilds[mNCh] = child;   mNCh++; 
+return;
+}
+
+/* --Methode-- */
+void PIContainerGen::ChildDel(PIWdgGen* child)
+{
+if (mPaSup) return;  // Ne rien faire si delete initie par Container-parent
+if ((child == NULL) || (mNCh < 1))  return;
+for(int i=0; i<mNCh; i++)  
+  if (mChilds[i] == child)
+    {
+    mNCh--;
+    mChilds[i] = mChilds[mNCh];
+    break;
+    }
+return;
+}
+
+
+/* --Methode-- */
+void PIContainerGen::SetAutoDelChilds(bool ad)
+{
+mACSup = ad;
+return;
+}
Index: /tags/V_Saclay_110697/SophyaPI/PI/picontainergen.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/picontainergen.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/picontainergen.h	(revision 50)
@@ -0,0 +1,37 @@
+#ifndef PICONTAINERBASE_SEEN
+#define PICONTAINERBASE_SEEN
+
+#include "pisysdep.h"
+
+#include PIWDG_H
+
+
+class PIContainerGen : public PIWdg 
+{
+public:
+  enum {ClassId = 1500};
+
+               PIContainerGen(PIContainerGen *par, char *nom, 
+                              int sx=10, int sy=10, int px=0, int py=0);
+  virtual      ~PIContainerGen();
+
+  virtual long         kind() {return ClassId; }
+
+  virtual void         PSPrint(PSFile *psf, int ofx=0, int ofy=0);
+
+  virtual void         Show();
+  virtual void         Hide();
+  virtual int          Visible();
+
+  virtual void         ChildAdd(PIWdgGen * child);
+  virtual void         ChildDel(PIWdgGen * child);
+
+  void                 SetAutoDelChilds(bool ad = false);
+protected:
+  int                  stvis;
+  PIWdgGen          ** mChilds;
+  int                  mNCh, mMxCh;
+  bool                 mPaSup,mACSup;
+};
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/picontainermac.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/picontainermac.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/picontainermac.cc	(revision 50)
@@ -0,0 +1,27 @@
+#include "picontainermac.h"
+
+PIContainerMac::PIContainerMac(PIContainerGen *par, char *nom,
+                         int sx, int sy, int px, int py)
+: PIContainerGen(par, nom, sx, sy, px, py)
+{
+}
+
+PIContainerMac::~PIContainerMac()
+{}
+
+/* --Methode-- */
+void PIContainerMac::Show()
+{
+  PIContainerGen::Show();
+  mPane->Show();
+  //((LWindow*)mPane)->Select();
+}
+
+/* --Methode-- */
+void PIContainerMac::Hide()
+{
+  PIContainerGen::Hide();
+  mPane->Hide();
+}
+
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/picontainermac.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/picontainermac.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/picontainermac.h	(revision 50)
@@ -0,0 +1,23 @@
+#ifndef PICONTAINERMAC_SEEN
+#define PICONTAINERMAC_SEEN
+
+#include "picontainergen.h"
+#include "pisysdep.h"
+#include <LView.h>
+
+class PIContainerMac : public PIContainerGen {
+public:
+                         PIContainerMac(PIContainerGen *par, char *nom,
+                                   int sx=10, int sy=10, int px=0, int py=0);
+  virtual                ~PIContainerMac();
+  
+  virtual void           Show();
+  virtual void           Hide();
+
+protected:
+
+};
+
+typedef PIContainerMac PIContainer;
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/picontainerx.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/picontainerx.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/picontainerx.cc	(revision 50)
@@ -0,0 +1,41 @@
+#include "picontainerx.h"
+
+#include <Xm/Form.h>
+
+/* --Methode-- */
+PIContainerX::PIContainerX(PIContainerGen *par, char *nom, 
+                           int sx, int sy, int px, int py) 
+: PIContainerGen(par, nom, sx, sy, px, py)
+{
+if ((sx > 0) && (sy > 0))
+  CreateXtWdg(nom, xmFormWidgetClass , NULL, sx, sy, px, py);
+//  CreateXtWdg(nom, xmBulletinBoardWidgetClass , NULL, sx, sy, px, py);
+}
+
+PIContainerX::PIContainerX(PIMsgHandler *par, PIWdgX *parwdg, char *nom,  
+                           int sx, int sy, int px, int py) 
+: PIContainerGen(NULL, nom, sx, sy, px, py)
+{
+SetMsgParent(par);
+if ((sx > 0) && (sy > 0))
+  CreateXtWdg(nom, xmFormWidgetClass , parwdg->XtWdg(), sx, sy, px, py);
+}
+
+/* --Methode-- */
+PIContainerX::~PIContainerX()
+{}
+
+/* --Methode-- */
+void PIContainerX::Show()
+{
+PIContainerGen::Show();
+Manage();
+}
+
+/* --Methode-- */
+void PIContainerX::Hide()
+{
+PIContainerGen::Hide();
+Unmanage();
+}
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/picontainerx.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/picontainerx.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/picontainerx.h	(revision 50)
@@ -0,0 +1,27 @@
+#ifndef PICONTAINERX_SEEN
+#define PICONTAINERX_SEEN
+
+#include "pisysdep.h"
+#include "picontainergen.h"
+
+
+class PIContainerX : public PIContainerGen 
+{
+public:
+              PIContainerX(PIContainerGen *par, char *nom,
+                           int sx=10, int sy=10, int px=0, int py=0);
+
+// Ce constructeur est a utiliser par PIApplicationX ...
+              PIContainerX(PIMsgHandler *par, PIWdgX *parwdg, char *nom,
+                           int sx=10, int sy=10, int px=0, int py=0);
+
+  virtual     ~PIContainerX();
+
+  virtual void           Show();
+  virtual void           Hide();
+
+};
+
+typedef PIContainerX PIContainer;
+
+#endif  /* PICONTAINERX_SEEN */
Index: /tags/V_Saclay_110697/SophyaPI/PI/pidrawwin.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pidrawwin.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pidrawwin.cc	(revision 50)
@@ -0,0 +1,28 @@
+#include "pidrawwin.h"
+
+PIDrawWindow::PIDrawWindow(PIMsgHandler* par, char *nom,
+                               PIWindowKind k, int sx, int sy, int px, int py)
+:PIWindow(par, nom, k, sx, sy, px, py)
+{
+   mDrawWdg = new PIScDrawWdg(this, nom, sx-20, sy-20, 10, 10);
+   mDrawWdg->SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_fixed);   
+}
+
+
+PIDrawWindow::~PIDrawWindow()
+{
+  delete mDrawWdg;
+}
+
+void
+PIDrawWindow::AddDrawer(PIScDrawer* d)
+{
+  mDrawWdg->AddDrawer(d);
+}
+
+void
+PIDrawWindow::SetAxesFlags(int flags)
+{
+  mDrawWdg->SetAxesFlags(flags);
+}
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/pidrawwin.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pidrawwin.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pidrawwin.h	(revision 50)
@@ -0,0 +1,26 @@
+#ifndef PIDRAWWIN_H
+#define PIDRAWWIN_H
+
+// Une fenetre qui contient un drawwdg...
+
+#include "pisysdep.h"
+#include PIWIN_H
+#include "piscdrawwdg.h"
+
+class PIDrawWindow : public PIWindow {
+public:
+                 PIDrawWindow(PIMsgHandler* par, char *nom, 
+                                PIWindowKind k=PIWK_normal, int sx=10, int sy=10, 
+                                int px=0, int py=0);
+                ~PIDrawWindow();
+                
+ virtual void    AddDrawer(PIScDrawer*);                
+ virtual void    SetAxesFlags(int flags=-1);
+ inline PIScDrawWdg * DrawWdg() { return mDrawWdg; }
+private:
+  PIScDrawWdg*   mDrawWdg;
+};
+
+
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/pierrdisp.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pierrdisp.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pierrdisp.cc	(revision 50)
@@ -0,0 +1,105 @@
+#include "pierrdisp.h"
+#include "utils.h"
+
+
+PIErrorBox::PIErrorBox(PIContainerGen* par, int sx, int sy,
+	     int px, int py)
+: PIBaseWdg(par, "Error Message", sx, sy, px, py)
+{
+  currErrText = "";
+  state = 0;
+}
+
+PIErrorBox::~PIErrorBox()
+{
+}
+
+void
+PIErrorBox::Draw()
+{
+  if (currErrText == "") {
+    SelBackground();
+    EraseWindow();
+  } else {
+    switch(state) {
+    case 0:
+      EraseWindow();
+      SelForeground(PI_Red);
+      DrawFBox(0,0,1000,1000);
+      SelForeground(PI_Black);
+      break;
+    default:
+      SelBackground();
+      SelForeground();
+    }
+    SelFont(PI_BigSizeFont, PI_BoldFont);
+    DrawString(20,30,(char*)currErrText.c_str());
+  }
+}
+
+void
+PIErrorBox::Cycle()
+{
+  state = (state + 1) % 2;
+}
+
+
+
+
+PIErrorDisplay::PIErrorDisplay(PIContainerGen* par, int sx, int sy,
+			       int px, int py)
+: PIContainer(par, "Error Display", sx, sy, px, py), PIPeriodX(1)
+{
+  currErrId = 0;
+
+  errorBox  = new PIErrorBox(this, 150, 80, 0, 0);
+  ackButton = new PIButton(this, "OK", 5000, 40, 20, 155, 20);
+  updButton = new PIButton(this, "Upd", 5001, 40, 20, 155, 50);
+  Start();
+}
+
+PIErrorDisplay::~PIErrorDisplay()
+{
+  delete updButton;
+  delete ackButton;
+  delete errorBox;
+}
+
+void
+PIErrorDisplay::Process(PIMessage msg, PIMsgHandler *sender, void *data)
+{
+msg = UserMsg(msg);
+  switch(msg) {
+  case 5000:
+    // On valide
+    if (currErrId) 
+      AcqAckError(currErrId);
+    UpdData();
+    break;
+  case 5001:
+    UpdData();
+    break;
+    
+  default:
+    PIContainer::Process(msg, sender, data);
+  }
+}
+
+void
+PIErrorDisplay::UpdData()
+{
+  currErrId = 0;
+  char tache[80];
+  char msg[200];
+  int code;
+  int severite;
+  int rc = AcqGetNextError(&currErrId, tache, &code, &severite, msg);
+  if (rc)
+    errorBox->SetText("");
+  else
+    errorBox->SetText(string(tache) + " : (" + itos(code) + "/" +
+		     itos(severite) +") " + msg);
+  errorBox->Draw();
+}
+
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/pierrdisp.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pierrdisp.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pierrdisp.h	(revision 50)
@@ -0,0 +1,49 @@
+// This may look like C code, but it is really -*- C++ -*-
+#ifndef PIERRDISP_H_SEEN
+#define PIERRDISP_H_SEEN
+
+#include "pisysdep.h"
+#include PIBWDG_H
+#include PISTDWDG_H
+#include PICONT_H
+#include PIPERIOD_H
+#include <string>
+
+#include "errorhandlerc.h"
+
+class PIErrorBox : public PIBaseWdg {
+public:
+  PIErrorBox(PIContainerGen* par, int sx=100, int sy = 50,
+	     int px=0, int py=0);
+  ~PIErrorBox();
+
+  void Draw();
+  
+  void SetText(string const& txt) {currErrText = txt;}
+  void Cycle();
+
+protected:
+  string currErrText;
+  int           state;     // Cycle decoratif en couleurs violentes...  
+};
+
+class PIErrorDisplay : public PIContainer, public PIPeriodic {
+public:
+  
+  PIErrorDisplay(PIContainerGen* par, int sx=150, int sy=50,
+		 int px=0, int py=0);
+  virtual      ~PIErrorDisplay();
+  
+  void          UpdData();
+  void          Process(PIMessage msg, PIMsgHandler *sender, void *data);
+  void          DoPeriodic() {UpdData();}
+protected:
+  int           currErrId;
+
+  PIErrorBox*   errorBox;
+  PIButton*     ackButton;
+  PIButton*     updButton;   // TEMPORAIRE
+};
+
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/pifilechogen.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pifilechogen.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pifilechogen.cc	(revision 50)
@@ -0,0 +1,27 @@
+#include "pifilechogen.h"
+
+
+/************* PIFileChooserGen ************/
+
+PIFileChooserGen::PIFileChooserGen(PIMsgHandler* par, char* nom, PIMessage msg)
+: PIWdg(NULL, nom)
+{
+SetMsg(msg);
+SetMsgParent(par);
+}
+
+PIFileChooserGen::~PIFileChooserGen()
+{}
+
+void PIFileChooserGen::Show()
+{
+return;
+}
+
+
+void PIFileChooserGen::AcceptNewFile(bool)
+{
+return;
+}
+
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/pifilechogen.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pifilechogen.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pifilechogen.h	(revision 50)
@@ -0,0 +1,35 @@
+#ifndef PIFILCHOGEN_H_SEEN
+#define PIFILCHOGEN_H_SEEN
+
+#include <string>
+#include "pisysdep.h"
+#include PIWDG_H
+
+class PIFileChooserGen : public PIWdg {
+public:
+  enum {ClassId = 2100};
+
+                     PIFileChooserGen(PIMsgHandler* par, char* nom, PIMessage msg);
+  virtual            ~PIFileChooserGen();
+
+  virtual void       Show();
+
+  virtual void       AcceptNewFile(bool acc);
+  virtual void       SetPath(string const&) = 0;
+  virtual void       SetFileName(string const&) = 0;
+
+  virtual string     GetPath() = 0;
+  virtual string     GetFileName() = 0;
+
+  virtual long       kind() {return ClassId; }
+
+protected:
+
+};
+
+
+#endif
+
+
+
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/pifilechomac.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pifilechomac.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pifilechomac.cc	(revision 50)
@@ -0,0 +1,121 @@
+#include "pifilechomac.h"
+
+string PathNameFromDirID(long dirID, short vRefNum);
+
+
+string PIGetFileName(string dir)
+{
+  StandardFileReply reply;
+  
+  
+  string fName;
+  int i = dir.rfind(':');
+  if (i == NPOS)
+    fName = dir;
+  else if (i == dir.length())
+    fName = "";
+  else
+    fName = dir.substr(i+1);
+    
+  LStr255 defaultName(fName.c_str());
+  
+  StandardPutFile("\pSave as:",defaultName,&reply);
+  
+  if (!reply.sfGood) return "";
+  
+  string directory = PathNameFromDirID(reply.sfFile.parID,reply.sfFile.vRefNum);
+  p2cstr(reply.sfFile.name);
+  
+//  return directory + '/' + (char*)reply.sfFile.name;
+  return directory + ':' + (char*)reply.sfFile.name;
+}
+
+string PIGetExistingFileName(string /*dir*/)
+{
+  StandardFileReply reply;
+  SFTypeList typeList;
+  
+  StandardGetFile(NULL,-1,typeList,&reply);
+  
+  if (!reply.sfGood) return "";
+  
+  string directory = PathNameFromDirID(reply.sfFile.parID,reply.sfFile.vRefNum);
+  p2cstr(reply.sfFile.name);
+  
+//  return directory + '/' + (char*)reply.sfFile.name;
+  return directory + ':' + (char*)reply.sfFile.name;
+}
+
+
+string PathNameFromDirID(long dirID, short vRefNum)
+{
+	DirInfo 	block;
+	Str255		directoryName;
+	OSErr		err;
+
+	string fullPathName = "";
+
+	block.ioDrParID = dirID;
+	block.ioNamePtr = directoryName;
+	do {
+			block.ioVRefNum = vRefNum;
+			block.ioFDirIndex = -1;
+			block.ioDrDirID = block.ioDrParID;
+			err = PBGetCatInfoSync(CInfoPBPtr(&block));
+			p2cstr(directoryName);
+			if (fullPathName != "") fullPathName = ':' + fullPathName;
+			fullPathName =  ((char*)directoryName + fullPathName);
+//			fullPathName = '/' + ((char*)directoryName + fullPathName);
+	} while (block.ioDrDirID != 2);
+	return fullPathName;
+}
+
+
+PIFileChooserMac::PIFileChooserMac(PIMsgHandler* par, char* nom, PIMessage msg)
+: PIFileChooserGen(par, nom, msg)
+{
+  mAccNew = false;
+  mFileName = "";
+}
+
+PIFileChooserMac::~PIFileChooserMac()
+{}
+
+void
+PIFileChooserMac::Show()
+{
+  if (mAccNew)
+    mFileName = PIGetFileName("");
+  else
+    mFileName = PIGetExistingFileName("");
+
+// Envoyer un message....
+  if (mFileName == "")
+    Send(Msg(), PIMsg_Cancel, NULL);
+  else
+    Send(Msg(), PIMsg_OK, (void *) (GetFileName().c_str()));
+}
+
+void
+PIFileChooserMac::AcceptNewFile(bool acc)
+{
+  mAccNew = acc;
+}
+
+void
+PIFileChooserMac::SetPath(string const& path) {}
+void
+PIFileChooserMac::SetFileName(string const& fname) {}
+
+string
+PIFileChooserMac::GetPath()
+{
+  return "";
+}
+
+string
+PIFileChooserMac::GetFileName()
+{
+  return mFileName;
+}
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/pifilechomac.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pifilechomac.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pifilechomac.h	(revision 50)
@@ -0,0 +1,33 @@
+#ifndef PIFILECHOMAC_H_SEEN
+#define PIFILECHOMAC_H_SEEN
+
+#include <string>
+#include "pisysdep.h"
+#include "pifilechogen.h"
+
+class PIFileChooserMac : public PIFileChooserGen {
+public:
+
+                   PIFileChooserMac(PIMsgHandler* par, char* nom, PIMessage msg);
+  virtual          ~PIFileChooserMac();
+
+  virtual void     Show();
+
+  virtual void     AcceptNewFile(bool acc);
+  virtual void     SetPath(string const& path);
+  virtual void     SetFileName(string const& fname);
+
+  virtual string   GetPath();
+  virtual string   GetFileName();
+
+protected:
+  bool             mAccNew;
+  string           mFileName;
+};
+
+typedef PIFileChooserMac     PIFileChooser ;
+
+#define FILESEP ':'
+
+#endif
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/pifilechox.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pifilechox.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pifilechox.cc	(revision 50)
@@ -0,0 +1,170 @@
+#include<stdio.h>
+#include<string.h>
+
+#include "pisysdep.h"
+
+#include "pifilechox.h"
+
+
+/************* PIFileChooserX ************/
+#include <X11/Shell.h>
+#include <Xm/FileSB.h>
+
+// Pour ces sal... de XmString  (ds piwdgx.cc)
+int CStrFrXmStr(XmString xms, char* buff, int nmx);
+
+// Fonctions privees (CallBack)
+//static void filesel_okact(Widget w, XtPointer *usd, XtPointer *calld);
+static void filesel_cancelact(Widget w, XtPointer *usd, XtPointer *calld);
+
+/* Nouvelle-Fonction */
+void  filesel_okact(Widget /*w*/, XtPointer *usd, 
+                    XmFileSelectionBoxCallbackStruct *calld)
+{
+PIFileChooserX *pif;
+pif = (PIFileChooserX *) usd ;
+pif->mSt = 1;
+pif->MWin()->Unmanage();
+//pif->Send(pif->Msg(), (void *) (pif->GetFileName().c_str()));
+CStrFrXmStr(calld->value, pif->mFName, 512); 
+pif->Send( pif->Msg(), PIMsg_OK, (void *) pif->mFName);
+return;
+}
+
+/* Nouvelle-Fonction */
+void  filesel_cancelact(Widget /*w*/, XtPointer *usd, XtPointer */*calld*/)
+{
+PIFileChooserX *pif;
+pif = (PIFileChooserX *) usd ;
+pif->mSt = 0;
+pif->mFName[0] = '\0';
+pif->MWin()->Unmanage();
+pif->Send(pif->Msg(), PIMsg_Cancel, NULL);
+return;
+}
+
+#define PIFC_SzX  350
+#define PIFC_SzY  300
+
+/* --Methode-- */
+PIFileChooserX::PIFileChooserX(PIMsgHandler* par, char* nom, PIMessage msg)
+: PIFileChooserGen(par, nom, msg)
+{
+SysDWdg wdg;
+
+mWin = NULL;
+mWin = new PIWdgX(NULL, nom, PIFC_SzX, PIFC_SzY, 150, 150);
+mWin->CreateXtWdg(nom, topLevelShellWidgetClass, NULL, PIFC_SzX, PIFC_SzY, 200, 200);
+
+mSt = 0;
+mFName[0] = mFName[511] = '\0';
+
+CreateXtWdg(nom, xmFileSelectionBoxWidgetClass, mWin->XtWdg(), PIFC_SzX, PIFC_SzY, 0, 0);
+XtAddCallback(XtWdg(), XmNokCallback, 
+              (XtCallbackProc)filesel_okact, (XtPointer)this);
+XtAddCallback(XtWdg(), XmNcancelCallback, 
+              (XtCallbackProc)filesel_cancelact, (XtPointer)this);
+// Pour avoir une version simplifiee 
+/* wdg = XmFileSelectionBoxGetChild(XtWdg(),XmDIALOG_DIR_LIST);
+XtUnmanageChild(wdg);
+wdg = XmFileSelectionBoxGetChild(XtWdg(),XmDIALOG_DIR_LIST_LABEL);
+XtUnmanageChild(wdg);
+*/
+wdg = XmFileSelectionBoxGetChild(XtWdg(),XmDIALOG_HELP_BUTTON);
+XtUnmanageChild(wdg);
+
+fnl = XmFileSelectionBoxGetChild(XtWdg(),XmDIALOG_SELECTION_LABEL);
+fnw = XmFileSelectionBoxGetChild(XtWdg(),XmDIALOG_TEXT);
+
+Arg warg[2];
+XtSetArg(warg[0], XmNfileTypeMask, XmFILE_REGULAR);
+XtSetValues(XtWdg(), warg, 1);
+
+AcceptNewFile(false);
+Manage();
+}
+
+/* --Methode-- */
+PIFileChooserX::~PIFileChooserX()
+{
+delete mWin;
+}
+
+/* --Methode-- */
+void PIFileChooserX::AcceptNewFile(bool acc)
+{
+if (acc) 
+  {
+  mWin->SetSize( PIFC_SzX, PIFC_SzY+75);
+  XtManageChild(fnl);  XtManageChild(fnw); 
+  }
+else 
+  { 
+  mWin->SetSize( PIFC_SzX, PIFC_SzY+50);
+  XtUnmanageChild(fnl); XtUnmanageChild(fnw); 
+  }
+}
+
+/* --Methode-- */
+void PIFileChooserX::Show()
+{
+mWin->Manage();
+}
+
+/* --Methode-- */
+void PIFileChooserX::SetPath(string const& path)
+{
+XmString xmstr;
+xmstr = XmStringLtoRCreate((char *)path.c_str(), XmSTRING_DEFAULT_CHARSET);
+Arg warg[2];
+XtSetArg(warg[0], XmNdirectory, xmstr); 
+XtSetValues(XtWdg(), warg, 1);
+XmStringFree(xmstr);
+return;
+}
+
+/* --Methode-- */
+void PIFileChooserX::SetFileName(string const& fname)
+{
+XmString xmstr;
+xmstr = XmStringLtoRCreate((char *)fname.c_str(), XmSTRING_DEFAULT_CHARSET);
+Arg warg[2];
+XtSetArg(warg[0], XmNtextString, xmstr); 
+XtSetValues(XtWdg(), warg, 1);
+XmStringFree(xmstr);
+return;
+}
+
+
+/* --Methode-- */
+string PIFileChooserX::GetFileName()
+{
+
+if (mSt)
+  {
+  XmString xmstr;
+  Arg warg[2];
+
+  XtSetArg(warg[0], XmNtextString, &xmstr);
+  XtGetValues(XtWdg(), warg, 1);
+  CStrFrXmStr(xmstr, mFName, 512); 
+  string s(mFName);
+  XmStringFree(xmstr);
+  return(s);
+  }
+else
+  {
+  mFName[0] = '\0';
+  string s(mFName);
+  return(s);
+  }
+}
+
+/* --Methode-- */
+string PIFileChooserX::GetPath()
+{
+printf("PIFileChooserX::GetPath() not implemented ! \n");
+string s("");
+return(s);
+}
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/pifilechox.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pifilechox.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pifilechox.h	(revision 50)
@@ -0,0 +1,42 @@
+#ifndef PIFILCHOX_H_SEEN
+#define PIFILCHOX_H_SEEN
+
+#include <string>
+#include "pisysdep.h"
+#include "pifilechogen.h"
+
+#include PIWIN_H
+
+class PIFileChooserX : public PIFileChooserGen {
+public:
+
+                   PIFileChooserX(PIMsgHandler* par, char* nom, PIMessage msg);
+  virtual          ~PIFileChooserX();
+
+  virtual void     Show();
+
+  virtual void     AcceptNewFile(bool acc);
+  virtual void     SetPath(string const& path);
+  virtual void     SetFileName(string const& fname);
+
+  virtual string   GetPath();
+  virtual string   GetFileName();
+
+  inline PIWdg *   MWin() { return mWin; }
+
+//  Je les declare ici, en public, a cause des callback
+  int mSt;
+  char mFName[512];     
+
+protected:
+  PIWdg * mWin;
+  SysDWdg  fnw, fnl;
+};
+
+typedef PIFileChooserX     PIFileChooser ;
+
+#define FILESEP '/'
+
+
+#endif
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/pigfname.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pigfname.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pigfname.h	(revision 50)
@@ -0,0 +1,11 @@
+#ifndef PIGFNAME_H_SEEN
+#define PIGFNAME_H_SEEN
+
+#include <string>
+
+string PIGetFileName(string = "");
+string PIGetExistingFileName(string = "");
+
+
+#endif
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/pihisto.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pihisto.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pihisto.cc	(revision 50)
@@ -0,0 +1,83 @@
+#include <stdio.h>
+#include "pihisto.h"
+
+PIHisto::PIHisto(Histo* histo)
+: PIScDrawer(), mHisto(histo)
+{
+  ahisup = false;     // Flag pour suppression automatique de mHisto
+}
+
+PIHisto::~PIHisto()
+{
+  if (ahisup)
+    delete mHisto;
+}
+
+
+void
+PIHisto::AttachTo(PIScDrawWdg* wdg)
+{
+  PIScDrawer::AttachTo(wdg);
+  UpdateSize();
+}
+
+
+void
+PIHisto::UpdateSize()
+{
+  if (!mDrawWdg) return;
+  if (mDrawWdg->LimitsFixed()) return;
+  // Commencer par trouver nos limites
+  
+  double xmin = mHisto->XMin();
+  double xmax = (mHisto->XMax());
+
+  double ymax = mHisto->VMax()*1.2;
+  double ymin = mHisto->VMin();
+  
+  mDrawWdg->SetLimits(xmin, xmax, ymin, ymax);
+  mDrawWdg->SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
+}
+
+
+void
+PIHisto::Draw()
+{
+  if (!mDrawWdg) return;
+  for (int i=0; i<mHisto->NBins(); i++) {
+		double left   = mHisto->BinLowEdge(i);
+		double width  = mHisto->BinWidth();
+		double bottom = 0;
+		double height = (*mHisto)(i);
+		mDrawWdg->ScDrawFBox(left,bottom,width,height);
+		mDrawWdg->ScDrawLine(left, bottom, left, bottom + height); // Au moins une ligne...
+	}
+  DrawStats();
+}
+
+void
+PIHisto::DrawStats()
+{
+  // Une boite dans le coin superieur droit
+  if (!mDrawWdg) return;
+  double cellHeight = (mDrawWdg->YMax() - mDrawWdg->YMin()) * 0.05;
+  double cellWidth  = (mDrawWdg->XMax() - mDrawWdg->XMin()) * 0.23;
+  mDrawWdg->ScDrawLine(mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax(),
+                       mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax() - cellHeight);
+  mDrawWdg->ScDrawLine(mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax() - cellHeight,
+                       mDrawWdg->XMax()            , mDrawWdg->YMax() - cellHeight);
+  char label[50];
+  sprintf(label, "N = %.6g", mHisto->NData());
+  mDrawWdg->ScSelFontSz((mDrawWdg->YMax() - mDrawWdg->YMin())/30);
+  mDrawWdg->ScDrawString(mDrawWdg->XMax() - cellWidth*0.9, mDrawWdg->YMax() - cellHeight*0.8, label);
+                       
+}
+
+void
+PIHisto::Refresh()
+{
+  if (!mDrawWdg) return;
+  mDrawWdg->FreeLimits();
+  UpdateSize();
+  mDrawWdg->Refresh();
+}
Index: /tags/V_Saclay_110697/SophyaPI/PI/pihisto.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pihisto.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pihisto.h	(revision 50)
@@ -0,0 +1,26 @@
+#ifndef PIHISTO_H
+#define PIHISTO_H
+
+
+#include "piscdrawwdg.h"
+#include "histos.h"
+
+class PIHisto : public PIScDrawer {
+public:
+                     PIHisto(Histo* histo);
+  virtual           ~PIHisto();
+  virtual void       Draw();
+  virtual void       DrawStats();
+  virtual void       Refresh();  // Recalcule les limites, et reaffiche
+  inline  void       SetAutoDelHisto(bool ad=false) {  ahisup = ad; } 
+  inline  Histo*     Histogram() { return(mHisto); }
+
+protected:
+  Histo* mHisto;
+  bool   ahisup;
+
+  virtual void       AttachTo(PIScDrawWdg*);
+  virtual void       UpdateSize();
+};
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/piimage.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piimage.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piimage.cc	(revision 50)
@@ -0,0 +1,925 @@
+// Affichage d'image            R. Ansari  05/95
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+//                        Refonte   Reza   10/95
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string>
+#include <string.h>
+
+#include "piimage.h"
+
+#include "imageop.h"
+
+
+/* --Methode-- */
+PIImage::PIImage(PIContainerGen *par, char *nom,
+   int sx, int sy, int px, int py) :
+  PIPixmap(par, nom, sx, sy, px, py)
+{
+
+img = NULL;
+aisup = false;
+curshow = true;
+winovis = true;     // $CHECK$ Reza A enlever si possible 17/6/96
+
+admrk = true;
+xpmrk = ypmrk = NULL;   nbmrk = 0;
+mrkt = PI_PlusMarker;   mrkbsz = 3;
+
+zow = NULL;
+gvw = NULL; 
+trtw = NULL;
+trtlb = txw = NULL;
+SetTextWin(NULL);
+gpixm = zpixm = pixm = NULL;
+xsgpxm = xszpxm = xspxm = 0;
+ysgpxm = yszpxm = yspxm = 0;
+lut = NULL; 
+offx = offy = 0;
+xpav = ypav = 0;
+xpv0 = ypv0 = 0;
+xszpav = yszpav = 1;
+xmv0 = ymv0 = -1;
+dxmv = dymv = 0;
+xcurs = ycurs = -1;
+zoom = 1;
+zmgv = 1;
+
+SetColMap(CMAP_COLRJ32);
+
+SelForeground(PI_White);
+SelBackground(PI_Black);
+
+ActivateButton(1);
+ActivateMove(1);
+ActivateButton(2);
+ActivateMove(2);
+ActivateButton(3);
+ActivateMove(3);
+
+}
+
+/* --Methode-- */
+PIImage::~PIImage()
+{
+if (pixm) delete pixm;
+if (zpixm) delete zpixm;
+if (txw)  txw->SetLabel("");
+if (zow) 
+  {
+  zow->SetPixmap(NULL,0,0);
+  zow->EraseWindow();
+  }
+if (gpixm) delete gpixm;
+if (gvw) 
+  {
+  gvw->SetPixmap(NULL,0,0);
+  gvw->EraseWindow();
+  gvw->SetMsg(0); gvw->SetMsgParent(NULL); 
+  gvw->SetUserData(NULL, 0); 
+  }
+if (lut) delete lut;
+if (aisup)  delete img;   // Suppression automatique d'image
+if (admrk) 
+  {
+  if (xpmrk)  delete xpmrk;
+  if (ypmrk)  delete ypmrk;
+  }
+if (trtw)  delete trtw;
+}
+
+/* --Methode-- */
+void PIImage::Process(PIMessage msg, PIMsgHandler* sender, void* data)
+{
+if (UserMsg(msg) == (Msg()+626))
+  {
+  if (ModMsg(msg) == PIMsg_Click) 
+    { int* pxy=(int *)data;   SetPave(pxy[0]*zmgv, pxy[1]*zmgv); }
+  if (ModMsg(msg) == PIMsg_Resize)
+    { ComputeGloVPixmap();   SetGloVPixmap(); }
+  }
+else ReSend(msg, sender, data);
+return;
+}
+
+/* --Methode-- */
+void PIImage::SetImage(RzImage *pim, bool refr)
+{
+
+offx = offy = 0;
+xpav = ypav = 0;
+xszpav = yszpav = 1;
+img = pim;
+if (gpixm) delete gpixm;
+gpixm = NULL;
+xsgpxm = ysgpxm = 0;
+zmgv = 1;
+
+if (img)
+  {
+//  SetSize(img->XSize(), img->YSize());
+  CenterPave();
+  if (img->minPix>img->maxPix) img->CheckDyn();
+  SetLut(img->minPix, img->maxPix, kLutType_Lin, 1, refr);
+  }
+return;
+}
+
+/* --Methode-- */
+void PIImage::AddMarks(int nm, float* px, float* py, bool refr, bool ad, PIMarker mrk, int msz)
+{
+if ( (nbmrk > 0) && admrk ) {
+  if (xpmrk)  delete xpmrk;
+  if (ypmrk)  delete ypmrk;
+}
+if (nm <= 0) { nbmrk = 0; xpmrk = ypmrk = NULL; }
+else { nbmrk = nm;  xpmrk = px, ypmrk = py; }
+admrk = ad;  mrkt = mrk;  mrkbsz = msz;
+if (refr)  DrawMarks(0, XSize(), 0, YSize());
+return;
+}
+
+/* --Methode-- */
+void PIImage::RemoveMarks(bool refr)
+{
+if (nbmrk < 1)  return;
+if (admrk ) {
+  if (xpmrk)  delete xpmrk;
+  if (ypmrk)  delete ypmrk;
+}
+nbmrk = 0; xpmrk = ypmrk = NULL;
+if (refr)  Refresh();
+}
+
+/* --Methode-- */
+void PIImage::SetZoomWin(PIPixmap * zw, bool refr) 
+{
+zow = zw;
+if (zow && refr && img)
+  ComputeZoomPixmap();
+return;
+}
+
+/* --Methode-- */
+void PIImage::SetGloVWin(PIPixmap * zw, bool refr) 
+{
+gvw = zw;
+if (gvw && img)  
+  { ComputeGloVPixmap();
+  if (refr) SetGloVPixmap(); } 
+return;
+}
+
+
+
+/* --Methode-- */
+void PIImage::SetTextWin(PILabel * tw, bool trw, int tx, int ty)
+{
+txw = tw;
+if (trw)
+  {
+  if (trtw)  trtw->SetSize(tx, ty);
+  else
+    {
+    trtw = new PIWindow(this, "PixVal", PIWK_transient, tx, ty, 0, 0);
+    trtw->SetAutoDelChilds(true);
+    trtlb = new PILabel(trtw, "PixVal", tx, ty, 0, 0);
+    trtlb->SetBinding(PIBK_fixed,PIBK_fixed, PIBK_fixed,PIBK_fixed);
+    }
+  }
+else
+  if (trtw) { delete trtw; trtw = NULL;  trtlb = NULL; }
+
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::SetAutoDelImage(bool ad)
+{
+aisup = ad;
+return;
+}
+
+/* --Methode-- */
+void PIImage::ShowCursor(bool sc)
+{
+if (curshow == sc) return;
+curshow = sc;
+if (curshow)  DrawCursor();
+else DrawCursor(-1, -1);
+return;
+}
+
+/* --Methode-- */
+void PIImage::SetLut(float min, float max, int typlut, int lauto, bool refr)
+{
+if (lut) delete(lut);
+if (lauto && img)
+  {
+  float fracnul, fracsat;
+  float fnd, sigfnd;
+  float minpix = min;  
+  float maxpix = max; 
+  int npix = img->XSize()*img->YSize();
+  int rc = -1;
+  if (npix > 2500)  // Ca ne marche pas quand il n'y a pas assez de pixels ...
+    {  
+    int vitesse=npix/20000;
+    vitesse = (vitesse < 1) ? 1 : ((vitesse > 25) ? 25 : vitesse );
+    int nbin=npix/10;
+    nbin = (nbin < 1) ? 1 : ((nbin > 500) ? 500 : nbin );
+    int nbsig = lauto;  
+    float fracmax = 0.95;
+    rc = RzFondSig2Ciel(img, vitesse, fracmax, nbsig, nbin, &minpix, &maxpix, 
+                 &fnd, &sigfnd, &min, &max, &fracnul, &fracsat);
+    }
+  if (rc != 0)
+    {
+    img->CheckDyn(minpix, maxpix);
+    min = img->moyPix-3.*img->sigPix;
+    max = img->moyPix+3.*img->sigPix;
+    if (min < minpix)  min = minpix;
+    if (max > maxpix)  max = maxpix;
+    }
+  }
+
+lut = new LUT(min, max, NbCol(), typlut);
+
+ComputeGloVPixmap();
+if (refr) Apply();
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::SetLut(LUT *clut, bool refr)
+{
+LUT * olut = lut;
+lut = new LUT(clut->Min(), clut->Max(), NbCol(), clut->Type());
+if (olut) delete olut;
+
+ComputeGloVPixmap();
+if (refr) Apply();
+return;
+}
+
+/* --Methode-- */
+void PIImage::SetZoomF(float fzm, bool refr)
+{
+int zm;
+
+if (fzm < 0.01) return;
+if (fzm < 1.)  zm = (int)(-(1./fzm));
+else zm = (int)(fzm+0.25);
+SetZoom(zm, refr);
+return;
+}
+
+/* --Methode-- */
+void PIImage::SetZoom(int zm, bool refr)
+{
+if ((zm == 0) || (zm == -1) )  zoom = 1;
+else if (zm > 20)  zoom = 20;
+else if (zm < -20) zoom = -20;
+else zoom = zm;
+if (img)
+  { SetOffsetFromPave();
+  if (refr) Apply(); }
+return;
+}
+
+/* --Methode-- */
+float PIImage::GetZoomF()
+{
+if (zoom >= 1)  return((float)zoom);
+else return(-1./(float)zoom);
+}
+
+
+/* --Methode-- */
+void PIImage::SetOffset(int ox, int oy, bool refr)
+{
+if (img == NULL)  {offx = offy = 0;  return; }
+if (ox < 0)  ox = 0;
+if (ox >= (img->XSize()-1))  ox = img->XSize()-2;
+if (oy < 0)  oy = 0;
+if (oy >= (img->YSize()-1))  oy = img->YSize()-2;
+offx = ox;  offy = oy;
+CenterPave();
+if (refr) Apply();
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::SetPave(int x, int y, bool refr, bool cent)
+{
+int xc, yc;
+
+if (img == NULL)  
+  { offx = offy = 0; 
+  xpav = ypav = 0; 
+  return; }
+
+if ( (x >= (img->XSize()-1)) || ( x < 0)  ||
+     (y >= (img->YSize()-1)) || ( y < 0)  ) return;
+
+if ( (x == xpav) && (y == ypav) )  return;
+xpav = x;  ypav = y;
+
+if ( PosImg2W(xpav,ypav,&xc, &yc) || cent)  // Il faut recenter l'image
+  { SetOffsetFromPave();  
+  if (refr) Apply(true);  }
+else if (refr)
+  { Apply(false);  if (curshow)  DrawCursor();  }
+
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::SetColMap(CMapId cmap, bool refr)
+{
+PIPixmap::SetColMap(cmap, refr);
+if (zow)  zow->SetColMap(cmap, refr);
+if (gvw)  gvw->SetColMap(cmap, refr);
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::Apply(bool mw)
+{
+if (img == NULL)  return;
+if (mw)
+  {  
+  ComputePixmap();
+  Send(Msg(), PIMsg_Active);
+  }
+if (zow != NULL)   ComputeZoomPixmap();
+if (gvw != NULL)
+  if ( (gvw->UserData() != this) || (mw) )  SetGloVPixmap();
+
+if (txw || trtlb)
+  {
+  char buff[256];
+  sprintf(buff,"X= %d , Y= %d  PixVal= %g ",  /*(char *)Nom().c_str(),*/
+          xpav, ypav, img->FValue(xpav, ypav));
+  if (txw)  txw->SetLabel((string)buff);
+  if (trtlb)  trtlb->SetLabel((string)buff);
+  }
+
+return;
+}
+
+/* --Methode-- */
+void PIImage::Resize()
+{
+// printf("PIImage::Resize\n");
+PIPixmap::Resize();
+CenterPave();
+Apply();
+return;
+}
+
+/* --Methode-- */
+void PIImage::Draw(int x0, int y0, int dx, int dy)
+{
+PIPixmap::Draw(x0, y0, dx, dy);
+winovis = false;    // $CHECK$ Reza A enlever si possible 17/6/96
+if (curshow)
+  {
+  int xc,yc;
+  PosImg2W(xpav, ypav, &xc, &yc);
+  if ((xc >= x0) && (xc < x0+dx) && 
+      (yc >= y0) && (yc < y0+dy) )  DrawCursor(xc, yc);
+  }
+
+DrawMarks(x0, x0+dx, y0, y0+dy);
+return;
+}
+
+/* --Methode-- */
+void PIImage::But1Press(int x, int y)
+{
+int xp, yp;
+
+Send(Msg(), PIMsg_Active);
+if (img == NULL)  return;
+if ( PosW2Img(x, y, &xp, &yp) )  return;
+SelPointerShape(PI_CrossPointer);
+xpav = xp;  ypav = yp;
+ShowTrTxW();
+Apply(false);
+if (curshow)  DrawCursor(-1,-1);
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::Ptr1Move(int x, int y)
+{
+int xp, yp;
+if (img == NULL)  return;
+if ( PosW2Img(x, y, &xp, &yp) )  return;
+xpav = xp;  ypav = yp;
+Apply(false);
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::But1Release(int /*x*/,  int /*y*/)
+{
+SelPointerShape(PI_ArrowPointer);
+if (curshow)  DrawCursor();
+if (trtw)  trtw->Hide();
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::But2Press(int x, int y)
+{
+
+Send(Msg(), PIMsg_Active);
+if (img == NULL)  return;
+if ( PosW2Img(x, y, &xpv0, &ypv0) )  {  xmv0 = -1;  return; }
+xmv0 = x;  ymv0 = y;  dxmv = dymv = 0;
+if (curshow)  DrawCursor(-1,-1);
+SelGOMode(PI_GOXOR);
+if (GetColMapId() == CMAP_COLRJ32)
+SelForeground(PI_Yellow);
+else SelForeground(PI_Magenta);
+SelLine(PI_NormalLine);
+ShowTrTxW();
+return;
+}
+
+/* --Methode-- */
+void PIImage::Ptr2Move(int x, int y)
+{
+int xp, yp;
+if (img == NULL)  return;
+if (xmv0 < 0)  return;
+if ( PosW2Img(x, y, &xp, &yp) )  return;
+DrawBox(xmv0, ymv0, dxmv, dymv);
+dxmv = x-xmv0;  dymv = y-ymv0;
+DrawBox(xmv0, ymv0, dxmv, dymv);
+if (txw || trtlb)
+  {
+  char buff[256];
+  sprintf(buff,"X,Y= %d,%d  PixVal= %g (X,Yc= %d,%d)",  
+          xp, yp, img->FValue(x, yp), (xp+xpv0)/2, (yp+ypv0)/2);
+  if (txw)  txw->SetLabel((string)buff);
+  if (trtlb)  trtlb->SetLabel((string)buff);
+  }
+return;
+}
+
+/* --Methode-- */
+void PIImage::But2Release(int x, int y)
+{
+int xp2, yp2;
+
+if (img == NULL)  return;
+if (xmv0 < 0)  return;
+DrawBox(xmv0, ymv0, dxmv, dymv);
+SelGOMode(PI_GOCopy);
+SelForeground(PI_White);
+if ( PosW2Img(x, y, &xp2, &yp2) )  
+  PosW2Img(xmv0+dxmv, ymv0+dymv, &xp2, &yp2);
+xpav = (xpv0+xp2)/2;
+ypav = (ypv0+yp2)/2;
+xszpav = ((xp2-xpv0) > 0) ? (xp2-xpv0) : 1;
+yszpav = ((yp2-ypv0) > 0) ? (yp2-ypv0) : 1;
+
+Apply(false);
+if (curshow)  DrawCursor();
+if (trtw)  trtw->Hide();
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::But3Press(int x, int y)
+{
+int xp, yp;
+
+Send(Msg(), PIMsg_Active);
+if (img == NULL)  return;
+if ( PosW2Img(x, y, &xp, &yp) )  { xmv0 = -1;  return; }
+if (curshow)  DrawCursor(-1,-1);
+ShowTrTxW();
+SelPointerShape(PI_TDLRArrowPointer);
+xmv0 = xp;
+ymv0 = yp;
+return;
+}
+
+
+/* --Methode-- */
+void PIImage::Ptr3Move(int x, int y)
+{
+int xp, yp;
+if (img == NULL)  return;
+if (xmv0 < 0)  return;
+if ( PosW2Img(x, y, &xp, &yp) )  return;
+if (txw || trtlb)
+  {
+  char buff[256];
+  sprintf(buff,"DelX= %d , DelY= %d ", xp-xmv0, yp-ymv0);
+  if (txw) txw->SetLabel((string)buff);
+  if (trtlb) trtlb->SetLabel((string)buff);
+  }
+}
+
+/* --Methode-- */
+void PIImage::But3Release(int x, int y)
+{
+int xp, yp;
+
+SelPointerShape(PI_ArrowPointer);
+if (trtw)  trtw->Hide();
+if (img == NULL)  return;
+if (xmv0 < 0)  return;
+if ( PosW2Img(x, y, &xp, &yp) )  return;
+
+offx -= (xp-xmv0);
+offy -= (yp-ymv0);
+
+if (offx < 0)  offx = 0;
+if (offy < 0)  offy = 0;
+if (offx >= img->XSize())  offx = img->XSize();
+if (offy >= img->YSize())  offy = img->YSize();
+xpav = xmv0;  ypav = ymv0;
+xmv0 = ymv0 = -1;
+Apply();
+return;
+}
+
+/* --Methode-- */
+unsigned char *  PIImage::ComputePixmap(int ofx, int ofy, int zm, 
+                           int xwsz, int ywsz, unsigned char * opix, 
+                           int * oxsp, int * oysp)
+{
+unsigned char *pix, *pp, ucp;
+int zmm=1;
+int npx, npy, nppx, nppy, nszp, oszp;
+int i,j,k,l;
+float vpx;
+
+
+if ( (img == NULL) || (lut == NULL) ) 
+  { /* printf("PIImage::ComputePixmap:Pb img ou lut %ld %ld \n", 
+            (long)img, (long)lut); */
+  *oxsp = *oysp = 0; return(NULL); }
+
+npx = img->XSize()-ofx;
+npy = img->YSize()-ofy;
+
+if ((zm == 0) || (zm == -1))  zm = 1;
+
+if (zm >= 1)
+  {
+  if (npx > (xwsz/zm))  npx = xwsz/zm; 
+  if (npy > (ywsz/zm))  npy = ywsz/zm;
+  nppx = npx*zm;   nppy = npy*zm;
+  }
+if (zm < -1)
+  {
+  zmm = -zm;
+  nppx = npx/zmm;   nppy = npy/zmm;
+  if (nppx > xwsz)  nppx = xwsz; 
+  if (nppy > ywsz)  nppy = ywsz;
+  npx = nppx*zmm;   npy = nppy*zmm; 
+  }
+
+oszp = (*oxsp)*(*oysp);
+nszp = nppx*nppy;
+if ( oszp != nszp )
+  {
+  if (opix)  delete[] opix;
+  pix = new unsigned char[nppx*nppy];
+  if (pix == NULL)  { *oxsp = *oysp = 0; ; return(NULL); }
+  }
+else  pix = opix;
+*oxsp = nppx; *oysp = nppy;
+
+/*
+printf("Debug_ComputePixmap %d %d %d (%d-%d %d-%d)\n", 
+      ofx, ofy, zm, npx,nppx, npy,nppy);
+*/
+
+pp = pix;
+if (zm == 1)    // Pas de zoom  
+  {
+  for(j=ofy; j<ofy+npy; j++)
+    for(i=ofx; i<ofx+npx; i++) 
+      { *pp = (unsigned char) lut->Apply(img->FValue(i,j));  pp++; }
+  }
+else if (zm < -1)        // Compression 
+  {
+  float fv = (float)(zmm*zmm); 
+  for(j=ofy; j<ofy+npy; j+=zmm)
+    for(i=ofx; i<ofx+npx; i+=zmm)
+      {
+      vpx = 0;
+      for(l=0; l<zmm; l++)
+        for(k=0; k<zmm; k++)
+          vpx += img->FValue(i+k, j+l);
+      *pp = (unsigned char) lut->Apply(vpx/fv); 
+      pp++;
+      }
+  }
+else      // Agrandissement
+  {
+  for(j=ofy; j<ofy+npy; j++)
+    for(i=ofx; i<ofx+npx; i++)
+      {
+      ucp = (unsigned char) lut->Apply(img->FValue(i,j));
+      for(l=0; l<zm; l++)
+        {
+        pp = pix+((j-ofy)*zm+l)*nppx+((i-ofx)*zm);
+        for(k=0; k<zm; k++)  { *pp = ucp; pp++; }  
+	}
+      }
+  }
+
+return(pix);
+}
+
+/* --Methode-- */
+void PIImage::ComputePixmap()
+{
+unsigned int xwsz, ywsz;
+
+if (img == NULL)  return;
+xwsz = this->XSize();
+ywsz = this->YSize();
+
+pixm = ComputePixmap(offx, offy, zoom, xwsz, ywsz, pixm, &xspxm, &yspxm);
+SetPixmap(pixm, xspxm, yspxm); 
+// Refresh();
+return; 
+}
+
+
+/* --Methode-- */
+void PIImage::ComputeZoomPixmap()
+{
+unsigned int xwsz, ywsz;
+int ofx, ofy;
+int zm;
+
+if (zow == NULL)  return;
+if (img == NULL)  return;
+
+xwsz = zow->XSize();
+ywsz = zow->YSize();
+
+zm = zoom+4;
+if ( (zm==-1) || (zm == 0) ) zm = 1;
+if (zm > 0)
+  {
+  ofx = xpav-(xwsz/2/zm);
+  ofy = ypav-(ywsz/2/zm);
+  }
+else 
+  {
+  ofx = xpav+(xwsz*zm/2);
+  ofy = ypav+(ywsz*zm/2);
+  }
+if (ofx < 0)  ofx = 0;
+if (ofy < 0)  ofy = 0;
+
+zpixm = ComputePixmap(ofx, ofy, zm, xwsz, ywsz, zpixm, &xszpxm, &yszpxm);
+zow->SetColMap(GetColMapId(), false);
+zow->SetPixmap(zpixm, xszpxm, yszpxm); 
+zow->SetUserData((void *)this, 0);
+// zow->Refresh();
+return; 
+
+}
+
+
+/* --Methode-- */
+void PIImage::ComputeGloVPixmap()
+{
+unsigned int xwsz, ywsz;
+int zmx,zmy;
+
+if (gvw == NULL)  return;
+if (img == NULL)  return;
+
+xwsz = gvw->XSize();
+ywsz = gvw->YSize();
+
+zmx = img->XSize()/xwsz;
+zmy = img->YSize()/ywsz;
+
+if (zmx < zmy)   zmx = zmy;
+if (zmx < 1)  zmx = 1;
+zmgv = zmx;
+if (zmx > 1)  zmx = -zmx; 
+gpixm = ComputePixmap(0, 0, zmx, xwsz, ywsz, gpixm, &xsgpxm, &ysgpxm);
+return;
+}
+
+/* --Methode-- */
+void PIImage::SetGloVPixmap()
+{
+float zm;
+int x,y, dx,dy;
+
+if (zoom > 0) zm = zmgv*zoom;
+else zm = (float)zmgv/(float)(-zoom);
+x = offx/zmgv+1;
+y = offy/zmgv+1;
+dx =  (int) ( (float)XSize()/zm-1. );  
+dy =  (int) ( (float)YSize()/zm-1. );  
+
+gvw->ElDelAll();
+gvw->SelForeground(PI_Yellow);
+gvw->SelLine(PI_NormalLine);
+gvw->ElAddRect(x,y,dx,dy);
+gvw->SetColMap(GetColMapId(), false);
+gvw->SetPixmap(gpixm, xsgpxm, ysgpxm); 
+gvw->SetUserData((void *)this, 0);
+gvw->SetMsg(Msg()+626);
+gvw->SetMsgParent(this);
+
+return; 
+}
+
+/* --Methode-- */
+void PIImage::DrawCursor() 
+{
+int xc, yc;
+if (PosImg2W(xpav, ypav, &xc, &yc)) DrawCursor(-1, -1);
+else DrawCursor(xc, yc);
+return;
+}
+
+#define CURSHSIZE  25
+ 
+/* --Methode-- */
+void PIImage::DrawCursor(int xc, int yc)
+{
+
+if ((xcurs>=0) && (ycurs>=0))
+  PIPixmap::Draw(xcurs-CURSHSIZE, ycurs-CURSHSIZE, CURSHSIZE*2, CURSHSIZE*2); 
+
+if ((xc >= 0) && (yc >= 0)) 
+  {
+  xcurs = xc;   ycurs = yc;
+  if (winovis)  return;      // $CHECK$ Reza A enlever si possible 17/6/96
+  if (zoom < 3)  SelLine(PI_NormalLine);
+  else SelLine(PI_ThickLine);
+  if ( (GetColMapId() == CMAP_GREY32) || (GetColMapId() == CMAP_GREYINV32) )
+    SelForeground(PI_Red);
+  else SelForeground(PI_White);
+  SelGOMode(PI_GOCopy);
+  DrawLine(xcurs-CURSHSIZE, ycurs, xcurs-4, ycurs);
+  DrawLine(xcurs+4, ycurs, xcurs+CURSHSIZE, ycurs);
+  DrawLine(xcurs, ycurs-CURSHSIZE, xcurs, ycurs-4);
+  DrawLine(xcurs, ycurs+4, xcurs, ycurs+CURSHSIZE);
+  }
+else { xcurs = ycurs = -1; }
+
+return;
+}
+
+/* --Methode-- */
+void PIImage::DrawMarks(int x1, int x2, int y1, int y2)
+{
+float fz;
+float tofx, tofy;
+int i,x,y;
+
+if ( (winovis || (nbmrk < 1) ) ) return;
+tofx = tofy = 0;
+if ( img ) { tofx = img->XOrg(); tofy = img->YOrg(); }  
+tofx += offx;  tofy += offy; 
+fz = GetZoomF();
+SelGOMode(PI_GOCopy);
+SelMarker((int)(fz*mrkbsz), mrkt);
+if ( (GetColMapId() == CMAP_GREY32) || (GetColMapId() == CMAP_GREYINV32) )
+  SelForeground(PI_Red);
+else SelForeground(PI_White);
+for(i=0; i<nbmrk; i++)
+  { 
+  x = (int) ((xpmrk[i]-tofx)*fz);
+  y = (int) ((ypmrk[i]-tofy)*fz);
+  if ((x < x1) || (x > x2) || (y < y1) || (y > y2))  continue;
+  DrawMarker(x,y);
+  }
+return;
+}
+
+/* --Methode-- */
+void PIImage::ShowTrTxW()
+{
+if (trtw) 
+  {
+  int tpx, tpy;
+  GetScreenPos(tpx, tpy);
+  tpy -= (trtw->YSize()+5);
+  if (tpy < 0)  tpy = 0;
+  trtw->SetPos(tpx, tpy);
+  trtw->Show();  
+  }
+
+return;
+}
+
+/* --Methode-- */
+int PIImage::PosW2Img(int xiw, int yiw, int * xp, int * yp)
+{
+
+if (zoom > 0)
+  {
+  *xp = xiw/zoom+offx;
+  *yp = yiw/zoom+offy;
+  }
+else
+  {
+  *xp = offx-xiw*zoom;
+  *yp = offy-yiw*zoom;
+  }
+
+if ( (*xp >= 0) && (*xp < img->XSize() ) &&
+     (*yp >= 0) && (*yp < img->YSize() )  )   return(0);
+else return(1);
+}
+
+
+/* --Methode-- */
+int PIImage::PosImg2W(int xp, int yp, int * xiw, int * yiw)
+{
+if (zoom > 0)
+  {
+  *xiw = (xp-offx)*zoom+(zoom/2);
+  *yiw = (yp-offy)*zoom+(zoom/2);
+  }
+else
+  {
+  *xiw = (offx-xp)/zoom;
+  *yiw = (offy-yp)/zoom;
+  }
+
+if (*xiw > XSize())  *xiw = -1;
+if (*yiw > YSize())  *yiw = -1;
+
+if ((*xiw < 0) || (*yiw < 0))  return(1);
+else return(0);
+}
+
+
+/* --Methode-- */
+void PIImage::SetOffsetFromPave()
+{
+if (zoom > 0)
+  {
+  offx = xpav-XSize()/2/zoom;
+  offy = ypav-YSize()/2/zoom;
+  }
+else
+  {
+  offx = xpav+XSize()/2*zoom;
+  offy = ypav+YSize()/2*zoom;
+  }
+
+if (offx < 0)  offx = 0;
+if (offx >= (img->XSize()-1))  offx = img->XSize()-2;
+if (offy < 0)  offy = 0;
+if (offy >= (img->YSize()-1))  offy = img->YSize()-2;
+
+return;
+}
+
+/* --Methode-- */
+void PIImage::CenterPave()
+{
+int xwsz, ywsz;
+
+if (zoom > 0)
+  { xwsz = XSize()/zoom;  
+  ywsz = YSize()/zoom;  }
+else
+  { xwsz = -(XSize()*zoom); 
+  ywsz = -(YSize()*zoom); }
+  
+if (xwsz > (img->XSize()-offx)) xwsz = (img->XSize()-offx);
+if (ywsz > (img->YSize()-offy)) ywsz = (img->YSize()-offy);
+xpav = offx+xwsz/2; 
+ypav = offx+ywsz/2;
+xszpav = ((xwsz+ywsz)/20) ;
+if (xszpav < 1) xszpav = 1;
+yszpav = xszpav; 
+
+return;
+}
Index: /tags/V_Saclay_110697/SophyaPI/PI/piimage.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piimage.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piimage.h	(revision 50)
@@ -0,0 +1,143 @@
+// This may look like C code, but it is really -*- C++ -*-
+// Affichage d'image            R. Ansari  05/95
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#ifndef PIIMAGEBASE_H_SEEN
+#define PIIMAGEBASE_H_SEEN
+
+#include "cimage.h"
+#include "lut.h"
+
+#include "pisysdep.h"
+
+#include PIPIXMAP_H
+#include PISTDWDG_H
+#include PIWIN_H
+
+class PIImage : public PIPixmap
+{
+
+public:
+  enum {ClassId = 5150};
+
+//  Les methodes 
+
+  PIImage(PIContainerGen *par, char *nom=NULL, 
+           int sx=0, int sy=0, int px=0, int py=0);
+  ~PIImage();
+
+  virtual long    kind() {return ClassId; }
+  virtual void    Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+
+  void SetImage(RzImage* pim, bool refr=true);
+  void SetAutoDelImage(bool ad = false);
+
+  void AddMarks(int nm, float* px, float* py, bool refr=true, 
+                bool ad=true, PIMarker mrk=PI_PlusMarker, int msz=3);
+  void RemoveMarks(bool refr=true);                
+
+  void SetZoomWin(PIPixmap * zw, bool refr=true);
+  void SetGloVWin(PIPixmap * zw, bool refr=true);
+  void SetTextWin(PILabel * tw, bool trw=true, int tx=350, int ty=30);
+  void ShowCursor(bool sc=true); 
+
+  void SetLut(float min, float max, int typlut=kLutType_Lin,
+              int lauto=0, bool refr=true);
+  void SetLut(LUT *clut, bool refr=true);
+
+  void SetZoom(int zm, bool refr=true);
+  void SetZoomF(float fzm, bool refr=true);
+  float GetZoomF();
+
+  void SetOffset(int ox, int oy, bool refr=true);
+  void SetPave(int x, int y, bool refr=true, bool cent=true);
+
+  virtual void SetColMap(CMapId cmap, bool refr=true);
+
+  inline RzImage * Image() { return(img); }
+  inline LUT *     Lut() { return(lut); }
+  inline int XPave() { return(xpav); } ;
+  inline int YPave() { return(ypav); } ;
+
+  inline int XSzPave() { return(xszpav); }
+  inline int YSzPave() { return(yszpav); }
+
+  void Apply(bool mw=true);
+
+  virtual void Resize();
+  virtual void Draw(int x0, int y0, int dx, int dy);
+
+  virtual void But1Press(int x, int y);
+  virtual void But1Release(int x, int y);
+  virtual void Ptr1Move(int x, int y);
+  virtual void But2Press(int x, int y);
+  virtual void But2Release(int x, int y);
+  virtual void Ptr2Move(int x, int y);
+  virtual void But3Press(int x, int y);
+  virtual void But3Release(int x, int y);
+  virtual void Ptr3Move(int x, int y);
+
+private:
+      
+  unsigned char *  ComputePixmap(int ofx, int ofy, int zm, 
+                       int xwsz, int ywsz, unsigned char * opix, 
+                       int * oxszp, int * oyszp);
+  void ComputePixmap();
+  void ComputeZoomPixmap();
+  void ComputeGloVPixmap();
+  void SetGloVPixmap();
+
+  void DrawCursor();
+  void DrawCursor(int xc, int yc);
+  void DrawMarks(int x1, int x2, int y1, int y2);
+
+  void ShowTrTxW();
+
+  int PosW2Img(int xiw, int yiw, int * xp, int * yp);
+  int PosImg2W(int xp, int yp, int * xiw, int * yiw);
+
+  void SetOffsetFromPave();
+  void CenterPave();
+
+// Les donnees 
+
+  RzImage * img;
+  bool aisup;
+  bool curshow;
+  bool winovis;   // $CHECK$ Reza A enlever si possible 17/6/96
+
+// Pour gerer les marques ajoutees
+  bool admrk;
+  int nbmrk, mrkbsz;
+  float * xpmrk, * ypmrk;
+  PIMarker mrkt;
+// Tableau des pixels principal  
+  unsigned char * pixm;
+  int xspxm, yspxm;
+  LUT * lut;
+  int offx, offy;
+// Fenetre de zoom
+  int zoom;
+  PIPixmap * zow;
+  unsigned char * zpixm;
+  int xszpxm, yszpxm;
+// Fenetre pour l'image entiere  
+  int zmgv;
+  PIPixmap * gvw;
+  unsigned char * gpixm;
+  int xsgpxm, ysgpxm;
+// Fenetre/champ de texte
+  PILabel * txw;
+  PILabel * trtlb;
+  PIWindow * trtw;
+// Le pave et le curseur
+  int xpav, ypav;
+  int xpv0, ypv0;
+  int xmv0, ymv0;
+  int dxmv, dymv;
+  int xcurs, ycurs;
+  int xszpav, yszpav;
+
+};
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/pilistgen.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pilistgen.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pilistgen.cc	(revision 50)
@@ -0,0 +1,10 @@
+#include "pilistgen.h"
+
+
+PIListGen::PIListGen(PIContainerGen *par, char *nom,
+                     int sx, int sy, int px, int py)
+: PIWdg(par, nom, sx, sy, px, py)
+{}
+
+PIListGen::~PIListGen()
+{}
Index: /tags/V_Saclay_110697/SophyaPI/PI/pilistgen.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pilistgen.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pilistgen.h	(revision 50)
@@ -0,0 +1,37 @@
+#ifndef PILISTGEN_H_SEEN
+#define PILISTGEN_H_SEEN
+
+#include "pisysdep.h"
+#include PIWDG_H
+
+
+class PIListGen : public PIWdg {
+public:
+  enum {ClassId = 1110};
+
+	             PIListGen(PIContainerGen* par, char* nom,
+                               int sx=100, int sy=100, int px=0, int py=0);
+	             ~PIListGen();
+				   
+  virtual void	     AppendItem(char* item, PIMessage msg)=0;
+  virtual void       DeleteItem(char *item)=0;
+  virtual void       DeleteItem(PIMessage msg)=0;
+  
+  virtual void       SetMultipleSelect(bool ms=false)=0;
+
+  virtual int        GetNbSelection()=0;
+  virtual PIMessage  GetSelection(int num=0)=0;
+  virtual string     GetSelectionStr(int num=0)=0;
+
+  virtual void       SelectItem(char *item)=0;
+  virtual void       SelectItem(PIMessage msg)=0;
+  virtual void       ClearSelItem(char *item)=0;
+  virtual void       ClearSelItem(PIMessage msg)=0;
+
+  virtual long       kind() {return ClassId; }
+
+protected:
+}; 
+
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/pilistx.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pilistx.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pilistx.cc	(revision 50)
@@ -0,0 +1,381 @@
+#include<stdio.h>
+
+#include "pilistx.h"
+#include "picontainerx.h"
+
+#include <Xm/Xm.h>
+#include <Xm/List.h>
+
+
+/************* PIListX ************/
+
+// Pour ces sal... de XmString  (ds piwdgx.cc)
+int CStrFrXmStr(XmString xms, char* buff, int nmx);
+
+// Fonction prive (CallBack)
+static void list_action(Widget w, XtPointer *usd, XmListCallbackStruct *isel);
+
+/* Nouvelle-Fonction */
+void  list_action(Widget /*w*/, XtPointer *usd, XmListCallbackStruct *isel)
+{
+PIListX *pil;
+
+pil = (PIListX *)usd ;
+pil->ToggleSel(isel->item_position, true);
+//printf("list_action/Debug: reason=%d itemPos= %d \n", 
+//isel->reason, isel->item_position);
+return;
+}
+
+
+#define NBITEMB  20
+#define NBISELB  5
+
+
+/* --Methode-- */
+PIListX::PIListX(PIContainerGen* par, char* nom,
+                 int sx, int sy, int px, int py)
+: PIListGen(par, nom, sx, sy, px, py)
+{
+
+mNItem = mNItemMax = 0;
+mMess = NULL;  mSel = NULL;
+mNbSel = mNSelMax = 0;
+mSelNum = NULL;
+ 
+Arg  warg[3];
+int n = 0;
+XtSetArg(warg[n], XmNlistSizePolicy, XmCONSTANT);  n++;
+XtSetArg(warg[n], XmNscrollBarDisplayPolicy, XmAS_NEEDED);  n++;
+mlist = XmCreateScrolledList(((PIWdgX *)par)->XtWdg(), nom, warg, n);
+XtManageChild(mlist);
+XtWdg() = XtParent(mlist);
+SetSize(sx, sy);
+SetPos(px, py);
+wmis == k_wmi_normal ;
+stmng = 0;
+
+//XtAddCallback(mlist, XmNdefaultActionCallback,
+//              list_action, (XtPointer)this);
+XtAddCallback(mlist, XmNmultipleSelectionCallback,
+              (XtCallbackProc)list_action, (XtPointer)this);
+XtAddCallback(mlist, XmNsingleSelectionCallback,
+              (XtCallbackProc)list_action, (XtPointer)this);
+
+SetMultipleSelect(false);
+Manage();
+}
+
+/* --Methode-- */
+PIListX::~PIListX()
+{
+
+if (mNItemMax > 0)  
+  {
+    //  XtFree((char *)mItems);
+  delete[] mMess;
+  delete[] mSel;
+  }  
+if (mNSelMax > 0)  delete[] mSelNum;
+}
+
+
+/* --Methode-- */
+void PIListX::AppendItem(char* item, PIMessage msg)
+{
+
+if (mNItem >= mNItemMax)
+  {
+  PIMessage *mso;
+  bool *slo;
+  int i;
+
+  mso = mMess;
+  slo = mSel;
+  mNItemMax += NBITEMB;
+  mMess = new PIMessage[mNItemMax];
+  mSel = new bool[mNItemMax];
+  for(i=0; i<mNItem; i++)   
+    {  mMess[i] = mso[i];  mSel[i] = slo[i]; }
+
+  delete[] mso;
+  delete[] slo;
+  }
+
+mMess[mNItem] = msg;
+mSel[mNItem] = false;
+mNItem++;
+
+XmString xms = XmStringCreate(item, XmSTRING_DEFAULT_CHARSET);
+XmListAddItem(mlist, xms, 0);
+XmStringFree(xms);
+return;
+}
+
+/* --Methode-- */
+void PIListX::DeleteItem(char *item)
+{
+int n;
+if ((n=GetNumItem(item)) < 0)  return;
+DelItem(n);
+return;
+}
+
+/* --Methode-- */
+void PIListX::DeleteItem(PIMessage msg)
+{
+int n;
+if ((n=GetNumItemMsg(msg)) < 0)  return;
+DelItem(n);
+return;
+}
+
+
+/* --Methode-- */
+void PIListX::SetMultipleSelect(bool ms)
+{
+Arg  warg[2];
+
+mMultSel = ms;
+if (ms)
+  XtSetArg(warg[0], XmNselectionPolicy, XmMULTIPLE_SELECT);  
+else
+  XtSetArg(warg[0], XmNselectionPolicy, XmSINGLE_SELECT);  
+
+XtSetValues(mlist, warg, 1);
+}
+
+/* --Methode-- */
+int PIListX::GetNbSelection()
+{
+return(mNbSel);
+}
+
+/* --Methode-- */
+PIMessage PIListX::GetSelection(int num)
+{
+return(ItemMsg(mSelNum[num]));
+}
+
+/* --Methode-- */
+string PIListX::GetSelectionStr(int num)
+{
+string s(ItemStr(mSelNum[num]));
+return(s);
+}
+
+/* --Methode-- */
+void PIListX::SelectItem(char * item)
+{
+int n;
+if ((n=GetNumItem(item)) < 0)  return;
+if ((!mMultSel) && (mNbSel > 0) && (mSelNum[0] != n))
+  ClrSItem(mSelNum[0], false, true);  
+SelItem(n, false, true);
+return;
+}
+
+/* --Methode-- */
+void PIListX::SelectItem(PIMessage msg)
+{
+int n;
+if ((n=GetNumItemMsg(msg)) < 0)  return;
+if ((!mMultSel) && (mNbSel > 0) && (mSelNum[0] != n))
+  ClrSItem(mSelNum[0], false, true);  
+SelItem(n, false, true);
+return;
+}
+
+
+/* --Methode-- */
+void PIListX::ClearSelItem(char * item)
+{
+int n;
+if ((n=GetNumItem(item)) < 0)  return;
+ClrSItem(n, false, true);
+return;
+}
+
+/* --Methode-- */
+void PIListX::ClearSelItem(PIMessage msg)
+{
+int n;
+if ((n=GetNumItemMsg(msg)) < 0)  return;
+ClrSItem(n, false, true);
+return;
+}
+
+
+/* --Methode-- */
+void PIListX::ToggleSel(int n, bool smg)
+{
+if ( (n < 0) || (n >= mNItem))  return;
+if (mSel[n])  ClrSItem(n,smg); 
+else
+  {
+  if ((!mMultSel) && (mNbSel > 0))  ClrSItem(mSelNum[0], smg);
+  SelItem(n, smg);
+  }
+}
+
+
+/* --Methode-- */
+PIMessage PIListX::ItemMsg(int n)
+{
+if ( (n < 0) || (n >= mNItem))  return(0);
+else return(mMess[n]);
+}
+
+/* --Methode-- */
+char * PIListX::ItemStr(int n)
+{
+Arg  warg[2];
+XmString *xmst;
+
+if ( (n < 0) || (n >= mNItem))  { mSItem[0] = '\0'; return(mSItem); }
+
+XtSetArg(warg[0], XmNitems, &xmst);  
+XtGetValues(mlist, warg, 1);
+CStrFrXmStr(xmst[n], mSItem, 320);
+return(mSItem);
+}
+
+/* --Methode-- */
+int PIListX::GetNumItem(char *it)
+{
+for(int i=0; i<mNItem; i++)
+  if (strcmp(ItemStr(i), it) == 0)  return(i);
+return(-1);
+}
+
+/* --Methode-- */
+int PIListX::GetNumItemMsg(PIMessage msg)
+{
+for(int i=0; i<mNItem; i++)
+  if (mMess[i] == msg)   return(i);  
+return(-1);
+}
+
+
+
+/* --Methode-- */
+void PIListX::DelItem(int n)
+{
+int i;
+
+if ((n < 0) || (n > mNItem))  return;
+
+ClrSItem(n);
+for(i=n; i<mNItem-1; i++)
+  { mMess[i] = mMess[i+1];  mSel[i] = mSel[i+1]; }
+mNItem--;
+
+if (mNItem < (mNItemMax-NBITEMB-1))
+  {
+    //  XmString *ito;
+  PIMessage *mso;
+  bool *slo;
+
+  //  ito = mItems;
+  mso = mMess;
+  slo = mSel;
+  mNItemMax -= NBITEMB;
+  mMess = new PIMessage[mNItemMax];
+  mSel = new bool[mNItemMax];
+  //  mItems = (XmString *) XtMalloc(sizeof(XmString)*mNItemMax);
+  for(i=0; i<mNItem; i++)   
+    { // mItems[i] = ito[i];
+    mMess[i] = mso[i];  mSel[i] = slo[i]; }
+
+  //  XtFree((char *)mItems);
+  delete[] mso;
+  delete[] slo;
+  }
+
+XmListDeletePos(mlist, n+1);
+return;
+}
+
+
+/* --Methode-- */
+bool PIListX::SelItem(int n, bool smg, bool cxw)
+{
+int i;
+
+if ((n < 0) || (n > mNItem))  return(false);
+if (mSel[n])  return(false);
+
+mSel[n] = true;
+if (mNbSel >= mNSelMax)
+  {
+  int * osel;
+  osel = mSelNum;
+  mNSelMax += NBISELB;
+  mSelNum = new int[mNSelMax];
+  for(i=0; i<mNbSel; i++)  mSelNum[i] = osel[i];
+  if (osel)  delete[] osel;
+  }
+
+mSelNum[mNbSel] = n; 
+mNbSel++;
+if (smg)  
+  Send(mMess[n], PIMsg_Select); 
+if (cxw)
+  XmListSelectPos(mlist, n+1, FALSE);
+return(true);
+}
+
+
+
+
+/* --Methode-- */
+bool PIListX::ClrSItem(int n, bool smg, bool cxw)
+{
+int i;
+if ((n < 0) || (n > mNItem))  return(false);
+if (!mSel[n])  return(false);
+mSel[n] = false;
+
+mNbSel --;
+if (smg)  
+  Send(mMess[n], PIMsg_ClearSel); 
+if (cxw)
+  XmListDeselectPos(mlist, n+1);
+
+delete[] mSelNum;
+if (mNbSel <= 0)
+  { mNSelMax = mNbSel = 0;  mSelNum = NULL; }
+else
+  {
+  mNSelMax = (mNbSel+NBISELB)/NBISELB;
+  mSelNum = new int[mNSelMax];
+  mNbSel =  0;
+  for(i=0; i<mNItem; i++)
+    if (mSel[i]) { mSelNum[mNbSel] = i; mNbSel++; }
+  }
+
+return(true);
+} 
+
+
+/* --Methode-- 
+    A Supprimer .....
+void PIListX::ChangeSel()
+{
+XmString *xmst;
+int n;
+
+n=0;
+XtSetArg(warg[n], XmNselectedItems, &xmst);  n++;
+XtGetValues(mlist, warg, n);
+if (xmst)  XtFree(xmst);
+xmst =  (XmString *) XtMalloc(sizeof(XmString)*mNbSel);
+for(i=0; i<mNbSel; i++)
+  xmst[i] = mItems[mSelNum[i]];
+n=0;
+XtSetArg(warg[n], XmNselectedItems, xmst);  n++;
+XtSetArg(warg[n], XmNselectedItemCount, mNbSel);  n++;
+XtSetValues(mlist, warg, n);
+return;
+}
+   .....  */
Index: /tags/V_Saclay_110697/SophyaPI/PI/pilistx.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pilistx.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pilistx.h	(revision 50)
@@ -0,0 +1,52 @@
+#ifndef PILISTX_H_SEEN
+#define PILISTX_H_SEEN
+
+#include "pilistgen.h"
+
+class PIListX : public PIListGen {
+public:
+	             PIListX(PIContainerGen* par, char* nom,
+                             int sx=100, int sy=100, int px=0, int py=0);
+	             ~PIListX();
+				   
+  virtual void	     AppendItem(char* item, PIMessage msg);
+  virtual void       DeleteItem(char *item);
+  virtual void       DeleteItem(PIMessage msg);
+
+  virtual void       SetMultipleSelect(bool ms=false);
+
+  virtual int        GetNbSelection();
+  virtual PIMessage  GetSelection(int num=0);
+  virtual string     GetSelectionStr(int num=0);
+
+  virtual void       SelectItem(char * item);
+  virtual void       SelectItem(PIMessage msg);
+  virtual void       ClearSelItem(char * item);
+  virtual void       ClearSelItem(PIMessage msg);
+
+// Mis en public pour Callback Xt
+  virtual void       ToggleSel(int n, bool smg=false);
+
+protected:
+  PIMessage          ItemMsg(int n);
+  char *             ItemStr(int n);
+  int                GetNumItem(char *nom);
+  int                GetNumItemMsg(PIMessage msg);
+  void               DelItem(int n);
+  bool               SelItem(int n, bool smg=false, bool cxw=false);
+  bool               ClrSItem(int n, bool smg=false, bool cxw=false);
+
+int mNItem, mNItemMax;
+PIMessage * mMess;
+bool * mSel;
+int mNbSel, mNSelMax;
+int * mSelNum;
+bool mMultSel;
+char mSItem[320];
+
+SysDWdg mlist;
+};
+
+typedef PIListX        PIList;
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/pimak
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pimak	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pimak	(revision 50)
@@ -0,0 +1,143 @@
+CC := gcc
+CXX := g++
+# General setup GNU Makefile for EROS. To be included in all makefiles.  
+# Define  makefile variables according to CPU
+# MACHEROSD = `uname | sed 's/-//'`   i.e. { AIX HPUX OSF1 ULTRIX }
+# 
+# Makefile variables set are:
+# - Path to Exec, Include, Libs, Objs directories (from EROSBASEREP env. var.)
+#     i.e. variables LIB, OBJ, EXE, INC 
+#---------------------------------------------------------------------------
+
+# define MACHEROS from uname
+MACHEROS := $(shell echo `uname`)
+# define the -D option
+MACHEROSD := $(shell echo `uname | sed 's/-//'`)
+
+#-
+#-     Optimization option different for HP...
+ifeq (${MACHEROS},HP-UX)
+  O := +O
+else
+  O := -O
+endif
+#-
+#-   Define Makefile paths
+#-  
+ PP  := ${EROSBASEREP}/${MACHEROS}/
+ LIB := ${PP}/Libs/
+ SLB := ${PP}/ShLibs/
+ OBJ := ${PP}/Objs/
+ EXE := ${PP}/Exec/
+ INC := ${EROSBASEREP}/Include/
+ CCI := ${INC}/CInc/
+ CXI := ${INC}/CxxInc/
+#--
+
+#-
+#-    Define default compilation flags
+#--
+ifeq (${MACHEROS},HP-UX)                                    
+  CFLAGS   :=  -Aa
+  FFLAGS   :=  -Aa -I${INC} -D${MACHEROSD}  
+  CPPFLAGS :=  -I${INC} -D${MACHEROSD} \
+               -D_INCLUDE_POSIX_SOURCE -D_INCLUDE_XOPEN_SOURCE
+else
+  FFLAGS   :=  -I${INC} -D${MACHEROSD}  
+  CPPFLAGS :=  -I${INC} -D${MACHEROSD}
+endif
+AR       := ar
+ARFLAGS  := -rcs
+
+ifeq ($(CC), gcc)
+CFLAGS       := -g -O -Wall -Wpointer-arith \
+                -Wmissing-prototypes -Wsynth -I$(INC)
+//CXXFLAGS     := $(CFLAGS) -fno-implicit-templates -I$(CXI)
+CXXFLAGS     := $(CFLAGS) -I$(CXI)
+endif
+
+#- redefine implicit rule. Les .o sont dans $(OBJ).
+$(OBJ)%.o:%.c
+	$(COMPILE.c) -o $@ $<
+
+$(OBJ)%.o:%.cc
+	$(COMPILE.cc) -o $@ $<
+
+$(OBJ)%.o:%.f
+	$(COMPILE.f) -o $@ $< 
+
+#OSF1
+#LDFC est f77
+#LDFCFLAGS est rien
+
+#parfois
+#LDFC est cc
+#LDFCFLAGS est -ltruc
+
+#------------------------------------------------- End of Makefile.h ------- 
+all : piapp piapp_nosh
+
+piapp : $(EXE)piapp $(SLB)piup.so 
+ 
+piapp_nosh : $(EXE)piapp_nosh
+ 
+
+$(EXE)piapp  : $(OBJ)pidemo.o $(SLB)libPI.so $(SLB)libOuIm.so \
+               $(SLB)liberosc.so $(SLB)libStarReco.so 
+	cc -call_shared -o $(EXE)piapp $(OBJ)pidemo.o \
+              -L$(SLB) -lPI -lOuIm -lerosc -lStarReco \
+              -lgcxx -lXm -lXt -lX11 -lm  
+
+$(EXE)piapp_nosh  : $(OBJ)pidemo_nosh.o $(LIB)libPI.a $(LIB)libStarReco.a  \
+               $(LIB)libOutils.a $(LIB)libImages.a $(LIB)libmath.a $(LIB)libdiv.a 
+	g++ -o $(EXE)piapp_nosh $(OBJ)pidemo_nosh.o \
+              -L$(LIB) -lPI -lStarReco -lImages -lOutils -lmath -ldiv \
+              -lXm -lXt -lX11 -lm 
+ 
+$(SLB)piup.so : $(OBJ)piup_def.o \
+                $(SLB)libOuIm.so $(SLB)liberosc.so 
+	ld -shared -o $(SLB)piup.so -all $(OBJ)piup_def.o \
+        -none -L$(SLB) -lOuIm -lerosc -lgcxx -lm -lc
+
+$(OBJ)pidemo_nosh.o: pidemo.cc pidemo.h
+	g++ -g -O -c -Wall -Wpointer-arith \
+            -Wmissing-prototypes -Wsynth -I$(INC) -I$(CXI) \
+            -D C_NO_SHLIBS -o $(OBJ)pidemo_nosh.o pidemo.cc
+
+$(OBJ)pidemo.o: ./pidemo.cc \
+ $(INC)perrors.h \
+ $(INC)exceptions.h \
+ $(INC)defs.h \
+ $(INC)fitsimage.h \
+ $(INC)cimage.h \
+ $(INC)rzimage.h \
+ $(INC)rzvect.h \
+ $(INC)machine.h \
+ $(INC)datatypes.h \
+ $(INC)fitsheader.h \
+ $(INC)fitskeys.h pidemo.h \
+ pisysdep.h piapplx.h piapplgen.h pimsghandler.h picontainerx.h \
+ picontainergen.h piwdgx.h piwdggen.h pimenubarx.h pimenubargen.h \
+ pimenux.h pimenugen.h piwindowx.h piwindowgen.h pioptmenux.h \
+ pioptmenugen.h pistdwdgx.h pistdwdggen.h pifilechox.h pifilechogen.h \
+ piimage.h $(INC)lut.h \
+ pipixmapx.h pipixmapgen.h pibwdgx.h pibwdggen.h picmap.h picmapx.h \
+ picmapgen.h pihisto.h piscdrawwdg.h \
+ $(INC)histos.h \
+ $(INC)peida.h \
+ $(INC)utils.h pidrawwin.h \
+ $(INC)piup.h
+$(OBJ)piup_def.o: piup_def.cc  piup.h \
+ $(INC)perrors.h \
+ $(INC)exceptions.h \
+ $(INC)defs.h \
+ $(INC)fitsimage.h \
+ $(INC)cimage.h \
+ $(INC)rzimage.h \
+ $(INC)rzvect.h \
+ $(INC)machine.h \
+ $(INC)datatypes.h \
+ $(INC)fitsheader.h \
+ $(INC)fitskeys.h \
+ $(INC)utils.h $(INC)peida.h 
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/pimenubargen.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pimenubargen.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pimenubargen.cc	(revision 50)
@@ -0,0 +1,14 @@
+#include "pimenubargen.h"
+
+#include PIAPP_H
+
+PIMenubarGen::PIMenubarGen(PIApplicationGen* par, char* nom)
+: PIWdg(NULL, nom)
+{
+SetMsgParent(par);
+}
+
+PIMenubarGen::~PIMenubarGen()
+{}
+
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/pimenubargen.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pimenubargen.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pimenubargen.h	(revision 50)
@@ -0,0 +1,21 @@
+#ifndef PIMBARGEN_H_SEEN
+#define PIMBARGEN_H_SEEN
+
+#include "pisysdep.h"
+#include PIMENU_H
+
+class PIApplicationGen;
+
+class PIMenubarGen : public PIWdg {
+public:
+  enum {ClassId = 2600};
+
+	            PIMenubarGen(PIApplicationGen* par, char* nom);
+	            ~PIMenubarGen();
+				   
+  virtual void      AppendMenu(PIPDMenu *pdm)=0;
+
+  virtual long      kind() {return ClassId; }
+};
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/pimenubarmac.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pimenubarmac.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pimenubarmac.cc	(revision 50)
@@ -0,0 +1,15 @@
+#include "pimenubarmac.h"
+#include <LMenuBar.h>
+
+PIMenubarMac::PIMenubarMac(PIApplicationGen* par, char* nom)
+:PIMenubarGen(par, nom)
+{}
+
+PIMenubarMac::~PIMenubarMac()
+{}
+
+void
+PIMenubarMac::AppendMenu(PIPDMenu *pdm)
+{
+  LMenuBar::GetCurrentMenuBar()->InstallMenu(pdm->macMenu, InstallMenu_AtEnd);
+}
Index: /tags/V_Saclay_110697/SophyaPI/PI/pimenubarmac.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pimenubarmac.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pimenubarmac.h	(revision 50)
@@ -0,0 +1,16 @@
+#ifndef PIMBARMAC_H_SEEN
+#define PIMBARMAC_H_SEEN
+
+#include "pimenubargen.h"
+
+class PIMenubarMac : public PIMenubarGen {
+ public:
+	            PIMenubarMac(PIApplicationGen* par, char* nom);
+	           ~PIMenubarMac();
+ virtual void	AppendMenu(PIPDMenu *pdm);
+
+};
+
+typedef PIMenubarMac   PIMenubar;
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/pimenubarx.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pimenubarx.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pimenubarx.cc	(revision 50)
@@ -0,0 +1,67 @@
+#include<stdio.h>
+
+#include "pimenubarx.h"
+#include PIAPP_H
+
+#include <Xm/Xm.h>
+#include <Xm/RowColumn.h>
+#include <Xm/PushB.h>
+#include <Xm/ToggleB.h>
+#include <Xm/CascadeB.h>
+
+/************* PIMenubarX ************/
+
+#define NBITEMB  10
+
+/* --Methode-- */
+PIMenubarX::PIMenubarX(PIApplicationGen* par, char* nom)
+: PIMenubarGen(par, nom)
+{
+mNItem = 0;  mNItemMax = NBITEMB; 
+mMbb = new _pimbxit_[mNItemMax];
+
+XtWdg() = XmCreateMenuBar( ((PIApplicationX *)par)->MBCont()->XtWdg(), 
+                            nom, NULL, 0); 
+
+wmis == k_wmi_normal ;
+stmng = 0;
+
+SetPos(0,0);
+SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_free);
+
+Manage();
+}
+
+
+/* --Methode-- */
+PIMenubarX::~PIMenubarX()
+{
+for(int i=0; i<mNItem; i++)
+  XtDestroyWidget(mMbb[i].itb);
+delete[] mMbb ;
+}
+
+/* --Methode-- */
+void PIMenubarX::AppendMenu(PIPDMenu *pdm)
+{
+_pimbxit_ *buto;
+Arg  wargs[2];
+
+if (mNItem >= mNItemMax)
+  {
+  buto = mMbb;
+  mNItemMax += NBITEMB;
+  mMbb = new _pimbxit_[mNItemMax];
+  for(int i=0; i<mNItem; i++)   mMbb[i] = buto[i];
+  delete[] buto;
+  }
+XtSetArg(wargs[0], XmNsubMenuId, pdm->XtWdg());
+mMbb[mNItem].itb = XtCreateManagedWidget(pdm->Nom().c_str(), xmCascadeButtonWidgetClass, 
+                                         this->XtWdg(), wargs, 1) ;
+mMbb[mNItem].pdm = pdm;
+mNItem++;
+
+pdm->SetMsgParent(this);
+return;
+}
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/pimenubarx.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pimenubarx.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pimenubarx.h	(revision 50)
@@ -0,0 +1,28 @@
+#ifndef PIMBARX_H_SEEN
+#define PIMBARX_H_SEEN
+
+#include "pimenubargen.h"
+
+struct _pimbxit_ 
+{
+SysDWdg itb;
+PIPDMenu *pdm;
+};
+
+class PIMenubarX : public PIMenubarGen {
+ public:
+	        PIMenubarX(PIApplicationGen* par, char* nom);
+	        ~PIMenubarX();
+virtual void	AppendMenu(PIPDMenu *pdm);
+
+ protected:
+
+int mNItem, mNItemMax;
+_pimbxit_ *mMbb;
+};
+
+
+typedef PIMenubarX     PIMenubar;
+
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/pimenugen.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pimenugen.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pimenugen.cc	(revision 50)
@@ -0,0 +1,11 @@
+#include "pimenugen.h"
+
+PIMenuGen::PIMenuGen(PIMsgHandler* par, char* nom, PIMenuType pdpu)
+: PIWdg(NULL, nom) , mMTyp(pdpu)
+{
+SetMsgParent(par);
+}
+
+PIMenuGen::~PIMenuGen()
+{}
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/pimenugen.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pimenugen.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pimenugen.h	(revision 50)
@@ -0,0 +1,37 @@
+#ifndef PIMENUGEN_H_SEEN
+#define PIMENUGEN_H_SEEN
+
+#include "pisysdep.h"
+#include PIWDG_H
+
+enum PIMenuType { k_PopupMenu = 1, k_PulldownMenu = 2 };
+
+class PIMenuGen : public PIWdg {
+public:
+  enum {ClassId = 2500};
+
+	          PIMenuGen(PIMsgHandler* par, char* nom, PIMenuType pdpu);
+	          ~PIMenuGen();
+				   
+  virtual void	  AppendItem(char* nom, PIMessage msg, char* sc=NULL)=0;
+
+  virtual void    DeleteItem(char *nom)=0;
+  virtual void    DeleteItemMsg(PIMessage msg)=0;
+  virtual void    DeleteItemNum(int n)=0;
+
+  virtual void    CheckItem(char *nom, bool st=false)=0; 
+  virtual void    CheckItemMsg(PIMessage msg, bool st=false)=0; 
+  virtual void    CheckItemNum(int n, bool st=false)=0; 
+
+  virtual void    Show()=0;
+  virtual void    Show(PIWdg *w, int px, int py)=0;
+  virtual void    Hide()=0;
+
+  virtual long    kind() {return ClassId; }
+
+protected:
+  PIMenuType mMTyp;
+}; 
+
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/pimenumac.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pimenumac.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pimenumac.cc	(revision 50)
@@ -0,0 +1,198 @@
+#include <LString.h>
+#include "pimenumac.h"
+#include <algorithm>
+
+int PIMenuMac::lastId = 1024;
+list<PIMenuMac*> PIMenuMac::sMenus;
+
+PIMenuMac::PIMenuMac(PIMsgHandler *par, char *nom, PIMenuType pdpu) 
+: PIMenuGen(par, nom, pdpu)
+{
+   macMenu = new LMenu(lastId, LStr255(nom));
+   mMenuId = lastId;
+   sMenus.push_back(this);
+   lastId++;
+}
+
+
+PIMenuMac::~PIMenuMac()
+{
+  LMenuBar::GetCurrentMenuBar()->RemoveMenu(macMenu);
+  sMenus.remove(this);
+  delete macMenu;
+}
+
+int
+PIMenuMac::FindItemByMsg(PIMessage msg)
+{
+  if (mMsgs.size() == 0) return -1;
+  int i = find(mMsgs.begin(), mMsgs.end(), msg) - mMsgs.begin();
+  return (i>=mMsgs.size()) ? -1 : i;
+}
+
+int
+PIMenuMac::FindItemByName(string const& s)
+{
+  int n = ::CountMItems(GetMacMenuHandle());
+  for (int i=0; i<n; i++)
+    if (GetMenuItemText(i) == s)
+      return i;
+  return -1;
+}
+
+
+void
+PIMenuMac::AppendItem(char* nom, PIMessage msg, char* sc)  // sc = short-cut , raccourci clavier
+{
+  LStr255 titre(nom);
+  
+  macMenu->InsertCommand(titre, -2000, 1000); // ou cmd_UseMenuItem ???
+  mMsgs.push_back(msg);
+}
+
+void
+PIMenuMac::CheckItemNum(int n, bool st)
+{
+  if (n<0 || n >= mMsgs.size()) return; // $CHECK$ exception ?
+  ::CheckItem(macMenu->GetMacMenuH(), n, st);
+}
+
+void
+PIMenuMac::CheckItemMsg(PIMessage msg, bool st)
+{
+  int i = FindItemByMsg(msg);
+  if (i>=0)
+    CheckItemNum(i, st);
+}
+
+void
+PIMenuMac::CheckItem(char* nom, bool st)
+{
+  int i = FindItemByName(nom);
+  if (i>=0)
+    CheckItemNum(i, st);
+}
+
+void
+PIMenuMac::DeleteItemNum(int n)
+{
+  if (n<0 || n >= mMsgs.size()) return; // $CHECK$ exception ?
+  macMenu->RemoveItem(n+1);
+  mMsgs.erase(mMsgs.begin()+n);
+}
+
+void
+PIMenuMac::DeleteItemMsg(PIMessage msg)
+{
+  int i = FindItemByMsg(msg);
+  if (i>=0)
+    DeleteItemNum(i);
+}
+
+void
+PIMenuMac::DeleteItem(char* nom)
+{
+  int i = FindItemByName(nom);
+  if (i>=0)
+    DeleteItemNum(i);
+}
+
+
+
+void
+PIMenuMac::ItemSelected(int item)
+{
+  if (item<0 || item >= mMsgs.size()) return; // $CHECK$ exception ?
+  Send(mMsgs[item], PIMsg_Click, (void*) GetMenuItemText(item).c_str());
+}
+
+
+void
+PIMenuMac::Show()
+{}
+
+void
+PIMenuMac::Show(PIWdg *w, int px, int py)
+{}
+
+void
+PIMenuMac::Hide()
+{}
+
+PIMenuMac*
+PIMenuMac::findMenu(int id)
+{
+  list<PIMenuMac*>::iterator i = sMenus.begin();
+  
+  while (i != sMenus.end()) {
+    if ((*i)->MenuId()==id) return *i;
+    i++;
+  }
+  
+  return NULL;
+}
+
+MenuHandle
+PIMenuMac::GetMacMenuHandle()
+{
+  return macMenu->GetMacMenuH();
+}
+
+ResIDT
+PIMenuMac::GetMacMenuID()
+{
+  return macMenu->GetMenuID();
+}
+
+
+string
+PIMenuMac::GetMenuItemText(int item)
+{
+  if (item<0 || item >= mMsgs.size()) return ""; // $CHECK$ exception ?
+  MenuHandle h = GetMacMenuHandle();
+  Str255 txt;
+  ::GetMenuItemText(h, item+1, txt);
+  p2cstr(txt);
+  return (char*) txt;
+}
+
+PIMenuMac::GetMenuItemMsg(int item)
+{
+  if (item<0 || item >= mMsgs.size()) return -1; // $CHECK$ exception ?
+  return mMsgs[item];
+}
+
+
+
+/* --Methode-- */
+PIPUMenuMac::PIPUMenuMac(PIMsgHandler* par, char* nom)
+: PIMenuMac(par, nom, k_PopupMenu)
+{
+}
+
+/* --Methode-- */
+PIPUMenuMac::~PIPUMenuMac()
+{
+}
+
+void
+PIPUMenuMac::Show()
+{
+  Point pt;
+  ::GetMouse(&pt);
+  ::LocalToGlobal(&pt);
+  int item = ::PopUpMenuSelect(macMenu->GetMacMenuH(),pt.v,pt.h,1);
+  ItemSelected(item);
+}
+
+/* --Methode-- */
+PIPDMenuMac::PIPDMenuMac(PIMsgHandler* par, char* nom)
+: PIMenuMac(par, nom, k_PulldownMenu)
+{
+}
+
+/* --Methode-- */
+PIPDMenuMac::~PIPDMenuMac()
+{
+}
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/pimenumac.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pimenumac.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pimenumac.h	(revision 50)
@@ -0,0 +1,77 @@
+#ifndef PIMENUMAC_H_SEEN
+#define PIMENUMAC_H_SEEN
+
+#include "pimenugen.h"
+#include <LMenu.h>
+#include <vector>
+#include <list>
+
+// Menu general
+class PIMenuMac : public PIMenuGen {
+public:
+					PIMenuMac(PIMsgHandler* par, char* nom, PIMenuType pdpu);
+				   ~PIMenuMac();
+				   
+    virtual void    AppendItem(char* nom, PIMessage msg, char* sc=NULL);
+
+    virtual void    DeleteItem(char *nom);
+    virtual void    DeleteItemMsg(PIMessage msg);
+    virtual void    DeleteItemNum(int n);
+
+    virtual void    CheckItem(char *nom, bool st=false); 
+    virtual void    CheckItemMsg(PIMessage msg, bool st=false); 
+    virtual void    CheckItemNum(int n, bool st=false); 
+	
+    virtual void    Show();
+    virtual void    Show(PIWdg *w, int px, int py);
+
+    virtual void    Hide();
+    
+    int             MenuId() {return mMenuId;}
+    void            ItemSelected(int item);
+    
+	string          GetMenuItemText(int item);
+	int             GetMenuItemMsg(int item);
+	int             FindItemByMsg(PIMessage msg);
+	int             FindItemByName(string const& nom);
+	
+protected:
+	static PIMenuMac* findMenu(int id);
+	LMenu*          macMenu;
+	int             mMenuId;
+	vector<PIMessage>    mMsgs;
+	static int      lastId;
+	static list<PIMenuMac*> sMenus;
+	
+	friend class    PIMenubarMac;
+	friend class    PIOptMenuMac;
+	friend class    PIPPMenuBar;
+	MenuHandle      GetMacMenuHandle();
+	ResIDT          GetMacMenuID();
+	
+   
+};
+
+// Menu popup
+class PIPUMenuMac : public PIMenuMac
+{
+public:
+               PIPUMenuMac(PIMsgHandler* par, char* nom);
+               ~PIPUMenuMac();
+virtual void   Show();
+};
+
+// Menu pull-down
+class PIPDMenuMac : public PIMenuMac
+{
+public:
+               PIPDMenuMac(PIMsgHandler* par, char* nom);
+               ~PIPDMenuMac();
+};
+
+
+typedef PIMenuMac      PIMenu;
+typedef PIPUMenuMac    PIPUMenu;
+typedef PIPDMenuMac    PIPDMenu;
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/pimenux.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pimenux.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pimenux.cc	(revision 50)
@@ -0,0 +1,408 @@
+#include<stdio.h>
+
+#include "pimenux.h"
+
+#include <Xm/Xm.h>
+#include <Xm/RowColumn.h>
+#include <Xm/PushB.h>
+#include <Xm/ToggleB.h>
+#include <Xm/CascadeB.h>
+
+/************* PIMenuX ************/
+
+// Pour ces sal... de XmString  (ds piwdgx.cc)
+int CStrFrXmStr(XmString xms, char* buff, int nmx);
+
+// Fonction prive (CallBack)
+static void menub_action(Widget w, XtPointer *usd, XtPointer *calld);
+
+/* Nouvelle-Fonction */
+void  menub_action(Widget w, XtPointer *usd, XtPointer *calld)
+{
+PIMenuX *pim;
+_pimxit_ *cusd;
+
+cusd = ( _pimxit_ *)usd ;
+pim = (PIMenuX *) (cusd->pmen);
+
+// pim->Hide();
+pim->Send(cusd->msg, PIMsg_Click, (void *)pim->ItemNameWdg(cusd->itb));
+#ifdef DEBUG_PIMenuX
+printf("%%%Debug_menub_action: Msg= %d  %lx\n", (int)cusd->msg, (long)pim);
+#endif
+return;
+}
+
+#define NBITEMB  10
+
+/* --Methode-- */
+PIMenuX::PIMenuX(PIMsgHandler *par, char *nom, PIMenuType pdpu) 
+: PIMenuGen(par, nom, pdpu)
+{
+mNItem = 0;  mNItemMax = NBITEMB; 
+mBut = new _pimxit_[mNItemMax];
+
+if (pdpu == k_PopupMenu)
+  XtWdg() = XmCreatePopupMenu( PIXtTopWdg(), nom, NULL, 0); 
+else 
+  XtWdg() = XmCreatePulldownMenu( PIXtTopWdg(), nom, NULL, 0); 
+
+wmis == k_wmi_normal ;
+stmng = 0;
+}
+
+/* --Methode-- */
+PIMenuX::~PIMenuX()
+{
+for(int i=0; i<mNItem; i++)
+  XtDestroyWidget(mBut[i].itb);
+delete[] mBut ;
+}
+
+
+/* --Methode-- */
+void PIMenuX::AppendItem(char* nom, PIMessage msg, char* sc)
+{
+AddItem(nom, msg, false, sc);
+}
+
+/* --Methode-- */
+void PIMenuX::DeleteItem(char *nom)
+{
+
+for(int i=0; i<mNItem; i++)
+  if (strcmp(ItemName(i), nom) == 0)  
+    { DeleteItemNum(i);  break; }
+
+return;
+}
+
+/* --Methode-- */
+void PIMenuX::DeleteItemMsg(PIMessage msg)
+{
+for(int i=0; i<mNItem; i++)
+  if (mBut[i].msg == msg)  
+    { DeleteItemNum(i);  break; }
+
+return;
+}
+
+
+/* --Methode-- */
+void PIMenuX::DeleteItemNum(int n)
+{
+if ((n < 0) || (n >= mNItem))  return;
+XtDestroyWidget(mBut[n].itb);
+for(int i=n; i<mNItem-1; i++)  
+  { 
+  String cbckn;
+  if (mBut[i+1].togg)  cbckn = XmNvalueChangedCallback;
+  else cbckn = XmNactivateCallback;
+  XtRemoveCallback(mBut[i+1].itb, cbckn, 
+                   (XtCallbackProc)menub_action, (XtPointer)(mBut+i+1));
+  mBut[i] = mBut[i+1];
+  XtAddCallback(mBut[i].itb, cbckn, 
+                (XtCallbackProc)menub_action, (XtPointer)(mBut+i));
+  }
+mNItem--;
+}
+
+
+/* --Methode-- */
+void PIMenuX::CheckItem(char *nom, bool st)
+{
+
+for(int i=0; i<mNItem; i++)
+  if (strcmp(ItemName(i), nom) == 0)  
+    { CheckItemNum(i, st);  break; }
+
+return;
+}
+
+/* --Methode-- */
+void PIMenuX::CheckItemMsg(PIMessage msg, bool st)
+{
+for(int i=0; i<mNItem; i++)
+  if (mBut[i].msg == msg)  
+    { CheckItemNum(i, st);  break; }
+
+return;
+}
+
+/* --Methode-- */
+void PIMenuX::CheckItemNum(int n, bool st)
+{
+printf("PIMenuX::CheckItemNum(%d,bool) Error/ Not yet implemented \n", n);
+return;
+}
+
+/* --Methode-- */
+void PIMenuX::Show()
+{
+Manage();
+}
+
+/* --Methode-- */
+void PIMenuX::Show(PIWdg *w, int px, int py)
+{
+Manage();
+}
+
+
+/* --Methode-- */
+void PIMenuX::Hide()
+{
+// Unmanage();
+}
+
+
+
+/* --Methode-- */
+char* PIMenuX::ItemName(int n)
+{
+if ( (n < 0) || (n >= mNItem))  { mSItem[0] = '\0'; return(mSItem); }
+else return (ItemNameWdg(mBut[n].itb));
+}
+
+
+/* --Methode-- */
+char* PIMenuX::ItemNameWdg(SysDWdg itw)
+{
+XmString xmstr;
+Arg warg[2];
+
+XtSetArg(warg[0], XmNlabelString, &xmstr);
+XtGetValues(itw, warg, 1);
+if (xmstr)
+  {
+  CStrFrXmStr(xmstr, mSItem, 96);
+  XmStringFree(xmstr);
+  }
+else mSItem[0] = '\0';
+
+return(mSItem);
+}
+
+
+/* --Methode-- */
+PIMessage PIMenuX::ItemMsg(int n)
+{
+if ( (n < 0) || (n >= mNItem))  return(0);
+else return(mBut[n].msg);
+}
+
+
+
+/* --Methode-- */
+int PIMenuX::GetNumItem(char *nom)
+{
+
+for(int i=0; i<mNItem; i++)
+  if (strcmp(ItemName(i),nom) == 0)  return(i);
+return(-1);
+}
+
+/* --Methode-- */
+int PIMenuX::GetNumItemMsg(PIMessage msg)
+{
+for(int i=0; i<mNItem; i++)
+  if (mBut[i].msg == msg)   return(i);  
+return(-1);
+}
+
+/* --Methode-- */
+SysDWdg PIMenuX::GetItemWdg(int n)
+{
+if ((n<0) || (n>=mNItem))  return(NULL);
+else return(mBut[n].itb);
+}
+
+
+/* --Methode-- */
+void PIMenuX::AddItem(char* nom, PIMessage msg, bool tog, char* sc)
+{
+_pimxit_ *buto;
+SysDWdgClass wdgcl;
+String cbckn;
+
+
+if (mNItem >= mNItemMax)
+  {
+  buto = mBut;
+  mNItemMax += NBITEMB;
+  mBut = new _pimxit_[mNItemMax];
+  for(int i=0; i<mNItem; i++)   
+    {
+    if (buto[i].togg)  cbckn = XmNvalueChangedCallback;
+    else cbckn = XmNactivateCallback;
+    XtRemoveCallback(buto[i].itb, cbckn, 
+                     (XtCallbackProc)menub_action, (XtPointer)(buto+i));
+    mBut[i] = buto[i];
+    XtAddCallback(mBut[i].itb, cbckn, 
+                 (XtCallbackProc) menub_action, (XtPointer)(mBut+i));
+    }
+
+  delete[] buto;
+  }
+
+if (tog)
+  {
+  cbckn = XmNvalueChangedCallback;
+  wdgcl = xmToggleButtonWidgetClass;
+  }
+else 
+  {
+  cbckn = XmNactivateCallback;
+  wdgcl = xmPushButtonWidgetClass;
+  }
+
+mBut[mNItem].itb = XtCreateManagedWidget(nom, wdgcl, this->XtWdg(), NULL, 0) ; 
+XtAddCallback(mBut[mNItem].itb, cbckn, 
+              (XtCallbackProc)menub_action, (XtPointer)(mBut+mNItem));
+if (sc)  // Raccourci clavier 
+  {
+  char acc[16];
+  int n=0;
+  Arg warg[2];
+  XmString xmstr;
+
+  sprintf(acc,"Ctrl/%c", sc[0]);
+  xmstr = XmStringLtoRCreate(acc, XmSTRING_DEFAULT_CHARSET);
+  XtSetArg(warg[n], XmNacceleratorText, xmstr); n++;
+  sprintf(acc,"Ctrl<Key>%c", sc[0]);
+  XtSetArg(warg[n], XmNaccelerator, acc); n++;
+  XtSetValues(mBut[mNItem].itb, warg, n);  
+  XmStringFree(xmstr);
+  }
+
+#ifdef DEBUG_PIMenuX
+printf("DBG>> %d (%d) %lx \n", mNItem, mNItemMax, (long)(mBut+mNItem));
+#endif
+mBut[mNItem].pmen = this;
+mBut[mNItem].msg = msg;
+mBut[mNItem].togg = tog;
+mNItem++;
+return;
+}
+
+
+
+/* --Methode-- */
+void PIMenuX::Check()
+{
+printf("#Debug_CHECK: %d %d %d %d \n",XSize(), YSize(), XPos(), YPos() );  
+for(int i=0; i<mNItem; i++)
+  printf("##Debug_CHECK: %d %d %ld %lx %lx %lx \n", i, (int)mBut[i].togg, 
+         (long) mBut[i].msg, (long) mBut[i].itb, 
+         (long) mBut[i].pmen, long (mBut+i));
+return;
+}
+
+/* --Methode-- A virer 
+void PIMenuX::AppendCheckItem(char* nom, PIMessage msg)
+{
+AddItem(nom, msg, true);
+}
+*/
+
+/* --Methode--   A virer 
+void PIMenuX::SetItem(int n, bool st) 
+{
+if ((n < 0) || (n >= mNItem))  return;
+if (mBut[n].togg)  // C'est un toggle Bouton !
+  {
+  Arg  wargs[2];
+  int n=0;
+  if (st)  XtSetArg(wargs[n],XmNset,TRUE);  
+  else XtSetArg(wargs[n],XmNset,FALSE);  
+  n++;
+  XtSetValues(mBut[n].itb, wargs, n);  
+  }
+return;
+}
+*/
+
+
+/* --Methode-- */
+PIPUMenuX::PIPUMenuX(PIMsgHandler* par, char* nom)
+: PIMenuX(par, nom, k_PopupMenu)
+{
+}
+
+/* --Methode-- */
+PIPUMenuX::~PIPUMenuX()
+{
+}
+
+void PIPUMenuX::Show()
+{
+// XEvent  mevt;
+XButtonEvent evt;
+
+// XPeekEvent(PIXDisplay(), &mevt);
+// evt = mevt.xbutton; 
+evt.type = ButtonPress;
+evt.display = PIXDisplay();
+evt.window = XtWindow(PIXtTopWdg());
+evt.root = DefaultRootWindow(evt.display);
+evt.serial = 8866559909;
+evt.send_event = False;
+evt.same_screen = XQueryPointer(evt.display, evt.window, &(evt.root), 
+                    &(evt.subwindow), &(evt.x_root), &(evt.y_root), 
+                    &(evt.x), &(evt.y), &(evt.state));
+ 
+#ifdef DEBUG_PIMenuX
+printf("XXDbg_Show : %d %d %d - %d %d \n", (int)evt.same_screen, 
+       (int)evt.x_root, (int)evt.y_root, (int)evt.x, (int)evt.y);
+#endif
+
+if (evt.same_screen) XmMenuPosition(XtWdg(), &evt);
+Manage();     
+}
+
+/* --Methode-- */
+void PIPUMenuX::Show(PIWdg *w, int px, int py)
+{
+// This method should only be used by a button press ...
+int xr, yr;
+Window cw, sw, rw;
+SysDWdg xtw;
+Display *dsp;
+XButtonEvent evt;
+
+xtw =  w->XtWdg();
+dsp = XtDisplay(xtw);
+sw = XtWindow(xtw);
+rw = DefaultRootWindow(dsp);
+XTranslateCoordinates(dsp, sw, rw, px, py, &xr, &yr, &cw);
+
+evt.type = ButtonPress;
+evt.display = dsp;
+evt.window = sw;
+evt.root = rw;
+evt.x_root = xr;
+evt.y_root = yr; 
+evt.x = px;
+evt.y = py;
+evt.serial = 8866559909;
+evt.send_event = False;
+evt.same_screen = True;
+XmMenuPosition(XtWdg(), &evt);
+// SetPos(xr, yr);
+Manage();
+return;    
+}
+
+
+/* --Methode-- */
+PIPDMenuX::PIPDMenuX(PIMsgHandler* par, char* nom)
+: PIMenuX(par, nom, k_PulldownMenu)
+{
+}
+
+/* --Methode-- */
+PIPDMenuX::~PIPDMenuX()
+{
+}
+
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/pimenux.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pimenux.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pimenux.h	(revision 50)
@@ -0,0 +1,84 @@
+#ifndef PIMENUX_H_SEEN
+#define PIMENUX_H_SEEN
+
+#include "pimenugen.h"
+
+
+class PIMenuX ;
+
+struct _pimxit_ 
+{
+SysDWdg itb;
+PIMenuX *pmen;
+PIMessage msg;
+bool togg;
+};
+
+
+
+class PIMenuX : public PIMenuGen {
+public:
+	          PIMenuX(PIMsgHandler* par, char* nom, PIMenuType pdpu);
+	          ~PIMenuX();
+				   
+  virtual void	  AppendItem(char* nom, PIMessage msg, char* sc=NULL);
+
+  virtual void    DeleteItem(char *nom);
+  virtual void    DeleteItemMsg(PIMessage msg);
+  virtual void    DeleteItemNum(int n);
+
+  virtual void    CheckItem(char *nom, bool st=false); 
+  virtual void    CheckItemMsg(PIMessage msg, bool st=false); 
+  virtual void    CheckItemNum(int n, bool st=false); 
+
+  virtual void    Show();
+  virtual void    Show(PIWdg *w, int px, int py);
+  virtual void    Hide();
+
+// Pour usage prive et par OptionMenu, ...
+  PIMessage       ItemMsg(int n);
+  int             GetNumItem(char *nom);
+  int             GetNumItemMsg(PIMessage msg);
+  SysDWdg         GetItemWdg(int n);
+  char*           ItemName(int n);
+  char*           ItemNameWdg(SysDWdg itw);
+
+protected:
+        void      AddItem(char* nom, PIMessage msg, bool tog, char* sc=NULL);
+        void      Check();
+
+int mNItem, mNItemMax;
+_pimxit_  * mBut;
+char mSItem[96];
+};
+
+class PIPUMenuX : public PIMenuX
+{
+public:
+                 PIPUMenuX(PIMsgHandler* par, char* nom);
+                 ~PIPUMenuX();
+
+  virtual void   Show();
+  virtual void   Show(PIWdg *w, int px, int py);
+
+protected:
+     
+};
+
+class PIPDMenuX : public PIMenuX
+{
+public:
+                 PIPDMenuX(PIMsgHandler* par, char* nom);
+                 ~PIPDMenuX();
+
+protected:
+     
+};
+
+typedef PIMenuX        PIMenu;
+typedef PIPUMenuX      PIPUMenu;
+typedef PIPDMenuX      PIPDMenu;
+
+
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/pimsghandler.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pimsghandler.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pimsghandler.cc	(revision 50)
@@ -0,0 +1,35 @@
+
+#include "pimsghandler.h"
+
+PIMsgHandler::PIMsgHandler(PIMsgHandler* par)
+: msgParent(par)
+{}
+
+PIMsgHandler::~PIMsgHandler()
+{}
+
+void
+PIMsgHandler::Process(PIMessage msg, PIMsgHandler* sender, void* data)
+{
+	ReSend(msg, sender, data);
+}
+
+void
+PIMsgHandler::Send(PIMessage msg, PIMsgMod mm,  void* data)
+{
+//	Process(msg, this, data);  $CHECK$  Reza 12/06/96
+// Send par defaut appelle le process du parent $CHECK$
+if (msgParent)
+  msgParent->Process(BuildMsg(msg, mm), this, data);
+
+}
+
+void
+PIMsgHandler::ReSend(PIMessage msg, PIMsgHandler* sender, void* data)
+{
+  if (msgParent)
+    msgParent->Process(msg, sender, data);
+}
+
+
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/pimsghandler.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pimsghandler.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pimsghandler.h	(revision 50)
@@ -0,0 +1,58 @@
+/* Classe de gestion de messages */
+
+#include <stdlib.h>
+
+#ifndef PIMSGHANDLER_H_SEEN
+#define PIMSGHANDLER_H_SEEN
+
+enum {
+ // Les messages reserves systeme (PI)   les 8 premiers bits
+ // Messages user, les bits restants
+	PIMsg_Active        = 1,
+        PIMsg_Close         = 2,
+        PIMsg_Resize        = 3,
+
+	PIMsg_OK            = 11,
+	PIMsg_Cancel        = 12,
+	PIMsg_Help          = 13,
+
+	PIMsg_DataChanged   = 21,
+	PIMsg_Click         = 22,
+        PIMsg_Press         = 23,
+        PIMsg_Drag          = 24,
+        PIMsg_Drop          = 25,
+
+        PIMsg_Select        = 31,
+        PIMsg_ClearSel      = 32
+
+};
+
+
+// Definition de type pour les messages - Il est peu probable que le typedef change ...
+//                                      Reza 17/10/96
+typedef unsigned long PIMessage;
+typedef unsigned char PIMsgMod;
+
+class PIMsgHandler {
+public:
+			     PIMsgHandler(PIMsgHandler* par=NULL);
+	virtual 	     ~PIMsgHandler();
+	
+	virtual void	     SetMsgParent(PIMsgHandler* par) {msgParent = par;}
+
+	virtual void         Send(PIMessage msg, PIMsgMod mm=0, void* data=NULL);
+
+        inline  PIMessage    UserMsg(PIMessage msg) { return (msg >> 8); }
+        inline  PIMessage    ModMsg(PIMessage msg) { return (msg & 0xFF); }
+	inline  PIMessage    BuildMsg(PIMessage um, PIMsgMod mm) 
+                        	  { return ((um << 8) | mm); }
+
+protected:
+	virtual void	ReSend(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+	virtual void	Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+
+private:
+	PIMsgHandler*     msgParent;
+};
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/pimsgmac.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pimsgmac.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pimsgmac.h	(revision 50)
@@ -0,0 +1,8 @@
+#include <PP_Types.h>
+
+const MessageT msg_Btn1    msg_Click;
+const MessageT msg_Btn2    10001;
+const MessageT msg_Btn3    10002;
+const MessageT msg_Move1   10003;
+const MessageT msg_Move2   10004;
+const MessageT msg_Move3   10005;
Index: /tags/V_Saclay_110697/SophyaPI/PI/pioptmenugen.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pioptmenugen.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pioptmenugen.cc	(revision 50)
@@ -0,0 +1,13 @@
+#include "pioptmenugen.h"
+
+
+PIOptMenuGen::PIOptMenuGen(PIContainerGen* par, PIPUMenu *pdm, 
+                         int sx, int sy, int px, int py)
+: PIContainer(par, (char*) pdm->Nom().c_str(), sx, sy, px, py) // Attention au const !
+{
+}
+
+PIOptMenuGen::~PIOptMenuGen()
+{}
+
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/pioptmenugen.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pioptmenugen.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pioptmenugen.h	(revision 50)
@@ -0,0 +1,28 @@
+#ifndef PIOPTMENGEN_H_SEEN
+#define PIOPTMENGEN_H_SEEN
+
+#include <string>
+#include "pisysdep.h"
+#include PICONT_H
+#include PIMENU_H
+
+class PIOptMenuGen : public PIContainer {
+public:
+  enum {ClassId = 1100};
+
+	             PIOptMenuGen(PIContainerGen* par, PIPUMenu *pdm,
+                                  int sx=10, int sy=10, int px=0, int py=0);
+	             ~PIOptMenuGen();
+				   
+  virtual long       kind() {return ClassId; }
+
+  virtual string     GetValueStr() = 0;    // Option choisie
+  virtual PIMessage  GetValue() = 0;       // Message correspondant a l'option choisie
+  virtual void       SetValueStr(string & s) = 0;
+  virtual void       SetValue(PIMessage msg) = 0;
+
+protected:
+
+};
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/pioptmenumac.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pioptmenumac.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pioptmenumac.cc	(revision 50)
@@ -0,0 +1,82 @@
+#include "pioptmenumac.h"
+
+/* --Methode-- */
+PIOptMenuMac::PIOptMenuMac(PIContainerGen* par, PIPUMenu *pdm,
+                     int sx, int sy, int px, int py)
+: PIOptMenuGen(par, pdm, sx, sy, px, py), mPUMenu(pdm)
+{
+  delete mPane;
+  LStr255 titre(Nom().c_str());
+  
+  StTextState textState;
+  ::TextFont(systemFont);
+  ::TextSize(12);
+  ::TextFace(0);
+  int titleWidth = ::StringWidth(titre);
+  
+  mPane = new LStdPopupMenu(mPaneInfo, msg_Click, 0, 200, titleWidth+5, popupMenuProc/*+popupVariableWidth*/, 0, titre, 0, 1);
+  //macMenu = ((LStdPopupMenu*)mPane)->GetMacMenuH();
+  
+  // On va changer la resource de menu au passage...
+  InsertMenu(pdm->GetMacMenuHandle(), hierMenu);
+  PopupPrivateDataHandle	dataH =
+		(PopupPrivateDataHandle) (**((LStdPopupMenu*)mPane)->GetMacControl()).contrlData;
+  (**dataH).mHandle = pdm->GetMacMenuHandle();
+  (**dataH).mID = pdm->GetMacMenuID();
+  
+  ((LStdPopupMenu*)mPane)->AddListener(this);
+}
+
+/* --Methode-- */
+PIOptMenuMac::~PIOptMenuMac()
+{
+}
+
+/* --Methode-- */
+void PIOptMenuMac::Process(PIMessage msg, PIMsgHandler* sender, void* data)
+{
+Select((char *)data, UserMsg(msg));  //  Reza 17/10/96 $CHECK$ ???
+ReSend(msg, sender, data);
+}
+
+void
+PIOptMenuMac::ListenToMessage(MessageT /*inMessage*/, void *)
+{
+//  if (inMessage == msg_Click)
+    mPUMenu->ItemSelected(((LStdPopupMenu*)mPane)->GetValue()-1);
+}
+
+void
+PIOptMenuMac::Select(char *txt, PIMessage msg)
+{ // Ca doit faire quoi ????
+mStext = txt;  mSmsg = msg;
+}
+
+/* --Methode-- */
+void PIOptMenuMac::SetValueStr(string & s)
+{
+int n;
+n=mPUMenu->FindItemByName((char *)s.c_str());
+if (n < 0)  return;  
+
+((LStdPopupMenu*)mPane)->SetValue(n+1);
+mStext = s;
+mSmsg  = mPUMenu->GetMenuItemMsg(n);
+
+return;
+}
+
+/* --Methode-- */
+void PIOptMenuMac::SetValue(PIMessage msg)
+{
+int n;
+n=mPUMenu->FindItemByMsg(msg);
+if (n < 0)  return;
+  
+((LStdPopupMenu*)mPane)->SetValue(n+1);
+mStext = mPUMenu->GetMenuItemText(n);
+mSmsg  = msg;
+
+return;
+}
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/pioptmenumac.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pioptmenumac.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pioptmenumac.h	(revision 50)
@@ -0,0 +1,33 @@
+#ifndef PIOPTMENMAC_H_SEEN
+#define PIOPTMENMAC_H_SEEN
+
+#include "pioptmenugen.h"
+
+class PIOptMenuMac : public PIOptMenuGen {
+public:
+	                PIOptMenuMac(PIContainerGen* par, PIPUMenu *pdm,  
+                               int sx=10, int sy=10, int px=0, int py=0);
+	               ~PIOptMenuMac();
+
+  virtual void      Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+				   
+  virtual void	    ListenToMessage(MessageT inMessage, void *ioParam);
+  virtual string    GetValueStr() { return(mStext); }
+  virtual PIMessage GetValue()    { return(mSmsg); } 
+  virtual void      SetValueStr(string & s);
+  virtual void      SetValue(PIMessage msg);
+  
+  inline void       Select(char *txt, PIMessage msg); // public ou protege ???
+
+
+protected:
+  string    mStext;
+  PIMessage mSmsg;
+  //MenuHandle macMenu;
+  PIPUMenu* mPUMenu;
+};
+
+
+typedef PIOptMenuMac  PIOptMenu ;
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/pioptmenux.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pioptmenux.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pioptmenux.cc	(revision 50)
@@ -0,0 +1,87 @@
+#include<stdio.h>
+
+#include "pisysdep.h"
+#include "pioptmenux.h"
+#include PICONT_H
+#include PISTDWDG_H
+
+#include <Xm/Xm.h>
+#include <Xm/RowColumn.h>
+
+/************* PIOptionMenuX ************/
+
+
+/* --Methode-- */
+PIOptMenuX::PIOptMenuX(PIContainerGen* par, PIPUMenu *pum,
+                     int sx, int sy, int px, int py)
+: PIOptMenuGen(par, pum, sx-2, sy-2, px, py)
+{
+sx -= 2;
+sy -= 2;
+SetBorderWidth(1); 
+mAB = new PIButton(this, "?", 0, sy-2, sy-2, 1, 1);
+mAB->SetBinding(PIBK_fixed, PIBK_fixed, PIBK_free, PIBK_fixed);
+mAB->ActivatePress(true);
+mLab = new PILabel(this, "OptLabel", sx-sy-1, sy, sy+1, 0);
+mLab->SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_fixed);
+mMen = pum;
+SetValue(mMen->ItemMsg(0));
+Manage();
+}
+
+
+/* --Methode-- */
+PIOptMenuX::~PIOptMenuX()
+{
+delete mAB;
+delete mLab;
+}
+
+/* --Methode-- */
+void PIOptMenuX::Process(PIMessage msg, PIMsgHandler* sender, void* data)
+{
+// printf("PIOptMenuX::Process Msg= %d Sender= %lx \n", (int)msg, (long)sender);
+if ((sender == mAB) && (ModMsg(msg) == PIMsg_Press))  
+  {  mMen->SetMsgParent(this);    mMen->Show(this, 0, YSize()); }
+else if (sender == mMen)
+  {
+  mAB->ReleaseButton();
+  SetValue(UserMsg(msg));
+  ReSend(msg, this, data);
+  }
+return;
+}
+
+
+/* --Methode-- */
+void PIOptMenuX::SetValueStr(string & s)
+{
+int n;
+Arg warg[2];
+n=mMen->GetNumItem((char *)s.c_str());
+if (n < 0)  return;  
+
+XtSetArg(warg[0], XmNmenuHistory, mMen->GetItemWdg(n));
+XtSetValues(XtWdg(), warg, 1);
+mStext = s;
+mSmsg  = mMen->ItemMsg(n);
+mLab->SetLabel(mStext);
+return;
+}
+
+/* --Methode-- */
+void PIOptMenuX::SetValue(PIMessage msg)
+{
+int n;
+Arg warg[2];
+n=mMen->GetNumItemMsg(msg);
+if (n < 0)  return;
+  
+XtSetArg(warg[0], XmNmenuHistory, mMen->GetItemWdg(n));
+XtSetValues(XtWdg(), warg, 1);
+mStext = mMen->ItemName(n);
+mSmsg  = msg;
+mLab->SetLabel(mStext);
+return;
+}
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/pioptmenux.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pioptmenux.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pioptmenux.h	(revision 50)
@@ -0,0 +1,35 @@
+#ifndef PIOPTMENX_H_SEEN
+#define PIOPTMENX_H_SEEN
+
+#include "pisysdep.h"
+#include "pioptmenugen.h"
+#include PISTDWDG_H
+
+class PIOptMenuX : public PIOptMenuGen {
+public:
+	            PIOptMenuX(PIContainerGen* par, PIPUMenu *pum,  
+                               int sx=10, int sy=10, int px=0, int py=0);
+	            ~PIOptMenuX();
+
+  virtual void      Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+				   
+  virtual string    GetValueStr() { return(mStext); }
+  virtual PIMessage GetValue()    { return(mSmsg); } 
+  virtual void      SetValueStr(string & s);
+  virtual void      SetValue(PIMessage msg);
+  
+  
+
+protected:
+  PIButton *mAB;
+  PILabel  *mLab;
+  PIPUMenu *mMen;
+  string   mStext;
+  PIMessage mSmsg;
+
+};
+
+
+typedef PIOptMenuX  PIOptMenu ;
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/piperiodx.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piperiodx.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piperiodx.cc	(revision 50)
@@ -0,0 +1,47 @@
+#include "piperiodx.h"
+
+/* Nouvelle-Fonction */
+static void xttimer_action(XtPointer usd, XtIntervalId * /*tid*/)
+{
+PIPeriodX * pip;
+XtIntervalId id;
+pip = (PIPeriodX *)usd;
+pip->DoPeriodic();
+id = XtAddTimeOut(pip->Interval()*1000, xttimer_action, pip);
+pip->SetTimerId(id);
+return;
+}
+
+
+/* --Methode-- */
+PIPeriodX::PIPeriodX(int dt, UsPeriodicAction act, void * usp)
+: Periodic(dt, act, usp)
+{
+}
+
+/* --Methode-- */
+PIPeriodX::~PIPeriodX()
+{
+if (mFgact) Stop();
+}
+
+/* --Methode-- */
+void PIPeriodX::Start(int dt)
+{
+if (mFgact) return;
+if (dt > 0)  mDt = dt;
+
+mTId = XtAddTimeOut(mDt*1000, xttimer_action, this);
+mFgact = true;
+return;
+}
+
+void
+PIPeriodX::Stop()
+{
+if(mFgact)
+  XtRemoveTimeOut(mTId);
+mFgact = false;
+return;
+}
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/piperiodx.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piperiodx.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piperiodx.h	(revision 50)
@@ -0,0 +1,24 @@
+// This may look like C code, but it is really -*- C++ -*-
+#ifndef PIPERIODX_H
+#define PIPERIODX_H
+
+#include <X11/Intrinsic.h>
+#include "periodic.h"
+
+class PIPeriodX : public Periodic {
+public:
+  PIPeriodX(int dt, UsPeriodicAction act=NULL, void * usp=NULL);
+  ~PIPeriodX();
+
+  virtual void Start(int dt=-1);
+  virtual void Stop();
+
+  inline void SetTimerId(XtIntervalId id) {mTId=id; }
+
+protected:
+XtIntervalId mTId;
+};
+
+typedef PIPeriodX PIPeriodic;
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/pipixmapgen.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pipixmapgen.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pipixmapgen.cc	(revision 50)
@@ -0,0 +1,137 @@
+/* Fonctions interface XWindow pour affichage d'images */
+/*                  Reza   05/95                       */
+
+/*                  LAL (Orsay) / IN2P3-CNRS           */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "pipixmapgen.h"
+
+// Methodes de la classe PIPixMap  :
+
+/* --Methode-- */
+PIPixmapGen::PIPixmapGen(PIContainerGen  *par, char *nom,
+                     int sx, int sy, int px, int py) :
+PIBaseWdg(par, nom, sx, sy, px, py)
+{
+pixmap = NULL;
+nx = ny = 0;
+ofx = ofy = 0;
+mPpos[0] = mPpos[0] = 0;
+cmap = new PIColorMap(CMAP_GREY32);
+mEn = 0;
+ActivateButton(1);
+}
+
+
+/* --Methode-- */
+PIPixmapGen::~PIPixmapGen()
+{
+delete cmap;
+}
+
+/* --Methode-- */
+void PIPixmapGen::SetPixmap(unsigned char *pix, int sx, int sy, bool refr, int ox, int oy)
+{
+pixmap = pix; 
+if (pixmap)
+  {
+  if (sx < 0)  sx = 0;
+  if (sy < 0)  sy = 0;
+  if (ox < 0)  ox = 0;
+  if (oy < 0)  oy = 0;
+  nx = sx; ny = sy;
+  ofx = ox;  ofy = oy;
+  }
+else { ofx = ofy = nx = ny = 0; }
+if (refr) Refresh();   
+}
+
+
+/* --Methode-- */
+void PIPixmapGen::SetColMap(CMapId cmapid, bool refr)
+{
+if (cmap) delete cmap;
+cmap = new PIColorMap(cmapid);
+if (refr)  Refresh();  
+}
+
+
+/* --Methode-- */
+void  PIPixmapGen::But1Press(int x, int y)
+{
+mPpos[0] = x;  mPpos[1] = y;  
+if (Msg())  Send(Msg(), PIMsg_Click, mPpos);
+return;
+}
+
+
+/* --Methode-- */
+int PIPixmapGen::ElAdd(int typ, int x, int y, int dx, int dy, char* s)
+{
+DrwEl dre;
+mEn++;
+dre.eid = mEn;  dre.etyp = typ;
+dre.ex = x;   dre.ey = y;
+dre.edx = dx;  dre.edy = dy;
+if (s)  dre.es = s;
+mElist.push_back(dre);
+return(mEn);
+}
+
+/* --Methode-- */
+void  PIPixmapGen::ElDel(int id)
+{
+DrwElList::iterator it;
+for (it = mElist.begin(); it != mElist.end(); it++)
+  if ( (*it).eid == id) { mElist.erase(it);   break; }
+return;
+}
+
+/* --Methode-- */
+void  PIPixmapGen::ElDelAll()
+{
+mElist.erase(mElist.begin(), mElist.end());
+return;
+}
+
+/* --Methode-- */
+void  PIPixmapGen::DrawElements()
+{
+char* txt;
+DrwElList::iterator it;
+for (it = mElist.begin(); it != mElist.end(); it++)
+  {
+  switch ( (*it).etyp )
+    {
+    case PIDEL_Line :
+      DrawLine((*it).ex, (*it).ey, (*it).edx, (*it).edy ); 
+      break;
+    case PIDEL_Text :
+      txt = (char*) ((*it).es.c_str());
+      DrawString((*it).ex, (*it).ey, txt ); 
+      break;
+    case PIDEL_Rect :
+      DrawBox((*it).ex, (*it).ey, (*it).edx, (*it).edy ); 
+      break;
+    case PIDEL_FRect :
+      DrawFBox((*it).ex, (*it).ey, (*it).edx, (*it).edy ); 
+      break;
+    case PIDEL_Circ :
+      DrawCircle((*it).ex, (*it).ey, (*it).edx ); 
+      break;
+    case PIDEL_FCirc :
+      DrawFCircle((*it).ex, (*it).ey, (*it).edx ); 
+      break;
+    default :
+      break;
+    }
+  }
+return;
+}
+
+
+// Fin des methodes de la classe 
+
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/pipixmapgen.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pipixmapgen.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pipixmapgen.h	(revision 50)
@@ -0,0 +1,87 @@
+/* Fonctions interface XWindow pour affichage d'images */
+
+#ifndef PIPIXMAP_H_SEEN
+#define PIPIXMAP_H_SEEN
+
+#include "pisysdep.h"
+
+#include PIBWDG_H
+#include PICMAP_H
+
+#include <list>
+
+class PIPixmapGen : public PIBaseWdg
+{
+public:
+  enum {ClassId = 5100};
+
+  enum { PIDEL_Line = 1, PIDEL_Text = 2,
+         PIDEL_Rect = 3, PIDEL_FRect = 4, 
+         PIDEL_Circ = 5, PIDEL_FCirc = 6 } ; 
+
+                PIPixmapGen(PIContainerGen *par, char *nom,
+                         int sx=10, int sy=10, int px=0, int py=0);
+  virtual       ~PIPixmapGen();
+
+  virtual long  kind() {return ClassId; }
+
+  virtual void  SetPixmap(unsigned char *pix, int sx, int sy, 
+                          bool refr=true, int ox=0, int oy=0);
+  void          SetColMap(CMapId cmapid, bool refr=true);
+  inline CMapId GetColMapId() { return (cmap->Type()); }; 
+  inline int    NbCol() { return(cmap->NCol()); };
+
+  virtual void  But1Press(int x, int y);
+  inline  int   XPPos() { return mPpos[0]; }
+  inline  int   YPPos() { return mPpos[1]; }
+
+  inline int    ElAddLine(int x1, int y1, int x2, int y2)
+    { return( ElAdd(PIDEL_Line, x1, y1, x2, y2, NULL) ); }  
+  inline int    ElAddText(int x, int y, char* s)
+    { return( ElAdd(PIDEL_Text, x, y, 0, 0, s) ); }  
+  inline int    ElAddRect(int x, int y, int dx, int dy)
+    { return( ElAdd(PIDEL_Rect, x, y, dx, dy, NULL) ); }  
+  inline int    ElAddFRect(int x, int y, int dx, int dy)
+    { return( ElAdd(PIDEL_FRect, x, y, dx, dy, NULL) ); }  
+  inline int    ElAddCirc(int x, int y, int r)
+    { return( ElAdd(PIDEL_Circ, x, y, r, r, NULL) ); }  
+  inline int    ElAddFCirc(int x, int y, int r)
+    { return( ElAdd(PIDEL_FCirc, x, y, r, r, NULL) ); }  
+
+  void          ElDel(int id);
+  void          ElDelAll();
+
+protected:
+  int           ElAdd(int typ, int x, int y, int dx, int dy, char* s);
+  virtual void  DrawElements();
+
+  unsigned char *pixmap;
+  int nx, ny;
+  int ofx, ofy;
+  PIColorMap* cmap;
+
+#ifdef __DECCXX
+public:
+#endif
+  struct DrwEl{
+    int eid, etyp;
+    int ex,ey;
+    int edx,edy;
+    string es;
+  };
+#ifdef __DECCXX
+protected:
+#endif
+  typedef list<DrwEl> DrwElList;
+
+  DrwElList mElist;
+  int mEn;
+  int mPpos[2];
+};  
+  
+
+
+
+#endif   /* PIPIXMAP_H_SEEN */
+
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/pipixmapmac.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pipixmapmac.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pipixmapmac.cc	(revision 50)
@@ -0,0 +1,89 @@
+#include "pipixmapmac.h"
+
+PIPixmapMac::PIPixmapMac(PIContainerGen *par, char *nom,
+                         int sx, int sy, int px, int py)
+: PIPixmapGen(par,nom,sx,sy,px,py), mGWorld(NULL)
+{}
+
+
+PIPixmapMac::~PIPixmapMac()
+{}
+
+
+/* --Methode-- */
+void PIPixmapMac::SetPixmap(unsigned char *pix, int sx, int sy, bool refr)
+{
+  if (nx != sx || ny != sy)
+    if (mGWorld) {
+      DisposeGWorld(mGWorld);
+      mGWorld = NULL;
+    }
+  PIPixmapGen::SetPixmap(pix, sx, sy, refr);
+}
+
+void
+PIPixmapMac::Resize()
+{
+  Refresh();
+}
+
+void
+PIPixmapMac::Refresh()
+{
+  if (mGWorld) {
+    DisposeGWorld(mGWorld);
+    mGWorld = NULL;
+  }
+  
+  if (!cmap) return;
+  if (!pixmap) return;
+  if (nx == 0 || ny == 0) return;
+  
+  Rect	frame;
+  SetRect(&frame, 0, 0, XSize(), YSize());
+
+  
+  ThrowIfOSErr_(NewGWorld(&mGWorld, 8, &frame, cmap->mCTab, nil, 0));
+
+    // Lock down Pixels that we are drawing to so that memory will not
+	// move
+	::LockPixels (mGWorld->portPixMap);
+
+ 	// Draw
+	PixMapHandle	pMap;
+	unsigned char	*pixP;
+	
+	pMap = GetGWorldPixMap(mGWorld);
+	for (int y=frame.top; y<frame.bottom; y++) {
+		pixP = (unsigned char *) GetPixBaseAddr(pMap) + y * ((**pMap).rowBytes & 0x7FFF);
+		for(int x = frame.left ; x < frame.right ; x++)
+			pixP[x] = (x<nx && y<ny) ? pixmap[x + y*nx]+2 : 0;
+	}
+			
+	// Now unlock Pixels.
+	::UnlockPixels (mGWorld->portPixMap);
+	
+	mPane->FocusDraw();
+	SetPalette(mPane->GetMacPort(),cmap->mPalette, true);
+	PIPixmapGen::Refresh();
+}
+
+void
+PIPixmapMac::Draw()
+{
+  if (!mGWorld) return;
+  mPane->FocusDraw();
+  Rect	paneFrame;
+  mPane-> CalcLocalFrameRect(paneFrame);
+  Rect	offsFrame;
+  SetRect(&offsFrame, 0, 0, paneFrame.right-paneFrame.left, paneFrame.bottom-paneFrame.top);
+  ::LockPixels (mGWorld->portPixMap);
+  ::ForeColor (blackColor);
+  ::BackColor (whiteColor);
+  ::CopyBits((BitMap *) (*(GetGWorldPixMap(mGWorld))),
+				&mPane->GetMacPort()->portBits,
+				&offsFrame, &paneFrame, srcCopy, nil);
+  ::UnlockPixels (mGWorld->portPixMap);
+
+
+}
Index: /tags/V_Saclay_110697/SophyaPI/PI/pipixmapmac.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pipixmapmac.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pipixmapmac.h	(revision 50)
@@ -0,0 +1,24 @@
+#ifndef PIPIXMAPMAC_H_SEEN
+#define PIPIXMAPMAC_H_SEEN
+
+#include "pipixmapgen.h"
+
+class PIPixmapMac : public PIPixmapGen {
+
+public:
+                PIPixmapMac(PIContainerGen *par, char *nom,
+                         int sx=10, int sy=10, int px=0, int py=0);
+  virtual      ~PIPixmapMac();
+
+  virtual void  SetPixmap(unsigned char *pix, int sx, int sy, bool refr=true);
+  virtual void  Draw();
+  virtual void	Refresh();
+  virtual void  Resize();
+protected:
+  GWorldPtr 	mGWorld;
+};
+
+typedef PIPixmapMac PIPixmap;
+
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/pipixmapx.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pipixmapx.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pipixmapx.cc	(revision 50)
@@ -0,0 +1,178 @@
+#include <stdio.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+
+#include "pipixmapx.h"
+#include "psfile.h"
+
+static  GC    mygc;
+
+/* --Methode-- */
+PIPixmapX::PIPixmapX(PIContainerGen *par, char *nom,
+                         int sx, int sy, int px, int py)
+: PIPixmapGen(par,nom,sx,sy,px,py) 
+{
+Init();
+AllocXImg();
+}
+
+
+/* --Methode-- */
+PIPixmapX::~PIPixmapX()
+{
+delete[] myximg->data;
+XFree(myximg); 
+}
+
+/* --Methode-- */
+void PIPixmapX::Refresh()
+{
+int i,j;
+unsigned char *pp;
+
+if (pixmap)
+  {
+  for(j=0; j<ny; j++)
+    {
+    pp = pixmap+j*nx;
+    for(i=0; i<nx; i++)
+      { XPutPixel(myximg, i, j, cmap->Color(*pp) );  pp++; }
+    }
+  }
+
+for(j=ny; j<YSize(); j++)
+  for(i=nx; i<XSize(); i++)
+     XPutPixel(myximg, i, j, 0 );
+
+PIBaseWdgX::Refresh();
+}
+
+
+/* --Methode-- */
+void PIPixmapX::Resize()
+{
+delete[] myximg->data;
+XFree(myximg); 
+AllocXImg();
+if (Msg())  Send(Msg(), PIMsg_Resize, mPpos);
+}
+
+/* --Methode-- */
+void PIPixmapX::Draw()
+{
+if(mPSOut)
+  {
+  if(pixmap) 
+    mPSOut->Image(0, 0, (float)XSize(), (float)YSize(), nx, ny, pixmap, cmap);
+  /*  Il faut faire quelque chose Sinon ??! */ 
+  DrawElements();
+  }
+else
+  Draw(0, 0, XSize(), YSize());
+}
+
+/* --Methode-- */
+void PIPixmapX::Draw(int x0, int y0, int dx, int dy)
+{
+int mx, my, ox, oy;
+Window xw;
+Display * mdsp;
+if ((myximg == NULL) || (cmap == NULL)) return;
+
+xw = XtWindow(XtWdg());
+mdsp = PIXDisplay();
+
+if (x0 < 0)  x0 = 0;
+if (y0 < 0)  y0 = 0;
+mx = nx+ofx;   my = ny+ofy;
+if (dx > (XSize()-x0)) dx = XSize()-x0;
+if (dy > (YSize()-y0)) dy = YSize()-y0;
+if ((dx <= 0) || (dy <= 0))  return;
+
+if ( (mx < x0 ) || (my < y0) )
+  { XClearArea(mdsp, xw, x0, y0, dx, dy, False);  return; }
+
+ox = oy = 0;  
+
+if (ofx > x0)
+  { XClearArea(mdsp, xw, x0, y0, ofx-x0, dy, False);   
+  dx -= (ofx-x0);  x0 = ofx;  ox = 0; }
+else  ox = x0-ofx;
+if (ofy > y0)
+  { XClearArea(mdsp, xw, x0, y0, dx, ofy-y0, False);  
+  dy -= (ofy-y0);  y0 = ofy;  oy = 0; }
+else  oy = y0-ofy;
+ 
+if (mx < (x0+dx))
+  { XClearArea(mdsp, xw, mx, y0, x0+dx-mx, dy, False);  dx = mx-x0; }
+if (my < (y0+dy))
+  { XClearArea(mdsp, xw, x0, my, dx, y0+dy-my, False);  dy = my-y0; }
+ 
+XPutImage(mdsp, xw, mygc, myximg, ox, oy, x0, y0, dx, dy);
+DrawElements();
+XFlush(mdsp);
+
+return;
+ 
+}
+
+static bool fgxpxm = false;
+
+
+/* --Methode-- */
+void PIPixmapX::Init()
+{
+XGCValues       values;
+XtGCMask        mask;
+Display *mdsp;
+int scr;
+
+if (fgxpxm)  return; 
+fgxpxm = true;
+
+mdsp = XtDisplay(XtWdg());
+scr = XDefaultScreen(mdsp);
+
+mask = GCFunction | GCPlaneMask;
+// mask = GCForeground | GCBackground;
+values.function = GXcopy;
+values.plane_mask = ~0;
+// values.foreground = WhitePixel(mdsp, scr);
+// values.background = BlackPixel(mdsp, scr);
+mygc = XtGetGC(XtWdg(), mask, &values);
+
+return;
+}
+
+
+/* --Methode-- */
+void PIPixmapX::AllocXImg()
+{
+Window xw;
+Display * mdsp;
+int scr;
+int depth;
+int pad;
+int i,j;
+
+xw = XtWindow(XtWdg());
+mdsp = PIXDisplay();
+scr = PIXScreen();
+
+depth = DefaultDepth(mdsp,scr);
+pad = (depth > 8) ? 32 : 8;
+myximg = XCreateImage (mdsp,DefaultVisual(mdsp,scr),
+           depth,ZPixmap,0,NULL, XSize(), YSize(), pad,0);
+if (myximg == NULL)  return;
+myximg->data = new char [YSize()*myximg->bytes_per_line];
+if (myximg->data == NULL)  
+  { XFree(myximg); myximg = NULL; } 
+
+for(j=0; j<YSize(); j++)
+  for(i=0; i<XSize(); i++)
+    XPutPixel(myximg, i, j, 0 );
+
+return;
+}
Index: /tags/V_Saclay_110697/SophyaPI/PI/pipixmapx.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pipixmapx.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pipixmapx.h	(revision 50)
@@ -0,0 +1,28 @@
+#ifndef PIPIXMAPX_H_SEEN
+#define PIPIXMAPX_H_SEEN
+
+#include "pipixmapgen.h"
+
+class PIPixmapX : public PIPixmapGen {
+
+public:
+                PIPixmapX(PIContainerGen *par, char *nom,
+                         int sx=10, int sy=10, int px=0, int py=0);
+  virtual      ~PIPixmapX();
+
+  virtual void  Refresh();
+  virtual void  Resize();
+  virtual void  Draw();
+  virtual void  Draw(int x0, int y0, int dx, int dy);
+
+
+protected:
+  void          Init();
+  void          AllocXImg();
+  XImage * myximg;  
+};
+
+typedef PIPixmapX PIPixmap;
+
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/pippapplmac.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pippapplmac.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pippapplmac.cc	(revision 50)
@@ -0,0 +1,36 @@
+#include "pippapplmac.h"
+#include "piupdattachment.h"
+#include "pippmenubar.h"
+
+PIPPApplMac::PIPPApplMac()
+:LApplication()
+{}
+
+
+PIPPApplMac::~PIPPApplMac()
+{}
+
+void
+PIPPApplMac::AdjustCursor(const EventRecord &inMacEvent)
+{
+  PIUpdAttachment::hit = false;
+  LApplication::AdjustCursor(inMacEvent);
+  if (!PIUpdAttachment::hit) {
+    if (PIUpdAttachment::lastCursPane)
+       PIUpdAttachment::lastCursPane->myWdg->Leave();
+    PIUpdAttachment::lastCursPane = NULL;
+  }   
+}
+
+void
+PIPPApplMac::MakeMenuBar()
+{
+	new PIPPMenuBar();
+}
+
+
+
+// $CHECK$
+// Gerer AllowSubRemoval, qui envoie un evenement a l'application PI.
+// Eventuellement avoir des fenetres qui se cachent lors d'un close et d'autres
+// qui se detruisent ??
Index: /tags/V_Saclay_110697/SophyaPI/PI/pippapplmac.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pippapplmac.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pippapplmac.h	(revision 50)
@@ -0,0 +1,11 @@
+#include <LApplication.h>
+
+class PIPPApplMac : public LApplication {
+public:
+						PIPPApplMac();
+	virtual				~PIPPApplMac();
+
+	void MakeMenuBar();
+	virtual void			AdjustCursor	(const EventRecord &inMacEvent);
+};
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/pippmenubar.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pippmenubar.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pippmenubar.cc	(revision 50)
@@ -0,0 +1,27 @@
+#include "pippmenubar.h"
+
+PIPPMenuBar::PIPPMenuBar()
+: LMenuBar(MBAR_Initial)
+{
+
+}
+
+PIPPMenuBar::~PIPPMenuBar()
+{}
+
+CommandT
+PIPPMenuBar::MenuCommandSelection(
+	const EventRecord	&inMouseEvent,
+	Int32				&outMenuChoice) const
+{
+	outMenuChoice = ::MenuSelect(inMouseEvent.where);
+	
+	int menuId = HiWord(outMenuChoice);
+	int menuItem = LoWord(outMenuChoice)-1; // Dans PI les menu items commencent a 0
+	
+	PIMenuMac* menu = PIMenuMac::findMenu(menuId);
+	if (menu)
+	  menu->ItemSelected(menuItem);
+	
+	return cmd_Nothing;
+}
Index: /tags/V_Saclay_110697/SophyaPI/PI/pippmenubar.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pippmenubar.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pippmenubar.h	(revision 50)
@@ -0,0 +1,18 @@
+#ifndef PIPPMENUBAR_H_SEEN
+#define PIPPMENUBAR_H_SEEN
+
+#include <LMenuBar.h>
+#include "pimenumac.h"
+
+class PIPPMenuBar : public LMenuBar {
+public:
+                           PIPPMenuBar();
+                          ~PIPPMenuBar();
+
+	virtual CommandT	   MenuCommandSelection(const EventRecord &inMouseEvent,
+								Int32 &outMenuChoice) const;
+
+};
+
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/piscdrawwdg.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piscdrawwdg.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piscdrawwdg.cc	(revision 50)
@@ -0,0 +1,810 @@
+#include "piscdrawwdg.h"
+#include "generalfit.h"
+#include <algorithm>
+
+
+PIScDrawWdg::PIScDrawWdg(PIContainerGen *par, char *nom,
+                         int sx, int sy, int px, int py)
+:PIBaseWdg(par, nom, sx, sy, px, py)
+{
+  SetLimits(-1, 1, -1, 1);
+  limitsFixed = 0;
+  xEndDrag = yEndDrag = xBegDrag = yBegDrag = 0;
+  SetAxesFlags(kAxesDflt);
+  clip = true;
+  padsup = false;
+  mTrlb = mTxw = NULL;
+  mTrW = NULL;
+  SetTextWin(NULL);
+  ActivateButton(1);    // Pour pouvoir activer la fenetre et coordonnees 
+  ActivateMove(1);      //    "         "         "        "
+  ActivateButton(2);
+  ActivateMove(2);
+
+}
+
+PIScDrawWdg::~PIScDrawWdg()
+{
+  DeleteDrawers();
+  if (mTrW)  delete mTrW;
+}
+
+
+void
+PIScDrawWdg::SetLimits(double xmin, double xmax, double ymin, double ymax,
+                       bool axrl, bool ayud, bool tmp)
+{
+  if (xmax <= xmin || ymax <= ymin)
+    return; // $CHECK$ exception ?
+  aXdir = axrl;      // Vrai si Axe X de Droite vers Gauche
+  aYdir = ayud;      // Vrai si Axe Y de Haut vers Bas
+  xMin = xmin;
+  xMax = xmax;
+  yMin = ymin;
+  yMax = ymax;
+  mPPos[0] = 0.5*(xMin+xMax);
+  mPPos[1] = 0.5*(yMin+yMax);
+  if (!tmp) {
+    xMinS = xmin;
+    xMaxS = xmax;
+    yMinS = ymin;
+    yMaxS = ymax;
+  }
+  CalcScale();
+  CalcTicks();
+  limitsFixed = 1;
+}
+
+void
+PIScDrawWdg::Resize()
+{
+  CalcScale();
+  CalcTicks();
+  Refresh();
+}
+
+void
+PIScDrawWdg::CalcScale()
+{
+  double margeH = (xMax-xMin)*0.15;
+  double margeV = (yMax-yMin)*0.15;
+  xScale = XSize() / (xMax-xMin + 2*margeH);
+  if (aXdir)  { 
+    xScale = -xScale;
+    xOrg   = (-xMax - margeH) * xScale;// + XPos();
+  }
+  else xOrg   = (-xMin + margeH) * xScale;// + XPos();
+  yScale = YSize() / (yMax-yMin + 2*margeV);
+  if (!aYdir) {
+    yScale = -yScale;
+    yOrg   = (-yMax - margeV) * yScale;// + YPos();
+  }
+  else yOrg   = (-yMin + margeV) * yScale;// + YPos();
+return;
+}
+
+void
+PIScDrawWdg::CalcTicks()
+{
+	double xExt = xMax-xMin;
+	int lx = (int) ceil(log10(xExt)-0.1);
+	xExt = pow(10.0,lx);
+	xMajTickStep = xExt/10;
+	xMinTickStep = xMajTickStep/10;
+    xFirstMajTick = int(xMin / xMajTickStep) * xMajTickStep;
+    if (xFirstMajTick < xMin) xFirstMajTick += xMajTickStep;
+    xFirstMinTick = int(xMin / xMinTickStep) * xMinTickStep;
+    if (xFirstMinTick < xMin) xFirstMinTick += xMinTickStep;
+    
+    
+	double yExt = yMax-yMin;
+	int ly = (int) ceil(log10(yExt)-0.1);
+	yExt = pow(10.0,ly);
+	yMajTickStep = yExt/10;
+	yMinTickStep = yMajTickStep/10;
+    yFirstMajTick = int(yMin / yMajTickStep) * yMajTickStep;
+    if (yFirstMajTick < yMin) yFirstMajTick += yMajTickStep;
+    yFirstMinTick = int(yMin / yMinTickStep) * yMinTickStep;
+    if (yFirstMinTick < yMin) yFirstMinTick += yMinTickStep;
+    
+//    xMajTickLen = -2/yScale;
+//    xMinTickLen = -1/yScale;
+//    yMajTickLen = 2/xScale;
+//    yMinTickLen = 1/xScale;
+
+    yMajTickLen = (xMax-xMin)/100;
+    yMinTickLen = (xMax-xMin)/250;
+    xMajTickLen = (yMax-yMin)/100;
+    xMinTickLen = (yMax-yMin)/250;
+
+}
+
+void
+PIScDrawWdg::Sc2Local(double x, double y, int& xpix, int& ypix)
+{
+  xpix = int(xOrg + x*xScale + .5);
+  ypix = int(yOrg + y*yScale + .5);
+}
+
+void
+PIScDrawWdg::Local2Sc(int xpix, int ypix, double& x, double& y)
+{
+  x = (xpix-xOrg)/xScale;
+  y = (ypix-yOrg)/yScale;
+}
+
+
+void
+PIScDrawWdg::DSc2Local(double dx, double dy, int& dxpix, int& dypix)
+{
+  dxpix = int(dx*xScale + .5);
+  dypix = int(dy*yScale + .5);
+}
+
+double
+PIScDrawWdg::ScStringWidth(char const* s)
+{
+  return CalcStringWidth(s) / xScale;
+}
+
+void
+PIScDrawWdg::ScSelFontSz(double size, PIFontAtt att)
+{
+  int npt = int(fabs(size * yScale)+.5);
+  if (npt < 8) npt = 8;
+  if (npt > 127) npt = 127;
+  SelFontSzPt(npt, att);
+}
+
+void
+PIScDrawWdg::ScSelMarker(double size, PIMarker mrk)
+{
+  int isz = int(fabs(size * xScale)+.5);
+  SelMarker( isz, mrk);
+}
+
+void
+PIScDrawWdg::ScDrawString(double x, double y, char* s, int pos)
+{
+  int xPix, yPix;
+  Sc2Local(x, y, xPix, yPix);
+  DrawString(xPix, yPix, s, pos);
+}
+
+void
+PIScDrawWdg::ScDrawLine(double x1, double y1, double x2, double y2)
+{
+  
+  if (clip) {
+    if (x2 < xMin && x1 < xMin) return;
+    if (x2 > xMax && x1 > xMax) return;
+    if (y1 < yMin && y2 < yMin) return;
+    if (y1 > yMax && y2 > yMax) return;
+    if (x2 < x1) {
+      swap(x1,x2);
+      swap(y1,y2);
+    }
+    if (x2>xMax) {
+      y2 = y1 + (y2-y1)/(x2-x1)*(xMax-x1);
+      x2 = xMax;
+    }
+    if (x1<xMin) {
+      y1 = y2 + (y1-y2)/(x1-x2)*(xMin-x2);
+      x1 = xMin;
+    }
+    if (y2 < y1) {
+      swap(x1,x2);
+      swap(y1,y2);
+    }
+    if (y2>yMax) {
+      x2 = x1 + (x2-x1)/(y2-y1)*(yMax-y1);
+      y2 = yMax;
+    }
+    if (y1<yMin) {
+      x1 = x2 + (x1-x2)/(y1-y2)*(yMin-y2);
+      y1 = yMin;
+    }
+  }
+  int x1Pix, y1Pix, x2Pix, y2Pix;
+  Sc2Local(x1, y1, x1Pix, y1Pix);
+  Sc2Local(x2, y2, x2Pix, y2Pix);
+  DrawLine(x1Pix, y1Pix, x2Pix, y2Pix);
+}  
+
+
+void
+PIScDrawWdg::ScDrawBox(double x, double y, double dx, double dy)
+{
+  if (clip) {
+    if (dx < 0) {
+      x = x+dx;
+      dx = -dx;
+    }
+    if (dy < 0) {
+      y = y+dy;
+      dy = -dy;
+    }
+    if (x > xMax || x+dx < xMin || y > yMax || y+dy < yMin) return;
+    if (x < xMin) {
+      dx -= (xMin-x);
+      x = xMin;
+    }
+    if (y < yMin) {
+      dy -= (yMin-y);
+      y = yMin;
+    }
+    if (x+dx > xMax)
+      dx = (xMax-x);
+    if (y+dy > yMax)
+      dy = (yMax-y);
+  }
+  int xPix, yPix, x2Pix, y2Pix;
+  Sc2Local(x, y, xPix, yPix);
+  Sc2Local(x+dx, y+dy, x2Pix, y2Pix);
+  DrawBox(xPix, yPix, x2Pix-xPix, y2Pix-yPix);
+}  
+
+void
+PIScDrawWdg::ScDrawFBox(double x, double y, double dx, double dy)
+{
+  if (clip) {
+    if (dx < 0) {
+      x = x+dx;
+      dx = -dx;
+    }
+    if (dy < 0) {
+      y = y+dy;
+      dy = -dy;
+    }
+    if (x > xMax || x+dx < xMin || y > yMax || y+dy < yMin) return;
+    if (x < xMin) {
+      dx -= (xMin-x);
+      x = xMin;
+    }
+    if (y < yMin) {
+      dy -= (yMin-y);
+      y = yMin;
+    }
+    if (x+dx > xMax)
+      dx = (xMax-x);
+    if (y+dy > yMax)
+      dy = (yMax-y);
+  }
+  int xPix, yPix, x2Pix, y2Pix;
+  Sc2Local(x, y, xPix, yPix);
+  Sc2Local(x+dx, y+dy, x2Pix, y2Pix);
+  DrawFBox(xPix, yPix, x2Pix-xPix, y2Pix-yPix);
+}  
+
+void
+PIScDrawWdg::ScDrawCircle(double x, double y, double r)
+{
+  int xPix, yPix, rPix;
+  Sc2Local(x, y, xPix, yPix);
+  rPix = r * xScale;
+  DrawCircle(xPix, yPix, rPix);
+}  
+
+void
+PIScDrawWdg::ScDrawFCircle(double x, double y, double r)
+{
+  int xPix, yPix, rPix;
+  Sc2Local(x, y, xPix, yPix);
+  rPix = r * xScale;
+  DrawFCircle(xPix, yPix, rPix);
+}
+
+#define NMXMULTP  30   // Pour multipoint sans new
+
+void  
+PIScDrawWdg::ScDrawPolygon(double *x, double *y, int n)
+{
+int ix[NMXMULTP], iy[NMXMULTP];
+int *pxi, *pyi;
+int i;
+ 
+if (n <= 0)  return;
+if (n > NMXMULTP) { pxi = new int[n];  pyi = new int[n]; }
+else { pxi = ix;  pyi = iy; }
+for(i=0; i<n; i++)  
+  Sc2Local(x[i], y[i], pxi[i], pyi[i]);
+DrawPolygon(pxi, pyi, n);
+if (n > NMXMULTP) { delete[] pxi;  delete[] pyi; }
+return;
+}
+  
+void  
+PIScDrawWdg::ScDrawFPolygon(double *x, double *y, int n)
+{
+int xi[NMXMULTP], yi[NMXMULTP];
+int *pxi, *pyi;
+int i;
+ 
+if (n <= 0)  return;
+if (n > NMXMULTP) { pxi = new int[n];  pyi = new int[n]; }
+else { pxi = xi;  pyi = yi; }
+for(i=0; i<n; i++)  
+  Sc2Local(x[i], y[i], pxi[i], pyi[i]);
+DrawFPolygon(pxi, pyi, n);
+if (n > NMXMULTP) { delete[] pxi;  delete[] pyi; }
+return;
+}
+
+void  
+PIScDrawWdg::ScDrawMarker(double x0, double y0)
+{
+  int xPix, yPix;
+  Sc2Local(x0, y0, xPix, yPix);
+  DrawMarker(xPix, yPix);
+  return;
+}
+void  
+PIScDrawWdg::ScDrawMarkers(double *x, double *y, int n)
+{
+int xi[NMXMULTP], yi[NMXMULTP];
+int *pxi, *pyi;
+int i;
+ 
+if (n <= 0)  return;
+if (n > NMXMULTP) { pxi = new int[n];  pyi = new int[n]; }
+else { pxi = xi;  pyi = yi; }
+for(i=0; i<n; i++)  
+  Sc2Local(x[i], y[i], pxi[i], pyi[i]);
+DrawMarkers(pxi, pyi, n);
+if (n > NMXMULTP) { delete[] pxi;  delete[] pyi; }
+return;
+}
+
+void
+PIScDrawWdg::DrawHTicks(double y, double tickUp, double tickDown, double xBeg, double xStep)
+{
+  for (double x=xBeg; x<=xMax; x += xStep)
+    ScDrawLine(x, y-tickDown, x, y+tickUp);
+}
+
+void
+PIScDrawWdg::DrawVTicks(double x, double tickLeft, double tickRight, double yBeg, double yStep)
+{
+  for (double y=yBeg; y<=yMax; y += yStep)
+    ScDrawLine(x-tickLeft, y, x+tickRight, y);
+}
+
+void
+PIScDrawWdg::DrawHLabels(double y, double xBeg, double xStep, int just)
+{
+  double xOffset = 0;
+  int kk;
+  ScSelFontSz(xMajTickLen*4);
+  for (double x=xBeg; x<=xMax; x += xStep) {
+      char label[20]; sprintf(label, "%-6g", x);
+      for(kk=0; kk<20; kk++)
+        if (label[kk] == ' ')   { label[kk] = '\0' ; break; }
+      double largeur = ScStringWidth(label);
+      if (just == 1)
+        xOffset = -largeur;
+      else if (just == 0)
+        xOffset = -largeur/2;
+      else
+        xOffset = 0;
+      if (aXdir)  xOffset = -xOffset;
+      ScDrawString(x+xOffset, y, label);
+  }
+}
+
+void
+PIScDrawWdg::DrawVLabels(double x, double yBeg, double yStep, int just)
+{
+  double xOffset = 0;
+  ScSelFontSz(xMajTickLen*4);
+  for (double y=yBeg; y<=yMax; y += yStep) {
+      char label[20]; sprintf(label, "%-6g", y);
+      double largeur = ScStringWidth(label);
+      if (just == 1)
+        xOffset = -largeur;
+      else if (just == 0)
+        xOffset = -largeur/2;
+      else
+        xOffset = 0;
+      if (aXdir)  xOffset = -xOffset;
+      ScDrawString(x+xOffset, y, label);
+  }
+}
+
+
+void
+PIScDrawWdg::DrawAxes(int flags)
+{
+  NoClip();
+  if (flags == -1)
+    flags = axesFlags;
+    
+  
+  if (flags & kStdAxes) {
+  
+    // Les axes
+    
+    ScDrawLine(xMin, 0, xMax, 0);
+    ScDrawLine(0, yMin, 0, yMax);
+  
+    // Les ticks majeurs
+  
+    if (flags & kMajTicks) {
+        DrawHTicks(0, xMajTickLen, xMajTickLen, xFirstMajTick, xMajTickStep);
+        DrawVTicks(0, yMajTickLen, yMajTickLen, yFirstMajTick, yMajTickStep);
+    }
+    
+    // Les ticks mineurs
+  
+    if (flags & kMinTicks) {
+        DrawHTicks(0, xMinTickLen, xMinTickLen, xFirstMinTick, xMinTickStep);
+        DrawVTicks(0, yMinTickLen, yMinTickLen, yFirstMinTick, yMinTickStep);
+    }
+    
+    // Les labels
+    
+    if (flags & kLabels) {
+      if (!aYdir)
+        DrawHLabels(-xMajTickLen*8, xFirstMajTick, xMajTickStep,0);
+      else 
+        DrawHLabels(xMajTickLen*8, xFirstMajTick, xMajTickStep,0);
+      if (!aXdir)
+        DrawVLabels(-yMajTickLen*2, yFirstMajTick, yMajTickStep,1);
+      else 
+        DrawVLabels(yMajTickLen*2, yFirstMajTick, yMajTickStep,1);
+    }
+    
+  }
+  
+  if (flags & kBoxAxes) {
+  
+    // La boite
+    
+    ScDrawLine(xMin, yMin, xMax, yMin);
+    ScDrawLine(xMax, yMin, xMax, yMax);
+    ScDrawLine(xMax, yMax, xMin, yMax);
+    ScDrawLine(xMin, yMax, xMin, yMin);
+
+    // Longueur des ticks
+    
+    double extXMajTickLen = flags&kExtTicks ? xMajTickLen : 0;
+    double intXMajTickLen = flags&kIntTicks ? xMajTickLen : 0;
+    double extXMinTickLen = flags&kExtTicks ? xMinTickLen : 0;
+    double intXMinTickLen = flags&kIntTicks ? xMinTickLen : 0;
+    double extYMajTickLen = flags&kExtTicks ? yMajTickLen : 0;
+    double intYMajTickLen = flags&kIntTicks ? yMajTickLen : 0;
+    double extYMinTickLen = flags&kExtTicks ? yMinTickLen : 0;
+    double intYMinTickLen = flags&kIntTicks ? yMinTickLen : 0;
+
+    // Les ticks majeurs
+  
+    if (flags & kMajTicks) {
+        DrawHTicks(yMin, intXMajTickLen, extXMajTickLen, xFirstMajTick, xMajTickStep);
+        DrawHTicks(yMax, extXMajTickLen, intXMajTickLen, xFirstMajTick, xMajTickStep);
+        DrawVTicks(xMin, extYMajTickLen, intYMajTickLen, yFirstMajTick, yMajTickStep);
+        DrawVTicks(xMax, intYMajTickLen, extYMajTickLen, yFirstMajTick, yMajTickStep);
+    }
+    
+    // Les ticks mineurs
+  
+    if (flags & kMinTicks) {
+        DrawHTicks(yMin, intXMinTickLen, extXMinTickLen, xFirstMinTick, xMinTickStep);
+        DrawHTicks(yMax, extXMinTickLen, intXMinTickLen, xFirstMinTick, xMinTickStep);
+        DrawVTicks(xMin, extYMinTickLen, intYMinTickLen, yFirstMinTick, yMinTickStep);
+        DrawVTicks(xMax, intYMinTickLen, extYMinTickLen, yFirstMinTick, yMinTickStep);
+    }
+
+
+    // Les labels
+    
+    if (flags & kLabels) {
+      if (!aYdir) {
+        DrawHLabels(yMin-xMajTickLen*8, xFirstMajTick, xMajTickStep,0);
+        DrawHLabels(yMax+xMajTickLen*2, xFirstMajTick, xMajTickStep,0);
+      }
+      else {
+        DrawHLabels(yMin-xMajTickLen*2, xFirstMajTick, xMajTickStep,0);
+        DrawHLabels(yMax+xMajTickLen*8, xFirstMajTick, xMajTickStep,0);
+      }
+      if (!aXdir) {
+        DrawVLabels(xMin-yMajTickLen*2, yFirstMajTick, yMajTickStep,1);
+        DrawVLabels(xMax+yMajTickLen*2, yFirstMajTick, yMajTickStep,-1);
+      }
+      else {
+        DrawVLabels(xMin-yMajTickLen*2, yFirstMajTick, yMajTickStep,-1);
+        DrawVLabels(xMax+yMajTickLen*2, yFirstMajTick, yMajTickStep,1);
+      }
+    }
+  }
+  Clip();
+}
+
+  
+
+void
+PIScDrawWdg::AddDrawer(PIScDrawer* d)
+{
+  mDrawers.push_back(d);
+  d->AttachTo(this);
+}
+
+void
+PIScDrawWdg::RemoveDrawer(PIScDrawer* d)
+{
+  if (padsup)  return;
+  mDrawers.remove(d);
+  d->mDrawWdg = NULL;
+}
+
+void
+PIScDrawWdg::DeleteDrawers()
+{
+  padsup = true;
+  for(list<PIScDrawer*>::iterator i = mDrawers.begin(); i != mDrawers.end(); i++)
+    delete *i;
+  mDrawers.erase(mDrawers.begin(),mDrawers.end());
+  padsup = false;
+}
+
+void
+PIScDrawWdg::CallDrawer(PIScDrawer* d)
+{
+  d->Draw();
+}
+
+void
+PIScDrawWdg::CallDrawers()
+{
+  for_each(mDrawers.begin(), mDrawers.end(), CallDrawer);
+}
+
+void
+PIScDrawWdg::SetAxesFlags(int flags)
+{
+  axesFlags = flags;
+  if (axesFlags & (kIntTicks | kExtTicks | kMajTicks | kMinTicks))
+    axesFlags |= kTicks;
+  if ((axesFlags & (kTicks | kIntTicks | kExtTicks)) == kTicks)
+    axesFlags |= kIntTicks | kExtTicks;
+  if ((axesFlags & (kTicks | kMajTicks | kMinTicks)) == kTicks)
+    axesFlags |= kMajTicks;
+}
+void
+PIScDrawWdg::SetTextWin(PILabel * tw, bool trw, int tx, int ty)
+{
+mTxw = tw;
+if (trw)
+  {
+  if (mTrW)  mTrW->SetSize(tx, ty);
+  else
+    {
+    mTrW = new PIWindow(this, "Point", PIWK_transient, tx, ty, 0, 0);
+    mTrW->SetAutoDelChilds(true);
+    mTrlb = new PILabel(mTrW, "PixVal", tx, ty, 0, 0);
+    mTrlb->SetBinding(PIBK_fixed,PIBK_fixed, PIBK_fixed,PIBK_fixed);
+    }
+  }
+else
+  if (mTrW) { delete mTrW; mTrW = NULL;  mTrlb = NULL; }
+
+return;
+}
+
+void
+PIScDrawWdg::Draw()
+{
+  EraseWindow();
+  DrawAxes();
+  CallDrawers();
+  DrawSelf();
+}
+
+
+
+// Gestion affichage coordonnees du point 
+void
+PIScDrawWdg::But1Press(int x, int y)
+{
+  if (UpdateText(x, y))
+     {
+     if (mTrW)
+       { 
+       int tpx, tpy;
+       GetScreenPos(tpx, tpy);       
+       tpy -= (mTrW->YSize()+5);
+       if (tpy < 0)  tpy = 0;
+       mTrW->SetPos(tpx, tpy);
+       mTrW->Show();
+       }
+     SelPointerShape(PI_CrossPointer);
+     }
+  Send(Msg(), PIMsg_Active);
+
+}
+
+void
+PIScDrawWdg::Ptr1Move(int x, int y)
+{
+  UpdateText(x, y);
+}
+
+void
+PIScDrawWdg::But1Release(int x, int y)
+{
+  if (UpdateText(x, y)) 
+    SelPointerShape(PI_ArrowPointer);
+  if (mTrW)  mTrW->Hide();
+}
+
+bool
+PIScDrawWdg::UpdateText(int xp, int yp)
+{
+
+  double dx, dy;
+  Local2Sc(xp, yp, dx, dy); 
+  mPPos[0] = dx;  mPPos[1] = dy; 
+  if ((mTxw == NULL) && (mTrlb == NULL)) return(false);
+
+  char buff[128];
+  sprintf(buff, "X= %g  Y= %g",  dx, dy);
+  if (mTxw)
+    mTxw->SetLabel((string)buff);
+  if (mTrlb)
+    mTrlb->SetLabel((string)buff);
+  return(true);
+
+}
+
+// Gestion du zoom
+void
+PIScDrawWdg::But2Press(int x, int y)
+{
+  xEndDrag = xBegDrag = x;
+  yEndDrag = yBegDrag = y;
+  cForCol = GetForeground();
+  cGOmod  = GetGOMode();
+  cPointer = GetPointerShape();
+  cLatt = GetLineAtt();
+  SelPointerShape(PI_CrossPointer);
+  SelForeground(PI_Magenta);
+  SelGOMode(PI_GOXOR);
+  SelLine(PI_ThinLine);
+  Send(Msg(), PIMsg_Active);
+}
+
+void
+PIScDrawWdg::But2Release(int /*x*/, int /*y*/)
+{
+
+  DrawBox(xBegDrag, yBegDrag, xEndDrag-xBegDrag, yEndDrag-yBegDrag);
+
+  SelForeground(cForCol);
+  SelGOMode(cGOmod);
+  SelPointerShape(cPointer); 
+  SelLine(cLatt); 
+  
+  if (xBegDrag == xEndDrag || yBegDrag == yEndDrag)
+    SetLimits(xMinS, xMaxS, yMinS, yMaxS, aXdir, aYdir );
+  else {
+    double xl,yl,xh,yh;
+    Local2Sc(xBegDrag, yBegDrag, xl, yl);
+    Local2Sc(xEndDrag, yEndDrag, xh, yh);
+    if (xl > xh) swap(xl, xh);
+    if (yl > yh) swap(yl, yh);
+    SetLimits(xl,xh,yl,yh, aXdir, aYdir, true);
+  }
+  
+  Refresh();
+}
+
+void
+PIScDrawWdg::Ptr2Move(int x, int y)
+{
+  DrawBox(xBegDrag, yBegDrag, xEndDrag-xBegDrag, yEndDrag-yBegDrag);
+  xEndDrag = x;
+  yEndDrag = y;
+  DrawBox(xBegDrag, yBegDrag, xEndDrag-xBegDrag, yEndDrag-yBegDrag);
+}
+
+//================================================================
+// PIScDrawer
+//================================================================
+
+PIScDrawer::PIScDrawer()
+: mDrawWdg(NULL)
+{}
+
+PIScDrawer::~PIScDrawer()
+{
+  if (mDrawWdg)
+    mDrawWdg->RemoveDrawer(this);
+}
+
+void
+PIScDrawer::AttachTo(PIScDrawWdg* wdg)
+{
+  if (mDrawWdg)
+    mDrawWdg->RemoveDrawer(this);
+  mDrawWdg = wdg;
+}
+
+
+
+//================================================================
+// PIScFuncDrawer
+//================================================================
+
+PIScFuncDrawer::PIScFuncDrawer(PIScFuncDrawer::FUNC f)
+: mFunc(f)
+{}
+
+PIScFuncDrawer::~PIScFuncDrawer()
+{
+}
+
+void
+PIScFuncDrawer::Draw()
+{
+  if (!mDrawWdg) return;
+  double xMax = mDrawWdg->XMax();
+  double xMin = mDrawWdg->XMin();
+  double yMax = mDrawWdg->YMax();
+  double yMin = mDrawWdg->YMin();
+  double xStep = (xMax - xMin)/100;
+  double xOld = xMin;
+  double yOld = mFunc(xMin);
+  for (double x = xMin+xStep; x<xMax; x+=xStep) {
+    double y = mFunc(x);
+    if (y>yMin && yOld>yMin && 
+        y<yMax && yOld<yMax) 
+           mDrawWdg->ScDrawLine(xOld, yOld, x, y);
+    xOld = x;
+    yOld = y;
+  }
+}
+
+//================================================================
+// PIScGFFDrawer
+//================================================================
+
+PIScGFFDrawer::PIScGFFDrawer(GeneralFunction* f)
+: mFunc(f), mNParms(f->NPar()), mParms(new double[mNParms])
+{
+  ASSERT(f->NVar() == 1);
+}
+
+PIScGFFDrawer::~PIScGFFDrawer()
+{
+  delete[] mParms;
+}
+
+void
+PIScGFFDrawer::SetParms(double const* p)
+{
+  for (int i=0; i<mNParms; i++)
+    mParms[i] = p[i];
+}
+
+
+void
+PIScGFFDrawer::Draw()
+{
+  if (!mDrawWdg) return;
+  double xMax = mDrawWdg->XMax();
+  double xMin = mDrawWdg->XMin();
+  double yMax = mDrawWdg->YMax();
+  double yMin = mDrawWdg->YMin();
+  double xStep = (xMax - xMin)/100;
+  double xOld = xMin;
+  double yOld = 0;
+//  double yOld = f->Value(&xMin, mParms);
+  for (double x = xMin+xStep; x<xMax; x+=xStep) {
+   double y = 0; // $CHECK$
+//    double y = f->Value(&x, mParms);
+    if (y>yMin && yOld>yMin && 
+        y<yMax && yOld<yMax) 
+           mDrawWdg->ScDrawLine(xOld, yOld, x, y);
+    xOld = x;
+    yOld = y;
+  }
+}
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/piscdrawwdg.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piscdrawwdg.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piscdrawwdg.h	(revision 50)
@@ -0,0 +1,172 @@
+#ifndef PISCDRAWWDG_H
+#define PISCDRAWWDG_H
+
+
+#include "pisysdep.h"
+#include PIBWDG_H
+#include PISTDWDG_H
+#include PIWIN_H
+
+#include <list>
+
+  enum {
+    kStdAxes     = 0x0001,
+    kBoxAxes     = 0x0002,
+    kTicks       = 0x0004,
+    kIntTicks    = 0x0010,
+    kExtTicks    = 0x0020,
+    kMajTicks    = 0x0040,
+    kMinTicks    = 0x0080,
+    kLabels      = 0x1000,
+    kAxesDflt    = kStdAxes | kTicks | kLabels
+  };
+
+
+class PIScDrawWdg : public PIBaseWdg {
+public:
+                     PIScDrawWdg(PIContainerGen *par, char *nom,
+                                   int sx=10, int sy=10, int px=0, int py=0);
+  virtual           ~PIScDrawWdg();
+
+  virtual void       SetLimits(double xmin, double xmax, double ymin, double ymax, 
+                               bool axrl=false, bool ayud=false, bool tmp=false);
+  
+  virtual void       ScDrawString(double x, double y, char* s, int pos = 0);
+  virtual void       ScDrawLine(double x1, double y1, double x2, double y2);
+  virtual void       ScDrawBox(double x0, double y0, double dx, double dy);
+  virtual void       ScDrawFBox(double x0, double y0, double dx, double dy);
+  virtual void       ScDrawCircle(double x0, double y0, double r);
+  virtual void       ScDrawFCircle(double x0, double y0, double r);
+  virtual void       ScDrawPolygon(double *x, double *y, int n);  
+  virtual void       ScDrawFPolygon(double *x, double *y, int n);
+  virtual void       ScDrawMarker(double x0, double y0);
+  virtual void       ScDrawMarkers(double *x0, double *y0, int n);
+
+  virtual double     ScStringWidth(char const*);
+
+  virtual void       ScSelFontSz(double size, PIFontAtt att=PI_RomanFont); 
+  virtual void       ScSelMarker(double size=0, PIMarker mrk=PI_DotMarker); 
+
+  virtual void       DrawAxes(int flags = -1);
+  virtual void       DrawSelf() {}
+  
+  virtual void       Resize();
+  
+  virtual void       CalcTicks();
+  virtual void       CalcScale();
+  
+  virtual void       Sc2Local(double x, double y, int& xpix, int& ypix);
+  virtual void       Local2Sc(int xpix, int ypix, double& x, double& y);
+  virtual void       DSc2Local(double dx, double dy, int& dxpix, int& dypix);
+  
+  virtual void       Draw();
+  
+  friend class PIScDrawer;
+  virtual void       AddDrawer(PIScDrawer*);   // Ajoute un drawer
+  virtual void       RemoveDrawer(PIScDrawer*);  // Ote un drawer sans le detruire
+  virtual void       DeleteDrawers();            // Ote et detruit tous les drawers
+  static  void       CallDrawer(PIScDrawer*);
+  virtual void       CallDrawers();
+  virtual void       SetAxesFlags(int flags=kAxesDflt);
+  
+  void               SetTextWin(PILabel * tw, bool trw=true, int tx=200, int ty=30);
+
+  double XMin() const {return xMin;}
+  double XMax() const {return xMax;}
+  double YMin() const {return yMin;}
+  double YMax() const {return yMax;}
+  double XPPos() const { return mPPos[0]; }
+  double YPPos() const { return mPPos[1]; }
+  int    LimitsFixed() const {return limitsFixed;}
+  void   FreeLimits() {limitsFixed = 0;}
+  void   NoClip() {clip = false;}
+  void   Clip() {clip = true;}
+    
+
+  virtual void       But1Press(int x, int y);
+  virtual void       But1Release(int x, int y);
+  virtual void       Ptr1Move(int x, int y);
+
+  virtual void       But2Press(int x, int y);
+  virtual void       But2Release(int x, int y);
+  virtual void       Ptr2Move(int x, int y);
+  
+protected:
+  double xMin, xMax, yMin, yMax; // Valeurs en unites user
+  double xMinS, xMaxS, yMinS, yMaxS; // Sauvegarde pour zoom
+  double xOrg, yOrg;             // Position en pixels de (0.0, 0.0)
+  double xScale, yScale;         // Pixels par unites graphiques
+  bool   aXdir, aYdir;           // Sens des axes horiz, vertical 
+  double mPPos[2];               // Position click souris X,Y
+  double xFirstMajTick, xFirstMinTick;
+  double yFirstMajTick, yFirstMinTick;
+  double xMajTickStep, xMinTickStep;
+  double yMajTickStep, yMinTickStep;
+  double xMajTickLen,  xMinTickLen;
+  double yMajTickLen,  yMinTickLen;
+  
+  int limitsFixed;
+  int axesFlags;
+  list<PIScDrawer*>   mDrawers;
+  
+  int xBegDrag, yBegDrag;
+  int xEndDrag, yEndDrag;
+  PIColors cForCol;
+  PIGOMode cGOmod;  
+  PIPointer cPointer;
+  PILineAtt cLatt;
+  PILabel * mTxw;  
+  PILabel * mTrlb;
+  PIWindow * mTrW;
+  bool clip;
+  bool padsup;
+
+
+private:
+  void DrawHTicks(double y, double tickUp, double tickDown, double xBeg, double xStep);
+  void DrawVTicks(double x, double tickLeft, double tickRight, double yBeg, double yStep);
+  void DrawHLabels(double y, double xBeg, double xStep, int just=0);
+  void DrawVLabels(double x, double yBeg, double yStep, int just=0);
+  
+  bool  UpdateText(int xp, int yp);
+};
+
+class PIScDrawer {
+public:
+                     PIScDrawer();
+  virtual           ~PIScDrawer();
+
+  virtual void       Draw() = 0;
+protected:
+  friend class       PIScDrawWdg;
+  virtual void       AttachTo(PIScDrawWdg*);
+  PIScDrawWdg*       mDrawWdg;
+};
+
+class PIScFuncDrawer : public PIScDrawer {
+public:
+  typedef double(*FUNC)(double);
+                     PIScFuncDrawer(FUNC);
+  virtual           ~PIScFuncDrawer();
+  
+  virtual void       Draw();
+protected:
+  FUNC               mFunc;
+};
+
+class GeneralFunction;
+class PIScGFFDrawer : public PIScDrawer {
+public:
+                     PIScGFFDrawer(GeneralFunction*);
+  virtual           ~PIScGFFDrawer();
+  
+  virtual void       Draw();
+  virtual void       SetParms(double const*);
+protected:
+  GeneralFunction*    mFunc;
+  int                 mNParms;
+  double*             mParms;
+};
+
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/pistdwdggen.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pistdwdggen.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pistdwdggen.cc	(revision 50)
@@ -0,0 +1,78 @@
+#include "pistdwdggen.h"
+
+
+/************* PILabelGen ************/
+
+PILabelGen::PILabelGen(PIContainerGen *par, char *nom,
+                         int sx, int sy, int px, int py)
+: PIWdg(par, nom, sx, sy, px, py)
+{}
+
+PILabelGen::~PILabelGen()
+{}
+
+/************* PIButtonGen ************/
+
+PIButtonGen::PIButtonGen(PIContainerGen *par, char *nom, PIMessage msg,
+                         int sx, int sy, int px, int py, PIBtnSign bsgn)
+: PIWdg(par, nom, sx, sy, px, py)
+{
+SetMsg(msg);
+mSgn = bsgn;
+}
+
+PIButtonGen::~PIButtonGen()
+{}
+
+
+
+/************* PITextGen ************/
+
+PITextGen::PITextGen(PIContainerGen *par, char *nom,
+                         int sx, int sy, int px, int py)
+: PIWdg(par, nom, sx, sy, px, py)
+{}
+
+PITextGen::~PITextGen()
+{}
+
+
+
+
+/************* PICheckBoxGen ************/
+
+PICheckBoxGen::PICheckBoxGen(PIContainerGen *par, char *nom, PIMessage msg,
+                         int sx, int sy, int px, int py)
+: PIWdg(par, nom, sx, sy, px, py)
+{
+SetMsg(msg);
+}
+
+PICheckBoxGen::~PICheckBoxGen()
+{}
+
+
+/************* PIScaleGen ************/
+
+PIScaleGen::PIScaleGen(PIContainerGen *par, char *nom, PIMessage msg, 
+                       bool /*horiz*/, int sx, int sy, int px, int py)
+: PIWdg(par, nom, sx, sy, px, py) 
+{
+SetMsg(msg);
+}
+
+PIScaleGen::~PIScaleGen()
+{}
+
+/************* PIScrollBarGen ************/
+
+PIScrollBarGen::PIScrollBarGen(PIContainerGen *par, char *nom, PIMessage msg, 
+                       bool /*horiz*/, int sx, int sy, int px, int py)
+: PIWdg(par, nom, sx, sy, px, py) 
+{
+SetMsg(msg);
+}
+
+PIScrollBarGen::~PIScrollBarGen()
+{}
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/pistdwdggen.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pistdwdggen.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pistdwdggen.h	(revision 50)
@@ -0,0 +1,125 @@
+#ifndef PISTDWDGGEN_H_SEEN
+#define PISTDWDGGEN_H_SEEN
+
+#include <string>
+#include "pisysdep.h"
+#include PIWDG_H
+
+class PILabelGen : public PIWdg {
+public:
+  enum {ClassId = 1001};
+
+                     PILabelGen(PIContainerGen* par, char* nom,
+                                 int sx=10, int sy=10, int px=0, int py=0);
+  virtual            ~PILabelGen();
+
+  virtual long       kind() {return ClassId; }
+};
+
+//  Les differents types de boutons avec un signe dessus ... 
+enum PIBtnSign {  PIBtn_Label=0, PIBtn_ArrowUp=1, PIBtn_ArrowDown=2,  
+                                 PIBtn_ArrowLeft=3, PIBtn_ArrowRight=4 };
+
+class PIButtonGen : public PIWdg
+{
+public:
+  enum {ClassId = 1010};
+
+                     PIButtonGen(PIContainerGen* par, char* nom, 
+                                 PIMessage msg = PIMsg_Click,
+                                 int sx=10, int sy=10, int px=0, int py=0,
+                                 PIBtnSign bsgn = PIBtn_Label);
+  virtual            ~PIButtonGen();
+
+  virtual long       kind() {return ClassId; }
+  virtual void       ActivatePress(bool acp=false)=0;
+
+protected:
+  PIBtnSign mSgn;
+};
+
+
+class PITextGen : public PIWdg
+{
+public:
+
+  enum {ClassId = 1020};
+
+  		     PITextGen(PIContainerGen* par, char* nom,
+         		       int sx=10, int sy=10, int px=0, int py=0);
+  virtual	     ~PITextGen();
+  virtual void       SetText(string const&) = 0;
+  virtual string     GetText() const = 0;
+
+  virtual void       SetMutiLineMode(bool mlm=false) = 0;
+  virtual void       SetTextEditable(bool te=true) = 0;
+
+  virtual long       kind() {return ClassId; }
+};
+
+
+
+class PICheckBoxGen : public PIWdg
+{
+public:
+
+  enum {ClassId = 1030};
+
+                     PICheckBoxGen(PIContainerGen* par, char* nom, 
+                                  PIMessage msg = PIMsg_Click,
+                                  int sx=10, int sy=10, int px=0, int py=0);
+  virtual            ~PICheckBoxGen()=0;
+  virtual void       SetState(bool st=false)=0;
+  virtual bool       GetState()=0;
+  
+  virtual long       kind() {return ClassId; }
+
+protected:
+
+};
+
+
+class PIScaleGen : public PIWdg
+{
+public:
+  enum {ClassId = 1040};
+
+                     PIScaleGen(PIContainerGen* par, char* nom, 
+                                PIMessage msg = PIMsg_DataChanged, bool horiz=true,
+                                int sx=100, int sy=10, int px=0, int py=0);
+  virtual            ~PIScaleGen();
+
+  virtual void       SetMinMax(int min, int max) = 0;
+  virtual void       SetValue(int val) = 0;
+  virtual int        GetValue() = 0; 
+
+  virtual long       kind() {return ClassId; }
+
+protected:
+
+};
+
+class PIScrollBarGen : public PIWdg
+{
+public:
+  enum {ClassId = 1050};
+
+                     PIScrollBarGen(PIContainerGen* par, char* nom, 
+                                    PIMessage msg=PIMsg_DataChanged, bool vert=true,
+                                    int sx=10, int sy=100, int px=0, int py=0);
+  virtual            ~PIScrollBarGen();
+
+  virtual void       ActivateDrag(bool acd=false) = 0;
+  virtual void       SetMinMax(int min, int max) = 0;
+  virtual void       SetValue(int val) = 0;
+  virtual int        GetValue() = 0; 
+  virtual void       SetSize(int sz) = 0;
+  virtual int        GetSize() = 0;
+
+  virtual long       kind() {return ClassId; }
+
+protected:
+
+};
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/pistdwdgmac.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pistdwdgmac.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pistdwdgmac.cc	(revision 50)
@@ -0,0 +1,214 @@
+#include "pistdwdgmac.h"
+#include <LString.h>
+#include <PP_Messages.h>
+
+/************* PILabelMac ************/
+#include <LCaption.h>
+
+PILabelMac::PILabelMac(PIContainerGen *par, char *nom,
+                         int sx, int sy, int px, int py)
+: PILabelGen(par, nom, sx, sy, px, py)
+{
+  delete mPane;
+  LStr255 titre(nom);
+  mPane = new LCaption(mPaneInfo, titre, 0);
+}
+
+PILabelMac::~PILabelMac()
+{}
+
+
+/************* PIButtonMac ************/
+#include <LStdControl.h>
+
+PIButtonMac::PIButtonMac(PIContainerGen *par, char *nom, PIMessage msg,
+                         int sx, int sy, int px, int py, PIBtnSign bsgn)
+: PIButtonGen(par, nom, msg, sx, sy, px, py, bsgn)
+{
+  delete mPane;
+  LStr255 titre(nom);
+  mPane = new LStdButton(mPaneInfo, msg_Click, 0, titre);
+  ((LStdButton*)mPane)->AddListener(this);
+}
+
+PIButtonMac::~PIButtonMac()
+{}
+
+void
+PIButtonMac::ListenToMessage(MessageT inMessage, void *)
+{
+  if (inMessage == msg_Click)
+    Send(myMsg, PIMsg_Press);
+}
+
+
+/************* PITextMac ************/
+#include <LEditField.h>
+
+PITextMac::PITextMac(PIContainerGen *par, char *nom,
+                         int sx, int sy, int px, int py)
+: PITextGen(par, nom, sx, sy, px, py)
+{
+  delete mPane;
+  LStr255 titre(nom);
+  mPane = new LEditField(mPaneInfo, titre, 0, 255, true, true, NULL, LCommander::GetTopCommander());
+}
+
+PITextMac::~PITextMac()
+{}
+
+void
+PITextMac::SetText(string const& s)
+{
+  SetLabel(s);
+}
+
+string
+PITextMac::GetText() const
+{
+  Str255 desc;
+  mPane->GetDescriptor(desc);
+  p2cstr(desc);
+  return (char*) desc;
+}
+
+/* --Methode-- */
+void PITextMac::SetMutiLineMode(bool mlm)
+{
+return;
+}
+
+/* --Methode-- */
+void PITextMac::SetTextEditable(bool te)
+{
+if (te)
+  { mPane->Enable(); }
+else
+  { mPane->Disable(); }
+return;
+}
+
+/************* PIScaleMac ************/
+static ControlActionUPP	sSBarAction = nil;
+
+
+PIScaleMac::PIScaleMac(PIContainerGen* par, char* nom, PIMessage msg,
+                       bool horiz, int sx, int sy, int px, int py)
+: PIScaleGen(par, nom, msg, horiz, sx, sy, px, py)
+{
+  delete mPane;
+  LStr255 titre(nom);
+  mPane = new LStdControl(mPaneInfo, msg_Click, 1, 1, 10,
+						  scrollBarProc, 0, titre, (Int32) this);
+  ((LStdControl*)mPane)->AddListener(this);
+  
+  if (sSBarAction == nil) {	// Allocate UPP if necessary
+	sSBarAction = NewControlActionProc((ProcPtr) SBarAction);
+  }
+  ((LStdControl*)mPane)->SetActionProc(sSBarAction);
+}
+
+PIScaleMac::~PIScaleMac()
+{}
+
+void
+PIScaleMac::ListenToMessage(MessageT inMessage, void *)
+{
+  if (inMessage == msg_ThumbDragged)
+    Send(myMsg, PIMsg_DataChanged);
+}
+
+void
+PIScaleMac::SetMinMax(int min, int max)
+{
+  ((LStdControl*)mPane)->SetMinValue(min);
+  ((LStdControl*)mPane)->SetMaxValue(max);
+}
+
+void
+PIScaleMac::SetValue(int val)
+{
+  ((LStdControl*)mPane)->SetValue(val);
+}
+
+int
+PIScaleMac::GetValue()
+{
+  return ((LStdControl*)mPane)->GetValue();
+}
+
+pascal void
+PIScaleMac::SBarAction(
+	ControlHandle	inMacControl,
+	Int16			inPart)
+{
+	PIScaleMac		*theScroller =
+							(PIScaleMac *) GetControlReference(inMacControl);
+	theScroller->HandleScroll(inPart);
+}
+
+void
+PIScaleMac::HandleScroll(
+	const Int16		inPart)
+{
+    int delta;
+	switch (inPart) {				// Determine how much to scroll
+	
+		case kControlUpButtonPart:	// Scroll left one unit
+			delta = -1;
+			break;
+			
+		case kControlDownButtonPart:	// Scroll right one unit
+			delta = 1;
+			break;
+			
+		case kControlPageUpPart:		// Scroll left by Frame width
+										//   less one unit of overlap
+			delta = -10;
+			break;
+			
+		case kControlPageDownPart:		// Scroll right by Frame width
+										//   less one unit of overlap
+			delta = 10;
+			break;
+	}
+	
+	if (delta != 0) {
+	    SetValue(GetValue()+delta);
+	}
+}
+
+/************* PICheckBoxMac ************/
+#include <LStdControl.h>
+
+PICheckBoxMac::PICheckBoxMac(PIContainerGen *par, char *nom, PIMessage msg,
+                         int sx, int sy, int px, int py)
+: PICheckBoxGen(par, nom, msg, sx, sy, px, py)
+{
+  delete mPane;
+  LStr255 titre(nom);
+  mPane = new LStdCheckBox(mPaneInfo, msg_Click, 0, 0, titre);
+  ((LStdCheckBox*)mPane)->AddListener(this);
+}
+
+PICheckBoxMac::~PICheckBoxMac()
+{}
+
+void
+PICheckBoxMac::ListenToMessage(MessageT inMessage, void *)
+{
+  if (inMessage == msg_Click)
+    Send(myMsg, PIMsg_DataChanged);
+}
+
+void
+PICheckBoxMac::SetState(bool st)
+{
+  ((LStdCheckBox*)mPane)->SetValue(st ? 1 : 0);
+}
+ 
+bool
+PICheckBoxMac::GetState()
+{
+  return ((LStdCheckBox*)mPane)->GetValue();
+}
Index: /tags/V_Saclay_110697/SophyaPI/PI/pistdwdgmac.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pistdwdgmac.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pistdwdgmac.h	(revision 50)
@@ -0,0 +1,79 @@
+#ifndef PISTDWDGMAC_H_SEEN
+#define PISTDWDGMAC_H_SEEN
+
+#include "pistdwdggen.h"
+
+
+class PILabelMac : public PILabelGen
+{
+public:
+                     PILabelMac(PIContainerGen *par, char *nom,
+                                 int sx=10, int sy=10, int px=0, int py=0);
+  virtual           ~PILabelMac();
+};
+
+class PIButtonMac : public PIButtonGen
+{
+public:
+                     PIButtonMac(PIContainerGen *par, char *nom, PIMessage msg = PIMsg_Click,
+                                 int sx=10, int sy=10, int px=0, int py=0,
+                                 PIBtnSign bsgn = PIBtn_Label);
+  virtual           ~PIButtonMac();
+  virtual void	     ListenToMessage(MessageT inMessage, void *ioParam);
+  virtual void       ActivatePress(bool=false) {}
+};
+
+class PITextMac : public PITextGen
+{
+public:
+                     PITextMac(PIContainerGen *par, char *nom,
+                               int sx=10, int sy=10, int px=0, int py=0);
+  virtual           ~PITextMac();
+
+  virtual void       SetMutiLineMode(bool mlm=false);
+  virtual void       SetTextEditable(bool te=true);
+
+  virtual void       SetText(string const&);
+  virtual string     GetText() const;
+};
+
+class PIScaleMac : public PIScaleGen
+{
+public:
+                     PIScaleMac(PIContainerGen* par, char* nom, 
+                                PIMessage msg=PIMsg_DataChanged, bool horiz=true,
+                                int sx=100, int sy=10, int px=0, int py=0);
+                    ~PIScaleMac();
+
+  virtual void       SetMinMax(int min, int max);
+  virtual void       SetValue(int val);
+  virtual int        GetValue(); 
+  virtual void	     ListenToMessage(MessageT inMessage, void *ioParam);
+  virtual void	     HandleScroll(const Int16 inPart);
+  
+protected:
+  static pascal void SBarAction(ControlHandle inMacControl,
+								Int16 inPart);
+};
+
+class PICheckBoxMac : public PICheckBoxGen
+{
+public:
+                     PICheckBoxMac(PIContainerGen* par, char* nom, 
+                                   PIMessage msg = PIMsg_Click,
+                                   int sx=10, int sy=10, int px=0, int py=0);
+  virtual           ~PICheckBoxMac();
+  virtual void	     ListenToMessage(MessageT inMessage, void *ioParam);
+  virtual void       SetState(bool st=false);
+  virtual bool       GetState();
+};
+
+
+ 
+typedef PILabelMac   PILabel;
+typedef PIButtonMac  PIButton;
+typedef PITextMac    PIText;
+typedef PIScaleMac   PIScale;
+typedef PICheckBoxMac PICheckBox;
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/pistdwdgx.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pistdwdgx.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pistdwdgx.cc	(revision 50)
@@ -0,0 +1,548 @@
+#include<stdlib.h>
+#include<string.h>
+
+#include "pisysdep.h"
+#include PISTDWDG_H
+
+/************* PILabelX ************/
+#include <Xm/Label.h>
+
+
+/* --Methode-- */
+PILabelX::PILabelX(PIContainerGen *par, char *nom,
+                   int sx, int sy, int px, int py)
+: PILabelGen(par, nom, sx, sy, px, py)
+{
+Arg warg[2];
+
+CreateXtWdg(nom, xmLabelWidgetClass, NULL, sx, sy, px, py);
+SetBorderWidth(0);
+XtSetArg(warg[0], XmNrecomputeSize, FALSE);  
+XtSetValues(XtWdg(), warg, 1);
+Manage();
+}
+
+/* --Methode-- */
+PILabelX::~PILabelX()
+{}
+
+
+/************* PIButtonX ************/
+#include <Xm/PushB.h>
+#include <Xm/ArrowB.h>
+
+// Fonctions privees (CallBack)
+static void button_action(Widget w, XtPointer *usd, XtPointer *calld);
+static void button_press(Widget w, XtPointer *usd, XmAnyCallbackStruct *calld);
+
+/* Nouvelle-Fonction */
+void  button_action(Widget , XtPointer *usd, XtPointer *)
+{
+PIButtonX *pib;
+pib = (PIButtonX *) usd ;
+pib->Send(pib->Msg(),PIMsg_Click,NULL);
+return;
+}
+
+/* Nouvelle-Fonction */
+void  button_press(Widget, XtPointer *usd, XmAnyCallbackStruct *calld)
+{
+PIButtonX *pib;
+pib = (PIButtonX *) usd ;
+pib->Send(pib->Msg(),PIMsg_Press,NULL);
+pib->myevt = *(calld->event);
+pib->myevt.type = pib->myevt.xbutton.type = ButtonRelease;
+pib->myevt.xbutton.serial += 10;
+
+return;
+}
+
+
+/* --Methode-- */
+PIButtonX::PIButtonX(PIContainerGen *par, char *nom, PIMessage msg, 
+                     int sx, int sy, int px, int py, PIBtnSign bsgn)
+: PIButtonGen(par, nom, msg, sx, sy, px, py, bsgn)
+{
+
+Arg  warg[3];
+int n = 0;
+
+XtSetArg(warg[n],XmNhighlightThickness, 0);  n++;
+XtSetArg(warg[n], XmNrecomputeSize, FALSE);  n++;
+
+if (bsgn == PIBtn_Label)
+  CreateXtWdg(nom, xmPushButtonWidgetClass, NULL, sx, sy, px, py);
+else
+  {
+  CreateXtWdg(nom, xmArrowButtonWidgetClass, NULL, sx, sy, px, py);
+  switch (bsgn)
+    {
+    case PIBtn_ArrowUp :
+      XtSetArg(warg[n], XmNarrowDirection, XmARROW_UP);  n++;
+      break;
+    case PIBtn_ArrowDown :
+      XtSetArg(warg[n], XmNarrowDirection, XmARROW_DOWN);  n++;
+      break;
+    case PIBtn_ArrowLeft :
+      XtSetArg(warg[n], XmNarrowDirection, XmARROW_LEFT);  n++;
+      break;
+    case PIBtn_ArrowRight :
+      XtSetArg(warg[n], XmNarrowDirection, XmARROW_RIGHT);  n++;
+      break;
+    }
+  }
+
+XtSetValues(XtWdg(), warg, n);
+XtAddCallback(XtWdg(), XmNactivateCallback, 
+              (XtCallbackProc)button_action, (XtPointer)this);
+
+mAcP = false;
+SetBorderWidth(0);
+Manage();
+}
+
+/* --Methode-- */
+PIButtonX::~PIButtonX()
+{}
+
+/* --Methode-- */
+void PIButtonX::ActivatePress(bool acp)
+{
+if (mAcP == acp)  return; 
+    
+if (mAcP)
+  XtRemoveCallback(XtWdg(), XmNarmCallback, 
+                   (XtCallbackProc)button_press, (XtPointer)this);
+else 
+  XtAddCallback(XtWdg(), XmNarmCallback, 
+                (XtCallbackProc)button_press, (XtPointer)this);
+mAcP = acp;
+return;
+}       
+
+/* --Methode-- */
+void PIButtonX::ReleaseButton()
+{
+XPutBackEvent(myevt.xbutton.display, &myevt);
+return;
+}
+
+
+/************* PITextX ************/
+#include <Xm/Text.h>
+
+/* --Methode-- */
+PITextX::PITextX(PIContainerGen *par, char *nom,
+                 int sx, int sy, int px, int py)
+: PITextGen(par, nom, sx, sy, px, py)
+{
+CreateXtWdg(nom, xmTextWidgetClass, NULL, sx, sy, px, py);
+SetMutiLineMode(false);
+SetTextEditable(true);
+Manage();
+}
+
+/* --Methode-- */
+PITextX::~PITextX()
+{}
+
+/* --Methode-- */
+void PITextX::SetText(string const& s)
+{
+XmTextSetString(XtWdg(), (char *)s.c_str());
+return;
+}
+
+/* --Methode-- */
+string PITextX::GetText() const
+{
+char *txtb;
+txtb = XmTextGetString(XtWdg());
+string s(txtb);
+XtFree(txtb);
+return(s);
+}
+
+/* --Methode-- */
+void PITextX::SetMutiLineMode(bool mlm)
+{
+Arg  warg[2];
+int n = 0;
+
+if (mlm)
+  { XtSetArg(warg[n],XmNeditMode, XmMULTI_LINE_EDIT);  n++; }
+else
+  { XtSetArg(warg[n],XmNeditMode, XmSINGLE_LINE_EDIT);  n++; }
+
+XtSetValues(XtWdg(), warg, n);
+return;
+}
+
+/* --Methode-- */
+void PITextX::SetTextEditable(bool te)
+{
+Arg  warg[2];
+int n = 0;
+
+if (te)
+  { XtSetArg(warg[n],XmNeditable, TRUE);  n++; }
+else
+  { XtSetArg(warg[n],XmNeditable, FALSE);  n++; }
+
+XtSetValues(XtWdg(), warg, n);
+return;
+}
+
+// Fonction privee (CallBack)
+static void text_action(Widget w, XtPointer *usd, XtPointer *calld);
+
+void  text_action(Widget, XtPointer *usd, XtPointer *)
+{
+PIText *pit;
+
+pit = (PIText *) usd ;
+pit->Send(pit->Msg(), PIMsg_DataChanged, NULL);
+}
+
+
+/* --Methode-- */
+void PITextX::SetMsg(PIMessage msg)
+{
+
+if (Msg() && !msg)
+  XtRemoveCallback(XtWdg(), XmNactivateCallback, 
+                   (XtCallbackProc)text_action, (XtPointer)this);
+if (!Msg() && msg)
+  XtAddCallback(XtWdg(), XmNactivateCallback, 
+                (XtCallbackProc)text_action, (XtPointer)this);
+
+PIWdg::SetMsg(msg);
+}
+
+
+/************* PICheckBoxX ************/
+#include <Xm/ToggleB.h>
+
+// Fonction prive (CallBack)
+static void toggb_action(Widget w, XtPointer *usd, XmToggleButtonCallbackStruct* calld);
+
+/* Nouvelle-Fonction */
+void  toggb_action(Widget , XtPointer *usd, XmToggleButtonCallbackStruct* calld)
+{
+PICheckBoxX *picb;
+picb = (PICheckBoxX *) usd ;
+if (calld->set == True)   picb->mSt = true;
+else picb->mSt = false;
+picb->Send(picb->Msg(), PIMsg_DataChanged, (void *)(picb->mSt));
+return;
+}
+
+/* --Methode-- */
+PICheckBoxX::PICheckBoxX(PIContainerGen *par, char *nom, PIMessage msg,
+                         int sx, int sy, int px, int py)
+: PICheckBoxGen(par, nom, msg, sx, sy, px, py)
+{
+CreateXtWdg(nom, xmToggleButtonWidgetClass, NULL, sx, sy, px, py);
+XtAddCallback(XtWdg(), XmNvalueChangedCallback,
+             (XtCallbackProc) toggb_action, (XtPointer)this);
+Arg warg[2];
+XtSetArg(warg[0],XmNhighlightThickness, 0);
+XtSetValues(XtWdg(), warg, 1);
+SetState(false);
+Manage();
+}
+
+
+/* --Methode-- */
+PICheckBoxX::~PICheckBoxX()
+{}
+
+
+/* --Methode-- */
+void PICheckBoxX::SetState(bool st)
+{
+Arg warg[2];
+mSt = st;
+XtSetArg(warg[0],XmNset, mSt);
+XtSetValues(XtWdg(), warg, 1);
+return;
+}
+
+/* --Methode-- */
+bool PICheckBoxX::GetState()
+{
+return(mSt);
+}
+
+
+/************* PIScaleX ************/
+#include <Xm/Scale.h>
+
+// Fonction prive (CallBack)
+static void scale_action(Widget w, XtPointer *usd, 
+                         XmScaleCallbackStruct *calld);
+
+void  scale_action(Widget, XtPointer *usd, 
+                         XmScaleCallbackStruct *calld)
+{
+PIScale *pis;
+
+pis = (PIScale *) usd ;
+pis->CBSetVal(calld->value);
+pis->Send(pis->Msg(), PIMsg_DataChanged, (void *)calld->value);
+return;
+}
+
+/* --Methode-- */
+PIScaleX::PIScaleX(PIContainerGen *par, char *nom, PIMessage msg,
+                   bool horiz, int sx, int sy, int px, int py)
+: PIScaleGen(par, nom, msg, horiz, sx, sy, px, py)
+{
+int n=0;
+Arg warg[6];
+CreateXtWdg(nom, xmScaleWidgetClass, NULL, sx, sy, px, py);
+XtSetArg(warg[n], XmNshowValue, TRUE); n++;
+if (horiz)
+  {
+  XtSetArg(warg[n], XmNorientation, XmHORIZONTAL); n++;
+  XtSetArg(warg[n], XmNprocessingDirection, XmMAX_ON_RIGHT); n++;
+  }
+else
+  { 
+  XtSetArg(warg[n], XmNorientation, XmVERTICAL); n++;
+  XtSetArg(warg[n], XmNprocessingDirection, XmMAX_ON_TOP); n++;
+  }
+XtSetArg(warg[n], XmNscaleWidth, sx); n++;
+XtSetArg(warg[n], XmNscaleHeight, sy); n++;
+XtSetArg(warg[n], XmNstringDirection, XmSTRING_DIRECTION_R_TO_L); n++;
+
+XtSetValues(XtWdg(), warg, n);
+SetMinMax(1, 10);
+SetValue(1);
+XtAddCallback(XtWdg(), XmNvalueChangedCallback, 
+             (XtCallbackProc) scale_action, (XtPointer)this);
+Manage();
+}
+
+/* --Methode-- */
+PIScaleX::~PIScaleX()
+{}
+
+/* --Methode-- */
+void PIScaleX::SetMinMax(int min, int max)
+{
+if (min >= max)  max = min+10;
+if (mVal < min)  mVal = min;
+if (mVal > max)  mVal = max;
+int n=0;
+Arg warg[3];
+XtSetArg(warg[n], XmNminimum, min); n++;
+XtSetArg(warg[n], XmNmaximum, max); n++;
+XtSetArg(warg[n], XmNvalue, mVal); n++;
+XtSetValues(XtWdg(), warg, n);
+mMin = min;   mMax = max;
+return;
+}
+
+
+/* --Methode-- */
+void PIScaleX::SetValue(int val)
+{
+int n=0;
+if (val < mMin)  val = mMin;
+if (val > mMax)  val = mMax;
+Arg warg[2];
+XtSetArg(warg[n], XmNvalue, val); n++;
+XtSetValues(this->sdw, warg, n);
+return;
+}
+
+/* --Methode-- */
+int  PIScaleX::GetValue()
+{
+int val;
+int n=0;
+Arg warg[2];
+XtSetArg(warg[n], XmNvalue, &val); n++;
+XtGetValues(this->sdw, warg, n);
+mVal = val;
+return(mVal);
+}
+
+/* --Methode-- */
+void  PIScaleX::CBSetVal(int val)
+{
+mVal = val;
+return;
+}
+
+
+
+/************* PIScrollBarX ************/
+
+#include <Xm/ScrollBar.h>
+
+// Fonction prive (CallBack)
+static void scrollbar_action(Widget w, XtPointer *usd, 
+                             XmScrollBarCallbackStruct *calld);
+static void scrollbar_drag(Widget w, XtPointer *usd, 
+                           XmScrollBarCallbackStruct *calld);
+
+void  scrollbar_action(Widget, XtPointer *usd, 
+                       XmScrollBarCallbackStruct *calld)
+{
+PIScrollBar *pis;
+
+pis = (PIScrollBar *) usd ;
+pis->CBSetVal(calld->value);
+pis->Send(pis->Msg(), PIMsg_DataChanged, (void *)calld->value);
+return;
+}
+
+void  scrollbar_drag(Widget, XtPointer *usd, 
+                       XmScrollBarCallbackStruct *calld)
+{
+PIScrollBar *pis;
+
+pis = (PIScrollBar *) usd ;
+pis->CBSetVal(calld->value);
+pis->Send(pis->Msg(), PIMsg_Drag, (void *)calld->value);
+return;
+}
+
+/* --Methode-- */
+PIScrollBarX::PIScrollBarX(PIContainerGen *par, char *nom, PIMessage msg,
+                           bool vert, int sx, int sy, int px, int py)
+: PIScrollBarGen(par, nom, msg, vert, sx, sy, px, py)
+{
+int n=0;
+Arg warg[3];
+
+CreateXtWdg(nom, xmScrollBarWidgetClass, NULL, sx, sy, px, py);
+if (vert)
+  {
+  XtSetArg(warg[n], XmNorientation, XmVERTICAL); n++;
+  XtSetArg(warg[n], XmNprocessingDirection, XmMAX_ON_BOTTOM); n++;
+  }
+else
+  { 
+  XtSetArg(warg[n], XmNorientation, XmHORIZONTAL); n++;
+  XtSetArg(warg[n], XmNprocessingDirection, XmMAX_ON_RIGHT); n++;
+  }
+XtSetValues(XtWdg(), warg, n);
+mAcD = false;
+mVal = -1;
+mMin = mMax = 0;
+mSz = 0;
+SetMinMax(0, 100);
+SetSize(10);
+SetValue(0);
+XtAddCallback(XtWdg(), XmNvalueChangedCallback, 
+             (XtCallbackProc) scrollbar_action, (XtPointer)this);
+Manage();
+}
+
+/* --Methode-- */
+PIScrollBarX::~PIScrollBarX()
+{}
+
+
+/* --Methode-- */
+void PIScrollBarX::ActivateDrag(bool acd)
+{
+if (mAcD == acd)  return; 
+    
+if (mAcD)
+  XtRemoveCallback(XtWdg(), XmNdragCallback, 
+                   (XtCallbackProc)scrollbar_drag, (XtPointer)this);
+else 
+  XtAddCallback(XtWdg(), XmNdragCallback, 
+                (XtCallbackProc)scrollbar_drag, (XtPointer)this);
+mAcD = acd;
+return;
+}       
+
+/* --Methode-- */
+void PIScrollBarX::SetMinMax(int min, int max)
+{
+if (min >= max)  max = min+100;
+if (mVal < min)  mVal = min;
+if (mVal > max)  mVal = max;
+int n=0;
+Arg warg[3];
+XtSetArg(warg[n], XmNminimum, min); n++;
+XtSetArg(warg[n], XmNmaximum, max); n++;
+XtSetArg(warg[n], XmNvalue, mVal); n++;
+XtSetValues(XtWdg(), warg, n);
+mMin = min;   mMax = max;
+return;
+}
+
+
+/* --Methode-- */
+void PIScrollBarX::SetValue(int val)
+{
+int n=0;
+if (val < mMin)  val = mMin;
+if (val > mMax)  val = mMax;
+Arg warg[2];
+XtSetArg(warg[n], XmNvalue, val); n++;
+XtSetValues(this->sdw, warg, n);
+mVal = val;
+return;
+}
+
+/* --Methode-- */
+int  PIScrollBarX::GetValue()
+{
+int val;
+int n=0;
+Arg warg[2];
+XtSetArg(warg[n], XmNvalue, &val); n++;
+XtGetValues(this->sdw, warg, n);
+mVal = val;
+return(mVal);
+}
+
+/* --Methode-- */
+void PIScrollBarX::SetSize(int sz)
+{
+int n=0;
+Arg warg[3];
+int szl;
+
+szl = mMax-mMin;
+if (sz > szl)  sz = szl;
+szl /= 100;
+if (szl < 1)  szl = 1;
+if (sz < szl)  sz = szl;
+szl = sz/10;
+if (szl < 1)  szl = 1;
+XtSetArg(warg[n], XmNsliderSize, sz); n++;
+XtSetArg(warg[n], XmNpageIncrement, sz); n++;
+XtSetArg(warg[n], XmNincrement, szl); n++;
+XtSetValues(this->sdw, warg, n);
+mSz = sz;
+return;
+}
+
+/* --Methode-- */
+int  PIScrollBarX::GetSize()
+{
+int sz;
+int n=0;
+Arg warg[2];
+XtSetArg(warg[n], XmNsliderSize, &sz); n++;
+XtGetValues(this->sdw, warg, n);
+mSz = sz;
+return(mSz);
+}
+
+
+/* --Methode-- */
+void  PIScrollBarX::CBSetVal(int val)
+{
+mVal = val;
+return;
+}
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/pistdwdgx.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pistdwdgx.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pistdwdgx.h	(revision 50)
@@ -0,0 +1,118 @@
+#ifndef PISTDWDGX_H_SEEN
+#define PISTDWDGX_H_SEEN
+
+#include "pistdwdggen.h"
+
+
+class PILabelX : public PILabelGen
+{
+public:
+                     PILabelX(PIContainerGen *par, char *nom,
+                                 int sx=10, int sy=10, int px=0, int py=0);
+  virtual            ~PILabelX();
+  
+};
+
+class PIButtonX : public PIButtonGen
+{
+public:
+                     PIButtonX(PIContainerGen *par, char *nom, 
+                               PIMessage msg = PIMsg_Click,
+                               int sx=10, int sy=10, int px=0, int py=0,
+                               PIBtnSign bsgn = PIBtn_Label);
+  virtual            ~PIButtonX();
+
+  virtual void       ActivatePress(bool acp=false);
+
+  void               ReleaseButton();   // Fonction a utiliser avec attention
+
+  XEvent myevt;   // Attention - Pour usage interne 
+
+protected :
+  bool mAcP;
+};
+
+
+class PITextX : public PITextGen
+{
+public:
+                     PITextX(PIContainerGen *par, char *nom, 
+                                  int sx=10, int sy=10, int px=0, int py=0);
+  virtual            ~PITextX();
+  virtual void       SetText(string const&);
+  virtual string     GetText() const;
+
+  virtual void       SetMutiLineMode(bool mlm=false);
+  virtual void       SetTextEditable(bool te=true);
+
+  virtual void       SetMsg(PIMessage msg=0);
+};
+
+
+class PICheckBoxX : public PICheckBoxGen
+{
+public:
+                     PICheckBoxX(PIContainerGen *par, char *nom, 
+                                 PIMessage msg=PIMsg_Click,
+                                 int sx=10, int sy=10, int px=0, int py=0);
+  virtual            ~PICheckBoxX();
+
+  virtual void       SetState(bool st=false);
+  virtual bool       GetState();
+
+  bool mSt;          // Etat du bouton, en public a cause du Callback
+};
+
+
+
+class PIScaleX : public PIScaleGen
+{
+public:
+                     PIScaleX(PIContainerGen* par, char* nom, 
+                              PIMessage msg=PIMsg_DataChanged, bool horiz=true,
+                              int sx=100, int sy=10, int px=0, int py=0);
+  virtual            ~PIScaleX();
+
+  virtual void       SetMinMax(int min, int max);
+  virtual void       SetValue(int val);
+  virtual int        GetValue(); 
+
+  virtual void       CBSetVal(int val);   // A ne pas utiliser (pour Callback Xt)
+protected: 
+  int mVal, mMin, mMax;
+};
+
+
+
+class PIScrollBarX : public PIScrollBarGen
+{
+public:
+                     PIScrollBarX(PIContainerGen* par, char* nom, 
+                                  PIMessage msg = PIMsg_DataChanged, bool vert=true,
+                                  int sx=10, int sy=100, int px=0, int py=0);
+                     ~PIScrollBarX();
+
+  virtual void       ActivateDrag(bool acd=false);
+  virtual void       SetMinMax(int min, int max);
+  virtual void       SetValue(int val);
+  virtual int        GetValue(); 
+  virtual void       SetSize(int sz);
+  virtual int        GetSize();
+
+  virtual void       CBSetVal(int val);   // A ne pas utiliser (pour Callback Xt)
+
+protected: 
+  int mVal, mMin, mMax, mSz;
+  bool mAcD;
+};
+
+
+typedef PILabelX       PILabel;
+typedef PIButtonX      PIButton;
+typedef PITextX        PIText;
+typedef PICheckBoxX    PICheckBox;
+typedef PIScaleX       PIScale;
+typedef PIScrollBarX   PIScrollBar;
+
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/pistlist.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pistlist.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pistlist.cc	(revision 50)
@@ -0,0 +1,133 @@
+#include <stdio.h>
+#include "pistlist.h"
+
+ 
+/* --Methode-- */
+PIStarList::PIStarList(StarList* stl, bool ayud)
+: PIScDrawer(), mStL(stl)
+{
+  mAdelStl = false;   
+  mAYdir = ayud;  
+  if (stl == NULL) return;
+  SetFluxLimits(1., -1.);
+  SetXYLimits(1., -1., 1., -1.);
+}
+
+PIStarList::~PIStarList()
+{
+  if (mAdelStl && mStL)
+    delete mStL;
+}
+
+/* --Methode-- */
+void  PIStarList::SetFluxLimits(float fmin, float fmax, int nl, int msz0, 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);
+  mF0 = mFmin;
+  if (nl < 1)  nl = 1;
+  if (nl > 20)  nl = 20;
+  mNLev = nl;  
+  if (msz0 < 0)  msz0 = 0;
+  if (msz0 > 10)  msz0 = 10; 
+  mMSz0 = msz0;
+  if (refr)  Refresh();
+  return;
+}
+
+/* --Methode-- */
+void  PIStarList::SetXYLimits(float xmin, float xmax, float ymin, float ymax, bool dfv, bool refr)
+{
+  if (!mStL)  return;  
+  if ((xmin < xmax) && (ymin < ymax)) {
+    mXMin = xmin; mXMax = xmax; mYMin = ymin; mYMax = ymax; 
+    }
+  else {
+    double x1, x2, y1, y2;
+    mStL->CalcXYLimits(x1, x2, y1, y2);
+    mXMin = (float)x1; mXMax = (float)x2; mYMin = (float)y1; mYMax = (float)y2; 
+    }
+  mDspFV = dfv;
+  if (refr)  Refresh();
+  return;    
+}  
+
+/* --Methode-- */
+void  PIStarList::AttachTo(PIScDrawWdg* wdg)
+{
+  PIScDrawer::AttachTo(wdg);
+  UpdateSize();
+}
+
+
+/* --Methode-- */
+void PIStarList::UpdateSize()
+{
+  if (!mStL) return;
+  if (!mDrawWdg) return;
+  if (mDrawWdg->LimitsFixed()) return;
+
+  // Commencer par trouver nos limites
+  float dx, dy;
+  
+  dx = 0.02*(mXMax-mXMin);
+  dy = 0.02*(mYMax-mYMin);
+  
+  mDrawWdg->SetLimits(mXMin-dx, mXMax+dx, mYMin-dy, mYMax+dy, false, mAYdir); 
+  mDrawWdg->SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
+}
+
+
+/* --Methode-- */
+void PIStarList::Draw()
+{
+BStar *sti;
+float xp,yp,flx;
+int sz,ixp, iyp;
+char buff[128];
+int nok, nl2;
+
+if (!mStL) return;
+if (!mDrawWdg) return;
+
+mDrawWdg->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 < mXMin) || (xp > mXMax) || (yp < mYMin) || (yp > mYMax) )  continue;
+  nok++;
+  sz = (int)((log10((double)flx/mF0))/mDLgF*(double)nl2-0.01) + mMSz0;
+  if (sz < 2)  mDrawWdg->SelMarker(sz, PI_DotMarker);
+  else mDrawWdg->SelMarker(sz, PI_FCircleMarker);
+  mDrawWdg->ScDrawMarker((double)xp,(double)yp ); 
+  if (mDspFV) {  
+    sprintf(buff," F=%g", flx);
+    mDrawWdg->Sc2Local(xp, yp, ixp, iyp);
+    mDrawWdg->DrawString( ixp+sz/2+1, iyp-4, buff);
+    } 
+  }
+
+sprintf(buff, "StarList:  NbStars= %d  NDisp= %d", (int)mStL->NbStars(), nok);
+mDrawWdg->DrawString(15,15,buff);
+sprintf(buff, "FMin= %g  FMax= %g Nl= %d Sz0= %d", mFmin, mFmax, mNLev, mMSz0);
+mDrawWdg->DrawString(15,30,buff);
+
+}
+
+
+/* --Methode-- */
+void PIStarList::Refresh()
+{
+  if (!mDrawWdg) return;
+  mDrawWdg->FreeLimits();
+  UpdateSize();
+  mDrawWdg->Refresh();
+}
Index: /tags/V_Saclay_110697/SophyaPI/PI/pistlist.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pistlist.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pistlist.h	(revision 50)
@@ -0,0 +1,45 @@
+#ifndef PISTLIST_H
+#define PISTLIST_H
+
+
+#include "piscdrawwdg.h"
+#include "stlist.h"
+
+class PIStarList : public PIScDrawer {
+public:
+                     PIStarList(StarList* stl, bool ayud=true);
+  virtual           ~PIStarList();
+  
+  virtual void       Draw();
+  virtual void       Refresh();  // Recalcule les limites, et reaffiche
+  
+  inline  void       SetAutoDelStList(bool ad=false)   { mAdelStl = ad; }
+  void               SetFluxLimits(float min=1., float max=-1., int nl=5, 
+                                   int msz0=0, bool refr=false);
+  void               SetXYLimits(float xmin=1., float xmax=-1., float ymin=1., float ymax=-1., 
+                                 bool dfv=false, bool refr=false);              
+
+  inline StarList*   StList()  { return(mStL); }  
+  inline float       XMin()    { return(mXMin); }       
+  inline float       XMax()    { return(mXMax); }       
+  inline float       YMin()    { return(mYMin); }       
+  inline float       YMax()    { return(mYMax); }       
+  inline float       FluxMin() { return(mFmin); }       
+  inline float       FluxMax() { return(mFmax); }
+       
+protected:
+  StarList* mStL;
+  bool   mAdelStl;
+  float mFmin, mFmax;
+  int mNLev, mMSz0;
+  double mF0, mDLgF;
+  float mXMin, mXMax;
+  float mYMin, mYMax;
+  bool mDspFV;
+  bool mAYdir;
+
+  virtual void       AttachTo(PIScDrawWdg*);
+  virtual void       UpdateSize();
+};
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/pisysdep.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pisysdep.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pisysdep.h	(revision 50)
@@ -0,0 +1,48 @@
+#ifndef PISYSDEP_SEEN
+#define PISYSDEP_SEEN
+
+#ifdef __MWERKS__         // Macintosh
+
+  #define PIWDG_H  "piwdgmac.h"
+  #define PICONT_H "picontainermac.h"
+  #define PIWIN_H  "piwindowmac.h"
+  #define PISTDWDG_H "pistdwdgmac.h"
+  #define PIMENU_H "pimenumac.h"
+  #define PIMENUBAR_H "pimenubarmac.h"
+  #define PIOPTMENU_H "pioptmenumac.h"
+  #define PIFILECHO_H "pifilechomac.h"
+  #define PILIST_H "pilistmac.h"
+
+  #define PIAPP_H "piapplmac.h"
+  
+  #define PIBWDG_H "pibwdgmac.h"
+
+  #define PICMAPNTV_H "picmapmac.h"
+  #define PICMAP_H "picmap.h"
+  #define PIPIXMAP_H "pipixmapmac.h"
+
+
+#else                  // XWindow
+  #define PIWDG_H  "piwdgx.h"
+  #define PICONT_H "picontainerx.h"
+  #define PIWIN_H  "piwindowx.h"
+  #define PISTDWDG_H "pistdwdgx.h"
+  #define PIMENU_H "pimenux.h"
+  #define PIMENUBAR_H "pimenubarx.h"
+  #define PIOPTMENU_H "pioptmenux.h"
+  #define PIFILECHO_H "pifilechox.h"
+  #define PILIST_H "pilistx.h"
+
+  #define PIAPP_H "piapplx.h"
+
+  #define PIBWDG_H "pibwdgx.h"
+
+  #define PICMAPNTV_H "picmapx.h"
+  #define PICMAP_H "picmap.h"
+  #define PIPIXMAP_H "pipixmapx.h"
+
+  #define PIPERIODIC_H "piperiodicx.h"
+
+#endif
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/pitestapp.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pitestapp.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pitestapp.cc	(revision 50)
@@ -0,0 +1,365 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "pisysdep.h"
+
+#include PIAPP_H
+#include PIWIN_H 
+#include PIMENU_H 
+#include PIOPTMENU_H 
+// #include PIMENUBAR_H 
+#include PISTDWDG_H 
+#include PIBWDG_H 
+
+#include PIPIXMAP_H 
+
+#include PIFILECHO_H 
+
+#include "ex_dessin.h"
+#include "sc_sample.h"
+#include "piimage.h"
+
+#include "fitsimage.h"
+
+int SysBeep(int n)
+{
+for(int i=0; i<n; i++)  putchar('\007');
+return(0);
+}
+/*
+class PITestWindow : public PIWindow {
+public:
+	PITestWindow(PIMsgHandler *par);
+	~PITestWindow() {}
+
+    PIText text;
+    PIButton bouton;
+    PIButton bouton2, bouton3;
+    PILabel label;
+    PIScale scl;
+    PIPUMenu  * menu;
+
+};
+*/
+
+class PITestApp : public PIApplication {
+public:
+	PITestApp(int sx, int sy);
+	~PITestApp();
+
+	virtual void	Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+
+//    PIMenubar * menb;
+    PIPDMenu  *m[3];
+    PICheckBox * ckb;
+    PIText * text;
+    PIButton * bouton;
+    PIButton * bouton2, * bouton3, * bouton4, *bouton5;
+    PILabel * label;
+    PIScale * scl;
+    PIPUMenu  * menu;
+    PIPUMenu * pum[2];
+    PIOptMenu * opt, * opt2, *opt3;
+    PIPixmap * zoom;
+    PILabel  * labimg;
+    ScSample * scs;
+
+};
+
+
+/*
+PITestWindow::PITestWindow(PIMsgHandler *par)
+: PIWindow(par, "Peida", PIWK_normal, 200, 200, 50, 50),
+  text(this, "TEXTE", 100, 30, 20,10),
+  label(this, "Label", 100, 20, 20,60),
+  bouton(this, "OK", 66, 40, 20, 20, 100),
+  bouton2(this, "Image", 133, 40, 20, 80, 100),
+  bouton3(this, "Menu", 555, 40, 20, 140, 100),
+  scl(this, "Scale", 88, 5, 45, 100, 20, 10, 130)
+{
+  menu = new PIPUMenu((PIMsgHandler *)this, "myMenu");
+  menu->AppendItem("DoIt-1", 4401);
+  menu->AppendItem("DoIt-2", 4402);
+  menu->AppendItem("DoIt-25", 4425);
+  menu->AppendItem("DoIt-26", 4426);
+  menu->AppendItem("Check-33", 4433);
+  menu->AppendItem("Check-33", 4433);
+
+  label.SetBorderWidth(3);
+  FinishCreate();
+}
+
+*/
+
+PITestApp::PITestApp(int sx, int sy)
+: PIApplication(sx, sy)
+{
+//   menb = new PIMenubar(this, "MyMenubar");
+   m[0] = new PIPDMenu((PIMsgHandler *)Menubar(),"File");
+   m[0]->AppendItem("Open", 10101);
+   m[0]->AppendItem("Close", 10102);
+   m[0]->AppendItem("New", 10103);
+   m[0]->AppendItem("Quit", 10104);
+   m[1] = new PIPDMenu((PIMsgHandler *)Menubar(),"Edit");
+   m[1]->AppendItem("Copier", 10201);
+   m[1]->AppendItem("Coller", 10202);
+   m[1]->AppendItem("Couper", 10203);
+   m[2] = new PIPDMenu((PIMsgHandler *)Menubar(),"Operation");
+   m[2]->AppendItem("AddItem", 10301);
+   m[2]->AppendItem("DelItemName", 10302);
+   m[2]->AppendItem("DelItemMsg", 10303);
+
+   AppendMenu(m[0]);
+   AppendMenu(m[1]);   
+   AppendMenu(m[2]);
+
+  ckb = new PICheckBox(this->MainWin(), "CheckBox", 166, 60, 20, 10, 10);
+  text = new PIText(this->MainWin(), "TEXTE", 100, 30, 20,40);
+  text->SetMsg(7440);
+  label  = new PILabel(this->MainWin(), "Label", 140, 20, 20,80);
+  label->SetBorderWidth(1);
+  bouton = new PIButton(this->MainWin(), "OK", 33, 40, 25, 20, 120);
+  bouton2 = new PIButton(this->MainWin(), "Image", 133, 40, 25, 80, 120);
+  bouton3 = new PIButton(this->MainWin(), "ExDess",  233, 40, 25, 140, 120);
+  bouton4 = new PIButton(this->MainWin(), "Dialog", 333, 40, 25, 200, 120);
+  bouton5 = new PIButton(this->MainWin(), "ScDraw", 433, 40, 25, 260, 120);
+  scl = new PIScale(this->MainWin(), "Scale", 88, 5, 45, 100, 20, 10, 150);
+
+  zoom = new PIPixmap(this->MainWin(), "Zoom", 100,100,5,195);
+  labimg = new PILabel(this->MainWin(), "PixelValue", 250, 20, 10, 320);
+
+  menu = new PIPUMenu((PIMsgHandler *)this, "myMenu");
+  menu->AppendItem("DoIt-1", 4401);
+  menu->AppendItem("DoIt-2", 4402);
+  menu->AppendItem("DoIt-25", 4425);
+  menu->AppendItem("DoIt-26", 4426);
+  menu->AppendItem("Check-33", 4433);
+  menu->AppendItem("Check-33", 4433);
+
+  pum[1] = new PIPUMenu((PIMsgHandler *)this,"Edit");
+  pum[1]->AppendItem("Copier", 80201);
+  pum[1]->AppendItem("Coller", 80202);
+  pum[1]->AppendItem("Couper", 80203);
+  pum[1]->AppendItem("Undo", 80204);
+  pum[1]->AppendItem("Select-All", 80205);
+
+  pum[0] = new PIPUMenu((PIMsgHandler *)this, "myMenu");
+  pum[0]->AppendItem("Linear", 5601);
+  pum[0]->AppendItem("Log.", 5602);
+  pum[0]->AppendItem("Sqrt", 5603);
+  pum[0]->AppendItem("Expon", 5604);
+  pum[0]->AppendItem("Polyn", 5605);
+
+  opt = new PIOptMenu(this->MainWin(), pum[0], 90, 25, 110, 150);
+  opt->SetValueStr("Sqrt");
+  opt2 = new PIOptMenu(this->MainWin(), pum[1], 90, 25, 150, 200);
+
+  opt3 = new PIOptMenu(this->MainWin(), pum[0], 80, 25, 110, 250);
+  opt3->SetValueStr("Linear");
+
+}
+
+PITestApp::~PITestApp()
+{
+  delete ckb;
+  delete text;
+  delete label;
+  delete bouton;
+  delete bouton2;
+  delete bouton3;
+  delete bouton4;
+  delete bouton5;
+  delete scl;
+  delete menu;
+  delete m[0]; delete m[1]; delete m[2];
+  delete opt;
+  delete opt2;
+  delete opt3;
+  delete pum[0];  delete pum[1]; 
+  delete zoom;
+  delete labimg;
+
+}
+
+static int nimg = 0;
+static PIImage *pimg[5];
+static RzImage *img[5];
+static PIWindow *imgw[5];
+static PIImage *cur=NULL;
+static ScSample *scs1, *scs2, *scs3;
+static ExBWdg *exb1;
+
+static PIWindow * wp3, *wp2, *wp4, *wp5;
+static PIPixmap * pxm;
+static unsigned char  pixels[25000];
+static PIFileChooser *pfc;
+static bool  fgpxm = false;
+static bool  fgt = false;
+static bool  fgt2 = false;
+
+void
+PITestApp::Process(PIMessage msg, PIMsgHandler* sender, void* data)
+{
+  static int x = 0;
+  static numsg=8800;
+
+//   SysBeep(1);
+  char truc[256];
+  sprintf(truc,"< %ld - %d (%d)>",msg,x++, (int)((PIWdgGen *)sender)->kind());
+  this->label->SetLabel(truc);
+  sprintf(truc,"[%d] Msg= %ld (%d-%d) Kind=(%d)",x, msg, (int)UserMsg(msg),
+         (int)ModMsg(msg), (int)((PIWdgGen *)sender)->kind());
+  puts(truc);
+
+  if (ModMsg(msg) == PIMsg_Active) 
+    {  printf("Process: Setting active ImageWindow (%lx) \n", (long)sender); 
+    cur = (PIImage *)data; return;}
+
+  if (ModMsg(msg) == PIMsg_Close)
+    {
+    printf("Close Message received (Sender= %lx)\n", (long)sender);
+    return;
+    }
+
+  msg = UserMsg(msg);
+  if (msg == 33) ckb->SetState(true);
+    
+  if (msg == 133)
+    {
+    if (!fgpxm)  { wp3->Show();  fgpxm = true; }
+    for (int i=0; i<25000; i++)  pixels[i] = rand()%32;
+    if ((x % 3) == 0)  pxm->SetColMap(CMAP_GREY32);
+    if ((x % 3) == 1)  pxm->SetColMap(CMAP_COLRJ32);
+    if ((x % 3) == 2)  pxm->SetColMap(CMAP_COLBR32);
+//    pxm->Refresh();
+    if (cur)
+      {
+//      printf("Process: Setting ColMap for (%lx) \n", (long)cur);
+      if ((x % 3) == 0)  cur->SetColMap(CMAP_GREY32);
+      if ((x % 3) == 1)  cur->SetColMap(CMAP_COLRJ32);
+      if ((x % 3) == 2)  cur->SetColMap(CMAP_COLBR32);
+      }
+    }
+  if (msg == 233)
+    {
+    if (fgt) { wp2->Hide();  fgt = false; }
+    else { wp2->Show();  fgt = true; }
+    }
+
+  if (msg == 333)  wp4->Show();
+  if ( (msg == 6001) || (msg == 6002) )  wp4->Hide();
+
+  if (msg == 433)
+    {
+    if (fgt2) { wp5->Hide();  fgt2 = false; }
+    else { wp5->Show();  fgt2 = true; }
+    }
+
+//  if (msg == 555)   (this->menu)->Show(); 
+
+  if (msg == 10104)  Stop();
+  if (msg == 10101)  { pfc->AcceptNewFile(false); pfc->Show(); }
+  if (msg == 10103)  { pfc->AcceptNewFile(true); pfc->Show(); }
+
+  if (msg == 10301)  
+   { 
+   numsg++;    
+   m[1]->AppendItem((char *)text->GetText().c_str(), numsg); 
+   opt2->SetValue(numsg);
+   }
+
+  if (msg == 10302)  { m[1]->DeleteItem((char *)text->GetText().c_str()); }
+  if (msg == 10303)  
+    {
+    long ml =  atol(text->GetText().c_str());
+    m[1]->DeleteItemMsg(ml);
+    opt2->SetValue(10201);
+    }
+
+
+  if ((msg > 8000) && data) printf("PITestApp::MenubarReturn: %s \n", (char *)data);
+  if (msg == 5000)  
+    { 
+    if (data) 
+      { 
+      printf("PITestApp::Process(5000) : %s \n", (char *)data); 
+      if (nimg < 5)  img[nimg] = RzReadFits((char *)data);
+      if (img[nimg])
+        {
+        imgw[nimg] = new PIWindow(this, "WindImage", 
+                                  PIWK_normal, 400, 400, 500, 500);
+        pimg[nimg] = new PIImage(imgw[nimg], "MyImage", 400, 400, 0, 0);
+        pimg[nimg]->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed,PIBK_fixed );
+        pimg[nimg]->SetZoomWin(zoom);
+        pimg[nimg]->SetTextWin(labimg);
+        pimg[nimg]->SetImage(img[nimg]);
+        pimg[nimg]->Apply();
+        imgw[nimg]->Show();
+        nimg++;
+        }
+    }
+    else printf("PITestApp::Process(5000) (data=NULL) \n");  }
+
+  if ((msg / 100) == 56) 
+    printf("PITestApp::Process(%d) : %s \n", (int)msg, (char *)data); 
+
+}
+
+int main()
+{
+  PITestApp * app;
+  app = new PITestApp(350, 350);
+
+  wp2 = new PIWindow(app, "Window-2", PIWK_normal,  150, 150, 250, 250);
+  ExBWdg bw(wp2, "BWdg", 150, 150, 0, 0);
+//  bw.ActivateButton(1);
+//  bw.ActivatePtrCross();
+//  bw.ActivateKeyboard();
+
+
+  wp4 = new PIWindow(app, "Window-4", PIWK_dialog,  200, 200, 350, 350);
+  PIButton bt1(wp4, "OK", 6001, 60, 30, 20, 160);
+  PIButton bt2(wp4, "Cancel", 6002, 60, 30, 100, 160);
+  bt1.SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+  bt2.SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+  PILabel  lb1(wp4, "Editable", 40, 30, 10, 10);
+    lb1.SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+  PIText  tx1(wp4, "A00", 100, 30, 60, 10);  
+    tx1.SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+  tx1.SetText("Hello");
+  tx1.SetTextEditable(false);
+  //  PILabel  lb2(wp4, "", 30, 20, 10, 40);
+  PIText  tx2(wp4, "A11", 180, 100, 15, 50);
+  tx2.SetMutiLineMode(true);
+  tx2.SetText(" Bonjour, \n Comment ca va ? \n A demain. ");
+    tx2.SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+
+  wp3 = new PIWindow(app, "Window-3", PIWK_normal, 200, 200, 350, 350);
+  pxm = new PIPixmap(wp3, "myPixmap", 150, 150, 10, 10);
+  pxm->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed,PIBK_fixed );
+  pxm->SetPixmap(pixels, 150, 150);
+
+  wp5 = new PIWindow(app, "Window-5", PIWK_normal,  400, 450, 200, 200);
+  scs1 = new ScSample(wp5, "ScSample", 200, 200, 0, 0);
+  scs1->SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+  scs2 = new ScSample(wp5, "ScSample", 160, 160, 220, 20);
+  scs2->SetBinding(PIBK_elastic,PIBK_fixed,PIBK_fixed,PIBK_elastic);
+
+  scs3 = new ScSample(wp5, "ScSample", 200, 200, 100, 220);
+
+  scs3->SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+  /*  
+  exb1 = new ExBWdg(wp5, "ExB1", 200, 200, 100, 220);
+  exb1->SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+  */
+  //  wp4 = new PIWindow(app, "Open...", PIWK_dialog, 300, 300, 400, 400);
+
+  pfc = new PIFileChooser(app,"FileChooser", 5000); 
+  pfc->SetPath("/exp/eros/ImagRed/");
+
+
+//  Int32 ioNumber = 100;
+  app->Run();
+  delete app;
+  exit(0);
+}
Index: /tags/V_Saclay_110697/SophyaPI/PI/piup.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piup.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piup.cc	(revision 50)
@@ -0,0 +1,61 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "ctimer.h"
+#include "imageop.h"
+
+#include "piup.h"
+
+RzImage * PIUserProc_1(ImageR4& myimg, int xp, int yp, int dx, int dy,
+                       char * arg1, char * arg2)
+{
+printf("**** PIUserProc_1 Pave[%d*%d] en (%d,%d) %s %s  Filtrage passe-bas 3*3 \n",
+       dx, dy, xp, yp, arg1, arg2);
+ImageR4 filt(3,3);
+ImageR4 * out;
+
+// Definition du filtre passe-bas
+int i,j;
+for(i=0; i<3; i++)
+  for(j=0; j<3; j++)  filt(i,j) = 0.1;
+filt(1,1) = 0.2;
+
+filt.PrintImage();
+out = new ImageR4(myimg.XSize(), myimg.YSize());
+TIMEF ;
+FilterImage(&myimg, out, &filt); 
+return((RzImage*)out);
+}
+ 
+RzImage * PIUserProc_2(ImageR4& myimg, int xp, int yp, int dx, int dy,
+                       char * arg1, char * arg2)
+{
+printf("**** PIUserProc_2 Pave[%d*%d] en (%d,%d) %s %s  Ombre 3*3 \n",
+       dx, dy, xp, yp, arg1, arg2);
+printf(" PIUserProc_2(%d %d %s %s)  Ombre 3*3 \n", xp, yp, arg1, arg2);
+ImageR4 filt(3,3);
+ImageR4 * out;
+
+// Definition du filtre ombre
+int i,j;
+filt(0,0) = filt(1,1) = filt(2,2) = 0.;
+filt(0,1) = filt(1,2) = -1.;
+filt(1,0) = filt(2,1) = 1.;
+filt(0,2) = -2.;
+filt(2,0) = 2.;
+filt.PrintImage();
+out = new ImageR4(myimg.XSize(), myimg.YSize());
+TIMEF ;
+FilterImage(&myimg, out, &filt); 
+return((RzImage*)out);
+}
+
+ 
+RzImage * PIUserProc_3(ImageR4& , int xp, int yp, int dx, int dy,
+                       char * arg1, char * arg2)
+{
+printf("PIUserProc_3 Pave[%d,%d] en (%d %d) %s %s ne fait rien !\n", 
+       dx, dy, xp, yp, arg1, arg2);
+return(NULL);
+}
Index: /tags/V_Saclay_110697/SophyaPI/PI/piup.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piup.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piup.h	(revision 50)
@@ -0,0 +1,8 @@
+#include "cimage.h"
+
+RzImage * PIUserProc_1(ImageR4& myimg, int xp, int yp, int dx, int dy,
+                       char * arg1, char * arg2);
+RzImage * PIUserProc_2(ImageR4& myimg, int xp, int yp, int dx, int dy,
+                       char * arg1, char * arg2);
+RzImage * PIUserProc_3(ImageR4& myimg, int xp, int yp, int dx, int dy, 
+                       char * arg1, char * arg2);
Index: /tags/V_Saclay_110697/SophyaPI/PI/piup_def.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piup_def.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piup_def.cc	(revision 50)
@@ -0,0 +1,33 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "ctimer.h"
+#include "imageop.h"
+
+#include "piup.h"
+
+RzImage * PIUserProc_1(ImageR4 & , int xp, int yp, int dx, int dy,
+                       char * arg1, char * arg2)
+{
+printf("PIUserProc_1/Dummy Pave[%d,%d] en (%d %d) %s %s ne fait rien !\n", 
+       dx, dy, xp, yp, arg1, arg2);
+return(NULL);
+}
+ 
+RzImage * PIUserProc_2(ImageR4 & , int xp, int yp, int dx, int dy,
+                       char * arg1, char * arg2)
+{
+printf("PIUserProc_2/Dummy Pave[%d,%d] en (%d %d) %s %s ne fait rien !\n", 
+       dx, dy, xp, yp, arg1, arg2);
+return(NULL);
+}
+ 
+RzImage * PIUserProc_3(ImageR4 & , int xp, int yp, int dx, int dy,
+                       char * arg1, char * arg2)
+{
+printf("PIUserProc_3/Dummy Pave[%d,%d] en (%d %d) %s %s ne fait rien !\n", 
+       dx, dy, xp, yp, arg1, arg2);
+return(NULL);
+}
+ 
Index: /tags/V_Saclay_110697/SophyaPI/PI/piupdattachment.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piupdattachment.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piupdattachment.cc	(revision 50)
@@ -0,0 +1,101 @@
+#include "piupdattachment.h"
+const MessageT	msg_Resize			= 817;
+const MessageT	msg_Move			= 818;
+//const MessageT	msg_MouseUp			= 819;
+
+PIUpdAttachment* PIUpdAttachment::lastCursPane = NULL;
+bool PIUpdAttachment::hit = false;
+int PIUpdAttachment::down = 0;
+
+PIUpdAttachment::PIUpdAttachment(PIBaseWdgMac* wdg)
+: LAttachment(), myWdg(wdg)
+{
+
+}
+
+PIUpdAttachment::~PIUpdAttachment()
+{
+ // SysBeep(1);
+}
+
+void PIUpdAttachment::ExecuteSelf(MessageT msg, void* data)
+{
+  if (myWdg)
+    switch(msg) {
+      case msg_DrawOrPrint:
+        myWdg->Draw();
+ 		break;
+      case msg_Resize:
+        myWdg->Resize();
+ 		break;
+      case msg_Move:
+//        myWdg->Move();
+        break;
+      case msg_Click: {
+        SMouseDownEvent* evt = (SMouseDownEvent*) data;
+        EventModifiers mod = evt->macEvent.modifiers;
+        if ((mod & cmdKey) && (mod & optionKey))
+          { myWdg->But3Press(evt->whereLocal.h,evt->whereLocal.v); down = 3;}
+        else if (mod & cmdKey)
+          { myWdg->But2Press(evt->whereLocal.h,evt->whereLocal.v); down = 2;}
+        else
+          { myWdg->But1Press(evt->whereLocal.h,evt->whereLocal.v); down = 1;}
+ 		break;
+ 		}
+ 	  case msg_KeyPress: {
+ 	    EventRecord* evt = (EventRecord*) data;
+ 	    PIKeyModifier kmod = PIKM_Blank;
+ 	    if (evt->modifiers & shiftKey)
+ 	      kmod = (PIKeyModifier) (kmod | PIKM_Shift);
+ 	      //kmod |= PIKM_Shift;  // Ca devrait passer !!!
+ 	    if (evt->modifiers & optionKey)
+ 	      kmod = (PIKeyModifier) (kmod | PIKM_Alt);
+ 	    if (evt->modifiers & controlKey)
+ 	      kmod = (PIKeyModifier) (kmod | PIKM_Cntl);
+ 	    myWdg->Keyboard(evt->message & charCodeMask, kmod);
+ 	    break;
+ 	    }
+ 	  case msg_AdjustCursor: {
+ 	    EventRecord* evt = (EventRecord*) data;
+ 	    if (lastCursPane != this) {
+ 	      if (lastCursPane)
+ 	        lastCursPane->myWdg->Leave();
+ 	      myWdg->Enter();
+ 	      lastCursPane = this;
+ 	    }
+ 	    hit = true;
+ 	    SetExecuteHost(!myWdg->AdjustCursor());
+ 	    // Est-ce un move, i.e. le bouton est-il toujours appuye depuis le dernier MouseDown ?
+ 	    if (::StillDown() && down) {
+ 	      Point pt = evt->where;
+ 	      myWdg->mPane->GlobalToPortPoint(pt);
+ 	      myWdg->mPane->PortToLocalPoint(pt);
+ 	      if (lastPt.h != pt.h || lastPt.v != pt.v) {
+ 	        lastPt = pt;
+            EventModifiers mod = evt->modifiers;
+            if ((mod & cmdKey) && (mod & optionKey))
+              myWdg->Ptr3Move(pt.h,pt.v);
+            else if (mod & cmdKey)
+              myWdg->Ptr2Move(pt.h,pt.v);
+            else
+              myWdg->Ptr1Move(pt.h,pt.v);
+          }
+ 	    } else if (down) {  // A changer le jour ou les attachements recoivent les mouseup.
+ 	      Point pt = evt->where;
+ 	      myWdg->mPane->GlobalToPortPoint(pt);
+ 	      myWdg->mPane->PortToLocalPoint(pt);
+          EventModifiers mod = evt->modifiers;
+          //if ((mod & cmdKey) && (mod & optionKey))
+          if (down == 3)
+            myWdg->But3Release(pt.h,pt.v);
+          //else if (mod & cmdKey)
+          else if (down == 2)
+            myWdg->But2Release(pt.h,pt.v);
+          else
+            myWdg->But1Release(pt.h,pt.v);
+ 	      down = 0;
+        }
+ 	    break;
+ 	    }
+    }
+}
Index: /tags/V_Saclay_110697/SophyaPI/PI/piupdattachment.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piupdattachment.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piupdattachment.h	(revision 50)
@@ -0,0 +1,24 @@
+
+#include <LAttachment.h>
+
+#include "pibwdgmac.h"
+
+class PIUpdAttachment : public LAttachment {
+public:
+  PIUpdAttachment(PIBaseWdgMac* wdg);
+  ~PIUpdAttachment();
+  
+protected:
+ virtual void	ExecuteSelf(
+							MessageT		inMessage,
+							void			*ioParam);
+
+ PIBaseWdgMac* myWdg;
+ 
+ friend class PIPPApplMac;
+ static PIUpdAttachment* lastCursPane;
+ static bool hit;
+ static int down;
+ Point lastPt;
+};
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/piusmak
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piusmak	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piusmak	(revision 50)
@@ -0,0 +1,33 @@
+CC := gcc
+CXX := g++
+include  $(EROSBASEREP)/Include/MakefileUser.h
+
+%.o:%.cc
+	$(COMPILE.cc) -o $@ $<
+LIBF =  $(SLB)libpeida.so $(SLB)liberosc.so
+LIBS = -L$(SLB) -lpeida -lerosc  
+
+#------------------------------------------------- End of Makefile.h ------- 
+all : piup.so
+
+clean:
+	rm -f user.o user.so piup.so
+
+piup.so : user.so
+	cp -p user.so piup.so
+
+ 
+user.so : user.o $(LIBF)
+	ld -shared -o user.so -all user.o \
+        -none $(LIBS) -lgcxx -lm -lc
+
+user.o: user.cc  $(INC)piup.h \
+ $(INC)perrors.h \
+ $(INC)exceptions.h \
+ $(INC)defs.h \
+ $(INC)cimage.h \
+ $(INC)rzimage.h \
+ $(INC)rzvect.h \
+ $(INC)machine.h \
+ $(INC)datatypes.h \
+ $(INC)utils.h $(INC)peida.h 
Index: /tags/V_Saclay_110697/SophyaPI/PI/piwdggen.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piwdggen.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piwdggen.cc	(revision 50)
@@ -0,0 +1,78 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "piwdggen.h"
+#include "picontainergen.h"
+
+#include "psfile.h"
+
+/* --Methode-- */
+PIWdgGen::PIWdgGen(PIContainerGen *par, char*, int, int, int, int)
+: PIMsgHandler(par)
+{
+parent = par;
+SetMsg(0);
+SetUserData(NULL, 0);
+if (par)  par->ChildAdd(this);   //  On previent le container parent  
+return;
+}
+
+
+/* --Methode-- */
+PIWdgGen::~PIWdgGen()
+{
+if (parent)  parent->ChildDel(this);   //  On previent le container parent 
+}
+
+/* --Methode-- */
+void PIWdgGen::SetMsg(PIMessage msg)
+{
+myMsg = msg;
+}
+
+/* --Methode-- */
+void PIWdgGen::GetScreenPos(int & spx, int & spy)
+/*  Renvoie la position de la fenetre par rapport a l'ecran */
+{
+PIWdgGen * wc;
+spx = 0;  spy = 0;
+wc = this;
+
+while (wc) 
+  { spx += wc->XPos();  
+  spy += wc->YPos();  wc = wc->Parent();
+  }
+return;
+}
+
+/* --Methode-- */
+void PIWdgGen::PSPrint(PSFile *psf, int ofx, int ofy)
+{
+char str[256];
+
+if (!psf) return;
+psf->NewBloc((float)ofx+XPos(), (float)ofy+YPos(), (float)XSize(), (float)YSize(),
+             (float)XSize(), (float)YSize());
+psf->DrawBox(0., 0., (float)XSize(), (float)YSize());
+sprintf(str,"PIWdgGen::PSPrint() Kind=%ld Name= %s", kind(), Nom().c_str());
+psf->DrawString(12., 12., str, PI_Black, PI_RomanFont, 10);
+psf->EndBloc();
+
+return;
+}
+
+/* --Methode-- 
+string PIWdgGen::kindstr()
+{
+char b[5];
+string s;
+
+b[0] = (char) (kind()&0x000000FF);
+b[1] = (char) ((kind()&0x0000FF00) / 0x100);
+b[2] = (char) ((kind()&0x00FF0000) / 0x10000);
+b[3] = (char) ((kind()&0xFF000000) / 0x1000000);
+b[4] = '\0';
+s = b;
+return(s);
+}
+*/
Index: /tags/V_Saclay_110697/SophyaPI/PI/piwdggen.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piwdggen.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piwdggen.h	(revision 50)
@@ -0,0 +1,76 @@
+/* Classe pour enrobage generique des widgets Xt, Mac, etc  */
+/*                                    Reza 10/95            */
+
+#ifndef PIWDG_H_SEEN
+#define PIWDG_H_SEEN
+
+#include <string>
+
+#include "pimsghandler.h"
+
+void PIBeep();
+
+// Les differents types d'accrochage aux containers  
+
+enum PIBindingKind {    
+  PIBK_free = 0,
+  PIBK_fixed = 1,
+  PIBK_elastic = 2
+};
+
+class PSFile;
+class PIContainerGen;
+class PIWdgGen : public PIMsgHandler
+{
+public:
+  enum {ClassId = 100};
+
+                         PIWdgGen(PIContainerGen *par, char *nom,
+                                   int sx=10, int sy=10, int px=0, int py=0);
+  virtual               ~PIWdgGen();
+  virtual void		 FinishCreate()=0; // apres avoir installe les sous-vues
+
+  virtual long           kind() {return ClassId; }
+//  string               kindstr();
+
+  inline PIWdgGen*       Parent() { return( (PIWdgGen*)parent ); }
+
+  inline void         	 SetUserData( void * p, int fg = 0) {pdata=p; flag=fg; }
+  inline void*       	 UserData() { return (pdata); };
+  inline void const* 	 UserData() const { return (pdata); };
+  inline int         	 UserFlag() { return(flag); };
+
+
+  virtual void           SetMsg(PIMessage msg = 0);
+  inline  PIMessage      Msg() { return (myMsg); }
+
+  virtual void           SetSize(int sx, int sy)=0;
+  virtual void           SetPos(int px, int py)=0;
+  virtual void           SetBorderWidth(int bw)=0;
+  virtual void           SetLabel(string const&) {}
+  virtual void           SetBinding(PIBindingKind left, PIBindingKind top, 
+                                    PIBindingKind right, PIBindingKind bottom)=0;
+
+  virtual int            XSize()=0;
+  virtual int            YSize()=0;
+  virtual int            XPos()=0;
+  virtual int            YPos()=0;
+
+  virtual string         Nom()=0;
+  virtual void           GetScreenPos(int & spx, int & spy);
+
+  virtual void           PSPrint(PSFile *psf, int ofx=0, int ofy=0);
+
+protected:
+  PIContainerGen        *parent;
+  PIMessage              myMsg;
+
+private:
+  int flag;
+  void * pdata;
+};
+
+
+  
+
+#endif/* PIWDG_H_SEEN */
Index: /tags/V_Saclay_110697/SophyaPI/PI/piwdgmac.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piwdgmac.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piwdgmac.cc	(revision 50)
@@ -0,0 +1,126 @@
+#include "piwdgmac.h"
+#include "pisysdep.h"
+
+#include PICONT_H
+
+#include <LView.h>
+#include <LString.h>
+
+void PIBeep()
+{
+  ::SysBeep(1);
+}
+
+
+PIWdgMac::PIWdgMac(PIContainerGen *par, char *nom,
+                   int sx, int sy, int px, int py)
+:PIWdgGen(par, nom, sx, sy, px, py), mNom(nom)
+{
+	mPaneInfo.paneID    = 'PIWD';
+	mPaneInfo.width     = sx;
+	mPaneInfo.height    = sy;
+	mPaneInfo.visible   = true;
+	mPaneInfo.enabled   = true;
+	mPaneInfo.bindings.left =
+		mPaneInfo.bindings.top =
+		mPaneInfo.bindings.right =
+		mPaneInfo.bindings.bottom = false;
+	mPaneInfo.left      = px;
+	mPaneInfo.top       = py;
+	mPaneInfo.userCon   = 'PIWD';
+	mPaneInfo.superView = par ? (LView*) (((PIContainerMac*)(par))->mPane) : NULL;
+
+  mViewInfo.imageSize.width = sx;
+  mViewInfo.imageSize.height = sy;
+  mViewInfo.scrollPos.h = 
+    mViewInfo.scrollPos.v = 
+    mViewInfo.scrollUnit.h = 
+    mViewInfo.scrollUnit.v = 0;
+  mViewInfo.reconcileOverhang = 0;
+  
+  mPane = new LView(mPaneInfo, mViewInfo);
+  ((LView*)mPane)->CalcPortOrigin();
+}
+
+
+PIWdgMac::~PIWdgMac()
+{
+  delete mPane;
+}
+
+void
+PIWdgMac::FinishCreate()
+{
+  mPane->FinishCreate();
+}
+
+void
+PIWdgMac::ListenToMessage(MessageT /*inMessage*/, void */*ioParam*/)
+{
+
+}
+
+void
+PIWdgMac::SetLabel(string const& lab)
+{
+  LStr255 titre(lab.c_str());
+  mPane->SetDescriptor(titre);
+}
+
+void
+PIWdgMac::SetSize(int sx, int sy)
+{
+   mPane->ResizeFrameTo(sx, sy, true);
+}
+
+void
+PIWdgMac::SetPos(int px, int py)
+{
+   mPane->MoveBy(px-XPos(), py-YPos(), false);
+}
+
+void
+PIWdgMac::SetBinding(PIBindingKind left, PIBindingKind top, 
+                     PIBindingKind right, PIBindingKind bottom)
+//  $CHECK$ Reza 13/10/96    Code a modifier
+{
+  SBooleanRect r;
+  r.left    = left;
+  r.top     = top;
+  r.right   = right;
+  r.bottom  = bottom;
+  mPane->SetFrameBinding(r);
+}
+
+int
+PIWdgMac::XSize()
+{ 
+  SDimension16 outSize;
+  mPane->GetFrameSize(outSize);
+  return outSize.width;
+}
+
+int
+PIWdgMac::YSize()
+{ 
+  SDimension16 outSize;
+  mPane->GetFrameSize(outSize);
+  return outSize.height;
+}
+
+int
+PIWdgMac::XPos()
+{
+  SPoint32 p;
+  mPane->GetFrameLocation(p);
+  return p.h;
+}
+
+int
+PIWdgMac::YPos()
+{
+  SPoint32 p;
+  mPane->GetFrameLocation(p);
+  return p.v;
+}
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/piwdgmac.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piwdgmac.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piwdgmac.h	(revision 50)
@@ -0,0 +1,39 @@
+#ifndef PIWDG_MAC_SEEN
+#define PIWDG_MAC_SEEN
+
+#include "piwdggen.h"
+#include <LPane.h>
+#include <LListener.h>
+
+class PIWdgMac : public PIWdgGen, public LListener {
+public:
+  
+                         PIWdgMac(PIContainerGen *par, char *nom,
+                                   int sx=10, int sy=10, int px=0, int py=0);
+  virtual                ~PIWdgMac();
+  virtual void			 FinishCreate(); // apres avoir installe les sous-vues
+                                       
+  virtual void	         ListenToMessage(MessageT inMessage, void *ioParam);
+  virtual void           SetLabel(string const&);
+
+  virtual void           SetSize(int sx, int sy);
+  virtual void           SetPos(int px, int py);
+  virtual void           SetBorderWidth(int /*bw*/) {}
+  virtual void           SetBinding(PIBindingKind left, PIBindingKind top, 
+                                    PIBindingKind right, PIBindingKind bottom);
+  virtual int            XSize();
+  virtual int            YSize();
+  virtual int            XPos();
+  virtual int            YPos();
+  virtual string         Nom()  { return mNom; }
+protected:
+  LPane*				 mPane;
+  SPaneInfo				 mPaneInfo;
+  SViewInfo				 mViewInfo;
+  string                 mNom;
+};
+
+typedef PIWdgMac PIWdg;
+
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/piwdgx.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piwdgx.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piwdgx.cc	(revision 50)
@@ -0,0 +1,476 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/IntrinsicP.h>
+#include <X11/Shell.h>
+#include <X11/Core.h>
+#include <X11/CoreP.h>
+
+#include <Xm/Xm.h>       // A cause des container XmForm 
+#include <Xm/Form.h>     // Idem 
+
+
+#include "piwdgx.h"
+#include "picontainerx.h"
+
+
+// #define DEBUG_PIWdgX
+
+static SysDWdg  top = NULL;
+static Display * dpy = NULL;
+static char appname[64];
+static char appclass[64];
+/* Nouvelle-Fonction */
+SysDWdg   PIXtTopWdg()
+{
+return (top);
+}
+
+/* Nouvelle-Fonction */
+Display * PIXDisplay()
+{
+return(dpy);
+}
+
+/* Nouvelle-Fonction */
+void PIBeep()
+{
+XBell(dpy, 0);
+return;
+}
+
+/* Nouvelle-Fonction */
+int CStrFrXmStr(XmString xms, char* buff, int nmx)
+/*  Pour recuperer le contenu d'un string Motif  */
+{
+int n,l,m;
+XmStringContext cntx;
+char *txs;
+XmStringDirection dir;
+XmStringCharSet cset;
+Boolean sep;
+
+if (nmx < 2)  return(0);
+n = 0;  m = nmx-1;  buff[0] = buff[m] = '\0';
+XmStringInitContext (&cntx, xms);
+while (m > 0)
+  {
+  if (XmStringGetNextSegment( cntx, &txs, &cset, &dir, &sep) )
+    {
+    l = strlen(txs);
+    if (m < l)  txs[m] = '\0';
+    strcpy(buff+n, txs);
+    n += l;   m -= l;
+    if (sep)  m = -2;
+    XtFree(txs);
+    }
+  else m = -1;
+  }
+
+return(n);
+} 
+
+
+/* --Methode-- */
+PIWdgX::PIWdgX(int narg, char *arg[])
+:PIWdgGen(NULL, "PITopLevel")  
+{
+if (top == NULL)  InitXt(narg, arg);
+sdw = top;
+wmis =  k_wmi_appshell;
+stmng = 0;
+#ifdef DEBUG_PIWdgX
+printf("Debug_PIWdgX::PIWdgX(int , char * [])  this=%lx  top=%lx \n", (long)this, (long)sdw);
+#endif
+}
+
+
+
+/* --Methode-- */
+PIWdgX::PIWdgX(PIContainerGen *par, char *nom, 
+               int sx, int sy, int px, int py)
+:PIWdgGen(par, nom, sx, sy, px, py) 
+{
+sdw = NULL;
+wmis = k_wmi_unknown;
+}
+
+/* --Methode-- */
+int PIWdgX::CreateXtWdg(char *nom, SysDWdgClass wdgcl, SysDWdg pwdg,
+                        int sx, int sy, int px, int py)
+{
+Arg  wargs[5];
+int n=0;
+
+if (pwdg == NULL)
+  {
+  if (parent == NULL)
+    {
+    if (top == NULL)  InitXt();
+    pwdg = top;
+    }
+  // else pwdg = ((PIContainerX *)parent)->sdw;
+  else pwdg = ((PIWdgX *)parent)->sdw;
+  }
+
+n=0;
+if ((sx >= 0) && (sy >= 0))
+  {
+  XtSetArg(wargs[n],XtNwidth,sx);  n++;
+  XtSetArg(wargs[n],XtNheight,sy);  n++;
+  }
+XtSetArg(wargs[n],XtNx,px);  n++;
+XtSetArg(wargs[n],XtNy,py);  n++;
+
+if (wdgcl == NULL)  wdgcl = coreWidgetClass;
+
+if ( (wdgcl == topLevelShellWidgetClass) || 
+     (wdgcl == transientShellWidgetClass) ||
+     (wdgcl == overrideShellWidgetClass) )
+  {
+  sdw = XtCreatePopupShell(nom, wdgcl, pwdg, wargs, n);
+  }
+else
+  {
+  sdw = XtCreateWidget(nom, wdgcl, pwdg, wargs, n);
+  }
+
+if (wdgcl == topLevelShellWidgetClass)  wmis = k_wmi_toplevel;
+else if (wdgcl == transientShellWidgetClass)  wmis = k_wmi_transient;
+else if (wdgcl == overrideShellWidgetClass)  wmis = k_wmi_override;
+else wmis == k_wmi_normal ;
+
+stmng = 0;
+#ifdef DEBUG_PIWdgX
+printf("Debug_PIWdgX::CreateXtWdg(%s) this=%lx sdw=%lx pere=%lx wmis=%d\n", nom, 
+       (long)this, (long)sdw, (long)pwdg, wmis);
+#endif
+
+SetBinding(PIBK_free, PIBK_free, PIBK_free, PIBK_free);
+return(0);
+}
+
+
+/* --Methode-- */
+PIWdgX::~PIWdgX()
+{
+#ifdef DEBUG_PIWdgX
+printf("Debug_PIWdgX::~PIWdgX()  %lx %lx \n", (long)this, (long)sdw);
+#endif
+if (!sdw)  XtDestroyWidget(sdw);
+}
+
+
+/* --Methode-- */
+void PIWdgX::FinishCreate()
+{
+#ifdef DEBUG_PIWdgX
+printf("Debug_PIWdgX::FinishCreate() ne fait rien ! \n");
+#endif
+return;
+}
+
+
+/* --Methode-- */
+void PIWdgX::Manage()
+{
+#ifdef DEBUG_PIWdgX
+printf("Debug_PIWdgX::Manage  this=%lx  sdw=%lx \n", (long)this, (long)sdw);
+#endif
+if (!sdw)  return;
+if (wmis != k_wmi_appshell)  XtManageChild(sdw);
+else if (!XtIsRealized(sdw))  XtRealizeWidget(sdw);  
+stmng = 1;
+return;
+}
+
+/* --Methode-- */
+void PIWdgX::Unmanage()
+{
+#ifdef DEBUG_PIWdgX
+printf("Debug_PIWdgX::Unmanage  this=%lx sdw=%lx \n", (long)this, (long)sdw);
+#endif
+if (!sdw)  return;
+if (wmis != k_wmi_appshell) 
+  XtUnmanageChild(sdw);
+stmng = 0;
+return;
+}
+
+/* --Methode-- */
+int PIWdgX::IfManaged()
+{
+return(stmng);
+}
+
+
+/* --Methode-- */
+void PIWdgX::SetSize(int sx, int sy)
+{
+#ifdef DEBUG_PIWdgX
+printf("Debug_PIWdgX::SetSize  this=%lx  sdw=%lx \n", (long)this, (long)sdw);
+#endif
+
+if (!sdw)  return;
+/*
+Arg  wargs[2];
+XtSetArg(wargs[0],XtNwidth,sx); 
+XtSetArg(wargs[1],XtNheight,sy); 
+XtSetValues(this->sdw, wargs, 2);
+*/
+XtResizeWidget(sdw, sx, sy, BorderWidth());
+
+return;
+} 
+
+/* --Methode-- */
+void PIWdgX::SetPos(int px, int py)
+{
+if (!sdw)  return;
+/*
+Arg  wargs[2];
+XtSetArg(wargs[0],XtNx,px);  
+XtSetArg(wargs[1],XtNy,py);  
+XtSetValues(this->sdw, wargs, 2);
+*/
+XtMoveWidget(sdw, px, py);
+
+return;
+} 
+
+/* --Methode-- */
+void PIWdgX::SetBinding(PIBindingKind left, PIBindingKind top, 
+                        PIBindingKind right, PIBindingKind bottom)
+{
+Arg  wargs[3];
+int n=0;
+if (!sdw)  return;
+if (!parent)  return;
+
+/*
+n = 0;
+XtSetArg(wargs[n],XmNfractionBase, 500);  n++;
+XtSetValues(this->sdw, wargs, n);
+*/
+switch (left)
+  {
+  case PIBK_free : 
+    n = 0;
+    XtSetArg(wargs[n],XmNleftAttachment, XmATTACH_NONE);  n++;
+    XtSetValues(this->sdw, wargs, n);
+    break;
+  case PIBK_fixed :
+    n = 0;
+    XtSetArg(wargs[n],XmNleftAttachment, XmATTACH_FORM);  n++;
+    XtSetArg(wargs[n],XmNleftOffset, XPos() );  n++;
+    XtSetValues(this->sdw, wargs, n);
+    break;
+  case PIBK_elastic :
+    n = 0;
+    XtSetArg(wargs[n],XmNleftAttachment, XmATTACH_POSITION);  n++;
+    XtSetArg(wargs[n],XmNleftPosition, (XPos()*100/parent->XSize()) );  n++;
+    XtSetValues(this->sdw, wargs, n);
+    break;
+  }
+
+switch (top)
+  {
+  case PIBK_free : 
+    n = 0;
+    XtSetArg(wargs[n],XmNtopAttachment, XmATTACH_NONE);  n++;
+    XtSetValues(this->sdw, wargs, n);
+    break;
+  case PIBK_fixed :
+    n = 0;
+    XtSetArg(wargs[n],XmNtopAttachment, XmATTACH_FORM);  n++;
+    XtSetArg(wargs[n],XmNtopOffset, YPos() );  n++;
+    XtSetValues(this->sdw, wargs, n);
+    break;
+  case PIBK_elastic :
+    n = 0;
+    XtSetArg(wargs[n],XmNtopAttachment, XmATTACH_POSITION);  n++;
+    XtSetArg(wargs[n],XmNtopPosition, (YPos()*100/parent->YSize()) );  n++;
+    XtSetValues(this->sdw, wargs, n);
+    break;
+  }
+  
+switch (right) 
+  {
+  case PIBK_free : 
+    n = 0;
+    XtSetArg(wargs[n],XmNrightAttachment, XmATTACH_NONE);  n++;
+    XtSetValues(this->sdw, wargs, n);
+    break;
+  case PIBK_fixed :
+    n = 0;
+    XtSetArg(wargs[n],XmNrightAttachment, XmATTACH_FORM);  n++;
+    XtSetArg(wargs[n],XmNrightOffset, parent->XSize()-(XSize()+XPos()) );  n++;
+    XtSetValues(this->sdw, wargs, n);
+    break;
+  case PIBK_elastic :
+    n = 0;
+    XtSetArg(wargs[n],XmNrightAttachment, XmATTACH_POSITION);  n++;
+    XtSetArg(wargs[n],XmNrightPosition, ((XPos()+XSize())*100/parent->XSize()) );  n++;
+    XtSetValues(this->sdw, wargs, n);
+    break;
+  }
+
+switch (bottom) 
+  {
+  case PIBK_free : 
+    n = 0;
+    XtSetArg(wargs[n],XmNbottomAttachment, XmATTACH_NONE);  n++;
+    XtSetValues(this->sdw, wargs, n);
+    break;
+  case PIBK_fixed :
+    n = 0;
+    XtSetArg(wargs[n],XmNbottomAttachment, XmATTACH_FORM);  n++;
+    XtSetArg(wargs[n],XmNbottomOffset, parent->YSize()-(YSize()+YPos()) );  n++;
+    XtSetValues(this->sdw, wargs, n);
+    break;
+  case PIBK_elastic :
+    n = 0;
+    XtSetArg(wargs[n],XmNbottomAttachment, XmATTACH_POSITION);  n++;
+    XtSetArg(wargs[n],XmNbottomPosition, ((YPos()+YSize())*100/parent->YSize()) );  n++;
+    XtSetValues(this->sdw, wargs, n);
+    break;
+  }
+
+return;
+}
+
+
+/* --Methode-- */
+void PIWdgX::SetBorderWidth(int bw)
+{
+if (!sdw)  return;
+
+Arg  wargs[2];
+int n=0;
+
+XtSetArg(wargs[n],XtNborderWidth,bw);  n++;
+XtSetValues(this->sdw, wargs, n);
+return;
+}
+
+/* --Methode-- */
+void PIWdgX::SetLabel(string const& lab)
+{
+XmString xmstr;
+xmstr = XmStringLtoRCreate((char *)lab.c_str(), XmSTRING_DEFAULT_CHARSET);
+int n=0;
+Arg warg[2];
+
+XtSetArg(warg[n], XmNlabelString, xmstr); n++;
+XtSetValues(XtWdg(), warg, n);
+XmStringFree(xmstr);
+return;
+}
+
+
+
+/* --Methode-- */
+int PIWdgX::XSize()
+{
+if (!sdw)  return(-1);
+else return((int)this->sdw->core.width);
+}
+
+/* --Methode-- */
+int PIWdgX::YSize()
+{
+if (!sdw)  return(-1);
+else return((int)this->sdw->core.height);
+}
+
+/* --Methode-- */
+int PIWdgX::XPos()
+{
+if (!sdw)  return(-1);
+else return((int)this->sdw->core.x);
+}
+
+/* --Methode-- */
+int PIWdgX::YPos()
+{
+if (!sdw)  return(-1);
+else return((int)this->sdw->core.y);
+}
+
+
+/* --Methode-- */
+int PIWdgX::BorderWidth()
+{
+if (!sdw)  return(-1);
+Arg  wargs[2];
+int bw;
+XtSetArg(wargs[0],XtNborderWidth, &bw);  
+XtGetValues(this->sdw, wargs, 1);
+return(bw);
+}
+
+/* --Methode-- */
+string PIWdgX::Nom()
+{
+return(XtName(this->sdw));
+}
+
+/* --Methode-- */
+void PIWdgX::GetScreenPos(int & spx, int & spy)
+{
+PIWdgX * wc;
+Display *mdsp;
+Window w, rw, pw, *cw;
+unsigned int ncw;
+Status st;
+int x,y;
+unsigned int bw, l, h, d;
+
+spx = 0;  spy = 0;
+wc = this;
+
+while (wc)
+  { spx += wc->XPos();
+  spy += wc->YPos();  wc = (PIWdgX *)wc->Parent();
+  }
+
+mdsp = XtDisplay(XtWdg());
+w = XtWindow(XtWdg());
+ncw = 0;
+st = XQueryTree(mdsp, w, &rw, &pw, &cw, &ncw);
+if (st) 
+  { XFree(cw);
+  if (pw == rw)  return; }
+
+while (st && (pw != rw))  
+  {
+  w = pw;
+  st = XQueryTree(mdsp, w, &rw, &pw, &cw, &ncw); 
+  if (st)   XFree(cw);
+  XGetGeometry(mdsp, w, &rw, &x, &y, &l, &h, &bw, &d);  
+  spy += y;  spx += x;
+  }  
+return;
+}
+
+
+
+/* --Methode-- */
+int PIWdgX::InitXt(int narg, char *arg[])
+{
+if (top == NULL)   // Initialisation ...  
+  {
+  int n;
+  char *pc = "PIWdgX";
+  char **ppc;
+  if (narg > 0)  { n = narg, ppc = arg; }
+  else { ppc = &pc; n = 1; }
+  strncpy(appname, ppc[0], 63); appname[63] = '\0';
+  strncpy(appclass,"PeidaInt",63);  appclass[63] = '\0';     
+  top = XtInitialize(appname, appclass, NULL, 0, &n, ppc);
+  dpy = XtDisplay(top);
+  }
+return(0);
+}
Index: /tags/V_Saclay_110697/SophyaPI/PI/piwdgx.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piwdgx.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piwdgx.h	(revision 50)
@@ -0,0 +1,83 @@
+/* Classe pour enrobage generique des widgets Xt, Mac, etc  */
+/*                                    Reza 10/95            */
+
+#ifndef PIWDG_X_SEEN
+#define PIWDG_X_SEEN
+
+#include <string>
+
+#include <X11/Xlib.h>
+#include <X11/Intrinsic.h>
+
+#include "piwdggen.h"
+#include "piwdggen.h"
+
+typedef Widget SysDWdg;
+typedef WidgetClass SysDWdgClass;
+
+
+enum WmIntState { k_wmi_unknown=0,
+                  k_wmi_normal=1, k_wmi_toplevel=2, 
+                  k_wmi_transient=3, k_wmi_override=4,
+                  k_wmi_appshell=5 };
+
+class PIWdgX : public PIWdgGen 
+{
+public:
+// Les methodes ...
+  PIWdgX(int narg=0, char *arg[]=NULL);
+  PIWdgX(PIContainerGen *par, char *nom, 
+         int sx=10, int sy=10, int px=0, int py=0);
+
+  virtual ~PIWdgX();
+
+  int CreateXtWdg(char *nom, SysDWdgClass wdgcl=NULL, SysDWdg pwdg=NULL,
+                  int sx=10, int sy=10, int px=0, int py=0 );
+
+  virtual void	 FinishCreate(); // apres avoir installe les sous-vues
+
+  virtual void   SetSize(int sx, int sy);
+  virtual void   SetPos(int px, int py);
+  virtual void   SetBorderWidth(int bw);
+  virtual void   SetLabel(string const & lab);
+  virtual void   SetBinding(PIBindingKind left, PIBindingKind top, 
+                            PIBindingKind right, PIBindingKind bottom);
+
+  virtual int    XSize();
+  virtual int    YSize();
+  virtual int    XPos();
+  virtual int    YPos();
+  virtual int    BorderWidth();
+
+  virtual string Nom();  
+  virtual void   GetScreenPos(int & spx, int & spy);
+
+  void Manage();
+  void Unmanage();
+  int  IfManaged();
+
+  inline SysDWdg XtWdg() const {return(sdw); }; 
+  inline SysDWdg& XtWdg() {return(sdw); }; 
+
+protected:
+  int InitXt(int narg=0, char *arg[]=NULL); 
+
+
+  SysDWdg sdw;
+  WmIntState wmis;
+  int stmng;
+  
+};
+
+typedef PIWdgX PIWdg;
+
+
+// Utile pour avoir acces au Display et Screen X ...
+SysDWdg   PIXtTopWdg();
+Display * PIXDisplay();
+#define  PIXScreen()  DefaultScreen(PIXDisplay()) 
+
+#endif/* PIWDGX_SEEN */
+
+
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/piwindowgen.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piwindowgen.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piwindowgen.cc	(revision 50)
@@ -0,0 +1,43 @@
+#include "piwindowgen.h"
+#include "psfile.h"
+
+/* --Methode-- */
+PIWindowGen::PIWindowGen(PIMsgHandler *par, char *nom, PIWindowKind k, 
+                         int sx, int sy, int px, int py)
+: PIContainer(NULL, nom, sx, sy, px, py), mWtyp(k)
+{
+  SetMsgParent(par);
+  AutoHideOnClose();
+}
+
+
+/* --Methode-- */
+PIWindowGen::~PIWindowGen()
+{}
+
+/* --Methode-- */
+void PIWindowGen::PSPrint(PSFile *psf, int ofx, int ofy)
+{
+if (!psf) return;
+//int ori;
+//ori = (XSize() > YSize()) ? LANDSCAPE : PORTRAIT ;
+psf->NewPage((float)XSize(), (float)YSize(),PI_Auto);
+PIContainerGen::PSPrint(psf, ofx, ofy);
+}
+
+
+/* --Methode-- */
+void PIWindowGen::Process(PIMessage msg, PIMsgHandler* sender, void* data)
+/*  On intercepte le message Active, et Close avant de les renvoyer */
+/*  avec un message ActiveWdg de la part de la fenetre              */
+{
+
+if ((msg == BuildMsg(Msg(), PIMsg_Close)) && (sender == this) && mAHC) 
+  Hide();   // Action par defaut en cas de MsgClose.
+
+if (ModMsg(msg) == PIMsg_Active)
+  Send(Msg(),PIMsg_Active);
+
+ReSend(msg, sender, data);
+return;  
+}
Index: /tags/V_Saclay_110697/SophyaPI/PI/piwindowgen.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piwindowgen.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piwindowgen.h	(revision 50)
@@ -0,0 +1,36 @@
+#ifndef PIWINDOWGEN_H_SEEN
+#define PIWINDOWGEN_H_SEEN
+
+#include "pisysdep.h"
+
+#include PICONT_H
+
+enum PIWindowKind {
+  PIWK_normal = 0,
+  PIWK_dialog = 1,
+  PIWK_transient = 2,
+  PIWK_floating = 3
+};
+
+class PIWindowGen : public PIContainer {
+public:
+  enum {ClassId = 1550};
+		    PIWindowGen(PIMsgHandler* par, char *nom, PIWindowKind k=PIWK_normal,
+                                int sx=10, int sy=10, int px=0, int py=0);
+  virtual           ~PIWindowGen();
+
+  virtual long      kind() {return ClassId; }
+
+  virtual void      PSPrint(PSFile *psf, int ofx=0, int ofy=0);
+
+  inline  void      AutoHideOnClose(bool ahc=true) { mAHC = ahc; }
+
+  virtual void      Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+  
+protected:  
+  PIWindowKind	       mWtyp;
+  bool                 mAHC;
+};
+
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/piwindowmac.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piwindowmac.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piwindowmac.cc	(revision 50)
@@ -0,0 +1,57 @@
+#include "piwindowmac.h"
+
+PIWindowMac::PIWindowMac(PIMsgHandler *par, char *nom, PIWindowKind k, int sx, int sy, int px, int py)
+: PIWindowGen(par, nom, k, sx, sy, px, py), finalized(false)
+{
+	delete mPane;
+	mWindowInfo.WINDid = 1000+k;
+	mWindowInfo.attributes = windAttr_EraseOnUpdate |
+	                         windAttr_Targetable |
+	                         windAttr_Enabled;
+	switch (k) {
+	 case PIWK_normal:
+	  mWindowInfo.attributes |= windAttr_Regular | 
+	                            windAttr_TitleBar |
+	                            windAttr_SizeBox |
+	                            windAttr_CloseBox |
+	                            windAttr_Resizable;
+	  mWindowInfo.layer = windLayer_Regular;
+	  break;
+	 case PIWK_dialog:
+	  mWindowInfo.attributes |= windAttr_Modal;
+	  mWindowInfo.layer = windLayer_Modal;
+	  break;
+	 case PIWK_floating:
+	  mWindowInfo.attributes |= windAttr_Floating |
+	                            windAttr_HideOnSuspend;
+	  mWindowInfo.layer = windLayer_Floating;
+	  break;
+	}
+	mWindowInfo.minimumWidth = 30;
+	mWindowInfo.minimumHeight = 30;
+	mWindowInfo.maximumWidth = 32000;
+	mWindowInfo.maximumHeight = 32000;
+	mWindowInfo.standardSize.width = sx;
+	mWindowInfo.standardSize.height = sy;
+	mWindowInfo.userCon = 0;
+	
+	mPane = new LWindow(mWindowInfo);
+	Rect r = {py, px, py+sy, px+sx};
+    ((LWindow*) mPane)->DoSetBounds(r);
+    SetLabel(nom);
+    ((LWindow*) mPane)->SetSuperCommander(LCommander::GetTopCommander());
+}
+
+
+PIWindowMac::~PIWindowMac()
+{}
+
+
+void PIWindowMac::Show()
+{
+  if (!finalized) {
+    FinishCreate();
+    finalized = true;
+  }
+  PIWindowGen::Show();
+}
Index: /tags/V_Saclay_110697/SophyaPI/PI/piwindowmac.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piwindowmac.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piwindowmac.h	(revision 50)
@@ -0,0 +1,22 @@
+#ifndef PIWINDOWMAC_H_SEEN
+#define PIWINDOWMAC_H_SEEN
+
+#include "piwindowgen.h"
+#include "pisysdep.h"
+#include <LWindow.h>
+
+class PIWindowMac : public PIWindowGen {
+public:
+                         PIWindowMac(PIMsgHandler *par, char *nom, PIWindowKind k=PIWK_normal,
+                                   int sx=10, int sy=10, int px=0, int py=0);
+  virtual                ~PIWindowMac();
+  virtual void           Show();
+
+protected:
+  SWindowInfo			  mWindowInfo;
+  Boolean				  finalized;
+};
+
+typedef PIWindowMac PIWindow;
+
+#endif
Index: /tags/V_Saclay_110697/SophyaPI/PI/piwindowx.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piwindowx.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piwindowx.cc	(revision 50)
@@ -0,0 +1,162 @@
+#include <stdio.h>
+
+#include "piwindowx.h"
+
+#include <X11/Xlib.h>
+
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/IntrinsicP.h>
+#include <X11/Shell.h>
+#include <Xm/Form.h>
+
+/* Fonctions (Callback et action) pour traiter le message Close de WM  */
+
+/* Nouvelle-Fonction */
+static void popdwn_cb(Widget /*w*/, XtPointer *usd,  XtPointer * )
+{
+PIWindowX * dw = (PIWindowX *) usd;
+dw->Process(dw->BuildMsg(dw->Msg(),PIMsg_Close), dw, NULL) ;
+}
+
+
+/* Nouvelle-Fonction */
+static int fgactl = 0;
+
+static void CloseWindow (Widget w, XEvent*, String*,Cardinal*)
+{
+XtCallCallbacks(w,  XtNpopdownCallback, NULL);
+}
+
+
+
+/* --Methode-- */
+PIWindowX::PIWindowX(PIMsgHandler *par, char *nom, PIWindowKind k, 
+                     int sx, int sy, int px, int py)
+: PIWindowGen(par, nom, k, -1, -1, 0, 0)
+{
+XtTranslations trans;
+
+pwm = new PIWdgX(NULL, nom, sx, sy, px, py);
+
+switch (k)
+  {
+  case PIWK_normal :
+  case PIWK_floating :
+    pwm->CreateXtWdg(nom, topLevelShellWidgetClass, NULL, sx, sy, px, py);
+    break;
+  case PIWK_dialog :
+    pwm->CreateXtWdg(nom, transientShellWidgetClass, NULL, sx, sy, px, py);
+    break;
+  case PIWK_transient :
+    pwm->CreateXtWdg(nom, overrideShellWidgetClass, NULL, sx, sy, px, py);
+    break;
+  }
+
+
+/*  Il faut "attraper" l'action close, genere par le window-manager       */
+/*  2 actions sont necessaires, installation d'une action (CloseWindow()) */
+/*  et j'utilise ensuite un callback ds CloseWindow()                     */
+/*  Il faut aussi desactiver l'action de destruction du widget par defaut */
+/*  (XtSetArg(warg, XmNdeleteResponse, ...                                */
+/*  Attention, voir la fonction Show(), pour l'appel a XSetWMProptocols() */
+/*  Pour une fenetre donnee, on peut recuperer les Map, UnMap, Destroy,   */
+/*  etc... il faut appeler XtAddEventHandler( w, Mask, ...)               */
+/*    Mask =  StructureNotifyMask | SubstructureNotifyMask                */
+
+
+
+if ((k == PIWK_normal) || (k == PIWK_floating) || (k == PIWK_dialog))
+  { 
+  if (k == PIWK_dialog)  AutoHideOnClose(false);
+  /* XtAddEventHandler(pwm->XtWdg(), StructureNotifyMask | SubstructureNotifyMask, 
+                  FALSE, wmaction_evthandler, this);*/
+
+  XtAddCallback(pwm->XtWdg(), XtNpopdownCallback,
+                (XtCallbackProc)popdwn_cb, (XtPointer)this);
+
+  if (!fgactl) 
+    { 
+    XtActionsRec desact = {"CloseWindow" ,CloseWindow};
+    XtAddActions(&desact, 1);  fgactl = 1; 
+    }
+
+  trans = XtParseTranslationTable("<Message>WM_PROTOCOLS:CloseWindow()");
+  XtOverrideTranslations(pwm->XtWdg() , trans);
+  Arg warg[2];
+  XtSetArg(warg[0], XmNdeleteResponse, XmDO_NOTHING);
+  XtSetValues(pwm->XtWdg(), warg, 1);
+  }
+
+CreateXtWdg(nom, xmFormWidgetClass, pwm->XtWdg(), sx, sy, 0, 0);
+}
+
+/* --Methode-- */
+PIWindowX::~PIWindowX()
+{
+delete pwm;
+}
+
+/* --Methode-- */
+void PIWindowX::SetBinding(PIBindingKind /*left*/, PIBindingKind /*top*/, 
+                           PIBindingKind /*right*/, PIBindingKind /*bottom*/)
+{
+// On ne doit rien faire pour les fenetres 
+return;
+}
+
+/* --Methode-- */
+void PIWindowX::SetSize(int sx, int sy)
+{
+pwm->SetSize(sx, sy);
+return;
+}
+
+/* --Methode-- */
+void PIWindowX::SetPos(int px, int py)
+{
+pwm->SetPos(px, py);
+return;
+}
+
+
+/* --Methode-- */
+void PIWindowX::Show()
+{
+int fgr = 0;
+Display *mdsp;
+
+mdsp = XtDisplay(pwm->XtWdg());
+
+PIContainerGen::Show();
+Manage();
+if (!XtIsRealized(pwm->XtWdg()))  fgr = 1;
+pwm->Manage();
+if (fgr) 
+  {
+  Atom wmd;
+  if ((mWtyp == PIWK_normal) || (mWtyp == PIWK_floating) || (mWtyp == PIWK_dialog))
+    { 
+    wmd = XInternAtom(mdsp, "WM_DELETE_WINDOW",False);
+    XSetWMProtocols(mdsp, XtWindow(pwm->XtWdg()), &wmd, 1);
+    }
+  else 
+    XSetTransientForHint(mdsp, XtWindow(PIXtTopWdg()), XtWindow(pwm->XtWdg()));
+  }
+
+// XRaiseWindow est necessaire, sinon la fenetre passe des fois derriere ...
+if (mWtyp == PIWK_transient)  
+  XRaiseWindow(mdsp, XtWindow(pwm->XtWdg()));
+ 
+return;
+}
+
+/* --Methode-- */
+void PIWindowX::Hide()
+{
+PIWindowGen::Hide();
+Unmanage();
+pwm->Unmanage();
+}
+
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/piwindowx.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/piwindowx.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/piwindowx.h	(revision 50)
@@ -0,0 +1,29 @@
+#ifndef PIWINDOWX_H_SEEN
+#define PIWINDOWX_H_SEEN
+
+#include "piwindowgen.h"
+#include "pisysdep.h"
+
+
+class PIWindowX : public PIWindowGen {
+public:
+                         PIWindowX(PIMsgHandler *par, char *nom, PIWindowKind k=PIWK_normal,
+                                   int sx=10, int sy=10, int px=0, int py=0);
+  virtual                ~PIWindowX();
+  
+  virtual void           SetBinding(PIBindingKind left, PIBindingKind top, 
+                                    PIBindingKind right, PIBindingKind bottom);
+  virtual void           SetSize(int sx, int sy);
+  virtual void           SetPos(int px, int py);  
+
+  virtual void           Show();
+  virtual void           Hide();
+
+protected:
+  PIWdgX   *pwm;
+
+};
+
+typedef PIWindowX PIWindow;
+
+#endif   /* PIWINDOWX_H_SEEN  */
Index: /tags/V_Saclay_110697/SophyaPI/PI/pixtbase.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pixtbase.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pixtbase.cc	(revision 50)
@@ -0,0 +1,378 @@
+#include <stdio.h>
+
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+
+#include <X11/IntrinsicP.h>
+#include <X11/CoreP.h>
+
+#include "pixtbaseP.h"
+#include "pixtbase.h"
+
+
+/*  Construction du widget Xt PIXtBase   */
+
+static void     init_class_pixtbase(void);
+
+static void     init_pixtbase    (Widget, Widget, ArgList, Cardinal*);
+static void     destroy_pixtbase (Widget);
+static void     resize_pixtbase  (Widget);
+static void     expose_pixtbase  (Widget, XEvent*, Region);
+
+
+static void     leave_pixtbase   (Widget, XEvent*, String* ,Cardinal*);
+static void     enter_pixtbase   (Widget, XEvent*, String* ,Cardinal*);
+static void     buu1_pixtbase    (Widget, XEvent*, String* ,Cardinal*);
+static void     bud1_pixtbase    (Widget, XEvent*, String* ,Cardinal*);
+static void     buu2_pixtbase    (Widget, XEvent*, String* ,Cardinal*);
+static void     bud2_pixtbase    (Widget, XEvent*, String* ,Cardinal*);
+static void     buu3_pixtbase    (Widget, XEvent*, String* ,Cardinal*);
+static void     bud3_pixtbase    (Widget, XEvent*, String* ,Cardinal*);
+static void     mov1_pixtbase    (Widget, XEvent*, String* ,Cardinal*);
+static void     mov2_pixtbase    (Widget, XEvent*, String* ,Cardinal*);
+static void     mov3_pixtbase    (Widget, XEvent*, String* ,Cardinal*);
+static void     keyb_pixtbase    (Widget, XEvent*, String* ,Cardinal*);
+
+
+static XtResource resources[] ={
+  {PIXNobject ,"Object", XtRPointer, sizeof(XtRPointer),
+   XtOffset(PIXtBaseWidget,  pixtbase.objet), XtRImmediate, (XtPointer)0},
+};
+
+/*
+static char translations[] =  "\
+                      <BtnDown>: bud1_pixtbase(None)\n\
+             Button1 <PtrMoved>: mov1_pixtbase(None)\n\
+                        <BtnUp>: buu1_pixtbase(None)\n\
+                          <Key>: keyb_pixtbase(None)";
+*/
+
+static XtActionsRec actions[] = 
+{
+  { "leave_pixtbase" , (XtActionProc)leave_pixtbase} ,
+  { "enter_pixtbase" , (XtActionProc)enter_pixtbase} ,
+  { "buu1_pixtbase" , (XtActionProc)buu1_pixtbase} ,
+  { "bud1_pixtbase" , (XtActionProc)bud1_pixtbase} ,
+  { "buu2_pixtbase" , (XtActionProc)buu2_pixtbase} ,
+  { "bud2_pixtbase" , (XtActionProc)bud2_pixtbase} ,
+  { "buu3_pixtbase" , (XtActionProc)buu3_pixtbase} ,
+  { "bud3_pixtbase" , (XtActionProc)bud3_pixtbase} ,
+  { "mov1_pixtbase" , (XtActionProc)mov1_pixtbase} ,
+  { "mov2_pixtbase" , (XtActionProc)mov2_pixtbase} ,
+  { "mov3_pixtbase" , (XtActionProc)mov3_pixtbase} ,
+  { "keyb_pixtbase" , (XtActionProc)keyb_pixtbase} ,
+};
+
+PIXtBaseClassRec  piXtBaseClassRec = {
+/* Core Class Part */
+{
+
+(WidgetClass) &coreClassRec,    /* pointer to superclass ClassRec   */
+"PIXtBase",         		/* widget resource class name       */
+sizeof(PIXtBaseRec),	        /* size in bytes of widget record   */
+init_class_pixtbase,            /* class_initialize                 */
+NULL, 			        /* dynamic initialization           */
+FALSE,       		        /* has class been initialized?      */
+init_pixtbase,                  /* initialize                       */
+NULL,			        /* notify that initialize called    */
+XtInheritRealize,               /* XCreateWindow for widget         */
+actions,     		        /* widget semantics name to proc map*/
+XtNumber(actions),              /* number of entries in actions     */
+resources,                      /* resources             */
+XtNumber(resources),            /* resources             */
+NULLQUARK,		        /* resource class quarkified        */
+TRUE,			        /* compress MotionNotify for widget */
+TRUE,			        /* compress Expose events for widget*/
+TRUE,			        /* compress enter and leave events  */
+TRUE,			        /* select for VisibilityNotify      */
+destroy_pixtbase,	        /* free data for subclass pointers  */
+resize_pixtbase,                /* geom manager changed widget size */
+expose_pixtbase,       	        /* rediplay window                  */
+NULL,		                /* set subclass resource values     */
+NULL,			        /* notify that set_values called    */
+XtInheritSetValuesAlmost,       /* set_values got "Almost" geo reply*/
+NULL,		                /* notify that get_values called    */
+XtInheritAcceptFocus,           /* assign input focus to widget     */
+XtVersion,	                /* version of intrinsics used       */
+NULL,		                /* list of callback offsets         */
+// translations,	        /* state machine                    */
+NULL,                           /* state machine                    */
+XtInheritQueryGeometry,         /* return preferred geometry        */
+XtInheritDisplayAccelerator,    /* display your accelerator         */
+NULL		                /* pointer to extension record      */
+}
+/* PIXtBase */
+,{   NULL }
+
+};
+
+WidgetClass piXtBaseWidgetClass = (WidgetClass) &piXtBaseClassRec;
+
+
+/* Nouvelle-Fonction */
+static void init_class_pixtbase()
+{
+#ifdef DEBUG_PIXTB
+puts("Debug_init_class_pixtbase() ");
+#endif
+return;
+}
+
+/* Nouvelle-Fonction */
+static void init_pixtbase (Widget request, Widget wdg,
+                          ArgList /*args*/, Cardinal* /*narg*/)
+{
+PIXtBaseWidget wdgp;
+wdgp = (PIXtBaseWidget)wdg;
+
+if(request->core.width<=0)  wdgp->core.width  = 10;
+if(request->core.height<=0) wdgp->core.height = 10;
+// get_GCs (wdgp);
+#ifdef DEBUG_PIXTB
+printf("Debug_init_pixtbase: Object= %ld  narg=%d \n", 
+(long)(wdgp->pixtbase.objet), (int)(*narg));
+#endif
+return;
+}
+
+/* Nouvelle-Fonction */
+static void destroy_pixtbase (Widget /*wdgp*/)
+{
+#ifdef DEBUG_PIXTB
+puts("Debug_destroy_pixtbase");
+#endif
+// free_GCs((PIXtBaseWidget)wdgp);
+}
+
+
+/* Nouvelle-Fonction */
+static void resize_pixtbase (Widget wdgp)
+{
+if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 
+  (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Resize();
+return;
+}
+
+/* Nouvelle-Fonction */
+static void expose_pixtbase (Widget  wdgp, XEvent* /*event*/, Region region)
+{
+#ifdef DEBUG_PIXTB
+printf ("debug:expose %ld\n",(long)((PIXtBaseWidget)wdgp)->pixtbase.objet);
+#endif
+
+if ( ((PIXtBaseWidget)wdgp)->pixtbase.objet ) 
+  {
+  XRectangle  xrec;
+  int x0, y0, dx, dy;
+  XClipBox(region, &xrec);
+  x0 = xrec.x;  y0 = xrec.y;
+  dx = xrec.width;  dy = xrec.height;
+  (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Draw(x0, y0, dx, dy);
+  }
+return;
+}
+
+/* Nouvelle-Fonction */
+static void enter_pixtbase (Widget wdgp, XEvent* /*evt*/, 
+                            String* /*args*/, Cardinal* /*narg*/)
+{
+if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 
+   (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Enter();
+return;
+}
+
+/* Nouvelle-Fonction */
+static void leave_pixtbase (Widget wdgp, XEvent* /*evt*/, 
+                            String* /*args*/, Cardinal* /*narg*/)
+{
+if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 
+   (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Leave();
+return;
+}
+
+/* Nouvelle-Fonction */
+static void bud1_pixtbase (Widget wdgp, XEvent* evt, 
+                           String* /*args*/, Cardinal* /*narg*/)
+
+{
+if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 
+  {
+  int x,y;
+  x = evt->xbutton.x;
+  y = evt->xbutton.y;
+  (((PIXtBaseWidget)wdgp)->pixtbase.objet)->But1Press(x,y);
+  }
+return;
+}
+
+/* Nouvelle-Fonction */
+static void buu1_pixtbase (Widget wdgp, XEvent* evt, 
+                           String* /*args*/, Cardinal* /*narg*/)
+
+{
+if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 
+  {
+  int x,y;
+  x = evt->xbutton.x;
+  y = evt->xbutton.y;  
+  (((PIXtBaseWidget)wdgp)->pixtbase.objet)->But1Release(x,y);
+  }
+return;
+}
+/* Nouvelle-Fonction */
+static void bud2_pixtbase (Widget wdgp, XEvent* evt, 
+                           String* /*args*/, Cardinal* /*narg*/)
+
+{
+if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 
+  {
+  int x,y;
+  x = evt->xbutton.x;
+  y = evt->xbutton.y;  
+  (((PIXtBaseWidget)wdgp)->pixtbase.objet)->But2Press(x,y);
+}
+return;
+}
+
+/* Nouvelle-Fonction */
+static void buu2_pixtbase (Widget wdgp, XEvent* evt, 
+                           String* /*args*/, Cardinal* /*narg*/)
+{
+if (((PIXtBaseWidget)wdgp)->pixtbase.objet)
+  { 
+  int x,y;
+  x = evt->xbutton.x;
+  y = evt->xbutton.y;  
+  (((PIXtBaseWidget)wdgp)->pixtbase.objet)->But2Release(x,y);
+  }
+return;
+}
+
+
+/* Nouvelle-Fonction */
+static void bud3_pixtbase (Widget wdgp, XEvent* evt, 
+                           String* /*args*/, Cardinal* /*narg*/)
+
+{
+if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 
+  {
+  int x,y;
+  x = evt->xbutton.x;
+  y = evt->xbutton.y;  
+  (((PIXtBaseWidget)wdgp)->pixtbase.objet)->But3Press(x,y);
+}
+return;
+}
+
+/* Nouvelle-Fonction */
+static void buu3_pixtbase (Widget wdgp, XEvent* evt, 
+                           String* /*args*/, Cardinal* /*narg*/)
+
+{
+if (((PIXtBaseWidget)wdgp)->pixtbase.objet) 
+  {
+  int x,y;
+  x = evt->xbutton.x;
+  y = evt->xbutton.y;  
+  (((PIXtBaseWidget)wdgp)->pixtbase.objet)->But3Release(x,y);
+}
+return;
+}
+
+/* Nouvelle-Fonction */
+static void mov1_pixtbase (Widget wdgp, XEvent* evt, 
+                           String* /*args*/, Cardinal* /*narg*/)
+{
+if (((PIXtBaseWidget)wdgp)->pixtbase.objet)  
+  {
+  int x,y;
+  x = evt->xbutton.x;
+  y = evt->xbutton.y;  
+  (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Ptr1Move(x,y);
+  }
+return;
+}
+
+/* Nouvelle-Fonction */
+static void mov2_pixtbase (Widget wdgp, XEvent* evt, 
+                           String* /*args*/, Cardinal* /*narg*/)
+{
+if (((PIXtBaseWidget)wdgp)->pixtbase.objet)  
+  {
+  int x,y;
+  x = evt->xbutton.x;
+  y = evt->xbutton.y;  
+  (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Ptr2Move(x,y);
+  }
+return;
+}
+
+/* Nouvelle-Fonction */
+static void mov3_pixtbase (Widget wdgp, XEvent* evt, 
+                           String* /*args*/, Cardinal* /*narg*/)
+{
+if (((PIXtBaseWidget)wdgp)->pixtbase.objet)  
+  {
+  int x,y;
+  x = evt->xbutton.x;
+  y = evt->xbutton.y;  
+  (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Ptr3Move(x,y);
+  }
+return;
+}
+
+/* Nouvelle-Fonction */
+static void keyb_pixtbase (Widget wdgp, XEvent* evt, 
+                           String* /*args*/, Cardinal* /*narg*/)
+{
+if (((PIXtBaseWidget)wdgp)->pixtbase.objet)  
+  {
+  XComposeStatus cs;
+  KeySym key;
+  char buf[10];
+  int i,nc;
+  PIKeyModifier kmod;
+  
+  kmod = PIKM_Blank;
+
+  nc = XLookupString(&(evt->xkey), buf, 10, &key, &cs);
+  if (nc <= 0)  return;
+  if  (evt->xkey.state & ShiftMask)   
+    kmod = (PIKeyModifier) (kmod | PIKM_Shift);
+  if  (evt->xkey.state & ControlMask) 
+    kmod = (PIKeyModifier) (kmod | PIKM_Cntl);
+  if  (evt->xkey.state & Mod2Mask)    
+    kmod = (PIKeyModifier) (kmod | PIKM_Alt);
+  for(i=0; i<nc; i++)  
+    (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Keyboard((int)(buf[i]), kmod);
+  }
+return;
+}
+
+
+/* Nouvelle-Fonction 
+static void get_GCs (PIXtBaseWidget wdgp)
+{
+
+XGCValues       values;
+XtGCMask        mask;
+Display *dpy;
+
+dpy = XtDisplay(wdgp);
+
+mask              = GCForeground | GCBackground ;
+values.foreground = WhitePixel(dpy, XDefaultScreen(dpy));
+values.background = BlackPixel(dpy, XDefaultScreen(dpy));
+wdgp->pixtbase.defgc      = XtGetGC((Widget) wdgp, mask, &values);
+return;
+}
+*/
+
+/* Nouvelle-Fonction 
+static void free_GCs (PIXtBaseWidget wdgp)
+{
+XtReleaseGC ((Widget) wdgp, wdgp->pixtbase.defgc);
+}
+
+*/
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/pixtbase.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pixtbase.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pixtbase.h	(revision 50)
@@ -0,0 +1,16 @@
+/* Widget Xt pour construction Widget C++  Interface Public  */
+/*                                    Reza 10/95             */
+
+#ifndef PIXTBASE_H_SEEN
+#define PIXTBASE_H_SEEN
+
+#include <X11/Intrinsic.h>
+ 
+typedef struct _PIXtBaseClassRec * PIXtBaseWidgetClass;
+typedef struct _PIXtBaseRec      * PIXtBaseWidget;
+
+#define PIXNobject      "object"
+
+extern WidgetClass piXtBaseWidgetClass;
+
+#endif /* PIXTBASE_H_SEEN */
Index: /tags/V_Saclay_110697/SophyaPI/PI/pixtbaseP.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/pixtbaseP.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/pixtbaseP.h	(revision 50)
@@ -0,0 +1,40 @@
+/* Widget Xt pour affichage d'image   Declaration privee  */
+/*                                      Reza 10/95        */
+
+
+#ifndef PIXTBASEP_H_SEEN
+#define PIXTBASEP_H_SEEN
+
+#include "pibwdgx.h"
+
+typedef struct
+{
+   void * mumble;   /* No new procedures */
+} PIXtBaseClassPart;
+
+
+typedef struct _RzXBaseClassRec
+{
+CoreClassPart		core_class;
+PIXtBaseClassPart	pixtbase_class;
+} PIXtBaseClassRec;
+
+typedef struct
+{
+PIBaseWdgX  * objet; 
+} PIXtBasePart;
+
+
+typedef struct _PIXtBaseRec
+{
+CorePart		core;
+PIXtBasePart		pixtbase;
+} PIXtBaseRec;
+
+extern PIXtBaseClassRec piXtBaseClassRec;
+
+
+#endif /* PIXTBASEP_H_SEEN */
+
+
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/psfile.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/psfile.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/psfile.cc	(revision 50)
@@ -0,0 +1,926 @@
+/*
+ *   PSFile.cc
+ *   
+ *   19/06/96
+ *
+ *   Modification le 01/03/96
+ *    - fusion psfile.cc - psdict.cc
+ *
+ */
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <time.h>
+
+#include "psfile.h"
+
+/* En cm */
+#define  MIN_SIZE_IN_PAGE  2.
+
+/*
+ *  Dictionnaire PIDict
+ *
+ *  Contient les fonctions suivantes : 
+ *
+ *
+ */
+#define PIDICT_PAR   \
+  \
+  PI_Landscape, PI_Portrait,\
+  \
+  PI_Black, PI_White, PI_Grey, PI_Red, PI_Blue,\
+  PI_Green, PI_Yellow, PI_Magenta, PI_NotDefColor,\
+  \
+  PI_RomanFont, PI_BoldFont, PI_ItalicFont, PI_NotDefFontAtt,\
+  PI_SmallSizeFont, PI_NormalSizeFont, PI_BigSizeFont, PI_NotDefFontSize, \
+  \
+  PI_NormalLine, PI_ThinLine, PI_ThickLine, PI_NotDefLineAtt
+
+#define PIDICT       "\
+/$PIDict 50 dict def\n\
+$PIDict begin $PIDict /mtrx matrix put /Landscape %d def /Portrait %d def\n\
+%% Couleurs et fontes courantes\n\
+/C%-2d  {0.0   0.0   0.0   setrgbcolor} bind def %% PI_Black\n\
+/C%-2d  {0.996 0.996 0.996 setrgbcolor} bind def %% PI_White\n\
+/C%-2d  {0.824 0.824 0.824 setrgbcolor} bind def %% PI_Grey\n\
+/C%-2d  {0.996 0.0   0.0   setrgbcolor} bind def %% PI_Red\n\
+/C%-2d  {0.0   0.0   0.996 setrgbcolor} bind def %% PI_Blue\n\
+/C%-2d  {0.0   0.996 0.0   setrgbcolor} bind def %% PI_Green\n\
+/C%-2d  {0.996 0.996 0.0   setrgbcolor} bind def %% PI_Yellow\n\
+/C%-2d  {0.996 0.0   0.996 setrgbcolor} bind def %% PI_Magenta\n\
+/C%-2d  {}                              bind def %% PI_NotDefColor\n\
+/F%-2d  {/Times-Roman   findfont} bind def       %% PI_RomanFont\n\
+/F%-2d  {/Times-Bold    findfont} bind def       %% PI_BoldFont\n\
+/F%-2d  {/Times-Italic  findfont} bind def       %% PI_ItalicFont\n\
+/F%-2d  {}\
+                        bind def       %% PI_NotDefFontAtt\n\
+/FS {scalefont setfont} bind def\n\
+%%/FS%-2d {8  scalefont setfont} bind def          %% PI_SmallSizeFont\n\
+%%/FS%-2d {12 scalefont setfont} bind def          %% PI_NormalSizeFont\n\
+%%/FS%-2d {16 scalefont setfont} bind def          %% PI_BigSizeFont\n\
+/FS%-2d {}                     bind def          %% PI_NotDefFontSize\n\
+/L%-2d  {1    slw} bind def                      %% PI_NormalLine\n\
+/L%-2d  {0.5  slw} bind def                      %% PI_ThinLine\n\
+/L%-2d  {3    slw} bind def                      %% PI_ThickLine\n\
+/L%-2d  {}         bind def                      %% PI_NotDefLineAtt\n\
+\
+%% Conversion\n\
+/cm   {28.3 mul}   bind def  %% cm --> points\n\
+/Ux   {$Cvrtx mul} bind def  %% Unites utilisateur /x --> points\n\
+/Uy   {$Cvrty mul} bind def  %% Unites utilisateur /y --> points\n\
+\
+%% Pages et Blocs\n\
+/newref  {%% Dx Dy Tx Ty X0 Y0 newref\n\
+translate 3 -1 roll cm div 28.3 mul /$Cvrty exch def\n\
+exch cm div 28.3 mul /$Cvrtx exch def} bind def\n\
+/NewPage {%% Dx Dy orientation NewPage\n\
+/$PageEnteredState save def 1 -1 scale Portrait eq {w cm h cm 0 h cm neg\n\
+newref} { -90 rotate h cm w cm 0 0 newref} ifelse} bind def\n\
+/EndPage { %% EndPage\n\
+$PageEnteredState restore} bind def\n\
+/NewBloc { %% Dx Dy Tx Ty X0 Y0 NewBloc\n\
+/$BlocEnteredState save def newref} bind def\n\
+/EndBloc { %% EndBloc\n\
+$BlocEnteredState restore} bind def\n\
+\
+%% Trace\n\
+/n  {newpath} bind def    /c  {closepath} bind def\n\
+/gs {gsave}  bind def     /gr {grestore} bind def\n\
+/m  {moveto} bind def     /l  {lineto} bind def\n\
+/s  {stroke} bind def     /f  {fill}   bind def\n\
+/sc {scale}  bind def     /S  {gs 1 -1 sc show gr} bind def \n\
+/slw {setlinewidth} bind def\n\
+/ff {findfont} bind def   /sf {setfont} bind def /scf {scalefont} bind def\n\
+/rl {rlineto} bind def    /tr {translate} bind def\n\
+%% Tx Ty X0 Y0 box\n\
+/box {tr 0 3 1 roll neg exch 0 0 3 index neg 0 0 m rl rl rl c} bind def\n\
+%% R X0 Y0 circle\n\
+/circle {tr dup 0 m 0 0 3 -1 roll 0 380 arc} bind def\n\
+%% DrawEllipse pompee sur transfig\n\
+/ellipse {/endangle exch def /startangle exch def /yrad exch def\n\
+/xrad exch def /y exch def /x exch def /savematrix mtrx currentmatrix def\n\
+x y tr xrad yrad sc 0 0 1 startangle endangle arc\n\
+closepath savematrix setmatrix } def\n\
+\
+%% Gestion des images\n\
+%% ColorImage, pompee sur xv (qui les avait pompees sur xgrab)\n\
+/colorimage where   %% do we know about 'colorimage'?\n\
+  { pop }           %% yes: pop off the 'dict' returned\n\
+  {                 %% no:  define one\n\
+    /colortogray {  %% define an RGB->I function\n\
+      /rgbdata exch store    %% call input 'rgbdata'\n\
+      rgbdata length 3 idiv\n\
+      /npixls exch store\n\
+      /rgbindx 0 store\n\
+      0 1 npixls 1 sub {\n\
+        grays exch\n\
+        rgbdata rgbindx       get 20 mul    %% Red\n\
+        rgbdata rgbindx 1 add get 32 mul    %% Green\n\
+        rgbdata rgbindx 2 add get 12 mul    %% Blue\n\
+        add add 64 idiv      %% I = .5G + .31R + .18B\n\
+        put\n\
+        /rgbindx rgbindx 3 add store\n\
+      } for\n\
+      grays 0 npixls getinterval\n\
+    } bind def\n\
+    /mergeprocs { %% def\n\
+      dup length 3 -1 roll dup length dup 5 1 roll 3 -1 roll add\n\
+      array cvx dup 3 -1 roll 0 exch putinterval dup 4 2 roll\n\
+      putinterval } bind def\n\
+    /colorimage {\n\
+      pop pop     %% remove 'false 3' operands\n\
+      {colortogray} mergeprocs image} bind def\n\
+  } ifelse          %% end of 'false' case\n\
+\
+%% GetRGB\n\
+/GetRGB { %% ImageStr --> RGBStr\n\
+  /ImageData exch store\n\
+  %% Pour chaque element de ImageData,\n\
+  %% On va chercher les valeurs RGB correspondantes\n\
+  0 1 Taille 1 sub {\n\
+    /i      exch store  %% On met a jour l'indice de parcours\n\
+    ImageData i get     %% Recupere la Indice e val dans la chaine ImData\n\
+    ColorMap exch get   %% On recupere la valeur RGB Correspondante\n\
+    aload pop           %% On met tout ca dans la pile\n\
+    %% Maintenant, on va mettre tout ca dans la chaine RGBStr\n\
+    RGBStr i 3 mul 2 add 3 -1 roll put\n\
+    RGBStr i 3 mul 1 add 3 -1 roll put\n\
+    RGBStr i 3 mul       3 -1 roll put\n\
+    } for\n\
+  RGBStr 0 Taille 3 mul getinterval %% On renvoie la chaine RGB\n\
+} bind def\n\
+end\n\
+"
+
+
+
+/* 
+ *  Les PIMarkers sont definis et geres commes des fontes
+ *
+ *
+ */
+#define PIMARKERS_PAR  PI_DotMarker, PI_PlusMarker, PI_CrossMarker,\
+  PI_CircleMarker, PI_FCircleMarker, PI_BoxMarker, PI_FBoxMarker,\
+  PI_TriangleMarker, PI_FTriangleMarker, PI_StarMarker, PI_FStarMarker
+
+#define PIMARKERS  "\
+%% Definition de la fonte $PIMarkers\n\
+/$PIMarkers 26 dict def\n\
+$PIMarkers begin\n\
+/FontType 3 def\n\
+/FontMatrix [0.001 0 0 0.001 -0.375 -0.375] def\n\
+/FontBBox   [0 0 1000 1000] def\n\
+/Encoding 256 array def\n\
+0 1 255 {Encoding exch /.notdef put} for\n\
+Encoding  %d /PIDot       put %% PI_DotMarker\n\
+Encoding  %d /PIPlus      put %% PI_PlusMarker\n\
+Encoding  %d /PICross     put %% PI_CrossMarker\n\
+Encoding  %d /PICircle    put %% PI_CircleMarker\n\
+Encoding  %d /PIFCircle   put %% PI_FCircleMarker\n\
+Encoding  %d /PIBox       put %% PI_BoxMarker\n\
+Encoding  %d /PIFBox      put %% PI_FBoxMarker\n\
+Encoding  %d /PITriangle  put %% PI_TriangleMarker\n\
+Encoding  %d /PIFTriangle put %% PI_FTriangleMarker\n\
+Encoding  %d /PIStar      put %% PI_StarMarker\n\
+Encoding  %d /PIFStar     put %% PI_FStarMarker\n\
+/CharProcs 26 dict def\n\
+$PIDict begin\n\
+CharProcs begin\n\
+/.notdef     {} def\n\
+/PIDot       {100 375 375 circle f} bind def\n\
+/PIPlus      {0 375 m 750 375 l 375 0 m 375 750 l s} bind def\n\
+/PICross     {0 0 m 750 750 l 750 0 m 0 750 l s} bind def\n\
+/PICircle    {375 375 375 circle s} bind def\n\
+/PIFCircle   {375 375 375 circle f} bind def\n\
+/PIBox       {0 0 m 750 0 l 750 750 l 0 750 l c s} bind def\n\
+/PIFBox      {0 0 m 750 0 l 750 750 l 0 750 l c f} bind def\n\
+/PITriangle  {0 750 m 375 0 l 750 750 l c s} bind def\n\
+/PIFTriangle {0 750 m 375 0 l 750 750 l c f} bind def\n\
+/PIStar      {} def\n\
+/PIFStar     {} def\n\
+end %%$PIDict\n\
+end %%$CharProcs\n\
+/BuildChar {\n\
+1000 0      %% Largeur \n\
+0 0 750 750 %% Bounding Box\n\
+setcachedevice \n\
+exch begin\n\
+Encoding exch get\n\
+CharProcs exch get\n\
+end exec} def\n\
+end\n\
+/PIMarkers $PIMarkers definefont pop\n\
+save\n\
+"
+
+/* Dimensions des divers formats */
+  struct PaperSize {
+      float width ;
+      float height ;
+  };
+struct PaperSize PaperSizeTable[] = {
+    { 0.0,  0.0},    /* PI_NotDefFormat */
+    {21.0, 29.7},    /* PI_A4 */
+    {29.7, 42.0},    /* PI_A3 */
+    {14.8, 21.0}     /* PI_A5 ? */
+} ;
+
+
+float cm2pt(float x);
+
+
+/* Fonction WriteHeader */
+#define END_PROLOG_PAR  PAGE_WIDTH, PAGE_HEIGHT
+#define END_PROLOG  "/NewFile { %%%% w h NewFile (--> h et w en cm <--)\n\
+$PIDict begin /PIMarkers ff 14 scf sf /h exch def /w exch def \n\
+/$PIEnteredState save def} bind def\n\
+/EndFile {$PIEnteredState restore end} bind def\n\
+%%%%EndProlog\n\n\
+"
+
+#define HEADER     "\
+%%%%Title: %s\n\
+%%%%Creator: PSFile\n\
+%%%%CreationDate: %s\
+%%%%Pages: (atend)\n\
+%%%%EndComments\n\n\
+"
+
+
+/* 
+ *   PostScript encapsule...
+ * 
+ *   Attention la bounding Box ne sera specifiee 
+ *     qu'au premier NewPage() --> definie dans 
+ *     le champ "Trailer" 
+ *
+ */
+PSFile::PSFile(char * FileName, float sc) 
+    : mPSFileName(FileName==NULL? "unnamed.eps" : FileName),
+      Tw (-1.), Th(-1.),         /* Non specifies pour du eps  */
+      WMargin (-1), HMargin(-1), /* Non specifiees en eps  */ 
+      isEPS(1),
+      scale(sc),                 /* Defaut : 1. */
+      mPaperSize(PI_NotDefPaperSize), /* Non specifiee en eps */
+      PageCounter(0),            /* Fichier vide */
+      FileEmpty(1),              /* Fichier vide */
+      currentPage(NULL),
+      currentBloc(NULL),
+      mDrawColor(PI_Black),
+      mFillColor(PI_Black),
+      mFontAtt(PI_RomanFont),
+      mFontSize(PI_NormalSizeFont),
+      mLineAtt(PI_NormalLine),
+      mMarker(PI_DotMarker)
+{
+    char*  date = new (char[64] ) ; 
+    time_t timer ; 
+
+    /* Ouverture du fichier en mode w+ */
+    if ( (mPSFile = fopen(FileName, "w+")) == NULL){
+	  perror (FileName);
+	  return;
+    }
+
+    /* Ecriture du Header  */
+    fprintf(mPSFile, "%%!PS-Adobe-2.0 EPSF-2.0\n");
+    fprintf(mPSFile, "%%%%BoundingBox: ");
+    /* 
+     * Les dimensions de la BB seront notees ici lors du 
+     * premier appel a NewPage
+     *
+     * C'est laid... si qqn a une meilleure idee...
+     */
+    boundingBox = ftell(mPSFile) ; 
+    fprintf(mPSFile, "                       \n");
+
+    time(&timer) ; 
+    date = ctime(&timer) ; 
+    fprintf(mPSFile, HEADER, mPSFileName, date) ; /* titre, date etc... */
+    fprintf(mPSFile, PIDICT, PIDICT_PAR) ;        /* Dictionnaire */
+    fprintf(mPSFile, PIMARKERS, PIMARKERS_PAR) ;  /* Fonte "PIMARKERS" */
+    //    fprintf(mPSFile, END_PROLOG) ;
+    /* Aucun format n'est specifie ici ... */
+    fprintf(mPSFile, "$PIDict begin /PIMarkers ff 14 scf sf\n") ;
+    fprintf(mPSFile, "/FState save def\n%%%%EndProlog\n\n") ;
+}
+
+
+
+/*
+ *  PostScript simple...
+ *
+ *
+ */
+PSFile::PSFile(char *FileName,
+	       PIOrientation orientation,
+	       PIPaperSize   paperSize,
+	       float marginX, float marginY)
+ :  mPSFileName (FileName == NULL ? "unnamed.ps" : FileName),
+    Tw(PaperSizeTable[paperSize].width),  /* Format papier utilise */
+    Th(PaperSizeTable[paperSize].height), /*                       */
+    WMargin(marginX),
+    HMargin(marginY),
+    isEPS(0),
+    scale(0.),
+    PageCounter(0),  /* Fichier vide */
+    FileEmpty(1),    /*              */
+    currentPage(NULL),
+    currentBloc(NULL),
+    mDrawColor(PI_Black),
+    mFillColor(PI_Black),
+    mFontAtt(PI_RomanFont),
+    mFontSize(PI_NormalSizeFont),
+    mLineAtt(PI_NormalLine),
+    mMarker(PI_DotMarker) 
+{
+    char * date = new(char[64]) ; 
+    time_t timer ; 
+
+    /* Ouverture du fichier, en mode w+ (tout est ecrase) */
+    if ( (mPSFile = fopen(FileName, "w+")) == NULL){
+	  perror (FileName);
+	  return;
+    }
+
+    /* Format et orientation */
+
+    /* Ecriture du Header  */
+    fprintf(mPSFile, "%%!PS-Adobe-2.0\n") ;
+    time(&timer) ; 
+    date = ctime(&timer) ; 
+    fprintf(mPSFile, HEADER, mPSFileName, date) ; /* titre, date etc... */
+    fprintf(mPSFile, PIDICT, PIDICT_PAR) ;        /* Dictionnaire */
+    fprintf(mPSFile, PIMARKERS, PIMARKERS_PAR) ;  /* Fonte "PIMARKERS" */
+    fprintf(mPSFile, "$PIDict begin /PIMarkers ff 14 scf sf\n") ;
+    fprintf(mPSFile, "/FState save def\n%%%%EndProlog\n\n") ;
+}
+
+
+/* 
+ * Destructeur
+ *
+ */
+PSFile::~PSFile () {
+
+    /* On ferme tout ce qui ne l'est pas */
+    if (currentBloc) PSFile::EndBloc();
+    if (currentPage) PSFile::EndPage();
+
+    /* Si le fichier est vide, on le detruit */
+    if (FileEmpty) remove(mPSFileName);
+
+    /* On ecrit le "Trailer" et on ferme */
+    else {
+	/* On restore l'etat initial */
+	fprintf(mPSFile,"FState restore\n") ;
+	fprintf(mPSFile, "%%%%Trailer\n%%%%Pages: %d\n%%%%EOF\n", 
+		PageCounter) ;
+	fclose (mPSFile);
+    }
+}
+
+
+int   PSFile::IsEPS(){
+
+    return(isEPS);
+}
+
+
+char* PSFile::GetFileName() {
+
+    return(mPSFileName);
+}
+
+PIColors PSFile::GetDrawColor() {
+
+    return(mDrawColor);
+}
+
+PIColors PSFile::GetFillColor() {
+
+    return(mFillColor);
+}
+
+PIFontAtt PSFile::GetFontAtt() {
+
+    return(mFontAtt);
+}
+
+PIFontSize PSFile::GetFontSize() {
+
+    return(mFontSize);
+}
+
+PILineAtt PSFile::GetLineAtt() {
+
+    return(mLineAtt);
+}
+
+PIMarker PSFile::GetMarker() {
+
+    return(mMarker);
+}
+
+void  PSFile::NewPage(float Dx, float Dy, PIOrientation orientation) {
+
+float  tw, th; /* largeur & hauteur corrigees des marges */
+
+    /* On ferme ce qui doit l'etre ... */
+    if (currentPage) PSFile::EndPage();
+
+    currentPage = new (Page) ; 
+
+    /* Initialisations */
+    currentPage->num = ++PageCounter;
+    currentPage->BlocCounter = 0;
+    currentPage->Dx = Dx;
+    currentPage->Dy = Dy;
+    currentPage->orientation = orientation ;
+
+    /* Position du debut AVANT D'ECRIRE! */
+    currentPage->begin  = ftell(mPSFile);
+
+    /* On ecrit dans le fichier */
+    fprintf(mPSFile, "%%%%Page: %d %d\n", PageCounter, PageCounter) ;
+    fprintf(mPSFile, "/PState save def 1 -1 scale\n");
+
+    /* 
+     *  Si eps : Portrait || Auto == on laisse tel que
+     *           Landscape == on tourne de -90 degres
+     */
+    if(isEPS) {
+	if( (orientation == PI_Portrait) || (orientation == PI_Auto) )
+	    fprintf(mPSFile,
+		    "%.2f %.2f %.2f %.2f %.2f %.2f newref\n",
+		    Dx, Dy, Dx*scale, Dy*scale, 0., -Dy*scale);
+	else
+	    if(orientation==PI_Landscape)
+		fprintf(mPSFile, 
+			"-90 rotate %.2f %.2f %.2f %.2f %.2f %.2f newref\n",
+			Dx, Dy, Dx*scale, Dy*scale, 0., 0.);
+	    else
+		fprintf(stderr, "Orientation Error ; Page : %d\n",
+			currentPage->num) ; 
+    /* 
+     * On specifie la bb 
+     * (Si non encore fait par un appel precedent a NewPage() ) 
+     */
+	if(boundingBox) {
+	    currentPage->tmp = ftell(mPSFile) ;
+	    fseek(mPSFile,boundingBox,SEEK_SET) ;
+	    if( (orientation == PI_Portrait) || (orientation == PI_Auto) )
+		fprintf(mPSFile, "%d %d %d %d", 0, 0, 
+			(int)(Dx*scale), (int)(Dy*scale) ) ; 
+	    else
+		fprintf(mPSFile, "%d %d %d %d", 0, 0, 
+			(int)(Dy*scale), (int)(Dx*scale) ) ;
+	    fseek(mPSFile,currentPage->tmp,SEEK_SET) ;
+	    boundingBox = 0 ; 
+	} /* BB */
+    } /* EPS */
+    /*
+     * Si ps : 
+     *   - soustraction marges --> rectangle utile.
+     *   - Si PI_Auto : On fait au mieux pour minimiser le 
+     *      redimensionnement...
+     *   - Si PI_Portrait, on ne fait rien, sauf 
+     *      peut-etre un redimensionnement pour rentrer dans les marges
+     *   - Si PI_Landscape, on tourne de -90 degres.
+     */
+    else {
+	/* Eviter image reduite a un point...ou moins... */
+	if((tw = Tw - 2*WMargin) < (Tw/10)) {
+	    WMargin = (0.45)*Tw ;
+	    tw = Tw/10;
+	}
+	if((th = Th - 2*HMargin)< (Th/10)) {
+	    HMargin = (0.45)*Th ;
+	    th = Th/10;
+	}
+	/* Portrait ou Landscape ? */
+	if(orientation == PI_Auto) 
+	    if( ((tw < th) && (Dx < Dy)) ||
+		((tw > th) && (Dx > Dy) )) 
+		currentPage->orientation = PI_Portrait ;
+	    else 
+		currentPage->orientation = PI_Landscape ;
+
+	if(currentPage->orientation == PI_Portrait) {
+	    if( (tw/Dx) < (th/Dy) ) 
+		scale = tw/Dx ;
+	    else 
+		scale = th/Dy;
+	    fprintf(mPSFile, 
+		    "%.2f %.2f %.2f cm %.2f cm %.2f cm %.2f cm newref\n",
+		    Dx, Dy, 
+		    Dx*scale, Dy*scale, 
+		    0.5*(Tw-tw), -0.5*(Th+th)) ;
+	}
+	if(currentPage->orientation == PI_Landscape) {
+	    /* Idem avec X<->Y */
+	    if( (th/Dx) < (th/Dy) ) 
+		scale = th/Dx;
+	    else
+		scale = tw/Dy ;
+	    fprintf(mPSFile,
+	       "-90 rotate %.2f %.2f %.2f cm %.2f cm %.2f cm %.2f cm newref\n",
+	       Dx, Dy,
+	       Dx*scale, Dy*scale, 
+	       0.5*(Th-th), 0.5*(Tw-tw));
+	}
+    } /* End if .ps */
+currentPage->tmp = ftell(mPSFile);
+}
+
+
+
+void  PSFile::EndPage() {
+
+    /* Si rien a fermer, on s'en va */
+    if ( ! currentPage ) return;
+
+    /* Si un bloc non ferme, on appelle EndBloc */
+    if ( currentBloc ) PSFile::EndBloc();
+    
+    /* Si la page est vide, on la detruit */
+    if (currentPage->tmp == ftell(mPSFile)) {
+	fseek(mPSFile, currentPage->begin, SEEK_SET);
+	delete(currentPage) ;
+	PageCounter--;
+    }
+    /* Sinon, fin page + empilage */
+    else {
+	//	it = mPageList.end(); it--;
+	fprintf(mPSFile,"PState restore  showpage\n");
+	fprintf(mPSFile,"%%>EndPage %d\n\n\n", currentPage->num);
+	currentPage->end = ftell(mPSFile);
+	mPageList.push_back(*currentPage); /* Pourquoi PageList ? */
+	FileEmpty = 0;
+    }
+    currentPage = NULL;
+}
+
+
+void  PSFile::NewBloc(float x0, float y0, float Tx, float Ty,
+			      float Dx, float Dy){
+
+    /* Si pas de page, on s'en va */
+    if ( ! currentPage ) return;
+
+    /* On ferme le bloc precedent (Pas de Bloc-gigognes ! ) */
+    if (currentBloc) PSFile::EndBloc();
+
+    currentBloc = new (Bloc) ; 
+    /* On remplit currentBloc */
+    currentBloc->num = ++(currentPage->BlocCounter);
+    currentBloc->X0 = x0;
+    currentBloc->Y0 = y0;
+    currentBloc->Tx = Tx;
+    currentBloc->Ty = Ty;
+    currentBloc->Dx = Dx;
+    currentBloc->Dy = Dy;
+    currentBloc->begin = ftell(mPSFile);
+
+    /* On met a jour le fichier */
+    fprintf(mPSFile, "%%>BeginBloc %d\n", currentBloc->num);
+    fprintf(mPSFile, "%.2f %.2f %.2f Ux %.2f Uy %.2f Ux %.2f Uy NewBloc\n",
+	    currentBloc->Dx, currentBloc->Dy,
+	    currentBloc->Tx, currentBloc->Ty,
+	    currentBloc->X0, currentBloc->Y0);
+    currentBloc->tmp = ftell(mPSFile) ;
+}
+
+
+void  PSFile::EndBloc() {
+
+    /* On verifie qu'un bloc ouvert existe bien */
+    if ( ! currentBloc ) return;
+
+    /* Si le bloc est vide, on le detruit */
+    if (currentBloc->tmp == ftell(mPSFile)) {
+	fseek(mPSFile, currentBloc->begin, SEEK_SET) ; 
+	currentPage->BlocCounter-- ; 
+    }
+    /* Sinon, Ok met a jour le fichier */
+    else { 
+	fprintf(mPSFile, "EndBloc\n"); 
+	fprintf(mPSFile, "%%>EndBloc %d\n", currentBloc->num); 
+	currentBloc->end = ftell(mPSFile) ; 
+	currentPage->mBlocList.push_back(*currentBloc) ; 
+	//	PageEmpty = 0; 
+    } 
+    /* Flags */
+    currentBloc = NULL ; 
+}
+
+
+void  PSFile::DrawString  (float x,  float y, char *s, 
+			   PIColors DrawColor, 
+			   PIFontAtt FontAtt, 
+			   int FontSize) {
+    int change = 0;
+
+    /* Couleurs */
+    if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) {
+	mDrawColor = DrawColor;
+	fprintf(mPSFile, "C%d ", mDrawColor) ; 
+    }
+    /* Choix des fontes */
+    if ( (FontAtt != PI_NotDefFontAtt) || (FontAtt != mFontAtt) ) {
+	mFontAtt = FontAtt;
+	change = 1;}
+    if ( (FontSize != PI_NotDefFontSize) || (FontSize != mFontSize) ) {
+	mFontSize = (PIFontSize) FontSize;  // $CHECK$ EA ajoute le cast un peu au pif
+	change = 1;}
+    if (change)
+	fprintf(mPSFile, "F%d %d FS ", mFontAtt, FontSize) ; 
+
+    fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) S gr\n", x, y, s) ; 
+}
+
+
+void  PSFile::DrawLine    (float x1, float y1, float x2, float y2, 
+		   PIColors DrawColor,
+		   PILineAtt LineAtt) {
+
+    /* Line Att */
+    if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {
+        mLineAtt = LineAtt;
+	fprintf(mPSFile, "%d slw ", mLineAtt) ; 
+    }
+
+    /* Couleurs */
+    if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) {
+	mDrawColor = DrawColor;
+	fprintf(mPSFile, "C%d ", mDrawColor);
+    }
+
+    /* Dessin */
+    fprintf(mPSFile, "n %.2f Ux %.2f Uy m %.2f Ux %.2f Uy l s\n",
+	    x1, y1, x2, y2) ;
+}
+
+
+
+void  PSFile::DrawBox(float x0, float y0, float Tx, float Ty, 
+		      PIColors  DrawColor,
+		      PILineAtt LineAtt) {
+
+    /* Changement couleurs ? */
+    if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) {
+	mDrawColor = DrawColor;
+	fprintf(mPSFile, "C%d ", mDrawColor) ; 
+    }
+
+    /* Line Att */
+    if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {
+        mLineAtt = LineAtt;
+	fprintf(mPSFile, "%d slw ", mLineAtt) ; 
+    }
+
+    /* On dessine */
+    fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy box s gr\n",
+	    Tx, Ty, x0, y0) ; 
+}
+
+
+void  PSFile::DrawFBox(float x0, float y0, float Tx, float Ty, 
+		   PIColors DrawColor,
+		   PIColors FillColor, 
+		   PILineAtt LineAtt) {
+
+    /* Line Att */
+    if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {
+        mLineAtt = LineAtt;
+	fprintf(mPSFile, "%d slw ", mLineAtt) ; 
+    }
+
+    /* Dessin du fond */
+    if ( (FillColor != PI_NotDefColor) || (FillColor != mFillColor) )
+	mFillColor = FillColor;
+    fprintf(mPSFile, "C%d ", mFillColor) ; 
+    fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy box f gr\n",
+	    Tx, Ty, x0, y0) ; 
+    
+    /* Dessin du contour (s'il y a lieu) */
+    if ( (DrawColor != PI_NotDefColor) && (FillColor != DrawColor) )
+	mDrawColor = DrawColor;
+    fprintf(mPSFile, "C%d ", mDrawColor) ; 
+    fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy box s gr\n",
+	    Tx, Ty, x0, y0) ;
+}
+
+
+void  PSFile::DrawCircle  (float x0, float y0, float r, 
+			   PIColors DrawColor,
+			   PILineAtt LineAtt) {
+
+    /* Couleurs */
+    if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) {
+	mDrawColor = DrawColor;
+	fprintf(mPSFile, "C%d ", mDrawColor); 
+    }
+
+    /* Line Att */
+    if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {
+        mLineAtt = LineAtt;
+	fprintf(mPSFile, "%d slw ", mLineAtt); 
+    }
+
+    /* Dessin */
+    fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy 0 360 ellipse s gr\n",
+	    x0, y0, r, r) ;
+}
+
+
+void  PSFile::DrawFCircle (float x0, float y0, float r,
+		   PIColors DrawColor,
+		   PIColors FillColor, 
+		   PILineAtt LineAtt) {
+
+    /* Line Att */
+    if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {
+        mLineAtt = LineAtt;
+	fprintf(mPSFile, "%d slw ", mLineAtt) ; 
+    }
+
+    /* Dessin du fond */
+    if ( (FillColor != PI_NotDefColor) || (FillColor != mFillColor) ){
+	mFillColor = FillColor;
+	fprintf(mPSFile, "C%d ", mFillColor) ;
+    }
+    fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy \
+                      0 360 ellipse f gr\n",
+	    x0, y0, r, r);
+    fprintf(mPSFile, "C%d ", mDrawColor) ;
+
+    /* Dessin du contour (s'il y a lieu) */
+    if ( (DrawColor != PI_NotDefColor) && (FillColor != DrawColor) ) {
+	mDrawColor = DrawColor;
+	fprintf(mPSFile, "C%d ", mDrawColor); 
+	fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy 0 360 ellipse s gr\n",
+		x0, y0, r, r) ;
+    }
+}
+
+
+void  PSFile::DrawPolygon (float *x, float *y, int n,
+		   PIColors DrawColor, 
+		   PILineAtt LineAtt) {
+
+    /* Line Att */
+    if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {
+        mLineAtt = LineAtt;
+	fprintf(mPSFile, "%d slw ", mLineAtt) ; 
+    }
+
+    /* Couleur */
+    if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) {
+	mDrawColor = DrawColor;
+	fprintf(mPSFile, "C%d ", mDrawColor) ;
+    }
+    
+    /* On dessine ; ici*/
+    fprintf(mPSFile, "%.2f Ux %.2f Uy m\n", x[0], y[0]);
+    for(int i = 0; i<n; i++) 
+	fprintf(mPSFile, "%.2f Ux %.2f Uy %.2f Ux %.2f Uy l\n",
+		x[i+1], y[i+1], x[i], y[i]);
+    fprintf(mPSFile, "c s\n");
+}
+
+
+void  PSFile::DrawFPolygon(float *x, float *y, int n,
+		   PIColors DrawColor,
+		   PIColors FillColor,
+		   PILineAtt LineAtt) {
+
+    /* Line Att */
+    if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {
+        mLineAtt = LineAtt;
+	fprintf(mPSFile, "%d slw ", mLineAtt) ; 
+    }
+
+    /* Dessin du fond... */
+    if ( (FillColor != PI_NotDefColor) || (FillColor != mFillColor) ) 
+	mFillColor = FillColor;
+    fprintf(mPSFile, "C%d ", mFillColor) ;
+    fprintf(mPSFile, "%.2f Ux %.2f Uy m\n", x[0], y[0]);
+    int i;
+    for(i = 0; i<n; i++) 
+	fprintf(mPSFile, "%.2f Ux %.2f Uy %.2f Ux %.2f Uy l\n",
+		x[i+1], y[i+1], x[i], y[i]);
+    fprintf(mPSFile, "c f\n");
+
+    /* ...puis du contour (s'il y a lieu) */
+    if ( (DrawColor != PI_NotDefColor) && (DrawColor != FillColor) )
+	mDrawColor = DrawColor;
+    fprintf(mPSFile, "C%d ", mDrawColor) ;
+    fprintf(mPSFile, "%.2f Ux %.2f Uy m\n", x[0], y[0]);
+    for(i = 0; i<n; i++) 
+	fprintf(mPSFile, "%.2f Ux %.2f Uy %.2f Ux %.2f Uy l\n",
+		x[i+1], y[i+1], x[i], y[i]);
+    fprintf(mPSFile, "c s\n");
+}
+
+
+
+void  PSFile::DrawMarker  (float x0, float y0,
+			   PIMarker MrkType,   
+			   PIColors DrawColor,
+			   int MarkerSize) {
+    /* Couleurs */
+    if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) {
+	mDrawColor = DrawColor;
+	fprintf(mPSFile, "C%d ", mDrawColor) ; 
+    }
+
+    /* Marker */
+    if (MrkType != PI_NotDefMarker)
+	mMarker = MrkType;
+
+    if(MarkerSize != mMarkerSize) {
+	mMarkerSize = MarkerSize ;
+	fprintf(mPSFile, "/PIMarkers ff %d scf sf\n", mMarkerSize) ; 
+    }
+    /* Dessin */
+    fprintf(mPSFile, "%.2f Ux %.2f Uy m (\\%#o) show\n", x0, y0, mMarker) ;
+
+}
+
+/*
+ * Pas d'options pour specifier la taille des Markers ?
+ *
+ */
+void  PSFile::DrawMarkers (float *x0, float *y0, int n,
+			   PIMarker MrkType,
+			   PIColors DrawColor,
+			   int MarkerSize) {
+    /* Couleurs */
+    if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) {
+	mDrawColor = DrawColor;
+	fprintf(mPSFile, "C%d ", mDrawColor) ; 
+    }    
+
+    /* Marker */
+    if (MrkType != PI_NotDefMarker)
+	mMarker = MrkType;
+
+    if(MarkerSize != mMarkerSize) {
+	mMarkerSize = MarkerSize ;
+	fprintf(mPSFile, "/PIMarkers ff %d scf sf\n", mMarkerSize) ; 
+    }
+    /* Dessin */
+    for(int i = 0; i<n; i++)
+	fprintf(mPSFile, "%.2f Ux %.2f Uy m (\\%#o) show\n", x0[i], y0[i], mMarker) ; 
+}
+
+void PSFile::Image(float x0, float y0, float Tx, float Ty,
+		   int Nx, int Ny,
+		   unsigned char *Pict, 
+		   PIColorMap *mMap) {
+
+    int i, j;
+
+    /* Buffers PostScript */
+    fprintf(mPSFile, "/Taille %d def\n", Nx);
+    fprintf(mPSFile, "/ImStr Taille string def\n");
+    fprintf(mPSFile, "/RGBStr Taille 3  mul string def\n");
+
+    /* Ecriture ColorMap */
+    fprintf(mPSFile, "/ColorMap %02d array def\n", mMap->NCol() );
+    for(i = 0; i < mMap->NCol(); i++) {
+	fprintf(mPSFile, "ColorMap %d [16#%02X 16#%02X 16#%02X] put\n",
+		i,
+		(int)(mMap->GetColor(i).red/256),
+		(int)(mMap->GetColor(i).green/256),
+		(int)(mMap->GetColor(i).blue/256));
+    }
+    /* Emplacement de l'image */
+    fprintf(mPSFile, "gs %.2f  %.2f  tr %.2f Ux %.2f Uy sc\n", x0, y0, Tx, Ty);
+    /* Nbr pix-X, Nbr pix-Y bits/pixels */
+    fprintf(mPSFile, "%d %d 8\n", Nx, Ny);
+    /* Matrice de passage */
+    fprintf(mPSFile, "[%d 0 0 %d 0 0]", Nx, Ny);
+    /* Fonction colorimage */
+    fprintf(mPSFile, "{currentfile ImStr readhexstring pop GetRGB}\
+false 3 colorimage\n\n");
+    /* Data */
+    for(i = 0; i < Ny; i++) {
+	for(j = 0; j<Nx-1; j++ )
+	    fprintf(mPSFile, "%02X", Pict[i*Nx+j]);
+    fprintf(mPSFile, "%02X\n", Pict[i*Nx+j]);
+    }
+    /* Un petit grestore ...*/
+    fprintf(mPSFile, "gr\n");
+}
+
+/* 
+ *  Conversion
+ *
+ */
+
+float cm2pt(float x) {
+    return (x*28.35);
+}
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/psfile.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/psfile.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/psfile.h	(revision 50)
@@ -0,0 +1,200 @@
+#ifndef PSFILE_H_SEEN
+#define PSFILE_H_SEEN
+
+/*
+ *  PSFile.h
+ * 
+ *  14/06/96, 19/06/96
+ *
+ *  Gestion des fichier .ps et .eps
+ *
+ *     - L'unite de mesure est lUnite Courante (UC)
+ *        Au depart, 1UC == 1cm 
+ *     - Les reperes sont orientes a la maniere XWindow
+ * 
+ *  17/02/97 : modification des constructeurs(1-->eps,2-->ps)
+ *             ajout du type enum orientation
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "defs.h"
+#ifdef __mac__
+#include <stat.h>
+#endif
+#include "pisysdep.h"
+//#include "piinclude.h"
+
+#include PIBWDG_H      // Types enumeres repris de Peida:PIFontSize...
+#include PICMAP_H
+
+#include <list>
+
+
+
+/*
+ *#define PAGE_WIDTH   21.0    == 595 points 
+ *#define PAGE_HEIGHT  29.7    == 842 points 
+ *#define PORTRAIT  1
+ *#define LANDSCAPE 0
+ */
+
+
+
+/* Valable pour une page, ou un bloc */
+/*typedef struct {
+ *  float X0;          Coordonnes sommet NO  
+ *  float Y0;           en unites courantes  
+ *  float Tx;          Format                
+ *  float Ty;           en unites courantes  
+ *  float Dx;          Coord sommet SE       
+ *  float Dy;           en unites courantes  
+ *  int orientation;   LANDSCAPE OU PORTRAIT 
+ *} Format;
+ */
+
+/*
+ *typedef struct{
+ *    char *Name;
+ *    int  Tx;     En 1/72e de pouce  !! 
+ *    int  Ty;     unite naturelle de ps 
+ *} PIMedia;
+ */
+
+
+
+class PSFile{
+
+public:
+    /* Production fichier eps */
+    PSFile (char * FileName, float sc = 1.0);
+    /* Production fichier ps  */
+    PSFile (char * FileName, PIOrientation orientation, 
+	    PIPaperSize paperSize= PI_A4, 
+	    float marginX = 1.0, float marginY = 1.0 ) ;
+
+    virtual      ~PSFile();
+
+    virtual int     IsEPS();
+    virtual char*   GetFileName();
+
+
+    /*    virtual Format* GetFormat(); */
+    /* Attributs graphiques */
+    virtual PIColors    GetDrawColor();
+    virtual PIColors    GetFillColor();
+    virtual PIFontAtt   GetFontAtt();
+    virtual PIFontSize  GetFontSize();
+    virtual PILineAtt   GetLineAtt();
+    virtual PIMarker    GetMarker();
+
+    virtual void  NewPage(float Dx, float Dy, PIOrientation orientation);
+    virtual void  EndPage();
+    virtual void  NewBloc(float x0, float y0, float Tx, float Ty,
+			  float Dx, float Dy);
+    virtual void  EndBloc();
+
+    /* Trace */
+    virtual void  DrawString  (float x,  float y, char *s, 
+			       PIColors DrawColor  = PI_NotDefColor, 
+			       PIFontAtt FontAtt   = PI_NotDefFontAtt, 
+			       int FontSize        = 8);
+    virtual void  DrawLine    (float x1, float y1, float x2, float y2, 
+			       PIColors DrawColor  = PI_NotDefColor,
+			       PILineAtt LineAtt   = PI_NotDefLineAtt);
+    virtual void  DrawBox     (float x0, float y0, float Tx, float Ty, 
+			       PIColors DrawColor  = PI_NotDefColor,
+			       PILineAtt LineAtt   = PI_NotDefLineAtt);
+    virtual void  DrawFBox    (float x0, float y0, float Tx, float Ty, 
+			       PIColors DrawColor  = PI_NotDefColor,
+			       PIColors FillColor  = PI_NotDefColor, 
+			       PILineAtt LineAtt   = PI_NotDefLineAtt);
+    virtual void  DrawCircle  (float x0, float y0, float r, 
+			       PIColors DrawColor  = PI_NotDefColor,
+			       PILineAtt LineAtt   = PI_NotDefLineAtt);
+    virtual void  DrawFCircle (float x0, float y0, float r,
+			       PIColors DrawColor  = PI_NotDefColor,
+			       PIColors FillColor  = PI_NotDefColor, 
+			       PILineAtt LineAtt   = PI_NotDefLineAtt);
+    virtual void  DrawPolygon (float *x, float *y, int n,
+			       PIColors DrawColor  = PI_NotDefColor, 
+			       PILineAtt LineAtt   = PI_NotDefLineAtt);
+    virtual void  DrawFPolygon(float *x, float *y, int n,
+			       PIColors DrawColor  = PI_NotDefColor,
+			       PIColors FillColor  = PI_NotDefColor,
+			       PILineAtt LineAtt   = PI_NotDefLineAtt);
+    virtual void  DrawMarker  (float x0, float y0, 
+			       PIMarker MrkType    = PI_NotDefMarker, 
+			       PIColors DrawColor  = PI_NotDefColor,
+			       int MarkerSize=14);
+    virtual void  DrawMarkers (float *x0, float *y0, int n,
+			       PIMarker MrkType    = PI_NotDefMarker,
+			       PIColors DrawColor  = PI_NotDefColor,
+			       int MarkerSize=14); 
+
+    virtual void  Image(float x0, float y0, float Tx, float Ty,
+			int Nx, int Ny,
+			unsigned char *pict,
+			PIColorMap *mColorMap);
+
+#ifndef __DECCXX
+private:
+#endif
+
+
+    /* Blocs */
+    typedef struct {
+	int    num;
+	char*  label;
+	float  X0, Y0;            /* coordonnees sommet NO */
+	float  Tx, Ty;            /* Format */
+	float  Dx, Dy;            /* Repere utilisateur */
+	long  begin,end,tmp;   /* offsets dans le fichier */
+    } Bloc ;
+    typedef list<Bloc> BlocList;  /* STL */
+
+
+    /* Pages */
+    typedef struct {
+	int num;
+	int BlocCounter;
+	float Dx,Dy;              /* Sommet SE (unites utilisateur) */ 
+	PIOrientation orientation;
+	long  begin, end, tmp;    /* Offsets dans le fichier */
+	BlocList mBlocList;       /* Page == Liste de blocs  */
+    } Page ;
+    typedef list<Page> PageList;  /* STL */
+
+#ifdef __DECCXX
+private:
+#endif
+
+    /* Fichier ps/eps */
+    FILE *   mPSFile;
+    char *   mPSFileName;
+    float    Tw,Th ;              /* Format, en cm */
+    float    WMargin,HMargin ;    /* Marges minimales */
+    int      isEPS;               /* Vrai si PostScript Encapsule */
+    long     boundingBox;         /* Endroit ou est specifiee la bb */
+    float    scale;               /* boundingbox = Dx*scale ; Dy*scale */
+    PIPaperSize mPaperSize ; 
+    int      PageCounter;         /* nbr pages */
+    int      FileEmpty;
+    Page*    currentPage;        /* Avant empilage */
+    Bloc*    currentBloc;        /* Avant empilage */
+    PageList mPageList;          /* Fichier == Liste de pages */
+
+
+    /* Attributs graphiques, initialises par constructeur */
+    enum PIColors    mDrawColor;  /* Couleur de trace courante */
+    enum PIColors    mFillColor;  /* Couleur de remplissage courante */
+    enum PIFontAtt   mFontAtt; 
+    enum PIFontSize  mFontSize; 
+    enum PILineAtt   mLineAtt;    /* Epaisseur d une ligne */
+    enum PIMarker    mMarker;     /* Marker courant */
+    int              mMarkerSize; /* Taille (en points) du marker courant */
+} ;
+
+
+#endif/* PSFILE_H_SEEN */
Index: /tags/V_Saclay_110697/SophyaPI/PI/sc_sample.cc
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/sc_sample.cc	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/sc_sample.cc	(revision 50)
@@ -0,0 +1,46 @@
+#include "sc_sample.h"
+
+static double f(double x) {return x*x;}
+
+ScSample::ScSample(PIContainerGen *par, char *nom,
+                  int sx, int sy, int px, int py)
+:PIScDrawWdg(par, nom, sx, sy, px, py)
+
+{
+PIScFuncDrawer * mfd;
+mfd = new PIScFuncDrawer(f);
+  SetLimits(-3,3,-4,4);
+AddDrawer(mfd);
+SetAxesFlags();
+}
+
+ScSample::~ScSample()
+{
+DeleteDrawers();
+}
+
+
+void
+ScSample::DrawSelf()
+{
+double x[5] = {-2, -1., 1., 1.7, 2.2};
+double y[5] = {-2.5, -2.0, -1.5, -2., -2.5};
+
+int i;
+SelForeground(PI_Green);
+ScSelMarker(0.3, PI_BoxMarker);
+ScDrawMarkers(x, y, 5);
+SelForeground(PI_Magenta);
+ScSelMarker(0.3, PI_FCircleMarker);
+for(i=0; i<5; i++)
+   y[i]+=1.;
+ScDrawMarkers(x, y, 5);
+SelForeground(PI_Black);
+
+ScDrawLine(-4, -4, 4, 4);
+ScDrawLine(-2, -5, 5, 2);
+ScDrawLine(-5, -4, -2, -2);
+ScDrawLine(1, -10, 1, 10);
+return;  
+}
+
Index: /tags/V_Saclay_110697/SophyaPI/PI/sc_sample.h
===================================================================
--- /tags/V_Saclay_110697/SophyaPI/PI/sc_sample.h	(revision 50)
+++ /tags/V_Saclay_110697/SophyaPI/PI/sc_sample.h	(revision 50)
@@ -0,0 +1,14 @@
+#include "pisysdep.h"
+
+#include "piscdrawwdg.h"
+
+class ScSample : public PIScDrawWdg {
+public:
+  ScSample(PIContainerGen *par, char *nom,
+           int sx=10, int sy=10, int px=0, int py=0);
+  ~ScSample();
+
+  
+  virtual void DrawSelf();
+
+};
