#include #include #include #include #include "GWt_globalParameters.h" #include "GWt_console.h" #include "dataManager.h" GWt_globalParameters::GWt_globalParameters(dataManager* dt) { dt_ = dt; } void GWt_globalParameters::setText(WContainerWidget* wt) { status_ = new WText("Go ahead...",wt); } void GWt_globalParameters::initilializeDialog() { dialog_ = new WDialog("global parameters"); string* param = dialogBegin(); new WText("Enter frequency (MHz) : ",dialog_->contents()); frequencyEdit_ = new WLineEdit(param[1].c_str(),dialog_->contents()); new WBreak(dialog_->contents()); new WText("Enter step in phase (deg) : ",dialog_->contents()); stepEdit_ = new WLineEdit(param[2].c_str(),dialog_->contents()); new WBreak(dialog_->contents()); new WText("Enter max step number : ",dialog_->contents()); nstepMAxEdit_ = new WLineEdit(param[3].c_str(),dialog_->contents()); new WBreak(dialog_->contents()); new WText("Enter periodicity of s.c. computation : ",dialog_->contents()); nscEdit_ = new WLineEdit(param[4].c_str(),dialog_->contents()); new WBreak(dialog_->contents()); WPushButton *ok = new WPushButton("Ok", dialog_->contents()); ok->clicked().connect(dialog_, &WDialog::accept); WPushButton *no = new WPushButton("Cancel", dialog_->contents()); no->clicked().connect(dialog_, &WDialog::reject); dialog_->finished().connect(this,&GWt_globalParameters::dialogDone); //dialog_->show(); dialog_->exec(WAnimation(WAnimation::SlideInFromTop)); } string* GWt_globalParameters::dialogBegin() { string* param = dt_->getGlobalParameters()->getParametersString(); if ( param == NULL ) { if ( static_cast (wApp->findWidget ("console"))) { GWt_console* console = static_cast (wApp->findWidget ("console")); console->addConsoleMessage(" GWt_globalParameters : empty parameter set"); } } int nbparam = atoi(param[0].c_str()); if ( nbparam != 4 ) { if ( static_cast (wApp->findWidget ("console"))) { GWt_console* console = static_cast (wApp->findWidget ("console")); console->addConsoleMessage(" GWt_globalParameters : wrong number of parameters"); } } envoi_[0] = param[0].c_str(); envoi_[1] = param[1].c_str(); envoi_[2] = param[2].c_str(); envoi_[3] = param[3].c_str(); envoi_[4] = param[4].c_str(); return param; } void GWt_globalParameters::dialogDone(WDialog::DialogCode code) { if (code == WDialog::Accepted) { updateGlobals(); setStatus(); } return; } void GWt_globalParameters::updateGlobals() { envoi_[0] = string("4"); envoi_[1] = frequencyEdit_->text().toUTF8(); envoi_[2] = stepEdit_->text().toUTF8(); envoi_[3] = nstepMAxEdit_->text().toUTF8(); envoi_[4] = nscEdit_->text().toUTF8(); dt_->getGlobalParameters()->setParametersString(envoi_); } void GWt_globalParameters::renew() { string* param = dialogBegin(); setStatus(); frequencyEdit_ = new WLineEdit(param[1].c_str()); stepEdit_ = new WLineEdit(param[2].c_str()); nstepMAxEdit_ = new WLineEdit(param[3].c_str()); nscEdit_ = new WLineEdit(param[4].c_str()); } void GWt_globalParameters::setStatus() { WString out= WString("

frequency="+envoi_[1]+"

" "

step in phase="+envoi_[2]+"

" "

max step number="+envoi_[3]+"

" "

periodicity of s.c. computation="+envoi_[4]+"

"); status_->setText(out); }