Changeset 229 in PSPA


Ignore:
Timestamp:
Jan 3, 2013, 9:50:36 AM (12 years ago)
Author:
lemeur
Message:

labels et dessins

Location:
Interface_Web/trunk/pspaWT
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • Interface_Web/trunk/pspaWT/include/GWt_abstractElement.h

    r226 r229  
    2222  WPushButton* dropped_;
    2323  WContainerWidget* wc_;
    24 
     24  WText* wc_item_;
    2525  WLineEdit* labelEdit_;
    2626
     
    3636
    3737  void clicked();
     38  void setLabelWidget();
    3839  void updateLabelWidget();
    3940  WPushButton* getButton();
  • Interface_Web/trunk/pspaWT/include/GWt_soleno.h

    r226 r229  
    11#ifndef GWTSOLENO_SEEN
    22#define GWTSOLENO_SEEN
     3
     4#include <Wt/WCheckBox>
    35
    46//#include "GWt_pspaApplication.h"
     
    1820  WLineEdit* apertureEdit_;
    1921  WLineEdit* B0Edit_;
     22  WCheckBox* varyB0Edit_;
    2023
    2124  GWt_soleno() {;}
  • Interface_Web/trunk/pspaWT/include/abstractElement.h

    r225 r229  
    1515 
    1616  bool parmelaOk_;
     17  bool parmelaIgnored_;
    1718  bool transportOk_;
    1819  int nbParam_;
     
    5455  double getLenghtOfElement() const;
    5556  int getNbParams() const; 
     57  bool is_parmela_ignored() const;
    5658  bool is_parmela_element() const;
    5759  bool is_transport_element() const;
  • Interface_Web/trunk/pspaWT/include/elementSoleno.h

    r84 r229  
    1616  double B0Def_;   // en kilogauss
    1717
     18  bool varyB0_;
     19  bool varyB0Def_;
    1820
    1921
  • Interface_Web/trunk/pspaWT/include/particleBeam.h

    r227 r229  
    5151
    5252
    53   void readTransportMoments(ifstream& inp);
     53  //  void readTransportMoments(ifstream& inp);
     54  void readTransportMoments(stringstream& inp);
    5455
    5556  void impressionDesMoments() const;
  • Interface_Web/trunk/pspaWT/include/transportMoments.h

    r180 r229  
    3232 void raz();
    3333
    34  void readFromTransportOutput(ifstream& inp);
     34 // void readFromTransportOutput(ifstream& inp);
     35 void readFromTransportOutput(stringstream& inp);
    3536 string writeToTransportInput(double P0) const;
    3637
  • Interface_Web/trunk/pspaWT/src/GWt_LigneFaisceau.cc

    r226 r229  
    6969      }
    7070     
    71       gw->updateLabelWidget();
     71      gw->setLabelWidget();
    7272      nObjets_[ptr->getNomdElement().getElementType()].incr();
    7373      GWt_dropZoneLigneFaiseau* dropZone = new GWt_dropZoneLigneFaiseau(pspa_);
  • Interface_Web/trunk/pspaWT/src/GWt_abstractElement.cc

    r226 r229  
    6969{
    7070  string str = element_->getLabel();
    71   WText *item = new WText(str);
    72   item->setObjectName("aText");
    73   wc_->addWidget(item);
     71  wc_item_->setText(str);
     72}
     73
     74void GWt_abstractElement::setLabelWidget()
     75{
     76  string str = element_->getLabel();
     77  wc_item_ = new WText(str);
     78  wc_item_->setObjectName("aText");
     79  wc_->addWidget(wc_item_);
    7480}
    7581
  • Interface_Web/trunk/pspaWT/src/GWt_beam.cc

    r226 r229  
    6565  }
    6666  element_->setParametersString(envoi);
     67  updateLabelWidget();
    6768  delete [] envoi;
    6869}
  • Interface_Web/trunk/pspaWT/src/GWt_bend.cc

    r226 r229  
    6666  }
    6767  element_->setParametersString(envoi);
     68  updateLabelWidget();
    6869  delete [] envoi;
    6970}
  • Interface_Web/trunk/pspaWT/src/GWt_cell.cc

    r226 r229  
    9191  }
    9292  element_->setParametersString(envoi);
     93  updateLabelWidget();
    9394  delete [] envoi;
    9495}
  • Interface_Web/trunk/pspaWT/src/GWt_drift.cc

    r226 r229  
    3939  }
    4040  element_->setParametersString(envoi);
     41  updateLabelWidget();
    4142  delete [] envoi;
    4243}
  • Interface_Web/trunk/pspaWT/src/GWt_dropZoneLigneFaiseau.cc

    r226 r229  
    153153
    154154  if(insertedAbstractElement == NULL) return;
    155   insertedAbstractElement->updateLabelWidget();
     155  insertedAbstractElement->setLabelWidget();
    156156
    157157//   //////////////////////////////////////////////////////////////////
     
    396396      str= elem.getElementLabel()+"0"+number;
    397397    } else {
    398     str= elem.getElementLabel()+" "+number;
     398    str= elem.getElementLabel()+number;
    399399    }
    400400  }
  • Interface_Web/trunk/pspaWT/src/GWt_fit.cc

    r226 r229  
    4242  new WText(" tolerance : ",dialog_->contents());
    4343  tolerEdit_  = new WLineEdit( (++param)->c_str(), dialog_->contents());
     44  new WBreak(dialog_->contents());
    4445  WPushButton *submit = new WPushButton("OK",dialog_->contents());
    4546  submit->clicked().connect(dialog_, &Wt::WDialog::accept);
     
    6667  }
    6768  element_->setParametersString(envoi);
     69  updateLabelWidget();
    6870  delete [] envoi;
    6971}
  • Interface_Web/trunk/pspaWT/src/GWt_pspaApplication.cc

    r227 r229  
    687687void PspaApplication::faireDessinEnveloppe(WContainerWidget* toto, string type)
    688688{
    689        new WText(nameOfCase_ + " : enveloppe", toto);
    690        unsigned nbel = dtmanage_->beamLineSize();
     689
     690  GWt_dialog* envDialog = new GWt_dialog("enveloppe",toto_,false);
     691  envDialog->setMinimumSize(400,400);
     692  envDialog->setClosable(true);
     693  envDialog->show();
     694
     695
     696
     697  //       new WText(nameOfCase_ + " : enveloppe", toto);
     698        unsigned nbel = dtmanage_->beamLineSize();
    691699
    692700
     
    697705  dtmanage_->donneesRmsEnveloppe(type,1, nbel, xcor,ycor);
    698706
    699     scatterPlot1D(toto,xcor,ycor);
     707  scatterPlot1D(envDialog->contents(),xcor,ycor);
    700708
    701709}
     
    703711void PspaApplication::faireDessinParmela(WContainerWidget* toto, particleBeam* beam)
    704712{
     713
     714  GWt_dialog* pointsDialog = new GWt_dialog("space phase",toto,false);
     715  pointsDialog->setMinimumSize(400,400);
     716  pointsDialog->setClosable(true);
     717  // pointsDialog->show();
     718
     719
     720
    705721  vector<bareParticle>& partic = beam->getParticleVector();
    706   new WText(nameOfCase_ + " : espace de phase x,x' "+ " nb partic. "+ mixedTools::intToString(partic.size()), toto);
    707   WStandardItemModel *model = new WStandardItemModel(partic.size(), 3, toto);
     722  new WText(nameOfCase_ + " : espace de phase x,x' "+ " nb partic. "+ mixedTools::intToString(partic.size()), pointsDialog->contents());
     723  WStandardItemModel *model = new WStandardItemModel(partic.size(), 3, pointsDialog->contents());
    708724  //    model->setHeaderData(0, WString("X"));
    709725  //   model->setHeaderData(1, WString("Y = sin(X)"));
     
    720736  }
    721737
    722   WCartesianChart *chart = new WCartesianChart(toto);
     738  WCartesianChart *chart = new WCartesianChart(pointsDialog->contents());
    723739  chart->setModel(model);        // set the model
    724740  chart->setXSeriesColumn(0);    // set the column that holds the X data
     
    757773#endif
    758774
     775  pointsDialog->show();
     776
    759777  //  chart->setMargin(10, Top | Bottom);            // add margin vertically
    760778  //  chart->setMargin(WLength::Auto, Left | Right); // center horizontally
     
    773791
    774792  //  new WText(nameOfCase_ + " : espace de phase x,x' "+ " nb partic. "+ mixedTools::intToString(partic.size()), toto);
     793
     794  GWt_dialog* ellipseDialog = new GWt_dialog("ellipse",toto,false);
     795  ellipseDialog->setMinimumSize(400,400);
     796  ellipseDialog->setClosable(true);
     797  ellipseDialog->show();
    775798
    776799
     
    787810  //  dtmanage_->getCurrentBeam()->donneesDessinEllipseXxp(xcor,ycor);
    788811  beam->donneesDessinEllipseXxp(xcor,ycor);
    789     scatterPlot1D(toto,xcor,ycor);
    790 
    791 }
     812  scatterPlot1D(ellipseDialog->contents(),xcor,ycor);
     813
     814}
     815
     816// void PspaApplication::scatterPlot1D(WContainerWidget* toto, vector<double>& xcor, vector<double>& ycor)
     817// {
     818//   int nbpts = xcor.size();
     819//   cout << " PspaApplication::scatterPlot1D nbpts = " << nbpts << endl;
     820//   WStandardItemModel *model = new WStandardItemModel(nbpts, 2, toto);
     821//   for (int i = 0; i < nbpts; ++i) {
     822//     model->setData(i, 0, xcor.at(i));
     823//     model->setData(i, 1, ycor.at(i));
     824//     //    cout << " PspaApplication::scatterPlot1D el= " << i+1 << " x= " << xcor.at(i) << " y= " << ycor.at(i) << endl;
     825//   }
     826
     827//   WCartesianChart *chart = new WCartesianChart(toto);
     828
     829//   chart->initLayout();
     830
     831//   chart->setModel(model);        // set the model
     832//   chart->setXSeriesColumn(0);    // set the column that holds the X data
     833//   chart->setLegendEnabled(true); // enable the legend
     834
     835//   chart->setType(ScatterPlot);   // set type to ScatterPlot
     836
     837//   // Typically, for mathematical functions, you want the axes to cross
     838//   // at the 0 mark:
     839//    chart->axis(XAxis).setLocation(ZeroValue);
     840//    chart->axis(YAxis).setLocation(ZeroValue);
     841
     842//   // Provide space for the X and Y axis and title.
     843// //   chart->setPlotAreaPadding(80, Left);
     844// //   chart->setPlotAreaPadding(40, Top | Bottom);
     845//   // Add the curves
     846//   WDataSeries s(1, CurveSeries, Y1Axis);
     847//   chart->addSeries(s);
     848
     849//   // chart->setBackground (WBrush(WColor("blue")));
     850//   chart->resize(300, 300); // WPaintedWidget must be given explicit size
     851
     852// #ifdef HAS_IMAGEMAGIC
     853//  Wt::WRasterImage pngImage("png", 600, 600);
     854//  Wt::WPainter p(&pngImage);
     855
     856//  chart->paint(p);
     857//  std::string name;
     858//  name = workingDir_ + "/chart-"+sessionId ()+".png";
     859//  std::ofstream f(name.c_str(), std::ios::out |std::ios::trunc | std::ios::binary);
     860//  pngImage.write(f);
     861
     862//  new WText("<a href='workingArea/chart-"+sessionId ()+".png' target='_blank'>Afficher l'image</a>",toto);
     863
     864//  /*
     865//  Wt::WPdfImage pdfImage("30cm", "30cm");
     866//  Wt::WPainter p1(&pdfImage);
     867//  chart->paint(p1);
     868//  std::ofstream f1("chart.pdf", std::ios::out | std::ios::binary);
     869//  pdfImage.write(f1);
     870//  */
     871// #endif
     872// }
     873
    792874
    793875void PspaApplication::scatterPlot1D(WContainerWidget* toto, vector<double>& xcor, vector<double>& ycor)
     
    802884  }
    803885
    804   WCartesianChart *chart = new WCartesianChart(toto);
    805 
    806   chart->initLayout();
     886WCartesianChart *chart = new WCartesianChart(toto);
     887  chart->setTitle("Enveloppe");
     888
     889  //  chart->initLayout();
    807890
    808891  chart->setModel(model);        // set the model
     
    825908
    826909  // chart->setBackground (WBrush(WColor("blue")));
    827   chart->resize(300, 300); // WPaintedWidget must be given explicit size
     910  chart->resize(800, 400); // WPaintedWidget must be given explicit size
    828911
    829912#ifdef HAS_IMAGEMAGIC
  • Interface_Web/trunk/pspaWT/src/GWt_rfgun.cc

    r226 r229  
    6161  }
    6262  element_->setParametersString(envoi);
     63  updateLabelWidget();
    6364  delete [] envoi;
    6465}
  • Interface_Web/trunk/pspaWT/src/GWt_soleno.cc

    r226 r229  
    1818  apertureEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());
    1919  new WBreak(dialog_->contents());
    20   new WText("fielg (kG) : ",dialog_->contents());
     20  new WText("field (kG) : ",dialog_->contents());
    2121  B0Edit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());
     22  varyB0Edit_ = new WCheckBox(" : may vary ? ", dialog_->contents());
     23  varyB0Edit_->setChecked(atoi( (++param)->c_str() ) );
    2224  new WBreak(dialog_->contents());
    23 
    2425  // Submit
    2526  WPushButton *submit = new WPushButton("OK",dialog_->contents());
     
    3839  envoi[++compteur] = apertureEdit_->text().toUTF8();
    3940  envoi[++compteur] = B0Edit_->text().toUTF8();
     41  int varie;
     42  if ( varyB0Edit_->checkState() == Checked ) varie = 1;
     43  else varie = 0;
     44  envoi[++compteur] = mixedTools::intToString(varie);
    4045  if ( compteur !=  (int)nbParam ) {
    4146    cerr << " GWt_bend::dialogDone() pb nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl;
     
    4348  }
    4449  element_->setParametersString(envoi);
     50  updateLabelWidget();
    4551  delete [] envoi;
    4652}
  • Interface_Web/trunk/pspaWT/src/abstractElement.cc

    r225 r229  
    3838  aperture_ = defaultAperture_;
    3939  parmelaOk_ = false;
     40  parmelaIgnored_ = false;
    4041  transportOk_ = false;
    4142}
     
    105106}
    106107
     108bool abstractElement::is_parmela_ignored() const {
     109  return parmelaIgnored_;
     110}
     111
    107112bool abstractElement::is_transport_element() const {
    108113  return transportOk_;
  • Interface_Web/trunk/pspaWT/src/elementSoleno.cc

    r225 r229  
    2121  {
    2222    B0Def_ = 0.0;
     23    varyB0Def_ = false;
    2324  }
    2425
     
    2627  {
    2728    B0_ = B0Def_;
     29    varyB0_ = varyB0Def_;
    2830  }
    2931
     
    3941   parametersString_[++compteur] = mixedTools::doubleToString(aperture_);
    4042   parametersString_[++compteur] = mixedTools::doubleToString(B0_);
     43   parametersString_[++compteur] = mixedTools::intToString(varyB0_);
    4144   if ( compteur != nbParam_ ) {
    4245     cerr << " elementSoleno::getParametersString() : ERROR nr pf parameters dosnt match " << endl;
     
    6568    aperture_  = atof(param[++compteur].c_str());
    6669    B0_ = atof(param[++compteur].c_str());
     70    varyB0_ = atoi(param[++compteur].c_str());
    6771 }
    6872
     
    7983    ostringstream sortie;
    8084    // on passe la longueur en metres
    81     sortie << label_ << ":" << "  SOLENOID, L=" << 0.01*lenghtElem_ << ", B=" << B0_ << ";";
     85    sortie << label_ << ":" << "  SOLENOID, L=" << 0.01*lenghtElem_ << ", B=" << B0_ << ";" << endl;
     86    if ( varyB0_ ) {
     87      sortie <<  "  VARY, " << label_+"[B]"  << ";";
     88    }
    8289    return sortie.str();
    8390  }
     
    8996    sortie << elementName_.getElementLabel() << endl;
    9097    sortie  << label_ << endl;
    91     sortie << lenghtElem_ << "  " << aperture_<< " "  << B0_ << endl;
     98    sortie << lenghtElem_ << "  " << aperture_<< " "  << B0_ << " " << varyB0_ << endl;
    9299    return sortie.str();
    93100  }
     
    96103{
    97104  ifs >> label_;
    98   ifs >> lenghtElem_ >>  aperture_ >> B0_;
     105  ifs >> lenghtElem_ >>  aperture_ >> B0_ >> varyB0_ ;
    99106}
  • Interface_Web/trunk/pspaWT/src/nomdElements.cc

    r226 r229  
    8080  case cell :  return 10;
    8181  case bend :  return 7;
    82   case soleno :   return 4;
     82  case soleno :   return 5;
    8383  case fit :   return 4;
    8484  default : return 0;
  • Interface_Web/trunk/pspaWT/src/particleBeam.cc

    r227 r229  
    55#include <stdio.h>
    66#include <algorithm>
    7 
     7#include <sstream>
    88//#include "environmentVariables.h"
    99#include <Wt/WApplication>
    1010
    11 
     11using namespace std;
    1212
    1313particleBeam::particleBeam()  {
     
    9595
    9696
     97// bool  particleBeam::setFromTransport(string workingDir, string elLab, const nomdElements elem)
     98// {
     99//   string elementLabel = elLab;
     100//   // transformer le label en majuscules ; je ne suis pas sur que ca
     101//   // marchera a tous les coups (glm)
     102//   std::transform(elementLabel.begin(), elementLabel.end(), elementLabel.begin(), (int (*)(int))std::toupper);
     103
     104//   cout << " particleBeam::setFromTransport on cherche element " << elementLabel << endl;
     105//   string buf;
     106//   ifstream infile;
     107//   //  string nameIn = WORKINGAREA + "transport.output";
     108//   string nameIn = workingDir + "transport.output";
     109//   infile.open(nameIn.c_str(), ios::in);
     110//   if (!infile) {
     111//     cerr << " particleBeam::setFromTransport : error re-opening transport output stream " << nameIn << endl;
     112//     return false;
     113//   }
     114//   //  else cout << " particleBeam::setFromTransport() : ouverture du fichier " << nameIn << endl;
     115
     116//   string::size_type nn = string::npos;
     117//   while ( getline(infile, buf) ) {
     118//     //      cout << " buf= "  << buf << endl;
     119//     nn = buf.find(elementLabel);
     120//     //     cout << " string::npos= " << string::npos << " nn= " << nn << endl;
     121//     if ( nn != string::npos ) {
     122//       //       cout << " particleBeam::setFromTransport : element " << elementLabel << " trouve " << endl;
     123//       break;
     124//     }
     125//   }
     126
     127//   if ( nn == string::npos ) {
     128//     cerr << " particleBeam::setFromTransport : element " << elementLabel << " non trouve dans le fichier  " << nameIn << endl;
     129//     return false;
     130//   }
     131//   if (elem.getElementType() == bend ) {
     132//     getline(infile, buf);
     133//     getline(infile, buf);
     134//   }
     135//   readTransportMoments(infile);
     136//   impressionDesMoments();
     137//   infile.close();
     138//   momentRepresentationOk_ = true;
     139//   return true;
     140// }
     141
    97142bool  particleBeam::setFromTransport(string workingDir, string elLab, const nomdElements elem)
    98143{
     
    103148
    104149  cout << " particleBeam::setFromTransport on cherche element " << elementLabel << endl;
    105   string buf;
    106150  ifstream infile;
    107151  //  string nameIn = WORKINGAREA + "transport.output";
     
    115159
    116160  string::size_type nn = string::npos;
     161  string  fichier;
     162  string buf;
     163  unsigned compteur = 0;
    117164  while ( getline(infile, buf) ) {
    118     //      cout << " buf= "  << buf << endl;
     165      fichier += buf+"\n";
    119166    nn = buf.find(elementLabel);
    120     //     cout << " string::npos= " << string::npos << " nn= " << nn << endl;
    121167    if ( nn != string::npos ) {
    122       //          cout << " particleBeam::setFromTransport : element " << elementLabel << " trouve " << endl;
    123       break;
    124     }
    125   }
    126 
    127   if ( nn == string::npos ) {
     168      compteur++;
     169      //      break;
     170    }
     171  }
     172  infile.close();
     173  cout << " compteur= " << compteur << endl;
     174  if ( compteur == 0 ) {
    128175    cerr << " particleBeam::setFromTransport : element " << elementLabel << " non trouve dans le fichier  " << nameIn << endl;
    129176    return false;
    130177  }
    131   if (elem.getElementType() == bend ) {
    132     getline(infile, buf);
    133     getline(infile, buf);
    134   }
    135   readTransportMoments(infile);
     178
     179
     180  stringstream fichierStream(fichier);
     181  buf.clear();
     182  unsigned relu = 0;
     183  while ( std::getline(fichierStream, buf) ) {
     184    //    cout << " relecture buffer : " << buf << endl;
     185    nn = buf.find(elementLabel);
     186    if ( nn != string::npos ) {
     187      relu++;
     188      if ( relu == compteur ) {
     189        cout << " TROUVE !" << endl;
     190        break;
     191      }
     192    }
     193  }
     194
     195  readTransportMoments(fichierStream);
    136196  //  impressionDesMoments();
    137   infile.close();
    138197  momentRepresentationOk_ = true;
    139198  return true;
     
    430489
    431490
    432 void particleBeam::readTransportMoments(ifstream& inp) {
     491// void particleBeam::readTransportMoments(ifstream& inp) {
     492// rij_.readFromTransportOutput(inp);
     493// }
     494
     495void particleBeam::readTransportMoments(stringstream& inp) {
    433496rij_.readFromTransportOutput(inp);
    434497}
  • Interface_Web/trunk/pspaWT/src/transportMoments.cc

    r226 r229  
    7676
    7777
     78// // suppose qu'on est bien positionné dans le stream (a revoir)
     79// void transportMoments::readFromTransportOutput(ifstream& inp) {
     80//   string  bidString;
     81//   double bidon;
     82
     83//   // initialisation des moments
     84//   raz();
     85
     86//   inp >> bidon >>  bidString >>  bidon >>  ( rij_transportMoments_.at(0) ).at(0) >> bidString;
     87//   inp >> bidon >> ( rij_transportMoments_.at(1) ).at(1) >>  bidString >> ( rij_transportMoments_.at(1) ).at(0);
     88//   inp >> bidon >> ( rij_transportMoments_.at(2) ).at(2) >>  bidString >> ( rij_transportMoments_.at(2) ).at(0)  >> ( rij_transportMoments_.at(2) ).at(1);
     89//   inp >> bidon >> ( rij_transportMoments_.at(3) ).at(3) >>  bidString >> ( rij_transportMoments_.at(3) ).at(0)  >> ( rij_transportMoments_.at(3) ).at(1) >> ( rij_transportMoments_.at(3) ).at(2);
     90
     91//   inp >> bidon >> ( rij_transportMoments_.at(4) ).at(4) >>  bidString >> ( rij_transportMoments_.at(4) ).at(0)  >> ( rij_transportMoments_.at(4) ).at(1) >> ( rij_transportMoments_.at(4) ).at(2) >> ( rij_transportMoments_.at(4) ).at(3);
     92
     93//   inp >> bidon >> ( rij_transportMoments_.at(5) ).at(5) >>  bidString >> ( rij_transportMoments_.at(5) ).at(0)  >> ( rij_transportMoments_.at(5) ).at(1) >> ( rij_transportMoments_.at(5) ).at(2) >> ( rij_transportMoments_.at(5) ).at(3) >> ( rij_transportMoments_.at(5) ).at(4);
     94
     95// }
     96
    7897// suppose qu'on est bien positionné dans le stream (a revoir)
    79 void transportMoments::readFromTransportOutput(ifstream& inp) {
     98void transportMoments::readFromTransportOutput(stringstream& inp) {
    8099  string  bidString;
    81100  double bidon;
     
    94113
    95114}
     115
    96116
    97117string transportMoments::writeToTransportInput(double P0) const {
  • Interface_Web/trunk/pspaWT/workingArea/pspa.save

    r202 r229  
    1919solnd
    2020solnd01
    21 7.88  1e+61 1.02885
     217.88  1e+61 1.02885 0
    2222drift
    2323drift02
Note: See TracChangeset for help on using the changeset viewer.