source: PSPA/Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_drift.cc @ 372

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

bug fix #18

File size: 1.8 KB
Line 
1
2#include "GWt_drift.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_drift::GWt_drift(GWt_elementLigneFaisceau* elemLigne)
12:GWt_abstractElement(new elementDrift())
13{
14  elementLigneFaiseauContainer_ = elemLigne;
15  initialize();
16}
17
18void GWt_drift::initilializeDialog() 
19{
20  string* param = beginDialog();
21   
22  new WText("length (cm) : ",dialog_->contents());
23  xlengthEdit_ = new WLineEdit(param->c_str(), dialog_->contents());
24  new WBreak(dialog_->contents());
25  new WText("aperture (cm) : ",dialog_->contents());
26  apertureEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());
27  new WBreak(dialog_->contents());
28 
29  WPushButton *annule= new WPushButton("cancel",dialog_->contents()); 
30  annule->clicked().connect(dialog_, &Wt::WDialog::reject);
31  WPushButton *submit= new WPushButton("OK",dialog_->contents());
32  submit->clicked().connect(dialog_, &Wt::WDialog::accept);
33  dialog_->finished().connect(this, &GWt_drift::dialogDone);
34}
35
36void GWt_drift::dialogDone(WDialog::DialogCode code)
37{
38  if (code != Wt::WDialog::Accepted) return;
39 
40  unsigned nbParam = abstractElement_->getNbParams();
41  string* envoi = new string[nbParam+1];
42  int compteur = -1;
43 
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  if ( compteur !=  (int)nbParam ) {
49    cerr << " GWt_drift::dialogDone() pb nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl;
50    return;
51  }
52  abstractElement_->setParametersString(envoi);
53  updateLabelAndToolTipWidget();
54  delete [] envoi;
55}
56
57WImage* GWt_drift::getImage() {
58  return image_;
59}
Note: See TracBrowser for help on using the repository browser.