QGIS API Documentation  2.3.0-Master
 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 );
47 
51  QgsComposerMap* composerMap() const;
55  void setComposerMap( QgsComposerMap* map );
56 
57  bool hideCoverage() const { return mHideCoverage; }
58  void setHideCoverage( bool hide );
59 
63  bool fixedScale() const;
67  void setFixedScale( bool fixed );
68 
72  float margin() const;
76  void setMargin( float margin );
77 
78  QString filenamePattern() const { return mFilenamePattern; }
79  void setFilenamePattern( const QString& pattern );
80 
81  QgsVectorLayer* coverageLayer() const { return mCoverageLayer; }
82  void setCoverageLayer( QgsVectorLayer* lmap );
83 
84  bool singleFile() const { return mSingleFile; }
85  void setSingleFile( bool single ) { mSingleFile = single; }
86 
87  bool sortFeatures() const { return mSortFeatures; }
88  void setSortFeatures( bool doSort ) { mSortFeatures = doSort; }
89 
90  bool sortAscending() const { return mSortAscending; }
91  void setSortAscending( bool ascending ) { mSortAscending = ascending; }
92 
93  bool filterFeatures() const { return mFilterFeatures; }
94  void setFilterFeatures( bool doFilter ) { mFilterFeatures = doFilter; }
95 
96  QString featureFilter() const { return mFeatureFilter; }
97  void setFeatureFilter( const QString& expression ) { mFeatureFilter = expression; }
98 
99  QString sortKeyAttributeName() const { return mSortKeyAttributeName; }
100  void setSortKeyAttributeName( QString fieldName ) { mSortKeyAttributeName = fieldName; }
101 
102  Q_DECL_DEPRECATED int sortKeyAttributeIndex() const;
103  Q_DECL_DEPRECATED void setSortKeyAttributeIndex( int idx );
104 
107  bool beginRender();
109  void endRender();
110 
112  int numFeatures() const;
113 
115  void prepareForFeature( int i );
116 
118  void prepareForFeature( QgsFeature * feat );
119 
121  const QString& currentFilename() const;
122 
123  void writeXML( QDomElement& elem, QDomDocument& doc ) const;
124  void readXML( const QDomElement& elem, const QDomDocument& doc );
125 
126  QgsComposition* composition() { return mComposition; }
127 
130  int updateFeatures();
131 
132  void nextFeature();
133  void prevFeature();
134  void lastFeature();
135  void firstFeature();
136 
138  QgsFeature* currentFeature() { return &mCurrentFeature; }
139 
141  void prepareMap( QgsComposerMap* map );
142 
143  signals:
145  void parameterChanged();
146 
148  void toggled( bool );
149 
151  void statusMsgChanged( QString message );
152 
154  void coverageLayerChanged( QgsVectorLayer* layer );
155 
157  void renderBegun();
158 
160  void renderEnded();
161 
162  private:
164  void updateFilenameExpression();
165 
167  void evalFeatureFilename();
168 
170 
171  bool mEnabled;
176 
179  // feature ordering
181  // sort direction
183 
184  // current atlas feature number
186 
187  public:
188  typedef QMap< QgsFeatureId, QVariant > SorterKeys;
189 
190  private:
191  // value of field that is used for ordering of features
193  // key (attribute index) used for ordering
195 
196  // feature filtering
198  // feature expression filter
199  QString mFeatureFilter;
200 
201  // id of each iterated feature (after filtering and sorting)
202  QVector<QgsFeatureId> mFeatureIds;
203 
205 
206  std::auto_ptr<QgsExpression> mFilenameExpr;
207 
208  // bounding box of the current feature transformed into map crs
210 
211  //forces all atlas enabled maps to redraw
212  void updateAtlasMaps();
213 
214  //computes the extent of the current feature, in the crs of the specified map
215  void computeExtent( QgsComposerMap *map );
216 };
217 
218 #endif
219 
220 
221 
Class for parsing and evaluation of expressions (formerly called "search strings").
Definition: qgsexpression.h:89
QMap< QgsFeatureId, QVariant > SorterKeys
A rectangle specified with double values.
Definition: qgsrectangle.h:35
void setSortFeatures(bool doSort)
QgsVectorLayer * mCoverageLayer
QVector< QgsFeatureId > mFeatureIds
bool hideCoverage() const
QgsComposition * composition()
bool enabled() const
Is the atlas generation enabled ?
void setSortKeyAttributeName(QString fieldName)
bool sortAscending() const
QgsCoordinateTransform mTransform
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:114
bool filterFeatures() const
QgsRectangle mTransformedFeatureBounds
QString sortKeyAttributeName() const
void setSortAscending(bool ascending)
Graphics scene for map printing.
QgsFeature * currentFeature()
Returns the current atlas feature.
Object representing map window.
QgsComposition * mComposition
void setFilterFeatures(bool doFilter)
void setFeatureFilter(const QString &expression)
bool sortFeatures() const
QString filenamePattern() const
void setSingleFile(bool single)
QString featureFilter() const
Class for doing transforms between two map coordinate systems.
Class used to render an Atlas, iterating over geometry features.
std::auto_ptr< QgsExpression > mFilenameExpr
QgsVectorLayer * coverageLayer() const
Represents a vector layer which manages a vector based data sets.