Skip to content
Permalink
Browse files

Add method to set a list of clipping regions for QgsMapSettings

  • Loading branch information
nyalldawson committed Jul 2, 2020
1 parent 9a97892 commit bbd5d80e718879a259c1c2c58625e772f45727ac
@@ -675,6 +675,19 @@ Adds a new clipping ``region`` to the map settings.

.. seealso:: :py:func:`clippingRegions`

.. seealso:: :py:func:`setClippingRegions`

.. versionadded:: 3.16
%End

void setClippingRegions( const QList< QgsMapClippingRegion > &regions );
%Docstring
Sets the list of clipping ``regions`` to apply to the map.

.. seealso:: :py:func:`addClippingRegion`

.. seealso:: :py:func:`clippingRegions`

.. versionadded:: 3.16
%End

@@ -684,6 +697,8 @@ Returns the list of clipping regions to apply to the map.

.. seealso:: :py:func:`addClippingRegion`

.. seealso:: :py:func:`setClippingRegions`

.. versionadded:: 3.16
%End

@@ -687,6 +687,11 @@ void QgsMapSettings::addClippingRegion( const QgsMapClippingRegion &region )
mClippingRegions.append( region );
}

void QgsMapSettings::setClippingRegions( const QList<QgsMapClippingRegion> &regions )
{
mClippingRegions = regions;
}

QList<QgsMapClippingRegion> QgsMapSettings::clippingRegions() const
{
return mClippingRegions;
@@ -583,15 +583,27 @@ class CORE_EXPORT QgsMapSettings : public QgsTemporalRangeObject
* Adds a new clipping \a region to the map settings.
*
* \see clippingRegions()
* \see setClippingRegions()
*
* \since QGIS 3.16
*/
void addClippingRegion( const QgsMapClippingRegion &region );

/**
* Sets the list of clipping \a regions to apply to the map.
*
* \see addClippingRegion()
* \see clippingRegions()
*
* \since QGIS 3.16
*/
void setClippingRegions( const QList< QgsMapClippingRegion > &regions );

/**
* Returns the list of clipping regions to apply to the map.
*
* \see addClippingRegion()
* \see setClippingRegions()
*
* \since QGIS 3.16
*/
@@ -614,6 +614,10 @@ void TestQgsMapSettings::testClippingRegions()
QCOMPARE( settings3.clippingRegions().size(), 2 );
QCOMPARE( settings3.clippingRegions().at( 0 ).geometry().asWkt(), QStringLiteral( "Polygon ((0 0, 1 0, 1 1, 0 1, 0 0))" ) );
QCOMPARE( settings3.clippingRegions().at( 1 ).geometry().asWkt(), QStringLiteral( "Polygon ((10 0, 11 0, 11 1, 10 1, 10 0))" ) ) ;

settings.setClippingRegions( QList< QgsMapClippingRegion >() << region2 );
QCOMPARE( settings.clippingRegions().size(), 1 );
QCOMPARE( settings.clippingRegions().at( 0 ).geometry().asWkt(), QStringLiteral( "Polygon ((10 0, 11 0, 11 1, 10 1, 10 0))" ) ) ;
}

QGSTEST_MAIN( TestQgsMapSettings )

0 comments on commit bbd5d80

Please sign in to comment.
You can’t perform that action at this time.