Changeset 388 in PSPA


Ignore:
Timestamp:
Mar 13, 2013, 11:23:31 AM (11 years ago)
Author:
garnier
Message:

Etape 2 : Remplacement de la structure selectedSections par un vecteur de GWt_sectionToExecute

Location:
Interface_Web/branches/12_03_12-managerComboBox/pspaWT/sources
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • Interface_Web/branches/12_03_12-managerComboBox/pspaWT/sources/controler/include/dataManager.h

    r385 r388  
    6666    abstractSoftware* createSoftwareConnexion(nomDeLogiciel logi);
    6767   
     68    /** return the jobList size
     69     */
     70    inline int getJobListSize() {
     71        return jobList_.size();
     72    }
    6873
     74    /** return a specific jobList index
     75     return NULL if the index does not exist
     76     */
     77    inline sectionToExecute* getJobListAt(int a) {
     78        if (a < 0) return NULL;
     79        if (a >= getJobListSize()) return NULL;
     80        return jobList_[a];
     81    }
     82   
     83    /** Clear a specific jobList */
     84    void clearSectionToExecute(int a);
    6985   
    7086private:
  • Interface_Web/branches/12_03_12-managerComboBox/pspaWT/sources/controler/include/sectionToExecute.h

    r385 r388  
    2424   
    2525    /** Deprecated : To be removed ! */
    26     inline int getFirstElementNumberInBeamLine() {
     26    inline int getElementNumberInSection() {
    2727        return firstElementNumberInBeamLine;
    2828    }
    2929   
    3030    /** Deprecated : To be removed ! */
    31     inline int getLastElementNumberInBeamLine()  {
     31    inline int getLastElementNumberInSection()  {
    3232        return lastElementNumberInBeamLine;
    3333    }
  • Interface_Web/branches/12_03_12-managerComboBox/pspaWT/sources/controler/src/dataManager.cc

    r385 r388  
    7474    for(k = 0; k < jobList_.size(); k++)
    7575    {
    76         if ( jobList_[k] != NULL ) delete jobList_[k];
     76        if ( jobList_[k] != NULL ) clearSectionToExecute(k);
    7777    }
    7878    jobList_.clear();
     79}
     80
     81
     82void dataManager::clearSectionToExecute(int a) {
     83  if (a<0) return;
     84  if (a>= jobList_.size()) return;
     85  delete jobList_[a];
    7986}
    8087
     
    121128      cout << " dataManager::executeAll je m'apprete a executer : " << (jobList_[k]->getSoftware()->getName()) << endl;
    122129     
    123       int debut = jobList_[k]->getFirstElementNumberInBeamLine();
    124       int fin = jobList_[k]->getLastElementNumberInBeamLine();
     130      int debut = jobList_[k]->getElementNumberInSection();
     131      int fin = jobList_[k]->getLastElementNumberInSection();
    125132      softw = jobList_[k]->getSoftware();
    126133     
  • Interface_Web/branches/12_03_12-managerComboBox/pspaWT/sources/userInterface/include/GWt_softwarePanel.h

    r367 r388  
    1313#include <Wt/WContainerWidget>
    1414#include <Wt/WPushButton>
    15 
     15#include "GWt_sectionToExecute.h"
    1616#include "dataManager.h"
    1717
     
    2323class GWt_softwarePanel  : public WContainerWidget
    2424{
    25     typedef struct {
    26         WLineEdit* debut;
    27         WLineEdit*  fin;
    28         WComboBox* selection;
    29         WContainerWidget* ligneDeWidget;
    30     } GWt_sectionToExecute;
    31 
    3225    public :
    3326    GWt_softwarePanel(dataManager*, PspaApplication*);
     
    4639    bool areDataCoherent();
    4740   
    48     list<GWt_sectionToExecute*> selectedSections_;
    4941    dataManager* dtmanage_;
    5042    WPushButton *exec_go_;
     
    5244    PspaApplication* pspa_;
    5345
     46    std::vector <GWt_sectionToExecute*> sections;
    5447};
    5548
  • Interface_Web/branches/12_03_12-managerComboBox/pspaWT/sources/userInterface/src/GWt_softwarePanel.cc

    r385 r388  
    1717#include "GWt_console.h"
    1818#include "GWt_globalParameters.h"
     19#include "GWt_sectionToExecute.h"
    1920
    2021
     
    6667void GWt_softwarePanel::addSectionToExecuteW()
    6768{   
    68   //  disableSectionExecute();
    69  
    70   string premierText, dernierText;
    71   if(selectedSections_.size() == 0) {
    72     premierText = dtmanage_->getLabelFromElementNumero(1);
    73     dernierText = dtmanage_->getLabelFromElementNumero(dtmanage_->getBeamLineSize());
     69 
     70  abstractElement* premierElement;
     71  abstractElement* dernierElement;
     72
     73  int premierIndex = 0;
     74  int dernierIndex = 0;
     75
     76    // if this is the first section
     77  if(dtmanage_->getJobListSize() == 0) {
     78      premierElement = pspa_->getBeamLine()->getAbstractElement(0);
     79      dernierElement = pspa_->getBeamLine()->getAbstractElement(pspa_->getBeamLine()->getBeamLineSize()-1);
     80      premierIndex = 0;
     81      dernierIndex = pspa_->getBeamLine()->getBeamLineSize()-1;
     82
     83  // if this is not the first :
     84  // - first element will be the last of the previous section
     85  // (or the same if it is the last of the beam line)
     86  // - lastElement will be the last of the beam line
     87  // - software will be the first of the list
     88     
    7489  } else {
    75     dernierText = selectedSections_.back()->fin->text().toUTF8();
    76     int dernierNumero = dtmanage_->getNumeroFromElementLabel(dernierText);
    77     dernierNumero++;
    78     if ( dernierNumero <= dtmanage_->getBeamLineSize() ) {
    79       premierText = dtmanage_->getLabelFromElementNumero(dernierNumero);
     90    int indexOfLastElementOfLastSection = dtmanage_->getJobListAt(dtmanage_->getJobListSize()-1)->getLastElementNumberInSection();
     91    if (pspa_->getBeamLine()->getAbstractElement(indexOfLastElementOfLastSection+1) != NULL ) {
     92      premierIndex = indexOfLastElementOfLastSection+1;
     93      premierElement = pspa_->getBeamLine()->getAbstractElement(indexOfLastElementOfLastSection+1);
    8094    } else {
    81       premierText = dtmanage_->getLabelFromElementNumero(dtmanage_->getBeamLineSize());
    82     }
    83     dernierText = premierText;
     95      premierIndex = indexOfLastElementOfLastSection;
     96      premierElement = pspa_->getBeamLine()->getAbstractElement(indexOfLastElementOfLastSection);
     97       
     98    }
     99    dernierIndex = dtmanage_->getJobListSize()-1;
     100    dernierElement = pspa_->getBeamLine()->getAbstractElement(pspa_->getBeamLine()->getBeamLineSize()-1);
    84101  }
    85102 
    86103  //  cout << "PspaApplication::addSectionToExecute() : " << premierText << " à  " << dernierText << endl;
    87104 
    88   WContainerWidget* newSection = new WContainerWidget;
    89    
    90   selectedSections_.push_back(new GWt_sectionToExecute);
    91   selectedSections_.back()->debut = new WLineEdit();
    92   selectedSections_.back()->debut->setDisabled(true);
    93   selectedSections_.back()->debut->setText(premierText);
    94   selectedSections_.back()->fin = new WLineEdit();
    95   //  selectedSections_.back()->fin->changed().connect(this,&GWt_softwarePanel::disableSectionExecute);
    96   selectedSections_.back()->fin->setText(dernierText);
    97   selectedSections_.back()->selection = new WComboBox();
    98   selectedSections_.back()->ligneDeWidget = newSection;
    99   newSection->addWidget(new WText(" from : "));
    100   newSection->addWidget(selectedSections_.back()->debut);
    101   newSection->addWidget(new WText(" to : "));
    102   newSection->addWidget(selectedSections_.back()->fin);
    103   newSection->addWidget(selectedSections_.back()->selection);
    104  
    105   contenuSections_->addWidget(newSection);
     105 
     106  abstractSoftware* soft = NULL;
     107  dtmanage_->addSectionToExecute(premierElement,premierIndex, dernierElement, dernierIndex, soft);
     108
     109  std::string premierElementLabel = "";
     110  std::string dernierElementLabel = "";
     111  if (premierElement) {
     112    premierElementLabel = premierElement->getLabel();
     113  }
     114
     115  if (dernierElement) {
     116    dernierElementLabel = dernierElement->getLabel();
     117  }
     118
     119  WLineEdit* lineFrom = new WLineEdit(premierElementLabel);
     120  WLineEdit* lineTo = new WLineEdit(dernierElementLabel);
     121  WComboBox* softCombo = new WComboBox();
     122
    106123  unsigned nb = nomDeLogiciel::getNumberOfSoftwares();
    107124  unsigned k;
    108125  for(k = 0; k < nb; k++) {
    109     selectedSections_.back()->selection->addItem(nomDeLogiciel(k).getString());
    110   }
     126    softCombo->addItem(nomDeLogiciel(k).getString());
     127  }
     128
     129  GWt_sectionToExecute* newSection = new GWt_sectionToExecute(lineFrom, lineTo, softCombo);
     130  sections.push_back(newSection);
     131  contenuSections_->addWidget(newSection);
     132
     133   
     134   
     135    // ______________test !!!!! _______________________
     136/*
     137 
     138   
     139     
     140    // create a new section
     141    WContainerWidget* addedSection = new WContainerWidget;
     142
     143    // add components
     144    addedSection->addWidget(new WText("TEST from : "));
     145    WComboBox* debCombo = new WComboBox();
     146    WComboBox* finCombo = new WComboBox();
     147    WComboBox* softwareCombo = new WComboBox();
     148
     149    // fill the combo with all elements
     150    for (int a=0; a< pspa_->getBeamLine()->getBeamLineSize(); a++) {
     151        abstractElement* abs = pspa_->getBeamLine()->getAbstractElement(a);
     152        if (abs != NULL){
     153            debCombo->addItem(abs->getLabel());
     154            finCombo->addItem(abs->getLabel());
     155        }
     156    }
     157    // set selection
     158    int index = 0;
     159    if (debut_section.size() > 0) {
     160        index = finCombo->currentIndex ()+1;
     161    }
     162    debCombo->setCurrentIndex(index);
     163//...
     164    // push it in the vector
     165    debut_section.push_back(debCombo);
     166    fin_section.push_back(finCombo);
     167    software_section.push_back(softwareCombo);
     168   
     169    addedSection->addWidget(debCombo);
     170    addedSection->addWidget(new WText("TEST to : "));
     171    addedSection->addWidget(finCombo);
     172    addedSection->addWidget(softwareCombo);
     173   
     174    contenuSections_->addWidget(addedSection);
     175    }
     176*/
     177   
     178
    111179}
    112180
     
    206274bool GWt_softwarePanel::updateSectionSelection()
    207275{
    208   if ( selectedSections_.empty() ) return false;
     276  if ( dtmanage_->getJobListSize() == 0 ) return false;
    209277 
    210278  // traitement de la premiere ligne
    211279  // on impose le depart du calcul au premier element
    212280  string premier = dtmanage_->getLabelFromElementNumero(1);
    213   (*selectedSections_.begin())->debut->setText(premier);
    214  
    215   string currentString =  (*selectedSections_.begin())->fin->text().toUTF8();
    216   int current = dtmanage_->getNumeroFromElementLabel(currentString);
    217    
     281  if (sections.size() > 0) {
     282    sections[0]->setFirstElementLineEditCurrentText(premier);
     283  }
     284 
     285  Wt::WString currentString =  sections[0]->getLastElementLineEditCurrentText();
     286  int current = dtmanage_->getNumeroFromElementLabel(currentString.toUTF8());
     287 
    218288  // si la fin est mal definie on prend toute la config par defaut
    219289  if ( current <= 0 || current > dtmanage_->getBeamLineSize() )
    220     {
    221       current = dtmanage_->getBeamLineSize();
    222       currentString =  dtmanage_->getLabelFromElementNumero(current);
    223       (*selectedSections_.begin())->fin->setText(currentString);
    224     }
    225   current++;
     290  {
     291    current = dtmanage_->getBeamLineSize();
     292    currentString =  dtmanage_->getLabelFromElementNumero(current);
     293    if (sections.size() > 0) {
     294      sections[0]->setLastElementLineEditCurrentText(currentString);
     295    }
     296  }
     297//  current++;
    226298  currentString = dtmanage_->getLabelFromElementNumero(current);
    227299 
    228300  // traitement des suivantes (on avance d'un cran dans la liste)
    229   list<GWt_sectionToExecute*>::iterator itr, itr0;
    230   itr0 = selectedSections_.begin();
    231   itr0++;
    232   for (itr = itr0; itr != selectedSections_.end(); itr++)
     301  for (int a = 0; a< sections.size(); a++)
    233302    {
    234303      // debut
     
    240309        }
    241310     
    242       (*itr)->debut->setText(currentString);
     311      sections[a]->setFirstElementLineEditCurrentText(currentString);
    243312      // fin
    244       string finString =  (*itr)->fin->text().toUTF8();
     313      string finString =  sections[a]->getLastElementLineEditCurrentText().toUTF8();
    245314     
    246315      int numeroFin = dtmanage_->getNumeroFromElementLabel( finString);
     
    269338  string diagnostic;
    270339   
    271   list<GWt_sectionToExecute*>::iterator itr;
    272   for(itr = selectedSections_.begin(); itr != selectedSections_.end(); itr++)
     340  for (int a = 0; a< sections.size(); a++)
    273341    {
    274       string debString = (*itr)->debut->text().toUTF8();
    275       string finString = (*itr)->fin->text().toUTF8();
     342      string debString = sections[a]->getFirstElementLineEditCurrentText().toUTF8();
     343      string finString = sections[a]->getLastElementLineEditCurrentText().toUTF8();
    276344     
    277345      int debut = pspa_->getBeamLine()->getAbstractElementIndexFromLabel(debString)+1; // FIXME : Should NOT be +1
    278346        int fin = pspa_->getBeamLine()->getAbstractElementIndexFromLabel(finString)+1; // FIXME : Should NOT be +1
    279347
    280       nomDeLogiciel prog = nomDeLogiciel ( (*itr)->selection->currentIndex() );
     348      nomDeLogiciel prog = nomDeLogiciel ( sections[a]->getSoftwareCurrentText().toUTF8());
    281349      dtmanage_->addSectionToExecute(pspa_->getBeamLine()->getAbstractElement(debut),
    282350                                     debut,
     
    324392void GWt_softwarePanel::deleteSectionToExecuteW()
    325393{
    326   if ( selectedSections_.empty() ) return;
    327   //  disableSectionExecute();
    328   selectedSections_.back()->ligneDeWidget->clear();
    329   delete selectedSections_.back()->ligneDeWidget;
    330   selectedSections_.pop_back();
     394  if ( dtmanage_->getJobListSize() == 0 ) return;
     395  // delete from dataManager
     396  dtmanage_->clearSectionToExecute(dtmanage_->getJobListSize()-1);
     397
     398  // delete from User Interface
     399  sections.pop_back();
    331400}
    332401
     
    335404{
    336405  string premierText, dernierText;
    337   if ( selectedSections_.size() > 0 )
     406  if ( dtmanage_->getJobListSize() > 0 )
    338407    {
    339408      premierText = dtmanage_->getLabelFromElementNumero(1);
    340409      dernierText = dtmanage_->getLabelFromElementNumero( dtmanage_->getBeamLineSize() );
    341       (*selectedSections_.begin())->debut->setText(premierText);
    342       (*selectedSections_.begin())->fin->setText(dernierText);
    343     }
    344 }
    345 
    346 
    347 string GWt_softwarePanel::getSelection()
     410      sections[0]->setFirstElementLineEditCurrentText(premierText);
     411      sections[0]->setLastElementLineEditCurrentText(dernierText);
     412    }
     413}
     414
     415
     416
     417/*
     418 string GWt_softwarePanel::getSelection()
    348419{
    349420  list<GWt_sectionToExecute*>::iterator itr = selectedSections_.begin();
     
    351422  return str;
    352423}
    353 
     424*/
    354425
    355426void GWt_softwarePanel::executer()
     
    388459  pspa_->faireDessin();
    389460}
     461
Note: See TracChangeset for help on using the changeset viewer.