MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / render

Method render

3rdparty/qwt/src/qwt_plot_renderer.cpp:482–664  ·  view source on GitHub ↗

! Paint the contents of a QwtPlot instance into a given rectangle. \param plot Plot to be rendered \param painter Painter \param plotRect Bounding rectangle \sa renderDocument(), renderTo(), QwtPainter::setRoundingAlignment() */

Source from the content-addressed store, hash-verified

480 \sa renderDocument(), renderTo(), QwtPainter::setRoundingAlignment()
481 */
482void QwtPlotRenderer::render( QwtPlot* plot,
483 QPainter* painter, const QRectF& plotRect ) const
484{
485 if ( painter == 0 || !painter->isActive() ||
486 !plotRect.isValid() || plot->size().isNull() )
487 {
488 return;
489 }
490
491 if ( !( m_data->discardFlags & DiscardBackground ) )
492 QwtPainter::drawBackgound( painter, plotRect, plot );
493
494 /*
495 The layout engine uses the same methods as they are used
496 by the Qt layout system. Therefore we need to calculate the
497 layout in screen coordinates and paint with a scaled painter.
498 */
499 QTransform transform;
500 transform.scale(
501 double( painter->device()->logicalDpiX() ) / plot->logicalDpiX(),
502 double( painter->device()->logicalDpiY() ) / plot->logicalDpiY() );
503
504 QRectF layoutRect = transform.inverted().mapRect( plotRect );
505
506 if ( !( m_data->discardFlags & DiscardBackground ) )
507 {
508 // subtract the contents margins
509
510 const QMargins m = plot->contentsMargins();
511 layoutRect.adjust( m.left(), m.top(), -m.right(), -m.bottom() );
512 }
513
514 QwtPlotLayout* layout = plot->plotLayout();
515
516 int baseLineDists[QwtAxis::AxisPositions];
517 int canvasMargins[QwtAxis::AxisPositions];
518
519 for ( int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ )
520 {
521 canvasMargins[axisPos] = layout->canvasMargin( axisPos );
522
523 if ( m_data->layoutFlags & FrameWithScales )
524 {
525 const QwtAxisId axisId( axisPos );
526
527 QwtScaleWidget* scaleWidget = plot->axisWidget( axisId );
528 if ( scaleWidget )
529 {
530 baseLineDists[axisPos] = scaleWidget->margin();
531 scaleWidget->setMargin( 0 );
532 }
533
534 if ( !plot->isAxisVisible( axisId ) )
535 {
536 // When we have a scale the frame is painted on
537 // the position of the backbone - otherwise we
538 // need to introduce a margin around the canvas
539

Callers

nothing calls this directly

Calls 15

qwtScalePenWidthFunction · 0.85
isActiveMethod · 0.80
axisWidgetMethod · 0.80
canvasRectMethod · 0.80
titleRectMethod · 0.80
footerLabelMethod · 0.80
footerRectMethod · 0.80
legendRectMethod · 0.80
isValidMethod · 0.45
isNullMethod · 0.45
sizeMethod · 0.45
invertedMethod · 0.45

Tested by

no test coverage detected