Changeset 118 in PSPA
- Timestamp:
- Nov 30, 2012, 8:56:51 PM (12 years ago)
- Location:
- Interface_Web/trunk/pspaWT
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/include/GWt_LigneFaisceau.h
r113 r118 29 29 Compteur *nObjets_[nElements]; 30 30 31 32 string createLabel(abstractElement* elem, int n); 33 31 34 public : 32 35 GWt_LigneFaisceau(PspaApplication*); -
Interface_Web/trunk/pspaWT/include/GWt_abstractElement.h
r117 r118 36 36 void clicked(); 37 37 void doubleClicked(); 38 void setLabel(int n); 38 // void createLabel(int n); 39 void updateLabelWidget(); 39 40 WPushButton* getButton(); 40 41 WContainerWidget* getWidget(); -
Interface_Web/trunk/pspaWT/include/dataManager.h
r114 r118 44 44 45 45 abstractElement* addElement(nomdElement elemType); 46 string getLabelFromElementNumero(int numero); 46 47 void initializeExecution(); 47 48 string checkExecute(); -
Interface_Web/trunk/pspaWT/include/elementsCollection.h
r107 r118 25 25 abstractElement* getElementPointer(string label) const; 26 26 abstractElement* getElementPointer(unsigned int index) const; 27 abstractElement* getElementPointerFromNumero(int num) const; 28 29 int getNumeroFromLabel(string lab); 27 30 28 31 void eraseElement(string label); -
Interface_Web/trunk/pspaWT/src/GWt_LigneFaisceau.cc
r112 r118 8 8 #include "GWt_soleno.h" 9 9 #include "GWt_bend.h" 10 #include "mixedTools.h" 10 11 11 12 #include <Wt/WComboBox> … … 29 30 } 30 31 32 33 string GWt_LigneFaisceau::createLabel(abstractElement* elem, int n) 34 { 35 string str; 36 if(n < 10) { 37 str= elem->getNameOfElement()+"0"+mixedTools::intToString(n); 38 } else { 39 str= elem->getNameOfElement()+mixedTools::intToString(n); 40 } 41 return str; 42 } 43 31 44 void GWt_LigneFaisceau::dropEvent(WDropEvent evt) 32 45 { … … 37 50 abstractElement* newDrift = pspa_->getDataManager()->addElement(drift); 38 51 GWt_drift* gdrift = new GWt_drift(pspa_,newDrift, evt.mimeType()); 39 gdrift->setLabel(nObjets_[drift]->incr()); 52 newDrift->setLabel( createLabel( newDrift, nObjets_[drift]->incr() )); 53 gdrift->updateLabelWidget(); 40 54 wc= gdrift->getWidget(); 55 // pspa_->updateSelections(); 41 56 } 42 57 else if ( strstr(evt.mimeType().c_str() , "beam") ) … … 45 60 abstractElement* newInitialBeam = pspa_->getDataManager()->addElement(initialBeam); 46 61 GWt_initialBeam* gwInitialBeam = new GWt_initialBeam(pspa_,newInitialBeam, evt.mimeType()); 47 gwInitialBeam->setLabel(nObjets_[initialBeam]->incr()); 62 newInitialBeam->setLabel( createLabel( newInitialBeam, nObjets_[initialBeam]->incr() ) ); 63 gwInitialBeam->updateLabelWidget(); 48 64 wc= gwInitialBeam->getWidget(); 65 // pspa_->updateSelections(); 49 66 } 50 67 else if ( strstr(evt.mimeType().c_str() , "cell") ) … … 53 70 abstractElement* newCell = pspa_->getDataManager()->addElement(cell); 54 71 GWt_cell* gwCell = new GWt_cell(pspa_,newCell, evt.mimeType()); 55 gwCell->setLabel(nObjets_[cell]->incr()); 72 newCell->setLabel( createLabel( newCell, nObjets_[cell]->incr() ) ); 73 gwCell->updateLabelWidget(); 56 74 wc= gwCell->getWidget(); 75 // pspa_->updateSelections(); 57 76 } 58 77 else if ( strstr(evt.mimeType().c_str() , "lens") ) … … 61 80 abstractElement* newSoleno = pspa_->getDataManager()->addElement(soleno); 62 81 GWt_soleno* gwSoleno = new GWt_soleno(pspa_,newSoleno, evt.mimeType()); 63 gwSoleno->setLabel(nObjets_[soleno]->incr()); 82 newSoleno->setLabel( createLabel( newSoleno, nObjets_[soleno]->incr() ) ); 83 gwSoleno->updateLabelWidget(); 64 84 wc= gwSoleno->getWidget(); 85 // pspa_->updateSelections(); 65 86 } 66 87 else if ( strstr(evt.mimeType().c_str() , "bend") ) … … 69 90 abstractElement* newBend = pspa_->getDataManager()->addElement(bend); 70 91 GWt_bend* gwBend = new GWt_bend(pspa_,newBend, evt.mimeType()); 71 gwBend->setLabel(nObjets_[bend]->incr()); 92 newBend->setLabel( createLabel( newBend, nObjets_[bend]->incr() ) ); 93 gwBend->updateLabelWidget(); 72 94 wc= gwBend->getWidget(); 95 // pspa_->updateSelections(); 73 96 } 74 97 else 75 98 { 76 pspa_->addConsoleMessage(" RIEN trouve");99 pspa_->addConsoleMessage(" unable to guess the element to create "); 77 100 return; 78 101 } 79 102 80 103 beamLayout_->addWidget(wc); 104 pspa_->updateSelections(); 81 105 82 106 // pourVoir … … 107 131 { 108 132 GWt_initialBeam* gw = new GWt_initialBeam(pspa_,ptr,string("icons/beam.jpg")); 109 gw->setLabel(nObjets_[initialBeam]->incr()); 133 // gw->setLabel(nObjets_[initialBeam]->incr()); 134 gw->updateLabelWidget(); 135 nObjets_[initialBeam]->incr(); 110 136 beamLayout_->addWidget(gw->getWidget()); 111 137 break; … … 114 140 { 115 141 GWt_drift* gw = new GWt_drift(pspa_,ptr,string("icons/drift.jpg")); 116 gw->setLabel(nObjets_[drift]->incr()); 142 // gw->setLabel( nObjets_[drift]->incr()); 143 gw->updateLabelWidget(); 144 nObjets_[drift]->incr(); 117 145 beamLayout_->addWidget(gw->getWidget()); 118 146 break; … … 121 149 { 122 150 GWt_cell* gw = new GWt_cell(pspa_,ptr,string("icons/cell.jpg")); 123 gw->setLabel(nObjets_[cell]->incr()); 151 // gw->setLabel(nObjets_[cell]->incr()); 152 gw->updateLabelWidget(); 153 nObjets_[cell]->incr(); 124 154 beamLayout_->addWidget(gw->getWidget()); 125 155 break; … … 128 158 { 129 159 GWt_soleno* gw = new GWt_soleno(pspa_,ptr,string("icons/lens.jpg")); 130 gw->setLabel(nObjets_[soleno]->incr()); 160 // gw->setLabel(nObjets_[soleno]->incr()); 161 gw->updateLabelWidget(); 162 nObjets_[soleno]->incr(); 131 163 beamLayout_->addWidget(gw->getWidget()); 132 164 break; … … 135 167 { 136 168 GWt_bend* gw = new GWt_bend(pspa_,ptr,string("icons/bend.jpg")); 137 gw->setLabel(nObjets_[bend]->incr()); 169 // gw->setLabel(nObjets_[bend]->incr()); 170 gw->updateLabelWidget(); 171 nObjets_[bend]->incr(); 138 172 beamLayout_->addWidget(gw->getWidget()); 139 173 break; … … 146 180 } 147 181 } 182 pspa_->updateSelections(); 183 148 184 } -
Interface_Web/trunk/pspaWT/src/GWt_abstractElement.cc
r116 r118 1 1 2 2 #include "GWt_abstractElement.h" 3 #include "mixedTools.h"4 3 #include <Wt/WText> 5 4 6 5 GWt_abstractElement::GWt_abstractElement(PspaApplication* ps,abstractElement* elem,string image) 7 6 { 8 cout << "GWt_abstractElement::GWt_abstractElement()" << endl;9 7 10 8 pspa_ = ps; 11 pspa_->updateSelections();9 // pspa_->updateSelections(); 12 10 13 11 element_ = elem; … … 22 20 wc_->addWidget(dropped_); 23 21 wc_->addWidget(new WBreak()); 24 25 22 } 26 23 27 void GWt_abstractElement::setLabel(int n) 24 25 void GWt_abstractElement::updateLabelWidget() 28 26 { 29 string str; 30 if(n < 10) { 31 str= element_->getNameOfElement()+"0"+mixedTools::intToString(n); 32 } else { 33 str= element_->getNameOfElement()+mixedTools::intToString(n); 34 } 35 cout << "2-GWt_abstractElement::label= " << str << endl; 36 37 element_->setLabel(str); 38 27 string str = element_->getLabel(); 39 28 WText *item = new WText(str); 40 29 wc_->addWidget(item); -
Interface_Web/trunk/pspaWT/src/GWt_pspaApplication.cc
r114 r118 160 160 WWidget* PspaApplication::createExecuteWidget() 161 161 { 162 cout << "PspaApplication::createExecuteWidget()" << endl;163 162 164 163 WContainerWidget* executeW = new WContainerWidget(); … … 218 217 void PspaApplication::addSectionToExecuteW() 219 218 { 220 cout << "PspaApplication::addSectionToExecute() : " << selectedSections_.size() << endl;221 219 222 220 disableSectionExecute(); … … 225 223 if(selectedSections_.size() == 0) 226 224 { 227 premierText = "1"; 228 dernierText = mixedTools::intToString( dtmanage_->beamLineSize() ); 225 premierText = dtmanage_->getLabelFromElementNumero(1); 226 227 dernierText = dtmanage_->getLabelFromElementNumero(dtmanage_->beamLineSize()); 229 228 } 230 229 else 231 230 { 232 231 dernierText = selectedSections_.back()->fin->text().toUTF8(); 233 int dernierNumero = atoi(dernierText.c_str());232 int dernierNumero = dtmanage_->getCollection()->getNumeroFromLabel(dernierText); 234 233 dernierNumero++; 235 234 if ( dernierNumero <= dtmanage_->beamLineSize() ) 236 235 { 237 premierText = mixedTools::intToString(dernierNumero); 238 dernierText = premierText; 236 premierText = dtmanage_->getLabelFromElementNumero(dernierNumero); 239 237 } 240 238 else 241 239 { 242 premierText = mixedTools::intToString( dtmanage_->beamLineSize() ); 243 dernierText = premierText; 240 premierText = dtmanage_->getLabelFromElementNumero(dtmanage_->beamLineSize()); 244 241 } 245 } 246 247 cout << "PspaApplication::addSectionToExecute() : " << premierText << ",Ã " << dernierText << endl; 242 dernierText = premierText; 243 } 244 245 // cout << "PspaApplication::addSectionToExecute() : " << premierText << " Ã " << dernierText << endl; 248 246 249 247 WContainerWidget* newSection = new WContainerWidget; … … 282 280 283 281 // traitement de la premiere ligne 284 (*selectedSections_.begin())->debut->setText("1"); 282 // on impose le depart du calcul au premier element 283 string premier = dtmanage_->getLabelFromElementNumero(1); 284 (*selectedSections_.begin())->debut->setText(premier); 285 285 286 string currentString = (*selectedSections_.begin())->fin->text().toUTF8(); 286 int current = atoi ( currentString.c_str() ); 287 if ( current <= 0 ) 288 { 289 (*selectedSections_.begin())->fin->setText("1"); 290 current = 1; 287 int current = dtmanage_->getCollection()->getNumeroFromLabel( currentString); 288 289 cout << " numero " << current << endl; 290 // si la fin est mal definie on prend toute la config par defaut 291 if ( current <= 0 || current > dtmanage_->beamLineSize() ) 292 { 293 current = dtmanage_->beamLineSize(); 294 currentString = dtmanage_->getLabelFromElementNumero(current); 295 (*selectedSections_.begin())->fin->setText(currentString); 291 296 } 292 297 current++; 293 if ( current > dtmanage_->beamLineSize() ) current = dtmanage_->beamLineSize(); 294 currentString = mixedTools::intToString(current); 298 currentString = dtmanage_->getLabelFromElementNumero(current); 295 299 296 300 // traitement des suivantes (on avance d'un cran dans la liste) … … 301 305 { 302 306 // debut 307 if ( current >= dtmanage_->beamLineSize() ) 308 { 309 addConsoleMessage(" bad section definition ! \n "); 310 probleme_->setHidden(false); 311 return; 312 } 313 303 314 (*itr)->debut->setText(currentString); 304 315 // fin 305 316 string finString = (*itr)->fin->text().toUTF8(); 306 if ( atoi(finString.c_str() ) < current) 317 318 int numeroFin = dtmanage_->getCollection()->getNumeroFromLabel( finString); 319 320 if ( numeroFin <= current || numeroFin > dtmanage_->beamLineSize()) 307 321 { 308 (*itr)->fin->setText(currentString); 322 addConsoleMessage(" bad section definition ! \n "); 323 probleme_->setHidden(false); 324 return; 309 325 } 310 326 311 327 // preparation de la ligne suivante 312 finString = (*itr)->fin->text().toUTF8(); 313 current = atoi(finString.c_str()) +1; 314 if ( current > dtmanage_->beamLineSize() ) current = dtmanage_->beamLineSize(); 315 currentString = mixedTools::intToString(current); 328 current = numeroFin +1; 329 currentString = dtmanage_->getLabelFromElementNumero(current); 316 330 } 317 331 … … 334 348 string debString = (*itr)->debut->text().toUTF8(); 335 349 string finString = (*itr)->fin->text().toUTF8(); 336 int debut = atoi(debString.c_str()); 337 int fin = atoi(finString.c_str()); 350 351 352 int debut = dtmanage_->getCollection()->getNumeroFromLabel(debString); 353 int fin = dtmanage_->getCollection()->getNumeroFromLabel(finString); 338 354 nomDeLogiciel prog = nomDeLogiciel ( (*itr)->selection->currentIndex() ); 339 355 dtmanage_->addSectionToExecute(debut,fin,prog); … … 512 528 if ( selectedSections_.size() > 0 ) 513 529 { 514 premierText = "1";515 dernierText = mixedTools::intToString( dtmanage_->beamLineSize() );530 premierText = dtmanage_->getLabelFromElementNumero(1); 531 dernierText = dtmanage_->getLabelFromElementNumero( dtmanage_->beamLineSize() ); 516 532 (*selectedSections_.begin())->debut->setText(premierText); 517 533 (*selectedSections_.begin())->fin->setText(dernierText); 518 534 } 519 535 520 cout << "PspaApplication::updateSelections(): " << premierText << " ,Ã " << dernierText << endl;536 cout << "PspaApplication::updateSelections(): " << premierText << " Ã " << dernierText << endl; 521 537 } 522 538 -
Interface_Web/trunk/pspaWT/src/dataManager.cc
r114 r118 9 9 return elementsGallery_.addElement(elemType); 10 10 } 11 12 string dataManager::getLabelFromElementNumero(int numero) 13 { 14 abstractElement* ptr = elementsGallery_.getElementPointerFromNumero(numero); 15 if ( ptr == NULL ) return ""; 16 return ptr->getLabel(); 17 } 18 11 19 12 20 void dataManager::addSectionToExecute(int debut, int fin, nomDeLogiciel prog) … … 39 47 indexDeb = jobList_[k]->firstElement; 40 48 indexFin = jobList_[k]->lastElement; 49 if ( indexFin <= indexDeb ) 50 { 51 diagnostic += " first ans last elements are the same \n"; 52 break; 53 } 54 cout << " indexDeb= " << indexDeb << " indexFin= " << indexFin << endl; 41 55 indexDeb--; 42 56 indexFin--; -
Interface_Web/trunk/pspaWT/src/elementBend.cc
r114 r118 81 81 ostringstream sortie; 82 82 sortie << elementName_ << endl; 83 sortie << label_ << endl; 83 84 sortie << angleDeg_ << " " << radius_ << " " << aperture_ << endl; 84 85 sortie << beta1_ << " " << beta2_ << endl; … … 88 89 void elementBend::FileInput(ifstream& ifs) 89 90 { 91 ifs >> label_; 90 92 ifs >> angleDeg_ >> radius_ >> aperture_; 91 93 ifs >> beta1_ >> beta2_; -
Interface_Web/trunk/pspaWT/src/elementCell.cc
r105 r118 100 100 ostringstream sortie; 101 101 sortie << elementName_ << endl; 102 sortie << label_ << endl; 102 103 sortie << lenghtElem_ << " " << aperture_ << endl; 103 104 sortie << initialPhase_ << " " << acceleratingField_ << endl; … … 111 112 void elementCell::FileInput(ifstream& ifs) 112 113 { 114 ifs >> label_; 113 115 ifs >> lenghtElem_ >> aperture_; 114 116 ifs >> initialPhase_ >> acceleratingField_; -
Interface_Web/trunk/pspaWT/src/elementDrift.cc
r114 r118 63 63 { 64 64 ostringstream sortie; 65 sortie << elementName_ << endl; 65 sortie << elementName_ << endl; 66 sortie << label_ << endl; 66 67 sortie << lenghtElem_ << " " << aperture_ <<endl; 67 68 return sortie.str(); … … 70 71 void elementDrift::FileInput(ifstream& ifs) 71 72 { 73 ifs >> label_; 72 74 ifs >> lenghtElem_ >> aperture_; 73 75 } -
Interface_Web/trunk/pspaWT/src/elementInitialBeam.cc
r102 r118 93 93 // on prend les troncatures tmax et rmax à 3 sigmas 94 94 sortie << elementName_ << endl; 95 sortie << label_ << endl; 95 96 sortie << nmacrop_ << " " << sigma_t_ << " " << sigma_r_ << endl; 96 97 sortie << E_cin_ << " " << sigma_E_ << endl; … … 101 102 void elementInitialBeam::FileInput(ifstream& ifs) 102 103 { 104 ifs >> label_; 103 105 ifs >> nmacrop_ >> sigma_t_ >> sigma_r_; 104 106 ifs >> E_cin_ >> sigma_E_; -
Interface_Web/trunk/pspaWT/src/elementSoleno.cc
r114 r118 76 76 ostringstream sortie; 77 77 sortie << elementName_ << endl; 78 sortie << label_ << endl; 78 79 sortie << lenghtElem_ << " " << aperture_<< " " << B0_ << endl; 79 80 return sortie.str(); … … 82 83 void elementSoleno::FileInput(ifstream& ifs) 83 84 { 85 ifs >> label_; 84 86 ifs >> lenghtElem_ >> aperture_ >> B0_; 85 87 } -
Interface_Web/trunk/pspaWT/src/elementsCollection.cc
r106 r118 78 78 } 79 79 80 // un numero va de 1 Ã l'infini 81 abstractElement* elementsCollection::getElementPointerFromNumero(int num) const 82 { 83 if ( num > elements_.size() || num <= 0) 84 { 85 return NULL; 86 } 87 else 88 { 89 return elements_[num-1]; 90 } 91 } 92 80 93 abstractElement* elementsCollection::getElementPointer(unsigned int index) const 81 94 { … … 83 96 else return elements_[index]; 84 97 } 98 99 int elementsCollection::getNumeroFromLabel(string lab) 100 { 101 unsigned int k; 102 int klab = -1; 103 for (k = 0; k < elements_.size() ; k++) 104 { 105 if ( elements_[k]->getLabel() == lab ) 106 { 107 klab = (int)k + 1; 108 break; 109 } 110 } 111 return klab; 112 } 113 85 114 86 115 void elementsCollection::eraseElement(string label) -
Interface_Web/trunk/pspaWT/workingArea/pspa.save
r84 r118 2 2 2998.65 1 100000 10 3 3 0 4 beam01 4 5 20 3.6 0.02 5 6 1e-06 1e-06 6 7 1 3.1211e+09 7 8 2 9 cell01 8 10 17.7 1.2 9 11 70 75 … … 13 15 -20.53 1 14 16 1 17 drift01 15 18 225.9 3 16 19 4 20 solnd01 17 21 7.88 1e+61 1.02885 18 22 1 23 drift02 19 24 153.72 1e+06 20 25 3 26 bend01 21 27 60 1 1e+06 22 28 18.24 18.24 23 29 1 30 drift03 24 31 124.27 1e+06
Note: See TracChangeset
for help on using the changeset viewer.