Change from QPainter to QPaintDevice in the API for PDF rendering

* This is to be able to use QPagedPaintDevice::nextPage in the Multi plot rendering.
This commit is contained in:
Gaute Lindkvist
2019-12-19 10:34:23 +01:00
parent 65f4a5e089
commit 27788b1abd
13 changed files with 46 additions and 33 deletions

View File

@@ -284,9 +284,9 @@ void RiuMultiPlotWindow::scheduleReplotOfAllPlots()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::renderTo( QPainter* painter )
void RiuMultiPlotWindow::renderTo( QPaintDevice* paintDevice )
{
doRenderTo( painter );
doRenderTo( paintDevice );
}
//--------------------------------------------------------------------------------------------------
@@ -789,22 +789,23 @@ std::pair<int, int>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotWindow::doRenderTo( QPainter* painter )
void RiuMultiPlotWindow::doRenderTo( QPaintDevice* paintDevice )
{
QPainter painter( paintDevice );
setSelectionsVisible( false );
m_plotTitle->render( painter );
m_plotTitle->render( &painter );
for ( auto subTitle : subTitlesForVisiblePlots() )
{
if ( subTitle->isVisible() )
{
subTitle->render( painter, m_plotWidgetFrame->mapToParent( subTitle->frameGeometry().topLeft() ) );
subTitle->render( &painter, m_plotWidgetFrame->mapToParent( subTitle->frameGeometry().topLeft() ) );
}
}
for ( auto legend : legendsForVisiblePlots() )
{
legend->render( painter, m_plotWidgetFrame->mapToParent( legend->frameGeometry().topLeft() ) );
legend->render( &painter, m_plotWidgetFrame->mapToParent( legend->frameGeometry().topLeft() ) );
}
for ( auto plotWidget : visiblePlotWidgets() )
@@ -814,7 +815,7 @@ void RiuMultiPlotWindow::doRenderTo( QPainter* painter )
QPoint plotWidgetFrameTopLeft = m_plotWidgetFrame->frameGeometry().topLeft();
plotWidgetGeometry.moveTo( plotWidgetTopLeft + plotWidgetFrameTopLeft );
plotWidget->renderTo( painter, plotWidgetGeometry );
plotWidget->renderTo( &painter, plotWidgetGeometry );
}
setSelectionsVisible( true );

View File

@@ -81,7 +81,7 @@ public:
void scheduleReplotOfAllPlots();
virtual void updateVerticalScrollBar( double visibleMin, double visibleMax, double totalMin, double totalMax ) {}
void renderTo( QPainter* painter );
void renderTo( QPaintDevice* paintDevice );
protected:
void contextMenuEvent( QContextMenuEvent* ) override;
@@ -114,7 +114,7 @@ protected:
std::pair<int, int> findAvailableRowAndColumn( int startRow, int startColumn, int columnSpan, int columnCount ) const;
virtual void doRenderTo( QPainter* painter );
virtual void doRenderTo( QPaintDevice* paintDevice );
private slots:
virtual void performUpdate();

View File

@@ -606,7 +606,7 @@ bool RiuQwtPlotWidget::isZoomerActive() const
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::endZoomOperations() {}
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::renderTo( QPainter* painter, const QRect& targetRect )
@@ -639,6 +639,15 @@ void RiuQwtPlotWidget::renderTo( QPainter* painter, const QRect& targetRect )
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::renderTo( QPaintDevice* paintDevice, const QRect& targetRect )
{
QPainter painter( paintDevice );
renderTo( &painter, targetRect );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -43,6 +43,8 @@ class QwtPlotPicker;
class QEvent;
class QLabel;
class QPainter;
class QPaintDevice;
//==================================================================================================
//
@@ -103,7 +105,8 @@ public:
void removeOverlayFrame( RiuDraggableOverlayFrame* overlayWidget );
void updateLayout() override;
void renderTo( QPainter* painter, const QRect& targetRect );
void renderTo( QPainter* painter, const QRect& targetRect );
void renderTo( QPaintDevice* painter, const QRect& targetRect );
int overlayMargins() const;
protected:

View File

@@ -40,10 +40,10 @@ RimWellLogPlot* RiuWellLogPlot::wellLogPlotDefinition()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellLogPlot::doRenderTo( QPainter* painter )
void RiuWellLogPlot::doRenderTo( QPaintDevice* paintDevice )
{
m_trackScrollBar->setVisible( false );
RiuMultiPlotWindow::doRenderTo( painter );
RiuMultiPlotWindow::doRenderTo( paintDevice );
m_trackScrollBar->setVisible( true );
}

View File

@@ -37,7 +37,7 @@ protected:
void reinsertScrollbar();
void alignScrollbar( int offset );
void doRenderTo( QPainter* painter ) override;
void doRenderTo( QPaintDevice* paintDevice ) override;
private:
RimWellLogPlot* wellLogPlotDefinition();