48 #include <QDomDocument>
49 #include <QDomElement>
50 #include <QGraphicsRectItem>
51 #include <QGraphicsView>
61 , mMapRenderer( mapRenderer )
62 , mMapSettings( mapRenderer->mapSettings() )
63 , mAtlasComposition( this )
71 , mMapSettings( mapSettings )
72 , mAtlasComposition( this )
83 mSpaceBetweenPages = 10;
85 mPrintAsRaster =
false;
86 mGenerateWorldFile =
false;
88 mUseAdvancedEffects =
true;
91 mSnapGridResolution = 0;
94 mAlignmentSnap =
true;
95 mGuidesVisible =
true;
98 mBoundingBoxesVisible =
true;
99 mSelectionHandles = 0;
100 mActiveItemCommand = 0;
101 mActiveMultiFrameCommand = 0;
103 mPreventCursorChange =
false;
122 connect( &mAtlasComposition, SIGNAL( toggled(
bool ) ),
this, SLOT( prepareAllDataDefinedExpressions() ) );
123 connect( &mAtlasComposition, SIGNAL( coverageLayerChanged(
QgsVectorLayer* ) ),
this, SLOT( prepareAllDataDefinedExpressions() ) );
126 createDefaultPageStyleSymbol();
135 mSelectionHandles->
hide();
138 mPrintResolution = 300;
188 deleteAndRemoveMultiFrames();
194 qDeleteAll( itemList );
197 qDeleteAll( mDataDefinedProperties );
198 mDataDefinedProperties.
clear();
205 delete mActiveItemCommand;
206 delete mActiveMultiFrameCommand;
207 delete mPageStyleSymbol;
211 void QgsComposition::loadDefaults()
214 mSnapGridResolution = settings.
value(
"/Composer/defaultSnapGridResolution", 10.0 ).
toDouble();
215 mSnapGridOffsetX = settings.
value(
"/Composer/defaultSnapGridOffsetX", 0 ).
toDouble();
216 mSnapGridOffsetY = settings.
value(
"/Composer/defaultSnapGridOffsetY", 0 ).
toDouble();
217 mSnapTolerance = settings.
value(
"/Composer/defaultSnapTolerancePixels", 5 ).
toInt();
232 for ( ; mapIt != maps.
end(); ++mapIt )
235 ( *mapIt )->update();
258 for ( ; itemIter != selectedItemList.
end(); ++itemIter )
283 QRectF QgsComposition::compositionBounds()
const
291 for ( ; itemIt != itemList.
end(); ++itemIt )
295 if (( composerItem || paperItem ) )
298 bounds = bounds.
united(( *itemIt )->sceneBoundingRect() );
303 bounds.
adjust( -mPageWidth * 0.05, -mPageWidth * 0.05, mPageWidth * 0.05, mPageWidth * 0.05 );
310 if ( width == mPageWidth && height == mPageHeight )
318 for ( ; itemIt != itemList.
end(); ++itemIt )
330 for ( ; guideIt != guides->
end(); ++guideIt )
332 QLineF line = ( *guideIt )->line();
333 if ( line.
dx() == 0 )
336 ( *guideIt )->
setLine( line.
x1(), 0, line.
x1(), totalHeight );
345 ( *guideIt )->setLine( 0, newY, width, newY );
352 for (
int i = 0; i < mPages.
size(); ++i )
354 mPages.
at( i )->setSceneRect(
QRectF( 0, currentY, width, height ) );
355 currentY += ( height + mSpaceBetweenPages );
375 int desiredPages =
pages;
382 int pagesD = exprVal.
toInt( &ok );
386 desiredPages = pagesD;
390 int diff = desiredPages - currentPages;
393 for (
int i = 0; i < diff; ++i )
401 for (
int i = 0; i < diff; ++i )
403 delete mPages.
last();
411 double totalHeight = ( mPageHeight +
spaceBetweenPages() ) * ( pages - 1 ) + mPageHeight;
412 for ( ; guideIt != guides->
end(); ++guideIt )
414 QLineF line = ( *guideIt )->line();
415 if ( line.
dx() == 0 )
418 ( *guideIt )->
setLine( line.
x1(), 0, line.
x1(), totalHeight );
433 return mPages.
size();
445 for ( ; itemIt != items.
constEnd(); ++itemIt )
461 if ( page >
numPages() || page < 1 )
472 for ( ; frameIt != frames.
constEnd(); ++frameIt )
474 if (( *frameIt )->hidePageIfEmpty() && ( *frameIt )->isEmpty() )
485 delete mPageStyleSymbol;
486 mPageStyleSymbol = symbol;
490 void QgsComposition::createDefaultPageStyleSymbol()
492 delete mPageStyleSymbol;
494 properties.
insert(
"color",
"white" );
495 properties.
insert(
"style",
"solid" );
496 properties.
insert(
"style_border",
"no" );
497 properties.
insert(
"joinstyle",
"miter" );
521 pageNumber = pageNumber < 1 ? 1 : pageNumber;
522 pageNumber = pageNumber > mPages.
size() ? mPages.
size() : pageNumber;
540 itemList =
items( position, Qt::IntersectsItemShape, Qt::DescendingOrder );
543 bool foundBelowItem =
false;
544 for ( ; itemIt != itemList.
end(); ++itemIt )
548 if ( composerItem && !paperItem )
552 if (( ! belowItem || foundBelowItem ) && ( !ignoreLocked || !composerItem->
positionLock() ) )
558 if ( composerItem == belowItem )
561 foundBelowItem =
true;
586 for ( ; itemIter != graphicsItemList.
end(); ++itemIter )
589 if ( composerItem && ( includeLockedItems || !composerItem->
positionLock() ) )
591 composerItemList.
push_back( composerItem );
595 return composerItemList;
604 for ( ; itemIt != itemList.
end(); ++itemIt )
620 for ( ; itemIt != itemList.
end(); ++itemIt )
625 if ( composerMap->
id() == id )
657 for ( ; itemIt != itemList.
end(); ++itemIt )
662 if ( mypItem->
id() == theId )
677 if ( inAllComposers )
679 composers = QgisApp::instance()->printComposers();
687 for ( ; it != composers.
constEnd(); ++it )
691 for ( ; itemIt != itemList.
end(); ++itemIt )
696 if ( mypItem->
uuid() == theUuid )
712 for ( ; itemIt != itemList.
end(); ++itemIt )
717 if ( mypItem->
uuid() == theUuid )
729 mPrintResolution = dpi;
736 mUseAdvancedEffects = effectsEnabled;
741 for ( ; itemIt != itemList.
constEnd(); ++itemIt )
763 if ( composerElem.
isNull() )
799 for ( ; snapLineIt != mSnapLines.
constEnd(); ++snapLineIt )
802 QLineF line = ( *snapLineIt )->line();
810 compositionElem.
setAttribute(
"printResolution", mPrintResolution );
811 compositionElem.
setAttribute(
"printAsRaster", mPrintAsRaster );
813 compositionElem.
setAttribute(
"generateWorldFile", mGenerateWorldFile ? 1 : 0 );
814 if ( mGenerateWorldFile && mWorldFileMap )
816 compositionElem.
setAttribute(
"worldFileMap", mWorldFileMap->
id() );
819 compositionElem.
setAttribute(
"alignmentSnap", mAlignmentSnap ? 1 : 0 );
820 compositionElem.
setAttribute(
"guidesVisible", mGuidesVisible ? 1 : 0 );
821 compositionElem.
setAttribute(
"smartGuides", mSmartGuides ? 1 : 0 );
822 compositionElem.
setAttribute(
"snapTolerancePixels", mSnapTolerance );
827 for ( ; itemIt != itemList.
constEnd(); ++itemIt )
834 composerItem->
writeXML( compositionElem, doc );
841 for ( ; multiFrameIt != mMultiFrames.
constEnd(); ++multiFrameIt )
843 ( *multiFrameIt )->writeXML( compositionElem, doc );
856 if ( compositionElem.
isNull() )
862 bool widthConversionOk, heightConversionOk;
863 mPageWidth = compositionElem.
attribute(
"paperWidth" ).
toDouble( &widthConversionOk );
864 mPageHeight = compositionElem.
attribute(
"paperHeight" ).
toDouble( &heightConversionOk );
869 if ( !pageStyleSymbolElem.
isNull() )
871 delete mPageStyleSymbol;
872 mPageStyleSymbol = QgsSymbolLayerV2Utils::loadSymbol<QgsFillSymbolV2>( pageStyleSymbolElem );
875 if ( widthConversionOk && heightConversionOk )
878 for (
int i = 0; i <
numPages; ++i )
885 mSnapToGrid = compositionElem.
attribute(
"snapping",
"0" ).
toInt() == 0 ?
false :
true;
886 mGridVisible = compositionElem.
attribute(
"gridVisible",
"0" ).
toInt() == 0 ?
false :
true;
888 mSnapGridResolution = compositionElem.
attribute(
"snapGridResolution" ).
toDouble();
892 mAlignmentSnap = compositionElem.
attribute(
"alignmentSnap",
"1" ).
toInt() == 0 ?
false :
true;
893 mGuidesVisible = compositionElem.
attribute(
"guidesVisible",
"1" ).
toInt() == 0 ?
false :
true;
894 mSmartGuides = compositionElem.
attribute(
"smartGuides",
"1" ).
toInt() == 0 ?
false :
true;
895 mSnapTolerance = compositionElem.
attribute(
"snapTolerancePixels",
"10" ).
toInt();
899 for (
int i = 0; i < snapLineNodes.
size(); ++i )
907 snapItem->
setLine( x1, y1, x2, y2 );
910 mPrintAsRaster = compositionElem.
attribute(
"printAsRaster" ).
toInt();
911 mPrintResolution = compositionElem.
attribute(
"printResolution",
"300" ).
toInt();
913 mGenerateWorldFile = compositionElem.
attribute(
"generateWorldFile",
"0" ).
toInt() == 1 ?
true :
false;
927 if ( clearComposition )
929 deleteAndRemoveMultiFrames();
934 for ( ; itemIter != itemList.
end(); ++itemIter )
938 if ( cItem && !pItem )
945 mItemsModel->
clear();
952 if ( substitutionMap )
956 for ( ; sIt != substitutionMap->
constEnd(); ++sIt )
958 xmlString = xmlString.
replace(
"[" + sIt.
key() +
"]", encodeStringForXML( sIt.
value() ) );
962 int errorLine, errorColumn;
963 if ( !importDoc.
setContent( xmlString, &errorMsg, &errorLine, &errorColumn ) )
975 if ( clearComposition )
978 if ( compositionElem.
isNull() )
983 bool ok =
readXML( compositionElem, importDoc );
996 for (
int i = 0; i < composerItemsNodes.
count(); ++i )
998 QDomNode composerItemNode = composerItemsNodes.
at( i );
1011 if ( clearComposition )
1023 for (
int i = 0; i < composerItemList.
size(); ++i )
1034 minX = qMin( minX, x );
1035 minY = qMin( minY, y );
1048 bool addUndoCommands,
QPointF* pos,
bool pasteInPlace )
1064 QPointF minItemPos = minPointFromXml( elem );
1067 pasteShiftPos = *pos - minItemPos;
1074 pasteInPlacePt =
new QPointF( 0,
pageNumberAt( *pos ) * ( mPageHeight + mSpaceBetweenPages ) );
1078 for (
int i = 0; i < composerLabelList.
size(); ++i )
1082 newLabel->
readXML( currentComposerLabelElem, doc );
1085 if ( pasteInPlacePt )
1088 newLabel->
move( pasteInPlacePt->
x(), pasteInPlacePt->
y() );
1092 newLabel->
move( pasteShiftPos.
x(), pasteShiftPos.
y() );
1095 lastPastedItem = newLabel;
1099 if ( addUndoCommands )
1106 for (
int i = 0; i < composerMapList.
size(); ++i )
1111 if ( mapsToRestore )
1116 newMap->
readXML( currentComposerMapElem, doc );
1119 if ( mapsToRestore )
1132 newMap->
move( pasteInPlacePt->
x(), pasteInPlacePt->
y() );
1136 newMap->
move( pasteShiftPos.
x(), pasteShiftPos.
y() );
1139 lastPastedItem = newMap;
1142 if ( addUndoCommands )
1157 for ( ; overviewIt != overviews.
end(); ++overviewIt )
1159 ( *overviewIt )->connectSignals();
1166 for (
int i = 0; i < composerArrowList.
size(); ++i )
1170 newArrow->
readXML( currentComposerArrowElem, doc );
1176 newArrow->
move( pasteInPlacePt->
x(), pasteInPlacePt->
y() );
1180 newArrow->
move( pasteShiftPos.
x(), pasteShiftPos.
y() );
1183 lastPastedItem = newArrow;
1187 if ( addUndoCommands )
1194 for (
int i = 0; i < composerScaleBarList.
size(); ++i )
1198 newScaleBar->
readXML( currentComposerScaleBarElem, doc );
1204 newScaleBar->
move( pasteInPlacePt->
x(), pasteInPlacePt->
y() );
1208 newScaleBar->
move( pasteShiftPos.
x(), pasteShiftPos.
y() );
1211 lastPastedItem = newScaleBar;
1215 if ( addUndoCommands )
1222 for (
int i = 0; i < composerShapeList.
size(); ++i )
1226 newShape->
readXML( currentComposerShapeElem, doc );
1234 newShape->
move( pasteInPlacePt->
x(), pasteInPlacePt->
y() );
1238 newShape->
move( pasteShiftPos.
x(), pasteShiftPos.
y() );
1241 lastPastedItem = newShape;
1245 if ( addUndoCommands )
1252 for (
int i = 0; i < composerPictureList.
size(); ++i )
1256 newPicture->
readXML( currentComposerPictureElem, doc );
1262 newPicture->
move( pasteInPlacePt->
x(), pasteInPlacePt->
y() );
1266 newPicture->
move( pasteShiftPos.
x(), pasteShiftPos.
y() );
1269 lastPastedItem = newPicture;
1273 if ( addUndoCommands )
1280 for (
int i = 0; i < composerLegendList.
size(); ++i )
1284 newLegend->
readXML( currentComposerLegendElem, doc );
1290 newLegend->
move( pasteInPlacePt->
x(), pasteInPlacePt->
y() );
1294 newLegend->
move( pasteShiftPos.
x(), pasteShiftPos.
y() );
1297 lastPastedItem = newLegend;
1301 if ( addUndoCommands )
1308 for (
int i = 0; i < composerTableList.
size(); ++i )
1312 newTable->
readXML( currentComposerTableElem, doc );
1318 newTable->
move( pasteInPlacePt->
x(), pasteInPlacePt->
y() );
1322 newTable->
move( pasteShiftPos.
x(), pasteShiftPos.
y() );
1325 lastPastedItem = newTable;
1329 if ( addUndoCommands )
1337 for (
int i = 0; i < composerHtmlList.
size(); ++i )
1341 newHtml->
readXML( currentHtmlElem, doc );
1354 for (
int i = 0; i < composerAttributeTableV2List.
size(); ++i )
1358 newTable->
readXML( currentTableElem, doc );
1375 for (
int i = 0; i < groupList.
size(); ++i )
1379 newGroup->
readXML( groupElem, doc );
1388 if ( lastPastedItem )
1393 delete pasteInPlacePt;
1424 bool itemsRaised =
false;
1425 for ( ; it != selectedItems.
end(); ++it )
1427 itemsRaised = itemsRaised |
raiseItem( *it );
1461 if ( selectedItems.
size() > 0 )
1463 previousSelectedItem = selectedItems.
at( 0 );
1466 if ( !previousSelectedItem )
1473 switch ( direction )
1483 if ( !selectedItem )
1498 bool itemsLowered =
false;
1499 for ( ; it != selectedItems.
end(); ++it )
1501 itemsLowered = itemsLowered |
lowerItem( *it );
1504 if ( !itemsLowered )
1525 bool itemsRaised =
false;
1526 for ( ; it != selectedItems.
end(); ++it )
1552 bool itemsLowered =
false;
1553 for ( ; it != selectedItems.
end(); ++it )
1558 if ( !itemsLowered )
1578 if ( selectedItems.
size() < 2 )
1584 if ( boundingRectOfSelectedItems( selectedItemBBox ) != 0 )
1589 double minXCoordinate = selectedItemBBox.
left();
1594 for ( ; align_it != selectedItems.
end(); ++align_it )
1598 ( *align_it )->setPos( minXCoordinate, ( *align_it )->pos().y() );
1601 mUndoStack->
push( parentCommand );
1608 if ( selectedItems.
size() < 2 )
1614 if ( boundingRectOfSelectedItems( selectedItemBBox ) != 0 )
1619 double averageXCoord = ( selectedItemBBox.
left() + selectedItemBBox.
right() ) / 2.0;
1624 for ( ; align_it != selectedItems.
end(); ++align_it )
1628 ( *align_it )->setPos( averageXCoord - ( *align_it )->rect().width() / 2.0, ( *align_it )->pos().y() );
1631 mUndoStack->
push( parentCommand );
1638 if ( selectedItems.
size() < 2 )
1644 if ( boundingRectOfSelectedItems( selectedItemBBox ) != 0 )
1649 double maxXCoordinate = selectedItemBBox.
right();
1654 for ( ; align_it != selectedItems.
end(); ++align_it )
1658 ( *align_it )->setPos( maxXCoordinate - ( *align_it )->rect().width(), ( *align_it )->pos().y() );
1661 mUndoStack->
push( parentCommand );
1668 if ( selectedItems.
size() < 2 )
1674 if ( boundingRectOfSelectedItems( selectedItemBBox ) != 0 )
1679 double minYCoordinate = selectedItemBBox.
top();
1683 for ( ; align_it != selectedItems.
end(); ++align_it )
1687 ( *align_it )->setPos(( *align_it )->pos().x(), minYCoordinate );
1690 mUndoStack->
push( parentCommand );
1697 if ( selectedItems.
size() < 2 )
1703 if ( boundingRectOfSelectedItems( selectedItemBBox ) != 0 )
1708 double averageYCoord = ( selectedItemBBox.
top() + selectedItemBBox.
bottom() ) / 2.0;
1711 for ( ; align_it != selectedItems.
end(); ++align_it )
1715 ( *align_it )->setPos(( *align_it )->pos().x(), averageYCoord - ( *align_it )->rect().height() / 2 );
1718 mUndoStack->
push( parentCommand );
1725 if ( selectedItems.
size() < 2 )
1731 if ( boundingRectOfSelectedItems( selectedItemBBox ) != 0 )
1736 double maxYCoord = selectedItemBBox.
bottom();
1739 for ( ; align_it != selectedItems.
end(); ++align_it )
1743 ( *align_it )->setPos(( *align_it )->pos().x(), maxYCoord - ( *align_it )->rect().height() );
1746 mUndoStack->
push( parentCommand );
1755 for ( ; itemIter != selectionList.
end(); ++itemIter )
1759 ( *itemIter )->setPositionLock(
true );
1764 mUndoStack->
push( parentCommand );
1779 for ( ; itemIt != itemList.
end(); ++itemIt )
1793 mUndoStack->
push( parentCommand );
1799 if ( items.
size() < 2 )
1808 for ( ; itemIter != items.
end(); ++itemIter )
1810 itemGroup->
addItem( *itemIter );
1822 return ungroupedItems;
1827 for ( ; itemIt != groupedItems.
end(); ++itemIt )
1829 ungroupedItems << ( *itemIt );
1838 return ungroupedItems;
1841 void QgsComposition::updateZValues(
const bool addUndoCommands )
1848 if ( addUndoCommands )
1850 parentCommand =
new QUndoCommand(
tr(
"Item z-order changed" ) );
1858 if ( addUndoCommands )
1864 if ( addUndoCommands )
1871 if ( addUndoCommands )
1873 mUndoStack->
push( parentCommand );
1885 updateZValues(
false );
1890 if ( !mSnapToGrid || mSnapGridResolution <= 0 || !graphicsView() )
1896 int pageNr = ( int )( scenePoint.
y() / ( mPageHeight + mSpaceBetweenPages ) );
1897 double yOffset = pageNr * ( mPageHeight + mSpaceBetweenPages );
1898 double yPage = scenePoint.
y() - yOffset;
1901 int xRatio = ( int )(( scenePoint.
x() - mSnapGridOffsetX ) / mSnapGridResolution + 0.5 );
1902 int yRatio = ( int )(( yPage - mSnapGridOffsetY ) / mSnapGridResolution + 0.5 );
1904 double xSnapped = xRatio * mSnapGridResolution + mSnapGridOffsetX;
1905 double ySnapped = yRatio * mSnapGridResolution + mSnapGridOffsetY + yOffset;
1908 double viewScaleFactor = graphicsView()->
transform().
m11();
1909 double alignThreshold = mSnapTolerance / viewScaleFactor;
1911 if ( fabs( xSnapped - scenePoint.
x() ) > alignThreshold )
1914 xSnapped = scenePoint.
x();
1916 if ( fabs( ySnapped - scenePoint.
y() ) > alignThreshold )
1919 ySnapped = scenePoint.
y();
1922 return QPointF( xSnapped, ySnapped );
1928 QPen linePen( Qt::SolidLine );
1951 for ( ; it != mSnapLines.
end(); ++it )
1961 mGuidesVisible = visible;
1963 for ( ; it != mSnapLines.
end(); ++it )
1979 double minSqrDist = DBL_MAX;
1981 double currentXCoord = 0;
1982 double currentYCoord = 0;
1983 double currentSqrDist = 0;
1984 double sqrTolerance = tolerance * tolerance;
1986 snappedItems.clear();
1989 for ( ; it != mSnapLines.
constEnd(); ++it )
1991 bool itemHorizontal =
qgsDoubleNear(( *it )->line().y2() - ( *it )->line().y1(), 0 );
1992 if ( horizontal && itemHorizontal )
1994 currentYCoord = ( *it )->line().y1();
1995 currentSqrDist = ( y - currentYCoord ) * ( y - currentYCoord );
1997 else if ( !horizontal && !itemHorizontal )
1999 currentXCoord = ( *it )->line().x1();
2000 currentSqrDist = ( x - currentXCoord ) * ( x - currentXCoord );
2007 if ( currentSqrDist < minSqrDist && currentSqrDist < sqrTolerance )
2010 minSqrDist = currentSqrDist;
2014 double itemTolerance = 0.0000001;
2020 for ( ; itemIt != itemList.
end(); ++itemIt )
2064 int QgsComposition::boundingRectOfSelectedItems(
QRectF& bRect )
2067 if ( selectedItems.
size() < 1 )
2074 double minX = currentItem->
pos().
x();
2075 double minY = currentItem->
pos().
y();
2076 double maxX = minX + currentItem->
rect().
width();
2077 double maxY = minY + currentItem->
rect().
height();
2079 double currentMinX, currentMinY, currentMaxX, currentMaxY;
2081 for (
int i = 1; i < selectedItems.
size(); ++i )
2083 currentItem = selectedItems.
at( i );
2084 currentMinX = currentItem->
pos().
x();
2085 currentMinY = currentItem->
pos().
y();
2086 currentMaxX = currentMinX + currentItem->
rect().
width();
2087 currentMaxY = currentMinY + currentItem->
rect().
height();
2089 if ( currentMinX < minX )
2091 if ( currentMaxX > maxX )
2093 if ( currentMinY < minY )
2095 if ( currentMaxY > maxY )
2118 mSnapGridResolution = r;
2124 mSnapGridOffsetX = offset;
2130 mSnapGridOffsetY = offset;
2150 mBoundingBoxesVisible = boundsVisible;
2152 if ( mSelectionHandles )
2154 mSelectionHandles->
update();
2166 void QgsComposition::loadSettings()
2172 gridStyleString = s.
value(
"/Composer/gridStyle",
"Dots" ).
toString();
2174 int gridRed, gridGreen, gridBlue, gridAlpha;
2175 gridRed = s.
value(
"/Composer/gridRed", 190 ).
toInt();
2176 gridGreen = s.
value(
"/Composer/gridGreen", 190 ).
toInt();
2177 gridBlue = s.
value(
"/Composer/gridBlue", 190 ).
toInt();
2178 gridAlpha = s.
value(
"/Composer/gridAlpha", 100 ).
toInt();
2179 QColor gridColor =
QColor( gridRed, gridGreen, gridBlue, gridAlpha );
2184 if ( gridStyleString ==
"Dots" )
2188 else if ( gridStyleString ==
"Crosses" )
2200 delete mActiveItemCommand;
2203 mActiveItemCommand = 0;
2220 if ( mActiveItemCommand )
2225 mUndoStack->
push( mActiveItemCommand );
2230 delete mActiveItemCommand;
2232 mActiveItemCommand = 0;
2238 delete mActiveItemCommand;
2239 mActiveItemCommand = 0;
2244 delete mActiveMultiFrameCommand;
2248 mActiveMultiFrameCommand = 0;
2265 if ( mActiveMultiFrameCommand )
2270 mUndoStack->
push( mActiveMultiFrameCommand );
2275 delete mActiveMultiFrameCommand;
2277 mActiveMultiFrameCommand = 0;
2283 delete mActiveMultiFrameCommand;
2284 mActiveMultiFrameCommand = 0;
2289 mMultiFrames.
insert( multiFrame );
2296 mMultiFrames.
remove( multiFrame );
2324 if ( setDefaultPreviewStyle )
2421 if ( itemGroup && removeGroupItems )
2428 for ( ; it != groupedItems.
end(); ++it )
2431 connectAddRemoveCommandSignals( subcommand );
2443 if ( createCommand )
2464 if ( frameItem && multiFrame )
2469 if ( createCommand )
2472 multiFrame,
this,
tr(
"Multiframe removed" ) );
2490 connectAddRemoveCommandSignals( c );
2586 void QgsComposition::updatePaperItems()
2589 for ( ; paperIt != mPages.
end(); ++paperIt )
2591 ( *paperIt )->update();
2595 void QgsComposition::addPaperItem()
2599 double currentY = paperHeight * mPages.
size() + mPages.
size() * mSpaceBetweenPages;
2609 void QgsComposition::removePaperItems()
2611 qDeleteAll( mPages );
2616 void QgsComposition::deleteAndRemoveMultiFrames()
2619 for ( ; multiFrameIt != mMultiFrames.
end(); ++multiFrameIt )
2621 delete *multiFrameIt;
2623 mMultiFrames.
clear();
2654 return print( printer );
2659 if ( ddPageSizeActive() )
2673 bool pageExported =
false;
2674 if ( mPrintAsRaster )
2676 for (
int i = fromPage; i <= toPage; ++i )
2682 if (( pageExported && i > fromPage ) || startNewPage )
2691 p.
drawImage( targetArea, image, targetArea );
2693 pageExported =
true;
2697 if ( !mPrintAsRaster )
2699 for (
int i = fromPage; i <= toPage; ++i )
2705 if (( pageExported && i > fromPage ) || startNewPage )
2710 pageExported =
true;
2724 if ( evaluateDDPageSize && ddPageSizeActive() )
2739 bool ready = p.
begin( &printer );
2755 QImage image(
QSize( width, height ), QImage::Format_ARGB32 );
2770 if ( mPages.
size() <= page )
2800 mPlotStyle = savedPlotStyle;
2806 modifiedStr.replace(
"&",
"&" );
2807 modifiedStr.replace(
"\"",
""" );
2808 modifiedStr.replace(
"'",
"'" );
2809 modifiedStr.replace(
"<",
"<" );
2810 modifiedStr.replace(
">",
">" );
2818 if ( viewList.
size() > 0 )
2820 return viewList.
at( 0 );
2832 if ( !mWorldFileMap )
2845 double XC = extent.
center().
x();
2846 double YC = extent.
center().
y();
2849 double xmin = extent.
xMinimum() - mWorldFileMap->
pos().
x() * xr;
2850 double ymax = extent.
yMaximum() + mWorldFileMap->
pos().
y() * yr;
2853 double X0 = paperExtent.
xMinimum();
2854 double Y0 = paperExtent.
yMinimum();
2859 double Ww = paperExtent.
width() / widthPx;
2860 double Hh = paperExtent.
height() / heightPx;
2869 s[5] = Y0 + paperExtent.
height();
2873 r[0] = cos( alpha );
2874 r[1] = -sin( alpha );
2875 r[2] = XC * ( 1 - cos( alpha ) ) + YC * sin( alpha );
2876 r[3] = sin( alpha );
2877 r[4] = cos( alpha );
2878 r[5] = - XC * sin( alpha ) + YC * ( 1 - cos( alpha ) );
2881 a = r[0] * s[0] + r[1] * s[3];
2882 b = r[0] * s[1] + r[1] * s[4];
2883 c = r[0] * s[2] + r[1] * s[5] + r[2];
2884 d = r[3] * s[0] + r[4] * s[3];
2885 e = r[3] * s[1] + r[4] * s[4];
2886 f = r[3] * s[2] + r[4] * s[5] + r[5];
2899 bool atlasHasFeatures = mAtlasComposition.
beginRender();
2900 if ( ! atlasHasFeatures )
2912 bool QgsComposition::ddPageSizeActive()
const
2921 void QgsComposition::refreshPageSize()
2923 double pageWidth = mPageWidth;
2924 double pageHeight = mPageHeight;
2937 pageHeight = heightD;
2945 double widthD = exprVal.
toDouble( &ok );
2955 double heightD = exprVal.
toDouble( &ok );
2959 pageHeight = heightD;
2972 double heightD, widthD;
2975 heightD = qMax( pageHeight, pageWidth );
2976 widthD = qMin( pageHeight, pageWidth );
2980 heightD = qMin( pageHeight, pageWidth );
2981 widthD = qMax( pageHeight, pageWidth );
2984 pageHeight = heightD;
3001 if ( it != mDataDefinedProperties.
constEnd() )
3018 bool defaultVals = ( !active && !useExpression && expression.
isEmpty() && field.
isEmpty() );
3020 if ( mDataDefinedProperties.
contains( property ) )
3023 if ( it != mDataDefinedProperties.
constEnd() )
3032 else if ( !defaultVals )
3035 mDataDefinedProperties.
insert( property, dd );
3048 expressionValue.
clear();
3053 if ( mAtlasComposition.
enabled() )
3067 QVariant result = dataDefinedValue( property, currentFeature, layerFields, dataDefinedProperties );
3071 expressionValue = result;
3085 if ( !dataDefinedProperties->
contains( property ) )
3093 if ( it != dataDefinedProperties->
constEnd() )
3114 if ( !dataDefinedProperties->
contains( property ) )
3122 if ( it != dataDefinedProperties->
constEnd() )
3143 prepareDataDefinedExpression( dd, dataDefinedProperties );
3150 result = expr->
evaluate( feature );
3157 else if ( !useExpression && !field.
isEmpty() && fields )
3177 if ( mAtlasComposition.
enabled() )
3191 for ( ; it != dataDefinedProperties->
constEnd(); ++it )
3193 it.
value()->prepareExpression( atlasLayer );
3198 void QgsComposition::prepareAllDataDefinedExpressions()
3200 prepareDataDefinedExpression( 0, &mDataDefinedProperties );
void lowerSelectedItems()
bool positionLock() const
Returns whether position lock for mouse drags is enabled returns true if item is locked for mouse mov...
Class for parsing and evaluation of expressions (formerly called "search strings").
void beginPrint(QPrinter &printer, const bool evaluateDDPageSize=false)
Prepare the printer for printing.
static void relativeResizeRect(QRectF &rectToResize, const QRectF &boundsBefore, const QRectF &boundsAfter)
Resizes a QRectF relative to a resized bounding rectangle.
Item representing the paper.
bool hasEvalError() const
Returns true if an error occurred when evaluating last input.
A scale bar item that can be added to a map composition.
QUndoStack * undoStack()
Returns pointer to undo/redo command storage.
QDomNodeList elementsByTagName(const QString &tagname) const
QgsComposerItem * composerItemAt(const QPointF &position, const bool ignoreLocked=false) const
Returns the topmost composer item at a specified position.
void unlockAllItems()
Unlock all items.
void setActive(bool active)
bool readXML(const QDomElement &itemElem, const QDomDocument &doc) override
Sets state from Dom document.
A rectangle specified with double values.
double paperWidth() const
Width of paper item.
void setDotsPerMeterX(int x)
void setDotsPerMeterY(int y)
bool writeXML(QDomElement &composerElem, QDomDocument &doc)
Writes settings to xml (paper dimension)
virtual bool writeXML(QDomElement &elem, QDomDocument &doc) const
Stores item state in DOM element.
void setAllUnselected()
Clears any selected items in the composition.
QgsComposerItem * getComposerItemAbove(QgsComposerItem *item) const
Finds the next composer item above an item.
bool readXML(const QDomElement &itemElem, const QDomDocument &doc) override
sets state from Dom document
A container class for data source field mapping or expression.
bool contains(const Key &key) const
An item that draws an arrow between to points.
QgsComposerMapOverviewStack * overviews()
Returns the map item's overview stack, which is used to control how overviews are drawn over the map'...
void render(QPainter *painter, const QRectF &target, const QRectF &source, Qt::AspectRatioMode aspectRatioMode)
void setResolution(int dpi)
QDomNode appendChild(const QDomNode &newChild)
void addItemToZList(QgsComposerItem *item)
Adds item to z list.
void composerArrowAdded(QgsComposerArrow *arrow)
Is emitted when new composer arrow has been added to the view.
void setBoundingBoxesVisible(const bool boundsVisible)
Sets whether selection bounding boxes should be shown in the composition.
void push_back(const T &value)
QList< QGraphicsItem * > selectedItems() const
void setPageStyleSymbol(QgsFillSymbolV2 *symbol)
Note: added in version 2.1.
void assignFreeId()
Sets mId to a number not yet used in the composition.
QVariant evaluate(const QgsFeature *f=NULL)
Evaluate the feature and return the result.
void setOutputFileName(const QString &fileName)
QString attribute(const QString &name, const QString &defValue) const
virtual void beginItemCommand(const QString &text)
void computeWorldFileParameters(double &a, double &b, double &c, double &d, double &e, double &f) const
Compute world file parameters.
double yMaximum() const
Get the y maximum value (top side of rectangle)
GridStyle
Style to draw the snapping grid.
QList< QGraphicsItem * > items() const
void alignSelectedItemsTop()
void rebuildZList()
Rebuilds the z-order list, based on the current stacking of items in the composition.
QString toString(int indent) const
void composerPictureAdded(QgsComposerPicture *picture)
Is emitted when a new composer picture has been added.
static double relativePosition(const double position, const double beforeMin, const double beforeMax, const double afterMin, const double afterMax)
Returns a scaled position given a before and after range.
int pageNumberForPoint(const QPointF &position) const
Returns the page number corresponding to a point in the composition.
QgsDataDefined * dataDefinedProperty(const QgsComposerObject::DataDefinedProperty property)
Returns a reference to the data defined settings for one of the composition's data defined properties...
void removeItems() override
Removes the items but does not delete them.
static QgsFillSymbolV2 * createSimple(const QgsStringMap &properties)
Create a fill symbol with one symbol layer: SimpleFill with specified properties. ...
void cache()
Create cache image.
int zOrderListSize() const
Returns the size of the z-order list, which includes items which may have been removed from the compo...
const_iterator constBegin() const
const T & at(int i) const
QgsComposerItemGroup * groupItems(QList< QgsComposerItem * > items)
Creates a new group from a list of composer items and adds it to the composition. ...
static void readDataDefinedPropertyMap(const QDomElement &itemElem, QMap< QgsComposerObject::DataDefinedProperty, QString > *dataDefinedNames, QMap< QgsComposerObject::DataDefinedProperty, QgsDataDefined * > *dataDefinedProperties)
Reads all data defined properties from xml.
QList< const QgsComposerMap * > composerMapItems() const
Returns pointers to all composer maps in the scene.
void addComposerScaleBar(QgsComposerScaleBar *scaleBar)
Adds scale bar to the graphics scene and advices composer to create a widget for it (through signal) ...
A item that forms part of a map composition.
void setBackgroundBrush(const QBrush &brush)
void setSelectedItem(QgsComposerItem *item)
Clears any selected items and sets an item as the current selection.
void pushAddRemoveCommand(QgsComposerItem *item, const QString &text, const QgsAddRemoveItemCommand::State state=QgsAddRemoveItemCommand::Added)
Convenience function to create a QgsAddRemoveItemCommand, connect its signals and push it to the undo...
void removeItemFromZList(QgsComposerItem *item)
Removes item from z list.
bool enabled() const
Returns whether the atlas generation is enabled.
void setSceneRect(const QRectF &rect)
QPointF snapPointToGrid(const QPointF &scenePoint) const
Snaps a scene coordinate point to grid.
QgsExpression * expression()
void updateBounds()
Updates the scene bounds of the composition.
Container of fields for a vector layer.
A container for grouping several QgsComposerItems.
void sendItemAddedSignal(QgsComposerItem *item)
Casts object to the proper subclass type and calls corresponding itemAdded signal.
virtual void setSelected(bool s)
Set selected, selected item should be highlighted.
void savePreviousState()
Saves current item state as previous state.
QImage printPageAsRaster(int page)
print composer page to image If the image does not fit into memory, a null image is returned ...
A composer command that merges together with other commands having the same context (=id)...
QDomElement documentElement() const
bool moveItemToBottom(QgsComposerItem *item)
void setCreateUndoCommands(bool enabled)
Sets whether undo commands should be created for interactions with the multiframe.
const_iterator insert(const T &value)
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
void beginPrintAsPDF(QPrinter &printer, const QString &file)
Prepare the printer for printing in a PDF.
A non GUI class for rendering a map layer set onto a QPainter.
QRectF mapRectToScene(const QRectF &rect) const
void composerScaleBarAdded(QgsComposerScaleBar *scalebar)
Is emitted when new composer scale bar has been added.
void moveSelectedItemsToBottom()
static void writeDataDefinedPropertyMap(QDomElement &itemElem, QDomDocument &doc, const QMap< QgsComposerObject::DataDefinedProperty, QString > *dataDefinedNames, const QMap< QgsComposerObject::DataDefinedProperty, QgsDataDefined * > *dataDefinedProperties)
Writes data defined properties to xml.
bool reorderItemDown(QgsComposerItem *item)
Moves an item down the z-order list.
void alignSelectedItemsHCenter()
double toDouble(bool *ok) const
double spaceBetweenPages() const
Returns the vertical space between pages in a composer view.
void doPrint(QPrinter &printer, QPainter &painter, bool startNewPage=false)
Print on a preconfigured printer.
void setStatusMessage(const QString &message)
Sets the status bar message for the composer window.
QString tr(const char *sourceText, const char *disambiguation, int n)
void composerMapAdded(QgsComposerMap *map)
Is emitted when new composer map has been added to the view.
int numPages() const
Returns the number of pages in the composition.
void adjust(qreal dx1, qreal dy1, qreal dx2, qreal dy2)
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
virtual bool readXML(const QDomElement &itemElem, const QDomDocument &doc, bool ignoreFrames=false) override
Reads the properties specific to an attribute table from xml.
void update(const QRectF &rect)
static Q_DECL_DEPRECATED double relativePosition(double position, double beforeMin, double beforeMax, double afterMin, double afterMax)
Returns a scaled position given a before and after range.
void setGridVisible(const bool b)
void alignSelectedItemsVCenter()
bool shouldExportPage(const int page) const
Returns whether a specified page number should be included in exports of the composition.
A table that displays attributes from a vector layer.
DataDefinedProperty
Data defined properties for different item types.
void composerItemsOnPage(QList< T * > &itemList, const int pageNumber) const
Return composer items of a specific type on a specified page.
void endRender()
Ends the rendering.
A composer class that displays svg files or raster format (jpg, png, ...)
void readXML(const QDomElement &elem, const QDomDocument &doc)
Reads general atlas settings from xml.
void endMultiFrameCommand()
QSet< QgsComposerItem * > items()
bool isDrawing() const
True if a draw is already in progress.
void composerLegendAdded(QgsComposerLegend *legend)
Is emitted when a new composer legend has been added.
void setItemPosition(double x, double y, ItemPositionMode itemPoint=UpperLeft, int page=-1)
Moves the item to a new position (in canvas coordinates)
The QgsMapSettings class contains configuration for rendering of the map.
QList< QgsComposerItem * > * zOrderList()
Returns the item z-order list.
QDomElement toElement() const
void addComposerShape(QgsComposerShape *shape)
Adds a composer shape to the graphics scene and advices composer to create a widget for it (through s...
void setGridPen(const QPen &p)
static QDomElement saveSymbol(QString symbolName, QgsSymbolV2 *symbol, QDomDocument &doc)
bool readXML(const QDomElement &itemElem, const QDomDocument &doc) override
Reads the properties specific to an attribute table from xml.
void setUseExpression(bool use)
QgsComposerItem * getComposerItemBelow(QgsComposerItem *item) const
QString uuid() const
Get item identification name.
void setNumPages(const int pages)
Sets the number of pages for the composition.
QString number(int n, int base)
void refreshItemsTriggered()
Is emitted when item in the composition must be refreshed.
bool beginRender()
Begins the rendering.
void setSnapLinesVisible(const bool visible)
Hides / shows custom snap lines.
int itemPageNumber(const QgsComposerItem *) const
Returns on which page number (0-based) is displayed an item.
static QgsComposition::PaperOrientation decodePaperOrientation(const QString orientationString, bool &ok)
Decodes a string representing a paper orientation.
int toInt(bool *ok) const
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
void removeItem(QGraphicsItem *item)
void cancelCommand()
Deletes current command.
void fill(uint pixelValue)
void setSnapGridOffsetX(const double offset)
#define QgsDebugMsgLevel(str, level)
bool containsChange() const
Returns true if previous state and after state are valid and different.
int pageNumberAt(const QPointF &position) const
Returns the page number (0-based) given a coordinate.
void setUseSymbolV2(bool useSymbolV2)
Controls whether the shape should be drawn using a QgsFillSymbolV2.
void endCommand()
Saves end state of item and pushes command to the undo history.
void itemRemoved(QgsComposerItem *)
Is emitted when a composer item has been removed from the scene.
int printResolution() const
void updatePagePos(double newPageWidth, double newPageHeight)
Moves the item so that it retains its relative position on the page when the paper size changes...
void setAttribute(const QString &name, const QString &value)
void setField(const QString &field)
void clear()
Clears all items from z-order list and resets the model.
QList< QGraphicsView * > views() const
void removeSnapLine(QGraphicsLineItem *line)
Remove custom snap line (and delete the object)
void addItem(QgsComposerItem *item) override
Adds an item to the group.
int toInt(bool *ok, int base) const
void alignSelectedItemsRight()
QDomNodeList elementsByTagName(const QString &tagname) const
Abstract base class for composer items with the ability to distribute the content to several frames (...
int removeAll(const T &value)
const_iterator constEnd() const
void setLine(const QLineF &line)
void addComposerTableFrame(QgsComposerAttributeTableV2 *table, QgsComposerFrame *frame)
Adds composer tablev2 frame and advises composer to create a widget for it (through signal) ...
QPaintDevice * device() const
const QgsComposerItem * getComposerItemByUuid(const QString theUuid) const
Returns a composer item given its unique identifier.
QList< QgsComposerItem * > ungroupItems(QgsComposerItemGroup *group)
Ungroups items by removing them from an item group and removing the group from the composition...
void cancelMultiFrameCommand()
Deletes current multi frame command.
void setWidthF(qreal width)
void removeComposerItem(QgsComposerItem *item, const bool createCommand=true, const bool removeGroupItems=true)
Remove item from the graphics scene.
static bool decodePresetPaperSize(const QString presetString, double &width, double &height)
Decodes a string representing a preset page size.
const_iterator constEnd() const
bool readXML(const QDomElement &itemElem, const QDomDocument &doc) override
sets state from Dom document
QRectF united(const QRectF &rectangle) const
bool loadFromTemplate(const QDomDocument &doc, QMap< QString, QString > *substitutionMap=0, bool addUndoCommands=false, const bool clearComposition=true)
Load a template document.
void setPaperSize(PaperSize newPaperSize)
void moveSelectedItemsToTop()
bool readXML(const QDomElement &itemElem, const QDomDocument &doc) override
sets state from Dom document
int frameCount() const
Returns the number of frames associated with this multiframe.
void setColor(const QColor &color)
A composer command that merges together with other commands having the same context (=id) for multi f...
double mapRotation(QgsComposerObject::PropertyValueType valueType=QgsComposerObject::EvaluatedValue) const
Returns the rotation used for drawing the map within the composer item.
void setSnapGridResolution(const double r)
bool pageIsEmpty(const int page) const
Returns whether a page is empty, ie, it contains no items except for the background paper item...
virtual QPaintEngine * paintEngine() const
void setPen(const QPen &pen)
QgsFeature * currentFeature()
Returns the current atlas feature.
void removeMultiFrame(QgsComposerMultiFrame *multiFrame)
Removes multi frame (but does not delete it)
Object representing map window.
Frame item for a composer multiframe item.
bool readXML(const QDomElement &compositionElem, const QDomDocument &doc)
Reads settings from xml file.
bool useExpression() const
int indexFromName(const QString &name) const
Look up field's index from name. Returns -1 on error.
bool readXML(const QDomElement &itemElem, const QDomDocument &doc) override
sets state from Dom document
QgsRectangle * currentMapExtent()
Returns a pointer to the current map extent, which is either the original user specified extent or th...
void addItemsFromXML(const QDomElement &elem, const QDomDocument &doc, QMap< QgsComposerMap *, int > *mapsToRestore=0, bool addUndoCommands=false, QPointF *pos=0, bool pasteInPlace=false)
Add items from XML representation to the graphics scene (for project file reading, pasting items from clipboard)
void refreshItems()
Forces items in the composition to refresh.
void setUpdatesEnabled(bool enabled)
Sets whether updates to the composer map are enabled.
QgsComposerItem * getComposerItemAbove(QgsComposerItem *item) const
Q_DECL_DEPRECATED int pixelFontSize(double pointSize) const
Returns the mm font size for a font that has point size set.
void setFullPage(bool fp)
void refreshDataDefinedProperty(const QgsComposerObject::DataDefinedProperty property=QgsComposerObject::AllProperties)
Refreshes a data defined property for the composition by reevaluating the property's value and redraw...
PreviewMode previewMode() const
void setLine(qreal x1, qreal y1, qreal x2, qreal y2)
void removeItem(QgsComposerItem *item)
Removes an item from the z-order list.
bool readXML(const QDomElement &itemElem, const QDomDocument &doc) override
sets state from Dom document
void setTopLeft(const QPointF &position)
void updateSettings()
Refreshes the composition when composer related options change.
void saveAfterState()
Saves current item state as after state.
const_iterator constBegin() const
bool setAtlasMode(const QgsComposition::AtlasMode mode)
Sets the current atlas mode of the composition.
void setPositionLock(const bool lock)
Locks / unlocks the item position for mouse drags.
void setOrientation(Orientation orientation)
void setPrintResolution(const int dpi)
bool print(QPrinter &printer, const bool evaluateDDPageSize=false)
Convenience function that prepares the printer and prints.
void composerTableAdded(QgsComposerAttributeTable *table)
Is emitted when a new composer table has been added.
const Key key(const T &value) const
QList< QgsPaperItem * > pages()
Return pages in the correct order.
void refreshZList()
Rebuilds the z order list by adding any item which are present in the composition but missing from th...
int id() const
Get identification number.
void composerShapeAdded(QgsComposerShape *shape)
Is emitted when a new composer shape has been added.
bool exportAsPDF(const QString &file)
Convenience function that prepares the printer for printing in PDF and prints.
void lockSelectedItems()
Lock the selected items.
QString & replace(int position, int n, QChar after)
void setGridStyle(const GridStyle s)
A composer command class for adding / removing composer items.
const QgsComposerItem * getComposerItemById(const QString theId) const
Returns a composer item given its text identifier.
void selectNextByZOrder(const ZValueDirection direction)
void statusMsgChanged(QString message)
Is emitted when the composition has an updated status bar message for the composer window...
QVariant value(const QString &key, const QVariant &defaultValue) const
void clearSnapLines()
Removes all snap lines.
A table class that displays a vector attribute table.
bool reorderItemUp(QgsComposerItem *item)
Moves an item up the z-order list.
void drawImage(const QRectF &target, const QImage &image, const QRectF &source, QFlags< Qt::ImageConversionFlag > flags)
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
QgsComposerItem * getComposerItemBelow(QgsComposerItem *item) const
Finds the next composer item below an item.
bool remove(const T &value)
Undo command to undo/redo all composer item related changes.
bool readXML(const QDomElement &itemElem, const QDomDocument &doc) override
sets state from Dom document
void setDataDefinedProperty(const QgsComposerObject::DataDefinedProperty property, bool active, bool useExpression, const QString &expression, const QString &field)
Sets parameters for a data defined property for the composition.
A composer items that draws common shapes (ellipse, triangle, rectangle)
virtual void endItemCommand()
void readXMLMapSettings(const QDomElement &elem, const QDomDocument &doc)
Reads old (pre 2.2) map related atlas settings from xml.
void raiseSelectedItems()
bool prepareExpression(QgsVectorLayer *layer)
Prepares the expression using a vector layer.
bool expressionIsPrepared() const
Returns whether the data defined object's expression is prepared.
void addComposerHtmlFrame(QgsComposerHtml *html, QgsComposerFrame *frame)
Adds composer html frame and advises composer to create a widget for it (through signal) ...
QList< QgsComposerMapOverview * > asList() const
Returns a list of QgsComposerMapOverviews contained by the stack.
AtlasMode
Composition atlas modes.
static QgsProject * instance()
access to canonical QgsProject instance
QDomElement firstChildElement(const QString &tagName) const
QPointF positionOnPage(const QPointF &position) const
Returns the position within a page of a point in the composition.
void addComposerMap(QgsComposerMap *map, const bool setDefaultPreviewStyle=true)
Adds map to the graphics scene and advices composer to create a widget for it (through signal) ...
void alignSelectedItemsBottom()
static void fixEngineFlags(QPaintEngine *engine)
void update(qreal x, qreal y, qreal w, qreal h)
void alignSelectedItemsLeft()
QGraphicsLineItem * nearestSnapLine(const bool horizontal, const double x, const double y, const double tolerance, QList< QPair< QgsComposerItem *, QgsComposerItem::ItemPositionMode > > &snappedItems) const
Get nearest snap line.
double paperHeight() const
Height of paper item.
static double pointsToMM(const double pointSize)
Returns the size in mm corresponding to a font point size.
void selectedItemChanged(QgsComposerItem *selected)
Is emitted when selected item changed.
void renderPage(QPainter *p, int page)
Render a page to a paint device.
void setVisible(bool visible)
A label that can be placed onto a map composition.
void setUseAdvancedEffects(const bool effectsEnabled)
Used to enable or disable advanced effects such as blend modes in a composition.
void setEffectsEnabled(const bool effectsEnabled)
Sets whether effects (eg blend modes) are enabled for the item.
void composerLabelAdded(QgsComposerLabel *label)
Is emitted when new composer label has been added to the view.
void addComposerPicture(QgsComposerPicture *picture)
Adds picture to the graphics scene and advices composer to create a widget for it (through signal) ...
QgsAtlasComposition & atlasComposition()
double toDouble(bool *ok) const
void composerHtmlFrameAdded(QgsComposerHtml *html, QgsComposerFrame *frame)
Is emitted when a new composer html has been added to the view.
iterator insert(const Key &key, const T &value)
static Q_DECL_DEPRECATED void relativeResizeRect(QRectF &rectToResize, const QRectF &boundsBefore, const QRectF &boundsAfter)
Resizes a QRectF relative to the change from boundsBefore to boundsAfter.
void addComposerTable(QgsComposerAttributeTable *table)
Adds a composer table to the graphics scene and advices composer to create a widget for it (through s...
void removeAttribute(const QString &name)
Handles drawing of selection outlines and mouse handles.
void composerTableFrameAdded(QgsComposerAttributeTableV2 *table, QgsComposerFrame *frame)
Is emitted when a new composer table frame has been added to the view.
Q_DECL_DEPRECATED const QgsComposerHtml * getComposerHtmlByItem(QgsComposerItem *item) const
Returns the composer html with specified id (a string as named in the composer user interface item pr...
QgsVectorLayer * coverageLayer() const
Returns the coverage layer used for the atlas features.
const QgsFields & pendingFields() const
returns field list in the to-be-committed state
void setItemRemoved(QgsComposerItem *item)
Marks an item as removed from the composition.
bool readXML(const QDomElement &itemElem, const QDomDocument &doc) override
Sets state from DOM document.
void setBrush(const QBrush &brush)
friend class QgsComposerModel
static void setSpecialColumn(const QString &name, QVariant value)
Assign a special column.
bool readXML(const QDomElement &itemElem, const QDomDocument &doc, bool ignoreFrames=false) override
Reads multiframe state information from a DOM element.
const_iterator constEnd() const
Q_DECL_DEPRECATED double pointFontSize(int pixelSize) const
Does the inverse calculation and returns points for mm.
QGraphicsLineItem * addSnapLine()
Add a custom snap line (can be horizontal or vertical)
QDomElement createElement(const QString &tagName)
void composerItems(QList< T * > &itemList)
Return composer items of a specific type.
const_iterator constBegin() const
void printResolutionChanged()
Is emitted when the compositions print resolution changes.
void setColorMode(ColorMode newColorMode)
void addItem(QGraphicsItem *item)
const QgsComposerMap * getComposerMapById(const int id) const
Returns the composer map with specified id.
void setPreviewMode(PreviewMode m)
double width() const
Width of the rectangle.
bool raiseItem(QgsComposerItem *item)
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QgsComposerMultiFrame * multiFrame() const
Returns the parent multiframe for the frame.
void setSnapToGridEnabled(const bool b)
bool reorderItemToTop(QgsComposerItem *item)
Moves an item to the top of the z-order list.
Represents a vector layer which manages a vector based data sets.
bool begin(QPaintDevice *device)
void setBottomRight(const QPointF &position)
void move(double dx, double dy)
Moves item in canvas coordinates.
A legend that can be placed onto a map composition.
void addComposerLabel(QgsComposerLabel *label)
Adds label to the graphics scene and advices composer to create a widget for it (through signal) ...
double xMinimum() const
Get the x minimum value (left side of rectangle)
void addMultiFrame(QgsComposerMultiFrame *multiFrame)
Adds multiframe.
void addItemAtTop(QgsComposerItem *item)
Adds an item to the top of the composition z stack.
QgsPoint center() const
Center point of the rectangle.
QString evalErrorString() const
Returns evaluation error.
void setExpressionString(const QString &expr)
iterator find(const Key &key)
bool lowerItem(QgsComposerItem *item)
void addComposerArrow(QgsComposerArrow *arrow)
Adds an arrow item to the graphics scene and advices composer to create a widget for it (through sign...
bool reorderItemToBottom(QgsComposerItem *item)
Moves an item to the bottom of the z-order list.
bool moveItemToTop(QgsComposerItem *item)
void setPaperSize(const double width, const double height)
Changes size of paper item.
void addComposerLegend(QgsComposerLegend *legend)
Adds legend to the graphics scene and advices composer to create a widget for it (through signal) ...
bool containsChange() const
Returns true if previous state and after state are valid and different.
Q_DECL_DEPRECATED QgsComposition(QgsMapRenderer *mapRenderer)
void push(QUndoCommand *cmd)
double height() const
Height of the rectangle.
virtual int type() const override
return correct graphics item type.
bool setContent(const QByteArray &data, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn)
QDomNode at(int index) const
void setSnapGridOffsetY(const double offset)
const T value(const Key &key) const
void beginCommand(QgsComposerItem *item, const QString &commandText, const QgsComposerMergeCommand::Context c=QgsComposerMergeCommand::Unknown)
Allocates new item command and saves initial state in it.
QList< QgsComposerItem * > selectedComposerItems(const bool includeLockedItems=true)
Returns list of selected composer items.
QList< QGraphicsLineItem * > * snapLines()
Returns pointer to snap lines collection.
void beginMultiFrameCommand(QgsComposerMultiFrame *multiFrame, const QString &text, const QgsComposerMultiFrameMergeCommand::Context c=QgsComposerMultiFrameMergeCommand::Unknown)
static double mmToPoints(const double mmSize)
Returns the size in mm corresponding to a font point size.
QString id() const
Get item's id (which is not necessarly unique)