1 | #include "GWt_beam.h" |
---|
2 | |
---|
3 | #include <Wt/WText> |
---|
4 | #include <Wt/WLineEdit> |
---|
5 | #include <Wt/WBreak> |
---|
6 | #include <Wt/WDialog> |
---|
7 | #include <Wt/WPushButton> |
---|
8 | |
---|
9 | GWt_beam::GWt_beam(PspaApplication* ps,abstractElement* elem) : GWt_abstractElement(ps,elem) { |
---|
10 | |
---|
11 | string* param = element_-> getParametersString(); |
---|
12 | if ( param == NULL ) |
---|
13 | { |
---|
14 | pspa_->addConsoleMessage(" GWt_beam : empty parameter set"); |
---|
15 | } |
---|
16 | int nbparam = atoi(param[0].c_str()); |
---|
17 | if ( nbparam != element_->getNbParams() ) |
---|
18 | { |
---|
19 | pspa_->addConsoleMessage(WString(" element uncoherently programmed for number of parameters: beam ")); |
---|
20 | } |
---|
21 | |
---|
22 | dialog_ = new WDialog("element : beam"); |
---|
23 | |
---|
24 | new WText(" 1/2 horizontal beam extend rms (cm) : ",dialog_->contents()); |
---|
25 | xEdit_ = new WLineEdit(param[1].c_str(), dialog_->contents()); |
---|
26 | // new WBreak(dialog_->contents()); |
---|
27 | |
---|
28 | new WText("1/2 horizontal beam divergence rms (mrad) : ",dialog_->contents()); |
---|
29 | xpEdit_ = new WLineEdit(param[2].c_str(), dialog_->contents()); |
---|
30 | new WBreak(dialog_->contents()); |
---|
31 | |
---|
32 | new WText("1/2 vertical beam extend rms (cm) : ",dialog_->contents()); |
---|
33 | yEdit_ = new WLineEdit(param[3].c_str(), dialog_->contents()); |
---|
34 | // new WBreak(dialog_->contents()); |
---|
35 | |
---|
36 | new WText("1/2 horizontal beam divergence rms (mrad) : ",dialog_->contents()); |
---|
37 | ypEdit_ = new WLineEdit(param[4].c_str(), dialog_->contents()); |
---|
38 | new WBreak(dialog_->contents()); |
---|
39 | |
---|
40 | new WText("1/2 longitudinal beam extend rms (cm) : ",dialog_->contents()); |
---|
41 | dlEdit_ = new WLineEdit(param[5].c_str(), dialog_->contents()); |
---|
42 | // new WBreak(dialog_->contents()); |
---|
43 | |
---|
44 | new WText("1/2 momentum spread rms (mrad) : ",dialog_->contents()); |
---|
45 | delEdit_ = new WLineEdit(param[6].c_str(), dialog_->contents()); |
---|
46 | new WBreak(dialog_->contents()); |
---|
47 | |
---|
48 | new WText("momentum of the central trajectory (GeV/c) : ",dialog_->contents()); |
---|
49 | p0Edit_ = new WLineEdit(param[7].c_str(), dialog_->contents()); |
---|
50 | new WBreak(dialog_->contents()); |
---|
51 | |
---|
52 | WPushButton *submit = new WPushButton("OK",dialog_->contents()); |
---|
53 | submit->clicked().connect(dialog_, &Wt::WDialog::accept); |
---|
54 | dialog_->finished().connect(this, &GWt_beam::dialogDone); |
---|
55 | } |
---|
56 | |
---|
57 | void GWt_beam::dialogDone() |
---|
58 | { |
---|
59 | string envoi[8]; |
---|
60 | envoi[0] = string("7"); |
---|
61 | envoi[1] = xEdit_->text().toUTF8(); |
---|
62 | envoi[2] = xpEdit_->text().toUTF8(); |
---|
63 | envoi[3] = yEdit_->text().toUTF8(); |
---|
64 | envoi[4] = ypEdit_->text().toUTF8(); |
---|
65 | envoi[5] = dlEdit_->text().toUTF8(); |
---|
66 | envoi[6] = delEdit_->text().toUTF8(); |
---|
67 | envoi[7] = p0Edit_->text().toUTF8(); |
---|
68 | |
---|
69 | element_->setParametersString(envoi); |
---|
70 | } |
---|
71 | |
---|