Index: /trunk/SophyaPI/PI/Tests/Makefile
===================================================================
--- /trunk/SophyaPI/PI/Tests/Makefile	(revision 181)
+++ /trunk/SophyaPI/PI/Tests/Makefile	(revision 181)
@@ -0,0 +1,47 @@
+MODULECXXREPNAME := PITest
+MODULEDECCXXFLAGS := -msg_quiet
+include $(EROSDEVREP)/Include/Makefile.h
+
+
+ifdef NOSHLIB
+LIBF =  $(LIB)libPI.a $(LIB)libOutils++.a $(LIB)libcoutils.a 
+LIBS = -L$(LIB) -lPI -lOutils++ -lcoutils -lXm -lXt -lX11 -lm
+else
+LIBF =  $(SLB)libPI.so $(SLB)libpeida.so $(SLB)liberosc.so 
+LIBS = -L$(SLB) -lPI -lpeida -lerosc -lnr  -lm
+endif
+
+ifndef (NOSHLIB)
+LIBS := $(SLIBS) $(LIBS)
+endif
+
+
+LDLIBS := $(LIBS) $(LDLIBS)
+
+%:%.cc
+%:%.o
+%.o:%.cc
+%.o:%.c
+%:%.c
+
+.PRECIOUS: $(EXE)% $(OBJ)%.o
+
+%:$(EXE)%
+	echo $@ " done"
+
+$(EXE)%:$(OBJ)%.o
+	$(LINK.cc)  -o $@ $< $(LIBS)
+
+$(OBJ)%.o:%.cc
+	$(COMPILE.cc)   $(USERFLAGS) -o $@ $<
+
+$(EXE)%:$(OBJ)%.cc
+	$(LINK.cc) $(USERFLAGS)  -o $@ $< $(LIBS) 
+
+$(EXE)%:$(OBJ)%.c
+	$(LINK.c)  $(USERFLAGS) -o $@ $< $(LIBS) 
+
+$(OBJ)%.o:%.c
+	$(COMPILE.c) -c $(CFLAGS) $(USERFLAGS) -o $@ $< 
+
+
Index: /trunk/SophyaPI/PI/Tests/pit0.cc
===================================================================
--- /trunk/SophyaPI/PI/Tests/pit0.cc	(revision 181)
+++ /trunk/SophyaPI/PI/Tests/pit0.cc	(revision 181)
@@ -0,0 +1,301 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include <iostream.h>
+
+
+#include "pisysdep.h"
+
+#include PIAPP_H
+#include PIMENU_H 
+#include PISTDWDG_H 
+#include PIWIN_H
+#include PIPERIODIC_H
+
+//  ----- Declaration de la classe ArgsWind : Fenetre de dialogue -------
+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:
+  PILabel  * mLab[3];
+  PIButton * mBut[2];
+  PIText * mText[3];
+  };
+
+//  ----- Declaration de notre classe PIApplication (PITApp) -------
+class PITApp : public PIApplication {
+public:
+     PITApp(int narg=0, char* arg[]=NULL);
+     ~PITApp();
+     virtual void   Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+
+  PILabel *lab;
+
+private :
+  PIMenu * m[2];
+  PIPeriodX mPeriod;
+  ArgsWind *mAW;
+};
+
+
+
+/* ........................................................... */
+/*              Classe ArgsWindow (methodes)                   */
+/* ........................................................... */
+
+
+/* --Methode-- */
+ArgsWind::ArgsWind(PIApplication *par)
+: PIWindow((PIMsgHandler *)par, "Args", PIWK_dialog, 100, 100, 150, 150)
+{
+int bsx, bsy;
+
+// On definit la taille a partir de la taille par defaut des composantes 
+printf("ArgsWind::ArgsWind() \n");
+PIApplicationPrefCompSize(bsx, bsy);
+// On redefinit la taille de la fenetre
+SetSize(bsx*7, bsy*6);
+
+// Creation de champs "labels"
+mLab[0] = new PILabel(this, "UserArg-1:", bsx*2, bsy, bsx/3, bsy/4); 
+mLab[1] = new PILabel(this, "UserArg-2", bsx*2, bsy, bsx/3, bsy/4 + (bsy/4+bsy) );
+mLab[2] = new PILabel(this, "UserArg-3", bsx*2, bsy, bsx/3, bsy/4 + 2*(bsy/4+bsy) );
+
+// Creation de champs textes 
+mText[0] = new PIText(this, "UsArg1", bsx*4, bsy, bsx*2+(bsx*2/3), bsy/4);
+mText[0]->SetText("Hello ");
+mText[1] = new PIText(this, "UsArg2", bsx*4, bsy, bsx*2+(bsx*2/3), bsy/4 + (bsy/4+bsy) );
+mText[1]->SetText("1. -1.");
+mText[2] = new PIText(this, "UsArg3", bsx*4, bsy, bsx*2+(bsx*2/3), bsy/4 + 2*(bsy/4+bsy) );
+mText[2]->SetText("1. -1.");
+
+// Creation de bouton d'action 
+//  Attention : Numero de message pour Process()
+mBut[0] = new PIButton(this, "OK",  555, bsx*2, bsy, bsx, 4.5*bsy);
+mBut[1] = new PIButton(this, "Cancel", 777, bsx*2, bsy, 4*bsx, 4.5*bsy);
+
+//  Taille et position proportionnelles a la taille de la fenetre pour les elements
+for(int i=0; i<3; i++) {
+  mLab[i]->SetBinding(PIBK_elastic , PIBK_elastic , PIBK_elastic , PIBK_elastic);
+  mText[i]->SetBinding(PIBK_elastic , PIBK_elastic , PIBK_elastic , PIBK_elastic);
+  }
+for(int ii=0; ii<2; ii++) mBut[ii]->SetBinding(PIBK_elastic , PIBK_elastic , PIBK_elastic , PIBK_elastic);
+
+}
+
+/* --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();
+    break;
+
+  case 555:    // Bouton OK
+// On recupere les textes des 3 champs :
+    printf("ArgsWind::Process() Txt[0] = %s \n", mText[0]->GetText().c_str());
+    sscanf(mText[1]->GetText().c_str(),"%g %g", &xmin, &xmax);
+    printf("... XMin/Max= %g %g \n", xmin, xmax);
+    this->Hide();
+    break;    
+  }
+    
+return;
+}
+
+
+/* ........................................................... */
+/*               Classe PITApp (methodes)                      */
+/* ........................................................... */
+
+static void mypact(void *);
+
+/* --Methode-- */
+PITApp::PITApp(int narg, char* arg[])
+: PIApplication(270, 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
+  cout << " PITApp::PITApp() - Creating menus " << endl;
+m[0] = new PIMenu(Menubar(),"Fichier");
+m[0]->AppendItem("Update", 10101);
+m[0]->AppendItem("Start", 10102);
+m[0]->AppendItem("Stop", 10103);
+m[0]->AppendItem("ArgsWindow", 10104);
+m[0]->AppendItem("Exit", 10105);
+// On accroche le menu au Menubar
+AppendMenu(m[0]);
+
+m[1] = new PIMenu(Menubar(),"Edit");
+m[1]->AppendItem("Cut", 10201);
+m[1]->AppendItem("Copy", 10202);
+m[1]->AppendItem("Paste", 10203);
+// 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
+  cout << " PITApp::PITApp() - Creating PILabel " << endl;
+lab = new PILabel(this->MainWin(), "time", 250, 50, 10, 10);
+
+mPeriod.SetAction(mypact);
+
+// Fenetre de dialogue
+mAW = new ArgsWind(this);
+SetReady();
+}
+
+/* --Methode-- */
+PITApp::~PITApp()
+{
+delete m[0]; delete m[1]; delete lab;
+delete mAW;
+}  
+
+/* --Methode-- */
+void PITApp::Process(PIMessage msg, PIMsgHandler* sender, void* /*data*/)
+{
+
+char strg[64];
+
+// Gestion des actions en fonctions des messages
+
+switch(UserMsg(msg))    {
+
+    case 10101:     // On met a l'heure
+      mypact(NULL);    
+      break;
+
+    case 10102:
+      mPeriod.Start();   // On demarre la montre 
+      break;
+
+    case 10103:
+      mPeriod.Stop();    // On arrete la montre 
+      break;
+
+    case 10104 :     // Apparition de la fenetre de dialogue
+      mAW->Show();
+      break;
+
+    case 10105:          // Sortie d'application
+      Stop();
+      break;
+
+    case 10201:          // 2 eme menu
+    case 10202:          //    "   "
+    case 10203:          //    "   "
+      printf("PITApp::Process() Msg= %d (%d - %d) Menu 2 not implemented \n",
+              (int)msg, (int)UserMsg(msg),(int)ModMsg(msg));
+      break;
+
+    default :
+      printf("PITApp::Process() Msg= %d (%d - %d)??? \n", 
+            (int)msg, (int)UserMsg(msg),(int)ModMsg(msg));
+     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
+{
+time_t tm;
+char *s;
+time(&tm);
+s = ctime(&tm);
+// printf("mypact_Info:  %d  (%s)", tm, s);
+app->lab->SetLabel((string)s);
+return;
+}
+
+// ................................................................
+//                   programme principal 
+// ................................................................
+
+int main(int narg, char *arg[])
+{
+if ( (narg > 1) && (strcmp(arg[1],"-h") == 0) ) {
+  printf("pit0 : Standard widget test \n");
+  printf("  Usage : pit0 [Xt options] \n");
+  }
+//  Creation de l'objet application et appel de Run()
+app = new PITApp(narg, arg);
+puts("appel de Application.Run() ... ");
+app->Run();
+
+delete app;
+exit(0);
+}
+
+
Index: /trunk/SophyaPI/PI/Tests/pit1.cc
===================================================================
--- /trunk/SophyaPI/PI/Tests/pit1.cc	(revision 181)
+++ /trunk/SophyaPI/PI/Tests/pit1.cc	(revision 181)
@@ -0,0 +1,526 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <iostream.h>
+
+#include "pisysdep.h"
+#include PIAPP_H
+#include PIWIN_H 
+#include PIMENU_H 
+#include PISTDWDG_H 
+#include PIBWDG_H
+#include "piscdrawwdg.h"
+#include "pievthandler.h"
+#include "parradapter.h"
+
+
+/*  Exemple d'utilisation PIBaseWdg - Creation d'une nouvelle composante graphique  */
+
+// ---- Declaration de la classe ExBWdg --------
+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(PIGraphic* g, int x0, int y0, int dx, int dy);
+
+  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[32];
+};
+
+
+/* ........................................................... */
+/*     Classe ExBWdg (Implementation des methodes)             */
+/* ........................................................... */
+
+/* --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, "Hello !");
+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(PIGraphicGen* g, int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/)
+{
+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 };
+EraseWindow();
+g->SelFont(PI_NormalSizeFont, att[mfnt]);
+g->SelMarker(8, pmk[mmrk]);
+
+g->SelLine(PI_NormalLine);
+g->DrawBox(10,10, XSize()-20, YSize()-20);
+
+g->SelLine(PI_ThinLine);
+g->DrawFBox(20, 20, 20, 20);
+g->DrawCircle(30, 30, 15);
+
+g->SelForeground(PI_Red);
+g->DrawFCircle(70, 30, 15);
+
+g->SelForeground(PI_Yellow);
+g->DrawFBox(10, 60, 120, 20);
+
+g->SelForeground(PI_Black);
+g->DrawString(20, 110, str);
+
+g->SelLine(PI_ThinLine);
+g->DrawLine(20, 140, 50, 130);
+g->SelLine(PI_NormalLine);
+g->DrawLine(50, 140, 80, 130);
+g->SelLine(PI_ThickLine);
+g->DrawLine(80, 140, 110, 130);
+
+g->SelForeground(PI_Magenta);
+g->DrawFCircle(120, 30, 15);
+g->SelForeground(PI_Grey);
+g->DrawFCircle(120, 60, 15);
+
+PIGrCoord x[5] = { 20, 35, 50, 65, 80 };
+PIGrCoord y[5] = { 150, 150, 150, 150, 150 };
+
+g->SelForeground(PI_Black);
+g->DrawMarkers(x, y, 5);
+return;
+}
+
+
+static char strbuff[128];
+/* --Methode-- */
+void ExBWdg::But1Press(int x, int y)
+{
+SelPointerShape(PI_CrossPointer);
+sprintf(strbuff,"Pos X= %d Y= %d", x, y);
+mWGrC->SelFont(PI_NormalSizeFont, PI_BoldFont);
+mWGrC->DrawString(x+10, y, strbuff);
+Send(Msg(), PIMsg_Active);
+return;
+}
+
+/* --Methode-- */
+void ExBWdg::But1Release(int x, int y)
+{
+SelPointerShape(PI_ArrowPointer);
+Refresh();
+return;
+}
+
+/* --Methode-- */
+void ExBWdg::But2Press(int x, int y)
+{
+if (++mfnt > 2)  mfnt = 0;
+if (++mmrk > 8)  mmrk = 0; 
+return;
+}
+
+/* --Methode-- */
+void ExBWdg::But2Release(int x, int y)
+{
+Refresh();
+return;
+}
+
+/* --Methode-- */
+void ExBWdg::But3Press(int x, int y)
+{
+SelPointerShape(PI_HandPointer);
+mWGrC->SelForeground(PI_Blue);
+mWGrC->DrawFBox(XSize()/3, YSize()/3, XSize()/8, YSize()/8);
+return;
+}
+
+/* --Methode-- */
+void ExBWdg::But3Release(int x, int y)
+{
+mWGrC->SelForeground(PI_White);
+mWGrC->DrawFBox(XSize()/3, YSize()/3, XSize()/8, YSize()/8);
+mWGrC->SelForeground(PI_Black);
+SelPointerShape(PI_ArrowPointer);
+return;
+}
+
+/* --Methode-- */
+void ExBWdg::Keyboard(int key, PIKeyModifier kmod)
+{
+str[nc] = key;  str[nc+1] = '\0';
+if (++nc > 30)  nc = 0;
+char buf[16];
+
+if (key == PIK_Return) { Refresh(); nc = 0; return; }
+mWGrC->SelFont(PI_NormalSizeFont, PI_BoldFont);
+sprintf(buf," %c (%3d) ", (char) key, key, (int)kmod);
+mWGrC->DrawOpaqueString(20, 75, buf);
+
+if ( (kmod == PIKM_Alt) && (key == 'c') ) {
+  printf("ExBWdg::Keyboard: Test-Copy ... \n"); 
+  ClaimSelection();
+}
+if ( (kmod == PIKM_Alt) && (key == 'v') ) {
+  printf("ExBWdg::Keyboard: Test-Paste ... \n"); 
+  RequestSelection();
+}
+
+return;
+}
+
+// ----- Exemple d'une classe heritant de PIScDrawWdg ----
+/* ........................................................... */
+/*                         Classe ScSample                     */
+/* ........................................................... */
+
+class ScSample : public PIScDrawWdg {
+public:
+  ScSample(PIContainerGen *par, char *nom,
+           int sx=10, int sy=10, int px=0, int py=0);
+  virtual ~ScSample();
+};
+
+static double fpol(double x) {return (0.3*x*x*x-x*x+7.);}
+static float xpts[10] =  {-2.4, -2  , -1., 1., 1.7, 2.2, 3., 3.75, 4.3,  4.8};
+static float ypts[10] =   {-5  , -1.5, 2.5, 5., 8.0, 12., 9., 6.00, 2.2, -3.0};
+
+ScSample::ScSample(PIContainerGen *par, char *nom,
+                  int sx, int sy, int px, int py)
+:PIScDrawWdg(par, nom, sx, sy, px, py)
+
+{
+// Definition des limites
+SetLimits(-3,5,-10,15);
+
+// Creation et ajout d'un drawer de fonctions
+PIFuncDrawer* mfd = new PIFuncDrawer(fpol);
+mfd->SetColAtt(PI_Blue);
+mfd->SetLineAtt(PI_NormalLine);
+AddScDrawer(mfd,true);
+
+// Creation et ajout d'un drawer de points
+PIYfXDrawer* mxyd = new PIYfXDrawer(new P1DAdapter<float>(xpts, 10, false), 
+                                    new P1DAdapter<float>(ypts, 10, false), true);
+mxyd->SetColAtt(PI_Magenta);
+mxyd->SetMarkerAtt(7, PI_FBoxMarker);
+AddScDrawer(mxyd, true);
+
+// Ajout de texte
+BaseDrawer()->SetFontAtt(PI_NormalSizeFont, PI_BoldFont);
+BaseDrawer()->ElAddText(-2.8, 12., "---- ScSample ----", PI_Red);
+BaseDrawer()->ElAddText(-2.8, 10.,  "f(x)=0.3*x^3-x^2+7.", PI_Red);
+
+SetAxesFlags(kAxesDflt);
+}
+
+ScSample::~ScSample()
+{
+}
+
+//      ----------- Une classe EventHandler ----------
+class MyEvHandler :  public PIEventHandler {
+public :
+			MyEvHandler();
+			~MyEvHandler();
+  virtual void		Draw(PIGraphic* g, int x0, int y0, int dx, int dy);
+  virtual void		ProcessEvent();
+  inline bool 		GrabOK() { return(grabok); }
+
+protected :
+  PIScreenBuffer* mscb;
+  int mposx, mposy;
+  int mposx2, mposy2;
+  int msx, msy;
+  bool grabok;
+};
+
+/* --Methode-- */
+MyEvHandler::MyEvHandler()
+        : PIEventHandler()
+{
+mscb = new PIScreenBuffer(100, 100);
+msx = 100;   msy = 100;
+mposx = mposy = 0;
+mposx2 = mposy2 = 0;
+grabok = false;
+}
+
+/* --Methode-- */
+MyEvHandler::~MyEvHandler()
+{
+delete mscb;
+}
+
+/* --Methode-- */
+void MyEvHandler::Draw(PIGraphic* g, int, int, int, int)
+{
+if (GrabOK()) {
+  printf("MyEvHandler::Draw() : Copying from ScreenBuffer to wdg (%lx) \n", (unsigned long)CurrentWdg());
+  mscb->CopyToWdg(CurrentWdg(), 0, 0, msx, msy, CurrentWdg()->XSize()/2, CurrentWdg()->YSize()/2);
+  }
+else printf("MyEvHandler::Draw() : Grab first from source \n");
+}
+
+/* --Methode-- */
+void MyEvHandler::ProcessEvent()
+{
+printf("MyEvHandler::ProcessEvent() \n");
+switch (EventType()) {
+
+  case PIEvent_But3Press : 
+    mposx = GetPosX();
+    mposy = GetPosY();
+    break;
+
+  case PIEvent_But3Release : 
+    mposx2 = GetPosX();
+    mposy2 = GetPosY();
+    printf("MyEvHandler::ProcessEvent(): Rectangle(%d,%d - %d,%d) \n", mposx, mposy, mposx2, mposy2);
+//    ((PIBaseWdg*)CurrentWdg())->WindowGraphic()->DrawBox(mposx, mposy, (mposx2-mposx), (mposy2-mposy));
+    break;
+
+  case PIEvent_Keyboard :
+    if ((GetKeyMod() == PIKM_Alt) && ((GetKey() == 'G') || (GetKey() == 'g')) ) {
+      printf("MyEvHandler::ProcessEvent(): Grabbing(%dx%d) from Wdg(%lx)@(%d,%d) \n", 
+             msx, msy, (unsigned long)CurrentWdg(), mposx, mposy);
+      mscb->CopyFromWdg(CurrentWdg(), mposx, mposy, msx, msy, 0, 0);
+      grabok = true;
+      }
+    break;
+
+  default :
+    printf("MyEvHandler::ProcessEvent(): Unexpected Event (Type = %d) received \n", (int)EventType());
+    break;
+  }
+
+return;
+}
+
+/* ........................................................... */
+/*                       Classe PITApp                         */
+/* ........................................................... */
+class PITApp : public PIApplication {
+public:
+     PITApp(int narg=0, char* arg[]=NULL);
+     ~PITApp();
+     virtual void   Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+private :
+  PIMenu* m[2];
+  PIText* txt;
+  MyEvHandler* evh;
+  PIWindow* mcurwin;
+  PIWdg* mdrhw;
+  PIWdg* mevhw;
+  PIWdg* mcurw;  
+};
+
+
+/* --Methode-- */
+PITApp::PITApp(int narg, char* arg[])
+: PIApplication(300, 100, narg, arg)
+{
+
+//  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  
+
+m[0] = new PIMenu(Menubar(),"Actions");
+m[0]->AppendItem("Info", 10101);
+m[0]->AppendItem("New ExBwdg", 10102);
+m[0]->AppendItem("New ScSample", 10103);
+m[0]->AppendItem("Exit", 10105);
+// On accroche le menu au Menubar
+AppendMenu(m[0]);
+
+m[1] = new PIMenu(Menubar(),"Edit");
+m[1]->AppendItem("Copy", 10201);
+m[1]->AppendItem("Paste", 10202);
+// On accroche le menu au Menubar
+AppendMenu(m[1]);
+
+// Creation d' zone texte multiligne
+txt = new PIText(MainWin(), "mltext", 290, 90, 5, 5);
+txt->SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+txt->SetMutiLineMode(true);
+txt->SetTextEditable(false);
+txt->SetText("");
+
+evh = new MyEvHandler; 
+mcurwin = NULL;
+mcurw = NULL;  
+mdrhw = NULL;
+mdrhw = NULL;
+SetReady();
+}
+
+/* --Methode-- */
+PITApp::~PITApp()
+{
+delete m[0]; delete m[1]; delete txt;
+}  
+
+static int nbwin = 0;
+/* --Methode-- */
+void PITApp::Process(PIMessage msg, PIMsgHandler* sender, void* /*data*/)
+{
+
+char strg[256];
+
+// Gestion des actions en fonctions des messages
+
+if ( ( ModMsg(msg) == PIMsg_Active) || (ModMsg(msg) == PIMsg_Close) ) {
+  PIWdg *sndw;
+  sndw = (PIWdg *)sender;      
+  if (sndw->kind() ==  PIWindow::ClassId)  {
+    if (ModMsg(msg) == PIMsg_Close)  { 
+//      printf("PITApp::Process()/Debug : Closing Window %lx \n", (long)sender);
+      if (mcurwin->UserData() == mcurw) mcurw = NULL;
+      if (mcurwin->UserData() == mdrhw) mdrhw = NULL;
+      if (mcurwin->UserData() == mevhw) mevhw = NULL;
+      delete (PIWindow *)sender;  
+      mcurwin = NULL;  
+      }
+    else mcurwin = (PIWindow *)sender;
+  }
+  else if ( ModMsg(msg) ==  PIMsg_Active) mcurw = sndw;
+}
+
+else switch(UserMsg(msg))    {
+
+    case 10101:     // Info 
+      txt->SetText("pit1: PITApp \n PIBaseWdg - PIScDrawWdg test \n ExBWdg (:PIBaseWdg) Creation \n ScSample (:PIScDrawWdg) creation");
+    break;
+
+    case 10102: // Creation d'un ExBWdg
+      {
+      nbwin++;
+      sprintf(strg, "Creation ExBwdg \n Fenetre No %d \n Test keyborard, button 1/2/3", nbwin);
+      txt->SetText(strg);
+      sprintf(strg,"Window %d - ExBwdg", nbwin);
+      PIWindow* wp = new PIWindow(this, strg, PIWK_normal,  250, 250, 150, 150);
+      wp->SetAutoDelChilds(true);
+      ExBWdg* exb  = new ExBWdg(wp, "bwdg", 250, 250, 0, 0);
+      exb->SetBinding(PIBK_fixed,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+      wp->SetUserData(exb);
+      wp->Show();
+      }
+    break;
+
+    case 10103:   // Creation d'un ScSample
+      {
+      nbwin++;
+      sprintf(strg, "Creation Scsample \n Fenetre No %d \n Button 1 -> mouse position \n Button 2 -> Zoom \n keyboard <Alt>O <Alt>V", nbwin);
+      txt->SetText(strg);
+      sprintf(strg,"Window %d - ScSample", nbwin);
+      PIWindow* wp = new PIWindow(this, strg, PIWK_normal,  400, 400, 200, 200);
+      wp->SetAutoDelChilds(true);
+      ScSample* sc  = new ScSample(wp, "scsample", 400, 400, 0, 0);
+      sc->SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+      wp->SetUserData(sc);
+      wp->Show();
+      }
+      break;
+
+    case 10105:          // Sortie d'application
+      Stop();
+      break;
+
+
+    case 10201:          // 2 eme menu  Copy
+      if (mcurw == NULL) { printf("PITApp::Process()/Warning : Select a window for copy \n"); 
+        sprintf(strg, "Warning : Select a window for copy");
+        txt->SetText(strg);
+        }
+      else {
+        printf("Adding EventHandler to Wdg %lx", (long)mcurw);
+        sprintf(strg, "Adding EventHandler to Wdg %lx \n, Use button 3 to select copy zone \n, <Alt>G to Get copy",
+                (long)mcurw);
+        txt->SetText(strg);
+        if (mevhw != NULL) mevhw->RemoveEventHandler(evh);  mevhw = NULL;  
+        mcurw->AddEventHandler(evh, PIEvent_But3Press | PIEvent_But3Release | PIEvent_Keyboard, false);
+        }
+      break;
+      
+    case 10202:          //   2eme Menu - Paste
+      if (mcurw == NULL) { printf("PITApp::Process()/Warning : Select a window for paste \n"); 
+        sprintf(strg, "Warning : Select a window for paste");
+        txt->SetText(strg);
+        }
+      else {
+        printf("Adding DrawHandler to Wdg %lx \n - Refreshing Wdg", (long)mcurw);
+        sprintf(strg, "Adding DrawHandler to Wdg %lx \n - Refreshing Wdg", (long)mcurw);
+        txt->SetText(strg); 
+        mcurw->AddDrawHandler(evh, false); 
+        mdrhw = mcurw;
+        ((PIBaseWdg*)mcurw)->Refresh();
+        }
+      break;
+      
+    default :
+      //      printf("PITApp::Process() Msg= %d (%d - %d)??? \n", 
+      //            (int)msg, (int)UserMsg(msg),(int)ModMsg(msg));
+     break;
+    
+  }
+return;
+}
+
+
+// ................................................................
+//                   programme principal 
+// ................................................................
+
+int main(int narg, char *arg[])
+{
+if ( (narg > 1) && (strcmp(arg[1],"-h") == 0) ) {
+  printf("pit1 : ExBWdg (:PIBaseWdg) / ScSample (:PIScDrawWdg) test \n");
+  printf("  Usage : pit1 [Xt options] \n");
+  }
+//  Creation de l'objet application et appel de Run()
+PITApp* app = new PITApp(narg, arg);
+// puts("appel de Application.Run() ... ");
+app->Run();
+
+delete app;
+exit(0);
+}
+
+
Index: /trunk/SophyaPI/PI/Tests/pitcons.cc
===================================================================
--- /trunk/SophyaPI/PI/Tests/pitcons.cc	(revision 181)
+++ /trunk/SophyaPI/PI/Tests/pitcons.cc	(revision 181)
@@ -0,0 +1,289 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <iostream.h>
+#include <X11/Intrinsic.h>
+#include <Xm/Xm.h>  // Pour *DBG*
+
+#include "pisysdep.h"
+
+#include PIAPP_H
+#include PIMENU_H 
+#include PISTDWDG_H 
+#include PIWIN_H
+#include "picons.h"
+
+class PITApp : public PIApplication {
+public:
+     PITApp(int narg=0, char* arg[]=NULL);
+     ~PITApp();
+     virtual void   Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL
+);
+
+// protected :
+     
+  PIMenu * m[2];
+  PIWindow *mCurW;
+  PIButton *but[2];
+};
+
+
+static PIConsole* scons=NULL;
+static PIConsole* cons=NULL;
+
+/* --Methode-- */
+PITApp::PITApp(int narg, char* arg[])
+: PIApplication(600, 300, narg, arg)
+{
+
+
+m[0] = new PIMenu(Menubar(),"Fichier");
+m[0]->AppendItem("NewConsole", 10101);
+m[0]->AppendItem("StdOut", 10102);
+m[0]->AppendItem("StdOut-2", 10103);
+m[0]->AppendItem("StdErr", 10104);
+m[0]->AppendItem("StdErr-2", 10105);
+m[0]->AppendItem("AccCmd", 10110);
+m[0]->AppendItem("AccCmd-2", 10111);
+m[0]->AppendItem("Exit", 10177,"Q");
+// On accroche le menu au Menubar
+AppendMenu(m[0]);
+
+
+m[1] = new PIMenu(Menubar(),"Actions");
+m[1]->AppendItem("Normal", 10201);
+m[1]->AppendItem("Bold", 10202);
+m[1]->AppendItem("Italique", 10203);
+m[1]->AppendItem("Reverse", 10204);
+m[1]->AppendItem("Print", 10205);
+m[1]->AppendItem("PrintNNL", 10206);
+m[1]->AppendItem("COUT", 10207);
+m[1]->AppendItem("PrintErr", 10208);
+m[1]->AppendItem("CERR", 10209);
+
+AppendMenu(m[1]);
+
+but[0] = but[1] = NULL;
+
+but[0] = new PIButton(MainWin(), "OK", 501, 50,  25, 30, 10);
+but[1] = new PIButton(MainWin(), "Cancel", 502, 50,  25, 100, 10);
+// printf("---DBG--- %lx %lx %lx \n", XtWindow(MainWin()->XtWdg()), 
+//       XtWindow(but[0]->XtWdg()), XtWindow(but[1]->XtWdg()) ); 
+
+scons = new PIConsole(MainWin(), "PIConsole", 4540, 120, 70, 600, 250, 0, 50 );
+
+// printf("---DBG-2=== %lx %lx % \n", XtWindow(PIXtTopWdg()), 
+//       XtWindow(scons->XtWdg()));
+
+int kkk;
+for(kkk=0; kkk<10; kkk++) { 
+  scons->AddStr("A-B-C-JHGTREWQ====Reza Ansari");
+  scons->AddChar('\n'); 
+  }
+for(kkk=0; kkk<5; kkk++) {
+  scons->AddStr("**** CMV ****", PIVA_Bold);
+  scons->AddStr(" Hello, Comment ca va ? Salam - Bye, Bye ",PIVA_Ital); 
+  scons->AddChar('\n'); 
+  }
+  
+
+scons->AcceptCmd(true);
+// RedirectOutStream(scons);
+// RedirectErrStream(scons);
+
+
+ 
+mCurW = NULL;    // Fenetre courante
+SetReady();
+}
+
+/* --Methode-- */
+PITApp::~PITApp()
+{
+}  
+
+static int lines = 0;
+
+/* --Methode-- */
+void PITApp::Process(PIMessage msg, PIMsgHandler* sender, void* data)
+{
+int i,l;
+char buff[128];
+
+/*   Debug version Motif
+XmNavigationType navtyp;
+Boolean trav;
+
+Arg  wargs[2];
+navtyp = 0;
+trav = FALSE;
+XtSetArg(wargs[0],XmNnavigationType, &navtyp);  
+XtSetArg(wargs[1],XmNtraversalOn, &trav);  
+XtGetValues(((PIWdg*)sender)->XtWdg(), wargs, 2);
+
+printf("-- DBG -- PITApp::Process() Widget= %lx (%lx) \n", (long) ((PIWdg*)sender)->XtWdg(), (long)sender);
+printf(" NavType = %d  (None=%d)  Trav= %d (False=%d) \n", (int)navtyp, (int)XmNONE, (int)trav, (int)FALSE);
+*/
+
+
+if ( ( ModMsg(msg) == PIMsg_Active) || (ModMsg(msg) == PIMsg_Close) ) {
+  PIWdg *sndw;
+  sndw = (PIWdg *)sender;      
+  if (sndw->kind() ==  PIWindow::ClassId)  {
+    if (ModMsg(msg) == PIMsg_Close)  { 
+      printf("PITApp::Process()/Debug : Closing Window %lx \n", (long)sender);
+      delete (PIWindow *)sender;  
+      mCurW = NULL; }
+    else  mCurW = (PIWindow *)sender;
+  }
+}
+else
+  {
+  switch(UserMsg(msg))
+    {
+    case 4540: 
+      if (ModMsg(msg) == PIMsg_OK) 
+        printf("Cmd from Console L=%d [%s] \n", strlen((char*)data), (char*)data ); 
+      else 
+        printf("Console Msg= %d Mod = %d \n",UserMsg(msg), ModMsg(msg));
+      break; 
+
+// --------- 1er menu ----------
+    case 10101: 
+      {
+      PIWindow* win = new PIWindow(this, "Console-2", PIWK_normal, 500, 200, 200, 200);
+      win->SetAutoDelChilds(true);
+      win->Show();
+      cons = new PIConsole(win, "PIConsole-2", 4560, 100, 60, 500, 200, 0, 0 );
+      int kkk;
+      for(kkk=0; kkk<20; kkk++) { 
+        cons->AddStr("A-B-C-JHGTREWQ====Reza Ansari");
+        cons->AddChar('\n'); 
+        }
+      for(kkk=0; kkk<25; kkk++) {
+        cons->AddStr("**** CMV ****", PIVA_Bold);
+        cons->AddStr(" Hello, Comment ca va ? Salam - Bye, Bye ",PIVA_Ital); 
+        cons->AddChar('\n'); 
+        }
+      }
+      break;
+    case 10102: 
+      RedirectOutStream(scons);
+      break;
+
+    case 10103: 
+      RedirectOutStream(cons);
+      break;
+
+    case 10104: 
+      RedirectErrStream(scons);
+      break;
+
+    case 10105: 
+      RedirectErrStream(cons);
+      break;
+
+    case 10110 :
+      if (scons) scons->AcceptCmd(true);
+      break;
+    case 10111 :
+      if (cons) cons->AcceptCmd(true);
+      break;
+
+    case 10177:          // Sortie d'application
+      Stop();
+      break;
+
+// ----------  2eme menu --------
+  case 10207 :
+    for(l=0; l<3; l++) 
+      cout << "TApp: Test-Cout (K= " << l << ") " << endl ; 
+    break;
+  case 10205 :
+    for(l=0; l<4; l++) 
+      printf("TApp: Test-Redirect Print %d - %d \n", l, lines); lines++;
+    break;
+  case 10206 :
+      printf("TApp: T-Print NNL %d n", lines);
+    break;
+
+  case 10209 :
+    for(l=0; l<2; l++) 
+      cerr << "TApp: CERR--Test (K= " << l << ") " << endl ; 
+    break;
+  case 10208 :
+    for(l=0; l<8; l++) 
+      fprintf(stderr, "TApp: StdErr Redirect  %d - %d \n", l, lines);  lines++;
+    break;
+
+  case 10204 :
+    for(l=0; l<1; l++) {
+      sprintf(buff, "TApp: Line type Reverse No %d ", lines);
+      scons->AddStr(buff, PIVA_Reverse, false);
+      sprintf(buff, "Normal  ");
+      scons->AddStr(buff, PIVA_Def, false);
+      sprintf(buff, "Bold  ");
+      scons->AddStr(buff, PIVA_Bold, false);
+      lines++;
+    }   
+    scons->Refresh();
+    break;
+  
+  case 10202 :
+    for(l=0; l<3; l++) {
+      sprintf(buff, "TApp: Line type Bold No %d \n", lines);
+      scons->AddStr(buff, PIVA_Bold, false);
+      lines++;
+    }   
+    scons->Refresh();
+    break;
+  
+  case 10203 :
+    for(l=0; l<3; l++) {
+      sprintf(buff, "Line type Italique No %d \n", lines);
+      scons->AddStr(buff, PIVA_Ital, false);
+      lines++;
+    }   
+    scons->Refresh();
+    break;
+  
+  case 10201 :
+    for(l=0; l<3; l++) {
+      sprintf(buff, "Tapp: Line type Normal No %d \n", lines);
+      scons->AddStr(buff, PIVA_Def, false);
+      lines++;
+    }   
+    scons->Refresh();
+    break;
+
+
+    default :
+      printf("PIDemoApp::Process() Msg= %d (%d - %d)??? \n", 
+            (int)msg, (int)UserMsg(msg),(int)ModMsg(msg));
+     break;
+    }
+  }
+return;
+}
+
+
+static PITApp * app;
+
+
+int main(int narg, char *arg[])
+{
+
+  // PeidaStarRecoInitiator InitStar;
+
+app = new PITApp(narg, arg);
+app->SetBusy();
+puts("appel de Application.Run() ... ");
+app->SetReady();
+app->Run();
+
+delete app;
+exit(0);
+}
+
+
Index: /trunk/SophyaPI/PI/Tests/pitgr.cc
===================================================================
--- /trunk/SophyaPI/PI/Tests/pitgr.cc	(revision 181)
+++ /trunk/SophyaPI/PI/Tests/pitgr.cc	(revision 181)
@@ -0,0 +1,399 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+
+#include <iostream.h>
+
+#include "pisysdep.h"
+
+#include PIAPP_H
+#include PIMENU_H 
+#include PISTDWDG_H 
+#include PIWIN_H
+#include PIPERIODIC_H
+
+#include "pidrawwin.h"
+#include "piscdrawwdg.h"
+#include "piimage.h"
+#include "parradapter.h"
+
+#include "psfile.h"
+
+#include "piimgtools.h"
+#include "pidrwtools.h"
+
+#include "pisurfdr.h"
+
+
+//  ---------- classe PITApp -----------------------
+class PITApp : public PIApplication {
+public:
+     PITApp(int narg=0, char* arg[]=NULL);
+     ~PITApp();
+     virtual void   Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+
+  PIMenu* m[3];
+  PIText* txt;
+  PIPixmap* zoom;  
+  PICMapView* cmapv;
+  PIWindow *mCurW;
+};
+
+
+/* --Methode-- */
+PITApp::PITApp(int narg, char* arg[])
+: PIApplication(360, 130, narg, arg) 
+{
+
+m[0] = new PIMenu(Menubar(),"Fichier");
+m[0]->AppendItem("Info", 10101);
+m[0]->AppendItem("Close", 10110);
+m[0]->AppendItem("Exit", 10150);
+// On accroche le menu au Menubar
+AppendMenu(m[0]);
+
+// 2eme Menu
+
+m[1] = new PIMenu(Menubar(),"Graphics");
+m[1]->AppendItem("Sin(x)/x", 10201);
+m[1]->AppendItem("YfXDrawer", 10202);
+m[1]->AppendItem("2-Drawers", 10203);
+m[1]->AppendItem("Surf-3D", 10204);
+m[1]->AppendItem("Surf-3D-Color", 10205);
+m[1]->AppendItem("Image", 10206);
+
+AppendMenu(m[1]);
+
+
+m[2] = new PIMenu(Menubar(),"Tools");
+m[2]->AppendItem("ShowImageTools", 10301);
+m[2]->AppendItem("ShowDrawerTools", 10302);
+m[2]->AppendItem("PostScript (EPS)", 10305);
+AppendMenu(m[2]);
+
+MainWin()->SetSize(360,130);
+zoom = new PIPixmap(MainWin(), "Zoom", 90, 90, 5, 5);
+// zoom->SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+cmapv = new PICMapView(MainWin(), "CMapView", 350, 25, 5, 100);
+// cmapv->SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+// Creation d' zone texte multiligne
+txt = new PIText(MainWin(), "mltext", 250, 90, 105, 5);
+// txt->SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
+txt->SetMutiLineMode(true);
+txt->SetTextEditable(false);
+txt->SetText("");
+
+SetReady();
+}
+
+/* --Methode-- */
+PITApp::~PITApp()
+{
+for(int i=0; i<3; i++)  delete m[i]; 
+delete txt;
+delete cmapv;
+delete zoom;
+}  
+
+
+static int nbwin = 0;
+static int numpsf = 0;
+static int fgswcol = 0;
+
+static double fsinc(double x) {if ( (x>-1.e-8) && (x<1.e-8) ) return(0.); else return (sin(x)/x);}
+
+/* --Methode-- */
+void PITApp::Process(PIMessage msg, PIMsgHandler* sender, void* data)
+{
+char strg[64];
+int i,j;
+
+if ( ( ModMsg(msg) == PIMsg_Active) || (ModMsg(msg) == PIMsg_Close) ) {
+  PIWdg *sndw;
+  sndw = (PIWdg *)sender;      
+  if (sndw->kind() ==  PIWindow::ClassId)  {
+    if (ModMsg(msg) == PIMsg_Close)  { 
+      printf("PITApp::Process()/Debug : Closing Window %lx \n", (long)sender);
+      delete (PIWindow *)sender;  
+      mCurW = NULL; }
+    else  mCurW = (PIWindow *)sender;
+  }
+}
+else
+  {
+  switch(UserMsg(msg))
+    {
+
+// --------- 1er menu ----------
+    case 10101:     
+      txt->SetText("pitgr: PI Graphics Tests \n * 2-D graphics \n * 3-D Graphics \n Image display ");
+      break;
+
+    case 10110 :
+      if (mCurW)  { mCurW->Hide();  delete mCurW;}
+      mCurW = NULL;
+      break;
+
+    case 10150:          // Sortie d'application
+      Stop();
+      break;
+
+
+// ----------  3eme menu --------
+    case 10301 :
+      PIImgTools::ShowPIImgTools();
+      break;
+    case 10302 :
+      PIDrwTools::ShowPIDrwTools();
+      break;
+    case 10305 :
+      if(mCurW) {
+        char buff[64];
+        sprintf(buff, "pigr_%d.eps", numpsf);        numpsf++;
+        printf("Creating EPS File %s (Encapsulated PostScript) \n", buff);
+        PSFile *mps;
+	mps = new PSFile(buff);
+	mCurW->PSPrint(mps,0,0);
+	delete mps;
+        }
+      break;
+
+// ----------  2eme menu --------
+
+    case 10201 :        //  Trace de la fonction sin(x)/x
+      {
+      SetBusy();    // souris -> montre 
+      txt->SetText("PIScDrawWdg Creation\n Sin(x)/x \n Button 1 -> Coord \n  Button 2 Zoom \n <Alt>O <Alt>V \n Try DrawerTools");
+
+      PIFuncDrawer* mfd = new PIFuncDrawer(fsinc);
+      mfd->SetColAtt(PI_Gold);
+      mfd->SetLineAtt(PI_NormalLine);
+      nbwin++; sprintf(strg,"2D Graphics (PI W %d)", nbwin);
+      PIWindow* wp = new PIWindow(this, strg, PIWK_normal,  300, 300, 150, 150);
+      wp->SetAutoDelChilds(true);
+      PIScDrawWdg* scd = new PIScDrawWdg(wp, "scwdg-sinc", 300, 300, 0, 0);
+      scd->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_fixed);
+      scd->SetLimits(0.1, 30., -1., 1.);
+      scd->AddScDrawer(mfd,true);
+      scd->BaseDrawer()->ElAddText(2, 0.8, "Y = Sin(x)/x", PI_Red);
+      scd->SetTitles(" --- PIFuncDrawer (Sin(x)/x) --- ");
+      wp->Show();    // On affiche  la fenetre 
+      SetReady();    //  souris->pointeur , on n'est plus occupe
+      }
+      break;
+
+
+    case 10202 :    // Trace Test de PIYfXDrawer
+      {
+      SetBusy();    // souris -> montre 
+      txt->SetText("PIScDrawWdg Creation\n PIYfXDrawer \n Button 1 -> Coord \n  Button 2 Zoom \n <Alt>O <Alt>V \n Try DrawerTools");
+
+      float* vpx = new float[30]; 
+      float* vpy = new float[30]; 
+      int i;   double x;
+      for(i=0; i<30; i++) { x = 8.*i/30;  vpx[i] = x;  vpy[i] = 3*cos(x)+2*sin(x); }
+      PIYfXDrawer* mxyd = new   PIYfXDrawer( new P1DAdapter<float>(vpx, 30, true), 
+                                            new P1DAdapter<float>(vpy, 30, true), true); 
+      mxyd->SetColAtt(PI_Red);
+      mxyd->SetMarkerAtt(7, PI_FTriangleMarker);
+
+      nbwin++; sprintf(strg,"2D Graphics (PI W %d)", nbwin);
+      PIWindow* awp = new PIWindow(this, strg, PIWK_normal, 300, 300, 300, 300);
+      PIScDrawWdg* scd = new PIScDrawWdg(awp, "scwdg-YfX", 300, 300, 0, 0);
+      scd->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_fixed);
+      scd->AddScDrawer(mxyd,true);
+      scd->SetTitles(" --- PIYfXDrawer (3*cons(x)+2*sin(x)) --- ");
+      awp->SetAutoDelChilds(true);
+      awp->Show();
+      SetReady();
+      }
+      break;
+
+    case 10203 :    // FunDrawer + PIYfXDrawer
+      {
+      SetBusy();    // souris -> montre 
+      txt->SetText("PIScDrawWdg Creation\n PIYfXDrawer + FuncDrawer(Sin(x)/x) \n Button 1 -> Coord \n  Button 2 Zoom \n <Alt>O <Alt>V \n Try DrawerTools");
+
+      float* vpx = new float[30]; 
+      float* vpy = new float[30]; 
+      int i;   double x;
+      for(i=0; i<30; i++) { x = 8.*i/30;  vpx[i] = x;  vpy[i] = 3*cos(x)+2*sin(x); }
+      PIYfXDrawer* mxyd = new   PIYfXDrawer( new P1DAdapter<float>(vpx, 30, true), 
+                                             new P1DAdapter<float>(vpy, 30, true), true); 
+
+      mxyd->SetColAtt(PI_Magenta);
+      mxyd->SetMarkerAtt(7, PI_FBoxMarker);
+
+      PIFuncDrawer* mfd = new PIFuncDrawer(fsinc);
+      mfd->SetColAtt(PI_Blue);
+      mfd->SetLineAtt(PI_NormalLine);
+
+      nbwin++; sprintf(strg,"2D Graphics (PI W %d)", nbwin);
+      PIWindow* awp = new PIWindow(this, strg, PIWK_normal, 400, 400, 300, 300);
+      PIScDrawWdg* scd = new PIScDrawWdg(awp, "scwdg-YfX", 400, 400, 0, 0);
+      scd->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_fixed);
+      scd->AddScDrawer(mxyd,true);
+      scd->AddScDrawer(mfd,true);
+      scd->SetTitles(" --- PIYfXDrawer + PIFuncDrawer --- ");
+      awp->SetAutoDelChilds(true);
+      awp->Show();
+
+      SetReady();
+      }
+      break;
+
+    case 10206 :
+      {
+      SetBusy();    // souris -> montre 
+      txt->SetText("PIImage Creation\n Image Display \n Button 1 -> Coord/value \n  Button 2 Select Rectangle \n Butt on 3 Move \n <Alt>O <Alt>V <Alt>C \n Try ImageTools");
+ 
+      int sx, sy;
+      sx = 400; 
+      sy = 600;
+      printf(" Creating Image (%dx%d) ... ", sx, sy);
+      float* img = new float[sx*sy];
+      int i, j, k, kk, i0, j0;
+      double lamp, amp,x,y;
+      for(k=0; k<sx*sy; k++)   img[k] = 1000.+(random()%200-100);
+//   On genere 500 etoiles
+      for(k=0; k<500; k++) {
+        i0 = 20+random()%(sx-20);
+        j0 = 20+random()%(sy-20);
+        lamp = 2.0+0.012*(random()%100);
+        amp = pow(10., lamp);
+//        if (k%5 == 0)  printf(" DBG %d %d - %g \n", i0, j0, flux);
+        for(i=i0-15; i<i0+15; i++)
+          for(j=j0-15; j<j0+15; j++) {
+            x = i-i0;  y = j-j0;
+            kk = j*sx+i;
+            img[kk] += amp*exp(-(x*x)/7.-(y*y)/8.);
+            }
+      }
+      printf("  >> OK \n");
+     
+      nbwin++; sprintf(strg,"Image (PI W %d)", nbwin);
+      PIWindow* awp = new PIWindow(this, strg, PIWK_normal, sx, sy, 300, 300);
+      PIImage * pii = new PIImage(awp, "fitsimage", sx, sy, 0, 0);
+      pii->SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_fixed);
+      pii->SetZoomWin(zoom, false);
+      pii->SetCMapWin(cmapv, false);
+      pii->ShowCursor(true);
+      awp->SetAutoDelChilds(true);
+      awp->Show();
+      pii->SetImage(new P2DAdapter<float>(img, sx, sy, true), true);
+      SetReady();
+      }
+      break;
+
+
+//    Dessins 3D  
+    case 10204:         
+      {
+      SetBusy();    // souris -> montre 
+      txt->SetText("PIDraw3DWdg Creation\n 3-D Surf Display \n Button 1 \n (Shift) Button 2 Rotate \n Button Zoom \n <Alt>O <Alt>V \n Try DrawerTools");
+
+      printf(" Creating Matrix 80x60  ... ");
+      float* tf = new float[60*80];
+      int i,j,k;
+      double xp,yp,rp;
+      for(i=0; i<80; i++)
+        for(j=0; j<60; j++) { 
+           xp = i-30;   yp = j-20;
+           rp = (xp*xp)/16.+(yp*yp)/9.;
+           tf[j*80+i] = 10.*exp(-rp);
+           xp = i-50;   yp = j-28;
+           rp = (xp*xp)/9.+(yp*yp)/9.;
+           tf[j*80+i] += 4.*exp(-rp);
+        }
+      printf("  >> OK \n");
+
+      nbwin++; sprintf(strg,"3D Surf (PI W %d)", nbwin);
+      PIWindow* awp = new PIWindow(this, strg, PIWK_normal, 500, 500, 200, 200);
+      PISurfaceDrawer* sd = new PISurfaceDrawer(new P2DAdapter<float>(tf, 80, 60, true), true, true, true);
+      PIDraw3DWdg* drw3 = new PIDraw3DWdg(awp, "ex3ddrw", 500, 500, 0, 0);
+      drw3->SetBinding(PIBK_fixed , PIBK_fixed , PIBK_fixed, PIBK_fixed);
+      drw3->AddDrawer3D(sd, false);
+      drw3->SetTitles(" --- PISurfaceDrawer (80x60) --- ");
+      awp->SetAutoDelChilds(true);
+      awp->Show();
+      SetReady();
+      }
+      break;
+
+    case 10205:         
+      {
+      SetBusy();    // souris -> montre 
+      txt->SetText("PIDraw3DWdg Creation\n 3-D Surf Display \n Button 1 \n (Shift) Button 2 Rotate \n Button Zoom \n <Alt>O <Alt>V \n Try DrawerTools");
+
+      printf(" Creating Matrix 50x50  ... ");
+      float * tf = new float[2500];
+      int i,j;
+      double xp,yp,rp;
+      for(i=0; i<50; i++)
+        for(j=0; j<50; j++) { 
+           xp = i-15;   yp = j-25;
+           rp = (xp*xp)/16.+(yp*yp)/16.;
+           tf[j*50+i] = 11.*exp(-rp);
+           xp = i-35;   yp = j-15;
+           rp = (xp*xp)/9.+(yp*yp)/9.;
+           tf[j*50+i] += 3.*exp(-rp);
+           xp = i-45;   yp = j-40;
+           rp = (xp*xp)/10.+(yp*yp)/20.;
+           tf[j*50+i] += 6.*exp(-rp);
+        }
+      printf("  >> OK \n");
+
+      nbwin++; sprintf(strg,"PI W# %d 3D Surf", nbwin);
+      PIWindow* awp = new PIWindow(this, strg, PIWK_normal, 500, 500, 200, 200);
+      PISurfaceDrawer* sd = new PISurfaceDrawer(new P2DAdapter<float>(tf, 50, 50, true), true, true, true);
+      if (fgswcol%3 == 0) sd->SetColMapId(CMAP_COLRJ32);
+      else if (fgswcol%3 == 1) sd->SetColMapId(CMAP_COLBR32);
+      else sd->SetColMapId(CMAP_COLRV32);
+      fgswcol++;
+      PIDraw3DWdg* drw3 = new PIDraw3DWdg(awp, "ex3ddrw", 600, 600, 0, 0);
+      drw3->SetBinding(PIBK_fixed , PIBK_fixed , PIBK_fixed, PIBK_fixed);
+      drw3->AddDrawer3D(sd, false);
+      drw3->SetTitles(" --- PISurfaceDrawer (50x50) --- ");
+      awp->SetAutoDelChilds(true);
+      awp->Show();
+      SetReady();
+      }
+      break;
+
+    default :
+//      printf("PITApp::Process() Msg= %d (%d - %d)??? \n", 
+//            (int)msg, (int)UserMsg(msg),(int)ModMsg(msg));
+     break;
+    }
+  }
+return;
+}
+
+
+// ................................................................
+//                   programme principal 
+// ................................................................
+
+int main(int narg, char *arg[])
+{
+
+if ( (narg > 1) && (strcmp(arg[1],"-h") == 0) ) {
+  printf("pitgr : PI 2D Graphics/ 3D Surface plot/ Image Display Tests  \n");
+  printf("  Usage : pitgr [Xt options] \n");
+  }
+
+
+PITApp* app = new PITApp(narg, arg);
+int sx,sy;
+PIApplicationPrefCompSize(sx, sy);
+printf("##### pit-main() PrefCompSize= %d %d ##### \n", sx, sy);
+PIApplicationScreenSize(sx, sy);
+printf("##### pit-main() ScreenSize= %d %d ##### \n", sx, sy);
+app->Run();
+
+delete app;
+exit(0);
+}
+
+
