1 | |
---|
2 | #include "GWt_cell.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 | #include <Wt/WPanel> |
---|
11 | |
---|
12 | GWt_cell::GWt_cell(abstractElement* elem) : GWt_abstractElement(elem) |
---|
13 | { |
---|
14 | |
---|
15 | string* param = beginDialog(); |
---|
16 | |
---|
17 | new WText("length (cm) : ",dialog_->contents()); |
---|
18 | lenghtElemEdit_ = new WLineEdit(param->c_str(), dialog_->contents()); |
---|
19 | new WBreak(dialog_->contents()); |
---|
20 | |
---|
21 | new WText("aperture (cm) : ",dialog_->contents()); |
---|
22 | apertureEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
23 | new WBreak(dialog_->contents()); |
---|
24 | |
---|
25 | new WText("initial phase (deg.) : ",dialog_->contents()); |
---|
26 | initialPhaseEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
27 | new WBreak(dialog_->contents()); |
---|
28 | |
---|
29 | new WText("max phase step (deg.) : ",dialog_->contents()); |
---|
30 | phaseStepMaxEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
31 | new WBreak(dialog_->contents()); |
---|
32 | |
---|
33 | new WText("max accelerating field (MV/m) : ",dialog_->contents()); |
---|
34 | acceleratingFieldEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
35 | new WBreak(dialog_->contents()); |
---|
36 | |
---|
37 | new WText("name of file for field shape : ",dialog_->contents()); |
---|
38 | acceleratingShapeFileEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
39 | new WBreak(dialog_->contents()); |
---|
40 | |
---|
41 | WPanel *panel = new WPanel(dialog_->contents()); |
---|
42 | panel->setTitle(" magnetic focusing "); |
---|
43 | |
---|
44 | WText* t1 = new WText("name of file for focusing mag. field : ",dialog_->contents()); |
---|
45 | focusingMagFileEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
46 | new WBreak(dialog_->contents()); |
---|
47 | |
---|
48 | WText* t2 = new WText(" z-offset for mag. field : ",dialog_->contents()); |
---|
49 | offsetMagEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
50 | |
---|
51 | WText* t3 = new WText(" scaling factor for mag. field : ",dialog_->contents()); |
---|
52 | scaleFactorEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
53 | |
---|
54 | WContainerWidget* contenu = new WContainerWidget(); |
---|
55 | contenu->addWidget(t1); |
---|
56 | contenu->addWidget(focusingMagFileEdit_); |
---|
57 | contenu->addWidget(new WBreak()); |
---|
58 | contenu->addWidget(t2); |
---|
59 | contenu->addWidget(offsetMagEdit_); |
---|
60 | contenu->addWidget(new WBreak()); |
---|
61 | contenu->addWidget(t3); |
---|
62 | contenu->addWidget(scaleFactorEdit_); |
---|
63 | |
---|
64 | panel->setCentralWidget(contenu); |
---|
65 | |
---|
66 | WPushButton *submit = new WPushButton("OK",dialog_->contents()); |
---|
67 | submit->clicked().connect(dialog_, &Wt::WDialog::accept); |
---|
68 | dialog_->finished().connect(this, &GWt_cell::dialogDone); |
---|
69 | } |
---|
70 | |
---|
71 | void GWt_cell::dialogDone() |
---|
72 | { |
---|
73 | unsigned nbParam = element_->getNbParams(); |
---|
74 | string* envoi = new string[nbParam+1]; |
---|
75 | int compteur = -1; |
---|
76 | |
---|
77 | envoi[++compteur] = mixedTools::intToString(nbParam); |
---|
78 | envoi[++compteur] = labelEdit_->text().toUTF8(); |
---|
79 | envoi[++compteur] = lenghtElemEdit_->text().toUTF8(); |
---|
80 | envoi[++compteur] = apertureEdit_->text().toUTF8(); |
---|
81 | envoi[++compteur] = initialPhaseEdit_->text().toUTF8(); |
---|
82 | envoi[++compteur] = phaseStepMaxEdit_->text().toUTF8(); |
---|
83 | envoi[++compteur] = acceleratingFieldEdit_->text().toUTF8(); |
---|
84 | envoi[++compteur] = acceleratingShapeFileEdit_->text().toUTF8(); |
---|
85 | envoi[++compteur] = focusingMagFileEdit_->text().toUTF8(); |
---|
86 | envoi[++compteur] = offsetMagEdit_->text().toUTF8(); |
---|
87 | envoi[++compteur] = scaleFactorEdit_->text().toUTF8(); |
---|
88 | if ( compteur != (int)nbParam ) { |
---|
89 | cerr << " GWt_cell::dialogDone() pb nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl; |
---|
90 | return; |
---|
91 | } |
---|
92 | element_->setParametersString(envoi); |
---|
93 | updateLabelWidget(); |
---|
94 | delete [] envoi; |
---|
95 | } |
---|