49 #include <QDomDocument>
50 #include <QDomElement>
51 #include <QGraphicsRectItem>
52 #include <QGraphicsView>
62 , mMapRenderer( mapRenderer )
63 , mMapSettings( mapRenderer->mapSettings() )
64 , mAtlasComposition( this )
72 , mMapSettings( mapSettings )
73 , mAtlasComposition( this )
84 mSpaceBetweenPages = 10;
86 mPrintAsRaster =
false;
87 mGenerateWorldFile =
false;
89 mUseAdvancedEffects =
true;
92 mSnapGridResolution = 0;
95 mAlignmentSnap =
true;
96 mGuidesVisible =
true;
99 mBoundingBoxesVisible =
true;
100 mSelectionHandles = 0;
101 mActiveItemCommand = 0;
102 mActiveMultiFrameCommand = 0;
104 mPreventCursorChange =
false;
106 mUndoStack =
new QUndoStack();
123 connect( &mAtlasComposition, SIGNAL( toggled(
bool ) ),
this, SLOT( prepareAllDataDefinedExpressions() ) );
124 connect( &mAtlasComposition, SIGNAL( coverageLayerChanged(
QgsVectorLayer* ) ),
this, SLOT( prepareAllDataDefinedExpressions() ) );
126 setBackgroundBrush( QColor( 215, 215, 215 ) );
127 createDefaultPageStyleSymbol();
135 addItem( mSelectionHandles );
136 mSelectionHandles->hide();
137 mSelectionHandles->setZValue( 500 );
139 mPrintResolution = 300;
189 deleteAndRemoveMultiFrames();
194 QList<QGraphicsItem*> itemList = items();
195 qDeleteAll( itemList );
198 qDeleteAll( mDataDefinedProperties );
199 mDataDefinedProperties.clear();
206 delete mActiveItemCommand;
207 delete mActiveMultiFrameCommand;
208 delete mPageStyleSymbol;
212 void QgsComposition::loadDefaults()
215 mSnapGridResolution = settings.value(
"/Composer/defaultSnapGridResolution", 10.0 ).toDouble();
216 mSnapGridOffsetX = settings.value(
"/Composer/defaultSnapGridOffsetX", 0 ).toDouble();
217 mSnapGridOffsetY = settings.value(
"/Composer/defaultSnapGridOffsetY", 0 ).toDouble();
218 mSnapTolerance = settings.value(
"/Composer/defaultSnapTolerancePixels", 5 ).toInt();
223 setSceneRect( compositionBounds() );
230 QList<QgsComposerMap*> maps;
232 QList<QgsComposerMap*>::iterator mapIt = maps.begin();
233 for ( ; mapIt != maps.end(); ++mapIt )
236 ( *mapIt )->update();
256 QList<QGraphicsItem *> selectedItemList = selectedItems();
257 QList<QGraphicsItem *>::iterator itemIter = selectedItemList.begin();
259 for ( ; itemIter != selectedItemList.end(); ++itemIter )
284 QRectF QgsComposition::compositionBounds()
const
287 QRectF bounds = QRectF( 0, 0, 0, 0 );
290 QList<QGraphicsItem *> itemList = items();
291 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
292 for ( ; itemIt != itemList.end(); ++itemIt )
296 if (( composerItem || paperItem ) )
299 bounds = bounds.united(( *itemIt )->sceneBoundingRect() );
304 bounds.adjust( -mPageWidth * 0.05, -mPageWidth * 0.05, mPageWidth * 0.05, mPageWidth * 0.05 );
311 if ( width == mPageWidth && height == mPageHeight )
317 QList<QGraphicsItem *> itemList = items();
318 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
319 for ( ; itemIt != itemList.end(); ++itemIt )
328 QList< QGraphicsLineItem* >* guides =
snapLines();
329 QList< QGraphicsLineItem* >::iterator guideIt = guides->begin();
331 for ( ; guideIt != guides->end(); ++guideIt )
333 QLineF line = ( *guideIt )->line();
334 if ( line.dx() == 0 )
337 ( *guideIt )->setLine( line.x1(), 0, line.x1(), totalHeight );
346 ( *guideIt )->setLine( 0, newY, width, newY );
351 mPageHeight = height;
353 for (
int i = 0; i < mPages.size(); ++i )
355 mPages.at( i )->setSceneRect( QRectF( 0, currentY, width, height ) );
356 currentY += ( height + mSpaceBetweenPages );
376 int desiredPages =
pages;
383 int pagesD = exprVal.toInt( &ok );
384 QgsDebugMsg( QString(
"exprVal NumPages:%1" ).arg( pagesD ) );
387 desiredPages = pagesD;
391 int diff = desiredPages - currentPages;
394 for (
int i = 0; i < diff; ++i )
402 for (
int i = 0; i < diff; ++i )
404 delete mPages.last();
410 QList< QGraphicsLineItem* >* guides =
snapLines();
411 QList< QGraphicsLineItem* >::iterator guideIt = guides->begin();
412 double totalHeight = ( mPageHeight +
spaceBetweenPages() ) * ( pages - 1 ) + mPageHeight;
413 for ( ; guideIt != guides->end(); ++guideIt )
415 QLineF line = ( *guideIt )->line();
416 if ( line.dx() == 0 )
419 ( *guideIt )->setLine( line.x1(), 0, line.x1(), totalHeight );
434 return mPages.size();
440 QList<QgsComposerItem*> items;
445 QList<QgsComposerItem*>::const_iterator itemIt = items.constBegin();
446 for ( ; itemIt != items.constEnd(); ++itemIt )
462 if ( page >
numPages() || page < 1 )
469 QList<QgsComposerFrame*> frames;
472 QList<QgsComposerFrame*>::const_iterator frameIt = frames.constBegin();
473 for ( ; frameIt != frames.constEnd(); ++frameIt )
475 if (( *frameIt )->hidePageIfEmpty() && ( *frameIt )->isEmpty() )
486 delete mPageStyleSymbol;
487 mPageStyleSymbol = symbol;
491 void QgsComposition::createDefaultPageStyleSymbol()
493 delete mPageStyleSymbol;
495 properties.insert(
"color",
"white" );
496 properties.insert(
"style",
"solid" );
497 properties.insert(
"style_border",
"no" );
498 properties.insert(
"joinstyle",
"miter" );
516 return QPointF( position.x(), y );
522 pageNumber = pageNumber < 1 ? 1 : pageNumber;
523 pageNumber = pageNumber > mPages.size() ? mPages.size() : pageNumber;
540 QList<QGraphicsItem*> itemList;
541 itemList = items( position, Qt::IntersectsItemShape, Qt::DescendingOrder );
542 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
544 bool foundBelowItem =
false;
545 for ( ; itemIt != itemList.end(); ++itemIt )
549 if ( composerItem && !paperItem )
553 if (( ! belowItem || foundBelowItem ) && ( !ignoreLocked || !composerItem->
positionLock() ) )
559 if ( composerItem == belowItem )
562 foundBelowItem =
true;
577 return pageNumberAt( QPointF( item->pos().x(), item->pos().y() ) );
582 QList<QgsComposerItem*> composerItemList;
584 QList<QGraphicsItem *> graphicsItemList = selectedItems();
585 QList<QGraphicsItem *>::iterator itemIter = graphicsItemList.begin();
587 for ( ; itemIter != graphicsItemList.end(); ++itemIter )
590 if ( composerItem && ( includeLockedItems || !composerItem->
positionLock() ) )
592 composerItemList.push_back( composerItem );
596 return composerItemList;
601 QList<const QgsComposerMap*> resultList;
603 QList<QGraphicsItem *> itemList = items();
604 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
605 for ( ; itemIt != itemList.end(); ++itemIt )
610 resultList.push_back( composerMap );
619 QList<QGraphicsItem *> itemList = items();
620 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
621 for ( ; itemIt != itemList.end(); ++itemIt )
626 if ( composerMap->
id() == id )
656 QList<QGraphicsItem *> itemList = items();
657 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
658 for ( ; itemIt != itemList.end(); ++itemIt )
663 if ( mypItem->
id() == theId )
676 QSet<QgsComposer*> composers = QSet<QgsComposer*>();
678 if ( inAllComposers )
680 composers = QgisApp::instance()->printComposers();
684 composers.insert(
this )
687 QSet<QgsComposer*>::const_iterator it = composers.constBegin();
688 for ( ; it != composers.constEnd(); ++it )
690 QList<QGraphicsItem *> itemList = ( *it )->items();
691 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
692 for ( ; itemIt != itemList.end(); ++itemIt )
697 if ( mypItem->
uuid() == theUuid )
711 QList<QGraphicsItem *> itemList = items();
712 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
713 for ( ; itemIt != itemList.end(); ++itemIt )
718 if ( mypItem->
uuid() == theUuid )
730 mPrintResolution = dpi;
737 mUseAdvancedEffects = effectsEnabled;
740 QList<QGraphicsItem*> itemList = items();
741 QList<QGraphicsItem*>::const_iterator itemIt = itemList.constBegin();
742 for ( ; itemIt != itemList.constEnd(); ++itemIt )
764 if ( composerElem.isNull() )
769 QDomElement compositionElem = doc.createElement(
"Composition" );
770 compositionElem.setAttribute(
"paperWidth", QString::number( mPageWidth ) );
771 compositionElem.setAttribute(
"paperHeight", QString::number( mPageHeight ) );
772 compositionElem.setAttribute(
"numPages", mPages.size() );
775 compositionElem.appendChild( pageStyleElem );
780 compositionElem.setAttribute(
"snapping",
"1" );
784 compositionElem.setAttribute(
"snapping",
"0" );
788 compositionElem.setAttribute(
"gridVisible",
"1" );
792 compositionElem.setAttribute(
"gridVisible",
"0" );
794 compositionElem.setAttribute(
"snapGridResolution", QString::number( mSnapGridResolution ) );
795 compositionElem.setAttribute(
"snapGridOffsetX", QString::number( mSnapGridOffsetX ) );
796 compositionElem.setAttribute(
"snapGridOffsetY", QString::number( mSnapGridOffsetY ) );
799 QList< QGraphicsLineItem* >::const_iterator snapLineIt = mSnapLines.constBegin();
800 for ( ; snapLineIt != mSnapLines.constEnd(); ++snapLineIt )
802 QDomElement snapLineElem = doc.createElement(
"SnapLine" );
803 QLineF line = ( *snapLineIt )->line();
804 snapLineElem.setAttribute(
"x1", QString::number( line.x1() ) );
805 snapLineElem.setAttribute(
"y1", QString::number( line.y1() ) );
806 snapLineElem.setAttribute(
"x2", QString::number( line.x2() ) );
807 snapLineElem.setAttribute(
"y2", QString::number( line.y2() ) );
808 compositionElem.appendChild( snapLineElem );
811 compositionElem.setAttribute(
"printResolution", mPrintResolution );
812 compositionElem.setAttribute(
"printAsRaster", mPrintAsRaster );
814 compositionElem.setAttribute(
"generateWorldFile", mGenerateWorldFile ? 1 : 0 );
815 if ( mGenerateWorldFile && mWorldFileMap )
817 compositionElem.setAttribute(
"worldFileMap", mWorldFileMap->
id() );
820 compositionElem.setAttribute(
"alignmentSnap", mAlignmentSnap ? 1 : 0 );
821 compositionElem.setAttribute(
"guidesVisible", mGuidesVisible ? 1 : 0 );
822 compositionElem.setAttribute(
"smartGuides", mSmartGuides ? 1 : 0 );
823 compositionElem.setAttribute(
"snapTolerancePixels", mSnapTolerance );
826 QList<QGraphicsItem*> itemList = items();
827 QList<QGraphicsItem*>::const_iterator itemIt = itemList.constBegin();
828 for ( ; itemIt != itemList.constEnd(); ++itemIt )
835 composerItem->
writeXML( compositionElem, doc );
841 QSet<QgsComposerMultiFrame*>::const_iterator multiFrameIt = mMultiFrames.constBegin();
842 for ( ; multiFrameIt != mMultiFrames.constEnd(); ++multiFrameIt )
844 ( *multiFrameIt )->writeXML( compositionElem, doc );
846 composerElem.appendChild( compositionElem );
857 if ( compositionElem.isNull() )
863 bool widthConversionOk, heightConversionOk;
864 mPageWidth = compositionElem.attribute(
"paperWidth" ).toDouble( &widthConversionOk );
865 mPageHeight = compositionElem.attribute(
"paperHeight" ).toDouble( &heightConversionOk );
867 int numPages = compositionElem.attribute(
"numPages",
"1" ).toInt();
869 QDomElement pageStyleSymbolElem = compositionElem.firstChildElement(
"symbol" );
870 if ( !pageStyleSymbolElem.isNull() )
872 delete mPageStyleSymbol;
873 mPageStyleSymbol = QgsSymbolLayerV2Utils::loadSymbol<QgsFillSymbolV2>( pageStyleSymbolElem );
876 if ( widthConversionOk && heightConversionOk )
879 for (
int i = 0; i <
numPages; ++i )
886 mSnapToGrid = compositionElem.attribute(
"snapping",
"0" ).toInt() == 0 ?
false :
true;
887 mGridVisible = compositionElem.attribute(
"gridVisible",
"0" ).toInt() == 0 ?
false :
true;
889 mSnapGridResolution = compositionElem.attribute(
"snapGridResolution" ).toDouble();
890 mSnapGridOffsetX = compositionElem.attribute(
"snapGridOffsetX" ).toDouble();
891 mSnapGridOffsetY = compositionElem.attribute(
"snapGridOffsetY" ).toDouble();
893 mAlignmentSnap = compositionElem.attribute(
"alignmentSnap",
"1" ).toInt() == 0 ?
false :
true;
894 mGuidesVisible = compositionElem.attribute(
"guidesVisible",
"1" ).toInt() == 0 ?
false :
true;
895 mSmartGuides = compositionElem.attribute(
"smartGuides",
"1" ).toInt() == 0 ?
false :
true;
896 mSnapTolerance = compositionElem.attribute(
"snapTolerancePixels",
"10" ).toInt();
899 QDomNodeList snapLineNodes = compositionElem.elementsByTagName(
"SnapLine" );
900 for (
int i = 0; i < snapLineNodes.size(); ++i )
902 QDomElement snapLineElem = snapLineNodes.at( i ).toElement();
904 double x1 = snapLineElem.attribute(
"x1" ).toDouble();
905 double y1 = snapLineElem.attribute(
"y1" ).toDouble();
906 double x2 = snapLineElem.attribute(
"x2" ).toDouble();
907 double y2 = snapLineElem.attribute(
"y2" ).toDouble();
908 snapItem->setLine( x1, y1, x2, y2 );
911 mPrintAsRaster = compositionElem.attribute(
"printAsRaster" ).toInt();
912 mPrintResolution = compositionElem.attribute(
"printResolution",
"300" ).toInt();
914 mGenerateWorldFile = compositionElem.attribute(
"generateWorldFile",
"0" ).toInt() == 1 ?
true :
false;
928 if ( clearComposition )
930 deleteAndRemoveMultiFrames();
933 QList<QGraphicsItem *> itemList = items();
934 QList<QGraphicsItem *>::iterator itemIter = itemList.begin();
935 for ( ; itemIter != itemList.end(); ++itemIter )
939 if ( cItem && !pItem )
946 mItemsModel->
clear();
952 QDomDocument importDoc;
953 if ( substitutionMap )
955 QString xmlString = doc.toString();
956 QMap<QString, QString>::const_iterator sIt = substitutionMap->constBegin();
957 for ( ; sIt != substitutionMap->constEnd(); ++sIt )
959 xmlString = xmlString.replace(
"[" + sIt.key() +
"]", encodeStringForXML( sIt.value() ) );
963 int errorLine, errorColumn;
964 if ( !importDoc.setContent( xmlString, &errorMsg, &errorLine, &errorColumn ) )
975 QDomElement atlasElem;
976 if ( clearComposition )
978 QDomElement compositionElem = importDoc.documentElement().firstChildElement(
"Composition" );
979 if ( compositionElem.isNull() )
984 bool ok =
readXML( compositionElem, importDoc );
991 atlasElem = importDoc.documentElement().firstChildElement(
"Atlas" );
996 QDomNodeList composerItemsNodes = importDoc.elementsByTagName(
"ComposerItem" );
997 for (
int i = 0; i < composerItemsNodes.count(); ++i )
999 QDomNode composerItemNode = composerItemsNodes.at( i );
1000 if ( composerItemNode.isElement() )
1002 composerItemNode.toElement().setAttribute(
"templateUuid", composerItemNode.toElement().attribute(
"uuid" ) );
1003 composerItemNode.toElement().removeAttribute(
"uuid" );
1008 addItemsFromXML( importDoc.documentElement(), importDoc, 0, addUndoCommands, 0 );
1012 if ( clearComposition )
1019 QPointF QgsComposition::minPointFromXml(
const QDomElement& elem )
const
1023 QDomNodeList composerItemList = elem.elementsByTagName(
"ComposerItem" );
1024 for (
int i = 0; i < composerItemList.size(); ++i )
1026 QDomElement currentComposerItemElem = composerItemList.at( i ).toElement();
1029 x = currentComposerItemElem.attribute(
"x" ).toDouble( &xOk );
1030 y = currentComposerItemElem.attribute(
"y" ).toDouble( &yOk );
1035 minX = qMin( minX, x );
1036 minY = qMin( minY, y );
1040 return QPointF( minX, minY );
1044 return QPointF( 0, 0 );
1049 bool addUndoCommands, QPointF* pos,
bool pasteInPlace )
1051 QPointF* pasteInPlacePt = 0;
1058 QPointF pasteShiftPos;
1065 QPointF minItemPos = minPointFromXml( elem );
1068 pasteShiftPos = *pos - minItemPos;
1075 pasteInPlacePt =
new QPointF( 0,
pageNumberAt( *pos ) * ( mPageHeight + mSpaceBetweenPages ) );
1078 QDomNodeList composerLabelList = elem.elementsByTagName(
"ComposerLabel" );
1079 for (
int i = 0; i < composerLabelList.size(); ++i )
1081 QDomElement currentComposerLabelElem = composerLabelList.at( i ).toElement();
1083 newLabel->
readXML( currentComposerLabelElem, doc );
1086 if ( pasteInPlacePt )
1089 newLabel->
move( pasteInPlacePt->x(), pasteInPlacePt->y() );
1093 newLabel->
move( pasteShiftPos.x(), pasteShiftPos.y() );
1096 lastPastedItem = newLabel;
1099 newLabel->setZValue( newLabel->zValue() + zOrderOffset );
1100 if ( addUndoCommands )
1106 QDomNodeList composerMapList = elem.elementsByTagName(
"ComposerMap" );
1107 for (
int i = 0; i < composerMapList.size(); ++i )
1109 QDomElement currentComposerMapElem = composerMapList.at( i ).toElement();
1112 if ( mapsToRestore )
1117 newMap->
readXML( currentComposerMapElem, doc );
1120 if ( mapsToRestore )
1122 mapsToRestore->insert( newMap, (
int )( newMap->
previewMode() ) );
1127 newMap->setZValue( newMap->zValue() + zOrderOffset );
1133 newMap->
move( pasteInPlacePt->x(), pasteInPlacePt->y() );
1137 newMap->
move( pasteShiftPos.x(), pasteShiftPos.y() );
1140 lastPastedItem = newMap;
1143 if ( addUndoCommands )
1149 QList<QgsComposerMap*> maps;
1151 for ( QList<QgsComposerMap*>::iterator mit = maps.begin(); mit != maps.end(); ++mit )
1156 QList<QgsComposerMapOverview* > overviews = map->
overviews()->
asList();
1157 QList<QgsComposerMapOverview* >::iterator overviewIt = overviews.begin();
1158 for ( ; overviewIt != overviews.end(); ++overviewIt )
1160 ( *overviewIt )->connectSignals();
1166 QDomNodeList composerArrowList = elem.elementsByTagName(
"ComposerArrow" );
1167 for (
int i = 0; i < composerArrowList.size(); ++i )
1169 QDomElement currentComposerArrowElem = composerArrowList.at( i ).toElement();
1171 newArrow->
readXML( currentComposerArrowElem, doc );
1177 newArrow->
move( pasteInPlacePt->x(), pasteInPlacePt->y() );
1181 newArrow->
move( pasteShiftPos.x(), pasteShiftPos.y() );
1184 lastPastedItem = newArrow;
1187 newArrow->setZValue( newArrow->zValue() + zOrderOffset );
1188 if ( addUndoCommands )
1194 QDomNodeList composerScaleBarList = elem.elementsByTagName(
"ComposerScaleBar" );
1195 for (
int i = 0; i < composerScaleBarList.size(); ++i )
1197 QDomElement currentComposerScaleBarElem = composerScaleBarList.at( i ).toElement();
1199 newScaleBar->
readXML( currentComposerScaleBarElem, doc );
1205 newScaleBar->
move( pasteInPlacePt->x(), pasteInPlacePt->y() );
1209 newScaleBar->
move( pasteShiftPos.x(), pasteShiftPos.y() );
1212 lastPastedItem = newScaleBar;
1215 newScaleBar->setZValue( newScaleBar->zValue() + zOrderOffset );
1216 if ( addUndoCommands )
1222 QDomNodeList composerShapeList = elem.elementsByTagName(
"ComposerShape" );
1223 for (
int i = 0; i < composerShapeList.size(); ++i )
1225 QDomElement currentComposerShapeElem = composerShapeList.at( i ).toElement();
1227 newShape->
readXML( currentComposerShapeElem, doc );
1235 newShape->
move( pasteInPlacePt->x(), pasteInPlacePt->y() );
1239 newShape->
move( pasteShiftPos.x(), pasteShiftPos.y() );
1242 lastPastedItem = newShape;
1245 newShape->setZValue( newShape->zValue() + zOrderOffset );
1246 if ( addUndoCommands )
1252 QDomNodeList composerPictureList = elem.elementsByTagName(
"ComposerPicture" );
1253 for (
int i = 0; i < composerPictureList.size(); ++i )
1255 QDomElement currentComposerPictureElem = composerPictureList.at( i ).toElement();
1257 newPicture->
readXML( currentComposerPictureElem, doc );
1263 newPicture->
move( pasteInPlacePt->x(), pasteInPlacePt->y() );
1267 newPicture->
move( pasteShiftPos.x(), pasteShiftPos.y() );
1270 lastPastedItem = newPicture;
1273 newPicture->setZValue( newPicture->zValue() + zOrderOffset );
1274 if ( addUndoCommands )
1280 QDomNodeList composerLegendList = elem.elementsByTagName(
"ComposerLegend" );
1281 for (
int i = 0; i < composerLegendList.size(); ++i )
1283 QDomElement currentComposerLegendElem = composerLegendList.at( i ).toElement();
1285 newLegend->
readXML( currentComposerLegendElem, doc );
1291 newLegend->
move( pasteInPlacePt->x(), pasteInPlacePt->y() );
1295 newLegend->
move( pasteShiftPos.x(), pasteShiftPos.y() );
1298 lastPastedItem = newLegend;
1301 newLegend->setZValue( newLegend->zValue() + zOrderOffset );
1302 if ( addUndoCommands )
1308 QDomNodeList composerTableList = elem.elementsByTagName(
"ComposerAttributeTable" );
1309 for (
int i = 0; i < composerTableList.size(); ++i )
1311 QDomElement currentComposerTableElem = composerTableList.at( i ).toElement();
1313 newTable->
readXML( currentComposerTableElem, doc );
1319 newTable->
move( pasteInPlacePt->x(), pasteInPlacePt->y() );
1323 newTable->
move( pasteShiftPos.x(), pasteShiftPos.y() );
1326 lastPastedItem = newTable;
1329 newTable->setZValue( newTable->zValue() + zOrderOffset );
1330 if ( addUndoCommands )
1337 QDomNodeList composerHtmlList = elem.elementsByTagName(
"ComposerHtml" );
1338 for (
int i = 0; i < composerHtmlList.size(); ++i )
1340 QDomElement currentHtmlElem = composerHtmlList.at( i ).toElement();
1342 newHtml->
readXML( currentHtmlElem, doc );
1354 QDomNodeList composerAttributeTableV2List = elem.elementsByTagName(
"ComposerAttributeTableV2" );
1355 for (
int i = 0; i < composerAttributeTableV2List.size(); ++i )
1357 QDomElement currentTableElem = composerAttributeTableV2List.at( i ).toElement();
1359 newTable->
readXML( currentTableElem, doc );
1375 QDomNodeList groupList = elem.elementsByTagName(
"ComposerItemGroup" );
1376 for (
int i = 0; i < groupList.size(); ++i )
1378 QDomElement groupElem = groupList.at( i ).toElement();
1380 newGroup->
readXML( groupElem, doc );
1381 addItem( newGroup );
1389 if ( lastPastedItem )
1394 delete pasteInPlacePt;
1424 QList<QgsComposerItem*>::iterator it = selectedItems.begin();
1425 bool itemsRaised =
false;
1426 for ( ; it != selectedItems.end(); ++it )
1428 itemsRaised = itemsRaised |
raiseItem( *it );
1462 if ( selectedItems.size() > 0 )
1464 previousSelectedItem = selectedItems.at( 0 );
1467 if ( !previousSelectedItem )
1474 switch ( direction )
1484 if ( !selectedItem )
1498 QList<QgsComposerItem*>::iterator it = selectedItems.begin();
1499 bool itemsLowered =
false;
1500 for ( ; it != selectedItems.end(); ++it )
1502 itemsLowered = itemsLowered |
lowerItem( *it );
1505 if ( !itemsLowered )
1525 QList<QgsComposerItem*>::iterator it = selectedItems.begin();
1526 bool itemsRaised =
false;
1527 for ( ; it != selectedItems.end(); ++it )
1552 QList<QgsComposerItem*>::iterator it = selectedItems.begin();
1553 bool itemsLowered =
false;
1554 for ( ; it != selectedItems.end(); ++it )
1559 if ( !itemsLowered )
1579 if ( selectedItems.size() < 2 )
1584 QRectF selectedItemBBox;
1585 if ( boundingRectOfSelectedItems( selectedItemBBox ) != 0 )
1590 double minXCoordinate = selectedItemBBox.left();
1593 QUndoCommand* parentCommand =
new QUndoCommand(
tr(
"Aligned items left" ) );
1594 QList<QgsComposerItem*>::iterator align_it = selectedItems.begin();
1595 for ( ; align_it != selectedItems.end(); ++align_it )
1599 ( *align_it )->setPos( minXCoordinate, ( *align_it )->pos().y() );
1602 mUndoStack->push( parentCommand );
1609 if ( selectedItems.size() < 2 )
1614 QRectF selectedItemBBox;
1615 if ( boundingRectOfSelectedItems( selectedItemBBox ) != 0 )
1620 double averageXCoord = ( selectedItemBBox.left() + selectedItemBBox.right() ) / 2.0;
1623 QUndoCommand* parentCommand =
new QUndoCommand(
tr(
"Aligned items horizontal center" ) );
1624 QList<QgsComposerItem*>::iterator align_it = selectedItems.begin();
1625 for ( ; align_it != selectedItems.end(); ++align_it )
1629 ( *align_it )->setPos( averageXCoord - ( *align_it )->rect().width() / 2.0, ( *align_it )->pos().y() );
1632 mUndoStack->push( parentCommand );
1639 if ( selectedItems.size() < 2 )
1644 QRectF selectedItemBBox;
1645 if ( boundingRectOfSelectedItems( selectedItemBBox ) != 0 )
1650 double maxXCoordinate = selectedItemBBox.right();
1653 QUndoCommand* parentCommand =
new QUndoCommand(
tr(
"Aligned items right" ) );
1654 QList<QgsComposerItem*>::iterator align_it = selectedItems.begin();
1655 for ( ; align_it != selectedItems.end(); ++align_it )
1659 ( *align_it )->setPos( maxXCoordinate - ( *align_it )->rect().width(), ( *align_it )->pos().y() );
1662 mUndoStack->push( parentCommand );
1669 if ( selectedItems.size() < 2 )
1674 QRectF selectedItemBBox;
1675 if ( boundingRectOfSelectedItems( selectedItemBBox ) != 0 )
1680 double minYCoordinate = selectedItemBBox.top();
1682 QUndoCommand* parentCommand =
new QUndoCommand(
tr(
"Aligned items top" ) );
1683 QList<QgsComposerItem*>::iterator align_it = selectedItems.begin();
1684 for ( ; align_it != selectedItems.end(); ++align_it )
1688 ( *align_it )->setPos(( *align_it )->pos().x(), minYCoordinate );
1691 mUndoStack->push( parentCommand );
1698 if ( selectedItems.size() < 2 )
1703 QRectF selectedItemBBox;
1704 if ( boundingRectOfSelectedItems( selectedItemBBox ) != 0 )
1709 double averageYCoord = ( selectedItemBBox.top() + selectedItemBBox.bottom() ) / 2.0;
1710 QUndoCommand* parentCommand =
new QUndoCommand(
tr(
"Aligned items vertical center" ) );
1711 QList<QgsComposerItem*>::iterator align_it = selectedItems.begin();
1712 for ( ; align_it != selectedItems.end(); ++align_it )
1716 ( *align_it )->setPos(( *align_it )->pos().x(), averageYCoord - ( *align_it )->rect().height() / 2 );
1719 mUndoStack->push( parentCommand );
1726 if ( selectedItems.size() < 2 )
1731 QRectF selectedItemBBox;
1732 if ( boundingRectOfSelectedItems( selectedItemBBox ) != 0 )
1737 double maxYCoord = selectedItemBBox.bottom();
1738 QUndoCommand* parentCommand =
new QUndoCommand(
tr(
"Aligned items bottom" ) );
1739 QList<QgsComposerItem*>::iterator align_it = selectedItems.begin();
1740 for ( ; align_it != selectedItems.end(); ++align_it )
1744 ( *align_it )->setPos(( *align_it )->pos().x(), maxYCoord - ( *align_it )->rect().height() );
1747 mUndoStack->push( parentCommand );
1753 QUndoCommand* parentCommand =
new QUndoCommand(
tr(
"Items locked" ) );
1755 QList<QgsComposerItem*>::iterator itemIter = selectionList.begin();
1756 for ( ; itemIter != selectionList.end(); ++itemIter )
1760 ( *itemIter )->setPositionLock(
true );
1765 mUndoStack->push( parentCommand );
1773 QUndoCommand* parentCommand =
new QUndoCommand(
tr(
"Items unlocked" ) );
1778 QList<QGraphicsItem *> itemList = items();
1779 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
1780 for ( ; itemIt != itemList.end(); ++itemIt )
1794 mUndoStack->push( parentCommand );
1800 if ( items.size() < 2 )
1808 QList<QgsComposerItem*>::iterator itemIter = items.begin();
1809 for ( ; itemIter != items.end(); ++itemIter )
1811 itemGroup->
addItem( *itemIter );
1814 addItem( itemGroup );
1820 QList<QgsComposerItem *> ungroupedItems;
1823 return ungroupedItems;
1826 QSet<QgsComposerItem*> groupedItems = group->
items();
1827 QSet<QgsComposerItem*>::iterator itemIt = groupedItems.begin();
1828 for ( ; itemIt != groupedItems.end(); ++itemIt )
1830 ungroupedItems << ( *itemIt );
1839 return ungroupedItems;
1842 void QgsComposition::updateZValues(
const bool addUndoCommands )
1845 QList<QgsComposerItem*>::const_iterator it = mItemsModel->
zOrderList()->constBegin();
1848 QUndoCommand* parentCommand = 0;
1849 if ( addUndoCommands )
1851 parentCommand =
new QUndoCommand(
tr(
"Item z-order changed" ) );
1853 for ( ; it != mItemsModel->
zOrderList()->constEnd(); ++it )
1859 if ( addUndoCommands )
1864 currentItem->setZValue( counter );
1865 if ( addUndoCommands )
1872 if ( addUndoCommands )
1874 mUndoStack->push( parentCommand );
1886 updateZValues(
false );
1891 if ( !mSnapToGrid || mSnapGridResolution <= 0 || !graphicsView() )
1897 int pageNr = ( int )( scenePoint.y() / ( mPageHeight + mSpaceBetweenPages ) );
1898 double yOffset = pageNr * ( mPageHeight + mSpaceBetweenPages );
1899 double yPage = scenePoint.y() - yOffset;
1902 int xRatio = ( int )(( scenePoint.x() - mSnapGridOffsetX ) / mSnapGridResolution + 0.5 );
1903 int yRatio = ( int )(( yPage - mSnapGridOffsetY ) / mSnapGridResolution + 0.5 );
1905 double xSnapped = xRatio * mSnapGridResolution + mSnapGridOffsetX;
1906 double ySnapped = yRatio * mSnapGridResolution + mSnapGridOffsetY + yOffset;
1909 double viewScaleFactor = graphicsView()->transform().m11();
1910 double alignThreshold = mSnapTolerance / viewScaleFactor;
1912 if ( fabs( xSnapped - scenePoint.x() ) > alignThreshold )
1915 xSnapped = scenePoint.x();
1917 if ( fabs( ySnapped - scenePoint.y() ) > alignThreshold )
1920 ySnapped = scenePoint.y();
1923 return QPointF( xSnapped, ySnapped );
1928 QGraphicsLineItem* item =
new QGraphicsLineItem();
1929 QPen linePen( Qt::SolidLine );
1930 linePen.setColor( Qt::red );
1933 linePen.setWidthF( 0 );
1934 item->setPen( linePen );
1935 item->setZValue( 100 );
1936 item->setVisible( mGuidesVisible );
1938 mSnapLines.push_back( item );
1945 mSnapLines.removeAll( line );
1951 QList< QGraphicsLineItem* >::iterator it = mSnapLines.begin();
1952 for ( ; it != mSnapLines.end(); ++it )
1954 removeItem(( *it ) );
1962 mGuidesVisible = visible;
1963 QList< QGraphicsLineItem* >::iterator it = mSnapLines.begin();
1964 for ( ; it != mSnapLines.end(); ++it )
1978 QList< QPair< QgsComposerItem*, QgsComposerItem::ItemPositionMode> >& snappedItems )
const
1980 double minSqrDist = DBL_MAX;
1981 QGraphicsLineItem* item = 0;
1982 double currentXCoord = 0;
1983 double currentYCoord = 0;
1984 double currentSqrDist = 0;
1985 double sqrTolerance = tolerance * tolerance;
1987 snappedItems.clear();
1989 QList< QGraphicsLineItem* >::const_iterator it = mSnapLines.constBegin();
1990 for ( ; it != mSnapLines.constEnd(); ++it )
1992 bool itemHorizontal =
qgsDoubleNear(( *it )->line().y2() - ( *it )->line().y1(), 0 );
1993 if ( horizontal && itemHorizontal )
1995 currentYCoord = ( *it )->line().y1();
1996 currentSqrDist = ( y - currentYCoord ) * ( y - currentYCoord );
1998 else if ( !horizontal && !itemHorizontal )
2000 currentXCoord = ( *it )->line().x1();
2001 currentSqrDist = ( x - currentXCoord ) * ( x - currentXCoord );
2008 if ( currentSqrDist < minSqrDist && currentSqrDist < sqrTolerance )
2011 minSqrDist = currentSqrDist;
2015 double itemTolerance = 0.0000001;
2019 QList<QGraphicsItem *> itemList = items();
2020 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
2021 for ( ; itemIt != itemList.end(); ++itemIt )
2031 if (
qgsDoubleNear( currentYCoord, currentItem->pos().y() + currentItem->rect().top(), itemTolerance ) )
2035 else if (
qgsDoubleNear( currentYCoord, currentItem->pos().y() + currentItem->rect().center().y(), itemTolerance ) )
2039 else if (
qgsDoubleNear( currentYCoord, currentItem->pos().y() + currentItem->rect().bottom(), itemTolerance ) )
2046 if (
qgsDoubleNear( currentXCoord, currentItem->pos().x(), itemTolerance ) )
2050 else if (
qgsDoubleNear( currentXCoord, currentItem->pos().x() + currentItem->rect().center().x(), itemTolerance ) )
2054 else if (
qgsDoubleNear( currentXCoord, currentItem->pos().x() + currentItem->rect().width(), itemTolerance ) )
2065 int QgsComposition::boundingRectOfSelectedItems( QRectF& bRect )
2068 if ( selectedItems.size() < 1 )
2075 double minX = currentItem->pos().x();
2076 double minY = currentItem->pos().y();
2077 double maxX = minX + currentItem->rect().width();
2078 double maxY = minY + currentItem->rect().height();
2080 double currentMinX, currentMinY, currentMaxX, currentMaxY;
2082 for (
int i = 1; i < selectedItems.size(); ++i )
2084 currentItem = selectedItems.at( i );
2085 currentMinX = currentItem->pos().x();
2086 currentMinY = currentItem->pos().y();
2087 currentMaxX = currentMinX + currentItem->rect().width();
2088 currentMaxY = currentMinY + currentItem->rect().height();
2090 if ( currentMinX < minX )
2092 if ( currentMaxX > maxX )
2094 if ( currentMinY < minY )
2096 if ( currentMaxY > maxY )
2100 bRect.setTopLeft( QPointF( minX, minY ) );
2101 bRect.setBottomRight( QPointF( maxX, maxY ) );
2119 mSnapGridResolution = r;
2125 mSnapGridOffsetX = offset;
2131 mSnapGridOffsetY = offset;
2139 mGridPen.setWidthF( 0 );
2151 mBoundingBoxesVisible = boundsVisible;
2153 if ( mSelectionHandles )
2155 mSelectionHandles->update();
2167 void QgsComposition::loadSettings()
2172 QString gridStyleString;
2173 gridStyleString = s.value(
"/Composer/gridStyle",
"Dots" ).toString();
2175 int gridRed, gridGreen, gridBlue, gridAlpha;
2176 gridRed = s.value(
"/Composer/gridRed", 190 ).toInt();
2177 gridGreen = s.value(
"/Composer/gridGreen", 190 ).toInt();
2178 gridBlue = s.value(
"/Composer/gridBlue", 190 ).toInt();
2179 gridAlpha = s.value(
"/Composer/gridAlpha", 100 ).toInt();
2180 QColor gridColor = QColor( gridRed, gridGreen, gridBlue, gridAlpha );
2182 mGridPen.setColor( gridColor );
2183 mGridPen.setWidthF( 0 );
2185 if ( gridStyleString ==
"Dots" )
2189 else if ( gridStyleString ==
"Crosses" )
2201 delete mActiveItemCommand;
2204 mActiveItemCommand = 0;
2221 if ( mActiveItemCommand )
2226 mUndoStack->push( mActiveItemCommand );
2231 delete mActiveItemCommand;
2233 mActiveItemCommand = 0;
2239 delete mActiveItemCommand;
2240 mActiveItemCommand = 0;
2245 delete mActiveMultiFrameCommand;
2249 mActiveMultiFrameCommand = 0;
2266 if ( mActiveMultiFrameCommand )
2271 mUndoStack->push( mActiveMultiFrameCommand );
2276 delete mActiveMultiFrameCommand;
2278 mActiveMultiFrameCommand = 0;
2284 delete mActiveMultiFrameCommand;
2285 mActiveMultiFrameCommand = 0;
2290 mMultiFrames.insert( multiFrame );
2297 mMultiFrames.remove( multiFrame );
2307 connect( arrow, SIGNAL( sizeChanged() ),
this, SLOT(
updateBounds() ) );
2317 connect( label, SIGNAL( sizeChanged() ),
this, SLOT(
updateBounds() ) );
2325 if ( setDefaultPreviewStyle )
2337 connect( map, SIGNAL( sizeChanged() ),
this, SLOT(
updateBounds() ) );
2344 addItem( scaleBar );
2347 connect( scaleBar, SIGNAL( sizeChanged() ),
this, SLOT(
updateBounds() ) );
2357 connect( legend, SIGNAL( sizeChanged() ),
this, SLOT(
updateBounds() ) );
2367 connect( picture, SIGNAL( sizeChanged() ),
this, SLOT(
updateBounds() ) );
2377 connect( shape, SIGNAL( sizeChanged() ),
this, SLOT(
updateBounds() ) );
2387 connect( table, SIGNAL( sizeChanged() ),
this, SLOT(
updateBounds() ) );
2397 connect( frame, SIGNAL( sizeChanged() ),
this, SLOT(
updateBounds() ) );
2407 connect( frame, SIGNAL( sizeChanged() ),
this, SLOT(
updateBounds() ) );
2422 if ( itemGroup && removeGroupItems )
2425 QUndoCommand* parentCommand =
new QUndoCommand(
tr(
"Remove item group" ) );
2427 QSet<QgsComposerItem*> groupedItems = itemGroup->
items();
2428 QSet<QgsComposerItem*>::iterator it = groupedItems.begin();
2429 for ( ; it != groupedItems.end(); ++it )
2432 connectAddRemoveCommandSignals( subcommand );
2444 if ( createCommand )
2465 if ( frameItem && multiFrame )
2470 if ( createCommand )
2473 multiFrame,
this,
tr(
"Multiframe removed" ) );
2491 connectAddRemoveCommandSignals( c );
2587 void QgsComposition::updatePaperItems()
2589 QList< QgsPaperItem* >::iterator paperIt = mPages.begin();
2590 for ( ; paperIt != mPages.end(); ++paperIt )
2592 ( *paperIt )->update();
2596 void QgsComposition::addPaperItem()
2600 double currentY = paperHeight * mPages.size() + mPages.size() * mSpaceBetweenPages;
2602 paperItem->setBrush( Qt::white );
2603 addItem( paperItem );
2604 paperItem->setZValue( 0 );
2605 mPages.push_back( paperItem );
2610 void QgsComposition::removePaperItems()
2612 qDeleteAll( mPages );
2617 void QgsComposition::deleteAndRemoveMultiFrames()
2619 QSet<QgsComposerMultiFrame*>::iterator multiFrameIt = mMultiFrames.begin();
2620 for ( ; multiFrameIt != mMultiFrames.end(); ++multiFrameIt )
2622 delete *multiFrameIt;
2624 mMultiFrames.clear();
2629 printer.setOutputFileName( file );
2636 printer.setOutputFormat( QPrinter::PdfFormat );
2641 printer.setOrientation( QPrinter::Portrait );
2655 return print( printer );
2660 if ( ddPageSizeActive() )
2666 printer.setOrientation( QPrinter::Portrait );
2671 int fromPage = ( printer.fromPage() < 1 ) ? 0 : printer.fromPage() - 1;
2672 int toPage = ( printer.toPage() < 1 ) ?
numPages() - 1 : printer.toPage() - 1;
2674 bool pageExported =
false;
2675 if ( mPrintAsRaster )
2677 for (
int i = fromPage; i <= toPage; ++i )
2683 if (( pageExported && i > fromPage ) || startNewPage )
2689 if ( !image.isNull() )
2691 QRectF targetArea( 0, 0, image.width(), image.height() );
2692 p.drawImage( targetArea, image, targetArea );
2694 pageExported =
true;
2698 if ( !mPrintAsRaster )
2700 for (
int i = fromPage; i <= toPage; ++i )
2706 if (( pageExported && i > fromPage ) || startNewPage )
2711 pageExported =
true;
2719 printer.setFullPage(
true );
2720 printer.setColorMode( QPrinter::Color );
2725 if ( evaluateDDPageSize && ddPageSizeActive() )
2731 printer.setOrientation( QPrinter::Portrait );
2740 bool ready = p.begin( &printer );
2756 QImage image( QSize( width, height ), QImage::Format_ARGB32 );
2757 if ( !image.isNull() )
2762 QPainter imagePainter( &image );
2764 if ( !imagePainter.isActive() )
return QImage();
2771 if ( mPages.size() <= page )
2782 QPaintDevice* paintDevice = p->device();
2788 QRectF paperRect = QRectF( paperItem->pos().x(), paperItem->pos().y(), paperItem->rect().width(), paperItem->rect().height() );
2795 setBackgroundBrush( Qt::NoBrush );
2796 render( p, QRectF( 0, 0, paintDevice->width(), paintDevice->height() ), paperRect );
2798 setBackgroundBrush( QColor( 215, 215, 215 ) );
2801 mPlotStyle = savedPlotStyle;
2804 QString QgsComposition::encodeStringForXML(
const QString& str )
2806 QString modifiedStr( str );
2807 modifiedStr.replace(
"&",
"&" );
2808 modifiedStr.replace(
"\"",
""" );
2809 modifiedStr.replace(
"'",
"'" );
2810 modifiedStr.replace(
"<",
"<" );
2811 modifiedStr.replace(
">",
">" );
2815 QGraphicsView *QgsComposition::graphicsView()
const
2818 QList<QGraphicsView*> viewList = views();
2819 if ( viewList.size() > 0 )
2821 return viewList.at( 0 );
2833 if ( !mWorldFileMap )
2838 QRectF brect = mWorldFileMap->mapRectToScene( mWorldFileMap->rect() );
2843 double xr = extent.
width() / brect.width();
2844 double yr = extent.
height() / brect.height();
2846 double XC = extent.
center().
x();
2847 double YC = extent.
center().
y();
2850 double xmin = extent.
xMinimum() - mWorldFileMap->pos().x() * xr;
2851 double ymax = extent.
yMaximum() + mWorldFileMap->pos().y() * yr;
2854 double X0 = paperExtent.
xMinimum();
2855 double Y0 = paperExtent.
yMinimum();
2860 double Ww = paperExtent.
width() / widthPx;
2861 double Hh = paperExtent.
height() / heightPx;
2870 s[5] = Y0 + paperExtent.
height();
2874 r[0] = cos( alpha );
2875 r[1] = -sin( alpha );
2876 r[2] = XC * ( 1 - cos( alpha ) ) + YC * sin( alpha );
2877 r[3] = sin( alpha );
2878 r[4] = cos( alpha );
2879 r[5] = - XC * sin( alpha ) + YC * ( 1 - cos( alpha ) );
2882 a = r[0] * s[0] + r[1] * s[3];
2883 b = r[0] * s[1] + r[1] * s[4];
2884 c = r[0] * s[2] + r[1] * s[5] + r[2];
2885 d = r[3] * s[0] + r[4] * s[3];
2886 e = r[3] * s[1] + r[4] * s[4];
2887 f = r[3] * s[2] + r[4] * s[5] + r[5];
2900 bool atlasHasFeatures = mAtlasComposition.
beginRender();
2901 if ( ! atlasHasFeatures )
2913 bool QgsComposition::ddPageSizeActive()
const
2922 void QgsComposition::refreshPageSize()
2924 double pageWidth = mPageWidth;
2925 double pageHeight = mPageHeight;
2931 QString presetString = exprVal.toString().trimmed();
2932 QgsDebugMsg( QString(
"exprVal Paper Preset size :%1" ).arg( presetString ) );
2938 pageHeight = heightD;
2946 double widthD = exprVal.toDouble( &ok );
2947 QgsDebugMsg( QString(
"exprVal Paper Width:%1" ).arg( widthD ) );
2956 double heightD = exprVal.toDouble( &ok );
2957 QgsDebugMsg( QString(
"exprVal Paper Height:%1" ).arg( heightD ) );
2960 pageHeight = heightD;
2968 QString orientationString = exprVal.toString().trimmed();
2970 QgsDebugMsg( QString(
"exprVal Paper Orientation:%1" ).arg( orientationString ) );
2973 double heightD, widthD;
2976 heightD = qMax( pageHeight, pageWidth );
2977 widthD = qMin( pageHeight, pageWidth );
2981 heightD = qMin( pageHeight, pageWidth );
2982 widthD = qMax( pageHeight, pageWidth );
2985 pageHeight = heightD;
3001 QMap< QgsComposerObject::DataDefinedProperty, QgsDataDefined* >::const_iterator it = mDataDefinedProperties.find( property );
3002 if ( it != mDataDefinedProperties.constEnd() )
3019 bool defaultVals = ( !active && !useExpression && expression.isEmpty() && field.isEmpty() );
3021 if ( mDataDefinedProperties.contains( property ) )
3023 QMap< QgsComposerObject::DataDefinedProperty, QgsDataDefined* >::const_iterator it = mDataDefinedProperties.find( property );
3024 if ( it != mDataDefinedProperties.constEnd() )
3033 else if ( !defaultVals )
3036 mDataDefinedProperties.insert( property, dd );
3040 bool QgsComposition::dataDefinedEvaluate(
QgsComposerObject::DataDefinedProperty property, QVariant &expressionValue, QMap<QgsComposerObject::DataDefinedProperty, QgsDataDefined *> *dataDefinedProperties )
3049 expressionValue.clear();
3054 if ( mAtlasComposition.
enabled() )
3068 QVariant result = dataDefinedValue( property, currentFeature, layerFields, dataDefinedProperties );
3070 if ( result.isValid() )
3072 expressionValue = result;
3079 bool QgsComposition::dataDefinedActive(
const QgsComposerObject::DataDefinedProperty property,
const QMap<QgsComposerObject::DataDefinedProperty, QgsDataDefined *> *dataDefinedProperties )
const
3086 if ( !dataDefinedProperties->contains( property ) )
3093 QMap< QgsComposerObject::DataDefinedProperty, QgsDataDefined* >::const_iterator it = dataDefinedProperties->find( property );
3094 if ( it != dataDefinedProperties->constEnd() )
3115 if ( !dataDefinedProperties->contains( property ) )
3122 QMap< QgsComposerObject::DataDefinedProperty, QgsDataDefined* >::const_iterator it = dataDefinedProperties->find( property );
3123 if ( it != dataDefinedProperties->constEnd() )
3138 QVariant result = QVariant();
3140 QString field = dd->
field();
3144 prepareDataDefinedExpression( dd, dataDefinedProperties );
3151 result = expr->
evaluate( feature );
3158 else if ( !useExpression && !field.isEmpty() && fields )
3174 void QgsComposition::prepareDataDefinedExpression(
QgsDataDefined *dd, QMap<QgsComposerObject::DataDefinedProperty, QgsDataDefined *> *dataDefinedProperties )
const
3178 if ( mAtlasComposition.
enabled() )
3191 QMap< QgsComposerObject::DataDefinedProperty, QgsDataDefined* >::const_iterator it = dataDefinedProperties->constBegin();
3192 for ( ; it != dataDefinedProperties->constEnd(); ++it )
3194 it.value()->prepareExpression( atlasLayer );
3199 void QgsComposition::prepareAllDataDefinedExpressions()
3201 prepareDataDefinedExpression( 0, &mDataDefinedProperties );