Skip to content
Permalink
Browse files

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

(cherry picked from commit 9e1cdda)
  • Loading branch information
nyalldawson committed Jul 29, 2020
1 parent af2e51d commit cbfdf3bc9b2bbaf1c32dc9fc50d6cb29acbc754e
@@ -345,6 +345,7 @@ Gets color that is used for drawing of selected vector features
RenderPartialOutput,
RenderPreviewJob,
RenderBlocking,
Render3DMap,
// TODO: ignore scale-based visibility (overview)
};
typedef QFlags<QgsMapSettings::Flag> Flags;
@@ -44,6 +44,7 @@ to be rendered etc.
RenderPreviewJob,
RenderBlocking,
RenderSymbolPreview,
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() );

@@ -311,6 +311,7 @@ class CORE_EXPORT QgsMapSettings : public QgsTemporalRangeObject
RenderPartialOutput = 0x200, //!< Whether to make extra effort to update map image with partially rendered layers (better for interactive map canvas). Added in QGIS 3.0
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.
Render3DMap = 0x2000, //!< Render is for a 3D map
// TODO: ignore scale-based visibility (overview)
};
Q_DECLARE_FLAGS( Flags, Flag )
@@ -188,6 +188,7 @@ QgsRenderContext QgsRenderContext::fromMapSettings( const QgsMapSettings &mapSet
ctx.setFlag( RenderPartialOutput, mapSettings.testFlag( QgsMapSettings::RenderPartialOutput ) );
ctx.setFlag( RenderPreviewJob, mapSettings.testFlag( QgsMapSettings::RenderPreviewJob ) );
ctx.setFlag( RenderBlocking, mapSettings.testFlag( QgsMapSettings::RenderBlocking ) );
ctx.setFlag( Render3DMap, mapSettings.testFlag( QgsMapSettings::Render3DMap ) );
ctx.setScaleFactor( mapSettings.outputDpi() / 25.4 ); // = pixels per mm
ctx.setRendererScale( mapSettings.scale() );
ctx.setExpressionContext( mapSettings.expressionContext() );
@@ -80,6 +80,7 @@ class CORE_EXPORT QgsRenderContext : public QgsTemporalRangeObject
RenderPreviewJob = 0x200, //!< Render is a 'canvas preview' render, and shortcuts should be taken to ensure fast rendering
RenderBlocking = 0x400, //!< 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.
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.
Render3DMap = 0x4000, //!< Render is for a 3D map
};
Q_DECLARE_FLAGS( Flags, Flag )

@@ -116,10 +116,14 @@ def testFromMapSettings(self):
ms.setOutputSize(QSize(1000, 1000))
ms.setDestinationCrs(QgsCoordinateReferenceSystem('EPSG:3111'))
ms.setExtent(QgsRectangle(10000, 20000, 30000, 40000))
ms.setFlag(QgsMapSettings.Antialiasing, 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.Render3DMap))

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

0 comments on commit cbfdf3b

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