QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsmapclippingregion.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmapclippingregion.h
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 #ifndef QGSMAPCLIPPINGREGION_H
17 #define QGSMAPCLIPPINGREGION_H
18 
19 #include "qgis_core.h"
20 #include "qgsgeometry.h"
21 #include "qgsmaplayer.h"
22 
31 class CORE_EXPORT QgsMapClippingRegion
32 {
33  public:
34 
39  enum class FeatureClippingType : int
40  {
41  ClipToIntersection,
42  ClipPainterOnly,
43  NoClipping,
44  };
45 
49  explicit QgsMapClippingRegion( const QgsGeometry &geometry )
50  : mGeometry( geometry )
51  {}
52 
58  QgsGeometry geometry() const;
59 
65  void setGeometry( const QgsGeometry &geometry );
66 
75  {
76  return mFeatureClip;
77  }
78 
87  {
88  mFeatureClip = type;
89  }
90 
97  bool restrictToLayers() const;
98 
105  void setRestrictToLayers( bool enabled );
106 
117  void setRestrictedLayers( const QList< QgsMapLayer * > &layers );
118 
129  QList< QgsMapLayer * > restrictedLayers() const;
130 
134  bool appliesToLayer( const QgsMapLayer *layer ) const;
135 
136  private:
137 
139  QgsGeometry mGeometry;
140 
141  bool mRestrictToLayers = false;
142  QgsWeakMapLayerPointerList mRestrictToLayersList;
143 
144  FeatureClippingType mFeatureClip = FeatureClippingType::ClipToIntersection;
145 
146 };
147 
148 #endif // QGSMAPCLIPPINGREGION_H
QgsMapClippingRegion
A map clipping region (in map coordinates and CRS).
Definition: qgsmapclippingregion.h:32
QgsWeakMapLayerPointerList
QList< QgsWeakMapLayerPointer > QgsWeakMapLayerPointerList
A list of weak pointers to QgsMapLayers.
Definition: qgsmaplayer.h:1695
qgsmaplayer.h
QgsMapClippingRegion::FeatureClippingType
FeatureClippingType
Feature clipping behavior, which controls how features from vector layers will be clipped.
Definition: qgsmapclippingregion.h:40
qgsgeometry.h
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
QgsMapClippingRegion::QgsMapClippingRegion
QgsMapClippingRegion(const QgsGeometry &geometry)
Constructor for a map clipping region, with the specified geometry in the destination map CRS.
Definition: qgsmapclippingregion.h:49
QgsMapClippingRegion::setFeatureClip
void setFeatureClip(FeatureClippingType type)
Sets the feature clipping type.
Definition: qgsmapclippingregion.h:86
QgsMapClippingRegion::featureClip
FeatureClippingType featureClip() const
Returns the feature clipping type.
Definition: qgsmapclippingregion.h:74