! Renders the plot using the passed \a painter. The plot is sized to \a width and \a height in pixels. If the \a painter's scale is not 1.0, the resulting plot will appear scaled accordingly. \note If you are restricted to using a QPainter (instead of QCPPainter), create a temporary QPicture and open a QCPPainter on it. Then call \ref toPainter with this QCPPainter. After ending th
| 16470 | \see toPixmap |
| 16471 | */ |
| 16472 | void QCustomPlot::toPainter(QCPPainter *painter, int width, int height) |
| 16473 | { |
| 16474 | // this method is somewhat similar to toPixmap. Change something here, and a change in toPixmap might be necessary, too. |
| 16475 | int newWidth, newHeight; |
| 16476 | if (width == 0 || height == 0) |
| 16477 | { |
| 16478 | newWidth = this->width(); |
| 16479 | newHeight = this->height(); |
| 16480 | } else |
| 16481 | { |
| 16482 | newWidth = width; |
| 16483 | newHeight = height; |
| 16484 | } |
| 16485 | |
| 16486 | if (painter->isActive()) |
| 16487 | { |
| 16488 | QRect oldViewport = viewport(); |
| 16489 | setViewport(QRect(0, 0, newWidth, newHeight)); |
| 16490 | painter->setMode(QCPPainter::pmNoCaching); |
| 16491 | if (mBackgroundBrush.style() != Qt::NoBrush) // unlike in toPixmap, we can't do QPixmap::fill for Qt::SolidPattern brush style, so we also draw solid fills with fillRect here |
| 16492 | painter->fillRect(mViewport, mBackgroundBrush); |
| 16493 | draw(painter); |
| 16494 | setViewport(oldViewport); |
| 16495 | } else |
| 16496 | qDebug() << Q_FUNC_INFO << "Passed painter is not active"; |
| 16497 | } |
| 16498 | /* end of 'src/core.cpp' */ |
| 16499 | |
| 16500 |