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