Changeset 2539 in Sophya


Ignore:
Timestamp:
May 25, 2004, 12:45:08 AM (21 years ago)
Author:
ansari
Message:

suite et (presque) fin codage menu et event handler manipulation interactive des drawers avec activation ds PIScDrawWdg, PIImage et PI3DWdg - Reza 24 Mai 2004

Location:
trunk/SophyaPI/PI
Files:
8 edited

Legend:

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

    r2528 r2539  
    3535//      * <Alt>G : Affichage d'une fenêtre de changement des attributs graphiques
    3636//      * <Alt>O : Action identique a <Alt>G
     37//      * <Alt>D : Affichage du menu de manipulation des traceurs (drawers)
    3738//      * <Alt>V : Copier/*Coller* Ajout du texte du buffer copier/coller
    3839//      sur l'objet à la position courante de la souris
     
    8990  cTeta = cPhi = 0.;  cUlen = 1.;
    9091
     92// Menu pour la manipulation des drawers
     93  mDrwMen = NULL;
     94
    9195  ActivateKeyboard();
    9296  ActivateButton(2);    //  Pour pouvoir tourner la camera
     
    106110  delete mBDrw;
    107111  delete mGr3d;
     112  if (mDrwMen) delete mDrwMen;
    108113}
    109114
     
    256261  else if (key == 'G' || key == 'g') // Fenetre des options graphiques de trace
    257262    PIDrwTools::ShowPIDrwTools(this);   
     263  else if (key == 'D' || key == 'd') { // Menu de manipulation des drawers
     264    if (mDrwMen) delete mDrwMen;
     265    mDrwMen = new PIDrwMgrMenu(this, true);
     266    mDrwMen->Show();
     267  } 
    258268
    259269  else if (key == 'A' || key == 'a')  {    // On affiche ou on enleve les axes
  • trunk/SophyaPI/PI/pi3dwdg.h

    r2528 r2539  
    1616
    1717//------------------------------ Classe PIDrawer3D --------------------
     18class PIDrwMgrMenu;
    1819
    1920class PIDraw3DWdg : public PIBaseWdg {
     
    8485  bool  axfg;                  // si Vrai on trace les axes
    8586  bool  skcfg;                 // si Vrai click-2 au centre -> rotation objet
     87
     88// Menu pour la manipulation des drawers
     89  PIDrwMgrMenu* mDrwMen;
    8690};
    8791
  • trunk/SophyaPI/PI/pidrwtools.cc

    r2529 r2539  
    947947
    948948  PIGraphic* gr = mBWdg->WindowGraphic();
    949  
     949  mBWdg->GetActiveDrawer()->HighLight(true);
    950950  PIGOMode gmod =  gr->GetGOMode();
    951951  PILineAtt gline = gr->GetLineAtt();
     
    976976void PIDrwPosSizeEvH::CheckBeforeDelete()
    977977{
    978   if (!_rmok)
     978  if (!_rmok) {
     979    PIDrawer* adrw = mBWdg->GetActiveDrawer();
     980    if (adrw) adrw->HighLight(true);
    979981    mBWdg->RemoveEventHandler(this);   
     982  }
    980983  _rmok = true;
    981984}
     
    11201123  // On enleve le handler
    11211124//      cout << " DBG-  mBWdg->RemoveEventHandler(this); " << endl;
     1125        PIDrawer* adrw = mBWdg->GetActiveDrawer();
     1126        if (adrw) adrw->HighLight(false);
    11221127        mBWdg->RemoveEventHandler(this);
    11231128        _rmok = true;
     
    11811186}
    11821187
     1188//-----------------------------------------------------------------
     1189//------- Classe Event handler pour Mouse Select de l'active Drawer
     1190class PIDrwSelectEvH : public PIEventHandler {
     1191public:
     1192  PIDrwSelectEvH(PIBaseWdg* bwdg);
     1193          void    CheckBeforeDelete();
     1194  virtual void    ProcessEvent();
     1195
     1196protected:
     1197//  void ComputeResizeZone();
     1198  void ComputeOKZone();
     1199//  inline void ComputeDrawerZone()
     1200//    { x1 = _x1;  y1 = _y1; x2 = _x2-_x1;  y2 = _y2-_y1; }
     1201
     1202
     1203  PIBaseWdg* mBWdg;
     1204  int _caid;
     1205  int _x1, _y1, _x2, _y2;
     1206  PIGrCoord x1, y1, x2, y2;
     1207  PIGrCoord xc, yc, rc;
     1208  bool _okend;
     1209  bool _rmok;
     1210};
     1211
     1212/* --Methode-- */
     1213PIDrwSelectEvH::PIDrwSelectEvH(PIBaseWdg* bwdg)
     1214{
     1215  mBWdg = bwdg;
     1216  _x1 = _y1 = _x2 = _y2 = -1;
     1217  x1 = y1 = x2 = y2 = xc = yc = rc = -1;
     1218  _okend = false;
     1219  _rmok = false;
     1220  if (bwdg == NULL) return;
     1221
     1222  int aid = bwdg->GetActiveDrawerId();
     1223  if (aid < 0) return;
     1224 
     1225  mBWdg->GetActiveDrawer()->HighLight(true);
     1226  _caid = aid;
     1227
     1228  PIGraphic* gr = mBWdg->WindowGraphic();
     1229 
     1230  PIGOMode gmod =  gr->GetGOMode();
     1231  PILineAtt gline = gr->GetLineAtt();
     1232  PIColors gcol = gr->GetForeground();
     1233
     1234  gr->SelForeground(PI_Magenta);
     1235  gr->SelGOMode(PI_GOXOR);
     1236  gr->SelLine(PI_ThinLine);
     1237
     1238  ComputeOKZone();
     1239  gr->DrawBox(x1,y1, x2, y2);
     1240  gr->DrawFCircle(xc,yc,rc);
     1241
     1242  gr->SelGOMode(gmod);
     1243  gr->SelLine(gline);
     1244  gr->SelForeground(gcol);
     1245
     1246//  cout << "DBG- Adding Event-Handler " << endl;
     1247  mBWdg->AddEventHandler(this, PIEvent_But1Press);
     1248}
     1249/* --Methode-- */
     1250void PIDrwSelectEvH::CheckBeforeDelete()
     1251{
     1252  if (!_rmok) {
     1253    PIDrawer* adrw = mBWdg->GetActiveDrawer();
     1254    if (adrw) adrw->HighLight(true);
     1255    mBWdg->RemoveEventHandler(this);   
     1256  }
     1257  _rmok = true;
     1258}
     1259
     1260
     1261/* --Methode-- */
     1262void PIDrwSelectEvH::ComputeOKZone()
     1263{
     1264  bool _elastic = false;
     1265  int aid = mBWdg->GetActiveDrawerId();
     1266  if (mBWdg->IsDrawerAutoSizePos(aid)) {
     1267    mBWdg->GetDefaultDrawRectangle(x1, y1, x2, y2, _elastic);
     1268  }
     1269  else {
     1270    mBWdg->GetDrawerPosition(aid, x1, y1, x2, y2, _elastic);
     1271  }
     1272   
     1273  if (_elastic) {
     1274    _x1 = (double)x1*(double)mBWdg->XSize();
     1275    _x2 = (double)x2*(double)mBWdg->XSize();
     1276    _y1 = (double)y1*(double)mBWdg->YSize();
     1277    _y2 = (double)y2*(double)mBWdg->YSize();
     1278  }
     1279  else {
     1280    _x1 = x1; _x2 = x2;
     1281    _y1 = y1; _y2 = y2;
     1282  }
     1283
     1284  int dx = (int)(0.06*(_x2-_x1));
     1285  int dy = (int)(0.06*(_y2-_y1));
     1286  if (dx < 20)  dx = 20;
     1287  if (dy < 20)  dx = 20;
     1288  int dxy = (dx < dy) ? dx : dy ;
     1289  if (dxy%2 != 0) dxy++;
     1290  _x1 = _x2-dxy;
     1291  _y1 = _y2-dxy;
     1292  x1 = _x1; 
     1293  y1 = _y1;   
     1294  x2 = y2 = dxy;
     1295  xc = _x1+dxy/2;
     1296  yc = _y1+dxy/2;
     1297  rc = dxy/2-2;
     1298}
     1299
     1300/* --Methode-- */
     1301void PIDrwSelectEvH::ProcessEvent()
     1302{
     1303
     1304  bool chgadrw = false;
     1305  int nid = -1;
     1306
     1307  PIGraphic* gr = mBWdg->WindowGraphic();
     1308
     1309  PIGOMode gmod =  gr->GetGOMode();
     1310  PILineAtt gline = gr->GetLineAtt();
     1311  PIColors gcol = gr->GetForeground();
     1312
     1313
     1314  switch (EventType()) {
     1315    case PIEvent_But1Press :
     1316      // Zone OK=Fin
     1317      if ( (GetPosX() >= _x1) && (GetPosX() <= _x2) &&
     1318           (GetPosY() >= _y1) && ((GetPosY() <= _y2) ) ) _okend = true;
     1319      else {
     1320        nid = mBWdg->FindNearestDrawerId(GetPosX(), GetPosY());
     1321        if (nid != _caid)  chgadrw = true;
     1322      }
     1323      break;
     1324
     1325    default :
     1326      break;
     1327  }
     1328  if ( _okend || chgadrw ) {
     1329    gr->SelForeground(PI_Magenta);
     1330    gr->SelGOMode(PI_GOXOR);
     1331    gr->SelLine(PI_ThinLine);
     1332
     1333    gr->DrawBox(x1,y1, x2, y2);
     1334    gr->DrawFCircle(xc,yc,rc);
     1335
     1336    gr->SelGOMode(gmod);
     1337    gr->SelLine(gline);
     1338    gr->SelForeground(gcol);
     1339
     1340    PIDrawer* adrw = mBWdg->GetActiveDrawer();
     1341    if (adrw) adrw->HighLight(false);
     1342   
     1343    if (_okend) {
     1344      mBWdg->RemoveEventHandler(this);
     1345      _rmok = true;
     1346      return;
     1347    }           
     1348    else {
     1349      mBWdg->SetActiveDrawerId(nid);
     1350      _caid = nid;
     1351      adrw = mBWdg->GetActiveDrawer();
     1352      if (adrw) adrw->HighLight(true);
     1353   
     1354      gr->SelForeground(PI_Magenta);
     1355      gr->SelGOMode(PI_GOXOR);
     1356      gr->SelLine(PI_ThinLine);
     1357
     1358      ComputeOKZone();
     1359
     1360      gr->DrawBox(x1,y1, x2, y2);
     1361      gr->DrawFCircle(xc,yc,rc);
     1362
     1363      gr->SelGOMode(gmod);
     1364      gr->SelLine(gline);
     1365      gr->SelForeground(gcol);
     1366    }
     1367  } 
     1368}
     1369
     1370
     1371
    11831372//------------------------------------------------------------
    11841373/* --Methode-- */
     
    11901379  mFgxor = fgxor;
    11911380  mEvH = NULL;
     1381  mSEvH = NULL;
    11921382
    11931383  if (bwdg == NULL) return;
     
    11991389  AppendSeparator();
    12001390  AppendItem("Detach", 405);
    1201   AppendItem("Highlight", 406);
     1391  AppendItem("MouseSelect", 406);
    12021392  AppendItem("Refresh", 407);
    12031393  int aid = bwdg->GetActiveDrawerId();
     
    12211411      mit += bwdg->GetDrawer(k)->Name();
    12221412      mListDrw->AppendItem(mit.c_str(), 1000+k);
     1413      if (bwdg->GetDrawerIdFromNum(k) == aid) 
     1414        mListDrw->SetSensitivityMsg(1000+k, false);
    12231415    }
    12241416    AppendPDMenu(mListDrw);
    12251417  }
    1226   PIDrawer*  actdr = mBWdg->GetActiveDrawer();
    1227   if (actdr)  actdr->HighLight(true);
     1418//SUP  PIDrawer*  actdr = mBWdg->GetActiveDrawer();
     1419//SUP  if (actdr)  actdr->HighLight(true);
    12281420}
    12291421
     
    12351427    mEvH->CheckBeforeDelete();
    12361428    delete mEvH;
     1429  }
     1430  if (mSEvH) {
     1431    mSEvH->CheckBeforeDelete();
     1432    delete mSEvH;
    12371433  }
    12381434}
     
    12491445    case 401 :
    12501446      if (aid >= 0)  PIDrwTools::ShowPIDrwTools(mBWdg);
    1251       if (actdrw != NULL) actdrw->HighLight(false);
    12521447      break;
    12531448    case 402 :
     
    12601455      if (actdrw != NULL) {
    12611456        actdrw->ShowControlWindow(mBWdg);
    1262         actdrw->HighLight(false);
    12631457      }
    12641458      break;
    12651459    case 404 :
    1266       if (mEvH) delete mEvH;
    1267       if (actdrw != NULL) actdrw->HighLight(false);
     1460      if (mEvH) {
     1461        mEvH->CheckBeforeDelete();     
     1462        delete mEvH;
     1463      }
    12681464      mEvH = new PIDrwPosSizeEvH(mBWdg, mFgxor);
    12691465      break;
     
    12751471      break;
    12761472    case 406 :
    1277       if (actdrw != NULL)  actdrw->HighLight(true);
     1473      if (mSEvH) {
     1474        mSEvH->CheckBeforeDelete();     
     1475        delete mSEvH;
     1476      }
     1477      mSEvH = new PIDrwSelectEvH(mBWdg);
    12781478      break;
    12791479    case 407 :
  • trunk/SophyaPI/PI/pidrwtools.h

    r2529 r2539  
    8585//-------------------------------------------------------------------------------------------
    8686class PIDrwPosSizeEvH;  // Event Handler pour le deplacement/resize des drawers
     87class PIDrwSelectEvH;   // Event Handler pour la selection interactive des drawers
    8788
    8889class PIDrwMgrMenu : public PIMenu {
     
    9697  bool mFgxor;
    9798  PIDrwPosSizeEvH* mEvH;
     99  PIDrwSelectEvH* mSEvH;
    98100};
    99101
  • trunk/SophyaPI/PI/piimage.cc

    r2528 r2539  
    4141//      * <Alt>O : Affichage de la fenêtre de contrôle des paramètres de visualisation.
    4242//      * <Alt>G : Affichage de la fenêtre de changement des attributs graphiques
     43//      * <Alt>D : Affichage du menu de manipulation des traceurs (drawers)
    4344//      * <Alt>R : Rafraîchit l'affichage.
    4445//      * <Alt>V : Copier/*Coller* Ajout du texte du buffer copier/coller
     
    151152cpbuflen = 0;
    152153
     154// Menu pour la manipulation des drawers
     155mDrwMen = NULL;
     156
    153157SetBackgroundColor(PI_Black);
    154158
     
    190194delete trtw;
    191195if (cpbuffer)  delete[] cpbuffer;
     196if (mDrwMen) delete mDrwMen;
    192197if (this == cur_piimage)  cur_piimage = NULL;
    193198}
     
    738743    PIDrwTools::ShowPIDrwTools();   // Fentre axes et options de trace
    739744    }
     745  else if (key == 'D' || key == 'd') {  // Menu de manipulation des drawers
     746    if (mDrwMen) delete mDrwMen;
     747    mDrwMen = new PIDrwMgrMenu(this, true);
     748    mDrwMen->Show();
     749  } 
    740750  else if (key == 'P' || key == 'p') {   // Activation/desactivation affichage curseur
    741751    bool sc = !curshow;
  • trunk/SophyaPI/PI/piimage.h

    r1914 r2539  
    1818
    1919class PIScDrawWdg;
     20class PIDrwMgrMenu;
    2021
    2122class PIImage : public PIPixmap
     
    198199//  PIImage courante
    199200  static PIImage* cur_piimage;
     201
     202// Menu pour la manipulation des drawers
     203  PIDrwMgrMenu* mDrwMen;
    200204};
    201205
  • trunk/SophyaPI/PI/piscdrawwdg.cc

    r2530 r2539  
    3232//      (Par défaut, action identique à <Alt>G)
    3333//      * <Alt>G : Affichage de la fenêtre de changement des attributs graphiques
     34//      * <Alt>D : Affichage du menu de manipulation des traceurs (drawers)
    3435//      * <Alt>R : Rafraîchit l'affichage.
    3536//      * <Alt>M : Active/Désactive l'affichage d'une réticule de mesure (Bouton-1)
     
    8081{
    8182  mFgReticule = false;
    82   mFgShiftBut = false;
    8383  mCPosX = mCPosY = 0;
    8484  mPPos[0] = mPPos[1] = 0.;
     
    156156    PIAxesTools::ShowPIAxesTools();  // Fenetre de gestion des axes
    157157  }
    158   else if (key == 'D' || key == 'd') {
     158  else if (key == 'D' || key == 'd') {  // Menu de manipulation des drawers
    159159    if (mDrwMen) delete mDrwMen;
    160160    mDrwMen = new PIDrwMgrMenu(this, true);
     
    424424  unsigned long tm;
    425425  GetLastEventInfo(kmod, tm);
    426   if (kmod == PIKM_Shift) {   //SetActive Drawer on Shift-Button-1
    427     mFgShiftBut = true;
    428     int nid = FindNearestDrawerId(x,y);
    429     SetActiveDrawerId(nid);
    430     PIDrawer*  actdr = GetActiveDrawer();
    431     if (actdr) {
    432       actdr->HighLight(true);
    433       if (mDrwMen) delete mDrwMen;
    434       mDrwMen = new PIDrwMgrMenu(this);
    435       mDrwMen->Show(this, x, y);
    436     }
    437     return;
    438   }
    439426  UpdateText(x, y);
    440427  if (mTrW)
     
    467454PIScDrawWdg::Ptr1Move(int x, int y)
    468455{
    469   if (mFgShiftBut) return;  //SetActive Drawer on Shift-Button-1
    470456  UpdateText(x, y);  // Met a jour mPPos
    471457  if (mFgReticule)  DrawReticule(x,y,1);
     
    474460void
    475461PIScDrawWdg::But1Release(int x, int y)
    476 {
    477   if (mFgShiftBut) {  //SetActive Drawer on Shift-Button-1
    478     mFgShiftBut = false;
    479     /*
    480     PIDrawer*  actdr = GetActiveDrawer();
    481     if (actdr) {
    482 //      actdr->HighLight(false);
    483       if (mDrwMen) delete mDrwMen;
    484       mDrwMen = new PIDrwMgrMenu(this);
    485       mDrwMen->Show();
    486     }
    487     */
    488     return;
    489   }
    490  
     462
    491463  UpdateText(x, y);
    492464  if (mFgReticule)  DrawReticule(x,y,2);
  • trunk/SophyaPI/PI/piscdrawwdg.h

    r2528 r2539  
    102102  int mPosFDX, mPosFDY;       // Position (coord fenetre memorise)
    103103  bool mFgReticule;       // Controle l'affiche d'une réticule (Bouton-1)
    104   bool mFgShiftBut;       // true -> shift-Button
    105104  string mFormatOpt[2];   // Format optimal d'impression des textes
    106105
Note: See TracChangeset for help on using the changeset viewer.