QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsatlascomposition.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsatlascomposermap.h
3  ---------------------
4  begin : October 2012
5  copyright : (C) 2005 by Hugo Mercier
6  email : hugo dot mercier at oslandia dot com
7  ***************************************************************************/
8 /***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 #ifndef QGSATLASCOMPOSITION_H
17 #define QGSATLASCOMPOSITION_H
18 
19 #include "qgscoordinatetransform.h"
20 #include "qgsfeature.h"
21 
22 #include <memory>
23 #include <QString>
24 #include <QDomElement>
25 #include <QDomDocument>
26 
27 class QgsComposerMap;
28 class QgsComposition;
29 class QgsVectorLayer;
30 class QgsExpression;
31 
37 class CORE_EXPORT QgsAtlasComposition : public QObject
38 {
39  Q_OBJECT
40  public:
41  QgsAtlasComposition( QgsComposition* composition );
43 
45  bool enabled() const { return mEnabled; }
46  void setEnabled( bool e ) { mEnabled = e; }
47 
48  QgsComposerMap* composerMap() const { return mComposerMap; }
49  void setComposerMap( QgsComposerMap* map ) { mComposerMap = map; }
50 
51  bool hideCoverage() const { return mHideCoverage; }
52  void setHideCoverage( bool hide ) { mHideCoverage = hide; }
53 
54  bool fixedScale() const { return mFixedScale; }
55  void setFixedScale( bool fixed ) { mFixedScale = fixed; }
56 
57  float margin() const { return mMargin; }
58  void setMargin( float margin ) { mMargin = margin; }
59 
60  QString filenamePattern() const { return mFilenamePattern; }
61  void setFilenamePattern( const QString& pattern ) { mFilenamePattern = pattern; }
62 
63  QgsVectorLayer* coverageLayer() const { return mCoverageLayer; }
64  void setCoverageLayer( QgsVectorLayer* lmap );
65 
66  bool singleFile() const { return mSingleFile; }
67  void setSingleFile( bool single ) { mSingleFile = single; }
68 
69  bool sortFeatures() const { return mSortFeatures; }
70  void setSortFeatures( bool doSort ) { mSortFeatures = doSort; }
71 
72  bool sortAscending() const { return mSortAscending; }
73  void setSortAscending( bool ascending ) { mSortAscending = ascending; }
74 
75  bool filterFeatures() const { return mFilterFeatures; }
76  void setFilterFeatures( bool doFilter ) { mFilterFeatures = doFilter; }
77 
78  QString featureFilter() const { return mFeatureFilter; }
79  void setFeatureFilter( const QString& expression ) { mFeatureFilter = expression; }
80 
81  size_t sortKeyAttributeIndex() const { return mSortKeyAttributeIdx; }
82  void setSortKeyAttributeIndex( size_t idx ) { mSortKeyAttributeIdx = idx; }
83 
85  void beginRender();
87  void endRender();
88 
90  size_t numFeatures() const;
91 
93  void prepareForFeature( size_t i );
94 
96  const QString& currentFilename() const;
97 
98  void writeXML( QDomElement& elem, QDomDocument& doc ) const;
99  void readXML( const QDomElement& elem, const QDomDocument& doc );
100 
101  QgsComposition* composition() { return mComposition; }
102 
103  signals:
105  void parameterChanged();
106 
107  private:
109 
110  bool mEnabled;
114  double mMargin;
118 
121  // feature ordering
123  // sort direction
125  public:
126  typedef std::map< QgsFeatureId, QVariant > SorterKeys;
127  private:
128  // value of field that is used for ordering of features
130  // key (attribute index) used for ordering
132 
133  // feature filtering
135  // feature expression filter
136  QString mFeatureFilter;
137 
138  // id of each iterated feature (after filtering and sorting)
139  std::vector<QgsFeatureId> mFeatureIds;
140 
144  std::auto_ptr<QgsExpression> mFilenameExpr;
145 };
146 
147 #endif
148 
149 
150