QGIS API Documentation  3.20.0-Odense (decaadbb31)
qgslayoutitemmapoverview.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgslayoutitemmapoverview.h
3  --------------------
4  begin : October 2017
5  copyright : (C) 2017 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QgsLayoutItemMapOVERVIEW_H
19 #define QgsLayoutItemMapOVERVIEW_H
20 
21 #include "qgis_core.h"
22 #include "qgis_sip.h"
23 #include "qgslayoutitemmapitem.h"
24 #include <QString>
25 #include <QObject>
26 #include <QPainter>
27 
28 class QDomDocument;
29 class QDomElement;
31 class QgsFillSymbol;
32 
43 {
44  public:
45 
51 
60  void addOverview( QgsLayoutItemMapOverview *overview SIP_TRANSFER );
61 
68  void removeOverview( const QString &overviewId );
69 
76  void moveOverviewUp( const QString &overviewId );
77 
84  void moveOverviewDown( const QString &overviewId );
85 
89  QgsLayoutItemMapOverview *overview( const QString &overviewId ) const;
90 
94  QgsLayoutItemMapOverview *overview( int index ) const;
95 
100  QgsLayoutItemMapOverview &operator[]( int index );
101 
105  QList< QgsLayoutItemMapOverview * > asList() const;
106  bool readXml( const QDomElement &elem, const QDomDocument &doc, const QgsReadWriteContext &context ) override;
107 
114  QList< QgsMapLayer * > modifyMapLayerList( const QList< QgsMapLayer * > &layers );
115 
116 };
117 
127 {
128  Q_OBJECT
129 
130  public:
131 
137  QgsLayoutItemMapOverview( const QString &name, QgsLayoutItemMap *map );
139 
140  void draw( QPainter *painter ) override;
141  bool writeXml( QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
142  bool readXml( const QDomElement &itemElem, const QDomDocument &doc, const QgsReadWriteContext &context ) override;
143  void finalizeRestoreFromXml() override;
144  bool usesAdvancedEffects() const override;
145 
150  void setLinkedMap( QgsLayoutItemMap *map );
151 
156  QgsLayoutItemMap *linkedMap();
157 
163  void setFrameSymbol( QgsFillSymbol *symbol SIP_TRANSFER );
164 
169  QgsFillSymbol *frameSymbol();
170 
176  const QgsFillSymbol *frameSymbol() const; SIP_SKIP
177 
182  QPainter::CompositionMode blendMode() const { return mBlendMode; }
183 
188  void setBlendMode( QPainter::CompositionMode mode );
189 
195  bool inverted() const { return mInverted; }
196 
202  void setInverted( bool inverted );
203 
208  bool centered() const { return mCentered; }
209 
214  void setCentered( bool centered );
215 
220  void connectSignals();
221 
231  QgsVectorLayer *asMapLayer();
232 
233  QgsMapLayer *mapLayer() override;
234 
235  bool accept( QgsStyleEntityVisitorInterface *visitor ) const override;
236 
237  public slots:
238 
242  void overviewExtentChanged();
243 
244  private:
245 
246  QgsLayoutItemMapOverview() = delete;
247 
248  QString mFrameMapUuid;
249  QPointer< QgsLayoutItemMap > mFrameMap;
250 
252  std::unique_ptr< QgsFillSymbol > mFrameSymbol;
253 
255  QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
256 
258  bool mInverted = false;
259 
261  bool mCentered = false;
262 
263  std::unique_ptr< QgsVectorLayer > mExtentLayer;
264 
266  void createDefaultFrameSymbol();
267 
268 };
269 
270 #endif // QgsLayoutItemMapOVERVIEW_H
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
Definition: qgsfillsymbol.h:30
A collection of map items which are drawn above the map content in a QgsLayoutItemMap.
virtual bool writeXml(QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context) const
Stores the state of the item stack in a DOM node, where element is the DOM element corresponding to a...
virtual void finalizeRestoreFromXml()
Called after all pending items have been restored from XML.
virtual bool readXml(const QDomElement &element, const QDomDocument &doc, const QgsReadWriteContext &context)=0
Sets the item stack's state from a DOM document, where element is a DOM node corresponding to a 'Layo...
QList< QgsLayoutItemMapItem * > asList() const
Returns a list of QgsLayoutItemMapItems contained by the stack.
QgsLayoutItemMapItem & operator[](int index)
Returns a reference to an item at the specified index within the stack.
An item which is drawn inside a QgsLayoutItemMap, e.g., a grid or map overview.
A collection of overviews which are drawn above the map content in a QgsLayoutItemMap.
An individual overview which is drawn above the map content in a QgsLayoutItemMap,...
QPainter::CompositionMode blendMode() const
Retrieves the blending mode used for drawing the overview.
bool centered() const
Returns whether the extent of the map is forced to center on the overview.
~QgsLayoutItemMapOverview() override
bool inverted() const
Returns whether the overview frame is inverted, ie, whether the shaded area is drawn outside the exte...
Layout graphical items for displaying a map.
Base class for all map layer types.
Definition: qgsmaplayer.h:70
The class is used as a container of context for various read/write operations on other objects.
An interface for classes which can visit style entity (e.g.
Represents a vector layer which manages a vector based data sets.
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_TRANSFER
Definition: qgis_sip.h:36