Skip to content
Permalink
Browse files
Template parameter {usage} for XYZ raster and vector tiles (#46731)
  • Loading branch information
vcloarec committed Jan 13, 2022
1 parent b5237da commit 9965eccdcecf12af6f6ec4fff6ccd960475800bf
@@ -601,6 +601,24 @@ Sets whether the 2D terrain surface will be rendered in.
.. seealso:: :py:func:`terrainRenderingEnabled`

.. versionadded:: 3.22
%End

Qgis::RendererUsage rendererUsage() const;
%Docstring
Returns the renderer usage

.. seealso:: :py:func:`rendererUsage`

.. versionadded:: 3.24
%End

void setRendererUsage( Qgis::RendererUsage rendererUsage );
%Docstring
Sets the renderer usage

.. seealso:: :py:func:`rendererUsage`

.. versionadded:: 3.24
%End

signals:
@@ -1194,6 +1194,13 @@
# --
Qgis.AngularDirection.baseClass = Qgis
# monkey patching scoped based enum
Qgis.RendererUsage.View.__doc__ = "Renderer used for displaying on screen"
Qgis.RendererUsage.Export.__doc__ = "Renderer used for printing or exporting to a file"
Qgis.RendererUsage.Unknown.__doc__ = "Renderer used for unknown usage"
Qgis.RendererUsage.__doc__ = 'Usage of the renderer.\n\n.. versionadded:: 3.24\n\n' + '* ``View``: ' + Qgis.RendererUsage.View.__doc__ + '\n' + '* ``Export``: ' + Qgis.RendererUsage.Export.__doc__ + '\n' + '* ``Unknown``: ' + Qgis.RendererUsage.Unknown.__doc__
# --
Qgis.RendererUsage.baseClass = Qgis
# monkey patching scoped based enum
Qgis.HistoryProviderBackend.LocalProfile.__doc__ = "Local profile"
Qgis.HistoryProviderBackend.__doc__ = 'History provider backends.\n\n.. versionadded:: 3.24\n\n' + '* ``LocalProfile``: ' + Qgis.HistoryProviderBackend.LocalProfile.__doc__
# --
@@ -765,6 +765,13 @@ The development version
CounterClockwise,
};

enum class RendererUsage
{
View,
Export,
Unknown,
};

enum class HistoryProviderBackend
{
LocalProfile,
@@ -909,6 +909,29 @@ Sets the ``range`` of z-values which will be visible in the map.
.. seealso:: :py:func:`zRange`

.. versionadded:: 3.18
%End

Qgis::RendererUsage rendererUsage() const;
%Docstring
Returns the rendering usage

.. seealso:: :py:func:`setRendererUsage`

.. versionadded:: 3.24
%End

void setRendererUsage( Qgis::RendererUsage rendererUsage );
%Docstring
Sets the rendering usage

.. note::

This usage not alter how the map gets rendered but the intention is that data provider
knows the context of rendering and may report that to the backend.

.. seealso:: :py:func:`rendererUsage`

.. versionadded:: 3.24
%End

protected:
@@ -931,6 +954,7 @@ Sets the ``range`` of z-values which will be visible in the map.





void updateDerived();

@@ -1028,6 +1028,29 @@ during rendering.
.. seealso:: :py:func:`setImageFormat`

.. versionadded:: 3.22
%End

Qgis::RendererUsage rendererUsage() const;
%Docstring
Returns the renderer usage

.. seealso:: :py:func:`setRendererUsage`

.. versionadded:: 3.24
%End

void setRendererUsage( Qgis::RendererUsage usage );
%Docstring
Sets the renderer usage

.. note::

This usage not alter how the map gets rendered but the intention is that data provider
knows the context of rendering and may report that to the backend.

.. seealso:: :py:func:`rendererUsage`

.. versionadded:: 3.24
%End

};
@@ -80,6 +80,24 @@ Returns a list of any errors encountered while retrieving the raster block.
.. seealso:: :py:func:`appendError`

.. versionadded:: 3.8.0
%End

QgsRenderContext renderContext() const;
%Docstring
Returns the render context of the associated block reading

.. seealso:: :py:func:`setRenderContext`

.. versionadded:: 3.24.0
%End

void setRenderContext( const QgsRenderContext &renderContext );
%Docstring
Sets the render context of the associated block reading

.. seealso:: :py:func:`renderContext`

.. versionadded:: 3.24.0
%End

};
@@ -88,6 +88,7 @@ Qgs3DMapSettings::Qgs3DMapSettings( const Qgs3DMapSettings &other )
, mDebugDepthMapCorner( other.mDebugDepthMapCorner )
, mDebugDepthMapSize( other.mDebugDepthMapSize )
, mTerrainRenderingEnabled( other.mTerrainRenderingEnabled )
, mRendererUsage( other.mRendererUsage )
{
for ( QgsAbstract3DRenderer *renderer : std::as_const( other.mRenderers ) )
{
@@ -812,6 +813,16 @@ void Qgs3DMapSettings::setTerrainRenderingEnabled( bool terrainRenderingEnabled
emit terrainGeneratorChanged();
}

Qgis::RendererUsage Qgs3DMapSettings::rendererUsage() const
{
return mRendererUsage;
}

void Qgs3DMapSettings::setRendererUsage( Qgis::RendererUsage rendererUsage )
{
mRendererUsage = rendererUsage;
}

void Qgs3DMapSettings::connectChangedSignalsToSettingsChanged()
{
connect( this, &Qgs3DMapSettings::selectionColorChanged, this, &Qgs3DMapSettings::settingsChanged );
@@ -845,4 +856,3 @@ void Qgs3DMapSettings::connectChangedSignalsToSettingsChanged()
connect( this, &Qgs3DMapSettings::shadowSettingsChanged, this, &Qgs3DMapSettings::settingsChanged );
connect( this, &Qgs3DMapSettings::fpsCounterEnabledChanged, this, &Qgs3DMapSettings::settingsChanged );
}

@@ -569,6 +569,22 @@ class _3D_EXPORT Qgs3DMapSettings : public QObject, public QgsTemporalRangeObjec
*/
void setTerrainRenderingEnabled( bool terrainRenderingEnabled );

/**
* Returns the renderer usage
*
* \see rendererUsage()
* \since QGIS 3.24
*/
Qgis::RendererUsage rendererUsage() const;

/**
* Sets the renderer usage
*
* \see rendererUsage()
* \since QGIS 3.24
*/
void setRendererUsage( Qgis::RendererUsage rendererUsage );

signals:

/**
@@ -798,6 +814,8 @@ class _3D_EXPORT Qgs3DMapSettings : public QObject, public QgsTemporalRangeObjec
double mDebugDepthMapSize = 0.2;

bool mTerrainRenderingEnabled = true;

Qgis::RendererUsage mRendererUsage;
};


@@ -132,6 +132,19 @@ void QgsLayoutItem3DMap::draw( QgsLayoutItemRenderContext &context )
{
painter->drawText( r, Qt::AlignCenter, tr( "Loading" ) );
painter->restore();
if ( mSettings->rendererUsage() != Qgis::RendererUsage::View )
{
mSettings->setRendererUsage( Qgis::RendererUsage::View );
mEngine.reset(); //we need to rebuild the scene to force the render again
}
}
else
{
if ( mSettings->rendererUsage() != Qgis::RendererUsage::Export )
{
mSettings->setRendererUsage( Qgis::RendererUsage::Export );
mEngine.reset(); //we need to rebuild the scene to force the render again
}
}

QSizeF sizePixels = mLayout->renderContext().measurementConverter().convert( sizeWithUnits(), QgsUnitTypes::LayoutPixels ).toQSizeF();
@@ -159,6 +159,7 @@ QgsMapSettings QgsTerrainTextureGenerator::baseMapSettings()
mapSettings.setFlag( Qgis::MapSettingsFlag::Render3DMap );
mapSettings.setTransformContext( mMap.transformContext() );
mapSettings.setPathResolver( mMap.pathResolver() );
mapSettings.setRendererUsage( mMap.rendererUsage() );

QgsMapThemeCollection *mapThemes = mMap.mapThemeCollection();
QString mapThemeName = mMap.terrainMapTheme();
@@ -14072,6 +14072,7 @@ void QgisApp::new3DMapCanvas()
// new scenes default to a single directional light
map->setDirectionalLights( QList<QgsDirectionalLightSettings>() << QgsDirectionalLightSettings() );
map->setOutputDpi( QgsApplication::desktop()->logicalDpiX() );
map->setRendererUsage( Qgis::RendererUsage::View );

QMetaObject::Connection conn = connect( QgsProject::instance(), &QgsProject::transformContextChanged, map, [map]
{
@@ -1519,11 +1519,13 @@ QgsMapSettings QgsLayoutItemMap::mapSettings( const QgsRectangle &extent, QSizeF
//if outputting layout, we disable optimisations like layer simplification by default, UNLESS the context specifically tells us to use them
jobMapSettings.setFlag( Qgis::MapSettingsFlag::UseRenderingOptimization, mLayout->renderContext().simplifyMethod().simplifyHints() != QgsVectorSimplifyMethod::NoSimplification );
jobMapSettings.setSimplifyMethod( mLayout->renderContext().simplifyMethod() );
jobMapSettings.setRendererUsage( Qgis::RendererUsage::Export );
}
else
{
// preview render - always use optimization
jobMapSettings.setFlag( Qgis::MapSettingsFlag::UseRenderingOptimization, true );
jobMapSettings.setRendererUsage( Qgis::RendererUsage::View );
}

jobMapSettings.setExpressionContext( expressionContext );
@@ -1250,6 +1250,19 @@ class CORE_EXPORT Qgis
};
Q_ENUM( AngularDirection )

/**
* Usage of the renderer.
*
* \since QGIS 3.24
*/
enum class RendererUsage : int
{
View, //!< Renderer used for displaying on screen
Export, //!< Renderer used for printing or exporting to a file
Unknown, //!< Renderer used for unknown usage
};
Q_ENUM( RendererUsage )

/**
* History provider backends.
*
@@ -854,3 +854,13 @@ void QgsMapSettings::setZRange( const QgsDoubleRange &zRange )
{
mZRange = zRange;
}

Qgis::RendererUsage QgsMapSettings::rendererUsage() const
{
return mRendererUsage;
}

void QgsMapSettings::setRendererUsage( Qgis::RendererUsage rendererUsage )
{
mRendererUsage = rendererUsage;
}
@@ -805,6 +805,25 @@ class CORE_EXPORT QgsMapSettings : public QgsTemporalRangeObject
*/
void setZRange( const QgsDoubleRange &range );

/**
* Returns the rendering usage
*
* \see setRendererUsage()
* \since QGIS 3.24
*/
Qgis::RendererUsage rendererUsage() const;

/**
* Sets the rendering usage
*
* \note This usage not alter how the map gets rendered but the intention is that data provider
* knows the context of rendering and may report that to the backend.
*
* \see rendererUsage()
* \since QGIS 3.24
*/
void setRendererUsage( Qgis::RendererUsage rendererUsage );

protected:

double mDpi = 96.0;
@@ -864,6 +883,8 @@ class CORE_EXPORT QgsMapSettings : public QgsTemporalRangeObject

QgsVectorSimplifyMethod mSimplifyMethod;

Qgis::RendererUsage mRendererUsage = Qgis::RendererUsage::Unknown;

#ifdef QGISDEBUG
bool mHasTransformContext = false;
#endif
@@ -78,6 +78,7 @@ QgsRenderContext::QgsRenderContext( const QgsRenderContext &rh )
, mSize( rh.mSize )
, mDevicePixelRatio( rh.mDevicePixelRatio )
, mImageFormat( rh.mImageFormat )
, mRendererUsage( rh.mRendererUsage )
#ifdef QGISDEBUG
, mHasTransformContext( rh.mHasTransformContext )
#endif
@@ -123,6 +124,7 @@ QgsRenderContext &QgsRenderContext::operator=( const QgsRenderContext &rh )
mDevicePixelRatio = rh.mDevicePixelRatio;
mImageFormat = rh.mImageFormat;
setIsTemporal( rh.isTemporal() );
mRendererUsage = rh.mRendererUsage;
if ( isTemporal() )
setTemporalRange( rh.temporalRange() );
#ifdef QGISDEBUG
@@ -277,6 +279,8 @@ QgsRenderContext QgsRenderContext::fromMapSettings( const QgsMapSettings &mapSet

ctx.mClippingRegions = mapSettings.clippingRegions();

ctx.mRendererUsage = mapSettings.rendererUsage();

return ctx;
}

@@ -974,6 +974,25 @@ class CORE_EXPORT QgsRenderContext : public QgsTemporalRangeObject
*/
QImage::Format imageFormat() const { return mImageFormat; }

/**
* Returns the renderer usage
*
* \see setRendererUsage()
* \since QGIS 3.24
*/
Qgis::RendererUsage rendererUsage() const {return mRendererUsage;}

/**
* Sets the renderer usage
*
* \note This usage not alter how the map gets rendered but the intention is that data provider
* knows the context of rendering and may report that to the backend.
*
* \see rendererUsage()
* \since QGIS 3.24
*/
void setRendererUsage( Qgis::RendererUsage usage ) {mRendererUsage = usage;}

private:

Qgis::RenderContextFlags mFlags;
@@ -1087,6 +1106,8 @@ class CORE_EXPORT QgsRenderContext : public QgsTemporalRangeObject
float mDevicePixelRatio = 1.0;
QImage::Format mImageFormat = QImage::Format_ARGB32_Premultiplied;

Qgis::RendererUsage mRendererUsage = Qgis::RendererUsage::Unknown;

#ifdef QGISDEBUG
bool mHasTransformContext = false;
#endif

0 comments on commit 9965ecc

Please sign in to comment.