1 | |
---|
2 | #include <Wt/WDialog> |
---|
3 | #include <Wt/WLineEdit> |
---|
4 | #include <Wt/WBreak> |
---|
5 | #include <Wt/WPushButton> |
---|
6 | |
---|
7 | #include "GWt_globalParameters.h" |
---|
8 | #include "GWt_console.h" |
---|
9 | |
---|
10 | #include "dataManager.h" |
---|
11 | |
---|
12 | GWt_globalParameters::GWt_globalParameters(dataManager* dt) |
---|
13 | { |
---|
14 | dt_ = dt; |
---|
15 | } |
---|
16 | |
---|
17 | GWt_globalParameters::GWt_globalParameters(dataManager* dt,WContainerWidget* wt) |
---|
18 | { |
---|
19 | dt_ = dt; |
---|
20 | status_ = new WText("Go ahead...",wt); |
---|
21 | } |
---|
22 | |
---|
23 | void GWt_globalParameters::initilializeDialog() |
---|
24 | { |
---|
25 | string* param = dialogBegin(); |
---|
26 | |
---|
27 | dialog_ = new WDialog("global parameters"); |
---|
28 | new WText("Enter frequency (MHz) : ",dialog_->contents()); |
---|
29 | frequencyEdit_ = new WLineEdit(param[1].c_str(),dialog_->contents()); |
---|
30 | new WBreak(dialog_->contents()); |
---|
31 | new WText("Enter step in phase (deg) : ",dialog_->contents()); |
---|
32 | stepEdit_ = new WLineEdit(param[2].c_str(),dialog_->contents()); |
---|
33 | new WBreak(dialog_->contents()); |
---|
34 | new WText("Enter max step number : ",dialog_->contents()); |
---|
35 | nstepMAxEdit_ = new WLineEdit(param[3].c_str(),dialog_->contents()); |
---|
36 | new WBreak(dialog_->contents()); |
---|
37 | new WText("Enter periodicity of s.c. computation : ",dialog_->contents()); |
---|
38 | nscEdit_ = new WLineEdit(param[4].c_str(),dialog_->contents()); |
---|
39 | new WBreak(dialog_->contents()); |
---|
40 | |
---|
41 | WPushButton *ok = new WPushButton("Ok", dialog_->contents()); |
---|
42 | ok->clicked().connect(dialog_, &WDialog::accept); |
---|
43 | WPushButton *no = new WPushButton("Cancel", dialog_->contents()); |
---|
44 | no->clicked().connect(dialog_, &WDialog::reject); |
---|
45 | |
---|
46 | dialog_->finished().connect(this,&GWt_globalParameters::dialogDone); |
---|
47 | //dialog_->show(); |
---|
48 | dialog_->exec(WAnimation(WAnimation::SlideInFromTop)); |
---|
49 | } |
---|
50 | |
---|
51 | string* GWt_globalParameters::dialogBegin() |
---|
52 | { |
---|
53 | string* param = dt_->getGlobalParameters()->getParametersString(); |
---|
54 | if ( param == NULL ) { |
---|
55 | if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) { |
---|
56 | GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console")); |
---|
57 | console->addConsoleMessage(" GWt_globalParameters : empty parameter set"); |
---|
58 | } |
---|
59 | } |
---|
60 | |
---|
61 | int nbparam = atoi(param[0].c_str()); |
---|
62 | if ( nbparam != 4 ) { |
---|
63 | if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) { |
---|
64 | GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console")); |
---|
65 | console->addConsoleMessage(" GWt_globalParameters : wrong number of parameters"); |
---|
66 | } |
---|
67 | } |
---|
68 | |
---|
69 | envoi_[0] = param[0].c_str(); |
---|
70 | envoi_[1] = param[1].c_str(); |
---|
71 | envoi_[2] = param[2].c_str(); |
---|
72 | envoi_[3] = param[3].c_str(); |
---|
73 | envoi_[4] = param[4].c_str(); |
---|
74 | setStatus(); |
---|
75 | return param; |
---|
76 | } |
---|
77 | |
---|
78 | void GWt_globalParameters::dialogDone(WDialog::DialogCode code) |
---|
79 | { |
---|
80 | if (code == WDialog::Accepted) updateGlobals(); |
---|
81 | return; |
---|
82 | } |
---|
83 | |
---|
84 | void GWt_globalParameters::updateGlobals() |
---|
85 | { |
---|
86 | envoi_[0] = string("4"); |
---|
87 | envoi_[1] = frequencyEdit_->text().toUTF8(); |
---|
88 | envoi_[2] = stepEdit_->text().toUTF8(); |
---|
89 | envoi_[3] = nstepMAxEdit_->text().toUTF8(); |
---|
90 | envoi_[4] = nscEdit_->text().toUTF8(); |
---|
91 | |
---|
92 | setStatus(); |
---|
93 | dt_->getGlobalParameters()->setParametersString(envoi_); |
---|
94 | } |
---|
95 | |
---|
96 | void GWt_globalParameters::renew() |
---|
97 | { |
---|
98 | string* param = dialogBegin(); |
---|
99 | |
---|
100 | frequencyEdit_->setText(param[1].c_str()); |
---|
101 | stepEdit_->setText(param[2].c_str()); |
---|
102 | nstepMAxEdit_->setText(param[3].c_str()); |
---|
103 | nscEdit_->setText(param[4].c_str()); |
---|
104 | } |
---|
105 | |
---|
106 | string* GWt_globalParameters::getGlobalParameters() |
---|
107 | { |
---|
108 | return envoi_; |
---|
109 | } |
---|
110 | |
---|
111 | void GWt_globalParameters::setStatus() |
---|
112 | { |
---|
113 | WString out= WString("<p>frequency="+envoi_[1]+"</p>" |
---|
114 | "<p>step in phase="+envoi_[2]+"</p>" |
---|
115 | "<p>max step number="+envoi_[3]+"</p>" |
---|
116 | "<p>periodicity of s.c. computation="+envoi_[4]+"</p>"); |
---|
117 | status_->setText(out); |
---|
118 | } |
---|