Changeset 320 in PSPA


Ignore:
Timestamp:
Feb 12, 2013, 2:21:19 PM (11 years ago)
Author:
garnier
Message:

Début de stockage de façon plus générique des parametres (ne change rien pour le moment)

Location:
Interface_Web/trunk/pspaWT
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • Interface_Web/trunk/pspaWT/History

    r319 r320  
    8812 Février 2013 Laurent Garnier
    99- Correction du fond qui ne passait pas sur le serveur
     10- GWt_abstractElement : Début de stockage de façon plus générique des parametres (ne change rien pour le moment)
    1011
    11125 Février 2013 Laurent Garnier
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_abstractElement.h

    r310 r320  
    2020#include <Wt/WContainerWidget>
    2121
     22#include <boost/variant.hpp>
     23
    2224using namespace Wt;
    2325using namespace std;
     26using namespace boost;
    2427
    2528class GWt_elementLigneFaisceau;
     29
     30// defined to ensure that the boost::variant could return something even when there is nothing
     31class NullType {};
    2632
    2733class GWt_abstractElement : public WContainerWidget
     
    7177    WImage* image_;
    7278    GWt_elementLigneFaisceau* elementLigneFaiseauContainer_;
     79
     80   
     81    // Nom, type de parametre
     82    std::map<std::string, variant<int, string, bool, float, NullType> > parameterMapValue;
     83    std::map<std::string, std::string > parameterMapDescription;
     84   
     85    inline void registerParam(string name, variant<int, string, bool, float, NullType> value, string desc) {
     86        parameterMapValue[name] = value;
     87        parameterMapDescription[name] = desc;
     88    }
     89   
     90    variant<int, string, bool, float, NullType> getParamValue(string elem);
     91    string getParamDescription(string elem);
     92
    7393};
    7494#endif
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_abstractElement.cc

    r311 r320  
    22#include <iostream>
    33#include <string>
     4#include <boost/variant.hpp>
     5#include <boost/variant/get.hpp>
    46
    57#include "GWt_abstractElement.h"
     
    2426#include <Wt/WMessageBox>
    2527
     28
    2629GWt_abstractElement::GWt_abstractElement(abstractElement* elem)
    2730: WContainerWidget()
     
    146149    }
    147150}
     151
     152
     153
     154variant<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();
     191}
     192
     193
     194string 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}
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_beam.cc

    r310 r320  
    1919void GWt_beam::initilializeDialog() {
    2020    string* param = beginDialog();
    21    
     21
     22    registerParam("int____",2000, " 1/2 horizontal beam extend rms (cm) : ");
     23    getParamValue("int____");
     24    getParamDescription("int____");
     25    registerParam("bool____",true, " 1/2 horizontal beam extend rms (cm) : ");
     26    getParamValue("bool____");
     27    getParamDescription("bool____");
     28
     29    string t = "ttttt";
     30    registerParam("str____",t, " 1/2 horizontal beam extend rms (cm) : ");
     31    getParamValue("str____");
     32    getParamDescription("str____");
     33
    2234    new WText(" 1/2 horizontal beam extend rms (cm) : ",dialog_->contents());
    2335    xEdit_ = new WLineEdit(param->c_str(), dialog_->contents());
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc

    r312 r320  
    274274    dessin->addWidget(caroule);
    275275    dessin->addWidget(new WBreak());
    276    
     276
     277
    277278   
    278279   
     
    282283    WPushButton* okHisto = new WPushButton("histogramme");
    283284    dessin->addWidget(okHisto);
     285
    284286    okHisto->clicked().connect(this,&PspaApplication::dessinerHistogramme);
    285287    /////////////////////////////////////////////////////////////////////
     
    359361    GWt_globalParameters* bibi = static_cast<GWt_globalParameters*>(globalParam_);
    360362    bibi->renew();
    361    
    362     GWt_LigneFaisceau* bobo = static_cast<GWt_LigneFaisceau*>(beamLine_);
    363 //    bobo->restoreElementCollectionFromDataManager();
    364    
     363       
    365364    console_->addConsoleMessage(string("...terminee"));
    366365}
Note: See TracChangeset for help on using the changeset viewer.