[437] | 1 | #include "GWt_elementFit.h" |
---|
[225] | 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> |
---|
[226] | 9 | #include <Wt/WComboBox> |
---|
[225] | 10 | |
---|
[437] | 11 | GWt_elementFit::GWt_elementFit(GWt_elementLigneFaisceau* elemLigne) |
---|
[305] | 12 | :GWt_abstractElement(new elementFit()) |
---|
[225] | 13 | { |
---|
[328] | 14 | elementLigneFaiseauContainer_ = elemLigne; |
---|
| 15 | initialize(); |
---|
[308] | 16 | } |
---|
| 17 | |
---|
[437] | 18 | void GWt_elementFit::initilializeDialog() |
---|
[328] | 19 | { |
---|
| 20 | string* param = beginDialog(); |
---|
[272] | 21 | |
---|
[328] | 22 | new WText(" variable to fit : ",dialog_->contents()); |
---|
| 23 | nameEdit_ = new WComboBox(dialog_->contents()); |
---|
| 24 | nameEdit_->addItem("R11"); |
---|
| 25 | nameEdit_->addItem("R22"); |
---|
| 26 | nameEdit_->addItem("R12"); |
---|
| 27 | nameEdit_->addItem("R21"); |
---|
| 28 | nameEdit_->addItem("??"); |
---|
| 29 | |
---|
| 30 | string var = *param; |
---|
| 31 | if ( var == "R11" ) { |
---|
| 32 | nameEdit_->setCurrentIndex(0); |
---|
| 33 | } |
---|
| 34 | else if ( var == "R22" ) { |
---|
| 35 | nameEdit_->setCurrentIndex(1); |
---|
| 36 | } |
---|
| 37 | else if ( var == "R12" ) { |
---|
| 38 | nameEdit_->setCurrentIndex(2); |
---|
| 39 | } |
---|
| 40 | else if ( var == "R21" ) { |
---|
| 41 | nameEdit_->setCurrentIndex(3); |
---|
| 42 | } |
---|
| 43 | else { |
---|
| 44 | nameEdit_->setCurrentIndex(4); |
---|
| 45 | } |
---|
| 46 | new WText(" value : ",dialog_->contents()); |
---|
| 47 | valueEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
| 48 | new WText(" tolerance : ",dialog_->contents()); |
---|
| 49 | tolerEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
| 50 | new WBreak(dialog_->contents()); |
---|
| 51 | |
---|
| 52 | WPushButton *annule= new WPushButton("cancel",dialog_->contents()); |
---|
| 53 | annule->clicked().connect(dialog_, &Wt::WDialog::reject); |
---|
| 54 | WPushButton *submit= new WPushButton("OK",dialog_->contents()); |
---|
| 55 | submit->clicked().connect(dialog_, &Wt::WDialog::accept); |
---|
[437] | 56 | dialog_->finished().connect(this, &GWt_elementFit::dialogDone); |
---|
[225] | 57 | } |
---|
| 58 | |
---|
[437] | 59 | void GWt_elementFit::dialogDone(WDialog::DialogCode code) |
---|
[225] | 60 | { |
---|
[328] | 61 | if (code != Wt::WDialog::Accepted) return; |
---|
| 62 | |
---|
| 63 | unsigned nbParam = abstractElement_->getNbParams(); |
---|
| 64 | string* envoi = new string[nbParam+1]; |
---|
| 65 | int compteur = -1; |
---|
| 66 | |
---|
| 67 | envoi[++compteur] = string(mixedTools::intToString(nbParam) ); |
---|
| 68 | envoi[++compteur] = labelEdit_->text().toUTF8(); |
---|
| 69 | string variableString = nameEdit_->currentText().toUTF8(); |
---|
[437] | 70 | cout << " GWt_elementFit::dialogDone() variable a fitter : " << variableString << endl; |
---|
[328] | 71 | envoi[++compteur] = variableString; |
---|
| 72 | envoi[++compteur] = valueEdit_->text().toUTF8(); |
---|
| 73 | envoi[++compteur] = tolerEdit_->text().toUTF8(); |
---|
| 74 | if ( compteur != (int)nbParam ) { |
---|
[437] | 75 | cerr << " GWt_elementFit::dialogDone() pb nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl; |
---|
[328] | 76 | return; |
---|
| 77 | } |
---|
| 78 | abstractElement_->setParametersString(envoi); |
---|
[372] | 79 | updateLabelAndToolTipWidget(); |
---|
[328] | 80 | delete [] envoi; |
---|
[225] | 81 | } |
---|
[260] | 82 | |
---|