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

systeme periodique (mailles) + multipoles + madx

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_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 
Note: See TracChangeset for help on using the changeset viewer.