30 mComposition( composition ),
33 mHideCoverage( false ), mFixedScale( false ), mMargin( 0.10 ), mFilenamePattern(
"'output_'||$feature" ),
34 mCoverageLayer( 0 ), mSingleFile( false ),
35 mSortFeatures( false ), mSortAscending( true ),
36 mFilterFeatures( false ), mFeatureFilter(
"" )
69 if (
mKeys[ id1 ].type() == QVariant::Int )
71 result =
mKeys[ id1 ].toInt() <
mKeys[ id2 ].toInt();
73 else if (
mKeys[ id1 ].type() == QVariant::Double )
75 result =
mKeys[ id1 ].toDouble() <
mKeys[ id2 ].toDouble();
77 else if (
mKeys[ id1 ].type() == QVariant::String )
79 result = ( QString::localeAwareCompare(
mKeys[ id1 ].toString(),
mKeys[ id2 ].toString() ) < 0 );
111 throw std::runtime_error(
tr(
"Filename parsing error: %1" ).arg(
mFilenameExpr->parserErrorString() ).toLocal8Bit().data() );
121 std::auto_ptr<QgsExpression> filterExpression;
125 if ( filterExpression->hasParserError() )
127 throw std::runtime_error(
tr(
"Feature filter parser error: %1" ).arg( filterExpression->parserErrorString() ).toLocal8Bit().data() );
141 if ( filterExpression->hasEvalError() )
143 throw std::runtime_error(
tr(
"Feature filter eval error: %1" ).arg( filterExpression->evalErrorString() ).toLocal8Bit().data() );
147 if ( !result.toBool() )
175 if ( removeAt != -1 )
178 layerSet.removeAt( removeAt );
195 QList<QgsComposerLabel*> labels;
197 for ( QList<QgsComposerLabel*>::iterator lit = labels.begin(); lit != labels.end(); ++lit )
199 ( *lit )->setExpressionContext( 0, 0 );
235 throw std::runtime_error(
tr(
"Filename eval error: %1" ).arg(
mFilenameExpr->evalErrorString() ).toLocal8Bit().data() );
268 double geom_center_x = ( xa1 + xa2 ) / 2.0;
269 double geom_center_y = ( ya1 + ya2 ) / 2.0;
281 double geom_ratio = geom_rect.
width() / geom_rect.
height();
285 if ( geom_ratio < map_ratio )
288 double adj_width = ( map_ratio * geom_rect.
height() - geom_rect.
width() ) / 2.0;
293 else if ( geom_ratio > map_ratio )
296 double adj_height = ( geom_rect.
width() / map_ratio - geom_rect.
height() ) / 2.0;
309 QList<QgsComposerLabel*> labels;
313 for ( QList<QgsComposerLabel*>::iterator lit = labels.begin(); lit != labels.end(); ++lit )
329 QDomElement atlasElem = doc.createElement(
"Atlas" );
330 atlasElem.setAttribute(
"enabled",
mEnabled ?
"true" :
"false" );
342 atlasElem.setAttribute(
"coverageLayer",
"" );
350 atlasElem.setAttribute(
"composerMap",
"" );
352 atlasElem.setAttribute(
"hideCoverage",
mHideCoverage ?
"true" :
"false" );
353 atlasElem.setAttribute(
"fixedScale",
mFixedScale ?
"true" :
"false" );
354 atlasElem.setAttribute(
"singleFile",
mSingleFile ?
"true" :
"false" );
355 atlasElem.setAttribute(
"margin", QString::number(
mMargin ) );
358 atlasElem.setAttribute(
"sortFeatures",
mSortFeatures ?
"true" :
"false" );
362 atlasElem.setAttribute(
"sortAscending",
mSortAscending ?
"true" :
"false" );
364 atlasElem.setAttribute(
"filterFeatures",
mFilterFeatures ?
"true" :
"false" );
370 elem.appendChild( atlasElem );
375 mEnabled = atlasElem.attribute(
"enabled",
"false" ) ==
"true" ?
true :
false;
385 for ( QMap<QString, QgsMapLayer*>::const_iterator it = layers.begin(); it != layers.end(); ++it )
387 if ( it.key() == atlasElem.attribute(
"coverageLayer" ) )
396 for ( QList<const QgsComposerMap*>::const_iterator it = maps.begin(); it != maps.end(); ++it )
398 if (( *it )->id() == atlasElem.attribute(
"composerMap" ).toInt() )
404 mMargin = atlasElem.attribute(
"margin",
"0.0" ).toDouble();
405 mHideCoverage = atlasElem.attribute(
"hideCoverage",
"false" ) ==
"true" ?
true :
false;
406 mFixedScale = atlasElem.attribute(
"fixedScale",
"false" ) ==
"true" ?
true :
false;
407 mSingleFile = atlasElem.attribute(
"singleFile",
"false" ) ==
"true" ?
true :
false;
410 mSortFeatures = atlasElem.attribute(
"sortFeatures",
"false" ) ==
"true" ?
true :
false;
414 mSortAscending = atlasElem.attribute(
"sortAscending",
"true" ) ==
"true" ?
true :
false;
416 mFilterFeatures = atlasElem.attribute(
"filterFeatures",
"false" ) ==
"true" ?
true :
false;
QgsFeatureId id() const
Get the feature id for this feature.
Class for parsing and evaluation of expressions (formerly called "search strings").
Wrapper for iterator of features from vector data provider or vector layer.
A rectangle specified with double values.
QgsVectorLayer * mCoverageLayer
size_t numFeatures() const
Returns the number of features in the coverage layer.
QgsAtlasComposition(QgsComposition *composition)
std::map< QgsFeatureId, QVariant > SorterKeys
double yMaximum() const
Get the y maximum value (top side of rectangle)
void beginRender()
Begins the rendering.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())
Query the provider for features specified in request.
QgsGeometry * geometry() const
Get the geometry object associated with this feature.
void cache()
Create cache image.
QList< const QgsComposerMap * > composerMapItems() const
Returns pointers to all composer maps in the scene.
QgsMapRenderer * mapRenderer()
Returns pointer to map renderer of qgis map canvas.
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
QgsCoordinateTransform mTransform
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
int numPages() const
Note: added in version 1.9.
void endRender()
Ends the rendering.
void readXML(const QDomElement &elem, const QDomDocument &doc)
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
double xMaximum() const
Get the x maximum value (right side of rectangle)
const QgsCoordinateReferenceSystem & destinationCrs() const
returns CRS of destination coordinate reference system
const QgsMapRenderer * mapRenderer() const
This class wraps a request for features to a vector layer (or directly its vector data provider)...
void setNewExtent(const QgsRectangle &extent)
Sets new Extent and changes width, height (and implicitely also scale)
const QgsAttributes & attributes() const
size_t mSortKeyAttributeIdx
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry.
void prepareForFeature(size_t i)
Prepare the atlas map for the given feature.
void setCoverageLayer(QgsVectorLayer *lmap)
void writeXML(QDomElement &elem, QDomDocument &doc) const
Graphics scene for map printing.
Object representing map window.
QgsComposition * mComposition
bool operator()(const QgsFeatureId &id1, const QgsFeatureId &id2)
int id() const
Get identification number.
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
QgsRectangle extent() const
FieldSorter(QgsAtlasComposition::SorterKeys &keys, bool ascending=true)
Class for storing a coordinate reference system (CRS)
QgsComposerMap * mComposerMap
const QMap< QString, QgsMapLayer * > & mapLayers()
Retrieve the mapLayers collection (mainly intended for use by projection)
void parameterChanged()
emitted when one of the parameters changes
int transform(const QgsCoordinateTransform &ct)
Transform this geometry as described by CoordinateTranasform ct.
QgsFeature mCurrentFeature
const QgsCoordinateReferenceSystem & crs() const
Returns layer's spatial reference system.
const QString & currentFilename() const
Returns the current filename.
std::auto_ptr< QgsExpression > mFilenameExpr
const QgsFields & pendingFields() const
returns field list in the to-be-committed state
std::vector< QgsFeatureId > mFeatureIds
static void setSpecialColumn(const QString &name, QVariant value)
Assign a special column.
bool nextFeature(QgsFeature &f)
void composerItems(QList< T * > &itemList)
Return composer items of a specific type.
double width() const
Width of the rectangle.
Represents a vector layer which manages a vector based data sets.
double xMinimum() const
Get the x minimum value (left side of rectangle)
QStringList & layerSet()
returns current layer set
QgsAtlasComposition::SorterKeys & mKeys
double height() const
Height of the rectangle.
void scale(double scaleFactor, const QgsPoint *c=0)
Scale the rectangle around its center point.