QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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 "qgssymbol.h"
25 #include <QString>
26 #include <QObject>
27 #include <QPainter>
28 
29 class QDomDocument;
30 class QDomElement;
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 );
138  ~QgsLayoutItemMapOverview() override;
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  bool accept( QgsStyleEntityVisitorInterface *visitor ) const override;
234 
235  public slots:
236 
240  void overviewExtentChanged();
241 
242  private:
243 
244  QgsLayoutItemMapOverview() = delete;
245 
246  QString mFrameMapUuid;
247  QPointer< QgsLayoutItemMap > mFrameMap;
248 
250  std::unique_ptr< QgsFillSymbol > mFrameSymbol;
251 
253  QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
254 
256  bool mInverted = false;
257 
259  bool mCentered = false;
260 
261  std::unique_ptr< QgsVectorLayer > mExtentLayer;
262 
264  void createDefaultFrameSymbol();
265 
266 };
267 
268 #endif // QgsLayoutItemMapOVERVIEW_H
The class is used as a container of context for various read/write operations on other objects...
An individual overview which is drawn above the map content in a QgsLayoutItemMap, and shows the extent of another QgsLayoutItemMap.
An item which is drawn inside a QgsLayoutItemMap, e.g., a grid or map overview.
virtual void finalizeRestoreFromXml()
Called after all pending items have been restored from XML.
A collection of map items which are drawn above the map content in a QgsLayoutItemMap.
A collection of overviews which are drawn above the map content in a QgsLayoutItemMap.
An interface for classes which can visit style entity (e.g.
virtual bool usesAdvancedEffects() const
Returns true if the item is drawn using advanced effects, such as blend modes.
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.
#define SIP_SKIP
Definition: qgis_sip.h:126
virtual bool readXml(const QDomElement &element, const QDomDocument &doc, const QgsReadWriteContext &context)=0
Sets the item stack&#39;s state from a DOM document, where element is a DOM node corresponding to a &#39;Layo...
QPainter::CompositionMode blendMode() const
Retrieves the blending mode used for drawing the overview.
#define SIP_TRANSFER
Definition: qgis_sip.h:36
virtual void draw(QPainter *painter)=0
Draws the item on to a destination painter.
QgsLayoutItemMapItem & operator[](int index)
Returns a reference to an item at the specified index within the stack.
virtual bool readXml(const QDomElement &element, const QDomDocument &doc, const QgsReadWriteContext &context)
Sets the map item state from a DOM document, where element is the DOM node corresponding to a &#39;Layout...
QList< QgsLayoutItemMapItem *> asList() const
Returns a list of QgsLayoutItemMapItems contained by the stack.
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified style entity visitor, causing it to visit all style entities associated with th...
bool centered() const
Returns whether the extent of the map is forced to center on the overview.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
Definition: qgssymbol.h:1155
Represents a vector layer which manages a vector based data sets.
virtual bool writeXml(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Stores map item state in a DOM element, where element is the DOM element corresponding to a &#39;LayoutMa...