Skip to content
Permalink
Browse files

Add render context flag to use when a map render job is part of a 3d map

  • Loading branch information
nyalldawson committed Jul 28, 2020
1 parent e06cefe commit 9e1cddaa8e5bec796e5cc42142acf6b4289b98a5
@@ -346,6 +346,7 @@ Gets color that is used for drawing of selected vector features
RenderPreviewJob,
RenderBlocking,
LosslessImageRendering,
Render3DMap,
// TODO: ignore scale-based visibility (overview)
};
typedef QFlags<QgsMapSettings::Flag> Flags;
@@ -46,6 +46,7 @@ to be rendered etc.
RenderSymbolPreview,
LosslessImageRendering,
ApplyScalingWorkaroundForTextRendering,
Render3DMap,
};
typedef QFlags<QgsRenderContext::Flag> Flags;

@@ -140,6 +140,7 @@ QgsMapSettings QgsTerrainTextureGenerator::baseMapSettings()
mapSettings.setDestinationCrs( mMap.crs() );
mapSettings.setBackgroundColor( mMap.backgroundColor() );
mapSettings.setFlag( QgsMapSettings::DrawLabeling, mMap.showLabels() );
mapSettings.setFlag( QgsMapSettings::Render3DMap );
mapSettings.setTransformContext( mMap.transformContext() );
mapSettings.setPathResolver( mMap.pathResolver() );

@@ -313,6 +313,7 @@ class CORE_EXPORT QgsMapSettings : public QgsTemporalRangeObject
RenderPreviewJob = 0x400, //!< Render is a 'canvas preview' render, and shortcuts should be taken to ensure fast rendering
RenderBlocking = 0x800, //!< Render and load remote sources in the same thread to ensure rendering remote sources (svg and images). WARNING: this flag must NEVER be used from GUI based applications (like the main QGIS application) or crashes will result. Only for use in external scripts or QGIS server.
LosslessImageRendering = 0x1000, //!< Render images losslessly whenever possible, instead of the default lossy jpeg rendering used for some destination devices (e.g. PDF). This flag only works with builds based on Qt 5.13 or later.
Render3DMap = 0x2000, //!< Render is for a 3D map
// TODO: ignore scale-based visibility (overview)
};
Q_DECLARE_FLAGS( Flags, Flag )
@@ -216,6 +216,7 @@ QgsRenderContext QgsRenderContext::fromMapSettings( const QgsMapSettings &mapSet
ctx.setFlag( RenderPreviewJob, mapSettings.testFlag( QgsMapSettings::RenderPreviewJob ) );
ctx.setFlag( RenderBlocking, mapSettings.testFlag( QgsMapSettings::RenderBlocking ) );
ctx.setFlag( LosslessImageRendering, mapSettings.testFlag( QgsMapSettings::LosslessImageRendering ) );
ctx.setFlag( Render3DMap, mapSettings.testFlag( QgsMapSettings::Render3DMap ) );
ctx.setScaleFactor( mapSettings.outputDpi() / 25.4 ); // = pixels per mm
ctx.setRendererScale( mapSettings.scale() );
ctx.setExpressionContext( mapSettings.expressionContext() );
@@ -83,6 +83,7 @@ class CORE_EXPORT QgsRenderContext : public QgsTemporalRangeObject
RenderSymbolPreview = 0x800, //!< The render is for a symbol preview only and map based properties may not be available, so care should be taken to handle map unit based sizes in an appropriate way.
LosslessImageRendering = 0x1000, //!< Render images losslessly whenever possible, instead of the default lossy jpeg rendering used for some destination devices (e.g. PDF). This flag only works with builds based on Qt 5.13 or later.
ApplyScalingWorkaroundForTextRendering = 0x2000, //!< Whether a scaling workaround designed to stablise the rendering of small font sizes (or for painters scaled out by a large amount) when rendering text. Generally this is recommended, but it may incur some performance cost.
Render3DMap = 0x4000, //!< Render is for a 3D map
};
Q_DECLARE_FLAGS( Flags, Flag )

@@ -128,12 +128,14 @@ def testFromMapSettings(self):
ms.setExtent(QgsRectangle(10000, 20000, 30000, 40000))
ms.setFlag(QgsMapSettings.Antialiasing, True)
ms.setFlag(QgsMapSettings.LosslessImageRendering, True)
ms.setFlag(QgsMapSettings.Render3DMap, True)

ms.setTextRenderFormat(QgsRenderContext.TextFormatAlwaysText)
rc = QgsRenderContext.fromMapSettings(ms)
self.assertEqual(rc.textRenderFormat(), QgsRenderContext.TextFormatAlwaysText)
self.assertTrue(rc.testFlag(QgsRenderContext.Antialiasing))
self.assertTrue(rc.testFlag(QgsRenderContext.LosslessImageRendering))
self.assertTrue(rc.testFlag(QgsRenderContext.Render3DMap))

ms.setTextRenderFormat(QgsRenderContext.TextFormatAlwaysOutlines)
rc = QgsRenderContext.fromMapSettings(ms)

0 comments on commit 9e1cdda

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