QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 
28 class CORE_EXPORT QgsComposerMapItem : public QgsComposerObject
29 {
30  Q_OBJECT
31 
32  public:
33 
38  QgsComposerMapItem( const QString& name, QgsComposerMap* map );
39 
40  virtual ~QgsComposerMapItem();
41 
45  virtual void draw( QPainter* painter ) = 0;
46 
52  virtual bool writeXML( QDomElement& elem, QDomDocument & doc ) const override;
53 
59  virtual bool readXML( const QDomElement& itemElem, const QDomDocument& doc ) override;
60 
65  virtual void setComposerMap( QgsComposerMap* map );
66 
71  virtual const QgsComposerMap* composerMap() const { return mComposerMap; }
72 
76  QString id() const { return mUuid; }
77 
82  virtual void setName( const QString& name ) { mName = name; }
83 
88  virtual QString name() const { return mName; }
89 
94  virtual void setEnabled( const bool enabled ) { mEnabled = enabled; }
95 
100  virtual bool enabled() const { return mEnabled; }
101 
105  virtual bool usesAdvancedEffects() const { return false; }
106 
107  protected:
108 
111 
114 
117 
119  bool mEnabled;
120 
121 };
122 
123 
124 
133 class CORE_EXPORT QgsComposerMapItemStack
134 {
135  public:
136 
141 
142  virtual ~QgsComposerMapItemStack();
143 
147  int size() const { return mItems.size(); }
148 
155  virtual bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
156 
163  virtual bool readXML( const QDomElement& elem, const QDomDocument& doc ) = 0;
164 
168  void drawItems( QPainter* painter );
169 
174  bool containsAdvancedEffects() const;
175 
176  protected:
177 
186  void addItem( QgsComposerMapItem* item );
187 
194  void removeItem( const QString& itemId );
195 
202  void moveItemUp( const QString& itemId );
203 
210  void moveItemDown( const QString& itemId );
211 
217  const QgsComposerMapItem* constItem( const QString& itemId ) const;
218 
224  QgsComposerMapItem* item( const QString& itemId ) const;
225 
231  QgsComposerMapItem* item( const int index ) const;
232 
240  QgsComposerMapItem &operator[]( int idx );
241 
245  QList< QgsComposerMapItem* > asList() const;
246 
247  protected:
248 
250 
252 
256  void removeItems();
257 };
258 
259 #endif //QGSCOMPOSERMAPITEM_H
260 
static unsigned index
A base class for objects which belong to a map composition.
virtual const QgsComposerMap * composerMap() const
Get composer map for the item.
QString mName
Friendly display name.
virtual bool writeXML(QDomElement &elem, QDomDocument &doc) const
Stores item state in DOM element.
An item which is drawn inside a QgsComposerMap, eg a grid or map overview.
virtual bool enabled() const
Returns whether the item will be drawn.
virtual bool usesAdvancedEffects() const
Returns true if the item is drawn using advanced effects, such as blend modes.
const char * name() const
virtual QString name() const
Get friendly display name for the item.
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.
Object representing map window.
QList< QgsComposerMapItem *> mItems
virtual bool readXML(const QDomElement &itemElem, const QDomDocument &doc)
Sets item state from DOM element.
QString mUuid
Unique id.
QString id() const
Get the unique id for the map item.
A collection of map items which are drawn above the map content in a QgsComposerMap.
virtual void setName(const QString &name)
Sets the friendly display name for the item.
int size() const
Returns the number of items in the stack.
QgsComposerMap * mComposerMap