Changeset 401 in PSPA for Interface_Web/trunk/pspaWT/sources


Ignore:
Timestamp:
Mar 27, 2013, 5:47:22 PM (12 years ago)
Author:
garnier
Message:

merge avec la branche 12_03_12-managerComboBox

Location:
Interface_Web/trunk/pspaWT
Files:
20 edited
3 copied

Legend:

Unmodified
Added
Removed
  • Interface_Web/trunk/pspaWT

  • Interface_Web/trunk/pspaWT/sources/controler/include/dataManager.h

    r386 r401  
    3131  particleBeam* getDiagnosticBeam(string elementLabel);
    3232
    33   void addSectionToExecute(int debut, int fin, nomDeLogiciel prog);
     33  void addSectionToExecute(abstractElement* debut,int debutIndex, abstractElement* fin, int finIndex, abstractSoftware* prog);
    3434
    3535    abstractElement* addElement(typedElement elemType);
     
    6565    bool restoreElements(string inputFileName);
    6666   
     67    abstractSoftware* createSoftwareConnexion(nomDeLogiciel logi);
     68   
     69    /** return the jobList size
     70     */
     71    inline int getJobListSize() {
     72        return jobList_.size();
     73    }
    6774
    6875    // si newBeam = true, on cree un nouveau diag
     
    7683    }
    7784
     85    /** return a specific jobList index
     86     return NULL if the index does not exist
     87     */
     88    inline sectionToExecute* getJobListAt(int a) {
     89        if (a < 0) return NULL;
     90        if (a >= getJobListSize()) return NULL;
     91        return jobList_[a];
     92    }
     93   
     94    /** Clear a specific jobList */
     95    void clearSectionToExecute(int a);
    7896   
    7997private:
     
    93111    void removeFile(string nameOfFile);
    94112    void clearSectionToExecute();
    95     abstractSoftware* createSoftwareConnexion(nomDeLogiciel logi);
    96113 
    97114  };
  • Interface_Web/trunk/pspaWT/sources/controler/include/nomDeLogiciel.h

    r316 r401  
    1919  };
    2020
    21 
     21   
    2222 private:
    2323
  • Interface_Web/trunk/pspaWT/sources/controler/include/sectionToExecute.h

    r312 r401  
    33
    44#include "nomDeLogiciel.h"
     5#include "abstractElement.h"
     6#include "abstractSoftware.h"
    57
    6 typedef struct 
     8class sectionToExecute
    79{
    8   unsigned firstElement;  // numero premier element
    9   unsigned lastElement;   // numero dernier element
    10   nomDeLogiciel software;
    11 }  sectionToExecute;
     10    public :
     11    sectionToExecute(abstractElement*, abstractElement*, abstractSoftware*);
     12
     13    /** Deprecated : To be removed ! */
     14    sectionToExecute(abstractElement*, int, abstractElement*, int, abstractSoftware*);
     15    ~sectionToExecute() {;}
     16
     17    inline abstractElement* getFirstElement() {
     18        return firstElement;
     19    }
     20   
     21    inline abstractElement* getLastElement() {
     22        return lastElement;
     23    }
     24   
     25    /** Deprecated : To be removed ! */
     26    inline int getElementNumberInSection() {
     27        return firstElementNumberInBeamLine;
     28    }
     29   
     30    /** Deprecated : To be removed ! */
     31    inline int getLastElementNumberInSection()  {
     32        return lastElementNumberInBeamLine;
     33    }
     34    inline abstractSoftware* getSoftware() {
     35        return software;
     36    }
     37   
     38    private :
     39    abstractElement*  firstElement;
     40    abstractElement*  lastElement;
     41
     42    int firstElementNumberInBeamLine;
     43    int lastElementNumberInBeamLine;
     44   
     45    abstractSoftware* software;
     46};
    1247
    1348#endif
  • Interface_Web/trunk/pspaWT/sources/controler/src/abstractElement.cc

    r373 r401  
    117117  }
    118118 
    119   if ((tb == TBoolOk) || (tb == TBoolIgnore)) {
     119  if (prog == nomDeLogiciel::unknownSoftware){
     120    tb = TBoolOk;
     121  }
     122   
     123          if ((tb == TBoolOk) || (tb == TBoolIgnore)) {
    120124    if (prog == nomDeLogiciel::parmela) {
    121125      abstractSoftware_ = new softwareParmela();
  • Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc

    r386 r401  
    6464}
    6565
    66 void dataManager::addSectionToExecute(int debut, int fin, nomDeLogiciel prog)
    67 {
    68     jobList_.push_back(new sectionToExecute);
    69     jobList_.back()->firstElement = debut;
    70     jobList_.back()->lastElement = fin;
    71     jobList_.back()->software  = prog;
     66void dataManager::addSectionToExecute(abstractElement* debut,int debutIndex, abstractElement* fin, int finIndex, abstractSoftware* prog)
     67{
     68    jobList_.push_back(new sectionToExecute(debut, debutIndex, fin, finIndex, prog));
    7269}
    7370
     
    7774    for(k = 0; k < jobList_.size(); k++)
    7875    {
    79         if ( jobList_[k] != NULL ) delete jobList_[k];
     76        if ( jobList_[k] != NULL ) clearSectionToExecute(k);
    8077    }
    8178    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];
    8286}
    8387
     
    123127  for(unsigned k = 0; k < jobList_.size(); k++)
    124128    {
    125       cout << " dataManager::executeAll je m'apprete a executer : " << (jobList_[k]->software).getString() << endl;
    126      
    127       int debut = jobList_[k]->firstElement;
    128       int fin = jobList_[k]->lastElement;
    129       softw = createSoftwareConnexion(jobList_[k]->software);
     129      cout << " dataManager::executeAll je m'apprete a executer : " << (jobList_[k]->getSoftware()->getName()) << endl;
     130     
     131      int debut = jobList_[k]->getElementNumberInSection();
     132      int fin = jobList_[k]->getLastElementNumberInSection();
     133      softw = jobList_[k]->getSoftware();
    130134     
    131135      if (softw == NULL) {
    132         success = false;
    133         consoleMessage("dataManager::executeAll : unknown software");
    134         break;
    135       }
    136        
     136        success = false;
     137        consoleMessage("dataManager::executeAll : unknown software");
     138        break;
     139      }
     140     
    137141      success = softw->createInputFile(currentBeam_,debut,fin,workingDir);
    138142      if ( success ) {
     
    141145          success = softw->buildBeamAfterElements(workingDir);
    142146        }
    143       }
    144        
     147//=======
     148//        success = softw->execute(debut,fin,workingDir);
     149//        if ( success ) {
     150//          success = softw->buildBeamAfterElements(debut,fin,diagnosticBeam_,workingDir);
     151//        }
     152//>>>>>>> .merge-right.r400
     153      }
     154     
    145155      delete softw;
    146156      if ( success ) {
     
    306316}
    307317
     318
    308319abstractSoftware* dataManager::createSoftwareConnexion(nomDeLogiciel logi)
    309320{
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_console.h

    r272 r401  
    1515   
    1616public:
    17     GWt_console();
    18     virtual ~GWt_console();
    19     void addConsoleMessage(WString msg);
     17  GWt_console();
     18  virtual ~GWt_console();
     19  void addConsoleMessage(WString msg);
     20private:
     21  WText* output_;
    2022};
    2123
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_dialog.h

    r336 r401  
    3838     */
    3939    GWt_dialog(WString titre, WString message, iconType icon=NoIcon, bool modal=false, bool okButton=false);
     40
     41    /** Add a v content to this widget
     42    */
     43    void addVContent(WContainerWidget* wc);
     44   
     45    private :
     46    WVBoxLayout* vDialogLayout_;
    4047};
    4148#endif
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_ligneFaisceau.h

    r379 r401  
    5454     */
    5555    abstractElement* getAbstractElement(int i);
     56
     57    /** return the index of the abstract element
     58     @param : label of this abstractElement in the beam line
     59     */
     60    int getAbstractElementIndexFromLabel(std::string str);
     61
    5662    //    void restoreElementCollectionFromDataManager();
    5763    void clickEvent(WContainerWidget*);
     
    7581    void update(int);
    7682
     83    void initializeSoftwares();
     84
    7785    private :
    7886    void manageLineFaisceauLayout();
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_pspaApplication.h

    r393 r401  
    6565  WText* createTitle(const WString&);
    6666  WWidget* createPalette();
    67   void createBeamLine();
     67  WWidget* createBeamLine();
    6868  WWidget* createGlobalParamWidget();
    6969  WWidget* createExecuteWidget();
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_softwarePanel.h

    r367 r401  
    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*);
     
    3528
    3629    void addSectionToExecuteW();
    37     void updateSelections();
     30    void updateSections();
    3831   
    3932    private :
     
    4538    void executer();
    4639    bool areDataCoherent();
    47    
    48     list<GWt_sectionToExecute*> selectedSections_;
     40    void fillComboWithElements(Wt::WComboBox* cBox);
     41    void fillComboWithSoftwares(Wt::WComboBox* cBox);
     42    Wt::WContainerWidget* createAddDeletePushButtons();
     43
    4944    dataManager* dtmanage_;
    5045    WPushButton *exec_go_;
     
    5247    PspaApplication* pspa_;
    5348
     49    std::vector <GWt_sectionToExecute*> sections;
    5450};
    5551
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_abstractElementFactory.cc

    r343 r401  
    9999{
    100100  vector <GWt_abstractElement*> elems;
    101   if (isDriftElementEnable) {
    102     elems.push_back(new GWt_drift());
     101  if (isRFGunElementEnable) {
     102    elems.push_back(new GWt_rfgun());
    103103  }
    104104  if (isBeamElementEnable) {
    105105    elems.push_back(new GWt_beam());
     106  }
     107  if (isDriftElementEnable) {
     108    elems.push_back(new GWt_drift());
    106109  }
    107110  if (isBendElementEnable) {
     
    111114    elems.push_back(new GWt_cell());
    112115  }
     116  if (isSolenoElementEnable) {
     117    elems.push_back(new GWt_soleno());
     118  }
    113119  if (isFitElementEnable) {
    114120    elems.push_back(new GWt_fit());
    115   }
    116   if (isRFGunElementEnable) {
    117     elems.push_back(new GWt_rfgun());
    118   }
    119   if (isSolenoElementEnable) {
    120     elems.push_back(new GWt_soleno());
    121121  }
    122122  if (isSnapshotElementEnable) {
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_console.cc

    r272 r401  
    33#include <Wt/WApplication>
    44#include <Wt/WText>
     5#include <Wt/WBorder>
     6#include <Wt/WLayout>
     7#include <Wt/WPanel>
     8#include <Wt/WScrollArea>
    59
    610GWt_console::GWt_console()
     
    812{
    913    setObjectName("console");
     14
     15    // le panel
     16    WPanel *panelConsole = new WPanel(this);
     17    WScrollArea* container = new  WScrollArea();
     18   
     19    panelConsole->setTitle(" output");
     20    output_ = new WText(this);
     21    output_->setTextFormat(PlainText);
     22    output_->setInline(false);
     23
     24    container->setWidget(output_);
     25
     26    panelConsole->setCentralWidget(container);
     27    output_->setMinimumSize(270,100);
     28    output_->setMaximumSize(400,400);
     29
     30
    1031}
    1132
     
    1839void GWt_console::addConsoleMessage(WString msg) {
    1940   
    20     WText *w = new WText(this);
    21     w->setTextFormat(PlainText);
    22     w->setText(msg);
    23     w->setInline(false);
     41    output_->setText(output_->text()+msg);
    2442   
    2543    /*
    2644     * Little javascript trick to make sure we scroll along with new content
    2745     */
    28     wApp->doJavaScript(this->jsRef() + ".scrollTop += "
    29                        + this->jsRef() + ".scrollHeight;");
     46    wApp->doJavaScript(output_->jsRef() + ".scrollTop += "
     47                       + output_->jsRef() + ".scrollHeight;");
    3048   
    3149}
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_dialog.cc

    r336 r401  
    33#include <Wt/WText>
    44#include <Wt/WBreak>
     5#include <Wt/WVBoxLayout>
    56#include <Wt/WHBoxLayout>
    67#include <Wt/WPushButton>
     
    1920    titleBar()->decorationStyle().setBackgroundColor (WColor(70,180,220));
    2021   
    21     if (wc != NULL) {
    22         WContainerWidget* widgt = new WContainerWidget(contents());
    23         WHBoxLayout* hLayout = new WHBoxLayout();
    24         hLayout->addWidget(wc);
    25         widgt->setLayout(hLayout);
    26     }
     22    WContainerWidget* widgt = new WContainerWidget(contents());
     23    vDialogLayout_ = new WVBoxLayout();
     24    widgt->setLayout(vDialogLayout_);
    2725   
    2826    setClosable(true);
    2927    setModal (modal);
     28    setResizable(true);
     29    show();
     30   
     31    if (wc != NULL) {
     32        addVContent(wc);
     33    }
    3034}
    3135
     
    111115
    112116
     117void GWt_dialog::addVContent(WContainerWidget* wc) {
    113118
     119    if (vDialogLayout_) {
     120        vDialogLayout_->addWidget(wc);
     121    }
     122}
     123
     124
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_elementLigneFaisceau.cc

    r382 r401  
    1818#include <Wt/WSignalMapper>
    1919#include <Wt/WText>
    20 #include <Wt/WImage>
    2120#include <Wt/WHBoxLayout>
    2221#include <Wt/WGridLayout>
     
    210209      setBGColor(WColor(getGWt_AbstractElement()->getAbstractElement()->getAbstractSoftware()->getColor()));
    211210      softwareName_->setText(getGWt_AbstractElement()->getAbstractElement()->getAbstractSoftware()->getName());
     211
     212    // no abstract software
     213    } else {
     214      setBGColor(WColor("#FFFFFF"));
     215      softwareName_->setText("");
    212216    }
    213217  }
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_globalParameters.cc

    r272 r401  
    1818    pspa_ = ps;
    1919    WVBoxLayout* globLayout = new WVBoxLayout();
    20     decorationStyle().setBackgroundColor (WColor("blue"));
    2120    //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
    2221    WContainerWidget *result = new WContainerWidget();
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_ligneFaisceau.cc

    r379 r401  
    99#include "GWt_soleno.h"
    1010#include "GWt_bend.h"
     11#include "nomDeLogiciel.h"
    1112
    1213#include "mixedTools.h"
     
    2425  ligneFaisceauLayout_ = new WHBoxLayout();
    2526  //  decorationStyle().setBackgroundColor (WColor(245,245,245));
    26   setLayout(ligneFaisceauLayout_);
    2727  ligneFaisceauLayout_->setContentsMargins(0,0,0,0);
    2828  ligneFaisceauLayout_->setSpacing(0);
    2929 
     30  setLayout(ligneFaisceauLayout_);
     31
    3032  // set the object name
    31   setObjectName("ligneFaisceau"); 
     33  setObjectName("ligneFaisceau");
    3234  clear();
    3335}
     
    157159  }
    158160 
    159   pspa_->getExecuteWidget()->updateSelections();
     161  pspa_->getExecuteWidget()->updateSections();
    160162}
    161163
     
    203205    }
    204206   
    205     // first if 1
    206     //    i--;
    207207    for (int a=0; a< ligneFaisceauLayout_->count(); a++) {
    208208        if (ligneFaisceauLayout_->itemAt(a)) {
     
    222222
    223223
     224int GWt_LigneFaisceau::getAbstractElementIndexFromLabel(std::string txt){
     225    int index = 0;
     226    if (txt == "") {
     227        return NULL;
     228    }
     229   
     230    for (int a=0; a< ligneFaisceauLayout_->count(); a++) {
     231        if (ligneFaisceauLayout_->itemAt(a)) {
     232           
     233            if (GWt_elementLigneFaisceau* elem = dynamic_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ())) {
     234                if (elem->getGWt_AbstractElement()) {
     235                    if (elem->getGWt_AbstractElement()->getAbstractElement()->getLabel() == txt) {
     236                        return index;
     237                    }
     238                }
     239                index ++;
     240            }
     241        }
     242    }
     243    return NULL;
     244   
     245}
     246
     247
    224248int GWt_LigneFaisceau::getBeamLineSize() {
    225249  int count = 0;
     
    260284}
    261285
     286
     287void GWt_LigneFaisceau::initializeSoftwares(){
     288   
     289  vector <abstractElement*> elems = getAllAbstractElements();
     290    for (int a=0; a< elems.size(); a++) {
     291        elems[a]->setSoftware(nomDeLogiciel::unknownSoftware);
     292    }
     293}
     294
     295
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc

    r398 r401  
    7777 
    7878  /*
    79    * The main layout is a 3x2 grid layout.
     79   * The main layout is a 4x3 grid layout.
    8080   */
    81   WGridLayout *layout = new WGridLayout();
     81  WGridLayout *mainGridLayout = new WGridLayout();
    8282  //  layout->addWidget(createTitle("<a href='workingArea/parmin'> Menu (In future)</a>"), 0, 0, 1, 2);
    8383  //  layout->addWidget(createTitle("Menu (In future)"), 0, 0, 1, 2);
     
    131131  toolbarLayout->addWidget(new WText("") , 1,Wt::AlignMiddle);
    132132 
    133   WContainerWidget * layoutContainer = new WContainerWidget();
    134   layoutContainer->setLayout(toolbarLayout);
    135   layoutContainer->decorationStyle().setBackgroundImage ("/htdocs/fond_toolbar.png");
    136   layout->addWidget(layoutContainer, 1, 0, 1, 2);
    137   layout->addWidget(createPalette(), 2, 0, 4, 1);
    138  
    139   createBeamLine();
     133  WContainerWidget * toolbarLayoutContainer = new WContainerWidget();
     134  toolbarLayoutContainer->setLayout(toolbarLayout);
     135  toolbarLayoutContainer->decorationStyle().setBackgroundImage ("/htdocs/fond_toolbar.png");
     136   
     137  mainGridLayout->addWidget(toolbarLayoutContainer, 1, 0, 1, 3);
     138  mainGridLayout->addWidget(createPalette(), 2, 0, 4, 1);
     139
    140140 
    141141  WScrollArea* scroll = new  WScrollArea();
    142   scroll->setWidget(beamLine_);
    143   layout->addWidget(scroll, 2, 1, 1, 1);
     142  scroll->setWidget(createBeamLine());
     143  scroll->setMinimumSize(300,150);
     144
     145  mainGridLayout->addWidget(scroll, 2, 1, 1, 2);
    144146 
    145147 
     
    151153  // console_->setOverflow(WContainerWidget::OverflowAuto);
    152154 
    153  
    154   console_ = new GWt_console();
    155   console_->clear();
    156   console_->decorationStyle().setBackgroundColor (WColor("lightgray"));
    157   console_->setMaximumSize(600,200);
    158   console_->setMinimumSize(300,100);
    159   console_->setOverflow(WContainerWidget::OverflowAuto);
    160   layout->addWidget(console_, 3, 2);
    161155 
    162156  //-----------
     
    171165  executeWidget_ = new GWt_softwarePanel(dtmanage_,this);
    172166 
    173   layout->addWidget( globalParam_, 3, 1);
     167  mainGridLayout->addWidget( globalParam_, 3, 1);
    174168  //  layout->addWidget( leDessin_, 3, 2);
    175   layout->addWidget( executeWidget_ , 4, 1);
     169  mainGridLayout->addWidget( executeWidget_ , 4, 1);
    176170  //-----------
    177171 
    178   layout->setColumnResizable(1);
    179   layout->setRowResizable(2);
     172  console_ = new GWt_console();
     173
     174  // manage sizes
     175  console_->setMinimumSize(300,100);
     176  executeWidget_->setMinimumSize(400,100);
     177
     178  mainGridLayout->addWidget(console_, 3, 2,2,1);
     179 
     180 
    180181  /*
    181182   * Let row 2 and column 1 take the excess space.
    182183   */
    183   layout->setRowStretch(2, 1);
    184   layout->setColumnStretch(1, 1);
    185  
    186   widroot->setLayout(layout);
     184  mainGridLayout->setRowStretch(4, 1);
     185  mainGridLayout->setColumnStretch(2, 1);
     186 
     187  widroot->setLayout(mainGridLayout);
     188
     189  // set auto scrollbar if needed
     190  widroot->setOverflow(WContainerWidget::OverflowAuto);
     191
    187192}
    188193
     
    210215}
    211216
    212 void PspaApplication::createBeamLine()
     217Wt::WWidget* PspaApplication::createBeamLine()
    213218{
    214219  extensionFile_= 0;
     
    220225  beamLine_->setMinimumSize(300,100);
    221226  setTitle(applicationDefaultTitle_);
     227
     228  return beamLine_;
    222229}
    223230
     
    225232{
    226233    WContainerWidget* globalParam = new GWt_globalParameters(this);
    227     globalParam->setMaximumSize(600,150);
    228     globalParam->setMinimumSize(600,150);
    229234    return globalParam;
    230235}
     
    980985void PspaApplication::removeBeamLine() {
    981986  createBeamLine();
     987  executeWidget_->updateSections();
    982988}
    983989
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_serverFileSelector.cc

    r347 r401  
    7070    WContainerWidget *buttonContainer = new WContainerWidget();
    7171    WHBoxLayout* hButtonLayout = new WHBoxLayout();
    72     buttonContainer->setLayout(hButtonLayout);
    7372   
    7473    WPushButton *annule = new WPushButton("cancel");
     
    8079    submit->clicked().connect(this, &Wt::WDialog::accept);
    8180   
     81    buttonContainer->setLayout(hButtonLayout);
    8282
    83     // overload the container already present
     83    // add the container already present
    8484   
    85     WContainerWidget* widgt = new WContainerWidget(contents());
    86     WVBoxLayout* vLayout = new WVBoxLayout();
    87     vLayout->addWidget(treeContainer);
    88     vLayout->addWidget(buttonContainer);
    89     widgt->setLayout(vLayout);
     85    addVContent(treeContainer);
     86    addVContent(buttonContainer);
    9087   
     88    treeContainer->resize(400,300);
     89    treeContainer->setOverflow(WContainerWidget::OverflowAuto);
     90
    9191}
    9292
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_softwarePanel.cc

    r398 r401  
    1212#include <Wt/WBreak>
    1313#include <Wt/WApplication>
     14#include <Wt/WVBoxLayout>
    1415
    1516#include "GWt_softwarePanel.h"
     
    1718#include "GWt_console.h"
    1819#include "GWt_globalParameters.h"
     20#include "GWt_sectionToExecute.h"
    1921
    2022
     
    2426  dtmanage_ = dataManager;
    2527  pspa_ = pspa;
    26   setMaximumSize(600,150);
    27   setMinimumSize(600,150);
    28    
     28 
    2929  // bouton execute
    3030  exec_go_ = new WPushButton("execute!");
     
    3333  exec_go_->clicked().connect(this, &GWt_softwarePanel::executer);
    3434 
    35   // preparation du bouton add
    36   WPushButton* exec_add = new WPushButton("add");
    37   exec_add->clicked().connect(this, &GWt_softwarePanel::addSectionToExecuteW);
    38    
    39   // preparation du bouton delete
    40   WPushButton* exec_delete = new WPushButton("delete");
    41   exec_delete->clicked().connect(this, &GWt_softwarePanel::deleteSectionToExecuteW);
    4235   
    4336  // preparation du bouton push_ok
     
    4740  // le panel
    4841  WPanel *panelLogiciels = new WPanel(this);
    49   panelLogiciels->setTitle(" sections of beam Line for executing softwares ");
     42  panelLogiciels->setTitle(" sections of beam line for executing softwares ");
    5043 
    5144  contenuSections_ = new WContainerWidget();
    52   contenuSections_->addWidget(exec_add);
    53   contenuSections_->addWidget(exec_delete);
    5445  //  contenuSections_->addWidget(exec_ok);
    5546  contenuSections_->addWidget(exec_go_);
     
    6657void GWt_softwarePanel::addSectionToExecuteW()
    6758{   
    68   //  disableSectionExecute();
    69  
    70   string premierText, dernierText;
    71   if(selectedSections_.size() == 0) {
    72     premierText = dtmanage_->getLabelFromElementNumero(1);
    73     dernierText = dtmanage_->getLabelFromElementNumero(dtmanage_->getBeamLineSize());
     59 
     60  abstractElement* premierElement;
     61  abstractElement* dernierElement;
     62
     63  int premierIndex = 0;
     64  int dernierIndex = 0;
     65
     66    // if this is the first section
     67  if(dtmanage_->getJobListSize() == 0) {
     68      premierElement = pspa_->getBeamLine()->getAbstractElement(0);
     69      dernierElement = pspa_->getBeamLine()->getAbstractElement(pspa_->getBeamLine()->getBeamLineSize()-1);
     70      premierIndex = 0;
     71      dernierIndex = pspa_->getBeamLine()->getBeamLineSize()-1;
     72
     73  // if this is not the first :
     74  // - first element will be the last of the previous section
     75  // (or the same if it is the last of the beam line)
     76  // - lastElement will be the last of the beam line
     77  // - software will be the first of the list
     78     
    7479  } 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);
     80    int indexOfLastElementOfLastSection = dtmanage_->getJobListAt(dtmanage_->getJobListSize()-1)->getLastElementNumberInSection();
     81    if (pspa_->getBeamLine()->getAbstractElement(indexOfLastElementOfLastSection+1) != NULL ) {
     82      premierIndex = indexOfLastElementOfLastSection+1;
     83      premierElement = pspa_->getBeamLine()->getAbstractElement(indexOfLastElementOfLastSection+1);
    8084    } else {
    81       premierText = dtmanage_->getLabelFromElementNumero(dtmanage_->getBeamLineSize());
     85      premierIndex = indexOfLastElementOfLastSection;
     86      premierElement = pspa_->getBeamLine()->getAbstractElement(indexOfLastElementOfLastSection);
     87       
    8288    }
    83     dernierText = premierText;
     89    dernierIndex = dtmanage_->getJobListSize()-1;
     90    dernierElement = pspa_->getBeamLine()->getAbstractElement(pspa_->getBeamLine()->getBeamLineSize()-1);
    8491  }
    8592 
    8693  //  cout << "PspaApplication::addSectionToExecute() : " << premierText << " à  " << dernierText << endl;
    8794 
    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);
    106   unsigned nb = nomDeLogiciel::getNumberOfSoftwares();
    107   unsigned k;
    108   for(k = 0; k < nb; k++) {
    109     selectedSections_.back()->selection->addItem(nomDeLogiciel(k).getString());
    110   }
     95 
     96  abstractSoftware* soft = NULL;
     97  dtmanage_->addSectionToExecute(premierElement,premierIndex, dernierElement, dernierIndex, soft);
     98
     99  std::string premierElementLabel = "";
     100  std::string dernierElementLabel = "";
     101  if (premierElement) {
     102    premierElementLabel = premierElement->getLabel();
     103  }
     104
     105  if (dernierElement) {
     106    dernierElementLabel = dernierElement->getLabel();
     107  }
     108
     109  WComboBox* lineFromCombo = new WComboBox();
     110  WComboBox* lineToCombo = new WComboBox();
     111  fillComboWithElements(lineFromCombo);
     112  fillComboWithElements(lineToCombo);
     113
     114  WComboBox* softCombo = new WComboBox();
     115  fillComboWithSoftwares(softCombo);
     116
     117  GWt_sectionToExecute* newSection = new GWt_sectionToExecute(lineFromCombo, lineToCombo, softCombo,this);
     118
     119  // push back on sections vector
     120  sections.push_back(newSection);
     121
     122  Wt::WContainerWidget* container = new Wt::WContainerWidget();
     123  Wt::WGridLayout* containerLayout = new Wt::WGridLayout();
     124  containerLayout->setContentsMargins(0,0,0,0);
     125
     126  // push back on User interface
     127  containerLayout->addWidget(newSection,0,0);
     128 
     129  // add buttons
     130  containerLayout->addWidget(createAddDeletePushButtons(),0,1);
     131
     132  container->setLayout(containerLayout);
     133 
     134  // add to sections
     135  contenuSections_->addWidget(container); 
    111136}
    112137
     
    206231bool GWt_softwarePanel::updateSectionSelection()
    207232{
    208   if ( selectedSections_.empty() ) return false;
     233  if ( dtmanage_->getJobListSize() == 0 ) return false;
    209234 
    210235  // traitement de la premiere ligne
    211236  // on impose le depart du calcul au premier element
    212237  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    
     238  if (sections.size() > 0) {
     239    sections[0]->setFirstElementCurrentSelection(premier);
     240  }
     241 
     242  Wt::WString currentString =  sections[0]->getLastElementCurrentText();
     243  int current = dtmanage_->getNumeroFromElementLabel(currentString.toUTF8());
     244 
    218245  // si la fin est mal definie on prend toute la config par defaut
    219246  if ( current <= 0 || current > dtmanage_->getBeamLineSize() )
    220     {
    221       current = dtmanage_->getBeamLineSize();
    222       currentString =  dtmanage_->getLabelFromElementNumero(current);
    223       (*selectedSections_.begin())->fin->setText(currentString);
     247  {
     248    current = dtmanage_->getBeamLineSize();
     249    currentString =  dtmanage_->getLabelFromElementNumero(current);
     250    if (sections.size() > 0) {
     251      sections[0]->setLastElementCurrentSelection(currentString);
     252//...
    224253    }
     254  }
    225255  current++;
    226256  currentString = dtmanage_->getLabelFromElementNumero(current);
    227257 
    228258  // 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++)
     259  for (int a = 1; a< sections.size(); a++)
    233260    {
    234261      // debut
    235262      if ( current > dtmanage_->getBeamLineSize() )
    236263        {
    237           GWt_dialog warningDialog("PSPA :: verification des sections", " bad section definition !", GWt_dialog::Error,true,true);
     264          GWt_dialog warningDialog("PSPA :: verification des sections", " bad section definition 1 !", GWt_dialog::Error,true,true);
    238265          warningDialog.exec();
    239266          return false;
    240267        }
    241268     
    242       (*itr)->debut->setText(currentString);
     269      sections[a]->setFirstElementCurrentSelection(currentString);
     270
    243271      // fin
    244       string finString =  (*itr)->fin->text().toUTF8();
     272      string finString =  sections[a]->getLastElementCurrentText().toUTF8();
    245273     
    246274      int numeroFin = dtmanage_->getNumeroFromElementLabel( finString);
     
    248276      if ( numeroFin < current || numeroFin > dtmanage_->getBeamLineSize())
    249277        {
    250           GWt_dialog warningDialog("PSPA : Checking of sections", " bad section definition !", GWt_dialog::Error, true,true);
     278          GWt_dialog warningDialog("PSPA : Checking of sections", " bad section definition 2 !", GWt_dialog::Error, true,true);
    251279          warningDialog.exec();
    252280          return false;
     
    258286    }
    259287  //  exec_go_->setDisabled(false);
     288
     289  if (!areDataCoherent()) {
     290    exec_go_->disable();
     291  } else {
     292    exec_go_->enable();
     293  }
     294
    260295  return true;
    261296}
     
    265300{
    266301  bool caMarche = true;
    267   trivaluedBool tbResume = TBoolOk;
     302
     303  // initialize dataManager
    268304  dtmanage_->initializeExecution();
    269   string diagnostic;
    270    
    271   list<GWt_sectionToExecute*>::iterator itr;
    272   for(itr = selectedSections_.begin(); itr != selectedSections_.end(); itr++)
    273     {
    274       string debString = (*itr)->debut->text().toUTF8();
    275       string finString = (*itr)->fin->text().toUTF8();
    276      
    277       int debut = dtmanage_->getNumeroFromElementLabel(debString);
    278       int fin = dtmanage_->getNumeroFromElementLabel(finString);
    279       nomDeLogiciel prog = nomDeLogiciel ( (*itr)->selection->currentIndex() );
    280       dtmanage_->addSectionToExecute(debut,fin,prog);
    281        
    282       // check sections
    283       for (int i=debut-1; i<fin; i++) {
    284         if (pspa_->getBeamLine()) {
    285           if (pspa_->getBeamLine()->getAbstractElement(i)) {
    286             trivaluedBool tb = pspa_->getBeamLine()->getAbstractElement(i)->setSoftware(prog.getString());
    287             if (tb  == TBoolError ) {
    288               diagnostic += pspa_->getBeamLine()->getAbstractElement(i)->getNomdElement().getElementName() + " is not allowed with "+ prog.getString()+"\n ";
    289               caMarche = false;
    290               tbResume = tb;
    291             } else if ( tb == TBoolIgnore ) {
    292               diagnostic += pspa_->getBeamLine()->getAbstractElement(i)->getNomdElement().getElementName() + " will be ignored by  "+ prog.getString()+"\n ";
    293               if ( tbResume != TBoolError ) tbResume = tb;
    294             } else {
    295               pspa_->getBeamLine()->update(i);
    296             }
    297           }
    298         }
     305 
     306  // intialize User Interface
     307  if (pspa_->getBeamLine()) {
     308    pspa_->getBeamLine()->initializeSoftwares();
     309  }
     310 
     311  string diagnosticErrors;
     312  string diagnosticWarnings;
     313 
     314  for (int a = 0; a< sections.size(); a++)
     315  {
     316    string debString = sections[a]->getFirstElementCurrentText().toUTF8();
     317    string finString = sections[a]->getLastElementCurrentText().toUTF8();
     318   
     319    int debut = pspa_->getBeamLine()->getAbstractElementIndexFromLabel(debString)+1; // FIXME : Should NOT be +1
     320    int fin = pspa_->getBeamLine()->getAbstractElementIndexFromLabel(finString)+1; // FIXME : Should NOT be +1
     321   
     322    nomDeLogiciel prog = nomDeLogiciel ( sections[a]->getSoftwareCurrentText().toUTF8());
     323    dtmanage_->addSectionToExecute(pspa_->getBeamLine()->getAbstractElement(debut),
     324                                   debut,
     325                                   pspa_->getBeamLine()->getAbstractElement(fin),
     326                                   fin,
     327                                   dtmanage_->createSoftwareConnexion(prog));
     328   
     329    diagnosticErrors = "";
     330    diagnosticWarnings = "";
     331
     332    // check sections
     333    for (int i=debut-1; i<fin; i++) {
     334      if (pspa_->getBeamLine()) {
     335        if (pspa_->getBeamLine()->getAbstractElement(i)) {
     336          trivaluedBool tb = pspa_->getBeamLine()->getAbstractElement(i)->setSoftware(prog.getString());
     337          if (tb  == TBoolError ) {
     338            diagnosticErrors += pspa_->getBeamLine()->getAbstractElement(i)->getLabel() + " is not allowed with "+ prog.getString()+"<br /> ";
     339
     340            caMarche = false;
     341
     342            // intialize thissoftware
     343            pspa_->getBeamLine()->getAbstractElement(i)->setSoftware(nomDeLogiciel::unknownSoftware);
     344
     345          } else if ( tb == TBoolIgnore ) {
     346            diagnosticWarnings += pspa_->getBeamLine()->getAbstractElement(i)->getLabel() + " will be ignored by  "+ prog.getString()+"<br /> ";
     347           
     348
     349          }
     350          pspa_->getBeamLine()->update(i);
     351        }
    299352      }
    300353    }
    301 
    302   if ( tbResume == TBoolError ) {
    303     GWt_dialog calculDialog("PSPA check execute : ERROR", diagnostic , GWt_dialog::Error,true,true);
    304     calculDialog.exec();
    305   } else if (tbResume == TBoolIgnore ) {
    306     GWt_dialog calculDialog("PSPA check execute : WARNING", diagnostic , GWt_dialog::Warning,false,true);
    307     calculDialog.exec();
    308   }
    309 
    310   /*
    311     } else if ( essai == warning )  {
    312     GWt_dialog calculDialog("PSPA check execute : warning ", diagnostic , GWt_dialog::Warning, false,true);
    313     calculDialog.exec();
    314   */
     354    // set errors and warnings
     355    sections[a]->setErrors(diagnosticErrors);
     356    sections[a]->setWarnings(diagnosticWarnings);
     357  }
    315358   
    316359  return caMarche;
     
    319362void GWt_softwarePanel::deleteSectionToExecuteW()
    320363{
    321   if ( selectedSections_.empty() ) return;
    322   //  disableSectionExecute();
    323   selectedSections_.back()->ligneDeWidget->clear();
    324   delete selectedSections_.back()->ligneDeWidget;
    325   selectedSections_.pop_back();
    326 }
    327 
    328 
    329 void GWt_softwarePanel::updateSelections()
    330 {
    331   string premierText, dernierText;
    332   if ( selectedSections_.size() > 0 )
    333     {
    334       premierText = dtmanage_->getLabelFromElementNumero(1);
    335       dernierText = dtmanage_->getLabelFromElementNumero( dtmanage_->getBeamLineSize() );
    336       (*selectedSections_.begin())->debut->setText(premierText);
    337       (*selectedSections_.begin())->fin->setText(dernierText);
    338     }
    339  
    340   cout << "PspaApplication::updateSelections(): " << premierText << " à  " << dernierText << endl;
    341 }
    342 
    343 
    344 string GWt_softwarePanel::getSelection()
     364  if ( dtmanage_->getJobListSize() == 0 ) return;
     365  // delete from dataManager
     366  dtmanage_->clearSectionToExecute(dtmanage_->getJobListSize()-1);
     367
     368  // delete from User Interface
     369  sections.pop_back();
     370}
     371
     372
     373void GWt_softwarePanel::updateSections()
     374{
     375  // update all sections in order to manage new/deleted items
     376  for (int a = 0; a< sections.size(); a++) {
     377    fillComboWithElements(sections[a]->getFirstElement());
     378    fillComboWithElements(sections[a]->getLastElement());
     379  }
     380  if (sections.size() == 0) {
     381    return;
     382  }
     383  // the first element will always be the first element of the beamLine
     384  sections[0]->getFirstElement()->setCurrentIndex(0);
     385 
     386  // the last element will always be the last element of the beamLine
     387  sections[sections.size()-1]->getLastElement()->setCurrentIndex(sections[sections.size()-1]->getLastElement()->count());
     388
     389  // set default values
     390
     391  // update
     392  updateSectionSelection();
     393}
     394
     395
     396
     397/*
     398 string GWt_softwarePanel::getSelection()
    345399{
    346400  list<GWt_sectionToExecute*>::iterator itr = selectedSections_.begin();
     
    348402  return str;
    349403}
    350 
     404*/
    351405
    352406void GWt_softwarePanel::executer()
    353407{
    354408
    355   if ( !updateSectionSelection() ) return;
    356 
    357 
    358     if (!areDataCoherent()) {
    359       //    GWt_dialog warningDialog("PSPA : verification des sections", " donnees incoherentes !", GWt_dialog::Error,true,true);
    360       //    warningDialog.exec();
    361       //    exec_go_->setDisabled(true);
     409  if (!areDataCoherent()) {
     410    //    GWt_dialog warningDialog("PSPA : verification des sections", " donnees incoherentes !", GWt_dialog::Error,true,true);
     411    //    warningDialog.exec();
     412    //    exec_go_->setDisabled(true);
    362413    return;
    363     }
    364 
     414  }
     415 
    365416  // GWt_console* console = NULL;
    366417  // if (static_cast<GWt_console*> (wApp->findWidget ("console"))) {
     
    385436  pspa_->faireDessin();
    386437}
     438
     439
     440void GWt_softwarePanel::fillComboWithElements(Wt::WComboBox* cBox) {
     441  if (cBox == NULL) return;
     442
     443  // get the last item selected
     444  WString selectedString = cBox->currentText ();
     445  cBox->clear();
     446
     447  for (int a=0; a< pspa_->getBeamLine()->getBeamLineSize(); a++) {
     448    abstractElement* abs = pspa_->getBeamLine()->getAbstractElement(a);
     449    if (abs != NULL){
     450      cBox->addItem(abs->getLabel());
     451    }
     452  }
     453 
     454  for (int a=0; a<cBox->count(); a++) {
     455    if (cBox->itemText (a) == selectedString) {
     456      cBox->setCurrentIndex(a);
     457    }
     458  }
     459}
     460
     461
     462void GWt_softwarePanel::fillComboWithSoftwares(Wt::WComboBox* cBox) {
     463  if (cBox == NULL) return;
     464  cBox->clear();
     465
     466  unsigned nb = nomDeLogiciel::getNumberOfSoftwares();
     467  unsigned k;
     468  for(k = 0; k < nb; k++) {
     469    cBox->addItem(nomDeLogiciel(k).getString());
     470  }
     471 
     472}
     473
     474
     475Wt::WContainerWidget* GWt_softwarePanel::createAddDeletePushButtons() {
     476
     477  WContainerWidget* buttonContainer= new WContainerWidget();
     478 
     479  Wt::WHBoxLayout* buttonContainerLayout = new Wt::WHBoxLayout();
     480  buttonContainerLayout->setContentsMargins(0,0,0,0);
     481  // preparation du bouton add
     482  WPushButton* exec_add = new WPushButton("+");
     483  exec_add->clicked().connect(this, &GWt_softwarePanel::addSectionToExecuteW);
     484  exec_add->setStyleClass("roundButton");
     485  exec_add->setMaximumSize(20,20);
     486  exec_add->setToolTip("Add new section");
     487 
     488  // preparation du bouton delete
     489  WPushButton* exec_delete = new WPushButton("-");
     490  //  warningsContainer_->setStyleClass("warningsContainer");
     491  exec_delete->clicked().connect(this, &GWt_softwarePanel::deleteSectionToExecuteW);
     492  exec_delete->setStyleClass("roundButton");
     493  exec_delete->setMaximumSize(20,20);
     494  exec_add->setToolTip("Remove this section");
     495
     496  buttonContainerLayout->addWidget(exec_add);
     497  buttonContainerLayout->addWidget(exec_delete);
     498
     499  buttonContainer->setLayout(buttonContainerLayout);
     500
     501  return buttonContainer;
     502}
Note: See TracChangeset for help on using the changeset viewer.