Skip to content

Commit

Permalink
Add SIP and Python unit test for overview autocentering.
Browse files Browse the repository at this point in the history
Work funded by Tuscany Region - SITA. Contract "Support to the use
of GFOSS (Geographic Free and Open Source Software) Desktop tools"
(CIG Z3B06FA6D7).
  • Loading branch information
Hugo Mercier committed Jun 17, 2013
1 parent 9d20a69 commit f0f72ca
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
7 changes: 6 additions & 1 deletion python/core/composer/qgscomposermap.sip
Expand Up @@ -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*/
Expand Down
26 changes: 26 additions & 0 deletions tests/src/python/test_qgscomposermap.py
Expand Up @@ -181,6 +181,32 @@ def testOverviewMapInvert(self):
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):
Expand Down

0 comments on commit f0f72ca

Please sign in to comment.