Changeset 324 in PSPA


Ignore:
Timestamp:
Feb 18, 2013, 1:52:42 PM (11 years ago)
Author:
touze
Message:

menu analyse graphique + histo

Location:
Interface_Web/trunk/pspaWT
Files:
5 edited

Legend:

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

    r316 r324  
    44include_path none
    55 
    6 use Platform v1r* $(PSPAWTROOT)/../Interfaces
    7 use dld      v2r* $(PSPAWTROOT)/../Interfaces
     6use Platform v1r* Interfaces
     7use dld      v2r* Interfaces
    88
    9 use Wt       v1r* $(PSPAWTROOT)/../Interfaces
    10 use boost    v1r* $(PSPAWTROOT)/../Interfaces
     9use Wt       v1r* Interfaces
     10use boost    v1r* Interfaces
    1111
    1212include_dirs $(PSPAWTROOT)/sources/userInterface/include  $(PSPAWTROOT)/sources/controler/include
     
    5555
    5656#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  -DPSPA_DEBUG"
     57macro lib_PSPSLib_cppflags " ${Wt_cflags} ${boost_cflags} -DTHREADED -DDRAWWT_BUILD -DPSPA_DEBUG"
    5858
    5959macro PSPSLib_shlibflags   " ${Wt_linkopts} ${boost_linkopts} ${dld_linkopts}"
  • Interface_Web/trunk/pspaWT/sources/controler/include/particleBeam.h

    r314 r324  
    8888  virtual bool FileInput(ifstream& ifs);
    8989
    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]);
    9191};
    9292
  • Interface_Web/trunk/pspaWT/sources/controler/src/particleBeam.cc

    r314 r324  
    428428}
    429429
    430 void particleBeam::histogramme(vector<double>&xcor,vector<int>& hist,int& cnts)
     430void particleBeam::histogramme(vector<double>&xcor,vector<int>& hist,int& cnts,double out[3])
    431431{
     432  // sortie pour la legende: out[0]= entries, out[1]= mean, out[2]= rms
     433
    432434  double gammin= GRAND;
    433435  double gammax= -gammin;
     
    446448
    447449  double sum= (float)goodPartic_.size();
     450  out[0]= sum;
    448451  Emoy /= sum;
     452  out[1]= Emoy; //MeV
    449453  ecatyp /= sum;
     454  out[2]= 1000.0*sqrt(ecatyp); //KeV
    450455  ecatyp = sqrt(abs(ecatyp-Emoy*Emoy));
    451456
     
    487492  for (int i = 0; i < ihist; ++i) {
    488493
    489     // on gradue l'abcisse en pourcents
     494    // on gradue l'abscisse en pourcents
    490495    xcor[i]= 100.*( vmin+i*hpas );
    491496  }
     
    497502    int k= var/hpas;
    498503    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;
    500505    hist[kk]++;
    501506  }
     
    504509  for (int i = 0; i < ihist; ++i) {
    505510    if(hist.at(i) > 0) cnts++;
    506     cout<<"("<<xcor.at(i)<<","<<hist.at(i)<<") ";
     511    //cout<<"("<<xcor.at(i)<<","<<hist.at(i)<<") ";
    507512  }
    508513  cout<< " ... cnts=  " << cnts << endl;
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_pspaApplication.h

    r305 r324  
    1616#include <Wt/Chart/WCartesianChart>
    1717#include <Wt/WLength>
     18#include <Wt/WButtonGroup>
    1819
    1920#include "GWt_dialog.h"
     
    2627using namespace Wt;
    2728
    28 /*
    29  * ESSAI PSPA
    30  */
    3129class PspaApplication : public WApplication
    3230{
    3331       
    34     private :
     32 private :
    3533   
    36     dataManager* dtmanage_;
    37     string nameOfCase_;
    38     string workingDir_;
    39     WDialog* dialogSave_;
    40     WDialog* dialogOpen_;
    41     WLineEdit* saveNameEdit_;
    42     WLineEdit* openNameEdit_;
    43     GWt_LigneFaisceau* beamLine_;
     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_;
    4442   
     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);
    4583   
    46     // WContainerWidget* console_;
    47     WWidget* globalParam_;
    48     // WContainerWidget* leDessin_;
    49     GWt_dialog* graphicsDialog_;
     84  bool removeExtensionFromConfigName(string& config);
    5085   
    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();
    6090   
    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);
    11294
    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  }
    116117};
    117118#endif
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc

    r320 r324  
    3333#include <Wt/WScrollArea>
    3434#include <Wt/WLineEdit>
     35#include <Wt/WRadioButton>
    3536
    3637using namespace Wt::Chart;
     
    110111    boutongraphicalAnalysis->clicked().connect(this, &PspaApplication::dialogOnGraphics);
    111112   
    112    
    113113    toolbarLayout->addWidget(boutonSauve , 0,Wt::AlignMiddle);
    114114    toolbarLayout->addWidget(boutonRestaure , 0,Wt::AlignMiddle);
     
    145145    console_->setOverflow(WContainerWidget::OverflowAuto);
    146146    layout->addWidget(console_, 3, 2);
    147    
    148    
    149    
    150    
    151147   
    152148    //-----------
     
    159155    graphicsDialog_->setClosable(true);
    160156   
    161    
    162    
    163157    executeWidget_ = new GWt_softwarePanel(dtmanage_,this);
    164158   
     
    167161    layout->addWidget( executeWidget_ , 4, 1);
    168162    //-----------
    169    
    170    
    171    
     163     
    172164    layout->setColumnResizable(1);
    173165    layout->setRowResizable(2);
     
    183175WWidget* PspaApplication::createPalette()
    184176{
    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
     187void 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);
    213196}
    214197
    215198void PspaApplication::createBeamLine()
    216199{
    217     beamLine_ = new GWt_LigneFaisceau(this);
    218     beamLine_->setMinimumSize(300,100);
     200  beamLine_ = new GWt_LigneFaisceau(this);
     201  beamLine_->setMinimumSize(300,100);
    219202}
    220203
     
    230213void PspaApplication::dialogOnGraphics()
    231214{
    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();
    239216}
    240217
    241218WContainerWidget* PspaApplication::createDrawingWidget()
    242219{
    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
     269void PspaApplication::closeGraphicDialog()
     270{
     271  cout << " close graphicsDialog_" << endl;
     272  graphicsDialog_->done(WDialog::Rejected);
     273}
     274
     275void 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}
    296296
    297297void PspaApplication::sauver()
    298298{
    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();
     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();
    311311}
    312312
    313313void PspaApplication::dialogSaveDone(WDialog::DialogCode code)
    314314{
    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}
    329327
    330328void PspaApplication::restaurer()
     
    343341
    344342void 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}
    367367
    368368void PspaApplication::openFileSelector()
    369369{
    370370   
    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}
    398397
    399398void PspaApplication::chargerConfig()
     
    440439}
    441440
    442 
    443441void PspaApplication::faireDessin()
    444442{
    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
     453void 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 )
    450468    {
    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 )
    476473    {
    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
     486void PspaApplication::dessinerEnveloppe()
     487{
     488  toto_->clear();
     489 
     490  int typeEnveloppe = choixEnveloppeDessin_->currentIndex();
     491  if ( typeEnveloppe == 0 )
    481492    {
    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  }
    510499}
    511500
     
    513502{
    514503   
    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); 
    534515}
    535516
     
    766747WText* PspaApplication::createTitle(const WString& title)
    767748{
    768     WText *result = new WText(title);
    769     result->setInline(false);
    770     result->setStyleClass("title");
    771     result->setMinimumSize(30,30);
    772    
    773     return result;
     749  WText *result = new WText(title);
     750  result->setInline(false);
     751  result->setStyleClass("title");
     752  result->setMinimumSize(30,30);
     753 
     754  return result;
    774755}
    775756
     
    788769
    789770// }
    790 
    791771
    792772bool PspaApplication::removeExtensionFromConfigName(string& config)
     
    820800}
    821801
    822 /////////////////////////
    823 //   c'est un embryon d'histogramme
    824 
    825802void PspaApplication::dessinerHistogramme()
    826803{
    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) {
    857842    model->setData(j,0,xcor[0]);
    858843    model->setData(j,1,hist[0]);
    859844    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.