Changeset 324 in PSPA
- Timestamp:
- Feb 18, 2013, 1:52:42 PM (12 years ago)
- Location:
- Interface_Web/trunk/pspaWT
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/cmt/requirements
r316 r324 4 4 include_path none 5 5 6 use Platform v1r* $(PSPAWTROOT)/../Interfaces7 use dld v2r* $(PSPAWTROOT)/../Interfaces6 use Platform v1r* Interfaces 7 use dld v2r* Interfaces 8 8 9 use Wt v1r* $(PSPAWTROOT)/../Interfaces10 use boost v1r* $(PSPAWTROOT)/../Interfaces9 use Wt v1r* Interfaces 10 use boost v1r* Interfaces 11 11 12 12 include_dirs $(PSPAWTROOT)/sources/userInterface/include $(PSPAWTROOT)/sources/controler/include … … 55 55 56 56 #macro lib_PSPSLib_cppflags " ${Wt_cflags} ${boost_cflags} -DTHREADED -DDRAWWT_BUILD -DHAS_IMAGEMAGIC -DPSPA_DEBUG" 57 macro lib_PSPSLib_cppflags " ${Wt_cflags} ${boost_cflags} -DTHREADED -DDRAWWT_BUILD 57 macro lib_PSPSLib_cppflags " ${Wt_cflags} ${boost_cflags} -DTHREADED -DDRAWWT_BUILD -DPSPA_DEBUG" 58 58 59 59 macro PSPSLib_shlibflags " ${Wt_linkopts} ${boost_linkopts} ${dld_linkopts}" -
Interface_Web/trunk/pspaWT/sources/controler/include/particleBeam.h
r314 r324 88 88 virtual bool FileInput(ifstream& ifs); 89 89 90 void histogramme(vector<double>&xcor,vector<int>& hist,int& cnts );90 void histogramme(vector<double>&xcor,vector<int>& hist,int& cnts,double out[3]); 91 91 }; 92 92 -
Interface_Web/trunk/pspaWT/sources/controler/src/particleBeam.cc
r314 r324 428 428 } 429 429 430 void particleBeam::histogramme(vector<double>&xcor,vector<int>& hist,int& cnts )430 void particleBeam::histogramme(vector<double>&xcor,vector<int>& hist,int& cnts,double out[3]) 431 431 { 432 // sortie pour la legende: out[0]= entries, out[1]= mean, out[2]= rms 433 432 434 double gammin= GRAND; 433 435 double gammax= -gammin; … … 446 448 447 449 double sum= (float)goodPartic_.size(); 450 out[0]= sum; 448 451 Emoy /= sum; 452 out[1]= Emoy; //MeV 449 453 ecatyp /= sum; 454 out[2]= 1000.0*sqrt(ecatyp); //KeV 450 455 ecatyp = sqrt(abs(ecatyp-Emoy*Emoy)); 451 456 … … 487 492 for (int i = 0; i < ihist; ++i) { 488 493 489 // on gradue l'ab cisse en pourcents494 // on gradue l'abscisse en pourcents 490 495 xcor[i]= 100.*( vmin+i*hpas ); 491 496 } … … 497 502 int k= var/hpas; 498 503 int kk= (int)floor(var/hpas); 499 if(i%20 == 0) cout<<"v("<<i<<")= " <<var<<" ["<<k<<"-"<<kk<<"], "<<endl;504 //if(i%20 == 0) cout<<"v("<<i<<")= " <<var<<" ["<<k<<"-"<<kk<<"], "<<endl; 500 505 hist[kk]++; 501 506 } … … 504 509 for (int i = 0; i < ihist; ++i) { 505 510 if(hist.at(i) > 0) cnts++; 506 cout<<"("<<xcor.at(i)<<","<<hist.at(i)<<") ";511 //cout<<"("<<xcor.at(i)<<","<<hist.at(i)<<") "; 507 512 } 508 513 cout<< " ... cnts= " << cnts << endl; -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_pspaApplication.h
r305 r324 16 16 #include <Wt/Chart/WCartesianChart> 17 17 #include <Wt/WLength> 18 #include <Wt/WButtonGroup> 18 19 19 20 #include "GWt_dialog.h" … … 26 27 using namespace Wt; 27 28 28 /*29 * ESSAI PSPA30 */31 29 class PspaApplication : public WApplication 32 30 { 33 31 34 32 private : 35 33 36 37 38 39 40 41 42 43 34 dataManager* dtmanage_; 35 string nameOfCase_; 36 string workingDir_; 37 WDialog* dialogSave_; 38 WDialog* dialogOpen_; 39 WLineEdit* saveNameEdit_; 40 WLineEdit* openNameEdit_; 41 GWt_LigneFaisceau* beamLine_; 44 42 43 // WContainerWidget* console_; 44 WWidget* globalParam_; 45 // WContainerWidget* leDessin_; 46 GWt_dialog* graphicsDialog_; 47 WButtonGroup *group_; 48 49 WText* probleme_; 50 WComboBox* choixElementDessin_; 51 WComboBox* choixTypeDessinFaisceau_; 52 WComboBox* choixEnveloppeDessin_; 53 WComboBox* choixHistoDessin_; 54 55 WContainerWidget* toto_; 56 GWt_softwarePanel* executeWidget_; 57 WFileUpload* uploadFileSelectorWidget_; 58 GWt_console* console_; 59 GWt_abstractElementFactory* abstractElementFactory_; 60 61 WText* createTitle(const WString&); 62 WWidget* createPalette(); 63 void createBeamLine(); 64 WWidget* createGlobalParamWidget(); 65 WWidget* createExecuteWidget(); 66 WContainerWidget* createDrawingWidget(); 67 void closeGraphicDialog(); 68 69 void createDragImage(const char *url,const char *smallurl,const char *mimeType,WContainerWidget *p,WString()); 70 void sauver(); 71 void dialogSaveDone(WDialog::DialogCode code); 72 void dialogOpenDone(WDialog::DialogCode code); 73 void restaurer(); 74 void chargerConfig(); 75 void openFileSelector(); 76 void fileTooLarge(); 77 78 void dialogOnGraphics(); 79 void faireDessinParmela(WContainerWidget* toto, particleBeam* beam); 80 void faireDessinTransport(WContainerWidget* toto, particleBeam* beam); 81 void faireDessinEnveloppe(WContainerWidget* toto, string type); 82 void scatterPlot1D(WContainerWidget* toto, vector<double>& xcor, vector<double>& ycor); 45 83 46 // WContainerWidget* console_; 47 WWidget* globalParam_; 48 // WContainerWidget* leDessin_; 49 GWt_dialog* graphicsDialog_; 84 bool removeExtensionFromConfigName(string& config); 50 85 51 WText* probleme_; 52 WComboBox* choixElementDessin_; 53 WComboBox* choixTypeDessinFaisceau_; 54 WComboBox* choixEnveloppeDessin_; 55 WContainerWidget* toto_; 56 GWt_softwarePanel* executeWidget_; 57 WFileUpload* uploadFileSelectorWidget_; 58 GWt_console* console_; 59 GWt_abstractElementFactory* abstractElementFactory_; 86 void dessiner(); 87 void dessinerEnveloppe(); 88 void dessinerPhaseSpace(); 89 void dessinerHistogramme(); 60 90 61 62 WText* createTitle(const WString&); 63 WWidget* createPalette(); 64 void createBeamLine(); 65 WWidget* createGlobalParamWidget(); 66 WWidget* createExecuteWidget(); 67 WContainerWidget* createDrawingWidget(); 68 69 void createDragImage(const char *url,const char *smallurl,const char *mimeType,WContainerWidget *p,WString name); 70 void sauver(); 71 void dialogSaveDone(WDialog::DialogCode code); 72 void dialogOpenDone(WDialog::DialogCode code); 73 void restaurer(); 74 void chargerConfig(); 75 void openFileSelector(); 76 void fileTooLarge(); 77 void dessiner(); 78 79 void dialogOnGraphics(); 80 void faireDessinParmela(WContainerWidget* toto, particleBeam* beam); 81 void faireDessinTransport(WContainerWidget* toto, particleBeam* beam); 82 83 void dessinerEnveloppe(); 84 void faireDessinEnveloppe(WContainerWidget* toto, string type); 85 void scatterPlot1D(WContainerWidget* toto, vector<double>& xcor, vector<double>& ycor); 86 87 bool removeExtensionFromConfigName(string& config); 88 89 void dessinerHistogramme(); 90 91 public : 92 93 PspaApplication(const WEnvironment& env); 94 95 inline dataManager* getDataManager() const { 96 return dtmanage_; 97 } 98 99 // void addConsoleMessage(WString msg); 100 101 string getSelection(); 102 void faireDessin(); 103 inline WWidget* getGlobalParam() { 104 return globalParam_; 105 }; 106 inline GWt_softwarePanel* getExecuteWidget() { 107 return executeWidget_; 108 }; 109 inline GWt_LigneFaisceau* getBeamLine() { 110 return beamLine_; 111 } 91 public : 92 93 PspaApplication(const WEnvironment& env); 112 94 113 inline GWt_abstractElementFactory* getAbstractElementFactory() { 114 return abstractElementFactory_; 115 }; 95 string getSelection(); 96 void faireDessin(); 97 98 inline dataManager* getDataManager() const { 99 return dtmanage_; 100 } 101 102 inline WWidget* getGlobalParam() { 103 return globalParam_; 104 } 105 106 inline GWt_softwarePanel* getExecuteWidget() { 107 return executeWidget_; 108 } 109 110 inline GWt_LigneFaisceau* getBeamLine() { 111 return beamLine_; 112 } 113 114 inline GWt_abstractElementFactory* getAbstractElementFactory() { 115 return abstractElementFactory_; 116 } 116 117 }; 117 118 #endif -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc
r320 r324 33 33 #include <Wt/WScrollArea> 34 34 #include <Wt/WLineEdit> 35 #include <Wt/WRadioButton> 35 36 36 37 using namespace Wt::Chart; … … 110 111 boutongraphicalAnalysis->clicked().connect(this, &PspaApplication::dialogOnGraphics); 111 112 112 113 113 toolbarLayout->addWidget(boutonSauve , 0,Wt::AlignMiddle); 114 114 toolbarLayout->addWidget(boutonRestaure , 0,Wt::AlignMiddle); … … 145 145 console_->setOverflow(WContainerWidget::OverflowAuto); 146 146 layout->addWidget(console_, 3, 2); 147 148 149 150 151 147 152 148 //----------- … … 159 155 graphicsDialog_->setClosable(true); 160 156 161 162 163 157 executeWidget_ = new GWt_softwarePanel(dtmanage_,this); 164 158 … … 167 161 layout->addWidget( executeWidget_ , 4, 1); 168 162 //----------- 169 170 171 163 172 164 layout->setColumnResizable(1); 173 165 layout->setRowResizable(2); … … 183 175 WWidget* PspaApplication::createPalette() 184 176 { 185 WContainerWidget* palette=new WContainerWidget(); 186 // palette->setLayout(new WVBoxLayout()); 187 188 // nomdElements *e= new nomdElements(); 189 // int nElts= e->getNumberOfElements(); 190 // delete e; 191 // nomdElements bidon; 192 193 vector <GWt_abstractElement*> elems = abstractElementFactory_->getAllElements(); 194 for (int a = 0; a< elems.size(); a++) { 195 elems[a]->createDragImage(palette); 196 new WBreak(palette); 197 } 198 199 // palette->setMinimumSize(100,300); 200 return palette; 201 202 } 203 204 void PspaApplication::createDragImage(const char *url,const char *smallurl,const char *mimeType,WContainerWidget *p,WString name) 205 { 206 GWt_draggableImage *result = new GWt_draggableImage(url,p); 207 208 /* 209 * Set the image to be draggable, showing the other image (dragImage) 210 * to be used as the widget that is visually dragged. 211 */ 212 result->setDraggable(mimeType,new WImage(smallurl,p),true); 177 WContainerWidget* palette = new WContainerWidget(); 178 vector <GWt_abstractElement*> elems = abstractElementFactory_->getAllElements(); 179 for (unsigned a = 0; a < elems.size(); a++) { 180 elems[a]->createDragImage(palette); 181 new WBreak(palette); 182 } 183 184 return palette; 185 } 186 187 void PspaApplication::createDragImage(const char *url,const char *smallurl,const char *mimeType,WContainerWidget *p,WString()) 188 { 189 GWt_draggableImage *result = new GWt_draggableImage(url,p); 190 191 /* 192 * Set the image to be draggable, showing the other image (dragImage) 193 * to be used as the widget that is visually dragged. 194 */ 195 result->setDraggable(mimeType,new WImage(smallurl,p),true); 213 196 } 214 197 215 198 void PspaApplication::createBeamLine() 216 199 { 217 218 200 beamLine_ = new GWt_LigneFaisceau(this); 201 beamLine_->setMinimumSize(300,100); 219 202 } 220 203 … … 230 213 void PspaApplication::dialogOnGraphics() 231 214 { 232 // GWt_dialog* graphicsDialog = new GWt_dialog("graphical analysis",createDrawingWidget(),false); 233 // graphicsDialog->setMinimumSize(400,400); 234 // graphicsDialog->setClosable(true); 235 236 237 graphicsDialog_->show(); 238 215 graphicsDialog_->show(); 239 216 } 240 217 241 218 WContainerWidget* PspaApplication::createDrawingWidget() 242 219 { 243 WContainerWidget* dessin = new WContainerWidget(); 244 245 246 247 248 choixEnveloppeDessin_ = new WComboBox(); 249 choixEnveloppeDessin_->addItem("x"); 250 // choixEnveloppeDessin_->addItem("y"); 251 WPushButton* okEnv = new WPushButton("draw enveloppe"); 252 okEnv->clicked().connect(this, &PspaApplication::dessinerEnveloppe); 253 254 255 dessin->addWidget(new WText(" enveloppe : ")); 256 dessin->addWidget(choixEnveloppeDessin_); 257 dessin->addWidget(okEnv); 258 259 dessin->addWidget(new WBreak()); 260 261 choixElementDessin_ = new WComboBox(); 262 263 264 265 choixTypeDessinFaisceau_ = new WComboBox(); 266 choixTypeDessinFaisceau_->addItem("courant_snyder"); 267 choixTypeDessinFaisceau_->addItem("macroparticles"); 268 WPushButton* caroule = new WPushButton("dessiner"); 269 caroule->clicked().connect(this, &PspaApplication::dessiner); 270 271 dessin->addWidget(new WText(" phase space after element : ")); 272 dessin->addWidget(choixElementDessin_); 273 dessin->addWidget(choixTypeDessinFaisceau_); 274 dessin->addWidget(caroule); 275 dessin->addWidget(new WBreak()); 276 277 278 279 280 281 ///////////////////////////////////////////////////////////////////// 282 dessin->addWidget(new WText(" histogramme : ")); 283 WPushButton* okHisto = new WPushButton("histogramme"); 284 dessin->addWidget(okHisto); 285 286 okHisto->clicked().connect(this,&PspaApplication::dessinerHistogramme); 287 ///////////////////////////////////////////////////////////////////// 288 289 toto_ = new WContainerWidget(); 290 dessin->addWidget(toto_); 291 return dessin; 292 } 293 294 295 220 WGridLayout *glayout= new WGridLayout(); 221 WContainerWidget* dessin = new WContainerWidget(); 222 dessin->setLayout(glayout); 223 224 group_ = new Wt::WButtonGroup(this); 225 226 ///////////////////////////////////////////////////////////////////// 227 228 choixEnveloppeDessin_ = new WComboBox(); 229 choixEnveloppeDessin_->addItem("x"); 230 // choixEnveloppeDessin_->addItem("y"); 231 Wt::WRadioButton *button1= new WRadioButton(" enveloppe"); 232 group_->addButton(button1,1); 233 glayout->addWidget(button1,0,1); 234 glayout->addWidget(choixEnveloppeDessin_,0,2); 235 ///////////////////////////////////////////////////////////////////// 236 237 choixElementDessin_ = new WComboBox(); 238 choixTypeDessinFaisceau_ = new WComboBox(); 239 choixTypeDessinFaisceau_->addItem("courant_snyder"); 240 choixTypeDessinFaisceau_->addItem("macroparticles"); 241 Wt::WRadioButton *button2= new WRadioButton(" phase space after element"); 242 group_->addButton(button2,2); 243 glayout->addWidget(button2,1,1); 244 glayout->addWidget(choixElementDessin_,1,2); 245 glayout->addWidget(choixTypeDessinFaisceau_,1,3); 246 ///////////////////////////////////////////////////////////////////// 247 248 choixHistoDessin_ = new WComboBox(); 249 Wt::WRadioButton *button3= new WRadioButton(" histogram after element"); 250 group_->addButton(button3,3); 251 glayout->addWidget(button3,2,1); 252 glayout->addWidget(choixHistoDessin_,2,2); 253 ///////////////////////////////////////////////////////////////////// 254 255 WPushButton *close= new WPushButton("close"); 256 glayout->addWidget(close,3,1); 257 close->clicked().connect(this,&PspaApplication::closeGraphicDialog); 258 259 WPushButton *draw= new WPushButton("draw"); 260 glayout->addWidget(draw,3,2,2,1); 261 draw->clicked().connect(this,&PspaApplication::dessiner); 262 ///////////////////////////////////////////////////////////////////// 263 264 toto_ = new WContainerWidget(); 265 dessin->addWidget(toto_); 266 return dessin; 267 } 268 269 void PspaApplication::closeGraphicDialog() 270 { 271 cout << " close graphicsDialog_" << endl; 272 graphicsDialog_->done(WDialog::Rejected); 273 } 274 275 void PspaApplication::dessiner() 276 { 277 int k= group_->checkedId(); 278 cout << "dessiner k= " << k << endl; 279 280 switch(k) { 281 case 1: 282 dessinerEnveloppe(); 283 break; 284 case 2: 285 dessinerPhaseSpace(); 286 break; 287 case 3: 288 dessinerHistogramme(); 289 break; 290 default: 291 GWt_dialog graphicalWarning("graphical analysis","select a button",GWt_dialog::Warning,false,true); 292 graphicalWarning.exec(); 293 break; 294 } 295 } 296 296 297 297 void PspaApplication::sauver() 298 298 { 299 300 301 302 303 304 305 306 307 308 309 310 299 cout << " on sauve " << endl; 300 console_->addConsoleMessage("sauvegarde"); 301 302 dialogSave_ = new WDialog("save"); 303 new WText("name of case : ",dialogSave_->contents()); 304 saveNameEdit_ = new WLineEdit(nameOfCase_.c_str(), dialogSave_->contents()); 305 WPushButton *annule = new WPushButton("cancel",dialogSave_->contents()); 306 WPushButton *submit = new WPushButton("OK",dialogSave_->contents()); 307 annule->clicked().connect(dialogSave_, &Wt::WDialog::reject); 308 submit->clicked().connect(dialogSave_, &Wt::WDialog::accept); 309 dialogSave_->finished().connect(this, &PspaApplication::dialogSaveDone); 310 dialogSave_->show(); 311 311 } 312 312 313 313 void PspaApplication::dialogSaveDone(WDialog::DialogCode code) 314 314 { 315 316 if ( code != Wt::WDialog::Accepted ) { console_->addConsoleMessage(" pas de sauvegarde"); return;} 317 else { console_->addConsoleMessage("sauvegarde sur repertoire : " + workingDir_);} 318 nameOfCase_ = saveNameEdit_->text().toUTF8(); 319 cout << " PspaApplication::dialogSaveDone() nameOfCase_= " << nameOfCase_ << endl; 320 delete dialogSave_; 321 dialogSave_ = NULL; 322 GWt_globalParameters* bibi = static_cast<GWt_globalParameters*>(globalParam_); 323 bibi->updateGlobals(); 324 // dtmanage_->saveConfiguration(nameOfCase_); 325 dtmanage_->saveConfiguration( nameOfCase_); 326 } 327 328 315 316 if ( code != Wt::WDialog::Accepted ) { console_->addConsoleMessage(" pas de sauvegarde"); return;} 317 else { console_->addConsoleMessage("sauvegarde sur repertoire : " + workingDir_);} 318 nameOfCase_ = saveNameEdit_->text().toUTF8(); 319 cout << " PspaApplication::dialogSaveDone() nameOfCase_= " << nameOfCase_ << endl; 320 delete dialogSave_; 321 dialogSave_ = NULL; 322 GWt_globalParameters* bibi = static_cast<GWt_globalParameters*>(globalParam_); 323 bibi->updateGlobals(); 324 // dtmanage_->saveConfiguration(nameOfCase_); 325 dtmanage_->saveConfiguration( nameOfCase_); 326 } 329 327 330 328 void PspaApplication::restaurer() … … 343 341 344 342 void PspaApplication::dialogOpenDone(WDialog::DialogCode code) 345 { 346 347 if ( code != Wt::WDialog::Accepted ) { console_->addConsoleMessage(" pas de restauration"); return;} 348 else { console_->addConsoleMessage("restauration depuis le repertoire " + workingDir_ );} 349 350 nameOfCase_ = openNameEdit_->text().toUTF8(); 351 cout << " PspaApplication::dialogOpenDone() nameOfCase_= " << nameOfCase_ << endl; 352 delete dialogOpen_; 353 dialogSave_ = NULL; 354 355 bool test = dtmanage_->restoreElements(nameOfCase_); 356 if ( !test ) { 357 GWt_dialog restoreWarning(" element restoring", "failure in restoring elements !", GWt_dialog::Error, false,true); 358 restoreWarning.exec(); 359 } 360 361 GWt_globalParameters* bibi = static_cast<GWt_globalParameters*>(globalParam_); 362 bibi->renew(); 363 364 console_->addConsoleMessage(string("...terminee")); 365 } 366 343 { 344 if (code != Wt::WDialog::Accepted) { 345 console_->addConsoleMessage(" pas de restauration"); 346 return; 347 } else { 348 console_->addConsoleMessage("restauration depuis le repertoire " + workingDir_ ); 349 } 350 351 nameOfCase_ = openNameEdit_->text().toUTF8(); 352 cout << " PspaApplication::dialogOpenDone() nameOfCase_= " << nameOfCase_ << endl; 353 delete dialogOpen_; 354 dialogSave_ = NULL; 355 356 bool test = dtmanage_->restoreElements(nameOfCase_); 357 if ( !test ) { 358 GWt_dialog restoreWarning(" element restoring", "failure in restoring elements !", GWt_dialog::Error, false,true); 359 restoreWarning.exec(); 360 } 361 362 GWt_globalParameters* bibi = static_cast<GWt_globalParameters*>(globalParam_); 363 bibi->renew(); 364 365 console_->addConsoleMessage(string("...terminee")); 366 } 367 367 368 368 void PspaApplication::openFileSelector() 369 369 { 370 370 371 WContainerWidget *result = new WContainerWidget(); 372 WVBoxLayout* myLayout = new WVBoxLayout(); 373 374 uploadFileSelectorWidget_ = new WFileUpload(); 375 376 uploadFileSelectorWidget_->setFileTextSize(40); 377 378 myLayout->addWidget(new WText("Select the configuration file for pspa : ")); 379 myLayout->addWidget(uploadFileSelectorWidget_); 380 381 result->setLayout (myLayout); 382 383 // Upload automatically when the user entered a file. 384 uploadFileSelectorWidget_->changed().connect(uploadFileSelectorWidget_, &WFileUpload::upload); 385 386 // React to a succesfull upload. 387 uploadFileSelectorWidget_->uploaded().connect(this, &PspaApplication::chargerConfig); 388 389 // React to a fileupload problem. 390 uploadFileSelectorWidget_->fileTooLarge().connect(this, &PspaApplication::fileTooLarge); 391 392 393 GWt_dialog* fileSelectorDialog = new GWt_dialog("Load a file",result,false); 394 395 fileSelectorDialog->exec(); 396 } 397 371 WContainerWidget *result = new WContainerWidget(); 372 WVBoxLayout* myLayout = new WVBoxLayout(); 373 374 uploadFileSelectorWidget_ = new WFileUpload(); 375 376 uploadFileSelectorWidget_->setFileTextSize(40); 377 378 myLayout->addWidget(new WText("Select the configuration file for pspa : ")); 379 myLayout->addWidget(uploadFileSelectorWidget_); 380 381 result->setLayout (myLayout); 382 383 // Upload automatically when the user entered a file. 384 uploadFileSelectorWidget_->changed().connect(uploadFileSelectorWidget_, &WFileUpload::upload); 385 386 // React to a succesfull upload. 387 uploadFileSelectorWidget_->uploaded().connect(this, &PspaApplication::chargerConfig); 388 389 // React to a fileupload problem. 390 uploadFileSelectorWidget_->fileTooLarge().connect(this, &PspaApplication::fileTooLarge); 391 392 393 GWt_dialog* fileSelectorDialog = new GWt_dialog("Load a file",result,false); 394 395 fileSelectorDialog->exec(); 396 } 398 397 399 398 void PspaApplication::chargerConfig() … … 440 439 } 441 440 442 443 441 void PspaApplication::faireDessin() 444 442 { 445 choixElementDessin_->clear(); 446 int nombre = dtmanage_->getBeamLineSize(); 447 cout << " PspaApplication::faireDessin() nb elements : " << nombre << endl; 448 449 for ( int numero =1; numero <= nombre; numero++) 443 choixElementDessin_->clear(); 444 choixHistoDessin_->clear(); 445 int nombre = dtmanage_->getBeamLineSize(); 446 cout << " PspaApplication::faireDessin() nb elements : " << nombre << endl; 447 for(int i = 1; i <= nombre; i++) { 448 choixElementDessin_->addItem(dtmanage_->getLabelFromElementNumero(i)); 449 choixHistoDessin_->addItem(dtmanage_->getLabelFromElementNumero(i)); 450 } 451 } 452 453 void PspaApplication::dessinerPhaseSpace() 454 { 455 toto_->clear(); 456 457 int typeFaisceau = choixTypeDessinFaisceau_->currentIndex(); 458 int index = choixElementDessin_->currentIndex(); 459 particleBeam* beam = dtmanage_->getDiagnosticBeam(index); 460 461 if ( beam == NULL ) { 462 GWt_dialog warningBeamState(" graphical analysis", "the beam does not exist at the end of this element !", GWt_dialog::Error, false,true); 463 warningBeamState.exec(); 464 return; 465 } 466 467 if ( typeFaisceau == 0 ) 450 468 { 451 choixElementDessin_->addItem(dtmanage_->getLabelFromElementNumero(numero)); 452 } 453 454 } 455 456 void PspaApplication::dessiner() 457 { 458 459 toto_->clear(); 460 461 int typeFaisceau = choixTypeDessinFaisceau_->currentIndex(); 462 463 int index = choixElementDessin_->currentIndex(); 464 465 466 particleBeam* beam = dtmanage_->getDiagnosticBeam(index); 467 468 if ( beam == NULL ) { 469 GWt_dialog warningBeamState(" graphical analysis", "the beam does not exist at the end of this element !", GWt_dialog::Error, false,true); 470 warningBeamState.exec(); 471 return; 472 } 473 474 475 if ( typeFaisceau == 0 ) 469 if ( !beam->momentRepresentationOk() ) beam->buildMomentRepresentation(); 470 faireDessinTransport(toto_, beam); 471 } 472 else if ( typeFaisceau == 1 ) 476 473 { 477 if ( !beam->momentRepresentationOk() ) beam->buildMomentRepresentation(); 478 faireDessinTransport(toto_, beam); 479 } 480 else if ( typeFaisceau == 1 ) 474 if ( beam->particleRepresentationOk() ) faireDessinParmela(toto_, beam); 475 else { 476 GWt_dialog warningBeamState(" graphical analysis", "the beam state does not allow providing a drawing with macroparticles !", GWt_dialog::Error, false,true); 477 warningBeamState.exec(); 478 } 479 } 480 else { 481 GWt_dialog warningTypeDrawing(" graphical analysis", "type of drawing not programmed !", GWt_dialog::Error, false,true); 482 warningTypeDrawing.exec(); 483 } 484 } 485 486 void PspaApplication::dessinerEnveloppe() 487 { 488 toto_->clear(); 489 490 int typeEnveloppe = choixEnveloppeDessin_->currentIndex(); 491 if ( typeEnveloppe == 0 ) 481 492 { 482 if ( beam->particleRepresentationOk() ) faireDessinParmela(toto_, beam); 483 else { 484 GWt_dialog warningBeamState(" graphical analysis", "the beam state does not allow providing a drawing with macroparticles !", GWt_dialog::Error, false,true); 485 warningBeamState.exec(); 486 } 487 } 488 else { 489 GWt_dialog warningTypeDrawing(" graphical analysis", "type of drawing not programmed !", GWt_dialog::Error, false,true); 490 warningTypeDrawing.exec(); 491 } 492 ////////////////////////////////////////// 493 } 494 495 void PspaApplication::dessinerEnveloppe() 496 { 497 498 toto_->clear(); 499 500 int typeEnveloppe = choixEnveloppeDessin_->currentIndex(); 501 if ( typeEnveloppe == 0 ) 502 { 503 faireDessinEnveloppe(toto_, "x"); 504 } 505 else { 506 GWt_dialog warningTypeEnveloppe(" graphical analysis", "type of enveloppe drawing not programmed !", GWt_dialog::Error, false,true); 507 warningTypeEnveloppe.exec(); 508 } 509 ////////////////////////////////////////// 493 faireDessinEnveloppe(toto_, "x"); 494 } 495 else { 496 GWt_dialog warningTypeEnveloppe(" graphical analysis", "type of enveloppe drawing not programmed !", GWt_dialog::Error, false,true); 497 warningTypeEnveloppe.exec(); 498 } 510 499 } 511 500 … … 513 502 { 514 503 515 GWt_dialog* envDialog = new GWt_dialog("enveloppe",toto_,false); 516 envDialog->setMinimumSize(400,400); 517 envDialog->setClosable(true); 518 envDialog->show(); 519 520 521 522 // new WText(nameOfCase_ + " : enveloppe", toto); 523 unsigned nbel = dtmanage_->getBeamLineSize(); 524 525 526 vector<double> xcor; 527 vector<double> ycor; 528 529 530 dtmanage_->donneesRmsEnveloppe(type,1, nbel, xcor,ycor); 531 532 scatterPlot1D(envDialog->contents(),xcor,ycor); 533 504 GWt_dialog* envDialog = new GWt_dialog("enveloppe",toto,false); 505 envDialog->setMinimumSize(400,400); 506 envDialog->setClosable(true); 507 envDialog->show(); 508 509 // new WText(nameOfCase_ + " : enveloppe", toto); 510 unsigned nbel = dtmanage_->getBeamLineSize(); 511 vector<double> xcor; 512 vector<double> ycor; 513 dtmanage_->donneesRmsEnveloppe(type,1, nbel, xcor,ycor); 514 scatterPlot1D(envDialog->contents(),xcor,ycor); 534 515 } 535 516 … … 766 747 WText* PspaApplication::createTitle(const WString& title) 767 748 { 768 769 770 771 772 773 749 WText *result = new WText(title); 750 result->setInline(false); 751 result->setStyleClass("title"); 752 result->setMinimumSize(30,30); 753 754 return result; 774 755 } 775 756 … … 788 769 789 770 // } 790 791 771 792 772 bool PspaApplication::removeExtensionFromConfigName(string& config) … … 820 800 } 821 801 822 /////////////////////////823 // c'est un embryon d'histogramme824 825 802 void PspaApplication::dessinerHistogramme() 826 803 { 827 // pour mon test : histo en energie 828 toto_->clear(); 829 830 GWt_dialog* pourVoir= new GWt_dialog("histogramme",toto_,false); 831 pourVoir->setMinimumSize(400,400); 832 pourVoir->setClosable(true); 833 pourVoir->show(); 834 835 836 particleBeam* beam = dtmanage_->getDiagnosticBeam(1); 837 vector<double> xcor; 838 vector<int> hist; 839 int cnts; 840 beam->histogramme(xcor,hist,cnts); 841 842 cout<<"xcor.size()= "<<xcor.size()<<", hist.size()= "<<hist.size()<<endl; 843 844 ////////////////////////////////////////////////////////////////////////////////// 845 846 WContainerWidget *w = toto_; 847 int nbpts= xcor.size()+cnts+1; 848 WStandardItemModel *model = new WStandardItemModel(nbpts,2,w); 849 model->setHeaderData(1, WString("energie")); 850 851 int j= 0; 852 if(hist[0] > 0) { 853 model->setData(j,0,xcor[0]); 854 model->setData(j,1,hist[0]); 855 j++; 856 } 804 // pour mon test : histo en energie 805 toto_->clear(); 806 807 GWt_dialog* pourVoir= new GWt_dialog("histogramme",toto_,false); 808 pourVoir->setMinimumSize(400,400); 809 pourVoir->setClosable(true); 810 pourVoir->show(); 811 812 int index = choixHistoDessin_->currentIndex(); 813 particleBeam* beam = dtmanage_->getDiagnosticBeam(index); 814 if (beam == NULL) { 815 GWt_dialog warningBeamState("histogram","the beam does not exist at the end of this element !", GWt_dialog::Error, false,true); 816 warningBeamState.exec(); 817 return; 818 } 819 820 if (!beam->particleRepresentationOk()) { 821 GWt_dialog warningBeamState("histogram", "the beam state does not allow providing a drawing with macroparticles !", GWt_dialog::Error, false,true); 822 warningBeamState.exec(); 823 return; 824 } 825 826 vector<double> xcor; 827 vector<int> hist; 828 int cnts; 829 double out[3]= {0.0}; 830 beam->histogramme(xcor,hist,cnts,out); 831 832 cout<<"xcor.size()= "<<xcor.size()<<", hist.size()= "<<hist.size()<<endl; 833 ////////////////////////////////////////////////////////////////////////////////// 834 835 WContainerWidget *w = toto_; 836 int nbpts= xcor.size()+cnts+1; 837 WStandardItemModel *model = new WStandardItemModel(nbpts,2,w); 838 model->setHeaderData(1, WString("energie")); 839 840 int j= 0; 841 if(hist[0] > 0) { 857 842 model->setData(j,0,xcor[0]); 858 843 model->setData(j,1,hist[0]); 859 844 j++; 860 for (int i = 1; i < nbpts; ++i) { 861 if(hist[i] == 0) { 862 if(hist[i-1] > 0) { 863 model->setData(j,0,xcor[i]); 864 model->setData(j,1,hist[i-1]); 865 j++; 866 } 867 model->setData(j,0,xcor[i]); 868 model->setData(j,1,hist[i]); 869 j++; 870 } 871 if(hist[i] > 0) { 872 model->setData(j,0,xcor[i]); 873 model->setData(j,1,hist[i-1]); 874 j++; 875 model->setData(j,0,xcor[i]); 876 model->setData(j,1,hist[i]); 877 j++; 878 } 879 } 880 881 WCartesianChart *chart = new WCartesianChart(w); 882 chart->setTitle("Histogramme"); 883 chart->setModel(model); // set the model 884 chart->setXSeriesColumn(0); // set the column that holds the categories 885 chart->setLegendEnabled(true); // enable the legend 886 887 // Provide space for the X and Y axis and title. 888 chart->setPlotAreaPadding(200, Right); 889 chart->setPlotAreaPadding(80, Left); 890 chart->setPlotAreaPadding(40, Top | Bottom); 891 892 chart->setType(ScatterPlot); 893 894 WAxis& axis = chart->axis(XAxis); 895 axis.setLabelFormat("%.3f"); 896 axis.setGridLinesEnabled(true); 897 chart->axis(Y1Axis).setGridLinesEnabled(true); 898 899 WDataSeries s(1, LineSeries); 900 chart->addSeries(s); 901 902 903 chart->resize(800, 400); 904 905 chart->setMargin(10, Top | Bottom); 906 chart->setMargin(WLength::Auto, Left | Right); 907 908 LegendLocation location = LegendOutside; 909 Side side = Right; 910 AlignmentFlag alignment = AlignMiddle; 911 chart->setLegendLocation(location, side, alignment); 912 chart->setLegendStyle(chart->legendFont(), WPen(black), WBrush(WColor(0xFF, 0xFA, 0xE5))); 913 } 845 } 846 model->setData(j,0,xcor[0]); 847 model->setData(j,1,hist[0]); 848 j++; 849 for (int i = 1; i < nbpts; ++i) { 850 if(hist[i] == 0) { 851 if(hist[i-1] > 0) { 852 model->setData(j,0,xcor[i]); 853 model->setData(j,1,hist[i-1]); 854 j++; 855 } 856 model->setData(j,0,xcor[i]); 857 model->setData(j,1,hist[i]); 858 j++; 859 } 860 if(hist[i] > 0) { 861 model->setData(j,0,xcor[i]); 862 model->setData(j,1,hist[i-1]); 863 j++; 864 model->setData(j,0,xcor[i]); 865 model->setData(j,1,hist[i]); 866 j++; 867 } 868 } 869 870 // legendes 871 new WText(" entries : "+ mixedTools::intToString((int)out[0]),w); 872 new WBreak(w); 873 new WText(" mean : "+ mixedTools::doubleToString(out[1])+" MeV",w); 874 new WBreak(w); 875 new WText(" rms : "+ mixedTools::doubleToString(out[2])+" KeV",w); 876 877 WCartesianChart *chart = new WCartesianChart(w); 878 chart->setTitle("Histogram of particle energies"); 879 chart->setModel(model); // set the model 880 chart->setXSeriesColumn(0); // set the column that holds the categories 881 chart->setLegendEnabled(false); // enable the legend 882 883 // Provide space for the X and Y axis and title. 884 chart->setPlotAreaPadding(200, Right); 885 chart->setPlotAreaPadding(80, Left); 886 chart->setPlotAreaPadding(40, Top | Bottom); 887 888 chart->setType(ScatterPlot); 889 890 WAxis& axis = chart->axis(XAxis); 891 axis.setLabelFormat("%.3f"); 892 axis.setGridLinesEnabled(true); 893 axis.setTitle(WString("legende x")); 894 895 chart->axis(Y1Axis).setGridLinesEnabled(true); 896 chart->axis(Y1Axis).setTitle(WString("legende y")); 897 898 WDataSeries s(1, LineSeries); 899 s.setFillRange(ZeroValueFill); 900 chart->addSeries(s); 901 902 chart->resize(800, 400); 903 chart->setMargin(10, Top | Bottom); 904 chart->setMargin(WLength::Auto, Left | Right); 905 906 LegendLocation location = LegendOutside; 907 Side side = Right; 908 AlignmentFlag alignment = AlignMiddle; 909 chart->setLegendLocation(location, side, alignment); 910 chart->setLegendStyle(chart->legendFont(), WPen(black), WBrush(WColor(0xFF, 0xFA, 0xE5))); 911 }
Note: See TracChangeset
for help on using the changeset viewer.