1 | #include "GWt_elementBeam.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_elementBeam::GWt_elementBeam(GWt_elementLigneFaisceau* elemLigne,abstractElement* abstract) |
---|
11 | :GWt_abstractElement(abstract) |
---|
12 | { |
---|
13 | elementLigneFaiseauContainer_ = elemLigne; |
---|
14 | initialize(); |
---|
15 | } |
---|
16 | |
---|
17 | void GWt_elementBeam::initilializeDialog() |
---|
18 | { |
---|
19 | string* param = beginDialog(); |
---|
20 | |
---|
21 | registerParam("int____",2000, " 1/2 horizontal beam extend rms (cm) : "); |
---|
22 | getParamValue("int____"); |
---|
23 | getParamDescription("int____"); |
---|
24 | registerParam("bool____",true, " 1/2 horizontal beam extend rms (cm) : "); |
---|
25 | getParamValue("bool____"); |
---|
26 | getParamDescription("bool____"); |
---|
27 | |
---|
28 | string t = "ttttt"; |
---|
29 | registerParam("str____",t, " 1/2 horizontal beam extend rms (cm) : "); |
---|
30 | getParamValue("str____"); |
---|
31 | getParamDescription("str____"); |
---|
32 | |
---|
33 | new WText(" 1/2 horizontal beam extend rms (cm) : ",dialog_->contents()); |
---|
34 | xEdit_ = new WLineEdit(param->c_str(), dialog_->contents()); |
---|
35 | // new WBreak(dialog_->contents()); |
---|
36 | |
---|
37 | new WText("1/2 horizontal beam divergence rms (mrad) : ",dialog_->contents()); |
---|
38 | xpEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
39 | new WBreak(dialog_->contents()); |
---|
40 | |
---|
41 | new WText("1/2 vertical beam extend rms (cm) : ",dialog_->contents()); |
---|
42 | yEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
43 | // new WBreak(dialog_->contents()); |
---|
44 | |
---|
45 | new WText("1/2 horizontal beam divergence rms (mrad) : ",dialog_->contents()); |
---|
46 | ypEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
47 | new WBreak(dialog_->contents()); |
---|
48 | |
---|
49 | new WText("1/2 longitudinal beam extend rms (cm) : ",dialog_->contents()); |
---|
50 | dlEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
51 | // new WBreak(dialog_->contents()); |
---|
52 | |
---|
53 | new WText("1/2 momentum spread rms (mrad) : ",dialog_->contents()); |
---|
54 | delEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
55 | new WBreak(dialog_->contents()); |
---|
56 | |
---|
57 | new WText("momentum of the central trajectory (GeV/c) : ",dialog_->contents()); |
---|
58 | p0Edit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
59 | new WBreak(dialog_->contents()); |
---|
60 | |
---|
61 | WPushButton *annule= new WPushButton("cancel",dialog_->contents()); |
---|
62 | annule->clicked().connect(dialog_, &Wt::WDialog::reject); |
---|
63 | WPushButton *submit= new WPushButton("OK",dialog_->contents()); |
---|
64 | submit->clicked().connect(dialog_, &Wt::WDialog::accept); |
---|
65 | dialog_->finished().connect(this, &GWt_elementBeam::dialogDone); |
---|
66 | } |
---|
67 | |
---|
68 | void GWt_elementBeam::dialogDone(WDialog::DialogCode code) |
---|
69 | { |
---|
70 | if (code != Wt::WDialog::Accepted) return; |
---|
71 | |
---|
72 | unsigned nbParam = abstractElement_->getNbParams(); |
---|
73 | string* envoi = new string[nbParam+1]; |
---|
74 | int compteur = -1; |
---|
75 | |
---|
76 | envoi[++compteur] = mixedTools::intToString(nbParam); |
---|
77 | envoi[++compteur] = labelEdit_->text().toUTF8(); |
---|
78 | envoi[++compteur] = xEdit_->text().toUTF8(); |
---|
79 | envoi[++compteur] = xpEdit_->text().toUTF8(); |
---|
80 | envoi[++compteur] = yEdit_->text().toUTF8(); |
---|
81 | envoi[++compteur] = ypEdit_->text().toUTF8(); |
---|
82 | envoi[++compteur] = dlEdit_->text().toUTF8(); |
---|
83 | envoi[++compteur] = delEdit_->text().toUTF8(); |
---|
84 | envoi[++compteur] = p0Edit_->text().toUTF8(); |
---|
85 | if ( compteur != (int)nbParam ) { |
---|
86 | cerr << " GWt_elementBeam::dialogDone() pb nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl; |
---|
87 | return; |
---|
88 | } |
---|
89 | abstractElement_->setParametersString(envoi); |
---|
90 | updateLabelAndToolTipWidget(); |
---|
91 | delete [] envoi; |
---|
92 | } |
---|