1 | |
---|
2 | #include "GWt_elementBend.h" |
---|
3 | #include "mixedTools.h" |
---|
4 | |
---|
5 | #include <Wt/WText> |
---|
6 | #include <Wt/WLineEdit> |
---|
7 | #include <Wt/WBreak> |
---|
8 | #include <Wt/WDialog> |
---|
9 | #include <Wt/WPushButton> |
---|
10 | |
---|
11 | GWt_elementBend::GWt_elementBend(GWt_elementLigneFaisceau* elemLigne ,abstractElement* abstract) |
---|
12 | :GWt_abstractElement(abstract) |
---|
13 | { |
---|
14 | elementLigneFaiseauContainer_ = elemLigne; |
---|
15 | initialize(); |
---|
16 | } |
---|
17 | |
---|
18 | void GWt_elementBend::initilializeDialog() |
---|
19 | { |
---|
20 | string* param = beginDialog(); |
---|
21 | |
---|
22 | new WText("angle (deg.) : ",dialog_->contents()); |
---|
23 | angleEdit_ = new WLineEdit( param->c_str(), dialog_->contents()); |
---|
24 | new WBreak(dialog_->contents()); |
---|
25 | |
---|
26 | new WText("radius (m) : ",dialog_->contents()); |
---|
27 | radiusEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
28 | new WBreak(dialog_->contents()); |
---|
29 | |
---|
30 | new WText("momentum (MeV/c) : ",dialog_->contents()); |
---|
31 | momentumEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
32 | new WBreak(dialog_->contents()); |
---|
33 | |
---|
34 | new WText("length (cm) : ",dialog_->contents()); |
---|
35 | xlengthEdit_ = new WLineEdit("0", dialog_->contents()); |
---|
36 | xlengthEdit_->setDisabled(true); |
---|
37 | new WBreak(dialog_->contents()); |
---|
38 | |
---|
39 | new WText("aperture (cm) : ",dialog_->contents()); |
---|
40 | apertureEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
41 | apertureEdit_->setDisabled(true); |
---|
42 | new WBreak(dialog_->contents()); |
---|
43 | |
---|
44 | new WText("pole face rotations (deg.) entrance : ",dialog_->contents()); |
---|
45 | beta1Edit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
46 | new WText("exit : ",dialog_->contents()); |
---|
47 | beta2Edit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
48 | new WBreak(dialog_->contents()); |
---|
49 | |
---|
50 | WPushButton *annule= new WPushButton("cancel",dialog_->contents()); |
---|
51 | annule->clicked().connect(dialog_, &Wt::WDialog::reject); |
---|
52 | WPushButton *submit= new WPushButton("OK",dialog_->contents()); |
---|
53 | submit->clicked().connect(dialog_, &Wt::WDialog::accept); |
---|
54 | dialog_->finished().connect(this, &GWt_elementBend::dialogDone); |
---|
55 | } |
---|
56 | |
---|
57 | void GWt_elementBend::dialogDone(WDialog::DialogCode code) |
---|
58 | { |
---|
59 | if (code != Wt::WDialog::Accepted) return; |
---|
60 | |
---|
61 | unsigned nbParam = abstractElement_->getNbParams(); |
---|
62 | string* envoi = new string[nbParam+1]; |
---|
63 | int compteur = -1; |
---|
64 | |
---|
65 | envoi[++compteur] = string(mixedTools::intToString(nbParam) ); |
---|
66 | envoi[++compteur] = labelEdit_->text().toUTF8(); |
---|
67 | envoi[++compteur] = angleEdit_->text().toUTF8(); |
---|
68 | envoi[++compteur] = radiusEdit_->text().toUTF8(); |
---|
69 | envoi[++compteur] = momentumEdit_->text().toUTF8(); |
---|
70 | envoi[++compteur] = apertureEdit_->text().toUTF8(); |
---|
71 | envoi[++compteur] = beta1Edit_->text().toUTF8(); |
---|
72 | envoi[++compteur] = beta2Edit_->text().toUTF8(); |
---|
73 | if ( compteur != (int)nbParam ) { |
---|
74 | cerr << " GWt_elementBend::dialogDone() pb nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl; |
---|
75 | return; |
---|
76 | } |
---|
77 | abstractElement_->setParametersString(envoi); |
---|
78 | updateLabelAndToolTipWidget(); |
---|
79 | delete [] envoi; |
---|
80 | } |
---|
81 | |
---|