source: PSPA/Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_soleno.cc @ 293

Last change on this file since 293 was 293, checked in by garnier, 12 years ago

bug #18 fixed

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