source: PSPA/Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_bend.cc @ 289

Last change on this file since 289 was 289, checked in by garnier, 11 years ago

refactoring : part 1

File size: 2.9 KB
Line 
1
2#include "GWt_bend.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
11GWt_bend::GWt_bend(abstractElement* elem ) : GWt_abstractElement(elem)
12{
13   
14    string* param = beginDialog();
15   
16    new WText("angle (deg.) : ",dialog_->contents());
17    angleEdit_ = new WLineEdit( param->c_str(), dialog_->contents());
18    new WBreak(dialog_->contents());
19   
20    new WText("radius (m) : ",dialog_->contents());
21    radiusEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());
22    new WBreak(dialog_->contents());
23   
24    new WText("momentum (MeV/c) : ",dialog_->contents());
25    momentumEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());
26    new WBreak(dialog_->contents());
27   
28    new WText("length (cm) : ",dialog_->contents());
29    xlengthEdit_ = new WLineEdit("0", dialog_->contents());
30    xlengthEdit_->setDisabled(true);
31    new WBreak(dialog_->contents());
32   
33    new WText("aperture (cm) : ",dialog_->contents());
34    apertureEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());
35    apertureEdit_->setDisabled(true);
36    new WBreak(dialog_->contents());
37   
38    new WText("pole face rotations (deg.) entrance : ",dialog_->contents());
39    beta1Edit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());
40    new WText("exit : ",dialog_->contents());
41    beta2Edit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());
42    new WBreak(dialog_->contents());
43   
44    WPushButton *submit = new WPushButton("OK",dialog_->contents());
45    submit->clicked().connect(dialog_, &Wt::WDialog::accept);
46    dialog_->finished().connect(this, &GWt_bend::dialogDone);
47   
48    // make image
49    image_ = new WImage("htdocs/bend.jpg",this);
50   
51    // activate slots
52    image_->clicked().connect(this,&GWt_abstractElement::clicked);
53   
54   
55}
56
57void GWt_bend::dialogDone()
58{
59    unsigned nbParam = abstractElement_->getNbParams();
60    string* envoi = new string[nbParam+1];
61    int compteur = -1;
62    envoi[++compteur] = string(mixedTools::intToString(nbParam) );
63    envoi[++compteur] = labelEdit_->text().toUTF8();
64    cout << " GWt_bend::dialogDone() j'envoie " << envoi[compteur] << endl;
65    envoi[++compteur] = angleEdit_->text().toUTF8();
66    envoi[++compteur] = radiusEdit_->text().toUTF8();
67    envoi[++compteur] = momentumEdit_->text().toUTF8();
68    envoi[++compteur] = apertureEdit_->text().toUTF8();
69    envoi[++compteur] = beta1Edit_->text().toUTF8();
70    envoi[++compteur] = beta2Edit_->text().toUTF8();
71   
72    if ( compteur !=  (int)nbParam ) {
73        cerr << " GWt_bend::dialogDone() pb nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl;
74        return;
75    }
76    abstractElement_->setParametersString(envoi);
77    updateLabelWidget();
78    delete [] envoi;
79}
80
81
82WImage* GWt_bend::getImage() {
83    return image_;
84}
85
86
87WString GWt_bend::print(){
88    return WString(abstractElement_->print());
89}
Note: See TracBrowser for help on using the repository browser.