Ignore:
Timestamp:
Oct 25, 2013, 3:51:05 PM (11 years ago)
Author:
touze
Message:

preparation pour ajouter une maille FODO

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_globalParameters.cc

    r408 r427  
    1 #include "GWt_globalParameters.h"
    2 #include <Wt/WVBoxLayout>
    3 #include <Wt/WGroupBox>
    4 #include <Wt/WText>
     1
     2#include <Wt/WDialog>
    53#include <Wt/WLineEdit>
    64#include <Wt/WBreak>
    75#include <Wt/WPushButton>
    86
    9 #include <Wt/WComboBox>
    10 
    11 #include "mixedTools.h"
     7#include "GWt_globalParameters.h"
    128#include "GWt_console.h"
    139
     10#include "dataManager.h"
    1411
    15 GWt_globalParameters::GWt_globalParameters(PspaApplication* ps)
     12GWt_globalParameters::GWt_globalParameters(dataManager* dt)
    1613{
    17    
    18     pspa_ = ps;
    19     WVBoxLayout* globLayout = new WVBoxLayout();
    20     //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
    21     WContainerWidget *result = new WContainerWidget();
    22     WPanel *panel = new WPanel(result);
    23     panel->setTitle(" global parameters ");
    24    
    25    
    26     WText* freqText = new WText("frequency (MHz) : ");
    27     frequencyEdit_ = new WLineEdit();
    28    
    29     WText *stepText = new WText("step in phase (deg.) : ");
    30     stepEdit_ = new WLineEdit();
    31    
    32     WText *nstepMaxText = new WText("max step number : ");
    33     nstepMAxEdit_ = new WLineEdit();
    34    
    35     WText *nscText = new WText("periodicity of s.c. computation : ");
    36     nscEdit_ = new WLineEdit();
    37    
    38    
    39    
    40     WContainerWidget* contenu = new WContainerWidget();
    41     contenu->addWidget(freqText);
    42     contenu->addWidget(frequencyEdit_);
    43     contenu->addWidget(new WBreak());
    44     contenu->addWidget(stepText);
    45     contenu->addWidget(stepEdit_);
    46     contenu->addWidget(new WBreak());
    47     contenu->addWidget(nstepMaxText);
    48     contenu->addWidget(nstepMAxEdit_);
    49     contenu->addWidget(new WBreak());
    50     contenu->addWidget(nscText);
    51     contenu->addWidget(nscEdit_);
    52    
    53    
    54    
    55     panel->setCentralWidget(contenu);
    56     // panel->setCollapsible(true);
    57    
    58    
    59     //  WPanel *panelModules = new WPanel(result);
    60     // panelModules->setTitle(" sections of beam Line for executing softwres ");
    61    
    62    
    63     // WPushButton* push_add = new WPushButton("add");
    64    
    65    
    66     // contenuSections_ = new WContainerWidget();
    67    
    68     // addSection();
    69     // contenuSections_->addWidget( push_add);
    70    
    71    
    72     // panelModules->setCentralWidget(contenuSections_);
    73    
    74    
    75     globLayout->addWidget(result);
    76    
    77     setLayout(globLayout);
    78     globLayout->setContentsMargins(0,0,0,0);
    79     renew();
     14  dt_ = dt;
    8015}
    8116
    82 // void GWt_globalParameters::addSection()
    83 // {
    84 //   unsigned k;
    85 //   //   WComboBox* selectionBox = new WComboBox();
     17GWt_globalParameters::GWt_globalParameters(dataManager* dt,WContainerWidget* wt)
     18{
     19  dt_ = dt;
     20  status_ = new WText("Go ahead...",wt);
     21}
    8622
    87 //     sectionSelection_.push_back(new WComboBox());
     23void GWt_globalParameters::initilializeDialog()
     24{
     25  string* param = dialogBegin();
    8826
    89 //     contenuSections_->addWidget(new WBreak());
     27  dialog_ = new WDialog("global parameters");
     28  new WText("Enter frequency (MHz) : ",dialog_->contents());
     29  frequencyEdit_ = new WLineEdit(param[1].c_str(),dialog_->contents());
     30  new WBreak(dialog_->contents());
     31  new WText("Enter step in phase (deg) : ",dialog_->contents());
     32  stepEdit_ = new WLineEdit(param[2].c_str(),dialog_->contents());
     33  new WBreak(dialog_->contents());
     34  new WText("Enter max step number : ",dialog_->contents());
     35  nstepMAxEdit_ = new WLineEdit(param[3].c_str(),dialog_->contents());
     36  new WBreak(dialog_->contents());
     37  new WText("Enter periodicity of s.c. computation : ",dialog_->contents());
     38  nscEdit_ = new WLineEdit(param[4].c_str(),dialog_->contents());
     39  new WBreak(dialog_->contents());
    9040
    91 //     contenuSections_->addWidget(new WText(" from : "));
    92 //     contenuSections_->addWidget(new WLineEdit());
    93 //     contenuSections_->addWidget(new WText(" to : "));
    94 //     contenuSections_->addWidget(new WLineEdit());
     41  WPushButton *ok =  new WPushButton("Ok", dialog_->contents());
     42  ok->clicked().connect(dialog_, &WDialog::accept);
     43  WPushButton *no = new WPushButton("Cancel", dialog_->contents());
     44  no->clicked().connect(dialog_, &WDialog::reject);
    9545
     46  dialog_->finished().connect(this,&GWt_globalParameters::dialogDone);
     47  //dialog_->show();
     48  dialog_->exec(WAnimation(WAnimation::SlideInFromTop));
     49}
    9650
    97 //     contenuSections_->addWidget(sectionSelection_.back());
     51string* GWt_globalParameters::dialogBegin()
     52{
     53  string* param = dt_->getGlobalParameters()->getParametersString();
     54  if ( param == NULL ) {
     55    if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
     56      GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
     57      console->addConsoleMessage(" GWt_globalParameters : empty parameter set");
     58    }
     59  }
    9860
    99 //     unsigned nb = nomDeLogiciel::getNumberOfSoftwares();
    100 //     for ( k=0; k < nb; k++) sectionSelection_.back()->addItem( nomDeLogiciel(k).getString() );
    101 //     //    selectionBox->addItem("Transport");
    102 // }
     61  int nbparam = atoi(param[0].c_str());
     62  if ( nbparam != 4 ) {
     63    if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
     64      GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
     65      console->addConsoleMessage(" GWt_globalParameters : wrong number of parameters");
     66    }
     67  }
     68 
     69  envoi_[0] = param[0].c_str();
     70  envoi_[1] = param[1].c_str();
     71  envoi_[2] = param[2].c_str();
     72  envoi_[3] = param[3].c_str();
     73  envoi_[4] = param[4].c_str();
     74  setStatus();
     75  return param;
     76}
    10377
    104 
    105 void GWt_globalParameters::renew()
     78void GWt_globalParameters::dialogDone(WDialog::DialogCode code)
    10679{
    107     string* param = pspa_->getDataManager()->getGlobalParameters()->getParametersString();
    108     if ( param == NULL )
    109     {
    110         if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
    111             GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
    112             console->addConsoleMessage(" GWt_globalParameters : empty parameter set");
    113         }
    114     }
    115     int nbparam = atoi(param[0].c_str());
    116     if ( nbparam != 4 )
    117     {
    118         if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
    119             GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
    120             console->addConsoleMessage(" GWt_globalParameters : wrong number of parameters");
    121         }
    122     }
    123     frequencyEdit_->setText(param[1].c_str());
    124     stepEdit_->setText(param[2].c_str());
    125     nstepMAxEdit_->setText(param[3].c_str());
    126     nscEdit_->setText(param[4].c_str());
     80  if (code == WDialog::Accepted) updateGlobals();
     81  return;
    12782}
    12883
    12984void GWt_globalParameters::updateGlobals()
    13085{
    131     string envoi[5];
    132     envoi[0] = string("4");
    133     envoi[1] = frequencyEdit_->text().toUTF8();
    134     envoi[2] = stepEdit_->text().toUTF8();
    135     envoi[3] = nstepMAxEdit_->text().toUTF8();
    136     envoi[4] = nscEdit_->text().toUTF8();
    137     pspa_->getDataManager()->getGlobalParameters()->setParametersString(envoi);
     86  envoi_[0] = string("4");
     87  envoi_[1] = frequencyEdit_->text().toUTF8();
     88  envoi_[2] = stepEdit_->text().toUTF8();
     89  envoi_[3] = nstepMAxEdit_->text().toUTF8();
     90  envoi_[4] = nscEdit_->text().toUTF8();
     91
     92  setStatus();
     93  dt_->getGlobalParameters()->setParametersString(envoi_);
    13894}
    13995
    140 // void GWt_globalParameters::getExecute(unsigned index, unsigned& first, unsigned& last, int& programm)
    141 // {
    142 //   string debut;
    143 //   string fin;
    144 //   if ( index == 1)
    145 //     {
    146 //       debut = origineEdit1_->text().toUTF8();
    147 //       fin = extremiteEdit1_->text().toUTF8();
    148 //       programm = selectionBox1_->currentIndex();
    149 //       cout << " current index " << programm << endl;
    150 //     }
    151 //   else
    152 //     {
    153 //       debut = origineEdit2_->text().toUTF8();
    154 //       fin = extremiteEdit2_->text().toUTF8();
    155 //     }
    156 //   first = atoi ( debut.c_str() );
    157 //   last = atoi ( fin.c_str() );
    158 //   programm++;
     96void GWt_globalParameters::renew()
     97{
     98  string* param = dialogBegin();
    15999
    160 // }
     100  frequencyEdit_->setText(param[1].c_str());
     101  stepEdit_->setText(param[2].c_str());
     102  nstepMAxEdit_->setText(param[3].c_str());
     103  nscEdit_->setText(param[4].c_str());
     104}
    161105
    162 // void GWt_globalParameters::addElem()
    163 // {
    164 //     int dernier = pspa_->getDataManager()->beamLineSize();
    165 //     extremiteEdit1_->setText( mixedTools::intToString(dernier) );
    166 // }
     106string* GWt_globalParameters::getGlobalParameters()
     107{
     108  return envoi_;
     109}
    167110
    168 
     111void GWt_globalParameters::setStatus()
     112{
     113  WString out= WString("<p>frequency="+envoi_[1]+"</p>"
     114                       "<p>step in phase="+envoi_[2]+"</p>"
     115                       "<p>max step number="+envoi_[3]+"</p>"
     116                       "<p>periodicity of s.c. computation="+envoi_[4]+"</p>");
     117  status_->setText(out);
     118}
Note: See TracChangeset for help on using the changeset viewer.