source: PSPA/Interface_Web/trunk/pspaWT/src/GWt_soleno.cc @ 82

Last change on this file since 82 was 82, checked in by lemeur, 12 years ago

introduction element solenoid

File size: 1.9 KB
Line 
1#include "GWt_soleno.h"
2#include "mixedTools.h"
3#include <Wt/WText>
4#include <Wt/WLineEdit>
5#include <Wt/WBreak>
6#include <Wt/WDialog>
7#include <Wt/WPushButton>
8
9
10GWt_soleno::GWt_soleno(PspaApplication* ps, abstractElement* elem, string image)
11{
12
13  pspa_ = ps;
14  pspa_->updateSelections();
15  solenoElement_ = elem;
16  dropped_ = new WPushButton();
17
18  dropped_->clicked().connect(this, &GWt_soleno::openParametersForm);
19
20  dropped_->setIcon(image);
21  dropped_->setMaximumSize(50,50);
22
23  string* param = solenoElement_-> getParametersString();
24  if ( param == NULL )
25    {
26      pspa_->addConsoleMessage(" GWt_soleno : empty parameter set");
27    }
28  int nbparam = atoi(param[0].c_str());
29  if ( nbparam != 3 ) 
30    {
31      pspa_->addConsoleMessage(" element seems not to be a SOLENOID");
32    }
33
34  dialog_ = new WDialog("element SOLENOID");
35
36  new WText("length : ",dialog_->contents());
37  xlengthEdit_ = new WLineEdit(param[1].c_str(), dialog_->contents());
38  new WBreak(dialog_->contents());
39  new WText("aperture : ",dialog_->contents());
40  apertureEdit_ = new WLineEdit(param[2].c_str(), dialog_->contents());
41  new WBreak(dialog_->contents());
42  new WText("fielg (kG) : ",dialog_->contents());
43  B0Edit_ = new WLineEdit(param[3].c_str(), dialog_->contents());
44  new WBreak(dialog_->contents());
45
46  // Submit
47  WPushButton *submit = new WPushButton("OK",dialog_->contents());
48  submit->clicked().connect(dialog_, &Wt::WDialog::accept);
49
50  dialog_->finished().connect(this, &GWt_soleno::dialogDone);
51}
52
53WPushButton* GWt_soleno::getButton() { return dropped_;}
54WDialog* GWt_soleno::getDialog() { return dialog_;}
55
56void GWt_soleno::openParametersForm()
57{
58 dialog_->show();
59}
60
61void GWt_soleno::dialogDone()
62{
63  string envoi[4];
64  envoi[0] = string("3");
65  envoi[1] = xlengthEdit_->text().toUTF8();
66  envoi[2] = apertureEdit_->text().toUTF8();
67  envoi[3] = B0Edit_->text().toUTF8();
68  solenoElement_->setParametersString(envoi);
69}
Note: See TracBrowser for help on using the repository browser.