1 | #include "GWt_fit.h" |
---|
2 | #include "mixedTools.h" |
---|
3 | |
---|
4 | #include <Wt/WText> |
---|
5 | #include <Wt/WLineEdit> |
---|
6 | #include <Wt/WBreak> |
---|
7 | #include <Wt/WDialog> |
---|
8 | #include <Wt/WPushButton> |
---|
9 | #include <Wt/WComboBox> |
---|
10 | |
---|
11 | GWt_fit::GWt_fit(abstractElement* elem) : GWt_abstractElement(elem) |
---|
12 | { |
---|
13 | |
---|
14 | string* param = beginDialog(); |
---|
15 | |
---|
16 | new WText(" variable to fit : ",dialog_->contents()); |
---|
17 | nameEdit_ = new WComboBox(dialog_->contents()); |
---|
18 | nameEdit_->addItem("R11"); |
---|
19 | nameEdit_->addItem("R22"); |
---|
20 | nameEdit_->addItem("R12"); |
---|
21 | nameEdit_->addItem("R21"); |
---|
22 | nameEdit_->addItem("??"); |
---|
23 | |
---|
24 | string var = *param; |
---|
25 | if ( var == "R11" ) { |
---|
26 | nameEdit_->setCurrentIndex(0); |
---|
27 | } |
---|
28 | else if ( var == "R22" ) { |
---|
29 | nameEdit_->setCurrentIndex(1); |
---|
30 | } |
---|
31 | else if ( var == "R12" ) { |
---|
32 | nameEdit_->setCurrentIndex(2); |
---|
33 | } |
---|
34 | else if ( var == "R21" ) { |
---|
35 | nameEdit_->setCurrentIndex(3); |
---|
36 | } |
---|
37 | else { |
---|
38 | nameEdit_->setCurrentIndex(4); |
---|
39 | } |
---|
40 | new WText(" value : ",dialog_->contents()); |
---|
41 | valueEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
42 | new WText(" tolerance : ",dialog_->contents()); |
---|
43 | tolerEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
44 | new WBreak(dialog_->contents()); |
---|
45 | WPushButton *submit = new WPushButton("OK",dialog_->contents()); |
---|
46 | submit->clicked().connect(dialog_, &Wt::WDialog::accept); |
---|
47 | dialog_->finished().connect(this, &GWt_fit::dialogDone); |
---|
48 | } |
---|
49 | |
---|
50 | void GWt_fit::dialogDone() |
---|
51 | { |
---|
52 | unsigned nbParam = element_->getNbParams(); |
---|
53 | string* envoi = new string[nbParam+1]; |
---|
54 | int compteur = -1; |
---|
55 | envoi[++compteur] = string(mixedTools::intToString(nbParam) ); |
---|
56 | |
---|
57 | envoi[++compteur] = labelEdit_->text().toUTF8(); |
---|
58 | |
---|
59 | string variableString = nameEdit_->currentText().toUTF8(); |
---|
60 | cout << " GWt_fit::dialogDone() variable a fitter : " << variableString << endl; |
---|
61 | envoi[++compteur] = variableString; |
---|
62 | envoi[++compteur] = valueEdit_->text().toUTF8(); |
---|
63 | envoi[++compteur] = tolerEdit_->text().toUTF8(); |
---|
64 | if ( compteur != (int)nbParam ) { |
---|
65 | cerr << " GWt_fit::dialogDone() pb nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl; |
---|
66 | return; |
---|
67 | } |
---|
68 | element_->setParametersString(envoi); |
---|
69 | updateLabelWidget(); |
---|
70 | delete [] envoi; |
---|
71 | } |
---|