Changeset 436 in PSPA


Ignore:
Timestamp:
Nov 26, 2013, 5:36:11 PM (10 years ago)
Author:
touze
Message:

ajout de secteurs

Location:
Interface_Web/trunk/pspaWT
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • Interface_Web/trunk/pspaWT/sources/controler/include/sectorParameters.h

    r431 r436  
    55#include <iostream>
    66#include "UAP/UAPNode.hpp"
     7
    78using namespace std;
     9
     10typedef pair<string, vector<string> > statements;
    811
    912class sectorParameters 
    1013{
    1114  string geometry_;
    12   int nCells_;
    13   double lCell_;
    14   double pc_;
    15 
    16   int nbParam_;
    17   string* parametersString_;
     15  vector<statements> sectors_;
    1816
    1917 public :
    2018 
    2119  sectorParameters();
    22   ~sectorParameters() {
    23     if(parametersString_ != NULL) delete [] parametersString_;
    24   }
     20  ~sectorParameters() {;}
    2521 
    26   string* getParametersString() const;
    27   void setParametersString(string*);
    2822  void raz();
    2923  string FileOutputFlow() const;
     
    3125  void InputRep(UAPNode* root);
    3226
    33   int getNumberOfCells() const;
    34   double getCellLength() const;
    35   double getParticleMomentum() const;
     27  void setSectors(const vector<statements>&);
     28  vector<statements> getSectors() const;
    3629};
    3730#endif
  • Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc

    r431 r436  
    7373sectionToExecute* dataManager::addSectionToExecute(abstractElement* debut,int debutIndex, abstractElement* fin, int finIndex, nomDeLogiciel logiciel)
    7474{
    75   #if BAVARD > 0
     75#if BAVARD > 0
    7676  cout << "***********************************" << endl;
    7777  cout << " dataManager::addSectionToExecute " << endl << endl;
     
    160160bool dataManager::executeAll()
    161161{
     162#if BAVARD > 0
    162163  cout << "***********************************" << endl;
    163164  cout << " dataManager::executeAll() " << endl << endl;
     165#endif
    164166
    165167  bool success = true;
     
    181183  unsigned fin;
    182184  for(unsigned k = 0; k < jobList_.size(); k++) {
    183  
     185
     186#if BAVARD > 0 
    184187    cout << " dataManager::executeAll je m'apprete a executer : " << (jobList_[k]->getSoftware()->getName()) << endl;
     188#endif
    185189   
    186190    debut = jobList_[k]->getElementNumberInSection();
     
    215219    if ( debut < firstComputedElemNumero_ ) firstComputedElemNumero_ = debut;
    216220    if ( fin > lastComputedElemNumero_ ) lastComputedElemNumero_ = fin;
    217    
    218     //debug
     221
     222#if BAVARD > 0   
    219223    cout << "dataManager::executeAll #diagnosticBeam= " << diagnosticBeam_.size() << endl;
    220224    cout << "dataManager::executeAll #getBeamLineSize()= " << getBeamLineSize() << endl;
     
    223227      cout << "[" << j << "] " << elPtr->getNomdElement().getExpandedName() << endl;
    224228    }
     229#endif
     230
    225231  } //k
    226232 
    227   cout << " dataManager::executeAll premier element : " << firstComputedElemNumero_ << " dernier : " << lastComputedElemNumero_ << endl;
     233  cout << " dataManager::executeAll() : premier element = " << firstComputedElemNumero_ << " dernier = " << lastComputedElemNumero_ << endl;
     234
    228235  return success;
    229236}
     
    232239{
    233240  ofstream outfile;
    234   //    string name = pspa_->getWorkingDir()+ folder + "/" + nameOfFile + ".save";
     241  //string name = pspa_->getWorkingDir()+ folder + "/" + nameOfFile + ".save";
    235242  cout << " dataManager::saveConfiguration : suppression du folder dans le nom de " << endl;
    236243  cout << " sauvegarde, en attendant que ce soit autre chose que le sessionId" << endl;
     
    248255  outfile << globParam_.FileOutputFlow();
    249256  outfile << sectorParam_.FileOutputFlow();
     257
    250258  abstractElement* elPtr;
    251259  for(int k = 0; k < getBeamLineSize() ; k++)
     
    268276  lab->addAttribute("name","PSPA lab");
    269277 
    270   // general global parameters
     278  // general global parameters--docroot . --http-address 0.0.0.0 --http-port 8077
    271279  globParam_.InputRep(lab);
    272280 
     
    275283  //acc->addAttribute("name",fileName);
    276284
    277   sectorParam_.InputRep(lab);
     285  //sectorParam_.InputRep(lab);
    278286
    279287  // sequence of elements
     
    307315  else cout << " successful opening input stream : " << name << endl;
    308316 
    309   string globalTitle;
    310   if ( infile >> globalTitle ) {
    311     if ( globalTitle == string("globals") ) {
    312       globParam_.raz();
    313       globParam_.FileInput(infile);
    314     } else {
    315       //cout << " INFO::dataManager::restoreElements : global parameters seems to be missing" << endl;
    316       //return false;
    317     }
    318   } else {
    319     cerr << " ERROR::dataManager::restoreElements : reading globalParameters in save file" << endl;
    320     return false;
    321   }
    322 
    323   //NOTE:: je ne sais pas si les parametres "secteur" seront conservés, aussi pour ne pas trop changer les fichiers je lis les données aprÚs "globals" dans la boucle
     317  //NOTE:: je ne sais pas si les "secteurs" seront conservés, aussi pour ne pas trop changer les fichiers je lis les données aprÚs "globals" dans la boucle
    324318 
    325319  pspa_->getBeamLine()->clear();
     
    327321  string elementLabel;
    328322  while (infile >> elementLabel) {
    329 
    330     if (elementLabel == string("lattice") ) {
     323    if (elementLabel == string("globals") ) {
     324      globParam_.raz();
     325      globParam_.FileInput(infile);
     326    } else if (elementLabel == string("sectors") ) {
    331327      sectorParam_.raz();
    332328      sectorParam_.FileInput(infile);
     
    343339  }// while
    344340 
    345  #if BAVARD > 1
     341#if BAVARD > 1
    346342  unsigned k;
    347343  for(k = 0; k < getBeamLineSize(); k++) {
  • Interface_Web/trunk/pspaWT/sources/controler/src/globalParameters.cc

    r424 r436  
    4545{
    4646  ostringstream sortie;
    47   sortie<<" globals "<<endl;
    48   sortie<<frequency_<<" "<<integrationStep_<<" "<<nstepsMax_<<" "<<nsc_<<endl;
     47  sortie << " globals " << endl;
     48  sortie << frequency_ << " " << integrationStep_ << " " << nstepsMax_ << " " << nsc_ << endl;
    4949  return sortie.str(); 
    5050}
  • Interface_Web/trunk/pspaWT/sources/controler/src/sectorParameters.cc

    r431 r436  
    1 
    2 //#include <cstdlib>
    31
    42#include "sectorParameters.h"
    53#include "mixedTools.h"
    64
    7 sectorParameters::sectorParameters() : parametersString_(NULL)
     5#define BAVARD 1
     6
     7sectorParameters::sectorParameters()
    88{
    99  geometry_= string("CIRCULAR");
    10   nCells_ = 0;
    11   lCell_ = 0.0;
    12   pc_ = 0.0;
    13   nbParam_ = 4;
    14   parametersString_ = new string[nbParam_+1];
     10  sectors_.push_back(statements("vide",vector<string>()));
     11  sectors_.back().second.push_back("xxx");
     12  sectors_.back().second.push_back("xxx");
     13  sectors_.back().second.push_back("Unchecked");
     14  sectors_.back().second.push_back("1");
    1515}
    1616
    17 string* sectorParameters::getParametersString() const
    18 {
    19   parametersString_[0] = mixedTools::intToString(nbParam_);
    20   parametersString_[1] = geometry_;
    21   parametersString_[2] = mixedTools::intToString(nCells_);
    22   parametersString_[3] = mixedTools::doubleToString(lCell_);
    23   parametersString_[4] = mixedTools::doubleToString(pc_);
    24   return parametersString_;
    25 }
     17// sectorParameters::sectorParameters() : parametersString_(NULL)
     18// {
     19//   geometry_= string("CIRCULAR");
     20//   nCells_ = 0;
     21//   lCell_ = 0.0;
     22//   pc_ = 0.0;
     23//   nbParam_ = 4;
     24//   parametersString_ = new string[nbParam_+1];
     25// }
    2626
    27 void sectorParameters::setParametersString(string* param)
    28 {
    29   geometry_ = param[1].c_str();
    30   nCells_ = atoi(param[2].c_str());
    31   lCell_ = atof(param[3].c_str());
    32   pc_ = atof(param[4].c_str());
    33 }
     27// string* sectorParameters::getParametersString() const
     28// {
     29//   parametersString_[0] = mixedTools::intToString(nbParam_);
     30//   parametersString_[1] = geometry_;
     31//   parametersString_[2] = mixedTools::intToString(nCells_);
     32//   parametersString_[3] = mixedTools::doubleToString(lCell_);
     33//   parametersString_[4] = mixedTools::doubleToString(pc_);
     34//   return parametersString_;
     35// }
     36
     37// void sectorParameters::setParametersString(string* param)
     38// {
     39//   geometry_ = param[1].c_str();
     40//   nCells_ = atoi(param[2].c_str());
     41//   lCell_ = atof(param[3].c_str());
     42//   pc_ = atof(param[4].c_str());
     43// }
    3444
    3545void sectorParameters::raz()
    3646{
    37   geometry_= string("CIRCULAR");
    38   nCells_ = 0;
    39   lCell_ = 0.0;
    40   pc_ = 0.0;
     47  if(!sectors_.empty()) sectors_.clear();
    4148}
    4249
     
    4451{
    4552  ostringstream sortie;
    46   sortie<<" lattice "<<endl;
    47   sortie<<geometry_<<" "<<nCells_<<" "<<lCell_<<" "<<pc_<<endl;
     53  sortie << " sectors " << endl;
     54  sortie << sectors_.size() << endl;
     55  for(int i = 0; i < sectors_.size(); i++) {
     56    sortie << sectors_.at(i).first << " " << sectors_.at(i).second.at(0) << " " << sectors_.at(i).second.at(1) << " " << sectors_.at(i).second.at(2) << " " << sectors_.at(i).second.at(3) << endl;
     57  }
    4858  return sortie.str(); 
    4959}
     
    5161void sectorParameters::FileInput(ifstream& ifs)
    5262{
    53   ifs >> geometry_ >> nCells_ >> lCell_ >> pc_;
     63  int n;
     64  ifs >> n;
     65  string txt = "";
     66  for(int i = 0; i < n; i++) {
     67    ifs >> txt;
     68    sectors_.push_back(statements(txt,vector<string>()));
     69    for(int j = 0; j < 4; j++) {
     70      ifs >> txt;
     71      sectors_.back().second.push_back(txt);
     72    }
     73  }
    5474}
    5575
    5676void sectorParameters::InputRep(UAPNode* root)
    5777{
    58   UAPNode* node = root->addChild("lattice");
    59   node->addAttribute("name","global_lattice");
    60   node->addChild("geometry")->addAttribute("type",geometry_);
    61   string txt = "";
    62   txt = mixedTools::doubleToString(pc_);
    63   node->addChild("pc")->addAttribute("design",txt);
     78  // UAPNode* node = root->addChild("lattice");
     79  // node->addAttribute("name","global_lattice");
     80  // node->addChild("geometry")->addAttribute("type",geometry_);
     81  // string txt = "";
     82  // txt = mixedTools::doubleToString(pc_);
     83  // node->addChild("pc")->addAttribute("design",txt);
    6484
    65   node = root->addChild("sector");
    66   node->addAttribute("name","sect");
    67   txt = mixedTools::doubleToString(lCell_);
    68   node->addAttribute("length",txt);
    69   txt = mixedTools::intToString(nCells_);
    70   node->addAttribute("repeat",txt);
     85  // node = root->addChild("sector");
     86  // node->addAttribute("name","sect");
     87  // txt = mixedTools::doubleToString(lCell_);
     88  // node->addAttribute("length",txt);
     89  // txt = mixedTools::intToString(nCells_);
     90  // node->addAttribute("repeat",txt);
    7191}
    7292
    73 int sectorParameters::getNumberOfCells() const {
    74   return nCells_;
     93// int sectorParameters::getNumberOfCells() const {
     94//   return nCells_;
     95// }
     96
     97// double sectorParameters::getCellLength() const {
     98//   return lCell_;
     99// }
     100
     101// double sectorParameters::getParticleMomentum() const {
     102//   return pc_;
     103// }
     104
     105vector<statements> sectorParameters::getSectors() const {
     106  return sectors_;
    75107}
    76108
    77 double sectorParameters::getCellLength() const {
    78   return lCell_;
     109void sectorParameters::setSectors(const vector<statements>& v)
     110{
     111#if BAVARD > 0
     112  cout << "***********************************" << endl;
     113  cout << " sectorParameters::setSectors() " << endl << endl;
     114#endif
     115
     116  if(!sectors_.empty()) sectors_.clear();
     117
     118  for(int i = 0; i < v.size(); i++) {
     119    sectors_.push_back(statements(v.at(i).first,vector<string>()));
     120    for(int j = 0; j < 4; j++)
     121      sectors_.back().second.push_back(v.at(i).second.at(j));
     122  }
     123
     124#if BAVARD > 0
     125  cout << "sectors_.size()= " << sectors_.size() << endl;
     126  for(int i = 0; i < sectors_.size(); i++) {
     127    cout << "name= " << sectors_.at(i).first << ", de " << sectors_.at(i).second.at(0) << ", à " << sectors_.at(i).second.at(1) << ", reflection = " << sectors_.at(i).second.at(2) << ", repeat= " << sectors_.at(i).second.at(3) << endl << endl;
     128  }
     129#endif
    79130}
    80 
    81 double sectorParameters::getParticleMomentum() const {
    82   return pc_;
    83 }
    84 
    85 
  • Interface_Web/trunk/pspaWT/sources/controler/src/softwareMadx.cc

    r431 r436  
    3232    return false;
    3333  }
    34  
    35   outfile << endl; // saut de ligne
    36   ostringstream os;
    37   os << "L: " << "line=(";
     34
     35  cout << " softwareMadx::createInputFile(...) lecture des elts de " << numeroDeb_ << " à " << numeroFin_ << endl;
     36 
     37  // element label //////////////////////////
     38
     39  outfile << endl; // saut de ligne
    3840
    3941  abstractElement* elPtr;
     
    4143    {
    4244      elPtr = dataManager_->getElementPointerFromNumero(k);
    43       cout << "debug:: element [" << k << "] " << elPtr->getNomdElement().getExpandedName() << endl;
     45      //cout << " debug:: element [" << k << "] " << elPtr->getNomdElement().getExpandedName() << endl;
    4446      vector<statements> v= elPtr->parametersToSoftware();
    45       string label= v.at(0).second.at(1);
    46       outfile << inputFormat(v); //<< endl;
    47       os << label <<",";
    48     }//k;
    49 
    50   os << ");" << endl;
    51   int nCells= sectParamPtr_->getNumberOfCells();
    52   os << "all: line=(" << nCells << "*L);" << endl;
    53   outfile << endl; // saut de ligne
    54   outfile << os.str() << endl; // beam line definition p34
     47      outfile << inputFormat(v);
     48    }
     49
     50  // sublines ///////////////////////////////
     51
     52  outfile << endl; // saut de ligne
     53
     54  vector<statements> u = sectParamPtr_->getSectors();
     55  for(unsigned int i = 0; i < u.size(); i++) {
     56    ostringstream os;
     57    os << u.at(i).first << ": line=(";
     58    unsigned ai = dataManager_->getNumeroFromElementLabel(u.at(i).second.at(0));
     59    unsigned bi = dataManager_->getNumeroFromElementLabel(u.at(i).second.at(1));
     60
     61    for(unsigned k = numeroDeb_; k <= numeroFin_; k++) {
     62      elPtr = dataManager_->getElementPointerFromNumero(k);
     63     
     64      if(k >= ai && k <= bi) {
     65        if(k == bi)
     66          os << elPtr->getLabel() <<");";
     67        else
     68          os << elPtr->getLabel() <<",";
     69      }
     70    }// k
     71
     72    outfile << os.str() << endl;
     73  }// i
     74
     75  // relection and repetition ///////////////
     76
     77  outfile << endl; // saut de ligne
     78
     79  string *str= NULL;
     80  if(u.size() > 0) {
     81    str = new string[u.size()];
     82    for(unsigned int i = 0; i < u.size(); i++) str[i]= "false";
     83  }
     84
     85  ostringstream os;
     86  os << "all: " << "line=(";
     87  for(unsigned k = numeroDeb_; k <= numeroFin_; k++) {
     88    elPtr = dataManager_->getElementPointerFromNumero(k);
     89    bool isMember = false;
     90
     91    for(unsigned int i = 0; i < u.size(); i++) {
     92      unsigned ai = dataManager_->getNumeroFromElementLabel(u.at(i).second.at(0));
     93      unsigned bi = dataManager_->getNumeroFromElementLabel(u.at(i).second.at(1));
     94      if(k >= ai && k <= bi) {
     95        isMember = true;
     96
     97        if(str[i] == "false") {
     98          //int reflection = atoi(u.at(i).second.at(2).c_str());
     99          int reflection = ( (u.at(i).second.at(2) == "Unchecked") ? 0:1 );
     100          int repeat = atoi(u.at(i).second.at(3).c_str());
     101          if(reflection > 0)
     102            os << "-" << repeat << "*" << u.at(i).first;
     103          else
     104            os << repeat << "*" << u.at(i).first;
     105
     106          if(i < u.size()-1) os << ", ";
     107        }
     108
     109        str[i] = "true";
     110        break;
     111      }
     112    }// i
     113   
     114    if(isMember && k == numeroFin_) os << ");";
     115   
     116    if(!isMember) {
     117      if(k == numeroFin_) os << elPtr->getLabel() << ");";
     118      else os << elPtr->getLabel() << ",";
     119    }
     120  }// k
     121
     122  outfile << os.str() << endl;
     123  ///////////////////////////////////////////
     124     
     125  outfile << endl; // saut de ligne
    55126
    56127  outfile << "beam;" << endl; // beam data p46
     
    58129 
    59130  outfile << "select,flag = twiss,column = name,s,betx,bety;" << endl; //p48
    60   outfile << "twiss,save,centre,file = twiss.out;" << endl; //p51
     131  outfile << "twiss,save,centre,file = "+workingDir+"twiss.out;" << endl; //p51
    61132  outfile << "stop;" << endl;
    62133
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_sectorParameters.h

    r431 r436  
    77#include <Wt/WDialog>
    88#include <Wt/WText>
     9#include <Wt/WGroupBox>
     10#include <Wt/WCheckBox>
    911
    1012using namespace Wt;
     
    1315class dataManager;
    1416
     17typedef pair<string, vector<string> > statements;
     18
    1519class GWt_sectorParameters : public WContainerWidget
    1620{
    17   WLineEdit* geometry_;
    18   WLineEdit* nCells_;
    19   WLineEdit* lCell_;
    20   WLineEdit* pc_;
     21  dataManager* dt_;
     22  vector<statements> sectors_;
     23 
     24  vector <WWidget*> cnt_;
     25  WLineEdit* sLabel_;
     26  WLineEdit* firstElement_;
     27  WLineEdit* lastElement_;
     28  WLineEdit* repeat_;
     29  WCheckBox* reflection_;
    2130
    22   dataManager* dt_;
    2331  WText *status_;
    24   WDialog *dialog_;
    25   string envoi_[5];
    26 
    27   string* getSectorParameters();
    28   void setStatus();
     32  WDialog *dialog_;
     33  WGroupBox *gb_;
     34 
     35  void createSector();
     36  WContainerWidget* buttons(int);
     37  void dialogDone(WDialog::DialogCode code);
     38  void add();
     39  void cancel(int);
     40  void setStatus(const WString&);
     41  void setAttributes();
    2942
    3043 public :
     
    3548
    3649  void execDialog();
    37   void dialogDone(WDialog::DialogCode code);
    38   void update();
    39   void renew();
    4050  void setText(WText*);
    4151};
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_globalParameters.cc

    r431 r436  
    9696{
    9797  string* param = dialogBegin();
    98   setStatus();
     98  //setStatus();
    9999  frequencyEdit_ = new WLineEdit(param[1].c_str());
    100100  stepEdit_ = new WLineEdit(param[2].c_str());
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc

    r435 r436  
    2727#include <Wt/WMessageBox>
    2828
    29 //#define HAS_IMAGEMAGIC 1
     29#define HAS_IMAGEMAGIC 1
    3030
    3131using namespace Wt::Chart;
     
    173173  button = new WPushButton("globalParameters",buttons);
    174174  button->clicked().connect(this, &PspaApplication::messageBox1);
    175   button = new WPushButton("sectorParameters", buttons);
     175  button = new WPushButton("sectors", buttons);
    176176  button->clicked().connect(this, &PspaApplication::messageBox2);
    177177 
     
    430430 
    431431  globalParam_->renew();
    432   sectorParam_->renew();
     432  //sectorParam_->renew();
    433433  console_->addConsoleMessage(string("restauration terminee \n"));
    434434}
     
    476476     
    477477    globalParam_->renew();
    478     sectorParam_->renew();
     478    //sectorParam_->renew();
    479479    console_->addConsoleMessage(string("rechargement de la config termine"));
    480480    message->show();
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_sectorParameters.cc

    r431 r436  
    33#include <Wt/WPushButton>
    44
     5#include <Wt/WGridLayout>
     6#include <Wt/WVBoxLayout>
     7#include <Wt/WHBoxLayout>
     8
     9#include <Wt/WCssDecorationStyle>
     10
    511#include "GWt_sectorParameters.h"
    612#include "dataManager.h"
     13#include "mixedTools.h"
     14
     15#define BAVARD 0
    716
    817GWt_sectorParameters::GWt_sectorParameters(dataManager* dt)
     
    1625}
    1726
    18 string* GWt_sectorParameters::getSectorParameters()
    19 {
    20   string* param = dt_->getSectorParameters()->getParametersString();
    21   envoi_[0] = param[0].c_str();
    22   envoi_[1] = param[1].c_str();
    23   envoi_[2] = param[2].c_str();
    24   envoi_[3] = param[3].c_str();
    25   envoi_[4] = param[4].c_str();
    26   return param;
    27 }
    28 
    2927void GWt_sectorParameters::execDialog()
    3028{
    31   dialog_ = new WDialog("sector parameters");
    32   string* param = getSectorParameters();
    33 
    34   new WText("geometry : ",dialog_->contents());
    35   geometry_ = new WLineEdit(param[1].c_str(),dialog_->contents());
    36   geometry_->disable();
    37   new WBreak(dialog_->contents());
    38   new WText("Enter number of cells : ",dialog_->contents());
    39   nCells_ = new WLineEdit(param[2].c_str(),dialog_->contents());
    40   new WBreak(dialog_->contents());
    41   new WText("Enter cell length (m): ",dialog_->contents());
    42   lCell_ = new WLineEdit(param[3].c_str(),dialog_->contents());
    43   new WBreak(dialog_->contents());
    44   new WText("Enter particle momentum (GeV/c) : ",dialog_->contents());
    45   pc_ = new WLineEdit(param[4].c_str(),dialog_->contents());
    46   new WBreak(dialog_->contents());
    47 
    48   WPushButton *ok =  new WPushButton("Ok", dialog_->contents());
     29#if BAVARD > 0
     30  cout << "***********************************" << endl;
     31  cout << " GWt_sectorParameters::execDialog() " << endl << endl;
     32#endif
     33
     34  dialog_ = new WDialog("sectors into beam line");
     35  dialog_->contents()->setMinimumSize(800,WLength::Auto);
     36
     37  dialog_->contents()->addWidget(new WText("geometry : "));
     38  dialog_->contents()->addWidget(new WLineEdit("CIRCULAR"));
     39  dialog_->contents()->addWidget(new WBreak());
     40  dialog_->contents()->addWidget(new WBreak());
     41
     42  gb_ = new WGroupBox("sectors",dialog_->contents());
     43  createSector();
     44
     45  dialog_->contents()->addWidget(new WBreak());
     46
     47  WContainerWidget *wb = new WContainerWidget();
     48  wb->setStyleClass("buttons");
     49  WPushButton *ok = new WPushButton("Ok",wb);
     50  ok->decorationStyle().setBackgroundColor(WColor("#87CEFA"));
    4951  ok->clicked().connect(dialog_, &WDialog::accept);
    50   WPushButton *no = new WPushButton("Cancel", dialog_->contents());
     52  WPushButton *no = new WPushButton("Cancel",wb);
    5153  no->clicked().connect(dialog_, &WDialog::reject);
     54  dialog_->contents()->addWidget(wb);
    5255
    5356  dialog_->finished().connect(this,&GWt_sectorParameters::dialogDone);
     
    5558}
    5659
     60void GWt_sectorParameters::createSector()
     61{
     62#if BAVARD > 0
     63  cout << "***********************************" << endl;
     64  cout << " GWt_sectorParameters::createSector() " << endl << endl;
     65#endif
     66
     67  WHBoxLayout* hbox= new WHBoxLayout();
     68  hbox->setContentsMargins(0,0,0,0);
     69
     70  vector<statements> v = dt_->getSectorParameters()->getSectors();
     71
     72  hbox->addWidget(new WText("name&nbsp;:&nbsp;"));
     73  sLabel_= new WLineEdit(v.at(0).first);
     74  hbox->addWidget(sLabel_);
     75  hbox->addWidget(new WText("from&nbsp;:&nbsp;"));
     76  firstElement_ = new WLineEdit(v.at(0).second.at(0));
     77  hbox->addWidget(firstElement_);
     78  hbox->addWidget(new WText("to&nbsp;:&nbsp;"));
     79  lastElement_ = new WLineEdit(v.at(0).second.at(1));
     80  hbox->addWidget(lastElement_);
     81  hbox->addWidget(new WText("reflection&nbsp;:&nbsp;"));
     82  reflection_ = new WCheckBox();
     83  reflection_->setChecked(false); // default: Unchecked
     84  if(v.at(0).second.at(2) == "Checked") reflection_->setChecked(true);
     85  hbox->addWidget(reflection_);
     86  hbox->addWidget(new WText("repeat&nbsp;:&nbsp;"));
     87  repeat_ = new WLineEdit(v.at(0).second.at(3));
     88  repeat_->setTextSize(2);
     89  hbox->addWidget(repeat_);
     90
     91  WContainerWidget* bs= buttons(cnt_.size());
     92  hbox->addWidget(bs);
     93
     94  WContainerWidget *w1 = new WContainerWidget();
     95  w1->setLayout(hbox);
     96
     97  WVBoxLayout* vbox= new WVBoxLayout();
     98  vbox->setContentsMargins(0,0,0,0);
     99  vbox->addWidget(w1);
     100  vbox->addStretch(10);
     101
     102  WContainerWidget *w2 = new WContainerWidget();
     103  w2->setLayout(vbox);
     104
     105  WGridLayout *grid = new WGridLayout();
     106  grid->setContentsMargins(0,0,0,0);
     107  grid->addWidget(w2,0,0);
     108  grid->setColumnStretch(0,1);
     109
     110  WContainerWidget *w3 = new WContainerWidget();
     111  std::stringstream st;
     112  st << cnt_.size();
     113  w3->setObjectName(st.str());
     114  cnt_.push_back(w3);
     115 
     116  w3->setLayout(grid);
     117  gb_->addWidget(w3);
     118}
     119
     120WContainerWidget* GWt_sectorParameters::buttons(int num)
     121{
     122#if BAVARD > 0
     123  cout << "***********************************" << endl;
     124  cout << " GWt_sectorParameters::buttons()" << endl << endl;
     125#endif
     126
     127  WHBoxLayout* hbox = new WHBoxLayout();
     128  hbox->setContentsMargins(0,0,0,0);
     129 
     130  WPushButton* add = new WPushButton("+");
     131  add->clicked().connect(this,&GWt_sectorParameters::add);
     132  add->setStyleClass("roundButton");
     133  add->setMaximumSize(20,20);
     134  add->setToolTip("Add new section");
     135  hbox->addWidget(add);
     136
     137  WPushButton* cancel = new WPushButton("-");
     138  cancel->clicked().connect(boost::bind(&GWt_sectorParameters::cancel,this,num));
     139  cancel->setStyleClass("roundButton");
     140  cancel->setMaximumSize(20,20);
     141  cancel->setToolTip("Remove this section");
     142  hbox->addWidget(cancel);
     143
     144  WContainerWidget* wb= new WContainerWidget();
     145  wb->setLayout(hbox);
     146  return wb;
     147}
     148
    57149void GWt_sectorParameters::dialogDone(WDialog::DialogCode code)
    58150{
     151#if BAVARD > 0
     152  cout << "***********************************" << endl;
     153  cout << " GWt_sectorParameters::dialogDone() " << endl << endl;
     154#endif
     155
    59156  if (code == WDialog::Accepted) {
    60     update();
    61     setStatus();
     157    setStatus("OK...");
     158    setAttributes();
     159    dt_->getSectorParameters()->setSectors(sectors_);
     160  } else {
     161    setStatus("Cancelled!");
     162    //cnt_.clear();
    62163  }
    63   return;
    64 }
    65 
    66 void GWt_sectorParameters::update()
    67 {
    68   envoi_[0] = string("4");
    69   envoi_[1] = geometry_->text().toUTF8();
    70   envoi_[2] = nCells_->text().toUTF8();
    71   envoi_[3] = lCell_->text().toUTF8();
    72   envoi_[4] = pc_->text().toUTF8();
    73   dt_->getSectorParameters()->setParametersString(envoi_);
    74 }
    75 
    76 void GWt_sectorParameters::renew()
    77 {
    78   string* param = getSectorParameters();
    79   setStatus();
    80   geometry_ = new WLineEdit(param[1].c_str());
    81   nCells_ = new WLineEdit(param[2].c_str());
    82   lCell_ = new WLineEdit(param[3].c_str());
    83   pc_ = new WLineEdit(param[4].c_str());
    84 }
    85 
    86 void GWt_sectorParameters::setStatus()
    87 {
    88   WString out= WString("<p>geometry = "+envoi_[1]+"</p>"
    89                        "<p>number of cells = "+envoi_[2]+"</p>"
    90                        "<p>cell length = "+envoi_[3]+"</p>"
    91                        "<p>particle momentum = "+envoi_[4]+"</p>");
    92   status_->setText(out);
    93 }
     164
     165#if BAVARD > 0
     166  cout << "dialogDone():: sectors_.size()= " << sectors_.size() << endl;
     167  for(int i = 0; i < sectors_.size(); i++) {
     168    cout << "name= " << sectors_.at(i).first << ", de " << sectors_.at(i).second.at(0) << ", à " << sectors_.at(i).second.at(1) << ", reflection = " << sectors_.at(i).second.at(2) << ", repeat= " << sectors_.at(i).second.at(3) << endl << endl;
     169  }
     170#endif
     171
     172  cnt_.clear();
     173}
     174
     175void GWt_sectorParameters::add()
     176{
     177#if BAVARD > 0
     178  cout << "***********************************" << endl;
     179  cout << " GWt_sectorParameters::add() " << endl << endl;
     180#endif
     181
     182  setStatus("add sector");
     183  setAttributes();
     184  createSector();
     185}
     186
     187void GWt_sectorParameters::cancel(int num)
     188{
     189#if BAVARD > 0
     190  cout << "***********************************" << endl;
     191  cout << " GWt_sectorParameters::cancel() " << endl << endl;
     192#endif
     193
     194  setStatus("delete sector");
     195  std::stringstream st;
     196  st << num;
     197  std::string ref = st.str();
     198 
     199  for(unsigned int k = 0; k < cnt_.size(); k++) {
     200    cout << "sectors[" << k << "]= " << cnt_[k]->objectName();
     201    if(cnt_[k]->objectName() == st.str()) {
     202      cout << " : cancelled" << endl;
     203      gb_->removeWidget(cnt_[k]);
     204      delete cnt_[k];
     205      cnt_.erase(cnt_.begin()+k);
     206    } else {
     207      cout << " : kept" << endl;
     208    }
     209  }
     210}
     211
     212void GWt_sectorParameters::setAttributes()
     213{
     214#if BAVARD > 0
     215  cout << "***********************************" << endl;
     216  cout << " GWt_sectorParameters::setAttributes() " << endl << endl;
     217#endif
     218
     219  string txt = "";
     220  txt = sLabel_->text().toUTF8(); 
     221  sectors_.push_back(statements(txt,vector<string>()));
     222  txt = firstElement_->text().toUTF8();
     223  sectors_.back().second.push_back(txt);
     224  txt = lastElement_->text().toUTF8();
     225  sectors_.back().second.push_back(txt);
     226  // checkState() retourne : Unchecked = 0,
     227  //                         PartiallyChecked = 1,
     228  //                         Checked = 2
     229  txt = "Unchecked";
     230  if(reflection_->checkState() > 0) txt = "Checked";
     231  sectors_.back().second.push_back(txt);
     232  txt = repeat_->text().toUTF8();
     233  sectors_.back().second.push_back(txt);
     234}
     235
     236void GWt_sectorParameters::setStatus(const WString& str)
     237{
     238  status_->setText(str);
     239}
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_softwarePanel.cc

    r431 r436  
    304304void GWt_softwarePanel::deleteSectionToExecuteW(int sectionLabel)
    305305{
     306#if BAVARD > 0
     307  cout << "***********************************" << endl;
     308  cout << " GWt_softwarePanel::deleteSectionToExecuteW()" << endl<<endl;
     309#endif
     310
    306311  stringstream st;
    307312  st << sectionLabel;
  • Interface_Web/trunk/pspaWT/workingArea/pspa.save

    r435 r436  
    11 globals
    222998.65 1 100000 10
    3  lattice
    4 CIRCULAR 0 0 0
    53rfgun
    64rfgun01
Note: See TracChangeset for help on using the changeset viewer.