QGIS API Documentation  2.12.0-Lyon
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 "qgscomposermapitem.h"
22 #include <QString>
23 #include <QObject>
24 #include <QPainter>
25 
26 class QDomDocument;
27 class QDomElement;
28 class QgsFillSymbolV2;
30 
40 {
41  public:
42 
47 
48  virtual ~QgsComposerMapOverviewStack();
49 
58  void addOverview( QgsComposerMapOverview* overview );
59 
66  void removeOverview( const QString& overviewId );
67 
74  void moveOverviewUp( const QString& overviewId );
75 
82  void moveOverviewDown( const QString& overviewId );
83 
89  const QgsComposerMapOverview* constOverview( const QString& overviewId ) const;
90 
96  QgsComposerMapOverview* overview( const QString& overviewId ) const;
97 
103  QgsComposerMapOverview* overview( const int index ) const;
104 
112 
117 
124  bool readXML( const QDomElement& elem, const QDomDocument& doc ) override;
125 
126 };
127 
135 class CORE_EXPORT QgsComposerMapOverview : public QgsComposerMapItem
136 {
137  Q_OBJECT
138 
139  public:
140 
145  QgsComposerMapOverview( const QString& name, QgsComposerMap* map );
146 
147  virtual ~QgsComposerMapOverview();
148 
152  void draw( QPainter* painter ) override;
153 
159  bool writeXML( QDomElement& elem, QDomDocument & doc ) const override;
160 
166  bool readXML( const QDomElement& itemElem, const QDomDocument& doc ) override;
167 
168  bool usesAdvancedEffects() const override;
169 
174  void setFrameMap( const int mapId );
175 
179  int frameMapId() const { return mFrameMapId; }
180 
185  void setFrameSymbol( QgsFillSymbolV2* symbol );
186 
191  QgsFillSymbolV2* frameSymbol() { return mFrameSymbol; }
192 
197  const QgsFillSymbolV2* 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  QgsFillSymbolV2* mFrameSymbol;
257 
259  QPainter::CompositionMode mBlendMode;
260 
262  bool mInverted;
263 
265  bool mCentered;
266 
268  void createDefaultFrameSymbol();
269 
270 };
271 
272 #endif // QGSCOMPOSERMAPOVERVIEW_H
static unsigned index
virtual void draw(QPainter *painter)=0
Draws the item on to a painter.
bool centered() const
Returns whether the extent of the map is forced to center on the overview.
An item which is drawn inside a QgsComposerMap, eg a grid or map overview.
An individual overview which is drawn above the map content in a QgsComposerMap, and shows the extent...
QgsFillSymbolV2 * frameSymbol()
Gets the fill symbol used for drawing the overview extent.
QList< QgsComposerMapItem * > asList() const
Returns a list of QgsComposerMapItems contained by the stack.
QPainter::CompositionMode blendMode() const
Retrieves the blending mode used for drawing the overview.
QgsComposerMapItem & operator[](int idx)
Returns a reference to an item within the stack.
Object representing map window.
A collection of map items which are drawn above the map content in a QgsComposerMap.
virtual bool readXML(const QDomElement &itemElem, const QDomDocument &doc) override
Sets map item state from a DOM document.
virtual bool usesAdvancedEffects() const
Returns true if the item is drawn using advanced effects, such as blend modes.
virtual bool writeXML(QDomElement &elem, QDomDocument &doc) const override
Stores map item state in DOM element.
const QgsFillSymbolV2 * frameSymbol() const
Gets the fill symbol used for drawing the overview extent.
virtual bool readXML(const QDomElement &elem, const QDomDocument &doc)=0
Sets the item stack's state from a DOM document.
int frameMapId() const
Returns id of source map.
bool inverted() const
Returns whether the overview frame is inverted, ie, whether the shaded area is drawn outside the exte...
A collection of overviews which are drawn above the map content in a QgsComposerMap.