1 | |
---|
2 | #include "GWt_elementQpole.h" |
---|
3 | #include "mixedTools.h" |
---|
4 | |
---|
5 | #include <Wt/WText> |
---|
6 | #include <Wt/WLineEdit> |
---|
7 | #include <Wt/WBreak> |
---|
8 | #include <Wt/WDialog> |
---|
9 | #include <Wt/WPushButton> |
---|
10 | |
---|
11 | GWt_elementQpole::GWt_elementQpole(GWt_elementLigneFaisceau* elm,abstractElement* abstract) : GWt_abstractElement(abstract) |
---|
12 | { |
---|
13 | elementLigneFaiseauContainer_ = elm; |
---|
14 | initialize(); |
---|
15 | } |
---|
16 | |
---|
17 | void GWt_elementQpole::initilializeDialog() |
---|
18 | { |
---|
19 | string* param = beginDialog(); |
---|
20 | new WText("length (m) : ",dialog_->contents()); |
---|
21 | lengthEdit_ = new WLineEdit(param->c_str(),dialog_->contents()); |
---|
22 | new WBreak(dialog_->contents()); |
---|
23 | new WText("component (m^-2) : ",dialog_->contents()); |
---|
24 | componentEdit_ = new WLineEdit((++param)->c_str(),dialog_->contents()); |
---|
25 | new WBreak(dialog_->contents()); |
---|
26 | |
---|
27 | WPushButton *annule= new WPushButton("cancel",dialog_->contents()); |
---|
28 | annule->clicked().connect(dialog_, &Wt::WDialog::reject); |
---|
29 | WPushButton *submit= new WPushButton("OK",dialog_->contents()); |
---|
30 | submit->clicked().connect(dialog_, &Wt::WDialog::accept); |
---|
31 | dialog_->finished().connect(this, &GWt_elementQpole::dialogDone); |
---|
32 | } |
---|
33 | |
---|
34 | void GWt_elementQpole::dialogDone(WDialog::DialogCode code) |
---|
35 | { |
---|
36 | if (code != Wt::WDialog::Accepted) return; |
---|
37 | |
---|
38 | unsigned nbParam = abstractElement_->getNbParams(); |
---|
39 | string* envoi = new string[nbParam+1]; |
---|
40 | int compteur = -1; |
---|
41 | |
---|
42 | envoi[++compteur] = mixedTools::intToString(nbParam); |
---|
43 | envoi[++compteur] = labelEdit_->text().toUTF8(); |
---|
44 | envoi[++compteur] = lengthEdit_->text().toUTF8(); |
---|
45 | envoi[++compteur] = componentEdit_->text().toUTF8(); |
---|
46 | if ( compteur != (int)nbParam ) { |
---|
47 | cerr << " GWt_elementQpole::dialogDone() : pb dans le nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl; |
---|
48 | return; |
---|
49 | } |
---|
50 | |
---|
51 | abstractElement_->setParametersString(envoi); |
---|
52 | updateLabelAndToolTipWidget(); |
---|
53 | delete [] envoi; |
---|
54 | } |
---|
55 | |
---|
56 | WImage* GWt_elementQpole::getImage() { |
---|
57 | return image_; |
---|
58 | } |
---|