QGIS API Documentation  2.12.0-Lyon
qgscomposermapitem.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscomposermapitem.h
3  -------------------
4  begin : September 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 #ifndef QGSCOMPOSERMAPITEM_H
18 #define QGSCOMPOSERMAPITEM_H
19 
20 #include "qgscomposerobject.h"
21 
22 class QgsComposerMap;
23 
29 class CORE_EXPORT QgsComposerMapItem : public QgsComposerObject
30 {
31  Q_OBJECT
32 
33  public:
34 
39  QgsComposerMapItem( const QString& name, QgsComposerMap* map );
40 
41  virtual ~QgsComposerMapItem();
42 
46  virtual void draw( QPainter* painter ) = 0;
47 
53  virtual bool writeXML( QDomElement& elem, QDomDocument & doc ) const override;
54 
60  virtual bool readXML( const QDomElement& itemElem, const QDomDocument& doc ) override;
61 
66  virtual void setComposerMap( QgsComposerMap* map );
67 
72  virtual const QgsComposerMap* composerMap() const { return mComposerMap; }
73 
77  QString id() const { return mUuid; }
78 
83  virtual void setName( const QString& name ) { mName = name; }
84 
89  virtual QString name() const { return mName; }
90 
95  virtual void setEnabled( const bool enabled ) { mEnabled = enabled; }
96 
101  virtual bool enabled() const { return mEnabled; }
102 
106  virtual bool usesAdvancedEffects() const { return false; }
107 
108  protected:
109 
112 
115 
118 
120  bool mEnabled;
121 
122 };
123 
124 
125 
134 class CORE_EXPORT QgsComposerMapItemStack
135 {
136  public:
137 
142 
143  virtual ~QgsComposerMapItemStack();
144 
148  int size() const { return mItems.size(); }
149 
156  virtual bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
157 
164  virtual bool readXML( const QDomElement& elem, const QDomDocument& doc ) = 0;
165 
169  void drawItems( QPainter* painter );
170 
175  bool containsAdvancedEffects() const;
176 
177  protected:
178 
187  void addItem( QgsComposerMapItem* item );
188 
195  void removeItem( const QString& itemId );
196 
203  void moveItemUp( const QString& itemId );
204 
211  void moveItemDown( const QString& itemId );
212 
218  const QgsComposerMapItem* constItem( const QString& itemId ) const;
219 
225  QgsComposerMapItem* item( const QString& itemId ) const;
226 
232  QgsComposerMapItem* item( const int index ) const;
233 
241  QgsComposerMapItem &operator[]( int idx );
242 
246  QList< QgsComposerMapItem* > asList() const;
247 
248  protected:
249 
251 
253 
257  void removeItems();
258 };
259 
260 #endif //QGSCOMPOSERMAPITEM_H
261 
static unsigned index
virtual bool writeXML(QDomElement &elem, QDomDocument &doc) const
Stores item state in DOM element.
A base class for objects which belong to a map composition.
int size() const
Returns the number of items in the stack.
virtual const QgsComposerMap * composerMap() const
Get composer map for the item.
QString mName
Friendly display name.
An item which is drawn inside a QgsComposerMap, eg a grid or map overview.
const char * name() const
bool mEnabled
True if item is to be displayed on map.
virtual void setEnabled(const bool enabled)
Controls whether the item will be drawn.
QgsComposerMap * mComposerMap
Associated composer map.
QString id() const
Get the unique id for the map item.
Object representing map window.
virtual QString name() const
Get friendly display name for the item.
QList< QgsComposerMapItem * > mItems
virtual bool enabled() const
Returns whether the item will be drawn.
virtual bool readXML(const QDomElement &itemElem, const QDomDocument &doc)
Sets item state from DOM element.
QString mUuid
Unique id.
A collection of map items which are drawn above the map content in a QgsComposerMap.
virtual bool usesAdvancedEffects() const
Returns true if the item is drawn using advanced effects, such as blend modes.
virtual void setName(const QString &name)
Sets the friendly display name for the item.
QgsComposerMap * mComposerMap