QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 );
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
QgsLayoutItemMapItemStack::readXml
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...
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:35
QgsLayoutItemMapItem::draw
virtual void draw(QPainter *painter)=0
Draws the item on to a destination painter.
QgsLayoutItemMapItem
An item which is drawn inside a QgsLayoutItemMap, e.g., a grid or map overview.
Definition: qgslayoutitemmapitem.h:34
QgsStyleEntityVisitorInterface
An interface for classes which can visit style entity (e.g.
Definition: qgsstyleentityvisitor.h:34
QgsLayoutItemMapItemStack
A collection of map items which are drawn above the map content in a QgsLayoutItemMap.
Definition: qgslayoutitemmapitem.h:231
QgsLayoutItemMapOverview::inverted
bool inverted() const
Returns whether the overview frame is inverted, ie, whether the shaded area is drawn outside the exte...
Definition: qgslayoutitemmapoverview.h:195
QgsLayoutItemMapItemStack::operator[]
QgsLayoutItemMapItem & operator[](int index)
Returns a reference to an item at the specified index within the stack.
Definition: qgslayoutitemmapitem.cpp:237
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsLayoutItemMapOverview::centered
bool centered() const
Returns whether the extent of the map is forced to center on the overview.
Definition: qgslayoutitemmapoverview.h:208
QgsLayoutItemMapOverview::~QgsLayoutItemMapOverview
~QgsLayoutItemMapOverview() override
QgsLayoutItemMapItem::finalizeRestoreFromXml
virtual void finalizeRestoreFromXml()
Called after all pending items have been restored from XML.
Definition: qgslayoutitemmapitem.cpp:75
qgis_sip.h
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsLayoutItemMapItem::readXml
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 'Layout...
Definition: qgslayoutitemmapitem.cpp:55
QgsLayoutItemMapItem::mapLayer
virtual QgsMapLayer * mapLayer()
Returns the internal map layer used by this item, if available.
Definition: qgslayoutitemmapitem.cpp:137
QgsLayoutItemMapItem::usesAdvancedEffects
virtual bool usesAdvancedEffects() const
Returns true if the item is drawn using advanced effects, such as blend modes.
Definition: qgslayoutitemmapitem.cpp:109
QgsLayoutItemMapOverviewStack
A collection of overviews which are drawn above the map content in a QgsLayoutItemMap.
Definition: qgslayoutitemmapoverview.h:43
QgsLayoutItemMapItemStack::asList
QList< QgsLayoutItemMapItem * > asList() const
Returns a list of QgsLayoutItemMapItems contained by the stack.
Definition: qgslayoutitemmapitem.cpp:242
QgsLayoutItemMapOverview
An individual overview which is drawn above the map content in a QgsLayoutItemMap,...
Definition: qgslayoutitemmapoverview.h:127
QgsLayoutItemMap
Layout graphical items for displaying a map.
Definition: qgslayoutitemmap.h:318
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:387
QgsMapLayer
Base class for all map layer types.
Definition: qgsmaplayer.h:83
QgsLayoutItemMapItem::writeXml
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 'LayoutMa...
Definition: qgslayoutitemmapitem.cpp:33
qgslayoutitemmapitem.h
QgsFillSymbol
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
Definition: qgssymbol.h:1234
QgsLayoutItemMapOverview::blendMode
QPainter::CompositionMode blendMode() const
Retrieves the blending mode used for drawing the overview.
Definition: qgslayoutitemmapoverview.h:182
QgsLayoutItemMapItem::accept
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified style entity visitor, causing it to visit all style entities associated with th...
Definition: qgslayoutitemmapitem.cpp:132
qgssymbol.h