32 mComposition( composition ),
34 mHideCoverage( false ), mFilenamePattern(
"'output_'||$feature" ),
35 mCoverageLayer( 0 ), mSingleFile( false ),
36 mSortFeatures( false ), mSortAscending( true ), mCurrentFeatureNo( 0 ),
37 mFilterFeatures( false ), mFeatureFilter(
"" )
81 QList<QgsComposerMap*> maps;
83 for ( QList<QgsComposerMap*>::iterator mit = maps.begin(); mit != maps.end(); ++mit )
166 if (
mKeys[ id1 ].type() == QVariant::Int )
168 result =
mKeys[ id1 ].toInt() <
mKeys[ id2 ].toInt();
170 else if (
mKeys[ id1 ].type() == QVariant::Double )
172 result =
mKeys[ id1 ].toDouble() <
mKeys[ id2 ].toDouble();
174 else if (
mKeys[ id1 ].type() == QVariant::String )
176 result = ( QString::localeAwareCompare(
mKeys[ id1 ].toString(),
mKeys[ id2 ].toString() ) < 0 );
200 std::auto_ptr<QgsExpression> filterExpression;
204 if ( filterExpression->hasParserError() )
206 throw std::runtime_error(
tr(
"Feature filter parser error: %1" ).arg( filterExpression->parserErrorString() ).toLocal8Bit().data() );
220 if ( filterExpression->hasEvalError() )
222 throw std::runtime_error(
tr(
"Feature filter eval error: %1" ).arg( filterExpression->evalErrorString() ).toLocal8Bit().data() );
226 if ( !result.toBool() )
267 if ( !featuresUpdated )
288 QList<QgsComposerLabel*> labels;
290 for ( QList<QgsComposerLabel*>::iterator lit = labels.begin(); lit != labels.end(); ++lit )
292 ( *lit )->setExpressionContext( 0, 0 );
301 QList<QgsComposerMap*> maps;
303 for ( QList<QgsComposerMap*>::iterator mit = maps.begin(); mit != maps.end(); ++mit )
384 QList<QgsComposerLabel*> labels;
386 for ( QList<QgsComposerLabel*>::iterator lit = labels.begin(); lit != labels.end(); ++lit )
392 QList<QgsComposerShape*> shapes;
394 for ( QList<QgsComposerShape*>::iterator lit = shapes.begin(); lit != shapes.end(); ++lit )
400 QList<QgsPaperItem*> pages;
402 for ( QList<QgsPaperItem*>::iterator pageIt = pages.begin(); pageIt != pages.end(); ++pageIt )
404 ( *pageIt )->update();
412 QList<QgsComposerMap*> maps;
413 QList<QgsComposerMap*> atlasMaps;
415 for ( QList<QgsComposerMap*>::iterator mit = maps.begin(); mit != maps.end(); ++mit )
422 atlasMaps << currentMap;
428 if ( atlasMaps.isEmpty() )
440 for ( QList<QgsComposerMap*>::iterator mit = atlasMaps.begin(); mit != atlasMaps.end(); ++mit )
489 double geom_center_x = ( xa1 + xa2 ) / 2.0;
490 double geom_center_y = ( ya1 + ya2 ) / 2.0;
491 double xx = geom_center_x - mOrigExtent.
width() / 2.0;
492 double yy = geom_center_y - mOrigExtent.
height() / 2.0;
495 xx + mOrigExtent.
width(),
496 yy + mOrigExtent.
height() );
503 double map_ratio = mOrigExtent.
width() / mOrigExtent.
height();
506 if ( geom_ratio < map_ratio )
514 else if ( geom_ratio > map_ratio )
540 QDomElement atlasElem = doc.createElement(
"Atlas" );
541 atlasElem.setAttribute(
"enabled",
mEnabled ?
"true" :
"false" );
553 atlasElem.setAttribute(
"coverageLayer",
"" );
556 atlasElem.setAttribute(
"hideCoverage",
mHideCoverage ?
"true" :
"false" );
557 atlasElem.setAttribute(
"singleFile",
mSingleFile ?
"true" :
"false" );
560 atlasElem.setAttribute(
"sortFeatures",
mSortFeatures ?
"true" :
"false" );
564 atlasElem.setAttribute(
"sortAscending",
mSortAscending ?
"true" :
"false" );
566 atlasElem.setAttribute(
"filterFeatures",
mFilterFeatures ?
"true" :
"false" );
572 elem.appendChild( atlasElem );
577 mEnabled = atlasElem.attribute(
"enabled",
"false" ) ==
"true" ?
true :
false;
588 for ( QMap<QString, QgsMapLayer*>::const_iterator it = layers.begin(); it != layers.end(); ++it )
590 if ( it.key() == atlasElem.attribute(
"coverageLayer" ) )
597 int composerMapNo = atlasElem.attribute(
"composerMap",
"-1" ).toInt();
599 if ( composerMapNo != -1 )
601 QList<QgsComposerMap*> maps;
603 for ( QList<QgsComposerMap*>::iterator it = maps.begin(); it != maps.end(); ++it )
605 if (( *it )->id() == composerMapNo )
607 composerMap = ( *it );
613 mHideCoverage = atlasElem.attribute(
"hideCoverage",
"false" ) ==
"true" ?
true :
false;
616 double margin = atlasElem.attribute(
"margin",
"0.0" ).toDouble();
617 if ( composerMap && margin != 0 )
621 bool fixedScale = atlasElem.attribute(
"fixedScale",
"false" ) ==
"true" ?
true :
false;
622 if ( composerMap && fixedScale )
627 mSingleFile = atlasElem.attribute(
"singleFile",
"false" ) ==
"true" ?
true :
false;
630 mSortFeatures = atlasElem.attribute(
"sortFeatures",
"false" ) ==
"true" ?
true :
false;
634 mSortAscending = atlasElem.attribute(
"sortAscending",
"true" ) ==
"true" ?
true :
false;
636 mFilterFeatures = atlasElem.attribute(
"filterFeatures",
"false" ) ==
"true" ?
true :
false;
675 throw std::runtime_error(
tr(
"Filename parsing error: %1" ).arg(
mFilenameExpr->parserErrorString() ).toLocal8Bit().data() );
698 throw std::runtime_error(
tr(
"Filename eval error: %1" ).arg(
mFilenameExpr->evalErrorString() ).toLocal8Bit().data() );
QgsFeatureId id() const
Get the feature id for this feature.
Class for parsing and evaluation of expressions (formerly called "search strings").
QMap< QgsFeatureId, QVariant > SorterKeys
Wrapper for iterator of features from vector data provider or vector layer.
QgsComposition::AtlasMode atlasMode() const
Returns the current atlas mode of the composition.
A rectangle specified with double values.
bool isEmpty() const
test if rectangle is empty
QgsVectorLayer * mCoverageLayer
QVector< QgsFeatureId > mFeatureIds
void setNewAtlasFeatureExtent(const QgsRectangle &extent)
Sets new Extent for the current atlas preview and changes width, height (and implicitely also scale)...
QgsAtlasComposition(QgsComposition *composition)
double yMaximum() const
Get the y maximum value (top side of rectangle)
double atlasMargin() const
Returns the margin size (percentage) used when the map is in atlas mode.
void computeExtent(QgsComposerMap *map)
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.
bool fixedScale() const
Returns whether the atlas map uses a fixed scale.
Container of fields for a vector layer.
QgsCoordinateTransform mTransform
void toggled(bool)
emitted when atlas is enabled or disabled
void setHideCoverage(bool hide)
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
void evalFeatureFilename()
Evaluates filename for current feature.
int numPages() const
Note: added in version 1.9.
void endRender()
Ends the rendering.
void readXML(const QDomElement &elem, const QDomDocument &doc)
void setFixedScale(bool fixed)
Sets whether the atlas map should use a fixed scale.
float margin() const
Returns the margin for the atlas map.
void setAtlasMargin(double margin)
Sets the margin size (percentage) used when the map is in atlas mode.
QgsRectangle mTransformedFeatureBounds
bool beginRender()
Begins the rendering.
void setComposerMap(QgsComposerMap *map)
Sets the map used by the atlas.
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
double xMaximum() const
Get the x maximum value (right side of rectangle)
void prepareMap(QgsComposerMap *map)
Recalculates the bounds of an atlas driven map.
void statusMsgChanged(QString message)
Is emitted when the atlas has an updated status bar message for the composer window.
const QgsCoordinateReferenceSystem & destinationCrs() const
returns CRS of destination coordinate reference system
const QgsMapRenderer * mapRenderer() const
bool setAtlasMode(QgsComposition::AtlasMode mode)
Sets the current atlas mode of the composition.
void prepareForFeature(int i)
Prepare the atlas map for the given feature.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
int numFeatures() const
Returns the number of features in the coverage layer.
const QgsAttributes & attributes() const
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry.
void updateFilenameExpression()
Updates the filename expression.
bool atlasFixedScale() const
Returns true if the map uses a fixed scale when in atlas mode.
void setCoverageLayer(QgsVectorLayer *lmap)
int updateFeatures()
Requeries the current atlas coverage layer and applies filtering and sorting.
void writeXML(QDomElement &elem, QDomDocument &doc) const
Graphics scene for map printing.
Object representing map window.
QgsComposition * mComposition
void coverageLayerChanged(QgsVectorLayer *layer)
Is emitted when the coverage layer for an atlas changes.
bool operator()(const QgsFeatureId &id1, const QgsFeatureId &id2)
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
QgsRectangle extent() const
FieldSorter(QgsAtlasComposition::SorterKeys &keys, bool ascending=true)
QgsComposerMap * composerMap() const
Returns the map used by the atlas.
void setMargin(float margin)
Sets the margin for the atlas map.
Class for storing a coordinate reference system (CRS)
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.
void setFilenamePattern(const QString &pattern)
void setAtlasFixedScale(bool fixed)
Set to true if the map should use a fixed scale when in atlas mode.
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
bool atlasDriven() const
Returns true if the map extent is set to follow the current atlas feature.
const QgsFields & pendingFields() const
returns field list in the to-be-committed state
static void setSpecialColumn(const QString &name, QVariant value)
Assign a special column.
void setAtlasDriven(bool enabled)
Set to true if the map extents should be set by the current atlas feature.
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)
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.