Skip to content

Commit

Permalink
North arrow / image should account for item rotation too
Browse files Browse the repository at this point in the history
Fixes #33540
  • Loading branch information
roya0045 authored and nyalldawson committed Dec 31, 2019
1 parent 5b7decb commit 1bf7e72
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/core/layout/qgslayoutitemmap.cpp
Expand Up @@ -2526,3 +2526,4 @@ void QgsLayoutItemMap::createStagedRenderJob( const QgsRectangle &extent, const
mStagedRendererJob->start();
}


7 changes: 5 additions & 2 deletions src/core/layout/qgslayoutitempicture.cpp
Expand Up @@ -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 );
}
}
Expand All @@ -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 )
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 );
}
}
Expand Down

0 comments on commit 1bf7e72

Please sign in to comment.