Changeset 431 in PSPA for Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_softwarePanel.cc
- Timestamp:
- Nov 15, 2013, 3:30:50 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_softwarePanel.cc
r427 r431 21 21 #include "GWt_pspaApplication.h" 22 22 23 #define BAVARD 0 24 23 25 GWt_softwarePanel::GWt_softwarePanel(dataManager* dataManager,PspaApplication* pspa) 24 26 : WContainerWidget() … … 49 51 void GWt_softwarePanel::addSectionToExecuteW() 50 52 { 53 #if BAVARD > 0 54 cout << "***********************************" << endl; 55 cout << " GWt_softwarePanel::addSectionToExecuteW() " << endl<<endl; 56 #endif 57 51 58 abstractElement* premierElement; 52 59 abstractElement* dernierElement; … … 55 62 int dernierIndex = 0; 56 63 64 cout << "sections_.size() = " << sections_.size() << endl; 65 57 66 // if there is no section 58 67 if(sections_.size() == 0) { … … 76 85 dernierElement = pspa_->getBeamLine()->getAbstractElement(pspa_->getBeamLine()->getBeamLineSize()-1); 77 86 dernierIndex = pspa_->getBeamLine()->getBeamLineSize()-1; 78 // cout << "PspaApplication::addSectionToExecute() : " << premierText << " ââ " << dernierText << endl; 79 80 // abstractSoftware* soft = NULL; 81 // dtmanage_->addSectionToExecute(premierElement,premierIndex, dernierElement, dernierIndex, soft); 82 dtmanage_->addSectionToExecute(premierElement,premierIndex, dernierElement, dernierIndex, nomDeLogiciel()); 87 88 dtmanage_->addSectionToExecute(premierElement,premierIndex,dernierElement,dernierIndex,nomDeLogiciel()); 83 89 84 90 std::string premierElementLabel = ""; … … 87 93 premierElementLabel = premierElement->getLabel(); 88 94 } 89 90 95 if (dernierElement) { 91 96 dernierElementLabel = dernierElement->getLabel(); … … 104 109 fillComboWithSoftwares(softCombo); 105 110 106 GWt_sectionToExecute* newSection = new GWt_sectionToExecute(lineFromCombo, lineToCombo,softCombo,createAddDeletePushButtons(sections_.size()),this);111 GWt_sectionToExecute* newSection = new GWt_sectionToExecute(lineFromCombo,lineToCombo,softCombo,createAddDeletePushButtons(sections_.size()),this); 107 112 108 113 stringstream st; … … 118 123 } 119 124 125 void GWt_softwarePanel::updateSections() 126 { 127 #if BAVARD > 0 128 cout << "***********************************" << endl; 129 cout << " GWt_softwarePanel::updateSections() " << endl<<endl; 130 #endif 131 132 // update all sections in order to manage new/deleted items 133 for (int a = 0; a < sections_.size(); a++) { 134 fillComboWithElements(sections_[a]->getFirstElement()); 135 fillComboWithElements(sections_[a]->getLastElement()); 136 sections_[a]->getFirstElement()->setEnabled (true); 137 sections_[a]->getLastElement()->setEnabled (true); 138 } 139 140 if (sections_.size() == 0) { 141 return; 142 } 143 144 // the first element will always be the first element of the beamLine 145 sections_[0]->getFirstElement()->setCurrentIndex(0); 146 sections_[0]->getFirstElement()->setEnabled (false); 147 148 // the last element will always be the last element of the beamLine 149 sections_[sections_.size()-1]->getLastElement()->setCurrentIndex(sections_[sections_.size()-1]->getLastElement()->count()); 150 sections_[sections_.size()-1]->getLastElement()->setEnabled(false); 151 152 // set default values 153 updateSectionSelection(); 154 } 155 120 156 bool GWt_softwarePanel::updateSectionSelection() 121 157 { 158 #if BAVARD > 0 159 cout << "***********************************" << endl; 160 cout << " GWt_softwarePanel::updateSectionSelection() " << endl<<endl; 161 #endif 162 122 163 if ( dtmanage_->getJobListSize() == 0 ) return false; 123 164 … … 134 175 // si la fin est mal definie on prend toute la config par defaut 135 176 if ( current <= 0 || current > dtmanage_->getBeamLineSize() ) 136 { 137 current = dtmanage_->getBeamLineSize(); 138 currentString = dtmanage_->getLabelFromElementNumero(current); 139 if (sections_.size() > 0) { 140 sections_[0]->setLastElementCurrentSelection(currentString); 141 //... 177 { 178 current = dtmanage_->getBeamLineSize(); 179 currentString = dtmanage_->getLabelFromElementNumero(current); 180 if (sections_.size() > 0) { 181 sections_[0]->setLastElementCurrentSelection(currentString); 182 //... 183 } 142 184 } 143 }144 185 current++; 145 186 currentString = dtmanage_->getLabelFromElementNumero(current); … … 184 225 185 226 if (!areDataCoherent()) { 227 #if BAVARD > 0 228 cout << " GWt_softwarePanel::addSectionToExecuteW() DISABLE" << endl; 229 #endif 186 230 exec_go_->disable(); 187 231 } else { 232 #if BAVARD > 0 233 cout << " GWt_softwarePanel::addSectionToExecuteW() ENABLE" << endl; 234 #endif 188 235 exec_go_->enable(); 189 236 } … … 192 239 } 193 240 194 195 241 bool GWt_softwarePanel::areDataCoherent() 196 242 { 243 #if BAVARD > 0 244 cout << "***********************************" << endl; 245 cout << " GWt_softwarePanel::areDataCoherent() " << endl<<endl; 246 #endif 247 197 248 bool caMarche = true; 198 249 … … 204 255 pspa_->getBeamLine()->initializeSoftwares(); 205 256 } 206 257 207 258 string diagnosticErrors; 208 259 string diagnosticWarnings; 209 210 for (int a = 0; a< sections_.size(); a++) 260 for (int a = 0; a < sections_.size(); a++) 211 261 { 212 string debString = sections_[a]->getFirstElementCurrentText().toUTF8(); 213 string finString = sections_[a]->getLastElementCurrentText().toUTF8(); 214 215 // int debut = pspa_->getBeamLine()->getAbstractElementIndexFromLabel(debString)+1; // FIXME : Should NOT be +1 216 // int fin = pspa_->getBeamLine()->getAbstractElementIndexFromLabel(finString)+1; // FIXME : Should NOT be +1 217 262 string debString= sections_[a]->getFirstElementCurrentText().toUTF8(); 263 string finString= sections_[a]->getLastElementCurrentText().toUTF8(); 218 264 int debut = pspa_->getBeamLine()->getAbstractElementNumeroFromLabel(debString); 219 265 int fin = pspa_->getBeamLine()->getAbstractElementNumeroFromLabel(finString); 220 221 nomDeLogiciel prog = nomDeLogiciel ( sections_[a]->getSoftwareCurrentText().toUTF8()); 222 // abstractSoftware* softToExec = dtmanage_->createSoftwareConnexion(prog); 223 sectionToExecute* sectToExec = dtmanage_->addSectionToExecute(pspa_->getBeamLine()->getAbstractElement(debut), 224 debut, 225 pspa_->getBeamLine()->getAbstractElement(fin), 226 fin, 227 prog); 266 267 string currentSoft= sections_[a]->getSoftwareCurrentText().toUTF8(); 268 nomDeLogiciel prog = nomDeLogiciel(currentSoft); 269 sectionToExecute* sectToExec = dtmanage_->addSectionToExecute(pspa_->getBeamLine()->getAbstractElement(debut),debut,pspa_->getBeamLine()->getAbstractElement(fin),fin,prog); 228 270 229 271 abstractSoftware* softToExec = sectToExec->getSoftware(); 230 272 diagnosticErrors = ""; 231 273 diagnosticWarnings = ""; 232 233 // check sections 234 for (int i=debut-1; i<fin; i++) { 235 if (pspa_->getBeamLine()) { 236 if (pspa_->getBeamLine()->getAbstractElement(i)) { 237 // trivaluedBool tb = pspa_->getBeamLine()->getAbstractElement(i)->setSoftware(prog.getString()); 238 239 240 trivaluedBool tb = softToExec->doAcceptElement(pspa_->getBeamLine()->getAbstractElement(i)->getNomdElement().getElementType() ); 241 242 if (tb == TBoolOk ) { 243 pspa_->getBeamLine()->getAbstractElement(i)->setSoftware(softToExec); 274 for(int i = debut-1; i < fin; i++) // check sections 275 { 276 if (!pspa_->getBeamLine()) continue; 277 abstractElement* elPtr= pspa_->getBeamLine()->getAbstractElement(i); 278 if (!elPtr) continue; 279 280 trivaluedBool tb = softToExec->doAcceptElement(elPtr->getNomdElement().getElementType()); 281 if (tb == TBoolOk ) { 282 elPtr->setSoftware(softToExec); 283 } else { 284 elPtr->setSoftware(NULL); 285 if (tb == TBoolIgnore) { 286 if(prog.getString() != "unknownSoftware") diagnosticWarnings += elPtr->getLabel() + " will be ignored by "+ prog.getString() + "<br /> "; 244 287 } else { 245 pspa_->getBeamLine()->getAbstractElement(i)->setSoftware( NULL ); 246 247 if ( tb == TBoolIgnore ) { 248 diagnosticWarnings += pspa_->getBeamLine()->getAbstractElement(i)->getLabel() + " will be ignored by "+ prog.getString()+"<br /> "; 249 } else { 250 // j'insiste pour remettre le nom generique de l'element refuse (glm / 30/03/2013) 251 diagnosticErrors += pspa_->getBeamLine()->getAbstractElement(i)->getNomdElement().getExpandedName() + " is not allowed with "+ prog.getString()+"<br /> "; 252 caMarche = false; 253 } 288 // j'insiste pour remettre le nom generique de l'element refuse (glm / 30/03/2013) 289 diagnosticErrors += elPtr->getNomdElement().getExpandedName() + " is not allowed with " + prog.getString() + "<br /> "; 290 caMarche = false; 254 291 } 255 pspa_->getBeamLine()->update(i);256 292 } 257 } 258 } 293 pspa_->getBeamLine()->update(i); 294 } //i 295 259 296 // set errors and warnings 260 297 sections_[a]->setErrors(diagnosticErrors); 261 298 sections_[a]->setWarnings(diagnosticWarnings); 262 } 299 }//a 263 300 264 301 return caMarche; … … 286 323 } 287 324 288 289 void GWt_softwarePanel::updateSections()290 {291 // update all sections in order to manage new/deleted items292 for (int a = 0; a< sections_.size(); a++) {293 fillComboWithElements(sections_[a]->getFirstElement());294 fillComboWithElements(sections_[a]->getLastElement());295 296 sections_[a]->getFirstElement()->setEnabled (true);297 sections_[a]->getLastElement()->setEnabled (true);298 }299 if (sections_.size() == 0) {300 return;301 }302 // the first element will always be the first element of the beamLine303 sections_[0]->getFirstElement()->setCurrentIndex(0);304 sections_[0]->getFirstElement()->setEnabled (false);305 306 // the last element will always be the last element of the beamLine307 sections_[sections_.size()-1]->getLastElement()->setCurrentIndex(sections_[sections_.size()-1]->getLastElement()->count());308 sections_[sections_.size()-1]->getLastElement()->setEnabled (false);309 310 // set default values311 312 // update313 updateSectionSelection();314 }315 316 325 void GWt_softwarePanel::executer() 317 326 { 318 327 cout << "***********************************" << endl; 328 cout << " GWt_softwarePanel::executer() " << endl<<endl; 329 319 330 if (!areDataCoherent()) { 320 331 return; 321 332 } 322 333 323 static_cast<GWt_globalParameters*>(pspa_->getGlobalParam())->updateGlobals();334 //static_cast<GWt_globalParameters*>(pspa_->getGlobalParam())->updateGlobals(); 324 335 325 336 GWt_dialog calculDialog("Calcul en cours", "Veuillez patienter...", GWt_dialog::Wait, true,false); … … 329 340 330 341 if (!dtmanage_->executeAll()) { 331 GWt_dialog warningDialog("PSPA : Echec", " echec lors de l'exà cution !", GWt_dialog::Error, true,true);342 GWt_dialog warningDialog("PSPA : Echec", " echec lors de l'exécution !", GWt_dialog::Error, true,true); 332 343 warningDialog.exec(); 333 344 } … … 338 349 } 339 350 340 341 void GWt_softwarePanel::fillComboWithElements(Wt::WComboBox* cBox){351 void GWt_softwarePanel::fillComboWithElements(Wt::WComboBox* cBox) 352 { 342 353 if (cBox == NULL) return; 343 354 344 355 // get the last item selected 345 WString selectedString = cBox->currentText 356 WString selectedString = cBox->currentText(); 346 357 cBox->clear(); 347 358 348 for (int a=0; a< pspa_->getBeamLine()->getBeamLineSize(); a++) {359 for(int a = 0; a < pspa_->getBeamLine()->getBeamLineSize(); a++) { 349 360 abstractElement* abs = pspa_->getBeamLine()->getAbstractElement(a); 350 if (abs != NULL) {361 if (abs != NULL) { 351 362 cBox->addItem(abs->getLabel()); 352 363 } 353 364 } 354 365 355 for (int a=0; a<cBox->count(); a++) {366 for(int a = 0; a < cBox->count(); a++) { 356 367 if (cBox->itemText (a) == selectedString) { 357 368 cBox->setCurrentIndex(a); … … 361 372 } 362 373 363 364 void GWt_softwarePanel::fillComboWithSoftwares(Wt::WComboBox* cBox) { 374 void GWt_softwarePanel::fillComboWithSoftwares(Wt::WComboBox* cBox) 375 { 376 #if BAVARD > 0 377 cout << "***********************************" << endl; 378 cout << " GWt_softwarePanel::fillComboWithSoftwares " << endl<<endl; 379 #endif 380 365 381 if (cBox == NULL) return; 366 382 cBox->clear(); … … 368 384 unsigned nb = nomDeLogiciel::getNumberOfSoftwares(); 369 385 unsigned k; 370 for(k = 0; k < nb; k++) {386 for(k = 0; k <= nb; k++) { //xx 371 387 cBox->addItem(nomDeLogiciel(k).getString()); 372 388 } 389 cBox->setCurrentIndex(nb); // xx 373 390 cBox->refresh(); 374 391 } 375 392 376 377 Wt::WContainerWidget* GWt_softwarePanel::createAddDeletePushButtons(int sectionNumber) { 378 393 Wt::WContainerWidget* GWt_softwarePanel::createAddDeletePushButtons(int sectionNumber) 394 { 379 395 WContainerWidget* buttonContainer= new WContainerWidget(); 380 396 … … 399 415 buttonContainerLayout->addWidget(exec_add); 400 416 buttonContainerLayout->addWidget(exec_delete); 401 402 417 buttonContainer->setLayout(buttonContainerLayout); 403 418
Note: See TracChangeset
for help on using the changeset viewer.