Changeset 63 in Sophya


Ignore:
Timestamp:
Dec 5, 1997, 11:13:15 PM (28 years ago)
Author:
ansari
Message:

Modifs pour les Drawers, Nouveaux ColorMap, Copier-Coller Reza 05/12/97

Location:
trunk/SophyaPI/PI
Files:
24 edited

Legend:

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

    r61 r63  
    152152DrawString(20, 75, buf);
    153153
     154if ( (kmod == PIKM_Alt) && (key == 'c') ) {
     155  printf("ExBWdg::Keyboard: Test-Copy ... \n");
     156  ClaimSelection();
     157}
     158if ( (kmod == PIKM_Alt) && (key == 'v') ) {
     159  printf("ExBWdg::Keyboard: Test-Paste ... \n");
     160  RequestSelection();
     161}
     162
    154163return;
    155164}
  • trunk/SophyaPI/PI/pibwdggen.cc

    r52 r63  
    5050  return;
    5151}
     52
     53/* --Methode-- */
     54void PIBaseWdgGen::Refresh()
     55{
     56if ( IsVisible() )  {
     57  Draw();
     58  CallDrawers();
     59}
     60return;
     61}
     62
     63/* --Methode-- */
     64void PIBaseWdgGen::Draw(int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/)
     65{
     66this->Draw();
     67return;
     68}
     69
     70/* --Methode-- */
     71void PIBaseWdgGen::Draw()
     72{
     73#ifdef DEBUG_RZXB
     74puts("Debug_PIBaseWdgGen::Draw() Efface la fenetre par defaut ! ");
     75#endif
     76this->EraseWindow();
     77return;
     78}
     79
     80
     81/* --Methode-- */
     82void PIBaseWdgGen::Resize()
     83{
     84#ifdef DEBUG_RZXB
     85puts("Debug_PIBaseWdgGen::Resize()  resize notify ");
     86#endif
     87return;
     88}
     89
    5290
    5391/* --Methode-- */
     
    173211drw->Attach((PIBaseWdg*)this, mDrwId);
    174212return(mDrwId);
     213}
     214
     215/* --Methode-- */
     216void PIBaseWdgGen::MoveResizeDrawer(int id, int x0, int y0, int dx, int dy)
     217{
     218list<BWDrwId>::iterator it;
     219for(it = mDrwList.begin(); it != mDrwList.end(); it++) 
     220  if ((*it).id == id) {
     221    (*it).x0 = x0;  (*it).y0 = y0;
     222    (*it).dx = dx;  (*it).dy = dy;
     223    break;
     224  }
     225return;
    175226}
    176227
     
    226277if (fgc)  ClearClipRectangle();
    227278
    228 }
     279return;
     280}
     281
     282/* --Methode-- */
     283void PIBaseWdgGen::CallDrawer(int id)
     284{
     285list<BWDrwId>::iterator it;
     286for(it = mDrwList.begin(); it != mDrwList.end(); it++)
     287  if ((*it).id == id) {
     288    SaveGraphicAtt();
     289    (*it).drw->SetDrwWdg(this, (*it).x0, (*it).y0, (*it).dx, (*it).dy);
     290    SetClipRectangle((*it).x0, (*it).y0, (*it).dx , (*it).dy);
     291    (*it).drw->Draw();
     292    RestoreGraphicAtt();   
     293    ClearClipRectangle();
     294    break;
     295  }
     296return;
     297}
  • trunk/SophyaPI/PI/pibwdggen.h

    r61 r63  
    1919                   PIK_Previous = 21+0x2000, PIK_Next = 22+0x2000  } ;
    2020
    21 enum PIColors  { PI_NotDefColor = -1,
     21enum PIColors  { PI_ColorFromMap = -2, PI_NotDefColor = -1,
    2222                 PI_Black = 0, PI_White = 1,  PI_Grey = 2,
    2323                 PI_Red = 3, PI_Blue = 4, PI_Green = 5, 
     
    7272  virtual void       EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0)   = 0;
    7373  virtual void       DrawString(int x, int y, char* s, int pos = 0)        = 0;
     74  virtual void       DrawOpaqueString(int x, int y, char* s, int pos = 0)  = 0;
    7475  virtual void       DrawLine(int x1, int y1, int x2, int y2)              = 0;
    7576  virtual void       DrawBox(int x0, int y0, int dx, int dy)               = 0;
     
    8990  virtual void       SelForeground(PIColors col=PI_Black)                  = 0;
    9091  virtual void       SelBackground(PIColors col=PI_White)                  = 0;
     92//  virtual void       SelForeground(PIColorMap* cmap, int cid)              = 0;
     93//  virtual void       SelBackground(PIColorMap* cmap, int cid)              = 0;
    9194  virtual void       SelGOMode(PIGOMode mod=PI_GOCopy)                     = 0;
    9295  virtual void       SelFont(PIFontSize sz=PI_NormalSizeFont,
     
    118121
    119122
    120 //  Fonction qui doit etre appelee pour rafraichir (retracer) tout
    121   virtual void       Refresh()          = 0;
     123//  Fonction qui doit etre appelee pour rafraichir la fenetre
     124  virtual void       Refresh();
     125
     126//  Fonctions qui doivent contenir le dessin du contenu du widget lui-meme
     127  virtual void       Draw();
     128  virtual void       Draw(int x0, int y0, int dx, int dy);
    122129 
    123130// Traitement des evenements   
    124   virtual void       Resize()           = 0;
    125   virtual void       Draw()             = 0;
    126   virtual void       Draw(int x0, int y0, int dx, int dy) = 0;
    127 
     131  virtual void       Resize();
    128132  virtual void       Enter();
    129133  virtual void       Leave(); 
     
    146150          int        AddDrawer(PIDrawer* drw, int x0, int y0, int dx, int dy,
    147151                               bool ad=false);
     152          void       MoveResizeDrawer(int id, int x0, int y0, int dx, int dy);
    148153          void       RemoveDrawer(int id);       // Ote un drawer de la liste
    149154          void       DeleteDrawers();            // Ote et detruit tous les drawers
    150155
     156//  Trace des Drawers ...         
     157  virtual void       CallDrawers(int x0=0, int y0=0, int dx=0, int dy=0);
     158  virtual void       CallDrawer(int id);
     159
    151160// Devrait etre protected - mis ici a cause de cxx  11/07/97  Reza
    152161  struct BWDrwId { int x0, y0; int dx, dy; int id; bool ad; PIDrawer* drw; };
    153          
     162
    154163protected:
    155   virtual void       CallDrawers(int x0, int y0, int dx, int dy); // Appel le trace des drawers
    156 
    157164  PSFile * mPSOut;  /* Fichier PostScript eventuel */
    158165
  • trunk/SophyaPI/PI/pibwdgmac.cc

    r61 r63  
    508508}
    509509
    510 /* --Methode-- */
     510/* --Methode--
    511511void PIBaseWdgMac::Refresh()
    512512{
     
    514514  Draw();
    515515}
    516 
    517 /* --Methode-- */
    518 void PIBaseWdgMac::Resize()
    519 {
    520 #ifdef DEBUG_RZXB
    521 printf ("Debug_PIBaseWdgMac::ReSize %ld %ld NewSize= %d %d\n",
    522          (long)(this), (long)(this->sdw),
    523          (int)this->sdw->core.width, (int)this->sdw->core.height);
    524 #endif
    525 return;
    526 }
    527 
    528 /* --Methode-- */
    529 void PIBaseWdgMac::Draw(int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/)
    530 {
    531 this->Draw();
    532 return;
    533 }
    534 
    535 /* --Methode-- */
    536 void PIBaseWdgMac::Draw()
    537 {
    538 #ifdef DEBUG_RZXB
    539 this->PIEraseWindow();
    540 this->PIDrawFBox(10,10, XSize()*2/3, YSize()*2/3);
    541 #endif
    542 return;
    543 }
    544 
    545 
     516   J'ai mis cette fonction ds PIWdgMac::IsVisible()    Reza $CHECK$  01/12/97
     517*/
     518
     519
  • trunk/SophyaPI/PI/pibwdgmac.h

    r61 r63  
    2727  virtual void       EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0);
    2828  virtual void       DrawString(int x, int y, char* s, int pos = 0);
     29  virtual void       DrawOpaqueString(int x, int y, char* s, int pos = 0);
    2930  virtual void       DrawLine(int x1, int y1, int x2, int y2);
    3031  virtual void       DrawBox(int x0, int y0, int dx, int dy);
     
    6162  virtual int        GetMarkerSize();
    6263
    63 //  Fonction qui doit etre appelee pour rafraichir (retracer) tout
    64   virtual void       Refresh();
    65 
    66 // Traitement des evenements   
    67   virtual void       Resize();
    68   virtual void       Draw();
    69   virtual void       Draw(int x0, int y0, int dx, int dy);
    70 
    7164
    7265protected:
  • trunk/SophyaPI/PI/pibwdgx.cc

    r61 r63  
    171171else
    172172XDrawString (XtDisplay (XtWdg()),XtWindow(XtWdg()),
     173                  DefGC(), x, y, s, strlen(s));
     174return;
     175}
     176
     177/* --Methode-- */
     178void PIBaseWdgX::DrawOpaqueString(int x, int y, char* s, int /*pos*/)
     179{
     180if(mPSOut){
     181mPSOut->DrawString((float)x,(float)y,s,mFCol,mFAtt,mFSize); /* $CHECK$ PIFontSize ?? */
     182}
     183else
     184XDrawImageString (XtDisplay (XtWdg()),XtWindow(XtWdg()),
    173185                  DefGC(), x, y, s, strlen(s));
    174186return;
     
    695707}
    696708
    697 /* --Methode-- */
    698 void PIBaseWdgX::Refresh()
    699 {
    700 if ( (XtIsRealized(XtWdg())) && 
    701    (((PIXtBaseWidget)(this->XtWdg()))->core.visible) )       
    702   { /* EraseWindow(); */ Draw(); }
    703 
    704 return;
    705 }
    706 
    707 
    708 /* --Methode-- */
    709 void PIBaseWdgX::Resize()
    710 {
    711 #ifdef DEBUG_PIBWDGX
    712 printf ("PIBaseWdgX::ReSize %ld %ld NewSize= %d %d\n",
    713          (long)(this), (long)(this->XtWdg()),
    714          (int)this->XtWdg()->core.width, (int)this->XtWdg()->core.height);
    715 #endif
    716 return;
    717 }
    718 
    719 /* --Methode-- */
    720 void PIBaseWdgX::Draw(int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/)
    721 {
    722 this->Draw();
    723 return;
    724 }
    725 
    726 /* --Methode-- */
    727 void PIBaseWdgX::Draw()
    728 {
    729 #ifdef DEBUG_PIBWDGX
    730 this->EraseWindow();
    731 this->DrawFBox(10,10, XSize()*2/3, YSize()*2/3);
    732 #endif
    733 CallDrawers(0,0,0,0);
    734 return;
    735 }
    736 
    737 
    738 /* --Methode-- */
    739 void PIBaseWdgX::Enter()
    740 {
    741 #ifdef DEBUG_PIBWDGX
    742 puts("PIBaseWdgX::Enter() enter notify ");
    743 #endif
    744 return;
    745 }
    746 
    747 /* --Methode-- */
    748 void PIBaseWdgX::Leave()
    749 {
    750 #ifdef DEBUG_PIBWDGX
    751 puts("PIBaseWdgX::Leave() leave notify ");
    752 #endif
    753 return;
    754 }
    755 
    756 
    757 /* --Methode-- */
    758 void PIBaseWdgX::But1Press(int, int)
    759 {
    760 #ifdef DEBUG_PIBWDGX
    761 printf ("PIBaseWdgX::But1Press PosX,Y= %d %d \n", x, y);
    762 #endif
    763 return;
    764 }
    765 
    766 /* --Methode-- */
    767 void PIBaseWdgX::But1Release(int, int)
    768 {
    769 Send(Msg(), PIMsg_Active);
    770 #ifdef DEBUG_PIBWDGX
    771 printf ("PIBaseWdgX::ButReleasePosX,Y= %d %d \n", x, y);
    772 #endif
    773 return;
    774 }
    775 
    776 /* --Methode-- */
    777 void PIBaseWdgX::But2Press(int /* x */, int /* y */)
    778 {
    779 return;
    780 }
    781 
    782 /* --Methode-- */
    783 void PIBaseWdgX::But2Release(int /* x */, int /* y */)
    784 {
    785 return;
    786 }
    787 
    788 /* --Methode-- */
    789 void PIBaseWdgX::But3Press(int /* x */, int /* y */)
    790 {
    791 return;
    792 }
    793 
    794 /* --Methode-- */
    795 void PIBaseWdgX::But3Release(int /* x */, int /* y */)
    796 {
    797 return;
    798 }
    799 
    800 
    801 /* --Methode-- */
    802 void PIBaseWdgX::Ptr1Move(int , int )
    803 {
    804 #ifdef DEBUG_PIBWDGX
    805 printf ("PIBaseWdgX::Ptr1Move PosX,Y= %d %d \n", x, y);
    806 #endif
    807 return;
    808 }
    809 
    810 /* --Methode-- */
    811 void PIBaseWdgX::Ptr2Move(int /* x */, int /* y */) 
    812 {
    813 return;
    814 }
    815 
    816 
    817 /* --Methode-- */
    818 void PIBaseWdgX::Ptr3Move(int /* x */, int /* y */) 
    819 {
    820 return;
    821 }
    822 
    823 /* --Methode-- */
    824 void PIBaseWdgX::Keyboard(int /*key*/, PIKeyModifier /*kmod*/)
    825 {
    826 
    827 #ifdef DEBUG_PIBWDGX
    828 printf("PIBaseWdgX::Keyboard: Key= %d (%c)  Mod= %d \n", key, (char)key, (int)kmod);
    829 XFlush(XtDisplay(this->XtWdg()));
    830 #endif
    831 return;
    832 }
    833709
    834710
  • trunk/SophyaPI/PI/pibwdgx.h

    r61 r63  
    2727  virtual void   EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0);
    2828  virtual void   DrawString(int x, int y, char* s, int pos = 0);
     29  virtual void   DrawOpaqueString(int x, int y, char* s, int pos = 0);
    2930  virtual void   DrawLine(int x1, int y1, int x2, int y2);
    3031  virtual void   DrawBox(int x0, int y0, int dx, int dy);
     
    7172  virtual void       SaveGraphicAtt();
    7273
    73 //  Fonction qui doit etre appelee pour rafraichir (retracer) tout
    74   virtual void   Refresh();
    75 
    76 // Traitement des evenements   
    77   virtual void   Resize();
    78   virtual void   Draw();
    79   virtual void   Draw(int x0, int y0, int dx, int dy);
    80 
    81   virtual void   Enter();
    82   virtual void   Leave(); 
    83   virtual void   But1Press(int x, int y);
    84   virtual void   But1Release(int x, int y);
    85   virtual void   But2Press(int x, int y);
    86   virtual void   But2Release(int x, int y);
    87   virtual void   But3Press(int x, int y);
    88   virtual void   But3Release(int x, int y);
    89   virtual void   Ptr1Move(int x, int y);
    90   virtual void   Ptr2Move(int x, int y);
    91   virtual void   Ptr3Move(int x, int y);
    92   virtual void   Keyboard(int key, PIKeyModifier kmod);
    93 
    94   inline  GC     DefGC() { return mDefGC; }
    9574
    9675protected:
     
    9877  void           Init();
    9978  void           SelectFont(int isz, int jat);
     79  inline  GC     DefGC() { return mDefGC; }
    10080
    10181  GC mDefGC;
  • trunk/SophyaPI/PI/picmap.cc

    r2 r63  
    11#include "picmap.h"
    22
     3#define  MXMAPIDS   10
     4static   int    MapNCols[MXMAPIDS] = {256, 256, 256, 256, 256, 256, 256, 256, 256, 256};
     5static   char*  MapNoms[MXMAPIDS]  = {"Grey32","InvGrey32","ColRJ32","ColBR32",
     6                               "ColRV32", "Grey128", "InvGrey128", "ColRJ128",
     7                               "ColBR128", "Col16"};
     8static   CMapId MapIds[MXMAPIDS] = { CMAP_GREY32, CMAP_GREYINV32, CMAP_COLRJ32,
     9                               CMAP_COLBR32, CMAP_COLRV32, CMAP_GREY128,
     10                               CMAP_GREYINV128, CMAP_COLRJ128, CMAP_COLBR128, 
     11                               CMAP_COL16 } ;
     12
     13static   int mColTNums[8192];   // Max 8192 tables differentes pour le moment 
     14static   int CTNum = 0;        //  Numero des tables ds mColTNum - s'incremente a chaque creation
     15
     16static   int NMaxTableAuto = 0;
     17static   PIColorMap* mMaps[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL };
     18
    319PIColorMap::PIColorMap(CMapId id)
    4 : PIColorMapNative(id)
    5 {
    6    if (!*maps) { // Il faut allouer les trois maps de depart
    7      maps[0] = new PIColorMap(CMAP_GREY32, 0);
    8      maps[1] = new PIColorMap(CMAP_GREYINV32, 0);
    9      maps[2] = new PIColorMap(CMAP_COLRJ32, 0);
     20: PIColorMapNative()
     21{
     22   int k, kdx;
     23   string mnom;
     24
     25   if (NMaxTableAuto == 0) { //  Il faut allouer les tables de depart
     26     if ( TotNbColors() > 2048 ) NMaxTableAuto = MXMAPIDS-1;
     27     else NMaxTableAuto = 3;
     28     for(k=0; k<NMaxTableAuto; k++)  {
     29        mnom = MapNoms[k];
     30        mMaps[k] = new PIColorMap(MapIds[k], MapNCols[k], mnom);
     31     }
    1032   }
    11    
    12    switch (id) {
    13      case CMAP_GREY32 :
    14        CopyFrom(maps[0]);
     33
     34//  Protection pour valeur de Id 
     35   for(kdx=0; kdx<MXMAPIDS; kdx++)  if (id == MapIds[kdx])  break;
     36   if (kdx == MXMAPIDS)  { id = MapIds[0];  kdx = 0; }
     37   for(k=0; k<NMaxTableAuto; k++) 
     38     if (id == mMaps[k]->Type()) {
     39       CopyFrom(mMaps[k]); 
     40       mCTId = mMaps[k]->mCTId;  mColTNums[mCTId]++;
    1541       break;
    16      case CMAP_GREYINV32 :
    17        CopyFrom(maps[1]);
    18        break;
    19      case CMAP_COLRJ32 :
    20        CopyFrom(maps[2]);
    21        break;
    22      default:
    23        if (!maps[3] || maps[3]->Type() != id) {
    24          if (maps[3])
    25            {
    26            maps[3]->FreeColors();
    27            delete maps[3];
    28            }
    29          maps[3] = new PIColorMap(id, 0);
     42     }
     43   if (Type() != id)  {  // Table pas encore trouve dans la liste
     44     k = NMaxTableAuto;
     45     if (!mMaps[k] || mMaps[k]->Type() != id) {
     46       if ( mMaps[k] ) { 
     47         mColTNums[mMaps[k]->mCTId] = 1;  // Je force a liberer les couleurs
     48         delete mMaps[k] ;
    3049       }
    31        CopyFrom(maps[3]);
     50       mnom = MapNoms[kdx];
     51       mMaps[k] = new PIColorMap(MapIds[kdx],  MapNCols[kdx], mnom);
     52     }
     53    CopyFrom(mMaps[k]); 
     54    mCTId = mMaps[k]->mCTId;  mColTNums[mCTId]++;
    3255   }
    3356}
     
    3558
    3659PIColorMap::PIColorMap(string const& nom, int nCol)
    37 : PIColorMapNative(nom, nCol)
     60: PIColorMapNative(CMAP_OTHER, nCol, nom)
    3861{
    3962  MakeColMap();
    40 }
    41 
    42 PIColorMap::PIColorMap(CMapId id, int i)      // Fait une veritable allocation
    43 : PIColorMapNative(id,i)
     63  mCTId = CTNum;
     64  mColTNums[mCTId] = 1;
     65  CTNum++;
     66}
     67
     68PIColorMap::PIColorMap(CMapId id, int nCol, string const& nom)
     69: PIColorMapNative(id, nCol, nom)
    4470{
    4571  MakeColMap();
     72  mCTId = CTNum;
     73  mColTNums[mCTId] = 1;
     74  CTNum++;
     75//  printf("PIColorMap/Debug-Creation:  %d %d - %s ", Type(), NCol(), Nom().c_str());
     76//  printf("  ..CRE.. %d %d \n", CTNum-1, mColTNums[CTNum-1]);
     77}
     78
     79PIColorMap::PIColorMap(PIColorMap& cm)
     80{
     81  CopyFrom(&cm);
     82  mCTId = cm.mCTId;
     83  mColTNums[mCTId]++;
    4684}
    4785
    4886PIColorMap::~PIColorMap()
    4987{
    50   if (mType == CMAP_OTHER)
    51     FreeColors();
    52 }
     88//  printf("PIColorMap/Debug-Delete:  %d %d - %s ", Type(), NCol(), Nom().c_str());
     89//  printf("...DEL.CTNum,mColTNums= %d %d (%d %d) ",
     90//        CTNum, mColTNums[CTNum], mCTId,mColTNums[mCTId] );
     91  mColTNums[mCTId]--;
     92  if ( mColTNums[mCTId] == 0 )  { FreeColors();  mColTNums[mCTId] = 0; }
     93  printf("\n");
     94}
     95
     96
     97
     98void PIColorMap::CleanColorMaps()
     99{
     100  int k;
     101  for(k=0; k<MXMAPIDS; k++)  {
     102    if (!mMaps[k])  continue;
     103    mMaps[k]->FreeColors();
     104    delete mMaps[k];
     105  }
     106}
     107
     108/*  Definition d' une table de couleurs  R G B   */
     109
     110static float R_RGB1[16] =
     111{0.0,0.00,0.0,0.0,0.0,0.00,0.0,0.6,0.8,1.0,1.00,1.0,0.75,1.0,0.85,1.0};
     112static float G_RGB1[16] =
     113{0.0,0.00,0.0,0.8,1.0,1.00,1.0,0.8,0.8,1.0,0.75,0.6,0.00,0.0,0.0,0.0};
     114static float B_RGB1[16] =
     115{0.0,0.75,1.0,1.0,1.0,0.75,0.0,0.0,0.0,0.0,0.00,0.5,0.75,1.0,0.0,0.0};
     116
     117
     118
     119void PIColorMap::MakeColMap()
     120{
     121  PIColor mycol;
     122  int i,j,k;
     123
     124  switch (mType) {
     125
     126    case CMAP_GREY32 :
     127      for(i=0; i<32; i++) {
     128        mycol.red = mycol.green = mycol.blue = 3535+(i*62000/32);
     129        for(k=0; k<8; k++)     AllocColor(mycol, i*8+k);
     130      }
     131      break;
     132   
     133
     134    case CMAP_GREYINV32 :
     135      for(i=0; i<32; i++) {
     136        mycol.red = mycol.green = mycol.blue = 3535+(i*62000/32);
     137        for(k=0; k<8; k++)     AllocColor(mycol, mNCol-(i*8+k)-1);
     138      }
     139      break;
     140
     141    case CMAP_COL16 :
     142      for(i=0; i<16; i++) {
     143        mycol.red = (int)(R_RGB1[i]*65535.);
     144        mycol.green = (int)(G_RGB1[i]*65535.);
     145        mycol.blue =(int)(B_RGB1[i]*65535.) ;
     146        for(k=0; k<16; k++)     AllocColor(mycol, i*16+k);
     147      }
     148      break;
     149
     150    case CMAP_COLRJ32 :
     151      for( i=0; i<32; i++) {
     152        if (i < 12)  {
     153          mycol.green = mycol.blue = 0; 
     154          mycol.red = 21535+(i*4000);  }
     155        else if (i < 24) {
     156          mycol.blue = 0;   mycol.red = 65535;
     157          mycol.green = 21535+(i-12)*4000;  }
     158        else {
     159          mycol.green = mycol.red = 65535;
     160          mycol.blue = 17535+(i-23)*6000; }
     161        for(k=0; k<8; k++)   AllocColor(mycol, i*8+k);
     162        }
     163      break;
     164
     165  case CMAP_COLBR32 :
     166    for( i=0; i<32; i++) {
     167      if (i < 5) {
     168        mycol.green = mycol.red = 0;    // Du bleu sombre au bleu clair
     169        mycol.blue = 5535+i*15000; }
     170      else if (i < 10) {
     171        mycol.blue = 65535;             // Plein bleu - On rajoute du vert -> bleu clair
     172        mycol.green = 5535+(i-5)*9000;
     173        mycol.red = 0;  }
     174      else if (i < 15) {
     175        mycol.blue = 60000-(i-10)*15000;   // On passe au vert
     176        mycol.green = 41535+(i-10)*6000;
     177        mycol.red = 0;  }
     178      else if (i < 21) {
     179        mycol.blue = 0;
     180        mycol.green = 65535;               // Plein vert, on rajoute du rouge -> jaune
     181        mycol.red = 5535+(i-15)*12000;  }
     182      else if (i < 27) { 
     183        mycol.blue = 0;                     //  On diminue vert -> Orange
     184        mycol.green = 60000-(i-21)*12000;
     185        mycol.red = 65535-(i-21)*2000;  }
     186      else {
     187        mycol.blue = 0;                     // Plein rouge
     188        mycol.green = 0;
     189        mycol.red = 57535+(i-27)*2000; }
     190
     191      for(k=0; k<8; k++)   AllocColor(mycol, i*8+k);
     192      }
     193    break;
     194
     195  case CMAP_COLRV32 :
     196    for( i=0; i<32; i++) {
     197      if (i < 8) {
     198        mycol.green = 15000+(i*5000); mycol.blue = 0; 
     199        mycol.red = 15000+(i*5000); }
     200      else if (i < 21) {
     201        mycol.green = 50000-(i-7)*5000;   
     202        if (mycol.green < 0)  mycol.green = 0;
     203        mycol.blue = 0;
     204        mycol.red = 53535+(i-8)*1000;  }
     205      else {
     206        mycol.green = 0;  mycol.red = 65535;
     207        mycol.blue = 15535+(i-21)*5000; }
     208
     209      for(k=0; k<8; k++)   AllocColor(mycol, i*8+k);
     210      }
     211    break;
     212
     213    case CMAP_GREY128 :
     214      for(i=0; i<128; i++) {
     215        mycol.red = mycol.green = mycol.blue = 2035+(i*500);
     216        for(k=0; k<2; k++)     AllocColor(mycol, i*2+k);
     217      }
     218      break;
     219   
     220
     221    case CMAP_GREYINV128 :
     222      for(i=0; i<128; i++) {
     223        mycol.red = mycol.green = mycol.blue = 2035+(i*500);
     224        for(k=0; k<2; k++)     AllocColor(mycol, mNCol-(i*2+k)-1);
     225      }
     226      break;
     227
     228    case CMAP_COLRJ128 :
     229      for( i=0; i<128; i++) {
     230        if (i < 48)  {
     231          mycol.green = mycol.blue = 0; 
     232          mycol.red = 5375+(i*1280);  }
     233        else if (i < 96) {
     234          mycol.blue = 0;   mycol.red = 65535;
     235          mycol.green = 5375+((i-48)*1280);  }
     236        else {
     237          mycol.green = mycol.red = 65535;
     238          mycol.blue = 3535+(i-96)*2000; }
     239        for(k=0; k<2; k++)   AllocColor(mycol, i*2+k);
     240        }
     241      break;
     242
     243    case CMAP_COLBR128 :
     244      for( i=0; i<128; i++) {
     245        if (i < 20) {
     246          mycol.green = mycol.red = 0;  // Du bleu sombre au bleu clair
     247          mycol.blue = 2835+i*3300; }
     248        else if (i < 36) {
     249          mycol.blue = 65535;           // Plein bleu - On rajoute du vert -> bleu clair
     250          mycol.green = 3000+(i-20)*2000;
     251          mycol.red = 0;  }
     252        else if (i < 56) {
     253          mycol.blue = 64600-(i-36)*3400;    // On passe au vert
     254          mycol.green = 32300+(i-36)*1700;
     255          mycol.red = 0;  }
     256        else if (i < 81) {         
     257          mycol.blue = 0;              // Plein vert, on rajoute du rouge -> jaune
     258          mycol.green = 65535;
     259          mycol.red = 3135+(i-56)*2600;  }
     260        else if (i < 96) {
     261          mycol.blue = 0;
     262          mycol.green = 63535-(i-80)*2000;
     263          mycol.red = 65535;  }
     264        else if (i < 112) {
     265          mycol.blue = 0;
     266          mycol.green = 30000-(i-96)*2000;
     267          mycol.red = 65535-(i-96)*1000;  }
     268        else {
     269          mycol.blue = 0;
     270          mycol.green = 0 ;
     271          mycol.red = 50535+(i-112)*1000; }
     272
     273        for(k=0; k<2; k++)   AllocColor(mycol, i*2+k);
     274      }
     275      break;
     276
     277  default :
     278    for(i=0; i<mNCol; i++) {
     279      mycol.green = mycol.red = mycol.blue = 0;
     280      AllocColor(mycol, i);
     281    }
     282    break;
     283  }
     284}
  • trunk/SophyaPI/PI/picmap.h

    r32 r63  
    55#include PICMAPNTV_H
    66
     7enum CMapId
     8 {
     9 CMAP_OTHER       = 0,
     10 CMAP_GREY32      = 1,     // 32 niveaux de gris                    * permanent
     11 CMAP_GREYINV32   = 2,     // 32 niveaux gris du blan au noir       * permanent
     12 CMAP_COLRJ32     = 3,     // 32 couleurs, du Rouge au Jaune/blanc  * permanent
     13 CMAP_COLBR32     = 4,     // 32 couleurs du bleu au rouge
     14 CMAP_COLRV32     = 5,     // 32 couleurs
     15 CMAP_GREY128     = 6,     // 128 couleurs  niveaux de gris
     16 CMAP_GREYINV128  = 7,     //    "     "      "      "
     17 CMAP_COLRJ128    = 8,     // 128 couleurs du rouge au jaune/blanc
     18 CMAP_COLBR128    = 9,     // 128 couleurs du bleu au rouge
     19 CMAP_COL16       = 10     // 16 Couleurs Arcenciel
     20 };
     21
    722
    823class PIColorMap : public PIColorMapNative {
     
    1025  PIColorMap(CMapId);
    1126  PIColorMap(string const& nom, int nCol);
     27  PIColorMap(PIColorMap&);
    1228  virtual ~PIColorMap();
     29
     30  static void CleanColorMaps();
     31
    1332protected:
    14   PIColorMap(CMapId id, int i);     // Fait une veritable allocation
     33  PIColorMap(CMapId id, int nc, string const& nom);  // Fait l'allocation des couleurs     
     34  void     MakeColMap();
     35
     36  int mCTId;    // Pour tenir trace de la derniere table qui doit liberer les couleurs
    1537};
    1638
  • trunk/SophyaPI/PI/picmapgen.cc

    r48 r63  
    88
    99
    10 PIColorMapGen* PIColorMapGen::maps[4] = {NULL,NULL,NULL,NULL};
     10PIColorMapGen::PIColorMapGen()
     11{
     12  mNom = "";
     13  mNCol = 0;
     14  mType = -1;
     15}
     16PIColorMapGen::PIColorMapGen(int id, int nc, string const& nom)
     17{
     18  mNom = nom;
     19  mNCol = nc;
     20  mType = id;
     21}
    1122
    12 int PIColorMapGen::nCols[6] = {32,32,32,32,32,16};
    13 char* PIColorMapGen::noms[6] = {"Grey32","InvGrey32","ColRJ32","ColBR32","ColRV32","Col16"};
    1423
    15 PIColorMapGen::PIColorMapGen(CMapId)
     24PIColorMapGen::~PIColorMapGen()
    1625{
    1726}
     
    2534
    2635
    27 PIColorMapGen::PIColorMapGen(string const& nom, int nCol)
    28 {
    29   mNom = nom;
    30   mNCol = nCol;
    31   mType = CMAP_OTHER;
    32 }
    33 
    34 PIColorMapGen::PIColorMapGen(CMapId id, int)
    35 {
    36   if (id < CMAP_GREY32 && id > CMAP_COL16)
    37      id = CMAP_GREY32; // BEUARK
    38   mNom = noms[id - 1];
    39   mNCol = nCols[id - 1];
    40   mType = id;
    41 }
    42 
    43 
    44 PIColorMapGen::~PIColorMapGen()
    45 {
    46 }
    47 
    48 /*  Definition d' une table de couleurs  R G B   */
    49 
    50 static float R_RGB1[16] =
    51 {0.0,0.00,0.0,0.0,0.0,0.00,0.0,0.6,0.8,1.0,1.00,1.0,0.75,1.0,0.85,1.0};
    52 static float G_RGB1[16] =
    53 {0.0,0.00,0.0,0.8,1.0,1.00,1.0,0.8,0.8,1.0,0.75,0.6,0.00,0.0,0.0,0.0};
    54 static float B_RGB1[16] =
    55 {0.0,0.75,1.0,1.0,1.0,0.75,0.0,0.0,0.0,0.0,0.00,0.5,0.75,1.0,0.0,0.0};
    56 
    57 
    58 
    59 void PIColorMapGen::MakeColMap()
    60 {
    61   PIColor mycol;
    62  
    63   switch (mType)
    64   {
    65   case CMAP_GREY32 :
    66     {for(int i=0; i<mNCol; i++)
    67       {
    68       mycol.red = mycol.green = mycol.blue = 3535+(i*62000/32);
    69       AllocColor(mycol, i);
    70       }
    71     break;
    72     }
    73   case CMAP_GREYINV32 :
    74     {for(int i=0; i<mNCol; i++)
    75       {
    76       mycol.red = mycol.green = mycol.blue = 65535-(i*62000/32);
    77       AllocColor(mycol, i);
    78       }
    79     break;
    80     }
    81   case CMAP_COL16 :
    82     {for(int i=0; i<mNCol; i++)
    83       {
    84       mycol.red = (int)(R_RGB1[i]*65535.);
    85       mycol.green = (int)(G_RGB1[i]*65535.);
    86       mycol.blue =(int)(B_RGB1[i]*65535.) ;
    87       AllocColor(mycol, i);
    88       }
    89     break;
    90     }
    91   case CMAP_COLRJ32 :
    92     {for(int i=0; i<mNCol; i++)
    93       {
    94       if (i < 12)
    95         { mycol.green = mycol.blue = 0; 
    96           mycol.red = 21535+(i*4000); }
    97       else if (i < 24)
    98         { mycol.blue = 0;   mycol.red = 65535;
    99           mycol.green = 21535+(i-12)*4000;  }
    100       else
    101         { mycol.green = mycol.red = 65535;
    102           mycol.blue = 17535+(i-23)*6000; }
    103 
    104       AllocColor(mycol, i);
    105       }
    106     break;
    107     }
    108   case CMAP_COLBR32 :
    109     {for(int i=0; i<mNCol; i++)
    110       {
    111       if (i < 5)
    112         { mycol.green = mycol.red = 0; 
    113           mycol.blue = 5535+i*15000; }
    114       else if (i < 10)
    115         { mycol.blue = 65535;
    116           mycol.green = 5535+(i-5)*9000;
    117           mycol.red = 0;  }
    118       else if (i < 15)
    119         { mycol.blue = 60000-(i-10)*15000;
    120           mycol.green = 41535+(i-10)*6000;
    121           mycol.red = 0;  }
    122       else if (i < 21)
    123         { mycol.blue = 0;
    124           mycol.green = 65535;
    125           mycol.red = 5535+(i-15)*12000;  }
    126       else if (i < 27)
    127         { mycol.blue = 0;
    128           mycol.green = 60000-(i-21)*12000;
    129           mycol.red = 65535-(i-21)*2000;  }
    130       else
    131         { mycol.blue = 0;
    132           mycol.green = 0;
    133           mycol.red = 57535+(i-27)*2000; }
    134 
    135       AllocColor(mycol, i);
    136       }
    137     break;
    138     }
    139   case CMAP_COLRV32 :
    140     {for(int i=0; i<mNCol; i++)
    141       {
    142       if (i < 8)
    143         { mycol.green = 15000+(i*5000); mycol.blue = 0; 
    144           mycol.red = 15000+(i*5000); }
    145       else if (i < 21)
    146         { mycol.green = 50000-(i-7)*5000;   
    147           if (mycol.green < 0)  mycol.green = 0;
    148           mycol.blue = 0;
    149           mycol.red = 53535+(i-8)*1000;  }
    150       else
    151         { mycol.green = 0;  mycol.red = 65535;
    152           mycol.blue = 15535+(i-21)*5000; }
    153 
    154       AllocColor(mycol, i);
    155       }
    156     break;
    157     }
    158   default :
    159     {for(int i=0; i<mNCol; i++)
    160       {
    161          mycol.green = mycol.red = mycol.blue = 0;
    162          AllocColor(mycol, i);
    163       }
    164     break;
    165     }
    166   }
    167 }
    168 
    169 
  • trunk/SophyaPI/PI/picmapgen.h

    r30 r63  
    66#include <string.h>
    77
    8 
    9 enum CMapId
    10  {
    11  CMAP_OTHER       = 0,
    12  CMAP_GREY32      = 1,     // 32 niveaux de gris                    * permanent
    13  CMAP_GREYINV32   = 2,     // 32 niveaux gris du blan au noir       * permanent
    14  CMAP_COLRJ32     = 3,     // 32 couleurs, du Rouge au Jaune/blanc  * permanent
    15  CMAP_COLBR32     = 4,     // 32 couleurs du bleu au rouge
    16  CMAP_COLRV32     = 5,     // 32 couleurs
    17  CMAP_COL16       = 6     // 16 Couleurs Arcenciel
    18  };
    19  
    208
    219 
     
    2816class PIColorMapGen {
    2917public:
    30   PIColorMapGen(CMapId);
    31   PIColorMapGen(string const& nom, int nCol);  // CMapId : CMAP_OTHER automatiquement
     18  PIColorMapGen(); 
     19  PIColorMapGen(int id, int nc, string const& nom); 
    3220  virtual ~PIColorMapGen();
    3321
    34   CMapId Type() const       {return mType;}
     22  int Type() const          {return mType;}
    3523  int NCol() const          {return mNCol;}
    3624  string const& Nom() const {return mNom;}
    3725
    3826  virtual PIColor GetColor(int n)=0;
    39   virtual void AllocColor(PIColor const& col, int index)=0;
     27  virtual bool AllocColor(PIColor const& col, int index)=0;
    4028  virtual void FreeColors()=0;     // Desalloue les couleurs
     29
     30  virtual int   TotNbColors()=0;    // Donne le nombre total de couleurs disponibles
     31  virtual int   NbAllocColors()=0;  // Nb de couleurs deja allouees
    4132protected:
    42   PIColorMapGen(CMapId, int);      // Fait une veritable allocation
    43   virtual void MakeColMap();       // Alloue la table de couleurs en appelant AllocColor
    4433  void CopyFromGen(PIColorMapGen*);
    4534  virtual void CopyFrom(PIColorMapGen*)=0;
    4635 
    47   static int nCols[6];
    48   static char* noms[6];
    49  
    50   static PIColorMapGen* maps[4];
    5136
    5237  int    mNCol;
    53   CMapId mType;
     38  int    mType;
    5439  string mNom;
    5540 
  • trunk/SophyaPI/PI/picmapmac.cc

    r34 r63  
    6666}
    6767
    68 void PIColorMapMac::AllocColor(PIColor const& col, int index)
     68
     69bool PIColorMapMac::AllocColor(PIColor const& col, int index)
    6970{
    7071  ColorSpec& sp = (**mCTab).ctTable[index+2];
     
    7374  sp.rgb.blue  = col.blue;
    7475  sp.value     = index+2;
     76  return true;    //  $CHECK$  retourne true si OK - Reza 01/12/97
    7577}
    7678
  • trunk/SophyaPI/PI/picmapmac.h

    r34 r63  
    1313  PIColorMapMac(string const& nom, int nCol);
    1414  virtual PIColor GetColor(int n);
    15   virtual void AllocColor(PIColor const& col, int index);
     15  virtual bool AllocColor(PIColor const& col, int index);   // $CHECK$  Reza 01/12/97(Modif)
    1616  virtual void FreeColors();
    1717  virtual void MakeColMap();
     18  virtual int  TotNbColor();         // A faire   $CHECK$  Reza 01/12/97
     19  virtual int  NbAllocColors();      // A faire       "    "     "
    1820protected:
    1921  PIColorMapMac(CMapId id, int i);      // Fait une veritable allocation
  • trunk/SophyaPI/PI/picmapx.cc

    r40 r63  
    99
    1010/* --Methode-- */
    11 PIColorMapX::PIColorMapX(CMapId id)
    12 : PIColorMapGen(id)
     11PIColorMapX::PIColorMapX()   
     12: PIColorMapGen()
    1313{
    14 int n = nCols[id-1];
    15 mColors = new PIXColor[n];
    16 mColRGB = new PIColor[n];
    17 for(int i=0; i<n; i++) 
    18   { mColors[i] = BlackPixel(PIXDisplay(), PIXScreen());
    19   mColRGB[i].red = mColRGB[i].green = mColRGB[i].blue = 0; }
    20 
    21 // printf("PIColorMapX::PIColorMapX(CMapId) %d %d \n", mNCol, Type());
    22 return;
     14mColors = NULL;
     15mColRGB = NULL;
    2316}
    2417
    2518/* --Methode-- */
    26 PIColorMapX::PIColorMapX(CMapId id, int i)       // Fait une veritable allocation
    27 : PIColorMapGen(id,i)
     19PIColorMapX::PIColorMapX(int id, int nc, string const& nom)   
     20: PIColorMapGen(id, nc, nom)
    2821{
    2922
    30 int n = nCols[id-1];
     23int n = nc;
    3124mColors = new PIXColor[n];
    3225mColRGB = new PIColor[n];
     
    4134
    4235/* --Methode-- */
    43 PIColorMapX::PIColorMapX(string const& nom, int nCol)
    44 : PIColorMapGen(nom, nCol)
    45 {
    46 
    47 int n = nCol;
    48 mColors = new PIXColor[n];
    49 mColRGB = new PIColor[n];
    50 for(int i=0; i<n; i++) 
    51   { mColors[i] = BlackPixel(PIXDisplay(), PIXScreen());
    52   mColRGB[i].red = mColRGB[i].green = mColRGB[i].blue = 0; }
    53 // printf("PIColorMapX::PIColorMapX(nom, nCol) %d %d \n", mNCol, Type());
    54 
    55 return;
    56 
    57 }
    58 
    59 /* --Methode-- */
    6036PIColorMapX::~PIColorMapX()
    6137{
    62 delete[] mColors;
    63 delete[] mColRGB;
     38if (mColors)  delete[] mColors;
     39if (mColRGB)  delete[] mColRGB;
    6440}
    6541
     
    8258static  Colormap  defxcmap;
    8359static  xinicmap = 0;
     60static int NTotColors = 0;
     61static int NTotAllocCol = 0;
    8462
    8563/* --Methode-- */
    86 void PIColorMapX::AllocColor(PIColor const& col, int index)
     64bool PIColorMapX::AllocColor(PIColor const& col, int index)
    8765{
    8866XColor myxcol;
     
    9472  }
    9573
    96 if ( (index < 0) || (index > mNCol) )  return;
     74if ( (index < 0) || (index > mNCol) )  return(false);
    9775
    9876if ( (col.red == 0) && (col.green == 0) && (col.blue == 0) )
     
    10078  mColors[index] = BlackPixel(PIXDisplay(), PIXScreen());
    10179  mColRGB[index] = col;
    102   return;
     80  return(true);
    10381  }
    10482
     
    10886
    10987
    110 if ( XAllocColor(PIXDisplay(), defxcmap, &myxcol) )
    111   {
     88if ( XAllocColor(PIXDisplay(), defxcmap, &myxcol) ) {
    11289  mColors[index] = myxcol.pixel;
    11390  mColRGB[index] = col;
    11491//  printf("PIColorMapX::AllocColor()  RGB= %d %d %d \n",
    11592//         (int) col.red, (int) col.blue, (int) col.green);
     93  NTotAllocCol++; 
     94  return(true);
    11695  }
    117 else  
     96else {
    11897  printf("PIColorMapX::AllocColor() Error: Pb Allocation RGB= %d %d %d \n",
    11998         (int) col.red, (int) col.blue, (int) col.green);
    120 return;
     99  return(false);
     100  }
    121101}
    122102
     
    153133}
    154134
     135
     136/* --Methode-- */
     137int PIColorMapX::TotNbColors()
     138{
     139if (NTotColors > 0)  return(NTotColors);
     140Visual* vis;
     141// DefaultVisual(PIXDisplay(),  PIXScreen() );
     142int k,kk;
     143// On calcule le nombre de couleurs a partir du nb de plans image
     144kk = DefaultDepth(PIXDisplay(),  PIXScreen() );
     145NTotColors = 1;
     146for(k=0; k<kk; k++) NTotColors *= 2;
     147/*
     148 printf("PIColorMapX::TotNbColor() / Debug : Nb Tot Colors = %d - D=%d - NCol=%d NP= %d \n", NTotColors,
     149 DefaultDepth(PIXDisplay(),  PIXScreen()),
     150 DisplayCells(PIXDisplay(),  PIXScreen()),
     151 DisplayPlanes(PIXDisplay(),  PIXScreen()) );
     152*/
     153return(NTotColors);
     154}
     155
     156/* --Methode-- */
     157int PIColorMapX::NbAllocColors()
     158{
     159return(NTotAllocCol);
     160}
     161
     162
    155163/* --Methode-- */
    156164void PIColorMapX::CopyFrom(PIColorMapGen* x)
    157165{
     166  if (mColors)  delete mColors;
     167  if (mColRGB)  delete mColRGB;
    158168  CopyFromGen(x);
     169  mColors = new PIXColor[mNCol];
     170  mColRGB = new PIColor[mNCol];
    159171  for (int i=0; i<mNCol; i++) 
    160172    { mColors[i] = ((PIColorMapX *)x)->mColors[i];
  • trunk/SophyaPI/PI/picmapx.h

    r30 r63  
    99class PIColorMapX : public PIColorMapGen {
    1010public:
    11   friend class PIColorMapGen;
    12   friend class PIPixmapX;
    13 
    14   PIColorMapX(CMapId);
    15   PIColorMapX(string const& nom, int nCol);
     11  PIColorMapX(); 
     12  PIColorMapX(int id, int nc, string const& nom); 
     13  virtual ~PIColorMapX();
    1614
    1715  inline PIXColor  Color(int index)
     
    1917
    2018  virtual PIColor GetColor(int n);
    21   virtual void AllocColor(PIColor const& col, int index);
     19  virtual bool AllocColor(PIColor const& col, int index);
    2220  virtual void FreeColors();
    23 //  virtual void MakeColMap();
     21
     22  virtual int  TotNbColors();
     23  virtual int  NbAllocColors();
     24
    2425protected:
    25   PIColorMapX(CMapId id, int i);      // Fait une veritable allocation
    26   void CopyFrom(PIColorMapGen*);
     26  virtual void CopyFrom(PIColorMapGen*);
    2727 
    2828  PIXColor  * mColors;     // La table des couleurs ...
  • trunk/SophyaPI/PI/pipixmapgen.cc

    r61 r63  
    5353void PIPixmapGen::SetColMap(CMapId cmapid, bool refr)
    5454{
    55 if (cmap) delete cmap;
    56 cmap = new PIColorMap(cmapid);
     55if (!cmap || (cmap->Type() != cmapid) || (cmapid == CMAP_OTHER) ) { 
     56  if (cmap) delete cmap;
     57  cmap = new PIColorMap(cmapid);
     58}
    5759if (refr)  Refresh(); 
    5860}
  • trunk/SophyaPI/PI/pipixmapgen.h

    r48 r63  
    2929                          bool refr=true, int ox=0, int oy=0);
    3030  void          SetColMap(CMapId cmapid, bool refr=true);
    31   inline CMapId GetColMapId() { return (cmap->Type()); };
     31  inline CMapId GetColMapId() { return ((CMapId)cmap->Type()); };
    3232  inline int    NbCol() { return(cmap->NCol()); };
    3333
  • trunk/SophyaPI/PI/piscdrawwdg.cc

    r61 r63  
    168168  DrawSelf(-9.e19, -9.e19, 9.e19, 9.e19);
    169169  CallScDrawers(-9.e19, -9.e19, 9.e19, 9.e19);
    170   CallDrawers(0,0,0,0);
    171170}
    172171
  • trunk/SophyaPI/PI/piwdggen.h

    r52 r63  
    1111void PIBeep();
    1212
    13 // Les differents types d'accrochage aux containers 
     13// Les differents types d accrochage aux containers 
    1414
    1515enum PIBindingKind {   
     
    6262  virtual void           Manage()=0;
    6363  virtual void           UnManage()=0;
    64   virtual int            IfManaged()=0;
     64  virtual bool           IfManaged()=0;
     65  virtual bool           IsVisible()=0;
    6566
    6667  virtual void           PSPrint(PSFile *psf, int ofx=0, int ofy=0);
     68
     69//  Gestion de copier-coller
     70  virtual bool           ClaimSelection()=0;
     71  virtual void           LoseSelection()=0;
     72  virtual void           RequestSelection()=0;
     73  virtual void           CopyFromSelection(char *, int l)=0;
     74  virtual char*          SelectionString(int& len)=0;
    6775
    6876protected:
  • trunk/SophyaPI/PI/piwdgmac.cc

    r23 r63  
    125125}
    126126
     127
     128bool
     129PIWdgMac::IsVisible()    // $CHECK$  REZA a verifier  01/12/97
     130{
     131if (mPane->IsVisible())  return(true);
     132else return(false);
     133}
  • trunk/SophyaPI/PI/piwdgmac.h

    r23 r63  
    2727  virtual int            YPos();
    2828  virtual string         Nom()  { return mNom; }
     29
     30  virtual void           Manage();
     31  virtual void           UnManage();
     32  virtual bool           IfManaged();
     33  virtual bool           IsVisible();
     34
    2935protected:
    3036  LPane*                                 mPane;
  • trunk/SophyaPI/PI/piwdgx.cc

    r60 r63  
    8080sdw = top;
    8181wmis =  k_wmi_appshell;
    82 stmng = 0;
     82stmng = false;
    8383#ifdef DEBUG_PIWdgX
    8484printf("Debug_PIWdgX::PIWdgX(int , char * [])  this=%lx  top=%lx \n", (long)this, (long)sdw);
     
    142142else wmis = k_wmi_normal ;
    143143
    144 stmng = 0;
     144stmng = false;
    145145#ifdef DEBUG_PIWdgX
    146146printf("Debug_PIWdgX::CreateXtWdg(%s) this=%lx sdw=%lx pere=%lx wmis=%d\n", nom,
     
    182182if (wmis != k_wmi_appshell)  XtManageChild(sdw);
    183183else if (!XtIsRealized(sdw))  XtRealizeWidget(sdw); 
    184 stmng = 1;
     184stmng = true;
    185185return;
    186186}
     
    195195if (wmis != k_wmi_appshell)
    196196  XtUnmanageChild(sdw);
    197 stmng = 0;
    198 return;
    199 }
    200 
    201 /* --Methode-- */
    202 int PIWdgX::IfManaged()
     197stmng = false;
     198return;
     199}
     200
     201/* --Methode-- */
     202bool PIWdgX::IfManaged()
    203203{
    204204return(stmng);
     205}
     206
     207/* --Methode-- */
     208bool PIWdgX::IsVisible()
     209{
     210if ( (XtIsRealized(XtWdg())) && 
     211   ( (this->XtWdg())->core.visible) )  return(true);
     212else return(false);       
    205213}
    206214
     
    468476return(0);
    469477}
     478
     479
     480static Boolean forXt_ConvertSelection(Widget w, Atom* sel, Atom *targ, Atom* typ,
     481                                   XtPointer* value, unsigned long* len, int* format);
     482
     483static void forXt_LoseSelection(Widget w, Atom* sel);
     484static void forXt_DoneSelection(Widget w, Atom* sel, Atom *targ);
     485static void forXt_SelectionValue(Widget w, XtPointer usd, Atom* sel, Atom* typ,
     486                                 XtPointer value, unsigned long* len, int* format );
     487
     488static PIWdgX* curselwdg = NULL;
     489static char* selval = NULL;
     490
     491
     492/* Nouvelle-Fonction */
     493Boolean forXt_ConvertSelection(Widget w, Atom* sel, Atom *targ, Atom* typ,
     494                                   XtPointer* value, unsigned long* len, int* format)
     495{
     496if (*targ != XA_STRING)  return(FALSE);
     497if (!curselwdg)  return(FALSE);
     498int l;
     499*value = curselwdg->SelectionString(l);
     500*len=l;
     501*typ = XA_STRING;
     502*format = 8;
     503return(TRUE);
     504}
     505
     506/* Nouvelle-Fonction */
     507void forXt_LoseSelection(Widget w, Atom* sel)
     508{
     509if (curselwdg)  curselwdg->LoseSelection();
     510curselwdg = NULL;
     511}
     512
     513/* Nouvelle-Fonction */
     514void forXt_DoneSelection(Widget w, Atom* sel, Atom *targ)
     515{
     516if (selval)   delete selval;
     517selval = NULL;
     518}
     519
     520/* Nouvelle-Fonction */
     521void forXt_SelectionValue(Widget w, XtPointer usd, Atom* sel, Atom* typ,
     522                                 XtPointer value, unsigned long* len, int* format )
     523{
     524printf("forXt_SelectionValue()/Debug: %lx %lx - %lx - %d \n", (unsigned long)w,
     525       (unsigned long)usd, (unsigned long)value, (*len));
     526if ( (value != NULL) && (*len > 0) )
     527  ((PIWdgX*)usd)->CopyFromSelection((char*)value, (*len)) ;
     528}
     529
     530
     531
     532// Gestion de Copier/Coller
     533/* --Methode-- */
     534bool PIWdgX::ClaimSelection()
     535{
     536if (XtOwnSelection(XtWdg(), XA_PRIMARY, PIXGetLastEventTime(), forXt_ConvertSelection,
     537                   forXt_LoseSelection, forXt_DoneSelection) ) {
     538  printf("PIWdgX::ClaimSelection() - OK  (Wdg= %lx)\n", (unsigned long)this);
     539  curselwdg = this;
     540  return (true);
     541}
     542else {
     543  printf("PIWdgX::ClaimSelection() - Probleme (Wdg= %lx)\n", (unsigned long)this);
     544  curselwdg = NULL;
     545  return (false);
     546}
     547}
     548
     549/* --Methode-- */
     550void PIWdgX::LoseSelection()
     551{
     552  printf("PIWdgX::LoseSelection()  Ne fait rien !(Wdg= %lx - %lx) \n",
     553        (unsigned long)this, (unsigned long)curselwdg);
     554  if (curselwdg == this)  curselwdg = NULL;
     555}
     556
     557/* --Methode-- */
     558void PIWdgX::RequestSelection()
     559{
     560printf("PIWdgX::RequestSelection() (Wdg= %lx - %lx) \n",
     561        (unsigned long)this, (unsigned long)curselwdg);
     562XtGetSelectionValue(XtWdg(), XA_PRIMARY, XA_STRING, forXt_SelectionValue,
     563                    (XtPointer)this, PIXGetLastEventTime());
     564}
     565
     566/* --Methode-- */
     567void PIWdgX::CopyFromSelection(char * sv, int l)
     568{
     569char* buff = new char[l+2];
     570strncpy(buff, sv, l);
     571buff[l] = '\0';
     572printf("PIWdgX::RequestSelection() L=%d [%s] \n", l, buff);
     573delete buff;
     574return;
     575}
     576
     577/* --Methode-- */
     578char* PIWdgX::SelectionString(int& len)
     579{
     580char *rs = new char[60];
     581strcpy(rs, "Test-of-PIWdgX::SelectionString()");
     582len = strlen(rs);
     583return(rs);
     584}
  • trunk/SophyaPI/PI/piwdgx.h

    r52 r63  
    5252  virtual void   Manage();
    5353  virtual void   UnManage();
    54   virtual int    IfManaged();
     54  virtual bool   IfManaged();
     55  virtual bool   IsVisible();
     56
     57//  Gestion de copier-coller
     58  virtual bool           ClaimSelection();
     59  virtual void           LoseSelection();
     60  virtual void           RequestSelection();
     61  virtual void           CopyFromSelection(char *, int l);
     62  virtual char*          SelectionString(int& len);
    5563
    5664  inline SysDWdg XtWdg() const {return(sdw); };
     
    6371  SysDWdg sdw;
    6472  WmIntState wmis;
    65   int stmng;
     73  bool stmng;
    6674 
    6775};
  • trunk/SophyaPI/PI/pixtbase.cc

    r61 r63  
    188188  dx = xrec.width;  dy = xrec.height;
    189189  (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Draw(x0, y0, dx, dy);
     190  (((PIXtBaseWidget)wdgp)->pixtbase.objet)->CallDrawers(x0, y0, dx, dy);
    190191  }
    191192return;
Note: See TracChangeset for help on using the changeset viewer.