Ignore:
Timestamp:
Nov 15, 2013, 3:30:50 PM (11 years ago)
Author:
touze
Message:

systeme periodique (mailles) + multipoles + madx

File:
1 edited

Legend:

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

    r427 r431  
    2121#include "GWt_pspaApplication.h"
    2222
     23#define BAVARD 0
     24
    2325GWt_softwarePanel::GWt_softwarePanel(dataManager* dataManager,PspaApplication* pspa)
    2426  : WContainerWidget()
     
    4951void GWt_softwarePanel::addSectionToExecuteW()
    5052{     
     53#if BAVARD > 0
     54  cout << "***********************************" << endl;
     55  cout << " GWt_softwarePanel::addSectionToExecuteW() " << endl<<endl;
     56#endif
     57
    5158  abstractElement* premierElement;
    5259  abstractElement* dernierElement;
     
    5562  int dernierIndex = 0;
    5663 
     64  cout << "sections_.size() = " << sections_.size() << endl;
     65
    5766  // if there is no section
    5867  if(sections_.size() == 0) {
     
    7685  dernierElement = pspa_->getBeamLine()->getAbstractElement(pspa_->getBeamLine()->getBeamLineSize()-1);
    7786  dernierIndex = pspa_->getBeamLine()->getBeamLineSize()-1;
    78   //  cout << "PspaApplication::addSectionToExecute() : " << premierText << " à  " << dernierText << endl;
    79  
    80   //  abstractSoftware* soft = NULL;
    81   //  dtmanage_->addSectionToExecute(premierElement,premierIndex, dernierElement, dernierIndex, soft);
    82   dtmanage_->addSectionToExecute(premierElement,premierIndex, dernierElement, dernierIndex, nomDeLogiciel());
     87 
     88  dtmanage_->addSectionToExecute(premierElement,premierIndex,dernierElement,dernierIndex,nomDeLogiciel());
    8389
    8490  std::string premierElementLabel = "";
     
    8793    premierElementLabel = premierElement->getLabel();
    8894  }
    89 
    9095  if (dernierElement) {
    9196    dernierElementLabel = dernierElement->getLabel();
     
    104109  fillComboWithSoftwares(softCombo);
    105110
    106   GWt_sectionToExecute* newSection = new GWt_sectionToExecute(lineFromCombo, lineToCombo, softCombo,createAddDeletePushButtons(sections_.size()),this);
     111  GWt_sectionToExecute* newSection = new GWt_sectionToExecute(lineFromCombo,lineToCombo,softCombo,createAddDeletePushButtons(sections_.size()),this);
    107112
    108113  stringstream st;
     
    118123}
    119124
     125void GWt_softwarePanel::updateSections()
     126{
     127#if BAVARD > 0
     128  cout << "***********************************" << endl;
     129  cout << " GWt_softwarePanel::updateSections() " << endl<<endl;
     130#endif
     131
     132  // update all sections in order to manage new/deleted items
     133  for (int a = 0; a < sections_.size(); a++) {
     134    fillComboWithElements(sections_[a]->getFirstElement());
     135    fillComboWithElements(sections_[a]->getLastElement());
     136    sections_[a]->getFirstElement()->setEnabled (true);
     137    sections_[a]->getLastElement()->setEnabled (true);
     138  }
     139 
     140  if (sections_.size() == 0) {
     141    return;
     142  }
     143 
     144  // the first element will always be the first element of the beamLine
     145  sections_[0]->getFirstElement()->setCurrentIndex(0);
     146  sections_[0]->getFirstElement()->setEnabled (false);
     147
     148  // the last element will always be the last element of the beamLine
     149  sections_[sections_.size()-1]->getLastElement()->setCurrentIndex(sections_[sections_.size()-1]->getLastElement()->count());
     150  sections_[sections_.size()-1]->getLastElement()->setEnabled(false);
     151
     152  // set default values
     153  updateSectionSelection();
     154}
     155
    120156bool GWt_softwarePanel::updateSectionSelection()
    121157{
     158#if BAVARD > 0
     159  cout << "***********************************" << endl;
     160  cout << " GWt_softwarePanel::updateSectionSelection() " << endl<<endl;
     161#endif
     162
    122163  if ( dtmanage_->getJobListSize() == 0 ) return false;
    123164 
     
    134175  // si la fin est mal definie on prend toute la config par defaut
    135176  if ( current <= 0 || current > dtmanage_->getBeamLineSize() )
    136   {
    137     current = dtmanage_->getBeamLineSize();
    138     currentString =  dtmanage_->getLabelFromElementNumero(current);
    139     if (sections_.size() > 0) {
    140       sections_[0]->setLastElementCurrentSelection(currentString);
    141 //...
     177    {
     178      current = dtmanage_->getBeamLineSize();
     179      currentString =  dtmanage_->getLabelFromElementNumero(current);
     180      if (sections_.size() > 0) {
     181        sections_[0]->setLastElementCurrentSelection(currentString);
     182        //...
     183      }
    142184    }
    143   }
    144185  current++;
    145186  currentString = dtmanage_->getLabelFromElementNumero(current);
     
    184225
    185226  if (!areDataCoherent()) {
     227#if BAVARD > 0
     228    cout << " GWt_softwarePanel::addSectionToExecuteW() DISABLE" << endl;
     229#endif
    186230    exec_go_->disable();
    187231  } else {
     232#if BAVARD > 0
     233    cout << " GWt_softwarePanel::addSectionToExecuteW() ENABLE" << endl;
     234#endif
    188235    exec_go_->enable();
    189236  }
     
    192239}
    193240
    194 
    195241bool GWt_softwarePanel::areDataCoherent()
    196242{
     243#if BAVARD > 0
     244  cout << "***********************************" << endl;
     245  cout << " GWt_softwarePanel::areDataCoherent() " << endl<<endl;
     246#endif
     247
    197248  bool caMarche = true;
    198249
     
    204255    pspa_->getBeamLine()->initializeSoftwares();
    205256  }
    206  
     257       
    207258  string diagnosticErrors;
    208259  string diagnosticWarnings;
    209  
    210   for (int a = 0; a< sections_.size(); a++)
     260  for (int a = 0; a < sections_.size(); a++)
    211261    {
    212       string debString = sections_[a]->getFirstElementCurrentText().toUTF8();
    213       string finString = sections_[a]->getLastElementCurrentText().toUTF8();
    214    
    215       // int debut = pspa_->getBeamLine()->getAbstractElementIndexFromLabel(debString)+1; // FIXME : Should NOT be +1
    216       // int fin = pspa_->getBeamLine()->getAbstractElementIndexFromLabel(finString)+1; // FIXME : Should NOT be +1
    217 
     262      string debString= sections_[a]->getFirstElementCurrentText().toUTF8();
     263      string finString= sections_[a]->getLastElementCurrentText().toUTF8();
    218264      int debut = pspa_->getBeamLine()->getAbstractElementNumeroFromLabel(debString);
    219265      int fin = pspa_->getBeamLine()->getAbstractElementNumeroFromLabel(finString);
    220    
    221       nomDeLogiciel prog = nomDeLogiciel ( sections_[a]->getSoftwareCurrentText().toUTF8());
    222       //      abstractSoftware* softToExec = dtmanage_->createSoftwareConnexion(prog);
    223       sectionToExecute* sectToExec = dtmanage_->addSectionToExecute(pspa_->getBeamLine()->getAbstractElement(debut),
    224                                      debut,
    225                                      pspa_->getBeamLine()->getAbstractElement(fin),
    226                                      fin,
    227                                      prog);
     266
     267      string currentSoft= sections_[a]->getSoftwareCurrentText().toUTF8();
     268      nomDeLogiciel prog = nomDeLogiciel(currentSoft);
     269      sectionToExecute* sectToExec = dtmanage_->addSectionToExecute(pspa_->getBeamLine()->getAbstractElement(debut),debut,pspa_->getBeamLine()->getAbstractElement(fin),fin,prog);
    228270
    229271      abstractSoftware* softToExec = sectToExec->getSoftware();
    230272      diagnosticErrors = "";
    231273      diagnosticWarnings = "";
    232 
    233       // check sections
    234       for (int i=debut-1; i<fin; i++) {
    235         if (pspa_->getBeamLine()) {
    236           if (pspa_->getBeamLine()->getAbstractElement(i)) {
    237             //         trivaluedBool tb = pspa_->getBeamLine()->getAbstractElement(i)->setSoftware(prog.getString());
    238 
    239 
    240             trivaluedBool tb = softToExec->doAcceptElement(pspa_->getBeamLine()->getAbstractElement(i)->getNomdElement().getElementType() );
    241 
    242             if (tb  == TBoolOk ) {
    243               pspa_->getBeamLine()->getAbstractElement(i)->setSoftware(softToExec);
     274      for(int i = debut-1; i < fin; i++) // check sections
     275        {
     276          if (!pspa_->getBeamLine()) continue;
     277          abstractElement* elPtr= pspa_->getBeamLine()->getAbstractElement(i);   
     278          if (!elPtr) continue;
     279
     280          trivaluedBool tb = softToExec->doAcceptElement(elPtr->getNomdElement().getElementType());
     281          if (tb  == TBoolOk ) {
     282            elPtr->setSoftware(softToExec);
     283          } else {
     284            elPtr->setSoftware(NULL);
     285            if (tb == TBoolIgnore) {
     286              if(prog.getString() != "unknownSoftware") diagnosticWarnings += elPtr->getLabel() + " will be ignored by  "+ prog.getString() + "<br /> ";           
    244287            } else {
    245               pspa_->getBeamLine()->getAbstractElement(i)->setSoftware( NULL );
    246 
    247               if ( tb == TBoolIgnore ) {
    248                 diagnosticWarnings += pspa_->getBeamLine()->getAbstractElement(i)->getLabel() + " will be ignored by  "+ prog.getString()+"<br /> ";           
    249               } else {
    250                 // j'insiste pour remettre le nom generique de l'element refuse (glm / 30/03/2013)
    251                 diagnosticErrors += pspa_->getBeamLine()->getAbstractElement(i)->getNomdElement().getExpandedName() + " is not allowed with "+ prog.getString()+"<br /> ";
    252                 caMarche = false;
    253               }
     288              // j'insiste pour remettre le nom generique de l'element refuse (glm / 30/03/2013)
     289              diagnosticErrors += elPtr->getNomdElement().getExpandedName() + " is not allowed with " + prog.getString() + "<br /> ";
     290              caMarche = false;
    254291            }
    255             pspa_->getBeamLine()->update(i);
    256292          }
    257         }
    258       }
     293          pspa_->getBeamLine()->update(i);
     294        } //i
     295     
    259296      // set errors and warnings
    260297      sections_[a]->setErrors(diagnosticErrors);
    261298      sections_[a]->setWarnings(diagnosticWarnings);
    262     }
     299    }//a
    263300   
    264301  return caMarche;
     
    286323}
    287324
    288 
    289 void GWt_softwarePanel::updateSections()
    290 {
    291   // update all sections in order to manage new/deleted items
    292   for (int a = 0; a< sections_.size(); a++) {
    293     fillComboWithElements(sections_[a]->getFirstElement());
    294     fillComboWithElements(sections_[a]->getLastElement());
    295 
    296     sections_[a]->getFirstElement()->setEnabled (true);
    297     sections_[a]->getLastElement()->setEnabled (true);
    298   }
    299   if (sections_.size() == 0) {
    300     return;
    301   }
    302   // the first element will always be the first element of the beamLine
    303   sections_[0]->getFirstElement()->setCurrentIndex(0);
    304   sections_[0]->getFirstElement()->setEnabled (false);
    305 
    306   // the last element will always be the last element of the beamLine
    307   sections_[sections_.size()-1]->getLastElement()->setCurrentIndex(sections_[sections_.size()-1]->getLastElement()->count());
    308   sections_[sections_.size()-1]->getLastElement()->setEnabled (false);
    309 
    310   // set default values
    311 
    312   // update
    313   updateSectionSelection();
    314 }
    315 
    316325void GWt_softwarePanel::executer()
    317326{
    318  
     327  cout << "***********************************" << endl;
     328  cout << " GWt_softwarePanel::executer() " << endl<<endl;
     329
    319330  if (!areDataCoherent()) {
    320331    return;
    321332  } 
    322333 
    323   static_cast<GWt_globalParameters*>(pspa_->getGlobalParam())->updateGlobals();
     334  //static_cast<GWt_globalParameters*>(pspa_->getGlobalParam())->updateGlobals();
    324335 
    325336  GWt_dialog calculDialog("Calcul en cours", "Veuillez patienter...", GWt_dialog::Wait, true,false);
     
    329340 
    330341  if (!dtmanage_->executeAll()) {
    331     GWt_dialog warningDialog("PSPA : Echec", " echec lors de l'exÈcution !", GWt_dialog::Error, true,true);
     342    GWt_dialog warningDialog("PSPA : Echec", " echec lors de l'exécution !", GWt_dialog::Error, true,true);
    332343    warningDialog.exec();
    333344  }
     
    338349}
    339350
    340 
    341 void GWt_softwarePanel::fillComboWithElements(Wt::WComboBox* cBox) {
     351void GWt_softwarePanel::fillComboWithElements(Wt::WComboBox* cBox)
     352{
    342353  if (cBox == NULL) return;
    343354
    344355  // get the last item selected
    345   WString selectedString = cBox->currentText ();
     356  WString selectedString = cBox->currentText();
    346357  cBox->clear();
    347358
    348   for (int a=0; a< pspa_->getBeamLine()->getBeamLineSize(); a++) {
     359  for(int a = 0; a < pspa_->getBeamLine()->getBeamLineSize(); a++) {
    349360    abstractElement* abs = pspa_->getBeamLine()->getAbstractElement(a);
    350     if (abs != NULL){
     361    if (abs != NULL) {
    351362      cBox->addItem(abs->getLabel());
    352363    }
    353364  }
    354365 
    355   for (int a=0; a<cBox->count(); a++) {
     366  for(int a = 0; a < cBox->count(); a++) {
    356367    if (cBox->itemText (a) == selectedString) {
    357368      cBox->setCurrentIndex(a);
     
    361372}
    362373
    363 
    364 void GWt_softwarePanel::fillComboWithSoftwares(Wt::WComboBox* cBox) {
     374void GWt_softwarePanel::fillComboWithSoftwares(Wt::WComboBox* cBox)
     375{
     376#if BAVARD > 0
     377  cout << "***********************************" << endl;
     378  cout << " GWt_softwarePanel::fillComboWithSoftwares " << endl<<endl;
     379#endif
     380
    365381  if (cBox == NULL) return;
    366382  cBox->clear();
     
    368384  unsigned nb = nomDeLogiciel::getNumberOfSoftwares();
    369385  unsigned k;
    370   for(k = 0; k < nb; k++) {
     386  for(k = 0; k <= nb; k++) { //xx
    371387    cBox->addItem(nomDeLogiciel(k).getString());
    372388  }
     389  cBox->setCurrentIndex(nb); // xx
    373390  cBox->refresh();
    374391}
    375392
    376 
    377 Wt::WContainerWidget* GWt_softwarePanel::createAddDeletePushButtons(int sectionNumber) {
    378 
     393Wt::WContainerWidget* GWt_softwarePanel::createAddDeletePushButtons(int sectionNumber)
     394{
    379395  WContainerWidget* buttonContainer= new WContainerWidget();
    380396 
     
    399415  buttonContainerLayout->addWidget(exec_add);
    400416  buttonContainerLayout->addWidget(exec_delete);
    401 
    402417  buttonContainer->setLayout(buttonContainerLayout);
    403418
Note: See TracChangeset for help on using the changeset viewer.