-
-
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
[Bugfix] North arrow / image should account for item rotation too. #33540
Conversation
PR might not be ready for review, haven't tested, just made it so I don't forget when I get back to work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this one!
src/core/layout/qgslayoutitemmap.cpp
Outdated
@@ -447,7 +447,7 @@ void QgsLayoutItemMap::setMapRotation( double rotation ) | |||
mMapRotation = rotation; | |||
mEvaluatedMapRotation = mMapRotation; | |||
invalidateCache(); | |||
emit mapRotationChanged( rotation ); | |||
emit mapRotationChanged( rotation + itemRotation() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mapRotationChanged signal is used quite heavily in other areas of code outside of the north arrow, so I'm reluctant to change it's current behavior here. I'd suggest instead hooking into the existing QgsLayoutItem::rotationChanged signal, i.e. by making the picture item listen out for both the mapRotationChanged AND rotationChanged signals (i.e. adding new connections to rotationChanged wherever QgsLayoutItemPicture currently uses mapRotationChanged )
Also note that you'll need to update QgsLayoutItemPicture::updateMapRotation() -- it doesn't use the rotation value from the mapRotationChanged signal in any case, so it needs to be updated to base the picture orientation on mRotationMap->mapRotation() + mRotationMap->rotation().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused as to why the value provided was useless, I saw the function and thought it was overloaded somewhere else to accept the given value and couldn't find that overloaded method. + the holiday lack of sleep doesn't help. I was debating simply changing the function at first but didn't want to alter some core component if it could be prevented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not useless, it's just not used by the north arrow code. Check the QgsLayoutItemPicture::updateMapRotation() slot, it doesn't have an argument accepting the rotation value used in the signal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nearly there!
There's also one connection missed in QgsLayoutItemPicture::finalizeRestoreFromXml() |
Co-Authored-By: Nyall Dawson <nyall.dawson@gmail.com>
Description
This is my proposal to fix #33482 .
The changes implemented are the following:
Override the rotateitem method in qgslayoutitemmap to add the rotation signal.
Change the mapRotationChanged signals by adding the rotation value of the item.
Backport for 3.10 is suggested.
Checklist
Fixes #11111
at the bottom of the commit messagescripts/prepare-commit.sh
script before each commit