Changeset 2503 in Sophya
- Timestamp:
- Mar 9, 2004, 7:21:48 PM (22 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 14 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 -
trunk/SophyaPI/PI/pibwdggen.h
r1827 r2503 104 104 virtual int GetActiveDrawerId(); 105 105 virtual int GetActiveDrawerNum(); 106 106 107 virtual PIDrawer* GetActiveDrawer(); 108 109 // Recherche du plus proche Drawer 110 virtual int FindNearestDrawerId(int x, int y); 107 111 108 112 // Trace des Drawers ... -
trunk/SophyaPI/PI/pidrawer.cc
r2394 r2503 374 374 // L'implémentation par défaut effectue le décodage des attributs graphiques en 375 375 // utilisant la méthode *PIGraphicAtt::DecodeAttStrings()* 376 // int OptionToString(vector<string> & opt) const 377 // Méthode virtuelle qui peut être redéfinie dans les classes filles, 378 // pour fournir des chaines de caracteres décodable par *DecodeOptionString()* . 379 // Renvoie le nombre d'éléments ajoutés. 380 // L'implémentation par défaut effectue le décodage des attributs graphiques en 381 // utilisant la méthode *PIGraphicAtt::AttToStrings()* 376 382 // void GetOptionsHelpInfo(string& info) 377 383 // Ajoute au bout de la chaine "info" l'aide concernant le décodage des options du traceur. … … 385 391 UpdateGraphicAtt(gratt); 386 392 return(ndec); 393 } 394 395 int 396 PIDrawer::OptionToString(vector<string> & opt) const 397 { 398 return mGrAtt.AttToStrings(opt); 387 399 } 388 400 … … 438 450 xW0 = x0; yW0 = y0; 439 451 xWd = dx; yWd = dy; 452 if (!limitsFixed) UpdateLimits(); 440 453 if (mGrUC) delete mGrUC; 441 454 mGrUC = new PIGraphicUC(g, x0, y0, dx, dy); … … 452 465 453 466 void 467 PIDrawer::WdgCoord2DrwCoord(int x, int y, double& xu, double& yu, 468 int x0, int y0, int dx, int dy) 469 { 470 if (!limitsFixed) UpdateLimits(); 471 PIGraphicUC guc(NULL, x0, y0, dx, dy); 472 guc.SetUCS(xMin, xMax, yMin, yMax, aXFlg, aYFlg); 473 if (aXlog || aYlog) guc.SetLogScale(aXlog, aYlog); 474 guc.GrC2UC(x,y,xu,yu); 475 return; 476 } 477 478 void 454 479 PIDrawer::SetAxesFlags(unsigned int flags) 455 480 { … … 496 521 // rectangulaire "(xmin,ymin) -- (xmax,ymax)". 497 522 // L'implémentation par défaut ne fait rien. 523 // double GetDistanceToPoint(double x, double y) 524 // Fournit une distance au point "x,y". Valeur entre 0 et 1 au bord xmin/max,ymin/max. 525 // L'implémentation par défaut retourne la distance normalisée au point 526 // ((xmin+xmax)/2,(ymin+ymax)/2) 498 527 //-- 499 528 … … 508 537 { 509 538 } 539 540 double 541 PIDrawer::GetDistanceToPoint(double x, double y) 542 { 543 double xc = 0.5*(XMin()+XMax()); 544 double yc = 0.5*(YMin()+YMax()); 545 double delx = (x-xc)/(0.5*(XMax()-XMin())); 546 double dely = (y-yc)/(0.5*(YMax()-YMin())); 547 return sqrt((delx*delx+dely*dely)/2.); 548 } -
trunk/SophyaPI/PI/pidrawer.h
r2301 r2503 42 42 virtual void GetClickInfo(string& info,double x,double y 43 43 ,double x0=0.,double y0=0.,bool fgdiff=false); 44 // Renvoie une distance au point x,y 45 // 0: au(x) point(s) le(s) plus proche(s) ... 1 au bord xmin/xmax , ymin/ymax 46 // La methode par defaut calcule la distance normalisee au point ((xmin+xmax)/2,(ymin+ymax)/2) 47 virtual double GetDistanceToPoint(double x, double y); 44 48 45 49 virtual void Refresh(); // Recalcule les limites et reaffiche … … 83 87 // Methode permettant de decoder des options a partir de chaines 84 88 virtual int DecodeOptionString(vector<string> & opt, bool rmdecopt=true); 89 // Methode retournant un vecteur de string a partir des options 90 virtual int OptionToString(vector<string> & opt) const; 91 85 92 // Texte d'aide des options disponibles 86 93 virtual void GetOptionsHelpInfo(string& info); … … 94 101 // Pb avec acces depuis PIBaseWdgGen (Reza 11/07/97) 95 102 virtual PIGraphicUC* SetDrwWdg(PIBaseWdgGen* drw, int x0, int y0, int dx, int dy, PIGraphicGen* g); 103 // Transformation coordonnees fenetre en coordonnees drawer 104 virtual void WdgCoord2DrwCoord(int x, int y, double& xu, double& yu, 105 int x0, int y0, int dx, int dy); 96 106 97 107 // Je declare en public a cause de cxx - Reza 11/07/97 -
trunk/SophyaPI/PI/pidrwtools.cc
r2394 r2503 773 773 mLab->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 774 774 mLab->SetLabel(""); 775 cpx += 2. 6*bsx;776 mBut[0] = new PIButton(this, "SetOption", 555, bsx*1. 5, bsy, cpx, cpy);775 cpx += 2.3*bsx; 776 mBut[0] = new PIButton(this, "SetOption", 555, bsx*1.2, bsy, cpx, cpy); 777 777 mBut[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 778 cpx += 1. 8*bsx;779 mBut[1] = new PIButton(this, " Dimiss", 777, bsx*1.5, bsy, cpx, cpy);778 cpx += 1.25*bsx; 779 mBut[1] = new PIButton(this, "GetOption", 666, bsx*1.2, bsy, cpx, cpy); 780 780 mBut[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 781 cpx += 1.25*bsx; 782 mBut[2] = new PIButton(this, "Dimiss", 777, bsx*1.2, bsy, cpx, cpy); 783 mBut[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 781 784 } 782 785 … … 789 792 delete mBut[0]; 790 793 delete mBut[1]; 794 delete mBut[2]; 791 795 } 792 796 /* --Methode-- */ … … 842 846 mDrw->Refresh(); 843 847 } 848 break; 849 case 666: 850 if (mDrw) { 851 vector<string> vops; 852 mDrw->OptionToString(vops); 853 string ops; 854 for(int kk=0; kk<vops.size(); kk++) { 855 ops += vops[kk]; ops += ' '; 856 } 857 mTxt[1]->SetText(ops); 858 } 859 break; 844 860 default : 845 861 break; -
trunk/SophyaPI/PI/pidrwtools.h
r2387 r2503 76 76 PIText* mTxt[2]; 77 77 PILabel* mLab; 78 PIButton* mBut[ 2];78 PIButton* mBut[3]; 79 79 PIDrawer* mDrw; 80 80 }; -
trunk/SophyaPI/PI/pieldrw.cc
r2394 r2503 675 675 } 676 676 677 /* --Methode-- */ 678 double PIElDrawer::GetDistanceToPoint(double x, double y) 679 { 680 double dist,disty,distx,d1,d2; 681 bool fgokx, fgoky; 682 d1 = fabs(x-XMin()); 683 d2 = fabs(x-XMax()); 684 if ((y<YMax()) && (y>YMin())) { 685 distx = (d1 < d2) ? d1 : d2; 686 distx /= 0.5*(XMax()-XMin()); 687 fgokx = true; 688 } 689 else fgokx = false; 690 d1 = fabs(y-YMin()); 691 d2 = fabs(y-YMax()); 692 if ((x<XMax()) && (x>XMin())) { 693 disty = (d1 < d2) ? d1 : d2; 694 disty /= 0.5*(YMax()-YMin()); 695 fgoky = true; 696 } 697 else fgoky = false; 698 if (!fgokx && !fgoky) return PIDrawer::GetDistanceToPoint(x,y); 699 else { 700 if (fgokx && fgoky) dist = (distx<disty) ? distx : disty; 701 else if (fgokx) dist = distx; 702 else dist = disty; 703 } 704 return dist; 705 } -
trunk/SophyaPI/PI/pieldrw.h
r2387 r2503 224 224 virtual void Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax); 225 225 226 // Renvoie une distance au point x,y 227 // 0: au(x) point(s) le(s) plus proche(s) ... 1 au bord xmin/xmax , ymin/ymax 228 // La methode par defaut calcule la distance normalisee au point ((xmin+xmax)/2,(ymin+ymax)/2) 229 virtual double GetDistanceToPoint(double x, double y); 230 226 231 inline void ConfigureAxeTicks(int ntickx=0, int nticky=0, 227 232 double majtl=0., double mintl=0.) -
trunk/SophyaPI/PI/pigratt.cc
r2401 r2503 87 87 // Si "rmdecatt == true", les attributs décodés sont supprimés du 88 88 // vecteur de départ. 89 // int AttToStrings(vector<string> & att) const 90 // Renvoie dans "att" les attributs sous forme de string Décodeable 91 // par *DecodeAttStrings()* . Retourne le nombre d'éléments ajoutés. 89 92 // unsigned long DecodeTextPosDirAtt(vector<string> & att, bool rmdecatt=true) 90 93 // Décode les attributs de direction et de positionnement de tracé de texte … … 654 657 } 655 658 659 int PIGraphicAtt::AttToStrings(vector<string> & att) const 660 { 661 // A FAIRE - Reza->CMV Mars 2004 662 // On ne vide pas (ne met pas a zero) att, mais on ajoute derriere. 663 att.push_back("A FAIRE - Reza->CMV Mars 2004"); 664 return 1; 665 } 666 656 667 int PIGraphicAtt::DecodeTextPosDirAtt(vector<string> & att, unsigned long& tdirpos, 657 668 bool rmdecatt) -
trunk/SophyaPI/PI/pigratt.h
r2242 r2503 33 33 virtual void UpdateFrom(PIGraphicAtt const & att); 34 34 virtual int DecodeAttStrings(vector<string> & att, bool rmdecatt=true); 35 virtual int AttToStrings(vector<string> & att) const; 35 36 // decodage des attributs de positions et direction de trace de texte 36 37 static int DecodeTextPosDirAtt(vector<string> & att, unsigned long& tdirpos, -
trunk/SophyaPI/PI/piscdrawwdg.cc
r2349 r2503 80 80 { 81 81 mFgReticule = false; 82 mFgShiftBut = false; 82 83 mCPosX = mCPosY = 0; 83 84 mPPos[0] = mPPos[1] = 0.; … … 408 409 PIScDrawWdg::But1Press(int x, int y) 409 410 { 411 PIKeyModifier kmod; 412 unsigned long tm; 413 GetLastEventInfo(kmod, tm); 414 if (kmod == PIKM_Shift) { //SetActive Drawer on Shift-Button-1 415 mFgShiftBut = true; 416 int nid = FindNearestDrawerId(x,y); 417 SetActiveDrawerId(nid); 418 PIDrawer* actdr = GetActiveDrawer(); 419 if (actdr) { 420 actdr->HighLight(true); 421 } 422 return; 423 } 410 424 UpdateText(x, y); 411 425 if (mTrW) … … 438 452 PIScDrawWdg::Ptr1Move(int x, int y) 439 453 { 454 if (mFgShiftBut) return; //SetActive Drawer on Shift-Button-1 440 455 UpdateText(x, y); // Met a jour mPPos 441 456 if (mFgReticule) DrawReticule(x,y,1); … … 445 460 PIScDrawWdg::But1Release(int x, int y) 446 461 { 462 if (mFgShiftBut) { //SetActive Drawer on Shift-Button-1 463 mFgShiftBut = false; 464 PIDrawer* actdr = GetActiveDrawer(); 465 if (actdr) { 466 actdr->HighLight(false); 467 } 468 return; 469 } 470 447 471 UpdateText(x, y); 448 472 if (mFgReticule) DrawReticule(x,y,2); -
trunk/SophyaPI/PI/piscdrawwdg.h
r2349 r2503 101 101 int mPosFDX, mPosFDY; // Position (coord fenetre memorise) 102 102 bool mFgReticule; // Controle l'affiche d'une réticule (Bouton-1) 103 bool mFgShiftBut; // true -> shift-Button 103 104 string mFormatOpt[2]; // Format optimal d'impression des textes 104 105 -
trunk/SophyaPI/PI/piwdggen.cc
r1914 r2503 79 79 // pour decoder des options a partir de chaines de caracteres. 80 80 // Renvoie le nombre d'options decodees. 81 // int OptionToString(vector<string> & opt) const 82 // Méthode virtuelle qui peut être redéfinie dans les classes filles, 83 // pour fournir des chaines de caracteres décodable par *DecodeOptionString()* . 84 // Renvoie le nombre d'éléments ajoutés. 81 85 //-- 82 86 … … 84 88 { 85 89 return(0); 90 } 91 int PIWdgGen::OptionToString(vector<string> & opt) const 92 { 93 return(0); 86 94 } 87 95 -
trunk/SophyaPI/PI/piwdggen.h
r1914 r2503 73 73 virtual int DecodeOptionString(vector<string> & opt, 74 74 bool rmdecopt=true); 75 // Remplissage de chaine decodable par DecodeOptionString() a partir des options 76 virtual int OptionToString(vector<string> & opt) const; 75 77 76 78 // Gestion des accrochages (binding) aux containers
Note:
See TracChangeset
for help on using the changeset viewer.