1 | #include "GWt_soleno.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 | |
---|
10 | GWt_soleno::GWt_soleno(GWt_elementLigneFaisceau* elemLigne) |
---|
11 | :GWt_abstractElement(new elementSoleno()) |
---|
12 | { |
---|
13 | elementLigneFaiseauContainer_ = elemLigne; |
---|
14 | initialize(); |
---|
15 | } |
---|
16 | |
---|
17 | void GWt_soleno::initilializeDialog() |
---|
18 | { |
---|
19 | string* param = beginDialog(); |
---|
20 | |
---|
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()); |
---|
32 | |
---|
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); |
---|
37 | dialog_->finished().connect(this, &GWt_soleno::dialogDone); |
---|
38 | } |
---|
39 | |
---|
40 | void GWt_soleno::dialogDone(WDialog::DialogCode code) |
---|
41 | { |
---|
42 | if (code != Wt::WDialog::Accepted) return; |
---|
43 | |
---|
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); |
---|
62 | delete [] envoi; |
---|
63 | } |
---|
64 | |
---|
65 | WImage* GWt_soleno::getImage() { |
---|
66 | return image_; |
---|
67 | } |
---|