Changeset 104 in Sophya for trunk/SophyaPI


Ignore:
Timestamp:
May 5, 1998, 7:18:25 PM (27 years ago)
Author:
ansari
Message:

1/ Suite optimisation de gestion d'evts X pour PIBaseWdg
2/ introduction des adaptateurs pour tableaux 2-D (PIImage ...)

Reza 5/04/98

Location:
trunk/SophyaPI/PI
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PI/picons.cc

    r98 r104  
    442442AssignKeyboard();
    443443mWGrC->SelGOMode(PI_GOXOR);
    444 mWGrC->SelForeground(mFgC);
     444mWGrC->SelForeground(PI_Grey);
    445445mCPbeginC = x;  mCPbeginL = y;
    446446mCPendC = mCPendL = -1;
     
    659659       }
    660660     lva = mAtt[mLPo[l]+j];
    661      g->SelFont(mFTaille, vafat[lva]);
    662      if (lva & PIVA_Select) bgc = PI_Grey;
    663      else bgc = dbgc;
     661     if (lva & PIVA_Select)
     662       { bgc = PI_Grey;   g->SelFont(mFTaille, vafat[lva-PIVA_Select]); }
     663     else { bgc = dbgc; g->SelFont(mFTaille, vafat[lva]); }
     664     
    664665     if (lva & PIVA_Reverse) {
    665666       g->SelForeground(bgc);
  • trunk/SophyaPI/PI/piimage.cc

    r88 r104  
    105105
    106106/* --Methode-- */
    107 void PIImage::SetImage(RzImage *pim, bool refr)
     107void PIImage::SetImage(P2DArrayAdapter *pim, bool refr)
    108108{
    109109
     
    121121//  SetSize(img->XSize(), img->YSize());
    122122  CenterPave();
    123   if (img->minPix>img->maxPix) img->CheckDyn();
    124   SetLut(img->minPix, img->maxPix, kLutType_Lin, 1, refr);
     123  float min=1., max=-1., moy, sig;
     124  int nbnul, nbsat;
     125  img->CheckDyn(min, max, moy, sig, nbnul, nbsat);
     126  SetLut(min, max, kLutType_Lin, 1, refr);
    125127  }
    126128return;
     
    217219{
    218220if (lut) delete(lut);
    219 if (lauto && img)
    220   {
    221   float fracnul, fracsat;
    222   float fnd, sigfnd;
    223   float minpix = min; 
    224   float maxpix = max;
    225   int npix = img->XSize()*img->YSize();
    226   int rc = -1;
    227   if (npix > 2500)  // Ca ne marche pas quand il n'y a pas assez de pixels ...
    228     { 
    229     int vitesse=npix/20000;
    230     vitesse = (vitesse < 1) ? 1 : ((vitesse > 25) ? 25 : vitesse );
    231     int nbin=npix/10;
    232     nbin = (nbin < 1) ? 1 : ((nbin > 500) ? 500 : nbin );
    233     int nbsig = lauto; 
    234     float fracmax = 0.95;
    235     rc = RzFondSig2Ciel(img, vitesse, fracmax, nbsig, nbin, &minpix, &maxpix,
    236                  &fnd, &sigfnd, &min, &max, &fracnul, &fracsat);
    237     }
    238   if (rc != 0)
    239     {
    240     img->CheckDyn(minpix, maxpix);
    241     min = img->moyPix-3.*img->sigPix;
    242     max = img->moyPix+3.*img->sigPix;
    243     if (min < minpix)  min = minpix;
    244     if (max > maxpix)  max = maxpix;
    245     }
     221if (lauto && img)
     222  {
     223  int nbsig = lauto; 
     224  float fracmax = 1. - 0.05*nbsig;
     225  img->ComputeLut_PicHisto(min, max, nbsig, fracmax);
    246226  }
    247227
     
    366346  {
    367347  char buff[256];
    368   sprintf(buff,"X= %d , Y= %d  PixVal= %g ",  /*(char *)Nom().c_str(),*/
    369           xpav, ypav, img->FValue(xpav, ypav));
     348  float x,y;
     349  img->XYCoord(xpav, ypav, x, y);
     350  sprintf(buff,"X= %g , Y= %g  PixVal= %g (%d,%d)",
     351          x, y , (*img)(xpav, ypav), xpav, ypav );
    370352  if (txw)  txw->SetLabel((string)buff);
    371353  if (trtlb)  trtlb->SetLabel((string)buff);
     
    471453if (txw || trtlb)
    472454  {
    473   char buff[256];
    474   sprintf(buff,"X,Y= %d,%d  PixVal= %g (X,Yc= %d,%d)", 
    475           xp, yp, img->FValue(xp, yp), (xp+xpv0)/2, (yp+ypv0)/2);
     455  char buff[256]; 
     456  float x,y;
     457  img->XYCoord(xp, yp, x, y);
     458  sprintf(buff,"X= %g , Y= %g  PixVal= %g  (C= %d,%d)",
     459          x, y , (*img)(xp, yp),  (xp+xpv0)/2, (yp+ypv0)/2 );
    476460  if (txw)  txw->SetLabel((string)buff);
    477461  if (trtlb)  trtlb->SetLabel((string)buff);
     
    561545}
    562546
    563 /* --Methode-- */
    564 unsigned char *  PIImage::ComputePixmap(int ofx, int ofy, int zm,
    565                            int xwsz, int ywsz, unsigned char * opix,
    566                            int * oxsp, int * oysp)
    567 {
    568 unsigned char *pix, *pp, ucp;
    569 int zmm=1;
    570 int npx, npy, nppx, nppy, nszp, oszp;
    571 int i,j,k,l;
    572 float vpx;
    573 
    574 
    575 if ( (img == NULL) || (lut == NULL) )
    576   { /* printf("PIImage::ComputePixmap:Pb img ou lut %ld %ld \n",
    577             (long)img, (long)lut); */
    578   *oxsp = *oysp = 0; return(NULL); }
    579 
    580 npx = img->XSize()-ofx;
    581 npy = img->YSize()-ofy;
    582 
    583 if ((zm == 0) || (zm == -1))  zm = 1;
    584 
    585 if (zm >= 1)
    586   {
    587   if (npx > (xwsz/zm))  npx = xwsz/zm;
    588   if (npy > (ywsz/zm))  npy = ywsz/zm;
    589   nppx = npx*zm;   nppy = npy*zm;
    590   }
    591 if (zm < -1)
    592   {
    593   zmm = -zm;
    594   nppx = npx/zmm;   nppy = npy/zmm;
    595   if (nppx > xwsz)  nppx = xwsz;
    596   if (nppy > ywsz)  nppy = ywsz;
    597   npx = nppx*zmm;   npy = nppy*zmm;
    598   }
    599 
    600 oszp = (*oxsp)*(*oysp);
    601 nszp = nppx*nppy;
    602 if ( oszp != nszp )
    603   {
    604   if (opix)  delete[] opix;
    605   pix = new unsigned char[nppx*nppy];
    606   if (pix == NULL)  { *oxsp = *oysp = 0; ; return(NULL); }
    607   }
    608 else  pix = opix;
    609 *oxsp = nppx; *oysp = nppy;
    610 
    611 /*
    612 printf("Debug_ComputePixmap %d %d %d (%d-%d %d-%d)\n",
    613       ofx, ofy, zm, npx,nppx, npy,nppy);
    614 */
    615 
    616 pp = pix;
    617 if (zm == 1)    // Pas de zoom 
    618   {
    619   for(j=ofy; j<ofy+npy; j++)
    620     for(i=ofx; i<ofx+npx; i++)
    621       { *pp = (unsigned char) lut->Apply(img->FValue(i,j));  pp++; }
    622   }
    623 else if (zm < -1)        // Compression
    624   {
    625   float fv = (float)(zmm*zmm);
    626   for(j=ofy; j<ofy+npy; j+=zmm)
    627     for(i=ofx; i<ofx+npx; i+=zmm)
    628       {
    629       vpx = 0;
    630       for(l=0; l<zmm; l++)
    631         for(k=0; k<zmm; k++)
    632           vpx += img->FValue(i+k, j+l);
    633       *pp = (unsigned char) lut->Apply(vpx/fv);
    634       pp++;
    635       }
    636   }
    637 else      // Agrandissement
    638   {
    639   for(j=ofy; j<ofy+npy; j++)
    640     for(i=ofx; i<ofx+npx; i++)
    641       {
    642       ucp = (unsigned char) lut->Apply(img->FValue(i,j));
    643       for(l=0; l<zm; l++)
    644         {
    645         pp = pix+((j-ofy)*zm+l)*nppx+((i-ofx)*zm);
    646         for(k=0; k<zm; k++)  { *pp = ucp; pp++; } 
    647         }
    648       }
    649   }
    650 
    651 return(pix);
    652 }
    653547
    654548/* --Methode-- */
     
    661555ywsz = this->YSize();
    662556
    663 pixm = ComputePixmap(offx, offy, zoom, xwsz, ywsz, pixm, &xspxm, &yspxm);
     557pixm = img->ComputePixmap(lut, offx, offy, zoom, xwsz, ywsz, pixm, &xspxm, &yspxm);
    664558SetPixmap(pixm, xspxm, yspxm);
    665559// Refresh();
     
    696590if (ofy < 0)  ofy = 0;
    697591
    698 zpixm = ComputePixmap(ofx, ofy, zm, xwsz, ywsz, zpixm, &xszpxm, &yszpxm);
     592zpixm = img->ComputePixmap(lut, ofx, ofy, zm, xwsz, ywsz, zpixm, &xszpxm, &yszpxm);
    699593zow->SetColMap(GetColMapId(), false);
    700594zow->SetPixmap(zpixm, xszpxm, yszpxm);
     
    725619zmgv = zmx;
    726620if (zmx > 1)  zmx = -zmx;
    727 gpixm = ComputePixmap(0, 0, zmx, xwsz, ywsz, gpixm, &xsgpxm, &ysgpxm);
     621gpixm = img->ComputePixmap(lut, 0, 0, zmx, xwsz, ywsz, gpixm, &xsgpxm, &ysgpxm);
    728622return;
    729623}
     
    803697if ( (winovis || (nbmrk < 1) ) ) return;
    804698tofx = tofy = 0;
    805 if ( img ) { tofx = img->XOrg(); tofy = img->YOrg(); } 
     699if ( img ) { tofx = tofy = 0; }  /* img->XOrg(); tofy = img->YOrg(); $CHECK$  REZA 5/04/98 */ 
    806700tofx += offx;  tofy += offy;
    807701fz = GetZoomF();
  • trunk/SophyaPI/PI/piimage.h

    r88 r104  
    66#define PIIMAGEBASE_H_SEEN
    77
    8 #include "cimage.h"
    9 #include "lut.h"
     8#include "parradapter.h"
    109
    1110#include "pisysdep.h"
     
    3029  virtual void    Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
    3130
    32   void SetImage(RzImage* pim, bool refr=true);
     31  void SetImage(P2DArrayAdapter* pim, bool refr=true);
    3332  void SetAutoDelImage(bool ad = false);
    3433
     
    5554  virtual void SetColMap(CMapId cmap, bool refr=true);
    5655
    57   inline RzImage * Image() { return(img); }
     56  inline P2DArrayAdapter * Image() { return(img); }
    5857  inline LUT *     Lut() { return(lut); }
    5958  inline int XPave() { return(xpav); } ;
     
    8079private:
    8180     
    82   unsigned char *  ComputePixmap(int ofx, int ofy, int zm,
    83                        int xwsz, int ywsz, unsigned char * opix,
    84                        int * oxszp, int * oyszp);
    8581  void ComputePixmap();
    8682  void ComputeZoomPixmap();
     
    10298// Les donnees
    10399
    104   RzImage * img;
     100  P2DArrayAdapter * img;
    105101  bool aisup;
    106102  bool curshow;
  • trunk/SophyaPI/PI/pistdwdgx.cc

    r98 r104  
    55#include PISTDWDG_H
    66
    7 // Note du 26/02/98 - Reza
     7// ------- Pb de gestion du focus-keyboard  Motif-PIBaseWdg -------
     8// ** Note du 26/02/98 - Reza
    89// Je desactive pour le moment XmNnavigationType et XmNtraversalOn
    910// afin d'ameliorer la gestion du focus-keyboard entre Widget Motif
    1011// et objet Peida - Cela semble avoir un effet secondaire -
    1112// Il faut que la souris reste dans le widget Text pour taper dedans
     13// ** Note du 30/04/98 - Reza
     14// J'ai modifie le mecanisme de gestion des evenements pour PIBaseWdg
     15// en passant par un EventHandler - Le probleme de gestion du
     16// focus-keyboard n'a pour autant pas ete resolu
     17// Je reactive XmNtraversalOn pour les PIText - Le probleme
     18// d'attribution du focus-keyboard au PIBaseWdg reste si on
     19// met PIText et un PIBaseWdg ds un meme conteneur
     20
    1221
    1322/************* PILabelX ************/
     
    151160CreateXtWdg(nom, xmTextWidgetClass, NULL, sx, sy, px, py);
    152161XtSetArg(warg[n],XmNnavigationType,XmNONE);  n++;
    153 XtSetArg(warg[n],XmNtraversalOn,FALSE);  n++;
     162// XtSetArg(warg[n],XmNtraversalOn,FALSE);  n++;
    154163XtSetValues(XtWdg(), warg, n);
    155164SetMutiLineMode(false);
  • trunk/SophyaPI/PI/pixtbase.cc

    r103 r104  
    1313
    1414// #define DEBUG_PIXTB
     15
     16 
     17//  ------- Pb de gestion du focus-keyboard  Motif-PIBaseWdg -------
     18// ** Note 30/04/98  Reza
     19// Il y un probleme d'attribution du focus-keyboard entre Widget Motif et
     20// PIBaseWdg (Widget PIXtBase) les Attributs XmNnavigationType et XmNtraversalOn
     21// ont ete desactives pour les StdWdgX - Le probleme n'a pas pu etre resolu
     22// meme en attribuant les attributs  XmNnavigationType XmNtraversalOn
     23// (et XmNsensitive) a PIXtBase, ni en utilisant
     24// XSetInputFocus(XtDisplay (wdgp), XtWindow(wdgp), RevertToParent, evt->xbutton.time)
     25// Solution pour le moment :
     26//  XmNnavigationType =XmNONE et XmNtraversalOn=FALSE pour les PIStdWdgX
     27// sauf pour PIText ou XmNtraversalOn=TRUE
     28
    1529
    1630/*  Construction du widget Xt PIXtBase   */
     
    2438
    2539
    26 static Boolean  acceptfocus_pixtbase   (Widget, Time* );
     40// Si on ne veut pas utiliser XtInheritAcceptFocus
     41// static Boolean  acceptfocus_pixtbase   (Widget, Time* );
    2742
    2843
     
    6479XtInheritSetValuesAlmost,       /* set_values got "Almost" geo reply*/
    6580NULL,                           /* notify that get_values called    */
    66 // XtInheritAcceptFocus,           /* assign input focus to widget     */
    67 acceptfocus_pixtbase,           /* assign input focus to widget     */
     81XtInheritAcceptFocus,           /* assign input focus to widget     */
     82// acceptfocus_pixtbase,           /* assign input focus to widget     */
    6883XtVersion,                      /* version of intrinsics used       */
    6984NULL,                           /* list of callback offsets         */
     
    161176}
    162177
    163 /* Nouvelle-Fonction */
     178/* Nouvelle-Fonction
    164179static Boolean  acceptfocus_pixtbase   (Widget wdgp , Time* )
    165180{
    166 printf("acceptfocus_pixtbase() %x %x \n",  ((PIXtBaseWidget)wdgp)->pixtbase.myeventmask, ShiftMask );
     181// printf("acceptfocus_pixtbase() %lx %x \n",  ((PIXtBaseWidget)wdgp)->pixtbase.myeventmask, ShiftMask );
    167182if (  ((PIXtBaseWidget)wdgp)->pixtbase.myeventmask & ShiftMask  )  return TRUE;
    168183else return FALSE;
    169184}
     185*/
    170186
    171187/* -------- Fonction de traitement des evenements --------- */
Note: See TracChangeset for help on using the changeset viewer.