Changeset 2528 in Sophya for trunk/SophyaPI


Ignore:
Timestamp:
Apr 27, 2004, 5:48:48 PM (21 years ago)
Author:
ansari
Message:

1/ Petites ameliorations de la gestion des differents attributs des
Drawers ajoutes aux PIBaseWdg.
2/ Ajout classes PIDrwMgrMenu (ds pidrwtools.h .cc) - Menu de manipulation
interactive des drawers accroches aux PIBaseWdg + classe EventHandler
PIDrwPosSizeEvH ds pidrwtools.cc pour Chgt Taille/Pos des drawers
3/ Activation du menu PIDrwMgrMenu ds PIScDrawWdg

Reza - 27 Avril 2004

Location:
trunk/SophyaPI/PI
Files:
10 edited

Legend:

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

    r2399 r2528  
    6161// long  kind()
    6262//      Renvoie le type de l'objet ("=PIDraw3DWdg::ClassId")
    63 // int AddDrawer3D(PIDrawer3D*, bool ad=false)
    64 //      Ajoute un Drawer3D
     63// int AddDrawer3D(PIDrawer3D*, bool ad=false, bool lock=false)
     64//      Ajoute un Drawer3D. Voir *PIBaseWdg::AddDrawer()* pour les flags "ad,lock".
    6565//--
    6666
     
    7979  //  AddDrawer(mBDrw, 0.12, 0.12, 0.88, 0.88, true, false, false);
    8080  mBDrw->SetLimits(0.,1.,0.,1.,kAxeDirLtoR,kAxeDirDownUp);
    81   AddDrawer3D(mBDrw, false);
     81  AddDrawer3D(mBDrw, false, true);
    8282  mBDrw->SetAxesFlags(kStdAxes);
    8383  vfixed = false; // Il faut laisser le premier Drawer3D fixer les limites et la vue 3D
     
    204204
    205205/* --Methode-- */
    206 int PIDraw3DWdg::AddDrawer3D(PIDrawer3D* dr3, bool ad)
     206int PIDraw3DWdg::AddDrawer3D(PIDrawer3D* dr3, bool ad, bool lock)
    207207{
    208208if ((!vfixed) && (dr3 != mBDrw))  {
     
    221221  else  dr3->Set3DView(xc, yc, zc, xo, yo, zo, dax, day, co, psi);
    222222  }
    223 int id = AddDrawer(dr3, false, false, ad);
     223int id = AddDrawer(dr3, false, false, ad, lock);
    224224if (dr3 != mBDrw) dr3->SetAxesFlags(kAxesNone);
    225225m3DrIl.push_back(id);
  • trunk/SophyaPI/PI/pi3dwdg.h

    r2164 r2528  
    4646
    4747// Ajoute un Drawer
    48   int                   AddDrawer3D(PIDrawer3D*, bool ad=false);   
     48  int                   AddDrawer3D(PIDrawer3D*, bool ad=false, bool lock=false);   
    4949
    5050//  Pour tenir trace des Drawers-3D qui sont detruits
  • trunk/SophyaPI/PI/pibwdggen.cc

    r2527 r2528  
    306306//--
    307307//++
    308 // void  SetDefaultDrawRectangle(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, bool psz=true)
     308// void  SetDefaultDrawRectangle(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, bool elastic=true)
    309309//      Définition du rectangle d'attachement par défaut. "(x1,y1)" et "(x2,y2)" determinent
    310310//      les positions des deux coins opposés.
    311 //      si "psz=true", les coordonnées sont supposées être des facteurs multiplicatifs
     311//      si "elastic=true", les coordonnées sont supposées être des facteurs multiplicatifs
    312312//      des dimensions de l'objet.
     313// void  GetDefaultDrawRectangle(PIGrCoord& x1, PIGrCoord& y1, PIGrCoord& x2, PIGrCoord& y2, bool& elastic)
     314//      Retourne le rectangle d'attachement par défaut. "(x1,y1)" et "(x2,y2)" determinent
     315//      les positions des deux coins opposés."elastic=true": Pos/Taille spécifiées en fraction
     316//      de la taille du PIBaseWdg.
    313317// void  SetDefaultDrawerLimits(double xmin, double xmax, double ymin, double ymax, -
    314318//                              int axrl=kAxeDirSame, int ayud=kAxeDirSame)
     
    322326
    323327/* --Methode-- */
    324 void PIBaseWdgGen::SetDefaultDrawRectangle(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, bool psz)
     328void PIBaseWdgGen::SetDefaultDrawRectangle(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, bool elastic)
    325329{
    326330mDrX1 = x1;  mDrY1 = y1;
    327 mDrX2 = x2;  mDrY2 = y2;   mDrElastic = psz;
     331mDrX2 = x2;  mDrY2 = y2;   mDrElastic = elastic;
     332}
     333
     334/* --Methode-- */
     335void PIBaseWdgGen::GetDefaultDrawRectangle(PIGrCoord& x1, PIGrCoord& y1, PIGrCoord& x2, PIGrCoord& y2, bool& elastic)
     336{
     337x1 = mDrX1;  y1 = mDrY1;
     338x2 = mDrX2;  y2 = mDrY2;   elastic = mDrElastic;
    328339}
    329340
     
    347358//++
    348359// int  AddDrawer(PIDrawer* drw, PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, -
    349 //                bool psz=true, bool clip=true, bool ad=false)
     360//                bool psz=true, bool clip=true, bool ad=false, bool lock=false)
    350361//      Attachement d'un "PIDrawer" au rectangle défini les coordonnées des deux coins opposés.
    351362//      si "psz=true", les coordonnées sont supposées être des facteurs multiplicatifs
     
    354365//      d'attachement.
    355366//      si "ad=true", le "PIDrawer* drw" est détruit lors de la destruction de l'objet PIBaseWdg.
     367//      si "lock=true", le drawer ne peut être détaché suite à une requête interactive.
    356368//      La méthode retourne l'identificateur du drawer attaché.
    357 // int  AddDrawer(PIDrawer* drw, bool autolim=false, bool clip=true, bool ad=false)
     369// int  AddDrawer(PIDrawer* drw, bool autolim=false, bool clip=true, bool ad=false, bool lock=false)
    358370//      Ajout d'un "PIDrawer" au rectangle d'attachement par défaut.
    359371//      Si "autolim=true", l'objet "PIBaseWdg" impose l'espace de coordonnées utilisateur
     
    362374//      d'attachement.
    363375//      si "ad=true", le "PIDrawer* drw" est détruit lors de la destruction de l'objet PIBaseWdg.
     376//      si "lock=true", le drawer ne peut être détaché suite à une requête interactive.
    364377//      La méthode retourne l'identificateur du drawer attaché.
    365378//--
     
    367380/* --Methode-- */
    368381int PIBaseWdgGen::AddDrawer(PIDrawer* drw, PIGrCoord x1, PIGrCoord y1, 
    369                             PIGrCoord x2, PIGrCoord y2, bool psz, bool clip, bool ad)
     382                            PIGrCoord x2, PIGrCoord y2, bool psz, bool clip, bool ad, bool lock)
    370383{
    371384if (drw == NULL)   return(0);
     
    377390did.elastic = psz;  did.clip = clip;
    378391did.id = mDrwId;  did.ad = ad;
     392did.lock = lock;
    379393did.drw = drw;
    380394mDrwList.push_back(did);
     
    385399
    386400/* --Methode-- */
    387 int PIBaseWdgGen::AddDrawer(PIDrawer* drw, bool autolim, bool clip, bool ad)
     401int PIBaseWdgGen::AddDrawer(PIDrawer* drw, bool autolim, bool clip, bool ad, bool lock)
    388402{
    389403if (drw == NULL)   return(0);
     
    394408did.autoszp = true;   did.autolim = autolim;   
    395409did.elastic = false;   did.clip = clip;
    396 did.id = mDrwId;  did.ad = ad;
     410did.id = mDrwId;  did.ad = ad;
     411did.lock = lock;
    397412did.drw = drw;
    398413mDrwList.push_back(did);
     
    404419
    405420//++
    406 // void  MoveResizeDrawer(int id, PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, bool psz=true)
     421// void  MoveResizeDrawer(int id, PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, bool elastic=true)
    407422//      Modification du rectangle d'attachement du PIDrawer avec l'identificateur "id" , retourné
    408 //      par "AddDrawer()"
     423//      par "AddDrawer()". Si "elatic=true", taille/pos spécifiée en fraction de la taille du PIBaseWdg.
    409424// void  RemoveDrawer(int id)
    410 //      Ote le drawer "id" de la liste.
     425//      Ote le drawer "id" de la liste des drawers du PIBaseWdg.
    411426// void  DeleteDrawers()
    412427//      Ote tous les drawers de la liste. Détruit ceux ajoutés avec l'option "ad=true"
     
    414429
    415430/* --Methode-- */
    416 void PIBaseWdgGen::MoveResizeDrawer(int id,  PIGrCoord x1, PIGrCoord y1,  PIGrCoord x2, PIGrCoord y2, bool psz)
     431void PIBaseWdgGen::MoveResizeDrawer(int id,  PIGrCoord x1, PIGrCoord y1,  PIGrCoord x2, PIGrCoord y2, bool elastic)
    417432{
    418433vector<BWDrwId>::iterator it;
     
    421436    (*it).x1 = x1;  (*it).y1 = y1;
    422437    (*it).x2 = x2;  (*it).y2 = y2;
    423     (*it).elastic = psz;
     438    (*it).elastic = elastic;
    424439    break;
    425440  }
     
    462477//      Retourne le nombre de PIDrawer attachés
    463478// PIDrawer*  GetDrawerId(int id)
    464 //      Retourne le PIDrawer avec l'identificateur id
     479//      Retourne le PIDrawer avec l'identificateur "id".
    465480// PIDrawer*  GetDrawer(int n)
    466481//      Retourne le PIDrawer "n=0..NbDrawers()-1" de la liste
    467 //--
    468 
    469 /* --Methode-- */
    470 int PIBaseWdgGen::NbDrawers()
    471 {
    472 return(mDrwList.size());
     482// int  GetDrawerIdFromNum(int n)
     483//      Retourne l'identificateur du drawer numero "n=0..NbDrawers()-1".
     484// bool IsDrawerLockedId(int id)
     485//      Retourne le flag "lock" pour le PIDrawer avec l'identificateur "id".
     486//      si "true", le drawer ne doit être détaché suite à une requête interactive.
     487// bool IsDrawerAutoSizePos(int id)
     488//      Retourne "true" si le  PIDrawer (Identificateur= "id") est positionné
     489//      dans le rectangle par défaut.
     490// void GetDrawerPosition(int id, PIGrCoord& x1, PIGrCoord& y1, PIGrCoord& x2, PIGrCoord& y2, bool& elastic)
     491//      Retourne le rectangle d'attachement du PIDrawer avec l'identificateur "id".
     492//      "elastic=true": position et taille spécifiées en fraction de la taille du PIBaseWdg.
     493//--
     494
     495/* --Methode-- */
     496int PIBaseWdgGen::GetDrawerIdFromNum(int n)
     497{
     498if ( (n < 0) || (n >= mDrwList.size()) ) return(-1);
     499return(mDrwList[n].id);
    473500}
    474501
     
    490517}
    491518
     519/* --Methode-- */
     520bool PIBaseWdgGen::IsDrawerLockedId(int id)
     521{
     522vector<BWDrwId>::iterator it;
     523for(it = mDrwList.begin(); it != mDrwList.end(); it++) 
     524  if ((*it).id == id)  return((*it).lock);
     525return true;
     526}
     527
     528/* --Methode-- */
     529bool PIBaseWdgGen::IsDrawerAutoSizePos(int id)
     530{
     531vector<BWDrwId>::iterator it;
     532for(it = mDrwList.begin(); it != mDrwList.end(); it++) 
     533  if ((*it).id == id)  return(! (*it).autoszp );
     534return false;
     535}
     536
     537/* --Methode-- */
     538void PIBaseWdgGen::GetDrawerPosition(int id, PIGrCoord& x1, PIGrCoord& y1,
     539                                     PIGrCoord& x2, PIGrCoord& y2, bool& elastic)
     540{
     541x1 = y1 = x2 = y2 = 0;
     542elastic = false;
     543vector<BWDrwId>::iterator it;
     544for(it = mDrwList.begin(); it != mDrwList.end(); it++) 
     545  if ((*it).id == id) {
     546    x1 = (*it).x1;  y1 = (*it).y1;
     547    x2 = (*it).x2;  y2 = (*it).y2;
     548    elastic = (*it).elastic;
     549    break;
     550  }
     551return;
     552}
    492553
    493554//++
  • trunk/SophyaPI/PI/pibwdggen.h

    r2503 r2528  
    8080  virtual void       SetDefaultDrawRectangle(PIGrCoord x1, PIGrCoord y1,
    8181                                             PIGrCoord x2, PIGrCoord y2, bool psz=true);
     82  virtual void       GetDefaultDrawRectangle(PIGrCoord& x1, PIGrCoord& y1,
     83                                             PIGrCoord& x2, PIGrCoord& y2, bool& psz);
    8284  virtual void       SetDefaultDrawerLimits(double xmin, double xmax, double ymin, double ymax,
    8385                                            int axrl=kAxeDirSame, int ayud=kAxeDirSame);
     
    8890  virtual int        AddDrawer(PIDrawer* drw, PIGrCoord x1, PIGrCoord y1,
    8991                               PIGrCoord x2, PIGrCoord y2,
    90                                bool psz=true, bool clip=true, bool ad=false);
    91   virtual int        AddDrawer(PIDrawer* drw, bool autolim=false, bool clip=true, bool ad=false);
     92                               bool psz=true, bool clip=true,
     93                               bool ad=false, bool lock=false);
     94  virtual int        AddDrawer(PIDrawer* drw, bool autolim=false, bool clip=true,
     95                               bool ad=false, bool lock=false);
    9296  virtual void       MoveResizeDrawer(int id, PIGrCoord x1, PIGrCoord y1,
    93                                       PIGrCoord x2, PIGrCoord y2, bool psz=true);
     97                                      PIGrCoord x2, PIGrCoord y2, bool elastic=true);
    9498  virtual void       RemoveDrawer(int id);       // Ote un drawer de la liste
    9599  virtual void       DeleteDrawers();            // Ote tous les drawers, delete des drawers ajoute avec ad=true
     100
    96101// Acces aux drawers
    97   virtual int        NbDrawers();
    98   virtual PIDrawer*  GetDrawerId(int id);   
    99   virtual PIDrawer*  GetDrawer(int n);
    100  
     102  inline  int        NbDrawers() { return mDrwList.size(); }
     103          int        GetDrawerIdFromNum(int n);
     104          PIDrawer*  GetDrawerId(int id);   
     105          PIDrawer*  GetDrawer(int n);
     106          bool       IsDrawerLockedId(int id);
     107          bool       IsDrawerAutoSizePos(int id);
     108          void       GetDrawerPosition(int id, PIGrCoord& x1, PIGrCoord& y1,
     109                                       PIGrCoord& x2, PIGrCoord& y2, bool& elastic);
     110
    101111// Quel est le drawer actif
    102   virtual void       SetActiveDrawerId(int id);   
    103   virtual void       SetActiveDrawer(int n);   
    104   virtual int        GetActiveDrawerId();   
    105   virtual int        GetActiveDrawerNum();   
    106 
    107   virtual PIDrawer*  GetActiveDrawer();   
     112          void       SetActiveDrawerId(int id);   
     113          void       SetActiveDrawer(int n);   
     114          int        GetActiveDrawerId();   
     115          int        GetActiveDrawerNum();   
     116          PIDrawer*  GetActiveDrawer();   
    108117
    109118// Recherche du plus proche Drawer
     
    114123  virtual void       CallDrawer(int id);
    115124
    116 // Devrait etre protected - mis ici a cause de cxx  11/07/97  Reza
    117   struct BWDrwId { int id; PIGrCoord x1, y1, x2, y2; bool autoszp, autolim, elastic, clip, ad;  PIDrawer* drw; };
    118 
    119125  virtual PIGraphic*  WindowGraphic();
    120126
    121 // -------------- Variables membre protegees -------------------
     127// -------------- Variables membres protegees -------------------
    122128protected:
     129// ..... Structure de la liste de gestion des drawers .....
     130  struct BWDrwId {
     131    int id;          // Drawer Identifier
     132    PIGrCoord x1, y1, x2, y2;  // Drawer Position(/Size) in Widget
     133    // autoszp/autolim=true, Size/Limits imposed by widget -
     134    // elastic=true: Pos/Size = fraction of wdget size
     135    bool autoszp, autolim, elastic;
     136    bool clip, ad;  // clip=true : No graphic draw outside Drawer rectangle
     137    // ad=true: Delete Drawer when delete of PIBaseWdg
     138    bool lock;  // lock=true: cannot be detached/deleted
     139    PIDrawer* drw;   // Pointer to drawer itself
     140  };
     141// ...........................................................
     142
    123143  PIGraphicWin* mWGrC;  // PIGraphic (Contexte graphique) associe a la fenetre
    124144  bool mAdfg;           // Pour la gestion de DeleteDrawers() quand appele par delete de PIBaseWdg
  • trunk/SophyaPI/PI/pidrwtools.cc

    r2503 r2528  
    863863  }
    864864}
     865
     866//++
     867// Class        PI
     868// Lib          PIDrwMgrMenu
     869// include      pidrwtools.h
     870//
     871//      Classe de menu (pop-up) permettant d'interagir avec les drawers
     872//      attachés aux "PIBaseWdg".
     873//--
     874// Links        Parents
     875// PIMenu
     876//--
     877//++
     878// Links        Voir aussi
     879// PIDrawer
     880// PIBaseWdg
     881//--
     882
     883//------------------------------------------------------------
     884//------- Classe Event handler pour move/resize
     885class PIDrwPosSizeEvH : public PIEventHandler {
     886public:
     887  PIDrwPosSizeEvH(PIBaseWdg* bwdg);
     888  virtual void    ProcessEvent();
     889protected:
     890  PIBaseWdg* mBWdg;
     891  int _x1, _y1, _x2, _y2;
     892  bool _elastic;
     893  int _ipx, _ipy;
     894  int _cpx, _cpy;
     895  bool _defrect;  // true -> modification DefaultRectangle
     896  bool _rsz; // true -> resize option
     897  bool _okend;
     898};
     899
     900/* --Methode-- */
     901PIDrwPosSizeEvH::PIDrwPosSizeEvH(PIBaseWdg* bwdg)
     902{
     903  mBWdg = bwdg;
     904  _x1 = _y1 = _x2 = _y2 = -1;
     905  _ipx = _ipy = -1;
     906  _cpx = _cpy = -1;
     907  _defrect = false;
     908  _rsz = false;
     909  _okend = false;
     910  if (bwdg == NULL) return;
     911  int aid = bwdg->GetActiveDrawerId();
     912  if (aid < 0) return;
     913  PIGrCoord x1, y1, x2, y2;
     914 
     915  _elastic = false;
     916  if (mBWdg->IsDrawerAutoSizePos(aid)) {
     917    mBWdg->GetDefaultDrawRectangle(x1, y1, x2, y2, _elastic);
     918    _defrect = true;
     919  }
     920  else {
     921    mBWdg->GetDrawerPosition(aid, x1, y1, x2, y2, _elastic);
     922    _defrect = false;
     923  }
     924   
     925  if (_elastic) {
     926    _x1 = (double)x1*(double)mBWdg->XSize();
     927    _x2 = (double)x2*(double)mBWdg->XSize();
     928    _y1 = (double)y1*(double)mBWdg->YSize();
     929    _y2 = (double)y2*(double)mBWdg->YSize();
     930  }
     931  else {
     932    _x1 = x1; _x2 = x2;
     933    _y1 = y1; _y2 = y2;
     934  }
     935  _x2 -= _x1;  _y2 -= _y1;
     936  cout << "DBG: x1=" << _x1 << " y1=" << _y1 << " x2=" << _x2 << " y2=" << _y2 << endl;
     937
     938  PIGraphic* gr = mBWdg->WindowGraphic();
     939 
     940  PIGOMode gmod =  gr->GetGOMode();
     941  PILineAtt gline = gr->GetLineAtt();
     942  PIColors gcol = gr->GetForeground();
     943  gr->SelForeground(PI_Magenta);
     944  gr->SelGOMode(PI_GOXOR);
     945  gr->SelLine(PI_ThinLine);
     946  gr->DrawBox(x1,y1, x2, y2);
     947  x1 = _x1+0.9*(_x2-_x1);
     948  y1 = _y1+0.9*(_y2-_y1);
     949  gr->DrawFBox(x1,y1, x2, y2);
     950  x1 = _x1+0.4*(_x2-_x1);
     951  x2 = _x2-0.4*(_x2-_x1);
     952  y1 = _y1+0.4*(_y2-_y1);
     953  y2 = _y2-0.4*(_y2-_y1);
     954  gr->DrawBox(x1,y1, x2, y2);
     955  gr->SelGOMode(gmod);
     956  gr->SelLine(gline);
     957  gr->SelForeground(gcol);
     958
     959  cout << "DBG- Adding Event-Handler " << endl;
     960  mBWdg->AddEventHandler(this, PIEvent_But1Press|PIEvent_Ptr1Move|PIEvent_But1Release);
     961}
     962
     963/* --Methode-- */
     964void PIDrwPosSizeEvH::ProcessEvent()
     965{
     966  int delx, dely;
     967  PIGrCoord x1,y1,x2,y2;
     968  x1 = _x1; x2 = _x2;
     969  y1 = _y1; y2 = _y2;
     970  bool fgok = false;
     971  int aid = -1;
     972
     973  PIGraphic* gr = mBWdg->WindowGraphic();
     974
     975  PIGOMode gmod =  gr->GetGOMode();
     976  PILineAtt gline = gr->GetLineAtt();
     977  PIColors gcol = gr->GetForeground();
     978
     979  cout << " DBG - PIDrwPosSizeEvH::ProcessEvent() EventType=" << EventType() << endl;
     980  switch (EventType()) {
     981    case PIEvent_But1Press :
     982      // Zone de changement de taille
     983      x1 = _x1+0.9*(_x2-_x1);
     984      y1 = _y1+0.9*(_y2-_y1);
     985      if ( (GetPosX() >= (int)x1) && (GetPosX() <= (int)x2) &&
     986           (GetPosY() >= (int)y1) && ((GetPosY() <= (int)y2) ) )
     987        { fgok = true; _rsz = true; }           
     988      x1 = _x1+0.4*(_x2-_x1);
     989      x2 = _x2-0.4*(_x2-_x1);
     990      y1 = _y1+0.4*(_y2-_y1);
     991      y2 = _y2-0.4*(_y2-_y1);
     992      if ( (GetPosX() >= (int)x1) && (GetPosX() <= (int)x2) &&
     993           (GetPosY() >= (int)y1) && ((GetPosY() <= (int)y2) ) )
     994        { fgok = true; _rsz = false; }
     995      cout << " DBG-GetPosX()= " << GetPosX() << " GetPosY()= " << GetPosY() << endl;
     996      if (GetPosX() < 5) fgok = false;
     997      if (!fgok) _okend = true;
     998      else {
     999        _cpx = _ipx = GetPosX();
     1000        _cpy = _ipy = GetPosY();
     1001      }
     1002      break;
     1003
     1004    case  PIEvent_Ptr1Move :
     1005      if (_okend) return;
     1006      if (_ipx < 0)  return;
     1007      delx = GetPosX()-_cpx;
     1008      dely = GetPosY()-_cpy;
     1009      _cpx = GetPosX();
     1010      _cpy = GetPosY();
     1011     
     1012      gr->SelForeground(PI_Magenta);
     1013      gr->SelGOMode(PI_GOXOR);
     1014      gr->SelLine(PI_ThinLine);
     1015
     1016      gr->DrawBox(x1,y1, x2, y2);
     1017      x1 = _x1+0.9*(_x2-_x1);
     1018      y1 = _y1+0.9*(_y2-_y1);
     1019      gr->DrawFBox(x1,y1, x2, y2);
     1020      x1 = _x1+0.4*(_x2-_x1);
     1021      x2 = _x2-0.4*(_x2-_x1);
     1022      y1 = _y1+0.4*(_y2-_y1);
     1023      y2 = _y2-0.4*(_y2-_y1);
     1024      gr->DrawBox(x1,y1, x2, y2);
     1025
     1026      // Nouvelle position / taille
     1027      _x2 += delx;
     1028      _y2 += dely;
     1029      if (!_rsz) { _x1 += delx;  _y1 += dely; }
     1030
     1031      x1 = _x1; x2 = _x2;
     1032      y1 = _y1; y2 = _y2;
     1033      gr->DrawBox(x1,y1, x2, y2);
     1034      x1 = _x1+0.9*(_x2-_x1);
     1035      y1 = _y1+0.9*(_y2-_y1);
     1036      gr->DrawFBox(x1,y1, x2, y2);
     1037      x1 = _x1+0.4*(_x2-_x1);
     1038      x2 = _x2-0.4*(_x2-_x1);
     1039      y1 = _y1+0.4*(_y2-_y1);
     1040      y2 = _y2-0.4*(_y2-_y1);
     1041      gr->DrawBox(x1,y1, x2, y2);     
     1042      gr->SelGOMode(gmod);
     1043      gr->SelLine(gline);
     1044      gr->SelForeground(gcol);
     1045
     1046      break;
     1047
     1048    case  PIEvent_But1Release :
     1049      if (_okend) {
     1050        // On enleve le handler et on efface de rectangle de resize/move
     1051       
     1052        gr->SelForeground(PI_Magenta);
     1053        gr->SelGOMode(PI_GOXOR);
     1054        gr->SelLine(PI_ThinLine);
     1055       
     1056        gr->DrawBox(x1,y1, x2, y2);
     1057        x1 = _x1+0.9*(_x2-_x1);
     1058        y1 = _y1+0.9*(_y2-_y1);
     1059        gr->DrawFBox(x1,y1, x2, y2);
     1060        x1 = _x1+0.4*(_x2-_x1);
     1061        x2 = _x2-0.4*(_x2-_x1);
     1062        y1 = _y1+0.4*(_y2-_y1);
     1063        y2 = _y2-0.4*(_y2-_y1);
     1064        gr->DrawBox(x1,y1, x2, y2);
     1065        gr->SelGOMode(gmod);
     1066        gr->SelLine(gline);
     1067        gr->SelForeground(gcol);
     1068
     1069        cout << " DBG-  mBWdg->RemoveEventHandler(this); " << endl;
     1070        mBWdg->RemoveEventHandler(this);
     1071
     1072        return;
     1073      }
     1074
     1075      if (_ipx < 0)  return;
     1076      delx = GetPosX()-_cpx;
     1077      dely = GetPosY()-_cpy;
     1078
     1079      gr->SelForeground(PI_Magenta);
     1080      gr->SelGOMode(PI_GOXOR);
     1081      gr->SelLine(PI_ThinLine);
     1082
     1083      gr->DrawBox(x1,y1, x2, y2);
     1084      x1 = _x1+0.9*(_x2-_x1);
     1085      y1 = _y1+0.9*(_y2-_y1);
     1086      gr->DrawFBox(x1,y1, x2, y2);
     1087      x1 = _x1+0.4*(_x2-_x1);
     1088      x2 = _x2-0.4*(_x2-_x1);
     1089      y1 = _y1+0.4*(_y2-_y1);
     1090      y2 = _y2-0.4*(_y2-_y1);
     1091      gr->DrawBox(x1,y1, x2, y2);
     1092      gr->SelGOMode(gmod);
     1093      gr->SelLine(gline);
     1094      gr->SelForeground(gcol);
     1095
     1096      // Nouvelle position / taille
     1097      _x2 += delx;
     1098      _y2 += dely;
     1099      if (!_rsz) { _x1 += delx;  _y1 += dely; }
     1100
     1101      x1 = _x1; x2 = _x2;
     1102      y1 = _y1; y2 = _y2;
     1103      gr->DrawBox(x1,y1, x2, y2);
     1104      x1 = _x1+0.9*(_x2-_x1);
     1105      y1 = _y1+0.9*(_y2-_y1);
     1106      gr->DrawFBox(x1,y1, x2, y2);
     1107      x1 = _x1+0.4*(_x2-_x1);
     1108      x2 = _x2-0.4*(_x2-_x1);
     1109      y1 = _y1+0.4*(_y2-_y1);
     1110      y2 = _y2-0.4*(_y2-_y1);
     1111      gr->DrawBox(x1,y1, x2, y2);     
     1112      gr->RestoreGraphicAtt();
     1113
     1114      aid = mBWdg->GetActiveDrawerId();
     1115      if (aid < 0) return;
     1116
     1117      if (_elastic) {
     1118        x1 = (double)_x1/(double)mBWdg->XSize();
     1119        x2 = (double)_x2/(double)mBWdg->XSize()+(double)_x1;
     1120        y1 = (double)_y1/(double)mBWdg->YSize();
     1121        y2 = (double)_y2/(double)mBWdg->YSize()+(double)_y1;
     1122      }
     1123      else {
     1124        x1 = _x1; x2 = _x2+_x1;
     1125        y1 = _y1; y2 = _y2+_y1;
     1126      }
     1127      if (_defrect)
     1128        //      mBWdg->SetDefaultDrawRectangle(x1, y1, x2, y2, _elastic);
     1129        cout << "DBG-SetDefaultDrawRectangle() x1,y1=" << _x1 << "," << _y1
     1130             << " x2,y2=" << _x2 << "," << _y2 << endl;
     1131      else // mBWdg->MoveResizeDrawer(aid, x1, y1, x2, y2, _elastic);
     1132        cout << "DBG-MoveResizeDrawer() x1,y1=" << _x1 << "," << _y1
     1133             << " x2,y2=" << _x2 << "," << _y2 << endl;
     1134       
     1135      mBWdg->Refresh();
     1136      break;
     1137
     1138    default :
     1139      break;
     1140  }
     1141 
     1142}
     1143
     1144//------------------------------------------------------------
     1145/* --Methode-- */
     1146PIDrwMgrMenu::PIDrwMgrMenu(PIBaseWdg* bwdg)
     1147  : PIMenu(bwdg, "PIDrwMgrMenu", k_PopupMenu)
     1148{
     1149  mBWdg = bwdg;
     1150  mListDrw = NULL;
     1151  mEvH = NULL;
     1152
     1153  if (bwdg == NULL) return;
     1154
     1155  AppendItem("GraphicAttTools", 401);
     1156  AppendItem("OptionStringWin", 402);
     1157  AppendItem("ControlWin", 403);
     1158  AppendItem("Move/ReSize", 404);
     1159  AppendSeparator();
     1160  AppendItem("Detach", 405);
     1161  AppendItem("Highlight", 406);
     1162  AppendItem("Refresh", 407);
     1163  int aid = bwdg->GetActiveDrawerId();
     1164  if (aid < 0) {
     1165    for(int i=1; i<=6; i++)
     1166      SetSensitivityMsg(400+i, false);
     1167  }
     1168  else {
     1169    if ( !(bwdg->GetActiveDrawer()->HasSpecificControlWindow()) )
     1170      SetSensitivityMsg(403, false);
     1171    if ( bwdg->IsDrawerLockedId(aid))
     1172      SetSensitivityMsg(405, false);
     1173  }
     1174  if (bwdg->NbDrawers() > 0) {
     1175    AppendSeparator();
     1176    mListDrw = new PIMenu(this, "SelActiveDrw", k_PulldownMenu);
     1177    for(int k=0; k<bwdg->NbDrawers(); k++) {
     1178      char buff[16];
     1179      sprintf(buff, "%d- ", k);
     1180      string mit = buff;
     1181      mit += bwdg->GetDrawer(k)->Name();
     1182      mListDrw->AppendItem(mit.c_str(), 1000+k);
     1183    }
     1184    AppendPDMenu(mListDrw);
     1185  }
     1186}
     1187
     1188/* --Methode-- */
     1189PIDrwMgrMenu::~PIDrwMgrMenu()
     1190{
     1191  if (mListDrw) delete mListDrw;
     1192  if (mEvH) delete mEvH;
     1193}
     1194
     1195/* --Methode-- */
     1196void PIDrwMgrMenu::Process(PIMessage msg, PIMsgHandler* sender, void* data)
     1197
     1198  if (mBWdg == NULL) return;
     1199  int aid = mBWdg->GetActiveDrawerId();
     1200  PIDrawer* actdrw = mBWdg->GetActiveDrawer();
     1201  PIMessage mod = ModMsg(msg);
     1202  msg = UserMsg(msg);
     1203  switch (msg) {
     1204    case 401 :
     1205      if (aid >= 0)  PIDrwTools::ShowPIDrwTools(mBWdg);
     1206      //        if (actdrw != NULL) actdrw->HighLight(false);
     1207      break;
     1208    case 402 :
     1209      if (actdrw != NULL) {
     1210        PIDrwOptionStringWindow::ShowDrwOptionStringWindow(actdrw);
     1211        //      actdrw->HighLight(false);
     1212      }
     1213      break;
     1214    case 403 :
     1215      if (actdrw != NULL) {
     1216        actdrw->ShowControlWindow(mBWdg);
     1217        // actdrw->HighLight(false);
     1218      }
     1219      break;
     1220    case 404 :
     1221      if (mEvH) delete mEvH;
     1222      mEvH = new PIDrwPosSizeEvH(mBWdg);
     1223      break;
     1224    case 405 :
     1225      if (aid >= 0) {
     1226        mBWdg->RemoveDrawer(aid);
     1227        mBWdg->Refresh();
     1228      }
     1229      break;
     1230    case 406 :
     1231      if (actdrw != NULL)  actdrw->HighLight(true);
     1232      break;
     1233    case 407 :
     1234      mBWdg->Refresh();
     1235      break;
     1236    default :
     1237      //      if (actdrw != NULL) actdrw->HighLight(false);
     1238      if (msg >= 1000)
     1239        mBWdg->SetActiveDrawer(msg-1000);
     1240      break;
     1241  }
     1242
     1243}
  • trunk/SophyaPI/PI/pidrwtools.h

    r2503 r2528  
    88#include "pisysdep.h"
    99#include PISTDWDG_H
     10#include PIMENU_H
    1011#include PIOPTMENU_H
    1112#include PIWIN_H
     
    8081};
    8182
     83//-------------------------------------------------------------------------------------------
     84// Classe de menu specifique de manipulation interactive des drawers attaches a un PIBaseWdg
     85//-------------------------------------------------------------------------------------------
     86class PIDrwPosSizeEvH;  // Event Handler pour le deplacement/resize des drawers
     87
     88class PIDrwMgrMenu : public PIMenu {
     89public:
     90                  PIDrwMgrMenu(PIBaseWdg* bwdg);
     91  virtual         ~PIDrwMgrMenu();
     92  virtual void    Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
     93protected:
     94  PIMenu*  mListDrw;
     95  PIBaseWdg* mBWdg;
     96  PIDrwPosSizeEvH* mEvH;
     97};
     98
    8299#endif
  • trunk/SophyaPI/PI/piimage.cc

    r2357 r2528  
    143143 mdrw->SetAxesFlags(kAxesNone);
    144144gvdrw = new PIElDrawer();
    145 AddDrawer(mdrw, true, false, false);
     145AddDrawer(mdrw, true, false, false, false);
    146146
    147147SetLut(-9.e19, 9.e19, kLutType_Lin, 0, false);
  • trunk/SophyaPI/PI/piscdrawwdg.cc

    r2504 r2528  
    7070// void  SetAxesFlags(unsigned int flags=kAxesDflt)
    7171//      Définit les attributs des axes.
    72 // int  AddScDrawer(PIDrawer*, bool ad=false)
     72// int  AddScDrawer(PIDrawer*, bool ad=false, bool lock=false)
    7373//      Ajoute un Drawer.
    7474//--
     
    9696  FreeLimits();
    9797  xEndDrag = yEndDrag = xBegDrag = yBegDrag = 0;
    98   AddDrawer(mBDrw, true, false, false);
     98  AddDrawer(mBDrw, true, false, false, false);
    9999
    100100//  Pour afficher les coordonnees courante (click-bouton-1) 
     
    106106  mInfoW = NULL;
    107107  mInfoTxt = NULL;
     108
     109// Menu pour la manipulation des drawers
     110  mDrwMen = NULL;
    108111
    109112  ActivateKeyboard();
     
    125128    PIAxesTools::SetCurrentScDrawWdg(NULL);
    126129  // Pour PIDrwTools, c'est fait par le destructeur de PIBaseWdgGen
     130  if (mDrwMen) delete mDrwMen;
    127131}
    128132
     
    152156    PIAxesTools::ShowPIAxesTools();  // Fenetre de gestion des axes
    153157  }
    154  
     158  else if (key == 'D' || key == 'd') {
     159    if (mDrwMen) delete mDrwMen;
     160    mDrwMen = new PIDrwMgrMenu(this);
     161    mDrwMen->Show();
     162  } 
    155163  else if (key == 'I' || key == 'i') UpdateInfoWindow();  // Fenetre Text-Info
    156164  }
     
    290298
    291299int
    292 PIScDrawWdg::AddScDrawer(PIDrawer* d, bool ad)
     300PIScDrawWdg::AddScDrawer(PIDrawer* d, bool ad, bool lock)
    293301{
    294302  if (d == NULL)  return(-1);
     
    301309    SetLimits(d->XMin(), d->XMax(), d->YMin(), d->YMax(), mDXdir, mDYdir);
    302310  }
    303   return(AddDrawer(d, true, true, ad));
     311  return(AddDrawer(d, true, true, ad, lock));
    304312}
    305313
     
    469477    if (actdr) {
    470478      actdr->HighLight(false);
     479      if (mDrwMen) delete mDrwMen;
     480      mDrwMen = new PIDrwMgrMenu(this);
     481      mDrwMen->Show(this, x, y);
    471482    }
    472483    return;
  • trunk/SophyaPI/PI/piscdrawwdg.h

    r2503 r2528  
    1616
    1717// PIScDrawWdg, Gestionnaire de traceur 2D
     18class PIDrwMgrMenu;
    1819
    1920class PIScDrawWdg : public PIBaseWdg {
     
    4748
    4849// Ajoute un Drawer en auto
    49   int                AddScDrawer(PIDrawer*, bool ad=false);   
     50  int                AddScDrawer(PIDrawer*, bool ad=false, bool lock=false);   
    5051
    5152  inline PIElDrawer* BaseDrawer() { return mBDrw; };
     
    120121  PIText * mInfoTxt;
    121122
     123// Menu pour la manipulation des drawers
     124  PIDrwMgrMenu* mDrwMen;
     125
    122126private:
    123127  void  UpdateText(int xp, int yp);
  • trunk/SophyaPI/PI/piwdgx.cc

    r2417 r2528  
    917917{
    918918PIWdgGen::AddDrawHandler(drwh, ad);
    919 XtInsertEventHandler( XtWdg(), ExposureMask, FALSE, evthandler_piwdgx, this, XtListTail);
     919if (mDHlist.size() == 1)
     920  XtInsertEventHandler( XtWdg(), ExposureMask, FALSE, evthandler_piwdgx, this, XtListTail);
    920921}
    921922
     
    924925{
    925926PIWdgGen::RemoveDrawHandler(drwh);
    926 if (mEHlist.size() <= 0) XtRemoveEventHandler( XtWdg(), ExposureMask, FALSE, evthandler_piwdgx, this);
     927if (mDHlist.size() == 0) XtRemoveEventHandler( XtWdg(), ExposureMask, FALSE, evthandler_piwdgx, this);
    927928}
    928929
     
    946947if (evtmask & PIEvent_Ptr3Move)  mask |= (PointerMotionHintMask | Button3MotionMask);
    947948if (evtmask & PIEvent_Keyboard)  mask |= KeyPressMask;
    948 printf("PIWdgX::AddEventHandler() Mask = %lx \n", (long)mask);
     949// printf("PIWdgX::AddEventHandler() Mask = %lx \n", (long)mask);
    949950XtInsertEventHandler( XtWdg(), mask, FALSE, evthandler_piwdgx, this, XtListTail);
    950951}
     
    954955{
    955956PIWdgGen::RemoveEventHandler(evh);
     957//cout << "DBG-PIWdgX::RemoveEventHandler( " << hex << evh << dec << ") mEHlist.size()="
     958//      << mEHlist.size() << endl;
    956959if (mEHlist.size() > 0) return;
    957960EventMask mask = EnterNotify;
     
    992995                               int k, int km, unsigned long tm)
    993996{
     997//cout << "DBG-PIWdgX:CallEventHandlers() - mEHlist.size()=" << mEHlist.size() << endl;
    994998PIEventHandler* eh;
    995999list<EvHand>::iterator it;
    996 for(it= mEHlist.begin(); it != mEHlist.end(); it++) {
     1000// On fait d'abord une copie pour eviter les problemes
     1001// lies a l'ajout ou la supression d'event-handler par un ProcessEvent()
     1002list<EvHand> cEHlist;
     1003for(it= mEHlist.begin(); it != mEHlist.end(); it++) {
    9971004  if (!((*it).mask & evt))  continue;
     1005  cEHlist.push_back(*it);
     1006}
     1007// Et on refait la boucle sur la liste copiee ...
     1008for(it= cEHlist.begin(); it != cEHlist.end(); it++) {
    9981009  eh = (*it).evh;
    9991010  eh->SetCurrentWdg(this);
Note: See TracChangeset for help on using the changeset viewer.