1 | #include "GWt_soleno.h" |
---|
2 | #include "mixedTools.h" |
---|
3 | |
---|
4 | #include <Wt/WText> |
---|
5 | #include <Wt/WLineEdit> |
---|
6 | #include <Wt/WBreak> |
---|
7 | #include <Wt/WDialog> |
---|
8 | #include <Wt/WPushButton> |
---|
9 | |
---|
10 | GWt_soleno::GWt_soleno(abstractElement* elem) : GWt_abstractElement(elem) |
---|
11 | { |
---|
12 | string* param = beginDialog(); |
---|
13 | |
---|
14 | new WText("length (cm) : ",dialog_->contents()); |
---|
15 | xlengthEdit_ = new WLineEdit( param->c_str(), dialog_->contents()); |
---|
16 | new WBreak(dialog_->contents()); |
---|
17 | new WText("aperture (cm) : ",dialog_->contents()); |
---|
18 | apertureEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
19 | new WBreak(dialog_->contents()); |
---|
20 | new WText("field (kG) : ",dialog_->contents()); |
---|
21 | B0Edit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); |
---|
22 | varyB0Edit_ = new WCheckBox(" : may vary ? ", dialog_->contents()); |
---|
23 | varyB0Edit_->setChecked(atoi( (++param)->c_str() ) ); |
---|
24 | new WBreak(dialog_->contents()); |
---|
25 | // Submit |
---|
26 | WPushButton *submit = new WPushButton("OK",dialog_->contents()); |
---|
27 | submit->clicked().connect(dialog_, &Wt::WDialog::accept); |
---|
28 | dialog_->finished().connect(this, &GWt_soleno::dialogDone); |
---|
29 | |
---|
30 | // make image |
---|
31 | image_ = new WImage("htdocs/soleno.jpg",this); |
---|
32 | |
---|
33 | // activate slots |
---|
34 | image_->clicked().connect(this,&GWt_abstractElement::clicked); |
---|
35 | |
---|
36 | } |
---|
37 | |
---|
38 | |
---|
39 | void GWt_soleno::dialogDone() |
---|
40 | { |
---|
41 | unsigned nbParam = abstractElement_->getNbParams(); |
---|
42 | string* envoi = new string[nbParam+1]; |
---|
43 | int compteur = -1; |
---|
44 | envoi[++compteur] = mixedTools::intToString(nbParam); |
---|
45 | envoi[++compteur] = labelEdit_->text().toUTF8(); |
---|
46 | envoi[++compteur] = xlengthEdit_->text().toUTF8(); |
---|
47 | envoi[++compteur] = apertureEdit_->text().toUTF8(); |
---|
48 | envoi[++compteur] = B0Edit_->text().toUTF8(); |
---|
49 | int varie; |
---|
50 | if ( varyB0Edit_->checkState() == Checked ) varie = 1; |
---|
51 | else varie = 0; |
---|
52 | envoi[++compteur] = mixedTools::intToString(varie); |
---|
53 | if ( compteur != (int)nbParam ) { |
---|
54 | cerr << " GWt_bend::dialogDone() pb nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl; |
---|
55 | return; |
---|
56 | } |
---|
57 | abstractElement_->setParametersString(envoi); |
---|
58 | updateLabelWidget(); |
---|
59 | delete [] envoi; |
---|
60 | } |
---|
61 | |
---|
62 | |
---|
63 | WImage* GWt_soleno::getImage() { |
---|
64 | return image_; |
---|
65 | } |
---|
66 | |
---|
67 | |
---|
68 | WString GWt_soleno::print(){ |
---|
69 | return WString(abstractElement_->print()); |
---|
70 | } |
---|