[106] | 1 | |
---|
[39] | 2 | #include "GWt_drift.h" |
---|
[202] | 3 | #include "mixedTools.h" |
---|
[106] | 4 | |
---|
[39] | 5 | #include <Wt/WText> |
---|
| 6 | #include <Wt/WLineEdit> |
---|
| 7 | #include <Wt/WBreak> |
---|
| 8 | #include <Wt/WDialog> |
---|
| 9 | #include <Wt/WPushButton> |
---|
| 10 | |
---|
[305] | 11 | GWt_drift::GWt_drift(GWt_elementLigneFaisceau* elemLigne) |
---|
| 12 | :GWt_abstractElement(new elementDrift()) |
---|
[39] | 13 | { |
---|
[328] | 14 | elementLigneFaiseauContainer_ = elemLigne; |
---|
| 15 | initialize(); |
---|
[308] | 16 | } |
---|
| 17 | |
---|
[328] | 18 | void GWt_drift::initilializeDialog() |
---|
| 19 | { |
---|
| 20 | string* param = beginDialog(); |
---|
[272] | 21 | |
---|
[328] | 22 | new WText("length (cm) : ",dialog_->contents()); |
---|
| 23 | xlengthEdit_ = new WLineEdit(param->c_str(), dialog_->contents()); |
---|
| 24 | new WBreak(dialog_->contents()); |
---|
| 25 | new WText("aperture (cm) : ",dialog_->contents()); |
---|
| 26 | apertureEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
| 27 | new WBreak(dialog_->contents()); |
---|
| 28 | |
---|
| 29 | WPushButton *annule= new WPushButton("cancel",dialog_->contents()); |
---|
| 30 | annule->clicked().connect(dialog_, &Wt::WDialog::reject); |
---|
| 31 | WPushButton *submit= new WPushButton("OK",dialog_->contents()); |
---|
| 32 | submit->clicked().connect(dialog_, &Wt::WDialog::accept); |
---|
| 33 | dialog_->finished().connect(this, &GWt_drift::dialogDone); |
---|
[39] | 34 | } |
---|
| 35 | |
---|
[328] | 36 | void GWt_drift::dialogDone(WDialog::DialogCode code) |
---|
[39] | 37 | { |
---|
[328] | 38 | if (code != Wt::WDialog::Accepted) return; |
---|
| 39 | |
---|
| 40 | unsigned nbParam = abstractElement_->getNbParams(); |
---|
| 41 | string* envoi = new string[nbParam+1]; |
---|
| 42 | int compteur = -1; |
---|
| 43 | |
---|
| 44 | envoi[++compteur] = mixedTools::intToString(nbParam); |
---|
| 45 | envoi[++compteur] = labelEdit_->text().toUTF8(); |
---|
| 46 | envoi[++compteur] = xlengthEdit_->text().toUTF8(); |
---|
| 47 | envoi[++compteur] = apertureEdit_->text().toUTF8(); |
---|
| 48 | if ( compteur != (int)nbParam ) { |
---|
| 49 | cerr << " GWt_drift::dialogDone() pb nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl; |
---|
| 50 | return; |
---|
| 51 | } |
---|
| 52 | abstractElement_->setParametersString(envoi); |
---|
[372] | 53 | updateLabelAndToolTipWidget(); |
---|
[328] | 54 | delete [] envoi; |
---|
[39] | 55 | } |
---|
[260] | 56 | |
---|
| 57 | WImage* GWt_drift::getImage() { |
---|
[328] | 58 | return image_; |
---|
[260] | 59 | } |
---|