QGIS API Documentation  3.0.2-Girona (307d082)
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 
91  QgsLayoutItemMapOverview *overview( const QString &overviewId ) const;
92 
97  QgsLayoutItemMapOverview *overview( const int index ) const;
98 
104  QgsLayoutItemMapOverview &operator[]( int index );
105 
109  QList< QgsLayoutItemMapOverview * > asList() const;
110  bool readXml( const QDomElement &elem, const QDomDocument &doc, const QgsReadWriteContext &context ) override;
111 
112 };
113 
123 {
124  Q_OBJECT
125 
126  public:
127 
133  QgsLayoutItemMapOverview( const QString &name, QgsLayoutItemMap *map );
134 
135  void draw( QPainter *painter ) override;
136  bool writeXml( QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
137  bool readXml( const QDomElement &itemElem, const QDomDocument &doc, const QgsReadWriteContext &context ) override;
138  void finalizeRestoreFromXml() override;
139  bool usesAdvancedEffects() const override;
140 
145  void setLinkedMap( QgsLayoutItemMap *map );
146 
151  QgsLayoutItemMap *linkedMap();
152 
158  void setFrameSymbol( QgsFillSymbol *symbol SIP_TRANSFER );
159 
164  QgsFillSymbol *frameSymbol();
165 
171  const QgsFillSymbol *frameSymbol() const; SIP_SKIP
172 
177  QPainter::CompositionMode blendMode() const { return mBlendMode; }
178 
183  void setBlendMode( const QPainter::CompositionMode mode );
184 
190  bool inverted() const { return mInverted; }
191 
197  void setInverted( const bool inverted );
198 
203  bool centered() const { return mCentered; }
204 
209  void setCentered( const bool centered );
210 
215  void connectSignals();
216 
217  public slots:
218 
222  void overviewExtentChanged();
223 
224  private:
225 
226  QgsLayoutItemMapOverview() = delete;
227 
228  QString mFrameMapUuid;
229  QPointer< QgsLayoutItemMap > mFrameMap;
230 
232  std::unique_ptr< QgsFillSymbol > mFrameSymbol;
233 
235  QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
236 
238  bool mInverted = false;
239 
241  bool mCentered = false;
242 
244  void createDefaultFrameSymbol();
245 
246 };
247 
248 #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...