Changeset 4083 in Sophya


Ignore:
Timestamp:
Oct 4, 2012, 2:26:28 PM (12 years ago)
Author:
garnier
Message:

Fichiers mis a jour en comparaison avec OnlyPI

Location:
trunk/SophyaPI/PI
Files:
57 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PI/Makefile

    r4077 r4083  
    1 include ../BuildMgr/sophyamake.inc
     1include ../sophyamake.inc
    22 
    33all: $(SOPHYALIBP)libPI.a
  • trunk/SophyaPI/PI/Quartz/pigraphquartz.cpp

    r4081 r4083  
    331331void PIGraphicQuartz::DrawMarker(PIGrCoord x0, PIGrCoord y0)
    332332{
     333        printf("PIGraphicQuartz::DrawMarker   NOT IMPLEMENTED\n");
    333334
    334335/*
     
    407408void PIGraphicQuartz::DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n)
    408409{
     410        printf("PIGraphicQuartz::DrawMarkers   NOT IMPLEMENTED\n");
    409411/*
    410412int i;
     
    431433
    432434
     435void PIGraphicQuartz::DrawPixmap(PIGrCoord, PIGrCoord, PIPixColIdx&, PIColorMap*) {
     436        printf("PIGraphicQuartz::DrawPixmap1   NOT IMPLEMENTED\n");
     437}
     438
    433439/* --Methode-- */
    434440void PIGraphicQuartz::DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix,
     
    470476XFree(ximg);
    471477*/
     478        printf("PIGraphicQuartz::DrawPixmap2   NOT IMPLEMENTED\n");
    472479return;
    473480}
     
    517524void PIGraphicQuartz::DrawVerticalString(int x, int y, const char* s, unsigned long pos, bool imgs)
    518525{
     526        printf("PIGraphicQuartz::DrawVerticalString   NOT IMPLEMENTED\n");
    519527/*
    520528  int fh, fasc, fdes;
     
    693701void PIGraphicQuartz::SelLine(PILineAtt const& att)
    694702{
     703        printf("PIGraphicQuartz::SelLine   NOT IMPLEMENTED\n");
    695704
    696705if (att == mLAtt)  return;
  • trunk/SophyaPI/PI/Quartz/pigraphquartz.h

    r4077 r4083  
    5252  virtual void       DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix,
    5353                                int sx, int sy, PIColorMap* cmap);
     54  virtual void       DrawPixmap(PIGrCoord, PIGrCoord, PIPixColIdx&, PIColorMap*);
    5455
    5556// Modifications attributs graphiques
  • trunk/SophyaPI/PI/Tests/xp1.cc

    r4077 r4083  
    1010#include PISTDWDG_H
    1111#include PIWIN_H
    12 #include "PIButtonQuartz.h"
     12#ifdef __PIWQUARTZ__
     13#include <pistdwdgquartz.h>
     14#else
     15#include <pistdwdgx.h>
     16#endif
    1317
    1418//  ----- Declaration de la classe ArgsWind : Fenetre de dialogue -------
     
    4852{
    4953int bsx, bsy;
    50 
     54                printf("ArgsWind::ArgsWind\n");
     55       
    5156// On definit la taille a partir de la taille par defaut des composantes
    5257PIApplicationPrefCompSize(bsx, bsy);
    5358// On redefinit la taille de la fenetre
    5459SetSize(bsx*4, bsy*4);
    55 
     60        printf("bsx:%d bsy:%d\n",bsx,bsy);
     61       
    5662// Creation de champs "labels"
    5763mLab[0] = new PILabel(this, "Arg-1:", bsx, bsy, bsx/3, bsy/4);
     
    96102void ArgsWind::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
    97103{
     104        printf("ArgsWind::Process\n");
    98105
    99106switch (UserMsg(msg))
  • trunk/SophyaPI/PI/lut.cc

    r4077 r4083  
    1212#include "lut.h"
    1313
    14 
     14//++
     15// Class        LUT
     16// Lib          PI
     17// include      lut.h
     18//
     19//      Classe Look-Up table : transformation de valeurs (intensite/RGB) en index de couleur
     20//--
     21//++
     22// Links        Voir aussi
     23// PIColorMap
     24// PIPixmap
     25// PIImage
     26//--
    1527/* --Methode-- */
    1628
    17 LUT::LUT(double min, double max, unsigned short ncol, int typ, int ntable)
     29LUT::LUT(double min, double max, unsigned short ncol, int typ)
    1830{
    19 int nlev;
    20 
    21 bornes=NULL;
    22 nlev = ncol-2;
     31int nlev = ncol-2;
    2332if (nlev < 1)  nlev = 1;
    2433bornes = new double[nlev+1];
     
    2635if (bornes == NULL)  return;
    2736type = typ;  nLevel = nlev;
     37int qqq = 1;
     38quantum = 1;
     39for(quantum=2; quantum<=42; quantum++) {
     40  qqq = quantum*quantum*quantum;
     41  if (qqq > NCol())  break;
     42}
     43quantum--;
     44
    2845table = NULL; 
    2946tablenbin = 0;
     
    3956delete[] table;
    4057}
     58/* --Methode-- */
     59void LUT::SetNCol(unsigned short ncol)
     60{
     61if (ncol == NCol())  return;
     62double min = Min();
     63double max = Max();
     64if (bornes) delete[] bornes;
     65int nlev = ncol-2;
     66if (nlev < 1)  nlev = 1;
     67bornes = new double[nlev+1];
     68nLevel = nlev;
     69int qqq = 1;
     70quantum = 1;
     71for(quantum=2; quantum<=42; quantum++) {
     72  qqq = quantum*quantum*quantum;
     73  if (qqq > NCol())  break;
     74}
     75quantum--;
     76// printf("*DBG*LUT* quantum= %d \n", (int)quantum);
     77SetLut(min, max, Type());
     78}
    4179
    4280/* --Methode-- */
    43 void LUT::SetLut(double min, double max, int typ, int ntable)
     81void LUT::SetLut(double min, double max, int typ)
    4482{
    4583
    4684if(  (typ != kLutType_Lin)  && (typ != kLutType_Log)
    47   && (typ != kLutType_Sqrt) && (typ != kLutType_Square)
    48   )  typ = kLutType_Lin;
     85  && (typ != kLutType_Sqrt) && (typ != kLutType_Square) 
     86  && (typ != kLutType_RGB) )  typ = kLutType_Lin;
    4987type = typ;
    5088if (max <= min)  max = min+1.;
     89mMin = min;  mMax = max;
     90mMinI = (int)(min+0.1);  mMaxI = (int)(max+0.1);
    5191if (nLevel > 0)
    5292  {
    5393  int i;
    54   double dx;
    55   double dlx;
     94  double dx, dlx, fmx;
    5695  switch (typ)
    5796    {
    5897    case kLutType_Lin :
     98    case kLutType_RGB :
    5999      dx = (max-min)/(double)nLevel;
    60100      for(i=0; i<nLevel; i++)
     
    62102      break;
    63103    case kLutType_Log :
    64       dlx = log(max-min) / (double)nLevel;
     104      fmx = (max-min)/(exp(1.)-1.);
     105      dlx = 1./(double)nLevel;
    65106      for(i=0; i<nLevel; i++)
    66         bornes[i] = min+(double)exp((double)i*dlx);
     107        bornes[i] = min+((double)exp((double)i*dlx)-1.)*fmx;
     108      break;
     109    case kLutType_Exp :
     110      dlx = (exp(1.)-1.)/(double)nLevel;
     111      for(i=0; i<nLevel; i++)
     112        bornes[i] = min+(double)log(1.+(double)i*dlx)*(max-min);
    67113      break;
    68114    case kLutType_Sqrt :
     
    84130  }
    85131else  bornes[0] = 0.5*(min+max);
    86 ComputeTable((ntable > nLevel) ? ntable : tablenbin);
     132// ComputeTable((ntable > nLevel) ? ntable : tablenbin);
     133if (type != kLutType_RGB) ComputeTable(0);
    87134return;
    88135}
     
    101148
    102149/* --Methode-- */
    103 unsigned short LUT::Apply(double x)
     150unsigned short LUT::ApplyI(double x)
    104151{
    105152int i;
     
    110157
    111158/* --Methode-- */
     159unsigned short LUT::ApplyRGB(double x)
     160{
     161  long lv = x+0.3;
     162  int r = (lv%256);
     163  lv /= 256;
     164  int g = (lv%256);
     165  lv /= 256;
     166  int b = (lv%256);
     167  return (unsigned short)((Contraste(b)*quantum+Contraste(g))*quantum+Contraste(r));
     168}
     169
     170/* --Methode-- */
    112171void LUT::ComputeTable(int nt)
    113172{
    114 if (nt <= 0) nt = 16*(nLevel+2);
     173if (nt <= 0) {
     174  int fm = 16;
     175  if ((nLevel+2)>4096) fm = 1;
     176  else if ((nLevel+2)>2048) fm = 2;
     177  else if ((nLevel+2)>1024) fm = 4;
     178  else if ((nLevel+2)>512) fm = 8;
     179  nt = fm*(nLevel+2);
     180}
    115181else if (nt < (nLevel+2))  nt = (nLevel+2);
    116182tablenbin = nt;
     183if (table) delete[] table;
    117184table = new unsigned short [nt-2];
    118185tablebinwidth = (Max()-Min())/(nt-2);
    119186double x = Min()+0.5*tablebinwidth;
    120 for(int i=0; i<nt-2; i++)  { table[i] = Apply(x); x += tablebinwidth; }
     187for(int i=0; i<nt-2; i++)  { table[i] = ApplyI(x); x += tablebinwidth; }
    121188}
  • trunk/SophyaPI/PI/lut.h

    r4077 r4083  
    1313
    1414// Type de lut possibles
    15 enum {kLutType_Lin=1, kLutType_Log=2, kLutType_Sqrt=3, kLutType_Square=4};
     15enum {kLutType_Lin=1, kLutType_Log=2, kLutType_Exp=3, kLutType_Sqrt=4, kLutType_Square=5, kLutType_RGB=11 };
    1616
    1717class LUT
     
    1919public:
    2020 
    21   LUT(double min, double max, unsigned short ncol=16, int typ=kLutType_Lin, int ntable=0);
     21  LUT(double min, double max, unsigned short ncol=16, int typ=kLutType_Lin);
    2222  ~LUT();
    23   void SetLut(double min, double max, int typ=kLutType_Lin, int ntable=0);
     23  void SetNCol(unsigned short ncol);
     24  void SetLut(double min, double max, int typ=kLutType_Lin);
    2425  void Print();
    25   unsigned short Apply(double x);
     26
     27  inline unsigned short Apply(double x)
     28    {
     29    if (type == kLutType_RGB) return ApplyRGB(x);
     30    else return ApplyI(x);     
     31    }
     32
    2633  inline unsigned short ApplyFast(double x)
    2734    {
     35    if (type == kLutType_RGB) return ApplyRGB(x);
     36    else return AppFast(x);     
     37    }
     38
     39
     40  inline double Min() { return(bornes[0]); };
     41  inline double Max() { return(bornes[nLevel]); };
     42  inline double Borne(int k) { return(bornes[k]); };
     43  inline int Type() { return(type); };
     44  inline int NCol() { return(nLevel+2); };
     45
     46
     47protected:
     48  void ComputeTable(int nt);
     49  unsigned short ApplyI(double x);
     50  unsigned short ApplyRGB(double x);
     51  inline unsigned short AppFast(double x)
     52    {
    2853    if (x < Min())  return(0);
    2954    if (x >= Max() )  return(nLevel+1); 
     
    3156    return(table[k]);
    3257    }
    33 
    34   inline double Min() { return(bornes[0]); };
    35   inline double Max() { return(bornes[nLevel]); };
    36   inline int Type() { return(type); };
    37   inline int NCol() { return(nLevel+2); };
    38 
    39 protected:
    40   void ComputeTable(int nt);
    41 
     58  inline int  Contraste(int ii)   /* for ApplyRGB */
     59    {
     60    if (ii >= mMaxI) return quantum-1;
     61    if (ii <= mMinI) return 0;
     62    else return ((ii-mMinI)*(quantum-1)/mMaxI);
     63    }     
    4264  int type;
    4365  int nLevel;
     66  int quantum;
    4467  double * bornes;
     68  double mMin, mMax;
     69  int mMinI, mMaxI;
    4570  int tablenbin;
    4671  unsigned short * table;
  • trunk/SophyaPI/PI/parradapter.cc

    r4077 r4083  
    174174
    175175/* --Methode-- */
     176double  P2DArrayAdapter::MeanVal(int ix1, int ix2, int jy1, int jy2)
     177{
     178int ec;
     179if (ix1>ix2) { ec=ix1; ix1=ix2; ix2=ec; }
     180if (jy1>jy2) { ec=jy1; jy1=jy2; jy2=ec; }   
     181// On calcule la somme des pixels dans la zone
     182double ss = 0.;
     183for(int j=jy1; j<=jy2; j++)
     184  for(int i=ix1; i<=ix2; i++)  ss += Value(i,j);
     185
     186ss /= (double)((jy2-jy1+1)*(ix2-ix1+1));
     187return ss; 
     188}   
     189
     190/* --Methode-- */
    176191void P2DArrayAdapter::XYfromxy(int ix, int iy, double& x, double& y)
    177192{
     
    187202  double x,y;
    188203  this->Coord(ix, iy, x, y);
    189   char * isr = "";
     204  const char * isr = "";
    190205  if (ISFunc != NULL)  isr = ISFunc(this, ix, iy);
    191206  sprintf(ibuff,"X= %g Y= %g  Pix= %g %s   ",
     
    433448
    434449/* --Methode-- */
    435 unsigned char * P2DArrayAdapter::ComputePixmap(LUT* lut, int ofx, int ofy, int zm,
    436                 int xwsz, int ywsz, unsigned char * opix, int * oxsp, int * oysp)
     450void P2DArrayAdapter::ComputePixmap(LUT* lut, int ofx, int ofy, int zm,
     451                                    int xwsz, int ywsz, PIPixColIdx & pixc)
    437452{
    438453// TIMEF ;
    439 unsigned char *pix, *pp, ucp;
    440454int zmm=1;
    441 int npx, npy, nppx, nppy, nszp, oszp;
     455int npx, npy, nppx, nppy;
    442456int i,j,k,l;
    443 double vpx;
    444457
    445458/*
     
    448461*/
    449462
    450 if ( (XSize() <= 0) || (YSize() <= 0) || (lut == NULL) || (ofx < 0) || (ofy < 0) )
    451   { *oxsp = *oysp = 0; return(NULL); }
     463if ( (XSize() <= 0) || (YSize() <= 0) || (lut == NULL) || (ofx < 0) || (ofy < 0) ) {
     464  pixc.DeAlloc();  return;
     465}
    452466
    453467npx = XSize()-ofx;
     
    471485  }
    472486
    473 oszp = (*oxsp)*(*oysp);
    474 nszp = nppx*nppy;
    475 if ( oszp != nszp )
    476   {
    477   if (opix)  delete[] opix;
    478   pix = new unsigned char[nppx*nppy];
    479   if (pix == NULL)  { *oxsp = *oysp = 0; ; return(NULL); }
    480   }
    481 else  pix = opix;
    482 *oxsp = nppx; *oysp = nppy;
    483 
     487
     488/* printf("Debug_ComputePixmap %d %d %d (%d-%d %d-%d)\n",
     489      ofx, ofy, zm, npx,nppx, npy,nppy); */
     490if (lut->NCol() <= 256) {  // On fait un pixmap de type Byte/pixel
    484491/*
    485 printf("Debug_ComputePixmap %d %d %d (%d-%d %d-%d)\n",
    486       ofx, ofy, zm, npx,nppx, npy,nppy);
    487 */
    488 
    489 pp = pix;
     492printf("Debug_ComputePixmap- pixc.AllocateByte() type=%d - %d %d %d - %d %d %d - %d %d %d \n",
     493  lut->Type(),
     494  lut->ApplyFast(0.), lut->ApplyFast(1.), lut->ApplyFast(2.),
     495  lut->ApplyRGB(0.), lut->ApplyRGB(1.), lut->ApplyRGB(2.),
     496  lut->Apply(0.), lut->Apply(1.), lut->Apply(2.));
     497*/ 
     498unsigned char *pp, ucp;
     499pixc.AllocateByte(nppx, nppy);
     500pp = pixc.BytePointer();
    490501if (eXY) { // Echange Axe X,Y
    491502  if (zm == 1)  {  // Pas de zoom 
     
    497508    }
    498509  else if (zm < -1) {       // Compression
    499     double fv = (double)(zmm*zmm);
    500510    for(j=ofy; j<ofy+npy; j+=zmm)
    501       for(i=ofx; i<ofx+npx; i+=zmm) {
    502         vpx = 0;
    503         for(l=0; l<zmm; l++)
    504           for(k=0; k<zmm; k++)
    505             vpx += this->Value( (j+l)*sgnX+offX, (i+k)*sgnY+offY);
    506         *pp = (unsigned char) lut->ApplyFast(vpx/fv);
     511      for(i=ofx; i<ofx+npx; i+=zmm) {
     512        *pp = lut->ApplyFast( MeanVal(j*sgnX+offX, (j+zmm-1)*sgnX+offX,
     513                                      i*sgnY+offY, (i+zmm-1)*sgnY+offY) );
    507514        pp++;
    508         }
     515      }
    509516    }
    510517  else  {      // Agrandissement
     
    513520        ucp = (unsigned char) lut->ApplyFast(this->Value(j*sgnX+offX, i*sgnY+offY));
    514521        for(l=0; l<zm; l++)  {
    515           pp = pix+((j-ofy)*zm+l)*nppx+((i-ofx)*zm);
     522          pp = pixc.BytePointer()+((j-ofy)*zm+l)*nppx+((i-ofx)*zm);
    516523          for(k=0; k<zm; k++)  { *pp = ucp; pp++; } 
    517524          }
     
    528535    }
    529536  else if (zm < -1) {       // Compression
    530     double fv = (double)(zmm*zmm);
    531537    for(j=ofy; j<ofy+npy; j+=zmm)
    532538      for(i=ofx; i<ofx+npx; i+=zmm) {
    533         vpx = 0;
    534         for(l=0; l<zmm; l++)
    535           for(k=0; k<zmm; k++)
    536             vpx += this->Value( (i+k)*sgnX+offX, (j+l)*sgnY+offY);
    537         *pp = (unsigned char) lut->ApplyFast(vpx/fv);
     539        *pp = lut->ApplyFast( MeanVal(i*sgnX+offX, (i+zmm-1)*sgnX+offX,
     540                                      j*sgnY+offY, (j+zmm-1)*sgnY+offY) );
    538541        pp++;
    539         }
     542      }
    540543    }
    541544  else  {      // Agrandissement
     
    544547        ucp = (unsigned char) lut->ApplyFast(this->Value(i*sgnX+offX, j*sgnY+offY));
    545548        for(l=0; l<zm; l++)  {
    546           pp = pix+((j-ofy)*zm+l)*nppx+((i-ofx)*zm);
     549          pp = pixc.BytePointer()+((j-ofy)*zm+l)*nppx+((i-ofx)*zm);
    547550          for(k=0; k<zm; k++)  { *pp = ucp; pp++; } 
    548551          }
     
    550553    }
    551554  }
    552 return(pix);
     555}  //  ---- Fin pixmap de type Byte
     556else {  // On fait un pixmap de type short/pixel
     557// printf("Debug_ComputePixmap- pixc.AllocateShort() \n");
     558unsigned short *pp, ucp;
     559pixc.AllocateShort(nppx, nppy);
     560pp = pixc.ShortPointer();
     561if (eXY) { // Echange Axe X,Y
     562  if (zm == 1)  {  // Pas de zoom 
     563    for(j=ofy; j<ofy+npy; j++)
     564      for(i=ofx; i<ofx+npx; i++) {
     565        *pp = lut->ApplyFast(this->Value(j*sgnX+offX, i*sgnY+offY));  pp++;
     566      }
     567    }
     568  else if (zm < -1) {       // Compression
     569    for(j=ofy; j<ofy+npy; j+=zmm)
     570      for(i=ofx; i<ofx+npx; i+=zmm) {
     571        *pp = lut->ApplyFast( MeanVal(j*sgnX+offX, (j+zmm-1)*sgnX+offX,
     572                                      i*sgnY+offY, (i+zmm-1)*sgnY+offY) );
     573        pp++;
     574      }
     575    }
     576  else  {      // Agrandissement
     577    for(j=ofy; j<ofy+npy; j++)
     578      for(i=ofx; i<ofx+npx; i++)  {
     579        ucp = lut->ApplyFast(this->Value(j*sgnX+offX, i*sgnY+offY));
     580        for(l=0; l<zm; l++)  {
     581          pp = pixc.ShortPointer()+((j-ofy)*zm+l)*nppx+((i-ofx)*zm);
     582          for(k=0; k<zm; k++)  { *pp = ucp; pp++; } 
     583          }
     584        }
     585    }
     586  }     // Fin du cas avec echange d'axe X/Y
     587else {
     588  if (zm == 1)  {  // Pas de zoom 
     589    for(j=ofy; j<ofy+npy; j++)
     590      for(i=ofx; i<ofx+npx; i++) {
     591        *pp = lut->ApplyFast(this->Value(i*sgnX+offX, j*sgnY+offY));  pp++;
     592      }
     593    }
     594  else if (zm < -1) {       // Compression
     595    for(j=ofy; j<ofy+npy; j+=zmm)
     596      for(i=ofx; i<ofx+npx; i+=zmm) {
     597        *pp = lut->ApplyFast( MeanVal(i*sgnX+offX, (i+zmm-1)*sgnX+offX,
     598                                      j*sgnY+offY, (j+zmm-1)*sgnY+offY) );
     599        pp++;
     600      }
     601    }
     602  else  {      // Agrandissement
     603    for(j=ofy; j<ofy+npy; j++)
     604      for(i=ofx; i<ofx+npx; i++)  {
     605        ucp = lut->ApplyFast(this->Value(i*sgnX+offX, j*sgnY+offY));
     606        for(l=0; l<zm; l++)  {
     607          pp = pixc.ShortPointer()+((j-ofy)*zm+l)*nppx+((i-ofx)*zm);
     608          for(k=0; k<zm; k++)  { *pp = ucp; pp++; } 
     609          }
     610        }
     611    }
     612  }
     613}  //  ---- Fin pixmap de type Byte
     614
     615return;
    553616}
    554617
  • trunk/SophyaPI/PI/parradapter.h

    r4077 r4083  
    99#include "machdefs.h"
    1010#include "lut.h"
     11#include "pipixutils.h"
    1112
    1213#include <string>
     
    5455  virtual void    DefineXYCoordinates(double x0, double y0, double dx, double dy);
    5556// Doit etre defini par les classes derivees
    56   virtual double  Value(int ix, int iy) = 0;   
     57  virtual double  Value(int ix, int iy) = 0;
     58// Peut etre redefini pour les classes derivees, pour une optimisation par exemple     
     59  virtual double  MeanVal(int ix1, int ix2, int jy1, int jy2);   
    5760
    5861  virtual void    XYfromxy(int ix, int iy, double& x, double& y);
     
    8992
    9093//    Calcul pixmap avec un LUT
    91   virtual unsigned char * ComputePixmap(LUT* lut, int ofx, int ofy, int zm,
    92                            int xwsz, int ywsz, unsigned char * opix,
    93                            int * oxsp, int * oysp);
     94  virtual void ComputePixmap(LUT* lut, int ofx, int ofy, int zm,
     95                             int xwsz, int ywsz, PIPixColIdx & pixc);
    9496
    9597//   Methode de decodage des options - Implementation par defaut ne fait rien
     
    109111};
    110112
     113//  Adaptateur de tableau 1D pour pointeur de type T *
     114
    111115template <class T>
    112116class P1DAdapter : public P1DArrayAdapter {
     
    126130
    127131
     132//  Adaptateur de tableau 2D pour pointeur de type T *
    128133template <class T>
    129134class P2DAdapter : public P2DArrayAdapter {
     
    134139
    135140  virtual         ~P2DAdapter() { if ( (aDel) && (mData) ) delete[] mData; }
    136   virtual double   Value(int ix, int iy)
     141  virtual double  Value(int ix, int iy)
    137142                    {  if ( (ix < 0)  || (iy < 0) || (ix >= sX) || (iy >= sY) ) return(0.);
    138143                    return(mData[ix+iy*sX]); }
     144  virtual double  MeanVal(int ix1, int ix2, int jy1, int jy2) 
     145    {
     146    int ec;
     147    if (ix1>ix2) { ec=ix1; ix1=ix2; ix2=ec; }
     148    if (jy1>jy2) { ec=jy1; jy1=jy2; jy2=ec; }   
     149    double ss = 0.;
     150    for(int j=jy1; j<=jy2; j++)
     151      for(int i=ix1; i<=ix2; i++)  ss += (double)(mData[i+j*sX]);
     152    ss /= (double)((jy2-jy1+1)*(ix2-ix1+1));
     153    return ss; 
     154    }   
     155
    139156protected :
    140157  bool aDel;
     
    142159};
    143160
     161//  Adaptateur de tableau 2D pour tableau RGB
     162
     163class P2DPixRGBAdapter : public P2DArrayAdapter {
     164public :
     165          P2DPixRGBAdapter(PIPixRGBArray * rgbp, bool ad=false) :
     166             P2DArrayAdapter(rgbp->XSize(), rgbp->YSize() )
     167                { aDel = ad; mPix = rgbp; }
     168  virtual ~P2DPixRGBAdapter() { if ( (aDel) && (mPix) ) delete mPix; }
     169
     170  virtual double  Value(int ix, int iy)
     171    { 
     172    if ( (ix < 0)  || (iy < 0) || (ix >= sX) || (iy >= sY) ) return(0.);
     173    PIPixRGB rgb = (*mPix)(ix, iy);
     174    return ( ((double)rgb.blue*256.+(double)rgb.green)*256.+(double)rgb.red );
     175    }
     176  virtual double  MeanVal(int ix1, int ix2, int jy1, int jy2) 
     177    {
     178    int ec;
     179    if (ix1>ix2) { ec=ix1; ix1=ix2; ix2=ec; }
     180    if (jy1>jy2) { ec=jy1; jy1=jy2; jy2=ec; }   
     181    int r = 0;
     182    int g = 0;
     183    int b = 0;
     184    for(int j=jy1; j<=jy2; j++)
     185      for(int i=ix1; i<=ix2; i++)  {
     186        PIPixRGB rgb = (*mPix)(i, j);
     187        r += rgb.red;  g += rgb.green;   b += rgb.blue;
     188      }
     189    int n = (jy2-jy1+1)*(ix2-ix1+1);   
     190    r /= n; g /= n; b /= n;
     191    return ( ((double)b*256.+(double)g)*256.+(double)r ); 
     192    }   
     193                   
     194protected :
     195  bool aDel;
     196  PIPixRGBArray* mPix;
     197};
     198
    144199
    145200
  • trunk/SophyaPI/PI/pi3dwdg.cc

    r4077 r4083  
    224224  double ymin = mBDrw->ScaleY( mBDrw->YMin3() );
    225225  double ymax = mBDrw->ScaleY( mBDrw->YMax3() );
    226   double zmin = mBDrw->ScaleY( mBDrw->ZMin3() );
    227   double zmax = mBDrw->ScaleY( mBDrw->ZMax3() );
     226  double zmin = mBDrw->ScaleZ( mBDrw->ZMin3() );
     227  double zmax = mBDrw->ScaleZ( mBDrw->ZMax3() );
    228228  bool asxy = mBDrw->isAutoScaleXY();
    229229  bool asz = mBDrw->isAutoScaleZ();
  • trunk/SophyaPI/PI/piapplgen.cc

    r4077 r4083  
    5454#include "sopnamsp.h"
    5555#include "piapplgen.h"
     56#include <stdlib.h>
     57#include <iostream>
     58#include "pidrawer.h"
    5659
    5760// Variable qui contient le pointeur de l'application courante
     
    6265:topcont(NULL), menubar(NULL), mState(0)
    6366{
    64 curapp = this;   
     67  curapp = this;   
     68// Si la variable d'environnement PIDEFAFSZFRAC est definie, on modifie
     69// la taille par defaut de AutoFontSizeFrac
     70  char *envafsz = getenv("PIDEFAFSZFRAC");
     71  if (envafsz) {
     72    double fsfr = atof(envafsz);
     73    if ((fsfr>0.)&&(fsfr<1.)) {
     74      PIDrawer::SetGlDefAutoFontSizeFrac(fsfr);
     75      cout << " PIApplicationGen()/Info: getenv(PIDEFAFSZFRAC)=" << envafsz << endl;
     76      cout << "  ... Set Global Default PIDrawer AutoFontSizeFrac to "
     77           << PIDrawer::GetGlDefAutoFontSizeFrac() << endl;
     78      }
     79  }
    6580}
    6681
  • trunk/SophyaPI/PI/piapplx.cc

    r4077 r4083  
    4343class PITopContAppX : public PIContainer {
    4444public :
    45                 PITopContAppX(PIContainer *par, char *nom, PIWdg* topw,
     45                PITopContAppX(PIContainer *par, const char *nom, PIWdg* topw,
    4646                          int sx=10, int sy=10, int px=0, int py=0);
    4747   virtual      ~PITopContAppX();
     
    5555
    5656/* --Methode-- */
    57 PITopContAppX::PITopContAppX(PIContainer *par, char *nom, PIWdg* topw, int sx, int sy, int px, int py)
     57PITopContAppX::PITopContAppX(PIContainer *par, const char *nom, PIWdg* topw, int sx, int sy, int px, int py)
    5858        : PIContainer(par, nom, (sx>10)?sx:10, (sy>10)?sy:10, px, py)
    5959{
     
    144144if (sx < sxt)  sx = sxt;
    145145if (sy < 10) sy = 10;
    146 topcont = new PITopContAppX(MBCont(), "TopLevelCont", topwdg,
    147                             sx, sy, 0, msy);
     146topcont = new PITopContAppX(MBCont(), "TopLevelCont", topwdg,sx, sy, 0, msy);
    148147MBCont()->Show();
    149148//DBG printf("PIApplicationX-DBG2:: MBContSize=%d %d \n", MBCont()->XSize(), MBCont()->YSize());
     
    289288{
    290289int szf;
     290 printf("XtAppContext* PIXtAppCtx :szx=%d szy=%d szf=%d\n",szx,szy,szf);
    291291PIXtAppCtx(szx, szy, szf);
     292 printf("XtAppContext* PIXtAppCtx :szx=%d szy=%d szf=%d\n",szx,szy,szf);
    292293return;
    293294}
  • trunk/SophyaPI/PI/piaxes.cc

    r4077 r4083  
    1111#include <math.h>
    1212#include "piaxes.h"
     13#include "pidrawer.h"
    1314
    1415//++
     
    4142{
    4243  ConfigureTicks();
    43   ConfigureAutoFontSize();
     44  ConfigureAutoFontSize(true, PIDrawer::GetGlDefAutoFontSizeFrac());
    4445  ConfigureAxesCenter();
    4546  setupDone = false;
     
    5354//++
    5455// void  DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt, \
    55 //                  unsigned int flags=kAxesDflt, bool afsz=true)
     56//                  unsigned int flags, bool afsz, double fszf)
    5657//      Trace les axes en utilisant les limites de l'objet PIGraphicUC.
    5758//      "flags" spécifie les attributs d'axes. Constantes prédéfinies:
     
    6465//|           kBoxAxes | kTicks | | kIntTicks | kLabels
    6566//|     kGridOn, kAxesNone
    66 //      Si "afsz == true", la taille de fonte est choisie automatiquement.
     67//      Si "afsz == true", la taille de fonte est choisie automatiquement avec "fszf"
     68//      representant la taille de fonte en fraction de (ymax-ymin)
     69//
     70// void DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt, unsigned int flags=kAxesDflt)
     71//        Appel de DrawXYAxes avec les parametres "axesAFSz. fontSz" de l'objet.
    6772//
    6873// void DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt, \
    6974//        double xmin, double xmax, double ymin, double ymax, \
    70 //        unsigned int flags=kAxesDflt, bool afsz=true)
     75//        unsigned int flags, bool afsz, double )
    7176//      Tracé d'axes avec spécification des limites d'axes.
     77//
     78// void DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt, \
     79//        double xmin, double xmax, double ymin, double ymax, unsigned int flags=kAxesDflt)
     80//        Appel de DrawXYAxes avec les parametres "axesAFSz. fontSz" de l'objet.
    7281//
    7382// void DrawXCaption(PIGraphicUC* g, string const& xLabel, PIGraphicAtt const& att)
     
    7988/* --Methode-- */
    8089void PIAxes::DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt,
    81                         unsigned int flags, bool afsz)
     90                        unsigned int flags, bool afsz, double fszf)
    8291{
    8392  PIGrCoord xmin, xmax, ymin, ymax;
    8493  g->GetGrSpace(xmin, xmax, ymin, ymax);
    8594  DrawXYAxes(g, gratt, (double)xmin, (double)xmax,
    86              (double)ymin, (double)ymax, flags, afsz);
     95             (double)ymin, (double)ymax, flags, afsz, fszf);
    8796}
    8897
     
    9099void PIAxes::DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt,
    91100                        double xmin, double xmax, double ymin, double ymax,
    92                         unsigned int flags, bool afsz)
     101                        unsigned int flags, bool afsz, double fszf)
    93102
    94103{
     
    107116
    108117  if(afsz) {
    109     double fsz = (yMax-yMin)*fontSz;
     118    double fsz = (yMax-yMin)*fszf;
    110119    g->SelFontSz(fsz);
    111120  }
     
    314323//      (X/Y max-min). Les paramètres ne sont pas changés si des valeurs
    315324//      négatives ou nulles sont spécifiées.
    316 // void ConfigureAutoFontSize(double fszf=0.0125)
    317 //      Configuration de la taille de fonte, en mode AutoFontSize.
     325// void ConfigureAutoFontSize(bool afsz=true, double fszf=0.04)
     326//      Configuration de la taille de fonte, en mode AutoFontSize ou FixedFontSize.
    318327//      La taille est exprimée en fraction de la taille totale YMax-Min
    319328// void  ConfigureAxesCenter(bool fset,double x0,double y0)
     
    332341
    333342/* --Methode-- */
    334 void PIAxes::ConfigureAutoFontSize(double fszf)
    335 {
     343void PIAxes::ConfigureAutoFontSize(bool afsz, double fszf)
     344{
     345  axesAFSz = afsz;
    336346  if (fszf > 1.e-19) fontSz = fszf;
    337347}
     
    420430    //Attention erreur d'arrondi x->0 (on code 5.1698e-26 au lieu de 0)
    421431    double xx = (fabs(xticks[i]/xstep)<1.e-5) ? 0.: xticks[i];
    422     sprintf(label,format.c_str(),xx/fac); Arrange_Label(label);
     432    double dog = fabs(xx/fac);
     433    if ((dog<=1.e-5)||(dog>=1.e5)) 
     434      sprintf(label,"%le",xx/fac);
     435    else
     436      sprintf(label,format.c_str(),xx/fac);
     437    Arrange_Label(label);
    423438    double largeur = g->CalcStringWidth(label);
    424439    g->DUC2GrC(largeur,0.,largpix,dum);
     
    463478    if(yticks[i]>yMax) break;
    464479    double yy = (fabs(yticks[i]/ystep)<1.e-5) ? 0.: yticks[i];
    465     sprintf(label,format.c_str(),yy/fac); Arrange_Label(label);
     480    double dog = fabs(yy/fac);
     481    if ((dog<=1.e-5)||(dog>=1.e5)) 
     482      sprintf(label,"%le",yy/fac);
     483    else
     484      sprintf(label,format.c_str(),yy/fac);
     485    Arrange_Label(label);
    466486    g->UC2GrC(x,yticks[i],dum,ypixdeb);   ypixdeb -= hautpix/2.;
    467487    // -- Attention: ypix=0 est en haut de l'ecran
     
    478498  if(npuiss!=0) {
    479499    if(aYdir) hauteur = -hauteur;
    480     double ym = (aYdir)? yMin: yMax; ym = g->DeltaUCY(ym,0.5*hauteur);
     500    double ym = (aYdir)? yMin: yMax; ym = g->DeltaUCY(ym,0.25*hauteur);
    481501    sprintf(label,"%d",npuiss);
    482502    g->DrawCompString(x,ym,"x 10",label,NULL,PI_VerticalBottom|just);
  • trunk/SophyaPI/PI/piaxes.h

    r4077 r4083  
    4040
    4141  virtual void      DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt,
    42                                unsigned int flags=kAxesDflt, bool afsz=true);
     42                               unsigned int flags, bool afsz, double fszf);
     43  inline  void      DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt, unsigned int flags=kAxesDflt)
     44     { DrawXYAxes(g, gratt, flags, axesAFSz, fontSz); }
    4345
    4446  virtual void      DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt,
    4547                               double xmin, double xmax,
    4648                               double ymin, double ymax,
    47                                unsigned int flags=kAxesDflt, bool afsz=true);
    48 
     49                               unsigned int flags, bool afsz, double fszf);
     50  inline void       DrawXYAxes(PIGraphicUC* g, PIGraphicAtt& gratt,
     51                               double xmin, double xmax, double ymin, double ymax, unsigned int flags=kAxesDflt)
     52    {   DrawXYAxes(g, gratt, xmin, xmax, ymin, ymax, flags, axesAFSz, fontSz); }
    4953
    5054  virtual void      DrawXCaption(PIGraphicUC* g, PIGraphicAtt& att, unsigned int flags,
     
    5660  void  ConfigureTicks(int ntickx=10, int nticky=12,
    5761                       double majtl=0.016, double mintl=0.01);
    58   void  ConfigureAutoFontSize(double fszf=0.04);
     62  //  Choix de taille automatique de fontes
     63  void  ConfigureAutoFontSize(bool afsz=true, double fszf=0.04);
    5964  void  ConfigureAxesCenter(bool fset=false,double x0=0.,double y0=0.);
    6065
     
    9196  bool   aXdir, aYdir;           // Sens des axes horiz, vertical
    9297  bool   aXlog, aYlog;           // Echelle log pour les axes horiz, vertical
    93   bool   axesAFSz;
     98  bool   axesAFSz;               // true -> AutoFontSize
    9499 
    95100  int xNTicks, yNTicks;             // Nb de ticks en X, Y
  • trunk/SophyaPI/PI/piaxestools.cc

    r4077 r4083  
    237237  mCkb[3]->SetState(scd->isLogScaleX());
    238238  mCkb[4]->SetState(scd->isLogScaleY());
    239   mCkb[7]->SetState(scd->BaseDrawer()->isAxesAutoFontSize());
     239  mCkb[7]->SetState(scd->BaseDrawer()->GetAutoFontSizeState());
    240240  }
    241241else {
     
    312312
    313313  scd->SetLogScale(mCkb[3]->GetState(), mCkb[4]->GetState() );
    314   scd->BaseDrawer()->SetAxesAutoFontSize(mCkb[7]->GetState() );
     314  scd->BaseDrawer()->ConfigureAutoFontSize(mCkb[7]->GetState(), -1);
    315315  if (refr) scd->Refresh();
    316316  return;
  • trunk/SophyaPI/PI/pibwdgx.cc

    r4077 r4083  
    3939CreateXtWdg(nom, piXtBaseWidgetClass, NULL, sx, sy, px, py);
    4040
    41 XtSetArg(wargs[0],PIXNobject,this);
     41XtSetArg(wargs[0],const_cast<char*>(PIXNobject),this);
    4242XtSetArg(wargs[1],XtNbackground, colpixwhite); 
    4343XtSetArg(wargs[2],XtNborderWidth, (Dimension)0); 
     
    7272#endif
    7373Arg  wargs[2];
    74 XtSetArg(wargs[0],PIXNobject,NULL);
     74 XtSetArg(wargs[0],const_cast<char*>(PIXNobject),NULL);
    7575XtSetValues(XtWdg(), wargs, 1);
    7676}
  • trunk/SophyaPI/PI/picmap.cc

    r4077 r4083  
    66#include "picmap.h"
    77#include <iostream>
     8
    89
    910//++
     
    2425//--
    2526
    26 #define  MXMAPIDS   30
     27#define  MXMAPIDS   34
    2728static   int    MapNCols[MXMAPIDS] = {
    2829  256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
    2930  256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
    30   256, 256, 256, 256, 256, 256, 256, 256, 256, 256  };
     31  256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
     32  216, 512, 4096, 32768  };
    3133
    3234// Tables de couleurs :
     
    3739// 1 Standard PI 64 couleurs differentes
    3840// 1 Standard PI 16 couleurs
     41// 1 Standard PI , 216 couleurs RGB (6x6x6)
     42// 1 Standard PI , 512 couleurs RGB (8x8x8)
     43// 1 Standard PI , 4096 couleurs RGB (16x16x16)
     44// 1 Standard PI , 32768 couleurs RGB (32x32x32)
    3945
    4046static   const char*  MapNoms[MXMAPIDS]  = {
     
    4753                      "MIDAS_Stairs9","MIDAS_StairCase","MIDAS_Color",
    4854                      "MIDAS_ManyCol","MIDAS_Idl14","MIDAS_Idl15",
    49                       "MultiCol16","MultiCol64"};
     55                      "MultiCol16","MultiCol64",
     56                      "RGB216CM","RGB512CM","RGB4096CM","RGB32768CM"};
    5057
    5158static   CMapId MapIds[MXMAPIDS] = {
     
    5865                      CMAP_MIDAS_Stairs9, CMAP_MIDAS_StairCase, CMAP_MIDAS_Color,
    5966                      CMAP_MIDAS_ManyCol, CMAP_MIDAS_Idl14, CMAP_MIDAS_Idl15,
    60                       CMAP_COL16, CMAP_COL64 } ;
     67                      CMAP_COL16, CMAP_COL64,
     68                      CMAP_RGB216, CMAP_RGB512, CMAP_RGB4096, CMAP_RGB32768} ;
    6169
    6270static   int mColTNums[8192];   // Max 8192 tables differentes pour le moment 
     
    7078                                  NULL, NULL, NULL, NULL, NULL,
    7179                                  NULL, NULL, NULL, NULL, NULL,
    72                                   NULL, NULL, NULL, NULL, NULL };
     80                                  NULL, NULL, NULL, NULL, NULL,
     81                                  NULL, NULL, NULL, NULL };
    7382
    7483int  PIColorMap::NumberStandardColorMaps()
     
    122131//|     CMAP_COL64      :  64 Couleurs arcenciel
    123132//|     CMAP_OTHER      :  Table non standard
     133//|     CMAP_RGB216     :  216 couleurs, 6x6x6 couleurs en composantes RGB
     134//|     CMAP_RGB512     :  512 couleurs, 8x8x8 couleurs en composantes RGB
     135//|     CMAP_RGB4096    :  4096 couleurs, 16x16x16 couleurs en composantes RGB
     136//|     CMAP_RGB4096    :  32768 couleurs, 32x32x32 couleurs en composantes RGB
     137
    124138//      Toutes les tables de couleurs standard possèdent 256 cellules de couleurs,
    125 //      contenant 16 ou 32 ou 128 couleurs distinctes.
     139//      contenant 16 ou 32 ou 128 (ou 216) couleurs distinctes,
     140//      sauf CMAP_RGB512 , CMAP_RGB4096 et CMAP_RGB32768.
    126141//
    127142// PIColorMap(string const& nom, int nCol)
     
    144159
    145160   if (NMaxTableAuto == 0) { //  Il faut allouer les tables de depart
    146      if ( TotNbColors() > 4096 ) NMaxTableAuto = MXMAPIDS-1;
     161     if ( TotNbColors() >= 4096 ) NMaxTableAuto = MXMAPIDS-2;
     162     if ( TotNbColors() >= 65536 ) NMaxTableAuto = MXMAPIDS-1;
    147163     else NMaxTableAuto = 3;
    148164     //     for(k=0; k<NMaxTableAuto; k++)  {
     
    158174   for(kdx=0; kdx<MXMAPIDS; kdx++)  if (id == MapIds[kdx])  break;
    159175   if (kdx == MXMAPIDS)  { id = MapIds[0];  kdx = 0; }
    160    for(k=0; k<NMaxTableAuto; k++) {
     176   for(k=0; k<=NMaxTableAuto; k++) {
    161177     if ((MapIds[k] == id) && (mMaps[k] == NULL))  { //  Table pas encore alloue
    162178       mnom = MapNoms[k];
     
    176192       if ( mMaps[k] ) { 
    177193         mColTNums[mMaps[k]->mCTId] = 1;  // Je force a liberer les couleurs
    178          delete mMaps[k] ;
     194         delete mMaps[k] ;   mMaps[k] = NULL;
     195         mnom = MapNoms[k];
     196         cout << " PIColorMap::PIColorMap(CMapId id) Freeing colors for ColorMap "
     197              << mnom << " ... " << endl;
    179198       }
    180199       mnom = MapNoms[kdx];
     200       cout << " PIColorMap::PIColorMap(CMapId id) Allocating ColorMap "
     201             << mnom << " ... " << endl;
    181202       mMaps[k] = new PIColorMap(MapIds[kdx],  MapNCols[kdx], mnom);
    182203     }
     
    563584      }
    564585      break;
     586
     587    case CMAP_RGB216 :
     588      i = 0;
     589      for(int kb=0; kb<6; kb++) {
     590        mycol.blue = (unsigned short)(kb*65535/5);
     591        for(int jg=0; jg<6; jg++) {
     592          mycol.green = (unsigned short)(jg*65535/5);
     593          for(int ir=0; ir<6; ir++) {
     594            mycol.red = (unsigned short)(ir*65535/5);
     595            AllocColor(mycol, i);   i++;
     596          }
     597        }           
     598      }
     599      mycol.blue = mycol.green =  mycol.red = 65535;
     600      for(i=216; i<256; i++)
     601        AllocColor(mycol, i);
     602      break;
     603
     604    case CMAP_RGB512 :
     605    case CMAP_RGB4096 :
     606    case CMAP_RGB32768 :
     607      {
     608      int nlev = 8;
     609      if (mType == CMAP_RGB4096)  nlev = 16;
     610      else if (mType == CMAP_RGB32768)  nlev = 32;
     611      int drgb = 65535/(nlev-1);
     612      i = 0;
     613      for(int kb=0; kb<nlev; kb++) {
     614        mycol.blue = (unsigned short)(kb*drgb);
     615        for(int jg=0; jg<nlev; jg++) {
     616          mycol.green = (unsigned short)(jg*drgb);
     617          for(int ir=0; ir<nlev; ir++) {
     618            mycol.red = (unsigned short)(ir*drgb);
     619            AllocColor(mycol, i);   i++;
     620          }
     621        }           
     622      }
     623      }
     624      break;
     625
    565626//----------------------------------------------------------
    566627//----------------------------------------------------------
  • trunk/SophyaPI/PI/picmap.h

    r4077 r4083  
    4747
    4848 //  Table simple a 16/64 couleurs
    49  CMAP_COL16       = 998,        // 16 Couleurs arcenciel
    50  CMAP_COL64       = 999         // 64 Couleurs differentes
     49 CMAP_COL16       = 991,        // 16 Couleurs arcenciel
     50 CMAP_COL64       = 992,         // 64 Couleurs differentes
     51 // Table de couleurs RGB 6x6x6=216 couleurs
     52 CMAP_RGB216      = 993,        // 216 couleurs avec toutes les nuances RGB
     53 CMAP_RGB512      = 994,        // 512 couleurs avec toutes les nuances RGB
     54 CMAP_RGB4096     = 995,        // 4096 couleurs avec toutes les nuances RGB
     55 CMAP_RGB32768    = 996         // 32768 couleurs avec toutes les nuances RGB
    5156 };
    5257
  • trunk/SophyaPI/PI/picmapview.cc

    r4077 r4083  
    55#include "sopnamsp.h"
    66#include "picmapview.h"
     7#include "strutil.h"
    78#include <math.h>
     9#include <iostream>
    810
    911//++
     
    7981  if ( cmap && (cmp->Type() == cmap->Type()) && (cmp->Type() != CMAP_OTHER)
    8082       && (cmp->IsColorIndexReversed() == cmap->IsColorIndexReversed())
    81        && (fabs(vmin-min) < 1.e-69)  && (fabs(vmax-max) > -1.e-69) )  return;
     83       && (fabs(vmin-min) < 1.e-69)  && (fabs(vmax-max) > -1.e-69) )  {
     84    if (refr)  Refresh();     
     85    return;
     86  }
    8287  if (cmap) delete cmap;
    8388  cmap = new PIColorMap(*cmp);
     
    9398       (cmap->IsColorIndexReversed() == revidx) &&
    9499       ((vmin-min) < 1.e-69) &&  ((vmin-min) > -1.e-69) &&
    95        ((vmax-max) < 1.e-69) &&  ((vmax-max) > -1.e-69) )  return;
     100       ((vmax-max) < 1.e-69) &&  ((vmax-max) > -1.e-69) )  {
     101    if (refr)  Refresh();     
     102    return;
     103  }
    96104  if (cmap) delete cmap;
    97105  cmap = new PIColorMap(cmapid);
     
    117125
    118126  int k;
     127  // On limite le nombre de carres de couleurs traces, si trop de couleur ...
     128  int dk = cmap->NCol()/128;
     129  if (dk<1) dk=1;
    119130  if (sx > sy) {    // horizontal
    120131    int xc, dx;
    121132    xc = 0;
    122     for(k=0; k<cmap->NCol(); k++) {
    123       dx = (sx-xc)/(cmap->NCol()-k);
     133    for(k=0; k<cmap->NCol(); k+=dk) {
     134      dx = dk*(sx-xc)/(cmap->NCol()-k);
    124135      g->SelForeground((*cmap), k);
    125136      g->DrawFBox(xc, 0, dx+1, sy);
     
    130141    int yc, dy;
    131142    yc = sy;
    132     for(k=0; k<cmap->NCol(); k++) {
    133       dy = yc/(cmap->NCol()-k);
     143    for(k=0; k<cmap->NCol(); k+=dk) {
     144      dy = dk*yc/(cmap->NCol()-k);
    134145      yc -= dy;
    135146      g->SelForeground((*cmap), k);
     
    177188}
    178189
    179 
    180 
    181 
    182 
    183 
     190//++
     191// Class        PICMapDrawer
     192// Lib          PI
     193// include      picmapview.h
     194//
     195//      Classe de traceur de colormap
     196//--
     197//++
     198// Links        Parents
     199// PIDrawer
     200//--
     201//++
     202
     203
     204/* --Methode-- */
     205PICMapDrawer::PICMapDrawer(bool fgvert)
     206  : fgvert_(fgvert), fgtext_(false), cmapp(NULL), bornes_(5)   
     207{
     208  SetLimits(0.,1.,0.,1., kAxeDirLtoR, kAxeDirDownUp);
     209  SetColMapId(CMAP_GREY32);
     210}
     211
     212/* --Methode-- */
     213PICMapDrawer::~PICMapDrawer()
     214{
     215}
     216
     217/* --Methode-- */
     218void PICMapDrawer::SetBornes(LUT& lut)
     219{
     220  fgtext_=true; 
     221  bornes_[0]=lut.Min();   bornes_[4]=lut.Max();
     222  bornes_[1]=lut.Borne((lut.NCol()-2)/4);
     223  bornes_[2]=lut.Borne((lut.NCol()-2)/2);
     224  bornes_[3]=lut.Borne(3*(lut.NCol()-2)/4);
     225  return;
     226}
     227
     228/* --Methode-- */
     229void PICMapDrawer::SetBornes(double min, double max)
     230{
     231  fgtext_=true; 
     232  bornes_[0]=min;   bornes_[4]=max;
     233  bornes_[1]=min+(max-min)*0.25;
     234  bornes_[2]=min+(max-min)*0.5;
     235  bornes_[3]=min+(max-min)*0.75;
     236  return;
     237}
     238
     239/* --Methode-- */
     240void PICMapDrawer::Draw(PIGraphicUC* g, double /*xmin*/, double /*ymin*/,
     241                        double /*xmax*/, double /*ymax*/)
     242{
     243  PIColorMap* cmp=cmapp;
     244  PIColorMap cmapi(cmapid_);
     245  if (cmp==NULL)  cmp=&cmapi;
     246  PIColorMap& cmap=(*cmp);
     247
     248  //  cout << " *DBG*PICMapDrawer::Draw() Sz:" << BWdgXSize() << "," << BWdgYSize()
     249  //     << " Pos:" << BWdgXPos() << "," << BWdgYPos() << endl;
     250  // On limite le nombre de carres de couleurs traces, si trop de couleur ...
     251  PIPixColIdx pixc;
     252  if (fgvert_) {   // vertical
     253    pixc.AllocateByte(0.25*BWdgXSize(), BWdgYSize());
     254    for(int j=0; j<pixc.YSize(); j++)  {
     255      int ci = j*cmap.NCol()/pixc.YSize();
     256      int jrev=pixc.YSize()-j-1;
     257      for(int i=0; i<pixc.XSize(); i++) pixc.GetByte(i,jrev)=(unsigned char)ci;
     258    }
     259    g->DrawPixmap(0.,1.,pixc, cmp);
     260  }
     261  else {    // horizontal
     262    pixc.AllocateByte(BWdgXSize(), 0.25*BWdgYSize());
     263    for(int i=0; i<pixc.XSize(); i++)  {
     264      int ci = i*cmap.NCol()/pixc.XSize();
     265      for(int j=0; j<pixc.YSize(); j++) pixc.GetByte(i,j)=(unsigned char)ci;
     266    }
     267    g->DrawPixmap(0.,0.25,pixc, cmp);
     268  }
     269
     270
     271  if (!fgtext_) return;
     272  char buff[32];
     273  double ps[5]={0.025,0.25,0.5,0.75,0.975};
     274  //  g->SelForeground(PI_White);
     275  for(int k=0; k<5; k++) {
     276    sprintf(buff,"%6.2lg",bornes_[k]);
     277    strip(buff,'B',' ');
     278    if (fgvert_) {   // vertical
     279      g->DrawLine(0.25,ps[k],0.35,ps[k]);
     280      g->DrawString(0.7, ps[k], buff, PI_TextDirectionVerticalUp|PI_HorizontalCenter|PI_VerticalCenter);
     281    }
     282    else {   // horizontal
     283      g->DrawLine(ps[k],0.25,ps[k],0.35);
     284      g->DrawString(ps[k], 0.7, buff, PI_VerticalCenter|PI_HorizontalCenter);
     285    }
     286  }
     287  return;
     288}
     289
     290
  • trunk/SophyaPI/PI/picmapview.h

    r4077 r4083  
    1111#include PIBWDG_H
    1212#include PICMAP_H
     13
     14#include "pidrawer.h"
     15#include "lut.h"
     16#include <vector>
     17
    1318
    1419class PICMapView : public PIBaseWdg
     
    3843};
    3944
     45class PICMapDrawer : public PIDrawer
     46{
     47public:
     48                     PICMapDrawer(bool fgvert=false);
     49                     ~PICMapDrawer();
     50
     51  virtual void       Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
     52  inline void        SetHorizontal()  { fgvert_=false; }
     53  inline void        SetVertical()  { fgvert_=true; }
     54
     55  inline void        SetColMapId(CMapId cmapid, bool revcidx=false)
     56                     { cmapid_=cmapid;  revcidx_=revcidx;  cmapp=NULL;  return; }
     57
     58  inline void        SetColMap(PIColorMap* cmp)
     59                     { cmapp=cmp;  return; }
     60
     61  void               SetBornes(LUT& lut);
     62  void               SetBornes(double min, double max);
     63
     64protected:
     65
     66  bool fgvert_;  // true -> vertical
     67  bool fgtext_;  // true -> ecriture des valeurs des bornes
     68  PIColorMap* cmapp; 
     69  CMapId cmapid_;
     70  bool revcidx_;  // true -> reverse color map index
     71  vector<double> bornes_; 
     72};
     73
    4074
    4175#endif
  • trunk/SophyaPI/PI/picmapx.cc

    r4077 r4083  
    187187  mColRGB = new PIColor[mNCol];
    188188  mNewCol = new bool[mNCol];
     189  /*   Remplace par memcpy pour performances, Reza, Nov 2008
    189190  for (int i=0; i<mNCol; i++) 
    190191    { mColors[i] = ((PIColorMapX *)x)->mColors[i];
     
    192193// C'est la table de couleur originale qui est responsable de liberer les couleurs - Reza 8/2/98
    193194    mNewCol[i] = false; } 
    194 }
     195  -> memcpy (Nov08) */
     196  memcpy(mColors, ((PIColorMapX *)x)->mColors, sizeof(PIXColor)*mNCol);
     197  memcpy(mColRGB, ((PIColorMapX *)x)->mColRGB, sizeof(PIColor)*mNCol);
     198// C'est la table de couleur originale qui est responsable de liberer les couleurs - Reza 8/2/98
     199  for (int i=0; i<mNCol; i++)   mNewCol[i] = false;
     200}
  • trunk/SophyaPI/PI/picontainergen.h

    r4077 r4083  
    5151  inline  PILayoutMgr* GetLayoutMgr() { return(layout); }
    5252
    53    virtual void         PSPrint(PSFile *psf, int ofx=0, int ofy=0,
    54                                double scale_x=1., double scale_y=1.);
     53  virtual void         PSPrint(PSFile *psf, int ofx=0, int ofy=0,
     54                               double scale_x=1., double scale_y=1.);
    5555
    5656  virtual void         Show();
  • trunk/SophyaPI/PI/pidrawer.cc

    r4077 r4083  
    5252//--
    5353
     54// Valeur par defaut global pour TailleFonteAuto
     55double PIDrawer::glDefAFSzFrac = 0.04;
     56void PIDrawer::SetGlDefAutoFontSizeFrac(double fszf)
     57{
     58  if (fszf>1.e-6)  glDefAFSzFrac = fszf;
     59}
     60double PIDrawer::GetGlDefAutoFontSizeFrac()
     61{
     62  return glDefAFSzFrac;
     63}
     64
    5465PIDrawer::PIDrawer()
    5566{
     
    6576  limitsFixed = false;
    6677  SetAxesFlags(kAxesNone);   // Pas de trace d'axes par defaut
    67   SetAxesAutoFontSize();
     78  ConfigureAutoFontSize(true, glDefAFSzFrac);
    6879
    6980  mDndfg = false;  // Pour controle de l'appel de Detach() si delete
     
    107118
    108119//++
    109 // Titre        Gestion des axes et des limites
     120// Titre        Gestion des axes, des limites et coordonnees fenetre
    110121//      Le tracé des axes 2D est pris en charge par la classe PIAxes.
    111122//--
    112123//++
     124// double BWdgXPos()  BWdgYPos()
     125//      Renvoient les positions (X,Y) du drawer dans l'objet PIBaseWdg. Ces positions ne sont
     126//      valables qu'apres appel a SetDrwWdg() - Ne peut donc etre utilise en pratique que dans
     127//      la methode Draw.
     128// double  BWdgXSize()  BWdgYSize()
     129//      Renvoient les tailles (X,Y) du drawer dans l'objet PIBaseWdg. Meme remarque que pour
     130//      BWdgXPos()  BWdgYPos().
     131//
    113132// void  SetLimits(double xmin, double xmax, double ymin, double ymax, -
    114133//                 int axrl=kAxeDirSame, int ayud=kAxeDirSame)
    115 //      Définit les limites du système de coordonnées.
     134//      Définit les limites du système de coordonnées du Drawer.
    116135//|     kAxeDirSame , kAxeDirAuto
    117136//|     kAxeDirLtoR , kAxeDirRtoL  (Axe X)
     
    143162//|     kMajTicks , kMinTicks , kLabels , kGridOn
    144163//|     kAxesDflt , kAxesNone
    145 // void SetAxesAutoFontSize(bool fg=true)
    146 //      Si "fg==true", la taille de la fonte pour les labels d'axes (chiffres) est
     164// void ConfigureAutoFontSize(bool afsz=true, double fszf=0.05)
     165//      Si "fg==true", la taille de la fonte par le drawer, est
    147166//      choisie automatiquement, en s'adaptant à la taille de la zone de tracé -
    148 //      sinon, taille de la fonte de l'objet PIDrawer.
     167//      sinon, taille de la fonte de l'objet PIDrawer. Cette taille est donnée par
     168//      FontSize=(YMax()-YMin())*(mFontSzF=fszf). "mFontSzF=fszf" n'est mis à jour
     169//      que si fszf>0. Le décodage des attributs graphiques par DecodeOptionString()
     170//      ("autofontsize=fszf" et "fixedfontsize")  permet de modifier ces attributs de
     171//      choix automtique de fonte. Utilisé en particulier par PIElDrawer pour
     172//      le tracé les labels d'axes (chiffres).
    149173// unsigned int GetAxesFlags()
    150174//      Renvoie les attributs de tracé d'axes 
    151 // bool  isAxesAutoFontSize()
    152 //      Renvoie la valeur du flag de choix automatique de taille de fonte pour axes.
     175// bool  GetAutoFontSizeState()
     176//      Renvoie la valeur du flag de choix automatique de taille de fonte.
     177// double  GetAutoFontSizeFraction()
     178//      Renvoie la valeur de la fraction de taille ("mFontSzF) pour lee
     179//      choix automatique de taille de fonte.
    153180// void  DrawAxes(PIGraphicUC* g)
    154181//      Méthode de tracé des axes (le tracé est pris en charge par la classe *PIAxes*)
     
    395422PIDrawer::DecodeOptionString(vector<string> & opt, bool rmdecop)
    396423{
    397   if (opt.size() < 1)  return(0); 
     424  int nopt0 = opt.size();
     425  if (nopt0 < 1)  return(0); 
    398426  PIGraphicAtt gratt;
    399   int ndec = gratt.DecodeAttStrings(opt, rmdecop);
     427  int ndec1 = gratt.DecodeAttStrings(opt, rmdecop);
    400428  UpdateGraphicAtt(gratt);
    401   return(ndec);
     429  if ((nopt0 - ndec1) < 1) return(ndec1);  // si tout a ete decode
     430  vector<string> udopt;
     431  unsigned int k = 0;
     432  int ndec = opt.size();
     433  string opts;
     434  for( k=0; k<opt.size(); k++ ) {
     435    opts = opt[k];
     436    if (opts.substr(0,13) == "autofontsize=") {
     437       double fszf = atof(opts.substr(13).c_str());
     438       ConfigureAutoFontSize(true, fszf);
     439    }
     440    else if (opts == "fixedfontsize")
     441       ConfigureAutoFontSize(false, -1.); 
     442    else {
     443      ndec--;
     444      if (rmdecop)  udopt.push_back(opts);
     445    }
     446  }
     447
     448  if (rmdecop)  opt = udopt;
     449  return(ndec+ndec1);
    402450}
    403451
     
    424472  info += "   FontAtt: roman, bold, italic, bolditalic  \n";
    425473  info += "   FontSize: 6,8,10,12... (pts) - integer \n";
     474  info += ">>> Automatic font size selection : \n";
     475  info += "    autofontsize=FontSizeFrac fixedfontsize \n";
     476  info += ">>> ColorTables: defcmap  grey32  invgrey32  colrj32  colbr32 \n";
    426477  info += ">>> marker=MarkerType,MarkerSize (MarkerSize: integer 3,5,7... \n";
    427478  info += "   MarkerType: dot, plus, cross, circle, fcircle, box, fbox \n";
     
    505556  PIAxes axes;
    506557  axes.DrawXYAxes(g, mGrAtt, XMin(), XMax(), YMin(), YMax(),
    507                   axesFlags, axesAFSz);
     558                  axesFlags, mAFSz, mFontSzF);
    508559  g->Clip();
    509560}
  • trunk/SophyaPI/PI/pidrawer.h

    r4077 r4083  
    3030
    3131  virtual void       SetAxesFlags(unsigned int flags=kAxesNone);
    32   inline  void       SetAxesAutoFontSize(bool fg=true) { axesAFSz = fg; }
     32
     33//---- Choix automatique ou pas de taille de fonte
     34  inline void        ConfigureAutoFontSize(bool afsz=true, double fszf=0.04)
     35    { mAFSz = afsz;  if (fszf>1e-5)  mFontSzF = fszf; }
     36//  Valeur par defaut global pour le AutoFontSizeFrac, utilise dans les constructeurs de PIDrawer
     37  static  void       SetGlDefAutoFontSizeFrac(double fszf=0.04);
     38//  Retourne la valeur globale par defaut de AutoFontSizeFrac
     39  static  double     GetGlDefAutoFontSizeFrac();
    3340
    3441  virtual void       DrawAxes(PIGraphicUC* g);
     
    5360  virtual void       HighLight(bool fgh); 
    5461
     62  // Zone de trace/accrochage dans le BaseWidget
     63  inline int         BWdgXPos() const { return xW0; }
     64  inline int         BWdgYPos() const { return yW0; }
     65  inline int         BWdgXSize() const { return xWd; }
     66  inline int         BWdgYSize() const { return yWd; }
     67
     68  // Limites et informations sur les coordonnees dans le systeme du Drawer
    5569  inline double      XMin() const {return xMin;}
    5670  inline double      XMax() const {return xMax;}
     
    6377
    6478  inline unsigned int GetAxesFlags() { return(axesFlags); }
    65   inline bool         isAxesAutoFontSize() { return axesAFSz; }
     79
     80  inline bool         GetAutoFontSizeState() { return mAFSz; }
     81  inline double       GetAutoFontSizeFraction() { return mFontSzF; }
    6682
    6783  inline PIGraphicUC*    GetGraphicUC() { return(mGrUC); }
     
    127143  bool limitsFixed;
    128144  unsigned int axesFlags;
    129   bool axesAFSz;
     145
     146  bool mAFSz;  // true -> Choix automatique de taille de font en fraction (ymax-ymin)
     147  double mFontSzF;   // TailleFonteAuto = mFontSzF*(ymax-ymin)
     148  static double glDefAFSzFrac;   // Valeur globale par defaut pour mFontSzF, utilise ds le constructeur
     149
    130150  PIBaseWdgGen* mBWdg;
    131151  PIGraphicUC* mGrUC;
  • trunk/SophyaPI/PI/pieldrw.cc

    r4077 r4083  
    575575      SetAxesFlags(GetAxesFlags() & ~kMinTicks);
    576576    else if (opts == "extticks")
    577       SetAxesFlags(GetAxesFlags() & ~kIntTicks |  kExtTicks);
     577      SetAxesFlags((GetAxesFlags() & ~kIntTicks) |  kExtTicks);
    578578    else if (opts == "intticks")
    579       SetAxesFlags(GetAxesFlags() & ~kExtTicks |  kIntTicks);
     579      SetAxesFlags((GetAxesFlags() & ~kExtTicks) |  kIntTicks);
    580580    else if (opts == "extintticks")
    581581      SetAxesFlags(GetAxesFlags() | kIntTicks |  kExtTicks);
     
    593593      }
    594594    }
    595 
    596     else if (opts.substr(0,13) == "autofontsize=") {
    597       double fszf = atof(opts.substr(13).c_str());
    598       ConfigureAxeAutoFontSize(fszf);
    599       SetAxesAutoFontSize(true);
    600     }
    601     else if (opts == "fixedfontsize")
    602       SetAxesAutoFontSize(false);
    603 
     595 
    604596    else if (opts == "title" || opts == "tit") ShowTitles(true);
    605597    else if (opts == "notitle" || opts == "notit") ShowTitles(false);
     
    639631  info += "   ticks/noticks minorticks/nominorticks \n";
    640632  info += "   extticks/intticks/extintticks nbticks=X_NbTicks,Y_NbTicks \n";
    641   info += "   tickslen=MajorTickLenFrac,MinorTickLenFraC \n";
    642   info += " >> Axe label font size: \n";
     633  info += "   tickslen=MajorTickLenFrac,MinorTickLenFraC \n"; 
     634  info += " >> Axe labels font size: \n";
    643635  info += "    autofontsize=FontSizeFrac fixedfontsize \n";
    644636  info += " >> Up/Down title: title tit notitle notit \n";
     
    655647  //  g->NoClip();
    656648  axeDr.DrawXYAxes(g, mGrAtt, XMin(), XMax(), YMin(), YMax(),
    657                    axesFlags, axesAFSz);
     649                   axesFlags, mAFSz, mFontSzF);
    658650  if (showAxesLabels) {
    659651    axeDr.DrawXCaption(g, labelAtt, axesFlags, xLabel);
  • trunk/SophyaPI/PI/pieldrw.h

    r4077 r4083  
    246246                                       double majtl=0., double mintl=0.)
    247247     { axeDr.ConfigureTicks(ntickx, nticky, majtl, mintl); }
    248   inline void        ConfigureAxeAutoFontSize(double fszf=0.)
    249      { axeDr.ConfigureAutoFontSize(fszf); }
    250248
    251249  inline PIElDrwMgr& ElDrwMgr()    { return eltsMgr; }
  • trunk/SophyaPI/PI/pifilechox.cc

    r4077 r4083  
    120120{
    121121XmString xmstr;
    122 xmstr = XmStringLtoRCreate((char *)path.c_str(), XmSTRING_DEFAULT_CHARSET);
     122xmstr = XmStringLtoRCreate(const_cast<char*>(path.c_str()), const_cast<char*>(XmSTRING_DEFAULT_CHARSET));
    123123Arg warg[2];
    124124XtSetArg(warg[0], XmNdirectory, xmstr);
     
    132132{
    133133XmString xmstr;
    134 xmstr = XmStringLtoRCreate((char *)fname.c_str(), XmSTRING_DEFAULT_CHARSET);
     134xmstr = XmStringLtoRCreate(const_cast<char*>(fname.c_str()),  const_cast<char*>(XmSTRING_DEFAULT_CHARSET));
    135135Arg warg[2];
    136136XtSetArg(warg[0], XmNtextString, xmstr);
  • trunk/SophyaPI/PI/pifontx.cc

    r4077 r4083  
    263263
    264264static XtResource resources[] = {
    265   { "fontFamilyName", "FontFamilyName", XtRString, sizeof(String),
     265  { const_cast<char *>("fontFamilyName"), const_cast<char *>("FontFamilyName"),
     266    XtRString, sizeof(String),
    266267    /*XtOffset(apd, fntFam[0])*/ 0, XtRString, const_cast<char *>("*-courier") } ,
    267   { "courierfontFamilyName", "CourierfontFamilyName", XtRString, sizeof(String),
     268  { const_cast<char *>("courierfontFamilyName"), const_cast<char *>("CourierfontFamilyName"),
     269    XtRString, sizeof(String),
    268270    sizeof(String) , XtRString, const_cast<char *>("*-courier") } ,
    269   { "helveticafontFamilyName", "HelveticafontFamilyName", XtRString, sizeof(String),
     271  { const_cast<char *>("helveticafontFamilyName"), const_cast<char *>("HelveticafontFamilyName"),
     272    XtRString, sizeof(String),
    270273    2*sizeof(String) , XtRString, const_cast<char *>("*-helvetica") } ,
    271   { "timesfontFamilyName", "TimesfontFamilyName", XtRString, sizeof(String),
     274  { const_cast<char *>("timesfontFamilyName"), const_cast<char *>("TimesfontFamilyName"),
     275    XtRString, sizeof(String),
    272276    3*sizeof(String) , XtRString, const_cast<char *>("*-times") } ,
    273   { "symbolfontFamilyName", "SymbolfontFamilyName", XtRString, sizeof(String),
     277  { const_cast<char *>("symbolfontFamilyName"), const_cast<char *>("SymbolfontFamilyName"),
     278    XtRString, sizeof(String),
    274279    4*sizeof(String) , XtRString, const_cast<char *>("*-symbol") }
    275280};
    276281 
    277 static char * fnbi_b[4] = { "medium-r-normal", "bold-r-normal",
     282static const char * fnbi_b[4] = { "medium-r-normal", "bold-r-normal",
    278283                          "medium-o-normal", "bold-o-normal" };
    279 static char * fnbo_b[4] = { NULL, NULL,
     284static const char * fnbo_b[4] = { NULL, NULL,
    280285                          "medium-i-normal", "bold-i-normal" };
    281286
     
    289294  int count,k;
    290295  Display * mdsp = PIXDisplay();
    291   char **list;
     296  char **list = NULL;
    292297
    293298  for (k=0; k<5; k++)  {  // Recherche de la fonte pour tailles croissantes
    294299    sprintf(buff,"-%s-%s-*-%d-*-*-*-*-*-*-*", apd.fntFam[kfn], fnbi_b[jat], fntsz[isz]+k);
    295300    list = XListFonts(mdsp, buff, 10, &count);
    296     XFreeFontNames(list);
    297301    if ((count <= 0) && (fnbo_b[jat] != NULL)) {
     302      if (list) XFreeFontNames(list); 
    298303      sprintf(buff,"-%s-%s-*-%d-*-*-*-*-*-*-*", apd.fntFam[kfn], fnbo_b[jat], fntsz[isz]+k);
    299304      list = XListFonts(mdsp, buff, 10, &count);
    300       XFreeFontNames(list);
    301305    }
    302306    if (count > 0)  break;
    303     }
     307  }
    304308  // certaines fontes n'ont pas de version  bold ou italique
    305309  if ( (count == 0) && (jat > 0) ) {
    306310    for (k=0; k<5; k++)  {  // Recherche de la fonte pour tailles croissantes
     311      if (list) XFreeFontNames(list); 
    307312      sprintf(buff,"-%s-%s-*-%d-*-*-*-*-*-*-*", apd.fntFam[kfn], fnbi_b[0], fntsz[isz]+k);
    308313      list = XListFonts(mdsp, buff, 10, &count);
    309       XFreeFontNames(list);
    310314      if (count > 0)  break;
    311       }
    312315    }
    313   if (count > 0)
    314     fntst[isz][jat][kfn] = XLoadQueryFont(mdsp, buff);
    315   else
    316     { printf("PIFontX::LoadFontSt/ Pb font %s - Using default \n", buff);   
    317     fntst[isz][jat][kfn] = defnt; }
     316  }
     317  if (count > 0) {
     318    for (int kkk=0; kkk<count; kkk++) {
     319      /*  pour debug
     320      printf("PIFontX::LoadFontSt/DBG - Call to XLoadFont(%s) \n", list[kkk]);
     321      Font lfid=XLoadFont(mdsp,list[kkk]);
     322      printf("PIFontX::LoadFontSt/DBG - Call to XQueryFont(FID=%ld) \n", (unsigned long)lfid);
     323      fntst[isz][jat][kfn] = XQueryFont(mdsp, lfid);   
     324      printf("PIFontX::LoadFontSt/DBG - Call to XLoadQueryFont(%s) \n", list[kkk]);
     325      */
     326      fntst[isz][jat][kfn] = XLoadQueryFont(mdsp, list[kkk]);
     327      if (fntst[isz][jat][kfn] != NULL) break;
     328    }
     329    if (list) XFreeFontNames(list); 
     330  }
     331  else  {
     332    if (list) XFreeFontNames(list); 
     333    printf("PIFontX::LoadFontSt/ Pb font %s - Using default \n", buff);   
     334    fntst[isz][jat][kfn] = defnt;
     335    }
    318336  }
    319337
     
    342360XtGetApplicationResources(PIXtTopWdg(), &apd, resources,
    343361                          XtNumber(resources), NULL, 0);
     362// printf("PIFontX::GlInit()-DBG- FontFamily = %s \n",apd.fntFam[0]);
     363
    344364sprintf(buff,"-%s-*-*-*-*-*-*-*-*-*-*-*-*", apd.fntFam[0]);
     365list = NULL;
    345366list = XListFonts(mdsp, buff, 15, &count);
    346 XFreeFontNames(list);
    347367if (count < 5)
    348368  {
    349369  printf("PIFontX::Init %d fonts found for %s , switching to courier\n",
    350370         count, apd.fntFam[0]);
    351   apd.fntFam[0] = "*-courier";
     371  apd.fntFam[0] = const_cast<char *>("*-courier");
     372  if (list) XFreeFontNames(list);
    352373  }
    353374sprintf(buff,"-%s-%s-*-*-*-*-12-*-*-*-*", apd.fntFam[0], fnbi_b[0]);
    354375list = XListFonts(mdsp, buff, 10, &count);
    355 XFreeFontNames(list);
    356376if (count < 1) {
     377  if (list) XFreeFontNames(list);
    357378  sprintf(buff,"-*-fixed-*-*-*-*-12-*-*-*-*-*-*-*");
    358379  list = XListFonts(mdsp, buff, 10, &count);
    359   XFreeFontNames(list);
    360380  if (count < 1)   { 
     381    if (list) XFreeFontNames(list);
    361382    sprintf(buff,"fixed");
    362383    list = XListFonts(mdsp, buff, 10, &count);
    363     XFreeFontNames(list);
    364384  }
    365385  if (count < 1)   { 
     386    if (list) XFreeFontNames(list);
    366387    strcpy(buff,"");
    367388    list = XListFonts(mdsp, buff, 10, &count);
    368     XFreeFontNames(list);
    369389  }
    370390}
    371391if (count < 1) { 
     392  if (list) XFreeFontNames(list);
    372393  printf("PIFontX::Init/ Erreur, no font found ... \n");
    373394  defnt = NULL;
    374   }
    375 else defnt = XLoadQueryFont(mdsp, buff);
    376 
     395  //Reza+Bruno, 17 Juin 2008 - Il faut lancer une exception
     396  }
     397else {
     398  defnt = NULL;
     399  for (int kkk=0; kkk<count; kkk++) {
     400    defnt = XLoadQueryFont(mdsp, list[kkk]);
     401    if (defnt != NULL) break;
     402  }
     403  if (list) XFreeFontNames(list); 
     404}
    377405for (i=0; i<NMAXFONTSZ; i++)
    378406  for (j=0; j<NMAXFONTATT; j++) 
     
    399427// HugeFontIndex = NMAXFONTSZ-1;
    400428
    401 // printf("PIFontX::Init()-DBG- FontIndex= %d %d %d (SzF=%d) \n",
    402 //       SmallFontIndex, NormalFontIndex, BigFontIndex, szf);
     429// printf("PIFontX::GlInit()-DBG- FontIndex= %d %d %d (SzF=%d) \n",
     430//       SmallFontIndex, NormalFontIndex, HugeFontIndex, szf);
    403431
    404432return;
  • trunk/SophyaPI/PI/pigraphgen.h

    r4077 r4083  
    1717
    1818#include "pilineatt.h"  // Class PILineAtt
     19#include "pipixutils.h"  // classes utilitaires pour pixels/RGB ...
    1920
    2021
     
    118119                                     bool fgline=true);
    119120
    120   virtual void       DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix,
    121                                 int sx, int sy, PIColorMap* cmap)              = 0;
     121  virtual void       DrawPixmap(PIGrCoord x, PIGrCoord y, PIPixColIdx & pix,
     122                                PIColorMap* cmap)                              = 0;
    122123
    123124// Modifications attributs graphiques
  • trunk/SophyaPI/PI/pigraphps.cc

    r4077 r4083  
    324324
    325325/* --Methode-- */
    326 void PIGraphicPS::DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix,
    327                             int sx, int sy, PIColorMap* cmap)
    328 {
     326void PIGraphicPS::DrawPixmap(PIGrCoord x, PIGrCoord y, PIPixColIdx & pixc, PIColorMap* cmap)
     327{
     328int sx = pixc.XSize();
     329int sy = pixc.YSize();
    329330if ( (sx < 1) || (sy < 1) )  return;
    330 if ((pix == NULL) || (cmap == NULL)) return;
    331 if(mPSOut)
    332   mPSOut->Image((double)x, (double)y, (double)sx, (double)sy, sx, sy, pix, cmap);
     331if (cmap == NULL) return;
     332if(mPSOut) {
     333  if (pixc.BytePointer())
     334    mPSOut->Image((double)x, (double)y, (double)sx, (double)sy, sx, sy, pixc.BytePointer(), cmap);
     335  else if (pixc.ShortPointer())
     336    mPSOut->Image((double)x, (double)y, (double)sx, (double)sy, sx, sy, pixc.ShortPointer(), cmap);
     337}
    333338return;
    334339}
  • trunk/SophyaPI/PI/pigraphps.h

    r4077 r4083  
    3838  virtual void       DrawMarker(PIGrCoord x0, PIGrCoord y0);
    3939  virtual void       DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n);
    40   virtual void       DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix,
    41                                 int sx, int sy, PIColorMap* cmap);
     40  virtual void       DrawPixmap(PIGrCoord x, PIGrCoord y, PIPixColIdx & pix,  PIColorMap* cmap);
    4241
    4342// Modifications attributs graphiques
  • trunk/SophyaPI/PI/pigraphuc.cc

    r4077 r4083  
    729729
    730730/* --Methode-- */
    731 void PIGraphicUC::DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix,
    732                         int sx, int sy, PIColorMap* cmap)
    733 {
    734   if (!mGrC) return;
    735   if ( (sx < 1) || (sy < 1) )  return;
    736   if ((pix == NULL) || (cmap == NULL)) return;
     731void PIGraphicUC::DrawPixmap(PIGrCoord x, PIGrCoord y, PIPixColIdx & pix, PIColorMap* cmap)
     732{
     733  if (!mGrC) return;
     734  if ( (pix.XSize() < 1) || (pix.YSize() < 1) )  return;
     735  if (cmap == NULL) return;
    737736  double xf,yf;
    738737  UC2GrC(x, y, xf, yf);
    739   mGrC->DrawPixmap(xf, yf, pix, sx, sy, cmap);
     738  mGrC->DrawPixmap(xf, yf, pix, cmap);
    740739}
    741740
  • trunk/SophyaPI/PI/pigraphuc.h

    r4077 r4083  
    7878                                     bool fgline=true);
    7979
    80   virtual void       DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix,
    81                                 int sx, int sy, PIColorMap* cmap);
     80  virtual void       DrawPixmap(PIGrCoord x, PIGrCoord y, PIPixColIdx & pix, PIColorMap* cmap);
    8281
    8382// Modifications attributs graphiques
  • trunk/SophyaPI/PI/pigraphx.cc

    r4077 r4083  
    384384
    385385/* --Methode-- */
    386 void PIGraphicX::DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix,
    387                             int sx, int sy, PIColorMap* cmap)
     386void PIGraphicX::DrawPixmap(PIGrCoord x, PIGrCoord y, PIPixColIdx & pixc, PIColorMap* cmap)
    388387{
    389388Window xw;
     
    395394XImage * ximg;
    396395
    397 if ( (sx < 1) || (sy < 1) )  return;
    398 if ((pix == NULL) || (cmap == NULL)) return;
     396int sx = pixc.XSize();
     397int sy = pixc.YSize();
     398if ((sx==0) || (sx==0) || (cmap == NULL)) return;
    399399
    400400 
     
    406406pad = (depth > 8) ? 32 : 8;
    407407ximg = XCreateImage (mdsp,DefaultVisual(mdsp,scr),
    408                      depth,ZPixmap,0,NULL, sx, sy, pad,0);
     408                     depth,ZPixmap,0,NULL, sx,sy, pad,0);
    409409if (ximg == NULL)  return;
    410410ximg->data = new char [sy*ximg->bytes_per_line];
     
    412412  { XFree(ximg); return; }
    413413
    414 for(j=0; j<sy; j++)
    415   for(i=0; i<sx; i++)
    416     { XPutPixel(ximg, i, j, cmap->Color(*pix) );  pix++; }
     414if (pixc.BytePointer()) {
     415  unsigned char * pix = pixc.BytePointer();
     416  for(j=0; j<sy; j++)
     417    for(i=0; i<sx; i++)
     418      { XPutPixel(ximg, i, j, cmap->Color(*pix) );  pix++; }
     419}
     420else if (pixc.ShortPointer()) {
     421  unsigned short * pix = pixc.ShortPointer();
     422  for(j=0; j<sy; j++)
     423    for(i=0; i<sx; i++)
     424      { XPutPixel(ximg, i, j, cmap->Color(*pix) );  pix++; }
     425}
     426else {
     427  for(j=0; j<sy; j++)
     428    for(i=0; i<sx; i++)  XPutPixel(ximg, i, j, 0 ); 
     429}
    417430
    418431XPutImage(mdsp, xw, DefGC(), ximg, 0, 0, (int)x, (int)y, sx, sy);
  • trunk/SophyaPI/PI/pigraphx.h

    r4077 r4083  
    3838  virtual void       DrawMarker(PIGrCoord x0, PIGrCoord y0);
    3939  virtual void       DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n);
    40   virtual void       DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix,
    41                                 int sx, int sy, PIColorMap* cmap);
     40  virtual void       DrawPixmap(PIGrCoord x, PIGrCoord y,  PIPixColIdx & pix,  PIColorMap* cmap);
    4241
    4342// Modifications attributs graphiques
  • trunk/SophyaPI/PI/piimage.cc

    r4077 r4083  
    111111gvw = NULL;   // widget vue globale
    112112cmvw = NULL;  // widget ColorMapView
     113fgshowcmap = 0;  // 0: Pas de vue ColMap, 1: top, 2:right,  3:bottom, 4:left
     114 cmdid = -1;
    113115// Fenetre transient et Label pour affichage de l'info (texte PixVal)
    114116int tx, ty;
     
    128130cutscw = NULL;
    129131
    130 gpixm = zpixm = pixm = NULL;
    131 xsgpxm = xszpxm = xspxm = 0;
    132 ysgpxm = yszpxm = yspxm = 0;
    133132lut = NULL;
    134133offx = offy = 0;
     
    145144
    146145mdrw = new PIElDrawer(false);
    147  mdrw->SetAxesFlags(kAxesNone);
     146mdrw->SetAxesFlags(kAxesNone);
    148147gvdrw = new PIElDrawer();
    149148AddDrawer(mdrw, true, false, false, false);
     
    174173PIImage::~PIImage()
    175174{
    176 if (pixm) delete pixm;
    177 if (zpixm) delete zpixm;
    178175if (zow)
    179176  {
    180   zow->SetPixmap(NULL,0,0);
     177  zow->SetPixmap(NULL);
    181178  zow->EraseWindow();
    182179  }
    183 if (gpixm) delete gpixm;
    184180if (gvw)
    185181  {
    186   gvw->SetPixmap(NULL,0,0);
     182  gvw->SetPixmap(NULL);
    187183  gvw->EraseWindow();
    188184  gvw->SetMsg(0); gvw->SetMsgParent(NULL);
     
    256252xszpav = yszpav = 1;
    257253img = pim;
    258 if (gpixm) delete gpixm;
    259 gpixm = NULL;
    260 xsgpxm = ysgpxm = 0;
     254gpixm.DeAlloc();
    261255zmgv = 1;
    262256
     
    607601    // Position du centre d'image
    608602    if (opts.substr(0,12) == "imagecenter=") {
    609       int xc = XPave(); 
    610       int yc = YPave();
     603      /* Si on ecrit "imagecenter=34.5,55.5" ca ne marche pas CMV 29/01/2011
     604      int xc = XPave(), yc = YPave();
    611605      sscanf(opts.substr(12).c_str(),"%d,%d",&xc, &yc);
     606      SetPave(xc, yc, false, true);
     607      */
     608      int xc = XPave(), yc = YPave();
     609      double ddxc = xc, ddyc = yc;
     610      sscanf(opts.substr(12).c_str(),"%lf,%lf",&ddxc, &ddyc);
     611      xc = int(ddxc+0.00001); yc = int(ddyc+0.00001);
    612612      SetPave(xc, yc, false, true);
    613613      continue;
     
    633633      double min = Lut()->Min();
    634634      double max = Lut()->Max();
     635      int typlut=kLutType_Lin;      ;
     636      if (opts.substr(4,3) == "lin")  typlut=kLutType_Lin;
     637      else if (opts.substr(4,3) == "log")  typlut=kLutType_Log;
     638      else if (opts.substr(4,3) == "exp")  typlut=kLutType_Exp;
     639      else if (opts.substr(4,4) == "sqrt")  typlut=kLutType_Sqrt;
     640      else if (opts.substr(4,6) == "square")  typlut=kLutType_Square;
     641      else if (opts.substr(4,3) == "rgb")  {
     642        typlut=kLutType_RGB;
     643        min = 0;  max = 255;
     644      }
    635645      size_t q = opts.find(',');
    636646      if (q < opts.length()-1)
    637647        sscanf(opts.substr(q+1).c_str(),"%lg,%lg",&min, &max);
    638       int typlut=kLutType_Lin;      ;
    639       if (opts.substr(4,3) == "lin")  typlut=kLutType_Lin;
    640       else if (opts.substr(4,3) == "log")  typlut=kLutType_Log;
    641       else if (opts.substr(4,4) == "sqrt")  typlut=kLutType_Sqrt;
    642       else if (opts.substr(4,6) == "square")  typlut=kLutType_Square;
     648
    643649      SetLut(AutoLut_No, min, max, typlut, 0, false);
    644650      continue;
     
    668674      continue;
    669675    }
     676    if (opts == "showcmap")  UpdateCMapDrawer(1);
     677    else if (opts == "noshowcmap")  UpdateCMapDrawer(0);
     678    else if (opts.substr(0,9) == "showcmap=") {
     679      if (opts.substr(9,2) == "no")   UpdateCMapDrawer(0);
     680      else if (opts.substr(9,3) == "top")     UpdateCMapDrawer(1);
     681      else if (opts.substr(9,5) == "right")   UpdateCMapDrawer(2);
     682      else if (opts.substr(9,6) == "bottom")  UpdateCMapDrawer(3);
     683      else if (opts.substr(9,4) == "left")    UpdateCMapDrawer(4);
     684      else if (opts.substr(9,5) == "horiz")   UpdateCMapDrawer(1);
     685      else if (opts.substr(9,4) == "vert")    UpdateCMapDrawer(2);
     686      else UpdateCMapDrawer(0);
     687    }
     688
    670689    ndec--;
    671690    udopt.push_back(opts);
    672691  }
    673692  // Set color map if requested
    674   if(fgcmapid || revcmapid) SetColMapId(cmapid,revcmapid,false);
     693  if(fgcmapid || revcmapid)
     694    SetColMapId(cmapid,revcmapid,false); 
     695
    675696  // Configure axes if requested
    676697  if (confaxes) ChangeAxesConfiguration(invx, invy, exchxy, false);
     
    691712      SetLut(t_al, min_al, max_al, Lut()->Type(), ns_al, false);
    692713  }
     714
    693715  return(ndec+ndec2);
    694716}
     
    724746{
    725747if (!cmp)  return;
     748int ncolold = 0;
     749if (cmap) ncolold = cmap->NCol();
     750bool fgapp = false;
     751if (refr && cmp->NCol() != ncolold) {
     752  fgapp = true;  refr = false;
     753}
    726754int cmapid = cmp->Type();
    727755if ( (cmapid == CMAP_GREY32) || (cmapid == CMAP_GREYINV32) ||
    728756     (cmapid == CMAP_GREY128) || (cmapid == CMAP_GREYINV128))  mdrw->GetGraphicAtt().SetColAtt(PI_Red);
    729757else mdrw->GetGraphicAtt().SetColAtt(PI_Turquoise);
     758if (lut) lut->SetNCol(cmp->NCol());
    730759PIPixmap::SetColMap(cmp, refr);
    731760if (refr) { xcurs =  ycurs = -1; }
    732761if (zow)  zow->SetColMap(cmp, refr);
    733 if (gvw)  gvw->SetColMap(cmp, refr);
     762if (gvw)  {
     763    if (cmap->NCol() != ncolold) {
     764    ComputeGloVPixmap();
     765    SetGloVPixmap();
     766  }
     767  else  gvw->SetColMap(cmp, refr);
     768}
    734769if (cmvw) cmvw->SetColMap(cmap, Lut()->Min(), Lut()->Max(), refr);
     770if (fgapp)  Apply();
    735771return;
    736772}
     
    739775void PIImage::SetColMapId(CMapId cmapid, bool revidx, bool refr)
    740776{
     777int ncolold = 0;
     778if (cmap) ncolold = cmap->NCol();
    741779if ( (cmapid == CMAP_GREY32) || (cmapid == CMAP_GREYINV32) ||
    742780     (cmapid == CMAP_GREY128) || (cmapid == CMAP_GREYINV128))  mdrw->GetGraphicAtt().SetColAtt(PI_Red);
    743781else mdrw->GetGraphicAtt().SetColAtt(PI_Turquoise);
    744 PIPixmap::SetColMapId(cmapid, revidx, refr);
     782PIPixmap::SetColMapId(cmapid, revidx, false);
     783if (refr) { xcurs =  ycurs = -1; }
     784bool fgapp = false;
     785if (refr && cmap->NCol() != ncolold) {
     786  fgapp = true;  refr = false;
     787}
     788if (lut) lut->SetNCol(GetColMap()->NCol());
     789if (refr) Refresh();
    745790if (zow)  zow->SetColMapId(cmapid, revidx, refr);
    746 if (gvw)  gvw->SetColMapId(cmapid, revidx, refr);
     791if (gvw)  {
     792    if (cmap->NCol() != ncolold) {
     793    ComputeGloVPixmap();
     794    SetGloVPixmap();
     795  }
     796  else  gvw->SetColMapId(cmapid, revidx, refr);
     797}
    747798if (cmvw) cmvw->SetColMapId(cmapid, revidx, Lut()->Min(), Lut()->Max(), refr);
     799if (fgapp)  Apply();
    748800return;
    749801}
     
    754806{
    755807if (img == NULL)  return;
     808if (fgshowcmap>0)  {
     809  cmpd.SetColMap(GetColMap());
     810  cmpd.SetBornes(*Lut());
     811}
    756812if (mw)  { 
    757813  ComputePixmap();
     
    11111167ywsz = YSize();
    11121168
    1113 pixm = img->ComputePixmap(lut, offx, offy, zoom, xwsz, ywsz, pixm, &xspxm, &yspxm);
     1169img->ComputePixmap(lut, offx, offy, zoom, xwsz, ywsz, pixm);
    11141170int xw1, yw1, xw2, yw2;
    1115 xw1 = (xwsz-xspxm)/2;
     1171xw1 = (xwsz-pixm.XSize())/2;
    11161172if (xw1 < 0) xw1 = 0;
    1117 yw1 = (ywsz-yspxm)/2;
     1173yw1 = (ywsz-pixm.YSize())/2;
    11181174if (yw1 < 0) yw1 = 0;
    1119 xw2 = xspxm+xw1;
    1120 yw2 = yspxm+yw1;
     1175xw2 = pixm.XSize()+xw1;
     1176yw2 = pixm.YSize()+yw1;
    11211177SetDefaultDrawRectangle(xw1, yw1, xw2, yw2, false);
    1122 // printf("--DBG-- ComputePixmap() %d %d $ %d %d :: %d %d , %d %d \n", xwsz, ywsz, xspxm, yspxm, xw1, yw1, xw2, yw2);
     1178// printf("--DBG-- ComputePixmap() %d %d $ %d %d :: %d %d , %d %d \n", xwsz, ywsz, pixm.XSize(), pixm.YSize(), xw1, yw1, xw2, yw2);
    11231179int x1,y1, x2,y2;
    11241180ofx = xw1;  ofy = yw1;
     
    11311187// printf("--DBG2-- ComputePixmap() %g %g  %g %g  \n", fx1, fx2, fy1, fy2);
    11321188xcurs = ycurs = -1;
    1133 SetPixmap(pixm, xspxm, yspxm, true, xw1, yw1);
     1189SetPixmap(&pixm, true, xw1, yw1);
    11341190// Refresh();
    11351191return;
     
    11741230if (lofy < 0)  lofy = 0;
    11751231
    1176 zpixm = img->ComputePixmap(lut, lofx, lofy, zm, xwsz, ywsz, zpixm, &xszpxm, &yszpxm);
     1232img->ComputePixmap(lut, lofx, lofy, zm, xwsz, ywsz, zpixm);
    11771233zow->SetColMap(cmap, false);
    1178 zow->SetPixmap(zpixm, xszpxm, yszpxm);
     1234zow->SetPixmap(&zpixm);
    11791235zow->SetUserData((void *)this, 0);
    11801236// zow->Refresh();
     
    12031259zmgv = zmx;
    12041260if (zmx > 1)  zmx = -zmx;
    1205 gpixm = img->ComputePixmap(lut, 0, 0, zmx, xwsz, ywsz, gpixm, &xsgpxm, &ysgpxm);
    1206 // printf("DEBUG-ComputeGloVPixmap()  %d-%d , (%d,%d) , %d-%d \n", xwsz, ywsz, zmx, zmy, xsgpxm, ysgpxm);
     1261img->ComputePixmap(lut, 0, 0, zmx, xwsz, ywsz, gpixm);
     1262// printf("DEBUG-ComputeGloVPixmap()  %d-%d , (%d,%d) , %d-%d \n", xwsz, ywsz, zmx, zmy, gpixm.XSize(), gpixm.YSize());
    12071263return;
    12081264}
     
    12151271
    12161272int xw1, yw1, xw2, yw2;
    1217 xw1 = (gvw->XSize()-xsgpxm)/2;
     1273xw1 = (gvw->XSize()-gpixm.XSize())/2;
    12181274if (xw1 < 0) xw1 = 0;
    1219 yw1 = (gvw->YSize()-ysgpxm)/2;
     1275yw1 = (gvw->YSize()-gpixm.YSize())/2;
    12201276if (yw1 < 0) yw1 = 0;
    1221 xw2 = xsgpxm+xw1;
    1222 yw2 = ysgpxm+yw1;
     1277xw2 = gpixm.XSize()+xw1;
     1278yw2 = gpixm.YSize()+yw1;
    12231279
    12241280if (zoom > 0) zm = zmgv*zoom;
     
    12421298gvw->AddDrawer(gvdrw, xw1, yw1, xw2, yw2, false);
    12431299gvw->SetColMap(cmap, false);
    1244 gvw->SetPixmap(gpixm, xsgpxm, ysgpxm, true, xw1, yw1);
     1300gvw->SetPixmap(&gpixm, true, xw1, yw1);
    12451301gvw->SetUserData((void *)this, 0);
    12461302gvw->SetMsg(Msg()+626);
     
    13481404//printf("UpdateCuts()-DBG X: %d  -> %g  , Y: %d -> %g \n", cutarrx->Size(), cutarrx->Value(0),
    13491405//       cutarry->Size(), cutarry->Value(0));
     1406}
     1407
     1408/* --Methode-- */
     1409void PIImage::UpdateCMapDrawer(int fgshow)
     1410{
     1411  if ((fgshow<0)||(fgshow>4))  fgshow=0;
     1412  if (fgshow==fgshowcmap) return;
     1413  fgshowcmap=fgshow;
     1414  switch (fgshowcmap ) {
     1415  case 0 :
     1416    RemoveDrawer(cmdid);
     1417    break;
     1418  case 1 :
     1419    cmpd.SetHorizontal();
     1420    cmdid=AddDrawer(&cmpd, 0.10, 0.02, 0.90, 0.10, true, false);
     1421    break;
     1422  case 2 :
     1423    cmpd.SetVertical();
     1424    cmdid=AddDrawer(&cmpd, 0.90, 0.1, 0.98, 0.9, true, false);
     1425    break;
     1426  case 3 :
     1427    cmpd.SetHorizontal();
     1428    cmdid=AddDrawer(&cmpd, 0.10, 0.90, 0.90, 0.98, true, false);
     1429    break;
     1430  case 4 :
     1431    cmpd.SetVertical();
     1432    cmdid=AddDrawer(&cmpd, 0.02, 0.1, 0.10, 0.9, true, false);
     1433    break;   
     1434  }
     1435  if (fgshowcmap>0) cmpd.GetGraphicAtt().SetColAtt(PI_Turquoise);
    13501436}
    13511437
  • trunk/SophyaPI/PI/piimage.h

    r4077 r4083  
    135135  void SetGloVPixmap();
    136136  void UpdateCuts();
     137  void UpdateCMapDrawer(int fgshow);
    137138
    138139  void DrawCursor(PIGraphic* g);
     
    154155  bool winovis;   // $CHECK$ Reza A enlever si possible 17/6/96
    155156// Tableau des pixels principal 
    156   unsigned char * pixm;
    157   int xspxm, yspxm;
     157  PIPixColIdx pixm;
    158158  LUT * lut;
    159159  AutoLutType t_al;   // Si AutoLut et le type lors du dernier appel a SetLut()
     
    164164  int zoom;
    165165  PIPixmap * zow;
    166   unsigned char * zpixm;
    167   int xszpxm, yszpxm;
    168 // Fenetre pour l'image entiere 
     166  PIPixColIdx zpixm;
     167// Fenetre pour vue globale de l'image   
    169168  int zmgv;
    170169  PIPixmap * gvw;
    171   unsigned char * gpixm;
    172   int xsgpxm, ysgpxm;
     170  PIPixColIdx gpixm;
    173171  PIElDrawer* gvdrw;
    174172// Fenetre d'affichage du ColMap
    175173  PICMapView* cmvw;
     174  int fgshowcmap;  // 0: Pas de vue ColMap, 1: top, 2:right, 3:bottom, 4:left
     175  PICMapDrawer cmpd;
     176  int cmdid;
    176177// Fenetre/champ de texte
    177178  PILabel * trtlb;
  • trunk/SophyaPI/PI/piimgtools.cc

    r4077 r4083  
    9999mOpt[0] = new PIOptMenu(this, "imglut-opt-1", 1.5*bsx, bsy, cpx, cpy);
    100100mOpt[0]->AppendItem("Linear", 1100);
    101 mOpt[0]->AppendItem("Log.", 1101);
    102 mOpt[0]->AppendItem("Sqrt", 1102);
    103 mOpt[0]->AppendItem("Square", 1103);
     101mOpt[0]->AppendItem("Log", 1101);
     102mOpt[0]->AppendItem("Exp", 1102);
     103mOpt[0]->AppendItem("Sqrt", 1103);
     104mOpt[0]->AppendItem("Square", 1104);
     105mOpt[0]->AppendItem("RGB", 1105);
    104106mOpt[0]->SetValue(1100);
    105107mOpt[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
     
    174176mCasc[1] = new PIMenu(mOptzc[0]->Menu(), "PIUniCol32");
    175177mCasc[2] = new PIMenu(mOptzc[0]->Menu(), "MIDAS-CMap");
    176 
    177 int nsct1,nsct2,nsct3,nsct4;
     178mCasc[3] = new PIMenu(mOptzc[0]->Menu(), "RGB-CMap");
     179
     180int nsct1,nsct2,nsct3,nsct4,nsct5;
    178181//  D'abord les tables standard de PI  32 couleurs
    179182nsct1 = 5;   // Les 5 premieres tables
     
    190193mOptzc[0]->AppendPDMenu(mCasc[1]);
    191194//  Apres les tables importees de MIDAS
    192 nsct4 = PIColorMap::NumberStandardColorMaps()-2; // Les reste jusqu'a l'avant derniere
     195nsct4 = PIColorMap::NumberStandardColorMaps()-6; // Les reste jusqu'a l'avant derniere
    193196for(kcc=nsct3; kcc<nsct4; kcc++)
    194197  mCasc[2]->AppendItem(PIColorMap::GetStandardColorMapName(kcc).c_str(), 201+kcc);
    195198mOptzc[0]->AppendPDMenu(mCasc[2]);
    196 // Les tables qui restent ( Col16 , ... )
    197 for(kcc=nsct4; kcc<PIColorMap::NumberStandardColorMaps(); kcc++)
    198 mOptzc[0]->AppendItem(PIColorMap::GetStandardColorMapName(kcc).c_str(), 201+kcc);
    199 // On ajoute un CheckItem pour inverser les index de table de couleur
     199nsct5 = PIColorMap::NumberStandardColorMaps()-4; // Les reste jusqu'aux tables RGB
     200for(kcc=nsct4; kcc<nsct5; kcc++)
     201  mOptzc[0]->AppendItem(PIColorMap::GetStandardColorMapName(kcc).c_str(), 201+kcc);
     202// Les tables de couleur RGB  ( RGB216, RGB512 , ... )
     203for(kcc=nsct5; kcc<PIColorMap::NumberStandardColorMaps(); kcc++)
     204  mCasc[3]->AppendItem(PIColorMap::GetStandardColorMapName(kcc).c_str(), 201+kcc);
     205mOptzc[0]->AppendPDMenu(mCasc[3]);
     206  // On ajoute un CheckItem pour inverser les index de table de couleur
    200207mOptzc[0]->Menu()->AppendSeparator();
    201208mOptzc[0]->Menu()->AppendCheckItem("Reverse CMap", 299);
     
    310317for(i=0; i<3; i++)  delete mBut[i];
    311318delete mButR;
    312 for(i=0; i<2; i++)  delete mCasc[i];
     319for(i=0; i<4; i++)  delete mCasc[i];
    313320for(i=0; i<5; i++)  delete mButsz[i];
    314321for(i=0; i<3; i++)  delete mButcax[i];
     
    371378  if     ( (mpii->Lut())->Type() == kLutType_Lin )    mOpt[0]->SetValue(1100);
    372379  else if( (mpii->Lut())->Type() == kLutType_Log )    mOpt[0]->SetValue(1101);
    373   else if( (mpii->Lut())->Type() == kLutType_Sqrt )   mOpt[0]->SetValue(1102);
    374   else if( (mpii->Lut())->Type() == kLutType_Square ) mOpt[0]->SetValue(1103);
     380  else if( (mpii->Lut())->Type() == kLutType_Exp )    mOpt[0]->SetValue(1102);
     381  else if( (mpii->Lut())->Type() == kLutType_Sqrt )   mOpt[0]->SetValue(1103);
     382  else if( (mpii->Lut())->Type() == kLutType_Square ) mOpt[0]->SetValue(1104);
     383  else if( (mpii->Lut())->Type() == kLutType_RGB )    mOpt[0]->SetValue(1105);
    375384  else                                                mOpt[0]->SetValue(1100);
    376385}
     
    388397double min, max, del;
    389398int lauto, typ;
    390 int typlut[4] = {kLutType_Lin, kLutType_Log, kLutType_Sqrt, kLutType_Square} ;
     399int typlut[6] = {kLutType_Lin, kLutType_Log,  kLutType_Exp, kLutType_Sqrt, kLutType_Square, kLutType_RGB } ;
    391400AutoLutType alts[13] = { AutoLut_No,
    392401                         AutoLut_MeanSigma, AutoLut_MeanSigma, AutoLut_MeanSigma,
     
    446455    if ((lauto < 0) || (lauto > 12))  lauto = 12;
    447456    typ = mOpt[0]->GetValue() - 1100;
    448     if ( (typ < 0) || (typ > 3) )  typ = 0;
     457    if ( (typ < 0) || (typ > 5) )  typ = 0;
    449458    (PIImage::CurrentPIImage())->SetLut(alts[lauto], min, max, typlut[typ], nsas[lauto]);
    450459    if (msg == 2500) {
  • trunk/SophyaPI/PI/pilistx.cc

    r4077 r4083  
    116116mNItem++;
    117117
    118 #if defined(__DECCXX) || defined(__KCC__) || defined(__aCC__)
    119 XmString xms = XmStringCreate(const_cast<char *>(item), XmSTRING_DEFAULT_CHARSET);
    120 #else
    121 XmString xms = XmStringCreate((char *)(item), XmSTRING_DEFAULT_CHARSET);
    122 #endif
     118XmString xms = XmStringCreate(const_cast<char*>(item), const_cast<char*>(XmSTRING_DEFAULT_CHARSET));
    123119XmListAddItem(mlist, xms, 0);
    124120XmStringFree(xms);
  • trunk/SophyaPI/PI/pimenux.cc

    r4077 r4083  
    386386  n=0;
    387387  sprintf(acc,"Ctrl/%c", sc[0]);
    388   xmstr = XmStringLtoRCreate(acc, XmSTRING_DEFAULT_CHARSET);
     388  xmstr = XmStringLtoRCreate(acc, const_cast<char*>(XmSTRING_DEFAULT_CHARSET));
    389389  XtSetArg(warg[n], XmNacceleratorText, xmstr); n++;
    390390  sprintf(acc,"Ctrl<Key>%c", sc[0]);
  • trunk/SophyaPI/PI/pipixmapgen.cc

    r4077 r4083  
    88#include "sopnamsp.h"
    99#include "pipixmapgen.h"
     10
    1011
    1112// --------- Methodes de la classe PIPixMap  ----------
     
    4344// long  kind()
    4445//      Retourne le type ("=PIPixmap::ClassId")
    45 // void  SetPixmap(unsigned char *pix, int sx, int sy, bool refr=true, int ox=0, int oy=0)
    46 //      Associe un tableau d'index "pix" de taille "sx * sy".
    47 //      (ox,oy)" définissent  l'offset d'affichage.
     46// void  SetPixmap(PIPixColIdx *pixidx, int sx, int sy, bool refr=true, int ox=0, int oy=0)
     47//      Associe un tableau d'index de couleur "pixidx". (ox,oy)" définissent  l'offset d'affichage.
    4848//      Si "refr=true", la méthode "Refresh()" est appelée.
    4949//--
     
    8787{
    8888pixmap = NULL;
    89 nx = ny = 0;
     89fgownpmap = false;
    9090ofx = ofy = 0;
    9191mPpos[0] = mPpos[0] = 0;
     
    9999{
    100100delete cmap;
     101if (fgownpmap && pixmap) delete pixmap;
    101102}
    102103
    103104/* --Methode-- */
    104 void PIPixmapGen::SetPixmap(unsigned char *pix, int sx, int sy, bool refr, int ox, int oy)
     105void PIPixmapGen::SetPixmap(PIPixColIdx *pixidx, bool refr, int ox, int oy)
    105106{
    106 pixmap = pix;
    107 if (pixmap)
    108   {
    109   if (sx < 0)  sx = 0;
    110   if (sy < 0)  sy = 0;
    111   if (ox < 0)  ox = 0;
    112   if (oy < 0)  oy = 0;
    113   nx = sx; ny = sy;
    114   ofx = ox;  ofy = oy;
     107if (fgownpmap && pixmap) delete pixmap;
     108fgownpmap = false;
     109pixmap = pixidx;
     110if (ox < 0)  ox = 0;
     111if (oy < 0)  oy = 0;
     112ofx = ox;  ofy = oy;
     113if (refr) Refresh();   
     114}
     115
     116/* --Methode-- */
     117void PIPixmapGen::SetRGBArray(PIPixRGBArray *rgba, CMapId cmapid, bool refr, int ox, int oy)
     118{
     119if (rgba == NULL) return;
     120int quantum = 8;
     121if (cmapid == CMAP_RGB216)  quantum = 6;
     122else if (cmapid == CMAP_RGB4096) quantum = 16;
     123else cmapid = CMAP_RGB512;
     124SetColMapId(cmapid, false);
     125PIPixColIdx * pixc = new PIPixColIdx;
     126pixc->AllocateByte(rgba->XSize(), rgba->YSize());
     127for(int j=0; j<rgba->YSize(); j++)
     128  for(int i=0; i<rgba->XSize(); i++) {
     129        PIPixRGB vv = (*rgba)(i,j);
     130        int r = (int)vv.red*quantum/256;
     131        int g = (int)vv.green*quantum/256;
     132        int b = (int)vv.blue*quantum/256;
     133    pixc->GetShort(i,j) = (unsigned short)((b*quantum+g)*quantum+r);
    115134  }
    116 else { ofx = ofy = nx = ny = 0; }
    117 if (refr) Refresh();   
     135SetPixmap(pixc, refr, ox, oy);
     136fgownpmap = true;
     137return; 
    118138}
    119139
  • trunk/SophyaPI/PI/pipixmapgen.h

    r4077 r4083  
    99#include PICMAP_H
    1010
     11#include "pipixutils.h"
     12
    1113#include <list>
     14
    1215
    1316class PIPixmapGen : public PIBaseWdg
     
    2225  virtual long  kind() {return ClassId; }
    2326
    24   virtual void  SetPixmap(unsigned char *pix, int sx, int sy,
    25                           bool refr=true, int ox=0, int oy=0);
     27  virtual void  SetPixmap(PIPixColIdx *pixidx, bool refr=true, int ox=0, int oy=0);
     28  virtual void  SetRGBArray(PIPixRGBArray *rgba, CMapId cmapid=CMAP_RGB512,
     29                            bool refr=true, int ox=0, int oy=0);
    2630
    2731  virtual void  SetColMap(PIColorMap* cmp, bool refr=true);
     
    3943
    4044protected:
    41   unsigned char *pixmap;
    42   int nx, ny;
    43   int ofx, ofy;
     45  PIPixColIdx *pixmap;   // Pointeur d'objet PIPixCoIdx, tableau d'index de couleurs, peut etre NULL
     46  bool fgownpmap;  // si true -> possede le pixmap et doit le deleter si besoin
     47  int ofx, ofy;       // Offset d'affichage
    4448  PIColorMap* cmap;
    4549
  • trunk/SophyaPI/PI/pipixmapx.cc

    r4077 r4083  
    77#include "sopnamsp.h"
    88#include "pipixmapx.h"
     9#include <iostream>
     10
     11using namespace std;
    912
    1013static  GC    mygc;
     
    3134{
    3235int i,j;
    33 unsigned char *pp;
    34 
    35 if (pixmap)
    36   {
    37   for(j=0; j<ny; j++)
    38     {
    39     pp = pixmap+j*nx;
    40     for(i=0; i<nx; i++)
    41       { XPutPixel(myximg, i, j, cmap->Color(*pp) );  pp++; }
     36int nx = 0;
     37int ny = 0;
     38if (pixmap!=NULL) {
     39  nx = pixmap->XSize();
     40  if (nx > XSize())  nx = XSize();
     41  ny = pixmap->YSize();
     42  if (ny > YSize())  ny = YSize();
     43  if (pixmap->BytePointer()!=NULL) {
     44    unsigned char *pp = pixmap->BytePointer();
     45    for(j=0; j<ny; j++) {
     46      pp = pixmap->BytePointer()+j*pixmap->XSize();
     47      for(i=0; i<nx; i++)
     48        { XPutPixel(myximg, i, j, cmap->Color(*pp) );  pp++; }
     49      }
     50  }
     51  else if (pixmap->ShortPointer()!=NULL) {
     52    unsigned short *pp = pixmap->ShortPointer();
     53    for(j=0; j<ny; j++) {
     54      pp = pixmap->ShortPointer()+j*pixmap->XSize();
     55      for(i=0; i<nx; i++) 
     56        { XPutPixel(myximg, i, j, cmap->Color(*pp) );  pp++; }
    4257    }
    4358  }
    44 
     59}
     60/* ----- On peut laisser le reste - ce n'est pas utilise dans le Draw
     61// On remplit le restant
     62for(j=0; j<YSize(); j++)
     63  for(i=nx; i<XSize(); i++)
     64       XPutPixel(myximg, i, j, 0 );
    4565for(j=ny; j<YSize(); j++)
    46   for(i=nx; i<XSize(); i++)
     66  for(i=0; i<XSize(); i++)
    4767     XPutPixel(myximg, i, j, 0 );
    48 
     68------- */
    4969PIBaseWdgX::Refresh();
    5070}
     
    6686if (!g) return;
    6787if (g->kind() == PI_PSFileGraphics ) {
    68     g->DrawPixmap(ofx, ofy, pixmap, nx, ny, cmap);
     88    g->DrawPixmap(ofx, ofy, pixmap, cmap);
    6989    //  Il faut faire quelque chose Sinon ??!
    7090  }
     
    7898
    7999if (!g) return;
    80 if ((myximg == NULL) || (cmap == NULL)) return;
    81100
    82101if (g->kind() == PI_PSFileGraphics ) {
    83   if (pixmap) g->DrawPixmap(ofx, ofy, pixmap, nx, ny, cmap);
     102  g->DrawPixmap(ofx, ofy, (*pixmap), cmap);
    84103  return;
    85104  }
     105 
    86106
    87107Window xw = XtWindow(XtWdg());
    88108Display * mdsp = PIXDisplay();
    89109
     110if ((myximg == NULL) || (cmap == NULL) || (pixmap == NULL) ||
     111    (pixmap->XSize()<=0) || (pixmap->YSize()<=0) ) {
     112  XClearArea(mdsp, xw, x0, y0, dx, dy, False);  return;
     113}
     114
    90115int mx, my, ox, oy;
    91116
    92117if (x0 < 0)  x0 = 0;
    93118if (y0 < 0)  y0 = 0;
    94 mx = nx+ofx;   my = ny+ofy;
     119
     120mx = pixmap->XSize()+ofx;   my = pixmap->YSize()+ofy;
     121
    95122if (dx > (XSize()-x0)) dx = XSize()-x0;
    96123if (dy > (YSize()-y0)) dy = YSize()-y0;
     
    101128
    102129ox = oy = 0; 
    103 
    104130if (ofx > x0)
    105131  { XClearArea(mdsp, xw, x0, y0, ofx-x0, dy, False);   
     
    115141if (my < (y0+dy))
    116142  { XClearArea(mdsp, xw, x0, my, dx, y0+dy-my, False);  dy = my-y0; }
     143
     144/*
     145if (ofx > x0)
     146  XClearArea(mdsp, xw, x0, y0, ofx-x0, dy, False);   
     147if (ofy > y0)
     148  XClearArea(mdsp, xw, x0, y0, dx, ofy-y0, False); 
    117149 
     150if (mx < (x0+dx))
     151  XClearArea(mdsp, xw, mx, y0, x0+dx-mx, dy, False);
     152if (my < (y0+dy))
     153  XClearArea(mdsp, xw, x0, my, dx, y0+dy-my, False); 
     154
     155if (ofx > x0)
     156  { dx -= (ofx-x0);  x0 = ofx;  ox = 0; }
     157else  ox = x0-ofx;
     158if (ofy > y0)
     159  { dy -= (ofy-y0);  y0 = ofy;  oy = 0; }
     160else  oy = y0-ofy;
     161if (mx < (x0+dx))  dx = mx-x0;
     162if (my < (y0+dy))  dy = my-y0;
     163*/
     164 
    118165XPutImage(mdsp, xw, mygc, myximg, ox, oy, x0, y0, dx, dy);
    119166XFlush(mdsp);
  • trunk/SophyaPI/PI/piscdrawwdg.cc

    r4077 r4083  
    248248  bool fglogy = isLogScaleY();
    249249
     250  // Flag declenchant SetLimits
     251  bool fgsaxel = false;
     252  // Limites et sens d'axe
     253  double xmin = XMin();
     254  double ymin = YMin();
     255  double xmax = XMax();
     256  double ymax = YMax();
     257  int axrl = kAxeDirLtoR;
     258  int ayud = kAxeDirDownUp;
     259  int xac, yac;
     260  GetAxesConfig(xac, yac);
     261  if (xac & kAxeDirRtoL) axrl = kAxeDirRtoL;
     262  if (yac & kAxeDirUpDown) ayud = kAxeDirUpDown;
     263
    250264  for( k=0; k<opt.size(); k++ ) {
    251265    string opts = opt[k];
     
    259273    // Limites en x,y
    260274    if (opts.substr(0,9) == "xylimits=") {
    261       double xmin = XMin();
    262       double ymin = YMin();
    263       double xmax = XMax();
    264       double ymax = YMax();
    265275      sscanf(opts.substr(9).c_str(),"%lg,%lg,%lg,%lg",&xmin, &xmax,&ymin,&ymax);
    266       SetLimits(xmin, xmax, ymin, ymax);
     276      fgsaxel = true;
    267277      continue;
    268278    }
     
    292302      continue;
    293303    }
    294 
    295 // Les attributs d'axes (stdaxes boxaxesgrid ...) sont decodes par PIElDrawer
     304    if ((opts == "revax") || (opts == "axerl") ) {
     305      fgsaxel = true;  axrl = kAxeDirRtoL;
     306      continue;
     307    }
     308    if ((opts == "revay") || (opts == "axeud") ) {
     309      fgsaxel = true;  ayud = kAxeDirUpDown;
     310      continue;
     311    }
     312    if (opts == "axelr") {
     313      fgsaxel = true;  axrl = kAxeDirLtoR;
     314      continue;
     315    }
     316    if (opts == "axedu") {
     317      fgsaxel = true;  ayud = kAxeDirDownUp;
     318      continue;
     319    }
     320
     321// Les autres attributs d'axes (stdaxes boxaxesgrid ...) sont decodes par PIElDrawer
    296322
    297323    ndec--;
     
    299325  } 
    300326
     327  if (fgsaxel)  SetLimits(xmin, xmax, ymin, ymax, axrl, ayud);
    301328  if (fglinlog) SetLogScale(fglogx, fglogy);
    302329
  • trunk/SophyaPI/PI/pistdwdgx.cc

    r4077 r4083  
    5151{
    5252XmString xmstr;
    53 xmstr = XmStringLtoRCreate((char *)lab.c_str(), XmSTRING_DEFAULT_CHARSET);
     53xmstr = XmStringLtoRCreate(const_cast<char*>(lab.c_str()), const_cast<char*>(XmSTRING_DEFAULT_CHARSET));
    5454int n=0;
    5555Arg warg[2];
     
    149149{
    150150XmString xmstr;
    151 xmstr = XmStringLtoRCreate((char *)lab.c_str(), XmSTRING_DEFAULT_CHARSET);
     151xmstr = XmStringLtoRCreate(const_cast<char*>(lab.c_str()), const_cast<char*>(XmSTRING_DEFAULT_CHARSET));
    152152int n=0;
    153153Arg warg[2];
  • trunk/SophyaPI/PI/pitherm.cc

    r4077 r4083  
    2424//--
    2525//++
    26 //  PIThermometer(PIContainerGen *par, char *nom, int sx=256, int sy=10, int px=0, int py=0)
     26//  PIThermometer(PIContainerGen *par, const char *nom, int sx=256, int sy=10, int px=0, int py=0)
    2727//      Constructeur - Le choix d'affichage (vertical ou horizontal) dépend
    2828//      du rapport des tailles "sx", "sy"
     
    3131
    3232/* --Methode-- */
    33 PIThermometer::PIThermometer(PIContainerGen *par, char *nom,
     33PIThermometer::PIThermometer(PIContainerGen *par, const char *nom,
    3434                       int sx, int sy, int px, int py)
    3535: PIBaseWdg(par, nom, sx, sy, px, py)
     
    139139void PIThermometer::Draw(PIGraphicGen* g, int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/)
    140140{
     141  if (!IsVisible())  return;
    141142  double delta = (max_-min_);
    142143  if (delta < 1.e-39) delta = 1.e-39;
  • trunk/SophyaPI/PI/pitherm.h

    r4077 r4083  
    1616  enum {ClassId = 5220};
    1717
    18                   PIThermometer(PIContainerGen *par, char *nom,
     18                  PIThermometer(PIContainerGen *par, const char *nom,
    1919                                int sx=256, int sy=10, int px=0, int py=0);
    2020  virtual         ~PIThermometer();
  • trunk/SophyaPI/PI/piversion.h

    r4077 r4083  
    22#define PIVERSION_H_SEEN
    33
    4 #define PI_VERSIONNUMBER  4.11
     4#define PI_VERSIONNUMBER  4.20
    55
    66#endif
  • trunk/SophyaPI/PI/piwdggen.cc

    r4077 r4083  
    5757//--
    5858//++
    59 // void  PSPrint(PSFile *psf, int ofx=0, int ofy=0)
    60 //      Méthode virtuelle qui doit être redéfinie pour chacune des classes filles.
    61 //      produit une représentation graphique de l'objet en Postscript.
    6259// SetSize(int sx, int sy)
    6360//      Modifie la taille de l'objet.
     
    181178// int  UserFlag()
    182179//      Renvoie la valeur "int" user de l'objet.
     180//--
     181
     182//++
     183// Titre        Export postscript et format RGB
     184//--
     185//++
     186// void  PSPrint(PSFile *psf, int ofx=0, int ofy=0)
     187//      Méthode virtuelle qui doit être redéfinie pour chacune des classes filles.
     188//      produit une représentation graphique de l'objet en Postscript.
     189// void  ExportToRGB(PIPixRGBArray & rgba)
     190//      Méthode virtuelle qui doit être redéfinie pour chaque architecture.
     191//      Remplit un tableau PIPixRGBArray le contenu pixels du widget en couleurs RGB.
    183192//--
    184193
     
    309318}
    310319
     320/* --Methode-- */
     321void PIWdgGen::ExportToRGB(PIPixRGBArray & rgba)
     322{
     323return;
     324}
     325
    311326//++
    312327// Titre        Gestion des Draw/Event Handler
  • trunk/SophyaPI/PI/piwdggen.h

    r4077 r4083  
    1010#include "pimsghandler.h"
    1111#include "picolist.h"
     12#include "pipixutils.h"
    1213
    1314#include <string>
     
    107108  virtual bool           IfSensitive()=0;
    108109
     110//  Pour exporter le contenu d'un widget (dessin vectoriel) en postscript
    109111  virtual void           PSPrint(PSFile *psf, int ofx=0, int ofy=0,
    110112                                 double scale_x=1., double scale_y=1.);
     113// Pour exporter le tableau des pixels du widget en classe  PIPixRGBArray
     114// L'implementation par defaut ne fait rien
     115  virtual void           ExportToRGB(PIPixRGBArray & rgba);
    111116
    112117//  Gestion de copier-coller
  • trunk/SophyaPI/PI/piwdgx.cc

    r4077 r4083  
    2020#include "pigraphx.h"
    2121
    22 #ifdef SANS_EVOLPLANCK
    23 #include "perrors.h"
    24 #else
    2522#include "pexceptions.h"
    26 #endif
    2723
    2824
     
    5046szx = appSzX;  szy = appSzY;
    5147szf = appSzFont;
     48 printf("XtAppContext* PIXtAppCtx :szx=%d szy=%d szf=%d",szx,szy,szf);
    5249return(&appctx);
    5350}
     
    627624// Ressources X si non definis
    628625static const String fallback_res[26] = {
    629 "PeidaInt*default*background:                 LightGrey" ,
    630 "PeidaInt*background:                         LightGrey" ,
    631 "PeidaInt*Foreground:                         Black",
    632 "PeidaInt*default*Foreground:                 Black",
    633 "PeidaInt*default*bottomShadowColor:          Black",
    634 "PeidaInt*bottomShadowColor:                  Black",
    635 "PeidaInt*default*topShadowColor:             White",
    636 "PeidaInt*topShadowColor:                     White",
    637 "PeidaInt*borderColor:                        Black",
    638 "PeidaInt*XmLabel.borderWidth:                0",
    639 "PeidaInt*XmDrawingArea*background:           Black",
    640 "PeidaInt*XmPushButton*borderWidth:           0",
    641 "PeidaInt*XmText*shadowThickness:             2",
    642 "PeidaInt*XmText*highlightThickness:          0",
    643 "PeidaInt*XmText*marginHeigt:                 0",
    644 "PeidaInt*XmText*marginWidth:                 2",
    645 // "PeidaInt*DefMenubar*XtNwidth:                250",
    646 // "PeidaInt*DefMenubar*XtNheight:               30",
    647 "PeidaInt*fontList:           -*-courier-bold-r-normal-*-12-*-*-*-*-*-ISO8859-1",
    648 "PeidaInt*default*fontList:   -*-courier-bold-r-normal-*-12-*-*-*-*-*-ISO8859-1",
    649 "PeidaInt*fontFamilyName:                     *-courier",    // Pas de blanc apres le nom de font
    650 "PeidaInt*courierfontFamilyName:              *-courier",    //           "        "
    651 "PeidaInt*helveticafontFamilyName:            *-helvetica",  //           "        "
    652 "PeidaInt*timesfontFamilyName:                *-times",      //           "        "
    653 "PeidaInt*symbolfontFamilyName:               *-symbol",     //           "        "
    654 "PeidaInt*XmToggleButton*selectColor:         Red",
     626const_cast<char*>("PeidaInt*default*background:                 LightGrey") ,
     627const_cast<char*>("PeidaInt*background:                         LightGrey") ,
     628const_cast<char*>("PeidaInt*Foreground:                         Black"),
     629const_cast<char*>("PeidaInt*default*Foreground:                 Black"),
     630const_cast<char*>("PeidaInt*default*bottomShadowColor:          Black"),
     631const_cast<char*>("PeidaInt*bottomShadowColor:                  Black"),
     632const_cast<char*>("PeidaInt*default*topShadowColor:             White"),
     633const_cast<char*>("PeidaInt*topShadowColor:                     White"),
     634const_cast<char*>("PeidaInt*borderColor:                        Black"),
     635const_cast<char*>("PeidaInt*XmLabel.borderWidth:                0"),
     636const_cast<char*>("PeidaInt*XmDrawingArea*background:           Black"),
     637const_cast<char*>("PeidaInt*XmPushButton*borderWidth:           0"),
     638const_cast<char*>("PeidaInt*XmText*shadowThickness:             2"),
     639const_cast<char*>("PeidaInt*XmText*highlightThickness:          0"),
     640const_cast<char*>("PeidaInt*XmText*marginHeigt:                 0"),
     641const_cast<char*>("PeidaInt*XmText*marginWidth:                 2"),
     642// const_cast<char*>("PeidaInt*DefMenubar*XtNwidth:                250"),
     643// const_cast<char*>("PeidaInt*DefMenubar*XtNheight:               30"),
     644const_cast<char*>("PeidaInt*fontList:           -*-courier-bold-r-normal-*-12-*-*-*-*-*-ISO8859-1"),
     645const_cast<char*>("PeidaInt*default*fontList:   -*-courier-bold-r-normal-*-12-*-*-*-*-*-ISO8859-1"),
     646const_cast<char*>("PeidaInt*fontFamilyName:                     *-courier"),    // Pas de blanc apres le nom de font
     647const_cast<char*>("PeidaInt*courierfontFamilyName:              *-courier"),    //           "        "
     648const_cast<char*>("PeidaInt*helveticafontFamilyName:            *-helvetica"),  //           "        "
     649const_cast<char*>("PeidaInt*timesfontFamilyName:                *-times"),      //           "        "
     650const_cast<char*>("PeidaInt*symbolfontFamilyName:               *-symbol"),     //           "        "
     651const_cast<char*>("PeidaInt*XmToggleButton*selectColor:         Red"),
    655652NULL
    656653};
     
    681678if (top == NULL) {
    682679  fprintf(stderr, "PIWdgX::InitXt()/ Error XtVaAppInitialize()\n");
    683 #ifdef SANS_EVOLPLANCK
    684   throw notFoundErr;
    685 #else
    686   throw NotFoundExc("PIWdgX::InitXt()/ Error XtVaAppInitialize()");
    687 #endif
     680  throw PError("PIWdgX::InitXt()/ Error XtVaAppInitialize()");
    688681  }
    689682dpy = XtDisplay(top);
    690683if (dpy == NULL)  {
    691684  fprintf(stderr, "PIWdgX::InitXt()/ Error XtVaAppInitialize()/DisplayConnection\n");
    692 #ifdef SANS_EVOLPLANCK
    693   throw notFoundErr;
    694 #else
    695   throw NotFoundExc("PIWdgX::InitXt()/ Error XtVaAppInitialize()/DisplayConnection");
    696 #endif
     685  throw PError("PIWdgX::InitXt()/ Error XtVaAppInitialize()/DisplayConnection");
    697686  }
    698687
     
    734723  }
    735724stdfnt = XLoadQueryFont(dpy, buff);
    736 char * myfntname = "???";
     725const char * myfntname = "???";
    737726// Recherche du champ taille en pixel de la fonte : apres le 7eme tiret
    738727int mySzFont = 12;
     
    831820}
    832821
     822
     823// Pour exporter le tableau des pixels du widget en classe  PIPixRGBArray
     824inline void _col2_fcol_(unsigned long & col, unsigned long & fcol)
     825{
     826  if (col > 0x00FFFFFF)  fcol = 0x01000000;
     827  else if  (col > 0x0000FFFF)  fcol = 0x000010000;
     828  else if (col > 0x000000FF) fcol = 0x00000100;
     829  else fcol = 1; 
     830}   
     831/* --Methode-- */
     832void PIWdgX::ExportToRGB(PIPixRGBArray & rgba)
     833{
     834Display* mdsp = PIXDisplay();
     835int scr = XDefaultScreen(mdsp);
     836int depth = DefaultDepth(mdsp,scr);
     837Window xw = XtWindow(XtWdg());
     838unsigned long plane_mask = ~0;  // tous les bits a 1
     839XImage * ximg = XGetImage(mdsp, xw, 0, 0, XSize(), YSize(), plane_mask, ZPixmap);
     840//DBG  cout << " Resultat XGetImage -> " << hex << ximg << dec << endl;
     841if (ximg == NULL)  return;     
     842                           
     843unsigned long red,green,blue;
     844unsigned long fred,fgreen,fblue;
     845XColor col;
     846Colormap  cmap = XDefaultColormap (mdsp, scr);
     847red = 0x000000FF;
     848green = 0x0000FF00;
     849blue = 0x00FF0000;
     850unsigned short maxrgb = ~0;
     851col.red = maxrgb;  col.green = col.blue = 0;
     852if (XAllocColor(mdsp, cmap, &col)) red = col.pixel;
     853col.green = maxrgb;  col.red = col.blue = 0;
     854if (XAllocColor(mdsp, cmap, &col)) green = col.pixel;     
     855col.blue = maxrgb;  col.red = col.green = 0;
     856if (XAllocColor(mdsp, cmap, &col)) blue = col.pixel;     
     857_col2_fcol_(red, fred);
     858_col2_fcol_(green, fgreen);
     859_col2_fcol_(blue, fblue);
     860rgba.SetSize(XSize(), YSize());
     861unsigned long pixel;
     862PIPixRGB rgb;
     863for(int j=0; j<YSize(); j++)
     864  for(int i=0; i<XSize(); i++) {
     865    pixel = XGetPixel(ximg, i, j);
     866    rgb.red = (pixel&red)/fred;
     867    rgb.green = (pixel&green)/fgreen;
     868    rgb.blue = (pixel&blue)/fblue;
     869    rgba(i,j) = rgb;
     870  }
     871  XDestroyImage(ximg);
     872  return; 
     873}
    833874
    834875
  • trunk/SophyaPI/PI/piwdgx.h

    r4077 r4083  
    6363  virtual void           SetUnSensitive();
    6464  virtual bool           IfSensitive();
     65
     66// Pour exporter le tableau des pixels du widget en classe  PIPixRGBArray
     67  virtual void           ExportToRGB(PIPixRGBArray & rgba);
    6568
    6669//  Gestion de copier-coller
  • trunk/SophyaPI/PI/piwindowgen.h

    r4077 r4083  
    2222  virtual long      kind() {return ClassId; }
    2323
    24    virtual void      PSPrint(PSFile *psf, int ofx=0, int ofy=0,
    25                             double scale_x=1., double scale_y=1.);
     24  virtual void      PSPrint(PSFile *psf, int ofx=0, int ofy=0,
     25                            double scale_x=1., double scale_y=1.);
    2626
    2727  inline  void      AutoHideOnClose(bool ahc=true) { mAHC = ahc; }
  • trunk/SophyaPI/PI/piwindowx.cc

    r4077 r4083  
    152152//if (mWtyp == PIWK_transient) 
    153153  XRaiseWindow(mdsp, XtWindow(pwm->XtWdg()));
     154  // cmv+rz Fevrier 2009 (retour Moriond) - Suppression de XFlush() / usleep 
     155  // Probleme regle par gestion VisibilityChange event ds pixtbase.cc
    154156  // cmv+rz 09/08/2007 Ajout XFlush() + usleep
    155157  // pour regler le probleme de  perte d'evenement expose a la creation
    156   XFlush(mdsp);   usleep(5000);
     158  //  XFlush(mdsp);   usleep(5000);
    157159return;
    158160}
  • trunk/SophyaPI/PI/pixtbase.cc

    r4077 r4083  
    4646
    4747static XtResource resources[] ={
    48   {PIXNobject ,(char *)"Object", XtRPointer, sizeof(XtRPointer),
     48  {const_cast<char*>(PIXNobject) ,const_cast<char*>("Object"), XtRPointer, sizeof(XtRPointer),
    4949   XtOffset(PIXtBaseWidget,  pixtbase.objet), XtRImmediate, (XtPointer)0},
    5050};
     
    143143}
    144144
     145// Pour traiter les etats de changements de visibilite de la fenetre
     146/* Nouvelle-Fonction */
     147void visibchange_handler_pixtbase (Widget wdgp, XtPointer /*closure*/,
     148                             XEvent* evt, Boolean* cont)
     149{
     150#ifdef DEBUG_PIXTB
     151printf("Debug_visibchange_handler_pixtbase: Wdg= %lx Object= %lx  fgvis_expose= %d (EvtType=%d VisSt=%d)\n",
     152  (long)wdgp, (long)(((PIXtBaseWidget)wdgp)->pixtbase.objet),
     153  ((PIXtBaseWidget)wdgp)->pixtbase.vis_expose_fg, (int)evt->type,(int)evt->xvisibility.state);
     154#endif
     155PIXtBaseWidget bwdg = (PIXtBaseWidget)wdgp;
     156if (bwdg->pixtbase.vis_expose_fg != 1) return;
     157if (evt->xvisibility.state == VisibilityFullyObscured)  return;
     158int x0, y0, dx, dy;
     159x0 = y0 = 0;
     160dx = wdgp->core.width;  dy = wdgp->core.height;
     161(bwdg->pixtbase.objet)->eXposeProcess(x0, y0, dx, dy);
     162bwdg->pixtbase.vis_expose_fg = 0;
     163}
     164
    145165/* Nouvelle-Fonction */
    146166static void init_pixtbase (Widget request, Widget wdg,
     
    154174// get_GCs (wdgp);
    155175#ifdef DEBUG_PIXTB
    156 printf("Debug_init_pixtbase: Wdg=%lx Object= %lx  narg=%d \n",
    157 (long)wdgp, (long)(wdgp->pixtbase.objet), (int)(*narg));
    158 #endif
    159 return;
    160 }
    161 
    162 /* Nouvelle-Fonction */
    163 static void destroy_pixtbase (Widget /*wdgp*/)
     176printf("Debug_init_pixtbase: Wdg=%lx Object= %lx  \n",
     177(long)wdgp, (long)(wdgp->pixtbase.objet));
     178#endif
     179
     180// Pour gerer les exposes event avec fenetre non visible ...
     181wdgp->pixtbase.vis_expose_fg = 0;
     182XtAddEventHandler(wdg, VisibilityChangeMask, FALSE, visibchange_handler_pixtbase, NULL);
     183return;
     184}
     185
     186/* Nouvelle-Fonction */
     187static void destroy_pixtbase (Widget wdgp)
    164188{
    165189#ifdef DEBUG_PIXTB
     
    194218(long)(((PIXtBaseWidget)wdgp)->pixtbase.objet) );
    195219#endif
    196 if (!(wdgp->core.visible))  return;
    197 if ( ((PIXtBaseWidget)wdgp)->pixtbase.objet )
    198   {
     220if (!(wdgp->core.visible))  {
     221  ((PIXtBaseWidget)wdgp)->pixtbase.vis_expose_fg = 1;
     222  return;
     223}
     224if ( ((PIXtBaseWidget)wdgp)->pixtbase.objet ) {
    199225  XRectangle  xrec;
    200226  int x0, y0, dx, dy;
    201   XClipBox(region, &xrec);
    202   x0 = xrec.x;  y0 = xrec.y;
    203   dx = xrec.width;  dy = xrec.height;
     227  if (region) {
     228    XClipBox(region, &xrec);
     229    x0 = xrec.x;  y0 = xrec.y;
     230    dx = xrec.width;  dy = xrec.height;
     231  }
     232  else {
     233    x0 = y0 = 0;
     234    dx = wdgp->core.width;  dy = wdgp->core.height;
     235  }
    204236  (((PIXtBaseWidget)wdgp)->pixtbase.objet)->eXposeProcess(x0, y0, dx, dy);
    205   }
     237  ((PIXtBaseWidget)wdgp)->pixtbase.vis_expose_fg = 0;
     238}
    206239return;
    207240}
  • trunk/SophyaPI/PI/pixtbaseP.h

    r4077 r4083  
    2424PIBaseWdgX  * objet;
    2525unsigned long myeventmask;
     26unsigned int vis_expose_fg;   // Gestion des expose_event avec fenetre non visible
    2627} PIXtBasePart;
    2728
  • trunk/SophyaPI/PI/psfile.cc

    r4077 r4083  
    682682        }
    683683        /* Portrait ou Landscape ? */
    684         if(orientation == PI_Auto)
     684        if(orientation == PI_Auto)  {
    685685            if( ((tw < th) && (Dx < 1.2*Dy)) ||
    686686                ((tw > th) && (Dx > Dy) ))
     
    688688            else
    689689                currentPage->orientation = PI_Landscape ;
    690 
     690        }
    691691        if(currentPage->orientation == PI_Portrait) {
    692692          //        if( (tw/Dx) < (th/Dy) )
     
    13671367    for(i = 0; i < Ny; i++) {
    13681368        for(j = 0; j<Nx-1; j++ )
    1369             fprintf(mPSFile, "%02X", Pict[i*Nx+j]);
    1370     fprintf(mPSFile, "%02X\n", Pict[i*Nx+j]);
     1369            fprintf(mPSFile, "%02X", (int)Pict[i*Nx+j]);
     1370    fprintf(mPSFile, "%02X\n", (int)Pict[i*Nx+j]);
     1371    }
     1372    /* Un petit grestore ...*/
     1373    fprintf(mPSFile, "gr\n");
     1374}
     1375
     1376void PSFile::Image(double x0, double y0, double Tx, double Ty,
     1377                   int Nx, int Ny,
     1378                   unsigned short *Pict,
     1379                   PIColorMap *mMap) {
     1380
     1381    int i, j;
     1382
     1383    /* Buffers PostScript */
     1384    fprintf(mPSFile, "/Taille %d def\n", Nx);
     1385    fprintf(mPSFile, "/ImStr Taille string def\n");
     1386    fprintf(mPSFile, "/RGBStr Taille 3  mul string def\n");
     1387
     1388    /* Ecriture ColorMap */
     1389    fprintf(mPSFile, "/ColorMap %05d array def\n", mMap->NCol() );
     1390    for(i = 0; i < mMap->NCol(); i++) {
     1391        fprintf(mPSFile, "ColorMap %d [16#%02X 16#%02X 16#%02X] put\n",
     1392                i,
     1393                (int)(mMap->GetColor(i).red/256),
     1394                (int)(mMap->GetColor(i).green/256),
     1395                (int)(mMap->GetColor(i).blue/256));
     1396    }
     1397    /* Emplacement de l'image */
     1398    fprintf(mPSFile, "gs %.2f Ux %.2f Uy tr %.2f Ux %.2f Uy sc\n", x0, y0, Tx, Ty);
     1399    /* Nbr pix-X, Nbr pix-Y bits/pixels */
     1400    fprintf(mPSFile, "%d %d 16\n", Nx, Ny);
     1401    /* Matrice de passage */
     1402    fprintf(mPSFile, "[%d 0 0 %d 0 0]", Nx, Ny);
     1403    /* Fonction colorimage */
     1404    fprintf(mPSFile, "{currentfile ImStr readhexstring pop GetRGB}\
     1405false 3 colorimage\n\n");
     1406    /* Data */
     1407    for(i = 0; i < Ny; i++) {
     1408        for(j = 0; j<Nx-1; j++ )
     1409            fprintf(mPSFile, "%04X", (int)Pict[i*Nx+j]);
     1410    fprintf(mPSFile, "%04X\n", (int)Pict[i*Nx+j]);
    13711411    }
    13721412    /* Un petit grestore ...*/
  • trunk/SophyaPI/PI/psfile.h

    r4077 r4083  
    165165                        unsigned char *pict,
    166166                        PIColorMap *mColorMap);
     167    virtual void  Image(double x0, double y0, double Tx, double Ty,
     168                        int Nx, int Ny,
     169                        unsigned short *pict,
     170                        PIColorMap *mColorMap);
    167171
    168172// Declarations en public - sinon certains compilateurs cxx , aCC, xlC ont des problemes
Note: See TracChangeset for help on using the changeset viewer.