diff --git a/python/PyQt6/gui/auto_additions/qgsmapcanvas.py b/python/PyQt6/gui/auto_additions/qgsmapcanvas.py index 4382677658fc..64f855c325ab 100644 --- a/python/PyQt6/gui/auto_additions/qgsmapcanvas.py +++ b/python/PyQt6/gui/auto_additions/qgsmapcanvas.py @@ -1,6 +1,6 @@ # The following has been generated automatically from src/gui/qgsmapcanvas.h try: - QgsMapCanvas.__attribute_docs__ = {'xyCoordinates': 'Emits current mouse position\n\n.. note::\n\n changed in 1.3\n', 'scaleChanged': 'Emitted when the scale of the map changes\n', 'scaleLockChanged': 'Emitted when the scale locked state of the map changes\n\n:param locked: true if the scale is locked\n\n.. seealso:: :py:func:`setScaleLocked`\n\n.. versionadded:: 3.18\n', 'extentsChanged': 'Emitted when the extents of the map change\n', 'rotationChanged': 'Emitted when the rotation of the map changes\n', 'magnificationChanged': 'Emitted when the scale of the map changes\n', 'canvasColorChanged': 'Emitted when canvas background color changes\n', 'renderComplete': 'Emitted when the canvas has rendered.\nPasses a pointer to the painter on which the map was drawn. This is\nuseful for plugins that wish to draw on the map after it has been\nrendered. Passing the painter allows plugins to work when the map is\nbeing rendered onto a pixmap other than the mapCanvas own pixmap member.\n\n- anything related to rendering progress is not visible outside of map canvas\n- additional drawing shall be done directly within the renderer job or independently as a map canvas item\n', 'mapCanvasRefreshed': 'Emitted when canvas finished a refresh request.\n', 'renderStarting': 'Emitted when the canvas is about to be rendered.\n', 'mapRefreshCanceled': 'Emitted when the pending map refresh has been canceled\n\n.. versionadded:: 3.18\n', 'layersChanged': 'Emitted when a new set of layers has been received\n', 'keyPressed': 'Emit key press event\n', 'keyReleased': 'Emit key release event\n', 'mapToolSet': 'Emit map tool changed with the old tool\n', 'selectionChanged': 'Emitted when selection in any ``layer`` gets changed.\n\n.. note::\n\n Since QGIS 3.28 this signal is emitted for multiple layer types, including :py:class:`QgsVectorLayer` and :py:class:`QgsVectorTileLayer`\n', 'zoomLastStatusChanged': 'Emitted when zoom last status changed\n', 'zoomNextStatusChanged': 'Emitted when zoom next status changed\n', 'destinationCrsChanged': 'Emitted when map CRS has changed\n', 'transformContextChanged': 'Emitted when the canvas transform context is changed.\n', 'currentLayerChanged': 'Emitted when the current layer is changed\n', 'layerStyleOverridesChanged': 'Emitted when the configuration of overridden layer styles changes\n', 'themeChanged': 'Emitted when the canvas has been assigned a different map theme.\n\n.. seealso:: :py:func:`setTheme`\n', 'messageEmitted': 'emit a message (usually to be displayed in a message bar)\n', 'renderErrorOccurred': 'Emitted whenever an error is encountered during a map render operation.\n\nThe ``layer`` argument indicates the associated map layer, if available.\n\n.. versionadded:: 3.10.0\n', 'panDistanceBearingChanged': 'Emitted whenever the distance or bearing of an in-progress panning\noperation is changed.\n\nThis signal will be emitted during a pan operation as the user moves the map,\ngiving the total distance and bearing between the map position at the\nstart of the pan and the current pan position.\n\n.. versionadded:: 3.12\n', 'tapAndHoldGestureOccurred': 'Emitted whenever a tap and hold ``gesture`` occurs at the specified map point.\n\n.. versionadded:: 3.12\n', 'temporalRangeChanged': 'Emitted when the map canvas temporal range changes.\n\n.. versionadded:: 3.14\n', 'zRangeChanged': 'Emitted when the map canvas z (elevation) range changes.\n\n.. seealso:: :py:func:`zRange`\n\n.. seealso:: :py:func:`setZRange`\n\n.. versionadded:: 3.18\n', 'contextMenuAboutToShow': 'Emitted before the map canvas context menu will be shown.\nCan be used to extend the context menu.\n\n.. versionadded:: 3.16\n'} + QgsMapCanvas.__attribute_docs__ = {'xyCoordinates': 'Emits current mouse position\n\n.. note::\n\n changed in 1.3\n', 'scaleChanged': 'Emitted when the scale of the map changes\n', 'scaleLockChanged': 'Emitted when the scale locked state of the map changes\n\n:param locked: true if the scale is locked\n\n.. seealso:: :py:func:`setScaleLocked`\n\n.. versionadded:: 3.18\n', 'extentsChanged': 'Emitted when the extents of the map change\n', 'rotationChanged': 'Emitted when the rotation of the map changes\n', 'magnificationChanged': 'Emitted when the scale of the map changes\n', 'canvasColorChanged': 'Emitted when canvas background color changes\n', 'renderComplete': 'Emitted when the canvas has rendered.\nPasses a pointer to the painter on which the map was drawn. This is\nuseful for plugins that wish to draw on the map after it has been\nrendered. Passing the painter allows plugins to work when the map is\nbeing rendered onto a pixmap other than the mapCanvas own pixmap member.\n\n- anything related to rendering progress is not visible outside of map canvas\n- additional drawing shall be done directly within the renderer job or independently as a map canvas item\n', 'mapCanvasRefreshed': 'Emitted when canvas finished a refresh request.\n', 'renderStarting': 'Emitted when the canvas is about to be rendered.\n', 'mapRefreshCanceled': 'Emitted when the pending map refresh has been canceled\n\n.. versionadded:: 3.18\n', 'layersChanged': 'Emitted when a new set of layers has been received\n', 'keyPressed': 'Emit key press event\n', 'keyReleased': 'Emit key release event\n', 'mapToolSet': 'Emit map tool changed with the old tool\n', 'selectionChanged': 'Emitted when selection in any ``layer`` gets changed.\n\n.. note::\n\n Since QGIS 3.28 this signal is emitted for multiple layer types, including :py:class:`QgsVectorLayer` and :py:class:`QgsVectorTileLayer`\n', 'zoomLastStatusChanged': 'Emitted when zoom last status changed\n', 'zoomNextStatusChanged': 'Emitted when zoom next status changed\n', 'destinationCrsChanged': 'Emitted when map CRS has changed\n', 'transformContextChanged': 'Emitted when the canvas transform context is changed.\n', 'currentLayerChanged': 'Emitted when the current layer is changed\n', 'layerStyleOverridesChanged': 'Emitted when the configuration of overridden layer styles changes\n', 'themeChanged': 'Emitted when the canvas has been assigned a different map theme.\n\n.. seealso:: :py:func:`setTheme`\n', 'messageEmitted': 'emit a message (usually to be displayed in a message bar)\n', 'renderErrorOccurred': 'Emitted whenever an error is encountered during a map render operation.\n\nThe ``layer`` argument indicates the associated map layer, if available.\n\n.. versionadded:: 3.10.0\n', 'panDistanceBearingChanged': 'Emitted whenever the distance or bearing of an in-progress panning\noperation is changed.\n\nThis signal will be emitted during a pan operation as the user moves the map,\ngiving the total distance and bearing between the map position at the\nstart of the pan and the current pan position.\n\n.. versionadded:: 3.12\n', 'tapAndHoldGestureOccurred': 'Emitted whenever a tap and hold ``gesture`` occurs at the specified map point.\n\n.. versionadded:: 3.12\n', 'temporalRangeChanged': 'Emitted when the map canvas temporal range changes.\n\n.. versionadded:: 3.14\n', 'zRangeChanged': 'Emitted when the map canvas z (elevation) range changes.\n\n.. seealso:: :py:func:`zRange`\n\n.. seealso:: :py:func:`setZRange`\n\n.. versionadded:: 3.18\n', 'contextMenuAboutToShow': 'Emitted before the map canvas context menu will be shown.\nCan be used to extend the context menu.\n\n.. versionadded:: 3.16\n', 'calculatedRenderDetailsChanged': 'Emitted when the calculated render details of a raster have changed\n\n.. versionadded:: 3.42\n'} QgsMapCanvas.__signal_arguments__ = {'xyCoordinates': ['p: QgsPointXY'], 'scaleChanged': ['scale: float'], 'scaleLockChanged': ['locked: bool'], 'rotationChanged': ['rotation: float'], 'magnificationChanged': ['magnification: float'], 'renderComplete': ['painter: QPainter'], 'keyPressed': ['e: QKeyEvent'], 'keyReleased': ['e: QKeyEvent'], 'mapToolSet': ['newTool: QgsMapTool', 'oldTool: QgsMapTool'], 'selectionChanged': ['layer: QgsMapLayer'], 'zoomLastStatusChanged': ['available: bool'], 'zoomNextStatusChanged': ['available: bool'], 'currentLayerChanged': ['layer: QgsMapLayer'], 'themeChanged': ['theme: str'], 'messageEmitted': ['title: str', 'message: str', 'level: Qgis.MessageLevel = Qgis.MessageLevel.Info'], 'renderErrorOccurred': ['error: str', 'layer: QgsMapLayer'], 'panDistanceBearingChanged': ['distance: float', 'unit: Qgis.DistanceUnit', 'bearing: float'], 'tapAndHoldGestureOccurred': ['mapPoint: QgsPointXY', 'gesture: QTapAndHoldGesture'], 'contextMenuAboutToShow': ['menu: QMenu', 'event: QgsMapMouseEvent']} except NameError: pass diff --git a/python/PyQt6/gui/auto_generated/qgsmapcanvas.sip.in b/python/PyQt6/gui/auto_generated/qgsmapcanvas.sip.in index 878cce87338f..c48037f785d5 100644 --- a/python/PyQt6/gui/auto_generated/qgsmapcanvas.sip.in +++ b/python/PyQt6/gui/auto_generated/qgsmapcanvas.sip.in @@ -1260,6 +1260,13 @@ Emitted before the map canvas context menu will be shown. Can be used to extend the context menu. .. versionadded:: 3.16 +%End + + void calculatedRenderDetailsChanged(); +%Docstring +Emitted when the calculated render details of a raster have changed + +.. versionadded:: 3.42 %End protected: diff --git a/python/gui/auto_additions/qgsmapcanvas.py b/python/gui/auto_additions/qgsmapcanvas.py index 4382677658fc..64f855c325ab 100644 --- a/python/gui/auto_additions/qgsmapcanvas.py +++ b/python/gui/auto_additions/qgsmapcanvas.py @@ -1,6 +1,6 @@ # The following has been generated automatically from src/gui/qgsmapcanvas.h try: - QgsMapCanvas.__attribute_docs__ = {'xyCoordinates': 'Emits current mouse position\n\n.. note::\n\n changed in 1.3\n', 'scaleChanged': 'Emitted when the scale of the map changes\n', 'scaleLockChanged': 'Emitted when the scale locked state of the map changes\n\n:param locked: true if the scale is locked\n\n.. seealso:: :py:func:`setScaleLocked`\n\n.. versionadded:: 3.18\n', 'extentsChanged': 'Emitted when the extents of the map change\n', 'rotationChanged': 'Emitted when the rotation of the map changes\n', 'magnificationChanged': 'Emitted when the scale of the map changes\n', 'canvasColorChanged': 'Emitted when canvas background color changes\n', 'renderComplete': 'Emitted when the canvas has rendered.\nPasses a pointer to the painter on which the map was drawn. This is\nuseful for plugins that wish to draw on the map after it has been\nrendered. Passing the painter allows plugins to work when the map is\nbeing rendered onto a pixmap other than the mapCanvas own pixmap member.\n\n- anything related to rendering progress is not visible outside of map canvas\n- additional drawing shall be done directly within the renderer job or independently as a map canvas item\n', 'mapCanvasRefreshed': 'Emitted when canvas finished a refresh request.\n', 'renderStarting': 'Emitted when the canvas is about to be rendered.\n', 'mapRefreshCanceled': 'Emitted when the pending map refresh has been canceled\n\n.. versionadded:: 3.18\n', 'layersChanged': 'Emitted when a new set of layers has been received\n', 'keyPressed': 'Emit key press event\n', 'keyReleased': 'Emit key release event\n', 'mapToolSet': 'Emit map tool changed with the old tool\n', 'selectionChanged': 'Emitted when selection in any ``layer`` gets changed.\n\n.. note::\n\n Since QGIS 3.28 this signal is emitted for multiple layer types, including :py:class:`QgsVectorLayer` and :py:class:`QgsVectorTileLayer`\n', 'zoomLastStatusChanged': 'Emitted when zoom last status changed\n', 'zoomNextStatusChanged': 'Emitted when zoom next status changed\n', 'destinationCrsChanged': 'Emitted when map CRS has changed\n', 'transformContextChanged': 'Emitted when the canvas transform context is changed.\n', 'currentLayerChanged': 'Emitted when the current layer is changed\n', 'layerStyleOverridesChanged': 'Emitted when the configuration of overridden layer styles changes\n', 'themeChanged': 'Emitted when the canvas has been assigned a different map theme.\n\n.. seealso:: :py:func:`setTheme`\n', 'messageEmitted': 'emit a message (usually to be displayed in a message bar)\n', 'renderErrorOccurred': 'Emitted whenever an error is encountered during a map render operation.\n\nThe ``layer`` argument indicates the associated map layer, if available.\n\n.. versionadded:: 3.10.0\n', 'panDistanceBearingChanged': 'Emitted whenever the distance or bearing of an in-progress panning\noperation is changed.\n\nThis signal will be emitted during a pan operation as the user moves the map,\ngiving the total distance and bearing between the map position at the\nstart of the pan and the current pan position.\n\n.. versionadded:: 3.12\n', 'tapAndHoldGestureOccurred': 'Emitted whenever a tap and hold ``gesture`` occurs at the specified map point.\n\n.. versionadded:: 3.12\n', 'temporalRangeChanged': 'Emitted when the map canvas temporal range changes.\n\n.. versionadded:: 3.14\n', 'zRangeChanged': 'Emitted when the map canvas z (elevation) range changes.\n\n.. seealso:: :py:func:`zRange`\n\n.. seealso:: :py:func:`setZRange`\n\n.. versionadded:: 3.18\n', 'contextMenuAboutToShow': 'Emitted before the map canvas context menu will be shown.\nCan be used to extend the context menu.\n\n.. versionadded:: 3.16\n'} + QgsMapCanvas.__attribute_docs__ = {'xyCoordinates': 'Emits current mouse position\n\n.. note::\n\n changed in 1.3\n', 'scaleChanged': 'Emitted when the scale of the map changes\n', 'scaleLockChanged': 'Emitted when the scale locked state of the map changes\n\n:param locked: true if the scale is locked\n\n.. seealso:: :py:func:`setScaleLocked`\n\n.. versionadded:: 3.18\n', 'extentsChanged': 'Emitted when the extents of the map change\n', 'rotationChanged': 'Emitted when the rotation of the map changes\n', 'magnificationChanged': 'Emitted when the scale of the map changes\n', 'canvasColorChanged': 'Emitted when canvas background color changes\n', 'renderComplete': 'Emitted when the canvas has rendered.\nPasses a pointer to the painter on which the map was drawn. This is\nuseful for plugins that wish to draw on the map after it has been\nrendered. Passing the painter allows plugins to work when the map is\nbeing rendered onto a pixmap other than the mapCanvas own pixmap member.\n\n- anything related to rendering progress is not visible outside of map canvas\n- additional drawing shall be done directly within the renderer job or independently as a map canvas item\n', 'mapCanvasRefreshed': 'Emitted when canvas finished a refresh request.\n', 'renderStarting': 'Emitted when the canvas is about to be rendered.\n', 'mapRefreshCanceled': 'Emitted when the pending map refresh has been canceled\n\n.. versionadded:: 3.18\n', 'layersChanged': 'Emitted when a new set of layers has been received\n', 'keyPressed': 'Emit key press event\n', 'keyReleased': 'Emit key release event\n', 'mapToolSet': 'Emit map tool changed with the old tool\n', 'selectionChanged': 'Emitted when selection in any ``layer`` gets changed.\n\n.. note::\n\n Since QGIS 3.28 this signal is emitted for multiple layer types, including :py:class:`QgsVectorLayer` and :py:class:`QgsVectorTileLayer`\n', 'zoomLastStatusChanged': 'Emitted when zoom last status changed\n', 'zoomNextStatusChanged': 'Emitted when zoom next status changed\n', 'destinationCrsChanged': 'Emitted when map CRS has changed\n', 'transformContextChanged': 'Emitted when the canvas transform context is changed.\n', 'currentLayerChanged': 'Emitted when the current layer is changed\n', 'layerStyleOverridesChanged': 'Emitted when the configuration of overridden layer styles changes\n', 'themeChanged': 'Emitted when the canvas has been assigned a different map theme.\n\n.. seealso:: :py:func:`setTheme`\n', 'messageEmitted': 'emit a message (usually to be displayed in a message bar)\n', 'renderErrorOccurred': 'Emitted whenever an error is encountered during a map render operation.\n\nThe ``layer`` argument indicates the associated map layer, if available.\n\n.. versionadded:: 3.10.0\n', 'panDistanceBearingChanged': 'Emitted whenever the distance or bearing of an in-progress panning\noperation is changed.\n\nThis signal will be emitted during a pan operation as the user moves the map,\ngiving the total distance and bearing between the map position at the\nstart of the pan and the current pan position.\n\n.. versionadded:: 3.12\n', 'tapAndHoldGestureOccurred': 'Emitted whenever a tap and hold ``gesture`` occurs at the specified map point.\n\n.. versionadded:: 3.12\n', 'temporalRangeChanged': 'Emitted when the map canvas temporal range changes.\n\n.. versionadded:: 3.14\n', 'zRangeChanged': 'Emitted when the map canvas z (elevation) range changes.\n\n.. seealso:: :py:func:`zRange`\n\n.. seealso:: :py:func:`setZRange`\n\n.. versionadded:: 3.18\n', 'contextMenuAboutToShow': 'Emitted before the map canvas context menu will be shown.\nCan be used to extend the context menu.\n\n.. versionadded:: 3.16\n', 'calculatedRenderDetailsChanged': 'Emitted when the calculated render details of a raster have changed\n\n.. versionadded:: 3.42\n'} QgsMapCanvas.__signal_arguments__ = {'xyCoordinates': ['p: QgsPointXY'], 'scaleChanged': ['scale: float'], 'scaleLockChanged': ['locked: bool'], 'rotationChanged': ['rotation: float'], 'magnificationChanged': ['magnification: float'], 'renderComplete': ['painter: QPainter'], 'keyPressed': ['e: QKeyEvent'], 'keyReleased': ['e: QKeyEvent'], 'mapToolSet': ['newTool: QgsMapTool', 'oldTool: QgsMapTool'], 'selectionChanged': ['layer: QgsMapLayer'], 'zoomLastStatusChanged': ['available: bool'], 'zoomNextStatusChanged': ['available: bool'], 'currentLayerChanged': ['layer: QgsMapLayer'], 'themeChanged': ['theme: str'], 'messageEmitted': ['title: str', 'message: str', 'level: Qgis.MessageLevel = Qgis.MessageLevel.Info'], 'renderErrorOccurred': ['error: str', 'layer: QgsMapLayer'], 'panDistanceBearingChanged': ['distance: float', 'unit: Qgis.DistanceUnit', 'bearing: float'], 'tapAndHoldGestureOccurred': ['mapPoint: QgsPointXY', 'gesture: QTapAndHoldGesture'], 'contextMenuAboutToShow': ['menu: QMenu', 'event: QgsMapMouseEvent']} except NameError: pass diff --git a/python/gui/auto_generated/qgsmapcanvas.sip.in b/python/gui/auto_generated/qgsmapcanvas.sip.in index ef0f3bdf9f73..81837afb5ab7 100644 --- a/python/gui/auto_generated/qgsmapcanvas.sip.in +++ b/python/gui/auto_generated/qgsmapcanvas.sip.in @@ -1260,6 +1260,13 @@ Emitted before the map canvas context menu will be shown. Can be used to extend the context menu. .. versionadded:: 3.16 +%End + + void calculatedRenderDetailsChanged(); +%Docstring +Emitted when the calculated render details of a raster have changed + +.. versionadded:: 3.42 %End protected: diff --git a/src/gui/qgsmapcanvas.cpp b/src/gui/qgsmapcanvas.cpp index ec6cae9c714d..6f7bbf56d5f1 100644 --- a/src/gui/qgsmapcanvas.cpp +++ b/src/gui/qgsmapcanvas.cpp @@ -95,6 +95,7 @@ email : sherman at mrcc.com #include "qgsscreenhelper.h" #include "qgs2dmapcontroller.h" #include "qgsoverlaywidgetlayout.h" +#include "qgsrenderedcalculatedresults.h" /** * \ingroup gui @@ -950,6 +951,18 @@ void QgsMapCanvas::rendererJobFinished() mRenderedItemResults = std::move( renderedItemResults ); mRenderedItemResultsOutdated = false; + for ( const QgsRenderedItemDetails *details : mRenderedItemResults->renderedItems() ) + { + // if the min-max of a raster have changed - update the style and the legend + const QgsRenderedCalculatedResults *renderedDetails = dynamic_cast( details ); + QgsMapLayer *layer = renderedDetails ? QgsProject::instance()->mapLayer( renderedDetails->layerId() ) : nullptr; + if ( layer ) + { + emit calculatedRenderDetailsChanged(); + break; + } + } + QImage img = mJob->renderedImage(); // emit renderComplete to get our decorations drawn diff --git a/src/gui/qgsmapcanvas.h b/src/gui/qgsmapcanvas.h index d31cce06d9a9..4d872d175b86 100644 --- a/src/gui/qgsmapcanvas.h +++ b/src/gui/qgsmapcanvas.h @@ -1228,6 +1228,13 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView, public QgsExpressionContex */ void contextMenuAboutToShow( QMenu *menu, QgsMapMouseEvent *event ); + /** + * Emitted when the calculated render details of a raster have changed + * + * \since QGIS 3.42 + */ + void calculatedRenderDetailsChanged(); + protected: bool event( QEvent *e ) override;