43 #include <QDomDocument>
44 #include <QDomElement>
45 #include <QGraphicsRectItem>
55 , mMapRenderer( mapRenderer )
59 , mSpaceBetweenPages( 10 )
60 , mPageStyleSymbol( 0 )
61 , mPrintAsRaster( false )
62 , mGenerateWorldFile( false )
64 , mUseAdvancedEffects( true )
65 , mSnapToGrid( false )
66 , mGridVisible( false )
67 , mSnapGridResolution( 0 )
68 , mSnapGridTolerance( 0 )
69 , mSnapGridOffsetX( 0 )
70 , mSnapGridOffsetY( 0 )
71 , mAlignmentSnap( true )
72 , mGuidesVisible( true )
73 , mSmartGuides( true )
74 , mAlignmentSnapTolerance( 0 )
75 , mSelectionHandles( 0 )
76 , mActiveItemCommand( 0 )
77 , mActiveMultiFrameCommand( 0 )
78 , mAtlasComposition( this )
80 , mPreventCursorChange( false )
82 setBackgroundBrush( QColor( 215, 215, 215 ) );
102 : QGraphicsScene( 0 ),
107 mSpaceBetweenPages( 10 ),
108 mPageStyleSymbol( 0 ),
109 mPrintAsRaster( false ),
110 mGenerateWorldFile( false ),
112 mUseAdvancedEffects( true ),
113 mSnapToGrid( false ),
114 mGridVisible( false ),
115 mSnapGridResolution( 0 ),
116 mSnapGridTolerance( 0 ),
117 mSnapGridOffsetX( 0 ),
118 mSnapGridOffsetY( 0 ),
119 mAlignmentSnap( true ),
120 mGuidesVisible( true ),
121 mSmartGuides( true ),
122 mAlignmentSnapTolerance( 0 ),
123 mSelectionHandles( 0 ),
124 mActiveItemCommand( 0 ),
125 mActiveMultiFrameCommand( 0 ),
126 mAtlasComposition( this ),
128 mPreventCursorChange( false )
152 mSnapGridResolution = settings.value(
"/Composer/defaultSnapGridResolution", 10.0 ).toDouble();
153 mSnapGridTolerance = settings.value(
"/Composer/defaultSnapGridTolerance", 2 ).toDouble();
154 mSnapGridOffsetX = settings.value(
"/Composer/defaultSnapGridOffsetX", 0 ).toDouble();
155 mSnapGridOffsetY = settings.value(
"/Composer/defaultSnapGridOffsetY", 0 ).toDouble();
167 QRectF bounds = QRectF( 0, 0, 0, 0 );
170 QList<QGraphicsItem *> itemList = items();
171 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
172 for ( ; itemIt != itemList.end(); ++itemIt )
176 if (( composerItem || paperItem ) )
179 bounds = bounds.united(( *itemIt )->sceneBoundingRect() );
194 for (
int i = 0; i <
mPages.size(); ++i )
196 mPages.at( i )->setSceneRect( QRectF( 0, currentY, width, height ) );
216 int diff = pages - currentPages;
219 for (
int i = 0; i < diff; ++i )
227 for (
int i = 0; i < diff; ++i )
257 properties.insert(
"color",
"white" );
258 properties.insert(
"style",
"solid" );
259 properties.insert(
"style_border",
"no" );
277 return QPointF( position.x(), y );
283 pageNumber = pageNumber < 1 ? 1 : pageNumber;
284 pageNumber = pageNumber >
mPages.size() ?
mPages.size() : pageNumber;
301 QList<QGraphicsItem*> itemList;
302 itemList = items( position, Qt::IntersectsItemShape, Qt::DescendingOrder );
303 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
305 bool foundBelowItem =
false;
306 for ( ; itemIt != itemList.end(); ++itemIt )
310 if ( composerItem && !paperItem )
314 if ( ! belowItem || foundBelowItem )
320 if ( composerItem == belowItem )
323 foundBelowItem =
true;
338 return pageNumberAt( QPointF( item->pos().x(), item->pos().y() ) );
343 QList<QgsComposerItem*> composerItemList;
345 QList<QGraphicsItem *> graphicsItemList = selectedItems();
346 QList<QGraphicsItem *>::iterator itemIter = graphicsItemList.begin();
348 for ( ; itemIter != graphicsItemList.end(); ++itemIter )
353 composerItemList.push_back( composerItem );
357 return composerItemList;
362 QList<const QgsComposerMap*> resultList;
364 QList<QGraphicsItem *> itemList = items();
365 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
366 for ( ; itemIt != itemList.end(); ++itemIt )
371 resultList.push_back( composerMap );
380 QList<QGraphicsItem *> itemList = items();
381 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
382 for ( ; itemIt != itemList.end(); ++itemIt )
387 if ( composerMap->
id() == id )
417 QList<QGraphicsItem *> itemList = items();
418 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
419 for ( ; itemIt != itemList.end(); ++itemIt )
424 if ( mypItem->
id() == theId )
437 QSet<QgsComposer*> composers = QSet<QgsComposer*>();
439 if ( inAllComposers )
441 composers = QgisApp::instance()->printComposers();
445 composers.insert(
this )
448 QSet<QgsComposer*>::const_iterator it = composers.constBegin();
449 for ( ; it != composers.constEnd(); ++it )
451 QList<QGraphicsItem *> itemList = ( *it )->items();
452 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
453 for ( ; itemIt != itemList.end(); ++itemIt )
458 if ( mypItem->
uuid() == theUuid )
472 QList<QGraphicsItem *> itemList = items();
473 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
474 for ( ; itemIt != itemList.end(); ++itemIt )
479 if ( mypItem->
uuid() == theUuid )
495 QList<QGraphicsItem*> itemList = items();
496 QList<QGraphicsItem*>::const_iterator itemIt = itemList.constBegin();
497 for ( ; itemIt != itemList.constEnd(); ++itemIt )
510 double sizeMillimeters = pointSize * 0.3527;
511 return qRound( sizeMillimeters );
516 double sizePoint = pixelSize / 0.3527;
522 if ( composerElem.isNull() )
527 QDomElement compositionElem = doc.createElement(
"Composition" );
528 compositionElem.setAttribute(
"paperWidth", QString::number(
mPageWidth ) );
529 compositionElem.setAttribute(
"paperHeight", QString::number(
mPageHeight ) );
530 compositionElem.setAttribute(
"numPages",
mPages.size() );
533 compositionElem.appendChild( pageStyleElem );
538 compositionElem.setAttribute(
"snapping",
"1" );
542 compositionElem.setAttribute(
"snapping",
"0" );
546 compositionElem.setAttribute(
"gridVisible",
"1" );
550 compositionElem.setAttribute(
"gridVisible",
"0" );
552 compositionElem.setAttribute(
"snapGridResolution", QString::number(
mSnapGridResolution ) );
553 compositionElem.setAttribute(
"snapGridTolerance", QString::number(
mSnapGridTolerance ) );
554 compositionElem.setAttribute(
"snapGridOffsetX", QString::number(
mSnapGridOffsetX ) );
555 compositionElem.setAttribute(
"snapGridOffsetY", QString::number(
mSnapGridOffsetY ) );
558 QList< QGraphicsLineItem* >::const_iterator snapLineIt =
mSnapLines.constBegin();
559 for ( ; snapLineIt !=
mSnapLines.constEnd(); ++snapLineIt )
561 QDomElement snapLineElem = doc.createElement(
"SnapLine" );
562 QLineF line = ( *snapLineIt )->line();
563 snapLineElem.setAttribute(
"x1", QString::number( line.x1() ) );
564 snapLineElem.setAttribute(
"y1", QString::number( line.y1() ) );
565 snapLineElem.setAttribute(
"x2", QString::number( line.x2() ) );
566 snapLineElem.setAttribute(
"y2", QString::number( line.y2() ) );
567 compositionElem.appendChild( snapLineElem );
579 compositionElem.setAttribute(
"alignmentSnap",
mAlignmentSnap ? 1 : 0 );
580 compositionElem.setAttribute(
"guidesVisible",
mGuidesVisible ? 1 : 0 );
581 compositionElem.setAttribute(
"smartGuides",
mSmartGuides ? 1 : 0 );
585 QList<QGraphicsItem*> itemList = items();
586 QList<QGraphicsItem*>::const_iterator itemIt = itemList.constBegin();
587 for ( ; itemIt != itemList.constEnd(); ++itemIt )
594 composerItem->
writeXML( compositionElem, doc );
600 QSet<QgsComposerMultiFrame*>::const_iterator multiFrameIt =
mMultiFrames.constBegin();
601 for ( ; multiFrameIt !=
mMultiFrames.constEnd(); ++multiFrameIt )
603 ( *multiFrameIt )->writeXML( compositionElem, doc );
605 composerElem.appendChild( compositionElem );
613 if ( compositionElem.isNull() )
619 bool widthConversionOk, heightConversionOk;
620 mPageWidth = compositionElem.attribute(
"paperWidth" ).toDouble( &widthConversionOk );
621 mPageHeight = compositionElem.attribute(
"paperHeight" ).toDouble( &heightConversionOk );
623 int numPages = compositionElem.attribute(
"numPages",
"1" ).toInt();
625 QDomElement pageStyleSymbolElem = compositionElem.firstChildElement(
"symbol" );
626 if ( !pageStyleSymbolElem.isNull() )
632 if ( widthConversionOk && heightConversionOk )
635 for (
int i = 0; i <
numPages; ++i )
642 mSnapToGrid = compositionElem.attribute(
"snapping",
"0" ).toInt() == 0 ?
false :
true;
643 mGridVisible = compositionElem.attribute(
"gridVisible",
"0" ).toInt() == 0 ?
false :
true;
646 mSnapGridTolerance = compositionElem.attribute(
"snapGridTolerance",
"2.0" ).toDouble();
647 mSnapGridOffsetX = compositionElem.attribute(
"snapGridOffsetX" ).toDouble();
648 mSnapGridOffsetY = compositionElem.attribute(
"snapGridOffsetY" ).toDouble();
650 mAlignmentSnap = compositionElem.attribute(
"alignmentSnap",
"1" ).toInt() == 0 ?
false :
true;
651 mGuidesVisible = compositionElem.attribute(
"guidesVisible",
"1" ).toInt() == 0 ?
false :
true;
652 mSmartGuides = compositionElem.attribute(
"smartGuides",
"1" ).toInt() == 0 ?
false :
true;
656 QDomNodeList snapLineNodes = compositionElem.elementsByTagName(
"SnapLine" );
657 for (
int i = 0; i < snapLineNodes.size(); ++i )
659 QDomElement snapLineElem = snapLineNodes.at( i ).toElement();
661 double x1 = snapLineElem.attribute(
"x1" ).toDouble();
662 double y1 = snapLineElem.attribute(
"y1" ).toDouble();
663 double x2 = snapLineElem.attribute(
"x2" ).toDouble();
664 double y2 = snapLineElem.attribute(
"y2" ).toDouble();
665 snapItem->setLine( x1, y1, x2, y2 );
668 mPrintAsRaster = compositionElem.attribute(
"printAsRaster" ).toInt();
669 mPrintResolution = compositionElem.attribute(
"printResolution",
"300" ).toInt();
671 mGenerateWorldFile = compositionElem.attribute(
"generateWorldFile",
"0" ).toInt() == 1 ?
true :
false;
685 QList<QGraphicsItem *> itemList = items();
686 QList<QGraphicsItem *>::iterator itemIter = itemList.begin();
687 for ( ; itemIter != itemList.end(); ++itemIter )
702 QDomDocument importDoc;
703 if ( substitutionMap )
705 QString xmlString = doc.toString();
706 QMap<QString, QString>::const_iterator sIt = substitutionMap->constBegin();
707 for ( ; sIt != substitutionMap->constEnd(); ++sIt )
709 xmlString = xmlString.replace(
"[" + sIt.key() +
"]",
encodeStringForXML( sIt.value() ) );
713 int errorLine, errorColumn;
714 if ( !importDoc.setContent( xmlString, &errorMsg, &errorLine, &errorColumn ) )
725 QDomElement compositionElem = importDoc.documentElement().firstChildElement(
"Composition" );
726 if ( compositionElem.isNull() )
731 bool ok =
readXML( compositionElem, importDoc );
738 QDomNodeList composerItemsNodes = importDoc.elementsByTagName(
"ComposerItem" );
739 for (
int i = 0; i < composerItemsNodes.count(); ++i )
741 QDomNode composerItemNode = composerItemsNodes.at( i );
742 if ( composerItemNode.isElement() )
744 composerItemNode.toElement().setAttribute(
"templateUuid", composerItemNode.toElement().attribute(
"uuid" ) );
745 composerItemNode.toElement().removeAttribute(
"uuid" );
750 addItemsFromXML( importDoc.documentElement(), importDoc, 0, addUndoCommands, 0 );
753 QDomElement atlasElem = importDoc.documentElement().firstChildElement(
"Atlas" );
762 QDomNodeList composerItemList = elem.elementsByTagName(
"ComposerItem" );
763 for (
int i = 0; i < composerItemList.size(); ++i )
765 QDomElement currentComposerItemElem = composerItemList.at( i ).toElement();
768 x = currentComposerItemElem.attribute(
"x" ).toDouble( &xOk );
769 y = currentComposerItemElem.attribute(
"y" ).toDouble( &yOk );
774 minX = qMin( minX, x );
775 minY = qMin( minY, y );
779 return QPointF( minX, minY );
783 return QPointF( 0, 0 );
788 bool addUndoCommands, QPointF* pos,
bool pasteInPlace )
790 QPointF* pasteInPlacePt = 0;
797 QPointF pasteShiftPos;
807 pasteShiftPos = *pos - minItemPos;
817 QDomNodeList composerLabelList = elem.elementsByTagName(
"ComposerLabel" );
818 for (
int i = 0; i < composerLabelList.size(); ++i )
820 QDomElement currentComposerLabelElem = composerLabelList.at( i ).toElement();
822 newLabel->
readXML( currentComposerLabelElem, doc );
825 if ( pasteInPlacePt )
828 newLabel->
move( pasteInPlacePt->x(), pasteInPlacePt->y() );
832 newLabel->
move( pasteShiftPos.x(), pasteShiftPos.y() );
835 lastPastedItem = newLabel;
838 newLabel->setZValue( newLabel->zValue() + zOrderOffset );
839 if ( addUndoCommands )
845 QDomNodeList composerMapList = elem.elementsByTagName(
"ComposerMap" );
846 for (
int i = 0; i < composerMapList.size(); ++i )
848 QDomElement currentComposerMapElem = composerMapList.at( i ).toElement();
850 newMap->
readXML( currentComposerMapElem, doc );
855 mapsToRestore->insert( newMap, (
int )( newMap->
previewMode() ) );
859 newMap->setZValue( newMap->zValue() + zOrderOffset );
865 newMap->
move( pasteInPlacePt->x(), pasteInPlacePt->y() );
869 newMap->
move( pasteShiftPos.x(), pasteShiftPos.y() );
872 lastPastedItem = newMap;
875 if ( addUndoCommands )
881 QList<QgsComposerMap*> maps;
883 for ( QList<QgsComposerMap*>::iterator mit = maps.begin(); mit != maps.end(); ++mit )
885 if (( *mit )->overviewFrameMapId() != -1 )
890 QObject::connect( overviewMap, SIGNAL( extentChanged() ), *mit, SLOT( overviewExtentChanged() ) );
896 QDomNodeList composerArrowList = elem.elementsByTagName(
"ComposerArrow" );
897 for (
int i = 0; i < composerArrowList.size(); ++i )
899 QDomElement currentComposerArrowElem = composerArrowList.at( i ).toElement();
901 newArrow->
readXML( currentComposerArrowElem, doc );
907 newArrow->
move( pasteInPlacePt->x(), pasteInPlacePt->y() );
911 newArrow->
move( pasteShiftPos.x(), pasteShiftPos.y() );
914 lastPastedItem = newArrow;
917 newArrow->setZValue( newArrow->zValue() + zOrderOffset );
918 if ( addUndoCommands )
924 QDomNodeList composerScaleBarList = elem.elementsByTagName(
"ComposerScaleBar" );
925 for (
int i = 0; i < composerScaleBarList.size(); ++i )
927 QDomElement currentComposerScaleBarElem = composerScaleBarList.at( i ).toElement();
929 newScaleBar->
readXML( currentComposerScaleBarElem, doc );
935 newScaleBar->
move( pasteInPlacePt->x(), pasteInPlacePt->y() );
939 newScaleBar->
move( pasteShiftPos.x(), pasteShiftPos.y() );
942 lastPastedItem = newScaleBar;
945 newScaleBar->setZValue( newScaleBar->zValue() + zOrderOffset );
946 if ( addUndoCommands )
952 QDomNodeList composerShapeList = elem.elementsByTagName(
"ComposerShape" );
953 for (
int i = 0; i < composerShapeList.size(); ++i )
955 QDomElement currentComposerShapeElem = composerShapeList.at( i ).toElement();
957 newShape->
readXML( currentComposerShapeElem, doc );
965 newShape->
move( pasteInPlacePt->x(), pasteInPlacePt->y() );
969 newShape->
move( pasteShiftPos.x(), pasteShiftPos.y() );
972 lastPastedItem = newShape;
975 newShape->setZValue( newShape->zValue() + zOrderOffset );
976 if ( addUndoCommands )
982 QDomNodeList composerPictureList = elem.elementsByTagName(
"ComposerPicture" );
983 for (
int i = 0; i < composerPictureList.size(); ++i )
985 QDomElement currentComposerPictureElem = composerPictureList.at( i ).toElement();
987 newPicture->
readXML( currentComposerPictureElem, doc );
993 newPicture->
move( pasteInPlacePt->x(), pasteInPlacePt->y() );
997 newPicture->
move( pasteShiftPos.x(), pasteShiftPos.y() );
1000 lastPastedItem = newPicture;
1003 newPicture->setZValue( newPicture->zValue() + zOrderOffset );
1004 if ( addUndoCommands )
1010 QDomNodeList composerLegendList = elem.elementsByTagName(
"ComposerLegend" );
1011 for (
int i = 0; i < composerLegendList.size(); ++i )
1013 QDomElement currentComposerLegendElem = composerLegendList.at( i ).toElement();
1015 newLegend->
readXML( currentComposerLegendElem, doc );
1021 newLegend->
move( pasteInPlacePt->x(), pasteInPlacePt->y() );
1025 newLegend->
move( pasteShiftPos.x(), pasteShiftPos.y() );
1028 lastPastedItem = newLegend;
1031 newLegend->setZValue( newLegend->zValue() + zOrderOffset );
1032 if ( addUndoCommands )
1038 QDomNodeList composerTableList = elem.elementsByTagName(
"ComposerAttributeTable" );
1039 for (
int i = 0; i < composerTableList.size(); ++i )
1041 QDomElement currentComposerTableElem = composerTableList.at( i ).toElement();
1043 newTable->
readXML( currentComposerTableElem, doc );
1049 newTable->
move( pasteInPlacePt->x(), pasteInPlacePt->y() );
1053 newTable->
move( pasteShiftPos.x(), pasteShiftPos.y() );
1056 lastPastedItem = newTable;
1059 newTable->setZValue( newTable->zValue() + zOrderOffset );
1060 if ( addUndoCommands )
1067 QDomNodeList composerHtmlList = elem.elementsByTagName(
"ComposerHtml" );
1068 for (
int i = 0; i < composerHtmlList.size(); ++i )
1070 QDomElement currentHtmlElem = composerHtmlList.at( i ).toElement();
1072 newHtml->
readXML( currentHtmlElem, doc );
1088 QDomNodeList groupList = elem.elementsByTagName(
"ComposerItemGroup" );
1089 for (
int i = 0; i < groupList.size(); ++i )
1091 QDomElement groupElem = groupList.at( i ).toElement();
1093 newGroup->
readXML( groupElem, doc );
1094 addItem( newGroup );
1102 if ( lastPastedItem )
1107 delete pasteInPlacePt;
1134 QList<QgsComposerItem*>::iterator it = selectedItems.begin();
1135 for ( ; it != selectedItems.end(); ++it )
1148 QMutableLinkedListIterator<QgsComposerItem*> it(
mItemZList );
1149 if ( it.findNext( item ) )
1163 QLinkedListIterator<QgsComposerItem*> it(
mItemZList );
1164 if ( it.findNext( item ) )
1178 QLinkedListIterator<QgsComposerItem*> it(
mItemZList );
1179 if ( it.findNext( item ) )
1184 if ( it.hasPrevious() )
1186 return it.previous();
1196 if ( selectedItems.size() > 0 )
1198 previousSelectedItem = selectedItems.at( 0 );
1201 if ( !previousSelectedItem )
1208 switch ( direction )
1218 if ( !selectedItem )
1232 QList<QgsComposerItem*>::iterator it = selectedItems.begin();
1233 for ( ; it != selectedItems.end(); ++it )
1246 QMutableLinkedListIterator<QgsComposerItem*> it(
mItemZList );
1247 if ( it.findNext( item ) )
1250 if ( it.hasPrevious() )
1262 QList<QgsComposerItem*>::iterator it = selectedItems.begin();
1264 for ( ; it != selectedItems.end(); ++it )
1277 QMutableLinkedListIterator<QgsComposerItem*> it(
mItemZList );
1278 if ( it.findNext( item ) )
1288 QList<QgsComposerItem*>::iterator it = selectedItems.begin();
1289 for ( ; it != selectedItems.end(); ++it )
1302 QMutableLinkedListIterator<QgsComposerItem*> it(
mItemZList );
1303 if ( it.findNext( item ) )
1313 if ( selectedItems.size() < 2 )
1318 QRectF selectedItemBBox;
1324 double minXCoordinate = selectedItemBBox.left();
1327 QUndoCommand* parentCommand =
new QUndoCommand(
tr(
"Aligned items left" ) );
1328 QList<QgsComposerItem*>::iterator align_it = selectedItems.begin();
1329 for ( ; align_it != selectedItems.end(); ++align_it )
1333 ( *align_it )->setPos( minXCoordinate, ( *align_it )->pos().y() );
1342 if ( selectedItems.size() < 2 )
1347 QRectF selectedItemBBox;
1353 double averageXCoord = ( selectedItemBBox.left() + selectedItemBBox.right() ) / 2.0;
1356 QUndoCommand* parentCommand =
new QUndoCommand(
tr(
"Aligned items horizontal center" ) );
1357 QList<QgsComposerItem*>::iterator align_it = selectedItems.begin();
1358 for ( ; align_it != selectedItems.end(); ++align_it )
1362 ( *align_it )->setPos( averageXCoord - ( *align_it )->rect().width() / 2.0, ( *align_it )->pos().y() );
1371 if ( selectedItems.size() < 2 )
1376 QRectF selectedItemBBox;
1382 double maxXCoordinate = selectedItemBBox.right();
1385 QUndoCommand* parentCommand =
new QUndoCommand(
tr(
"Aligned items right" ) );
1386 QList<QgsComposerItem*>::iterator align_it = selectedItems.begin();
1387 for ( ; align_it != selectedItems.end(); ++align_it )
1391 ( *align_it )->setPos( maxXCoordinate - ( *align_it )->rect().width(), ( *align_it )->pos().y() );
1400 if ( selectedItems.size() < 2 )
1405 QRectF selectedItemBBox;
1411 double minYCoordinate = selectedItemBBox.top();
1413 QUndoCommand* parentCommand =
new QUndoCommand(
tr(
"Aligned items top" ) );
1414 QList<QgsComposerItem*>::iterator align_it = selectedItems.begin();
1415 for ( ; align_it != selectedItems.end(); ++align_it )
1419 ( *align_it )->setPos(( *align_it )->pos().x(), minYCoordinate );
1428 if ( selectedItems.size() < 2 )
1433 QRectF selectedItemBBox;
1439 double averageYCoord = ( selectedItemBBox.top() + selectedItemBBox.bottom() ) / 2.0;
1440 QUndoCommand* parentCommand =
new QUndoCommand(
tr(
"Aligned items vertical center" ) );
1441 QList<QgsComposerItem*>::iterator align_it = selectedItems.begin();
1442 for ( ; align_it != selectedItems.end(); ++align_it )
1446 ( *align_it )->setPos(( *align_it )->pos().x(), averageYCoord - ( *align_it )->rect().height() / 2 );
1455 if ( selectedItems.size() < 2 )
1460 QRectF selectedItemBBox;
1466 double maxYCoord = selectedItemBBox.bottom();
1467 QUndoCommand* parentCommand =
new QUndoCommand(
tr(
"Aligned items bottom" ) );
1468 QList<QgsComposerItem*>::iterator align_it = selectedItems.begin();
1469 for ( ; align_it != selectedItems.end(); ++align_it )
1473 ( *align_it )->setPos(( *align_it )->pos().x(), maxYCoord - ( *align_it )->rect().height() );
1481 QUndoCommand* parentCommand =
new QUndoCommand(
tr(
"Items locked" ) );
1483 QList<QgsComposerItem*>::iterator itemIter = selectionList.begin();
1484 for ( ; itemIter != selectionList.end(); ++itemIter )
1488 ( *itemIter )->setPositionLock(
true );
1500 QUndoCommand* parentCommand =
new QUndoCommand(
tr(
"Items unlocked" ) );
1505 QList<QGraphicsItem *> itemList = items();
1506 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
1507 for ( ; itemIt != itemList.end(); ++itemIt )
1527 QLinkedList<QgsComposerItem*>::iterator it =
mItemZList.begin();
1530 QUndoCommand* parentCommand = 0;
1531 if ( addUndoCommands )
1533 parentCommand =
new QUndoCommand(
tr(
"Item z-order changed" ) );
1541 if ( addUndoCommands )
1546 currentItem->setZValue( counter );
1547 if ( addUndoCommands )
1554 if ( addUndoCommands )
1567 QLinkedList<QgsComposerItem*>::const_iterator lIt =
mItemZList.constBegin();
1568 QLinkedList<QgsComposerItem*> sortedList;
1570 for ( ; lIt !=
mItemZList.constEnd(); ++lIt )
1572 QLinkedList<QgsComposerItem*>::iterator insertIt = sortedList.begin();
1573 for ( ; insertIt != sortedList.end(); ++insertIt )
1575 if (( *lIt )->zValue() < ( *insertIt )->zValue() )
1580 sortedList.insert( insertIt, ( *lIt ) );
1588 QLinkedList<QgsComposerItem*> sortedList;
1593 QList<QGraphicsItem*> itemList = items();
1594 QList<QGraphicsItem*>::iterator itemIt = itemList.begin();
1595 for ( ; itemIt != itemList.end(); ++itemIt )
1603 sortedList.prepend( composerItem );
1625 double yPage = scenePoint.y() - yOffset;
1637 xSnapped = scenePoint.x();
1642 ySnapped = scenePoint.y();
1645 return QPointF( xSnapped, ySnapped );
1650 QGraphicsLineItem* item =
new QGraphicsLineItem();
1651 QPen linePen( Qt::SolidLine );
1652 linePen.setColor( Qt::red );
1655 linePen.setWidthF( 0 );
1656 item->setPen( linePen );
1657 item->setZValue( 100 );
1673 QList< QGraphicsLineItem* >::iterator it =
mSnapLines.begin();
1676 removeItem(( *it ) );
1685 QList< QGraphicsLineItem* >::iterator it =
mSnapLines.begin();
1700 QList< QPair< QgsComposerItem*, QgsComposerItem::ItemPositionMode> >& snappedItems )
1702 double minSqrDist = DBL_MAX;
1703 QGraphicsLineItem* item = 0;
1704 double currentXCoord = 0;
1705 double currentYCoord = 0;
1706 double currentSqrDist = 0;
1707 double sqrTolerance = tolerance * tolerance;
1709 snappedItems.clear();
1711 QList< QGraphicsLineItem* >::const_iterator it =
mSnapLines.constBegin();
1714 bool itemHorizontal =
qgsDoubleNear(( *it )->line().y2() - ( *it )->line().y1(), 0 );
1715 if ( horizontal && itemHorizontal )
1717 currentYCoord = ( *it )->line().y1();
1718 currentSqrDist = ( y - currentYCoord ) * ( y - currentYCoord );
1720 else if ( !horizontal && !itemHorizontal )
1722 currentXCoord = ( *it )->line().x1();
1723 currentSqrDist = ( x - currentXCoord ) * ( x - currentXCoord );
1730 if ( currentSqrDist < minSqrDist && currentSqrDist < sqrTolerance )
1733 minSqrDist = currentSqrDist;
1737 double itemTolerance = 0.0000001;
1741 QList<QGraphicsItem *> itemList = items();
1742 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
1743 for ( ; itemIt != itemList.end(); ++itemIt )
1753 if (
qgsDoubleNear( currentYCoord, currentItem->pos().y() + currentItem->rect().top(), itemTolerance ) )
1757 else if (
qgsDoubleNear( currentYCoord, currentItem->pos().y() + currentItem->rect().center().y(), itemTolerance ) )
1761 else if (
qgsDoubleNear( currentYCoord, currentItem->pos().y() + currentItem->rect().bottom(), itemTolerance ) )
1768 if (
qgsDoubleNear( currentXCoord, currentItem->pos().x(), itemTolerance ) )
1772 else if (
qgsDoubleNear( currentXCoord, currentItem->pos().x() + currentItem->rect().center().x(), itemTolerance ) )
1776 else if (
qgsDoubleNear( currentXCoord, currentItem->pos().x() + currentItem->rect().width(), itemTolerance ) )
1790 if ( selectedItems.size() < 1 )
1797 double minX = currentItem->pos().x();
1798 double minY = currentItem->pos().y();
1799 double maxX = minX + currentItem->rect().width();
1800 double maxY = minY + currentItem->rect().height();
1802 double currentMinX, currentMinY, currentMaxX, currentMaxY;
1804 for (
int i = 1; i < selectedItems.size(); ++i )
1806 currentItem = selectedItems.at( i );
1807 currentMinX = currentItem->pos().x();
1808 currentMinY = currentItem->pos().y();
1809 currentMaxX = currentMinX + currentItem->rect().width();
1810 currentMaxY = currentMinY + currentItem->rect().height();
1812 if ( currentMinX < minX )
1814 if ( currentMaxX > maxX )
1816 if ( currentMinY < minY )
1818 if ( currentMaxY > maxY )
1822 bRect.setTopLeft( QPointF( minX, minY ) );
1823 bRect.setBottomRight( QPointF( maxX, maxY ) );
1889 QString gridStyleString;
1890 gridStyleString = s.value(
"/Composer/gridStyle",
"Dots" ).toString();
1892 int gridRed, gridGreen, gridBlue, gridAlpha;
1893 gridRed = s.value(
"/Composer/gridRed", 190 ).toInt();
1894 gridGreen = s.value(
"/Composer/gridGreen", 190 ).toInt();
1895 gridBlue = s.value(
"/Composer/gridBlue", 190 ).toInt();
1896 gridAlpha = s.value(
"/Composer/gridAlpha", 100 ).toInt();
1897 QColor gridColor = QColor( gridRed, gridGreen, gridBlue, gridAlpha );
1902 if ( gridStyleString ==
"Dots" )
1906 else if ( gridStyleString ==
"Crosses" )
2004 connect( arrow, SIGNAL( sizeChanged() ),
this, SLOT(
updateBounds() ) );
2014 connect( label, SIGNAL( sizeChanged() ),
this, SLOT(
updateBounds() ) );
2022 if ( setDefaultPreviewStyle )
2034 connect( map, SIGNAL( sizeChanged() ),
this, SLOT(
updateBounds() ) );
2041 addItem( scaleBar );
2044 connect( scaleBar, SIGNAL( sizeChanged() ),
this, SLOT(
updateBounds() ) );
2054 connect( legend, SIGNAL( sizeChanged() ),
this, SLOT(
updateBounds() ) );
2064 connect( picture, SIGNAL( sizeChanged() ),
this, SLOT(
updateBounds() ) );
2074 connect( shape, SIGNAL( sizeChanged() ),
this, SLOT(
updateBounds() ) );
2084 connect( table, SIGNAL( sizeChanged() ),
this, SLOT(
updateBounds() ) );
2094 connect( frame, SIGNAL( sizeChanged() ),
this, SLOT(
updateBounds() ) );
2110 QUndoCommand* parentCommand =
new QUndoCommand(
tr(
"Remove item group" ) );
2112 QSet<QgsComposerItem*> groupedItems = itemGroup->
items();
2113 QSet<QgsComposerItem*>::iterator it = groupedItems.begin();
2114 for ( ; it != groupedItems.end(); ++it )
2129 if ( createCommand )
2150 if ( frameItem && multiFrame )
2155 if ( createCommand )
2158 multiFrame,
this,
tr(
"Multiframe removed" ) );
2269 QList< QgsPaperItem* >::iterator paperIt =
mPages.begin();
2270 for ( ; paperIt !=
mPages.end(); ++paperIt )
2272 ( *paperIt )->update();
2282 paperItem->setBrush( Qt::white );
2283 addItem( paperItem );
2284 paperItem->setZValue( 0 );
2285 mPages.push_back( paperItem );
2292 for (
int i = 0; i <
mPages.size(); ++i )
2302 QSet<QgsComposerMultiFrame*>::iterator multiFrameIt =
mMultiFrames.begin();
2303 for ( ; multiFrameIt !=
mMultiFrames.end(); ++multiFrameIt )
2305 delete *multiFrameIt;
2312 printer.setOutputFormat( QPrinter::PdfFormat );
2313 printer.setOutputFileName( file );
2329 int fromPage = ( printer.fromPage() < 1 ) ? 0 : printer.fromPage() - 1 ;
2330 int toPage = ( printer.toPage() < 1 ) ?
numPages() - 1 : printer.toPage() - 1;
2334 for (
int i = fromPage; i <= toPage; ++i )
2342 if ( !image.isNull() )
2344 QRectF targetArea( 0, 0, image.width(), image.height() );
2345 p.drawImage( targetArea, image, targetArea );
2352 for (
int i = fromPage; i <= toPage; ++i )
2366 printer.setFullPage(
true );
2367 printer.setColorMode( QPrinter::Color );
2376 QPainter p( &printer );
2385 QImage image( QSize( width, height ), QImage::Format_ARGB32 );
2386 if ( !image.isNull() )
2391 QPainter imagePainter( &image );
2393 if ( !imagePainter.isActive() )
return QImage();
2400 if (
mPages.size() <= page )
2411 QPaintDevice* paintDevice = p->device();
2417 QRectF paperRect = QRectF( paperItem->pos().x(), paperItem->pos().y(), paperItem->rect().width(), paperItem->rect().height() );
2424 setBackgroundBrush( Qt::NoBrush );
2425 render( p, QRectF( 0, 0, paintDevice->width(), paintDevice->height() ), paperRect );
2427 setBackgroundBrush( QColor( 215, 215, 215 ) );
2435 QString modifiedStr( str );
2436 modifiedStr.replace(
"&",
"&" );
2437 modifiedStr.replace(
"\"",
""" );
2438 modifiedStr.replace(
"'",
"'" );
2439 modifiedStr.replace(
"<",
"<" );
2440 modifiedStr.replace(
">",
">" );
2459 double xr = extent.
width() / brect.width();
2460 double yr = extent.
height() / brect.height();
2462 double XC = extent.
center().
x();
2463 double YC = extent.
center().
y();
2470 double X0 = paperExtent.
xMinimum();
2471 double Y0 = paperExtent.
yMinimum();
2476 double Ww = paperExtent.
width() / widthPx;
2477 double Hh = paperExtent.
height() / heightPx;
2486 s[5] = Y0 + paperExtent.
height();
2490 r[0] = cos( alpha );
2491 r[1] = -sin( alpha );
2492 r[2] = XC * ( 1 - cos( alpha ) ) + YC * sin( alpha );
2493 r[3] = sin( alpha );
2494 r[4] = cos( alpha );
2495 r[5] = - XC * sin( alpha ) + YC * ( 1 - cos( alpha ) );
2498 a = r[0] * s[0] + r[1] * s[3];
2499 b = r[0] * s[1] + r[1] * s[4];
2500 c = r[0] * s[2] + r[1] * s[5] + r[2];
2501 d = r[3] * s[0] + r[4] * s[3];
2502 e = r[3] * s[1] + r[4] * s[4];
2503 f = r[3] * s[2] + r[4] * s[5] + r[5];
2517 if ( ! atlasHasFeatures )
2524 QList<QgsComposerMap*> maps;
2526 for ( QList<QgsComposerMap*>::iterator mit = maps.begin(); mit != maps.end(); ++mit )
2543 double left =
relativePosition( rectToResize.left(), boundsBefore.left(), boundsBefore.right(), boundsAfter.left(), boundsAfter.right() );
2544 double right =
relativePosition( rectToResize.right(), boundsBefore.left(), boundsBefore.right(), boundsAfter.left(), boundsAfter.right() );
2545 double top =
relativePosition( rectToResize.top(), boundsBefore.top(), boundsBefore.bottom(), boundsAfter.top(), boundsAfter.bottom() );
2546 double bottom =
relativePosition( rectToResize.bottom(), boundsBefore.top(), boundsBefore.bottom(), boundsAfter.top(), boundsAfter.bottom() );
2548 rectToResize.setRect( left, top, right - left, bottom - top );
2554 double m = ( afterMax - afterMin ) / ( beforeMax - beforeMin );
2555 double c = afterMin - ( beforeMin * m );
2558 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)
sets state from Dom document
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 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 setItemPosition(double x, double y, ItemPositionMode itemPoint=UpperLeft)
Moves the item to a new position (in canvas coordinates)
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.
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.
bool beginRender()
Begins the rendering.
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)
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.
Graphics scene for map printing.
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 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)
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.
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 print(QPrinter &printer)
Convenience function that prepares the printer and prints.
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.
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
bool atlasDriven() const
Returns true if 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 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)
void exportAsPDF(const QString &file)
Convenience function that prepares the printer for printing in PDF and prints.
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)
QString id() const
Get item's id (which is not necessarly unique)