Changeset 354 in PSPA


Ignore:
Timestamp:
Mar 1, 2013, 3:38:12 PM (11 years ago)
Author:
lemeur
Message:

complement dessin phase space + rationalisation

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

Legend:

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

    r342 r354  
    1717  bool particleRepresentationOk_;
    1818  bool momentRepresentationOk_;
    19   bareParticle referenceParticle_;
    2019  beam2Moments rij_;
    2120  double P0Transport_;
    2221
     22  // la representation du faisceau de particules sera a preciser ulterieurement
     23  // Pour l'instant une particule courante est definie par :
     24  // x
     25  // y
     26  // deltaz = z - z0 (z0 est le z de la particule de reference)
     27  // gamma.betax
     28  // gamma.betay
     29  // gamma.betaz
    2330  vector<bareParticle> goodPartic_;
     31
     32  // par ailleurs, la particules de reference est definie par x,y,z,gamma.betax, gamma.betay, gamma.betaz
     33  // elle est dupliquee dans le faisceau prorement dit (goodPartic_) avec z = z-z0 et ne doit, par consequent,
     34  // pas etre prise en compte dans les calculs de trajectoire.
     35  bareParticle referenceParticle_;
     36 
     37
    2438  vector<double> centroid_;
    2539
    2640  void impressionDesMoments() const;
    2741  void razDesMoments();
     42  void particlesPhaseSpaceComponent(vector<double>& coord, unsigned index);
    2843
    2944 public:
     
    5166  void printAllXYZ() const;
    5267  void Zrange(double& zmin, double& zmax) const;
    53   void donneesDessinEllipseXxp(vector<double>& xcor, vector<double>& ycor);
     68  //  void donneesDessinEllipseXxp(vector<double>& xcor, vector<double>& ycor);
    5469  void donneesDessinEllipse(vector<double>& xcor, vector<double>& ycor, unsigned indexAbs, unsigned indexOrd);
    55 
     70  void particlesPhaseSpaceData(vector<double>& xcor, vector<double>& ycor, unsigned indexAbs, unsigned indexOrd);
    5671  virtual string FileOutputFlow() const;
    5772  virtual bool FileInput(ifstream& ifs);
  • Interface_Web/trunk/pspaWT/sources/controler/src/particleBeam.cc

    r342 r354  
    333333}
    334334
    335 void particleBeam::donneesDessinEllipseXxp(vector<double>& xcor, vector<double>& ycor) {
     335// void particleBeam::donneesDessinEllipseXxp(vector<double>& xcor, vector<double>& ycor) {
     336//   int k;
     337//   double x,y;
     338
     339//   if ( !momentRepresentationOk_ ) return;
     340
     341//   xcor.clear();
     342//   ycor.clear();
     343
     344//   double xm = ( rij_.getMatrix().at(0) ).at(0);
     345//   double ym = ( rij_.getMatrix().at(1) ).at(1);
     346//   double r  = ( rij_.getMatrix().at(1) ).at(0);
     347
     348//   cout <<  " racs11= " << xm << " racs22= " << ym << " r12= " << r << endl;
     349
     350
     351//   int nbintv = 50;
     352//   if ( xm == 0.0 ) return;
     353//   double pas = 2.0 * xm / nbintv;
     354
     355//   //  cout << " r= " << r << endl;
     356//   double rac = (1 - r*r);
     357//   if ( rac > 0.0 )
     358//     {
     359//       cout << " cas rac > " << endl;
     360//       rac = sqrt(1 - r*r);
     361//       double alpha = -r / rac;
     362//       double beta = xm / ( ym * rac);
     363//       //  double gamma = ym / ( xm * rac );
     364//       double epsil = xm * ym * rac;
     365//       double fac1 = -1.0 / ( beta * beta);
     366//       double fac2 = epsil/beta;
     367//       double fac3 = -alpha/beta;
     368//       double aux;
     369//       for ( k=0; k < nbintv; k++)
     370//      {
     371//        x = -xm + k*pas;
     372//        aux = fac1 * x * x + fac2;
     373//        //     cout << " aux2= " << aux << endl;
     374//        if ( aux <= 0.0 )
     375//          {
     376//            aux = 0.0;
     377//          }
     378//        else aux = sqrt(aux);
     379     
     380//        //        y = fac3*x;
     381//        y = fac3*x + aux;
     382//        xcor.push_back(x);
     383//        ycor.push_back(y);
     384//      }
     385
     386//       for ( k=0; k <= nbintv; k++)
     387//      {
     388//        x = xm - k*pas;
     389//        aux =  fac1 * x * x + fac2;
     390//        if ( aux <= 0.0 )
     391//          {
     392//            aux = 0.0;
     393//          }
     394//        else aux = sqrt(aux);
     395//        //   y = fac3*x;
     396//        y = fac3*x - aux;
     397//        xcor.push_back(x);
     398//        ycor.push_back(y);
     399//      }
     400//     }
     401//   else
     402//     // cas degenere
     403//     {
     404//       cout << " cas degenere " << endl;
     405//       double fac = ym/xm;
     406//       for ( k=0; k < nbintv; k++)
     407//      {
     408//        x = -xm + k*pas;
     409//        y = fac*x;
     410//        xcor.push_back(x);
     411//        ycor.push_back(y);
     412//      }
     413       
     414//     }
     415// }
     416
     417void particleBeam::particlesPhaseSpaceData(vector<double>& xcor, vector<double>& ycor, unsigned indexAbs, unsigned indexOrd) {
     418  particlesPhaseSpaceComponent(xcor, indexAbs);
     419  particlesPhaseSpaceComponent(ycor, indexOrd);
     420}
     421
     422void particleBeam::particlesPhaseSpaceComponent(vector<double>& coord, unsigned index) {
     423  if ( !particleRepresentationOk_ ) return;
     424  coord.clear();
     425  coord.resize(goodPartic_.size(), 0.0 );
     426  cout << " particleBeam::particlesPhaseSpaceComponent index = " << index << endl;
     427  if ( index <= 2 ) {
     428    for (unsigned i = 0; i < goodPartic_.size(); ++i) {
     429      coord.at(i) =  goodPartic_.at(i).getPosition().getComponent(index);
     430    }
     431    return;
     432  }
     433
     434  if ( index >  2 && index < 5 ) {
     435    for (unsigned i = 0; i < goodPartic_.size(); ++i) {
     436      double begamz = goodPartic_.at(i).getBetaGamma().getComponent(2);
     437      if ( begamz != 0.0) {
     438        coord.at(i) =  1000.*goodPartic_.at(i).getBetaGamma().getComponent(index - 3)/begamz; // mimmiradians
     439      } else {
     440        coord.at(i) = 0.0;
     441      }
     442    }
     443    return;
     444  }
     445
     446  if ( index == 5 ) {
     447    double gamma0 = referenceParticle_.getGamma();
     448    cout << " gamma0 = " << gamma0 << endl;
     449    if ( gamma0 == 0.0 ) return;
     450    for (unsigned i = 0; i < goodPartic_.size(); ++i) {
     451      coord.at(i) =  100.*(goodPartic_.at(i).getGamma() - gamma0)/gamma0;  // en %
     452      cout << " gamma0 = " << gamma0 << " gamma = " << goodPartic_.at(i).getGamma() << endl;
     453    }
     454    return;
     455  }
     456}
     457
     458void particleBeam::donneesDessinEllipse(vector<double>& xcor, vector<double>& ycor, unsigned indexAbs, unsigned indexOrd) {
    336459  int k;
    337460  double x,y;
     
    339462  if ( !momentRepresentationOk_ ) return;
    340463
     464  if ( indexAbs > 5 || indexOrd > 5 ) return;
     465
    341466  xcor.clear();
    342467  ycor.clear();
    343 
    344   double xm = ( rij_.getMatrix().at(0) ).at(0);
    345   double ym = ( rij_.getMatrix().at(1) ).at(1);
    346   double r  = ( rij_.getMatrix().at(1) ).at(0);
     468  // les index sont dans l'ordre x,y,z,xp,yp, de/E
     469  // on traduit en TRANSPORT
     470  if ( indexAbs == 1 ) indexAbs = 2;  // y
     471  if ( indexAbs == 2 ) indexAbs = 4;  // z -> l
     472  if ( indexAbs == 3 ) indexAbs = 1;  // xp
     473  if ( indexAbs == 4 ) indexAbs = 3;  // yp
     474
     475  if ( indexOrd == 1 ) indexOrd = 2;  // y
     476  if ( indexOrd == 2 ) indexOrd = 4;  // z -> l
     477  if ( indexOrd == 3 ) indexOrd = 1;  // xp
     478  if ( indexOrd == 4 ) indexOrd = 3;  // yp
     479
     480  cout << " index x" << indexAbs << " index y " << indexOrd << endl;
     481
     482  double xm = ( rij_.getMatrix().at(indexAbs) ).at(indexAbs);
     483  double ym = ( rij_.getMatrix().at(indexOrd) ).at(indexOrd);
     484  double r;
     485  if ( indexOrd > indexAbs ) {
     486    r  = ( rij_.getMatrix().at(indexOrd) ).at(indexAbs);
     487  } else {
     488    r  = ( rij_.getMatrix().at(indexAbs) ).at(indexOrd);
     489  }
    347490
    348491  cout <<  " racs11= " << xm << " racs22= " << ym << " r12= " << r << endl;
     
    415558}
    416559
    417 
    418 
    419 void particleBeam::donneesDessinEllipse(vector<double>& xcor, vector<double>& ycor, unsigned indexAbs, unsigned indexOrd) {
    420   int k;
    421   double x,y;
    422 
    423   if ( !momentRepresentationOk_ ) return;
    424 
    425   if ( indexAbs > 5 || indexOrd > 5 ) return;
    426 
    427   xcor.clear();
    428   ycor.clear();
    429   // les index sont dans l'ordre x,y,z,xp,yp, de/E
    430   // on traduit en TRANSPORT
    431   if ( indexAbs == 1 ) indexAbs = 2;  // y
    432   if ( indexAbs == 2 ) indexAbs = 4;  // z -> l
    433   if ( indexAbs == 3 ) indexAbs = 1;  // xp
    434   if ( indexAbs == 4 ) indexAbs = 3;  // yp
    435 
    436   if ( indexOrd == 1 ) indexOrd = 2;  // y
    437   if ( indexOrd == 2 ) indexOrd = 4;  // z -> l
    438   if ( indexOrd == 3 ) indexOrd = 1;  // xp
    439   if ( indexOrd == 4 ) indexOrd = 3;  // yp
    440 
    441   cout << " index x" << indexAbs << " index y " << indexOrd << endl;
    442 
    443   double xm = ( rij_.getMatrix().at(indexAbs) ).at(indexAbs);
    444   double ym = ( rij_.getMatrix().at(indexOrd) ).at(indexOrd);
    445   double r;
    446   if ( indexOrd > indexAbs ) {
    447     r  = ( rij_.getMatrix().at(indexOrd) ).at(indexAbs);
    448   } else {
    449     r  = ( rij_.getMatrix().at(indexAbs) ).at(indexOrd);
    450   }
    451 
    452   cout <<  " racs11= " << xm << " racs22= " << ym << " r12= " << r << endl;
    453 
    454 
    455   int nbintv = 50;
    456   if ( xm == 0.0 ) return;
    457   double pas = 2.0 * xm / nbintv;
    458 
    459   //  cout << " r= " << r << endl;
    460   double rac = (1 - r*r);
    461   if ( rac > 0.0 )
    462     {
    463       cout << " cas rac > " << endl;
    464       rac = sqrt(1 - r*r);
    465       double alpha = -r / rac;
    466       double beta = xm / ( ym * rac);
    467       //  double gamma = ym / ( xm * rac );
    468       double epsil = xm * ym * rac;
    469       double fac1 = -1.0 / ( beta * beta);
    470       double fac2 = epsil/beta;
    471       double fac3 = -alpha/beta;
    472       double aux;
    473       for ( k=0; k < nbintv; k++)
    474         {
    475           x = -xm + k*pas;
    476           aux = fac1 * x * x + fac2;
    477           //     cout << " aux2= " << aux << endl;
    478           if ( aux <= 0.0 )
    479             {
    480               aux = 0.0;
    481             }
    482           else aux = sqrt(aux);
    483      
    484           //        y = fac3*x;
    485           y = fac3*x + aux;
    486           xcor.push_back(x);
    487           ycor.push_back(y);
    488         }
    489 
    490       for ( k=0; k <= nbintv; k++)
    491         {
    492           x = xm - k*pas;
    493           aux =  fac1 * x * x + fac2;
    494           if ( aux <= 0.0 )
    495             {
    496               aux = 0.0;
    497             }
    498           else aux = sqrt(aux);
    499           //   y = fac3*x;
    500           y = fac3*x - aux;
    501           xcor.push_back(x);
    502           ycor.push_back(y);
    503         }
    504     }
    505   else
    506     // cas degenere
    507     {
    508       cout << " cas degenere " << endl;
    509       double fac = ym/xm;
    510       for ( k=0; k < nbintv; k++)
    511         {
    512           x = -xm + k*pas;
    513           y = fac*x;
    514           xcor.push_back(x);
    515           ycor.push_back(y);
    516         }
    517        
    518     }
    519 }
    520 
    521560void particleBeam::histogramme(vector<double>&xcor,vector<int>& hist,int& cnts,double out[3])
    522561{
  • Interface_Web/trunk/pspaWT/sources/controler/src/softwareParmela.cc

    r353 r354  
    163163bool softwareParmela::beamFromParmela(string workingDir,unsigned numeroParmel, double referencefrequency, vector<double>& centroid, bareParticle& refPart,vector<bareParticle>& particles )
    164164{
     165
    165166  string nomfilefais = workingDir + "parmdesz";
    166167  cout << " nom fichier desz : " << nomfilefais << endl;
     
    183184
    184185      if ( partic.ne == (int)numeroParmel ) {
    185         faisceau.push_back(partic);
    186186        if ( partic.np == 1 ) {
    187187          // en principe on est sur la particule de reference
     
    191191          }
    192192          phaseRef = partic.phi;
    193           TRIDVECTOR  posRef(partic.xx,partic.yy,0.0);
     193
     194          // le 'z' est 'absolu' (le long de la trajectoire)
     195          TRIDVECTOR  posRef(partic.xx,partic.yy,partic.z);
    194196          TRIDVECTOR betagammaRef(partic.xxp*partic.begamz, partic.yyp*partic.begamz, partic.begamz);
    195197          refPart = bareParticle(posRef, betagammaRef);
     
    200202            return false;
    201203          }
    202         }
     204        }
     205        faisceau.push_back(partic);
    203206      }
    204207    } //while
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_pspaApplication.h

    r341 r354  
    7878 
    7979  void dialogOnGraphics();
    80   void setModelComponentForPhaseSpace(WStandardItemModel* model, vector<bareParticle>& partic, unsigned indexParticleComponent, unsigned modelComponent);
     80  //  void setModelComponentForPhaseSpace(WStandardItemModel* model, vector<bareParticle>& partic, unsigned indexParticleComponent, unsigned modelComponent);
    8181void faireDessinParmela(WContainerWidget* toto, particleBeam* beam, unsigned indexAbs, unsigned indexOrd, string namex, string namey  );
    8282  void faireDessinTransport(WContainerWidget* toto, particleBeam* beam, unsigned indexAbs, unsigned indexOrd, string namex, string namey);
    8383  void faireDessinEnveloppe(WContainerWidget* toto, string type);
    84   void scatterPlot1D(WContainerWidget* toto, vector<double>& xcor, vector<double>& ycor);
    85    
     84  //  void scatterPlot1D(WContainerWidget* toto, vector<double>& xcor, vector<double>& ycor);
     85  void chartPlot2vec(WContainerWidget* toto, vector<double>& xcor, vector<double>& ycor, bool drawPoints);
    8686  bool removePathFromConfigName(string& config);
    8787  bool removeExtensionFromConfigName(string& config);
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc

    r347 r354  
    248248  choixAbsPhase_->addItem("x");
    249249  choixAbsPhase_->addItem("y");
    250   choixAbsPhase_->addItem("z");
     250  choixAbsPhase_->addItem("dz");
    251251  choixAbsPhase_->addItem("xp");
    252252  choixAbsPhase_->addItem("yp");
     
    257257  choixOrdPhase_->addItem("x");
    258258  choixOrdPhase_->addItem("y");
    259   choixOrdPhase_->addItem("z");
     259  choixOrdPhase_->addItem("dz");
    260260  choixOrdPhase_->addItem("xp");
    261261  choixOrdPhase_->addItem("yp");
     
    547547  //dtmanage_->donneesRmsEnveloppe(type,1, nbel, xcor,ycor);
    548548  dtmanage_->donneesRmsEnveloppe(type,nbel,xcor,ycor);
    549   scatterPlot1D(envDialog->contents(),xcor,ycor); 
    550 }
    551 
    552 void PspaApplication::setModelComponentForPhaseSpace(WStandardItemModel* model, vector<bareParticle>& partic, unsigned indexParticleComponent, unsigned modelComponent) {
    553   double valeur;
    554   if ( indexParticleComponent > 5  ) return;
    555 
    556   if ( indexParticleComponent <= 2 ) {
    557     for (unsigned i = 0; i < partic.size(); ++i) {
    558       valeur = partic.at(i).getPosition().getComponent(indexParticleComponent);
    559       model->setData(i, modelComponent, valeur);
    560     }
    561   } else {
    562     if ( indexParticleComponent == 5 ) {
    563       cout << " PspaApplication::faireDessinParmela : deltap non programme " << endl;
    564       return;
    565     } else {
    566       for (unsigned i = 0; i < partic.size(); ++i) {
    567         double begamz = partic.at(i).getBetaGamma().getComponent(2);
    568         if ( begamz != 0.0) {
    569           valeur = 1.e3*partic.at(i).getBetaGamma().getComponent(indexParticleComponent-3)/begamz;
    570         } else {
    571           valeur = 0.0;
    572         }
    573         model->setData(i, modelComponent, valeur);
    574       }
    575     }
    576   }
    577 }
     549  //    scatterPlot1D(envDialog->contents(),xcor,ycor); 
     550chartPlot2vec(envDialog->contents(), xcor, ycor, false);
     551}
     552
     553// void PspaApplication::setModelComponentForPhaseSpace(WStandardItemModel* model, vector<bareParticle>& partic, unsigned indexParticleComponent, unsigned modelComponent) {
     554//   double valeur;
     555//   if ( indexParticleComponent > 5  ) return;
     556
     557//   if ( indexParticleComponent <= 2 ) {
     558//     for (unsigned i = 0; i < partic.size(); ++i) {
     559//       valeur = partic.at(i).getPosition().getComponent(indexParticleComponent);
     560//       model->setData(i, modelComponent, valeur);
     561//     }
     562//   } else {
     563//     if ( indexParticleComponent == 5 ) {
     564//       cout << " PspaApplication::faireDessinParmela : deltap non programme " << endl;
     565//       return;
     566//     } else {
     567//       for (unsigned i = 0; i < partic.size(); ++i) {
     568//      double begamz = partic.at(i).getBetaGamma().getComponent(2);
     569//      if ( begamz != 0.0) {
     570//        valeur = 1.e3*partic.at(i).getBetaGamma().getComponent(indexParticleComponent-3)/begamz;
     571//      } else {
     572//        valeur = 0.0;
     573//      }
     574//      model->setData(i, modelComponent, valeur);
     575//       }
     576//     }
     577//   }
     578// }
    578579
    579580void PspaApplication::faireDessinParmela(WContainerWidget* toto, particleBeam* beam, unsigned indexAbs, unsigned indexOrd, string namex, string namey )
     
    586587  // pointsDialog->show();
    587588     
    588   vector<bareParticle>& partic = beam->getParticleVector();
    589   new WText(nameOfCase_ + " : phase space " + namex + " ," + namey + " ; particle number : "+ mixedTools::intToString(partic.size()), pointsDialog->contents());
    590 
    591   WStandardItemModel *model = new WStandardItemModel(partic.size(), 2, pointsDialog->contents());
    592 
    593 
    594   setModelComponentForPhaseSpace(model, partic, indexAbs, 0);
    595   setModelComponentForPhaseSpace(model, partic, indexOrd, 1);
    596 
    597   cout << " faireDessinParmela : FAISCEAU VU  " << endl;
    598 
    599   WCartesianChart *chart = new WCartesianChart(pointsDialog->contents());
    600   chart->setModel(model);        // set the model
    601   chart->setXSeriesColumn(0);    // set the column that holds the X data
    602   chart->setLegendEnabled(true); // enable the legend
    603    
    604   chart->setType(ScatterPlot);   // set type to ScatterPlot
    605    
    606   // Typically, for mathematical functions, you want the axes to cross
    607   // at the 0 mark:
    608   chart->axis(XAxis).setLocation(ZeroValue);
    609   chart->axis(YAxis).setLocation(ZeroValue);
    610    
    611   // Provide space for the X and Y axis and title.
    612   chart->setPlotAreaPadding(80, Left);
    613   chart->setPlotAreaPadding(40, Top | Bottom);
    614   // Add the curves
    615   WDataSeries s(1, PointSeries, Y1Axis);
    616   //  s.setShadow(WShadow(3, 3, WColor(0, 0, 0, 127), 3));
    617   //    s.setMarker(SquareMarker);
    618   //  s.setMarkerSize(600.);
    619   //  cout << "le marker est : " << s.marker() << endl;
    620   chart->addSeries(s);
    621    
    622   chart->resize(400, 400); // WPaintedWidget must be given explicit size
    623    
    624    
    625 #ifdef HAS_IMAGEMAGIC
    626   Wt::WRasterImage pngImage("png", 600, 600);
    627   Wt::WPainter p(&pngImage);
    628   chart->paint(p);
    629   std::string name;
    630   name = workingDir_ + "/chart-"+sessionId ()+".png";
    631   std::ofstream f(name.c_str(), std::ios::out |std::ios::trunc | std::ios::binary);
    632   pngImage.write(f);
    633   new WText("<a href='workingArea/chart-"+sessionId ()+".png' target='_blank'>Afficher l'image</a>",toto);
    634 #endif
     589  //    vector<bareParticle>& partic = beam->getParticleVector();
     590  new WText(nameOfCase_ + " : phase space " + namex + " ," + namey + " ; particle number : "+ mixedTools::intToString(beam->getNbParticles()), pointsDialog->contents());
     591
     592  vector<double> xcor;
     593  vector<double> ycor;
     594  beam->particlesPhaseSpaceData(xcor, ycor, indexAbs, indexOrd);
     595  chartPlot2vec(pointsDialog->contents(), xcor, ycor, true);
     596
     597
    635598   
    636599  pointsDialog->show();
     
    660623  beam->donneesDessinEllipse(xcor,ycor,indexAbs, indexOrd);
    661624  //  beam->donneesDessinEllipseXxp(xcor,ycor);
    662   scatterPlot1D(ellipseDialog->contents(),xcor,ycor); 
    663 }
    664 
    665 
    666 
    667 void PspaApplication::scatterPlot1D(WContainerWidget* toto, vector<double>& xcor, vector<double>& ycor)
     625  //  scatterPlot1D(ellipseDialog->contents(),xcor,ycor); 
     626chartPlot2vec(ellipseDialog->contents(), xcor, ycor, false);
     627}
     628
     629
     630
     631// void PspaApplication::scatterPlot1D(WContainerWidget* toto, vector<double>& xcor, vector<double>& ycor)
     632// {
     633//     int nbpts = xcor.size();
     634//     cout << " PspaApplication::scatterPlot1D nbpts = " << nbpts << endl;
     635//     WStandardItemModel *model = new WStandardItemModel(nbpts, 2, toto);
     636//     for (int i = 0; i < nbpts; ++i) {
     637//         model->setData(i, 0, xcor.at(i));
     638//         model->setData(i, 1, ycor.at(i));
     639//         //    cout << " PspaApplication::scatterPlot1D el= " << i+1 << " x= " << xcor.at(i) << " y= " << ycor.at(i) << endl;
     640//     }
     641   
     642//     WCartesianChart *chart = new WCartesianChart(toto);
     643//     chart->setTitle("titre");
     644   
     645//     //  chart->initLayout();
     646   
     647//     chart->setModel(model);        // set the model
     648//     chart->setXSeriesColumn(0);    // set the column that holds the X data
     649//     chart->setLegendEnabled(true); // enable the legend
     650   
     651//     chart->setType(ScatterPlot);   // set type to ScatterPlot
     652   
     653//     // Typically, for mathematical functions, you want the axes to cross
     654//     // at the 0 mark:
     655//     chart->axis(XAxis).setLocation(ZeroValue);
     656//     chart->axis(YAxis).setLocation(ZeroValue);
     657   
     658//     // Provide space for the X and Y axis and title.
     659//     //   chart->setPlotAreaPadding(80, Left);
     660//     //   chart->setPlotAreaPadding(40, Top | Bottom);
     661//     // Add the curves
     662//     WDataSeries s(1, LineSeries, Y1Axis);
     663//     chart->addSeries(s);
     664   
     665//     // chart->setBackground (WBrush(WColor("blue")));
     666//     chart->resize(500, 300); // WPaintedWidget must be given explicit size
     667   
     668// #ifdef HAS_IMAGEMAGIC
     669//     Wt::WRasterImage pngImage("png", 600, 600);
     670//     Wt::WPainter p(&pngImage);
     671   
     672//     chart->paint(p);
     673//     std::string name;
     674//     name = workingDir_ + "/chart-"+sessionId ()+".png";
     675//     std::ofstream f(name.c_str(), std::ios::out |std::ios::trunc | std::ios::binary);
     676//     pngImage.write(f);
     677   
     678//     new WText("<a href='workingArea/chart-"+sessionId ()+".png' target='_blank'>Afficher l'image</a>",toto);
     679   
     680//     /*
     681//      Wt::WPdfImage pdfImage("30cm", "30cm");
     682//      Wt::WPainter p1(&pdfImage);
     683//      chart->paint(p1);
     684//      std::ofstream f1("chart.pdf", std::ios::out | std::ios::binary);
     685//      pdfImage.write(f1);
     686//      */
     687// #endif
     688// }
     689
     690// dernier parametre, drawPoints : true = on trace des points (phase space) ; false = on trace des lignes 'enveloppes...)
     691void PspaApplication::chartPlot2vec(WContainerWidget* toto, vector<double>& xcor, vector<double>& ycor, bool drawPoints)
    668692{
    669693    int nbpts = xcor.size();
    670     cout << " PspaApplication::scatterPlot1D nbpts = " << nbpts << endl;
     694    cout << " PspaApplication::chartPlot2vec nbpts = " << nbpts << endl;
    671695    WStandardItemModel *model = new WStandardItemModel(nbpts, 2, toto);
    672696    for (int i = 0; i < nbpts; ++i) {
    673697        model->setData(i, 0, xcor.at(i));
    674698        model->setData(i, 1, ycor.at(i));
    675         //    cout << " PspaApplication::scatterPlot1D el= " << i+1 << " x= " << xcor.at(i) << " y= " << ycor.at(i) << endl;
     699        //    cout << " PspaApplication::chartPlot2vec el= " << i+1 << " x= " << xcor.at(i) << " y= " << ycor.at(i) << endl;
    676700    }
    677701   
     
    693717   
    694718    // Provide space for the X and Y axis and title.
    695     //   chart->setPlotAreaPadding(80, Left);
    696     //   chart->setPlotAreaPadding(40, Top | Bottom);
    697     // Add the curves
    698     WDataSeries s(1, LineSeries, Y1Axis);
    699     chart->addSeries(s);
    700    
    701     // chart->setBackground (WBrush(WColor("blue")));
    702     chart->resize(500, 300); // WPaintedWidget must be given explicit size
     719    if ( drawPoints ) {
     720      chart->setPlotAreaPadding(80, Left);
     721      chart->setPlotAreaPadding(40, Top | Bottom);
     722      WDataSeries s(1, PointSeries, Y1Axis);
     723      chart->addSeries(s);
     724      chart->resize(400, 400); // WPaintedWidget must be given explicit size
     725     } else {
     726       WDataSeries s(1, LineSeries, Y1Axis);
     727       chart->addSeries(s);   
     728       chart->resize(500, 300); // WPaintedWidget must be given explicit size
     729     }
    703730   
    704731#ifdef HAS_IMAGEMAGIC
    705732    Wt::WRasterImage pngImage("png", 600, 600);
    706     Wt::WPainter p(&pngImage);
    707    
     733    Wt::WPainter p(&pngImage);   
    708734    chart->paint(p);
    709735    std::string name;
    710736    name = workingDir_ + "/chart-"+sessionId ()+".png";
    711737    std::ofstream f(name.c_str(), std::ios::out |std::ios::trunc | std::ios::binary);
    712     pngImage.write(f);
    713    
     738    pngImage.write(f);   
    714739    new WText("<a href='workingArea/chart-"+sessionId ()+".png' target='_blank'>Afficher l'image</a>",toto);
    715740   
     
    723748#endif
    724749}
    725 
    726750
    727751
Note: See TracChangeset for help on using the changeset viewer.