[431] | 1 | |
---|
| 2 | #include <Wt/WBreak> |
---|
| 3 | #include <Wt/WPushButton> |
---|
| 4 | |
---|
| 5 | #include "GWt_sectorParameters.h" |
---|
| 6 | #include "dataManager.h" |
---|
| 7 | |
---|
| 8 | GWt_sectorParameters::GWt_sectorParameters(dataManager* dt) |
---|
| 9 | { |
---|
| 10 | dt_ = dt; |
---|
| 11 | } |
---|
| 12 | |
---|
| 13 | void GWt_sectorParameters::setText(WText *st) |
---|
| 14 | { |
---|
| 15 | status_ = st; |
---|
| 16 | } |
---|
| 17 | |
---|
| 18 | string* GWt_sectorParameters::getSectorParameters() |
---|
| 19 | { |
---|
| 20 | string* param = dt_->getSectorParameters()->getParametersString(); |
---|
| 21 | envoi_[0] = param[0].c_str(); |
---|
| 22 | envoi_[1] = param[1].c_str(); |
---|
| 23 | envoi_[2] = param[2].c_str(); |
---|
| 24 | envoi_[3] = param[3].c_str(); |
---|
| 25 | envoi_[4] = param[4].c_str(); |
---|
| 26 | return param; |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | void GWt_sectorParameters::execDialog() |
---|
| 30 | { |
---|
| 31 | dialog_ = new WDialog("sector parameters"); |
---|
| 32 | string* param = getSectorParameters(); |
---|
| 33 | |
---|
| 34 | new WText("geometry : ",dialog_->contents()); |
---|
| 35 | geometry_ = new WLineEdit(param[1].c_str(),dialog_->contents()); |
---|
| 36 | geometry_->disable(); |
---|
| 37 | new WBreak(dialog_->contents()); |
---|
| 38 | new WText("Enter number of cells : ",dialog_->contents()); |
---|
| 39 | nCells_ = new WLineEdit(param[2].c_str(),dialog_->contents()); |
---|
| 40 | new WBreak(dialog_->contents()); |
---|
| 41 | new WText("Enter cell length (m): ",dialog_->contents()); |
---|
| 42 | lCell_ = new WLineEdit(param[3].c_str(),dialog_->contents()); |
---|
| 43 | new WBreak(dialog_->contents()); |
---|
| 44 | new WText("Enter particle momentum (GeV/c) : ",dialog_->contents()); |
---|
| 45 | pc_ = new WLineEdit(param[4].c_str(),dialog_->contents()); |
---|
| 46 | new WBreak(dialog_->contents()); |
---|
| 47 | |
---|
| 48 | WPushButton *ok = new WPushButton("Ok", dialog_->contents()); |
---|
| 49 | ok->clicked().connect(dialog_, &WDialog::accept); |
---|
| 50 | WPushButton *no = new WPushButton("Cancel", dialog_->contents()); |
---|
| 51 | no->clicked().connect(dialog_, &WDialog::reject); |
---|
| 52 | |
---|
| 53 | dialog_->finished().connect(this,&GWt_sectorParameters::dialogDone); |
---|
| 54 | dialog_->exec(WAnimation(WAnimation::SlideInFromTop)); |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | void GWt_sectorParameters::dialogDone(WDialog::DialogCode code) |
---|
| 58 | { |
---|
| 59 | if (code == WDialog::Accepted) { |
---|
| 60 | update(); |
---|
| 61 | setStatus(); |
---|
| 62 | } |
---|
| 63 | return; |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | void GWt_sectorParameters::update() |
---|
| 67 | { |
---|
| 68 | envoi_[0] = string("4"); |
---|
| 69 | envoi_[1] = geometry_->text().toUTF8(); |
---|
| 70 | envoi_[2] = nCells_->text().toUTF8(); |
---|
| 71 | envoi_[3] = lCell_->text().toUTF8(); |
---|
| 72 | envoi_[4] = pc_->text().toUTF8(); |
---|
| 73 | dt_->getSectorParameters()->setParametersString(envoi_); |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | void GWt_sectorParameters::renew() |
---|
| 77 | { |
---|
| 78 | string* param = getSectorParameters(); |
---|
| 79 | setStatus(); |
---|
| 80 | geometry_ = new WLineEdit(param[1].c_str()); |
---|
| 81 | nCells_ = new WLineEdit(param[2].c_str()); |
---|
| 82 | lCell_ = new WLineEdit(param[3].c_str()); |
---|
| 83 | pc_ = new WLineEdit(param[4].c_str()); |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | void GWt_sectorParameters::setStatus() |
---|
| 87 | { |
---|
| 88 | WString out= WString("<p>geometry = "+envoi_[1]+"</p>" |
---|
| 89 | "<p>number of cells = "+envoi_[2]+"</p>" |
---|
| 90 | "<p>cell length = "+envoi_[3]+"</p>" |
---|
| 91 | "<p>particle momentum = "+envoi_[4]+"</p>"); |
---|
| 92 | status_->setText(out); |
---|
| 93 | } |
---|