@@ -39,12 +39,15 @@ class TestQgsComposerMap: public QObject
39
39
void grid (); // test if grid and grid annotation works
40
40
void crossGrid (); // test if grid "cross" mode works
41
41
void overviewMap (); // test if overview map frame works
42
+ void overviewMapRotated (); // test if overview map frame works with rotated overview
43
+ void overviewMapRotated2 (); // test if overview map frame works with rotated map
42
44
void overviewMapBlending (); // test if blend modes with overview map frame works
43
45
void overviewMapInvert (); // test if invert of overview map frame works
44
46
void uniqueId (); // test if map id is adapted when doing copy paste
45
47
void zebraStyle (); // test zebra map border style
46
48
void overviewMapCenter (); // test if centering of overview map frame works
47
49
void worldFileGeneration (); // test world file generation
50
+ void mapPolygonVertices (); // test mapPolygon function with no map rotation
48
51
49
52
private:
50
53
QgsComposition* mComposition ;
@@ -176,6 +179,39 @@ void TestQgsComposerMap::overviewMap()
176
179
QVERIFY ( testResult );
177
180
}
178
181
182
+ void TestQgsComposerMap::overviewMapRotated ()
183
+ {
184
+ QgsComposerMap* overviewMap = new QgsComposerMap ( mComposition , 20 , 130 , 70 , 70 );
185
+ overviewMap->setFrameEnabled ( true );
186
+ mComposition ->addComposerMap ( overviewMap );
187
+ mComposerMap ->setNewExtent ( QgsRectangle ( 785462.375 , 3341423.125 , 789262.375 , 3343323.125 ) ); // zoom in
188
+ mComposerMap ->setMapRotation ( 30 );
189
+ overviewMap->setNewExtent ( QgsRectangle ( 781662.375 , 3339523.125 , 793062.375 , 3350923.125 ) );
190
+ overviewMap->setOverviewFrameMap ( mComposerMap ->id () );
191
+ QgsCompositionChecker checker ( " composermap_overview_rotated" , mComposition );
192
+
193
+ bool testResult = checker.testComposition ( mReport , 0 , 100 );
194
+ mComposition ->removeComposerItem ( overviewMap );
195
+ mComposerMap ->setMapRotation ( 0 );
196
+ QVERIFY ( testResult );
197
+ }
198
+
199
+ void TestQgsComposerMap::overviewMapRotated2 ()
200
+ {
201
+ QgsComposerMap* overviewMap = new QgsComposerMap ( mComposition , 20 , 130 , 70 , 70 );
202
+ overviewMap->setFrameEnabled ( true );
203
+ mComposition ->addComposerMap ( overviewMap );
204
+ mComposerMap ->setNewExtent ( QgsRectangle ( 785462.375 , 3341423.125 , 789262.375 , 3343323.125 ) ); // zoom in
205
+ overviewMap->setMapRotation ( 30 );
206
+ overviewMap->setNewExtent ( QgsRectangle ( 781662.375 , 3339523.125 , 793062.375 , 3350923.125 ) );
207
+ overviewMap->setOverviewFrameMap ( mComposerMap ->id () );
208
+ QgsCompositionChecker checker ( " composermap_overview_rotated2" , mComposition );
209
+
210
+ bool testResult = checker.testComposition ( mReport , 0 , 100 );
211
+ mComposition ->removeComposerItem ( overviewMap );
212
+ QVERIFY ( testResult );
213
+ }
214
+
179
215
void TestQgsComposerMap::overviewMapBlending ()
180
216
{
181
217
QgsComposerMap* overviewMapBlend = new QgsComposerMap ( mComposition , 20 , 130 , 70 , 70 );
@@ -292,6 +328,43 @@ void TestQgsComposerMap::worldFileGeneration()
292
328
QVERIFY ( fabs ( d - 2.4136 ) < 0.001 );
293
329
QVERIFY ( fabs ( e + 4.17997 ) < 0.001 );
294
330
QVERIFY ( fabs ( f - 3.34241e+06 ) < 1e+03 );
331
+
332
+ mComposition ->setGenerateWorldFile ( false );
333
+ mComposerMap ->setMapRotation ( 0.0 );
334
+
335
+ }
336
+
337
+ void TestQgsComposerMap::mapPolygonVertices ()
338
+ {
339
+ mComposerMap ->setNewExtent ( QgsRectangle ( 781662.375 , 3339523.125 , 793062.375 , 3345223.125 ) );
340
+ QPolygonF visibleExtent = mComposerMap ->visibleExtentPolygon ();
341
+
342
+ // vertices should be returned in clockwise order starting at the top-left point
343
+ QVERIFY ( fabs ( visibleExtent[0 ].x () - 781662.375 ) < 0.001 );
344
+ QVERIFY ( fabs ( visibleExtent[0 ].y () - 3345223.125 ) < 0.001 );
345
+ QVERIFY ( fabs ( visibleExtent[1 ].x () - 793062.375 ) < 0.001 );
346
+ QVERIFY ( fabs ( visibleExtent[1 ].y () - 3345223.125 ) < 0.001 );
347
+ QVERIFY ( fabs ( visibleExtent[2 ].x () - 793062.375 ) < 0.001 );
348
+ QVERIFY ( fabs ( visibleExtent[2 ].y () - 3339523.125 ) < 0.001 );
349
+ QVERIFY ( fabs ( visibleExtent[3 ].x () - 781662.375 ) < 0.001 );
350
+ QVERIFY ( fabs ( visibleExtent[3 ].y () - 3339523.125 ) < 0.001 );
351
+
352
+ // now test with rotated map
353
+ mComposerMap ->setMapRotation ( 10 );
354
+ visibleExtent = mComposerMap ->visibleExtentPolygon ();
355
+
356
+ // vertices should be returned in clockwise order starting at the top-left point
357
+ QVERIFY ( fabs ( visibleExtent[0 ].x () - 781254.0735015 ) < 0.001 );
358
+ QVERIFY ( fabs ( visibleExtent[0 ].y () - 3344190.0324834 ) < 0.001 );
359
+ QVERIFY ( fabs ( visibleExtent[1 ].x () - 792480.881886 ) < 0.001 );
360
+ QVERIFY ( fabs ( visibleExtent[1 ].y () - 3346169.62171 ) < 0.001 );
361
+ QVERIFY ( fabs ( visibleExtent[2 ].x () - 793470.676499 ) < 0.001 );
362
+ QVERIFY ( fabs ( visibleExtent[2 ].y () - 3340556.21752 ) < 0.001 );
363
+ QVERIFY ( fabs ( visibleExtent[3 ].x () - 782243.868114 ) < 0.001 );
364
+ QVERIFY ( fabs ( visibleExtent[3 ].y () - 3338576.62829 ) < 0.001 );
365
+
366
+ mComposerMap ->setMapRotation ( 0 );
367
+
295
368
}
296
369
297
370
QTEST_MAIN ( TestQgsComposerMap )
0 commit comments