Changeset 368 in Sophya for trunk/SophyaPI/PIext/piafitting.cc


Ignore:
Timestamp:
Aug 9, 1999, 1:57:10 PM (26 years ago)
Author:
ercodmgr
Message:

modifs Fenetre de fit et gestion repertoire /func Reza 9/8/99

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PIext/piafitting.cc

    r361 r368  
    2929
    3030////      ----------    Classe de fenetre de fit interactive ------------
     31#define FINPARMAX  10    // Nb maxi de parametres de fit
     32
    3133class PIAFitterWind :  public PIWindow {
    3234public :
     
    3638  virtual void  Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
    3739  inline  void  SetObjName(string& nom) { oname = nom; }
     40          void  SetNbParms(int npar);
    3841protected :
    3942  PIStdImgApp* dap;
    4043  PIAFitter* fitter;
     44  PILabel* labn; 
    4145  PIOptMenu* pom[2];
    42   PILabel* lab[2];  // Maximum 20 parametres
    43   PIText* txt[2];   //     "    "      "
    4446  PIButton* but[2];
    4547  PICheckBox* ckb[2];
     48  PILabel* lab[2];
     49  PILabel* labp[FINPARMAX];   // Maximum FINPARMAX  parametres
     50  PIText* txtp[FINPARMAX];    //        "       "      "
     51  PIText* txts[FINPARMAX];    //        "       "      " 
    4652  string oname;
    4753};
     
    101107}
    102108else if (kw == "fitw") {
     109  if (tokens.size() < 1) {
     110    cout << "Usage: fitw nomobj" << endl;
     111    return(0);
     112    }
    103113  cout << " *DBG* Affichage PIAFitterWind ** " << endl;
     114  fwind->SetObjName(tokens[0]);
    104115  fwind->Show();
    105116 }
     
    592603spy = bsy/4;
    593604
    594 int wszx = 5*spx+3*bsx;
     605int wszx = 3*spx+4*bsx;
    595606int wszy = 5*bsy+6*spy;
    596607SetSize(wszx, wszy);
    597608int cpx = spx;
    598609int cpy = spy;
    599 int csx = cpx;
    600 int csy = cpy;
    601 lab[0] = new PILabel(this, "Object", 1.5*bsx, bsy, cpx, cpy);
     610
     611cpx = spx+bsx;
     612labn = new PILabel(this, "ObjectName", 2.0*bsx, bsy, cpx, cpy);
     613labn->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free);
     614
    602615cpy += 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);
     616cpx = spx;
     617ckb[0] = new PICheckBox(this,"Gen.Func", 1001, 2*bsx, bsy, cpx, cpy);
     618cpx += bsx*2+spx;
     619ckb[1] = new PICheckBox(this,"Gen.Resid", 1002, 2*bsx, bsy, cpx, cpy);
     620ckb[0]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free);
     621ckb[1]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free);
     622
    608623cpy += 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);
     624cpx = spx;
     625pom[0] = new PIOptMenu(this, "FitFunc", 2*bsx, bsy, cpx, cpy);
    618626pom[0]->AppendItem("Poly0", 100);
    619627pom[0]->AppendItem("Poly1", 101);
     
    623631pom[0]->AppendItem("Gauss+Poly1",105);
    624632pom[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);
     633pom[0]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free);
     634
     635cpx += bsx*2+spx;
     636pom[1] = new PIOptMenu(this, "NPar", 2*bsx, bsy, cpx, cpy);
     637pom[1]->AppendItem("Un NP=1", 201);
     638pom[1]->AppendItem("Deux NP=2",202);
     639pom[1]->AppendItem("Trois NP=3",203);
     640pom[1]->AppendItem("Cinq  NP=5",205);
     641pom[1]->AppendItem("Huit  NP=8",208);
     642pom[1]->AppendItem("Dix  NP=10",210);
     643pom[1]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free);
    631644
    632645cpy += 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 }
     646cpx = 0.5*bsx;
     647but[0] =  new PIButton(this, "DoFit", 555, bsx*1.5, bsy, cpx, cpy);
     648cpx += bsx*1.5+3*spx;
     649but[1] =  new PIButton(this, "Dismiss", 777, bsx*1.5, bsy, cpx, cpy);
     650but[0]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free);
     651but[1]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free);
     652
     653//  Pour les parametres
     654cpy += bsy+spy;
     655cpx = 0.6*bsx+1.5*spx;
     656lab[0] = new PILabel(this, "Init.Val", 1.7*bsx, bsy, cpx, cpy);
     657cpx += 1.7*bsx+0.5*spx;
     658lab[1] = new PILabel(this, "Step", 1.7*bsx, bsy, cpx, cpy);
     659lab[0]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free);
     660lab[1]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free);
     661
     662for(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
    639680/* --Methode-- */
    640681PIAFitterWind::~PIAFitterWind()
    641682{
    642 for(int i=0; i<2; i++) {
    643   delete lab[i];
    644   delete txt[i];
     683int i;
     684for(i=0; i<2; i++) {
    645685  delete pom[i];
    646686  delete ckb[i];
    647687  delete but[i];
    648688  }
    649 }
     689delete labn;
     690delete lab[0];
     691delete lab[1];
     692for(i=0; i< FINPARMAX; i++) {
     693  delete labp[i];
     694  delete txtp[i];
     695  delete txts[i];
     696  }
     697}
     698
     699/* --Methode-- */
     700void PIAFitterWind::SetNbParms(int npar)
     701{
     702if (npar < 1) npar = 1;
     703if (npar > FINPARMAX) npar = FINPARMAX;
     704
     705int bsx, bsy, spx, spy;
     706
     707dap->PrefCompSz(bsx, bsy);
     708spx = bsx/10;
     709spy = bsy/4;
     710
     711int wszx = 3*spx+4*bsx;
     712int wszy = (5+npar)*bsy+(6+npar)*spy;
     713SetSize(wszx, wszy);
     714
     715int i;
     716for(i=0; i<npar; i++) {
     717  labp[i]->Manage();
     718  txtp[i]->Manage();
     719  txts[i]->Manage();
     720  }
     721for(i=npar; i<FINPARMAX; i++) {
     722  labp[i]->UnManage();
     723  txtp[i]->UnManage();
     724  txts[i]->UnManage();
     725  }
     726
     727}
     728
    650729/* --Methode-- */
    651730void PIAFitterWind::Show()
    652731{
    653732// Si on veut initialiser des trucs au moment ou apparait la fenetre
    654 txt[0]->SetText(oname);
     733labn->SetLabel(oname);
     734SetNbParms(3);
     735pom[1]->SetValue(203);
    655736PIWindow::Show();
    656737}
     
    662743char *mf[7] = {"p0","p1","p2","g","g0","g1","g2"};
    663744msg = UserMsg(msg);
     745
     746if ((msg > 200) && (msg <= 200+FINPARMAX)) {  // On change le nombre de parametre
     747  SetNbParms(msg-200);
     748  return;
     749  }
     750 
    664751if (msg == 777)  { Hide(); return; }  // On cache la fenetre
    665752
     
    674761  cmd += " " + a + " ";
    675762  args.push_back(a);
    676   a = txt[1]->GetText();  // Definition des parametres
    677763  cmd += a;
    678764  args.push_back(a);
Note: See TracChangeset for help on using the changeset viewer.