Index: /Interface_Web/trunk/pspaWT/cmt/requirements
===================================================================
--- /Interface_Web/trunk/pspaWT/cmt/requirements	(revision 323)
+++ /Interface_Web/trunk/pspaWT/cmt/requirements	(revision 324)
@@ -4,9 +4,9 @@
 include_path none
   
-use Platform v1r* $(PSPAWTROOT)/../Interfaces
-use dld      v2r* $(PSPAWTROOT)/../Interfaces
+use Platform v1r* Interfaces
+use dld      v2r* Interfaces
 
-use Wt       v1r* $(PSPAWTROOT)/../Interfaces
-use boost    v1r* $(PSPAWTROOT)/../Interfaces
+use Wt       v1r* Interfaces
+use boost    v1r* Interfaces
 
 include_dirs $(PSPAWTROOT)/sources/userInterface/include  $(PSPAWTROOT)/sources/controler/include
@@ -55,5 +55,5 @@
 
 #macro lib_PSPSLib_cppflags " ${Wt_cflags} ${boost_cflags} -DTHREADED -DDRAWWT_BUILD  -DHAS_IMAGEMAGIC -DPSPA_DEBUG"
-macro lib_PSPSLib_cppflags " ${Wt_cflags} ${boost_cflags} -DTHREADED -DDRAWWT_BUILD  -DPSPA_DEBUG"
+macro lib_PSPSLib_cppflags " ${Wt_cflags} ${boost_cflags} -DTHREADED -DDRAWWT_BUILD -DPSPA_DEBUG"
 
 macro PSPSLib_shlibflags   " ${Wt_linkopts} ${boost_linkopts} ${dld_linkopts}"
Index: /Interface_Web/trunk/pspaWT/sources/controler/include/particleBeam.h
===================================================================
--- /Interface_Web/trunk/pspaWT/sources/controler/include/particleBeam.h	(revision 323)
+++ /Interface_Web/trunk/pspaWT/sources/controler/include/particleBeam.h	(revision 324)
@@ -88,5 +88,5 @@
   virtual bool FileInput(ifstream& ifs);
 
-  void histogramme(vector<double>&xcor,vector<int>& hist,int& cnts);
+  void histogramme(vector<double>&xcor,vector<int>& hist,int& cnts,double out[3]);
 };
 
Index: /Interface_Web/trunk/pspaWT/sources/controler/src/particleBeam.cc
===================================================================
--- /Interface_Web/trunk/pspaWT/sources/controler/src/particleBeam.cc	(revision 323)
+++ /Interface_Web/trunk/pspaWT/sources/controler/src/particleBeam.cc	(revision 324)
@@ -428,6 +428,8 @@
 }
 
-void particleBeam::histogramme(vector<double>&xcor,vector<int>& hist,int& cnts)
+void particleBeam::histogramme(vector<double>&xcor,vector<int>& hist,int& cnts,double out[3])
 {
+  // sortie pour la legende: out[0]= entries, out[1]= mean, out[2]= rms
+
   double gammin= GRAND;
   double gammax= -gammin;
@@ -446,6 +448,9 @@
 
   double sum= (float)goodPartic_.size();
+  out[0]= sum;
   Emoy /= sum;
+  out[1]= Emoy; //MeV
   ecatyp /= sum;
+  out[2]= 1000.0*sqrt(ecatyp); //KeV
   ecatyp = sqrt(abs(ecatyp-Emoy*Emoy));
 
@@ -487,5 +492,5 @@
   for (int i = 0; i < ihist; ++i) {
 
-    // on gradue l'abcisse en pourcents
+    // on gradue l'abscisse en pourcents
     xcor[i]= 100.*( vmin+i*hpas );
   }
@@ -497,5 +502,5 @@
     int k= var/hpas;
     int kk= (int)floor(var/hpas);
-    if(i%20 == 0) cout<<"v("<<i<<")= " <<var<<" ["<<k<<"-"<<kk<<"], "<<endl; 
+    //if(i%20 == 0) cout<<"v("<<i<<")= " <<var<<" ["<<k<<"-"<<kk<<"], "<<endl; 
     hist[kk]++;
   }
@@ -504,5 +509,5 @@
   for (int i = 0; i < ihist; ++i) {
     if(hist.at(i) > 0) cnts++;
-    cout<<"("<<xcor.at(i)<<","<<hist.at(i)<<") ";
+    //cout<<"("<<xcor.at(i)<<","<<hist.at(i)<<") ";
   }
   cout<< " ... cnts=  " << cnts << endl;
Index: /Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_pspaApplication.h
===================================================================
--- /Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_pspaApplication.h	(revision 323)
+++ /Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_pspaApplication.h	(revision 324)
@@ -16,4 +16,5 @@
 #include <Wt/Chart/WCartesianChart>
 #include <Wt/WLength>
+#include <Wt/WButtonGroup>
 
 #include "GWt_dialog.h"
@@ -26,92 +27,92 @@
 using namespace Wt;
 
-/*
- * ESSAI PSPA
- */
 class PspaApplication : public WApplication
 {
         
-    private :
+ private :
     
-    dataManager* dtmanage_;
-    string nameOfCase_;
-    string workingDir_;
-    WDialog* dialogSave_;
-    WDialog* dialogOpen_;
-    WLineEdit* saveNameEdit_;
-    WLineEdit* openNameEdit_;
-    GWt_LigneFaisceau* beamLine_;
+  dataManager* dtmanage_;
+  string nameOfCase_;
+  string workingDir_;
+  WDialog* dialogSave_;
+  WDialog* dialogOpen_;
+  WLineEdit* saveNameEdit_;
+  WLineEdit* openNameEdit_;
+  GWt_LigneFaisceau* beamLine_;
     
+  // WContainerWidget* console_;
+  WWidget* globalParam_;
+  // WContainerWidget* leDessin_;
+  GWt_dialog* graphicsDialog_;
+  WButtonGroup *group_;
+
+  WText* probleme_;
+  WComboBox* choixElementDessin_;
+  WComboBox* choixTypeDessinFaisceau_;
+  WComboBox* choixEnveloppeDessin_;
+  WComboBox* choixHistoDessin_;
+
+  WContainerWidget* toto_;
+  GWt_softwarePanel* executeWidget_;
+  WFileUpload* uploadFileSelectorWidget_;
+  GWt_console* console_;
+  GWt_abstractElementFactory* abstractElementFactory_;
+      
+  WText* createTitle(const WString&);
+  WWidget* createPalette();
+  void createBeamLine();
+  WWidget* createGlobalParamWidget();
+  WWidget* createExecuteWidget();
+  WContainerWidget* createDrawingWidget();
+  void closeGraphicDialog();
+  
+  void createDragImage(const char *url,const char *smallurl,const char *mimeType,WContainerWidget *p,WString());
+  void sauver();
+  void dialogSaveDone(WDialog::DialogCode code);
+  void dialogOpenDone(WDialog::DialogCode code);
+  void restaurer();
+  void chargerConfig();
+  void openFileSelector();
+  void fileTooLarge();
+  
+  void dialogOnGraphics();
+  void faireDessinParmela(WContainerWidget* toto, particleBeam* beam);
+  void faireDessinTransport(WContainerWidget* toto, particleBeam* beam);
+  void faireDessinEnveloppe(WContainerWidget* toto, string type);
+  void scatterPlot1D(WContainerWidget* toto, vector<double>& xcor, vector<double>& ycor);
     
-    // WContainerWidget* console_;
-    WWidget* globalParam_;
-    // WContainerWidget* leDessin_;
-    GWt_dialog* graphicsDialog_;
+  bool removeExtensionFromConfigName(string& config);
     
-    WText* probleme_;
-    WComboBox* choixElementDessin_;
-    WComboBox* choixTypeDessinFaisceau_;
-    WComboBox* choixEnveloppeDessin_;
-    WContainerWidget* toto_;
-    GWt_softwarePanel* executeWidget_;
-    WFileUpload* uploadFileSelectorWidget_;
-    GWt_console* console_;
-    GWt_abstractElementFactory* abstractElementFactory_;
+  void dessiner();
+  void dessinerEnveloppe();
+  void dessinerPhaseSpace();
+  void dessinerHistogramme();
     
-    
-    WText*   createTitle(const WString&);
-    WWidget* createPalette();
-    void createBeamLine();
-    WWidget* createGlobalParamWidget();
-    WWidget* createExecuteWidget();
-    WContainerWidget* createDrawingWidget();
-    
-    void createDragImage(const char *url,const char *smallurl,const char *mimeType,WContainerWidget *p,WString name);
-    void sauver();
-    void dialogSaveDone(WDialog::DialogCode code);
-    void dialogOpenDone(WDialog::DialogCode code);
-    void restaurer();
-    void chargerConfig();
-    void openFileSelector();
-    void fileTooLarge();
-    void dessiner();
-    
-    void dialogOnGraphics();
-    void faireDessinParmela(WContainerWidget* toto, particleBeam* beam);
-    void faireDessinTransport(WContainerWidget* toto, particleBeam* beam);
-    
-    void dessinerEnveloppe();
-    void faireDessinEnveloppe(WContainerWidget* toto, string type);
-    void scatterPlot1D(WContainerWidget* toto, vector<double>& xcor, vector<double>& ycor);
-    
-    bool removeExtensionFromConfigName(string& config);
-    
-    void dessinerHistogramme();
-    
-    public :
-    
-    PspaApplication(const WEnvironment& env);
-    
-    inline dataManager* getDataManager() const  {
-        return dtmanage_;
-    }
-    
-    // void addConsoleMessage(WString msg);
-    
-    string getSelection();
-    void faireDessin();
-    inline WWidget* getGlobalParam() {
-        return globalParam_;
-    };
-    inline GWt_softwarePanel* getExecuteWidget() {
-        return executeWidget_;
-    };
-    inline GWt_LigneFaisceau* getBeamLine() {
-        return beamLine_;
-    }
+ public :
+  
+  PspaApplication(const WEnvironment& env);
 
-    inline GWt_abstractElementFactory* getAbstractElementFactory() {
-        return abstractElementFactory_;
-    };
+  string getSelection();
+  void faireDessin();
+
+  inline dataManager* getDataManager() const  {
+    return dtmanage_;
+  }
+  
+  inline WWidget* getGlobalParam() {
+    return globalParam_;
+  }
+
+  inline GWt_softwarePanel* getExecuteWidget() {
+    return executeWidget_;
+  }
+
+  inline GWt_LigneFaisceau* getBeamLine() {
+    return beamLine_;
+  }
+
+  inline GWt_abstractElementFactory* getAbstractElementFactory() {
+    return abstractElementFactory_;
+  }
 };
 #endif
Index: /Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc
===================================================================
--- /Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc	(revision 323)
+++ /Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc	(revision 324)
@@ -33,4 +33,5 @@
 #include <Wt/WScrollArea>
 #include <Wt/WLineEdit>
+#include <Wt/WRadioButton>
 
 using namespace Wt::Chart;
@@ -110,5 +111,4 @@
     boutongraphicalAnalysis->clicked().connect(this, &PspaApplication::dialogOnGraphics);
     
-    
     toolbarLayout->addWidget(boutonSauve , 0,Wt::AlignMiddle);
     toolbarLayout->addWidget(boutonRestaure , 0,Wt::AlignMiddle);
@@ -145,8 +145,4 @@
     console_->setOverflow(WContainerWidget::OverflowAuto);
     layout->addWidget(console_, 3, 2);
-    
-    
-    
-    
     
     //-----------
@@ -159,6 +155,4 @@
     graphicsDialog_->setClosable(true);
     
-    
-    
     executeWidget_ = new GWt_softwarePanel(dtmanage_,this);
     
@@ -167,7 +161,5 @@
     layout->addWidget( executeWidget_ , 4, 1);
     //-----------
-    
-    
-    
+     
     layout->setColumnResizable(1);
     layout->setRowResizable(2);
@@ -183,38 +175,29 @@
 WWidget* PspaApplication::createPalette()
 {
-    WContainerWidget* palette=new WContainerWidget();
-    //  palette->setLayout(new WVBoxLayout());
-    
-    // nomdElements *e= new nomdElements();
-    // int nElts= e->getNumberOfElements();
-    // delete e;
-    //  nomdElements bidon;
-    
-    vector <GWt_abstractElement*> elems = abstractElementFactory_->getAllElements();
-    for (int a = 0; a< elems.size(); a++) {
-        elems[a]->createDragImage(palette);
-        new WBreak(palette);
-    }
-    
-    //  palette->setMinimumSize(100,300);
-    return palette;
-    
-}
-
-void PspaApplication::createDragImage(const char *url,const char *smallurl,const char *mimeType,WContainerWidget *p,WString name)
-{
-    GWt_draggableImage *result = new GWt_draggableImage(url,p);
-    
-    /*
-     * Set the image to be draggable, showing the other image (dragImage)
-     * to be used as the widget that is visually dragged.
-     */
-    result->setDraggable(mimeType,new WImage(smallurl,p),true);
+  WContainerWidget* palette = new WContainerWidget();
+  vector <GWt_abstractElement*> elems = abstractElementFactory_->getAllElements();
+  for (unsigned a = 0; a < elems.size(); a++) {
+    elems[a]->createDragImage(palette);
+    new WBreak(palette);
+  }
+
+  return palette;  
+}
+
+void PspaApplication::createDragImage(const char *url,const char *smallurl,const char *mimeType,WContainerWidget *p,WString())
+{
+  GWt_draggableImage *result = new GWt_draggableImage(url,p);
+  
+  /*
+   * Set the image to be draggable, showing the other image (dragImage)
+   * to be used as the widget that is visually dragged.
+   */
+  result->setDraggable(mimeType,new WImage(smallurl,p),true);
 }
 
 void PspaApplication::createBeamLine()
 {
-    beamLine_ = new GWt_LigneFaisceau(this);
-    beamLine_->setMinimumSize(300,100);
+  beamLine_ = new GWt_LigneFaisceau(this);
+  beamLine_->setMinimumSize(300,100);
 }
 
@@ -230,101 +213,116 @@
 void PspaApplication::dialogOnGraphics()
 {
-    // GWt_dialog* graphicsDialog = new GWt_dialog("graphical analysis",createDrawingWidget(),false);
-    // graphicsDialog->setMinimumSize(400,400);
-    // graphicsDialog->setClosable(true);
-    
-    
-    graphicsDialog_->show();
-    
+  graphicsDialog_->show();
 }
 
 WContainerWidget* PspaApplication::createDrawingWidget()
 {
-    WContainerWidget* dessin = new WContainerWidget();
-    
-    
-    
-    
-    choixEnveloppeDessin_ = new WComboBox();
-    choixEnveloppeDessin_->addItem("x");
-    //  choixEnveloppeDessin_->addItem("y");
-    WPushButton* okEnv = new WPushButton("draw enveloppe");
-    okEnv->clicked().connect(this, &PspaApplication::dessinerEnveloppe);
-    
-    
-    dessin->addWidget(new WText(" enveloppe :  "));
-    dessin->addWidget(choixEnveloppeDessin_);
-    dessin->addWidget(okEnv);
-    
-    dessin->addWidget(new WBreak());
-    
-    choixElementDessin_ = new WComboBox();
-    
-    
-    
-    choixTypeDessinFaisceau_ = new WComboBox();
-    choixTypeDessinFaisceau_->addItem("courant_snyder");
-    choixTypeDessinFaisceau_->addItem("macroparticles");
-    WPushButton* caroule = new WPushButton("dessiner");
-    caroule->clicked().connect(this, &PspaApplication::dessiner);
-    
-    dessin->addWidget(new WText(" phase space after element :  "));
-    dessin->addWidget(choixElementDessin_);
-    dessin->addWidget(choixTypeDessinFaisceau_);
-    dessin->addWidget(caroule);
-    dessin->addWidget(new WBreak());
-
-
-    
-    
-    
-    /////////////////////////////////////////////////////////////////////
-    dessin->addWidget(new WText(" histogramme :  "));
-    WPushButton* okHisto = new WPushButton("histogramme");
-    dessin->addWidget(okHisto);
-
-    okHisto->clicked().connect(this,&PspaApplication::dessinerHistogramme);
-    /////////////////////////////////////////////////////////////////////
-    
-    toto_ = new WContainerWidget();
-    dessin->addWidget(toto_);
-    return dessin;
-}
-
-
-
+  WGridLayout *glayout= new WGridLayout();
+  WContainerWidget* dessin = new WContainerWidget();
+  dessin->setLayout(glayout);
+
+  group_ = new Wt::WButtonGroup(this);
+  
+  /////////////////////////////////////////////////////////////////////
+       
+  choixEnveloppeDessin_ = new WComboBox();
+  choixEnveloppeDessin_->addItem("x");
+  // choixEnveloppeDessin_->addItem("y");
+  Wt::WRadioButton *button1= new WRadioButton(" enveloppe");
+  group_->addButton(button1,1);
+  glayout->addWidget(button1,0,1);
+  glayout->addWidget(choixEnveloppeDessin_,0,2);
+  /////////////////////////////////////////////////////////////////////
+
+  choixElementDessin_ = new WComboBox();
+  choixTypeDessinFaisceau_ = new WComboBox();
+  choixTypeDessinFaisceau_->addItem("courant_snyder");
+  choixTypeDessinFaisceau_->addItem("macroparticles");
+  Wt::WRadioButton *button2= new WRadioButton(" phase space after element");
+  group_->addButton(button2,2);
+  glayout->addWidget(button2,1,1);
+  glayout->addWidget(choixElementDessin_,1,2);
+  glayout->addWidget(choixTypeDessinFaisceau_,1,3);
+  /////////////////////////////////////////////////////////////////////
+
+  choixHistoDessin_ = new WComboBox();
+  Wt::WRadioButton *button3= new WRadioButton(" histogram after element");
+  group_->addButton(button3,3);
+  glayout->addWidget(button3,2,1);
+  glayout->addWidget(choixHistoDessin_,2,2);
+  /////////////////////////////////////////////////////////////////////
+  
+  WPushButton *close= new WPushButton("close"); 
+  glayout->addWidget(close,3,1);
+  close->clicked().connect(this,&PspaApplication::closeGraphicDialog);
+  
+  WPushButton *draw= new WPushButton("draw"); 
+  glayout->addWidget(draw,3,2,2,1);
+  draw->clicked().connect(this,&PspaApplication::dessiner);
+  /////////////////////////////////////////////////////////////////////
+
+  toto_ = new WContainerWidget();
+  dessin->addWidget(toto_);
+  return dessin;
+}
+
+void PspaApplication::closeGraphicDialog()
+{
+  cout << " close graphicsDialog_" << endl;
+  graphicsDialog_->done(WDialog::Rejected);
+}
+
+void PspaApplication::dessiner()
+{
+  int k= group_->checkedId();
+  cout << "dessiner k= " << k << endl;
+
+  switch(k) {
+  case  1: 
+    dessinerEnveloppe();
+    break;
+  case 2:
+    dessinerPhaseSpace();
+    break;
+  case 3:
+    dessinerHistogramme();
+    break;
+  default:
+    GWt_dialog graphicalWarning("graphical analysis","select a button",GWt_dialog::Warning,false,true);
+    graphicalWarning.exec();
+    break;
+  }
+}
 
 void PspaApplication::sauver()
 {
-    cout << " on sauve " << endl;
-    console_->addConsoleMessage("sauvegarde");
-    
-    dialogSave_ = new WDialog("save");
-    new WText("name of case : ",dialogSave_->contents());
-    saveNameEdit_ = new WLineEdit(nameOfCase_.c_str(), dialogSave_->contents());
-    WPushButton *annule = new WPushButton("cancel",dialogSave_->contents());
-    WPushButton *submit = new WPushButton("OK",dialogSave_->contents());
-    annule->clicked().connect(dialogSave_, &Wt::WDialog::reject);
-    submit->clicked().connect(dialogSave_, &Wt::WDialog::accept);
-    dialogSave_->finished().connect(this, &PspaApplication::dialogSaveDone);
-    dialogSave_->show();
+  cout << " on sauve " << endl;
+  console_->addConsoleMessage("sauvegarde");
+  
+  dialogSave_ = new WDialog("save");
+  new WText("name of case : ",dialogSave_->contents());
+  saveNameEdit_ = new WLineEdit(nameOfCase_.c_str(), dialogSave_->contents());
+  WPushButton *annule = new WPushButton("cancel",dialogSave_->contents());
+  WPushButton *submit = new WPushButton("OK",dialogSave_->contents());
+  annule->clicked().connect(dialogSave_, &Wt::WDialog::reject);
+  submit->clicked().connect(dialogSave_, &Wt::WDialog::accept);
+  dialogSave_->finished().connect(this, &PspaApplication::dialogSaveDone);
+  dialogSave_->show();
 }
 
 void PspaApplication::dialogSaveDone(WDialog::DialogCode code)
 {
-    
-    if ( code != Wt::WDialog::Accepted ) { console_->addConsoleMessage(" pas de sauvegarde"); return;}
-    else { console_->addConsoleMessage("sauvegarde sur repertoire : " + workingDir_);}
-    nameOfCase_ = saveNameEdit_->text().toUTF8();
-    cout << " PspaApplication::dialogSaveDone() nameOfCase_= " << nameOfCase_ << endl;
-    delete dialogSave_;
-    dialogSave_ = NULL;
-    GWt_globalParameters* bibi = static_cast<GWt_globalParameters*>(globalParam_);
-    bibi->updateGlobals();
-    //  dtmanage_->saveConfiguration(nameOfCase_);
-    dtmanage_->saveConfiguration( nameOfCase_);
-}
-
-
+  
+  if ( code != Wt::WDialog::Accepted ) { console_->addConsoleMessage(" pas de sauvegarde"); return;}
+  else { console_->addConsoleMessage("sauvegarde sur repertoire : " + workingDir_);}
+  nameOfCase_ = saveNameEdit_->text().toUTF8();
+  cout << " PspaApplication::dialogSaveDone() nameOfCase_= " << nameOfCase_ << endl;
+  delete dialogSave_;
+  dialogSave_ = NULL;
+  GWt_globalParameters* bibi = static_cast<GWt_globalParameters*>(globalParam_);
+  bibi->updateGlobals();
+  //  dtmanage_->saveConfiguration(nameOfCase_);
+  dtmanage_->saveConfiguration( nameOfCase_);
+}
 
 void PspaApplication::restaurer()
@@ -343,57 +341,58 @@
 
 void PspaApplication::dialogOpenDone(WDialog::DialogCode code)
-{
-    
-    if ( code != Wt::WDialog::Accepted ) { console_->addConsoleMessage(" pas de restauration"); return;}
-    else { console_->addConsoleMessage("restauration depuis le repertoire " + workingDir_ );}
-    
-    nameOfCase_ = openNameEdit_->text().toUTF8();
-    cout << " PspaApplication::dialogOpenDone() nameOfCase_= " << nameOfCase_ << endl;
-    delete dialogOpen_;
-    dialogSave_ = NULL;
-    
-    bool test = dtmanage_->restoreElements(nameOfCase_);
-    if ( !test ) {
-        GWt_dialog restoreWarning(" element restoring", "failure in restoring elements !", GWt_dialog::Error, false,true);
-        restoreWarning.exec();
-    }
-    
-    GWt_globalParameters* bibi = static_cast<GWt_globalParameters*>(globalParam_);
-    bibi->renew();
-        
-    console_->addConsoleMessage(string("...terminee"));
-}
-
+{   
+  if (code != Wt::WDialog::Accepted) { 
+    console_->addConsoleMessage(" pas de restauration"); 
+    return;
+  } else { 
+    console_->addConsoleMessage("restauration depuis le repertoire " + workingDir_ );
+  }
+    
+  nameOfCase_ = openNameEdit_->text().toUTF8();
+  cout << " PspaApplication::dialogOpenDone() nameOfCase_= " << nameOfCase_ << endl;
+  delete dialogOpen_;
+  dialogSave_ = NULL;
+  
+  bool test = dtmanage_->restoreElements(nameOfCase_);
+  if ( !test ) {
+    GWt_dialog restoreWarning(" element restoring", "failure in restoring elements !", GWt_dialog::Error, false,true);
+    restoreWarning.exec();
+  }
+  
+  GWt_globalParameters* bibi = static_cast<GWt_globalParameters*>(globalParam_);
+  bibi->renew();
+  
+  console_->addConsoleMessage(string("...terminee"));
+}
 
 void PspaApplication::openFileSelector()
 {
     
-    WContainerWidget *result = new WContainerWidget();
-    WVBoxLayout* myLayout = new WVBoxLayout();
-    
-    uploadFileSelectorWidget_ = new WFileUpload();
-    
-    uploadFileSelectorWidget_->setFileTextSize(40);
-    
-    myLayout->addWidget(new WText("Select the configuration file for pspa : "));
-    myLayout->addWidget(uploadFileSelectorWidget_);
-    
-    result->setLayout (myLayout);
-    
-    // Upload automatically when the user entered a file.
-    uploadFileSelectorWidget_->changed().connect(uploadFileSelectorWidget_, &WFileUpload::upload);
-    
-    // React to a succesfull upload.
-    uploadFileSelectorWidget_->uploaded().connect(this, &PspaApplication::chargerConfig);
-    
-    // React to a fileupload problem.
-    uploadFileSelectorWidget_->fileTooLarge().connect(this, &PspaApplication::fileTooLarge);
-    
-    
-    GWt_dialog* fileSelectorDialog = new GWt_dialog("Load a file",result,false);
-    
-    fileSelectorDialog->exec();
-}
-
+  WContainerWidget *result = new WContainerWidget();
+  WVBoxLayout* myLayout = new WVBoxLayout();
+    
+  uploadFileSelectorWidget_ = new WFileUpload();
+    
+  uploadFileSelectorWidget_->setFileTextSize(40);
+    
+  myLayout->addWidget(new WText("Select the configuration file for pspa : "));
+  myLayout->addWidget(uploadFileSelectorWidget_);
+    
+  result->setLayout (myLayout);
+    
+  // Upload automatically when the user entered a file.
+  uploadFileSelectorWidget_->changed().connect(uploadFileSelectorWidget_, &WFileUpload::upload);
+  
+  // React to a succesfull upload.
+  uploadFileSelectorWidget_->uploaded().connect(this, &PspaApplication::chargerConfig);
+  
+  // React to a fileupload problem.
+  uploadFileSelectorWidget_->fileTooLarge().connect(this, &PspaApplication::fileTooLarge);
+  
+  
+  GWt_dialog* fileSelectorDialog = new GWt_dialog("Load a file",result,false);
+  
+  fileSelectorDialog->exec();
+}
 
 void PspaApplication::chargerConfig()
@@ -440,72 +439,62 @@
 }
 
-
 void PspaApplication::faireDessin()
 {
-    choixElementDessin_->clear();
-    int nombre = dtmanage_->getBeamLineSize();
-    cout << " PspaApplication::faireDessin() nb elements : " << nombre << endl;
-
-    for ( int numero =1; numero <= nombre; numero++)
+  choixElementDessin_->clear();
+  choixHistoDessin_->clear();
+  int nombre = dtmanage_->getBeamLineSize();
+  cout << " PspaApplication::faireDessin() nb elements : " << nombre << endl;
+  for(int i = 1; i <= nombre; i++) {
+    choixElementDessin_->addItem(dtmanage_->getLabelFromElementNumero(i));
+    choixHistoDessin_->addItem(dtmanage_->getLabelFromElementNumero(i));
+  } 
+}
+
+void PspaApplication::dessinerPhaseSpace()
+{    
+  toto_->clear();
+    
+  int typeFaisceau = choixTypeDessinFaisceau_->currentIndex();  
+  int index = choixElementDessin_->currentIndex();
+  particleBeam* beam = dtmanage_->getDiagnosticBeam(index);
+    
+  if ( beam == NULL ) {
+    GWt_dialog warningBeamState(" graphical analysis", "the beam does not exist at the end of this element !", GWt_dialog::Error, false,true);
+    warningBeamState.exec();
+    return;
+  }
+      
+  if ( typeFaisceau == 0 )
     {
-        choixElementDessin_->addItem(dtmanage_->getLabelFromElementNumero(numero));
-    }
-    
-}
-
-void PspaApplication::dessiner()
-{
-    
-    toto_->clear();
-    
-    int typeFaisceau = choixTypeDessinFaisceau_->currentIndex();
-    
-    int index = choixElementDessin_->currentIndex();
-    
-    
-    particleBeam* beam = dtmanage_->getDiagnosticBeam(index);
-    
-    if ( beam == NULL ) {
-        GWt_dialog warningBeamState(" graphical analysis", "the beam does not exist at the end of this element !", GWt_dialog::Error, false,true);
-        warningBeamState.exec();
-        return;
-    }
-    
-    
-    if ( typeFaisceau == 0 )
+      if ( !beam->momentRepresentationOk() ) beam->buildMomentRepresentation();
+      faireDessinTransport(toto_, beam);
+    }
+  else if ( typeFaisceau == 1 )
     {
-        if ( !beam->momentRepresentationOk() ) beam->buildMomentRepresentation();
-        faireDessinTransport(toto_, beam);
-    }
-    else if ( typeFaisceau == 1 )
+      if ( beam->particleRepresentationOk() ) faireDessinParmela(toto_, beam);
+      else {
+	GWt_dialog warningBeamState(" graphical analysis", "the beam state does not allow providing a drawing with macroparticles !", GWt_dialog::Error, false,true);
+	warningBeamState.exec();
+      }
+    }
+  else {
+    GWt_dialog warningTypeDrawing(" graphical analysis", "type of  drawing not programmed !", GWt_dialog::Error, false,true);
+    warningTypeDrawing.exec();
+  }
+}
+
+void PspaApplication::dessinerEnveloppe()
+{
+  toto_->clear();
+  
+  int typeEnveloppe = choixEnveloppeDessin_->currentIndex();
+  if ( typeEnveloppe == 0 )
     {
-        if ( beam->particleRepresentationOk() ) faireDessinParmela(toto_, beam);
-        else {
-            GWt_dialog warningBeamState(" graphical analysis", "the beam state does not allow providing a drawing with macroparticles !", GWt_dialog::Error, false,true);
-            warningBeamState.exec();
-        }
-    }
-    else {
-        GWt_dialog warningTypeDrawing(" graphical analysis", "type of  drawing not programmed !", GWt_dialog::Error, false,true);
-        warningTypeDrawing.exec();
-    }
-    //////////////////////////////////////////
-}
-
-void PspaApplication::dessinerEnveloppe()
-{
-    
-    toto_->clear();
-    
-    int typeEnveloppe = choixEnveloppeDessin_->currentIndex();
-    if ( typeEnveloppe == 0 )
-    {
-        faireDessinEnveloppe(toto_, "x");
-    }
-    else {
-        GWt_dialog warningTypeEnveloppe(" graphical analysis", "type of enveloppe drawing not programmed !", GWt_dialog::Error, false,true);
-        warningTypeEnveloppe.exec();
-    }
-    //////////////////////////////////////////
+      faireDessinEnveloppe(toto_, "x");
+    }
+  else {
+    GWt_dialog warningTypeEnveloppe(" graphical analysis", "type of enveloppe drawing not programmed !", GWt_dialog::Error, false,true);
+    warningTypeEnveloppe.exec();
+  }
 }
 
@@ -513,23 +502,15 @@
 {
     
-    GWt_dialog* envDialog = new GWt_dialog("enveloppe",toto_,false);
-    envDialog->setMinimumSize(400,400);
-    envDialog->setClosable(true);
-    envDialog->show();
-    
-    
-    
-    //       new WText(nameOfCase_ + " : enveloppe", toto);
-    unsigned nbel = dtmanage_->getBeamLineSize();
-    
-    
-    vector<double> xcor;
-    vector<double> ycor;
-    
-    
-    dtmanage_->donneesRmsEnveloppe(type,1, nbel, xcor,ycor);
-    
-    scatterPlot1D(envDialog->contents(),xcor,ycor);
-    
+  GWt_dialog* envDialog = new GWt_dialog("enveloppe",toto,false);
+  envDialog->setMinimumSize(400,400);
+  envDialog->setClosable(true);
+  envDialog->show();
+      
+  //       new WText(nameOfCase_ + " : enveloppe", toto);
+  unsigned nbel = dtmanage_->getBeamLineSize();
+  vector<double> xcor;
+  vector<double> ycor;
+  dtmanage_->donneesRmsEnveloppe(type,1, nbel, xcor,ycor);
+  scatterPlot1D(envDialog->contents(),xcor,ycor);  
 }
 
@@ -766,10 +747,10 @@
 WText* PspaApplication::createTitle(const WString& title)
 {
-    WText *result = new WText(title);
-    result->setInline(false);
-    result->setStyleClass("title");
-    result->setMinimumSize(30,30);
-    
-    return result;
+  WText *result = new WText(title);
+  result->setInline(false);
+  result->setStyleClass("title");
+  result->setMinimumSize(30,30);
+  
+  return result;
 }
 
@@ -788,5 +769,4 @@
 
 // }
-
 
 bool PspaApplication::removeExtensionFromConfigName(string& config)
@@ -820,94 +800,112 @@
 }
 
-/////////////////////////
-//   c'est un embryon d'histogramme
-
 void PspaApplication::dessinerHistogramme()
 {
-    // pour mon test : histo en energie
-    toto_->clear();
-    
-    GWt_dialog* pourVoir= new GWt_dialog("histogramme",toto_,false);
-    pourVoir->setMinimumSize(400,400);
-    pourVoir->setClosable(true);
-    pourVoir->show();
-    
-    
-    particleBeam* beam = dtmanage_->getDiagnosticBeam(1);
-    vector<double> xcor;
-    vector<int> hist;
-    int cnts;
-    beam->histogramme(xcor,hist,cnts);
-    
-    cout<<"xcor.size()= "<<xcor.size()<<", hist.size()= "<<hist.size()<<endl;
-    
-    //////////////////////////////////////////////////////////////////////////////////
-    
-    WContainerWidget *w = toto_;
-    int nbpts= xcor.size()+cnts+1;
-    WStandardItemModel *model = new WStandardItemModel(nbpts,2,w);
-    model->setHeaderData(1, WString("energie"));
-    
-    int j= 0;
-    if(hist[0] > 0) {
-        model->setData(j,0,xcor[0]);
-        model->setData(j,1,hist[0]);
-        j++;
-    }
+  // pour mon test : histo en energie
+  toto_->clear();
+    
+  GWt_dialog* pourVoir= new GWt_dialog("histogramme",toto_,false);
+  pourVoir->setMinimumSize(400,400);
+  pourVoir->setClosable(true);
+  pourVoir->show();
+  
+  int index = choixHistoDessin_->currentIndex();    
+  particleBeam* beam = dtmanage_->getDiagnosticBeam(index);
+  if (beam == NULL) {
+    GWt_dialog warningBeamState("histogram","the beam does not exist at the end of this element !", GWt_dialog::Error, false,true);
+    warningBeamState.exec();
+    return;
+  }
+  
+  if (!beam->particleRepresentationOk()) {
+    GWt_dialog warningBeamState("histogram", "the beam state does not allow providing a drawing with macroparticles !", GWt_dialog::Error, false,true);
+    warningBeamState.exec();
+    return;
+  }
+
+  vector<double> xcor;
+  vector<int> hist;
+  int cnts;
+  double out[3]= {0.0};
+  beam->histogramme(xcor,hist,cnts,out);
+  
+  cout<<"xcor.size()= "<<xcor.size()<<", hist.size()= "<<hist.size()<<endl;
+  //////////////////////////////////////////////////////////////////////////////////
+    
+  WContainerWidget *w = toto_;
+  int nbpts= xcor.size()+cnts+1;
+  WStandardItemModel *model = new WStandardItemModel(nbpts,2,w);
+  model->setHeaderData(1, WString("energie"));
+  
+  int j= 0;
+  if(hist[0] > 0) {
     model->setData(j,0,xcor[0]);
     model->setData(j,1,hist[0]);
     j++;
-    for (int i = 1; i < nbpts; ++i) {
-        if(hist[i] == 0) {
-            if(hist[i-1] > 0) {
-                model->setData(j,0,xcor[i]);
-                model->setData(j,1,hist[i-1]);
-                j++;
-            }
-            model->setData(j,0,xcor[i]);
-            model->setData(j,1,hist[i]);
-            j++;
-        }
-        if(hist[i] > 0) {
-            model->setData(j,0,xcor[i]);
-            model->setData(j,1,hist[i-1]);
-            j++;
-            model->setData(j,0,xcor[i]);
-            model->setData(j,1,hist[i]);
-            j++;
-        }
-    }
-    
-    WCartesianChart *chart = new WCartesianChart(w);
-    chart->setTitle("Histogramme");
-    chart->setModel(model);        // set the model
-    chart->setXSeriesColumn(0);    // set the column that holds the categories
-    chart->setLegendEnabled(true); // enable the legend
-    
-    // Provide space for the X and Y axis and title.
-    chart->setPlotAreaPadding(200, Right);
-    chart->setPlotAreaPadding(80, Left);
-    chart->setPlotAreaPadding(40, Top | Bottom);
-    
-    chart->setType(ScatterPlot);
-    
-    WAxis& axis = chart->axis(XAxis);
-    axis.setLabelFormat("%.3f");
-    axis.setGridLinesEnabled(true);
-    chart->axis(Y1Axis).setGridLinesEnabled(true);
-    
-    WDataSeries s(1, LineSeries);
-    chart->addSeries(s);
-    
-    
-    chart->resize(800, 400);
-    
-    chart->setMargin(10, Top | Bottom);
-    chart->setMargin(WLength::Auto, Left | Right);
-    
-    LegendLocation location = LegendOutside;
-    Side side = Right;
-    AlignmentFlag alignment = AlignMiddle;
-    chart->setLegendLocation(location, side, alignment);
-    chart->setLegendStyle(chart->legendFont(), WPen(black), WBrush(WColor(0xFF, 0xFA, 0xE5)));
-}
+  }
+  model->setData(j,0,xcor[0]);
+  model->setData(j,1,hist[0]);
+  j++;
+  for (int i = 1; i < nbpts; ++i) {
+    if(hist[i] == 0) {
+      if(hist[i-1] > 0) {
+	model->setData(j,0,xcor[i]);
+	model->setData(j,1,hist[i-1]);
+	j++;
+      }
+      model->setData(j,0,xcor[i]);
+      model->setData(j,1,hist[i]);
+      j++;
+    }
+    if(hist[i] > 0) {
+      model->setData(j,0,xcor[i]);
+      model->setData(j,1,hist[i-1]);
+      j++;
+      model->setData(j,0,xcor[i]);
+      model->setData(j,1,hist[i]);
+      j++;
+    }
+  }
+  
+  // legendes
+  new WText(" entries : "+ mixedTools::intToString((int)out[0]),w);
+  new WBreak(w);
+  new WText(" mean : "+ mixedTools::doubleToString(out[1])+" MeV",w);
+  new WBreak(w);
+  new WText(" rms : "+ mixedTools::doubleToString(out[2])+" KeV",w);
+  
+  WCartesianChart *chart = new WCartesianChart(w);
+  chart->setTitle("Histogram of particle energies");
+  chart->setModel(model);        // set the model
+  chart->setXSeriesColumn(0);    // set the column that holds the categories
+  chart->setLegendEnabled(false); // enable the legend
+    
+  // Provide space for the X and Y axis and title.
+  chart->setPlotAreaPadding(200, Right);
+  chart->setPlotAreaPadding(80, Left);
+  chart->setPlotAreaPadding(40, Top | Bottom);
+    
+  chart->setType(ScatterPlot);
+    
+  WAxis& axis = chart->axis(XAxis);
+  axis.setLabelFormat("%.3f");
+  axis.setGridLinesEnabled(true);
+  axis.setTitle(WString("legende x"));
+
+  chart->axis(Y1Axis).setGridLinesEnabled(true);
+  chart->axis(Y1Axis).setTitle(WString("legende y"));
+    
+  WDataSeries s(1, LineSeries);
+  s.setFillRange(ZeroValueFill);
+  chart->addSeries(s);
+    
+  chart->resize(800, 400);
+  chart->setMargin(10, Top | Bottom);
+  chart->setMargin(WLength::Auto, Left | Right);
+    
+  LegendLocation location = LegendOutside;
+  Side side = Right;
+  AlignmentFlag alignment = AlignMiddle;
+  chart->setLegendLocation(location, side, alignment);
+  chart->setLegendStyle(chart->legendFont(), WPen(black), WBrush(WColor(0xFF, 0xFA, 0xE5)));
+}
