Changeset 343 in PSPA


Ignore:
Timestamp:
Feb 26, 2013, 2:38:17 PM (11 years ago)
Author:
touze
Message:

nvx element snapshot

Location:
Interface_Web/trunk/pspaWT/sources/userInterface
Files:
2 added
9 edited

Legend:

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

    r328 r343  
    1212#include "elementBeam.h"
    1313#include "elementFit.h"
     14#include "elementSnapshot.h"
    1415
    1516#include <Wt/WDialog>
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_abstractElementFactory.h

    r289 r343  
    1717#include "GWt_beam.h"
    1818#include "GWt_fit.h"
     19#include "GWt_snapshot.h"
    1920
    2021using namespace Wt;
    2122using namespace std;
    2223
     24class GWt_abstractElementFactory
     25{
    2326
    24 class GWt_abstractElementFactory {
    25     public :
    26     GWt_abstractElementFactory();
    27     ~GWt_abstractElementFactory();
    28    
    29     /* Enable the rfgun element creation
    30      */
    31     inline void setRFGunEnable(bool a) { isRFGunElementEnable = a;};
     27 public :
     28 
     29  GWt_abstractElementFactory();
     30  ~GWt_abstractElementFactory();
     31 
     32  /* Enable the rfgun element creation
     33   */
     34  inline void setRFGunEnable(bool a) { isRFGunElementEnable = a;};
     35 
     36  /* Enable the drift element creation
     37   */
     38  inline void setDriftEnable(bool a) { isDriftElementEnable = a;};
     39 
     40  /* Enable the cell element creation
     41   */
     42  inline void setCellEnable(bool a) { isCellElementEnable = a;};
     43 
     44  /* Enable the bend element creation
     45   */
     46  inline void setBendEnable(bool a) { isBendElementEnable = a;};
     47 
     48  /* Enable the soleno element creation
     49   */
     50  inline void setSolenoEnable(bool a) { isSolenoElementEnable = a;};
     51 
     52  /* Enable the beam element creation
     53   */
     54  inline void setBeamEnable(bool a) { isBeamElementEnable = a;};
     55 
     56  /* Enable the fit element creation
     57   */
     58  inline void setFitEnable(bool a) { isFitElementEnable = a;};
     59 
     60  /* Enable the snapshot element creation
     61   */
     62  inline void setSnapshotEnable(bool a) { isSnapshotElementEnable = a;};
     63 
     64  GWt_drift* createDriftElement();
     65  GWt_rfgun* createRFGunElement();
     66  GWt_cell* createCellElement();
     67  GWt_bend* createBendElement();
     68  GWt_soleno* createSolenoElement();
     69  GWt_beam* createBeamElement();
     70  GWt_fit* createFitElement();
     71  GWt_snapshot* createSnapshotElement();
     72  vector <GWt_abstractElement*> getAllElements();
     73 
     74 private :
    3275
    33     /* Enable the drift element creation
    34      */
    35     inline void setDriftEnable(bool a) { isDriftElementEnable = a;};
    36 
    37     /* Enable the cell element creation
    38      */
    39     inline void setCellEnable(bool a) { isCellElementEnable = a;};
    40 
    41     /* Enable the bend element creation
    42      */
    43     inline void setBendEnable(bool a) { isBendElementEnable = a;};
    44 
    45     /* Enable the soleno element creation
    46      */
    47     inline void setSolenoEnable(bool a) { isSolenoElementEnable = a;};
    48 
    49     /* Enable the beam element creation
    50      */
    51     inline void setBeamEnable(bool a) { isBeamElementEnable = a;};
    52 
    53     /* Enable the fit element creation
    54      */
    55     inline void setFitEnable(bool a) { isFitElementEnable = a;};
    56 
    57     GWt_drift* createDriftElement();
    58     GWt_rfgun* createRFGunElement();
    59     GWt_cell* createCellElement();
    60     GWt_bend* createBendElement();
    61     GWt_soleno* createSolenoElement();
    62     GWt_beam* createBeamElement();
    63     GWt_fit* createFitElement();
    64     vector <GWt_abstractElement*> getAllElements();
    65    
    66     private :
    67     bool isDriftElementEnable;
    68     bool isRFGunElementEnable;
    69     bool isCellElementEnable;
    70     bool isBendElementEnable;
    71     bool isSolenoElementEnable;
    72     bool isBeamElementEnable;
    73     bool isFitElementEnable;
     76  bool isDriftElementEnable;
     77  bool isRFGunElementEnable;
     78  bool isCellElementEnable;
     79  bool isBendElementEnable;
     80  bool isSolenoElementEnable;
     81  bool isBeamElementEnable;
     82  bool isFitElementEnable;
     83  bool isSnapshotElementEnable;
    7484};
    75 
    7685#endif
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_abstractElement.cc

    r322 r343  
    1414#include "GWt_beam.h"
    1515#include "GWt_fit.h"
     16#include "GWt_snapshot.h"
    1617#include "GWt_draggableImage.h"
    1718#include "GWt_ligneFaisceau.h"
     
    5051string* GWt_abstractElement::beginDialog()
    5152{
    52     string* param = abstractElement_-> getParametersString();
    53    
    54     if ( param == NULL )
     53  string* param = abstractElement_-> getParametersString();
     54   
     55  if ( param == NULL )
     56    {
     57      if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
     58        GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
     59        console->addConsoleMessage(" GWt_abstractElement::beginDialog : empty parameter set for element " + abstractElement_->getNomdElement().getElementName());
     60        }
     61    }
     62  //   int compteur = -1;
     63 
     64  //  int nbparam = atoi(param[++compteur].c_str());
     65  int nbparam = atoi(param->c_str());
     66  if ( nbparam != abstractElement_->getNbParams())
    5567    {
    5668        if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
    57             GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
    58             console->addConsoleMessage(" GWt_abstractElement::beginDialog : empty parameter set for element " + abstractElement_->getNomdElement().getElementName());
    59         }
    60     }
    61     //   int compteur = -1;
    62    
    63     //  int nbparam = atoi(param[++compteur].c_str());
    64     int nbparam = atoi(param->c_str());
    65     if ( nbparam != abstractElement_->getNbParams())
    66     {
    67         if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
    68             GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
    69             console->addConsoleMessage(" element seems not to be a " + abstractElement_->getNomdElement().getElementName());
    70         }
    71     }
    72    
    73     dialog_ = new WDialog("element " + abstractElement_->getNomdElement().getElementName());
     69          GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
     70          console->addConsoleMessage(" element seems not to be a " + abstractElement_->getNomdElement().getElementName());
     71        }
     72    }
     73 
     74  dialog_ = new WDialog("element " + abstractElement_->getNomdElement().getElementName());
    7475    new WText(" label of the element : ",dialog_->contents());
    7576    //  labelEdit_ = new WLineEdit(param[++compteur].c_str(), dialog_->contents());
     
    8889void GWt_abstractElement::clicked()
    8990{
    90     initilializeDialog();
    91     dialog_->show();
     91  initilializeDialog();
     92  dialog_->show();
    9293}
    9394
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_abstractElementFactory.cc

    r289 r343  
    99#include "GWt_abstractElementFactory.h"
    1010
     11GWt_abstractElementFactory::GWt_abstractElementFactory()
     12 :isDriftElementEnable(false),
     13  isRFGunElementEnable(false),
     14  isCellElementEnable(false),
     15  isBendElementEnable(false),
     16  isSolenoElementEnable(false),
     17  isBeamElementEnable(false),
     18  isFitElementEnable(false),
     19  isSnapshotElementEnable(false)
     20{}
    1121
    12 GWt_abstractElementFactory::GWt_abstractElementFactory()
    13 :isDriftElementEnable(false),
    14 isRFGunElementEnable(false),
    15 isCellElementEnable(false),
    16 isBendElementEnable(false),
    17 isSolenoElementEnable(false),
    18 isBeamElementEnable(false),
    19 isFitElementEnable(false)
     22GWt_abstractElementFactory::~GWt_abstractElementFactory()
    2023{
    21    
     24  isDriftElementEnable = false;
     25  isRFGunElementEnable = false;
     26  isCellElementEnable = false;
     27  isBendElementEnable = false;
     28  isSolenoElementEnable = false;
     29  isBeamElementEnable = false;
     30  isFitElementEnable = false;
     31  isSnapshotElementEnable = false;
    2232}
    2333
    24 
    25 GWt_abstractElementFactory::~GWt_abstractElementFactory() {
    26     isDriftElementEnable = false;
    27     isRFGunElementEnable = false;
    28     isCellElementEnable = false;
    29     isBendElementEnable = false;
    30     isSolenoElementEnable = false;
    31     isBeamElementEnable = false;
    32     isFitElementEnable = false;
     34GWt_drift* GWt_abstractElementFactory::createDriftElement()
     35{
     36  if (isDriftElementEnable) {
     37    return new GWt_drift();
     38  }
     39  return NULL;
    3340}
    3441
    35 
    36 GWt_drift* GWt_abstractElementFactory::createDriftElement() {
    37     if (isDriftElementEnable) {
    38         return new GWt_drift();
    39     }
    40     return NULL;
     42GWt_rfgun* GWt_abstractElementFactory::createRFGunElement()
     43{
     44  if (isRFGunElementEnable) {
     45    return new GWt_rfgun();
     46  }
     47  return NULL;
    4148}
    4249
    43 
    44 GWt_rfgun* GWt_abstractElementFactory::createRFGunElement() {
    45     if (isRFGunElementEnable) {
    46         return new GWt_rfgun();
    47     }
    48     return NULL;
     50GWt_cell* GWt_abstractElementFactory::createCellElement()
     51{
     52  if (isCellElementEnable) {
     53    return new GWt_cell();
     54  }
     55  return NULL;
    4956}
    5057
    51 GWt_cell* GWt_abstractElementFactory::createCellElement() {
    52     if (isCellElementEnable) {
    53         return new GWt_cell();
    54     }
    55     return NULL;
     58GWt_bend* GWt_abstractElementFactory::createBendElement()
     59{
     60  if (isBendElementEnable) {
     61    return new GWt_bend();
     62  }
     63  return NULL;
    5664}
    57 
    58 
    59 GWt_bend* GWt_abstractElementFactory::createBendElement() {
    60     if (isBendElementEnable) {
    61         return new GWt_bend();
    62     }
    63     return NULL;
    64 }
    65 
    6665
    6766GWt_soleno* GWt_abstractElementFactory::createSolenoElement()
    6867{
    69     if (isSolenoElementEnable) {
    70         return new GWt_soleno();
    71     }
    72     return NULL;
     68  if (isSolenoElementEnable) {
     69    return new GWt_soleno();
     70  }
     71  return NULL;
    7372}
    7473
    75 GWt_beam* GWt_abstractElementFactory::createBeamElement() {
    76     if (isBeamElementEnable) {
    77         return new GWt_beam();
    78     }
    79     return NULL;
     74GWt_beam* GWt_abstractElementFactory::createBeamElement()
     75{
     76  if (isBeamElementEnable) {
     77    return new GWt_beam();
     78  }
     79  return NULL;
    8080}
    8181
    82 
    83 GWt_fit* GWt_abstractElementFactory::createFitElement() {
    84     if (isFitElementEnable) {
    85         return new GWt_fit();
    86     }
    87     return NULL;
     82GWt_fit* GWt_abstractElementFactory::createFitElement()
     83{
     84  if (isFitElementEnable) {
     85    return new GWt_fit();
     86  }
     87  return NULL;
    8888}
    8989
    90 vector <GWt_abstractElement*> GWt_abstractElementFactory::getAllElements(){
    91     vector <GWt_abstractElement*> elems;
    92     if (isDriftElementEnable) {
    93         elems.push_back(new GWt_drift());
    94     }
    95     if (isBeamElementEnable) {
    96         elems.push_back(new GWt_beam());
    97     }
    98     if (isBendElementEnable) {
    99         elems.push_back(new GWt_bend());
    100     }
    101     if (isCellElementEnable) {
    102         elems.push_back(new GWt_cell());
    103     }
    104     if (isFitElementEnable) {
    105         elems.push_back(new GWt_fit());
    106     }
    107     if (isRFGunElementEnable) {
    108         elems.push_back(new GWt_rfgun());
    109     }
    110     if (isSolenoElementEnable) {
    111         elems.push_back(new GWt_soleno());
    112     }
    113     return elems;
     90GWt_snapshot* GWt_abstractElementFactory::createSnapshotElement()
     91{
     92  if (isSnapshotElementEnable) {
     93    return new GWt_snapshot();
     94  }
     95  return NULL;
    11496}
     97
     98vector <GWt_abstractElement*> GWt_abstractElementFactory::getAllElements()
     99{
     100  vector <GWt_abstractElement*> elems;
     101  if (isDriftElementEnable) {
     102    elems.push_back(new GWt_drift());
     103  }
     104  if (isBeamElementEnable) {
     105    elems.push_back(new GWt_beam());
     106  }
     107  if (isBendElementEnable) {
     108    elems.push_back(new GWt_bend());
     109  }
     110  if (isCellElementEnable) {
     111    elems.push_back(new GWt_cell());
     112  }
     113  if (isFitElementEnable) {
     114    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());
     121  }
     122  if (isSnapshotElementEnable) {
     123    elems.push_back(new GWt_snapshot());
     124  }
     125
     126  return elems;
     127}
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_dropZoneLigneFaisceau.cc

    r309 r343  
    99#include "nomdElements.h"
    1010
    11 
    12 
    1311GWt_dropZoneLigneFaisceau::GWt_dropZoneLigneFaisceau( PspaApplication* pspa)
    14 : WContainerWidget(){
    15     initialise(pspa);
     12  : WContainerWidget()
     13{
     14  initialise(pspa);
    1615}
    17 
    1816
    1917GWt_dropZoneLigneFaisceau::~GWt_dropZoneLigneFaisceau()
     
    2119}
    2220
    23 
    2421void GWt_dropZoneLigneFaisceau::initialise( PspaApplication* pspa)
    2522{
    26    
    27     // connect mouse events
    28    
    29     mouseWentOver().connect(this, &GWt_dropZoneLigneFaisceau::mouseOver);
    30     mouseWentUp().connect(this, &GWt_dropZoneLigneFaisceau::mouseUp);
    31     mouseWentDown().connect(this, &GWt_dropZoneLigneFaisceau::mouseDown);
    32     mouseWentOut().connect(this, &GWt_dropZoneLigneFaisceau::mouseOut);
    33     mouseDragged().connect(this, &GWt_dropZoneLigneFaisceau::mouseIsDragged);
    34    
    35     // accept drops
    36    
    37     vector <GWt_abstractElement*> elems = pspa->getAbstractElementFactory()->getAllElements();
    38     for (int a = 0; a< elems.size(); a++) {
    39         acceptDrops(elems[a]->getMimeType());
    40     }
    41     setMinimumSize(10,32);
     23 
     24  // connect mouse events
     25  mouseWentOver().connect(this, &GWt_dropZoneLigneFaisceau::mouseOver);
     26  mouseWentUp().connect(this, &GWt_dropZoneLigneFaisceau::mouseUp);
     27  mouseWentDown().connect(this, &GWt_dropZoneLigneFaisceau::mouseDown);
     28  mouseWentOut().connect(this, &GWt_dropZoneLigneFaisceau::mouseOut);
     29  mouseDragged().connect(this, &GWt_dropZoneLigneFaisceau::mouseIsDragged);
     30 
     31  // accept drops
     32  vector <GWt_abstractElement*> elems = pspa->getAbstractElementFactory()->getAllElements();
     33  for(int a = 0; a < elems.size(); a++) {
     34    acceptDrops(elems[a]->getMimeType());
     35  }
     36  setMinimumSize(10,32);
    4237}
    43 
    4438
    4539void GWt_dropZoneLigneFaisceau::mouseOver(const WMouseEvent& e)
     
    4943void GWt_dropZoneLigneFaisceau::mouseOut(const WMouseEvent& e)
    5044{
    51     decorationStyle().setCursor(ArrowCursor);
     45  decorationStyle().setCursor(ArrowCursor);
    5246}
    5347
    5448void GWt_dropZoneLigneFaisceau::mouseIsDragged(const WMouseEvent& e)
    5549{
    56     decorationStyle().setCursor(OpenHandCursor);
     50  decorationStyle().setCursor(OpenHandCursor);
    5751}
    5852
     
    6761void GWt_dropZoneLigneFaisceau::dropEvent(WDropEvent evt)
    6862{
    69     // get LigneFaiseau widget and add new elementLigneFaiseau
    70     GWt_LigneFaisceau* ligneFaisceau = NULL;
    71     if ( static_cast<GWt_LigneFaisceau*> (wApp->findWidget ("ligneFaisceau"))) {
    72         ligneFaisceau = static_cast<GWt_LigneFaisceau*> (wApp->findWidget ("ligneFaisceau"));
    73     } else {
    74         return;
    75     }
    76    
    77     // get the type of element
    78     nomdElements e(evt.mimeType());
    79     typedElement eType = e.getElementType();
    80     ligneFaisceau->addElement(eType, this);
     63  // get LigneFaiseau widget and add new elementLigneFaiseau
     64  GWt_LigneFaisceau* ligneFaisceau = NULL;
     65  if ( static_cast<GWt_LigneFaisceau*> (wApp->findWidget ("ligneFaisceau"))) {
     66    ligneFaisceau = static_cast<GWt_LigneFaisceau*> (wApp->findWidget ("ligneFaisceau"));
     67  } else {
     68    return;
     69  }
     70 
     71  // get the type of element
     72  nomdElements e(evt.mimeType());
     73  typedElement eType = e.getElementType();
     74  ligneFaisceau->addElement(eType, this);
    8175}
    8276
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_elementLigneFaisceau.cc

    r336 r343  
    1212#include "GWt_beam.h"
    1313#include "GWt_fit.h"
     14#include "GWt_snapshot.h"
    1415
    1516
     
    2627#define PSPA_DEBUG 1
    2728
    28 
    2929GWt_elementLigneFaisceau::GWt_elementLigneFaisceau(PspaApplication* pspa)
    30 : WContainerWidget(),
    31 firstTimeInsertMessage_(NULL),
    32 dropZoneLeft_(NULL),
    33 dropZoneRight_(NULL),
    34 GWt_abstractElement_(NULL),
    35 elementLabel_(NULL),
    36 pspa_(pspa)
    37 {
    38    
    39     initialize_ligneFaisceau(inconnu);
     30  : WContainerWidget(),
     31    firstTimeInsertMessage_(NULL),
     32    dropZoneLeft_(NULL),
     33    dropZoneRight_(NULL),
     34    GWt_abstractElement_(NULL),
     35    elementLabel_(NULL),
     36    pspa_(pspa)
     37{
     38  initialize_ligneFaisceau(inconnu);
    4039}
    4140
    4241
    4342GWt_elementLigneFaisceau::GWt_elementLigneFaisceau(typedElement type, PspaApplication* pspa)
    44 : WContainerWidget(),
    45 firstTimeInsertMessage_(NULL),
    46 dropZoneLeft_(NULL),
    47 dropZoneRight_(NULL),
    48 GWt_abstractElement_(NULL),
    49 elementLabel_(NULL),
    50 pspa_(pspa)
    51 {
    52     // set the css name
    53     setObjectName("elementLigneFaisceau");
    54 
    55     initialize_ligneFaisceau(type);
    56 }
    57 
     43  : WContainerWidget(),
     44    firstTimeInsertMessage_(NULL),
     45    dropZoneLeft_(NULL),
     46    dropZoneRight_(NULL),
     47    GWt_abstractElement_(NULL),
     48    elementLabel_(NULL),
     49    pspa_(pspa)
     50{
     51  // set the css name
     52  setObjectName("elementLigneFaisceau");
     53  initialize_ligneFaisceau(type);
     54}
    5855
    5956void GWt_elementLigneFaisceau::initialize_ligneFaisceau(typedElement eType)
    6057{
    6158   
    62     cout<<"new GWt_elementLigneFaisceau : "<< this << endl;
    63    
    64     // set layout
    65     //     +----------+--------+---------+
    66     //     |   (--->) |  ELEM  | (-----) |
    67     //     +----------+--------+---------+
    68     //     |             NAME            |
    69     //     +----------+--------+---------+
    70    
    71    
    72     WGridLayout *gridLayout = new WGridLayout();
    73    
    74     gridLayout->setContentsMargins(0,0,0,0);
    75     gridLayout->setHorizontalSpacing    (0);
    76     gridLayout->setVerticalSpacing      (0);
    77    
    78     // add first line :  initialize arrow and link images
    79     dropZoneLeft_ = new GWt_dropZoneLigneFaisceau(pspa_);
    80     dropZoneRight_ = new GWt_dropZoneLigneFaisceau(pspa_);
    81    
    82     // change object name in order to manage css :
    83     dropZoneLeft_->resize(10,30);
    84     dropZoneRight_->resize(10,30);
    85    
    86     gridLayout->addWidget       (dropZoneLeft_,0,0);
    87     gridLayout->addWidget       (dropZoneRight_,0,2);
    88    
    89     // add the image if present
    90    
    91     switch (  eType ) {
    92         case RFgun :
    93             GWt_abstractElement_ = new GWt_rfgun(this);
    94             break;
    95         case drift :
    96             GWt_abstractElement_ = new GWt_drift(this);
    97             break;
    98         case cell  :
    99             GWt_abstractElement_ = new GWt_cell(this);
    100             break;
    101         case bend  :
    102             GWt_abstractElement_ = new GWt_bend(this);
    103             break;
    104         case soleno  :
    105             GWt_abstractElement_ = new GWt_soleno(this);
    106             break;
    107         case beam  :
    108             GWt_abstractElement_ = new GWt_beam(this);
    109             break;
    110         case fit  :
    111             GWt_abstractElement_ = new GWt_fit(this);
    112             break;
    113         case inconnu :
    114             GWt_abstractElement_ = NULL;
     59  cout<<"new GWt_elementLigneFaisceau : "<< this << endl;
     60   
     61  // set layout
     62  //     +----------+--------+---------+
     63  //     |   (--->) |  ELEM  | (-----) |
     64  //     +----------+--------+---------+
     65  //     |             NAME            |
     66  //     +----------+--------+---------+
     67 
     68   
     69  WGridLayout *gridLayout = new WGridLayout();
     70   
     71  gridLayout->setContentsMargins(0,0,0,0);
     72  gridLayout->setHorizontalSpacing(0);
     73  gridLayout->setVerticalSpacing(0);
     74 
     75  // add first line :  initialize arrow and link images
     76  dropZoneLeft_ = new GWt_dropZoneLigneFaisceau(pspa_);
     77  dropZoneRight_ = new GWt_dropZoneLigneFaisceau(pspa_);
     78   
     79  // change object name in order to manage css :
     80  dropZoneLeft_->resize(10,30);
     81  dropZoneRight_->resize(10,30);
     82 
     83  gridLayout->addWidget (dropZoneLeft_,0,0);
     84  gridLayout->addWidget (dropZoneRight_,0,2);
     85   
     86  // add the image if present
     87 
     88  switch ( eType ) {
     89  case RFgun :
     90    GWt_abstractElement_ = new GWt_rfgun(this);
     91    break;
     92  case drift :
     93    GWt_abstractElement_ = new GWt_drift(this);
     94    break;
     95  case cell  :
     96    GWt_abstractElement_ = new GWt_cell(this);
     97    break;
     98  case bend  :
     99    GWt_abstractElement_ = new GWt_bend(this);
     100    break;
     101  case soleno  :
     102    GWt_abstractElement_ = new GWt_soleno(this);
     103    break;
     104  case beam  :
     105    GWt_abstractElement_ = new GWt_beam(this);
     106    break;
     107  case fit  :
     108    GWt_abstractElement_ = new GWt_fit(this);
     109    break;
     110  case snapshot :
     111    GWt_abstractElement_ = new GWt_snapshot(this);
     112    break;
     113  case inconnu :
     114    GWt_abstractElement_ = NULL;
     115  }
     116
     117  if (GWt_abstractElement_ != NULL) {
     118    gridLayout->addWidget(GWt_abstractElement_,0,1);
     119    GWt_abstractElement_->setMaximumSize(32,32);
     120    GWt_abstractElement_->setMinimumSize(32,32);
     121  }
     122 
     123  // add second line
     124    if (GWt_abstractElement_ == NULL) {
     125      elementLabel_ = new WText();
     126    } else {
     127      elementLabel_ = new WText(GWt_abstractElement_->getAbstractElement()->getLabel());
    115128    }
    116     if (GWt_abstractElement_ != NULL) {
    117         gridLayout->addWidget   (GWt_abstractElement_,0,1);
    118         GWt_abstractElement_->setMaximumSize(32,32);
    119         GWt_abstractElement_->setMinimumSize(32,32);
    120     }
    121    
    122     // add second line
    123     if (GWt_abstractElement_ == NULL) {
    124         elementLabel_ = new WText();
    125     } else {
    126         elementLabel_ = new WText(GWt_abstractElement_->getAbstractElement()->getLabel());
    127     }
    128    
    129     gridLayout->addWidget       (elementLabel_,1,0,1,3,Wt::AlignCenter |Wt::AlignMiddle);
     129   
     130    gridLayout->addWidget(elementLabel_,1,0,1,3,Wt::AlignCenter |Wt::AlignMiddle);
    130131   
    131132    gridLayout->setColumnStretch (0,1);
     
    141142}
    142143
    143 
    144144void GWt_elementLigneFaisceau::removeDone(GWt_abstractElement* gw)
    145145{
    146     if (messageDropZone_->result() == WDialog::Accepted) {
    147         // FIXME
    148         //    removeDropZone();
    149     }
    150 }
    151 
    152 
    153 void GWt_elementLigneFaisceau::addElement(GWt_abstractElement* elem){
    154    
    155     clear();
    156     GWt_abstractElement_ = elem;
    157     addWidget(GWt_abstractElement_);
    158     if (static_cast <WContainerWidget*> (parent())) {
    159         WContainerWidget* wc = static_cast <WContainerWidget*> (parent());
    160         WBoxLayout* layout = ((WBoxLayout*)(wc->layout()));
    161         layout->setStretchFactor(this,0);
    162     }
    163    
    164    
    165     firstTimeInsertMessage_ = NULL;
     146  if (messageDropZone_->result() == WDialog::Accepted) {
     147    // FIXME
     148    //    removeDropZone();
     149  }
     150}
     151
     152
     153void GWt_elementLigneFaisceau::addElement(GWt_abstractElement* elem)
     154{   
     155  clear();
     156  GWt_abstractElement_ = elem;
     157  addWidget(GWt_abstractElement_);
     158  if (static_cast <WContainerWidget*> (parent())) {
     159    WContainerWidget* wc = static_cast <WContainerWidget*> (parent());
     160    WBoxLayout* layout = ((WBoxLayout*)(wc->layout()));
     161    layout->setStretchFactor(this,0);
     162  }
     163 
     164 
     165  firstTimeInsertMessage_ = NULL;
    166166    dropZoneLeft_ = NULL;
    167167}
     
    169169
    170170std::string GWt_elementLigneFaisceau::getElementNumberInBeamLine(nomdElements elem){
    171     string str = "";
     171  string str = "";
    172172   
    173173    if (static_cast <WContainerWidget*> (parent())) {
     
    210210
    211211void GWt_elementLigneFaisceau::setElementLabel(std::string label) {
    212     if (elementLabel_) {
    213         elementLabel_->setText(label);
    214     }
    215 }
    216 
     212  if (elementLabel_) {
     213    elementLabel_->setText(label);
     214  }
     215}
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_ligneFaisceau.cc

    r323 r343  
    33#include "GWt_elementLigneFaisceau.h"
    44#include "GWt_ligneFaisceau.h"
     5
    56#include "GWt_drift.h"
    67#include "GWt_rfgun.h"
     
    1516
    1617GWt_LigneFaisceau::GWt_LigneFaisceau(PspaApplication* ps) :
    17 WContainerWidget(),
    18 pspa_(ps),
    19 nObjets_(NULL)
    20 {
    21    
    22     cout<<"GWt_LigneFaisceau::GWt_LigneFaisceau() %d"<< this << "<---------------"<< endl;
    23    
    24     ligneFaisceauLayout_ = new WHBoxLayout();
    25     //  decorationStyle().setBackgroundColor (WColor(245,245,245));
    26     setLayout(ligneFaisceauLayout_);
    27     ligneFaisceauLayout_->setContentsMargins(0,0,0,0);
    28     ligneFaisceauLayout_->setSpacing    (0);
    29    
    30     int nElts= nomdElements::getNumberOfElements();
    31     nObjets_= new Compteur[nElts];
    32    
    33     // set the object name
    34     setObjectName("ligneFaisceau");
    35    
    36    
    37     clear();
    38 }
    39 
    40 
    41 void GWt_LigneFaisceau::clear() {
    42     ligneFaisceauLayout_->clear();
    43 
    44     // add the first drop zone
    45     decorationStyle().setBorder (WBorder (WBorder::Dotted));
    46     allDropZone_ = new GWt_dropZoneLigneFaisceau(pspa_);
    47     WVBoxLayout* fit = new WVBoxLayout();
    48     allDropZone_->setLayout(fit);
    49    
    50     fit->addWidget(new WText("Drag elements here...."),1,Wt::AlignCenter |Wt::AlignMiddle);
    51     ligneFaisceauLayout_->addWidget(allDropZone_,1);
     18  WContainerWidget(),
     19  pspa_(ps),
     20  nObjets_(NULL)
     21{
     22 
     23  cout<<"GWt_LigneFaisceau::GWt_LigneFaisceau() %d"<< this << "<---------------"<< endl;
     24   
     25  ligneFaisceauLayout_ = new WHBoxLayout();
     26  //  decorationStyle().setBackgroundColor (WColor(245,245,245));
     27  setLayout(ligneFaisceauLayout_);
     28  ligneFaisceauLayout_->setContentsMargins(0,0,0,0);
     29  ligneFaisceauLayout_->setSpacing(0);
     30 
     31  int nElts= nomdElements::getNumberOfElements();
     32  nObjets_= new Compteur[nElts];
     33 
     34  // set the object name
     35  setObjectName("ligneFaisceau");
     36 
     37 
     38  clear();
     39}
     40
     41
     42void GWt_LigneFaisceau::clear()
     43{
     44  ligneFaisceauLayout_->clear();
     45
     46  // add the first drop zone
     47  decorationStyle().setBorder (WBorder (WBorder::Dotted));
     48  allDropZone_ = new GWt_dropZoneLigneFaisceau(pspa_);
     49  WVBoxLayout* fit = new WVBoxLayout();
     50  allDropZone_->setLayout(fit);
     51 
     52  fit->addWidget(new WText("Drag elements here...."),1,Wt::AlignCenter |Wt::AlignMiddle);
     53  ligneFaisceauLayout_->addWidget(allDropZone_,1);
    5254}
    5355
    5456
    5557GWt_abstractElement* GWt_LigneFaisceau::addElement(typedElement eType){
    56     return addElement(eType,NULL);
    57 }
    58 
    59 
    60 
    61 GWt_abstractElement* GWt_LigneFaisceau::addElement(typedElement eType, GWt_dropZoneLigneFaisceau* dropContainer ){
    62 
    63     GWt_abstractElement* GWtAbstractElem = NULL;
    64    
    65     cout << " Entree addElement element " << nomdElements::getLabelFromType(eType) << endl;
    66    
    67     int nElements= nomdElements ::getNumberOfElements();
    68     nObjets_= new Compteur[nElements];
    69    
    70     // 3 cases :
    71     // -dropContainer is an element of the ligneFaisceauLayout_
    72     // -dropContainer is an element of the GWt_elementLigneFaisceau_
    73     // -dropContainer is NULL, insert in the last element
    74    
    75     if(eType == inconnu) {
    76         cout << "GWt_LigneFaisceau::element type " << eType << " inconnu " << endl;
    77         return NULL;
    78     }
    79    
    80     // add the element to the datamanager
    81    
    82     // first time we insert an element :
    83     GWt_elementLigneFaisceau* firstElemIsElement = dynamic_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(0)->widget());
    84     if ((ligneFaisceauLayout_->count() == 1) && (!firstElemIsElement)) {
    85         int index = indexOf (dropContainer);
    86         if ((index != -1) || (dropContainer == NULL)){ // found
    87             // remove global drop zone
    88             ligneFaisceauLayout_->clear();
    89 
    90             // add first element
    91             GWt_elementLigneFaisceau* elemLigneFaisceau = new GWt_elementLigneFaisceau(eType, pspa_);
    92            
    93             ligneFaisceauLayout_->addWidget(elemLigneFaisceau,1);
    94             GWtAbstractElem = elemLigneFaisceau->getGWt_AbstractElement();
    95             // remove arrow from begin and end
    96            
    97         } else { // error
    98             return NULL;
    99         }
     58  return addElement(eType,NULL);
     59}
     60
     61GWt_abstractElement* GWt_LigneFaisceau::addElement(typedElement eType, GWt_dropZoneLigneFaisceau* dropContainer )
     62{
     63
     64  GWt_abstractElement* GWtAbstractElem = NULL;
     65   
     66  cout << " Entree addElement element " << nomdElements::getLabelFromType(eType) << endl;
     67   
     68  int nElements= nomdElements ::getNumberOfElements();
     69  nObjets_= new Compteur[nElements];
     70 
     71  // 3 cases :
     72  // -dropContainer is an element of the ligneFaisceauLayout_
     73  // -dropContainer is an element of the GWt_elementLigneFaisceau_
     74  // -dropContainer is NULL, insert in the last element
     75 
     76  if(eType == inconnu) {
     77    cout << "GWt_LigneFaisceau::element type " << eType << " inconnu " << endl;
     78    return NULL;
     79  }
     80 
     81  // add the element to the datamanager
     82 
     83  // first time we insert an element :
     84  GWt_elementLigneFaisceau* firstElemIsElement = dynamic_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(0)->widget());
     85  if ((ligneFaisceauLayout_->count() == 1) && (!firstElemIsElement)) {
     86    int index = indexOf (dropContainer);
     87    if ((index != -1) || (dropContainer == NULL)){ // found
     88      // remove global drop zone
     89      ligneFaisceauLayout_->clear();
     90     
     91      // add first element
     92      GWt_elementLigneFaisceau* elemLigneFaisceau = new GWt_elementLigneFaisceau(eType, pspa_);
     93     
     94      ligneFaisceauLayout_->addWidget(elemLigneFaisceau,1);
     95      GWtAbstractElem = elemLigneFaisceau->getGWt_AbstractElement();
     96      // remove arrow from begin and end
     97     
     98    } else { // error
     99      return NULL;
     100    }
     101  } else {
     102    int index = -1;
     103    for (int a=0; a< ligneFaisceauLayout_->count(); a++) {
     104      GWt_elementLigneFaisceau* elem = static_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ());
     105      if (elem) {
     106        if (elem->getDropZoneLeft() == dropContainer) {
     107          index = a;
     108        }
     109        if (elem->getDropZoneRight() == dropContainer) {
     110          index = a+1;
     111        }
     112      }
     113     
     114    }
     115   
     116   
     117    //  ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaiseau(ptr),0);
     118    GWt_elementLigneFaisceau* elemLigneFaisceau = new GWt_elementLigneFaisceau(eType, pspa_);
     119    if (index != -1) {
     120      //            nObjets_[ptr->getNomdElement().getElementType()].incr();
     121      ligneFaisceauLayout_->insertWidget(index,elemLigneFaisceau,1);
     122      GWtAbstractElem = elemLigneFaisceau->getGWt_AbstractElement();
    100123    } else {
    101         int index = -1;
    102         for (int a=0; a< ligneFaisceauLayout_->count(); a++) {
    103             GWt_elementLigneFaisceau* elem = static_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ());
    104             if (elem) {
    105                 if (elem->getDropZoneLeft() == dropContainer) {
    106                     index = a;
    107                 }
    108                 if (elem->getDropZoneRight() == dropContainer) {
    109                     index = a+1;
    110                 }
    111             }
    112            
    113         }
     124      ligneFaisceauLayout_->addWidget(elemLigneFaisceau,1);
     125      GWtAbstractElem = elemLigneFaisceau->getGWt_AbstractElement();
     126    }
     127  }
     128  manageLineFaisceauLayout();
     129 
     130  return GWtAbstractElem;
     131}
     132
     133
     134void GWt_LigneFaisceau::manageLineFaisceauLayout() {
     135  // special : hide/setVisible arrow :
     136  for (int a=0; a< ligneFaisceauLayout_->count(); a++) {
     137    if (GWt_elementLigneFaisceau* elem = dynamic_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ())) {
     138     
     139      // update labels
     140      elem->getGWt_AbstractElement()->updateLabelAndToolTipWidget();
     141     
     142      //  one element
     143      if ((a == 0) && (a == (ligneFaisceauLayout_->count()-1))) {
     144        elem->getDropZoneLeft()->setStyleClass("elementLigneFaiseau_transparent");
     145        elem->getDropZoneRight()->setStyleClass("elementLigneFaiseau_transparent");
     146       
     147        // first
     148      } else if (a == 0){
     149        elem->getDropZoneLeft()->setStyleClass("elementLigneFaiseau_transparent");
     150        elem->getDropZoneRight()->setStyleClass("elementLigneFaiseau_line");
     151       
     152        // last
     153      } else if (a == (ligneFaisceauLayout_->count()-1)){
     154        elem->getDropZoneLeft()->setStyleClass("elementLigneFaiseau_line");
     155        elem->getDropZoneRight()->setStyleClass("elementLigneFaiseau_transparent");
    114156       
    115157       
    116         //  ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaiseau(ptr),0);
    117         GWt_elementLigneFaisceau* elemLigneFaisceau = new GWt_elementLigneFaisceau(eType, pspa_);
    118         if (index != -1) {
    119 //            nObjets_[ptr->getNomdElement().getElementType()].incr();
    120             ligneFaisceauLayout_->insertWidget(index,elemLigneFaisceau,1);
    121             GWtAbstractElem = elemLigneFaisceau->getGWt_AbstractElement();
    122         } else {
    123             ligneFaisceauLayout_->addWidget(elemLigneFaisceau,1);
    124             GWtAbstractElem = elemLigneFaisceau->getGWt_AbstractElement();
    125         }
    126     }
     158        // middle elements
     159      } else {
     160        elem->getDropZoneLeft()->setStyleClass("elementLigneFaiseau_line");
     161        elem->getDropZoneRight()->setStyleClass("elementLigneFaiseau_line");
     162      }
     163    }
     164  }
     165 
     166  // insure that there is still the dropzone !
     167  if (ligneFaisceauLayout_->count() == 0) {
     168    clear();
     169  }
     170 
     171  pspa_->getExecuteWidget()->updateSelections();
     172}
     173
     174
     175
     176void GWt_LigneFaisceau::update() {
     177  manageLineFaisceauLayout();
     178}
     179
     180
     181void GWt_LigneFaisceau::removeElement(GWt_abstractElement* GWt_abstractElement) {
     182  if (GWt_abstractElement == NULL)
     183    return;
     184 
     185  // remove Widget
     186  // - GWt_abstractElement is an element of the GWt_elementLigneFaisceau_
     187 
     188  int index = -1;
     189  for (int a=0; a< ligneFaisceauLayout_->count(); a++) {
     190    GWt_elementLigneFaisceau* elem = static_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ());
     191    if (elem) {
     192      if (elem->getGWt_AbstractElement() == GWt_abstractElement) {
     193        index = a;
     194      }
     195    }
     196  }
     197 
     198  if (index != -1) {
     199    // remove element from the list
     200    //        pspa_->getDataManager()->removeElement(GWt_abstractElement->getElement()->getLabel());
     201   
     202    ligneFaisceauLayout_->removeItem(ligneFaisceauLayout_->itemAt(index));
     203    delete GWt_abstractElement;
     204   
     205    // manage widgets if necessary
    127206    manageLineFaisceauLayout();
    128 
    129     return GWtAbstractElem;
    130 }
    131 
    132 
    133 void GWt_LigneFaisceau::manageLineFaisceauLayout() {
    134     // special : hide/setVisible arrow :
    135     for (int a=0; a< ligneFaisceauLayout_->count(); a++) {
    136         if (GWt_elementLigneFaisceau* elem = dynamic_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ())) {
    137 
    138             // update labels
    139             elem->getGWt_AbstractElement()->updateLabelAndToolTipWidget();
    140            
    141             //  one element
    142             if ((a == 0) && (a == (ligneFaisceauLayout_->count()-1))) {
    143                 elem->getDropZoneLeft()->setStyleClass("elementLigneFaiseau_transparent");
    144                 elem->getDropZoneRight()->setStyleClass("elementLigneFaiseau_transparent");
    145 
    146                 // first
    147             } else if (a == 0){
    148                 elem->getDropZoneLeft()->setStyleClass("elementLigneFaiseau_transparent");
    149                 elem->getDropZoneRight()->setStyleClass("elementLigneFaiseau_line");
    150 
    151                 // last
    152             } else if (a == (ligneFaisceauLayout_->count()-1)){
    153                 elem->getDropZoneLeft()->setStyleClass("elementLigneFaiseau_line");
    154                 elem->getDropZoneRight()->setStyleClass("elementLigneFaiseau_transparent");
    155                
    156                
    157                 // middle elements
    158             } else {
    159                 elem->getDropZoneLeft()->setStyleClass("elementLigneFaiseau_line");
    160                 elem->getDropZoneRight()->setStyleClass("elementLigneFaiseau_line");
    161             }
    162         }
    163     }
    164    
    165     // insure that there is still the dropzone !
    166     if (ligneFaisceauLayout_->count() == 0) {
    167         clear();
    168     }
    169    
    170     pspa_->getExecuteWidget()->updateSelections();
    171 }
    172 
    173 
    174 
    175 void GWt_LigneFaisceau::update() {
    176     manageLineFaisceauLayout();
    177 }
    178 
    179 
    180 void GWt_LigneFaisceau::removeElement(GWt_abstractElement* GWt_abstractElement) {
    181     if (GWt_abstractElement == NULL)
    182         return;
    183    
    184     // remove Widget
    185     // - GWt_abstractElement is an element of the GWt_elementLigneFaisceau_
    186    
    187     int index = -1;
    188     for (int a=0; a< ligneFaisceauLayout_->count(); a++) {
    189         GWt_elementLigneFaisceau* elem = static_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ());
    190         if (elem) {
    191             if (elem->getGWt_AbstractElement() == GWt_abstractElement) {
    192                 index = a;
    193             }
    194         }
    195     }
    196    
    197     if (index != -1) {
    198         // remove element from the list
    199 //        pspa_->getDataManager()->removeElement(GWt_abstractElement->getElement()->getLabel());
    200        
    201         ligneFaisceauLayout_->removeItem(ligneFaisceauLayout_->itemAt(index));
    202         delete GWt_abstractElement;
    203        
    204         // manage widgets if necessary
    205         manageLineFaisceauLayout();
    206     }
     207  }
    207208}
    208209
    209210
    210211abstractElement* GWt_LigneFaisceau::getAbstractElement(int i){
    211     int index = 0;
    212 
    213     // first if 1
    214 //    i--;
    215    
    216     for (int a=0; a< ligneFaisceauLayout_->count(); a++) {
    217         if (GWt_elementLigneFaisceau* elem = dynamic_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ())) {
    218             if (index == i) {
    219                 printf("GWt_LigneFaisceau::getAbstractElement %d %s\n",i,elem->getGWt_AbstractElement()->getAbstractElement()->getLabel().c_str());
    220                 return elem->getGWt_AbstractElement()->getAbstractElement();
    221             }
    222             index ++;
    223         }
    224     }
    225     return NULL;
     212  int index = 0;
     213 
     214  // first if 1
     215  //    i--;
     216 
     217  for (int a=0; a< ligneFaisceauLayout_->count(); a++) {
     218    if (GWt_elementLigneFaisceau* elem = dynamic_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ())) {
     219      if (index == i) {
     220        printf("GWt_LigneFaisceau::getAbstractElement %d %s\n",i,elem->getGWt_AbstractElement()->getAbstractElement()->getLabel().c_str());
     221        return elem->getGWt_AbstractElement()->getAbstractElement();
     222      }
     223      index ++;
     224    }
     225  }
     226  return NULL;
    226227}
    227228
    228229
    229230int GWt_LigneFaisceau::getBeamLineSize() {
    230     int count = 0;
    231     for (int a=0; a< ligneFaisceauLayout_->count(); a++) {
    232         if (dynamic_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ())) {
    233             count ++;
    234         }
    235     }
    236     return count;
    237 }
    238 
    239 
    240 vector <abstractElement*> GWt_LigneFaisceau::getAllAbstractElements(){
    241     vector <abstractElement*> elems;
    242     for (int a=0; a< ligneFaisceauLayout_->count(); a++) {
    243         if (GWt_elementLigneFaisceau* elem = dynamic_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ())) {
    244             elems.push_back(elem->getGWt_AbstractElement()->getAbstractElement());
    245         }
    246     }
    247     return elems;
    248 }
    249 
     231  int count = 0;
     232  for (int a=0; a< ligneFaisceauLayout_->count(); a++) {
     233    if (dynamic_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ())) {
     234      count ++;
     235    }
     236  }
     237  return count;
     238}
     239
     240vector <abstractElement*> GWt_LigneFaisceau::getAllAbstractElements()
     241{
     242  vector <abstractElement*> elems;
     243  for (int a=0; a< ligneFaisceauLayout_->count(); a++) {
     244    if (GWt_elementLigneFaisceau* elem = dynamic_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ())) {
     245      elems.push_back(elem->getGWt_AbstractElement()->getAbstractElement());
     246    }
     247  }
     248  return elems;
     249}
     250
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc

    r341 r343  
    6565    abstractElementFactory_->setBeamEnable(true);
    6666    abstractElementFactory_->setFitEnable(true);
     67    abstractElementFactory_->setSnapshotEnable(true);
    6768   
    6869    // include the styleSheet
     
    7172    dtmanage_ = new dataManager(this);
    7273    //    dtmanage_->setWorkingDir(workingDir_);
     74
    7375    /*
    7476     * The main layout is a 3x2 grid layout.
     
    125127   
    126128    createBeamLine();
    127 
     129   
    128130    WScrollArea* scroll = new  WScrollArea();
    129131    scroll->setWidget(beamLine_);
     
    243245  Wt::WRadioButton *button2= new WRadioButton(" phase space after element");
    244246
    245     choixAbsPhase_ = new WComboBox();
    246     choixAbsPhase_->addItem("x");
    247     choixAbsPhase_->addItem("y");
    248     choixAbsPhase_->addItem("z");
    249     choixAbsPhase_->addItem("xp");
    250     choixAbsPhase_->addItem("yp");
    251     choixAbsPhase_->addItem("dE/E");
    252     choixAbsPhase_->setCurrentIndex(0);
    253 
    254     choixOrdPhase_ = new WComboBox();
    255     choixOrdPhase_->addItem("x");
    256     choixOrdPhase_->addItem("y");
    257     choixOrdPhase_->addItem("z");
    258     choixOrdPhase_->addItem("xp");
    259     choixOrdPhase_->addItem("yp");
    260     choixOrdPhase_->addItem("dE/E");
    261     choixOrdPhase_->setCurrentIndex(3);
    262 
    263 
    264 
     247  choixAbsPhase_ = new WComboBox();
     248  choixAbsPhase_->addItem("x");
     249  choixAbsPhase_->addItem("y");
     250  choixAbsPhase_->addItem("z");
     251  choixAbsPhase_->addItem("xp");
     252  choixAbsPhase_->addItem("yp");
     253  choixAbsPhase_->addItem("dE/E");
     254  choixAbsPhase_->setCurrentIndex(0);
     255 
     256  choixOrdPhase_ = new WComboBox();
     257  choixOrdPhase_->addItem("x");
     258  choixOrdPhase_->addItem("y");
     259  choixOrdPhase_->addItem("z");
     260  choixOrdPhase_->addItem("xp");
     261  choixOrdPhase_->addItem("yp");
     262  choixOrdPhase_->addItem("dE/E");
     263  choixOrdPhase_->setCurrentIndex(3);
     264 
    265265  group_->addButton(button2,2);
    266266  glayout->addWidget(button2,1,1);
     
    461461  choixElementDessin_->clear();
    462462  choixHistoDessin_->clear();
    463   int nombre = dtmanage_->getBeamLineSize();
    464   cout << " PspaApplication::faireDessin() nb elements : " << nombre << endl;
     463
     464  int nombre = dtmanage_->getBeamLineSize(); 
    465465  for(int i = 1; i <= nombre; i++) {
    466     choixElementDessin_->addItem(dtmanage_->getLabelFromElementNumero(i));
    467     choixHistoDessin_->addItem(dtmanage_->getLabelFromElementNumero(i));
     466    abstractElement* elPtr = dtmanage_->getElementPointerFromNumero(i);
     467    if(elPtr->getNomdElement().getElementType() == snapshot) continue;
     468
     469    choixElementDessin_->addItem(elPtr->getLabel());
     470    choixHistoDessin_->addItem(elPtr->getLabel());
    468471  }
    469472}
     
    537540  envDialog->show();
    538541     
    539   //       new WText(nameOfCase_ + " : enveloppe", toto);
    540542  unsigned nbel = dtmanage_->getBeamLineSize();
    541543  vector<double> xcor;
    542544  vector<double> ycor;
    543   dtmanage_->donneesRmsEnveloppe(type,1, nbel, xcor,ycor);
     545  //dtmanage_->donneesRmsEnveloppe(type,1, nbel, xcor,ycor);
     546  dtmanage_->donneesRmsEnveloppe(type,nbel,xcor,ycor);
    544547  scatterPlot1D(envDialog->contents(),xcor,ycor); 
    545548}
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_softwarePanel.cc

    r316 r343  
    2121
    2222GWt_softwarePanel::GWt_softwarePanel(dataManager* dataManager,PspaApplication* pspa)
    23 : WContainerWidget() {
    24    
    25     dtmanage_ = dataManager;
    26     pspa_ = pspa;
    27     setMaximumSize(600,150);
    28     setMinimumSize(600,150);
    29    
    30     // bouton execute
    31     exec_go_ = new WPushButton("execute!");
    32     //    exec_go_->setMinimumSize(300,300);
    33     exec_go_->setDisabled(true);
    34     exec_go_->clicked().connect(this, &GWt_softwarePanel::executer);
    35    
    36     // preparation du bouton add
    37     WPushButton* exec_add = new WPushButton("add");
    38     exec_add->clicked().connect(this, &GWt_softwarePanel::addSectionToExecuteW);
    39    
    40     // preparation du bouton delete
    41     WPushButton* exec_delete = new WPushButton("delete");
    42     exec_delete->clicked().connect(this, &GWt_softwarePanel::deleteSectionToExecuteW);
    43    
    44     // preparation du bouton push_ok
    45     WPushButton* exec_ok = new WPushButton("check/ok");
    46     exec_ok->clicked().connect(this, &GWt_softwarePanel::checkSectionSelection);
    47    
    48     // le panel
    49     WPanel *panelLogiciels = new WPanel(this);
    50     panelLogiciels->setTitle(" sections of beam Line for executing softwares ");
    51    
    52     contenuSections_ = new WContainerWidget();
    53     contenuSections_->addWidget(exec_add);
    54     contenuSections_->addWidget(exec_delete);
    55     contenuSections_->addWidget(exec_ok);
    56     contenuSections_->addWidget(exec_go_);
    57     contenuSections_->addWidget(new WBreak());
    58     contenuSections_->addWidget(new WBreak());
    59     addSectionToExecuteW();
    60    
    61     panelLogiciels->setCentralWidget(contenuSections_);
    62 }
    63 
     23  : WContainerWidget()
     24{
     25  dtmanage_ = dataManager;
     26  pspa_ = pspa;
     27  setMaximumSize(600,150);
     28  setMinimumSize(600,150);
     29   
     30  // bouton execute
     31  exec_go_ = new WPushButton("execute!");
     32  //    exec_go_->setMinimumSize(300,300);
     33  exec_go_->setDisabled(true);
     34  exec_go_->clicked().connect(this, &GWt_softwarePanel::executer);
     35 
     36  // preparation du bouton add
     37  WPushButton* exec_add = new WPushButton("add");
     38  exec_add->clicked().connect(this, &GWt_softwarePanel::addSectionToExecuteW);
     39   
     40  // preparation du bouton delete
     41  WPushButton* exec_delete = new WPushButton("delete");
     42  exec_delete->clicked().connect(this, &GWt_softwarePanel::deleteSectionToExecuteW);
     43   
     44  // preparation du bouton push_ok
     45  WPushButton* exec_ok = new WPushButton("check/ok");
     46  exec_ok->clicked().connect(this, &GWt_softwarePanel::checkSectionSelection);
     47 
     48  // le panel
     49  WPanel *panelLogiciels = new WPanel(this);
     50  panelLogiciels->setTitle(" sections of beam Line for executing softwares ");
     51 
     52  contenuSections_ = new WContainerWidget();
     53  contenuSections_->addWidget(exec_add);
     54  contenuSections_->addWidget(exec_delete);
     55  contenuSections_->addWidget(exec_ok);
     56  contenuSections_->addWidget(exec_go_);
     57  contenuSections_->addWidget(new WBreak());
     58  contenuSections_->addWidget(new WBreak());
     59  addSectionToExecuteW();
     60 
     61  panelLogiciels->setCentralWidget(contenuSections_);
     62}
    6463
    6564GWt_softwarePanel::~GWt_softwarePanel() {
    6665}
    6766
    68 
    6967void GWt_softwarePanel::addSectionToExecuteW()
    70 {
    71    
    72     disableSectionExecute();
    73    
    74     string premierText, dernierText;
    75     if(selectedSections_.size() == 0)
    76     {
    77         premierText = dtmanage_->getLabelFromElementNumero(1);
     68{   
     69  disableSectionExecute();
     70 
     71  string premierText, dernierText;
     72  if(selectedSections_.size() == 0) {
     73    premierText = dtmanage_->getLabelFromElementNumero(1);
     74    dernierText = dtmanage_->getLabelFromElementNumero(dtmanage_->getBeamLineSize());
     75  } else {
     76    dernierText = selectedSections_.back()->fin->text().toUTF8();
     77    int dernierNumero = dtmanage_->getNumeroFromElementLabel(dernierText);
     78    dernierNumero++;
     79    if ( dernierNumero <= dtmanage_->getBeamLineSize() ) {
     80      premierText = dtmanage_->getLabelFromElementNumero(dernierNumero);
     81    } else {
     82      premierText = dtmanage_->getLabelFromElementNumero(dtmanage_->getBeamLineSize());
     83    }
     84    dernierText = premierText;
     85  }
     86 
     87  //  cout << "PspaApplication::addSectionToExecute() : " << premierText << " à  " << dernierText << endl;
     88 
     89  WContainerWidget* newSection = new WContainerWidget;
     90   
     91  selectedSections_.push_back(new GWt_sectionToExecute);
     92  selectedSections_.back()->debut = new WLineEdit();
     93  selectedSections_.back()->debut->setDisabled(true);
     94  selectedSections_.back()->debut->setText(premierText);
     95  selectedSections_.back()->fin = new WLineEdit();
     96  selectedSections_.back()->fin->changed().connect(this,&GWt_softwarePanel::disableSectionExecute);
     97  selectedSections_.back()->fin->setText(dernierText);
     98  selectedSections_.back()->selection = new WComboBox();
     99  selectedSections_.back()->ligneDeWidget = newSection;
     100  newSection->addWidget(new WText(" from : "));
     101  newSection->addWidget(selectedSections_.back()->debut);
     102  newSection->addWidget(new WText(" to : "));
     103  newSection->addWidget(selectedSections_.back()->fin);
     104  newSection->addWidget(selectedSections_.back()->selection);
     105 
     106  contenuSections_->addWidget(newSection);
     107  unsigned nb = nomDeLogiciel::getNumberOfSoftwares();
     108  unsigned k;
     109  for(k = 0; k < nb; k++) {
     110    selectedSections_.back()->selection->addItem(nomDeLogiciel(k).getString());
     111  }
     112}
     113
     114
     115void GWt_softwarePanel::disableSectionExecute()
     116{
     117  exec_go_->setDisabled(true);
     118}
     119
     120
     121void GWt_softwarePanel::checkSectionSelection()
     122{
     123  if ( selectedSections_.empty() ) return;
     124 
     125  // traitement de la premiere ligne
     126  // on impose le depart du calcul au premier element
     127  string premier = dtmanage_->getLabelFromElementNumero(1);
     128  (*selectedSections_.begin())->debut->setText(premier);
     129 
     130  string currentString =  (*selectedSections_.begin())->fin->text().toUTF8();
     131  int current = dtmanage_->getNumeroFromElementLabel(currentString);
     132   
     133  // si la fin est mal definie on prend toute la config par defaut
     134  if ( current <= 0 || current > dtmanage_->getBeamLineSize() )
     135    {
     136      current = dtmanage_->getBeamLineSize();
     137      currentString =  dtmanage_->getLabelFromElementNumero(current);
     138      (*selectedSections_.begin())->fin->setText(currentString);
     139    }
     140  current++;
     141  currentString = dtmanage_->getLabelFromElementNumero(current);
     142 
     143  // traitement des suivantes (on avance d'un cran dans la liste)
     144  list<GWt_sectionToExecute*>::iterator itr, itr0;
     145  itr0 = selectedSections_.begin();
     146  itr0++;
     147  for (itr = itr0; itr != selectedSections_.end(); itr++)
     148    {
     149      // debut
     150      if ( current > dtmanage_->getBeamLineSize() )
     151        {
     152          GWt_dialog warningDialog("PSPA :: verification des sections", " bad section definition !", GWt_dialog::Error,true,true);
     153          warningDialog.exec();
     154          return;
     155        }
     156     
     157      (*itr)->debut->setText(currentString);
     158      // fin
     159      string finString =  (*itr)->fin->text().toUTF8();
     160     
     161      int numeroFin = dtmanage_->getNumeroFromElementLabel( finString);
     162     
     163      if ( numeroFin < current || numeroFin > dtmanage_->getBeamLineSize())
     164        {
     165          GWt_dialog warningDialog("PSPA : Checking of sections", " bad section definition !", GWt_dialog::Error, true,true);
     166          warningDialog.exec();
     167          return;
     168        }
     169     
     170      // preparation de la ligne suivante
     171      current = numeroFin +1;
     172      currentString = dtmanage_->getLabelFromElementNumero(current);
     173    }
     174 
     175  if (!areDataCoherent()) {
     176    GWt_dialog warningDialog("PSPA : verification des sections", " donnees incoherentes !", GWt_dialog::Error,true,true);
     177    warningDialog.exec();
     178  }
     179  else
     180    {
     181      exec_go_->setDisabled(false);
     182    }
     183}
     184
     185
     186bool GWt_softwarePanel::areDataCoherent()
     187{
     188  bool caMarche = true;
     189  dtmanage_->initializeExecution();
     190 
     191  list<GWt_sectionToExecute*>::iterator itr;
     192  for(itr = selectedSections_.begin(); itr != selectedSections_.end(); itr++)
     193    {
     194      string debString = (*itr)->debut->text().toUTF8();
     195      string finString = (*itr)->fin->text().toUTF8();
    78196       
    79         dernierText = dtmanage_->getLabelFromElementNumero(dtmanage_->getBeamLineSize());
    80     }
    81     else
    82     {
    83         dernierText = selectedSections_.back()->fin->text().toUTF8();
    84         int dernierNumero = dtmanage_->getNumeroFromElementLabel(dernierText);
    85         dernierNumero++;
    86         if ( dernierNumero <= dtmanage_->getBeamLineSize() )
    87         {
    88             premierText = dtmanage_->getLabelFromElementNumero(dernierNumero);
    89         }
    90         else
    91         {
    92             premierText = dtmanage_->getLabelFromElementNumero(dtmanage_->getBeamLineSize());
    93         }
    94         dernierText = premierText;
    95     }
    96    
    97     //  cout << "PspaApplication::addSectionToExecute() : " << premierText << " à  " << dernierText << endl;
    98    
    99     WContainerWidget* newSection = new WContainerWidget;
    100    
    101     selectedSections_.push_back(new GWt_sectionToExecute);
    102     selectedSections_.back()->debut = new WLineEdit();
    103     selectedSections_.back()->debut->setDisabled(true);
    104     selectedSections_.back()->debut->setText(premierText);
    105     selectedSections_.back()->fin = new WLineEdit();
    106     selectedSections_.back()->fin->changed().connect(this,&GWt_softwarePanel::disableSectionExecute);
    107     selectedSections_.back()->fin->setText(dernierText);
    108     selectedSections_.back()->selection = new WComboBox();
    109     selectedSections_.back()->ligneDeWidget = newSection;
    110     newSection->addWidget(new WText(" from : "));
    111     newSection->addWidget(selectedSections_.back()->debut);
    112     newSection->addWidget(new WText(" to : "));
    113     newSection->addWidget(selectedSections_.back()->fin);
    114     newSection->addWidget(selectedSections_.back()->selection);
    115    
    116     contenuSections_->addWidget(newSection);
    117     unsigned nb = nomDeLogiciel::getNumberOfSoftwares();
    118     unsigned k;
    119     for(k = 0; k < nb; k++) {
    120         selectedSections_.back()->selection->addItem(nomDeLogiciel(k).getString());
    121     }
    122 }
    123 
    124 
    125 void GWt_softwarePanel::disableSectionExecute()
    126 {
    127     exec_go_->setDisabled(true);
    128 }
    129 
    130 
    131 void GWt_softwarePanel::checkSectionSelection()
    132 {
    133     if ( selectedSections_.empty() ) return;
    134    
    135     // traitement de la premiere ligne
    136     // on impose le depart du calcul au premier element
    137     string premier = dtmanage_->getLabelFromElementNumero(1);
    138     (*selectedSections_.begin())->debut->setText(premier);
    139    
    140     string currentString =  (*selectedSections_.begin())->fin->text().toUTF8();
    141     int current = dtmanage_->getNumeroFromElementLabel( currentString);
    142    
    143     // si la fin est mal definie on prend toute la config par defaut
    144     if ( current <= 0 || current > dtmanage_->getBeamLineSize() )
    145     {
    146         current = dtmanage_->getBeamLineSize();
    147         currentString =  dtmanage_->getLabelFromElementNumero(current);
    148         (*selectedSections_.begin())->fin->setText(currentString);
    149     }
    150     current++;
    151     currentString = dtmanage_->getLabelFromElementNumero(current);
    152    
    153     // traitement des suivantes (on avance d'un cran dans la liste)
    154     list<GWt_sectionToExecute*>::iterator itr, itr0;
    155     itr0 = selectedSections_.begin();
    156     itr0++;
    157     for (itr = itr0; itr != selectedSections_.end(); itr++)
    158     {
    159         // debut
    160         if ( current > dtmanage_->getBeamLineSize() )
    161         {
    162             GWt_dialog warningDialog("PSPA : VÈrification des sections", " bad section definition !", GWt_dialog::Error,true,true);
    163             warningDialog.exec();
    164             return;
    165         }
    166        
    167         (*itr)->debut->setText(currentString);
    168         // fin
    169         string finString =  (*itr)->fin->text().toUTF8();
    170        
    171         int numeroFin = dtmanage_->getNumeroFromElementLabel( finString);
    172        
    173         if ( numeroFin < current || numeroFin > dtmanage_->getBeamLineSize())
    174         {
    175             GWt_dialog warningDialog("PSPA : Checking of sections", " bad section definition !", GWt_dialog::Error, true,true);
    176             warningDialog.exec();
    177             return;
    178         }
    179        
    180         // preparation de la ligne suivante
    181         current = numeroFin +1;
    182         currentString = dtmanage_->getLabelFromElementNumero(current);
    183     }
    184    
    185     if (!areDataCoherent()) {
    186         GWt_dialog warningDialog("PSPA : VÈrification des sections", " donnees incoherentes !", GWt_dialog::Error,true,true);
    187         warningDialog.exec();
    188     }
    189     else
    190     {
    191         exec_go_->setDisabled(false);
    192     }
    193 }
    194 
    195 
    196 bool GWt_softwarePanel::areDataCoherent()
    197 {
    198     bool caMarche = true;
    199     dtmanage_->initializeExecution();
    200    
    201     list<GWt_sectionToExecute*>::iterator itr;
    202     for(itr = selectedSections_.begin(); itr != selectedSections_.end(); itr++)
    203     {
    204         string debString = (*itr)->debut->text().toUTF8();
    205         string finString = (*itr)->fin->text().toUTF8();
    206        
    207        
    208         int debut = dtmanage_->getNumeroFromElementLabel(debString);
    209         int fin = dtmanage_->getNumeroFromElementLabel(finString);
    210         nomDeLogiciel prog = nomDeLogiciel ( (*itr)->selection->currentIndex() );
    211         dtmanage_->addSectionToExecute(debut,fin,prog);
    212     }
    213    
    214     string diagnostic;
    215     trivaluedBool essai = dtmanage_->checkExecute(diagnostic);
    216     if ( essai == error ) {
    217         caMarche = false;
    218         GWt_dialog calculDialog("PSPA check execute : ERROR", diagnostic , GWt_dialog::Error,true,true);
    219         calculDialog.exec();
    220     } else if ( essai == warning )  {
    221         caMarche = true;
    222         GWt_dialog calculDialog("PSPA check execute : warning ", diagnostic , GWt_dialog::Warning, false,true);
    223         calculDialog.exec();
    224     }
    225    
    226     return caMarche;
    227 }
    228 
     197      int debut = dtmanage_->getNumeroFromElementLabel(debString);
     198      int fin = dtmanage_->getNumeroFromElementLabel(finString);
     199      nomDeLogiciel prog = nomDeLogiciel ( (*itr)->selection->currentIndex() );
     200      dtmanage_->addSectionToExecute(debut,fin,prog);
     201    }
     202 
     203  string diagnostic;
     204  trivaluedBool essai = dtmanage_->checkExecute(diagnostic);
     205  if ( essai == error ) {
     206    caMarche = false;
     207    GWt_dialog calculDialog("PSPA check execute : ERROR", diagnostic , GWt_dialog::Error,true,true);
     208    calculDialog.exec();
     209  } else if ( essai == warning )  {
     210    caMarche = true;
     211    GWt_dialog calculDialog("PSPA check execute : warning ", diagnostic , GWt_dialog::Warning, false,true);
     212    calculDialog.exec();
     213  }
     214 
     215  return caMarche;
     216}
    229217
    230218void GWt_softwarePanel::deleteSectionToExecuteW()
    231219{
    232     if ( selectedSections_.empty() ) return;
    233     disableSectionExecute();
    234     selectedSections_.back()->ligneDeWidget->clear();
    235     delete selectedSections_.back()->ligneDeWidget;
    236     selectedSections_.pop_back();
     220  if ( selectedSections_.empty() ) return;
     221  disableSectionExecute();
     222  selectedSections_.back()->ligneDeWidget->clear();
     223  delete selectedSections_.back()->ligneDeWidget;
     224  selectedSections_.pop_back();
    237225}
    238226
     
    240228void GWt_softwarePanel::updateSelections()
    241229{
    242     string premierText, dernierText;
    243     if ( selectedSections_.size() > 0 )
    244     {
    245         premierText = dtmanage_->getLabelFromElementNumero(1);
    246         dernierText = dtmanage_->getLabelFromElementNumero( dtmanage_->getBeamLineSize() );
    247         (*selectedSections_.begin())->debut->setText(premierText);
    248         (*selectedSections_.begin())->fin->setText(dernierText);
    249     }
    250    
    251     cout << "PspaApplication::updateSelections(): " << premierText << " à  " << dernierText << endl;
     230  string premierText, dernierText;
     231  if ( selectedSections_.size() > 0 )
     232    {
     233      premierText = dtmanage_->getLabelFromElementNumero(1);
     234      dernierText = dtmanage_->getLabelFromElementNumero( dtmanage_->getBeamLineSize() );
     235      (*selectedSections_.begin())->debut->setText(premierText);
     236      (*selectedSections_.begin())->fin->setText(dernierText);
     237    }
     238 
     239  cout << "PspaApplication::updateSelections(): " << premierText << " à  " << dernierText << endl;
    252240}
    253241
     
    255243string GWt_softwarePanel::getSelection()
    256244{
    257     list<GWt_sectionToExecute*>::iterator itr = selectedSections_.begin();
    258     string str = (*itr)->fin->text().toUTF8();
    259     return str;
     245  list<GWt_sectionToExecute*>::iterator itr = selectedSections_.begin();
     246  string str = (*itr)->fin->text().toUTF8();
     247  return str;
    260248}
    261249
     
    263251void GWt_softwarePanel::executer()
    264252{
    265     GWt_console* console = NULL;
    266     if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
    267         console = static_cast<GWt_console*> (wApp->findWidget ("console"));
    268         console->addConsoleMessage(string("on va peut etre y arriver"));
    269     }
    270    
    271    
    272     static_cast<GWt_globalParameters*>(pspa_->getGlobalParam())->updateGlobals();
    273    
    274     GWt_dialog calculDialog("Calcul en cours", "Veuillez patienter...", GWt_dialog::Wait, true,false);
    275     calculDialog.show();
    276    
    277     wApp->processEvents();
    278    
    279     //    string resultat;
    280     if ( !dtmanage_->executeAll()) {
    281         GWt_dialog warningDialog("PSPA : Echec", " echec lors de l'exÈcution !", GWt_dialog::Error, true,true);
    282         warningDialog.exec();
    283     }
    284     //    cout << " PspaApplication : retour d'execution resultat =  " << resultat << endl;
    285 
    286 
    287 
    288     // if (console) {
    289     //     console->addConsoleMessage(resultat);
    290     // }
    291     //  cout << " PspaApplication : affichage console termine  " << endl;
    292    
    293     exec_go_->setDisabled(true);
    294    
    295     calculDialog.hide();
    296    
    297     pspa_->faireDessin();
    298 }
    299 
    300 
     253  GWt_console* console = NULL;
     254  if (static_cast<GWt_console*> (wApp->findWidget ("console"))) {
     255    console = static_cast<GWt_console*> (wApp->findWidget ("console"));
     256    console->addConsoleMessage(string("on va peut etre y arriver"));
     257  }
     258 
     259  static_cast<GWt_globalParameters*>(pspa_->getGlobalParam())->updateGlobals();
     260 
     261  GWt_dialog calculDialog("Calcul en cours", "Veuillez patienter...", GWt_dialog::Wait, true,false);
     262  calculDialog.show();
     263   
     264  wApp->processEvents();
     265 
     266  if (!dtmanage_->executeAll()) {
     267    GWt_dialog warningDialog("PSPA : Echec", " echec lors de l'exÈcution !", GWt_dialog::Error, true,true);
     268    warningDialog.exec();
     269  }
     270     
     271  exec_go_->setDisabled(true);
     272  calculDialog.hide(); 
     273  pspa_->faireDessin();
     274}
Note: See TracChangeset for help on using the changeset viewer.