From 1bf7e7213299aa7068a62ecd02f512f9119b4fab Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 30 Dec 2019 21:11:41 -0500 Subject: [PATCH] North arrow / image should account for item rotation too Fixes #33540 --- src/core/layout/qgslayoutitemmap.cpp | 1 + src/core/layout/qgslayoutitempicture.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/layout/qgslayoutitemmap.cpp b/src/core/layout/qgslayoutitemmap.cpp index 563b2e142735..a93b69e02c2b 100644 --- a/src/core/layout/qgslayoutitemmap.cpp +++ b/src/core/layout/qgslayoutitemmap.cpp @@ -2526,3 +2526,4 @@ void QgsLayoutItemMap::createStagedRenderJob( const QgsRectangle &extent, const mStagedRendererJob->start(); } + diff --git a/src/core/layout/qgslayoutitempicture.cpp b/src/core/layout/qgslayoutitempicture.cpp index f18eb7a26c45..182a8d3a814a 100644 --- a/src/core/layout/qgslayoutitempicture.cpp +++ b/src/core/layout/qgslayoutitempicture.cpp @@ -444,6 +444,7 @@ void QgsLayoutItemPicture::disconnectMap( QgsLayoutItemMap *map ) if ( map ) { disconnect( map, &QgsLayoutItemMap::mapRotationChanged, this, &QgsLayoutItemPicture::updateMapRotation ); + disconnect( map, &QgsLayoutItemMap::rotationChanged, this, &QgsLayoutItemPicture::updateMapRotation ); disconnect( map, &QgsLayoutItemMap::extentChanged, this, &QgsLayoutItemPicture::updateMapRotation ); } } @@ -454,7 +455,7 @@ void QgsLayoutItemPicture::updateMapRotation() return; // take map rotation - double rotation = mRotationMap->mapRotation(); + double rotation = mRotationMap->mapRotation() + mRotationMap->rotation(); // handle true north switch ( mNorthMode ) @@ -483,7 +484,7 @@ void QgsLayoutItemPicture::updateMapRotation() } rotation += mNorthOffset; - setPictureRotation( rotation ); + setPictureRotation( ( rotation > 360.0 ) ? rotation - 360.0 : rotation ); } void QgsLayoutItemPicture::loadPicture( const QVariant &data ) @@ -661,6 +662,7 @@ void QgsLayoutItemPicture::setLinkedMap( QgsLayoutItemMap *map ) { mPictureRotation = map->mapRotation(); connect( map, &QgsLayoutItemMap::mapRotationChanged, this, &QgsLayoutItemPicture::updateMapRotation ); + connect( map, &QgsLayoutItemMap::rotationChanged, this, &QgsLayoutItemPicture::updateMapRotation ); connect( map, &QgsLayoutItemMap::extentChanged, this, &QgsLayoutItemPicture::updateMapRotation ); mRotationMap = map; updateMapRotation(); @@ -867,6 +869,7 @@ void QgsLayoutItemPicture::finalizeRestoreFromXml() if ( ( mRotationMap = qobject_cast< QgsLayoutItemMap * >( mLayout->itemByUuid( mRotationMapUuid, true ) ) ) ) { connect( mRotationMap, &QgsLayoutItemMap::mapRotationChanged, this, &QgsLayoutItemPicture::updateMapRotation ); + connect( mRotationMap, &QgsLayoutItemMap::rotationChanged, this, &QgsLayoutItemPicture::updateMapRotation ); connect( mRotationMap, &QgsLayoutItemMap::extentChanged, this, &QgsLayoutItemPicture::updateMapRotation ); } }