Changeset 333 in PSPA for Interface_Web


Ignore:
Timestamp:
Feb 20, 2013, 11:21:23 AM (11 years ago)
Author:
lemeur
Message:

addition graphique (en cours)

Location:
Interface_Web/trunk/pspaWT
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • Interface_Web/trunk/pspaWT/sources/controler/include/softwareTest.h

    r316 r333  
    1212
    1313  softwareTest();
     14
     15  bool beamToParin(string workingDir, particleBeam* beam );
     16  bool beamFromParin(string workingDir, vector<bareParticle>& particles );
    1417
    1518 public :
  • Interface_Web/trunk/pspaWT/sources/controler/src/softwareParmela.cc

    r316 r333  
    121121bool  softwareParmela::buildBeamAfterElements(unsigned int numeroDeb,unsigned int numeroFin, vector<particleBeam>& beams, string workingDir) {
    122122  bool result = true;
    123         unsigned k;
    124 
    125         for ( k= numeroDeb; k <= numeroFin; k++)
    126           {
    127             beams.push_back(particleBeam());
    128             vector<double> centroid;
    129             bareParticle refPart;
    130             vector<bareParticle> particles;
    131             if (!beamFromParmela(workingDir,k - offsetNumElem_ , globParamPtr_->getFrequency(), centroid, refPart,particles ))
    132               {
    133                 abstractElement* elem = dataManager_->getElementPointerFromNumero(k);
    134                 if ( elem->is_accepted_by_software(nomDeLogiciel::parmela) == warning) {
    135                   int avantDernier = beams.size() -2;
    136                   beams.back() = beams.at(avantDernier);
    137                 } else {
    138                   // sortie << " reading parmdesz  failed " << endl;
    139     dataManager_->consoleMessage(" softwareParmela::buildBeamAfterElements : reading parmdesz  failed " );
    140                   result = false;
    141                   break;
    142                 }
    143               }
    144             else {
    145               beams.back().setWithParticles(centroid, refPart,particles);
    146             }
     123  unsigned k;
     124
     125  for ( k= numeroDeb; k <= numeroFin; k++)
     126    {
     127      beams.push_back(particleBeam());
     128      vector<double> centroid;
     129      bareParticle refPart;
     130      vector<bareParticle> particles;
     131      if (!beamFromParmela(workingDir,k - offsetNumElem_ , globParamPtr_->getFrequency(), centroid, refPart,particles ))
     132        {
     133          abstractElement* elem = dataManager_->getElementPointerFromNumero(k);
     134          if ( elem->is_accepted_by_software(nomDeLogiciel::parmela) == warning) {
     135            int avantDernier = beams.size() -2;
     136            beams.back() = beams.at(avantDernier);
     137          } else {
     138            // sortie << " reading parmdesz  failed " << endl;
     139            dataManager_->consoleMessage(" softwareParmela::buildBeamAfterElements : reading parmdesz  failed " );
     140            result = false;
     141            break;
    147142          }
    148         return result;
     143        }
     144      else {
     145        beams.back().setWithParticles(centroid, refPart,particles);
     146      }
     147    }
     148  return result;
    149149}
    150150
     
    274274  unsigned k;
    275275  double weight = 1.0;
    276   cout << " ICI sortie des particules " << endl;
    277276  double xx,yy,zz;
    278277  double begamx, begamy, begamz;
  • Interface_Web/trunk/pspaWT/sources/controler/src/softwareTest.cc

    r316 r333  
    2222{
    2323    dataManager_->consoleMessage(" softwareTest::createInputFile  " );
     24
     25    beamToParin(workingDir, beamBefore );
     26
     27
     28
    2429  return true;
    2530}
     
    3136
    3237bool  softwareTest::buildBeamAfterElements(unsigned int numeroDeb,unsigned int numeroFin, vector<particleBeam>& beams, string workingDir) {
    33     dataManager_->consoleMessage(" softwareTest::buildBeamAfterElements  " );
     38  dataManager_->consoleMessage(" softwareTest::buildBeamAfterElements  " );
     39  bool result = true;
     40  unsigned k;
     41  for ( k= numeroDeb; k <= numeroFin; k++)
     42    {
     43      beams.push_back(particleBeam());
     44      vector<double> centroid = vector<double>(6,0.0);
     45      bareParticle refPart;
     46      vector<bareParticle> particles;
     47           
     48 
     49      if (!beamFromParin(workingDir,particles ) )
     50        {
     51          dataManager_->consoleMessage(" softwareTest::buildBeamAfterElements : reading parin  failed " );
     52          result = false;
     53          break;
     54        }
     55      else {
     56        bareParticle refPart (particles.at(0));
     57        beams.back().setWithParticles(centroid, refPart,particles);
     58      }
     59    }
     60  return result;
     61}
     62
     63// sauvegarde d'un 'particleBeam' sur un fichier parmela, en guise d'INPUT
     64// pour l'instant de nom standard 'parin.input0'
     65bool softwareTest::beamToParin(string workingDir, particleBeam* beam ) {
     66  if ( !beam->particleRepresentationOk() ) {
     67    dataManager_->consoleMessage("softwareParmela::beamToParmela : beam not in particles form : not yet programmed");
     68    cout << " softwareParmela::beamToParmela : beam not in particles form : not yet programmed " << endl;
     69    return false;
     70  }
     71  ofstream outfile;
     72  string name = workingDir + "parin.input0";
     73  outfile.open(name.c_str(), ios::out);
     74  if (!outfile) {
     75    dataManager_->consoleMessage(" softwareTest::beamToParin : error opening in stream ");
     76    cerr << " softwareParmela::beamToParmela : error opening output stream " << name << endl;
     77    return false;
     78  }
     79
     80  const vector<bareParticle>& partic = beam->getParticleVector();
     81  unsigned k;
     82  double weight = 1.0;
     83  double xx,yy,zz;
     84  double begamx, begamy, begamz;
     85  for ( k=0; k < partic.size(); k++) {
     86    partic.at(k).getPosition().getComponents(xx,yy,zz);
     87    partic.at(k).getBetaGamma().getComponents(begamx, begamy, begamz);
     88    outfile << xx << " " << begamx << " " <<  yy << " " << begamy << " " << zz << " " << begamz  << " " << weight << endl;
     89  }
     90  outfile.close();
    3491  return true;
    3592}
     93
     94bool softwareTest::beamFromParin(string workingDir, vector<bareParticle>& particles ) {
     95  ifstream infile;
     96  string name = workingDir + "parin.input0";
     97  infile.open(name.c_str(), ios::in);
     98  if (!infile) {
     99    dataManager_->consoleMessage(" softwareParmela::beamToParmela : error opening output stream ");
     100    cerr << " softwareParmela::beamToParmela : error opening output stream " << name << endl;
     101    return false;
     102  }
     103
     104  particles.clear();
     105  double weight;
     106  double xx,yy,zz;
     107  double begamx, begamy, begamz;
     108  TRIDVECTOR  pos;
     109  TRIDVECTOR betagamma;
     110  while ( infile >> xx >> begamx >>  yy >>  begamy >> zz >> begamz  >> weight) {
     111    pos.setComponents(xx,yy,zz);
     112    betagamma.setComponents(begamx, begamy, begamz);
     113    particles.push_back(bareParticle(pos,betagamma));
     114  }
     115  infile.close();
     116  return true;
     117}
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_pspaApplication.h

    r324 r333  
    5050  WComboBox* choixElementDessin_;
    5151  WComboBox* choixTypeDessinFaisceau_;
     52    WComboBox* choixAbsPhase_;
     53    WComboBox* choixOrdPhase_;
    5254  WComboBox* choixEnveloppeDessin_;
    5355  WComboBox* choixHistoDessin_;
     
    7779 
    7880  void dialogOnGraphics();
    79   void faireDessinParmela(WContainerWidget* toto, particleBeam* beam);
     81    void faireDessinParmela(WContainerWidget* toto, particleBeam* beam, unsigned indexAbs, unsigned indexOrd );
    8082  void faireDessinTransport(WContainerWidget* toto, particleBeam* beam);
    8183  void faireDessinEnveloppe(WContainerWidget* toto, string type);
     
    8991  void dessinerHistogramme();
    9092   
     93   
     94     
     95
     96   
    9197 public :
    9298 
    9399  PspaApplication(const WEnvironment& env);
     100
    94101
    95102  string getSelection();
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc

    r324 r333  
    240240  choixTypeDessinFaisceau_->addItem("macroparticles");
    241241  Wt::WRadioButton *button2= new WRadioButton(" phase space after element");
     242
     243    choixAbsPhase_ = new WComboBox();
     244    choixAbsPhase_->addItem("x");
     245    choixAbsPhase_->addItem("y");
     246    choixAbsPhase_->addItem("z");
     247    choixAbsPhase_->addItem("xp");
     248    choixAbsPhase_->addItem("yp");
     249    choixAbsPhase_->addItem("dE/E");
     250
     251    choixOrdPhase_ = new WComboBox();
     252    choixOrdPhase_->addItem("x");
     253    choixOrdPhase_->addItem("y");
     254    choixOrdPhase_->addItem("z");
     255    choixOrdPhase_->addItem("xp");
     256    choixOrdPhase_->addItem("yp");
     257    choixOrdPhase_->addItem("dE/E");
     258
     259
     260
    242261  group_->addButton(button2,2);
    243262  glayout->addWidget(button2,1,1);
    244263  glayout->addWidget(choixElementDessin_,1,2);
    245264  glayout->addWidget(choixTypeDessinFaisceau_,1,3);
     265
     266  glayout->addWidget(choixAbsPhase_,1,4);
     267  glayout->addWidget(choixOrdPhase_,1,5);
    246268  /////////////////////////////////////////////////////////////////////
    247269
     
    455477  toto_->clear();
    456478   
    457   int typeFaisceau = choixTypeDessinFaisceau_->currentIndex(); 
     479  int typeFaisceau = choixTypeDessinFaisceau_->currentIndex();
    458480  int index = choixElementDessin_->currentIndex();
     481  unsigned xabs = choixAbsPhase_->currentIndex();
     482  unsigned yord = choixOrdPhase_->currentIndex();
     483       
    459484  particleBeam* beam = dtmanage_->getDiagnosticBeam(index);
    460485   
     
    464489    return;
    465490  }
    466      
     491   
     492   
    467493  if ( typeFaisceau == 0 )
    468494    {
     
    472498  else if ( typeFaisceau == 1 )
    473499    {
    474       if ( beam->particleRepresentationOk() ) faireDessinParmela(toto_, beam);
     500      if ( beam->particleRepresentationOk() ) faireDessinParmela(toto_, beam, xabs, yord);
    475501      else {
    476502        GWt_dialog warningBeamState(" graphical analysis", "the beam state does not allow providing a drawing with macroparticles !", GWt_dialog::Error, false,true);
     
    515541}
    516542
    517 void PspaApplication::faireDessinParmela(WContainerWidget* toto, particleBeam* beam)
    518 {
    519    
     543
     544void PspaApplication::faireDessinParmela(WContainerWidget* toto, particleBeam* beam, unsigned indexAbs, unsigned indexOrd )
     545{
     546  cout << " faireDessinParmela " << endl;
    520547    GWt_dialog* pointsDialog = new GWt_dialog("space phase",toto,false);
    521548    pointsDialog->setMinimumSize(400,400);
     
    527554    vector<bareParticle>& partic = beam->getParticleVector();
    528555    new WText(nameOfCase_ + " : espace de phase x,x' "+ " nb partic. "+ mixedTools::intToString(partic.size()), pointsDialog->contents());
    529     WStandardItemModel *model = new WStandardItemModel(partic.size(), 3, pointsDialog->contents());
     556    WStandardItemModel *model = new WStandardItemModel(partic.size(), 2, pointsDialog->contents());
    530557    //    model->setHeaderData(0, WString("X"));
    531558    //   model->setHeaderData(1, WString("Y = sin(X)"));
    532559   
    533    
     560    if ( indexAbs > 5 || indexOrd > 5 ) return;
     561
    534562    for (unsigned i = 0; i < partic.size(); ++i) {
    535         double x= partic.at(i).getPosition().getComponent(0);
    536         double begamz = partic.at(i).getBetaGamma().getComponent(2);
    537         double xp;
    538         if ( begamz != 0.0) {
    539           xp = partic.at(i).getBetaGamma().getComponent(0)/begamz;
     563      double valAbs, valOrd;
     564      double begamz = partic.at(i).getBetaGamma().getComponent(2);
     565      if ( indexAbs <= 2 ) {
     566        valAbs = partic.at(i).getPosition().getComponent(indexAbs);
     567        cout << " i= " << i << " valabs = " << valAbs << endl;
     568      } else {
     569        if ( indexAbs == 5 ) {
     570          cout << " PspaApplication::faireDessinParmela : deltap non programme " << endl;
     571          return;
    540572        } else {
    541           xp = 0.0;
     573          if ( begamz != 0.0) {
     574            valAbs = 1.e3*partic.at(i).getBetaGamma().getComponent(indexAbs-3)/begamz;
     575          } else {
     576            valAbs = 0.0;
     577          }
    542578        }
    543         //    cout << "x = " << x << " xp= " << xp << endl;
    544         model->setData(i, 0, x);
    545         model->setData(i, 1,1.e3*xp);
    546         model->setData(i, 2,2.e3*xp);
    547     }
    548    
     579      }
     580
     581      if ( indexOrd <= 2 ) {
     582        valOrd = partic.at(i).getPosition().getComponent(indexOrd);
     583      } else {
     584        if ( indexOrd == 5 ) {
     585          cout << " PspaApplication::faireDessinParmela : deltap non programme " << endl;
     586          return;
     587        } else {
     588
     589
     590          if ( begamz != 0.0) {
     591            valOrd = 1.e3*partic.at(i).getBetaGamma().getComponent(indexOrd-3)/begamz;
     592          } else {
     593            valOrd = 0.0;
     594          }
     595        cout << " i= " << i << " valord = " << valOrd << endl;
     596        }
     597      }
     598     
     599
     600        // double x= partic.at(i).getPosition().getComponent(0);
     601        // double begamz = partic.at(i).getBetaGamma().getComponent(2);
     602        // double xp;
     603        // if ( begamz != 0.0) {
     604        //   xp = partic.at(i).getBetaGamma().getComponent(0)/begamz;
     605        // } else {
     606        //   xp = 0.0;
     607        // }
     608        // //    cout << "x = " << x << " xp= " << xp << endl;
     609        // model->setData(i, 0, x);
     610        // model->setData(i, 1,1.e3*xp);
     611        // model->setData(i, 2,2.e3*xp);
     612        model->setData(i, 0, valAbs);
     613        model->setData(i, 1,  valOrd);
     614    }
     615      cout << " faireDessinParmela : FAISCEAU VU  " << endl;
     616
    549617    WCartesianChart *chart = new WCartesianChart(pointsDialog->contents());
    550618    chart->setModel(model);        // set the model
  • Interface_Web/trunk/pspaWT/workingArea/pmbfield

    r54 r333  
    11 z(cm)   b(gauss)
    2  -20.530     32.19      0.00     32.18     -0.00
     2 -20.530      0.00      0.00      0.00      0.00
Note: See TracChangeset for help on using the changeset viewer.