QGIS API Documentation  master-59fd5e0
src/core/composer/qgsatlascomposition.h
Go to the documentation of this file.
00001 /***************************************************************************
00002                              qgsatlascomposermap.h
00003                              ---------------------
00004     begin                : October 2012
00005     copyright            : (C) 2005 by Hugo Mercier
00006     email                : hugo dot mercier at oslandia dot com
00007  ***************************************************************************/
00008 /***************************************************************************
00009  *                                                                         *
00010  *   This program is free software; you can redistribute it and/or modify  *
00011  *   it under the terms of the GNU General Public License as published by  *
00012  *   the Free Software Foundation; either version 2 of the License, or     *
00013  *   (at your option) any later version.                                   *
00014  *                                                                         *
00015  ***************************************************************************/
00016 #ifndef QGSATLASCOMPOSITION_H
00017 #define QGSATLASCOMPOSITION_H
00018 
00019 #include "qgscoordinatetransform.h"
00020 #include "qgsfeature.h"
00021 
00022 #include <memory>
00023 #include <QString>
00024 #include <QDomElement>
00025 #include <QDomDocument>
00026 
00027 class QgsComposerMap;
00028 class QgsComposition;
00029 class QgsVectorLayer;
00030 class QgsExpression;
00031 
00037 class CORE_EXPORT QgsAtlasComposition : public QObject
00038 {
00039     Q_OBJECT
00040   public:
00041     QgsAtlasComposition( QgsComposition* composition );
00042     ~QgsAtlasComposition();
00043 
00045     bool enabled() const { return mEnabled; }
00046     void setEnabled( bool e ) { mEnabled = e; }
00047 
00048     QgsComposerMap* composerMap() const { return mComposerMap; }
00049     void setComposerMap( QgsComposerMap* map ) { mComposerMap = map; }
00050 
00051     bool hideCoverage() const { return mHideCoverage; }
00052     void setHideCoverage( bool hide ) { mHideCoverage = hide; }
00053 
00054     bool fixedScale() const { return mFixedScale; }
00055     void setFixedScale( bool fixed ) { mFixedScale = fixed; }
00056 
00057     float margin() const { return mMargin; }
00058     void setMargin( float margin ) { mMargin = margin; }
00059 
00060     QString filenamePattern() const { return mFilenamePattern; }
00061     void setFilenamePattern( const QString& pattern ) { mFilenamePattern = pattern; }
00062 
00063     QgsVectorLayer* coverageLayer() const { return mCoverageLayer; }
00064     void setCoverageLayer( QgsVectorLayer* lmap );
00065 
00066     bool singleFile() const { return mSingleFile; }
00067     void setSingleFile( bool single ) { mSingleFile = single; }
00068 
00069     bool sortFeatures() const { return mSortFeatures; }
00070     void setSortFeatures( bool doSort ) { mSortFeatures = doSort; }
00071 
00072     bool sortAscending() const { return mSortAscending; }
00073     void setSortAscending( bool ascending ) { mSortAscending = ascending; }
00074 
00075     bool filterFeatures() const { return mFilterFeatures; }
00076     void setFilterFeatures( bool doFilter ) { mFilterFeatures = doFilter; }
00077 
00078     QString featureFilter() const { return mFeatureFilter; }
00079     void setFeatureFilter( const QString& expression ) { mFeatureFilter = expression; }
00080 
00081     size_t sortKeyAttributeIndex() const { return mSortKeyAttributeIdx; }
00082     void setSortKeyAttributeIndex( size_t idx ) { mSortKeyAttributeIdx = idx; }
00083 
00085     void beginRender();
00087     void endRender();
00088 
00090     size_t numFeatures() const;
00091 
00093     void prepareForFeature( size_t i );
00094 
00096     const QString& currentFilename() const;
00097 
00098     void writeXML( QDomElement& elem, QDomDocument& doc ) const;
00099     void readXML( const QDomElement& elem, const QDomDocument& doc );
00100 
00101     QgsComposition* composition() { return mComposition; }
00102 
00103   signals:
00105     void parameterChanged();
00106 
00107   private:
00108     QgsComposition* mComposition;
00109 
00110     bool mEnabled;
00111     QgsComposerMap* mComposerMap;
00112     bool mHideCoverage;
00113     bool mFixedScale;
00114     double mMargin;
00115     QString mFilenamePattern;
00116     QgsVectorLayer* mCoverageLayer;
00117     bool mSingleFile;
00118 
00119     QgsCoordinateTransform mTransform;
00120     QString mCurrentFilename;
00121     // feature ordering
00122     bool mSortFeatures;
00123     // sort direction
00124     bool mSortAscending;
00125   public:
00126     typedef std::map< QgsFeatureId, QVariant > SorterKeys;
00127   private:
00128     // value of field that is used for ordering of features
00129     SorterKeys mFeatureKeys;
00130     // key (attribute index) used for ordering
00131     size_t mSortKeyAttributeIdx;
00132 
00133     // feature filtering
00134     bool mFilterFeatures;
00135     // feature expression filter
00136     QString mFeatureFilter;
00137 
00138     // id of each iterated feature (after filtering and sorting)
00139     std::vector<QgsFeatureId> mFeatureIds;
00140 
00141     QgsFeature mCurrentFeature;
00142     QgsRectangle mOrigExtent;
00143     bool mRestoreLayer;
00144     std::auto_ptr<QgsExpression> mFilenameExpr;
00145 };
00146 
00147 #endif
00148 
00149 
00150 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines