Changeset 2529 in Sophya for trunk/SophyaPI


Ignore:
Timestamp:
Apr 27, 2004, 11:49:37 PM (21 years ago)
Author:
ansari
Message:

Suite implementation menu de manipulation des drawers et handler de Move/ResizeDrawer (quasi fini) - Reza 27/04/2004

Location:
trunk/SophyaPI/PI
Files:
5 edited

Legend:

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

    r2528 r2529  
    531531vector<BWDrwId>::iterator it;
    532532for(it = mDrwList.begin(); it != mDrwList.end(); it++) 
    533   if ((*it).id == id)  return(! (*it).autoszp );
     533  if ((*it).id == id)  return( (*it).autoszp );
    534534return false;
    535535}
  • trunk/SophyaPI/PI/pidrwtools.cc

    r2528 r2529  
    885885class PIDrwPosSizeEvH : public PIEventHandler {
    886886public:
    887   PIDrwPosSizeEvH(PIBaseWdg* bwdg);
     887  PIDrwPosSizeEvH(PIBaseWdg* bwdg, bool fgxor=true);
     888          void    CheckBeforeDelete();
    888889  virtual void    ProcessEvent();
     890
    889891protected:
     892  void ComputeResizeZone();
     893  void ComputeMoveZone();
     894  inline void ComputeDrawerZone()
     895    { x1 = _x1;  y1 = _y1; x2 = _x2-_x1;  y2 = _y2-_y1; }
     896
     897
    890898  PIBaseWdg* mBWdg;
     899  bool _fgxor;
    891900  int _x1, _y1, _x2, _y2;
     901  PIGrCoord x1, y1, x2, y2;
    892902  bool _elastic;
    893903  int _ipx, _ipy;
     
    896906  bool _rsz; // true -> resize option
    897907  bool _okend;
     908  bool _rmok;
    898909};
    899910
    900911/* --Methode-- */
    901 PIDrwPosSizeEvH::PIDrwPosSizeEvH(PIBaseWdg* bwdg)
     912PIDrwPosSizeEvH::PIDrwPosSizeEvH(PIBaseWdg* bwdg, bool fgxor)
    902913{
    903914  mBWdg = bwdg;
     915  _fgxor = fgxor;
    904916  _x1 = _y1 = _x2 = _y2 = -1;
    905917  _ipx = _ipy = -1;
     
    908920  _rsz = false;
    909921  _okend = false;
     922  _rmok = false;
    910923  if (bwdg == NULL) return;
    911924  int aid = bwdg->GetActiveDrawerId();
    912925  if (aid < 0) return;
    913   PIGrCoord x1, y1, x2, y2;
    914926 
    915927  _elastic = false;
     
    933945    _y1 = y1; _y2 = y2;
    934946  }
    935   _x2 -= _x1;  _y2 -= _y1;
    936   cout << "DBG: x1=" << _x1 << " y1=" << _y1 << " x2=" << _x2 << " y2=" << _y2 << endl;
    937947
    938948  PIGraphic* gr = mBWdg->WindowGraphic();
     
    941951  PILineAtt gline = gr->GetLineAtt();
    942952  PIColors gcol = gr->GetForeground();
    943   gr->SelForeground(PI_Magenta);
    944   gr->SelGOMode(PI_GOXOR);
     953  if (_fgxor) {
     954    gr->SelForeground(PI_Magenta);
     955    gr->SelGOMode(PI_GOXOR);
     956  }
     957  else {
     958    gr->SelForeground(PI_HighlightBlue);
     959    gr->SelGOMode(PI_GOCopy);
     960  }
    945961  gr->SelLine(PI_ThinLine);
     962  ComputeDrawerZone();
    946963  gr->DrawBox(x1,y1, x2, y2);
    947   x1 = _x1+0.9*(_x2-_x1);
    948   y1 = _y1+0.9*(_y2-_y1);
     964  ComputeResizeZone();
    949965  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);
     966  ComputeMoveZone();
    954967  gr->DrawBox(x1,y1, x2, y2);
    955968  gr->SelGOMode(gmod);
     
    957970  gr->SelForeground(gcol);
    958971
    959   cout << "DBG- Adding Event-Handler " << endl;
     972//  cout << "DBG- Adding Event-Handler " << endl;
    960973  mBWdg->AddEventHandler(this, PIEvent_But1Press|PIEvent_Ptr1Move|PIEvent_But1Release);
    961974}
     975/* --Methode-- */
     976void PIDrwPosSizeEvH::CheckBeforeDelete()
     977{
     978  if (!_rmok)
     979    mBWdg->RemoveEventHandler(this);   
     980  _rmok = true;
     981}
     982
     983/* --Methode-- */
     984void PIDrwPosSizeEvH::ComputeResizeZone()
     985{
     986  int dx = (int)(0.05*(_x2-_x1));
     987  int dy = (int)(0.05*(_y2-_y1));
     988  int maxdx = (int)(0.20*(_x2-_x1));
     989  int maxdy = (int)(0.20*(_y2-_y1));
     990  if (dx < 20)  dx = 20;
     991  if (dx > maxdx) dx = maxdx;
     992  if (dy < 20)  dx = 20;
     993  if (dy > maxdy) dy = maxdy;
     994  int dxy = (dx < dy) ? dx : dy ;
     995  x1 = _x2-dxy;  y1 = _y2-dxy;
     996  x2 = y2 = dxy;
     997}
     998
     999/* --Methode-- */
     1000void PIDrwPosSizeEvH::ComputeMoveZone()
     1001{
     1002  int dx = (int)(0.08*(_x2-_x1));
     1003  int dy = (int)(0.08*(_y2-_y1));
     1004  int maxdx = (int)(0.20*(_x2-_x1));
     1005  int maxdy = (int)(0.20*(_y2-_y1));
     1006  if (dx < 20)  dx = 20;
     1007  if (dx > maxdx) dx = maxdx;
     1008  if (dy < 20)  dx = 20;
     1009  if (dy > maxdy) dy = maxdy;
     1010  int dxy = (dx < dy) ? dx : dy ;
     1011  x1 = (_x1+_x2)*0.5-dxy; 
     1012  y1 = (_y1+_y2)*0.5-dxy;   
     1013  x2 = y2 = 2*dxy;
     1014}
    9621015
    9631016/* --Methode-- */
     
    9651018{
    9661019  int delx, dely;
    967   PIGrCoord x1,y1,x2,y2;
     1020  int ix1,iy1,ix2,iy2;
    9681021  x1 = _x1; x2 = _x2;
    9691022  y1 = _y1; y2 = _y2;
     
    9771030  PIColors gcol = gr->GetForeground();
    9781031
    979   cout << " DBG - PIDrwPosSizeEvH::ProcessEvent() EventType=" << EventType() << endl;
    9801032  switch (EventType()) {
    9811033    case PIEvent_But1Press :
    9821034      // 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) ) )
     1035      ComputeResizeZone();
     1036      ix1 = x1;  iy1 = y1;
     1037      ix2 = _x2;  iy2 = _y2;
     1038      if ( (GetPosX() >= ix1) && (GetPosX() <= ix2) &&
     1039           (GetPosY() >= iy1) && ((GetPosY() <= iy2) ) )
    9871040        { 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) ) )
     1041      ComputeMoveZone();
     1042      ix1 = x1;  iy1 = y1;
     1043      ix2 = (int)x2+ix1;  iy2 = (int)y2+iy1;
     1044      if ( (GetPosX() >= ix1) && (GetPosX() <= ix2) &&
     1045           (GetPosY() >= iy1) && ((GetPosY() <= iy2) ) )
    9941046        { fgok = true; _rsz = false; }
    995       cout << " DBG-GetPosX()= " << GetPosX() << " GetPosY()= " << GetPosY() << endl;
    996       if (GetPosX() < 5) fgok = false;
    9971047      if (!fgok) _okend = true;
    9981048      else {
     
    10101060      _cpy = GetPosY();
    10111061     
    1012       gr->SelForeground(PI_Magenta);
    1013       gr->SelGOMode(PI_GOXOR);
     1062      if (_fgxor) {
     1063        gr->SelForeground(PI_Magenta);
     1064        gr->SelGOMode(PI_GOXOR);
     1065      }
     1066      else {
     1067        gr->SelForeground(mBWdg->GetBackgroundColor());
     1068        gr->SelGOMode(PI_GOCopy);
     1069      }
    10141070      gr->SelLine(PI_ThinLine);
    10151071
     1072      ComputeDrawerZone();
    10161073      gr->DrawBox(x1,y1, x2, y2);
    1017       x1 = _x1+0.9*(_x2-_x1);
    1018       y1 = _y1+0.9*(_y2-_y1);
     1074      ComputeResizeZone();
    10191075      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);
     1076      ComputeMoveZone();
    10241077      gr->DrawBox(x1,y1, x2, y2);
    10251078
     
    10291082      if (!_rsz) { _x1 += delx;  _y1 += dely; }
    10301083
    1031       x1 = _x1; x2 = _x2;
    1032       y1 = _y1; y2 = _y2;
     1084      if (!_fgxor) gr->SelForeground(PI_HighlightBlue);
     1085      ComputeDrawerZone();
    10331086      gr->DrawBox(x1,y1, x2, y2);
    1034       x1 = _x1+0.9*(_x2-_x1);
    1035       y1 = _y1+0.9*(_y2-_y1);
     1087      ComputeResizeZone();
    10361088      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);
     1089      ComputeMoveZone();
    10411090      gr->DrawBox(x1,y1, x2, y2);     
    10421091      gr->SelGOMode(gmod);
     
    10471096
    10481097    case  PIEvent_But1Release :
     1098      if (_ipx < 0)  return;
    10491099      if (_okend) {
    1050         // On enleve le handler et on efface de rectangle de resize/move
     1100   // On efface de rectangle de resize/move
     1101        if (_fgxor) {
     1102          gr->SelForeground(PI_Magenta);
     1103          gr->SelGOMode(PI_GOXOR);
     1104        }       
     1105        else {
     1106          gr->SelForeground(mBWdg->GetBackgroundColor());
     1107          gr->SelGOMode(PI_GOCopy);
     1108        }
     1109        gr->SelLine(PI_ThinLine);
    10511110       
    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);
     1111        ComputeDrawerZone();
     1112        gr->DrawBox(x1,y1, x2, y2);
     1113        ComputeResizeZone();
     1114        gr->DrawFBox(x1,y1, x2, y2);
     1115        ComputeMoveZone();
     1116        gr->DrawBox(x1,y1, x2, y2);
    10651117        gr->SelGOMode(gmod);
    10661118        gr->SelLine(gline);
    10671119        gr->SelForeground(gcol);
    1068 
    1069         cout << " DBG-  mBWdg->RemoveEventHandler(this); " << endl;
     1120  // On enleve le handler
     1121//      cout << " DBG-  mBWdg->RemoveEventHandler(this); " << endl;
    10701122        mBWdg->RemoveEventHandler(this);
    1071 
     1123        _rmok = true;
    10721124        return;
    10731125      }
    10741126
    1075       if (_ipx < 0)  return;
     1127      // Nouvelle position / taille
    10761128      delx = GetPosX()-_cpx;
    10771129      dely = GetPosY()-_cpy;
    1078 
    1079       gr->SelForeground(PI_Magenta);
    1080       gr->SelGOMode(PI_GOXOR);
    1081       gr->SelLine(PI_ThinLine);
    1082 
     1130      _x2 += delx;
     1131      _y2 += dely;
     1132      if (!_rsz) { _x1 += delx;  _y1 += dely; }
     1133      if (_elastic) {
     1134        x1 = (double)_x1/(double)mBWdg->XSize();
     1135        x2 = (double)_x2/(double)mBWdg->XSize();
     1136        y1 = (double)_y1/(double)mBWdg->YSize();
     1137        y2 = (double)_y2/(double)mBWdg->YSize();
     1138      }
     1139      else {
     1140        x1 = _x1; x2 = _x2;
     1141        y1 = _y1; y2 = _y2;
     1142      }
     1143      if (_defrect) {
     1144        mBWdg->SetDefaultDrawRectangle(x1, y1, x2, y2, _elastic);
     1145//      cout << "DBG-SetDefaultDrawRectangle() x1,y1=" << _x1 << "," << _y1
     1146//     << " x2,y2=" << _x2 << "," << _y2 << endl;
     1147      }
     1148      else {
     1149        aid = mBWdg->GetActiveDrawerId();
     1150        mBWdg->MoveResizeDrawer(aid, x1, y1, x2, y2, _elastic);
     1151//      cout << "DBG-MoveResizeDrawer() x1,y1=" << _x1 << "," << _y1
     1152//           << " x2,y2=" << _x2 << "," << _y2 << endl;
     1153      }
     1154      mBWdg->Refresh();
     1155
     1156      if (_fgxor) {
     1157        gr->SelForeground(PI_Magenta);
     1158        gr->SelGOMode(PI_GOXOR);
     1159      }
     1160      else {
     1161        gr->SelForeground(PI_HighlightBlue);
     1162        gr->SelGOMode(PI_GOCopy);
     1163      }
     1164      ComputeDrawerZone();
    10831165      gr->DrawBox(x1,y1, x2, y2);
    1084       x1 = _x1+0.9*(_x2-_x1);
    1085       y1 = _y1+0.9*(_y2-_y1);
     1166      ComputeResizeZone();
    10861167      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);
     1168      ComputeMoveZone();
     1169      gr->DrawBox(x1,y1, x2, y2);     
     1170
    10921171      gr->SelGOMode(gmod);
    10931172      gr->SelLine(gline);
    10941173      gr->SelForeground(gcol);
    10951174
    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();
    11361175      break;
    11371176
     
    11441183//------------------------------------------------------------
    11451184/* --Methode-- */
    1146 PIDrwMgrMenu::PIDrwMgrMenu(PIBaseWdg* bwdg)
     1185PIDrwMgrMenu::PIDrwMgrMenu(PIBaseWdg* bwdg, bool fgxor)
    11471186  : PIMenu(bwdg, "PIDrwMgrMenu", k_PopupMenu)
    11481187{
    11491188  mBWdg = bwdg;
    11501189  mListDrw = NULL;
     1190  mFgxor = fgxor;
    11511191  mEvH = NULL;
    11521192
     
    11841224    AppendPDMenu(mListDrw);
    11851225  }
     1226  PIDrawer*  actdr = mBWdg->GetActiveDrawer();
     1227  if (actdr)  actdr->HighLight(true);
    11861228}
    11871229
     
    11901232{
    11911233  if (mListDrw) delete mListDrw;
    1192   if (mEvH) delete mEvH;
     1234  if (mEvH) {
     1235    mEvH->CheckBeforeDelete();
     1236    delete mEvH;
     1237  }
    11931238}
    11941239
     
    12041249    case 401 :
    12051250      if (aid >= 0)  PIDrwTools::ShowPIDrwTools(mBWdg);
    1206       //        if (actdrw != NULL) actdrw->HighLight(false);
     1251      if (actdrw != NULL) actdrw->HighLight(false);
    12071252      break;
    12081253    case 402 :
    12091254      if (actdrw != NULL) {
    12101255        PIDrwOptionStringWindow::ShowDrwOptionStringWindow(actdrw);
    1211         //      actdrw->HighLight(false);
     1256        actdrw->HighLight(false);
    12121257      }
    12131258      break;
     
    12151260      if (actdrw != NULL) {
    12161261        actdrw->ShowControlWindow(mBWdg);
    1217         // actdrw->HighLight(false);
     1262        actdrw->HighLight(false);
    12181263      }
    12191264      break;
    12201265    case 404 :
    12211266      if (mEvH) delete mEvH;
    1222       mEvH = new PIDrwPosSizeEvH(mBWdg);
     1267      if (actdrw != NULL) actdrw->HighLight(false);
     1268      mEvH = new PIDrwPosSizeEvH(mBWdg, mFgxor);
    12231269      break;
    12241270    case 405 :
     
    12351281      break;
    12361282    default :
    1237       //      if (actdrw != NULL) actdrw->HighLight(false);
     1283      if (actdrw != NULL) actdrw->HighLight(false);
    12381284      if (msg >= 1000)
    12391285        mBWdg->SetActiveDrawer(msg-1000);
  • trunk/SophyaPI/PI/pidrwtools.h

    r2528 r2529  
    8888class PIDrwMgrMenu : public PIMenu {
    8989public:
    90                   PIDrwMgrMenu(PIBaseWdg* bwdg);
     90                  PIDrwMgrMenu(PIBaseWdg* bwdg, bool fgxor=true);
    9191  virtual         ~PIDrwMgrMenu();
    9292  virtual void    Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
     
    9494  PIMenu*  mListDrw;
    9595  PIBaseWdg* mBWdg;
     96  bool mFgxor;
    9697  PIDrwPosSizeEvH* mEvH;
    9798};
  • trunk/SophyaPI/PI/piscdrawwdg.cc

    r2528 r2529  
    9696  FreeLimits();
    9797  xEndDrag = yEndDrag = xBegDrag = yBegDrag = 0;
    98   AddDrawer(mBDrw, true, false, false, false);
     98  AddDrawer(mBDrw, true, false, false, true);
    9999
    100100//  Pour afficher les coordonnees courante (click-bouton-1) 
     
    158158  else if (key == 'D' || key == 'd') {
    159159    if (mDrwMen) delete mDrwMen;
    160     mDrwMen = new PIDrwMgrMenu(this);
     160    mDrwMen = new PIDrwMgrMenu(this, true);
    161161    mDrwMen->Show();
    162162  } 
     
    428428    int nid = FindNearestDrawerId(x,y);
    429429    SetActiveDrawerId(nid);
    430     PIDrawer*  actdr = GetActiveDrawer();
    431     if (actdr) {
    432       actdr->HighLight(true);
    433     }
     430//    PIDrawer*  actdr = GetActiveDrawer();
     431//    if (actdr) {
     432//      actdr->HighLight(true);
     433//    }
    434434    return;
    435435  }
     
    476476    PIDrawer*  actdr = GetActiveDrawer();
    477477    if (actdr) {
    478       actdr->HighLight(false);
     478//      actdr->HighLight(false);
    479479      if (mDrwMen) delete mDrwMen;
    480480      mDrwMen = new PIDrwMgrMenu(this);
    481       mDrwMen->Show(this, x, y);
    482     }
     481      mDrwMen->Show();
     482    }
     483
    483484    return;
    484485  }
  • trunk/SophyaPI/PI/piversion.h

    r2426 r2529  
    22#define PIVERSION_H_SEEN
    33
    4 #define PI_VERSIONNUMBER  3.96
     4#define PI_VERSIONNUMBER  3.97
    55
    66#endif
Note: See TracChangeset for help on using the changeset viewer.