Index: trunk/SophyaPI/PI/parradapter.cc
===================================================================
--- trunk/SophyaPI/PI/parradapter.cc	(revision 104)
+++ trunk/SophyaPI/PI/parradapter.cc	(revision 104)
@@ -0,0 +1,298 @@
+//     Classes ArrayAdapter           R. Ansari  05/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+
+#include "parradapter.h"
+
+/* --Methode-- */
+P2DArrayAdapter::P2DArrayAdapter(int sx, int sy)
+{
+sX = sx; sY = sy; 
+sgnX = sgnY = 1;
+offX = offY = 0;
+invX = invY = eXY = false;
+}
+
+/* --Methode-- */
+P2DArrayAdapter::~P2DArrayAdapter()
+{
+}
+
+/* --Methode-- */
+void P2DArrayAdapter::ConfigureAxes(bool invx, bool invy, bool exy, int sx, int sy)
+{
+invX = invx;  invY = invy;  eXY = exy; 
+if ( (sx > 0) && (sy > 0) )   { sX = sx; sY = sy; }
+if (invX) { sgnX = -1;  offX = sX; } 
+if (invY) { sgnY = -1;  offY = sY; } 
+}
+
+/* --Methode-- */
+void P2DArrayAdapter::XYfromxy(int ix, int iy, float& x, float& y)
+{
+x = ix+0.5;
+y = iy+0.5; 
+}
+
+/* --Methode-- */
+int P2DArrayAdapter::CheckDyn(float& min, float& max, float& moy, float& sig, int& nbnul, int& nbsat, int vit)
+{
+double m = 0.;
+double s = 0.;
+double dv; 
+
+int n9 = 0;
+int n0 = 0;
+
+if (min >= max) { min = -9.e19; max = 9.e19; }
+float minpix = 9.e19;
+float maxpix = -9.e19; 
+float pixv;
+
+int n = 0;
+if (vit < 1) vit = 1;
+if (sX*sY/vit < 1000) {
+  vit = sX*sY/1000;
+  if (vit < 1) vit = 1;
+}
+
+for(int j=0; j<sY; j++) 
+  for(int i=0; i<sX; i++)   {
+    if (n%vit != 0)  continue;
+    n++;
+    pixv = Value(i,j);
+    if (pixv <= max && pixv >= min) {  
+      if (pixv < minpix)  minpix = pixv;
+      else if (pixv > maxpix)  maxpix = pixv; 
+      dv = (double)pixv;
+      m += dv;  s += (dv*dv);
+      }
+    else  {  
+      if (pixv > max)  n9++;
+      if (pixv < min)  n0++; 
+    }
+  }
+
+nbnul = n0;  nbsat = n9;
+
+n = sX*sY-(n0+n9);
+if (n > 0)
+  { dv = (double)n;  m /= dv;  s = s/dv - m*m;
+  if (s>0.)  s = sqrt(s);  else s = 0.;
+  moy = m;  sig = s; }
+else { moy = 0.;  sig = -1.; }
+
+return(n);
+}
+
+
+/* --Methode-- */
+void P2DArrayAdapter::ComputeLut_PicHisto(float& min, float& max, int nbsig, float fracmax)
+{
+int MINNBIN = 64;
+int MAXNBIN = 1024;
+
+int nbin = sX*sY/10;
+nbin = (nbin < MINNBIN) ? MINNBIN : ((nbin > MAXNBIN) ? MAXNBIN : nbin );
+int vitesse = sX*sY / 20000;
+vitesse = (vitesse < 1) ? 1 : ((vitesse > 25) ? 25 : vitesse );
+
+
+//  Variable decrivant l'histogramme 
+float minhis, maxhis, binwidth;
+int under,over,tothis;
+int *phis;
+int *q;
+
+float MINDYNAMIC = 1.e-5;          /* Gamme dynamique minimale (MaxAff-MinAff)*/
+float FRACPIC =	0.6065;            /*  Valeur de exp(-0.5)   */
+
+
+int nbnul, nbsat, nok;
+float moy, sig;
+if ( min >= (max-MINDYNAMIC) ) nok = CheckDyn(min, max, moy, sig, nbnul, nbsat);
+if (nok < 1) { min=0.; max = 1.; return; }
+if ( min >= (max-MINDYNAMIC) )  max = min+MINDYNAMIC;
+minhis = min;
+maxhis = max;
+binwidth = (maxhis-minhis) / nbin;
+if (binwidth < MINDYNAMIC/MINNBIN) { 
+  binwidth = MINDYNAMIC/MINNBIN;
+  maxhis = nbin*binwidth + minhis;
+  }
+
+/* allocation dynamique de memoire et mise a zero de l'histogramme */
+phis = new int_4[nbin];
+for ( q=phis ; q<phis+nbin ; *q++ = 0 )  ;
+under = over = tothis = 0;
+
+//  Boucle sur les pixels   
+//  Pour aller plus vite, on prend un pixel sur vitesse   
+int kk = 0;
+int bin;
+for(int j=0; j<sY; j++)
+  for(int i=0; i<sX; i++) {
+    if ( (kk%vitesse) != 0) continue;
+    kk++;
+   /* remplissage de l'histogramme */
+    bin = (int)((Value(i, j) - minhis) / binwidth) ;
+    if ( bin < 0 )  under++;
+    else  {
+      if (bin < nbin) { (*(phis+bin))++; tothis++; }
+      else   over++; 
+      }
+    }     /*  Fin de for : Boucle sur les pixels   */
+
+/*  On verifie qu'il y a eu une entree ds l'histo */
+if (tothis <= 0)
+  { delete[] phis;  return; }
+  
+/* recherche du maximum */
+int binmax = -1 ; 
+int hmax = -1 ; 
+q = phis;
+for (kk = 0 ; kk < nbin ;  kk++, q++ )
+  if ( *(q) > hmax ) {hmax = *(q) ; binmax = kk ;}
+
+if ( (binmax < 0) || (binmax >= nbin) )
+  { delete[] phis;  return; }
+
+
+/*   On va chercher le sigma du fond  SigmaLeft, SigmaRight */
+int hmin = (int) ( (float)(hmax) * FRACPIC ) ;
+
+int sigr = 0;
+q = phis+binmax;
+while ( ((*q) > hmin) && (sigr < (nbin-binmax)) )  { sigr++;  q++; }
+int sigl = 0;
+q = phis+binmax;
+while ( ((*q) > hmin) && (sigl < binmax) )  { sigl++; q--; }
+
+
+if (nbsig == 0) nbsig = 1;
+if (nbsig < 0)  {  /*   On considere le cas ou NbSigmas est negatif   */
+  if ( (bin = binmax+nbsig*sigl) < 0 )  bin = 0;
+  min = minhis + (float)bin*binwidth;
+  if ( (bin = binmax-nbsig*sigr) >= nbin ) bin = nbin-1;
+  max = minhis + (float)bin*binwidth;
+  if (max < (min+MINDYNAMIC))  max = min+MINDYNAMIC;
+  delete[] phis;  return; 
+  }
+
+// NbSigma positif 
+if ( (bin = binmax+nbsig*sigl) >= nbin ) {
+  min = minhis + binmax*binwidth;
+  max = maxhis;
+  if (max < (min+MINDYNAMIC))  max = min+MINDYNAMIC;
+  delete[] phis;  return;
+  }
+
+min = minhis + bin*binwidth;
+
+/*   Calcul du nb de pixel entre MinAff et ValSat  */
+int nbpix = 0;
+for( q = phis+bin ; q < phis+nbin ; q++)  nbpix += (*q);
+nbpix = (int_4)((float)nbpix * fracmax);
+int nbpix2 = 0; q = phis+bin; 
+int k = bin;
+while( (nbpix2 < nbpix) && (k < nbin) )  
+  { nbpix2 += (*q); k++; q++; }
+
+max = minhis + (float)k*binwidth;
+delete[] phis;
+if (max < (min+MINDYNAMIC))  max = min+MINDYNAMIC;
+
+return;
+}
+
+
+/* --Methode-- */
+unsigned char * P2DArrayAdapter::ComputePixmap(LUT* lut, int ofx, int ofy, int zm, 
+                int xwsz, int ywsz, unsigned char * opix, int * oxsp, int * oysp){
+unsigned char *pix, *pp, ucp;
+int zmm=1;
+int npx, npy, nppx, nppy, nszp, oszp;
+int i,j,k,l;
+float vpx;
+
+
+if ( (XSize() <= 0) || (YSize() <= 0) || (lut == NULL) ) 
+  { *oxsp = *oysp = 0; return(NULL); }
+
+npx = XSize()-ofx;
+npy = YSize()-ofy;
+
+if ((zm == 0) || (zm == -1))  zm = 1;
+
+if (zm >= 1)
+  {
+  if (npx > (xwsz/zm))  npx = xwsz/zm; 
+  if (npy > (ywsz/zm))  npy = ywsz/zm;
+  nppx = npx*zm;   nppy = npy*zm;
+  }
+else
+  {
+  zmm = -zm;
+  nppx = npx/zmm;   nppy = npy/zmm;
+  if (nppx > xwsz)  nppx = xwsz; 
+  if (nppy > ywsz)  nppy = ywsz;
+  npx = nppx*zmm;   npy = nppy*zmm; 
+  }
+
+oszp = (*oxsp)*(*oysp);
+nszp = nppx*nppy;
+if ( oszp != nszp )
+  {
+  if (opix)  delete[] opix;
+  pix = new unsigned char[nppx*nppy];
+  if (pix == NULL)  { *oxsp = *oysp = 0; ; return(NULL); }
+  }
+else  pix = opix;
+*oxsp = nppx; *oysp = nppy;
+
+/*
+printf("Debug_ComputePixmap %d %d %d (%d-%d %d-%d)\n", 
+      ofx, ofy, zm, npx,nppx, npy,nppy);
+*/
+
+pp = pix;
+if (zm == 1)    // Pas de zoom  
+  {
+  for(j=ofy; j<ofy+npy; j++)
+    for(i=ofx; i<ofx+npx; i++) 
+      { *pp = (unsigned char) lut->Apply((*this)(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 += (*this)(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((*this)(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);
+}
+
Index: trunk/SophyaPI/PI/parradapter.h
===================================================================
--- trunk/SophyaPI/PI/parradapter.h	(revision 104)
+++ trunk/SophyaPI/PI/parradapter.h	(revision 104)
@@ -0,0 +1,79 @@
+// This may look like C code, but it is really -*- C++ -*-
+//     Classes ArrayAdapter           R. Ansari  05/98
+// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
+
+// Cette classe est un adaptateur pour les PIImages et 
+// autres classes de PI qui operent sur des structures 
+// de type Tableaux 2-D (images, ...) 
+
+#ifndef PARRADAPTER_SEEN
+#define PARRADAPTER_SEEN
+
+#include "defs.h"
+#include "machine.h"
+#include "lut.h"
+
+class LUT;
+class P2DArrayAdapter {
+public :
+                  P2DArrayAdapter(int sx=0, int sy=0);
+  virtual 	  ~P2DArrayAdapter();
+
+  void  	  ConfigureAxes(bool invx=false, bool invy=false, bool exy=false,
+                                int sx=-1, int sy=-1);
+
+// Doit etre defini par les classes derivees
+  virtual float   Value(int ix, int iy) = 0;   
+
+  virtual void    XYfromxy(int ix, int iy, float& x, float& y);
+
+  inline  int     XSize() { return ( eXY ? sY : sX ) ; }
+  inline  int     YSize() { return ( eXY ? sX : sY ) ; }
+
+  inline  void    XYCoord(int i, int j, float& x, float& y)
+                         { int ix, iy;  IJ2xy(i, j, ix, iy); 
+                           XYfromxy(ix, iy, x, y); }
+  inline  float   operator() (int i, int j) 
+                         { int ix, iy;  IJ2xy(i, j, ix, iy); 
+                         return Value(ix, iy); }
+  inline void     IJ2xy(int i, int j, int& x, int& y)
+                  { if  (eXY) {int ii = i; i = j; j = ii; }
+                  x = i*sgnX+offX; y = j*sgnY+offY; 
+                  return; }
+
+//    Calcul Min-Max, Moy-Sig
+  virtual int     CheckDyn(float& min, float& max, float& moy, float& sig, int& nbnul, int& nbsat, int vit=10);
+//    Calcul AutoLut
+  virtual void    ComputeLut_PicHisto(float& min, float& max, int nbsig=1, float fracmax=0.95);
+
+//    Calcul pixmap avec un LUT
+  virtual unsigned char * ComputePixmap(LUT* lut, int ofx, int ofy, int zm, 
+                           int xwsz, int ywsz, unsigned char * opix, 
+                           int * oxsp, int * oysp);
+protected :
+  int sX, sY;
+  int sgnX, sgnY;
+  int offX, offY;
+  bool invX, invY, eXY;
+};
+
+
+template <class T> 
+class P2DAdapter : public P2DArrayAdapter {
+public :
+                  P2DAdapter(T* data, int sx, int sy, bool ad=false) :
+                    P2DArrayAdapter(sx, sy)
+                    { aDel = ad; mData = data; }
+
+  virtual 	  ~P2DAdapter() { if ( (aDel) && (mData != NULL) ) delete[] mData; }
+  virtual float   Value(int ix, int iy) 
+                    {  if ( (ix < 0)  || (iy < 0) || (ix >= sX) || (iy >= sY) ) return(0.); 
+                    return(mData[ix+iy*sX]); }
+protected :
+  bool aDel;
+  T* mData;
+};
+
+
+
+#endif
Index: trunk/SophyaPI/PI/picons.cc
===================================================================
--- trunk/SophyaPI/PI/picons.cc	(revision 103)
+++ trunk/SophyaPI/PI/picons.cc	(revision 104)
@@ -442,5 +442,5 @@
 AssignKeyboard();
 mWGrC->SelGOMode(PI_GOXOR);
-mWGrC->SelForeground(mFgC);
+mWGrC->SelForeground(PI_Grey);
 mCPbeginC = x;  mCPbeginL = y;
 mCPendC = mCPendL = -1;
@@ -659,7 +659,8 @@
        }
      lva = mAtt[mLPo[l]+j];
-     g->SelFont(mFTaille, vafat[lva]);
-     if (lva & PIVA_Select) bgc = PI_Grey; 
-     else bgc = dbgc;
+     if (lva & PIVA_Select) 
+       { bgc = PI_Grey;   g->SelFont(mFTaille, vafat[lva-PIVA_Select]); }
+     else { bgc = dbgc; g->SelFont(mFTaille, vafat[lva]); }
+     
      if (lva & PIVA_Reverse) { 
        g->SelForeground(bgc);
Index: trunk/SophyaPI/PI/piimage.cc
===================================================================
--- trunk/SophyaPI/PI/piimage.cc	(revision 103)
+++ trunk/SophyaPI/PI/piimage.cc	(revision 104)
@@ -105,5 +105,5 @@
 
 /* --Methode-- */
-void PIImage::SetImage(RzImage *pim, bool refr)
+void PIImage::SetImage(P2DArrayAdapter *pim, bool refr)
 {
 
@@ -121,6 +121,8 @@
 //  SetSize(img->XSize(), img->YSize());
   CenterPave();
-  if (img->minPix>img->maxPix) img->CheckDyn();
-  SetLut(img->minPix, img->maxPix, kLutType_Lin, 1, refr);
+  float min=1., max=-1., moy, sig;
+  int nbnul, nbsat;
+  img->CheckDyn(min, max, moy, sig, nbnul, nbsat);
+  SetLut(min, max, kLutType_Lin, 1, refr);
   }
 return;
@@ -217,31 +219,9 @@
 {
 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;
-    }
+if (lauto && img) 
+  {
+  int nbsig = lauto;  
+  float fracmax = 1. - 0.05*nbsig;
+  img->ComputeLut_PicHisto(min, max, nbsig, fracmax);
   }
 
@@ -366,6 +346,8 @@
   {
   char buff[256];
-  sprintf(buff,"X= %d , Y= %d  PixVal= %g ",  /*(char *)Nom().c_str(),*/
-          xpav, ypav, img->FValue(xpav, ypav));
+  float x,y;
+  img->XYCoord(xpav, ypav, x, y);
+  sprintf(buff,"X= %g , Y= %g  PixVal= %g (%d,%d)", 
+          x, y , (*img)(xpav, ypav), xpav, ypav );
   if (txw)  txw->SetLabel((string)buff);
   if (trtlb)  trtlb->SetLabel((string)buff);
@@ -471,7 +453,9 @@
 if (txw || trtlb)
   {
-  char buff[256];
-  sprintf(buff,"X,Y= %d,%d  PixVal= %g (X,Yc= %d,%d)",  
-          xp, yp, img->FValue(xp, yp), (xp+xpv0)/2, (yp+ypv0)/2);
+  char buff[256];  
+  float x,y;
+  img->XYCoord(xp, yp, x, y);
+  sprintf(buff,"X= %g , Y= %g  PixVal= %g  (C= %d,%d)", 
+          x, y , (*img)(xp, yp),  (xp+xpv0)/2, (yp+ypv0)/2 );
   if (txw)  txw->SetLabel((string)buff);
   if (trtlb)  trtlb->SetLabel((string)buff);
@@ -561,94 +545,4 @@
 }
 
-/* --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-- */
@@ -661,5 +555,5 @@
 ywsz = this->YSize();
 
-pixm = ComputePixmap(offx, offy, zoom, xwsz, ywsz, pixm, &xspxm, &yspxm);
+pixm = img->ComputePixmap(lut, offx, offy, zoom, xwsz, ywsz, pixm, &xspxm, &yspxm);
 SetPixmap(pixm, xspxm, yspxm); 
 // Refresh();
@@ -696,5 +590,5 @@
 if (ofy < 0)  ofy = 0;
 
-zpixm = ComputePixmap(ofx, ofy, zm, xwsz, ywsz, zpixm, &xszpxm, &yszpxm);
+zpixm = img->ComputePixmap(lut, ofx, ofy, zm, xwsz, ywsz, zpixm, &xszpxm, &yszpxm);
 zow->SetColMap(GetColMapId(), false);
 zow->SetPixmap(zpixm, xszpxm, yszpxm); 
@@ -725,5 +619,5 @@
 zmgv = zmx;
 if (zmx > 1)  zmx = -zmx; 
-gpixm = ComputePixmap(0, 0, zmx, xwsz, ywsz, gpixm, &xsgpxm, &ysgpxm);
+gpixm = img->ComputePixmap(lut, 0, 0, zmx, xwsz, ywsz, gpixm, &xsgpxm, &ysgpxm);
 return;
 }
@@ -803,5 +697,5 @@
 if ( (winovis || (nbmrk < 1) ) ) return;
 tofx = tofy = 0;
-if ( img ) { tofx = img->XOrg(); tofy = img->YOrg(); }  
+if ( img ) { tofx = tofy = 0; }  /* img->XOrg(); tofy = img->YOrg(); $CHECK$  REZA 5/04/98 */  
 tofx += offx;  tofy += offy; 
 fz = GetZoomF();
Index: trunk/SophyaPI/PI/piimage.h
===================================================================
--- trunk/SophyaPI/PI/piimage.h	(revision 103)
+++ trunk/SophyaPI/PI/piimage.h	(revision 104)
@@ -6,6 +6,5 @@
 #define PIIMAGEBASE_H_SEEN
 
-#include "cimage.h"
-#include "lut.h"
+#include "parradapter.h"
 
 #include "pisysdep.h"
@@ -30,5 +29,5 @@
   virtual void    Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
 
-  void SetImage(RzImage* pim, bool refr=true);
+  void SetImage(P2DArrayAdapter* pim, bool refr=true);
   void SetAutoDelImage(bool ad = false);
 
@@ -55,5 +54,5 @@
   virtual void SetColMap(CMapId cmap, bool refr=true);
 
-  inline RzImage * Image() { return(img); }
+  inline P2DArrayAdapter * Image() { return(img); }
   inline LUT *     Lut() { return(lut); }
   inline int XPave() { return(xpav); } ;
@@ -80,7 +79,4 @@
 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();
@@ -102,5 +98,5 @@
 // Les donnees 
 
-  RzImage * img;
+  P2DArrayAdapter * img;
   bool aisup;
   bool curshow;
Index: trunk/SophyaPI/PI/pimgadapter.h
===================================================================
--- trunk/SophyaPI/PI/pimgadapter.h	(revision 104)
+++ trunk/SophyaPI/PI/pimgadapter.h	(revision 104)
@@ -0,0 +1,36 @@
+#ifndef PIMGADAPTER_SEEN
+#define PIMGADAPTER_SEEN
+
+#include "cimage.h"
+#include "parradapter.h"
+
+class RzImageAdapter : public P2DArrayAdapter {
+public:
+                  RzImageAdapter(RzImage* rzi, bool ad=false) :
+                    P2DArrayAdapter(rzi->XSize(), rzi->YSize())
+                    { aDel = ad; mImg = rzi; }
+
+  virtual 	  ~RzImageAdapter() { if (aDel) delete mImg; }
+  virtual float   Value(int ix, int iy) { return mImg->FValue(ix, iy); }
+
+protected :
+  bool aDel;
+  RzImage* mImg;
+};
+
+template <class T> 
+class ImageAdapter : public P2DArrayAdapter {
+public:
+                  ImageAdapter(Image<T>* img, bool ad=false) :
+                    P2DArrayAdapter(img->XSize(), img->YSize())
+                    { aDel = ad; mImg = img; }
+
+  virtual 	  ~ImageAdapter() { if (aDel) delete mImg; }
+  virtual float   Value(int ix, int iy) { return((*mImg)(ix, iy)); }
+
+protected :
+  bool aDel;
+  Image<T>* mImg;
+};
+
+#endif
Index: trunk/SophyaPI/PI/pistdwdgx.cc
===================================================================
--- trunk/SophyaPI/PI/pistdwdgx.cc	(revision 103)
+++ trunk/SophyaPI/PI/pistdwdgx.cc	(revision 104)
@@ -5,9 +5,18 @@
 #include PISTDWDG_H
 
-// Note du 26/02/98 - Reza 
+// ------- Pb de gestion du focus-keyboard  Motif-PIBaseWdg -------
+// ** Note du 26/02/98 - Reza 
 // Je desactive pour le moment XmNnavigationType et XmNtraversalOn
 // afin d'ameliorer la gestion du focus-keyboard entre Widget Motif
 // et objet Peida - Cela semble avoir un effet secondaire - 
 // Il faut que la souris reste dans le widget Text pour taper dedans
+// ** Note du 30/04/98 - Reza
+// J'ai modifie le mecanisme de gestion des evenements pour PIBaseWdg
+// en passant par un EventHandler - Le probleme de gestion du 
+// focus-keyboard n'a pour autant pas ete resolu
+// Je reactive XmNtraversalOn pour les PIText - Le probleme 
+// d'attribution du focus-keyboard au PIBaseWdg reste si on 
+// met PIText et un PIBaseWdg ds un meme conteneur
+
 
 /************* PILabelX ************/
@@ -151,5 +160,5 @@
 CreateXtWdg(nom, xmTextWidgetClass, NULL, sx, sy, px, py);
 XtSetArg(warg[n],XmNnavigationType,XmNONE);  n++;
-XtSetArg(warg[n],XmNtraversalOn,FALSE);  n++;
+// XtSetArg(warg[n],XmNtraversalOn,FALSE);  n++;
 XtSetValues(XtWdg(), warg, n);
 SetMutiLineMode(false);
Index: trunk/SophyaPI/PI/pixtbase.cc
===================================================================
--- trunk/SophyaPI/PI/pixtbase.cc	(revision 103)
+++ trunk/SophyaPI/PI/pixtbase.cc	(revision 104)
@@ -13,4 +13,18 @@
 
 // #define DEBUG_PIXTB
+
+ 
+//  ------- Pb de gestion du focus-keyboard  Motif-PIBaseWdg -------
+// ** Note 30/04/98  Reza
+// Il y un probleme d'attribution du focus-keyboard entre Widget Motif et
+// PIBaseWdg (Widget PIXtBase) les Attributs XmNnavigationType et XmNtraversalOn
+// ont ete desactives pour les StdWdgX - Le probleme n'a pas pu etre resolu
+// meme en attribuant les attributs  XmNnavigationType XmNtraversalOn 
+// (et XmNsensitive) a PIXtBase, ni en utilisant 
+// XSetInputFocus(XtDisplay (wdgp), XtWindow(wdgp), RevertToParent, evt->xbutton.time)
+// Solution pour le moment :
+//  XmNnavigationType =XmNONE et XmNtraversalOn=FALSE pour les PIStdWdgX 
+// sauf pour PIText ou XmNtraversalOn=TRUE
+
 
 /*  Construction du widget Xt PIXtBase   */
@@ -24,5 +38,6 @@
 
 
-static Boolean  acceptfocus_pixtbase   (Widget, Time* ); 
+// Si on ne veut pas utiliser XtInheritAcceptFocus
+// static Boolean  acceptfocus_pixtbase   (Widget, Time* ); 
 
 
@@ -64,6 +79,6 @@
 XtInheritSetValuesAlmost,       /* set_values got "Almost" geo reply*/
 NULL,		                /* notify that get_values called    */
-// XtInheritAcceptFocus,           /* assign input focus to widget     */
-acceptfocus_pixtbase,           /* assign input focus to widget     */
+XtInheritAcceptFocus,           /* assign input focus to widget     */
+// acceptfocus_pixtbase,           /* assign input focus to widget     */
 XtVersion,	                /* version of intrinsics used       */
 NULL,		                /* list of callback offsets         */
@@ -161,11 +176,12 @@
 }
 
-/* Nouvelle-Fonction */
+/* Nouvelle-Fonction 
 static Boolean  acceptfocus_pixtbase   (Widget wdgp , Time* )
 {
-printf("acceptfocus_pixtbase() %x %x \n",  ((PIXtBaseWidget)wdgp)->pixtbase.myeventmask, ShiftMask );
+// printf("acceptfocus_pixtbase() %lx %x \n",  ((PIXtBaseWidget)wdgp)->pixtbase.myeventmask, ShiftMask );
 if (  ((PIXtBaseWidget)wdgp)->pixtbase.myeventmask & ShiftMask  )  return TRUE;
 else return FALSE;
 }
+*/
 
 /* -------- Fonction de traitement des evenements --------- */
