Changeset 417 in PSPA for Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc
- Timestamp:
- Jun 10, 2013, 4:52:52 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc
r416 r417 702 702 703 703 704 // parametre drawPoints : true = on trace des points (phase space) ; false = on trace des lignes (enveloppes...)705 void PspaApplication::chartPlot2vec(WContainerWidget* toto, vector<double>& xcor, vector<double>& ycor, bool drawPoints,string title,string legendx, string legendy,int width, int height, bool makeIcon)706 {707 int nbpts = xcor.size();708 cout << " PspaApplication::chartPlot2vec nbpts = " << nbpts << endl;709 WStandardItemModel *model = new WStandardItemModel(nbpts, 2, toto);710 for (int i = 0; i < nbpts; ++i) {711 model->setData(i, 0, xcor.at(i));712 model->setData(i, 1, ycor.at(i));713 // cout << " PspaApplication::chartPlot2vec el= " << i+1 << " x= " << xcor.at(i) << " y= " << ycor.at(i) << endl;714 }715 716 WCartesianChart *chart = new WCartesianChart(toto);717 if (!makeIcon) {718 chart->setTitle(title);719 }720 chart->initLayout();721 722 chart->setModel(model); // set the model723 chart->setXSeriesColumn(0); // set the column that holds the X data724 if (!makeIcon) {725 chart->setLegendEnabled(true); // enable the legend726 } else {727 chart->setLegendEnabled(false); // enable the legend728 }729 730 chart->setType(ScatterPlot); // set type to ScatterPlot731 732 // Typically, for mathematical functions, you want the axes to cross733 // at the 0 mark:734 chart->axis(XAxis).setLocation(ZeroValue);735 chart->axis(YAxis).setLocation(ZeroValue);736 737 // Provide space for the X and Y axis and title.738 chart->setPlotAreaPadding(80, Left); // ?739 chart->setPlotAreaPadding(40, Bottom);740 chart->setPlotAreaPadding(60, Top);741 if ( drawPoints ) {742 WDataSeries s(1, PointSeries, Y1Axis);743 chart->addSeries(s);744 } else {745 WDataSeries s(1, LineSeries, Y1Axis);746 chart->addSeries(s);747 }748 chart->resize(width, height); // WPaintedWidget must be given explicit size749 750 751 WAxis& axis = chart->axis(XAxis);752 axis.setLabelFormat("%.3f");753 // axis.setGridLinesEnabled(true);754 axis.setTitle(legendx);755 756 WAxis& axey = chart->axis(YAxis);757 axey.setTitle(legendy);758 // axis = chart->axis(YAxis);759 // axis.setLabelFormat("%.3f");760 // axis.setGridLinesEnabled(true);761 // axis.setTitle(legendy);762 763 if (makeIcon) {764 chart->setPlotAreaPadding(0);765 chart->setAxisPadding(0);766 WFont xAxisFont = chart->axis(XAxis).labelFont();767 xAxisFont.setSize(8);768 WFont yAxisFont = chart->axis(YAxis).labelFont();769 yAxisFont.setSize(8);770 chart->axis(XAxis).setLabelFont(xAxisFont);771 chart->axis(YAxis).setLabelFont(yAxisFont);772 }773 774 #ifdef HAS_IMAGEMAGIC775 / * Wt::WRasterImage pngImage("png", 600, 600);776 Wt::WPainter p(&pngImage);777 chart->paint(p);778 std::string name;779 name = workingDir_ + "/chart-"+sessionId ()+".png";780 std::ofstream f(name.c_str(), std::ios::out |std::ios::trunc | std::ios::binary);781 pngImage.write(f);782 new WText("<a href='workingArea/chart-"+sessionId ()+".png' target='_blank'>Afficher l'image</a>",toto);783 784 Wt::WPdfImage pdfImage("30cm", "30cm");785 Wt::WPainter p1(&pdfImage);786 pdfImage.init();787 chart->paint(p1);788 name = workingDir_ + "/chart-"+sessionId ()+".pdf";789 std::ofstream f1(name.c_str(), std::ios::out |std::ios::trunc | std::ios::binary);790 pdfImage.write(f1);791 */792 #endif793 }704 // // parametre drawPoints : true = on trace des points (phase space) ; false = on trace des lignes (enveloppes...) 705 // void PspaApplication::chartPlot2vec(WContainerWidget* toto, vector<double>& xcor, vector<double>& ycor, bool drawPoints,string title,string legendx, string legendy,int width, int height, bool makeIcon) 706 // { 707 // int nbpts = xcor.size(); 708 // cout << " PspaApplication::chartPlot2vec nbpts = " << nbpts << endl; 709 // WStandardItemModel *model = new WStandardItemModel(nbpts, 2, toto); 710 // for (int i = 0; i < nbpts; ++i) { 711 // model->setData(i, 0, xcor.at(i)); 712 // model->setData(i, 1, ycor.at(i)); 713 // // cout << " PspaApplication::chartPlot2vec el= " << i+1 << " x= " << xcor.at(i) << " y= " << ycor.at(i) << endl; 714 // } 715 716 // WCartesianChart *chart = new WCartesianChart(toto); 717 // if (!makeIcon) { 718 // chart->setTitle(title); 719 // } 720 // chart->initLayout(); 721 722 // chart->setModel(model); // set the model 723 // chart->setXSeriesColumn(0); // set the column that holds the X data 724 // if (!makeIcon) { 725 // chart->setLegendEnabled(true); // enable the legend 726 // } else { 727 // chart->setLegendEnabled(false); // enable the legend 728 // } 729 730 // chart->setType(ScatterPlot); // set type to ScatterPlot 731 732 // // Typically, for mathematical functions, you want the axes to cross 733 // // at the 0 mark: 734 // chart->axis(XAxis).setLocation(ZeroValue); 735 // chart->axis(YAxis).setLocation(ZeroValue); 736 737 // // Provide space for the X and Y axis and title. 738 // chart->setPlotAreaPadding(80, Left); // ? 739 // chart->setPlotAreaPadding(40, Bottom); 740 // chart->setPlotAreaPadding(60, Top); 741 // if ( drawPoints ) { 742 // WDataSeries s(1, PointSeries, Y1Axis); 743 // chart->addSeries(s); 744 // } else { 745 // WDataSeries s(1, LineSeries, Y1Axis); 746 // chart->addSeries(s); 747 // } 748 // chart->resize(width, height); // WPaintedWidget must be given explicit size 749 750 751 // WAxis& axis = chart->axis(XAxis); 752 // axis.setLabelFormat("%.3f"); 753 // // axis.setGridLinesEnabled(true); 754 // axis.setTitle(legendx); 755 756 // WAxis& axey = chart->axis(YAxis); 757 // axey.setTitle(legendy); 758 // // axis = chart->axis(YAxis); 759 // // axis.setLabelFormat("%.3f"); 760 // // axis.setGridLinesEnabled(true); 761 // // axis.setTitle(legendy); 762 763 // if (makeIcon) { 764 // chart->setPlotAreaPadding(0); 765 // chart->setAxisPadding(0); 766 // WFont xAxisFont = chart->axis(XAxis).labelFont(); 767 // xAxisFont.setSize(8); 768 // WFont yAxisFont = chart->axis(YAxis).labelFont(); 769 // yAxisFont.setSize(8); 770 // chart->axis(XAxis).setLabelFont(xAxisFont); 771 // chart->axis(YAxis).setLabelFont(yAxisFont); 772 // } 773 774 // #ifdef HAS_IMAGEMAGIC 775 // /* Wt::WRasterImage pngImage("png", 600, 600); 776 // Wt::WPainter p(&pngImage); 777 // chart->paint(p); 778 // std::string name; 779 // name = workingDir_ + "/chart-"+sessionId ()+".png"; 780 // std::ofstream f(name.c_str(), std::ios::out |std::ios::trunc | std::ios::binary); 781 // pngImage.write(f); 782 // new WText("<a href='workingArea/chart-"+sessionId ()+".png' target='_blank'>Afficher l'image</a>",toto); 783 784 // Wt::WPdfImage pdfImage("30cm", "30cm"); 785 // Wt::WPainter p1(&pdfImage); 786 // pdfImage.init(); 787 // chart->paint(p1); 788 // name = workingDir_ + "/chart-"+sessionId ()+".pdf"; 789 // std::ofstream f1(name.c_str(), std::ios::out |std::ios::trunc | std::ios::binary); 790 // pdfImage.write(f1); 791 // */ 792 // #endif 793 // } 794 794 795 795 … … 950 950 */ 951 951 952 Wt::WPdfImage pdfImage("1000", "600"); 952 // Wt::WPdfImage pdfImage("1000", "600"); 953 WPdfImage pdfImage("1000", "600"); 953 954 { 954 955 Wt::WPainter p1(&pdfImage);
Note: See TracChangeset
for help on using the changeset viewer.