Skip to content
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

Fix map grid decoration bottom vertical labels placement and vertical labels background placement #44968

Merged

Conversation

agiudiceandrea
Copy link
Contributor

@agiudiceandrea agiudiceandrea commented Sep 7, 2021

Description

Fixes the position of the bottom vertical label of a map grid decoration when a non zero "Distance to map frame" is set (regression introduced with #37133 since 3.14).

Fixes the vertical labels background placement of a map grid decoration.
(It seems to me the QgsTextRenderer::drawText function has an issue with a rotated background placement, but I couldn't find the cause)
Now fixed with #45425.

Fixes #44907.

This PR needs to be backported to 3.20 and 3.16 branches.

Before:
image

After:
image

Edited after #45425.

Fixes the position of the bottom vertical label of a map grid decoration when a non zero "Distance to map frame" is set
@github-actions github-actions bot added this to the 3.22.0 milestone Sep 7, 2021
@agiudiceandrea agiudiceandrea changed the title Fix map grid decoration bottom vertical label placement Fix map grid decoration bottom vertical labels placement and vertical labels background placement Sep 7, 2021
@agiudiceandrea agiudiceandrea marked this pull request as ready for review September 7, 2021 10:39
@github-actions
Copy link

The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular

    • link to any issues which this pull request fixes

    • add a description of workflows which this pull request fixes

    • add screenshots if applicable

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in a week.

@github-actions github-actions bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Sep 27, 2021
@agiudiceandrea
Copy link
Contributor Author

I think this bugfix should be merged and backported.

@github-actions github-actions bot removed the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Sep 27, 2021
@nyalldawson
Copy link
Collaborator

@agiudiceandrea

It seems to me the QgsTextRenderer::drawText function has an issue with a rotated background placement, but I couldn't find the cause

I'd rather track this down instead -- we use QgsTextRenderer a LOT in qgis now, so the underlying issue would affect other code paths...

@nyalldawson
Copy link
Collaborator

The background issue is fixed in #45425 -- can you drop that commit so we can merge the other?

@agiudiceandrea
Copy link
Contributor Author

The background issue is fixed in #45425 -- can you drop that commit so we can merge the other?

Yes, of course. Commit dropped. Thanks a lot @nyalldawson! So, does your fix makes no longer needed a similar "patch" used for map layout grid in QgsLayoutItemMapGrid::drawCoordinateAnnotation?

const QgsScopedQPainterState painterState( context.painter() );
context.painter()->translate( QPointF( xpos, ypos ) );
context.painter()->rotate( rotation );
context.painter()->translate( -anchor );
const QgsScopedRenderContextScaleToPixels scale( context );
QgsTextRenderer::drawText( QPointF( 0, 0 ), 0, QgsTextRenderer::AlignLeft, QStringList() << annotationString, context, mAnnotationFormat );

@nyalldawson
Copy link
Collaborator

Hmm... Probably. I suspect that's been in place there from before the grids were drawn using the text renderer. There's good tests coverage there -- you could try removing and see if everything passes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Grid Overlay labels in main window position problems
2 participants