void CGraph::printGraph()
{
this->replot();
//filter.setOptions(QwtPlotPrintFilter::PrintAll | QwtPlotPrintFilter::Options::PrintBackground);
//options |= QwtPlotPrintFilter::PrintBackground;
//options |= QwtPlotPrintFilter::PrintFrameWithScales;
filter.setOptions(options);
printer.
setOrientation(QPrinter::Landscape);
printer.setOutputFileName("graph.pdf");
print(printer, filter);
this->canvas();
canvas = this->canvas();
image = canvas->paintCache();
image->save("graph2.png");
pixmap.save("graph3.png", "png" );
}
void CGraph::printGraph()
{
this->replot();
QwtPlotPrintFilter filter;
//filter.setOptions(QwtPlotPrintFilter::PrintAll | QwtPlotPrintFilter::Options::PrintBackground);
int options = QwtPlotPrintFilter::PrintAll;
//options |= QwtPlotPrintFilter::PrintBackground;
//options |= QwtPlotPrintFilter::PrintFrameWithScales;
filter.setOptions(options);
QPrinter printer;
printer.setOrientation(QPrinter::Landscape);
printer.setOutputFileName("graph.pdf");
print(printer, filter);
QPixmap *image;
QwtPlotCanvas *canvas;
this->canvas();
canvas = this->canvas();
image = canvas->paintCache();
image->save("graph2.png");
QPixmap pixmap= QPixmap::grabWidget(this);
pixmap.save("graph3.png", "png" );
}
To copy to clipboard, switch view to plain text mode
void CGraph
::drawCanvas(QPainter* painter
) {
QwtPolygon polygon(3);
painter->setPen(Qt::NoPen);
painter->setBrush(Qt::red);
painter->translate(0,canvas()->height());
polygon.setPoint(0,0,0);
polygon.setPoint(1,canvas()->width(),0);
polygon.setPoint(2,canvas()->width(),-canvas()->height());
polygon.setPoint(2,canvas()->width(),-(double)canvas()->height()*6/7);
polygon.setPoint(2,canvas()->width(),-(double)canvas()->height()*5/7);
painter->setBrush(Qt::yellow);
polygon.setPoint(2,canvas()->width(),-(double)canvas()->height()*4/7);
polygon.setPoint(2,canvas()->width(),-(double)canvas()->height()*3/7);
painter->setBrush(Qt::darkGreen);
polygon.setPoint(2,canvas()->width(),-(double)canvas()->height()*2/7);
painter->setBrush(Qt::green);
polygon.setPoint(2,canvas()->width(),-(double)canvas()->height()*1/7);
}
void CGraph::drawCanvas(QPainter* painter)
{
QwtPainter qwtPainter;
QwtPolygon polygon(3);
painter->setPen(Qt::NoPen);
painter->setBrush(Qt::red);
painter->translate(0,canvas()->height());
polygon.setPoint(0,0,0);
polygon.setPoint(1,canvas()->width(),0);
polygon.setPoint(2,canvas()->width(),-canvas()->height());
painter->setBrush(QBrush(QColor(255,100,0)));
qwtPainter.drawPolygon(painter,polygon);
polygon.setPoint(2,canvas()->width(),-(double)canvas()->height()*6/7);
qwtPainter.drawPolygon(painter,polygon);
painter->setBrush(QBrush(QColor(255,200,0)));
polygon.setPoint(2,canvas()->width(),-(double)canvas()->height()*5/7);
qwtPainter.drawPolygon(painter,polygon);
painter->setBrush(Qt::yellow);
polygon.setPoint(2,canvas()->width(),-(double)canvas()->height()*4/7);
qwtPainter.drawPolygon(painter,polygon);
painter->setBrush(QBrush(QColor(180,230,0)));
polygon.setPoint(2,canvas()->width(),-(double)canvas()->height()*3/7);
qwtPainter.drawPolygon(painter,polygon);
painter->setBrush(Qt::darkGreen);
polygon.setPoint(2,canvas()->width(),-(double)canvas()->height()*2/7);
qwtPainter.drawPolygon(painter,polygon);
painter->setBrush(Qt::green);
polygon.setPoint(2,canvas()->width(),-(double)canvas()->height()*1/7);
qwtPainter.drawPolygon(painter,polygon);
}
To copy to clipboard, switch view to plain text mode
Bookmarks