Skip to content
Permalink
Browse files

Decouple QgsLayoutExporter from QgsLayout

  • Loading branch information
nyalldawson committed Dec 17, 2017
1 parent be8d1d7 commit fb712d7d65e8991bb11078c1e25961d18f564fa6
@@ -32,7 +32,6 @@ QgsLayout::QgsLayout( QgsProject *project )
, mGridSettings( this )
, mPageCollection( new QgsLayoutPageCollection( this ) )
, mUndoStack( new QgsLayoutUndoStack( this ) )
, mExporter( QgsLayoutExporter( this ) )
{
// just to make sure - this should be the default, but maybe it'll change in some future Qt version...
setBackgroundBrush( Qt::NoBrush );
@@ -112,11 +111,6 @@ QgsLayoutModel *QgsLayout::itemsModel()
return mItemsModel.get();
}

QgsLayoutExporter &QgsLayout::exporter()
{
return mExporter;
}

void QgsLayout::setName( const QString &name )
{
mName = name;
@@ -93,12 +93,6 @@ class CORE_EXPORT QgsLayout : public QGraphicsScene, public QgsExpressionContext
*/
QgsLayoutModel *itemsModel();

/**
* Returns the layout's exporter, which is used for rendering the layout and exporting
* to various formats.
*/
QgsLayoutExporter &exporter();

/**
* Returns the layout's name.
* \see setName()
@@ -608,7 +602,6 @@ class CORE_EXPORT QgsLayout : public QGraphicsScene, public QgsExpressionContext

std::unique_ptr< QgsLayoutPageCollection > mPageCollection;
std::unique_ptr< QgsLayoutUndoStack > mUndoStack;
QgsLayoutExporter mExporter;

//! List of multiframe objects
QList<QgsLayoutMultiFrame *> mMultiFrames;
@@ -217,7 +217,8 @@ bool QgsLayoutChecker::testLayout( QString &checkedReport, int page, int pixelDi
outputImage.setDotsPerMeterY( mDotsPerMeter );
drawBackground( &outputImage );
QPainter p( &outputImage );
mLayout->exporter().renderPage( &p, page );
QgsLayoutExporter exporter( mLayout );
exporter.renderPage( &p, page );
p.end();

QString renderedFilePath = QDir::tempPath() + '/' + QFileInfo( mTestName ).baseName() + "_rendered.png";
@@ -19,7 +19,7 @@

from qgis.PyQt.QtCore import QSize, QDir, QFileInfo
from qgis.PyQt.QtGui import QImage, QPainter
from qgis.core import QgsMultiRenderChecker, QgsLayout
from qgis.core import QgsMultiRenderChecker, QgsLayoutExporter


class QgsLayoutChecker(QgsMultiRenderChecker):
@@ -47,7 +47,8 @@ def testLayout(self, page=0, pixelDiff=0):
outputImage.setDotsPerMeterY(self.dots_per_meter)
QgsMultiRenderChecker.drawBackground(outputImage)
p = QPainter(outputImage)
self.layout.exporter().renderPage(p, page)
exporter = QgsLayoutExporter(self.layout)
exporter.renderPage(p, page)
p.end()

renderedFilePath = QDir.tempPath() + QDir.separator() + QFileInfo(self.test_name).baseName() + "_rendered.png"

0 comments on commit fb712d7

Please sign in to comment.
You can’t perform that action at this time.