source: PSPA/Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_globalParameters.cc @ 436

Last change on this file since 436 was 436, checked in by touze, 11 years ago

ajout de secteurs

File size: 3.4 KB
Line 
1
2#include <Wt/WDialog>
3#include <Wt/WLineEdit>
4#include <Wt/WBreak>
5#include <Wt/WPushButton>
6
7#include "GWt_globalParameters.h"
8#include "GWt_console.h"
9
10#include "dataManager.h"
11
12GWt_globalParameters::GWt_globalParameters(dataManager* dt)
13{
14  dt_ = dt;
15}
16
17void GWt_globalParameters::setText(WText *st)
18{
19  status_ = st;
20}
21
22void GWt_globalParameters::initilializeDialog()
23{
24  dialog_ = new WDialog("global parameters");
25  string* param = dialogBegin();
26
27  new WText("Enter frequency (MHz) : ",dialog_->contents());
28  frequencyEdit_ = new WLineEdit(param[1].c_str(),dialog_->contents());
29  new WBreak(dialog_->contents());
30  new WText("Enter step in phase (deg) : ",dialog_->contents());
31  stepEdit_ = new WLineEdit(param[2].c_str(),dialog_->contents());
32  new WBreak(dialog_->contents());
33  new WText("Enter max step number : ",dialog_->contents());
34  nstepMAxEdit_ = new WLineEdit(param[3].c_str(),dialog_->contents());
35  new WBreak(dialog_->contents());
36  new WText("Enter periodicity of s.c. computation : ",dialog_->contents());
37  nscEdit_ = new WLineEdit(param[4].c_str(),dialog_->contents());
38  new WBreak(dialog_->contents());
39
40  WPushButton *ok =  new WPushButton("Ok", dialog_->contents());
41  ok->clicked().connect(dialog_, &WDialog::accept);
42  WPushButton *no = new WPushButton("Cancel", dialog_->contents());
43  no->clicked().connect(dialog_, &WDialog::reject);
44
45  dialog_->finished().connect(this,&GWt_globalParameters::dialogDone);
46  //dialog_->show();
47  dialog_->exec(WAnimation(WAnimation::SlideInFromTop));
48}
49
50string* GWt_globalParameters::dialogBegin()
51{
52  string* param = dt_->getGlobalParameters()->getParametersString();
53  if ( param == NULL ) {
54    if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
55      GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
56      console->addConsoleMessage(" GWt_globalParameters : empty parameter set");
57    }
58  }
59
60  int nbparam = atoi(param[0].c_str());
61  if ( nbparam != 4 ) {
62    if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
63      GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
64      console->addConsoleMessage(" GWt_globalParameters : wrong number of parameters");
65    }
66  }
67 
68  envoi_[0] = param[0].c_str();
69  envoi_[1] = param[1].c_str();
70  envoi_[2] = param[2].c_str();
71  envoi_[3] = param[3].c_str();
72  envoi_[4] = param[4].c_str();
73  return param;
74}
75
76void GWt_globalParameters::dialogDone(WDialog::DialogCode code)
77{
78  if (code == WDialog::Accepted) {
79    updateGlobals();
80    setStatus();
81  }
82  return;
83}
84
85void GWt_globalParameters::updateGlobals()
86{
87  envoi_[0] = string("4");
88  envoi_[1] = frequencyEdit_->text().toUTF8();
89  envoi_[2] = stepEdit_->text().toUTF8();
90  envoi_[3] = nstepMAxEdit_->text().toUTF8();
91  envoi_[4] = nscEdit_->text().toUTF8();
92  dt_->getGlobalParameters()->setParametersString(envoi_);
93}
94
95void GWt_globalParameters::renew()
96{
97  string* param = dialogBegin();
98  //setStatus();
99  frequencyEdit_ = new WLineEdit(param[1].c_str());
100  stepEdit_ = new WLineEdit(param[2].c_str());
101  nstepMAxEdit_ = new WLineEdit(param[3].c_str());
102  nscEdit_ = new WLineEdit(param[4].c_str());
103}
104
105void GWt_globalParameters::setStatus()
106{
107  WString out= WString("<p>frequency = "+envoi_[1]+"</p>"
108                       "<p>step in phase = "+envoi_[2]+"</p>"
109                       "<p>max step number = "+envoi_[3]+"</p>"
110                       "<p>periodicity of s.c. computation = "+envoi_[4]+"</p>");
111  status_->setText(out);
112}
Note: See TracBrowser for help on using the repository browser.