[106] | 1 | |
---|
[437] | 2 | #include "GWt_elementCell.h" |
---|
[202] | 3 | #include "mixedTools.h" |
---|
[106] | 4 | |
---|
[38] | 5 | #include <Wt/WText> |
---|
| 6 | #include <Wt/WLineEdit> |
---|
| 7 | #include <Wt/WBreak> |
---|
| 8 | #include <Wt/WDialog> |
---|
| 9 | #include <Wt/WPushButton> |
---|
[46] | 10 | #include <Wt/WPanel> |
---|
[38] | 11 | |
---|
[437] | 12 | GWt_elementCell::GWt_elementCell(GWt_elementLigneFaisceau* elemLigne) |
---|
[305] | 13 | :GWt_abstractElement(new elementCell()) |
---|
[38] | 14 | { |
---|
[293] | 15 | elementLigneFaiseauContainer_ = elemLigne; |
---|
[310] | 16 | initialize(); |
---|
[308] | 17 | } |
---|
| 18 | |
---|
[437] | 19 | void GWt_elementCell::initilializeDialog() |
---|
[328] | 20 | { |
---|
| 21 | string* param = beginDialog(); |
---|
[272] | 22 | |
---|
[328] | 23 | new WText("length (cm) : ",dialog_->contents()); |
---|
| 24 | lenghtElemEdit_ = new WLineEdit(param->c_str(), dialog_->contents()); |
---|
| 25 | new WBreak(dialog_->contents()); |
---|
[272] | 26 | |
---|
[328] | 27 | new WText("aperture (cm) : ",dialog_->contents()); |
---|
| 28 | apertureEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
| 29 | new WBreak(dialog_->contents()); |
---|
| 30 | |
---|
| 31 | new WText("initial phase (deg.) : ",dialog_->contents()); |
---|
| 32 | initialPhaseEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
| 33 | new WBreak(dialog_->contents()); |
---|
| 34 | |
---|
| 35 | new WText("max phase step (deg.) : ",dialog_->contents()); |
---|
| 36 | phaseStepMaxEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
| 37 | new WBreak(dialog_->contents()); |
---|
| 38 | |
---|
| 39 | new WText("max accelerating field (MV/m) : ",dialog_->contents()); |
---|
| 40 | acceleratingFieldEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
| 41 | new WBreak(dialog_->contents()); |
---|
| 42 | |
---|
| 43 | new WText("name of file for field shape : ",dialog_->contents()); |
---|
| 44 | acceleratingShapeFileEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
| 45 | new WBreak(dialog_->contents()); |
---|
| 46 | |
---|
| 47 | WPanel *panel = new WPanel(dialog_->contents()); |
---|
| 48 | panel->setTitle(" magnetic focusing "); |
---|
| 49 | |
---|
| 50 | WText* t1 = new WText("name of file for focusing mag. field : ",dialog_->contents()); |
---|
| 51 | focusingMagFileEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
| 52 | new WBreak(dialog_->contents()); |
---|
| 53 | |
---|
| 54 | WText* t2 = new WText(" z-offset for mag. field : ",dialog_->contents()); |
---|
| 55 | offsetMagEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
| 56 | |
---|
| 57 | WText* t3 = new WText(" scaling factor for mag. field : ",dialog_->contents()); |
---|
| 58 | scaleFactorEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
| 59 | |
---|
| 60 | WContainerWidget* contenu = new WContainerWidget(); |
---|
| 61 | contenu->addWidget(t1); |
---|
| 62 | contenu->addWidget(focusingMagFileEdit_); |
---|
| 63 | contenu->addWidget(new WBreak()); |
---|
| 64 | contenu->addWidget(t2); |
---|
| 65 | contenu->addWidget(offsetMagEdit_); |
---|
| 66 | contenu->addWidget(new WBreak()); |
---|
| 67 | contenu->addWidget(t3); |
---|
| 68 | contenu->addWidget(scaleFactorEdit_); |
---|
| 69 | |
---|
| 70 | panel->setCentralWidget(contenu); |
---|
| 71 | |
---|
| 72 | WPushButton *annule= new WPushButton("cancel",dialog_->contents()); |
---|
| 73 | annule->clicked().connect(dialog_, &Wt::WDialog::reject); |
---|
| 74 | WPushButton *submit= new WPushButton("OK",dialog_->contents()); |
---|
| 75 | submit->clicked().connect(dialog_, &Wt::WDialog::accept); |
---|
[437] | 76 | dialog_->finished().connect(this, &GWt_elementCell::dialogDone); |
---|
[38] | 77 | } |
---|
| 78 | |
---|
[437] | 79 | void GWt_elementCell::dialogDone(WDialog::DialogCode code) |
---|
[38] | 80 | { |
---|
[328] | 81 | if (code != Wt::WDialog::Accepted) return; |
---|
| 82 | |
---|
| 83 | unsigned nbParam = abstractElement_->getNbParams(); |
---|
| 84 | string* envoi = new string[nbParam+1]; |
---|
| 85 | int compteur = -1; |
---|
[272] | 86 | |
---|
[328] | 87 | envoi[++compteur] = mixedTools::intToString(nbParam); |
---|
| 88 | envoi[++compteur] = labelEdit_->text().toUTF8(); |
---|
| 89 | envoi[++compteur] = lenghtElemEdit_->text().toUTF8(); |
---|
| 90 | envoi[++compteur] = apertureEdit_->text().toUTF8(); |
---|
| 91 | envoi[++compteur] = initialPhaseEdit_->text().toUTF8(); |
---|
| 92 | envoi[++compteur] = phaseStepMaxEdit_->text().toUTF8(); |
---|
| 93 | envoi[++compteur] = acceleratingFieldEdit_->text().toUTF8(); |
---|
| 94 | envoi[++compteur] = acceleratingShapeFileEdit_->text().toUTF8(); |
---|
| 95 | envoi[++compteur] = focusingMagFileEdit_->text().toUTF8(); |
---|
| 96 | envoi[++compteur] = offsetMagEdit_->text().toUTF8(); |
---|
| 97 | envoi[++compteur] = scaleFactorEdit_->text().toUTF8(); |
---|
| 98 | if ( compteur != (int)nbParam ) { |
---|
[437] | 99 | cerr << " GWt_elementCell::dialogDone() pb nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl; |
---|
[328] | 100 | return; |
---|
| 101 | } |
---|
| 102 | abstractElement_->setParametersString(envoi); |
---|
[372] | 103 | updateLabelAndToolTipWidget(); |
---|
[328] | 104 | delete [] envoi; |
---|
[38] | 105 | } |
---|