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  //composer map
61  MapRotation, /*< map rotation */
62  MapScale, /*< map scale */
63  MapXMin, /*< map extent x minimum */
64  MapYMin, /*< map extent y minimum */
65  MapXMax, /*< map extent x maximum */
66  MapYMax, /*< map extent y maximum */
67  //composer picture
68  PictureSource, /*< picture source url */
69  //html item
70  SourceUrl /*< html source utl */
71  };
72 
78  {
79  EvaluatedValue = 0, /*< return the current evaluated value for the property */
80  OriginalValue /*< return the original, user set value */
81  };
82 
86  QgsComposerObject( QgsComposition* composition );
87  virtual ~QgsComposerObject();
88 
92  const QgsComposition* composition() const { return mComposition; }
93  QgsComposition* composition() { return mComposition; }
94 
99  virtual bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
100 
105  virtual bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
106 
111  QgsDataDefined* dataDefinedProperty( const DataDefinedProperty property ) const;
112 
121  void setDataDefinedProperty( const DataDefinedProperty property, const bool active, const bool useExpression, const QString &expression, const QString &field );
122 
123  public slots:
124 
126  virtual void repaint();
127 
135  virtual void refreshDataDefinedProperty( const DataDefinedProperty property = AllProperties );
136 
137  protected:
138 
140 
142  QMap< QgsComposerObject::DataDefinedProperty, QString > mDataDefinedNames;
143 
150  bool dataDefinedEvaluate( const QgsComposerObject::DataDefinedProperty property, QVariant &expressionValue );
151 
152  signals:
156  void itemChanged();
157 
158  private slots:
162  void prepareDataDefinedExpressions() const;
163 
164  private:
165 
167  QMap< QgsComposerObject::DataDefinedProperty, QgsDataDefined* > mDataDefinedProperties;
168 
169  friend class TestQgsComposerObject;
170 };
171 
172 #endif
Definition: qgscomposerobject.h:58
Definition: qgscomposerobject.h:61
A base class for objects which belong to a map composition.
Definition: qgscomposerobject.h:33
Definition: qgscomposerobject.h:65
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:142
Definition: qgscomposerobject.h:62
DataDefinedProperty
Data defined properties for different item types.
Definition: qgscomposerobject.h:40
Definition: qgscomposerobject.h:57
Definition: qgscomposerobject.h:43
Definition: qgscomposerobject.h:44
Definition: qgscomposerobject.h:48
Definition: qgscomposerobject.h:56
Definition: qgscomposerobject.h:68
Definition: qgscomposerobject.h:66
const QgsComposition * composition() const
Returns the composition the item is attached to.
Definition: qgscomposerobject.h:92
QgsComposition * composition()
Definition: qgscomposerobject.h:93
Definition: qgscomposerobject.h:64
PropertyValueType
Specifies whether the value returned by a function should be the original, user set value...
Definition: qgscomposerobject.h:77
Graphics scene for map printing.
Definition: qgscomposition.h:72
Definition: qgscomposerobject.h:63
Definition: qgscomposerobject.h:46
QgsComposition * mComposition
Definition: qgscomposerobject.h:139
Definition: qgscomposerobject.h:59
Definition: qgscomposerobject.h:53
Definition: qgscomposerobject.h:50
Definition: qgscomposerobject.h:55
Definition: qgscomposerobject.h:49
Definition: qgscomposerobject.h:47