Пример #1
0
/*! \brief paint method.
    In this method each Plotter is grabbed from its own QCustomPlot Widget
    to a Pixmap and then drawed with the QPainter primitive drawPixmap
*/
void QtYARPScope::paint(QPainter *painter)
{
	if(!loader){
		return;
	}
    int rows = loader->portscope_rows;
    int cols = loader->portscope_columns;
    int w = painter->device()->width();
    int h = painter->device()->height();

    for (int i=0; i<plotManager->getPlotters()->count();i++)
    {
        painter->beginNativePainting(); // Workaround to flush the painter
        auto* plotter = (Plotter*)plotManager->getPlotters()->at(i);

        int hSpan = plotter->hspan;
        int vSpan = plotter->vspan;
        int plotterWidth = (w/cols) * hSpan;
        int plotterHeight = (h/rows) * vSpan;

        QPixmap picture(QSize(plotter->customPlot.width() * plotter->customPlot.devicePixelRatio(),
                              plotter->customPlot.height() * plotter->customPlot.devicePixelRatio()));

        QCPPainter qcpPainter( &picture );
        plotter->customPlot.toPainter( &qcpPainter );
        QRectF r = QRectF(plotter->gridx * plotterWidth/hSpan,
                          plotter->gridy * plotterHeight/vSpan,
                          picture.rect().width(),picture.rect().height());
        plotter->setPaintGeometry(r);
        painter->drawPixmap(r,picture,QRectF(0,0,plotterWidth,plotterHeight) );

        painter->endNativePainting();
    }

}
Пример #2
0
void qmlPlotPaintedItem::paint(QPainter* painter)
{
	QPixmap    picture(boundingRect().size().toSize());
	QCPPainter qcpPainter(&picture);
	m_CustomPlot.toPainter(&qcpPainter);
	painter->drawPixmap(QPoint(), picture);
}
Пример #3
0
void CustomPlotLineChart::paint(QPainter* aPainter)
{
    if (m_CustomPlot)
    {
        QPixmap    picture( boundingRect().size().toSize() );
        QCPPainter qcpPainter( &picture );

        m_CustomPlot->toPainter( &qcpPainter );
        aPainter->drawPixmap( QPoint(), picture );
    }
}
Пример #4
0
void CustomPlotRegression::paint( QPainter* painter )
{
    if (m_CustomPlot)
    {
        QPixmap    picture( boundingRect().width(),boundingRect().height());
        //QPixmap    picture( boundingRect().size().toSize());
        QCPPainter qcpPainter( &picture );

        //m_CustomPlot->replot();
        m_CustomPlot->toPainter( &qcpPainter );
        painter->drawPixmap( QPoint(), picture );
    }
}