Changeset 368 in Sophya for trunk/SophyaPI/PIext/piafitting.cc
- Timestamp:
- Aug 9, 1999, 1:57:10 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PIext/piafitting.cc
r361 r368 29 29 30 30 //// ---------- Classe de fenetre de fit interactive ------------ 31 #define FINPARMAX 10 // Nb maxi de parametres de fit 32 31 33 class PIAFitterWind : public PIWindow { 32 34 public : … … 36 38 virtual void Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL); 37 39 inline void SetObjName(string& nom) { oname = nom; } 40 void SetNbParms(int npar); 38 41 protected : 39 42 PIStdImgApp* dap; 40 43 PIAFitter* fitter; 44 PILabel* labn; 41 45 PIOptMenu* pom[2]; 42 PILabel* lab[2]; // Maximum 20 parametres43 PIText* txt[2]; // " " "44 46 PIButton* but[2]; 45 47 PICheckBox* ckb[2]; 48 PILabel* lab[2]; 49 PILabel* labp[FINPARMAX]; // Maximum FINPARMAX parametres 50 PIText* txtp[FINPARMAX]; // " " " 51 PIText* txts[FINPARMAX]; // " " " 46 52 string oname; 47 53 }; … … 101 107 } 102 108 else if (kw == "fitw") { 109 if (tokens.size() < 1) { 110 cout << "Usage: fitw nomobj" << endl; 111 return(0); 112 } 103 113 cout << " *DBG* Affichage PIAFitterWind ** " << endl; 114 fwind->SetObjName(tokens[0]); 104 115 fwind->Show(); 105 116 } … … 592 603 spy = bsy/4; 593 604 594 int wszx = 5*spx+3*bsx;605 int wszx = 3*spx+4*bsx; 595 606 int wszy = 5*bsy+6*spy; 596 607 SetSize(wszx, wszy); 597 608 int cpx = spx; 598 609 int cpy = spy; 599 int csx = cpx; 600 int csy = cpy; 601 lab[0] = new PILabel(this, "Object", 1.5*bsx, bsy, cpx, cpy); 610 611 cpx = spx+bsx; 612 labn = new PILabel(this, "ObjectName", 2.0*bsx, bsy, cpx, cpy); 613 labn->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free); 614 602 615 cpy += spy+bsy; 603 lab[1] = new PILabel(this, "Params", 1.5*bsx, bsy, cpx, cpy); 604 cpx += bsx*1.5+spx; 605 606 cpy = spy; 607 txt[0] = new PIText(this, "", 3.5*bsx, bsy, cpx, cpy); 616 cpx = spx; 617 ckb[0] = new PICheckBox(this,"Gen.Func", 1001, 2*bsx, bsy, cpx, cpy); 618 cpx += bsx*2+spx; 619 ckb[1] = new PICheckBox(this,"Gen.Resid", 1002, 2*bsx, bsy, cpx, cpy); 620 ckb[0]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free); 621 ckb[1]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free); 622 608 623 cpy += spy+bsy; 609 txt[1] = new PIText(this, "1.", 3.5*bsx, bsy, cpx, cpy); 610 611 cpy += spy+bsy; 612 ckb[0] = new PICheckBox(this,"Gen.Func", 1001, 2.5*bsx, bsy, cpx, cpy); 613 cpx += bsx*1.5+spx; 614 ckb[1] = new PICheckBox(this,"Gen.Resid", 1002, 2.5*bsx, bsy, cpx, cpy); 615 616 cpy += spy+bsy; 617 pom[0] = new PIOptMenu(this, "FitFunc", 2.5*bsx, bsy, cpx, cpy); 624 cpx = spx; 625 pom[0] = new PIOptMenu(this, "FitFunc", 2*bsx, bsy, cpx, cpy); 618 626 pom[0]->AppendItem("Poly0", 100); 619 627 pom[0]->AppendItem("Poly1", 101); … … 623 631 pom[0]->AppendItem("Gauss+Poly1",105); 624 632 pom[0]->AppendItem("Gauss+Poly2",106); 625 626 cpx += bsx*1.5+spx; 627 pom[1] = new PIOptMenu(this, "Bidon", 2.5*bsx, bsy, cpx, cpy); 628 pom[1]->AppendItem("Un", 150); 629 pom[1]->AppendItem("Deux",250); 630 pom[1]->AppendItem("Trois",350); 633 pom[0]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free); 634 635 cpx += bsx*2+spx; 636 pom[1] = new PIOptMenu(this, "NPar", 2*bsx, bsy, cpx, cpy); 637 pom[1]->AppendItem("Un NP=1", 201); 638 pom[1]->AppendItem("Deux NP=2",202); 639 pom[1]->AppendItem("Trois NP=3",203); 640 pom[1]->AppendItem("Cinq NP=5",205); 641 pom[1]->AppendItem("Huit NP=8",208); 642 pom[1]->AppendItem("Dix NP=10",210); 643 pom[1]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free); 631 644 632 645 cpy += spy+bsy; 633 cpx = 0.5*spx; 634 but[0] = new PIButton(this, "DoFit", 555, bsx*2, bsy, cpx, cpy); 635 cpx += 3*spx; 636 but[1] = new PIButton(this, "Dismiss", 777, bsx*2, bsy, cpx, cpy); 637 638 } 646 cpx = 0.5*bsx; 647 but[0] = new PIButton(this, "DoFit", 555, bsx*1.5, bsy, cpx, cpy); 648 cpx += bsx*1.5+3*spx; 649 but[1] = new PIButton(this, "Dismiss", 777, bsx*1.5, bsy, cpx, cpy); 650 but[0]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free); 651 but[1]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free); 652 653 // Pour les parametres 654 cpy += bsy+spy; 655 cpx = 0.6*bsx+1.5*spx; 656 lab[0] = new PILabel(this, "Init.Val", 1.7*bsx, bsy, cpx, cpy); 657 cpx += 1.7*bsx+0.5*spx; 658 lab[1] = new PILabel(this, "Step", 1.7*bsx, bsy, cpx, cpy); 659 lab[0]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free); 660 lab[1]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free); 661 662 for(int i=0; i<FINPARMAX; i++) { 663 char buff[32]; 664 cpy += bsy+spy; 665 cpx = spx; 666 sprintf(buff, "P%d",i); 667 labp[i] = new PILabel(this, buff, 0.6*bsx, bsy, cpx, cpy); 668 labp[i]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free); 669 sprintf(buff, "Val%d",i); 670 cpx += 0.6*bsx+0.5*spx; 671 txtp[i] = new PIText(this, buff, 1.7*bsx, bsy, cpx, cpy); 672 txtp[i]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free); 673 sprintf(buff, "Step%d",i); 674 cpx += 1.7*bsx+0.5*spx; 675 txts[i] = new PIText(this, buff, 1.7*bsx, bsy, cpx, cpy); 676 txts[i]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free); 677 } 678 } 679 639 680 /* --Methode-- */ 640 681 PIAFitterWind::~PIAFitterWind() 641 682 { 642 for(int i=0; i<2; i++) { 643 delete lab[i]; 644 delete txt[i]; 683 int i; 684 for(i=0; i<2; i++) { 645 685 delete pom[i]; 646 686 delete ckb[i]; 647 687 delete but[i]; 648 688 } 649 } 689 delete labn; 690 delete lab[0]; 691 delete lab[1]; 692 for(i=0; i< FINPARMAX; i++) { 693 delete labp[i]; 694 delete txtp[i]; 695 delete txts[i]; 696 } 697 } 698 699 /* --Methode-- */ 700 void PIAFitterWind::SetNbParms(int npar) 701 { 702 if (npar < 1) npar = 1; 703 if (npar > FINPARMAX) npar = FINPARMAX; 704 705 int bsx, bsy, spx, spy; 706 707 dap->PrefCompSz(bsx, bsy); 708 spx = bsx/10; 709 spy = bsy/4; 710 711 int wszx = 3*spx+4*bsx; 712 int wszy = (5+npar)*bsy+(6+npar)*spy; 713 SetSize(wszx, wszy); 714 715 int i; 716 for(i=0; i<npar; i++) { 717 labp[i]->Manage(); 718 txtp[i]->Manage(); 719 txts[i]->Manage(); 720 } 721 for(i=npar; i<FINPARMAX; i++) { 722 labp[i]->UnManage(); 723 txtp[i]->UnManage(); 724 txts[i]->UnManage(); 725 } 726 727 } 728 650 729 /* --Methode-- */ 651 730 void PIAFitterWind::Show() 652 731 { 653 732 // Si on veut initialiser des trucs au moment ou apparait la fenetre 654 txt[0]->SetText(oname); 733 labn->SetLabel(oname); 734 SetNbParms(3); 735 pom[1]->SetValue(203); 655 736 PIWindow::Show(); 656 737 } … … 662 743 char *mf[7] = {"p0","p1","p2","g","g0","g1","g2"}; 663 744 msg = UserMsg(msg); 745 746 if ((msg > 200) && (msg <= 200+FINPARMAX)) { // On change le nombre de parametre 747 SetNbParms(msg-200); 748 return; 749 } 750 664 751 if (msg == 777) { Hide(); return; } // On cache la fenetre 665 752 … … 674 761 cmd += " " + a + " "; 675 762 args.push_back(a); 676 a = txt[1]->GetText(); // Definition des parametres677 763 cmd += a; 678 764 args.push_back(a);
Note:
See TracChangeset
for help on using the changeset viewer.