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(GWt_elementLigneFaisceau* elemLigne) |
---|
12 | :GWt_abstractElement(new elementFit()) |
---|
13 | { |
---|
14 | elementLigneFaiseauContainer_ = elemLigne; |
---|
15 | initialize(); |
---|
16 | } |
---|
17 | |
---|
18 | void GWt_fit::initilializeDialog() |
---|
19 | { |
---|
20 | string* param = beginDialog(); |
---|
21 | |
---|
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); |
---|
56 | dialog_->finished().connect(this, &GWt_fit::dialogDone); |
---|
57 | } |
---|
58 | |
---|
59 | void GWt_fit::dialogDone(WDialog::DialogCode code) |
---|
60 | { |
---|
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(); |
---|
70 | cout << " GWt_fit::dialogDone() variable a fitter : " << variableString << endl; |
---|
71 | envoi[++compteur] = variableString; |
---|
72 | envoi[++compteur] = valueEdit_->text().toUTF8(); |
---|
73 | envoi[++compteur] = tolerEdit_->text().toUTF8(); |
---|
74 | if ( compteur != (int)nbParam ) { |
---|
75 | cerr << " GWt_fit::dialogDone() pb nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl; |
---|
76 | return; |
---|
77 | } |
---|
78 | abstractElement_->setParametersString(envoi); |
---|
79 | updateLabelAndToolTipWidget(); |
---|
80 | delete [] envoi; |
---|
81 | } |
---|
82 | |
---|
83 | WImage* GWt_fit::getImage() { |
---|
84 | return image_; |
---|
85 | } |
---|