QGIS API Documentation  3.21.0-Master (402cf1129e)
qgsmapclippingregion.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmapclippingregion.cpp
3  --------------------------------------
4  Date : June 2020
5  Copyright : (C) 2020 by Nyall Dawson
6  Email : nyall dot dawson at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #include "qgsmapclippingregion.h"
17 #include "qgsmaplayerlistutils.h"
18 #include <algorithm>
19 
21 {
22  return mGeometry;
23 }
24 
26 {
27  mGeometry = geometry;
28 }
29 
30 void QgsMapClippingRegion::setRestrictedLayers( const QList<QgsMapLayer *> &layers )
31 {
32  mRestrictToLayersList = _qgis_listRawToQPointer( layers );
33 }
34 
35 QList<QgsMapLayer *> QgsMapClippingRegion::restrictedLayers() const
36 {
37  return _qgis_listQPointerToRaw( mRestrictToLayersList );
38 }
39 
41 {
42  if ( !mRestrictToLayers )
43  return true;
44 
45  if ( mRestrictToLayersList.empty() )
46  return false;
47 
48  auto it = std::find_if( mRestrictToLayersList.begin(), mRestrictToLayersList.end(), [layer]( const QgsWeakMapLayerPointer & item ) -> bool
49  {
50  return item == layer;
51  } );
52  return it != mRestrictToLayersList.end();
53 }
54 
56 {
57  return mRestrictToLayers;
58 }
59 
61 {
62  mRestrictToLayers = enabled;
63 }
64 
65 
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
void setRestrictToLayers(bool enabled)
Sets whether clipping should be restricted to a subset of layers.
bool appliesToLayer(const QgsMapLayer *layer) const
Returns true if the clipping region should be applied to the specified map layer.
bool restrictToLayers() const
Returns true if clipping should be restricted to a subset of layers.
QgsGeometry geometry() const
Returns the geometry of the clipping region (in the destination map CRS).
void setGeometry(const QgsGeometry &geometry)
Sets the clipping region geometry (in the destination map CRS).
void setRestrictedLayers(const QList< QgsMapLayer * > &layers)
Sets a list of layers to restrict the clipping region effects to.
QList< QgsMapLayer * > restrictedLayers() const
Returns the list of layers to restrict the clipping region effects to.
Base class for all map layer types.
Definition: qgsmaplayer.h:71
QPointer< QgsMapLayer > QgsWeakMapLayerPointer
Weak pointer for QgsMapLayer.
Definition: qgsmaplayer.h:2075