Changeset 2503 in Sophya for trunk/SophyaPI/PI/pibwdggen.cc
- Timestamp:
- Mar 9, 2004, 7:21:48 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/pibwdggen.cc
r2301 r2503 502 502 // PIDrawer* GetActiveDrawer() 503 503 // Retourne le pointeur sur le traceur actif (NULL si pas de traceur actif). 504 // int FindNearestDrawerId(int x, int y) 505 // Retourne le numéro du traceur le plus proche au point "(x,y)" de l'objet PIBaseWdg. 506 // -1 si pas de traceur. 504 507 //-- 505 508 … … 540 543 if (mActDrwId < 0) return(NULL); 541 544 else return(GetDrawerId(mActDrwId)); 545 } 546 547 /* --Methode-- */ 548 int PIBaseWdgGen::FindNearestDrawerId(int xp, int yp) 549 { 550 if (mDrwList.size() < 1) return -1; 551 double xmin,ymin, xmax, ymax; 552 int drx0, dry0, drdx, drdy; 553 int ddrx0, ddry0, ddrdx, ddrdy; 554 555 if (mDrElastic) { 556 ddrx0 = (int)((double) mDrX1 * (double)XSize()); 557 ddry0 = (int)((double) mDrY1 * (double)YSize()); 558 ddrdx = (int)((double) mDrX2 * (double)XSize()) - ddrx0 ; 559 ddrdy = (int)((double) mDrY2 * (double)YSize()) - ddry0 ; 560 } 561 else { 562 ddrx0 = (int)mDrX1; ddry0 = (int)mDrY1; 563 ddrdx = (int)mDrX2-ddrx0; ddrdy = (int)mDrY2-ddry0; 564 } 565 566 int nid = -1; 567 double neardist = 9.e39; 568 bool fgido = false; 569 570 vector<BWDrwId>::iterator it; 571 for(it = mDrwList.begin(); it != mDrwList.end(); it++) { 572 if ( (*it).autoszp ) // Taille/position par defaut impose par PIBaseWdg 573 { drx0 = ddrx0; dry0 = ddry0; drdx = ddrdx; drdy = ddrdy; } 574 else { 575 if ( (*it).elastic ) { // Taille/position defin en fraction de la taille du PIBaseWdg 576 drx0 = (int)((double)(*it).x1 * (double)XSize()); 577 dry0 = (int)((double)(*it).y1 * (double)YSize()); 578 drdx = (int)((double)(*it).x2 * (double)XSize()) - drx0 ; 579 drdy = (int)((double)(*it).y2 * (double)YSize()) - dry0 ; 580 } 581 else { 582 drx0 = (int)(*it).x1 ; dry0 = (int)(*it).y1 ; 583 drdx = (int)(*it).x2-drx0 ; drdy = (int)(*it).y2-dry0 ; 584 } 585 } 586 // L'ordre des operations ici est importante 587 if ( (*it).autolim ) { 588 (*it).drw->SetLimits(mDrXmin, mDrXmax, mDrYmin, mDrYmax, mDXdir, mDYdir); 589 (*it).drw->SetLogScale(mDXlog, mDYlog); 590 } 591 double xu, yu; 592 (*it).drw->WdgCoord2DrwCoord(xp, yp, xu, yu, drx0, dry0, drdx, drdy); 593 double curd = (*it).drw->GetDistanceToPoint(xu, yu); 594 if (!fgido || (curd < neardist)) { 595 neardist = curd; nid = (*it).id; fgido = true; 596 } 597 } 598 return nid; 542 599 } 543 600
Note:
See TracChangeset
for help on using the changeset viewer.