-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RasterLayer: Properly handle GUI updates when multiple canvas are displayed #59444
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ptitjano
added
the
Bug
Either a bug report, or a bug fix. Let's hope for the latter!
label
Nov 14, 2024
ptitjano
added
the
Rasters
Related to general raster layer handling (not specific data formats)
label
Nov 14, 2024
ptitjano
force-pushed
the
canvas-min-max
branch
3 times, most recently
from
November 14, 2024 12:11
26595b2
to
7b17df6
Compare
🪟 Windows buildsDownload Windows builds of this PR for testing. 🪟 Windows Qt6 buildsDownload Windows Qt6 builds of this PR for testing. |
ptitjano
force-pushed
the
canvas-min-max
branch
2 times, most recently
from
November 15, 2024 16:34
61f86be
to
33998d8
Compare
nyalldawson
reviewed
Nov 18, 2024
Good approach, I like where this is going! 👍 |
ptitjano
force-pushed
the
canvas-min-max
branch
2 times, most recently
from
November 21, 2024 17:10
db19524
to
abf6011
Compare
@nyalldawson This should be ready now. |
ptitjano
force-pushed
the
canvas-min-max
branch
4 times, most recently
from
November 22, 2024 08:34
3060e67
to
a6a76a1
Compare
nyalldawson
reviewed
Nov 25, 2024
Much cleaner, this is great! 💯 |
Looks good 👍 This approach will be useful for MeshLayer as well. |
This will be used in the next commits to store the min-max values of a raster layer and report them to the main canvas.
This is similar to what is achieved in `QgsRasterLayer::refreshRendererIfNeeded()` to check if the renderer needs to be refresh according to an extent. It does not perform any refresh. It is not used at the moment. This will replace the logic to refresh a renderer in the following commits.
This is similar to what is achieved in `QgsRasterLayer::refreshRenderer()` to refresh the renderer according to an extent. Contrary to the first one, this method does not perform any GUI update or emit any signal. It is not used at the moment. This will replace the logic to refresh a renderer in the following commits.
This will be used in the next commit to refresh a renderer.
This replaces the existing logic in `QgsRasterLayerRenderer` which calls `QgsRasterLayer::refreshRendererIfNeeded()` to refresh the renderer associated `QgsRasterLayerRenderer` and the raster associated with `QgsRasterLayer`. It also makes GUI updates. With this approach, the following new logic is done: 1. `QgsRasterRenderer::needsRefresh()` is called to check if `rasterRenderer` needs to be updated. 2. If a refresh is needed, the new min/max values are computed by calling `QgsRasterLayer::computeMinMax()` 3. The min/max values are used to refresh `rasterRenderer` 4. The min/max values are stored in a `QgsRenderedLayerStatistics` and propagated to `QgisApp` 5. In QgisApp, `QgsRenderedLayerStatistics` is used to refresh the renderer of `QgsRasterLayer` and force a refresh of the style and the legend if the change comes from the main canvas.
This is not used anymore.
ptitjano
force-pushed
the
canvas-min-max
branch
from
November 27, 2024 09:57
a6a76a1
to
d569eaf
Compare
nyalldawson
approved these changes
Nov 28, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This fixes an issue mentioned by @nyalldawson in qgis/QGIS-Enhancement-Proposals#273
This occurs when the Min/Max settings is set in the renderer and multiple canvas are displayed. Indeed, in that case
QgsRasterLayer
updates the GUI (the renderer widget and the legend) multiple times when the rendered values are updated because each canvas causes a renderer update.This issue is fixed by removing the GUI update from the raster layer code. With this change, when the rendered values are updated, these statistics (min-max) are propagated to the canvas by the use of a
QgsRenderedItemDetails
:QgsRenderedCalculatedResults
. Then, only the main canvas is notified of this change and updates the GUI accordingly.