QGIS API Documentation  2.99.0-Master (40f86b2)
qgscomposermapoverview.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscomposermapoverview.h
3  --------------------
4  begin : July 2014
5  copyright : (C) 2014 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 QGSCOMPOSERMAPOVERVIEW_H
19 #define QGSCOMPOSERMAPOVERVIEW_H
20 
21 #include "qgis_core.h"
22 #include "qgscomposermapitem.h"
23 #include <QString>
24 #include <QObject>
25 #include <QPainter>
26 
27 class QDomDocument;
28 class QDomElement;
29 class QgsFillSymbol;
31 
41 {
42  public:
43 
48 
57  void addOverview( QgsComposerMapOverview *overview );
58 
65  void removeOverview( const QString &overviewId );
66 
73  void moveOverviewUp( const QString &overviewId );
74 
81  void moveOverviewDown( const QString &overviewId );
82 
88  const QgsComposerMapOverview *constOverview( const QString &overviewId ) const;
89 
95  QgsComposerMapOverview *overview( const QString &overviewId ) const;
96 
102  QgsComposerMapOverview *overview( const int index ) const;
103 
111 
115  QList< QgsComposerMapOverview * > asList() const;
116 
123  bool readXml( const QDomElement &elem, const QDomDocument &doc ) override;
124 
125 };
126 
134 class CORE_EXPORT QgsComposerMapOverview : public QgsComposerMapItem
135 {
136  Q_OBJECT
137 
138  public:
139 
144  QgsComposerMapOverview( const QString &name, QgsComposerMap *map );
145 
146  virtual ~QgsComposerMapOverview();
147 
151  void draw( QPainter *painter ) override;
152 
158  bool writeXml( QDomElement &elem, QDomDocument &doc ) const override;
159 
165  bool readXml( const QDomElement &itemElem, const QDomDocument &doc ) override;
166 
167  bool usesAdvancedEffects() const override;
168 
173  void setFrameMap( const int mapId );
174 
178  int frameMapId() const { return mFrameMapId; }
179 
184  void setFrameSymbol( QgsFillSymbol *symbol );
185 
190  QgsFillSymbol *frameSymbol() { return mFrameSymbol; }
191 
197  const QgsFillSymbol *frameSymbol() const { return mFrameSymbol; }
198 
203  QPainter::CompositionMode blendMode() const { return mBlendMode; }
204 
209  void setBlendMode( const QPainter::CompositionMode blendMode );
210 
216  bool inverted() const { return mInverted; }
217 
223  void setInverted( const bool inverted );
224 
229  bool centered() const { return mCentered; }
230 
235  void setCentered( const bool centered );
236 
240  void connectSignals();
241 
242  public slots:
243 
246  void overviewExtentChanged();
247 
248  private:
249 
250  QgsComposerMapOverview(); //forbidden
251 
253  int mFrameMapId;
254 
256  QgsFillSymbol *mFrameSymbol = nullptr;
257 
259  QPainter::CompositionMode mBlendMode;
260 
262  bool mInverted;
263 
265  bool mCentered;
266 
268  void createDefaultFrameSymbol();
269 
270 };
271 
272 #endif // QGSCOMPOSERMAPOVERVIEW_H
bool centered() const
Returns whether the extent of the map is forced to center on the overview.
static unsigned index
virtual bool readXml(const QDomElement &itemElem, const QDomDocument &doc) override
Sets map item state from a DOM document.
virtual void draw(QPainter *painter)=0
Draws the item on to a painter.
virtual bool writeXml(QDomElement &elem, QDomDocument &doc) const override
Stores map item state in DOM element.
virtual bool readXml(const QDomElement &elem, const QDomDocument &doc)=0
Sets the item stack&#39;s state from a DOM document.
An item which is drawn inside a QgsComposerMap, e.g., a grid or map overview.
virtual bool usesAdvancedEffects() const
Returns true if the item is drawn using advanced effects, such as blend modes.
An individual overview which is drawn above the map content in a QgsComposerMap, and shows the extent...
QgsComposerMapItem & operator[](int idx)
Returns a reference to an item within the stack.
QgsFillSymbol * frameSymbol()
Gets the fill symbol used for drawing the overview extent.
Object representing map window.
QList< QgsComposerMapItem *> asList() const
Returns a list of QgsComposerMapItems contained by the stack.
const QgsFillSymbol * frameSymbol() const
Gets the fill symbol used for drawing the overview extent.
bool inverted() const
Returns whether the overview frame is inverted, ie, whether the shaded area is drawn outside the exte...
A collection of map items which are drawn above the map content in a QgsComposerMap.
int frameMapId() const
Returns id of source map.
QPainter::CompositionMode blendMode() const
Retrieves the blending mode used for drawing the overview.
A collection of overviews which are drawn above the map content in a QgsComposerMap.