mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 23:16:00 -06:00
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:
parent
65f4a5e089
commit
27788b1abd
@ -40,7 +40,6 @@
|
||||
#include <QFileInfo>
|
||||
#include <QMdiSubWindow>
|
||||
#include <QPageLayout>
|
||||
#include <QPainter>
|
||||
#include <QPdfWriter>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicSnapshotViewToFileFeature, "RicSnapshotViewToFileFeature" );
|
||||
@ -90,12 +89,11 @@ void RicSnapshotViewToFileFeature::savePlotPDFReportAs( const QString& fileName,
|
||||
pdfPrinter.setPageLayout( plot->pageLayout() );
|
||||
pdfPrinter.setCreator( QCoreApplication::applicationName() );
|
||||
pdfPrinter.setResolution( resolution );
|
||||
QPainter painter( &pdfPrinter );
|
||||
QRect widgetRect = plot->viewWidget()->contentsRect();
|
||||
QRect fullPageRect = pdfPrinter.pageLayout().fullRectPixels( resolution );
|
||||
QRect paintRect = pdfPrinter.pageLayout().paintRectPixels( resolution );
|
||||
QRect widgetRect = plot->viewWidget()->contentsRect();
|
||||
QRect fullPageRect = pdfPrinter.pageLayout().fullRectPixels( resolution );
|
||||
QRect paintRect = pdfPrinter.pageLayout().paintRectPixels( resolution );
|
||||
plot->viewWidget()->resize( paintRect.size() );
|
||||
plot->renderWindowContent( &painter );
|
||||
plot->renderWindowContent( &pdfPrinter );
|
||||
plot->viewWidget()->resize( widgetRect.size() );
|
||||
}
|
||||
else
|
||||
|
@ -304,11 +304,11 @@ void RimMultiPlotWindow::doSetAutoScaleYEnabled( bool enabled )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimMultiPlotWindow::doRenderWindowContent( QPainter* painter )
|
||||
void RimMultiPlotWindow::doRenderWindowContent( QPaintDevice* paintDevice )
|
||||
{
|
||||
if ( m_viewer )
|
||||
{
|
||||
m_viewer->renderTo( painter );
|
||||
m_viewer->renderTo( paintDevice );
|
||||
}
|
||||
}
|
||||
|
||||
@ -439,9 +439,8 @@ QImage RimMultiPlotWindow::snapshotWindowContent()
|
||||
|
||||
if ( m_viewer )
|
||||
{
|
||||
QPixmap pix( m_viewer->size() );
|
||||
QPainter painter( &pix );
|
||||
m_viewer->renderTo( &painter );
|
||||
QPixmap pix( m_viewer->size() );
|
||||
m_viewer->renderTo( &pix );
|
||||
image = pix.toImage();
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ private:
|
||||
virtual void updateSubPlotNames();
|
||||
virtual void updatePlotWindowTitle();
|
||||
virtual void doSetAutoScaleYEnabled( bool enabled );
|
||||
void doRenderWindowContent( QPainter* painter ) override;
|
||||
void doRenderWindowContent( QPaintDevice* paintDevice ) override;
|
||||
|
||||
protected:
|
||||
caf::PdmField<bool> m_showPlotWindowTitle;
|
||||
|
@ -127,10 +127,10 @@ void RimPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const Q
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPlot::doRenderWindowContent( QPainter* painter )
|
||||
void RimPlot::doRenderWindowContent( QPaintDevice* paintDevice )
|
||||
{
|
||||
if ( viewer() )
|
||||
{
|
||||
viewer()->renderTo( painter, viewer()->frameGeometry() );
|
||||
viewer()->renderTo( paintDevice, viewer()->frameGeometry() );
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,8 @@ class RiuQwtPlotWidget;
|
||||
class RimPlotCurve;
|
||||
class QwtPlotCurve;
|
||||
|
||||
class QPaintDevice;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
@ -93,7 +95,7 @@ protected:
|
||||
|
||||
private:
|
||||
virtual void doRemoveFromCollection() = 0;
|
||||
virtual void doRenderWindowContent( QPainter* painter );
|
||||
virtual void doRenderWindowContent( QPaintDevice* paintDevice );
|
||||
|
||||
protected:
|
||||
caf::PdmField<RowOrColSpanEnum> m_rowSpan;
|
||||
|
@ -159,9 +159,9 @@ void RimPlotWindow::updateParentLayout()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPlotWindow::renderWindowContent( QPainter* painter )
|
||||
void RimPlotWindow::renderWindowContent( QPaintDevice* paintDevice )
|
||||
{
|
||||
doRenderWindowContent( painter );
|
||||
doRenderWindowContent( paintDevice );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -30,6 +30,7 @@ class RimProject;
|
||||
|
||||
class QwtPlotCurve;
|
||||
class QKeyEvent;
|
||||
class QPaintDevice;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -59,7 +60,7 @@ public:
|
||||
void updateLayout();
|
||||
void updateParentLayout();
|
||||
|
||||
void renderWindowContent( QPainter* painter );
|
||||
void renderWindowContent( QPaintDevice* painter );
|
||||
QPageLayout pageLayout() const;
|
||||
|
||||
protected:
|
||||
@ -75,7 +76,7 @@ protected:
|
||||
private:
|
||||
virtual void doUpdateLayout() {}
|
||||
virtual bool hasCustomPageLayout( QPageLayout* customPageLayout ) const;
|
||||
virtual void doRenderWindowContent( QPainter* painter ) = 0;
|
||||
virtual void doRenderWindowContent( QPaintDevice* paintDevice ) = 0;
|
||||
|
||||
private:
|
||||
friend class RimProject;
|
||||
|
@ -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 );
|
||||
|
@ -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();
|
||||
|
@ -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 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -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:
|
||||
|
@ -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 );
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ protected:
|
||||
|
||||
void reinsertScrollbar();
|
||||
void alignScrollbar( int offset );
|
||||
void doRenderTo( QPainter* painter ) override;
|
||||
void doRenderTo( QPaintDevice* paintDevice ) override;
|
||||
|
||||
private:
|
||||
RimWellLogPlot* wellLogPlotDefinition();
|
||||
|
Loading…
Reference in New Issue
Block a user