37 #include <QGraphicsScene>
38 #include <QGraphicsView>
44 :
QgsComposerItem( x, y, width, height, composition ), mMapRotation( 0 ), mKeepLayerSet( false ),
45 mOverviewFrameMapId( -1 ), mOverviewBlendMode( QPainter::CompositionMode_SourceOver ), mOverviewInverted( false ), mOverviewCentered( false ),
46 mGridEnabled( false ), mGridStyle( Solid ),
47 mGridIntervalX( 0.0 ), mGridIntervalY( 0.0 ), mGridOffsetX( 0.0 ), mGridOffsetY( 0.0 ), mGridAnnotationFontColor( QColor( 0, 0, 0 ) ),
48 mGridAnnotationPrecision( 3 ), mShowGridAnnotation( false ), mGridBlendMode( QPainter::CompositionMode_SourceOver ),
49 mLeftGridAnnotationPosition( OutsideMapFrame ), mRightGridAnnotationPosition( OutsideMapFrame ),
50 mTopGridAnnotationPosition( OutsideMapFrame ), mBottomGridAnnotationPosition( OutsideMapFrame ), mAnnotationFrameDistance( 1.0 ),
51 mLeftGridAnnotationDirection( Horizontal ), mRightGridAnnotationDirection( Horizontal ), mTopGridAnnotationDirection( Horizontal ),
52 mBottomGridAnnotationDirection( Horizontal ), mGridFrameStyle( NoGridFrame ), mGridFrameWidth( 2.0 ),
53 mGridFramePenThickness( 0.5 ), mGridFramePenColor( QColor( 0, 0, 0 ) ), mGridFrameFillColor1( Qt::white ), mGridFrameFillColor2( Qt::black ),
54 mCrossLength( 3 ), mMapCanvas( 0 ), mDrawCanvasItems( true ), mAtlasDriven( false ), mAtlasFixedScale( false ), mAtlasMargin( 0.10 )
79 QString defaultFontString = settings.value(
"/Composer/defaultFont" ).toString();
80 if ( !defaultFontString.isEmpty() )
99 setToolTip(
tr(
"Map %1" ).arg(
mId ) );
105 :
QgsComposerItem( 0, 0, 10, 10, composition ), mMapRotation( 0 ), mKeepLayerSet( false ), mOverviewFrameMapId( -1 ),
106 mOverviewBlendMode( QPainter::CompositionMode_SourceOver ), mOverviewInverted( false ), mOverviewCentered( false ),
107 mGridEnabled( false ), mGridStyle( Solid ),
108 mGridIntervalX( 0.0 ), mGridIntervalY( 0.0 ), mGridOffsetX( 0.0 ), mGridOffsetY( 0.0 ), mGridAnnotationFontColor( QColor( 0, 0, 0 ) ),
109 mGridAnnotationPrecision( 3 ), mShowGridAnnotation( false ), mGridBlendMode( QPainter::CompositionMode_SourceOver ),
110 mLeftGridAnnotationPosition( OutsideMapFrame ), mRightGridAnnotationPosition( OutsideMapFrame ),
111 mTopGridAnnotationPosition( OutsideMapFrame ), mBottomGridAnnotationPosition( OutsideMapFrame ), mAnnotationFrameDistance( 1.0 ),
112 mLeftGridAnnotationDirection( Horizontal ), mRightGridAnnotationDirection( Horizontal ), mTopGridAnnotationDirection( Horizontal ),
113 mBottomGridAnnotationDirection( Horizontal ), mGridFrameStyle( NoGridFrame ), mGridFrameWidth( 2.0 ), mGridFramePenThickness( 0.5 ),
114 mGridFramePenColor( QColor( 0, 0, 0 ) ), mGridFrameFillColor1( Qt::white ), mGridFrameFillColor2( Qt::black ),
115 mCrossLength( 3 ), mMapCanvas( 0 ), mDrawCanvasItems( true ), mAtlasDriven( false ), mAtlasFixedScale( false ), mAtlasMargin( 0.10 )
133 setToolTip(
tr(
"Map %1" ).arg(
mId ) );
140 double itemWidthHeightRatio = itemWidth / itemHeight;
141 double newWidthHeightRatio = extent.
width() / extent.
height();
143 if ( itemWidthHeightRatio <= newWidthHeightRatio )
146 double newHeight = extent.
width() / itemWidthHeightRatio;
147 double deltaHeight = newHeight - extent.
height();
154 double newWidth = itemWidthHeightRatio * extent.
height();
155 double deltaWidth = newWidth - extent.
width();
196 if ( settings.value(
"/qgis/enable_anti_aliasing",
true ).toBool() )
198 painter->setRenderHint( QPainter::Antialiasing );
202 if ( theRendererContext )
222 double bk_scale = theMapRenderer.
scale();
227 bool bkLayerCaching = s.value(
"/qgis/enable_render_caching",
false ).toBool();
228 s.setValue(
"/qgis/enable_render_caching",
false );
233 if ( forceWidthScale )
235 theMapRenderer.
render( painter, forceWidthScale );
239 theMapRenderer.
render( painter );
241 s.setValue(
"/qgis/enable_render_caching", bkLayerCaching );
243 theMapRenderer.
setScale( bk_scale );
265 if ( horizontalVScaleFactor < 0 )
286 mCacheImage = QImage( w, h, QImage::Format_ARGB32 );
297 mCacheImage.fill( QColor( 255, 255, 255, 0 ).rgba() );
307 draw( &p, requestExtent, QSizeF( w, h ),
mCacheImage.logicalDpiX(), &forcedWidthScaleFactor );
323 QRectF thisPaintRect = QRectF( 0, 0, QGraphicsRectItem::rect().width(), QGraphicsRectItem::rect().height() );
325 painter->setClipRect( thisPaintRect );
331 QFont messageFont(
"", 12 );
332 painter->setFont( messageFont );
333 painter->setPen( QColor( 0, 0, 0, 125 ) );
334 painter->drawText( thisPaintRect,
tr(
"Map will be printed here" ) );
351 double scale = rect().width() / imagePixelWidth;
365 painter->translate( xTopLeftShift, yTopLeftShift );
367 painter->translate( xShiftMM, -yShiftMM );
368 painter->scale( scale, scale );
386 QPaintDevice* thePaintDevice = painter->device();
387 if ( !thePaintDevice )
413 painter->translate( xTopLeftShift, yTopLeftShift );
415 painter->translate( xShiftMM, -yShiftMM );
416 draw( painter, requestRectangle, theSize, 25.4 );
427 painter->setClipRect( thisPaintRect , Qt::NoClip );
451 QGraphicsRectItem::update();
470 QStringList renderLayerSet;
488 if ( removeAt != -1 )
490 renderLayerSet.removeAt( removeAt );
495 return renderLayerSet;
502 calculator.
setDpi( 25.4 );
509 QRectF currentRect = rect();
510 QRectF newSceneRect = QRectF( pos().x(), pos().y(), currentRect.width() + dx, currentRect.height() + dy );
542 int zoomMode = settings.value(
"/qgis/wheel_action", 2 ).toInt();
548 double zoomFactor = settings.value(
"/qgis/zoom_factor", 2.0 ).toDouble();
564 else if ( zoomMode == 2 )
566 centerX = mapMouseX + ( centerX - mapMouseX ) * ( 1.0 / zoomFactor );
567 centerY = mapMouseY + ( centerY - mapMouseY ) * ( 1.0 / zoomFactor );
571 double newIntervalX, newIntervalY;
578 else if ( delta < 0 )
601 double w = rectangle.width();
602 double h = rectangle.height();
627 QRectF currentRect = rect();
629 double newHeight = currentRect.width() * extent.
height() / extent.
width();
631 setSceneRect( QRectF( pos().x(), pos().y(), currentRect.width(), newHeight ) );
646 double currentWidthHeightRatio = rect().
width() / rect().height();
647 double newWidthHeightRatio = newExtent.
width() / newExtent.
height();
649 if ( currentWidthHeightRatio < newWidthHeightRatio )
652 double newHeight = newExtent.
width() / currentWidthHeightRatio;
653 double deltaHeight = newHeight - newExtent.
height();
657 else if ( currentWidthHeightRatio >= newWidthHeightRatio )
660 double newWidth = currentWidthHeightRatio * newExtent.
height();
661 double deltaWidth = newWidth - newExtent.
width();
716 double currentScaleDenominator =
scale();
718 if ( scaleDenominator == currentScaleDenominator )
723 double scaleRatio = scaleDenominator / currentScaleDenominator;
776 QStringList::const_iterator layer_it = layers.constBegin();
779 for ( ; layer_it != layers.constEnd(); ++layer_it )
785 if ( currentRasterLayer )
788 if (( rasterProvider = currentRasterLayer->
dataProvider() ) )
790 if ( rasterProvider->
name() ==
"wms" )
814 QStringList::const_iterator layer_it = layers.constBegin();
817 for ( ; layer_it != layers.constEnd(); ++layer_it )
822 if ( currentLayer->
blendMode() != QPainter::CompositionMode_SourceOver )
828 if ( currentVectorLayer )
834 if ( currentVectorLayer->
featureBlendMode() != QPainter::CompositionMode_SourceOver )
843 if (( layerSettings.
blendMode != QPainter::CompositionMode_SourceOver ) ||
864 connect( layerRegistry, SIGNAL( layerWillBeRemoved( QString ) ),
this, SLOT(
updateCachedImage() ) );
876 QDomElement composerMapElem = doc.createElement(
"ComposerMap" );
877 composerMapElem.setAttribute(
"id",
mId );
882 composerMapElem.setAttribute(
"previewMode",
"Cache" );
886 composerMapElem.setAttribute(
"previewMode",
"Render" );
890 composerMapElem.setAttribute(
"previewMode",
"Rectangle" );
895 composerMapElem.setAttribute(
"keepLayerSet",
"true" );
899 composerMapElem.setAttribute(
"keepLayerSet",
"false" );
904 composerMapElem.setAttribute(
"drawCanvasItems",
"true" );
908 composerMapElem.setAttribute(
"drawCanvasItems",
"false" );
912 QDomElement overviewFrameElem = doc.createElement(
"overviewFrame" );
917 overviewFrameElem.setAttribute(
"overviewInverted",
"true" );
921 overviewFrameElem.setAttribute(
"overviewInverted",
"false" );
924 overviewFrameElem.setAttribute(
"overviewCentered",
mOverviewCentered ?
"true" :
"false" );
927 overviewFrameElem.appendChild( overviewFrameStyleElem );
928 composerMapElem.appendChild( overviewFrameElem );
932 QDomElement extentElem = doc.createElement(
"Extent" );
937 composerMapElem.appendChild( extentElem );
940 composerMapElem.setAttribute(
"mapRotation", QString::number(
mMapRotation ) );
943 QDomElement layerSetElem = doc.createElement(
"LayerSet" );
944 QStringList::const_iterator layerIt =
mLayerSet.constBegin();
945 for ( ; layerIt !=
mLayerSet.constEnd(); ++layerIt )
947 QDomElement layerElem = doc.createElement(
"Layer" );
948 QDomText layerIdText = doc.createTextNode( *layerIt );
949 layerElem.appendChild( layerIdText );
950 layerSetElem.appendChild( layerElem );
952 composerMapElem.appendChild( layerSetElem );
958 QDomElement gridElem = doc.createElement(
"Grid" );
960 gridElem.setAttribute(
"gridStyle",
mGridStyle );
970 QDomElement framePenColorElem = doc.createElement(
"framePenColor" );
975 gridElem.appendChild( framePenColorElem );
977 QDomElement frameFillColor1Elem = doc.createElement(
"frameFillColor1" );
982 gridElem.appendChild( frameFillColor1Elem );
983 QDomElement frameFillColor2Elem = doc.createElement(
"frameFillColor2" );
988 gridElem.appendChild( frameFillColor2Elem );
992 gridElem.appendChild( gridLineStyleElem );
995 QDomElement annotationElem = doc.createElement(
"Annotation" );
1010 QDomElement annotationFontColorElem = doc.createElement(
"fontColor" );
1015 annotationElem.appendChild( annotationFontColorElem );
1017 gridElem.appendChild( annotationElem );
1018 composerMapElem.appendChild( gridElem );
1021 QDomElement atlasElem = doc.createElement(
"AtlasMap" );
1025 composerMapElem.appendChild( atlasElem );
1027 elem.appendChild( composerMapElem );
1028 return _writeXML( composerMapElem, doc );
1033 if ( itemElem.isNull() )
1038 QString idRead = itemElem.attribute(
"id",
"not found" );
1039 if ( idRead !=
"not found" )
1041 mId = idRead.toInt();
1046 QString
previewMode = itemElem.attribute(
"previewMode" );
1047 if ( previewMode ==
"Cache" )
1051 else if ( previewMode ==
"Render" )
1060 QDomElement overviewFrameElem = itemElem.firstChildElement(
"overviewFrame" );
1061 if ( !overviewFrameElem.isNull() )
1066 QString overviewInvertedFlag = overviewFrameElem.attribute(
"overviewInverted" );
1067 if ( overviewInvertedFlag.compare(
"true", Qt::CaseInsensitive ) == 0 )
1076 if ( overviewFrameElem.attribute(
"overviewCentered" ).compare(
"true", Qt::CaseInsensitive ) == 0 )
1085 QDomElement overviewFrameSymbolElem = overviewFrameElem.firstChildElement(
"symbol" );
1086 if ( !overviewFrameSymbolElem.isNull() )
1094 QDomNodeList extentNodeList = itemElem.elementsByTagName(
"Extent" );
1095 if ( extentNodeList.size() > 0 )
1097 QDomElement extentElem = extentNodeList.at( 0 ).toElement();
1098 double xmin, xmax, ymin, ymax;
1099 xmin = extentElem.attribute(
"xmin" ).toDouble();
1100 xmax = extentElem.attribute(
"xmax" ).toDouble();
1101 ymin = extentElem.attribute(
"ymin" ).toDouble();
1102 ymax = extentElem.attribute(
"ymax" ).toDouble();
1108 if ( itemElem.attribute(
"mapRotation",
"0" ).toDouble() != 0 )
1110 mMapRotation = itemElem.attribute(
"mapRotation",
"0" ).toDouble();
1114 QString keepLayerSetFlag = itemElem.attribute(
"keepLayerSet" );
1115 if ( keepLayerSetFlag.compare(
"true", Qt::CaseInsensitive ) == 0 )
1124 QString drawCanvasItemsFlag = itemElem.attribute(
"drawCanvasItems" );
1125 if ( drawCanvasItemsFlag.compare(
"true", Qt::CaseInsensitive ) == 0 )
1135 QDomNodeList layerSetNodeList = itemElem.elementsByTagName(
"LayerSet" );
1137 if ( layerSetNodeList.size() > 0 )
1139 QDomElement layerSetElem = layerSetNodeList.at( 0 ).toElement();
1140 QDomNodeList layerIdNodeList = layerSetElem.elementsByTagName(
"Layer" );
1141 for (
int i = 0; i < layerIdNodeList.size(); ++i )
1143 layerSet << layerIdNodeList.at( i ).toElement().text();
1153 QDomNodeList gridNodeList = itemElem.elementsByTagName(
"Grid" );
1154 if ( gridNodeList.size() > 0 )
1156 QDomElement gridElem = gridNodeList.at( 0 ).toElement();
1157 mGridEnabled = ( gridElem.attribute(
"show",
"0" ) !=
"0" );
1159 mGridIntervalX = gridElem.attribute(
"intervalX",
"0" ).toDouble();
1160 mGridIntervalY = gridElem.attribute(
"intervalY",
"0" ).toDouble();
1161 mGridOffsetX = gridElem.attribute(
"offsetX",
"0" ).toDouble();
1162 mGridOffsetY = gridElem.attribute(
"offsetY",
"0" ).toDouble();
1163 mCrossLength = gridElem.attribute(
"crossLength",
"3" ).toDouble();
1165 mGridFrameWidth = gridElem.attribute(
"gridFrameWidth",
"2.0" ).toDouble();
1169 QDomNodeList gridFramePenColorList = gridElem.elementsByTagName(
"framePenColor" );
1170 if ( gridFramePenColorList.size() > 0 )
1172 QDomElement penColorElem = gridFramePenColorList.at( 0 ).toElement();
1173 int red = penColorElem.attribute(
"red",
"0" ).toInt();
1174 int green = penColorElem.attribute(
"green",
"0" ).toInt();
1175 int blue = penColorElem.attribute(
"blue",
"0" ).toInt();
1176 int alpha = penColorElem.attribute(
"alpha",
"255" ).toInt();
1184 QDomNodeList gridFrameFillColor1List = gridElem.elementsByTagName(
"frameFillColor1" );
1185 if ( gridFrameFillColor1List.size() > 0 )
1187 QDomElement fillColorElem = gridFrameFillColor1List.at( 0 ).toElement();
1188 int red = fillColorElem.attribute(
"red",
"0" ).toInt();
1189 int green = fillColorElem.attribute(
"green",
"0" ).toInt();
1190 int blue = fillColorElem.attribute(
"blue",
"0" ).toInt();
1191 int alpha = fillColorElem.attribute(
"alpha",
"255" ).toInt();
1199 QDomNodeList gridFrameFillColor2List = gridElem.elementsByTagName(
"frameFillColor2" );
1200 if ( gridFrameFillColor2List.size() > 0 )
1202 QDomElement fillColorElem = gridFrameFillColor2List.at( 0 ).toElement();
1203 int red = fillColorElem.attribute(
"red",
"0" ).toInt();
1204 int green = fillColorElem.attribute(
"green",
"0" ).toInt();
1205 int blue = fillColorElem.attribute(
"blue",
"0" ).toInt();
1206 int alpha = fillColorElem.attribute(
"alpha",
"255" ).toInt();
1216 QDomElement gridSymbolElem = gridElem.firstChildElement(
"symbol" );
1218 if ( gridSymbolElem.isNull( ) )
1224 gridElem.attribute(
"penColorGreen",
"0" ).toInt(),
1225 gridElem.attribute(
"penColorBlue",
"0" ).toInt() ) );
1232 QDomNodeList annotationNodeList = gridElem.elementsByTagName(
"Annotation" );
1233 if ( annotationNodeList.size() > 0 )
1235 QDomElement annotationElem = annotationNodeList.at( 0 ).toElement();
1250 QDomNodeList annotationFontColorList = annotationElem.elementsByTagName(
"fontColor" );
1251 if ( annotationFontColorList.size() > 0 )
1253 QDomElement fontColorElem = annotationFontColorList.at( 0 ).toElement();
1254 int red = fontColorElem.attribute(
"red",
"0" ).toInt();
1255 int green = fontColorElem.attribute(
"green",
"0" ).toInt();
1256 int blue = fontColorElem.attribute(
"blue",
"0" ).toInt();
1257 int alpha = fontColorElem.attribute(
"alpha",
"255" ).toInt();
1270 QDomNodeList atlasNodeList = itemElem.elementsByTagName(
"AtlasMap" );
1271 if ( atlasNodeList.size() > 0 )
1273 QDomElement atlasElem = atlasNodeList.at( 0 ).toElement();
1274 mAtlasDriven = ( atlasElem.attribute(
"atlasDriven",
"0" ) !=
"0" );
1276 mAtlasMargin = atlasElem.attribute(
"margin",
"0.1" ).toDouble();
1280 QDomNodeList composerItemList = itemElem.elementsByTagName(
"ComposerItem" );
1281 if ( composerItemList.size() > 0 )
1283 QDomElement composerItemElem = composerItemList.at( 0 ).toElement();
1285 if ( composerItemElem.attribute(
"rotation",
"0" ).toDouble() != 0 )
1288 mMapRotation = composerItemElem.attribute(
"rotation",
"0" ).toDouble();
1315 QStringList currentLayerSet;
1325 for (
int i =
mLayerSet.size() - 1; i >= 0; --i )
1327 if ( !currentLayerSet.contains(
mLayerSet.at( i ) ) )
1336 QList< QPair< double, QLineF > > verticalLines;
1338 QList< QPair< double, QLineF > >::const_iterator vIt = verticalLines.constBegin();
1339 QList< QPair< double, QLineF > > horizontalLines;
1341 QList< QPair< double, QLineF > >::const_iterator hIt = horizontalLines.constBegin();
1343 QRectF thisPaintRect = QRectF( 0, 0, QGraphicsRectItem::rect().width(), QGraphicsRectItem::rect().height() );
1344 p->setClipRect( thisPaintRect );
1353 for ( ; vIt != verticalLines.constEnd(); ++vIt )
1358 for ( ; hIt != horizontalLines.constEnd(); ++hIt )
1365 QPointF intersectionPoint, crossEnd1, crossEnd2;
1366 for ( ; vIt != verticalLines.constEnd(); ++vIt )
1370 drawGridLine( QLineF( vIt->second.p1(), crossEnd1 ), p );
1373 hIt = horizontalLines.constBegin();
1374 for ( ; hIt != horizontalLines.constEnd(); ++hIt )
1376 if ( hIt->second.intersect( vIt->second, &intersectionPoint ) == QLineF::BoundedIntersection )
1385 drawGridLine( QLineF( vIt->second.p2(), crossEnd2 ), p );
1388 hIt = horizontalLines.constBegin();
1389 for ( ; hIt != horizontalLines.constEnd(); ++hIt )
1393 drawGridLine( QLineF( hIt->second.p1(), crossEnd1 ), p );
1395 vIt = verticalLines.constBegin();
1396 for ( ; vIt != verticalLines.constEnd(); ++vIt )
1398 if ( vIt->second.intersect( hIt->second, &intersectionPoint ) == QLineF::BoundedIntersection )
1407 drawGridLine( QLineF( hIt->second.p2(), crossEnd1 ), p );
1413 p->setClipRect( thisPaintRect , Qt::NoClip );
1430 QMap< double, double > leftGridFrame;
1431 QMap< double, double > rightGridFrame;
1432 QMap< double, double > topGridFrame;
1433 QMap< double, double > bottomGridFrame;
1464 poly << line.p1() << line.p2();
1479 QMap< double, double > pos = borderPos;
1481 if ( border ==
Left || border ==
Right )
1483 pos.insert( rect().height(), rect().height() );
1488 pos.insert( rect().width(), rect().width() );
1495 framePen.setJoinStyle( Qt::MiterJoin );
1496 p->setPen( framePen );
1498 QMap< double, double >::const_iterator posIt = pos.constBegin();
1499 for ( ; posIt != pos.constEnd(); ++posIt )
1502 if ( border ==
Left || border ==
Right )
1504 height = posIt.key() - currentCoord;
1512 width = posIt.key() - currentCoord;
1516 p->drawRect( QRectF( x, y, width, height ) );
1517 currentCoord = posIt.key();
1530 QString currentAnnotationString;
1531 QList< QPair< double, QLineF > >::const_iterator it = hLines.constBegin();
1532 for ( ; it != hLines.constEnd(); ++it )
1539 it = vLines.constBegin();
1540 for ( ; it != vLines.constEnd(); ++it )
1554 double xpos = pos.x();
1555 double ypos = pos.y();
1560 if ( frameBorder ==
Left )
1568 ypos += textWidth / 2.0;
1574 ypos += textHeight / 2.0;
1582 ypos += textWidth / 2.0;
1588 ypos += textHeight / 2.0;
1597 else if ( frameBorder ==
Right )
1604 ypos += textWidth / 2.0;
1610 ypos += textHeight / 2.0;
1618 ypos += textWidth / 2.0;
1624 ypos += textHeight / 2.0;
1632 else if ( frameBorder ==
Bottom )
1639 xpos -= textWidth / 2.0;
1643 xpos += textHeight / 2.0;
1653 xpos -= textWidth / 2.0;
1657 xpos += textHeight / 2.0;
1673 xpos -= textWidth / 2.0;
1678 xpos += textHeight / 2.0;
1687 xpos -= textWidth / 2.0;
1692 xpos += textHeight / 2.0;
1703 drawAnnotation( p, QPointF( xpos, ypos ), rotation, annotationString );
1709 p->translate( pos );
1710 p->rotate( rotation );
1727 QString annotationString;
1737 QStringList split = annotationString.split(
"," );
1740 return split.at( 0 );
1744 if ( split.size() < 2 )
1748 return split.at( 1 );
1762 QRectF mapBoundingRect = mapPolygon.boundingRect();
1765 double roundCorrection = mapBoundingRect.top() > 0 ? 1.0 : 0.0;
1772 double yCanvasCoord;
1774 while ( currentLevel <= mapBoundingRect.bottom() )
1776 yCanvasCoord = rect().height() * ( 1 - ( currentLevel - mapBoundingRect.top() ) / mapBoundingRect.height() );
1777 lines.push_back( qMakePair( currentLevel, QLineF( 0, yCanvasCoord, rect().width(), yCanvasCoord ) ) );
1783 QVector<QLineF> borderLines;
1784 borderLines << QLineF( mapPolygon.at( 0 ), mapPolygon.at( 1 ) );
1785 borderLines << QLineF( mapPolygon.at( 1 ), mapPolygon.at( 2 ) );
1786 borderLines << QLineF( mapPolygon.at( 2 ), mapPolygon.at( 3 ) );
1787 borderLines << QLineF( mapPolygon.at( 3 ), mapPolygon.at( 0 ) );
1789 QList<QPointF> intersectionList;
1791 while ( currentLevel <= mapBoundingRect.bottom() )
1793 intersectionList.clear();
1794 QLineF gridLine( mapBoundingRect.left(), currentLevel, mapBoundingRect.right(), currentLevel );
1796 QVector<QLineF>::const_iterator it = borderLines.constBegin();
1797 for ( ; it != borderLines.constEnd(); ++it )
1799 QPointF intersectionPoint;
1800 if ( it->intersect( gridLine, &intersectionPoint ) == QLineF::BoundedIntersection )
1802 intersectionList.push_back( intersectionPoint );
1803 if ( intersectionList.size() >= 2 )
1810 if ( intersectionList.size() >= 2 )
1812 lines.push_back( qMakePair( currentLevel, QLineF(
mapToItemCoords( intersectionList.at( 0 ) ),
mapToItemCoords( intersectionList.at( 1 ) ) ) ) );
1830 QRectF mapBoundingRect = mapPolygon.boundingRect();
1833 double roundCorrection = mapBoundingRect.left() > 0 ? 1.0 : 0.0;
1839 double xCanvasCoord;
1841 while ( currentLevel <= mapBoundingRect.right() )
1843 xCanvasCoord = rect().width() * ( currentLevel - mapBoundingRect.left() ) / mapBoundingRect.width();
1844 lines.push_back( qMakePair( currentLevel, QLineF( xCanvasCoord, 0, xCanvasCoord, rect().height() ) ) );
1850 QVector<QLineF> borderLines;
1851 borderLines << QLineF( mapPolygon.at( 0 ), mapPolygon.at( 1 ) );
1852 borderLines << QLineF( mapPolygon.at( 1 ), mapPolygon.at( 2 ) );
1853 borderLines << QLineF( mapPolygon.at( 2 ), mapPolygon.at( 3 ) );
1854 borderLines << QLineF( mapPolygon.at( 3 ), mapPolygon.at( 0 ) );
1856 QList<QPointF> intersectionList;
1858 while ( currentLevel <= mapBoundingRect.right() )
1860 intersectionList.clear();
1861 QLineF gridLine( currentLevel, mapBoundingRect.bottom(), currentLevel, mapBoundingRect.top() );
1863 QVector<QLineF>::const_iterator it = borderLines.constBegin();
1864 for ( ; it != borderLines.constEnd(); ++it )
1866 QPointF intersectionPoint;
1867 if ( it->intersect( gridLine, &intersectionPoint ) == QLineF::BoundedIntersection )
1869 intersectionList.push_back( intersectionPoint );
1870 if ( intersectionList.size() >= 2 )
1877 if ( intersectionList.size() >= 2 )
1879 lines.push_back( qMakePair( currentLevel, QLineF(
mapToItemCoords( intersectionList.at( 0 ) ),
mapToItemCoords( intersectionList.at( 1 ) ) ) ) );
1916 p.setCapStyle( Qt::FlatCap );
1934 QRectF rectangle = rect();
1936 rectangle.setLeft( rectangle.left() - extension );
1937 rectangle.setRight( rectangle.right() + extension );
1938 rectangle.setTop( rectangle.top() - extension );
1939 rectangle.setBottom( rectangle.bottom() + extension );
1942 prepareGeometryChange();
1974 poly.translate( -dx, -dy );
1980 double frameExtension =
mFrame ? pen().widthF() / 2.0 : 0.0;
1984 return frameExtension;
1987 QList< QPair< double, QLineF > > xLines;
1988 QList< QPair< double, QLineF > > yLines;
1993 if ( xGridReturn != 0 && yGridReturn != 0 )
1995 return frameExtension;
1999 double currentExtension = 0;
2000 QString currentAnnotationString;
2002 QList< QPair< double, QLineF > >::const_iterator it = xLines.constBegin();
2003 for ( ; it != xLines.constEnd(); ++it )
2007 maxExtension = qMax( maxExtension, currentExtension );
2010 it = yLines.constBegin();
2011 for ( ; it != yLines.constEnd(); ++it )
2015 maxExtension = qMax( maxExtension, currentExtension );
2040 dx = rotationPoint.
x() - extent.
xMinimum();
2041 dy = rotationPoint.
y() - extent.
yMaximum();
2043 poly << QPointF( rotationPoint.
x() + dx, rotationPoint.
y() + dy );
2046 dx = rotationPoint.
x() - extent.
xMaximum();
2047 dy = rotationPoint.
y() - extent.
yMaximum();
2049 poly << QPointF( rotationPoint.
x() + dx, rotationPoint.
y() + dy );
2052 dx = rotationPoint.
x() - extent.
xMaximum();
2053 dy = rotationPoint.
y() - extent.
yMinimum();
2055 poly << QPointF( rotationPoint.
x() + dx, rotationPoint.
y() + dy );
2058 dx = rotationPoint.
x() - extent.
xMinimum();
2059 dy = rotationPoint.
y() - extent.
yMinimum();
2061 poly << QPointF( rotationPoint.
x() + dx, rotationPoint.
y() + dy );
2080 QRectF bRect = poly.boundingRect();
2091 if ( extentWidth <= 0 )
2095 return rect().width() / extentWidth;
2180 double dxScaled = xShift * mmToMapUnits;
2181 double dyScaled = - yShift * mmToMapUnits;
2192 if ( mapPoly.size() < 1 )
2194 return QPointF( 0, 0 );
2199 double dx = mapCoords.x() - rotationPoint.
x();
2200 double dy = mapCoords.y() - rotationPoint.
y();
2202 QgsPoint backRotatedCoords( rotationPoint.
x() + dx, rotationPoint.
y() + dy );
2205 double xItem = rect().width() * ( backRotatedCoords.x() - unrotatedExtent.xMinimum() ) / unrotatedExtent.width();
2206 double yItem = rect().height() * ( 1 - ( backRotatedCoords.y() - unrotatedExtent.yMinimum() ) / unrotatedExtent.height() );
2207 return QPointF( xItem, yItem );
2212 if ( p.x() <= pen().widthF() )
2216 else if ( p.x() >= ( rect().width() - pen().widthF() ) )
2220 else if ( p.y() <= pen().widthF() )
2237 QList<QGraphicsItem*> itemList =
mMapCanvas->items();
2238 if ( itemList.size() < 1 )
2242 QGraphicsItem* currentItem = 0;
2244 for (
int i = itemList.size() - 1; i >= 0; --i )
2246 currentItem = itemList.at( i );
2248 if ( !currentItem || currentItem->data( 0 ).toString() !=
"AnnotationItem" )
2269 double scaleFactor = 1.0 /
mMapCanvas->logicalDpiX() * 25.4;
2271 double itemX, itemY;
2272 QGraphicsItem* parent = item->parentItem();
2281 QPointF itemScenePos = item->scenePos();
2282 QPointF parentScenePos = parent->scenePos();
2286 itemX = mapPos.x() + ( itemScenePos.x() - parentScenePos.x() ) * scaleFactor;
2287 itemY = mapPos.y() + ( itemScenePos.y() - parentScenePos.y() ) * scaleFactor;
2289 painter->translate( itemX, itemY );
2292 painter->scale( scaleFactor, scaleFactor );
2295 item->setData( 1,
"composer" );
2296 item->paint( painter, itemStyle, 0 );
2297 item->setData( 1,
"" );
2305 return QPointF( 0, 0 );
2310 return QPointF( 0, 0 );
2313 QRectF graphicsSceneRect =
mMapCanvas->sceneRect();
2314 QPointF itemScenePos = item->scenePos();
2317 double mapX = itemScenePos.x() / graphicsSceneRect.
width() * mapRendererExtent.
width() + mapRendererExtent.
xMinimum();
2318 double mapY = mapRendererExtent.
yMaximum() - itemScenePos.y() / graphicsSceneRect.height() * mapRendererExtent.
height();
2410 QMap< double, double >& rightFrameEntries, QMap< double, double >& topFrameEntries, QMap< double, double >& bottomFrameEntries )
const
2412 QList< QPair< double, QPointF > > borderPositions;
2413 QList< QPair< double, QLineF > >::const_iterator it = hLines.constBegin();
2414 for ( ; it != hLines.constEnd(); ++it )
2416 borderPositions << qMakePair( it->first, it->second.p1() );
2417 borderPositions << qMakePair( it->first, it->second.p2() );
2419 it = vLines.constBegin();
2420 for ( ; it != vLines.constEnd(); ++it )
2422 borderPositions << qMakePair( it->first, it->second.p1() );
2423 borderPositions << qMakePair( it->first, it->second.p2() );
2426 QList< QPair< double, QPointF > >::const_iterator bIt = borderPositions.constBegin();
2427 for ( ; bIt != borderPositions.constEnd(); ++bIt )
2432 leftFrameEntries.insert( bIt->second.y(), bIt->first );
2436 rightFrameEntries.insert( bIt->second.y(), bIt->first );
2440 topFrameEntries.insert( bIt->second.x(), bIt->first );
2444 bottomFrameEntries.insert( bIt->second.x(), bIt->first );
2464 if ( !overviewFrameMap )
2484 QPolygonF intersectPolygon;
2485 double x = ( intersectRect.
xMinimum() - thisExtent.
xMinimum() ) / thisExtent.
width() * rect().width();
2487 double width = intersectRect.
width() / thisExtent.
width() * rect().width();
2488 double height = intersectRect.
height() / thisExtent.
height() * rect().height();
2489 intersectPolygon << QPointF( x, y ) << QPointF( x + width, y ) << QPointF( x + width, y + height ) << QPointF( x, y + height ) << QPointF( x, y );
2491 QList<QPolygonF> rings;
2501 QPolygonF outerPolygon;
2502 outerPolygon << QPointF( 0, 0 ) << QPointF( rect().width(), 0 ) << QPointF( rect().width(), rect().height() ) << QPointF( 0, rect().height() ) << QPointF( 0, 0 );
2505 rings.append( intersectPolygon );
2517 properties.insert(
"color",
"255,0,0,255" );
2518 properties.insert(
"style",
"solid" );
2519 properties.insert(
"style_border",
"no" );
2528 properties.insert(
"color",
"0,0,0,255" );
2529 properties.insert(
"width",
"0.3" );
2530 properties.insert(
"capstyle",
"flat" );
2538 bool degreeUnits =
true;
2544 if ( format ==
"DM" && degreeUnits )
2548 else if ( format ==
"DMS" && degreeUnits )
2573 QList<const QgsComposerMap*>::const_iterator mapIt = mapList.constBegin();
2574 for ( ; mapIt != mapList.constEnd(); ++mapIt )
2576 if (( *mapIt )->id() > maxId )
2578 maxId = ( *mapIt )->id();
QString toDegreesMinutesSeconds(int thePrecision) const
Return a string representation as degrees minutes seconds.
bool mAtlasFixedScale
True if map uses a fixed scale when controlled by an atlas.
int mOverviewFrameMapId
Id of map which displays its extent rectangle into this composer map (overview map functionality)...
double mXOffset
Offset in x direction for showing map cache image.
void setMapUnits(QGis::UnitType mapUnits)
Set the map units.
QgsPalLayerSettings & layer(const QString &layerName)
returns PAL layer settings for a registered layer
void setForceVectorOutput(bool force)
Added in QGIS v1.5.
QgsComposition::AtlasMode atlasMode() const
Returns the current atlas mode of the composition.
bool mGridEnabled
True if coordinate grid has to be displayed.
void draw(QPainter *painter, const QgsRectangle &extent, const QSizeF &size, double dpi, double *forceWidthScale=0)
Draw to paint device.
bool imageSizeConsideringRotation(double &width, double &height, double rotation) const
Calculates width and hight of the picture (in mm) such that it fits into the item frame with the give...
void setRenderingStopped(bool stopped)
A rectangle specified with double values.
Base class for all map layer types.
void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, const QgsFeature *f, QgsRenderContext &context, int layer=-1, bool selected=false)
void render(QPainter *painter, double *forceWidthScale=0)
starts rendering @ param forceWidthScale Force a specific scale factor for line widths and marker siz...
bool mDrawing
set to true if in state of drawing.
void setLabelingEngine(QgsLabelingEngineInterface *iface)
Set labeling engine.
double mGridIntervalY
Grid line interval in y-direction (map units)
double mMapRotation
Map rotation.
GridAnnotationDirection gridAnnotationDirection(QgsComposerMap::Border border) const
QgsRenderContext * rendererContext()
Accessor for render context.
void overviewExtentChanged()
double fontHeightCharacterMM(const QFont &font, const QChar &c) const
Returns the font height of a character in millimeters.
void setOverviewCentered(bool centered)
Set the overview's centering mode.
bool containsWMSLayer() const
True if composer map renders a WMS layer.
void setXMaximum(double x)
Set the maximum x value.
double mapUnitsToMM() const
Returns the conversion factor map units -> mm.
bool hideCoverage() const
void assignFreeId()
Sets mId to a number not yet used in the composition.
void setNewAtlasFeatureExtent(const QgsRectangle &extent)
Sets new Extent for the current atlas preview and changes width, height (and implicitely also scale)...
void setOffset(double xOffset, double yOffset)
Sets offset values to shift image (useful for live updates when moving item content) ...
double yMaximum() const
Get the y maximum value (top side of rectangle)
QStringList mLayerSet
Stored layer list (used if layer live-link mKeepLayerSet is disabled)
QFont mGridAnnotationFont
Font for grid line annotation.
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
void requestedExtent(QgsRectangle &extent) const
Calculates the extent to request and the yShift of the top-left point in case of rotation.
bool mDrawCanvasItems
True if annotation items, rubber band, etc.
QString toDegreesMinutes(int thePrecision) const
Return a string representation as degrees minutes.
QPainter::CompositionMode bufferBlendMode
QStringList layerSet() const
Getter for stored layer set that is used if mKeepLayerSet is true.
double maxExtension() const
QgsRectangle extent() const
returns current extent
QString qgsDoubleToString(const double &a)
static QgsFillSymbolV2 * createSimple(const QgsStringMap &properties)
Create a fill symbol with one symbol layer: SimpleFill with specified properties. ...
void cache()
Create cache image.
bool imageSizeConsideringRotation(double &width, double &height) const
Calculates width and hight of the picture (in mm) such that it fits into the item frame with the give...
QList< const QgsComposerMap * > composerMapItems() const
Returns pointers to all composer maps in the scene.
A item that forms part of a map composition.
void connectUpdateSlot()
Establishes signal/slot connection for update in case of layer change.
QgsMapRenderer * mapRenderer()
Returns pointer to map renderer of qgis map canvas.
Border
Enum for different frame borders.
void updateItem()
Updates item, with the possibility to do custom update for subclasses.
QPointF composerMapPosForItem(const QGraphicsItem *item) const
QPainter::CompositionMode mOverviewBlendMode
Blend mode for overview.
void setDpi(double dpi)
Set the dpi to be used in scale calculations.
QGraphicsView * mMapCanvas
double mLastValidViewScaleFactor
Backup to restore item appearance if no view scale factor is available.
void setScale(double scale)
Sets scale for scale based visibility.
void mapRotationChanged(double newRotation)
Is emitted on rotation change to notify north arrow pictures.
void setProjectionsEnabled(bool enabled)
sets whether to use projections for this layer set
virtual void drawFrame(QPainter *p)
Draw black frame around item.
void updateCachedImage()
Called if map canvas has changed.
bool cornerPointOnRotatedAndScaledRect(double &x, double &y, double width, double height) const
Calculates corner point after rotation and scaling.
bool readXML(const QDomElement &itemElem, const QDomDocument &doc)
sets state from Dom document
void createDefaultGridLineSymbol()
QPolygonF transformedMapPolygon() const
Returns extent that considers rotation and shift with mOffsetX / mOffsetY.
QColor backgroundColor() const
Gets the background color for this item.
void setLayerSet(const QStringList &layers)
change current layer set
A non GUI class for rendering a map layer set onto a QPainter.
void mapPolygon(QPolygonF &poly) const
Returns the polygon of the map extent.
void initGridAnnotationFormatFromProject()
bool mShowGridAnnotation
True if coordinate values should be drawn.
void setSceneRect(const QRectF &rectangle)
Sets new scene rectangle bounds and recalculates hight and extent.
bool containsAdvancedEffects() const
True if composer map contains layers with blend modes or flattened layers for vectors.
QMap< QString, QString > QgsStringMap
int readNumEntry(const QString &scope, const QString &key, int def=0, bool *ok=0) const
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
QRectF boundingRect() const
In case of annotations, the bounding rectangle can be larger than the map item rectangle.
bool mOverviewCentered
Centering mode for overview.
BlendMode
Blending modes enum defining the available composition modes that can be used when rendering a layer...
void zoomContent(int delta, double x, double y)
Zoom content of map.
void setGridPenColor(const QColor &c)
Sets the color of the grid pen.
virtual QString name() const =0
return a provider name
void setWidth(double width)
GridFrameStyle mGridFrameStyle
QColor mGridFrameFillColor1
QColor mGridFramePenColor
int mGridAnnotationPrecision
Digits after the dot.
void itemChanged()
Used e.g.
void setNewScale(double scaleDenominator)
Sets new scale and changes only mExtent.
bool _readXML(const QDomElement &itemElem, const QDomDocument &doc)
Reads parameter that are not subclass specific in document.
static QDomElement saveSymbol(QString symbolName, QgsSymbolV2 *symbol, QDomDocument &doc)
Perform transforms between map coordinates and device coordinates.
QgsLineSymbolV2 * mGridLineSymbol
void storeCurrentLayerSet()
Stores the current layer set of the qgis mapcanvas in mLayerSet.
GridAnnotationDirection mLeftGridAnnotationDirection
Annotation direction on left side ( horizontal or vertical )
void setColor(const QColor &color)
double mAnnotationFrameDistance
Distance between map frame and annotation.
double scale() const
Scale.
GridAnnotationDirection mRightGridAnnotationDirection
Annotation direction on right side ( horizontal or vertical )
void drawCoordinateAnnotations(QPainter *p, const QList< QPair< double, QLineF > > &hLines, const QList< QPair< double, QLineF > > &vLines)
Draw coordinates for mGridAnnotationType Coordinate.
QPainter::CompositionMode blendMode() const
Read blend mode for layer.
void setUseAdvancedEffects(bool enabled)
Used to enable or disable advanced effects such as blend modes.
double horizontalViewScaleFactor() const
Returns the zoom factor of the graphics view.
QRectF mCurrentRectangle
Current bounding rectangle.
void setScaleFactor(double factor)
double mCrossLength
The length of the cross sides for mGridStyle Cross.
double mGridFramePenThickness
QPainter::CompositionMode featureBlendMode() const
Read blend mode for layer.
virtual bool willUseLayer(QgsVectorLayer *layer)
called to find out whether the layer is used for labeling
double calculate(const QgsRectangle &mapExtent, int canvasWidth)
Calculate the scale denominator.
void updateBoundingRect()
Updates the bounding rect of this item.
double mGridOffsetY
Grid line offset in y-direction.
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
void toggleAtlasPreview()
Called when atlas preview is toggled, to force map item to update its extent and redraw.
double xMaximum() const
Get the x maximum value (right side of rectangle)
virtual void updateItem()
Updates item, with the possibility to do custom update for subclasses.
void drawOverviewMapExtent(QPainter *p)
virtual void drawSelectionBoxes(QPainter *p)
Draw selection boxes around item.
virtual QgsLabelingEngineInterface * clone()=0
called when passing engine among map renderers
double textWidthMillimeters(const QFont &font, const QString &text) const
Returns the font width in millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE...
static QgsLineSymbolV2 * createSimple(const QgsStringMap &properties)
Create a line symbol with one symbol layer: SimpleLine with specified properties. ...
void rotate(double angle, double &x, double &y) const
Rotates a point / vector.
QPainter::CompositionMode blendMode
QString gridAnnotationString(double value, AnnotationCoordinate coord) const
bool hasCrsTransformEnabled() const
returns true if projections are enabled for this layer set
int printResolution() const
bool mFrame
True if item fram needs to be painted.
bool writeXML(QDomElement &elem, QDomDocument &doc) const
stores state in Dom node
bool drawCanvasItems() const
const QgsCoordinateReferenceSystem & destinationCrs() const
returns CRS of destination coordinate reference system
void setCacheUpdated(bool u=false)
void setYMinimum(double y)
Set the minimum y value.
double scale() const
Scale denominator.
void setDrawEditingInformation(bool b)
double rotation() const
Returns the rotation used for drawing the map within the composer item.
int yGridLines(QList< QPair< double, QLineF > > &lines) const
Returns the grid lines for the y-coordinates.
double mYOffset
Offset in y direction for showing map cache image.
void renderPolyline(const QPolygonF &points, const QgsFeature *f, QgsRenderContext &context, int layer=-1, bool selected=false)
bool setExtent(const QgsRectangle &extent)
sets extent and checks whether suitable (returns false if not)
virtual void setFrameOutlineWidth(double outlineWidth)
Sets frame outline width.
QColor mGridFrameFillColor2
void drawAnnotation(QPainter *p, const QPointF &pos, int rotation, const QString &annotationText)
Draws a single annotation.
void setNewExtent(const QgsRectangle &extent)
Sets new Extent and changes width, height (and implicitely also scale)
void setGridPen(const QPen &p)
Sets the pen to draw composer grid.
void setPainter(QPainter *p)
void moveContent(double dx, double dy)
Move content of map.
QStringList layersToRender()
Returns a list of the layers to render for this map item.
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry.
void drawText(QPainter *p, double x, double y, const QString &text, const QFont &font) const
Draws Text.
void setOutputSize(QSize size, int dpi)
void drawGridFrame(QPainter *p, const QList< QPair< double, QLineF > > &hLines, const QList< QPair< double, QLineF > > &vLines)
double mGridIntervalX
Grid line interval in x-direction (map units)
GridAnnotationPosition mTopGridAnnotationPosition
Annotation position for top map side (inside / outside / not shown)
QPainter::CompositionMode shapeBlendMode
void drawCanvasItem(QGraphicsItem *item, QPainter *painter, const QStyleOptionGraphicsItem *itemStyle)
void sizeChangedByRotation(double &width, double &height)
Calculates width / height of the bounding box of a rotated rectangle.
void setOverviewFrameMapSymbol(QgsFillSymbolV2 *symbol)
bool mAtlasDriven
True if map is being controlled by an atlas.
PreviewMode
Preview style.
GridAnnotationPosition gridAnnotationPosition(QgsComposerMap::Border border) const
GridAnnotationPosition mLeftGridAnnotationPosition
Annotation position for left map side (inside / outside / not shown)
QgsComposition * mComposition
A class to represent a point geometry.
GridAnnotationFormat mGridAnnotationFormat
Graphics scene for map printing.
void sortGridLinesOnBorders(const QList< QPair< double, QLineF > > &hLines, const QList< QPair< double, QLineF > > &vLines, QMap< double, double > &leftFrameEntries, QMap< double, double > &rightFrameEntries, QMap< double, double > &topFrameEntries, QMap< double, double > &bottomFrameEntries) const
This class tracks map layers that are currently loaded and provides a means to fetch a pointer to a m...
Object representing map window.
GridStyle mGridStyle
Solid or crosses.
QgsRectangle * currentMapExtent()
Returns a pointer to the current map extent, which is either the original user specified extent or th...
QgsFillSymbolV2 * mOverviewFrameMapSymbol
Drawing style for overview farme.
GridAnnotationPosition mRightGridAnnotationPosition
Annotation position for right map side (inside / outside / not shown)
GridAnnotationDirection mTopGridAnnotationDirection
Annotation direction on top side ( horizontal or vertical )
void renderModeUpdateCachedImage()
Call updateCachedImage if item is in render mode.
PreviewMode previewMode() const
void drawGridLine(const QLineF &line, QPainter *p)
virtual ~QgsComposerMap()
void setGridAnnotationDirection(GridAnnotationDirection d, QgsComposerMap::Border border)
Calculates scale for a given combination of canvas size, map extent, and monitor dpi.
int layerTransparency() const
Read transparency for layer.
int xGridLines(QList< QPair< double, QLineF > > &lines) const
Returns the grid lines with associated coordinate value.
static QPainter::CompositionMode getCompositionMode(const QgsMapRenderer::BlendMode &blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode Added in 1.9.
bool useAdvancedEffects() const
Returns true if a composition should use advanced effects such as blend modes.
void paint(QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget)
Reimplementation of QCanvasItem::paint - draw on canvas.
QColor mBackgroundColor
Background color.
double mAtlasMargin
Margin size for atlas driven extents (percentage of feature size)
Contains information about the context of a rendering operation.
bool mKeepLayerSet
Flag if layers to be displayed should be read from qgis canvas (true) or from stored list in mLayerSe...
bool cornerPointOnRotatedAndScaledRect(double &x, double &y, double width, double height, double rotation) const
Calculates corner point after rotation and scaling.
QString readEntry(const QString &scope, const QString &key, const QString &def=QString::null, bool *ok=0) const
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
virtual void setFrameOutlineWidth(double outlineWidth)
Sets frame outline width.
void stopRender(QgsRenderContext &context)
double mGridOffsetX
Grid line offset in x-direction.
void setOverviewInverted(bool inverted)
Sets the overview's inversion mode.
QgsLabelingEngineInterface * labelingEngine()
Labeling engine (NULL if there's no custom engine)
bool _writeXML(QDomElement &itemElem, QDomDocument &doc) const
Writes parameter that are not subclass specific in document.
QgsMapRenderer * mMapRenderer
QgsRectangle extent() const
GridAnnotationDirection mBottomGridAnnotationDirection
Annotation direction on bottom side ( horizontal or vertical )
QPainter::CompositionMode blendMode() const
Returns the item's composition blending mode.
int mId
Unique identifier.
void setYMaximum(double y)
Set the maximum y value.
virtual void drawBackground(QPainter *p)
Draw background.
QgsRectangle intersect(const QgsRectangle *rect) const
return the intersection with the given rectangle
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs, bool refreshCoordinateTransformInfo=true)
sets destination coordinate reference system
static QgsProject * instance()
access to canonical QgsProject instance
void startRender(QgsRenderContext &context, const QgsVectorLayer *layer=0)
void setMapRotation(double r)
Sets rotation for the map - this does not affect the composer item shape, only the way the map is dra...
virtual void setSceneRect(const QRectF &rectangle)
Sets this items bound in scene coordinates such that 1 item size units corresponds to 1 scene size un...
void setGridAnnotationPosition(GridAnnotationPosition p, QgsComposerMap::Border border)
void drawCoordinateAnnotation(QPainter *p, const QPointF &pos, QString annotationString)
void transformShift(double &xShift, double &yShift) const
Scales a composer map shift (in MM) and rotates it by mRotation.
const QgsComposition * composition() const
void adjustExtentToItemShape(double itemWidth, double itemHeight, QgsRectangle &extent) const
Adjusts an extent rectangle to match the provided item width and height, so that extent center of ext...
void drawGridFrameBorder(QPainter *p, const QMap< double, double > &borderPos, Border border)
bool hasBackground() const
Whether this item has a Background or not.
const QMap< QString, QgsMapLayer * > & mapLayers()
Retrieve the mapLayers collection (mainly intended for use by projection)
QgsComposerMap(QgsComposition *composition, int x, int y, int width, int height)
Constructor.
QgsRectangle mAtlasFeatureExtent
void setUseRenderingOptimization(bool enabled)
void resize(double dx, double dy)
resizes an item in x- and y direction (canvas coordinates)
QgsAtlasComposition & atlasComposition()
QgsMapLayer * mapLayer(QString theLayerId)
Retrieve a pointer to a loaded layer by id.
QPainter::CompositionMode shadowBlendMode
static QgsSymbolV2 * loadSymbol(QDomElement &element)
QgsRasterDataProvider * dataProvider()
Returns the data provider.
void setRasterScaleFactor(double factor)
static QgsMapRenderer::BlendMode getBlendModeEnum(const QPainter::CompositionMode &blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode Added in 1.9.
void setOverviewBlendMode(QPainter::CompositionMode blendMode)
Sets the overview's blending mode.
QgsVectorLayer * coverageLayer() const
GridAnnotationPosition mBottomGridAnnotationPosition
Annotation position for bottom map side (inside / outside / not shown)
void setGridLineSymbol(QgsLineSymbolV2 *symbol)
void setGridPenWidth(double w)
Sets with of grid pen.
void createDefaultOverviewFrameSymbol()
static void setSpecialColumn(const QString &name, QVariant value)
Assign a special column.
void drawGrid(QPainter *p)
Draws the map grid.
QColor mGridAnnotationFontColor
Font color for grid line annotation.
QPointF mapToItemCoords(const QPointF &mapCoords) const
Transforms map coordinates to item coordinates (considering rotation and move offset) ...
void setPreviewMode(PreviewMode m)
QgsComposition::PlotStyle plotStyle() const
double width() const
Width of the rectangle.
static QPointF pointOnLineWithDistance(const QPointF &startPoint, const QPointF &directionPoint, double distance)
Returns a point on the line from startPoint to directionPoint that is a certain distance away from th...
QGis::UnitType mapUnits() const
Represents a vector layer which manages a vector based data sets.
const QgsComposerMap * getComposerMapById(int id) const
Returns the composer map with specified id.
double xMinimum() const
Get the x minimum value (left side of rectangle)
PreviewMode mPreviewMode
Preview style.
void setRotation(double r)
Sets rotation for the map - this does not affect the composer item shape, only the way the map is dra...
QStringList & layerSet()
returns current layer set
QgsPoint center() const
Center point of the rectangle.
void setAlpha(qreal alpha)
Set alpha transparency 1 for opaque, 0 for invisible.
QPainter::CompositionMode mGridBlendMode
Blend mode for grid.
void setGridBlendMode(QPainter::CompositionMode blendMode)
Sets the grid's blending mode.
void syncLayerSet()
Removes layer ids from mLayerSet that are no longer present in the qgis main map. ...
double fontAscentMillimeters(const QFont &font) const
Returns the font ascent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCAL...
void setOverviewFrameMap(int mapId)
Sets overview frame map.
int mNumCachedLayers
Number of layers when cache was created.
void setXMinimum(double x)
Set the minimum x value.
QgsRectangle transformedExtent() const
Returns extent that considers mOffsetX / mOffsetY (during content move)
void sizeChangedByRotation(double &width, double &height, double rotation)
Calculates width / height of the bounding box of a rotated rectangle.
double height() const
Height of the rectangle.
Base class for raster data providers.
void scale(double scaleFactor, const QgsPoint *c=0)
Scale the rectangle around its center point.
Border borderForLineCoord(const QPointF &p) const
Returns the item border of a point (in item coordinates)
QString id() const
Get item's id (which is not necessarly unique)