QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 
QgsMapClippingRegion::restrictedLayers
QList< QgsMapLayer * > restrictedLayers() const
Returns the list of layers to restrict the clipping region effects to.
Definition: qgsmapclippingregion.cpp:35
QgsMapClippingRegion::setGeometry
void setGeometry(const QgsGeometry &geometry)
Sets the clipping region geometry (in the destination map CRS).
Definition: qgsmapclippingregion.cpp:25
QgsMapClippingRegion::appliesToLayer
bool appliesToLayer(const QgsMapLayer *layer) const
Returns true if the clipping region should be applied to the specified map layer.
Definition: qgsmapclippingregion.cpp:40
QgsMapClippingRegion::geometry
QgsGeometry geometry() const
Returns the geometry of the clipping region (in the destination map CRS).
Definition: qgsmapclippingregion.cpp:20
QgsMapClippingRegion::setRestrictedLayers
void setRestrictedLayers(const QList< QgsMapLayer * > &layers)
Sets a list of layers to restrict the clipping region effects to.
Definition: qgsmapclippingregion.cpp:30
QgsWeakMapLayerPointer
QPointer< QgsMapLayer > QgsWeakMapLayerPointer
Weak pointer for QgsMapLayer.
Definition: qgsmaplayer.h:1688
QgsMapClippingRegion::setRestrictToLayers
void setRestrictToLayers(bool enabled)
Sets whether clipping should be restricted to a subset of layers.
Definition: qgsmapclippingregion.cpp:60
QgsGeometry
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
QgsMapLayer
Base class for all map layer types.
Definition: qgsmaplayer.h:83
qgsmaplayerlistutils.h
QgsMapClippingRegion::restrictToLayers
bool restrictToLayers() const
Returns true if clipping should be restricted to a subset of layers.
Definition: qgsmapclippingregion.cpp:55
qgsmapclippingregion.h