1 | |
---|
2 | #include "GWt_cell.h" |
---|
3 | |
---|
4 | #include <Wt/WText> |
---|
5 | #include <Wt/WLineEdit> |
---|
6 | #include <Wt/WBreak> |
---|
7 | #include <Wt/WDialog> |
---|
8 | #include <Wt/WPushButton> |
---|
9 | #include <Wt/WPanel> |
---|
10 | |
---|
11 | GWt_cell::GWt_cell(PspaApplication* ps,abstractElement* elem,string image) : GWt_abstractElement(ps,elem,image) |
---|
12 | { |
---|
13 | string* param = element_-> getParametersString(); |
---|
14 | if ( param == NULL ) { |
---|
15 | pspa_->addConsoleMessage(" GWt_cell : empty parameter set"); |
---|
16 | } |
---|
17 | int nbparam = atoi(param[0].c_str()); |
---|
18 | if ( nbparam != 9 ) { |
---|
19 | pspa_->addConsoleMessage(" element seems not to be a CELL"); |
---|
20 | } |
---|
21 | |
---|
22 | dialog_ = new WDialog("element CELL"); |
---|
23 | |
---|
24 | new WText("length (cm) : ",dialog_->contents()); |
---|
25 | lenghtElemEdit_ = new WLineEdit(param[1].c_str(), dialog_->contents()); |
---|
26 | new WBreak(dialog_->contents()); |
---|
27 | |
---|
28 | new WText("aperture (cm) : ",dialog_->contents()); |
---|
29 | apertureEdit_ = new WLineEdit(param[2].c_str(), dialog_->contents()); |
---|
30 | new WBreak(dialog_->contents()); |
---|
31 | |
---|
32 | new WText("initial phase (deg.) : ",dialog_->contents()); |
---|
33 | initialPhaseEdit_ = new WLineEdit(param[3].c_str(), dialog_->contents()); |
---|
34 | new WBreak(dialog_->contents()); |
---|
35 | |
---|
36 | new WText("max phase step (deg.) : ",dialog_->contents()); |
---|
37 | phaseStepMaxEdit_ = new WLineEdit(param[4].c_str(), dialog_->contents()); |
---|
38 | new WBreak(dialog_->contents()); |
---|
39 | |
---|
40 | new WText("max accelerating field (MV/m) : ",dialog_->contents()); |
---|
41 | acceleratingFieldEdit_ = new WLineEdit(param[5].c_str(), dialog_->contents()); |
---|
42 | new WBreak(dialog_->contents()); |
---|
43 | |
---|
44 | new WText("name of file for field shape : ",dialog_->contents()); |
---|
45 | acceleratingShapeFileEdit_ = new WLineEdit(param[6].c_str(), dialog_->contents()); |
---|
46 | new WBreak(dialog_->contents()); |
---|
47 | |
---|
48 | WPanel *panel = new WPanel(dialog_->contents()); |
---|
49 | panel->setTitle(" magnetic focusing "); |
---|
50 | |
---|
51 | WText* t1 = new WText("name of file for focusing mag. field : ",dialog_->contents()); |
---|
52 | focusingMagFileEdit_ = new WLineEdit(param[7].c_str(), dialog_->contents()); |
---|
53 | new WBreak(dialog_->contents()); |
---|
54 | |
---|
55 | WText* t2 = new WText(" z-offset for mag. field : ",dialog_->contents()); |
---|
56 | offsetMagEdit_ = new WLineEdit(param[8].c_str(), dialog_->contents()); |
---|
57 | |
---|
58 | WText* t3 = new WText(" scaling factor for mag. field : ",dialog_->contents()); |
---|
59 | scaleFactorEdit_ = new WLineEdit(param[9].c_str(), dialog_->contents()); |
---|
60 | |
---|
61 | WContainerWidget* contenu = new WContainerWidget(); |
---|
62 | contenu->addWidget(t1); |
---|
63 | contenu->addWidget(focusingMagFileEdit_); |
---|
64 | contenu->addWidget(new WBreak()); |
---|
65 | contenu->addWidget(t2); |
---|
66 | contenu->addWidget(offsetMagEdit_); |
---|
67 | contenu->addWidget(new WBreak()); |
---|
68 | contenu->addWidget(t3); |
---|
69 | contenu->addWidget(scaleFactorEdit_); |
---|
70 | |
---|
71 | panel->setCentralWidget(contenu); |
---|
72 | |
---|
73 | WPushButton *submit = new WPushButton("OK",dialog_->contents()); |
---|
74 | submit->clicked().connect(dialog_, &Wt::WDialog::accept); |
---|
75 | dialog_->finished().connect(this, &GWt_cell::dialogDone); |
---|
76 | } |
---|
77 | |
---|
78 | void GWt_cell::dialogDone() |
---|
79 | { |
---|
80 | string envoi[10]; |
---|
81 | envoi[0] = string("9"); |
---|
82 | envoi[1] = lenghtElemEdit_->text().toUTF8(); |
---|
83 | envoi[2] = apertureEdit_->text().toUTF8(); |
---|
84 | envoi[3] = initialPhaseEdit_->text().toUTF8(); |
---|
85 | envoi[4] = phaseStepMaxEdit_->text().toUTF8(); |
---|
86 | envoi[5] = acceleratingFieldEdit_->text().toUTF8(); |
---|
87 | envoi[6] = acceleratingShapeFileEdit_->text().toUTF8(); |
---|
88 | envoi[7] = focusingMagFileEdit_->text().toUTF8(); |
---|
89 | envoi[8] = offsetMagEdit_->text().toUTF8(); |
---|
90 | envoi[9] = scaleFactorEdit_->text().toUTF8(); |
---|
91 | |
---|
92 | element_->setParametersString(envoi); |
---|
93 | } |
---|