Changeset 160 in PSPA for Interface_Web/trunk


Ignore:
Timestamp:
Dec 9, 2012, 1:50:14 PM (12 years ago)
Author:
lemeur
Message:

normalisation nomdElements et nomDeLogiciel

Location:
Interface_Web/trunk/pspaWT
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • Interface_Web/trunk/pspaWT/cmt/requirements

    r156 r160  
    2222#macro PSPSLib_linkopts     " -L${PSPAWTROOT}/$(Platform_bin) -lPSPSLib "
    2323
    24 application pspaWT bareParticle.cc particleBeam.cc GWt_cell.cc GWt_rfgun.cc GWt_soleno.cc GWt_bend.cc GWt_globalParameters.cc GWt_drift.cc GWt_abstractElement.cc dataManager.cc elementsCollection.cc elementDrift.cc elementCell.cc elementRfgun.cc elementSoleno.cc elementBend.cc globalParameters.cc abstractElement.cc GWt_LigneFaisceau.cc GWt_pspaApplication.cc GWt_dialog.cc nomdElements.cc main.cc use_cppflags='" ${lib_PSPSLib_cppflags} "'
     24application pspaWT bareParticle.cc particleBeam.cc GWt_cell.cc GWt_rfgun.cc GWt_soleno.cc GWt_bend.cc GWt_globalParameters.cc GWt_drift.cc GWt_abstractElement.cc dataManager.cc elementsCollection.cc elementDrift.cc elementCell.cc elementRfgun.cc elementSoleno.cc elementBend.cc globalParameters.cc abstractElement.cc GWt_LigneFaisceau.cc GWt_pspaApplication.cc GWt_dialog.cc nomdElements.cc nomDeLogiciel.cc main.cc use_cppflags='" ${lib_PSPSLib_cppflags} "'
    2525
    2626macro DrawWt_linkopts " ${PSPSLib_linkopts} ${Wt_linkopts} ${boost_linkopts} ${dld_linkopts}"
  • Interface_Web/trunk/pspaWT/include/nomDeLogiciel.h

    r107 r160  
    44#include <string>
    55
     6using namespace std;
    67
    78class nomDeLogiciel
     
    2324  int value_;
    2425
    25   static Logiciel fromString( std::string s)
    26   {
    27     if (s == "parmela" ) return parmela;
    28     else if ( s == "transport" ) return transport;
    29     return unknownSoftware;
    30   }
    31 
    32   static std::string toString( Logiciel lg)
    33   {
    34     switch (lg)
    35       {
    36       case parmela : { return "parmela"; }
    37       case transport : { return "transport"; }
    38       case unknownSoftware : { return "unknownSoftware"; }
    39       }
    40     return "unknownSoftware";
    41   }
    42  
    43   static Logiciel fromValue( int v)
    44   {
    45     switch (v)
    46       {
    47       case 0 : { return parmela; }
    48       case 1 : { return transport; }
    49       }
    50     return unknownSoftware;
    51   }
    52  
    53   static int toValue( Logiciel lg)
    54   {
    55     switch (lg)
    56       {
    57       case parmela : { return 0; }
    58       case transport : { return 1; }
    59       case unknownSoftware :  { return 2; }
    60       }
    61     return -1;
    62   }
     26  static Logiciel fromString( std::string s);
     27  static std::string toString( Logiciel lg); 
     28  static Logiciel fromValue( int v); 
     29  static int toValue( Logiciel lg);
    6330 
    6431 public :
    6532  // constructors
    6633 
    67  nomDeLogiciel() : program_(transport)
    68   {
    69     progString_ = toString(program_);
    70     value_ = toValue(program_);
    71   }
     34  nomDeLogiciel(); 
     35  nomDeLogiciel(const string& s); 
     36  nomDeLogiciel(int val);
    7237 
    73  
    74   nomDeLogiciel(const string& s)
    75     {
    76       program_ = fromString(s);
    77       progString_ = toString(program_);
    78       value_ = toValue(program_);
    79     }
    80  
    81   nomDeLogiciel(int val)
    82     { 
    83       program_ = fromValue(val);
    84       progString_ = toString(program_);
    85       value_ = toValue(program_);
    86     }
    87  
    88   static int getNumberOfSoftwares() { return toValue(unknownSoftware);}
     38  static int getNumberOfSoftwares();
    8939 
    9040  inline std::string getString() const {return progString_;}
     
    9242  // operators
    9343 
    94   nomDeLogiciel& operator= (const nomDeLogiciel& nl)
    95     {
    96       program_ = nl.program_;
    97       progString_ = nl.progString_;
    98       value_ = nl.value_;
    99       return *this;
    100     }
    101  
    102   bool operator== (const nomDeLogiciel& nl)
    103   {
    104     return ( program_ == nl.program_);
    105   }
    106  
    107   bool operator!= (const nomDeLogiciel& nl)
    108   {
    109     return ( program_ != nl.program_);
    110   }
     44  nomDeLogiciel& operator= (const nomDeLogiciel& nl); 
     45  bool operator== (const nomDeLogiciel& nl); 
     46  bool operator!= (const nomDeLogiciel& nl);
    11147 
    11248};
  • Interface_Web/trunk/pspaWT/include/nomdElements.h

    r153 r160  
    66enum typedElement {RFgun, drift, cell, bend, soleno, inconnu};
    77
     8
     9
    810class nomdElements
    911{
    10   typedElement e_;
    11   std::string eStr_;
    12   std::string eImg_;
     12  typedElement e_;  // type entier (enum)
     13  std::string eName_;  // nom de l'element
     14  std::string eImg_;  // nom du fichier de l'icone
     15  std::string eLabel_; // label affiche sous l'icone
    1316
    14   typedElement fromString(std::string s);
    15   std::string toString(typedElement eType);
    16   std::string toImage(typedElement eType);
     17
     18  static   typedElement fromImage(std::string s);
     19  static   std::string toName(typedElement eType);
     20  static   std::string toImage(typedElement eType);
     21  static   std::string toLabel(typedElement eType);
    1722
    1823 public :
     
    2631
    2732  static int getNumberOfElements();
     33  static string getImageFromType( typedElement tp);
     34  static std::string getLabelFromType(typedElement tp);
     35
    2836  typedElement getElementType() const;
    2937  std::string getElementName() const;
  • Interface_Web/trunk/pspaWT/src/GWt_LigneFaisceau.cc

    r156 r160  
    2222  int nElts= nomdElements::getNumberOfElements();
    2323  nObjets_= new Compteur[nElts];
    24   nomdElements *e;
    2524  for(int k = 0; k < nElts; k++) {
    2625    typedElement eType= (typedElement)k;
    27     e= new nomdElements(eType);
    28     acceptDrops(e->getElementImage());
    29     delete e;
     26    acceptDrops(nomdElements::getImageFromType(eType));
    3027  }
    3128
     
    9895    {     
    9996      abstractElement* ptr = pspa_->getDataManager()->getCollection()->getElementPointer(k);
    100       //     typedElement eType= ptr->getName();
    101       //      nomdElements e(eType);
    102 
    103       //      GWt_abstractElement* gw = GWt_abstractElement::ajoute(pspa_,ptr, ptr->getName().getElementImage());
    10497      GWt_abstractElement* gw = GWt_abstractElement::ajoute(pspa_,ptr);
    10598      if(gw == NULL) {
  • Interface_Web/trunk/pspaWT/src/GWt_abstractElement.cc

    r156 r160  
    1919
    2020  dropped_ = new WPushButton();
    21   //  dropped_->setIcon(image);
    2221  dropped_->setIcon(element_->getName().getElementImage());
    2322  dropped_->setMaximumSize(50,50);
  • Interface_Web/trunk/pspaWT/src/GWt_pspaApplication.cc

    r152 r160  
    111111  int nElts= nomdElements::getNumberOfElements();
    112112
    113  nomdElements *e;
    114113  for(int k = 0; k < nElts; k++) {
    115114    typedElement eType= (typedElement)k;
    116     e= new nomdElements(eType);
    117     string image = e->getElementImage();
     115    string image = nomdElements::getImageFromType(eType);
    118116    createDragImage(image.c_str(),
    119                     image.c_str(),image.c_str(), palette,e->getElementLabel());
     117                    image.c_str(),image.c_str(), palette,nomdElements::getLabelFromType(eType));
    120118  new WBreak(palette);
    121     delete e;
    122119  }
    123120
  • Interface_Web/trunk/pspaWT/src/nomdElements.cc

    r153 r160  
    44#include "nomdElements.h"
    55
    6 typedElement nomdElements::fromString(std::string s)
     6typedElement nomdElements::fromImage(std::string s)
    77{
    88  if( strstr(s.c_str(),"rfgun") ) return RFgun;
     
    1414}
    1515
    16 std::string nomdElements::toString(typedElement eType)
     16std::string nomdElements::toName(typedElement eType)
    1717{
    1818  switch(eType) {
     
    3838}
    3939
     40std::string nomdElements::toLabel(typedElement eType)
     41{
     42  switch(eType) {
     43  case RFgun : return "RFgun";
     44  case drift :  return "drift";
     45  case cell :  return "cell";
     46  case bend :  return "bend";
     47  case soleno :   return "solnd";
     48  default : return string("");
     49  }
     50}
     51
     52
    4053nomdElements::nomdElements()
    4154{
    42   e_= fromString("");
    43   eStr_= toString(e_);
    44   eImg_= toImage(e_);
     55  e_= fromImage("");
     56  eName_ = toName(e_);
     57  eImg_ = toImage(e_);
     58  eLabel_ = toLabel(e_);
    4559}
    4660
     
    4862{
    4963  e_= ne.e_;
    50   eStr_= ne.eStr_;
    51   eImg_= ne.eImg_;
     64  eName_ = ne.eName_;
     65  eImg_ = ne.eImg_;
     66  eLabel_ = ne.eLabel_;
    5267}
    5368
     
    5570{
    5671  e_= ne.e_;
    57   eStr_= ne.eStr_;
    58   eImg_= ne.eImg_;
     72  eName_ = ne.eName_;
     73  eImg_ = ne.eImg_;
     74  eLabel_ = ne.eLabel_;
    5975}
    6076 
     
    6278nomdElements::nomdElements(const std::string& s)
    6379{
    64   e_= fromString(s);
    65   eStr_= toString(e_);
    66   eImg_= toImage(e_);
     80  e_= fromImage(s);
     81  eName_ = toName(e_);
     82  eImg_ = toImage(e_);
     83  eLabel_ = toLabel(e_);
    6784}
    6885
     
    7087{
    7188  e_= eType;
    72   eStr_= toString(e_);
    73   eImg_= toImage(e_);
     89  eName_ = toName(e_);
     90  eImg_ = toImage(e_);
     91  eLabel_ = toLabel(e_);
    7492}
    7593
     
    7896}
    7997
     98std::string nomdElements::getImageFromType( typedElement tp)
     99{
     100  return toImage(tp);
     101}
     102
     103std::string nomdElements::getLabelFromType(typedElement tp)
     104{
     105  return toLabel(tp);
     106}
     107
     108
     109
     110
    80111typedElement nomdElements::getElementType() const {
    81112  return e_;
     
    83114
    84115std::string nomdElements::getElementName() const {
    85   return eStr_;
     116  return eName_;
    86117}
    87118
     
    92123std::string nomdElements::getElementLabel() const
    93124{
    94   switch(e_) {
    95   case RFgun : return "RFgun"; break;
    96   case drift : return "drift"; break;
    97   case cell : return "cell"; break;
    98   case bend : return "bend"; break;
    99   case soleno : return "solnd"; break;
    100   default : return "";
    101   }
     125  return eLabel_;
    102126}
     127
     128
     129
    103130
    104131// operators
     
    107134{
    108135  e_= ne.e_;
    109   eStr_= ne.eStr_;
    110   eImg_= ne.eImg_;
     136  eName_ = ne.eName_;
     137  eImg_ = ne.eImg_;
     138  eLabel_ = ne.eLabel_;
    111139}
Note: See TracChangeset for help on using the changeset viewer.