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 )
378 QgsExpression::setSpecialColumn(
"$feature", QVariant((
int )featureI + 1 ) );
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() );