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