QGIS API Documentation  3.2.0-Bonn (bc43194)
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 "qgis.h"
24 #include "qgslayoutitemmapitem.h"
25 #include "qgssymbol.h"
26 #include <QString>
27 #include <QObject>
28 #include <QPainter>
29 
30 class QDomDocument;
31 class QDomElement;
33 
44 {
45  public:
46 
52 
61  void addOverview( QgsLayoutItemMapOverview *overview SIP_TRANSFER );
62 
69  void removeOverview( const QString &overviewId );
70 
77  void moveOverviewUp( const QString &overviewId );
78 
85  void moveOverviewDown( const QString &overviewId );
86 
90  QgsLayoutItemMapOverview *overview( const QString &overviewId ) const;
91 
95  QgsLayoutItemMapOverview *overview( int index ) const;
96 
101  QgsLayoutItemMapOverview &operator[]( int index );
102 
106  QList< QgsLayoutItemMapOverview * > asList() const;
107  bool readXml( const QDomElement &elem, const QDomDocument &doc, const QgsReadWriteContext &context ) override;
108 
109 };
110 
120 {
121  Q_OBJECT
122 
123  public:
124 
130  QgsLayoutItemMapOverview( const QString &name, QgsLayoutItemMap *map );
131 
132  void draw( QPainter *painter ) override;
133  bool writeXml( QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
134  bool readXml( const QDomElement &itemElem, const QDomDocument &doc, const QgsReadWriteContext &context ) override;
135  void finalizeRestoreFromXml() override;
136  bool usesAdvancedEffects() const override;
137 
142  void setLinkedMap( QgsLayoutItemMap *map );
143 
148  QgsLayoutItemMap *linkedMap();
149 
155  void setFrameSymbol( QgsFillSymbol *symbol SIP_TRANSFER );
156 
161  QgsFillSymbol *frameSymbol();
162 
168  const QgsFillSymbol *frameSymbol() const; SIP_SKIP
169 
174  QPainter::CompositionMode blendMode() const { return mBlendMode; }
175 
180  void setBlendMode( QPainter::CompositionMode mode );
181 
187  bool inverted() const { return mInverted; }
188 
194  void setInverted( bool inverted );
195 
200  bool centered() const { return mCentered; }
201 
206  void setCentered( bool centered );
207 
212  void connectSignals();
213 
214  public slots:
215 
219  void overviewExtentChanged();
220 
221  private:
222 
223  QgsLayoutItemMapOverview() = delete;
224 
225  QString mFrameMapUuid;
226  QPointer< QgsLayoutItemMap > mFrameMap;
227 
229  std::unique_ptr< QgsFillSymbol > mFrameSymbol;
230 
232  QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
233 
235  bool mInverted = false;
236 
238  bool mCentered = false;
239 
241  void createDefaultFrameSymbol();
242 
243 };
244 
245 #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.
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:119
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.
bool centered() const
Returns whether the extent of the map is forced to center on the overview.
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...