Changeset 407 in PSPA


Ignore:
Timestamp:
Mar 28, 2013, 4:32:42 PM (11 years ago)
Author:
garnier
Message:

Correction dans les comboBox

Location:
Interface_Web/trunk/pspaWT/sources
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc

    r401 r407  
    8383  if (a<0) return;
    8484  if (a>= jobList_.size()) return;
    85   delete jobList_[a];
     85  jobList_.erase (jobList_.begin()+a);
    8686}
    8787
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_pspaApplication.h

    r401 r407  
    103103  void dessinerPhaseSpace();
    104104
    105   void old_dessinerHistogramme();
    106105  void dessinerHistogramme();
    107106
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_sectionToExecute.h

    r401 r407  
    1111{
    1212    public :
    13     GWt_sectionToExecute(Wt::WComboBox*,Wt::WComboBox*,Wt::WComboBox*,GWt_softwarePanel* sPanel);
     13    GWt_sectionToExecute(Wt::WComboBox*,Wt::WComboBox*,Wt::WComboBox*,Wt::WContainerWidget* buttonPanel,GWt_softwarePanel* sPanel);
    1414
    1515    ~GWt_sectionToExecute() {;}
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_softwarePanel.h

    r405 r407  
    3434    //    void checkSectionSelection();
    3535    bool updateSectionSelection();
    36     void deleteSectionToExecuteW();
     36    void deleteSectionToExecuteW(int section);
    3737    string getSelection();
    3838    void executer();
     
    4040    void fillComboWithElements(Wt::WComboBox* cBox);
    4141    void fillComboWithSoftwares(Wt::WComboBox* cBox);
    42     Wt::WContainerWidget* createAddDeletePushButtons();
     42    Wt::WContainerWidget* createAddDeletePushButtons(int sectionIndex);
    4343
    4444    dataManager* dtmanage_;
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc

    r404 r407  
    22#include <string.h>
    33#include <vector>
     4#include <ctime>
    45
    56#include "GWt_pspaApplication.h"
     
    575576{
    576577 
    577   GWt_dialog* envDialog = new GWt_dialog("enveloppe",toto,false);
     578  std::time_t result = std::time(NULL);
     579 
     580  GWt_dialog* envDialog = new GWt_dialog(WString("enveloppe&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(")+std::asctime(std::localtime(&result))+")",toto,false);
    578581  eDialog_.push_back(envDialog);
    579582  envDialog->setMinimumSize(400,400);
     
    618621    return;
    619622  }
    620 
    621   GWt_dialog* phaseSpaceDialog = new GWt_dialog("phase space",toto,false);
     623 
     624  std::time_t result = std::time(NULL);
     625  GWt_dialog* phaseSpaceDialog = new GWt_dialog(WString("phase space&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(")+std::asctime(std::localtime(&result))+")",toto,false);
    622626  eDialog_.push_back(phaseSpaceDialog);
    623627  phaseSpaceDialog->setMinimumSize(400,400);
     
    852856}
    853857
    854 void PspaApplication::old_dessinerHistogramme()
    855 {
    856   // pour mon test : histo en energie
    857   toto_->clear();
    858  
    859   GWt_dialog* histoDialog = new GWt_dialog("histogramme",toto_,false);
    860   eDialog_.push_back(histoDialog);
    861   histoDialog->setMinimumSize(400,400);
    862   histoDialog->setClosable(true);
    863  
    864   // int index = choixHistoDessin_->currentIndex();   
    865   // particleBeam* beam = dtmanage_->getDiagnosticBeam(index);
    866    string elementLabel = choixHistoDessin_->currentText().toUTF8();   
    867    particleBeam* beam = dtmanage_->getDiagnosticBeam(elementLabel);
    868   if (beam == NULL) {
    869     GWt_dialog warningBeamState("histogram","the beam does not exist at the end of this element !", GWt_dialog::Error, false,true);
    870     warningBeamState.exec();
    871     return;
    872   }
    873  
    874   if (!beam->particleRepresentationOk()) {
    875     GWt_dialog warningBeamState("histogram", "the beam state does not allow providing a drawing with macroparticles !", GWt_dialog::Error, false,true);
    876     warningBeamState.exec();
    877     return;
    878   }
    879 
    880   histoDialog->show();
    881   vector<double> xcor;
    882   vector<int> hist;
    883   double out[3]= {0.0};
    884 
    885   unsigned iabs= choixVariableHisto_->currentIndex(); 
    886   beam->histogramme(iabs,xcor,hist,out);
    887 
    888   cout<<"xcor.size()= "<<xcor.size()<<", hist.size()= "<<hist.size()<<endl;
    889   //////////////////////////////////////////////////////////////////////////////////
    890 
    891   WContainerWidget *w= histoDialog->contents();
    892   int n = hist.size();
    893   int nbpts= 2*(n+1);
    894   WStandardItemModel *model = new WStandardItemModel(nbpts,2,w);
    895 
    896   int j= 0;
    897   model->setData(j,0,xcor[0]);
    898   model->setData(j,1,0.0);
    899   j++;
    900   model->setData(j,0,xcor[0]);
    901   model->setData(j,1,hist[0]);
    902   j++;
    903 
    904   for (int i = 1; i < n; ++i) {
    905     model->setData(j,0,xcor[i]);
    906     model->setData(j,1,hist[i-1]);
    907     j++;
    908     model->setData(j,0,xcor[i]);
    909     model->setData(j,1,hist[i]);
    910     j++;
    911   }
    912 
    913   model->setData(j,0,xcor[n]);
    914   model->setData(j,1,hist[n-1]);
    915   j++;
    916   model->setData(j,0,xcor[n]);
    917   model->setData(j,1,0.0);
    918 
    919   // legendes
    920   string unites[2];
    921   if(iabs == 0 || iabs == 1 || iabs == 2) {
    922     unites[0]= unites[1]= " mm";
    923   }
    924   if(iabs == 3 || iabs == 4) {
    925     unites[0]= unites[1]= " mrad";
    926   }
    927   if(iabs == 5) {
    928     unites[0]= " MeV"; unites[1]= " KeV";
    929   }
    930 
    931   new WText(" entries : "+ mixedTools::intToString((int)out[0]),w);
    932   new WBreak(w);
    933   new WText(" mean : "+ mixedTools::doubleToString(out[1])+unites[0],w);
    934   new WBreak(w);
    935   new WText(" sigma rms : "+ mixedTools::doubleToString(out[2])+unites[1],w);
    936    
    937   WCartesianChart *chart = new WCartesianChart(w);
    938 
    939   if(iabs == 0) chart->setTitle("x-coordinate");
    940   if(iabs == 1) chart->setTitle("y-coordinate");
    941   if(iabs == 2) chart->setTitle("z-coordinate");
    942   if(iabs == 3) chart->setTitle("xp-divergence");
    943   if(iabs == 4) chart->setTitle("yp-devergence");
    944   if(iabs == 5) chart->setTitle("kinetic energy");
    945  
    946   chart->setModel(model);        // set the model
    947   chart->setXSeriesColumn(0);    // set the column that holds the categories
    948   chart->setLegendEnabled(false); // enable the legend
    949    
    950   // Provide space for the X and Y axis and title.
    951   chart->setPlotAreaPadding(200, Right);
    952   chart->setPlotAreaPadding(80, Left);
    953   chart->setPlotAreaPadding(40, Top | Bottom);
    954    
    955   chart->setType(ScatterPlot);
    956    
    957   WAxis& axis = chart->axis(XAxis);
    958   axis.setLabelFormat("%.3f");
    959   axis.setGridLinesEnabled(true);
    960 
    961   if(iabs == 0) axis.setTitle(WString(" x (mm)"));
    962   if(iabs == 1) axis.setTitle(WString(" y (mm)"));
    963   if(iabs == 2) axis.setTitle(WString(" z (mm)"));
    964   if(iabs == 3) axis.setTitle(WString(" xp (mrad)"));
    965   if(iabs == 4) axis.setTitle(WString(" yp (mrad)"));
    966   if(iabs == 5) axis.setTitle(WString(" dEcin/Ecin (%)"));
    967  
    968   chart->axis(Y1Axis).setGridLinesEnabled(true);
    969   //chart->axis(Y1Axis).setTitle(WString("legende y"));
    970    
    971   WDataSeries s(1, LineSeries);
    972   s.setFillRange(ZeroValueFill);
    973   chart->addSeries(s);
    974    
    975   chart->resize(800, 400);
    976   chart->setMargin(10, Top | Bottom);
    977   chart->setMargin(WLength::Auto, Left | Right);
    978    
    979   LegendLocation location = LegendOutside;
    980   Side side = Right;
    981   AlignmentFlag alignment = AlignMiddle;
    982   chart->setLegendLocation(location, side, alignment);
    983   chart->setLegendStyle(chart->legendFont(), WPen(black), WBrush(WColor(0xFF, 0xFA, 0xE5)));
    984 }
     858
    985859
    986860void PspaApplication::removeBeamLine() {
     
    1076950  toto_->clear();
    1077951 
    1078   GWt_dialog* histoDialog = new GWt_dialog("histogramme",toto_,false);
     952  std::time_t result = std::time(NULL);
     953  GWt_dialog* histoDialog = new GWt_dialog(WString("histogramme&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(")+std::asctime(std::localtime(&result))+")",toto_,false);
    1079954  eDialog_.push_back(histoDialog);
    1080955  histoDialog->setMinimumSize(400,400);
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_sectionToExecute.cc

    r405 r407  
    99#include "GWt_softwarePanel.h"
    1010
    11 GWt_sectionToExecute::GWt_sectionToExecute(Wt::WComboBox* first,Wt::WComboBox* last,Wt::WComboBox* soft,GWt_softwarePanel* sPanel)
     11GWt_sectionToExecute::GWt_sectionToExecute(Wt::WComboBox* first,Wt::WComboBox* last,Wt::WComboBox* soft,Wt::WContainerWidget* buttonPanel, GWt_softwarePanel* sPanel)
    1212:WContainerWidget(),
    1313firstElement(first),
     
    3232    labelAndComboInsideContainerLayout->addWidget(last);
    3333    labelAndComboInsideContainerLayout->addWidget(soft);
     34
     35    // add buttons
     36    labelAndComboInsideContainerLayout->addWidget(buttonPanel);
    3437
    3538    labelAndComboInsideContainer->setLayout(labelAndComboInsideContainerLayout);
     
    8992    lastElement->setMinimumSize(80,12);
    9093    software->setMinimumSize(80,12);
    91    
     94       
    9295    firstElement->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections);
    9396    lastElement->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections);
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_softwarePanel.cc

    r406 r407  
    129129  fillComboWithSoftwares(softCombo);
    130130
    131   GWt_sectionToExecute* newSection = new GWt_sectionToExecute(lineFromCombo, lineToCombo, softCombo,this);
     131  GWt_sectionToExecute* newSection = new GWt_sectionToExecute(lineFromCombo, lineToCombo, softCombo,createAddDeletePushButtons(sections_.size()),this);
     132
     133  stringstream st;
     134  st << sections_.size();
     135
     136  // this is the mean to identify this section!
     137  newSection->setObjectName(st.str());
    132138
    133139  // push back on sections vector
    134140  sections_.push_back(newSection);
    135141
    136   Wt::WContainerWidget* container = new Wt::WContainerWidget();
     142/*  Wt::WContainerWidget* container = new Wt::WContainerWidget();
    137143  Wt::WGridLayout* containerLayout = new Wt::WGridLayout();
    138144  containerLayout->setContentsMargins(0,0,0,0);
     
    142148 
    143149  // add buttons
    144   containerLayout->addWidget(createAddDeletePushButtons(),0,1);
     150  containerLayout->addWidget(createAddDeletePushButtons(sections_.size()-1),0,1);
    145151
    146152  container->setLayout(containerLayout);
     153*/
    147154 
    148155  // add to sections
    149   contenuSections_->addWidget(container); 
     156//  contenuSections_->addWidget(container);
     157  contenuSections_->addWidget(newSection);
    150158}
    151159
     
    374382}
    375383
    376 void GWt_softwarePanel::deleteSectionToExecuteW()
    377 {
    378 /*  if ( dtmanage_->getJobListSize() == 0 ) return;
    379   // delete from dataManager
    380   dtmanage_->clearSectionToExecute(dtmanage_->getJobListSize()-1);
    381 
    382   // delete from User Interface
    383   sections_.pop_back();
    384 */
     384void GWt_softwarePanel::deleteSectionToExecuteW(int sectionLabel)
     385{
     386  stringstream st;
     387  st << sectionLabel;
     388  std::string sectionName = st.str();
     389 
     390  if ( dtmanage_->getJobListSize() == 0 ) return;
     391  for (unsigned int sectionIndex = 0; sectionIndex< sections_.size(); sectionIndex++) {
     392    if (sections_[sectionIndex]->objectName() == sectionName) {
     393
     394      // delete from dataManager
     395      dtmanage_->clearSectionToExecute(sectionIndex);
     396
     397      // delete from User Interface
     398      contenuSections_->removeWidget(sections_[sectionIndex]);
     399      delete sections_[sectionIndex];
     400      sections_.erase (sections_.begin()+sectionIndex);
     401    }
     402  } 
    385403}
    386404
     
    494512
    495513
    496 Wt::WContainerWidget* GWt_softwarePanel::createAddDeletePushButtons() {
     514Wt::WContainerWidget* GWt_softwarePanel::createAddDeletePushButtons(int sectionNumber) {
    497515
    498516  WContainerWidget* buttonContainer= new WContainerWidget();
     
    510528  WPushButton* exec_delete = new WPushButton("-");
    511529  //  warningsContainer_->setStyleClass("warningsContainer");
    512   exec_delete->clicked().connect(this, &GWt_softwarePanel::deleteSectionToExecuteW);
     530
     531  exec_delete->clicked().connect(boost::bind(&GWt_softwarePanel::deleteSectionToExecuteW, this, sectionNumber));
    513532  exec_delete->setStyleClass("roundButton");
    514533  exec_delete->setMaximumSize(20,20);
Note: See TracChangeset for help on using the changeset viewer.