Skip to content
Permalink
Browse files

Rename enum values for clarity

  • Loading branch information
nyalldawson committed Jul 2, 2020
1 parent 992d5f3 commit 5b8af77578c75ffbaea4a4ffb462e8e14324163d
@@ -1,7 +1,7 @@
# The following has been generated automatically from src/core/qgsmapclippingregion.h
# monkey patching scoped based enum
QgsMapClippingRegion.FeatureClippingType.Intersect.__doc__ = "Clip the geometry of these features to the region prior to rendering (i.e. feature boundaries will follow the clip region)"
QgsMapClippingRegion.FeatureClippingType.PainterClip.__doc__ = "Applying clipping on the painter only (i.e. feature boundaries will be unchanged, but may be invisible where the feature falls outside the clipping region)"
QgsMapClippingRegion.FeatureClippingType.Intersects.__doc__ = "Only render features which intersect the clipping region, but do not clip these features to the region"
QgsMapClippingRegion.FeatureClippingType.__doc__ = 'Feature clipping behavior.\n\n' + '* ``Intersect``: ' + QgsMapClippingRegion.FeatureClippingType.Intersect.__doc__ + '\n' + '* ``PainterClip``: ' + QgsMapClippingRegion.FeatureClippingType.PainterClip.__doc__ + '\n' + '* ``Intersects``: ' + QgsMapClippingRegion.FeatureClippingType.Intersects.__doc__
QgsMapClippingRegion.FeatureClippingType.ClipToIntersection.__doc__ = "Clip the geometry of these features to the region prior to rendering (i.e. feature boundaries will follow the clip region)"
QgsMapClippingRegion.FeatureClippingType.ClipPainterOnly.__doc__ = "Applying clipping on the painter only (i.e. feature boundaries will be unchanged, but may be invisible where the feature falls outside the clipping region)"
QgsMapClippingRegion.FeatureClippingType.NoClipping.__doc__ = "Only render features which intersect the clipping region, but do not clip these features to the region"
QgsMapClippingRegion.FeatureClippingType.__doc__ = 'Feature clipping behavior, which controls how features from vector layers\nwill be clipped.\n\n' + '* ``ClipToIntersection``: ' + QgsMapClippingRegion.FeatureClippingType.ClipToIntersection.__doc__ + '\n' + '* ``ClipPainterOnly``: ' + QgsMapClippingRegion.FeatureClippingType.ClipPainterOnly.__doc__ + '\n' + '* ``NoClipping``: ' + QgsMapClippingRegion.FeatureClippingType.NoClipping.__doc__
# --
@@ -24,9 +24,9 @@ A map clipping region (in map coordinates and CRS).

enum class FeatureClippingType
{
Intersect,
PainterClip,
Intersects,
ClipToIntersection,
ClipPainterOnly,
NoClipping,
};

explicit QgsMapClippingRegion( const QgsGeometry &geometry );
@@ -33,13 +33,14 @@ class CORE_EXPORT QgsMapClippingRegion
public:

/**
* Feature clipping behavior.
* Feature clipping behavior, which controls how features from vector layers
* will be clipped.
*/
enum class FeatureClippingType : int
{
Intersect, //!< Clip the geometry of these features to the region prior to rendering (i.e. feature boundaries will follow the clip region)
PainterClip, //!< Applying clipping on the painter only (i.e. feature boundaries will be unchanged, but may be invisible where the feature falls outside the clipping region)
Intersects, //!< Only render features which intersect the clipping region, but do not clip these features to the region
ClipToIntersection, //!< Clip the geometry of these features to the region prior to rendering (i.e. feature boundaries will follow the clip region)
ClipPainterOnly, //!< Applying clipping on the painter only (i.e. feature boundaries will be unchanged, but may be invisible where the feature falls outside the clipping region)
NoClipping, //!< Only render features which intersect the clipping region, but do not clip these features to the region
};

/**
@@ -118,7 +119,7 @@ class CORE_EXPORT QgsMapClippingRegion

QgsWeakMapLayerPointerList mRestrictToLayersList;

FeatureClippingType mFeatureClip = FeatureClippingType::Intersect;
FeatureClippingType mFeatureClip = FeatureClippingType::ClipToIntersection;

};

@@ -87,7 +87,7 @@ QgsGeometry QgsMapClippingUtils::calculateFeatureIntersectionGeometry( const QLi
if ( region.geometry().type() != QgsWkbTypes::PolygonGeometry )
continue;

if ( region.featureClip() != QgsMapClippingRegion::FeatureClippingType::Intersect )
if ( region.featureClip() != QgsMapClippingRegion::FeatureClippingType::ClipToIntersection )
continue;

shouldClip = true;
@@ -136,7 +136,7 @@ QPainterPath QgsMapClippingUtils::calculatePainterClipRegion( const QList<QgsMap
switch ( layerType )
{
case QgsMapLayerType::VectorLayer:
if ( region.featureClip() != QgsMapClippingRegion::FeatureClippingType::PainterClip )
if ( region.featureClip() != QgsMapClippingRegion::FeatureClippingType::ClipPainterOnly )
continue;
break;

@@ -193,8 +193,8 @@ QgsGeometry QgsMapClippingUtils::calculateLabelIntersectionGeometry( const QList
// for labeling, we clip using either painter clip regions or intersects type regions.
// unlike feature rendering, we clip features to painter clip regions for labeling, because
// we want the label to sit within the clip region if possible
if ( region.featureClip() != QgsMapClippingRegion::FeatureClippingType::PainterClip &&
region.featureClip() != QgsMapClippingRegion::FeatureClippingType::Intersect )
if ( region.featureClip() != QgsMapClippingRegion::FeatureClippingType::ClipPainterOnly &&
region.featureClip() != QgsMapClippingRegion::FeatureClippingType::ClipToIntersection )
continue;

shouldClip = true;
@@ -935,11 +935,11 @@ class TestQgsDiagram : public QObject
mMapSettings->setLayers( QList<QgsMapLayer *>() << vl2.get() );

QgsMapClippingRegion region1( QgsGeometry::fromWkt( "Polygon ((-92 45, -99 36, -94 29, -82 29, -81 45, -92 45))" ) );
region1.setFeatureClip( QgsMapClippingRegion::FeatureClippingType::Intersect );
region1.setFeatureClip( QgsMapClippingRegion::FeatureClippingType::ClipToIntersection );
mMapSettings->addClippingRegion( region1 );

QgsMapClippingRegion region2( QgsGeometry::fromWkt( "Polygon ((-85 36, -85 46, -107 47, -108 28, -85 28, -85 36))" ) );
region2.setFeatureClip( QgsMapClippingRegion::FeatureClippingType::PainterClip );
region2.setFeatureClip( QgsMapClippingRegion::FeatureClippingType::ClipPainterOnly );
mMapSettings->addClippingRegion( region2 );

const bool res = imageCheck( QStringLiteral( "diagram_clipping" ) );
@@ -2731,11 +2731,11 @@ void TestQgsLabelingEngine::testClipping()
mapSettings.setOutputDpi( 96 );

QgsMapClippingRegion region1( QgsGeometry::fromWkt( "Polygon ((-92 45, -99 36, -94 29, -82 29, -81 45, -92 45))" ) );
region1.setFeatureClip( QgsMapClippingRegion::FeatureClippingType::Intersect );
region1.setFeatureClip( QgsMapClippingRegion::FeatureClippingType::ClipToIntersection );
mapSettings.addClippingRegion( region1 );

QgsMapClippingRegion region2( QgsGeometry::fromWkt( "Polygon ((-85 36, -85 46, -107 47, -108 28, -85 28, -85 36))" ) );
region2.setFeatureClip( QgsMapClippingRegion::FeatureClippingType::PainterClip );
region2.setFeatureClip( QgsMapClippingRegion::FeatureClippingType::ClipPainterOnly );
mapSettings.addClippingRegion( region2 );

QgsLabelingEngineSettings engineSettings = mapSettings.labelingEngineSettings();
@@ -265,9 +265,9 @@ void TestQgsMeshRenderer::test_native_mesh_renderingWithClipping()
mMemoryLayer->setRendererSettings( rendererSettings );

QgsMapClippingRegion region( QgsGeometry::fromWkt( "Polygon ((1706.47279549718587077 2907.78611632270212795, 1306.56660412757969425 2480.30018761726114462, 1665.10318949343354689 2123.73358348968167775, 2360.5065666041273289 2060.6941838649163401, 2640.24390243902416842 2669.41838649155761232, 2228.51782363977508794 2874.29643527204552811, 1706.47279549718587077 2907.78611632270212795))" ) );
region.setFeatureClip( QgsMapClippingRegion::FeatureClippingType::PainterClip );
region.setFeatureClip( QgsMapClippingRegion::FeatureClippingType::ClipPainterOnly );
QgsMapClippingRegion region2( QgsGeometry::fromWkt( "Polygon ((1966.51031894934340016 2925.51594746716773443, 1801.03189493433410462 2452.7204502814265652, 2057.12945590994377199 2027.20450281425951289, 2457.03564727954972113 2033.11444652908130593, 2380.20637898686709377 2957.03564727955017588, 1966.51031894934340016 2925.51594746716773443))" ) );
region2.setFeatureClip( QgsMapClippingRegion::FeatureClippingType::Intersect );
region2.setFeatureClip( QgsMapClippingRegion::FeatureClippingType::ClipToIntersection );
mMapSettings->addClippingRegion( region );
mMapSettings->addClippingRegion( region2 );

@@ -141,9 +141,9 @@ void TestQgsVectorTileLayer::test_render()
void TestQgsVectorTileLayer::test_render_withClip()
{
QgsMapClippingRegion region( QgsGeometry::fromWkt( "Polygon ((-3584104.41462873760610819 9642431.51156153343617916, -3521836.1401221314445138 -3643384.67029104987159371, -346154.14028519613202661 -10787760.6154897827655077, 11515952.15322335436940193 -10530608.51481428928673267, 11982964.21202290244400501 11308099.1972544826567173, -3584104.41462873760610819 9642431.51156153343617916))" ) );
region.setFeatureClip( QgsMapClippingRegion::FeatureClippingType::PainterClip );
region.setFeatureClip( QgsMapClippingRegion::FeatureClippingType::ClipPainterOnly );
QgsMapClippingRegion region2( QgsGeometry::fromWkt( "Polygon ((836943.07534032803960145 12108307.34630974195897579, 1179418.58512666448950768 -8011790.66139839310199022, 17306901.68233776465058327 -8130936.37545258551836014, 17680511.32937740534543991 14072993.65374799631536007, 836943.07534032803960145 12108307.34630974195897579))" ) );
region2.setFeatureClip( QgsMapClippingRegion::FeatureClippingType::Intersect );
region2.setFeatureClip( QgsMapClippingRegion::FeatureClippingType::ClipToIntersection );
mMapSettings->addClippingRegion( region );
mMapSettings->addClippingRegion( region2 );
const bool res = imageCheck( "render_painterclip", mLayer, mLayer->extent() );
@@ -29,9 +29,9 @@ def testGetSet(self):
region.setGeometry(QgsGeometry.fromWkt('Polygon((10 0, 11 0, 11 1, 10 1, 10 0))'))
self.assertEqual(region.geometry().asWkt(), 'Polygon ((10 0, 11 0, 11 1, 10 1, 10 0))')

self.assertEqual(region.featureClip(), QgsMapClippingRegion.FeatureClippingType.Intersect)
region.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.PainterClip)
self.assertEqual(region.featureClip(), QgsMapClippingRegion.FeatureClippingType.PainterClip)
self.assertEqual(region.featureClip(), QgsMapClippingRegion.FeatureClippingType.ClipToIntersection)
region.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.ClipPainterOnly)
self.assertEqual(region.featureClip(), QgsMapClippingRegion.FeatureClippingType.ClipPainterOnly)

layer = QgsVectorLayer("Point?field=fldtxt:string&field=fldint:integer",
"addfeat", "memory")
@@ -59,9 +59,9 @@ def testClippingRegionsForLayer(self):

def testCalculateFeatureRequestGeometry(self):
region = QgsMapClippingRegion(QgsGeometry.fromWkt('Polygon((0 0, 1 0, 1 1, 0 1, 0 0))'))
region.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.Intersects)
region.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.NoClipping)
region2 = QgsMapClippingRegion(QgsGeometry.fromWkt('Polygon((0 0, 0.1 0, 0.1 2, 0 2, 0 0))'))
region2.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.Intersect)
region2.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.NoClipping)

rc = QgsRenderContext()

@@ -84,11 +84,11 @@ def testCalculateFeatureRequestGeometry(self):

def testCalculateFeatureIntersectionGeometry(self):
region = QgsMapClippingRegion(QgsGeometry.fromWkt('Polygon((0 0, 1 0, 1 1, 0 1, 0 0))'))
region.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.Intersect)
region.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.ClipToIntersection)
region2 = QgsMapClippingRegion(QgsGeometry.fromWkt('Polygon((0 0, 0.1 0, 0.1 2, 0 2, 0 0))'))
region2.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.Intersects)
region2.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.ClipToIntersection)
region3 = QgsMapClippingRegion(QgsGeometry.fromWkt('Polygon((0 0, 0.1 0, 0.1 2, 0 2, 0 0))'))
region3.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.Intersect)
region3.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.ClipToIntersection)

rc = QgsRenderContext()

@@ -120,11 +120,11 @@ def testCalculateFeatureIntersectionGeometry(self):

def testPainterClipPath(self):
region = QgsMapClippingRegion(QgsGeometry.fromWkt('Polygon((0 0, 1 0, 1 1, 0 1, 0 0))'))
region.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.PainterClip)
region.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.ClipPainterOnly)
region2 = QgsMapClippingRegion(QgsGeometry.fromWkt('Polygon((0 0, 0.1 0, 0.1 2, 0 2, 0 0))'))
region2.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.Intersects)
region2.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.ClipPainterOnly)
region3 = QgsMapClippingRegion(QgsGeometry.fromWkt('Polygon((0 0, 0.1 0, 0.1 2, 0 2, 0 0))'))
region3.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.PainterClip)
region3.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.ClipPainterOnly)

rc = QgsRenderContext()

@@ -161,11 +161,11 @@ def testPainterClipPath(self):

def testLabelIntersectionGeometry(self):
region = QgsMapClippingRegion(QgsGeometry.fromWkt('Polygon((0 0, 1 0, 1 1, 0 1, 0 0))'))
region.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.Intersect)
region.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.ClipToIntersection)
region2 = QgsMapClippingRegion(QgsGeometry.fromWkt('Polygon((0 0, 0.1 0, 0.1 2, 0 2, 0 0))'))
region2.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.Intersects)
region2.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.NoClipping)
region3 = QgsMapClippingRegion(QgsGeometry.fromWkt('Polygon((0 0, 0.1 0, 0.1 2, 0 2, 0 0))'))
region3.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.PainterClip)
region3.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.ClipPainterOnly)

rc = QgsRenderContext()

@@ -58,9 +58,9 @@ def testRenderWithPainterClipRegions(self):
mapsettings.setLayers([raster_layer])

region = QgsMapClippingRegion(QgsGeometry.fromWkt('Polygon ((0.00131242078273144 -0.00059281669806561, 0.00066744230712249 -0.00110186995774045, 0.00065145110524788 -0.00152830200772984, 0.00141369839460392 -0.00189076925022083, 0.00210931567614912 -0.00094195793899443, 0.00169354442740946 -0.00067810310806349, 0.00131242078273144 -0.00059281669806561))'))
region.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.PainterClip)
region.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.ClipPainterOnly)
region2 = QgsMapClippingRegion(QgsGeometry.fromWkt('Polygon ((0.00067010750743492 -0.0007740503193111, 0.00064612070462302 -0.00151764120648011, 0.00153629760897587 -0.00158693641460339, 0.0014909892036645 -0.00063812510337699, 0.00106722235398754 -0.00055816909400397, 0.00067010750743492 -0.0007740503193111))'))
region2.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.Intersect)
region2.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.ClipToIntersection)
mapsettings.addClippingRegion(region)
mapsettings.addClippingRegion(region2)

@@ -62,9 +62,9 @@ def testRenderWithIntersectsRegions(self):
mapsettings.setLayers([poly_layer])

region = QgsMapClippingRegion(QgsGeometry.fromWkt('Polygon ((-11725957 5368254, -12222900 4807501, -12246014 3834025, -12014878 3496059, -11259833 3518307, -10751333 3621153, -10574129 4516741, -10847640 5194995, -11105742 5325957, -11725957 5368254))'))
region.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.Intersects)
region.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.NoClipping)
region2 = QgsMapClippingRegion(QgsGeometry.fromWkt('Polygon ((-11032549 5421399, -11533344 4693167, -11086481 4229112, -11167378 3742984, -10616504 3553984, -10161936 3925771, -9618766 4668482, -9472380 5620753, -10115709 5965063, -11032549 5421399))'))
region2.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.Intersects)
region2.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.NoClipping)
mapsettings.addClippingRegion(region)
mapsettings.addClippingRegion(region2)

@@ -104,9 +104,9 @@ def testRenderWithIntersectionRegions(self):
mapsettings.setLayers([poly_layer])

region = QgsMapClippingRegion(QgsGeometry.fromWkt('Polygon ((-11725957 5368254, -12222900 4807501, -12246014 3834025, -12014878 3496059, -11259833 3518307, -10751333 3621153, -10574129 4516741, -10847640 5194995, -11105742 5325957, -11725957 5368254))'))
region.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.Intersect)
region.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.ClipToIntersection)
region2 = QgsMapClippingRegion(QgsGeometry.fromWkt('Polygon ((-11032549 5421399, -11533344 4693167, -11086481 4229112, -11167378 3742984, -10616504 3553984, -10161936 3925771, -9618766 4668482, -9472380 5620753, -10115709 5965063, -11032549 5421399))'))
region2.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.Intersect)
region2.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.ClipToIntersection)
mapsettings.addClippingRegion(region)
mapsettings.addClippingRegion(region2)

@@ -160,10 +160,10 @@ def testIntersectionRuleBased(self):

region = QgsMapClippingRegion(QgsGeometry.fromWkt(
'Polygon ((-11725957 5368254, -12222900 4807501, -12246014 3834025, -12014878 3496059, -11259833 3518307, -10751333 3621153, -10574129 4516741, -10847640 5194995, -11105742 5325957, -11725957 5368254))'))
region.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.Intersect)
region.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.ClipToIntersection)
region2 = QgsMapClippingRegion(QgsGeometry.fromWkt(
'Polygon ((-11032549 5421399, -11533344 4693167, -11086481 4229112, -11167378 3742984, -10616504 3553984, -10161936 3925771, -9618766 4668482, -9472380 5620753, -10115709 5965063, -11032549 5421399))'))
region2.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.Intersect)
region2.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.ClipToIntersection)
mapsettings.addClippingRegion(region)
mapsettings.addClippingRegion(region2)

@@ -203,9 +203,9 @@ def testRenderWithPainterClipRegions(self):
mapsettings.setLayers([poly_layer])

region = QgsMapClippingRegion(QgsGeometry.fromWkt('Polygon ((-11725957 5368254, -12222900 4807501, -12246014 3834025, -12014878 3496059, -11259833 3518307, -10751333 3621153, -10574129 4516741, -10847640 5194995, -11105742 5325957, -11725957 5368254))'))
region.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.PainterClip)
region.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.ClipPainterOnly)
region2 = QgsMapClippingRegion(QgsGeometry.fromWkt('Polygon ((-11032549 5421399, -11533344 4693167, -11086481 4229112, -11167378 3742984, -10616504 3553984, -10161936 3925771, -9618766 4668482, -9472380 5620753, -10115709 5965063, -11032549 5421399))'))
region2.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.PainterClip)
region2.setFeatureClip(QgsMapClippingRegion.FeatureClippingType.ClipPainterOnly)
mapsettings.addClippingRegion(region)
mapsettings.addClippingRegion(region2)

0 comments on commit 5b8af77

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