diff --git a/python/core/composer/qgscomposermap.sip b/python/core/composer/qgscomposermap.sip index b646d22e604..a81bf600be5 100644 --- a/python/core/composer/qgscomposermap.sip +++ b/python/core/composer/qgscomposermap.sip @@ -300,7 +300,12 @@ class QgsComposerMap : QgsComposerItem /**Sets flag if overview frame should be inverted @note this function was added in version 1.9*/ void setOverviewInverted( bool inverted ); - bool overviewInverted() const; + bool overviewInverted() const; + + /** Returns true if the extent is forced to center on the overview when the overview is outside the extent */ + bool overviewCentered() const; + /** Set the overview's centering mode */ + void setOverviewCentered( bool centered ); /**Sets mId to a number not yet used in the composition. mId is kept if it is not in use. Usually, this function is called before adding the composer map to the composition*/ diff --git a/tests/src/python/test_qgscomposermap.py b/tests/src/python/test_qgscomposermap.py index 72c1895e6b4..4fe23712028 100644 --- a/tests/src/python/test_qgscomposermap.py +++ b/tests/src/python/test_qgscomposermap.py @@ -181,6 +181,32 @@ class TestQgsComposerMap(TestCase): self.mComposition.removeComposerItem(overviewMap) assert myTestResult == True, myMessage + def testOverviewMapCenter(self): + overviewMap = QgsComposerMap(self.mComposition, 20, 130, 70, 70) + overviewMap.setFrameEnabled(True) + self.mComposition.addComposerMap(overviewMap) + # zoom in + myRectangle = QgsRectangle(785462.375+5000, 3341423.125, + 789262.375+5000, 3343323.125) + self.mComposerMap.setNewExtent(myRectangle) + myRectangle2 = QgsRectangle(781662.375, 3339523.125, + 793062.375, 3350923.125) + overviewMap.setNewExtent(myRectangle2) + overviewMap.setOverviewFrameMap(self.mComposerMap.id()) + overviewMap.setOverviewInverted(False) + overviewMap.setOverviewCentered(True) + checker = QgsCompositionChecker() + myPngPath = os.path.join(TEST_DATA_DIR, + 'control_images', + 'expected_composermap', + 'composermap_landsat_overview_center.png') + myTestResult, myMessage = checker.testComposition( + 'Composer map overview centered', + self.mComposition, + myPngPath) + self.mComposition.removeComposerItem(overviewMap) + assert myTestResult == True, myMessage + # Fails because addItemsFromXML has been commented out in sip @expectedFailure def testuniqueId(self):