1 | #include "GWt_rfgun.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_rfgun::GWt_rfgun(GWt_elementLigneFaisceau* elemLigne) |
---|
11 | :GWt_abstractElement(new elementRfgun()) |
---|
12 | { |
---|
13 | elementLigneFaiseauContainer_ = elemLigne; |
---|
14 | initialize(); |
---|
15 | } |
---|
16 | |
---|
17 | void GWt_rfgun::initilializeDialog() |
---|
18 | { |
---|
19 | string* param = beginDialog(); |
---|
20 | |
---|
21 | new WText("nr of macroparticles : ",dialog_->contents()); |
---|
22 | nmacropEdit_ = new WLineEdit(param->c_str(), dialog_->contents()); |
---|
23 | new WBreak(dialog_->contents()); |
---|
24 | |
---|
25 | new WText("sigma_t (ps) : ",dialog_->contents()); |
---|
26 | sigma_tEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
27 | new WBreak(dialog_->contents()); |
---|
28 | |
---|
29 | new WText("sigma_r (cm) : ",dialog_->contents()); |
---|
30 | sigma_rEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
31 | new WBreak(dialog_->contents()); |
---|
32 | |
---|
33 | new WText("emittance x (pi.mm.mrad) : ",dialog_->contents()); |
---|
34 | emit_xEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
35 | new WText("emittance y (pi.mm.mrad) : ",dialog_->contents()); |
---|
36 | emit_yEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
37 | new WBreak(dialog_->contents()); |
---|
38 | |
---|
39 | new WText("initial kinetic energy (MeV) : ",dialog_->contents()); |
---|
40 | E_cinEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
41 | new WBreak(dialog_->contents()); |
---|
42 | |
---|
43 | new WText("sigma_Ecin (MeV) : ",dialog_->contents()); |
---|
44 | sigma_EEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
45 | new WBreak(dialog_->contents()); |
---|
46 | |
---|
47 | new WText("total charge in beam (nC) : ",dialog_->contents()); |
---|
48 | totalChargeEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
49 | new WBreak(dialog_->contents()); |
---|
50 | |
---|
51 | WPushButton *annule= new WPushButton("cancel",dialog_->contents()); |
---|
52 | annule->clicked().connect(dialog_, &Wt::WDialog::reject); |
---|
53 | WPushButton *submit= new WPushButton("OK",dialog_->contents()); |
---|
54 | submit->clicked().connect(dialog_, &Wt::WDialog::accept); |
---|
55 | dialog_->finished().connect(this, &GWt_rfgun::dialogDone); |
---|
56 | } |
---|
57 | |
---|
58 | void GWt_rfgun::dialogDone(WDialog::DialogCode code) |
---|
59 | { |
---|
60 | if (code != Wt::WDialog::Accepted) return; |
---|
61 | |
---|
62 | unsigned nbParam = abstractElement_->getNbParams(); |
---|
63 | string* envoi = new string[nbParam+1]; |
---|
64 | int compteur = -1; |
---|
65 | |
---|
66 | envoi[++compteur] = mixedTools::intToString(nbParam); |
---|
67 | envoi[++compteur] = labelEdit_->text().toUTF8(); |
---|
68 | envoi[++compteur] = nmacropEdit_->text().toUTF8(); |
---|
69 | envoi[++compteur] = sigma_tEdit_->text().toUTF8(); |
---|
70 | envoi[++compteur] = sigma_rEdit_->text().toUTF8(); |
---|
71 | envoi[++compteur] = emit_xEdit_->text().toUTF8(); |
---|
72 | envoi[++compteur] = emit_yEdit_->text().toUTF8(); |
---|
73 | envoi[++compteur] = E_cinEdit_->text().toUTF8(); |
---|
74 | envoi[++compteur] = sigma_EEdit_->text().toUTF8(); |
---|
75 | envoi[++compteur] = totalChargeEdit_->text().toUTF8(); |
---|
76 | if ( compteur != (int)nbParam ) { |
---|
77 | cerr << " GWt_rfgun::dialogDone() pb nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl; |
---|
78 | return; |
---|
79 | } |
---|
80 | abstractElement_->setParametersString(envoi); |
---|
81 | updateLabelAndToolTipWidget(); |
---|
82 | delete [] envoi; |
---|
83 | } |
---|
84 | |
---|
85 | WImage* GWt_rfgun::getImage() { |
---|
86 | return image_; |
---|
87 | } |
---|