43 #include <QDomDocument>
44 #include <QDomElement>
45 #include <QGraphicsRectItem>
55 , mMapRenderer( mapRenderer )
56 , mMapSettings( mapRenderer->mapSettings() )
57 , mAtlasComposition( this )
65 , mMapSettings( mapSettings )
66 , mAtlasComposition( this )
99 setBackgroundBrush( QColor( 215, 215, 215 ) );
172 mSnapGridResolution = settings.value(
"/Composer/defaultSnapGridResolution", 10.0 ).toDouble();
173 mSnapGridTolerance = settings.value(
"/Composer/defaultSnapGridTolerance", 2 ).toDouble();
174 mSnapGridOffsetX = settings.value(
"/Composer/defaultSnapGridOffsetX", 0 ).toDouble();
175 mSnapGridOffsetY = settings.value(
"/Composer/defaultSnapGridOffsetY", 0 ).toDouble();
199 QRectF bounds = QRectF( 0, 0, 0, 0 );
202 QList<QGraphicsItem *> itemList = items();
203 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
204 for ( ; itemIt != itemList.end(); ++itemIt )
208 if (( composerItem || paperItem ) )
211 bounds = bounds.united(( *itemIt )->sceneBoundingRect() );
224 QList<QGraphicsItem *> itemList = items();
225 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
226 for ( ; itemIt != itemList.end(); ++itemIt )
235 QList< QGraphicsLineItem* >* guides =
snapLines();
236 QList< QGraphicsLineItem* >::iterator guideIt = guides->begin();
238 for ( ; guideIt != guides->end(); ++guideIt )
240 QLineF line = ( *guideIt )->line();
241 if ( line.dx() == 0 )
244 ( *guideIt )->setLine( line.x1(), 0, line.x1(), totalHeight );
253 ( *guideIt )->setLine( 0, newY, width, newY );
260 for (
int i = 0; i <
mPages.size(); ++i )
262 mPages.at( i )->setSceneRect( QRectF( 0, currentY, width, height ) );
283 int diff = pages - currentPages;
286 for (
int i = 0; i < diff; ++i )
294 for (
int i = 0; i < diff; ++i )
302 QList< QGraphicsLineItem* >* guides =
snapLines();
303 QList< QGraphicsLineItem* >::iterator guideIt = guides->begin();
305 for ( ; guideIt != guides->end(); ++guideIt )
307 QLineF line = ( *guideIt )->line();
308 if ( line.dx() == 0 )
311 ( *guideIt )->setLine( line.x1(), 0, line.x1(), totalHeight );
340 properties.insert(
"color",
"white" );
341 properties.insert(
"style",
"solid" );
342 properties.insert(
"style_border",
"no" );
343 properties.insert(
"joinstyle",
"miter" );
361 return QPointF( position.x(), y );
367 pageNumber = pageNumber < 1 ? 1 : pageNumber;
368 pageNumber = pageNumber >
mPages.size() ?
mPages.size() : pageNumber;
385 QList<QGraphicsItem*> itemList;
386 itemList = items( position, Qt::IntersectsItemShape, Qt::DescendingOrder );
387 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
389 bool foundBelowItem =
false;
390 for ( ; itemIt != itemList.end(); ++itemIt )
394 if ( composerItem && !paperItem )
398 if ( ! belowItem || foundBelowItem )
404 if ( composerItem == belowItem )
407 foundBelowItem =
true;
422 return pageNumberAt( QPointF( item->pos().x(), item->pos().y() ) );
427 QList<QgsComposerItem*> composerItemList;
429 QList<QGraphicsItem *> graphicsItemList = selectedItems();
430 QList<QGraphicsItem *>::iterator itemIter = graphicsItemList.begin();
432 for ( ; itemIter != graphicsItemList.end(); ++itemIter )
437 composerItemList.push_back( composerItem );
441 return composerItemList;
446 QList<const QgsComposerMap*> resultList;
448 QList<QGraphicsItem *> itemList = items();
449 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
450 for ( ; itemIt != itemList.end(); ++itemIt )
455 resultList.push_back( composerMap );
464 QList<QGraphicsItem *> itemList = items();
465 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
466 for ( ; itemIt != itemList.end(); ++itemIt )
471 if ( composerMap->
id() == id )
501 QList<QGraphicsItem *> itemList = items();
502 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
503 for ( ; itemIt != itemList.end(); ++itemIt )
508 if ( mypItem->
id() == theId )
521 QSet<QgsComposer*> composers = QSet<QgsComposer*>();
523 if ( inAllComposers )
525 composers = QgisApp::instance()->printComposers();
529 composers.insert(
this )
532 QSet<QgsComposer*>::const_iterator it = composers.constBegin();
533 for ( ; it != composers.constEnd(); ++it )
535 QList<QGraphicsItem *> itemList = ( *it )->items();
536 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
537 for ( ; itemIt != itemList.end(); ++itemIt )
542 if ( mypItem->
uuid() == theUuid )
556 QList<QGraphicsItem *> itemList = items();
557 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
558 for ( ; itemIt != itemList.end(); ++itemIt )
563 if ( mypItem->
uuid() == theUuid )
585 QList<QGraphicsItem*> itemList = items();
586 QList<QGraphicsItem*>::const_iterator itemIt = itemList.constBegin();
587 for ( ; itemIt != itemList.constEnd(); ++itemIt )
600 double sizeMillimeters = pointSize * 0.3527;
601 return qRound( sizeMillimeters );
606 double sizePoint = pixelSize / 0.3527;
612 if ( composerElem.isNull() )
617 QDomElement compositionElem = doc.createElement(
"Composition" );
618 compositionElem.setAttribute(
"paperWidth", QString::number(
mPageWidth ) );
619 compositionElem.setAttribute(
"paperHeight", QString::number(
mPageHeight ) );
620 compositionElem.setAttribute(
"numPages",
mPages.size() );
623 compositionElem.appendChild( pageStyleElem );
628 compositionElem.setAttribute(
"snapping",
"1" );
632 compositionElem.setAttribute(
"snapping",
"0" );
636 compositionElem.setAttribute(
"gridVisible",
"1" );
640 compositionElem.setAttribute(
"gridVisible",
"0" );
642 compositionElem.setAttribute(
"snapGridResolution", QString::number(
mSnapGridResolution ) );
643 compositionElem.setAttribute(
"snapGridTolerance", QString::number(
mSnapGridTolerance ) );
644 compositionElem.setAttribute(
"snapGridOffsetX", QString::number(
mSnapGridOffsetX ) );
645 compositionElem.setAttribute(
"snapGridOffsetY", QString::number(
mSnapGridOffsetY ) );
648 QList< QGraphicsLineItem* >::const_iterator snapLineIt =
mSnapLines.constBegin();
649 for ( ; snapLineIt !=
mSnapLines.constEnd(); ++snapLineIt )
651 QDomElement snapLineElem = doc.createElement(
"SnapLine" );
652 QLineF line = ( *snapLineIt )->line();
653 snapLineElem.setAttribute(
"x1", QString::number( line.x1() ) );
654 snapLineElem.setAttribute(
"y1", QString::number( line.y1() ) );
655 snapLineElem.setAttribute(
"x2", QString::number( line.x2() ) );
656 snapLineElem.setAttribute(
"y2", QString::number( line.y2() ) );
657 compositionElem.appendChild( snapLineElem );
669 compositionElem.setAttribute(
"alignmentSnap",
mAlignmentSnap ? 1 : 0 );
670 compositionElem.setAttribute(
"guidesVisible",
mGuidesVisible ? 1 : 0 );
671 compositionElem.setAttribute(
"smartGuides",
mSmartGuides ? 1 : 0 );
675 QList<QGraphicsItem*> itemList = items();
676 QList<QGraphicsItem*>::const_iterator itemIt = itemList.constBegin();
677 for ( ; itemIt != itemList.constEnd(); ++itemIt )
684 composerItem->
writeXML( compositionElem, doc );
690 QSet<QgsComposerMultiFrame*>::const_iterator multiFrameIt =
mMultiFrames.constBegin();
691 for ( ; multiFrameIt !=
mMultiFrames.constEnd(); ++multiFrameIt )
693 ( *multiFrameIt )->writeXML( compositionElem, doc );
695 composerElem.appendChild( compositionElem );
703 if ( compositionElem.isNull() )
709 bool widthConversionOk, heightConversionOk;
710 mPageWidth = compositionElem.attribute(
"paperWidth" ).toDouble( &widthConversionOk );
711 mPageHeight = compositionElem.attribute(
"paperHeight" ).toDouble( &heightConversionOk );
713 int numPages = compositionElem.attribute(
"numPages",
"1" ).toInt();
715 QDomElement pageStyleSymbolElem = compositionElem.firstChildElement(
"symbol" );
716 if ( !pageStyleSymbolElem.isNull() )
722 if ( widthConversionOk && heightConversionOk )
725 for (
int i = 0; i <
numPages; ++i )
732 mSnapToGrid = compositionElem.attribute(
"snapping",
"0" ).toInt() == 0 ?
false :
true;
733 mGridVisible = compositionElem.attribute(
"gridVisible",
"0" ).toInt() == 0 ?
false :
true;
736 mSnapGridTolerance = compositionElem.attribute(
"snapGridTolerance",
"2.0" ).toDouble();
737 mSnapGridOffsetX = compositionElem.attribute(
"snapGridOffsetX" ).toDouble();
738 mSnapGridOffsetY = compositionElem.attribute(
"snapGridOffsetY" ).toDouble();
740 mAlignmentSnap = compositionElem.attribute(
"alignmentSnap",
"1" ).toInt() == 0 ?
false :
true;
741 mGuidesVisible = compositionElem.attribute(
"guidesVisible",
"1" ).toInt() == 0 ?
false :
true;
742 mSmartGuides = compositionElem.attribute(
"smartGuides",
"1" ).toInt() == 0 ?
false :
true;
746 QDomNodeList snapLineNodes = compositionElem.elementsByTagName(
"SnapLine" );
747 for (
int i = 0; i < snapLineNodes.size(); ++i )
749 QDomElement snapLineElem = snapLineNodes.at( i ).toElement();
751 double x1 = snapLineElem.attribute(
"x1" ).toDouble();
752 double y1 = snapLineElem.attribute(
"y1" ).toDouble();
753 double x2 = snapLineElem.attribute(
"x2" ).toDouble();
754 double y2 = snapLineElem.attribute(
"y2" ).toDouble();
755 snapItem->setLine( x1, y1, x2, y2 );
758 mPrintAsRaster = compositionElem.attribute(
"printAsRaster" ).toInt();
759 mPrintResolution = compositionElem.attribute(
"printResolution",
"300" ).toInt();
761 mGenerateWorldFile = compositionElem.attribute(
"generateWorldFile",
"0" ).toInt() == 1 ?
true :
false;
775 QList<QGraphicsItem *> itemList = items();
776 QList<QGraphicsItem *>::iterator itemIter = itemList.begin();
777 for ( ; itemIter != itemList.end(); ++itemIter )
792 QDomDocument importDoc;
793 if ( substitutionMap )
795 QString xmlString = doc.toString();
796 QMap<QString, QString>::const_iterator sIt = substitutionMap->constBegin();
797 for ( ; sIt != substitutionMap->constEnd(); ++sIt )
799 xmlString = xmlString.replace(
"[" + sIt.key() +
"]",
encodeStringForXML( sIt.value() ) );
803 int errorLine, errorColumn;
804 if ( !importDoc.setContent( xmlString, &errorMsg, &errorLine, &errorColumn ) )
815 QDomElement compositionElem = importDoc.documentElement().firstChildElement(
"Composition" );
816 if ( compositionElem.isNull() )
821 bool ok =
readXML( compositionElem, importDoc );
828 QDomNodeList composerItemsNodes = importDoc.elementsByTagName(
"ComposerItem" );
829 for (
int i = 0; i < composerItemsNodes.count(); ++i )
831 QDomNode composerItemNode = composerItemsNodes.at( i );
832 if ( composerItemNode.isElement() )
834 composerItemNode.toElement().setAttribute(
"templateUuid", composerItemNode.toElement().attribute(
"uuid" ) );
835 composerItemNode.toElement().removeAttribute(
"uuid" );
840 addItemsFromXML( importDoc.documentElement(), importDoc, 0, addUndoCommands, 0 );
843 QDomElement atlasElem = importDoc.documentElement().firstChildElement(
"Atlas" );
852 QDomNodeList composerItemList = elem.elementsByTagName(
"ComposerItem" );
853 for (
int i = 0; i < composerItemList.size(); ++i )
855 QDomElement currentComposerItemElem = composerItemList.at( i ).toElement();
858 x = currentComposerItemElem.attribute(
"x" ).toDouble( &xOk );
859 y = currentComposerItemElem.attribute(
"y" ).toDouble( &yOk );
864 minX = qMin( minX, x );
865 minY = qMin( minY, y );
869 return QPointF( minX, minY );
873 return QPointF( 0, 0 );
878 bool addUndoCommands, QPointF* pos,
bool pasteInPlace )
880 QPointF* pasteInPlacePt = 0;
887 QPointF pasteShiftPos;
897 pasteShiftPos = *pos - minItemPos;
907 QDomNodeList composerLabelList = elem.elementsByTagName(
"ComposerLabel" );
908 for (
int i = 0; i < composerLabelList.size(); ++i )
910 QDomElement currentComposerLabelElem = composerLabelList.at( i ).toElement();
912 newLabel->
readXML( currentComposerLabelElem, doc );
915 if ( pasteInPlacePt )
918 newLabel->
move( pasteInPlacePt->x(), pasteInPlacePt->y() );
922 newLabel->
move( pasteShiftPos.x(), pasteShiftPos.y() );
925 lastPastedItem = newLabel;
928 newLabel->setZValue( newLabel->zValue() + zOrderOffset );
929 if ( addUndoCommands )
935 QDomNodeList composerMapList = elem.elementsByTagName(
"ComposerMap" );
936 for (
int i = 0; i < composerMapList.size(); ++i )
938 QDomElement currentComposerMapElem = composerMapList.at( i ).toElement();
946 newMap->
readXML( currentComposerMapElem, doc );
951 mapsToRestore->insert( newMap, (
int )( newMap->
previewMode() ) );
956 newMap->setZValue( newMap->zValue() + zOrderOffset );
962 newMap->
move( pasteInPlacePt->x(), pasteInPlacePt->y() );
966 newMap->
move( pasteShiftPos.x(), pasteShiftPos.y() );
969 lastPastedItem = newMap;
972 if ( addUndoCommands )
978 QList<QgsComposerMap*> maps;
980 for ( QList<QgsComposerMap*>::iterator mit = maps.begin(); mit != maps.end(); ++mit )
982 if (( *mit )->overviewFrameMapId() != -1 )
987 QObject::connect( overviewMap, SIGNAL( extentChanged() ), *mit, SLOT( overviewExtentChanged() ) );
993 QDomNodeList composerArrowList = elem.elementsByTagName(
"ComposerArrow" );
994 for (
int i = 0; i < composerArrowList.size(); ++i )
996 QDomElement currentComposerArrowElem = composerArrowList.at( i ).toElement();
998 newArrow->
readXML( currentComposerArrowElem, doc );
1004 newArrow->
move( pasteInPlacePt->x(), pasteInPlacePt->y() );
1008 newArrow->
move( pasteShiftPos.x(), pasteShiftPos.y() );
1011 lastPastedItem = newArrow;
1014 newArrow->setZValue( newArrow->zValue() + zOrderOffset );
1015 if ( addUndoCommands )
1021 QDomNodeList composerScaleBarList = elem.elementsByTagName(
"ComposerScaleBar" );
1022 for (
int i = 0; i < composerScaleBarList.size(); ++i )
1024 QDomElement currentComposerScaleBarElem = composerScaleBarList.at( i ).toElement();
1026 newScaleBar->
readXML( currentComposerScaleBarElem, doc );
1032 newScaleBar->
move( pasteInPlacePt->x(), pasteInPlacePt->y() );
1036 newScaleBar->
move( pasteShiftPos.x(), pasteShiftPos.y() );
1039 lastPastedItem = newScaleBar;
1042 newScaleBar->setZValue( newScaleBar->zValue() + zOrderOffset );
1043 if ( addUndoCommands )
1049 QDomNodeList composerShapeList = elem.elementsByTagName(
"ComposerShape" );
1050 for (
int i = 0; i < composerShapeList.size(); ++i )
1052 QDomElement currentComposerShapeElem = composerShapeList.at( i ).toElement();
1054 newShape->
readXML( currentComposerShapeElem, doc );
1062 newShape->
move( pasteInPlacePt->x(), pasteInPlacePt->y() );
1066 newShape->
move( pasteShiftPos.x(), pasteShiftPos.y() );
1069 lastPastedItem = newShape;
1072 newShape->setZValue( newShape->zValue() + zOrderOffset );
1073 if ( addUndoCommands )
1079 QDomNodeList composerPictureList = elem.elementsByTagName(
"ComposerPicture" );
1080 for (
int i = 0; i < composerPictureList.size(); ++i )
1082 QDomElement currentComposerPictureElem = composerPictureList.at( i ).toElement();
1084 newPicture->
readXML( currentComposerPictureElem, doc );
1090 newPicture->
move( pasteInPlacePt->x(), pasteInPlacePt->y() );
1094 newPicture->
move( pasteShiftPos.x(), pasteShiftPos.y() );
1097 lastPastedItem = newPicture;
1100 newPicture->setZValue( newPicture->zValue() + zOrderOffset );
1101 if ( addUndoCommands )
1107 QDomNodeList composerLegendList = elem.elementsByTagName(
"ComposerLegend" );
1108 for (
int i = 0; i < composerLegendList.size(); ++i )
1110 QDomElement currentComposerLegendElem = composerLegendList.at( i ).toElement();
1112 newLegend->
readXML( currentComposerLegendElem, doc );
1118 newLegend->
move( pasteInPlacePt->x(), pasteInPlacePt->y() );
1122 newLegend->
move( pasteShiftPos.x(), pasteShiftPos.y() );
1125 lastPastedItem = newLegend;
1128 newLegend->setZValue( newLegend->zValue() + zOrderOffset );
1129 if ( addUndoCommands )
1135 QDomNodeList composerTableList = elem.elementsByTagName(
"ComposerAttributeTable" );
1136 for (
int i = 0; i < composerTableList.size(); ++i )
1138 QDomElement currentComposerTableElem = composerTableList.at( i ).toElement();
1140 newTable->
readXML( currentComposerTableElem, doc );
1146 newTable->
move( pasteInPlacePt->x(), pasteInPlacePt->y() );
1150 newTable->
move( pasteShiftPos.x(), pasteShiftPos.y() );
1153 lastPastedItem = newTable;
1156 newTable->setZValue( newTable->zValue() + zOrderOffset );
1157 if ( addUndoCommands )
1164 QDomNodeList composerHtmlList = elem.elementsByTagName(
"ComposerHtml" );
1165 for (
int i = 0; i < composerHtmlList.size(); ++i )
1167 QDomElement currentHtmlElem = composerHtmlList.at( i ).toElement();
1169 newHtml->
readXML( currentHtmlElem, doc );
1185 QDomNodeList groupList = elem.elementsByTagName(
"ComposerItemGroup" );
1186 for (
int i = 0; i < groupList.size(); ++i )
1188 QDomElement groupElem = groupList.at( i ).toElement();
1190 newGroup->
readXML( groupElem, doc );
1191 addItem( newGroup );
1199 if ( lastPastedItem )
1204 delete pasteInPlacePt;
1231 QList<QgsComposerItem*>::iterator it = selectedItems.begin();
1232 for ( ; it != selectedItems.end(); ++it )
1245 QMutableLinkedListIterator<QgsComposerItem*> it(
mItemZList );
1246 if ( it.findNext( item ) )
1249 while ( it.hasNext() )
1255 if ( it.value() && it.value()->scene() )
1267 QLinkedListIterator<QgsComposerItem*> it(
mItemZList );
1268 if ( it.findNext( item ) )
1282 QLinkedListIterator<QgsComposerItem*> it(
mItemZList );
1283 if ( it.findNext( item ) )
1288 if ( it.hasPrevious() )
1290 return it.previous();
1300 if ( selectedItems.size() > 0 )
1302 previousSelectedItem = selectedItems.at( 0 );
1305 if ( !previousSelectedItem )
1312 switch ( direction )
1322 if ( !selectedItem )
1336 QList<QgsComposerItem*>::iterator it = selectedItems.begin();
1337 for ( ; it != selectedItems.end(); ++it )
1350 QMutableLinkedListIterator<QgsComposerItem*> it(
mItemZList );
1351 if ( it.findNext( item ) )
1354 while ( it.hasPrevious() )
1360 if ( it.value() && it.value()->scene() )
1372 QList<QgsComposerItem*>::iterator it = selectedItems.begin();
1374 for ( ; it != selectedItems.end(); ++it )
1387 QMutableLinkedListIterator<QgsComposerItem*> it(
mItemZList );
1388 if ( it.findNext( item ) )
1398 QList<QgsComposerItem*>::iterator it = selectedItems.begin();
1399 for ( ; it != selectedItems.end(); ++it )
1412 QMutableLinkedListIterator<QgsComposerItem*> it(
mItemZList );
1413 if ( it.findNext( item ) )
1423 if ( selectedItems.size() < 2 )
1428 QRectF selectedItemBBox;
1434 double minXCoordinate = selectedItemBBox.left();
1437 QUndoCommand* parentCommand =
new QUndoCommand(
tr(
"Aligned items left" ) );
1438 QList<QgsComposerItem*>::iterator align_it = selectedItems.begin();
1439 for ( ; align_it != selectedItems.end(); ++align_it )
1443 ( *align_it )->setPos( minXCoordinate, ( *align_it )->pos().y() );
1453 if ( selectedItems.size() < 2 )
1458 QRectF selectedItemBBox;
1464 double averageXCoord = ( selectedItemBBox.left() + selectedItemBBox.right() ) / 2.0;
1467 QUndoCommand* parentCommand =
new QUndoCommand(
tr(
"Aligned items horizontal center" ) );
1468 QList<QgsComposerItem*>::iterator align_it = selectedItems.begin();
1469 for ( ; align_it != selectedItems.end(); ++align_it )
1473 ( *align_it )->setPos( averageXCoord - ( *align_it )->rect().width() / 2.0, ( *align_it )->pos().y() );
1483 if ( selectedItems.size() < 2 )
1488 QRectF selectedItemBBox;
1494 double maxXCoordinate = selectedItemBBox.right();
1497 QUndoCommand* parentCommand =
new QUndoCommand(
tr(
"Aligned items right" ) );
1498 QList<QgsComposerItem*>::iterator align_it = selectedItems.begin();
1499 for ( ; align_it != selectedItems.end(); ++align_it )
1503 ( *align_it )->setPos( maxXCoordinate - ( *align_it )->rect().width(), ( *align_it )->pos().y() );
1513 if ( selectedItems.size() < 2 )
1518 QRectF selectedItemBBox;
1524 double minYCoordinate = selectedItemBBox.top();
1526 QUndoCommand* parentCommand =
new QUndoCommand(
tr(
"Aligned items top" ) );
1527 QList<QgsComposerItem*>::iterator align_it = selectedItems.begin();
1528 for ( ; align_it != selectedItems.end(); ++align_it )
1532 ( *align_it )->setPos(( *align_it )->pos().x(), minYCoordinate );
1542 if ( selectedItems.size() < 2 )
1547 QRectF selectedItemBBox;
1553 double averageYCoord = ( selectedItemBBox.top() + selectedItemBBox.bottom() ) / 2.0;
1554 QUndoCommand* parentCommand =
new QUndoCommand(
tr(
"Aligned items vertical center" ) );
1555 QList<QgsComposerItem*>::iterator align_it = selectedItems.begin();
1556 for ( ; align_it != selectedItems.end(); ++align_it )
1560 ( *align_it )->setPos(( *align_it )->pos().x(), averageYCoord - ( *align_it )->rect().height() / 2 );
1570 if ( selectedItems.size() < 2 )
1575 QRectF selectedItemBBox;
1581 double maxYCoord = selectedItemBBox.bottom();
1582 QUndoCommand* parentCommand =
new QUndoCommand(
tr(
"Aligned items bottom" ) );
1583 QList<QgsComposerItem*>::iterator align_it = selectedItems.begin();
1584 for ( ; align_it != selectedItems.end(); ++align_it )
1588 ( *align_it )->setPos(( *align_it )->pos().x(), maxYCoord - ( *align_it )->rect().height() );
1597 QUndoCommand* parentCommand =
new QUndoCommand(
tr(
"Items locked" ) );
1599 QList<QgsComposerItem*>::iterator itemIter = selectionList.begin();
1600 for ( ; itemIter != selectionList.end(); ++itemIter )
1604 ( *itemIter )->setPositionLock(
true );
1617 QUndoCommand* parentCommand =
new QUndoCommand(
tr(
"Items unlocked" ) );
1622 QList<QGraphicsItem *> itemList = items();
1623 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
1624 for ( ; itemIt != itemList.end(); ++itemIt )
1645 QLinkedList<QgsComposerItem*>::iterator it =
mItemZList.begin();
1648 QUndoCommand* parentCommand = 0;
1649 if ( addUndoCommands )
1651 parentCommand =
new QUndoCommand(
tr(
"Item z-order changed" ) );
1659 if ( addUndoCommands )
1664 currentItem->setZValue( counter );
1665 if ( addUndoCommands )
1672 if ( addUndoCommands )
1686 QLinkedList<QgsComposerItem*>::const_iterator lIt =
mItemZList.constBegin();
1687 QLinkedList<QgsComposerItem*> sortedList;
1689 for ( ; lIt !=
mItemZList.constEnd(); ++lIt )
1691 QLinkedList<QgsComposerItem*>::iterator insertIt = sortedList.begin();
1692 for ( ; insertIt != sortedList.end(); ++insertIt )
1694 if (( *lIt )->zValue() < ( *insertIt )->zValue() )
1699 sortedList.insert( insertIt, ( *lIt ) );
1707 QLinkedList<QgsComposerItem*> sortedList;
1712 QList<QGraphicsItem*> itemList = items();
1713 QList<QGraphicsItem*>::iterator itemIt = itemList.begin();
1714 for ( ; itemIt != itemList.end(); ++itemIt )
1722 sortedList.prepend( composerItem );
1744 double yPage = scenePoint.y() - yOffset;
1756 xSnapped = scenePoint.x();
1761 ySnapped = scenePoint.y();
1764 return QPointF( xSnapped, ySnapped );
1769 QGraphicsLineItem* item =
new QGraphicsLineItem();
1770 QPen linePen( Qt::SolidLine );
1771 linePen.setColor( Qt::red );
1774 linePen.setWidthF( 0 );
1775 item->setPen( linePen );
1776 item->setZValue( 100 );
1792 QList< QGraphicsLineItem* >::iterator it =
mSnapLines.begin();
1795 removeItem(( *it ) );
1804 QList< QGraphicsLineItem* >::iterator it =
mSnapLines.begin();
1819 QList< QPair< QgsComposerItem*, QgsComposerItem::ItemPositionMode> >& snappedItems )
1821 double minSqrDist = DBL_MAX;
1822 QGraphicsLineItem* item = 0;
1823 double currentXCoord = 0;
1824 double currentYCoord = 0;
1825 double currentSqrDist = 0;
1826 double sqrTolerance = tolerance * tolerance;
1828 snappedItems.clear();
1830 QList< QGraphicsLineItem* >::const_iterator it =
mSnapLines.constBegin();
1833 bool itemHorizontal =
qgsDoubleNear(( *it )->line().y2() - ( *it )->line().y1(), 0 );
1834 if ( horizontal && itemHorizontal )
1836 currentYCoord = ( *it )->line().y1();
1837 currentSqrDist = ( y - currentYCoord ) * ( y - currentYCoord );
1839 else if ( !horizontal && !itemHorizontal )
1841 currentXCoord = ( *it )->line().x1();
1842 currentSqrDist = ( x - currentXCoord ) * ( x - currentXCoord );
1849 if ( currentSqrDist < minSqrDist && currentSqrDist < sqrTolerance )
1852 minSqrDist = currentSqrDist;
1856 double itemTolerance = 0.0000001;
1860 QList<QGraphicsItem *> itemList = items();
1861 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
1862 for ( ; itemIt != itemList.end(); ++itemIt )
1872 if (
qgsDoubleNear( currentYCoord, currentItem->pos().y() + currentItem->rect().top(), itemTolerance ) )
1876 else if (
qgsDoubleNear( currentYCoord, currentItem->pos().y() + currentItem->rect().center().y(), itemTolerance ) )
1880 else if (
qgsDoubleNear( currentYCoord, currentItem->pos().y() + currentItem->rect().bottom(), itemTolerance ) )
1887 if (
qgsDoubleNear( currentXCoord, currentItem->pos().x(), itemTolerance ) )
1891 else if (
qgsDoubleNear( currentXCoord, currentItem->pos().x() + currentItem->rect().center().x(), itemTolerance ) )
1895 else if (
qgsDoubleNear( currentXCoord, currentItem->pos().x() + currentItem->rect().width(), itemTolerance ) )
1909 if ( selectedItems.size() < 1 )
1916 double minX = currentItem->pos().x();
1917 double minY = currentItem->pos().y();
1918 double maxX = minX + currentItem->rect().width();
1919 double maxY = minY + currentItem->rect().height();
1921 double currentMinX, currentMinY, currentMaxX, currentMaxY;
1923 for (
int i = 1; i < selectedItems.size(); ++i )
1925 currentItem = selectedItems.at( i );
1926 currentMinX = currentItem->pos().x();
1927 currentMinY = currentItem->pos().y();
1928 currentMaxX = currentMinX + currentItem->rect().width();
1929 currentMaxY = currentMinY + currentItem->rect().height();
1931 if ( currentMinX < minX )
1933 if ( currentMaxX > maxX )
1935 if ( currentMinY < minY )
1937 if ( currentMaxY > maxY )
1941 bRect.setTopLeft( QPointF( minX, minY ) );
1942 bRect.setBottomRight( QPointF( maxX, maxY ) );
2008 QString gridStyleString;
2009 gridStyleString = s.value(
"/Composer/gridStyle",
"Dots" ).toString();
2011 int gridRed, gridGreen, gridBlue, gridAlpha;
2012 gridRed = s.value(
"/Composer/gridRed", 190 ).toInt();
2013 gridGreen = s.value(
"/Composer/gridGreen", 190 ).toInt();
2014 gridBlue = s.value(
"/Composer/gridBlue", 190 ).toInt();
2015 gridAlpha = s.value(
"/Composer/gridAlpha", 100 ).toInt();
2016 QColor gridColor = QColor( gridRed, gridGreen, gridBlue, gridAlpha );
2021 if ( gridStyleString ==
"Dots" )
2025 else if ( gridStyleString ==
"Crosses" )
2123 connect( arrow, SIGNAL( sizeChanged() ),
this, SLOT(
updateBounds() ) );
2133 connect( label, SIGNAL( sizeChanged() ),
this, SLOT(
updateBounds() ) );
2141 if ( setDefaultPreviewStyle )
2153 connect( map, SIGNAL( sizeChanged() ),
this, SLOT(
updateBounds() ) );
2160 addItem( scaleBar );
2163 connect( scaleBar, SIGNAL( sizeChanged() ),
this, SLOT(
updateBounds() ) );
2173 connect( legend, SIGNAL( sizeChanged() ),
this, SLOT(
updateBounds() ) );
2183 connect( picture, SIGNAL( sizeChanged() ),
this, SLOT(
updateBounds() ) );
2193 connect( shape, SIGNAL( sizeChanged() ),
this, SLOT(
updateBounds() ) );
2203 connect( table, SIGNAL( sizeChanged() ),
this, SLOT(
updateBounds() ) );
2213 connect( frame, SIGNAL( sizeChanged() ),
this, SLOT(
updateBounds() ) );
2229 QUndoCommand* parentCommand =
new QUndoCommand(
tr(
"Remove item group" ) );
2231 QSet<QgsComposerItem*> groupedItems = itemGroup->
items();
2232 QSet<QgsComposerItem*>::iterator it = groupedItems.begin();
2233 for ( ; it != groupedItems.end(); ++it )
2248 if ( createCommand )
2269 if ( frameItem && multiFrame )
2274 if ( createCommand )
2277 multiFrame,
this,
tr(
"Multiframe removed" ) );
2388 QList< QgsPaperItem* >::iterator paperIt =
mPages.begin();
2389 for ( ; paperIt !=
mPages.end(); ++paperIt )
2391 ( *paperIt )->update();
2401 paperItem->setBrush( Qt::white );
2402 addItem( paperItem );
2403 paperItem->setZValue( 0 );
2404 mPages.push_back( paperItem );
2411 for (
int i = 0; i <
mPages.size(); ++i )
2421 QSet<QgsComposerMultiFrame*>::iterator multiFrameIt =
mMultiFrames.begin();
2422 for ( ; multiFrameIt !=
mMultiFrames.end(); ++multiFrameIt )
2424 delete *multiFrameIt;
2431 printer.setOutputFileName( file );
2438 printer.setOutputFormat( QPrinter::PdfFormat );
2452 return print( printer );
2458 int fromPage = ( printer.fromPage() < 1 ) ? 0 : printer.fromPage() - 1 ;
2459 int toPage = ( printer.toPage() < 1 ) ?
numPages() - 1 : printer.toPage() - 1;
2463 for (
int i = fromPage; i <= toPage; ++i )
2471 if ( !image.isNull() )
2473 QRectF targetArea( 0, 0, image.width(), image.height() );
2474 p.drawImage( targetArea, image, targetArea );
2481 for (
int i = fromPage; i <= toPage; ++i )
2495 printer.setFullPage(
true );
2496 printer.setColorMode( QPrinter::Color );
2506 bool ready = p.begin( &printer );
2522 QImage image( QSize( width, height ), QImage::Format_ARGB32 );
2523 if ( !image.isNull() )
2528 QPainter imagePainter( &image );
2530 if ( !imagePainter.isActive() )
return QImage();
2537 if (
mPages.size() <= page )
2548 QPaintDevice* paintDevice = p->device();
2554 QRectF paperRect = QRectF( paperItem->pos().x(), paperItem->pos().y(), paperItem->rect().width(), paperItem->rect().height() );
2561 setBackgroundBrush( Qt::NoBrush );
2562 render( p, QRectF( 0, 0, paintDevice->width(), paintDevice->height() ), paperRect );
2564 setBackgroundBrush( QColor( 215, 215, 215 ) );
2572 QString modifiedStr( str );
2573 modifiedStr.replace(
"&",
"&" );
2574 modifiedStr.replace(
"\"",
""" );
2575 modifiedStr.replace(
"'",
"'" );
2576 modifiedStr.replace(
"<",
"<" );
2577 modifiedStr.replace(
">",
">" );
2596 double xr = extent.
width() / brect.width();
2597 double yr = extent.
height() / brect.height();
2599 double XC = extent.
center().
x();
2600 double YC = extent.
center().
y();
2607 double X0 = paperExtent.
xMinimum();
2608 double Y0 = paperExtent.
yMinimum();
2613 double Ww = paperExtent.
width() / widthPx;
2614 double Hh = paperExtent.
height() / heightPx;
2623 s[5] = Y0 + paperExtent.
height();
2627 r[0] = cos( alpha );
2628 r[1] = -sin( alpha );
2629 r[2] = XC * ( 1 - cos( alpha ) ) + YC * sin( alpha );
2630 r[3] = sin( alpha );
2631 r[4] = cos( alpha );
2632 r[5] = - XC * sin( alpha ) + YC * ( 1 - cos( alpha ) );
2635 a = r[0] * s[0] + r[1] * s[3];
2636 b = r[0] * s[1] + r[1] * s[4];
2637 c = r[0] * s[2] + r[1] * s[5] + r[2];
2638 d = r[3] * s[0] + r[4] * s[3];
2639 e = r[3] * s[1] + r[4] * s[4];
2640 f = r[3] * s[2] + r[4] * s[5] + r[5];
2654 if ( ! atlasHasFeatures )
2662 QList<QgsComposerMap*> maps;
2664 for ( QList<QgsComposerMap*>::iterator mit = maps.begin(); mit != maps.end(); ++mit )
2681 double left =
relativePosition( rectToResize.left(), boundsBefore.left(), boundsBefore.right(), boundsAfter.left(), boundsAfter.right() );
2682 double right =
relativePosition( rectToResize.right(), boundsBefore.left(), boundsBefore.right(), boundsAfter.left(), boundsAfter.right() );
2683 double top =
relativePosition( rectToResize.top(), boundsBefore.top(), boundsBefore.bottom(), boundsAfter.top(), boundsAfter.bottom() );
2684 double bottom =
relativePosition( rectToResize.bottom(), boundsBefore.top(), boundsBefore.bottom(), boundsAfter.top(), boundsAfter.bottom() );
2686 rectToResize.setRect( left, top, right - left, bottom - top );
2692 double m = ( afterMax - afterMin ) / ( beforeMax - beforeMin );
2693 double c = afterMin - ( beforeMin * m );
2696 return m * position + c;
void lowerSelectedItems()
bool positionLock() const
Returns position lock for mouse drags (true means locked)
void setGridVisible(bool b)
QgsComposition::PlotStyle mPlotStyle
Item representing the paper.
QgsComposerItem * getComposerItemBelow(QgsComposerItem *item)
A scale bar item that can be added to a map composition.
QUndoStack * undoStack()
Returns pointer to undo/redo command storage.
void unlockAllItems()
Unlock all items.
void loadDefaults()
Loads default composer settings.
A rectangle specified with double values.
double paperWidth() const
Returns width of paper item.
bool writeXML(QDomElement &composerElem, QDomDocument &doc)
Writes settings to xml (paper dimension)
bool readXML(const QDomElement &itemElem, const QDomDocument &doc)
sets state from Dom document
const QgsComposerItem * getComposerItemById(QString theId) const
Returns a composer item given its text identifier.
void setEffectsEnabled(bool effectsEnabled)
Sets whether effects (eg blend modes) are enabled for the item.
double mAlignmentSnapTolerance
int boundingRectOfSelectedItems(QRectF &bRect)
Returns the bounding rectangle of the selected items in scene coordinates.
An item that draws an arrow between to points.
void addItemToZList(QgsComposerItem *item)
Adds item to z list.
bool readXML(const QDomElement &itemElem, const QDomDocument &doc)
sets state from Dom document
void composerArrowAdded(QgsComposerArrow *arrow)
Is emitted when new composer arrow has been added to the view.
double mSnapGridTolerance
void setSnapLinesVisible(bool visible)
Hides / shows custom snap lines.
void setPageStyleSymbol(QgsFillSymbolV2 *symbol)
Note: added in version 2.1.
void assignFreeId()
Sets mId to a number not yet used in the composition.
bool readXML(const QDomElement &itemElem, const QDomDocument &doc)
sets state from Dom document
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.
void alignSelectedItemsTop()
void composerPictureAdded(QgsComposerPicture *picture)
Is emitted when a new composer picture has been added.
int pageNumberForPoint(const QPointF &position) const
Returns the page number corresponding to a point in the composition.
QgsComposerItem * getComposerItemAbove(QgsComposerItem *item)
void setNumPages(int pages)
Note: added in version 1.9.
QPointF minPointFromXml(const QDomElement &elem) const
Calculates the item minimum position from an xml string.
static QgsFillSymbolV2 * createSimple(const QgsStringMap &properties)
Create a fill symbol with one symbol layer: SimpleFill with specified properties. ...
void cache()
Create cache image.
bool readXML(const QDomElement &itemElem, const QDomDocument &doc)
Reads the properties specific to an attribute table 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 setSelectedItem(QgsComposerItem *item)
Clears any selected items and sets an item as the current selection.
void removeItemFromZList(QgsComposerItem *item)
Removes item from z list.
void setSnapGridOffsetY(double offset)
QPointF snapPointToGrid(const QPointF &scenePoint) const
Snaps a scene coordinate point to grid.
void updateBounds()
Updates the scene bounds of the composition.
void removeComposerItem(QgsComposerItem *item, bool createCommand=true)
Remove item from the graphics scene.
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)...
bool mPrintAsRaster
Flag if map should be printed as a raster (via QImage).
void setCreateUndoCommands(bool enabled)
QGraphicsLineItem * nearestSnapLine(bool horizontal, double x, double y, double tolerance, QList< QPair< QgsComposerItem *, QgsComposerItem::ItemPositionMode > > &snappedItems)
Get nearest snap line.
bool readXML(const QDomElement &itemElem, const QDomDocument &doc)
sets state from Dom document
void setSnapGridTolerance(double tolerance)
void beginPrintAsPDF(QPrinter &printer, const QString &file)
Prepare the printer for printing in a PDF.
QList< QgsPaperItem * > mPages
A non GUI class for rendering a map layer set onto a QPainter.
void composerScaleBarAdded(QgsComposerScaleBar *scalebar)
Is emitted when new composer scale bar has been added.
void moveSelectedItemsToBottom()
void alignSelectedItemsHCenter()
double spaceBetweenPages() const
void beginMultiFrameCommand(QgsComposerMultiFrame *multiFrame, const QString &text)
bool loadFromTemplate(const QDomDocument &doc, QMap< QString, QString > *substitutionMap=0, bool addUndoCommands=false)
Load a template document.
void setStatusMessage(const QString &message)
Sets the status bar message for the composer window.
double mapRotation() const
Returns the rotation used for drawing the map within the composer item.
QMap< QString, QString > QgsStringMap
void composerMapAdded(QgsComposerMap *map)
Is emitted when new composer map has been added to the view.
int numPages() const
Note: added in version 1.9.
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
static double relativePosition(double position, double beforeMin, double beforeMax, double afterMin, double afterMax)
Returns a scaled position given a before and after range.
void alignSelectedItemsVCenter()
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)
void endMultiFrameCommand()
QSet< QgsComposerItem * > items()
void beginPrint(QPrinter &printer)
Prepare the printer for printing.
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.
virtual int type() const
return correct graphics item type.
QgsComposerItem * composerItemAt(const QPointF &position)
Returns the topmost composer item.
double ANALYSIS_EXPORT max(double x, double y)
returns the maximum of two doubles or the first argument if both are equal
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)
void lowerItem(QgsComposerItem *item)
static QDomElement saveSymbol(QString symbolName, QgsSymbolV2 *symbol, QDomDocument &doc)
QString uuid() const
Get item identification name.
void refreshItemsTriggered()
Is emitted when item in the composition must be refreshed.
bool beginRender()
Begins the rendering.
void setPrintResolution(int dpi)
int itemPageNumber(const QgsComposerItem *) const
Returns on which page number (0-based) is displayed an item.
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
void selectNextByZOrder(ZValueDirection direction)
void cancelCommand()
Deletes current command.
void toggleAtlasPreview()
Called when atlas preview is toggled, to force map item to update its extent and redraw.
bool mGenerateWorldFile
Flag if a world file should be generated on raster export.
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-bsaed) 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 setSnapGridResolution(double r)
void updatePagePos(double newPageWidth, double newPageHeight)
Moves the item so that it retains its relative position on the page when the paper size changes...
QSet< QgsComposerMultiFrame * > mMultiFrames
List multiframe objects.
void removeSnapLine(QGraphicsLineItem *line)
Remove custom snap line (and delete the object)
void alignSelectedItemsRight()
QLinkedList< QgsComposerItem * > mItemZList
Maintains z-Order of items.
QRectF compositionBounds() const
Calculates the bounds of all non-gui items in the composition.
Abstract base class for composer entries with the ability to distribute the content to several frames...
bool setAtlasMode(QgsComposition::AtlasMode mode)
Sets the current atlas mode of the composition.
QgsComposerItemCommand * mActiveItemCommand
void moveItemToTop(QgsComposerItem *item)
bool readXML(const QDomElement &itemElem, const QDomDocument &doc)
sets state from Dom document
void moveSelectedItemsToTop()
int frameCount() const
Return the number of frames associated with this multiframeset.
int mPrintResolution
Dpi for printout.
void sortZList()
Sorts the zList.
void removeMultiFrame(QgsComposerMultiFrame *multiFrame)
Removes multi frame (but does not delete it)
Object representing map window.
Frame for html, table, text which can be divided onto several frames.
bool readXML(const QDomElement &compositionElem, const QDomDocument &doc)
Reads settings from xml file.
QgsComposerMouseHandles * mSelectionHandles
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.
void setSnapToGridEnabled(bool b)
int pixelFontSize(double pointSize) const
Returns the pixel font size for a font that has point size set.
void setPositionLock(bool lock)
Locks / unlocks the item position for mouse drags.
PreviewMode previewMode() const
void updateSettings()
Refreshes the composition when composer related options change Note: added in version 2...
void saveAfterState()
Saves current item state as after state.
double mSpaceBetweenPages
static QString encodeStringForXML(const QString &str)
bool mSnapToGrid
Parameters for snap to grid function.
void raiseItem(QgsComposerItem *item)
bool mPreventCursorChange
void composerTableAdded(QgsComposerAttributeTable *table)
Is emitted when a new composer table has been added.
void refreshZList()
Rebuilds the z order list based on current order of items in scene.
int id() const
Get identification number.
QgsComposition::AtlasMode mAtlasMode
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.
A composer command class for adding / removing composer items.
void statusMsgChanged(QString message)
Is emitted when the composition has an updated status bar message for the composer window...
void clearSnapLines()
Removes all snap lines.
A table class that displays a vector attribute table.
bool mAlignmentSnap
Parameters for alignment snap.
Undo command to undo/redo all composer item related changes.
void connectAddRemoveCommandSignals(QgsAddRemoveItemCommand *c)
void updateZValues(bool addUndoCommands=true)
Reset z-values of items based on position in z list.
A composer items that draws common shapes (ellipse, triangle, rectangle)
virtual void endItemCommand()
void raiseSelectedItems()
QgsComposerMap * mWorldFileMap
Composer map to use for the world file generation.
void setSnapGridOffsetX(double offset)
bool readXML(const QDomElement &itemElem, const QDomDocument &doc)
sets state from Dom document
void addComposerHtmlFrame(QgsComposerHtml *html, QgsComposerFrame *frame)
Adds composer html frame and advices composer to create a widget for it (through signal) ...
AtlasMode
Composition atlas modes.
static QgsProject * instance()
access to canonical QgsProject instance
QPointF positionOnPage(const QPointF &position) const
Returns the position within a page of a point in the composition.
void alignSelectedItemsBottom()
static void fixEngineFlags(QPaintEngine *engine)
void alignSelectedItemsLeft()
QList< QGraphicsLineItem * > mSnapLines
Arbitraty snap lines (horizontal and vertical)
double paperHeight() const
Returns height of paper item.
QgsComposerMultiFrameCommand * mActiveMultiFrameCommand
QgsAtlasComposition mAtlasComposition
The atlas composition object.
void selectedItemChanged(QgsComposerItem *selected)
Is emitted when selected item changed.
bool print(QPrinter &printer)
Convenience function that prepares the printer and prints.
void renderPage(QPainter *p, int page)
Render a page to a paint device.
void pushAddRemoveCommand(QgsComposerItem *item, const QString &text, QgsAddRemoveItemCommand::State state=QgsAddRemoveItemCommand::Added)
Convenience function to create a QgsAddRemoveItemCommand, connect its signals and push it to the undo...
A label that can be placed onto a map composition.
void setUseAdvancedEffects(bool effectsEnabled)
Used to enable or disable advanced effects such as blend modes in a composition.
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()
void composerHtmlFrameAdded(QgsComposerHtml *html, QgsComposerFrame *frame)
Is emitted when a new composer html has been added to the view.
void doPrint(QPrinter &printer, QPainter &painter)
Print on a preconfigured printer.
static 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...
Handles drawing of selection outlines and mouse handles.
static QgsSymbolV2 * loadSymbol(QDomElement &element)
const QgsComposerHtml * getComposerHtmlByItem(QgsComposerItem *item) const
Returns the composer html with specified id (a string as named in the composer user interface item pr...
bool atlasDriven() const
Returns whether the map extent is set to follow the current atlas feature.
static void setSpecialColumn(const QString &name, QVariant value)
Assign a special column.
double pointFontSize(int pixelSize) const
Does the inverse calculation and returns points for pixels (equals to mm in QgsComposition) ...
QGraphicsLineItem * addSnapLine()
Add a custom snap line (can be horizontal or vertical)
void composerItems(QList< T * > &itemList)
Return composer items of a specific type.
void printResolutionChanged()
Is emitted when the compositions print resolution changes.
void moveItemToBottom(QgsComposerItem *item)
void setPreviewMode(PreviewMode m)
double width() const
Width of the rectangle.
QgsComposerMultiFrame * multiFrame() const
bool mUseAdvancedEffects
Flag if advanced visual effects such as blend modes should be used.
QList< QgsComposerItem * > selectedComposerItems()
void deleteAndRemoveMultiFrames()
const QgsComposerMap * getComposerMapById(int id) const
Returns the composer map with specified id.
void move(double dx, double dy)
Moves item in canvas coordinates.
double mSnapGridResolution
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.
QgsPoint center() const
Center point of the rectangle.
bool readXML(const QDomElement &itemElem, const QDomDocument &doc)
sets state from Dom document
void setGridStyle(GridStyle s)
virtual bool writeXML(QDomElement &elem, QDomDocument &doc) const =0
stores state in Dom element
void addComposerArrow(QgsComposerArrow *arrow)
Adds an arrow item to the graphics scene and advices composer to create a widget for it (through sign...
void loadSettings()
Loads composer settings which may change, eg grid color.
void addComposerMap(QgsComposerMap *map, bool setDefaultPreviewStyle=true)
Adds map to the graphics scene and advices composer to create a widget for it (through signal) ...
bool readXML(const QDomElement &itemElem, const QDomDocument &doc)
sets state from Dom document
void setPaperSize(double width, 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.
const QgsComposerItem * getComposerItemByUuid(QString theUuid) const
Returns a composer item given its unique identifier.
void createDefaultPageStyleSymbol()
double height() const
Height of the rectangle.
QgsFillSymbolV2 * mPageStyleSymbol
Drawing style for page.
void beginCommand(QgsComposerItem *item, const QString &commandText, QgsComposerMergeCommand::Context c=QgsComposerMergeCommand::Unknown)
Allocates new item command and saves initial state in it.
bool readXML(const QDomElement &itemElem, const QDomDocument &doc, bool ignoreFrames=false)
QList< QGraphicsLineItem * > * snapLines()
Returns pointer to snap lines collection.
QString id() const
Get item's id (which is not necessarly unique)