#include #include #include "GWt_sectorParameters.h" #include "dataManager.h" GWt_sectorParameters::GWt_sectorParameters(dataManager* dt) { dt_ = dt; } void GWt_sectorParameters::setText(WText *st) { status_ = st; } string* GWt_sectorParameters::getSectorParameters() { string* param = dt_->getSectorParameters()->getParametersString(); 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_sectorParameters::execDialog() { dialog_ = new WDialog("sector parameters"); string* param = getSectorParameters(); new WText("geometry : ",dialog_->contents()); geometry_ = new WLineEdit(param[1].c_str(),dialog_->contents()); geometry_->disable(); new WBreak(dialog_->contents()); new WText("Enter number of cells : ",dialog_->contents()); nCells_ = new WLineEdit(param[2].c_str(),dialog_->contents()); new WBreak(dialog_->contents()); new WText("Enter cell length (m): ",dialog_->contents()); lCell_ = new WLineEdit(param[3].c_str(),dialog_->contents()); new WBreak(dialog_->contents()); new WText("Enter particle momentum (GeV/c) : ",dialog_->contents()); pc_ = 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_sectorParameters::dialogDone); dialog_->exec(WAnimation(WAnimation::SlideInFromTop)); } void GWt_sectorParameters::dialogDone(WDialog::DialogCode code) { if (code == WDialog::Accepted) { update(); setStatus(); } return; } void GWt_sectorParameters::update() { envoi_[0] = string("4"); envoi_[1] = geometry_->text().toUTF8(); envoi_[2] = nCells_->text().toUTF8(); envoi_[3] = lCell_->text().toUTF8(); envoi_[4] = pc_->text().toUTF8(); dt_->getSectorParameters()->setParametersString(envoi_); } void GWt_sectorParameters::renew() { string* param = getSectorParameters(); setStatus(); geometry_ = new WLineEdit(param[1].c_str()); nCells_ = new WLineEdit(param[2].c_str()); lCell_ = new WLineEdit(param[3].c_str()); pc_ = new WLineEdit(param[4].c_str()); } void GWt_sectorParameters::setStatus() { WString out= WString("

geometry = "+envoi_[1]+"

" "

number of cells = "+envoi_[2]+"

" "

cell length = "+envoi_[3]+"

" "

particle momentum = "+envoi_[4]+"

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