Changeset 305 in PSPA for Interface_Web
- Timestamp:
- Feb 1, 2013, 8:08:52 PM (11 years ago)
- Location:
- Interface_Web/trunk/pspaWT
- Files:
-
- 36 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/History
r302 r305 6 6 ========================================================= 7 7 8 31 Janvier 2012 Laurent Garnier 8 1er Février 2013 Laurent Garnier 9 - Suppression de la classe "elementsCollection", celle-ci stockait le contenu de 10 la beamLine, qui était déja stokée de façon graphique, toutes les méthodes ont étées 11 reportées sur le dataManager 12 13 - abstractSoftware, softwareTransport, softwareParmela : 14 o remplacement de "elementsCollection" par "dataManager" 15 16 - dataManager : Ajout des méthodes provenant de "elementsCollection" 17 - GWt_elementLigneFaisceau : 18 o suppression de l'image "fleche" et quelques renommages 19 - GWt_bend, GWt_drift, GWt_beam 20 GWt_soleno, GWt_fit, GWt_rfgun 21 GWt_cell : quelques simplifications internes 22 - GWt_LigneFaisceau : 23 o Ajout des méthodes provenant de "elementsCollection" 24 o mise à jour des labels à chaque ajout d'élément 25 - PspaApplication : qq changements pour la lecture/sauvegarde des éléments (bug fixed #20) 26 - GWt_abstractElement : quelques renommages 27 - GWt_softwarePanel : remplacement de "elementsCollection" par "dataManager" 28 29 31 Janvier 2013 Laurent Garnier 9 30 - dataManager : Suppression des références au workingDir et passage de 10 31 cette variable dans la classe elle même … … 13 34 - GWt_softwarePanel : Création de cette classe pour gérer l'ancien "executeWidget" 14 35 15 30 Janvier 201 2Laurent Garnier36 30 Janvier 2013 Laurent Garnier 16 37 - dataManager : Ajout de la méthode removeElement() 17 38 - GWt_elementLigneFaisceau : Amélioration de la gestion interne à cette classe … … 29 50 classes héritées softwareParmela, softwareTransport 30 51 31 29 Janvier 201 2Laurent Garnier52 29 Janvier 2013 Laurent Garnier 32 53 - Ajout de la classe GWt_abstractElementFactory 33 54 - GWt_bend, GWt_drift, GWt_beam … … 45 66 - GWt_pspaApplication : ajout d'une abstractElementFactory 46 67 47 28 Janvier 201 2Laurent Garnier68 28 Janvier 2013 Laurent Garnier 48 69 - GWt_ligneFaisceau: 49 70 o Suppression de code inutile … … 65 86 o Remise en ordre du label sans les 999 66 87 67 25 Janvier 201 2Laurent Garnier88 25 Janvier 2013 Laurent Garnier 68 89 - Insertion dans la drop box ok + images ok 69 90 - Restaurer la config refonctionne 70 91 - Avec un ascenseur qui marche mieux 71 92 72 24 Janvier 201 2Laurent Garnier93 24 Janvier 2013 Laurent Garnier 73 94 - Ameliorations sur la drop zone 74 95 - re-identation du code dans la partie graphique 75 96 - Insertion dans la drop box ok 76 97 77 23 Janvier 201 2Laurent Garnier98 23 Janvier 2013 Laurent Garnier 78 99 - quelques renommages et améliorations sur la drop zone 79 100 80 22 Janvier 201 2Laurent Garnier101 22 Janvier 2013 Laurent Garnier 81 102 - Fix probleme de compilation introduit par la derniÚre revision (260) 82 103 - refactoring (suite) 83 104 84 21 Janvier 201 2Laurent Garnier105 21 Janvier 2013 Laurent Garnier 85 106 - Grosse modifications pour une meilleur gestion des drag & drop (a terminer) 86 107 - Deplacement des styles dans la feuille css … … 90 111 - refactoring 91 112 92 19 Janvier 201 2Laurent Garnier113 19 Janvier 2013 Laurent Garnier 93 114 - Ajout d'icones pour la toolbar et d'un fond sur le programme 94 115 95 18 Janvier 201 2Laurent Garnier116 18 Janvier 2013 Laurent Garnier 96 117 - Mise à jour de la partie web (drop zone). Aucune modification majeures, 97 118 uniquement des méthodes modifiées en vue de faire mieux. Quelques problÚmes -
Interface_Web/trunk/pspaWT/sources/controler/include/abstractSoftware.h
r304 r305 11 11 using namespace std; 12 12 13 class dataManager; 14 13 15 class abstractSoftware 14 16 { … … 17 19 18 20 globalParameters* globParamPtr_; 19 elementsCollection* beamLinePtr_;21 dataManager* dataManager_; 20 22 21 23 … … 26 28 public : 27 29 28 abstractSoftware(globalParameters* globals, elementsCollection* beamLine);30 abstractSoftware(globalParameters* globals, dataManager* dt); 29 31 ~abstractSoftware() {;} 30 32 -
Interface_Web/trunk/pspaWT/sources/controler/include/dataManager.h
r302 r305 13 13 #include "parmelaParticle.h" 14 14 15 15 class PspaApplication; 16 16 17 17 class dataManager 18 18 { 19 19 20 elementsCollection elementsGallery_;21 globalParameters globParam_;22 particleBeam* currentBeam_;23 24 vector<particleBeam> diagnosticBeam_;25 26 vector<sectionToExecute*> jobList_;27 28 void removeFile(string nameOfFile);29 void clearSectionToExecute();30 20 public: 31 21 32 dataManager() { 33 currentBeam_ = NULL; 34 workingDir_=""; 35 } 36 ~dataManager() { 37 unsigned k; 38 for (k=0; k < jobList_.size();k++) { 39 if ( jobList_[k] != NULL ) delete jobList_[k]; 40 } 41 if ( currentBeam_ == NULL ) delete currentBeam_; 42 } 22 dataManager(PspaApplication*); 23 virtual ~dataManager(); 43 24 44 inline int beamLineSize() {return elementsGallery_.size();}25 inline int getBeamLineSize(); 45 26 inline globalParameters* getGlobalParameters() {return &globParam_;} 46 inline elementsCollection* getCollection() {return &elementsGallery_;}27 // inline elementsCollection* getCollection() {return &elementsGallery_;} 47 28 inline particleBeam* getCurrentBeam() {return currentBeam_;} 48 29 … … 53 34 abstractElement* addElement(typedElement elemType); 54 35 void removeElement(string); 36 37 /** 38 Get the label from the order number in the beam line 39 @return return "" if not found 40 */ 55 41 string getLabelFromElementNumero(int numero); 42 43 /** 44 Get the numero from the label in the beam line 45 @return return -1 if not found 46 */ 47 int getNumeroFromElementLabel(string); 48 abstractElement* getElementPointerFromIndex(int); 49 56 50 void initializeExecution(); 57 51 trivaluedBool checkExecute(string& diagnostic); … … 66 60 67 61 private: 62 // elementsCollection elementsGallery_; 63 globalParameters globParam_; 64 particleBeam* currentBeam_; 65 66 vector<particleBeam> diagnosticBeam_; 67 68 vector<sectionToExecute*> jobList_; 69 70 void removeFile(string nameOfFile); 71 void clearSectionToExecute(); 72 68 73 string workingDir_; 74 PspaApplication* pspa_; 69 75 }; 70 76 #endif -
Interface_Web/trunk/pspaWT/sources/controler/include/elementsCollection.h
r295 r305 27 27 abstractElement* getElementPointerFromNumero(int num) const; 28 28 29 int getNumeroFrom Label(string lab);29 int getNumeroFromElementLabel(string lab); 30 30 31 31 void eraseElement(string label); -
Interface_Web/trunk/pspaWT/sources/controler/include/softwareGenerator.h
r304 r305 18 18 19 19 20 softwareGenerator(globalParameters* globals, elementsCollection* beamLine);20 softwareGenerator(globalParameters* globals, dataManager* ); 21 21 22 22 virtual ~softwareGenerator() {;} -
Interface_Web/trunk/pspaWT/sources/controler/include/softwareParmela.h
r304 r305 14 14 15 15 public : 16 softwareParmela(globalParameters* globals, elementsCollection* beamLine);16 softwareParmela(globalParameters* globals, dataManager* beamLine); 17 17 18 18 virtual ~softwareParmela() {;} -
Interface_Web/trunk/pspaWT/sources/controler/include/softwareTransport.h
r304 r305 14 14 15 15 public : 16 softwareTransport(globalParameters* globals, elementsCollection* beamLine);16 softwareTransport(globalParameters* globals, dataManager* beamLine); 17 17 18 18 virtual ~softwareTransport() {;} -
Interface_Web/trunk/pspaWT/sources/controler/src/abstractSoftware.cc
r295 r305 1 1 #include "abstractSoftware.h" 2 #include "dataManager.h" 2 3 3 4 abstractSoftware::abstractSoftware() … … 6 7 } 7 8 8 abstractSoftware::abstractSoftware(globalParameters* globals, elementsCollection* beamLine) {9 abstractSoftware::abstractSoftware(globalParameters* globals, dataManager* dt) { 9 10 globParamPtr_ = globals; 10 beamLinePtr_ = beamLine;11 dataManager_ = dt; 11 12 } 12 13 -
Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc
r304 r305 4 4 #include "softwareParmela.h" 5 5 #include "softwareTransport.h" 6 #include "GWt_pspaApplication.h" 6 7 #include "softwareGenerator.h" 7 8 … … 10 11 //#include <algorithm> 11 12 12 abstractElement* dataManager::addElement(typedElement elemType) 13 { 14 return elementsGallery_.addElement(elemType); 15 } 16 17 18 void dataManager::removeElement(string elem) { 19 elementsGallery_.eraseElement(elem); 20 } 21 13 14 dataManager::dataManager(PspaApplication* pspa) : 15 currentBeam_(NULL) 16 ,workingDir_("") 17 ,pspa_ ( pspa) 18 { 19 } 20 21 22 dataManager::~dataManager() { 23 unsigned k; 24 for (k=0; k < jobList_.size();k++) { 25 if ( jobList_[k] != NULL ) delete jobList_[k]; 26 } 27 if ( currentBeam_ == NULL ) delete currentBeam_; 28 } 29 30 31 /* 32 abstractElement* dataManager::addElement(typedElement elemType) 33 { 34 return elementsGallery_.addElement(elemType); 35 } 36 37 38 void dataManager::removeElement(string elem) { 39 elementsGallery_.eraseElement(elem); 40 } 41 */ 22 42 23 43 string dataManager::getLabelFromElementNumero(int numero) 24 44 { 25 abstractElement* ptr = elementsGallery_.getElementPointerFromNumero(numero); 26 if ( ptr == NULL ) return ""; 27 return ptr->getLabel(); 45 abstractElement* ptr = pspa_->getBeamLine()->getAbstractElement(numero-1); 46 if ( ptr == NULL ) return ""; 47 return ptr->getLabel(); 48 } 49 50 51 int dataManager::getNumeroFromElementLabel(string label){ 52 int index = -1; 53 unsigned int k; 54 55 for (k = 0; k < getBeamLineSize() ; k++) 56 { 57 if (pspa_->getBeamLine()->getAbstractElement(k) != NULL){ 58 if ( pspa_->getBeamLine()->getAbstractElement(k)->getLabel() == label ) 59 { 60 index = (int)k + 1; 61 return index; 62 } 63 } 64 } 65 return index; 66 } 67 68 69 abstractElement* dataManager::getElementPointerFromIndex(int k){ 70 return pspa_->getBeamLine()->getAbstractElement(k); 28 71 } 29 72 … … 31 74 void dataManager::addSectionToExecute(int debut, int fin, nomDeLogiciel prog) 32 75 { 33 jobList_.push_back(new sectionToExecute);34 jobList_.back()->firstElement = debut;35 jobList_.back()->lastElement = fin;36 jobList_.back()->software = prog;76 jobList_.push_back(new sectionToExecute); 77 jobList_.back()->firstElement = debut; 78 jobList_.back()->lastElement = fin; 79 jobList_.back()->software = prog; 37 80 } 38 81 39 82 void dataManager::clearSectionToExecute() 40 83 { 41 unsigned k;42 for(k = 0; k < jobList_.size(); k++)43 { 44 if ( jobList_[k] != NULL ) delete jobList_[k];45 } 46 jobList_.clear();84 unsigned k; 85 for(k = 0; k < jobList_.size(); k++) 86 { 87 if ( jobList_[k] != NULL ) delete jobList_[k]; 88 } 89 jobList_.clear(); 47 90 } 48 91 49 92 trivaluedBool dataManager::checkExecute(string& diagnostic) 50 93 { 51 cout << "dataManager::checkExecute()" << endl; 94 95 cout << "dataManager::checkExecute()" << endl; 52 96 trivaluedBool resul = ok; 53 97 unsigned k,j; … … 77 121 } 78 122 123 79 124 trivaluedBool dataManager::checkElementsForExec(nomDeLogiciel logiciel, unsigned indexDeb, unsigned indexFin, string& diagnostic) 80 125 { 81 trivaluedBool resul = ok;82 diagnostic.clear();83 trivaluedBool accepted;84 abstractElement* elPtr;85 for(unsigned j = indexDeb; j <= indexFin; j++) {86 elPtr = elementsGallery_.getElementPointerFromIndex(j);87 accepted = elPtr->is_accepted_by_software(logiciel);88 if(accepted == error ) {89 diagnostic += " the element " + elPtr->getNomdElement().getElementName() + " is not allowed with " + logiciel.getString() + " \n";90 resul = error;91 } else if ( accepted == warning ) {92 diagnostic += " the element " + elPtr->getNomdElement().getElementName() + " will be ignored by " + logiciel.getString() + " \n";93 if ( resul != error ) resul = warning;94 }95 }96 return resul;126 trivaluedBool resul = ok; 127 diagnostic.clear(); 128 trivaluedBool accepted; 129 abstractElement* elPtr; 130 for(unsigned j = indexDeb; j <= indexFin; j++) { 131 elPtr = pspa_->getBeamLine()->getAbstractElement(j); 132 accepted = elPtr->is_accepted_by_software(logiciel); 133 if(accepted == error ) { 134 diagnostic += " the element " + elPtr->getNomdElement().getElementName() + " is not allowed with " + logiciel.getString() + " \n"; 135 resul = error; 136 } else if ( accepted == warning ) { 137 diagnostic += " the element " + elPtr->getNomdElement().getElementName() + " will be ignored by " + logiciel.getString() + " \n"; 138 if ( resul != error ) resul = warning; 139 } 140 } 141 return resul; 97 142 } 98 143 … … 114 159 } 115 160 116 void dataManager::removeFile(string nameOfFile) 117 { 118 ifstream fileExists;119 fileExists.open(nameOfFile.c_str(), ios::in);120 if (fileExists) {121 fileExists.close();122 remove(nameOfFile.c_str());123 }161 void dataManager::removeFile(string nameOfFile) 162 { 163 ifstream fileExists; 164 fileExists.open(nameOfFile.c_str(), ios::in); 165 if (fileExists) { 166 fileExists.close(); 167 remove(nameOfFile.c_str()); 168 } 124 169 } 125 170 126 171 bool dataManager::executeAll(string &resul) 127 172 { 128 bool success = true;129 resul.clear();130 string resultatPartiel;131 unsigned k;132 abstractSoftware* softw =NULL;133 134 for(k = 0; k < jobList_.size(); k++)173 bool success = true; 174 resul.clear(); 175 string resultatPartiel; 176 unsigned k; 177 abstractSoftware* softw =NULL; 178 179 for(k = 0; k < jobList_.size(); k++) 135 180 { 136 181 int debut = jobList_[k]->firstElement; … … 141 186 string inputFileName; 142 187 if(jobList_[k]->software == nomDeLogiciel::parmela) { 143 softw = new softwareParmela(&globParam_, &elementsGallery_);188 softw = new softwareParmela(&globParam_, this); 144 189 inputFileName = "parmin"; 145 190 } else if (jobList_[k]->software == nomDeLogiciel::transport) { 146 softw = new softwareTransport(&globParam_, &elementsGallery_);191 softw = new softwareTransport(&globParam_, this); 147 192 inputFileName = "transport.input"; 148 193 } else if (jobList_[k]->software == nomDeLogiciel::generator) { 149 softw = new softwareGenerator(&globParam_, &elementsGallery_);194 softw = new softwareGenerator(&globParam_, this); 150 195 inputFileName = "generator.in"; 151 196 } else { … … 173 218 if ( !success ) break; 174 219 } 175 return success; 176 } 220 return success; 221 } 222 177 223 178 224 void dataManager::saveConfiguration( string nameOfFile) 179 225 { 180 ofstream outfile; 181 string name = workingDir_ + nameOfFile + ".save"; 182 outfile.open(name.c_str(), ios::out); 183 if (!outfile) { 184 cerr << " error opening output file for persistency " << name << endl; 185 } 186 187 outfile << globParam_.FileOutputFlow(); 188 unsigned k; 189 abstractElement* elPtr; 190 for ( k=0 ; k < elementsGallery_.size() ; k++) 191 { 192 elPtr = elementsGallery_.getElementPointerFromIndex(k); 193 outfile << elPtr->FileOutputFlow(); 194 } 195 outfile.close(); 196 } 226 ofstream outfile; 227 string name = workingDir_ + nameOfFile + ".save"; 228 outfile.open(name.c_str(), ios::out); 229 if (!outfile) { 230 cerr << " error opening output file for persistency " << name << endl; 231 } 232 233 outfile << globParam_.FileOutputFlow(); 234 unsigned k; 235 abstractElement* elPtr; 236 for ( k=0 ; k < getBeamLineSize() ; k++) 237 { 238 elPtr = pspa_->getBeamLine()->getAbstractElement(k); 239 outfile << elPtr->FileOutputFlow(); 240 } 241 outfile.close(); 242 } 243 197 244 198 245 bool dataManager::restoreElements( string inputFileName) 199 246 { 200 cout << "dataManager::restoreElements() fichier " << inputFileName << endl; 201 ifstream infile; 202 string name = workingDir_ + inputFileName + ".save"; 203 infile.open(name.c_str(), ios::in); 204 if (!infile) { 205 cerr << " error opening input stream " << name << endl; 206 return false; 207 } 208 else cout << " successful opening input stream " << name << endl; 209 210 string globalTitle; 211 if ( infile >> globalTitle ) { 212 if ( globalTitle == string("globals") ) { 213 globParam_.raz(); 214 globParam_.FileInput(infile); 247 cout << "dataManager::restoreElements() fichier " << inputFileName << endl; 248 ifstream infile; 249 string name = workingDir_ + inputFileName + ".save"; 250 infile.open(name.c_str(), ios::in); 251 if (!infile) { 252 cerr << " error opening input stream " << name << endl; 253 return false; 254 } 255 else cout << " successful opening input stream " << name << endl; 256 257 string globalTitle; 258 if ( infile >> globalTitle ) { 259 if ( globalTitle == string("globals") ) { 260 globParam_.raz(); 261 globParam_.FileInput(infile); 262 } else { 263 cerr << " dataManager::restoreElements ERROR : global parameters seems to be missing" << endl; 264 return false; 265 } 215 266 } else { 216 cerr << " dataManager::restoreElements ERROR : global parameters seems to be missing" << endl; 217 return false; 218 } 219 } else { 220 cerr << " dataManager::restoreElements ERROR : reading data save file" << endl; 221 return false; 222 } 223 224 elementsGallery_.raz(); 225 // typedElement elem; 226 typedElement elementType; 227 string elementLabel; 228 // while (infile >> ielem) { 229 while (infile >> elementLabel) { 230 // elem = (typedElement)ielem; 231 // abstractElement* nouveau = addElement(elem); 232 elementType = nomdElements::getTypeFromLabel(elementLabel); 233 abstractElement* nouveau = addElement( elementType); 234 if ( nouveau == NULL ) { 235 cerr << " dataManager::restoreElements ERROR : restoring element " << elementLabel << " failed " << endl; 236 return false; 237 } 238 nouveau->FileInput(infile); 239 } 240 infile.close(); 241 242 // debug 243 unsigned k; 244 for(k = 0; k < elementsGallery_.size(); k++) { 245 abstractElement* ptr= elementsGallery_.getElementPointerFromIndex(k); 246 cout << "reupere " << ptr->getLabel() << endl; 247 } 248 249 250 return true; 251 } 252 253 particleBeam* dataManager::getDiagnosticBeam(unsigned index) 254 { 255 cout << " particleBeam* dataManager je vais dessiner " << getLabelFromElementNumero(index+1) << endl; 256 257 258 if ( index >= diagnosticBeam_.size() ) { 259 return NULL; 267 cerr << " dataManager::restoreElements ERROR : reading data save file" << endl; 268 return false; 269 } 270 271 pspa_->getBeamLine()->clear(); 272 273 // typedElement elem; 274 typedElement elementType; 275 string elementLabel; 276 // while (infile >> ielem) { 277 while (infile >> elementLabel) { 278 // elem = (typedElement)ielem; 279 // abstractElement* nouveau = addElement(elem); 280 elementType = nomdElements::getTypeFromLabel(elementLabel); 281 // abstractElement* nouveau = addElement( elementType); 282 283 abstractElement* nouveau = pspa_->getBeamLine()->addElement(elementType); 284 285 if ( nouveau == NULL ) { 286 cerr << " dataManager::restoreElements ERROR : restoring element " << elementLabel << " failed " << endl; 287 return false; 288 } 289 nouveau->FileInput(infile); 290 } 291 infile.close(); 292 293 // after adding, set the good label on GUI 294 pspa_->getBeamLine()->update(); 295 296 // debug 297 unsigned k; 298 for(k = 0; k < getBeamLineSize(); k++) { 299 abstractElement* ptr = pspa_->getBeamLine()->getAbstractElement(k); 300 301 cout << "reupere " << ptr->getLabel() << endl; 302 } 303 return true; 304 } 305 306 307 particleBeam* dataManager::getDiagnosticBeam(unsigned index) 308 { 309 310 311 if ( index >= diagnosticBeam_.size() ) { 312 return NULL; 260 313 } 261 314 else { 262 return &diagnosticBeam_.at(index); 263 } 264 } 315 return &diagnosticBeam_.at(index); 316 } 317 } 318 265 319 266 320 void dataManager::donneesRmsEnveloppe( string type, unsigned int numeroDeb, unsigned int numeroFin, vector<double>& xcor, vector<double>& ycor) 267 321 { 268 unsigned k; 269 if ( numeroDeb < 1 ) numeroDeb = 1; 270 if ( numeroFin > diagnosticBeam_.size() ) numeroFin = diagnosticBeam_.size(); 271 272 unsigned indexDeb = numeroDeb -1; 273 unsigned indexFin = numeroFin -1; 274 275 double longueur = 0.0; 276 double valeur = 0.0; 277 xcor.clear(); 278 ycor.clear(); 279 if ( type == "x" ) 280 { 281 for (k= indexDeb; k <= indexFin; k++) 282 { 283 if ( !diagnosticBeam_.at(k).momentRepresentationOk() ) diagnosticBeam_.at(k).buildMomentRepresentation(); 284 longueur += elementsGallery_.getElementPointerFromIndex(k)->getLenghtOfElement(); 285 valeur = diagnosticBeam_.at(k).getXmaxRms(); 286 xcor.push_back(longueur); 287 ycor.push_back(valeur); 288 } 289 } 290 else 291 { 292 cerr << " dataManager::donneesRmsEnveloppe type " << type << " not programmed " << endl; 293 return; 294 } 295 } 296 322 unsigned k; 323 if ( numeroDeb < 1 ) numeroDeb = 1; 324 if ( numeroFin > diagnosticBeam_.size() ) numeroFin = diagnosticBeam_.size(); 325 326 unsigned indexDeb = numeroDeb -1; 327 unsigned indexFin = numeroFin -1; 328 329 double longueur = 0.0; 330 double valeur = 0.0; 331 xcor.clear(); 332 ycor.clear(); 333 if ( type == "x" ) 334 { 335 for (k= indexDeb; k <= indexFin; k++) 336 { 337 if ( !diagnosticBeam_.at(k).momentRepresentationOk() ) diagnosticBeam_.at(k).buildMomentRepresentation(); 338 longueur += pspa_->getBeamLine()->getAbstractElement(k)->getLenghtOfElement(); 339 valeur = diagnosticBeam_.at(k).getXmaxRms(); 340 xcor.push_back(longueur); 341 ycor.push_back(valeur); 342 } 343 } 344 else 345 { 346 cerr << " dataManager::donneesRmsEnveloppe type " << type << " not programmed " << endl; 347 return; 348 } 349 } 350 351 int dataManager::getBeamLineSize() { 352 return pspa_->getBeamLine()->getBeamLineSize(); 353 } -
Interface_Web/trunk/pspaWT/sources/controler/src/elementsCollection.cc
r295 r305 100 100 } 101 101 102 int elementsCollection::getNumeroFrom Label(string lab)102 int elementsCollection::getNumeroFromElementLabel(string lab) 103 103 { 104 104 unsigned int k; -
Interface_Web/trunk/pspaWT/sources/controler/src/softwareGenerator.cc
r304 r305 2 2 #include "abstractElement.h" 3 3 #include "parmelaParticle.h" 4 #include "dataManager.h" 4 5 5 6 … … 12 13 13 14 14 softwareGenerator::softwareGenerator(globalParameters* globals, elementsCollection* beamLine) : abstractSoftware(globals, beamLine)15 softwareGenerator::softwareGenerator(globalParameters* globals, dataManager* dt) : abstractSoftware(globals, dt) 15 16 { 16 17 ; … … 24 25 25 26 abstractElement* elPtr; 26 elPtr = beamLinePtr_->getElementPointerFromNumero(numeroDeb);27 elPtr = dataManager_->getElementPointerFromIndex(numeroDeb); 27 28 28 29 if ( elPtr->getNomdElement().getElementType() != RFgun ) { -
Interface_Web/trunk/pspaWT/sources/controler/src/softwareParmela.cc
r304 r305 4 4 #include "mathematicalConstants.h" 5 5 #include "PhysicalConstants.h" 6 #include "dataManager.h" 6 7 7 8 … … 11 12 } 12 13 13 softwareParmela::softwareParmela(globalParameters* globals, elementsCollection* beamLine) : abstractSoftware(globals, beamLine)14 softwareParmela::softwareParmela(globalParameters* globals, dataManager* dt) : abstractSoftware(globals, dt) 14 15 { 15 16 ; … … 20 21 unsigned int k; 21 22 22 if ( numeroDeb < 1 || numeroFin > beamLinePtr_->size() ) {23 if ( numeroDeb < 1 || numeroFin > dataManager_->getBeamLineSize() ) { 23 24 cerr << " index of element out of limits " << endl; 24 25 return false; … … 26 27 27 28 28 unsigned indexDeb = numeroDeb - 1;29 unsigned indexFin = numeroFin - 1;29 unsigned indexDeb = numeroDeb - 1; 30 unsigned indexFin = numeroFin - 1; 30 31 31 32 ofstream outfile; … … 39 40 abstractElement* elPtr; 40 41 double initalKineticEnergy = 0.0; 41 elPtr = beamLinePtr_->getElementPointerFromIndex(indexDeb);42 elPtr = dataManager_->getElementPointerFromIndex(indexDeb); 42 43 if ( elPtr->getNomdElement().getElementType() != RFgun ) { 43 44 cerr << " dataManager::createInputFileParmela : the first element should be rfgun" << endl; … … 57 58 for ( k = indexDeb; k <= indexFin; k++) 58 59 { 59 elPtr = beamLinePtr_->getElementPointerFromIndex(k);60 elPtr = dataManager_->getElementPointerFromIndex(k); 60 61 outfile << elPtr->parmelaOutputFlow() << endl; 61 62 } … … 131 132 if (!beamFromParmela(workingDir,k, globParamPtr_->getFrequency(), centroid, refPart,particles )) 132 133 { 133 abstractElement* elem = beamLinePtr_->getElementPointerFromNumero(k);134 abstractElement* elem = dataManager_->getElementPointerFromIndex(k); 134 135 if ( elem->is_accepted_by_software(nomDeLogiciel::parmela) == warning) { 135 136 int avantDernier = beams.size() -2; -
Interface_Web/trunk/pspaWT/sources/controler/src/softwareTransport.cc
r304 r305 2 2 #include "abstractElement.h" 3 3 #include "beam2Moments.h" 4 #include "dataManager.h" 4 5 5 6 #include <algorithm> … … 10 11 } 11 12 12 softwareTransport::softwareTransport(globalParameters* globals, elementsCollection* beamLine) : abstractSoftware(globals, beamLine)13 softwareTransport::softwareTransport(globalParameters* globals, dataManager* dt) : abstractSoftware(globals, dt) 13 14 { 14 15 ; … … 19 20 { 20 21 unsigned int k; 21 if ( numeroDeb < 1 || numeroFin > beamLinePtr_->size() ) {22 if ( numeroDeb < 1 || numeroFin > dataManager_->getBeamLineSize() ) { 22 23 cerr << " numero of element out of limits " << endl; 23 24 return false; 24 25 } 25 26 26 unsigned indexDeb = numeroDeb - 1;27 unsigned indexFin = numeroFin - 1;27 unsigned indexDeb = numeroDeb - 1; 28 unsigned indexFin = numeroFin - 1; 28 29 29 30 abstractElement* premierEl = NULL; 30 premierEl = beamLinePtr_->getElementPointerFromIndex(indexDeb);31 premierEl = dataManager_->getElementPointerFromIndex(indexDeb); 31 32 32 33 // ceinture et bretelles … … 90 91 for ( k=indexDeb; k <= indexFin; k++) 91 92 { 92 elPtr = beamLinePtr_->getElementPointerFromIndex(k);93 elPtr = dataManager_->getElementPointerFromIndex(k); 93 94 outfile << elPtr->transportOutputFlow() << endl; 94 95 } … … 164 165 // string elemLabel = getLabelFromElementNumero (k); 165 166 166 abstractElement* ptr = beamLinePtr_->getElementPointerFromNumero(k);167 abstractElement* ptr = dataManager_->getElementPointerFromIndex(k); 167 168 168 169 if ( ptr == NULL ) { -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_abstractElement.h
r294 r305 5 5 #include "abstractElement.h" 6 6 #include "GWt_console.h" 7 #include "elementDrift.h" 8 #include "elementRfgun.h" 9 #include "elementCell.h" 10 #include "elementSoleno.h" 11 #include "elementBend.h" 12 #include "elementBeam.h" 13 #include "elementFit.h" 14 7 15 8 16 #include <Wt/WDialog> … … 42 50 void clicked(); 43 51 void doubleClicked(); 44 void setLabelWidget();45 52 void updateLabelWidget(); 46 53 // GWt_draggableImage* getImage(); 47 54 WContainerWidget* getWidget(); 48 abstractElement* get Element();55 abstractElement* getAbstractElement(); 49 56 50 57 virtual void dialogDone() = 0; -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_beam.h
r293 r305 19 19 20 20 GWt_beam() {;} 21 GWt_beam( abstractElement* elem,GWt_elementLigneFaisceau* );21 GWt_beam(GWt_elementLigneFaisceau* ); 22 22 ~GWt_beam() {;} 23 23 virtual void dialogDone(); -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_bend.h
r293 r305 18 18 19 19 GWt_bend() {;} 20 GWt_bend( abstractElement* elem,GWt_elementLigneFaisceau* );20 GWt_bend(GWt_elementLigneFaisceau* ); 21 21 ~GWt_bend() {;} 22 22 virtual void dialogDone(); -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_cell.h
r293 r305 29 29 30 30 GWt_cell() {;} 31 GWt_cell( abstractElement* elem,GWt_elementLigneFaisceau* );31 GWt_cell(GWt_elementLigneFaisceau* ); 32 32 ~GWt_cell() {;} 33 33 virtual void dialogDone(); -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_drift.h
r293 r305 21 21 22 22 GWt_drift() {;} 23 GWt_drift( abstractElement* elem,GWt_elementLigneFaisceau* );23 GWt_drift(GWt_elementLigneFaisceau* ); 24 24 ~GWt_drift() {;} 25 25 virtual void dialogDone(); -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_elementLigneFaisceau.h
r301 r305 33 33 34 34 GWt_elementLigneFaisceau(PspaApplication*); 35 GWt_elementLigneFaisceau( abstractElement*,PspaApplication*);35 GWt_elementLigneFaisceau(typedElement,PspaApplication*); 36 36 37 37 ~GWt_elementLigneFaisceau(); … … 39 39 40 40 inline WText* getElementName() { 41 return element Name_;41 return elementLabel_; 42 42 } 43 43 44 44 inline WText* getElementIcon() { 45 return element Name_;45 return elementLabel_; 46 46 } 47 47 48 void setElement Name(std::string label);48 void setElementLabel(std::string label); 49 49 50 50 inline GWt_dropZoneLigneFaisceau* getDropZoneLeft() { … … 56 56 } 57 57 58 inline GWt_abstractElement* get Element() {59 return abstractElement_;58 inline GWt_abstractElement* getGWt_AbstractElement() { 59 return GWt_abstractElement_; 60 60 } 61 61 … … 64 64 void removeDone(GWt_abstractElement*); 65 65 std::string getElementNumberInBeamLine(nomdElements el); 66 void initialize_ligneFaisceau( abstractElement*);66 void initialize_ligneFaisceau(typedElement eType); 67 67 GWt_dialog* messageDropZone_; 68 68 WText* firstTimeInsertMessage_; … … 70 70 GWt_dropZoneLigneFaisceau* dropZoneLeft_; 71 71 GWt_dropZoneLigneFaisceau* dropZoneRight_; 72 WText* element Name_;72 WText* elementLabel_; 73 73 PspaApplication* pspa_; 74 GWt_abstractElement* abstractElement_;74 GWt_abstractElement* GWt_abstractElement_; 75 75 }; 76 76 #endif -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_fit.h
r293 r305 15 15 16 16 GWt_fit() {;} 17 GWt_fit( abstractElement* elem,GWt_elementLigneFaisceau* );17 GWt_fit(GWt_elementLigneFaisceau* ); 18 18 ~GWt_fit() {;} 19 19 virtual void dialogDone(); -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_ligneFaisceau.h
r299 r305 7 7 #include "GWt_pspaApplication.h" 8 8 #include "GWt_abstractElement.h" 9 #include "GWt_dropZoneLigneFaisceau.h"10 9 11 10 #include <Wt/WApplication> … … 15 14 16 15 using namespace Wt; 16 17 class GWt_dropZoneLigneFaisceau; 17 18 18 19 class Compteur { … … 44 45 and we center everything 45 46 */ 46 void addElement(typedElement eType, GWt_dropZoneLigneFaisceau* dropContainer); 47 abstractElement* addElement(typedElement eType, GWt_dropZoneLigneFaisceau* dropContainer); 48 abstractElement* addElement(typedElement eType); 49 47 50 void removeElement(GWt_abstractElement*); 48 51 … … 51 54 } 52 55 53 void restoreElementCollectionFromDataManager(); 56 /** return the abstract element at a position 57 @param : position in the beam line 58 */ 59 abstractElement* getAbstractElement(int i); 60 // void restoreElementCollectionFromDataManager(); 54 61 void clickEvent(WContainerWidget*); 55 62 void deleteElement(WContainerWidget*); 63 int getBeamLineSize(); 64 65 /** 66 remove all elements from beam line 67 */ 68 void clear(); 69 70 /** 71 Return a vector contains all abstract elements in the beam line 72 */ 73 vector <abstractElement*> getAllAbstractElements(); 74 75 void update(); 76 56 77 private : 57 78 void manageLineFaisceauLayout(); 58 79 GWt_dropZoneLigneFaisceau* allDropZone_; 59 80 60 81 }; -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_pspaApplication.h
r302 r305 22 22 #include "GWt_abstractElementFactory.h" 23 23 #include "GWt_softwarePanel.h" 24 #include "GWt_ligneFaisceau.h" 24 25 25 26 using namespace Wt; … … 40 41 WLineEdit* saveNameEdit_; 41 42 WLineEdit* openNameEdit_; 43 GWt_LigneFaisceau* beamLine_; 42 44 43 45 44 46 // WContainerWidget* console_; 45 47 WWidget* globalParam_; 46 WWidget* beamLine_;47 48 // WContainerWidget* leDessin_; 48 49 GWt_dialog* graphicsDialog_; … … 61 62 WText* createTitle(const WString&); 62 63 WWidget* createPalette(); 63 WWidget*createBeamLine();64 void createBeamLine(); 64 65 WWidget* createGlobalParamWidget(); 65 66 WWidget* createExecuteWidget(); … … 106 107 return executeWidget_; 107 108 }; 109 inline GWt_LigneFaisceau* getBeamLine() { 110 return beamLine_; 111 } 108 112 109 113 inline GWt_abstractElementFactory* getAbstractElementFactory() { -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_rfgun.h
r304 r305 28 28 29 29 GWt_rfgun() {;} 30 GWt_rfgun( abstractElement* elem,GWt_elementLigneFaisceau* );30 GWt_rfgun(GWt_elementLigneFaisceau* ); 31 31 ~GWt_rfgun() {;} 32 32 virtual void dialogDone(); -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_soleno.h
r293 r305 27 27 28 28 GWt_soleno() {;} 29 GWt_soleno( abstractElement* elem,GWt_elementLigneFaisceau* );29 GWt_soleno(GWt_elementLigneFaisceau* ); 30 30 ~GWt_soleno() {;} 31 31 virtual void dialogDone(); -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_abstractElement.cc
r301 r305 79 79 void GWt_abstractElement::updateLabelWidget() 80 80 { 81 elementLigneFaiseauContainer_->setElementName(abstractElement_->getLabel()); 82 83 /* string str = abstractElement_->getLabel(); 84 wc_item_->setText(str); 85 */ 86 } 87 88 void GWt_abstractElement::setLabelWidget() 89 { 90 /* 91 string str = abstractElement_->getLabel(); 92 wc_item_ = new WText(str); 93 wc_item_->setObjectName("aText"); 94 wc_->addWidget(wc_item_); 95 */ 81 elementLigneFaiseauContainer_->setElementLabel(abstractElement_->getLabel()); 96 82 } 97 83 … … 104 90 void GWt_abstractElement::doubleClicked() 105 91 { 106 StandardButton result = WMessageBox::show("PSPA : Delete element", WString("Delete '")+WString(get Element()->getLabel())+"' ?", Ok | Cancel);92 StandardButton result = WMessageBox::show("PSPA : Delete element", WString("Delete '")+WString(getAbstractElement()->getLabel())+"' ?", Ok | Cancel); 107 93 108 94 if (result == Cancel ) { … … 125 111 } 126 112 127 abstractElement* GWt_abstractElement::get Element() {113 abstractElement* GWt_abstractElement::getAbstractElement() { 128 114 return abstractElement_; 129 115 } -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_beam.cc
r294 r305 8 8 #include <Wt/WPushButton> 9 9 10 GWt_beam::GWt_beam( abstractElement* elem,GWt_elementLigneFaisceau* elemLigne)11 :GWt_abstractElement( elem)10 GWt_beam::GWt_beam(GWt_elementLigneFaisceau* elemLigne) 11 :GWt_abstractElement(new elementBeam()) 12 12 { 13 13 elementLigneFaiseauContainer_ = elemLigne; -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_bend.cc
r294 r305 9 9 #include <Wt/WPushButton> 10 10 11 GWt_bend::GWt_bend( abstractElement* elem,GWt_elementLigneFaisceau* elemLigne )12 :GWt_abstractElement( elem)11 GWt_bend::GWt_bend(GWt_elementLigneFaisceau* elemLigne ) 12 :GWt_abstractElement(new elementBend()) 13 13 { 14 14 elementLigneFaiseauContainer_ = elemLigne; -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_cell.cc
r294 r305 10 10 #include <Wt/WPanel> 11 11 12 GWt_cell::GWt_cell( abstractElement* elem,GWt_elementLigneFaisceau* elemLigne)13 :GWt_abstractElement( elem)12 GWt_cell::GWt_cell(GWt_elementLigneFaisceau* elemLigne) 13 :GWt_abstractElement(new elementCell()) 14 14 { 15 15 elementLigneFaiseauContainer_ = elemLigne; -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_drift.cc
r294 r305 9 9 #include <Wt/WPushButton> 10 10 11 GWt_drift::GWt_drift( abstractElement* elem,GWt_elementLigneFaisceau* elemLigne)12 :GWt_abstractElement( elem)11 GWt_drift::GWt_drift(GWt_elementLigneFaisceau* elemLigne) 12 :GWt_abstractElement(new elementDrift()) 13 13 { 14 14 elementLigneFaiseauContainer_ = elemLigne; -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_elementLigneFaisceau.cc
r301 r305 32 32 dropZoneLeft_(NULL), 33 33 dropZoneRight_(NULL), 34 abstractElement_(NULL),35 element Name_(NULL),34 GWt_abstractElement_(NULL), 35 elementLabel_(NULL), 36 36 pspa_(pspa) 37 37 { 38 38 39 initialize_ligneFaisceau(NULL); 40 } 41 42 GWt_elementLigneFaisceau::GWt_elementLigneFaisceau(abstractElement* abstractElement, PspaApplication* pspa) 39 initialize_ligneFaisceau(inconnu); 40 } 41 42 43 GWt_elementLigneFaisceau::GWt_elementLigneFaisceau(typedElement type, PspaApplication* pspa) 43 44 : WContainerWidget(), 44 45 firstTimeInsertMessage_(NULL), 45 46 dropZoneLeft_(NULL), 46 47 dropZoneRight_(NULL), 47 abstractElement_(NULL),48 element Name_(NULL),48 GWt_abstractElement_(NULL), 49 elementLabel_(NULL), 49 50 pspa_(pspa) 50 51 { … … 52 53 setObjectName("elementLigneFaisceau"); 53 54 54 initialize_ligneFaisceau( abstractElement);55 } 56 57 58 void GWt_elementLigneFaisceau::initialize_ligneFaisceau( abstractElement* abstractElement)55 initialize_ligneFaisceau(type); 56 } 57 58 59 void GWt_elementLigneFaisceau::initialize_ligneFaisceau(typedElement eType) 59 60 { 60 61 … … 80 81 81 82 // change object name in order to manage css : 83 dropZoneLeft_->resize(10,30); 82 84 dropZoneRight_->resize(10,30); 83 84 85 WContainerWidget* arrow = new WContainerWidget();86 new WImage(arrow);87 arrow->resize(10,30);88 89 arrow->setStyleClass("elementLigneFaiseau_arrow");90 dropZoneLeft_->addWidget(arrow);91 85 92 86 gridLayout->addWidget (dropZoneLeft_,0,0); … … 94 88 95 89 // add the image if present 96 if (abstractElement != NULL) { 97 typedElement eType = abstractElement->getNomdElement().getElementType(); 98 99 switch ( eType ) { 100 case RFgun : 101 abstractElement_ = new GWt_rfgun(abstractElement, this); 102 break; 103 case drift : 104 abstractElement_ = new GWt_drift(abstractElement, this); 105 break; 106 case cell : 107 abstractElement_ = new GWt_cell(abstractElement, this); 108 break; 109 case bend : 110 abstractElement_ = new GWt_bend(abstractElement, this); 111 break; 112 case soleno : 113 abstractElement_ = new GWt_soleno(abstractElement, this); 114 break; 115 case beam : 116 abstractElement_ = new GWt_beam(abstractElement, this); 117 break; 118 case fit : 119 abstractElement_ = new GWt_fit(abstractElement, this); 120 break; 121 case inconnu : 122 abstractElement_ = NULL; 123 } 124 if (abstractElement_ != NULL) { 125 gridLayout->addWidget (abstractElement_,0,1); 126 abstractElement_->setMaximumSize(32,32); 127 abstractElement_->setMinimumSize(32,32); 128 abstractElement_->setToolTip(abstractElement_->print()); 129 } 130 } 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; 115 } 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 GWt_abstractElement_->setToolTip(GWt_abstractElement_->print()); 121 } 122 131 123 // add second line 132 if ( abstractElement== NULL) {133 element Name_ = new WText();124 if (GWt_abstractElement_ == NULL) { 125 elementLabel_ = new WText(); 134 126 } else { 135 element Name_ = new WText(abstractElement->getLabel());136 } 137 138 gridLayout->addWidget (element Name_,1,0,1,3,Wt::AlignCenter |Wt::AlignMiddle);127 elementLabel_ = new WText(GWt_abstractElement_->getAbstractElement()->getLabel()); 128 } 129 130 gridLayout->addWidget (elementLabel_,1,0,1,3,Wt::AlignCenter |Wt::AlignMiddle); 139 131 140 132 gridLayout->setColumnStretch (0,1); … … 160 152 161 153 162 163 164 154 void GWt_elementLigneFaisceau::addElement(GWt_abstractElement* elem){ 165 155 166 156 clear(); 167 abstractElement_ = elem;168 addWidget( abstractElement_);157 GWt_abstractElement_ = elem; 158 addWidget(GWt_abstractElement_); 169 159 if (static_cast <WContainerWidget*> (parent())) { 170 160 WContainerWidget* wc = static_cast <WContainerWidget*> (parent()); … … 177 167 dropZoneLeft_ = NULL; 178 168 } 169 179 170 180 171 std::string GWt_elementLigneFaisceau::getElementNumberInBeamLine(nomdElements elem){ … … 218 209 } 219 210 220 void GWt_elementLigneFaisceau::setElementName(std::string label) { 221 elementName_->setText(label); 222 } 223 211 212 void GWt_elementLigneFaisceau::setElementLabel(std::string label) { 213 elementLabel_->setText(label); 214 } 215 -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_fit.cc
r294 r305 9 9 #include <Wt/WComboBox> 10 10 11 GWt_fit::GWt_fit( abstractElement* elem,GWt_elementLigneFaisceau* elemLigne)12 :GWt_abstractElement( elem)11 GWt_fit::GWt_fit(GWt_elementLigneFaisceau* elemLigne) 12 :GWt_abstractElement(new elementFit()) 13 13 { 14 14 elementLigneFaiseauContainer_ = elemLigne; -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_ligneFaisceau.cc
r302 r305 35 35 36 36 37 clear(); 38 } 39 40 41 void GWt_LigneFaisceau::clear() { 42 ligneFaisceauLayout_->clear(); 43 37 44 // add the first drop zone 38 45 decorationStyle().setBorder (WBorder (WBorder::Dotted)); 39 GWt_dropZoneLigneFaisceau* allDropZone= new GWt_dropZoneLigneFaisceau(pspa_);46 allDropZone_ = new GWt_dropZoneLigneFaisceau(pspa_); 40 47 WVBoxLayout* fit = new WVBoxLayout(); 41 allDropZone ->setLayout(fit);48 allDropZone_->setLayout(fit); 42 49 43 50 fit->addWidget(new WText("Drag elements here...."),1,Wt::AlignCenter |Wt::AlignMiddle); 44 ligneFaisceauLayout_->addWidget(allDropZone,1); 45 } 46 47 48 49 void GWt_LigneFaisceau::restoreElementCollectionFromDataManager() 50 { 51 52 cout<<"GWt_LigneFaisceau::restoreElementCollection()"<<endl; 53 54 ligneFaisceauLayout_->clear(); 55 56 delete[] nObjets_; 51 ligneFaisceauLayout_->addWidget(allDropZone_,1); 52 } 53 54 55 abstractElement* GWt_LigneFaisceau::addElement(typedElement eType){ 56 return addElement(eType,NULL); 57 } 58 59 60 61 abstractElement* GWt_LigneFaisceau::addElement(typedElement eType, GWt_dropZoneLigneFaisceau* dropContainer ){ 62 63 abstractElement* abstractElem = NULL; 64 65 cout << " Entree addElement element " << nomdElements::getLabelFromType(eType) << endl; 66 57 67 int nElements= nomdElements ::getNumberOfElements(); 58 68 nObjets_= new Compteur[nElements]; 59 69 60 int nbElem = pspa_->getDataManager()->beamLineSize(); 61 unsigned int k; 62 63 for(k = 0; k < (unsigned)nbElem; k++) 64 { 65 abstractElement* ptr = pspa_->getDataManager()->getCollection()->getElementPointerFromIndex(k); 66 67 nObjets_[ptr->getNomdElement().getElementType()].incr(); 68 69 ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaisceau(ptr,pspa_),1); 70 71 } 72 manageLineFaisceauLayout(); 73 } 74 75 76 void GWt_LigneFaisceau::addElement(typedElement eType, GWt_dropZoneLigneFaisceau* dropContainer ){ 77 78 cout << " Entree addElement element " << nomdElements::getLabelFromType(eType) << endl; 79 80 int nElements= nomdElements ::getNumberOfElements(); 81 nObjets_= new Compteur[nElements]; 82 83 // 2 cases : 70 // 3 cases : 84 71 // -dropContainer is an element of the ligneFaisceauLayout_ 85 72 // -dropContainer is an element of the GWt_elementLigneFaisceau_ 73 // -dropContainer is NULL, insert in the last element 86 74 87 75 if(eType == inconnu) { 88 76 cout << "GWt_LigneFaisceau::element type " << eType << " inconnu " << endl; 89 return ;77 return NULL; 90 78 } 91 79 92 80 // add the element to the datamanager 93 abstractElement* ptr = pspa_->getDataManager()->addElement(eType);81 // abstractElement* ptr = pspa_->getDataManager()->addElement(eType); 94 82 95 83 // first time we insert an element : … … 97 85 if ((ligneFaisceauLayout_->count() == 1) && (!firstElemIsElement)) { 98 86 int index = indexOf (dropContainer); 99 if ( index != -1){ // found87 if ((index != -1) || (dropContainer == NULL)){ // found 100 88 // remove global drop zone 101 89 ligneFaisceauLayout_->clear(); 90 102 91 // add first element 103 ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaisceau(ptr,pspa_),1); 92 GWt_elementLigneFaisceau* elemLigneFaisceau = new GWt_elementLigneFaisceau(eType, pspa_); 93 abstractElem = elemLigneFaisceau->getGWt_AbstractElement()->getAbstractElement(); 94 95 ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaisceau(eType, pspa_),1); 104 96 // remove arrow from begin and end 105 97 106 98 } else { // error 107 return ;99 return NULL; 108 100 } 109 101 } else { … … 124 116 125 117 // ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaiseau(ptr),0); 118 GWt_elementLigneFaisceau* elemLigneFaisceau = new GWt_elementLigneFaisceau(eType, pspa_); 126 119 if (index != -1) { 127 nObjets_[ptr->getNomdElement().getElementType()].incr(); 128 ligneFaisceauLayout_->insertWidget(index,new GWt_elementLigneFaisceau(ptr,pspa_),1); 120 // nObjets_[ptr->getNomdElement().getElementType()].incr(); 121 ligneFaisceauLayout_->insertWidget(index,elemLigneFaisceau,1); 122 abstractElem = elemLigneFaisceau->getGWt_AbstractElement()->getAbstractElement(); 123 } else { 124 ligneFaisceauLayout_->addWidget(elemLigneFaisceau,1); 125 abstractElem = elemLigneFaisceau->getGWt_AbstractElement()->getAbstractElement(); 129 126 } 130 127 } 131 128 manageLineFaisceauLayout(); 132 129 130 return abstractElem; 133 131 } 134 132 … … 137 135 // special : hide/setVisible arrow : 138 136 for (int a=0; a< ligneFaisceauLayout_->count(); a++) { 139 GWt_elementLigneFaisceau* elem = static_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ()); 140 if (elem) { 137 if (GWt_elementLigneFaisceau* elem = dynamic_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ())) { 138 139 // update labels 140 elem->getGWt_AbstractElement()->updateLabelWidget(); 141 142 // one element 141 143 if ((a == 0) && (a == (ligneFaisceauLayout_->count()-1))) { 142 144 elem->getDropZoneLeft()->setStyleClass("elementLigneFaiseau_transparent"); 143 145 elem->getDropZoneRight()->setStyleClass("elementLigneFaiseau_transparent"); 144 elem->getDropZoneLeft()->widget(0)->setHidden(true); 145 printf(" - - %d\n",a);146 147 // first 146 148 } else if (a == 0){ 147 149 elem->getDropZoneLeft()->setStyleClass("elementLigneFaiseau_transparent"); 148 150 elem->getDropZoneRight()->setStyleClass("elementLigneFaiseau_line"); 149 elem->getDropZoneLeft()->widget(0)->setHidden(true); 150 printf(" - D %d\n",a);151 152 // last 151 153 } else if (a == (ligneFaisceauLayout_->count()-1)){ 152 154 elem->getDropZoneLeft()->setStyleClass("elementLigneFaiseau_line"); 153 155 elem->getDropZoneRight()->setStyleClass("elementLigneFaiseau_transparent"); 154 elem->getDropZoneLeft()->widget(0)->setHidden(false);155 156 156 printf(" L - %d\n",a); 157 158 // middle elements 157 159 } else { 158 160 elem->getDropZoneLeft()->setStyleClass("elementLigneFaiseau_line"); 159 161 elem->getDropZoneRight()->setStyleClass("elementLigneFaiseau_line"); 160 elem->getDropZoneLeft()->widget(0)->setHidden(false);161 printf(" L D %d\n",a);162 162 } 163 163 } … … 167 167 168 168 169 void GWt_LigneFaisceau::removeElement(GWt_abstractElement* abstractElement) { 170 if (abstractElement == NULL) 169 170 void GWt_LigneFaisceau::update() { 171 manageLineFaisceauLayout(); 172 } 173 174 175 void GWt_LigneFaisceau::removeElement(GWt_abstractElement* GWt_abstractElement) { 176 if (GWt_abstractElement == NULL) 171 177 return; 172 178 … … 178 184 GWt_elementLigneFaisceau* elem = static_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ()); 179 185 if (elem) { 180 if (elem->get Element() ==abstractElement) {186 if (elem->getGWt_AbstractElement() == GWt_abstractElement) { 181 187 index = a; 182 188 } … … 186 192 if (index != -1) { 187 193 // remove element from the list 188 pspa_->getDataManager()->removeElement(abstractElement->getElement()->getLabel());194 // pspa_->getDataManager()->removeElement(GWt_abstractElement->getElement()->getLabel()); 189 195 190 196 ligneFaisceauLayout_->removeItem(ligneFaisceauLayout_->itemAt(index)); 191 delete abstractElement;197 delete GWt_abstractElement; 192 198 193 199 // manage widgets if necessary 194 200 manageLineFaisceauLayout(); 195 201 } 196 197 198 } 199 202 } 203 204 205 abstractElement* GWt_LigneFaisceau::getAbstractElement(int i){ 206 int index = 0; 207 208 // first if 1 209 // i--; 210 211 for (int a=0; a< ligneFaisceauLayout_->count(); a++) { 212 if (GWt_elementLigneFaisceau* elem = dynamic_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ())) { 213 if (index == i) { 214 printf("GWt_LigneFaisceau::getAbstractElement %d %s\n",i,elem->getGWt_AbstractElement()->getAbstractElement()->getLabel().c_str()); 215 return elem->getGWt_AbstractElement()->getAbstractElement(); 216 } 217 index ++; 218 } 219 } 220 return NULL; 221 } 222 223 224 int GWt_LigneFaisceau::getBeamLineSize() { 225 int count = 0; 226 for (int a=0; a< ligneFaisceauLayout_->count(); a++) { 227 if (dynamic_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ())) { 228 count ++; 229 } 230 } 231 return count; 232 } 233 234 235 vector <abstractElement*> GWt_LigneFaisceau::getAllAbstractElements(){ 236 vector <abstractElement*> elems; 237 for (int a=0; a< ligneFaisceauLayout_->count(); a++) { 238 if (GWt_elementLigneFaisceau* elem = dynamic_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ())) { 239 elems.push_back(elem->getGWt_AbstractElement()->getAbstractElement()); 240 } 241 } 242 return elems; 243 } 244 -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc
r302 r305 67 67 WContainerWidget *widroot = root(); 68 68 useStyleSheet ("htdocs/pspa.css"); 69 dtmanage_ = new dataManager( );69 dtmanage_ = new dataManager(this); 70 70 dtmanage_->setWorkingDir(workingDir_); 71 71 /* … … 123 123 layout->addWidget(createPalette(), 2, 0, 4, 1); 124 124 125 beamLine_ = createBeamLine(); 125 createBeamLine(); 126 126 127 WScrollArea* scroll = new WScrollArea(); 127 128 scroll->setWidget(beamLine_); … … 212 213 } 213 214 214 WWidget* PspaApplication::createBeamLine() 215 { 216 WContainerWidget* beamLine = new GWt_LigneFaisceau(this); 217 beamLine->setMinimumSize(300,100); 218 return beamLine; 215 void PspaApplication::createBeamLine() 216 { 217 beamLine_ = new GWt_LigneFaisceau(this); 218 beamLine_->setMinimumSize(300,100); 219 219 } 220 220 … … 361 361 362 362 GWt_LigneFaisceau* bobo = static_cast<GWt_LigneFaisceau*>(beamLine_); 363 bobo->restoreElementCollectionFromDataManager();363 // bobo->restoreElementCollectionFromDataManager(); 364 364 365 365 console_->addConsoleMessage(string("...terminee")); … … 421 421 422 422 GWt_LigneFaisceau* bobo = static_cast<GWt_LigneFaisceau*>(beamLine_); 423 bobo->restoreElementCollectionFromDataManager();423 // bobo->restoreElementCollectionFromDataManager(); 424 424 425 425 console_->addConsoleMessage(string("...terminee")); … … 448 448 { 449 449 choixElementDessin_->clear(); 450 int nombre = dtmanage_-> beamLineSize();450 int nombre = dtmanage_->getBeamLineSize(); 451 451 for ( int numero =1; numero <= nombre; numero++) 452 452 { … … 523 523 524 524 // new WText(nameOfCase_ + " : enveloppe", toto); 525 unsigned nbel = dtmanage_-> beamLineSize();525 unsigned nbel = dtmanage_->getBeamLineSize(); 526 526 527 527 -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_rfgun.cc
r304 r305 8 8 #include <Wt/WPushButton> 9 9 10 GWt_rfgun::GWt_rfgun( abstractElement* elem,GWt_elementLigneFaisceau* elemLigne)11 :GWt_abstractElement( elem)10 GWt_rfgun::GWt_rfgun(GWt_elementLigneFaisceau* elemLigne) 11 :GWt_abstractElement(new elementRfgun()) 12 12 { 13 13 elementLigneFaiseauContainer_ = elemLigne; -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_softwarePanel.cc
r302 r305 77 77 premierText = dtmanage_->getLabelFromElementNumero(1); 78 78 79 dernierText = dtmanage_->getLabelFromElementNumero(dtmanage_-> beamLineSize());79 dernierText = dtmanage_->getLabelFromElementNumero(dtmanage_->getBeamLineSize()); 80 80 } 81 81 else 82 82 { 83 83 dernierText = selectedSections_.back()->fin->text().toUTF8(); 84 int dernierNumero = dtmanage_->get Collection()->getNumeroFromLabel(dernierText);84 int dernierNumero = dtmanage_->getNumeroFromElementLabel(dernierText); 85 85 dernierNumero++; 86 if ( dernierNumero <= dtmanage_-> beamLineSize() )86 if ( dernierNumero <= dtmanage_->getBeamLineSize() ) 87 87 { 88 88 premierText = dtmanage_->getLabelFromElementNumero(dernierNumero); … … 90 90 else 91 91 { 92 premierText = dtmanage_->getLabelFromElementNumero(dtmanage_-> beamLineSize());92 premierText = dtmanage_->getLabelFromElementNumero(dtmanage_->getBeamLineSize()); 93 93 } 94 94 dernierText = premierText; … … 139 139 140 140 string currentString = (*selectedSections_.begin())->fin->text().toUTF8(); 141 int current = dtmanage_->get Collection()->getNumeroFromLabel( currentString);141 int current = dtmanage_->getNumeroFromElementLabel( currentString); 142 142 143 143 cout << " numero " << current << endl; 144 144 // si la fin est mal definie on prend toute la config par defaut 145 if ( current <= 0 || current > dtmanage_-> beamLineSize() )146 { 147 current = dtmanage_-> beamLineSize();145 if ( current <= 0 || current > dtmanage_->getBeamLineSize() ) 146 { 147 current = dtmanage_->getBeamLineSize(); 148 148 currentString = dtmanage_->getLabelFromElementNumero(current); 149 149 (*selectedSections_.begin())->fin->setText(currentString); … … 159 159 { 160 160 // debut 161 if ( current >= dtmanage_-> beamLineSize() )161 if ( current >= dtmanage_->getBeamLineSize() ) 162 162 { 163 163 // GWt_tools::addConsoleMessage(" bad section definition ! \n "); … … 171 171 string finString = (*itr)->fin->text().toUTF8(); 172 172 173 int numeroFin = dtmanage_->get Collection()->getNumeroFromLabel( finString);174 175 if ( numeroFin <= current || numeroFin > dtmanage_-> beamLineSize())173 int numeroFin = dtmanage_->getNumeroFromElementLabel( finString); 174 175 if ( numeroFin <= current || numeroFin > dtmanage_->getBeamLineSize()) 176 176 { 177 177 // GWt_tools::addConsoleMessage(" bad section definition ! \n "); … … 209 209 210 210 211 int debut = dtmanage_->get Collection()->getNumeroFromLabel(debString);212 int fin = dtmanage_->get Collection()->getNumeroFromLabel(finString);211 int debut = dtmanage_->getNumeroFromElementLabel(debString); 212 int fin = dtmanage_->getNumeroFromElementLabel(finString); 213 213 nomDeLogiciel prog = nomDeLogiciel ( (*itr)->selection->currentIndex() ); 214 214 dtmanage_->addSectionToExecute(debut,fin,prog); … … 250 250 { 251 251 premierText = dtmanage_->getLabelFromElementNumero(1); 252 dernierText = dtmanage_->getLabelFromElementNumero( dtmanage_-> beamLineSize() );252 dernierText = dtmanage_->getLabelFromElementNumero( dtmanage_->getBeamLineSize() ); 253 253 (*selectedSections_.begin())->debut->setText(premierText); 254 254 (*selectedSections_.begin())->fin->setText(dernierText); -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_soleno.cc
r294 r305 8 8 #include <Wt/WPushButton> 9 9 10 GWt_soleno::GWt_soleno( abstractElement* elem,GWt_elementLigneFaisceau* elemLigne)11 :GWt_abstractElement( elem)10 GWt_soleno::GWt_soleno(GWt_elementLigneFaisceau* elemLigne) 11 :GWt_abstractElement(new elementSoleno()) 12 12 { 13 13 elementLigneFaiseauContainer_ = elemLigne;
Note: See TracChangeset
for help on using the changeset viewer.