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

systeme periodique (mailles) + multipoles + madx

Location:
Interface_Web/trunk/pspaWT/sources/userInterface
Files:
4 added
13 edited

Legend:

Unmodified
Added
Removed
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_abstractElement.h

    r365 r431  
    33
    44#include "GWt_draggableImage.h"
     5#include "GWt_console.h"
     6
    57#include "abstractElement.h"
    6 #include "GWt_console.h"
    78#include "elementDrift.h"
    89#include "elementRfgun.h"
     
    1314#include "elementFit.h"
    1415#include "elementSnapshot.h"
     16#include "elementMultipole.h"
    1517
    1618#include <Wt/WDialog>
     
    3335class GWt_abstractElement : public WContainerWidget
    3436{
    35     protected :
     37 protected :
    3638   
    37     abstractElement* abstractElement_;
     39  abstractElement* abstractElement_;
    3840   
    39     WDialog* dialog_;
    40     GWt_draggableImage* dropped_;
    41     WContainerWidget* wc_;
    42     WText* wc_item_;
    43     WLineEdit* labelEdit_;
     41  WDialog* dialog_;
     42  GWt_draggableImage* dropped_;
     43  WContainerWidget* wc_;
     44  WText* wc_item_;
     45  WLineEdit* labelEdit_;
    4446   
    45     GWt_abstractElement() {;}
    46     string* beginDialog();
    47    
    48     public :
    49    
    50     GWt_abstractElement(abstractElement*);
    51    
    52     void initialize();
    53     void showParameters();
    54     void deleteElement();
     47  GWt_abstractElement() {;}
     48  string* beginDialog();
     49 
     50 public :
     51 
     52  GWt_abstractElement(abstractElement*);
     53 
     54  void initialize();
     55  void showParameters();
     56  void deleteElement();
     57 
     58  void updateLabelAndToolTipWidget();
     59  void FileInput(ifstream& ifs);
     60 
     61  WContainerWidget* getWidget();
     62  abstractElement* getAbstractElement();
    5563
    56     void updateLabelAndToolTipWidget();
    57     void FileInput(ifstream& ifs);
    58    
    59     //  GWt_draggableImage* getImage();
    60     WContainerWidget* getWidget();
    61     abstractElement* getAbstractElement();
    62    
    63     virtual void dialogDone(WDialog::DialogCode code) = 0;
    64    
    65     inline WString print() {
    66         return abstractElement_->print();
    67     }
    68    
    69     virtual string getMimeType() = 0;
    70     virtual string getSmallImageURL() = 0;
    71     virtual string getBigImageURL() = 0;
    72     virtual string getName() = 0;
    73     virtual void initilializeDialog() = 0;
    74    
    75     void createDragImage(WContainerWidget*);
    76     WImage* getImage();
    77    
    78 protected:
    79    
     64  inline WString print() {
     65    return abstractElement_->print();
     66  }
     67
     68  virtual void dialogDone(WDialog::DialogCode code) = 0;
     69  virtual string getMimeType() = 0;
     70  virtual string getSmallImageURL() = 0;
     71  virtual string getBigImageURL() = 0;
     72  virtual string getName() = 0;
     73  virtual void initilializeDialog() = 0;
     74 
     75  void createDragImage(WContainerWidget*);
     76  WImage* getImage();
     77 
     78 protected:
     79 
    8080    WImage* image_;
    8181    GWt_elementLigneFaisceau* elementLigneFaiseauContainer_;
     
    8686   
    8787    inline void registerParam(string name, variant<int, string, bool, float, NullType> value, string desc) {
    88         parameterMapValue[name] = value;
    89         parameterMapDescription[name] = desc;
     88      parameterMapValue[name] = value;
     89      parameterMapDescription[name] = desc;
    9090    }
    9191   
    92     variant<int, string, bool, float, NullType> getParamValue(string elem);
    93     string getParamDescription(string elem);
     92    variant<int, string, bool, float, NullType> getParamValue(string);
     93    string getParamDescription(string);
    9494};
    9595#endif
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_abstractElementFactory.h

    r343 r431  
    1818#include "GWt_fit.h"
    1919#include "GWt_snapshot.h"
     20#include "GWt_mpole.h"
    2021
    2122using namespace Wt;
     
    6263  inline void setSnapshotEnable(bool a) { isSnapshotElementEnable = a;};
    6364 
     65  /* Enable the mpole element creation
     66   */
     67  inline void setMPoleEnable(bool a) { isMPoleElementEnable = a;};
     68 
    6469  GWt_drift* createDriftElement();
    6570  GWt_rfgun* createRFGunElement();
     
    7075  GWt_fit* createFitElement();
    7176  GWt_snapshot* createSnapshotElement();
     77  GWt_mpole* createMPoleElement();
    7278  vector <GWt_abstractElement*> getAllElements();
    7379 
     
    8288  bool isFitElementEnable;
    8389  bool isSnapshotElementEnable;
     90  bool isMPoleElementEnable;
    8491};
    8592#endif
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_globalParameters.h

    r428 r431  
    3939  void updateGlobals();
    4040  void renew();
    41   void setText(WContainerWidget*);
     41  void setText(WText*);
    4242};
    4343#endif
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_pspaApplication.h

    r426 r431  
    33
    44#include <cstdlib>
    5 #include <list>
     5#include <string.h>
     6#include <vector>
    67
    78#include <Wt/WApplication>
     
    910#include <Wt/WContainerWidget>
    1011#include <Wt/WText>
     12#include <Wt/WLineEdit>
    1113#include <Wt/WPanel>
    1214#include <Wt/WComboBox>
     
    2426#include "GWt_ligneFaisceau.h"
    2527#include "GWt_globalParameters.h"
     28#include "GWt_sectorParameters.h"
    2629
    2730#include "dataManager.h"
     
    4346  GWt_LigneFaisceau* beamLine_;
    4447   
    45   // WWidget* globalParam_;
    46   GWt_globalParameters* globalParam_; // xx
     48  GWt_globalParameters* globalParam_;
     49  GWt_sectorParameters* sectorParam_;
    4750 
    4851  GWt_dialog* graphicsDialog_;
     
    7376  WContainerWidget* createDrawingWidget();
    7477
    75   //WWidget* createGlobalParamWidget();
    76   WWidget* createDashBoard(); // xx
    77   void messageBox1(); // xx
    78   void messageBox2(); // xx
     78  WWidget* createDashBoard();
     79  void messageBox1();
     80  void messageBox2();
    7981 
    8082  // extensions (.001, .002,...) pour les fichiers "snapshot"
     
    119121  }
    120122
    121 
    122   /* inline WWidget* getGlobalParam() { */
    123   /*   return globalParam_; */
    124   /* } */
    125 
    126123  inline GWt_softwarePanel* getExecuteWidget() {
    127124    return executeWidget_;
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_softwarePanel.h

    r407 r431  
    2323class GWt_softwarePanel  : public WContainerWidget
    2424{
    25     public :
    26     GWt_softwarePanel(dataManager*, PspaApplication*);
    27     virtual ~GWt_softwarePanel();
     25 public :
     26 
     27  GWt_softwarePanel(dataManager*, PspaApplication*);
     28  virtual ~GWt_softwarePanel();
    2829
    29     void addSectionToExecuteW();
    30     void updateSections();
     30  void addSectionToExecuteW();
     31  void updateSections();
    3132   
    32     private :
    33     //    void disableSectionExecute();
    34     //    void checkSectionSelection();
    35     bool updateSectionSelection();
    36     void deleteSectionToExecuteW(int section);
    37     string getSelection();
    38     void executer();
    39     bool areDataCoherent();
    40     void fillComboWithElements(Wt::WComboBox* cBox);
    41     void fillComboWithSoftwares(Wt::WComboBox* cBox);
    42     Wt::WContainerWidget* createAddDeletePushButtons(int sectionIndex);
     33 private :
     34 
     35  bool updateSectionSelection();
     36  void deleteSectionToExecuteW(int section);
     37  string getSelection();
     38  void executer();
     39  bool areDataCoherent();
     40  void fillComboWithElements(Wt::WComboBox* cBox);
     41  void fillComboWithSoftwares(Wt::WComboBox* cBox);
     42  Wt::WContainerWidget* createAddDeletePushButtons(int sectionIndex);
    4343
    44     dataManager* dtmanage_;
    45     WPushButton *exec_go_;
    46     WContainerWidget* contenuSections_;
    47     PspaApplication* pspa_;
     44  dataManager* dtmanage_;
     45  WPushButton *exec_go_;
     46  WContainerWidget* contenuSections_;
     47  PspaApplication* pspa_;
    4848
    49     std::vector <GWt_sectionToExecute*> sections_;
     49  std::vector <GWt_sectionToExecute*> sections_;
    5050};
    51 
    5251#endif /* defined(__PSPA__GWt_softwarePanel__) */
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_abstractElement.cc

    r418 r431  
    1414#include "GWt_beam.h"
    1515#include "GWt_fit.h"
    16 #include "GWt_snapshot.h"
     16//#include "GWt_snapshot.h"
     17
    1718#include "GWt_draggableImage.h"
    1819#include "GWt_ligneFaisceau.h"
     
    2930
    3031GWt_abstractElement::GWt_abstractElement(abstractElement* elem)
    31 : WContainerWidget()
     32  : WContainerWidget()
    3233{
    33     abstractElement_ = elem;
     34  abstractElement_ = elem;
    3435}
    35 
    3636
    3737void GWt_abstractElement::initialize()
    3838{
    39     // make image
    40     image_ = new WImage(getBigImageURL(),this);
    41    
    42     addWidget(image_);
    43     updateLabelAndToolTipWidget();
     39  image_ = new WImage(getBigImageURL(),this); // make image 
     40  addWidget(image_);
     41  updateLabelAndToolTipWidget();
    4442}
    45 
    4643
    4744string* GWt_abstractElement::beginDialog()
    4845{
    49   string* param = abstractElement_-> getParametersString();
    50    
    51   if ( param == NULL )
    52     {
    53       if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
    54         GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
    55         console->addConsoleMessage(" GWt_abstractElement::beginDialog : empty parameter set for element " + abstractElement_->getNomdElement().getExpandedName());
    56         }
     46  string* param = abstractElement_->getParametersString();
     47 
     48  if ( param == NULL ) {
     49    if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
     50      GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
     51      console->addConsoleMessage(" GWt_abstractElement::beginDialog : empty parameter set for element " + abstractElement_->getNomdElement().getExpandedName());
    5752    }
    58   //   int compteur = -1;
     53  }
     54
     55  int nbparam = atoi(param->c_str());
     56  if ( nbparam != abstractElement_->getNbParams()) {
     57    if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
     58      GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
     59      console->addConsoleMessage(" element seems not to be a " + abstractElement_->getNomdElement().getExpandedName());
     60    }
     61  }
    5962 
    60   //  int nbparam = atoi(param[++compteur].c_str());
    61   int nbparam = atoi(param->c_str());
    62   if ( nbparam != abstractElement_->getNbParams())
    63     {
    64         if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
    65           GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
    66           console->addConsoleMessage(" element seems not to be a " + abstractElement_->getNomdElement().getExpandedName());
    67         }
    68     }
    69  
    70   dialog_ = new WDialog("element " + abstractElement_->getNomdElement().getExpandedName());
    71     new WText(" label of the element : ",dialog_->contents());
    72     //  labelEdit_ = new WLineEdit(param[++compteur].c_str(), dialog_->contents());
    73    
    74     labelEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());
    75     new WBreak(dialog_->contents());
    76     return ++param;
     63  dialog_ = new WDialog("element "+abstractElement_->getNomdElement().getExpandedName());
     64  new WText(" label of the element : ",dialog_->contents());
     65  labelEdit_ = new WLineEdit( (++param)->c_str(),dialog_->contents());
     66  new WBreak(dialog_->contents());
     67  return ++param;
    7768}
    7869
    7970void GWt_abstractElement::updateLabelAndToolTipWidget()
    8071{
    81     if (abstractElement_ != NULL) {
     72  if (abstractElement_ != NULL) {
    8273    elementLigneFaiseauContainer_->setElementLabel(abstractElement_->getLabel());
    8374    setToolTip(print());
    84     }
     75  }
    8576}
    8677
     
    9182}
    9283
    93 
    9484void GWt_abstractElement::deleteElement()
    9585{
    96     StandardButton result = WMessageBox::show("PSPA : Delete element", WString("Delete '")+WString(getAbstractElement()->getLabel())+"' ?", Ok | Cancel);
     86  StandardButton result = WMessageBox::show("PSPA : Delete element", WString("Delete '")+WString(getAbstractElement()->getLabel())+"' ?", Ok | Cancel);
     87 
     88  if (result == Cancel) {
     89    return;
     90  }
     91  // get LigneFaiseau widget and add new elementLigneFaiseau
     92  GWt_LigneFaisceau* ligneFaisceau = NULL;
     93  if ( static_cast<GWt_LigneFaisceau*> (wApp->findWidget ("ligneFaisceau"))) {
     94    ligneFaisceau = static_cast<GWt_LigneFaisceau*> (wApp->findWidget ("ligneFaisceau"));
     95  } else {
     96    return;
     97  }
     98 
     99  ligneFaisceau->removeElement(this);
     100}
    97101
    98     if (result == Cancel ) {
    99         return;
    100     }
    101     // get LigneFaiseau widget and add new elementLigneFaiseau
    102     GWt_LigneFaisceau* ligneFaisceau = NULL;
    103     if ( static_cast<GWt_LigneFaisceau*> (wApp->findWidget ("ligneFaisceau"))) {
    104         ligneFaisceau = static_cast<GWt_LigneFaisceau*> (wApp->findWidget ("ligneFaisceau"));
    105     } else {
    106         return;
    107     }
    108    
    109     ligneFaisceau->removeElement(this);
     102void GWt_abstractElement::createDragImage(WContainerWidget* w)
     103{
     104  GWt_draggableImage *result= new GWt_draggableImage(getBigImageURL(),w);
     105 
     106  /*
     107   * Set the image to be draggable, showing the other image (dragImage)
     108   * to be used as the widget that is visually dragged.
     109   */
     110  result->setDraggable(getMimeType(),new WImage(getSmallImageURL(),w),true);
     111  result->setToolTip(getName());
     112}
     113
     114void GWt_abstractElement::FileInput(ifstream& ifs)
     115{
     116  getAbstractElement()->FileInput(ifs);
     117  initilializeDialog();
     118  updateLabelAndToolTipWidget();
     119 
     120  // update parameters
     121  GWt_LigneFaisceau* ligneFaisceau = NULL;
     122  if ( static_cast<GWt_LigneFaisceau*> (wApp->findWidget ("ligneFaisceau"))) {
     123    ligneFaisceau = static_cast<GWt_LigneFaisceau*> (wApp->findWidget ("ligneFaisceau"));
     124    ligneFaisceau->update();
     125  }
     126}
     127
     128abstractElement* GWt_abstractElement::getAbstractElement() {
     129  return abstractElement_;
    110130}
    111131
    112132WContainerWidget* GWt_abstractElement::getWidget() {
    113     return wc_;
    114 }
    115 
    116 abstractElement* GWt_abstractElement::getAbstractElement() {
    117     return abstractElement_;
    118 }
    119 
    120 
    121 void GWt_abstractElement::createDragImage(WContainerWidget* w){
    122 
    123     GWt_draggableImage *result = new GWt_draggableImage(getBigImageURL(),w);
    124 
    125     /*
    126      * Set the image to be draggable, showing the other image (dragImage)
    127      * to be used as the widget that is visually dragged.
    128      */
    129     result->setDraggable(getMimeType(),new WImage(getSmallImageURL(),w),true);
    130     result->setToolTip(getName());
    131 
     133  return wc_;
    132134}
    133135
    134136WImage* GWt_abstractElement::getImage() {
    135     return image_;
     137  return image_;
    136138}
    137139
    138 
    139 void GWt_abstractElement::FileInput(ifstream& ifs){
    140     getAbstractElement()->FileInput(ifs);
    141     initilializeDialog();
    142     updateLabelAndToolTipWidget();
    143 
    144 // update parameters
    145     GWt_LigneFaisceau* ligneFaisceau = NULL;
    146     if ( static_cast<GWt_LigneFaisceau*> (wApp->findWidget ("ligneFaisceau"))) {
    147         ligneFaisceau = static_cast<GWt_LigneFaisceau*> (wApp->findWidget ("ligneFaisceau"));
    148         ligneFaisceau->update();
     140variant<int, string, bool, float, NullType> GWt_abstractElement::getParamValue(string elem)
     141{
     142  if(parameterMapValue.find(elem) == parameterMapValue.end()) {
     143    return new NullType();
     144  }
     145 
     146  std::map<std::string, variant<int, string, bool, float, NullType> >::iterator it;
     147  it = parameterMapValue.find(elem);
     148  variant <int, string, bool, float, NullType> value = it->second;
     149 
     150  try {
     151    int pi = boost::get<int>(value);
     152    printf("%s Type is int\n",elem.c_str());
     153    return pi;
     154  }
     155  catch (boost::bad_get v) {
     156    try {
     157      string si = boost::get<string>(value);
     158      printf("%s Type is string\n",elem.c_str());
     159      return si;
    149160    }
     161    catch (boost::bad_get v) {
     162      try {
     163        bool bi = boost::get<bool>(value);
     164        printf("%s Type is bool\n",elem.c_str());
     165        return bi;
     166      }
     167      catch (boost::bad_get v) {
     168        printf("%s Type is NULL\n",elem.c_str());
     169        return new NullType();
     170      }
     171    }
     172  }
     173  printf("%s Type is NULL NULL\n",elem.c_str());
     174  return new NullType();
    150175}
    151176
    152 
    153 
    154 variant<int, string, bool, float, NullType> GWt_abstractElement::getParamValue(string elem) {
    155 
    156     if (parameterMapValue.find(elem) == parameterMapValue.end() )
    157     {
    158         return new NullType();
    159     }
    160 
    161     std::map<std::string, variant<int, string, bool, float, NullType> >::iterator it;
    162     it = parameterMapValue.find(elem);
    163    
    164     variant <int, string, bool, float, NullType> value = it->second;
    165    
    166     try {
    167         int pi = boost::get<int>(value);
    168         printf("%s Type is int\n",elem.c_str());
    169         return pi;
    170     }
    171     catch (boost::bad_get v) {
    172         try {
    173             string si = boost::get<string>(value);
    174             printf("%s Type is string\n",elem.c_str());
    175             return si;
    176         }
    177         catch (boost::bad_get v) {
    178             try {
    179                 bool bi = boost::get<bool>(value);
    180                 printf("%s Type is bool\n",elem.c_str());
    181                 return bi;
    182             }
    183             catch (boost::bad_get v) {
    184                 printf("%s Type is NULL\n",elem.c_str());
    185                 return new NullType();
    186             }
    187         }
    188     }
    189     printf("%s Type is NULL NULL\n",elem.c_str());
    190     return new NullType();
     177string GWt_abstractElement::getParamDescription(string elem)
     178{   
     179  if(parameterMapDescription.find(elem) == parameterMapDescription.end() ) {
     180    printf("%s Descr is NULL NULL\n",elem.c_str());
     181    return "";
     182  } else {
     183    printf("%s Descr is %s\n",elem.c_str(),parameterMapDescription.find(elem)->second.c_str());
     184    return parameterMapDescription.find(elem)->second;
     185  }
    191186}
    192 
    193 
    194 string GWt_abstractElement::getParamDescription(string elem) {
    195    
    196     if (parameterMapDescription.find(elem) == parameterMapDescription.end() )
    197     {
    198         printf("%s Descr is NULL NULL\n",elem.c_str());
    199         return "";
    200     } else {
    201         printf("%s Descr is %s\n",elem.c_str(),parameterMapDescription.find(elem)->second.c_str());
    202         return parameterMapDescription.find(elem)->second;
    203     }
    204 }
    205 
    206 
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_abstractElementFactory.cc

    r401 r431  
    1717  isBeamElementEnable(false),
    1818  isFitElementEnable(false),
    19   isSnapshotElementEnable(false)
     19  isSnapshotElementEnable(false),
     20  isMPoleElementEnable(false)
    2021{}
    2122
     
    3031  isFitElementEnable = false;
    3132  isSnapshotElementEnable = false;
     33  isMPoleElementEnable = false;
    3234}
    3335
     
    9698}
    9799
     100GWt_mpole* GWt_abstractElementFactory::createMPoleElement()
     101{
     102  if (isMPoleElementEnable) {
     103    return new GWt_mpole();
     104  }
     105  return NULL;
     106}
     107
    98108vector <GWt_abstractElement*> GWt_abstractElementFactory::getAllElements()
    99109{
     
    123133    elems.push_back(new GWt_snapshot());
    124134  }
     135  if (isMPoleElementEnable) {
     136    elems.push_back(new GWt_mpole());
     137  }
    125138
    126139  return elems;
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_elementLigneFaisceau.cc

    r418 r431  
    1313#include "GWt_fit.h"
    1414#include "GWt_snapshot.h"
     15#include "GWt_mpole.h"
    1516
    1617
     
    5556void GWt_elementLigneFaisceau::initialize_ligneFaisceau(nomdElements::typedElement eType)
    5657{   
    57   cout<<"new GWt_elementLigneFaisceau : "<< this << endl;
     58  cout << " new GWt_elementLigneFaisceau : "<< nomdElements::getLabelFromType(eType) << endl;
    5859   
    5960  // set layout
     
    113114  case nomdElements::fit  :
    114115    GWt_abstractElement_ = new GWt_fit(this);
     116    break;
     117  case nomdElements::mpole  :
     118    GWt_abstractElement_ = new GWt_mpole(this);
    115119    break;
    116120  case nomdElements::snapshot :
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_globalParameters.cc

    r428 r431  
    1515}
    1616
    17 void GWt_globalParameters::setText(WContainerWidget* wt)
     17void GWt_globalParameters::setText(WText *st)
    1818{
    19   status_ = new WText("Go ahead...",wt);
     19  status_ = st;
    2020}
    2121
     
    105105void GWt_globalParameters::setStatus()
    106106{
    107   WString out= WString("<p>frequency="+envoi_[1]+"</p>"
    108                        "<p>step in phase="+envoi_[2]+"</p>"
    109                        "<p>max step number="+envoi_[3]+"</p>"
    110                        "<p>periodicity of s.c. computation="+envoi_[4]+"</p>");
     107  WString out= WString("<p>frequency = "+envoi_[1]+"</p>"
     108                       "<p>step in phase = "+envoi_[2]+"</p>"
     109                       "<p>max step number = "+envoi_[3]+"</p>"
     110                       "<p>periodicity of s.c. computation = "+envoi_[4]+"</p>");
    111111  status_->setText(out);
    112112}
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_ligneFaisceau.cc

    r418 r431  
    5959
    6060  GWt_abstractElement* GWtAbstractElem = NULL; 
    61   cout << " Entree addElement element " << nomdElements::getLabelFromType(eType) << endl;
     61  cout << " addElement::element : " << nomdElements::getLabelFromType(eType) << endl;
    6262   
    6363  // 3 cases :
     
    288288
    289289
    290 void GWt_LigneFaisceau::initializeSoftwares(){
    291    
     290void GWt_LigneFaisceau::initializeSoftwares()
     291{   
    292292  vector <abstractElement*> elems = getAllAbstractElements();
    293     for (int a=0; a< elems.size(); a++) {
    294       //     elems[a]->setSoftware(nomDeLogiciel::unknownSoftware);
    295       elems[a]->setSoftware( NULL );
    296     }
    297 }
    298 
    299 
     293  cout << "GWt_LigneFaisceau::initializeSoftwares() " << elems.size() << endl;
     294
     295  for (int a = 0; a < elems.size(); a++) {
     296    elems[a]->setSoftware( NULL );
     297  }
     298}
     299
     300
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc

    r428 r431  
    11#include <stdio.h>
    2 #include <string.h>
    3 #include <vector>
    42#include <ctime>
    53
    64#include "GWt_pspaApplication.h"
    7 #include "GWt_ligneFaisceau.h"
    8 #include "GWt_softwarePanel.h"
    9 #include "GWt_globalParameters.h"
    105#include "GWt_draggableImage.h"
     6#include "GWt_serverFileSelector.h"
    117#include "particleBeam.h"
    128#include "bareParticle.h"
     
    1511#include "nomdElements.h"
    1612#include "environmentVariables.h"
    17 #include "GWt_console.h"
    18 #include "GWt_serverFileSelector.h"
    1913#include "trivaluedBool.h"
    2014
     
    2620#include <Wt/WStackedWidget>
    2721#include <Wt/WBreak>
    28 #include <Wt/WDialog>
    2922#include <Wt/WStandardItemModel>
    3023#include <Wt/WFileUpload>
    3124#include <Wt/WPainter>
    32 #include <Wt/WPdfImage>
    3325#include <Wt/WScrollArea>
    34 #include <Wt/WLineEdit>
    3526#include <Wt/WRadioButton>
    36 
    37 #include <Wt/WPanel>
    3827#include <Wt/WMessageBox>
    3928
     
    7362  abstractElementFactory_->setFitEnable(true);
    7463  abstractElementFactory_->setSnapshotEnable(true);
    75  
    76   // include the styleSheet
     64  abstractElementFactory_->setMPoleEnable(true);
     65 
     66  // include the styleSheetcd
    7767  WContainerWidget *widroot = root();
    7868  useStyleSheet("htdocs/pspa.css");
     
    144134
    145135  globalParam_ = new GWt_globalParameters(dtmanage_);
     136  sectorParam_ = new GWt_sectorParameters(dtmanage_);
    146137  WWidget* dboard = createDashBoard();
    147138  dboard->setMinimumSize(300,100);
     
    171162}
    172163
    173 // WWidget* PspaApplication::createGlobalParamWidget()
    174 // {
    175 //   WContainerWidget* globalParam = new GWt_globalParameters(this);
    176 //   globalParam->setMinimumSize(300,100);
    177 //   return globalParam;
    178 // }
    179 
    180164WWidget* PspaApplication::createDashBoard()
    181165{
    182   WContainerWidget *result = new WContainerWidget();
    183  
    184   WPanel *panel = new WPanel(result);
    185   panel->setTitle("dashboard");
    186  
    187   WContainerWidget *textdiv;
    188   textdiv = new WContainerWidget();
    189   textdiv->setStyleClass("text");
    190   globalParam_->setText(textdiv);
    191 
    192   WContainerWidget *cnt = new WContainerWidget();
     166  WContainerWidget *wt= new WContainerWidget();
     167  wt->setStyleClass("text");
     168  WText *st= new WText("Go ahead...",wt); 
     169
    193170  WContainerWidget *buttons = new WContainerWidget();
    194171  buttons->setStyleClass("buttons");
    195 
    196172  WPushButton *button;
    197   button = new WPushButton("globalParameters", buttons);
     173  button = new WPushButton("globalParameters",buttons);
    198174  button->clicked().connect(this, &PspaApplication::messageBox1);
    199  
    200   button = new WPushButton("fodoCells", buttons);
     175  button = new WPushButton("sectorParameters", buttons);
    201176  button->clicked().connect(this, &PspaApplication::messageBox2);
    202177 
     
    205180  styleSheet().addRule("body", "margin: 0px;");
    206181
     182  WContainerWidget *cnt = new WContainerWidget();
    207183  cnt->addWidget(buttons);
    208   cnt->addWidget(textdiv);
     184  cnt->addWidget(wt);
     185
     186  WContainerWidget *result = new WContainerWidget();
     187  WPanel *panel = new WPanel(result);
     188  panel->setTitle("dashboard");
    209189  panel->setCentralWidget(cnt);
     190
     191  globalParam_->setText(st);
     192  sectorParam_->setText(st);
    210193  return result;
    211194}
     
    219202void PspaApplication::messageBox2()
    220203{
     204  sectorParam_->execDialog();
    221205  return;
    222206}
     
    382366void PspaApplication::sauver()
    383367{
    384   cout << " on sauve " << endl;
    385   console_->addConsoleMessage("sauvegarde");
    386  
     368  cout << "***********************************" << endl;
     369  cout << " on sauve " << endl<<endl;
     370 
     371  console_->addConsoleMessage("sauvegarde \n"); 
    387372  dialogSave_ = new WDialog("save");
    388373  new WText("name of case : ",dialogSave_->contents());
     
    405390  dialogSave_ = NULL;
    406391
    407   globalParam_->updateGlobals();
     392  //globalParam_->updateGlobals();
    408393
    409394  //  dtmanage_->saveConfiguration(nameOfCase_);
     
    416401void PspaApplication::restaurer()
    417402{
     403  cout << "***********************************" << endl;
     404  cout << " on restaure " << endl<<endl;
     405
    418406  GWt_serverFileSelector * fs = new GWt_serverFileSelector("Select a configuration file",workingDir_);
    419407  string fileName = fs->exec();
     
    423411  }
    424412   
    425   removePathFromConfigName(nameOfCase_ );
     413  removePathFromConfigName(nameOfCase_);
    426414  cout << " nom sans path " << nameOfCase_ << endl;
    427415  removeExtensionFromConfigName(nameOfCase_);
    428416  cout << " nom sans extension " << nameOfCase_ << endl;
    429   if (nameOfCase_ == "")
    430     return;
    431   cout << " PspaApplication:: restaure le fichier " << fileName << endl;
     417  if (nameOfCase_ == "") return;
     418  cout << " PspaApplication::restaure le fichier   : " << fileName << endl;
    432419  dialogSave_ = NULL;
    433420 
     
    442429  }
    443430 
    444   globalParam_->renew(); 
     431  globalParam_->renew();
     432  sectorParam_->renew();
    445433  console_->addConsoleMessage(string("restauration terminee \n"));
    446434}
     
    448436void PspaApplication::openFileSelector()
    449437{
    450    
    451438  WContainerWidget *result = new WContainerWidget();
    452   WVBoxLayout* myLayout = new WVBoxLayout();
    453    
     439  WVBoxLayout* myLayout = new WVBoxLayout(); 
    454440  uploadFileSelectorWidget_ = new WFileUpload();
    455    
    456441  uploadFileSelectorWidget_->setFileTextSize(40);
    457    
    458442  myLayout->addWidget(new WText("Select the configuration file for pspa : "));
    459443  myLayout->addWidget(uploadFileSelectorWidget_);
    460    
    461444  result->setLayout (myLayout);
    462445   
     
    470453  uploadFileSelectorWidget_->fileTooLarge().connect(this, &PspaApplication::fileTooLarge);
    471454 
    472  
    473455  GWt_dialog* fileSelectorDialog = new GWt_dialog("Load a file",result,false);
    474  
    475456  fileSelectorDialog->exec();
    476457}
     
    485466  cout << " fichier client sans extension : " << nomDuFichier << endl;
    486467 
    487   if ( test )
    488     {
    489       nameOfCase_ = nomDuFichier;
    490       console_->addConsoleMessage(string("restauration..."));
     468  if ( test ) {
     469    nameOfCase_ = nomDuFichier;
     470    console_->addConsoleMessage(string("restauration..."));
    491471     
    492       if ( !dtmanage_->restoreElements(uploadFileSelectorWidget_->spoolFileName()) ) {
    493         GWt_dialog restoreWarning(" element restoring", "failure in restoring elements !", GWt_dialog::Error, false,true);
    494         restoreWarning.exec();
    495       }
     472    if ( !dtmanage_->restoreElements(uploadFileSelectorWidget_->spoolFileName()) ) {
     473      GWt_dialog restoreWarning(" element restoring", "failure in restoring elements !", GWt_dialog::Error, false,true);
     474      restoreWarning.exec();
     475    }
    496476     
    497       GWt_globalParameters* bibi = static_cast<GWt_globalParameters*>(globalParam_);
    498       bibi->renew();
    499      
    500       console_->addConsoleMessage(string("rechargement de config termine"));
    501       message->show();
    502     }
     477    globalParam_->renew();
     478    sectorParam_->renew();
     479    console_->addConsoleMessage(string("rechargement de la config termine"));
     480    message->show();
     481  }
    503482}
    504483
     
    513492  message += " bytes\n";
    514493   
    515   GWt_dialog*  messageBox= new GWt_dialog("Error during upload file" ,message ,GWt_dialog::Error,false,true);
    516  
     494  GWt_dialog*  messageBox= new GWt_dialog("Error during upload file" ,message ,GWt_dialog::Error,false,true);
    517495  messageBox->show();
    518496}
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_sectionToExecute.cc

    r407 r431  
    1616softwarePanel(sPanel)
    1717{
    18     Wt::WGridLayout* mainContainerLayout = new Wt::WGridLayout();
    19     mainContainerLayout->setContentsMargins(0,0,0,0);
     18  Wt::WGridLayout* mainContainerLayout = new Wt::WGridLayout();
     19  mainContainerLayout->setContentsMargins(0,0,0,0);
    2020
    21     Wt::WContainerWidget* labelAndComboContainer = new Wt::WContainerWidget();
    22     Wt::WVBoxLayout* labelAndComboContainerLayout = new Wt::WVBoxLayout();
    23     labelAndComboContainerLayout->setContentsMargins(0,0,0,0);
     21  Wt::WContainerWidget* labelAndComboContainer = new Wt::WContainerWidget();
     22  Wt::WVBoxLayout* labelAndComboContainerLayout = new Wt::WVBoxLayout();
     23  labelAndComboContainerLayout->setContentsMargins(0,0,0,0);
    2424
    25     Wt::WContainerWidget* labelAndComboInsideContainer = new Wt::WContainerWidget();
    26     Wt::WHBoxLayout* labelAndComboInsideContainerLayout = new Wt::WHBoxLayout();
    27     labelAndComboInsideContainerLayout->setContentsMargins(0,0,0,0);
    28    
    29     labelAndComboInsideContainerLayout->addWidget(new Wt::WText("from&nbsp;:&nbsp;"));
    30     labelAndComboInsideContainerLayout->addWidget(first);
    31     labelAndComboInsideContainerLayout->addWidget(new Wt::WText("to&nbsp;:&nbsp;"));
    32     labelAndComboInsideContainerLayout->addWidget(last);
    33     labelAndComboInsideContainerLayout->addWidget(soft);
     25  Wt::WContainerWidget* labelAndComboInsideContainer = new Wt::WContainerWidget();
     26  Wt::WHBoxLayout* labelAndComboInsideContainerLayout = new Wt::WHBoxLayout();
     27  labelAndComboInsideContainerLayout->setContentsMargins(0,0,0,0);
     28 
     29  labelAndComboInsideContainerLayout->addWidget(new Wt::WText("from&nbsp;:&nbsp;"));
     30  labelAndComboInsideContainerLayout->addWidget(first);
     31  labelAndComboInsideContainerLayout->addWidget(new Wt::WText("to&nbsp;:&nbsp;"));
     32  labelAndComboInsideContainerLayout->addWidget(last);
     33  labelAndComboInsideContainerLayout->addWidget(soft);
     34 
     35    // add buttons
     36  labelAndComboInsideContainerLayout->addWidget(buttonPanel);
     37  labelAndComboInsideContainer->setLayout(labelAndComboInsideContainerLayout);
     38  labelAndComboContainerLayout->addWidget(labelAndComboInsideContainer);
     39  labelAndComboContainerLayout->addStretch (10);
     40  labelAndComboContainer->setLayout(labelAndComboContainerLayout);
     41 
     42  // add errors and warning layout
     43  warningsContainer_ = new Wt::WContainerWidget();
     44  errorsContainer_ = new Wt::WContainerWidget();
     45 
     46  Wt::WContainerWidget* warningsAndErrorsContainer = new Wt::WContainerWidget();
     47  Wt::WVBoxLayout* vWarningsAndErrorsLayoutContainer = new Wt::WVBoxLayout();
     48 
     49  Wt::WHBoxLayout* hLayoutContainerWarnings = new Wt::WHBoxLayout();
     50  Wt::WHBoxLayout* hLayoutContainerErrors = new Wt::WHBoxLayout();
     51 
     52 
     53  warningsLabel_ = new Wt::WText("",XHTMLText);
     54  errorsLabel_ = new Wt::WText("",XHTMLText);
     55  hLayoutContainerWarnings->addWidget(warningsLabel_);
     56  hLayoutContainerErrors->addWidget(errorsLabel_);
    3457
    35     // add buttons
    36     labelAndComboInsideContainerLayout->addWidget(buttonPanel);
    37 
    38     labelAndComboInsideContainer->setLayout(labelAndComboInsideContainerLayout);
    39 
    40     labelAndComboContainerLayout->addWidget(labelAndComboInsideContainer);
    41     labelAndComboContainerLayout->addStretch (10);
    42    
    43     labelAndComboContainer->setLayout(labelAndComboContainerLayout);
    44    
    45            
    46     // add errors and warning layout
    47     warningsContainer_ = new Wt::WContainerWidget();
    48     errorsContainer_ = new Wt::WContainerWidget();
    49 
    50     Wt::WContainerWidget* warningsAndErrorsContainer = new Wt::WContainerWidget();
    51     Wt::WVBoxLayout* vWarningsAndErrorsLayoutContainer = new Wt::WVBoxLayout();
    52    
    53     Wt::WHBoxLayout* hLayoutContainerWarnings = new Wt::WHBoxLayout();
    54     Wt::WHBoxLayout* hLayoutContainerErrors = new Wt::WHBoxLayout();
    55 
    56    
    57     warningsLabel_ = new Wt::WText("",XHTMLText);
    58     errorsLabel_ = new Wt::WText("",XHTMLText);
    59     hLayoutContainerWarnings->addWidget(warningsLabel_);
    60     hLayoutContainerErrors->addWidget(errorsLabel_);
    61 
    62     warningsAndErrorsContainer->addWidget(warningsLabel_);
    63     warningsAndErrorsContainer->addWidget(errorsLabel_);
    64    
    65    
    66     // set Layouts
    67     warningsContainer_->setLayout(hLayoutContainerWarnings);
    68     errorsContainer_->setLayout(hLayoutContainerErrors);
    69    
    70     vWarningsAndErrorsLayoutContainer->addWidget(errorsContainer_);
    71     vWarningsAndErrorsLayoutContainer->addWidget(warningsContainer_);
    72     vWarningsAndErrorsLayoutContainer->addStretch (100);
    73 
    74     warningsAndErrorsContainer->setLayout(vWarningsAndErrorsLayoutContainer);
    75 
    76     // add label and Combo containers
    77     mainContainerLayout->addWidget(labelAndComboContainer,0,0);
    78     // add warnings and errors containers
    79     mainContainerLayout->addWidget(warningsAndErrorsContainer,1,0);
    80 
    81     // manage margins
    82     vWarningsAndErrorsLayoutContainer->setContentsMargins(20,0,0,0);
    83     hLayoutContainerWarnings->setContentsMargins(0,0,0,0);
    84     hLayoutContainerErrors->setContentsMargins(0,0,0,0);
    85 
    86     setLayout(mainContainerLayout);
    87     warningsContainer_->setStyleClass("warningsContainer");
    88     errorsContainer_->setStyleClass("errorsContainer");
    89 
    90     // resize combo
    91     firstElement->setMinimumSize(80,12);
    92     lastElement->setMinimumSize(80,12);
    93     software->setMinimumSize(80,12);
    94        
    95     firstElement->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections);
    96     lastElement->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections);
    97     software->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections);
    98 
    99     manageWarningsAndErrors();
     58  warningsAndErrorsContainer->addWidget(warningsLabel_);
     59  warningsAndErrorsContainer->addWidget(errorsLabel_);
     60 
     61 
     62  // set Layouts
     63  warningsContainer_->setLayout(hLayoutContainerWarnings);
     64  errorsContainer_->setLayout(hLayoutContainerErrors);
     65 
     66  vWarningsAndErrorsLayoutContainer->addWidget(errorsContainer_);
     67  vWarningsAndErrorsLayoutContainer->addWidget(warningsContainer_);
     68  vWarningsAndErrorsLayoutContainer->addStretch (100);
     69 
     70  warningsAndErrorsContainer->setLayout(vWarningsAndErrorsLayoutContainer);
     71 
     72  // add label and Combo containers
     73  mainContainerLayout->addWidget(labelAndComboContainer,0,0);
     74  // add warnings and errors containers
     75  mainContainerLayout->addWidget(warningsAndErrorsContainer,1,0);
     76 
     77  // manage margins
     78  vWarningsAndErrorsLayoutContainer->setContentsMargins(20,0,0,0);
     79  hLayoutContainerWarnings->setContentsMargins(0,0,0,0);
     80  hLayoutContainerErrors->setContentsMargins(0,0,0,0);
     81 
     82  setLayout(mainContainerLayout);
     83  warningsContainer_->setStyleClass("warningsContainer");
     84  errorsContainer_->setStyleClass("errorsContainer");
     85 
     86  // resize combo
     87  firstElement->setMinimumSize(80,12);
     88  lastElement->setMinimumSize(80,12);
     89  software->setMinimumSize(80,12);
     90 
     91  firstElement->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections);
     92  lastElement->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections);
     93  software->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections);
     94 
     95  manageWarningsAndErrors();
    10096}
    10197
  • 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.