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