Changeset 2528 in Sophya for trunk/SophyaPI
- Timestamp:
- Apr 27, 2004, 5:48:48 PM (21 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/pi3dwdg.cc
r2399 r2528 61 61 // long kind() 62 62 // 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". 65 65 //-- 66 66 … … 79 79 // AddDrawer(mBDrw, 0.12, 0.12, 0.88, 0.88, true, false, false); 80 80 mBDrw->SetLimits(0.,1.,0.,1.,kAxeDirLtoR,kAxeDirDownUp); 81 AddDrawer3D(mBDrw, false );81 AddDrawer3D(mBDrw, false, true); 82 82 mBDrw->SetAxesFlags(kStdAxes); 83 83 vfixed = false; // Il faut laisser le premier Drawer3D fixer les limites et la vue 3D … … 204 204 205 205 /* --Methode-- */ 206 int PIDraw3DWdg::AddDrawer3D(PIDrawer3D* dr3, bool ad )206 int PIDraw3DWdg::AddDrawer3D(PIDrawer3D* dr3, bool ad, bool lock) 207 207 { 208 208 if ((!vfixed) && (dr3 != mBDrw)) { … … 221 221 else dr3->Set3DView(xc, yc, zc, xo, yo, zo, dax, day, co, psi); 222 222 } 223 int id = AddDrawer(dr3, false, false, ad );223 int id = AddDrawer(dr3, false, false, ad, lock); 224 224 if (dr3 != mBDrw) dr3->SetAxesFlags(kAxesNone); 225 225 m3DrIl.push_back(id); -
trunk/SophyaPI/PI/pi3dwdg.h
r2164 r2528 46 46 47 47 // Ajoute un Drawer 48 int AddDrawer3D(PIDrawer3D*, bool ad=false );48 int AddDrawer3D(PIDrawer3D*, bool ad=false, bool lock=false); 49 49 50 50 // Pour tenir trace des Drawers-3D qui sont detruits -
trunk/SophyaPI/PI/pibwdggen.cc
r2527 r2528 306 306 //-- 307 307 //++ 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) 309 309 // Définition du rectangle d'attachement par défaut. "(x1,y1)" et "(x2,y2)" determinent 310 310 // les positions des deux coins opposés. 311 // si " psz=true", les coordonnées sont supposées être des facteurs multiplicatifs311 // si "elastic=true", les coordonnées sont supposées être des facteurs multiplicatifs 312 312 // 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. 313 317 // void SetDefaultDrawerLimits(double xmin, double xmax, double ymin, double ymax, - 314 318 // int axrl=kAxeDirSame, int ayud=kAxeDirSame) … … 322 326 323 327 /* --Methode-- */ 324 void PIBaseWdgGen::SetDefaultDrawRectangle(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, bool psz)328 void PIBaseWdgGen::SetDefaultDrawRectangle(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, bool elastic) 325 329 { 326 330 mDrX1 = x1; mDrY1 = y1; 327 mDrX2 = x2; mDrY2 = y2; mDrElastic = psz; 331 mDrX2 = x2; mDrY2 = y2; mDrElastic = elastic; 332 } 333 334 /* --Methode-- */ 335 void PIBaseWdgGen::GetDefaultDrawRectangle(PIGrCoord& x1, PIGrCoord& y1, PIGrCoord& x2, PIGrCoord& y2, bool& elastic) 336 { 337 x1 = mDrX1; y1 = mDrY1; 338 x2 = mDrX2; y2 = mDrY2; elastic = mDrElastic; 328 339 } 329 340 … … 347 358 //++ 348 359 // 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) 350 361 // Attachement d'un "PIDrawer" au rectangle défini les coordonnées des deux coins opposés. 351 362 // si "psz=true", les coordonnées sont supposées être des facteurs multiplicatifs … … 354 365 // d'attachement. 355 366 // 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. 356 368 // 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) 358 370 // Ajout d'un "PIDrawer" au rectangle d'attachement par défaut. 359 371 // Si "autolim=true", l'objet "PIBaseWdg" impose l'espace de coordonnées utilisateur … … 362 374 // d'attachement. 363 375 // 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. 364 377 // La méthode retourne l'identificateur du drawer attaché. 365 378 //-- … … 367 380 /* --Methode-- */ 368 381 int 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) 370 383 { 371 384 if (drw == NULL) return(0); … … 377 390 did.elastic = psz; did.clip = clip; 378 391 did.id = mDrwId; did.ad = ad; 392 did.lock = lock; 379 393 did.drw = drw; 380 394 mDrwList.push_back(did); … … 385 399 386 400 /* --Methode-- */ 387 int PIBaseWdgGen::AddDrawer(PIDrawer* drw, bool autolim, bool clip, bool ad )401 int PIBaseWdgGen::AddDrawer(PIDrawer* drw, bool autolim, bool clip, bool ad, bool lock) 388 402 { 389 403 if (drw == NULL) return(0); … … 394 408 did.autoszp = true; did.autolim = autolim; 395 409 did.elastic = false; did.clip = clip; 396 did.id = mDrwId; did.ad = ad; 410 did.id = mDrwId; did.ad = ad; 411 did.lock = lock; 397 412 did.drw = drw; 398 413 mDrwList.push_back(did); … … 404 419 405 420 //++ 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) 407 422 // 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. 409 424 // void RemoveDrawer(int id) 410 // Ote le drawer "id" de la liste .425 // Ote le drawer "id" de la liste des drawers du PIBaseWdg. 411 426 // void DeleteDrawers() 412 427 // Ote tous les drawers de la liste. Détruit ceux ajoutés avec l'option "ad=true" … … 414 429 415 430 /* --Methode-- */ 416 void PIBaseWdgGen::MoveResizeDrawer(int id, PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, bool psz)431 void PIBaseWdgGen::MoveResizeDrawer(int id, PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2, bool elastic) 417 432 { 418 433 vector<BWDrwId>::iterator it; … … 421 436 (*it).x1 = x1; (*it).y1 = y1; 422 437 (*it).x2 = x2; (*it).y2 = y2; 423 (*it).elastic = psz;438 (*it).elastic = elastic; 424 439 break; 425 440 } … … 462 477 // Retourne le nombre de PIDrawer attachés 463 478 // PIDrawer* GetDrawerId(int id) 464 // Retourne le PIDrawer avec l'identificateur id479 // Retourne le PIDrawer avec l'identificateur "id". 465 480 // PIDrawer* GetDrawer(int n) 466 481 // 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-- */ 496 int PIBaseWdgGen::GetDrawerIdFromNum(int n) 497 { 498 if ( (n < 0) || (n >= mDrwList.size()) ) return(-1); 499 return(mDrwList[n].id); 473 500 } 474 501 … … 490 517 } 491 518 519 /* --Methode-- */ 520 bool PIBaseWdgGen::IsDrawerLockedId(int id) 521 { 522 vector<BWDrwId>::iterator it; 523 for(it = mDrwList.begin(); it != mDrwList.end(); it++) 524 if ((*it).id == id) return((*it).lock); 525 return true; 526 } 527 528 /* --Methode-- */ 529 bool PIBaseWdgGen::IsDrawerAutoSizePos(int id) 530 { 531 vector<BWDrwId>::iterator it; 532 for(it = mDrwList.begin(); it != mDrwList.end(); it++) 533 if ((*it).id == id) return(! (*it).autoszp ); 534 return false; 535 } 536 537 /* --Methode-- */ 538 void PIBaseWdgGen::GetDrawerPosition(int id, PIGrCoord& x1, PIGrCoord& y1, 539 PIGrCoord& x2, PIGrCoord& y2, bool& elastic) 540 { 541 x1 = y1 = x2 = y2 = 0; 542 elastic = false; 543 vector<BWDrwId>::iterator it; 544 for(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 } 551 return; 552 } 492 553 493 554 //++ -
trunk/SophyaPI/PI/pibwdggen.h
r2503 r2528 80 80 virtual void SetDefaultDrawRectangle(PIGrCoord x1, PIGrCoord y1, 81 81 PIGrCoord x2, PIGrCoord y2, bool psz=true); 82 virtual void GetDefaultDrawRectangle(PIGrCoord& x1, PIGrCoord& y1, 83 PIGrCoord& x2, PIGrCoord& y2, bool& psz); 82 84 virtual void SetDefaultDrawerLimits(double xmin, double xmax, double ymin, double ymax, 83 85 int axrl=kAxeDirSame, int ayud=kAxeDirSame); … … 88 90 virtual int AddDrawer(PIDrawer* drw, PIGrCoord x1, PIGrCoord y1, 89 91 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); 92 96 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); 94 98 virtual void RemoveDrawer(int id); // Ote un drawer de la liste 95 99 virtual void DeleteDrawers(); // Ote tous les drawers, delete des drawers ajoute avec ad=true 100 96 101 // 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 101 111 // 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(); 108 117 109 118 // Recherche du plus proche Drawer … … 114 123 virtual void CallDrawer(int id); 115 124 116 // Devrait etre protected - mis ici a cause de cxx 11/07/97 Reza117 struct BWDrwId { int id; PIGrCoord x1, y1, x2, y2; bool autoszp, autolim, elastic, clip, ad; PIDrawer* drw; };118 119 125 virtual PIGraphic* WindowGraphic(); 120 126 121 // -------------- Variables membre protegees -------------------127 // -------------- Variables membres protegees ------------------- 122 128 protected: 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 123 143 PIGraphicWin* mWGrC; // PIGraphic (Contexte graphique) associe a la fenetre 124 144 bool mAdfg; // Pour la gestion de DeleteDrawers() quand appele par delete de PIBaseWdg -
trunk/SophyaPI/PI/pidrwtools.cc
r2503 r2528 863 863 } 864 864 } 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 885 class PIDrwPosSizeEvH : public PIEventHandler { 886 public: 887 PIDrwPosSizeEvH(PIBaseWdg* bwdg); 888 virtual void ProcessEvent(); 889 protected: 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-- */ 901 PIDrwPosSizeEvH::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-- */ 964 void 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-- */ 1146 PIDrwMgrMenu::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-- */ 1189 PIDrwMgrMenu::~PIDrwMgrMenu() 1190 { 1191 if (mListDrw) delete mListDrw; 1192 if (mEvH) delete mEvH; 1193 } 1194 1195 /* --Methode-- */ 1196 void 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 8 8 #include "pisysdep.h" 9 9 #include PISTDWDG_H 10 #include PIMENU_H 10 11 #include PIOPTMENU_H 11 12 #include PIWIN_H … … 80 81 }; 81 82 83 //------------------------------------------------------------------------------------------- 84 // Classe de menu specifique de manipulation interactive des drawers attaches a un PIBaseWdg 85 //------------------------------------------------------------------------------------------- 86 class PIDrwPosSizeEvH; // Event Handler pour le deplacement/resize des drawers 87 88 class PIDrwMgrMenu : public PIMenu { 89 public: 90 PIDrwMgrMenu(PIBaseWdg* bwdg); 91 virtual ~PIDrwMgrMenu(); 92 virtual void Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL); 93 protected: 94 PIMenu* mListDrw; 95 PIBaseWdg* mBWdg; 96 PIDrwPosSizeEvH* mEvH; 97 }; 98 82 99 #endif -
trunk/SophyaPI/PI/piimage.cc
r2357 r2528 143 143 mdrw->SetAxesFlags(kAxesNone); 144 144 gvdrw = new PIElDrawer(); 145 AddDrawer(mdrw, true, false, false );145 AddDrawer(mdrw, true, false, false, false); 146 146 147 147 SetLut(-9.e19, 9.e19, kLutType_Lin, 0, false); -
trunk/SophyaPI/PI/piscdrawwdg.cc
r2504 r2528 70 70 // void SetAxesFlags(unsigned int flags=kAxesDflt) 71 71 // Définit les attributs des axes. 72 // int AddScDrawer(PIDrawer*, bool ad=false )72 // int AddScDrawer(PIDrawer*, bool ad=false, bool lock=false) 73 73 // Ajoute un Drawer. 74 74 //-- … … 96 96 FreeLimits(); 97 97 xEndDrag = yEndDrag = xBegDrag = yBegDrag = 0; 98 AddDrawer(mBDrw, true, false, false );98 AddDrawer(mBDrw, true, false, false, false); 99 99 100 100 // Pour afficher les coordonnees courante (click-bouton-1) … … 106 106 mInfoW = NULL; 107 107 mInfoTxt = NULL; 108 109 // Menu pour la manipulation des drawers 110 mDrwMen = NULL; 108 111 109 112 ActivateKeyboard(); … … 125 128 PIAxesTools::SetCurrentScDrawWdg(NULL); 126 129 // Pour PIDrwTools, c'est fait par le destructeur de PIBaseWdgGen 130 if (mDrwMen) delete mDrwMen; 127 131 } 128 132 … … 152 156 PIAxesTools::ShowPIAxesTools(); // Fenetre de gestion des axes 153 157 } 154 158 else if (key == 'D' || key == 'd') { 159 if (mDrwMen) delete mDrwMen; 160 mDrwMen = new PIDrwMgrMenu(this); 161 mDrwMen->Show(); 162 } 155 163 else if (key == 'I' || key == 'i') UpdateInfoWindow(); // Fenetre Text-Info 156 164 } … … 290 298 291 299 int 292 PIScDrawWdg::AddScDrawer(PIDrawer* d, bool ad )300 PIScDrawWdg::AddScDrawer(PIDrawer* d, bool ad, bool lock) 293 301 { 294 302 if (d == NULL) return(-1); … … 301 309 SetLimits(d->XMin(), d->XMax(), d->YMin(), d->YMax(), mDXdir, mDYdir); 302 310 } 303 return(AddDrawer(d, true, true, ad ));311 return(AddDrawer(d, true, true, ad, lock)); 304 312 } 305 313 … … 469 477 if (actdr) { 470 478 actdr->HighLight(false); 479 if (mDrwMen) delete mDrwMen; 480 mDrwMen = new PIDrwMgrMenu(this); 481 mDrwMen->Show(this, x, y); 471 482 } 472 483 return; -
trunk/SophyaPI/PI/piscdrawwdg.h
r2503 r2528 16 16 17 17 // PIScDrawWdg, Gestionnaire de traceur 2D 18 class PIDrwMgrMenu; 18 19 19 20 class PIScDrawWdg : public PIBaseWdg { … … 47 48 48 49 // Ajoute un Drawer en auto 49 int AddScDrawer(PIDrawer*, bool ad=false );50 int AddScDrawer(PIDrawer*, bool ad=false, bool lock=false); 50 51 51 52 inline PIElDrawer* BaseDrawer() { return mBDrw; }; … … 120 121 PIText * mInfoTxt; 121 122 123 // Menu pour la manipulation des drawers 124 PIDrwMgrMenu* mDrwMen; 125 122 126 private: 123 127 void UpdateText(int xp, int yp); -
trunk/SophyaPI/PI/piwdgx.cc
r2417 r2528 917 917 { 918 918 PIWdgGen::AddDrawHandler(drwh, ad); 919 XtInsertEventHandler( XtWdg(), ExposureMask, FALSE, evthandler_piwdgx, this, XtListTail); 919 if (mDHlist.size() == 1) 920 XtInsertEventHandler( XtWdg(), ExposureMask, FALSE, evthandler_piwdgx, this, XtListTail); 920 921 } 921 922 … … 924 925 { 925 926 PIWdgGen::RemoveDrawHandler(drwh); 926 if (m EHlist.size() <= 0) XtRemoveEventHandler( XtWdg(), ExposureMask, FALSE, evthandler_piwdgx, this);927 if (mDHlist.size() == 0) XtRemoveEventHandler( XtWdg(), ExposureMask, FALSE, evthandler_piwdgx, this); 927 928 } 928 929 … … 946 947 if (evtmask & PIEvent_Ptr3Move) mask |= (PointerMotionHintMask | Button3MotionMask); 947 948 if (evtmask & PIEvent_Keyboard) mask |= KeyPressMask; 948 printf("PIWdgX::AddEventHandler() Mask = %lx \n", (long)mask);949 // printf("PIWdgX::AddEventHandler() Mask = %lx \n", (long)mask); 949 950 XtInsertEventHandler( XtWdg(), mask, FALSE, evthandler_piwdgx, this, XtListTail); 950 951 } … … 954 955 { 955 956 PIWdgGen::RemoveEventHandler(evh); 957 //cout << "DBG-PIWdgX::RemoveEventHandler( " << hex << evh << dec << ") mEHlist.size()=" 958 // << mEHlist.size() << endl; 956 959 if (mEHlist.size() > 0) return; 957 960 EventMask mask = EnterNotify; … … 992 995 int k, int km, unsigned long tm) 993 996 { 997 //cout << "DBG-PIWdgX:CallEventHandlers() - mEHlist.size()=" << mEHlist.size() << endl; 994 998 PIEventHandler* eh; 995 999 list<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() 1002 list<EvHand> cEHlist; 1003 for(it= mEHlist.begin(); it != mEHlist.end(); it++) { 997 1004 if (!((*it).mask & evt)) continue; 1005 cEHlist.push_back(*it); 1006 } 1007 // Et on refait la boucle sur la liste copiee ... 1008 for(it= cEHlist.begin(); it != cEHlist.end(); it++) { 998 1009 eh = (*it).evh; 999 1010 eh->SetCurrentWdg(this);
Note:
See TracChangeset
for help on using the changeset viewer.