mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
parent
35f16f3f37
commit
7f0df70478
@ -111,7 +111,6 @@ void QgsInvertedPolygonRenderer::startRender( QgsRenderContext &context, const Q
|
||||
// We compute coordinates of the extent which will serve as exterior ring
|
||||
// for the final polygon
|
||||
// It must be computed in the destination CRS if reprojection is enabled.
|
||||
const QgsMapToPixel &mtp( context.mapToPixel() );
|
||||
|
||||
if ( !context.painter() )
|
||||
{
|
||||
@ -119,15 +118,16 @@ void QgsInvertedPolygonRenderer::startRender( QgsRenderContext &context, const Q
|
||||
}
|
||||
|
||||
// convert viewport to dest CRS
|
||||
QRect e( context.painter()->viewport() );
|
||||
// add some space to hide borders and tend to infinity
|
||||
e.adjust( -e.width() * 5, -e.height() * 5, e.width() * 5, e.height() * 5 );
|
||||
const double buffer = std::max( context.mapExtent().width(), context.mapExtent().height() ) * 0.1;
|
||||
const QRectF outer = context.mapExtent().buffered( buffer ).toRectF();
|
||||
QgsPolylineXY exteriorRing;
|
||||
exteriorRing << mtp.toMapCoordinates( e.topLeft() );
|
||||
exteriorRing << mtp.toMapCoordinates( e.topRight() );
|
||||
exteriorRing << mtp.toMapCoordinates( e.bottomRight() );
|
||||
exteriorRing << mtp.toMapCoordinates( e.bottomLeft() );
|
||||
exteriorRing << mtp.toMapCoordinates( e.topLeft() );
|
||||
exteriorRing.reserve( 5 );
|
||||
exteriorRing << outer.topLeft();
|
||||
exteriorRing << outer.topRight();
|
||||
exteriorRing << outer.bottomRight();
|
||||
exteriorRing << outer.bottomLeft();
|
||||
exteriorRing << outer.topLeft();
|
||||
|
||||
// copy the rendering context
|
||||
mContext = context;
|
||||
@ -142,8 +142,7 @@ void QgsInvertedPolygonRenderer::startRender( QgsRenderContext &context, const Q
|
||||
// disable projection
|
||||
mContext.setCoordinateTransform( QgsCoordinateTransform() );
|
||||
// recompute extent so that polygon clipping is correct
|
||||
QRect v( context.painter()->viewport() );
|
||||
mContext.setExtent( QgsRectangle( mtp.toMapCoordinates( v.topLeft() ), mtp.toMapCoordinates( v.bottomRight() ) ) );
|
||||
mContext.setExtent( context.mapExtent() );
|
||||
// do we have to recompute the MapToPixel ?
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,7 @@ class TestQgsInvertedPolygon : public QObject
|
||||
void preprocess();
|
||||
void projectionTest();
|
||||
void curvedPolygons();
|
||||
void rotationTest();
|
||||
|
||||
private:
|
||||
bool mTestHasError = false ;
|
||||
@ -154,7 +155,6 @@ void TestQgsInvertedPolygon::projectionTest()
|
||||
mMapSettings.setDestinationCrs( mpPolysLayer->crs() );
|
||||
}
|
||||
|
||||
// This test relies on GDAL support of curved polygons
|
||||
void TestQgsInvertedPolygon::curvedPolygons()
|
||||
{
|
||||
QString myCurvedPolysFileName = mTestDataDir + "curved_polys.gpkg";
|
||||
@ -170,6 +170,16 @@ void TestQgsInvertedPolygon::curvedPolygons()
|
||||
mMapSettings.setLayers( QList< QgsMapLayer * >() << mpPolysLayer );
|
||||
}
|
||||
|
||||
void TestQgsInvertedPolygon::rotationTest()
|
||||
{
|
||||
mReport += QLatin1String( "<h2>Inverted polygon renderer, rotation test</h2>\n" );
|
||||
mMapSettings.setRotation( 45 );
|
||||
QVERIFY( setQml( mpPolysLayer, "inverted_polys_single.qml" ) );
|
||||
QVERIFY( imageCheck( "inverted_polys_rotation" ) );
|
||||
mMapSettings.setRotation( 0 );
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Private helper functions not called directly by CTest
|
||||
//
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
Loading…
x
Reference in New Issue
Block a user