Skip to content

Commit f0f72ca

Browse files
author
Hugo Mercier
committedJun 17, 2013
Add SIP and Python unit test for overview autocentering.
Work funded by Tuscany Region - SITA. Contract "Support to the use of GFOSS (Geographic Free and Open Source Software) Desktop tools" (CIG Z3B06FA6D7).
1 parent 9d20a69 commit f0f72ca

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed
 

‎python/core/composer/qgscomposermap.sip

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,12 @@ class QgsComposerMap : QgsComposerItem
300300
/**Sets flag if overview frame should be inverted
301301
@note this function was added in version 1.9*/
302302
void setOverviewInverted( bool inverted );
303-
bool overviewInverted() const;
303+
bool overviewInverted() const;
304+
305+
/** Returns true if the extent is forced to center on the overview when the overview is outside the extent */
306+
bool overviewCentered() const;
307+
/** Set the overview's centering mode */
308+
void setOverviewCentered( bool centered );
304309

305310
/**Sets mId to a number not yet used in the composition. mId is kept if it is not in use.
306311
Usually, this function is called before adding the composer map to the composition*/

‎tests/src/python/test_qgscomposermap.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,32 @@ def testOverviewMapInvert(self):
181181
self.mComposition.removeComposerItem(overviewMap)
182182
assert myTestResult == True, myMessage
183183

184+
def testOverviewMapCenter(self):
185+
overviewMap = QgsComposerMap(self.mComposition, 20, 130, 70, 70)
186+
overviewMap.setFrameEnabled(True)
187+
self.mComposition.addComposerMap(overviewMap)
188+
# zoom in
189+
myRectangle = QgsRectangle(785462.375+5000, 3341423.125,
190+
789262.375+5000, 3343323.125)
191+
self.mComposerMap.setNewExtent(myRectangle)
192+
myRectangle2 = QgsRectangle(781662.375, 3339523.125,
193+
793062.375, 3350923.125)
194+
overviewMap.setNewExtent(myRectangle2)
195+
overviewMap.setOverviewFrameMap(self.mComposerMap.id())
196+
overviewMap.setOverviewInverted(False)
197+
overviewMap.setOverviewCentered(True)
198+
checker = QgsCompositionChecker()
199+
myPngPath = os.path.join(TEST_DATA_DIR,
200+
'control_images',
201+
'expected_composermap',
202+
'composermap_landsat_overview_center.png')
203+
myTestResult, myMessage = checker.testComposition(
204+
'Composer map overview centered',
205+
self.mComposition,
206+
myPngPath)
207+
self.mComposition.removeComposerItem(overviewMap)
208+
assert myTestResult == True, myMessage
209+
184210
# Fails because addItemsFromXML has been commented out in sip
185211
@expectedFailure
186212
def testuniqueId(self):

0 commit comments

Comments
 (0)
Please sign in to comment.