Changeset 354 in PSPA for Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc
- Timestamp:
- Mar 1, 2013, 3:38:12 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc
r347 r354 248 248 choixAbsPhase_->addItem("x"); 249 249 choixAbsPhase_->addItem("y"); 250 choixAbsPhase_->addItem(" z");250 choixAbsPhase_->addItem("dz"); 251 251 choixAbsPhase_->addItem("xp"); 252 252 choixAbsPhase_->addItem("yp"); … … 257 257 choixOrdPhase_->addItem("x"); 258 258 choixOrdPhase_->addItem("y"); 259 choixOrdPhase_->addItem(" z");259 choixOrdPhase_->addItem("dz"); 260 260 choixOrdPhase_->addItem("xp"); 261 261 choixOrdPhase_->addItem("yp"); … … 547 547 //dtmanage_->donneesRmsEnveloppe(type,1, nbel, xcor,ycor); 548 548 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); 550 chartPlot2vec(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 // } 578 579 579 580 void PspaApplication::faireDessinParmela(WContainerWidget* toto, particleBeam* beam, unsigned indexAbs, unsigned indexOrd, string namex, string namey ) … … 586 587 // pointsDialog->show(); 587 588 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 635 598 636 599 pointsDialog->show(); … … 660 623 beam->donneesDessinEllipse(xcor,ycor,indexAbs, indexOrd); 661 624 // 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); 626 chartPlot2vec(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...) 691 void PspaApplication::chartPlot2vec(WContainerWidget* toto, vector<double>& xcor, vector<double>& ycor, bool drawPoints) 668 692 { 669 693 int nbpts = xcor.size(); 670 cout << " PspaApplication:: scatterPlot1Dnbpts = " << nbpts << endl;694 cout << " PspaApplication::chartPlot2vec nbpts = " << nbpts << endl; 671 695 WStandardItemModel *model = new WStandardItemModel(nbpts, 2, toto); 672 696 for (int i = 0; i < nbpts; ++i) { 673 697 model->setData(i, 0, xcor.at(i)); 674 698 model->setData(i, 1, ycor.at(i)); 675 // cout << " PspaApplication:: scatterPlot1Del= " << 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; 676 700 } 677 701 … … 693 717 694 718 // 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 } 703 730 704 731 #ifdef HAS_IMAGEMAGIC 705 732 Wt::WRasterImage pngImage("png", 600, 600); 706 Wt::WPainter p(&pngImage); 707 733 Wt::WPainter p(&pngImage); 708 734 chart->paint(p); 709 735 std::string name; 710 736 name = workingDir_ + "/chart-"+sessionId ()+".png"; 711 737 std::ofstream f(name.c_str(), std::ios::out |std::ios::trunc | std::ios::binary); 712 pngImage.write(f); 713 738 pngImage.write(f); 714 739 new WText("<a href='workingArea/chart-"+sessionId ()+".png' target='_blank'>Afficher l'image</a>",toto); 715 740 … … 723 748 #endif 724 749 } 725 726 750 727 751
Note: See TracChangeset
for help on using the changeset viewer.