Changeset 6 in Sophya


Ignore:
Timestamp:
Feb 19, 1996, 6:04:14 PM (30 years ago)
Author:
eros
Message:

Modifs avant Presentation 21,22/02 + Ajout fichiers MAC (Reza+Eric, 19/02/96)

Location:
trunk/SophyaPI/PI
Files:
2 added
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PI/Makefile

    r5 r6  
    8585
    8686$(EXE)pitest : $(OBJ)pitestapp.o
    87         g++ -o $(EXE)pitest $(OBJ)pitestapp.o -L$(LIB) -lPI -lImages -lOutils -lXm -lXt -lX11
     87        g++ -o $(EXE)pitest $(OBJ)pitestapp.o -L$(LIB) -lPI -lImages -lOutils -lmath -lXm -lXt -lX11 -lm
    8888
    8989$(OBJ)ex_dessin.o: ex_dessin.cc ex_dessin.h pisysdep.h pibwdgx.h pibwdggen.h \
     
    166166 piwindowgen.h pioptmenux.h pioptmenugen.h pistdwdgx.h pistdwdggen.h \
    167167 pibwdgx.h pibwdggen.h pipixmapx.h pipixmapgen.h picmap.h picmapx.h \
    168  picmapgen.h pifilechox.h pifilechogen.h ex_dessin.h
     168 picmapgen.h pifilechox.h pifilechogen.h piimage.h ex_dessin.h
  • trunk/SophyaPI/PI/pi.rsc

    r2 r6  
    88PeidaInt*activeTopShadowColor:               White
    99PeidaInt*default*activeTopShadowColor:       White
    10 PeidaInt*background:                         Grey
    11 PeidaInt*default*background:                 Grey
     10PeidaInt*background:                         LightGrey
     11PeidaInt*default*background:                 LightGrey
    1212PeidaInt*bottomShadowColor:                  Black
    1313PeidaInt*default*bottomShadowColor:          Black
    14 PeidaInt*Foreground:                         Yellow
    15 PeidaInt*default*Foreground:                 Yellow
     14PeidaInt*Foreground:                         Black
     15PeidaInt*default*Foreground:                 Black
    1616PeidaInt*topShadowColor:                     White
    1717PeidaInt*default*topShadowColor:             White
    18 PeidaInt*borderColor:                        Yellow
     18PeidaInt*borderColor:                        Black
    1919
    2020PeidaInt*XmLabel.borderWidth:                1
     
    2323PeidaInt*XmPushButton*borderWidth:           0
    2424
    25 PeidaInt*XmText*XmNshadowThickness:          0
    26 PeidaInt*XmText*XmNhighlightThickness:          0
     25PeidaInt*XmText*XmNshadowThickness:          1
     26PeidaInt*XmText*XmNhighlightThickness:          2
    2727
    2828
  • trunk/SophyaPI/PI/piapplx.cc

    r2 r6  
    4646#endif
    4747topwdg->Unmanage();
    48 delete topcont;
     48delete menubar;
     49if (topcont != MBCont())  delete topcont;
     50delete intcont;
    4951delete topwdg;
    5052exit(0);
  • trunk/SophyaPI/PI/pibwdggen.h

    r2 r6  
    1616enum PILineAtt { PI_NormalLine = 0, PI_ThinLine = 1, PI_ThickLine = 2 };
    1717
    18 enum PIPointer { PI_ArrowPointer = 1, PI_CrossPointer = 2, PI_HandPointer = 3 };
     18enum PIPointer { PI_ArrowPointer = 1, PI_CrossPointer = 2,
     19                 PI_HandPointer = 3, PI_TDLRArrowPointer = 4 };
    1920
    2021class PIBaseWdgGen : public PIWdg
  • trunk/SophyaPI/PI/pibwdgx.cc

    r2 r6  
    131131void PIBaseWdgX::DrawString(int x, int y, char* s, int pos)
    132132{
    133 XDrawImageString (XtDisplay (XtWdg()),XtWindow(XtWdg()),
     133XDrawString (XtDisplay (XtWdg()),XtWindow(XtWdg()),
    134134                  DefGC(), x, y, s, strlen(s));
    135135return;
     
    262262void PIBaseWdgX::Refresh()
    263263{
    264 if ( (XtIsRealized(this->XtWdg())) && 
     264if ( (XtIsRealized(XtWdg())) && 
    265265   (((PIXtBaseWidget)(this->XtWdg()))->core.visible) )       
    266   { this->Draw(); }
     266  { /* EraseWindow(); */ Draw(); }
    267267
    268268return;
     
    457457curs[PI_CrossPointer] =  XCreateFontCursor(mdsp, XC_crosshair);
    458458curs[PI_HandPointer] =  XCreateFontCursor(mdsp, XC_hand2);
    459 
    460 return;
    461 }
     459curs[PI_TDLRArrowPointer] =  XCreateFontCursor(mdsp, XC_fleur);
     460
     461return;
     462}
  • trunk/SophyaPI/PI/pifilechox.cc

    r2 r6  
    8080PIFileChooserX::~PIFileChooserX()
    8181{
     82delete mWin;
    8283}
    8384
  • trunk/SophyaPI/PI/piimage.cc

    r2 r6  
    1414
    1515/* --Methode-- */
    16 PIImage::PIImage(PIContainerGen *par, char *nom, RzImage *pim,
     16PIImage::PIImage(PIContainerGen *par, char *nom,
    1717   int sx, int sy, int px, int py) :
    1818  PIPixmap(par, nom, sx, sy, px, py)
     
    3131
    3232SetColMap(CMAP_COLRJ32);
    33 SetImage(pim);
    3433
    3534ActivateButton(1);
     35ActivateMove(1);
    3636ActivateButton(2);
    37 //ActivateMove(1);
     37ActivateMove(2);
     38
    3839
    3940}
     
    5051void PIImage::SetImage(RzImage *pim)
    5152{
    52 int xwsz, ywsz;
    53 
     53
     54offx = offy = 0;
     55xpav = ypav = 0;
    5456img = pim;
    5557if (img)
    5658  {
    5759  SetSize(img->XSize(), img->YSize());
    58   xwsz = XSize();  ywsz = YSize();
    59   if (xwsz > img->XSize()) xwsz = img->XSize();
    60   if (ywsz > img->YSize()) ywsz = img->YSize();
    61   xpav = xwsz/2;
    62   ypav = ywsz/2;
     60  SetPave();
    6361  if (img->minPix>img->maxPix) img->CheckDyn();
    64   SetLut(img->minPix, img->maxPix, kLutType_Lin, 2);
     62  SetLut(img->minPix, img->maxPix, kLutType_Lin, 1);
    6563  }
    6664//printf("Debug_SetImage: %ld %ld \n", (long)img, (long)lut);
     
    10199lut = new LUT(min, max, NbCol(), typlut);
    102100
     101Apply();
    103102return;
    104103}
     
    111110lut = new LUT(clut->Min(), clut->Max(), NbCol(), clut->Type());
    112111if (olut) delete olut;
     112
     113Apply();
    113114return;
    114115}
     
    122123else if (zm < -10) zoom = -10;
    123124else zoom = zm;
    124 return;
    125 }
    126 /* --Methode-- */
    127 void PIImage::SelectColor(CMapId cmap)
    128 {
    129 SetColMap(cmap);
     125SetOffset();
     126Apply();
     127return;
     128}
     129
     130
     131/* --Methode-- */
     132void PIImage::SetColMap(CMapId cmap)
     133{
     134PIPixmap::SetColMap(cmap);
    130135if (zow)  zow->SetColMap(cmap);
    131136return;
     
    134139
    135140/* --Methode-- */
    136 void PIImage::Apply()
    137 {
    138 ComputePixmap();
    139 Refresh();
    140 if (zow == NULL)  return;
    141 ComputeZoomPixmap();
    142 zow->Refresh();
     141void PIImage::Apply(bool mw)
     142{
     143if (mw) ComputePixmap();
     144if (zow != NULL)
     145  {
     146  zow->SetColMap(GetColMapId());
     147  ComputeZoomPixmap();
     148  }
     149if (txw)
     150  {
     151  char buff[256];
     152  sprintf(buff,"%s : X= %d , Y= %d  PixVal= %g ",
     153          (char *)Nom().c_str(), xpav, ypav, img->FValue(xpav, ypav));
     154  txw->SetLabel((string)buff);
     155  }
     156Send(PIMsg_ActiveWindow, (char *)this);
    143157return;
    144158}
     
    147161void PIImage::Resize()
    148162{
    149 printf("PIImage::Resize\n");
    150 ComputePixmap();
     163// printf("PIImage::Resize\n");
     164SetPave();
     165Apply();
    151166return;
    152167}
     
    157172int xp, yp;
    158173
     174if (img == NULL)  return;
     175if ( PosW2Img(x, y, &xp, &yp) )  return;
     176SelPointerShape(PI_CrossPointer);
     177xpav = xp;  ypav = yp;
     178Apply(false);
     179return;
     180}
     181
     182/* --Methode-- */
     183void PIImage::Ptr1Move(int x, int y)
     184{
     185int xp, yp;
    159186if (img == NULL)  return;
    160187if ( PosW2Img(x, y, &xp, &yp) )  return;
    161188xpav = xp;  ypav = yp;
    162 if (zow)
    163   {
    164   ComputeZoomPixmap();
    165   zow->Refresh();
    166   }
     189Apply(false);
     190return;
     191}
     192
     193/* --Methode-- */
     194void PIImage::But1Release(int /*x*/,  int /*y*/)
     195{
     196SelPointerShape(PI_ArrowPointer);
     197return;
     198}
     199
     200
     201/* --Methode-- */
     202void PIImage::But2Press(int x, int y)
     203{
     204int xp, yp;
     205
     206if (img == NULL)  return;
     207if ( PosW2Img(x, y, &xp, &yp) )  return;
     208SelPointerShape(PI_TDLRArrowPointer);
     209xmv0 = xp;
     210ymv0 = yp;
     211Send(PIMsg_ActiveWindow, (char *)this);
     212return;
     213}
     214
     215
     216/* --Methode-- */
     217void PIImage::Ptr2Move(int x, int y)
     218{
     219int xp, yp;
     220if (img == NULL)  return;
     221if ( PosW2Img(x, y, &xp, &yp) )  return;
    167222if (txw)
    168223  {
    169224  char buff[256];
    170   sprintf(buff,"Image %s : X= %d , Y= %d  PixVal= %g ",
    171           img->name, xpav, ypav, img->FValue(xpav, ypav));
    172   txw->SetLabel(buff);
    173   }
    174 return;
    175 }
    176 
    177 
    178 /* --Methode-- */
    179 void PIImage::But2Press(int x, int y)
     225  sprintf(buff,"%s : DelX= %d , DelY= %d ", (char *)Nom().c_str(), xp-xmv0, yp-ymv0);
     226  txw->SetLabel((string)buff);
     227  }
     228}
     229
     230/* --Methode-- */
     231void PIImage::But2Release(int x, int y)
    180232{
    181233int xp, yp;
    182 int xwsz, ywsz;
    183 
     234
     235SelPointerShape(PI_ArrowPointer);
    184236if (img == NULL)  return;
    185237if ( PosW2Img(x, y, &xp, &yp) )  return;
    186 xpav = xp;  ypav = yp;
    187 
    188 xwsz = XSize();
    189 ywsz = YSize();
    190 if (zoom > 0)
    191   {
    192   offx = xpav-(xwsz/2/zoom);
    193   offy = ypav-(ywsz/2/zoom);
    194   }
    195 else
    196   {
    197   offx = xpav+(xwsz*zoom/2);
    198   offy = ypav+(ywsz*zoom/2);
    199   }
     238
     239offx -= (xp-xmv0);
     240offy -= (yp-ymv0);
     241
    200242if (offx < 0)  offx = 0;
    201243if (offy < 0)  offy = 0;
    202244if (offx >= img->XSize())  offx = img->XSize();
    203245if (offy >= img->YSize())  offy = img->YSize();
    204 
    205 ComputePixmap();
    206 Refresh();
    207 if (zow)
    208   {
    209   ComputeZoomPixmap();
    210   zow->Refresh();
    211   }
     246xpav = xmv0;  ypav = ymv0;
     247
     248Apply();
    212249return;
    213250}
     
    226263
    227264if ( (img == NULL) || (lut == NULL) )
    228   { printf("PIImage::ComputePixmap:Pb img ou lut %ld %ld \n",
    229             (long)img, (long)lut);
     265  { /* printf("PIImage::ComputePixmap:Pb img ou lut %ld %ld \n",
     266            (long)img, (long)lut); */
    230267  *oxsp = *oysp = 0; return(NULL); }
    231268
     
    253290if ( oszp != nszp )
    254291  {
    255   if (opix)  delete opix;
     292  if (opix)  delete[] opix;
    256293  pix = new unsigned char[nppx*nppy];
    257294  if (pix == NULL)  { *oxsp = *oysp = 0; ; return(NULL); }
     
    260297*oxsp = nppx; *oysp = nppy;
    261298
     299/*
    262300printf("Debug_ComputePixmap %d %d %d (%d-%d %d-%d)\n",
    263301      ofx, ofy, zm, npx,nppx, npy,nppy);
     302*/
    264303
    265304pp = pix;
     
    312351pixm = ComputePixmap(offx, offy, zoom, xwsz, ywsz, pixm, &xspxm, &yspxm);
    313352SetPixmap(pixm, xspxm, yspxm);
     353// Refresh();
    314354return;
    315355}
     
    345385zow->SetPixmap(zpixm, xszpxm, yszpxm);
    346386zow->SetUserData((void *)this, 0);
     387// zow->Refresh();
    347388return;
    348389
     
    372413
    373414
     415/* --Methode-- */
     416void PIImage::SetOffset()
     417{
     418if (zoom > 0)
     419  {
     420  offx = xpav-XSize()/2/zoom;
     421  offy = ypav-YSize()/2/zoom;
     422  }
     423else
     424  {
     425  offx = xpav-XSize()/2*zoom;
     426  offy = ypav-YSize()/2*zoom;
     427  }
     428
     429if (offx < 0)  offx = 0;
     430if (offx >= (img->XSize()-1))  offx = img->XSize()-2;
     431if (offy < 0)  offy = 0;
     432if (offy >= (img->YSize()-1))  offy = img->YSize()-2;
     433
     434return;
     435}
     436
     437/* --Methode-- */
     438void PIImage::SetPave()
     439{
     440int xwsz, ywsz;
     441
     442xwsz = XSize();  ywsz = YSize();
     443if (xwsz > (img->XSize()-offx)) xwsz = (img->XSize()-offx);
     444if (ywsz > (img->YSize()-offy)) ywsz = (img->YSize()-offy);
     445xpav = offx+xwsz/2;
     446ypav = offx+ywsz/2;
     447
     448return;
     449}
  • trunk/SophyaPI/PI/piimage.h

    r2 r6  
    3333  PILabel * txw;
    3434  int xpav, ypav;
    35 
     35  int xmv0, ymv0;
    3636public:
    3737//  Les methodes
    3838
    39   PIImage(PIContainerGen *par, char *nom=NULL, RzImage *pim=NULL,
     39  PIImage(PIContainerGen *par, char *nom=NULL,
    4040           int sx=0, int sy=0, int px=0, int py=0);
    4141  ~PIImage();
     
    4949  void SetLut(LUT *clut);
    5050  void SetZoom(int zm);
    51   void SelectColor(CMapId cmap);
    5251
    53   void Apply();
    54   void Resize();
     52  virtual void SetColMap(CMapId cmap);
    5553
    56 //  void Ptr1Move(int x, int y);
    57   void But1Press(int x, int y);
    58   void But1Release(int x, int y);
    59   void But2Press(int x, int y);
     54  inline RzImage * Image() { return(img); }
     55  inline LUT *     Lut() { return(lut); }
     56  inline int XPave() { return(xpav); } ;
     57  inline int YPave() { return(ypav); } ;
    6058
    61   inline int GetXPave() { return(xpav); } ;
    62   inline int GetYPave() { return(ypav); } ;
     59  void Apply(bool mw=true);
     60
     61  virtual void Resize();
     62
     63  virtual void But1Press(int x, int y);
     64  virtual void But1Release(int x, int y);
     65  virtual void Ptr1Move(int x, int y);
     66  virtual void But2Press(int x, int y);
     67  virtual void But2Release(int x, int y);
     68  virtual void Ptr2Move(int x, int y);
    6369
    6470private:
     
    7177
    7278  int PosW2Img(int xiw, int yiw, int * xp, int * yp);
     79  void SetOffset();
     80  void SetPave();
    7381};
    7482
  • trunk/SophyaPI/PI/pimenux.cc

    r2 r6  
    2525
    2626// pim->Unmanage();
    27 pim->Send(cusd->msg, pim->ItemName(cusd->itb).c_str());
     27pim->Send(cusd->msg, (void *)pim->ItemNameWdg(cusd->itb).c_str());
    2828#ifdef DEBUG_PIMenuX
    2929printf("%%%Debug_menub_action: Msg= %d  \n", (int)cusd->msg);
     
    5858}
    5959
    60 /* --Methode-- */
    61 void PIMenuX::Show()
    62 {
    63 Manage();
    64 }
    65 
    66 /* --Methode-- */
    67 void PIMenuX::Hide()
    68 {
    69 Unmanage();
    70 }
    71 
    72 
    7360
    7461/* --Methode-- */
     
    8471
    8572for(int i=0; i<mNItem; i++)
    86   if (ItemName(mBut[i].itb) == s) 
     73  if (ItemName(i) == s) 
    8774    { DeleteItemNum(i);  break; }
    8875
     
    127114
    128115for(int i=0; i<mNItem; i++)
    129   if (ItemName(mBut[i].itb) == s) 
     116  if (ItemName(i) == s) 
    130117    { CheckItemNum(i, st);  break; }
    131118
     
    148135printf("PIMenuX::CheckItemNum(%d,bool) Error/ Not yet implemented \n", n);
    149136return;
     137}
     138
     139/* --Methode-- */
     140void PIMenuX::Show()
     141{
     142Manage();
     143}
     144
     145/* --Methode-- */
     146void PIMenuX::Hide()
     147{
     148Unmanage();
     149}
     150
     151
     152
     153/* --Methode-- */
     154string PIMenuX::ItemName(int n)
     155{
     156if ( (n < 0) || (n >= mNItem))  return("");
     157return (ItemNameWdg(mBut[n].itb));
     158}
     159
     160
     161/* --Methode-- */
     162string PIMenuX::ItemNameWdg(SysDWdg itw)
     163{
     164string s;
     165char *buff;
     166XmString xmstr;
     167Arg warg[2];
     168
     169XtSetArg(warg[0], XmNlabelString, &xmstr);
     170XtGetValues(itw, warg, 1);
     171if (xmstr)
     172  {
     173  XmStringGetLtoR(xmstr, XmSTRING_DEFAULT_CHARSET, &buff);
     174  s=buff;
     175  XmStringFree(xmstr);
     176  }
     177else s = "";
     178
     179return(s);
     180}
     181
     182
     183/* --Methode-- */
     184long PIMenuX::ItemMsg(int n)
     185{
     186if ( (n < 0) || (n >= mNItem))  return(0);
     187else return(mBut[n].msg);
     188}
     189
     190
     191
     192/* --Methode-- */
     193int PIMenuX::GetNumItem(char *nom)
     194{
     195string s(nom);
     196
     197for(int i=0; i<mNItem; i++)
     198  if (ItemName(i) == s)  return(i);
     199return(-1);
     200}
     201
     202/* --Methode-- */
     203int PIMenuX::GetNumItemMsg(long msg)
     204{
     205for(int i=0; i<mNItem; i++)
     206  if (mBut[i].msg == msg)   return(i); 
     207return(-1);
     208}
     209
     210/* --Methode-- */
     211SysDWdg PIMenuX::GetItemWdg(int n)
     212{
     213if ((n<0) || (n>=mNItem))  return(NULL);
     214else return(mBut[n].itb);
    150215}
    151216
     
    203268
    204269
    205 /* --Methode-- */
    206 string PIMenuX::ItemName(SysDWdg itb)
    207 {
    208 string s;
    209 char *buff;
    210 XmString xmstr;
    211 Arg warg[2];
    212 
    213 
    214 XtSetArg(warg[0], XmNlabelString, &xmstr);
    215 XtGetValues(itb, warg, 1);
    216 if (xmstr)
    217   {
    218   XmStringGetLtoR(xmstr, XmSTRING_DEFAULT_CHARSET, &buff);
    219   s=buff;
    220   XmStringFree(xmstr);
    221   }
    222 else s = "";
    223 
    224 return(s);
    225 }
    226270
    227271/* --Methode-- */
  • trunk/SophyaPI/PI/pimenux.h

    r2 r6  
    3535  virtual void    Hide();
    3636
    37   string          ItemName(SysDWdg itb);
     37// Pour usage prive et par OptionMenu, ...
     38  long            ItemMsg(int n);
     39  int             GetNumItem(char *nom);
     40  int             GetNumItemMsg(long msg);
     41  SysDWdg         GetItemWdg(int n);
     42  string          ItemName(int n);
     43  string          ItemNameWdg(SysDWdg itw);
    3844
    3945protected:
  • trunk/SophyaPI/PI/pimsghandler.h

    r2 r6  
    77
    88enum {
    9  // Les flags
    10  
    11         PIMsg_FgBtn    = 0x00010000,
    12         PIMsg_FgText   = 0x00020000,
    13         PIMsg_FgScale  = 0x00040000,
    14         PIMsg_FgMenu   = 0x00080000,
    15  
    169 // Les messages
    17         PIMsg_OK          = 1,
    18         PIMsg_Cancel      = 2,
    19         PIMsg_Help        = 3,
    20         PIMsg_DataChanged = 4,
    21         PIMsg_Click       = 5
     10        PIMsg_ActiveWindow  = 1,
     11        PIMsg_OK            = 2,
     12        PIMsg_Cancel        = 3,
     13        PIMsg_Help          = 4,
     14        PIMsg_DataChanged   = 5,
     15        PIMsg_Click         = 6
    2216};
    2317
  • trunk/SophyaPI/PI/pioptmenugen.h

    r2 r6  
    1919  virtual string     GetValueStr() = 0;    // Option choisie
    2020  virtual long       GetValue() = 0;       // Message correspondant a l'option choisie
     21  virtual void       SetValueStr(string & s) = 0;
     22  virtual void       SetValue(long msg) = 0;
    2123
    2224protected:
  • trunk/SophyaPI/PI/pioptmenux.cc

    r2 r6  
    2828wmis == k_wmi_normal ;
    2929stmng = 0;
     30mMen = pdm;
    3031
    3132cb = XmOptionButtonGadget (XtWdg());
     
    3738// SetLabel(pdm->Nom());
    3839
    39 pdm->SetMsgParent(this);
     40mMen->SetMsgParent(this);
    4041Manage();
    4142}
     
    5556}
    5657
     58
     59/* --Methode-- */
     60void PIOptMenuX::SetValueStr(string & s)
     61{
     62int n;
     63Arg warg[2];
     64n=mMen->GetNumItem((char *)s.c_str());
     65if (n < 0)  return; 
     66
     67XtSetArg(warg[0], XmNmenuHistory, mMen->GetItemWdg(n));
     68XtSetValues(XtWdg(), warg, 1);
     69mStext = s;
     70mSmsg  = mMen->ItemMsg(n);
     71
     72return;
     73}
     74
     75/* --Methode-- */
     76void PIOptMenuX::SetValue(long msg)
     77{
     78int n;
     79Arg warg[2];
     80n=mMen->GetNumItemMsg(msg);
     81if (n < 0)  return;
     82 
     83XtSetArg(warg[0], XmNmenuHistory, mMen->GetItemWdg(n));
     84XtSetValues(XtWdg(), warg, 1);
     85mStext = mMen->ItemName(n);
     86mSmsg  = msg;
     87
     88return;
     89}
     90
  • trunk/SophyaPI/PI/pioptmenux.h

    r2 r6  
    1414  virtual string    GetValueStr() { return(mStext); }
    1515  virtual long      GetValue()    { return(mSmsg); }
     16  virtual void      SetValueStr(string & s);
     17  virtual void      SetValue(long msg);
     18 
    1619 
    1720  inline void       Select(char *txt, long msg) { mStext = txt;  mSmsg = msg; }
     
    1922
    2023protected:
     24  PIPDMenu *mMen;
    2125  string   mStext;
    2226  long     mSmsg;
  • trunk/SophyaPI/PI/pipixmapgen.cc

    r2 r6  
    3232{
    3333pixmap = pix; nx = sx; ny = sy;
    34 Refresh();
     34Refresh();   
    3535}
    3636
     
    4141  if (cmap) delete cmap;
    4242  cmap = new PIColorMap(cmapid);
    43   Refresh();
     43  Refresh(); 
    4444}
    4545
  • trunk/SophyaPI/PI/pipixmapx.cc

    r2 r6  
    2727void PIPixmapX::Draw()
    2828{
    29 // EraseWindow();
     29Window xw;
     30Display * mdsp;
     31xw = XtWindow(XtWdg());
     32mdsp = PIXDisplay();
     33if (nx < XSize())  XClearArea(mdsp, xw, nx, 0, XSize()-nx, YSize(), False);
     34if (ny < YSize())  XClearArea(mdsp, xw, 0, ny, XSize(), YSize()-ny, False);
    3035Draw(0,0,XSize(),YSize());
    3136}
     
    7378XSync(mdsp, 0);
    7479
    75 delete ximg->data;
     80delete[] ximg->data;
    7681XFree(ximg);
    7782return;
  • trunk/SophyaPI/PI/pitestapp.cc

    r5 r6  
    1717
    1818#include "ex_dessin.h"
    19 
     19#include "piimage.h"
     20
     21RzImage * RzReadFits(char *flnm);
    2022
    2123int SysBeep(int n)
     
    5759    PIPUMenu  * menu;
    5860    PIPDMenu * pdm;
    59     PIOptMenu * opt;
     61    PIOptMenu * opt, * opt2;
     62    PIPixmap * zoom;
     63    PILabel  * labimg;
    6064
    6165};
     
    111115  text = new PIText(this->MainWin(), "TEXTE", 100, 30, 20,40);
    112116  label  = new PILabel(this->MainWin(), "Label", 140, 20, 20,80);
     117  label->SetBorderWidth(1);
    113118  bouton = new PIButton(this->MainWin(), "OK", 66, 40, 25, 20, 120);
    114119  bouton2 = new PIButton(this->MainWin(), "Image", 133, 40, 25, 80, 120);
     
    116121  bouton4 = new PIButton(this->MainWin(), "Menu", 555, 40, 25, 200, 120);
    117122  scl = new PIScale(this->MainWin(), "Scale", 88, 5, 45, 100, 20, 10, 150);
     123
     124  zoom = new PIPixmap(this->MainWin(), "Zoom", 100,100,5,195);
     125  labimg = new PILabel(this->MainWin(), "PixelValue", 250, 20, 10, 320);
    118126
    119127  menu = new PIPUMenu((PIMsgHandler *)this, "myMenu");
     
    133141
    134142  opt = new PIOptMenu(this->MainWin(), pdm, 80, 20, 110, 150);
    135 
    136   printf("Debug_PITestApp::PITestApp() MenBarSizeX,Y= %d %d \n",
    137          Menubar()->XSize(), Menubar()->YSize());
     143  opt->SetValueStr("Sqrt");
     144  opt2 = new PIOptMenu(this->MainWin(), m[1], 80, 20, 150, 200);
    138145
    139146}
     
    151158  delete menu;
    152159  delete m[0]; delete m[1]; delete m[2];
    153 //  delete menb;
    154 
    155 }
     160  delete opt;
     161  delete opt2;
     162  delete pdm;
     163  delete zoom;
     164  delete labimg;
     165
     166}
     167
     168static int nimg = 0;
     169static PIImage *pimg[5];
     170static RzImage *img[5];
     171static PIWindow *imgw[5];
     172static PIImage *cur=NULL;
    156173
    157174static PIWindow * wp3, *wp2, *wp4;
     
    172189  sprintf(truc,"< %ld - %d (%d)>",msg,x++, (int)((PIWdgGen *)sender)->kind());
    173190  this->label->SetLabel(truc);
     191
     192  if (msg == PIMsg_ActiveWindow)
     193    { /* printf("Process: Setting active ImageWindow (%lx) \n", (long)data); */
     194    cur = (PIImage *)data; }
     195   
    174196  if (msg == 133)
    175197    {
     
    179201    if ((x % 3) == 1)  pxm->SetColMap(CMAP_COLRJ32);
    180202    if ((x % 3) == 2)  pxm->SetColMap(CMAP_COLBR32);
    181     pxm->Refresh();
     203//    pxm->Refresh();
     204    if (cur)
     205      {
     206//      printf("Process: Setting ColMap for (%lx) \n", (long)cur);
     207      if ((x % 3) == 0)  cur->SetColMap(CMAP_GREY32);
     208      if ((x % 3) == 1)  cur->SetColMap(CMAP_COLRJ32);
     209      if ((x % 3) == 2)  cur->SetColMap(CMAP_COLBR32);
     210      }
    182211    }
    183212  if (msg == 233)
     
    193222
    194223  if (msg == 10301) 
    195    { numsg++;    m[1]->AppendItem((char *)text->GetText().c_str(), numsg); }
     224   {
     225   numsg++;   
     226   m[1]->AppendItem((char *)text->GetText().c_str(), numsg);
     227   opt2->SetValue(numsg);
     228   }
     229
    196230  if (msg == 10302)  { m[1]->DeleteItem((char *)text->GetText().c_str()); }
    197   if (msg == 10303)  { m[1]->DeleteItemMsg(atol(text->GetText().c_str())); }
     231  if (msg == 10303) 
     232    {
     233    long ml =  atol(text->GetText().c_str());
     234    m[1]->DeleteItemMsg(ml);
     235    opt2->SetValue(10201);
     236    }
    198237
    199238  if (msg == 555)  wp4->Show();
     
    202241  if ((msg > 8000) && data) printf("PITestApp::MenubarReturn: %s \n", (char *)data);
    203242  if (msg == 5000) 
    204     { if (data) printf("PITestApp::Process(5000) : %s \n", (char *)data);
     243    {
     244    if (data)
     245      {
     246      printf("PITestApp::Process(5000) : %s \n", (char *)data);
     247      if (nimg < 5)  img[nimg] = RzReadFits((char *)data);
     248      if (img[nimg])
     249        {
     250        imgw[nimg] = new PIWindow(this, "WindImage",
     251                                  PIWK_normal, 400, 400, 500, 500);
     252        pimg[nimg] = new PIImage(imgw[nimg], "MyImage", 400, 400, 0, 0);
     253        pimg[nimg]->SetBinding(true, true, true, true);
     254        pimg[nimg]->SetZoomWin(zoom);
     255        pimg[nimg]->SetTextWin(labimg);
     256        pimg[nimg]->SetImage(img[nimg]);
     257        pimg[nimg]->Apply();
     258        imgw[nimg]->Show();
     259        nimg++;
     260        }
     261    }
    205262    else printf("PITestApp::Process(5000) (data=NULL) \n");  }
     263
    206264  if (msg == 66) ckb->SetState(true);
    207   if ((msg / 100) == 56) printf("PITestApp::Process(%d) : %s \n", (int)msg, (char *)data);
     265  if ((msg / 100) == 56)
     266    printf("PITestApp::Process(%d) : %s \n", (int)msg, (char *)data);
    208267
    209268}
     
    212271{
    213272  PITestApp * app;
    214   app = new PITestApp(300, 200);
     273  app = new PITestApp(350, 350);
    215274
    216275  wp2 = new PIWindow(app, "Window-2", PIWK_normal,  150, 150, 250, 250);
     
    238297
    239298  pfc = new PIFileChooser(app,"FileChooser", 5000);
    240   pfc->SetPath("/users/eros/ansari/Images++");
     299  pfc->SetPath("/exp/eros/ImagRed/");
    241300
    242301
  • trunk/SophyaPI/PI/piwdggen.h

    r2 r6  
    3535  virtual void           SetSize(int sx, int sy)=0;
    3636  virtual void           SetPos(int px, int py)=0;
     37  virtual void           SetBorderWidth(int bw)=0;
    3738  virtual void           SetLabel(string const&) {}
    3839  virtual void           SetBinding(bool left, bool top, bool right, bool bottom)=0;
  • trunk/SophyaPI/PI/piwdgx.h

    r2 r6  
    3939  virtual void   SetSize(int sx, int sy);
    4040  virtual void   SetPos(int px, int py);
    41   virtual void   SetBinding(bool left, bool top, bool right, bool bottom);
    4241  virtual void   SetBorderWidth(int bw);
    4342  virtual void   SetLabel(string const & lab);
     43  virtual void   SetBinding(bool left, bool top, bool right, bool bottom);
    4444
    4545  virtual int    XSize();
Note: See TracChangeset for help on using the changeset viewer.