QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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
Definition: qgscomposerobject.h:58
Definition: qgscomposerobject.h:62
A base class for objects which belong to a map composition.
Definition: qgscomposerobject.h:33
Definition: qgscomposerobject.h:66
A container class for data source field mapping or expression.
Definition: qgsdatadefined.h:32
Definition: qgscomposerobject.h:52
Definition: qgscomposerobject.h:54
QMap< QgsComposerObject::DataDefinedProperty, QString > mDataDefinedNames
Map of data defined properties for the item to string name to use when exporting item to xml...
Definition: qgscomposerobject.h:144
Definition: qgscomposerobject.h:63
DataDefinedProperty
Data defined properties for different item types.
Definition: qgscomposerobject.h:40
Definition: qgscomposerobject.h:57
Definition: qgscomposerobject.h:60
Definition: qgscomposerobject.h:43
Definition: qgscomposerobject.h:44
Definition: qgscomposerobject.h:48
Definition: qgscomposerobject.h:56
Definition: qgscomposerobject.h:70
Definition: qgscomposerobject.h:67
const QgsComposition * composition() const
Returns the composition the item is attached to.
Definition: qgscomposerobject.h:94
QgsComposition * composition()
Definition: qgscomposerobject.h:95
Definition: qgscomposerobject.h:65
PropertyValueType
Specifies whether the value returned by a function should be the original, user set value...
Definition: qgscomposerobject.h:79
Graphics scene for map printing.
Definition: qgscomposition.h:73
Definition: qgscomposerobject.h:68
Definition: qgscomposerobject.h:64
Definition: qgscomposerobject.h:46
QgsComposition * mComposition
Definition: qgscomposerobject.h:141
Definition: qgscomposerobject.h:59
Definition: qgscomposerobject.h:53
Definition: qgscomposerobject.h:50
Definition: qgscomposerobject.h:55
Definition: qgscomposerobject.h:49
Definition: qgscomposerobject.h:47