QGIS API Documentation  2.6.0-Brighton
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgscomposerobject.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscomposerobject.h
3  -------------------
4  begin : July 2014
5  copyright : (C) 2014 by Nyall Dawson,Radim Blazek
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 QGSCOMPOSEROBJECT_H
18 #define QGSCOMPOSEROBJECT_H
19 
20 #include <QObject>
21 #include <QDomNode>
22 #include <QPointF>
23 #include <QRectF>
24 #include <QMap>
25 
26 class QgsComposition;
27 class QPainter;
28 class QgsDataDefined;
29 
33 class CORE_EXPORT QgsComposerObject: public QObject
34 {
35  Q_OBJECT
36  public:
37 
41  {
42  NoProperty = 0, /*< no property */
43  AllProperties, /*< all properties for item */
44  TestProperty, /*< dummy property with no effect on item*/
45  //composer page properties
46  PresetPaperSize, /*< preset paper size for composition */
47  PaperWidth, /*< paper width */
48  PaperHeight, /*< paper height */
49  NumPages, /*< number of pages in composition */
50  PaperOrientation, /*< paper orientation */
51  //general composer item properties
52  PageNumber, /*< page number for item placement */
53  PositionX, /*< x position on page */
54  PositionY, /*< y position on page */
55  ItemWidth, /*< width of item */
56  ItemHeight, /*< height of item */
57  ItemRotation, /*< rotation of item */
58  Transparency, /*< item transparency */
59  BlendMode, /*< item blend mode */
60  ExcludeFromExports, /*< exclude item from exports */
61  //composer map
62  MapRotation, /*< map rotation */
63  MapScale, /*< map scale */
64  MapXMin, /*< map extent x minimum */
65  MapYMin, /*< map extent y minimum */
66  MapXMax, /*< map extent x maximum */
67  MapYMax, /*< map extent y maximum */
68  MapAtlasMargin, /*< map atlas margin*/
69  //composer picture
70  PictureSource, /*< picture source url */
71  //html item
72  SourceUrl /*< html source utl */
73  };
74 
80  {
81  EvaluatedValue = 0, /*< return the current evaluated value for the property */
82  OriginalValue /*< return the original, user set value */
83  };
84 
88  QgsComposerObject( QgsComposition* composition );
89  virtual ~QgsComposerObject();
90 
94  const QgsComposition* composition() const { return mComposition; }
95  QgsComposition* composition() { return mComposition; }
96 
101  virtual bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
102 
107  virtual bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
108 
113  QgsDataDefined* dataDefinedProperty( const DataDefinedProperty property ) const;
114 
123  void setDataDefinedProperty( const DataDefinedProperty property, const bool active, const bool useExpression, const QString &expression, const QString &field );
124 
125  public slots:
126 
128  virtual void repaint();
129 
137  virtual void refreshDataDefinedProperty( const DataDefinedProperty property = AllProperties );
138 
139  protected:
140 
142 
144  QMap< QgsComposerObject::DataDefinedProperty, QString > mDataDefinedNames;
145 
152  bool dataDefinedEvaluate( const QgsComposerObject::DataDefinedProperty property, QVariant &expressionValue );
153 
154  signals:
158  void itemChanged();
159 
160  private slots:
164  void prepareDataDefinedExpressions() const;
165 
166  private:
167 
169  QMap< QgsComposerObject::DataDefinedProperty, QgsDataDefined* > mDataDefinedProperties;
170 
171  friend class TestQgsComposerObject;
172 };
173 
174 #endif