38 #include <QGraphicsScene>
39 #include <QGraphicsView>
45 :
QgsComposerItem( x, y, width, height, composition ), mMapRotation( 0 ), mKeepLayerSet( false )
46 , mOverviewFrameMapId( -1 ), mOverviewBlendMode( QPainter::CompositionMode_SourceOver ), mOverviewInverted( false ), mOverviewCentered( false )
47 , mUpdatesEnabled( true ), mGridEnabled( false ), mGridStyle( Solid )
48 , mGridIntervalX( 0.0 ), mGridIntervalY( 0.0 ), mGridOffsetX( 0.0 ), mGridOffsetY( 0.0 ), mGridAnnotationFontColor( QColor( 0, 0, 0 ) )
49 , mGridAnnotationPrecision( 3 ), mShowGridAnnotation( false ), mGridBlendMode( QPainter::CompositionMode_SourceOver )
50 , mLeftGridAnnotationPosition( OutsideMapFrame ), mRightGridAnnotationPosition( OutsideMapFrame )
51 , mTopGridAnnotationPosition( OutsideMapFrame ), mBottomGridAnnotationPosition( OutsideMapFrame ), mAnnotationFrameDistance( 1.0 )
52 , mLeftGridAnnotationDirection( Horizontal ), mRightGridAnnotationDirection( Horizontal ), mTopGridAnnotationDirection( Horizontal )
53 , mBottomGridAnnotationDirection( Horizontal ), mGridFrameStyle( NoGridFrame ), mGridFrameWidth( 2.0 )
54 , mGridFramePenThickness( 0.5 ), mGridFramePenColor( QColor( 0, 0, 0 ) ), mGridFrameFillColor1( Qt::white ), mGridFrameFillColor2( Qt::black )
55 , mCrossLength( 3 ), mMapCanvas( 0 ), mDrawCanvasItems( true ), mAtlasDriven( false ), mAtlasScalingMode( Auto ), mAtlasMargin( 0.10 )
79 QString defaultFontString = settings.value(
"/Composer/defaultFont" ).toString();
80 if ( !defaultFontString.isEmpty() )
97 setToolTip(
tr(
"Map %1" ).arg(
mId ) );
103 :
QgsComposerItem( 0, 0, 10, 10, composition ), mMapRotation( 0 ), mKeepLayerSet( false ), mOverviewFrameMapId( -1 )
104 , mOverviewBlendMode( QPainter::CompositionMode_SourceOver ), mOverviewInverted( false ), mOverviewCentered( false )
105 , mUpdatesEnabled( true ), mGridEnabled( false ), mGridStyle( Solid )
106 , mGridIntervalX( 0.0 ), mGridIntervalY( 0.0 ), mGridOffsetX( 0.0 ), mGridOffsetY( 0.0 ), mGridAnnotationFontColor( QColor( 0, 0, 0 ) )
107 , mGridAnnotationPrecision( 3 ), mShowGridAnnotation( false ), mGridBlendMode( QPainter::CompositionMode_SourceOver )
108 , mLeftGridAnnotationPosition( OutsideMapFrame ), mRightGridAnnotationPosition( OutsideMapFrame )
109 , mTopGridAnnotationPosition( OutsideMapFrame ), mBottomGridAnnotationPosition( OutsideMapFrame ), mAnnotationFrameDistance( 1.0 )
110 , mLeftGridAnnotationDirection( Horizontal ), mRightGridAnnotationDirection( Horizontal ), mTopGridAnnotationDirection( Horizontal )
111 , mBottomGridAnnotationDirection( Horizontal ), mGridFrameStyle( NoGridFrame ), mGridFrameWidth( 2.0 ), mGridFramePenThickness( 0.5 )
112 , mGridFramePenColor( QColor( 0, 0, 0 ) ), mGridFrameFillColor1( Qt::white ), mGridFrameFillColor2( Qt::black )
113 , mCrossLength( 3 ), mMapCanvas( 0 ), mDrawCanvasItems( true ), mAtlasDriven( false ), mAtlasScalingMode( Auto ), mAtlasMargin( 0.10 )
131 setToolTip(
tr(
"Map %1" ).arg(
mId ) );
138 double itemWidthHeightRatio = itemWidth / itemHeight;
139 double newWidthHeightRatio = extent.
width() / extent.
height();
141 if ( itemWidthHeightRatio <= newWidthHeightRatio )
144 double newHeight = extent.
width() / itemWidthHeightRatio;
145 double deltaHeight = newHeight - extent.
height();
152 double newWidth = itemWidthHeightRatio * extent.
height();
153 double deltaWidth = newWidth - extent.
width();
169 Q_UNUSED( forceWidthScale );
175 if ( size.width() == 0 || size.height() == 0 )
198 ( layerIdx >= 0 && layerIdx < theLayerSet.length() )
199 ? QStringList( theLayerSet[ theLayerSet.length() - layerIdx - 1 ] )
250 if ( horizontalVScaleFactor < 0 )
259 int w = widthMM * horizontalVScaleFactor;
260 int h = heightMM * horizontalVScaleFactor;
272 mCacheImage = QImage( w, h, QImage::Format_ARGB32 );
275 mCacheImage.setDotsPerMeterX( 1000 * w / widthMM );
276 mCacheImage.setDotsPerMeterY( 1000 * h / heightMM );
287 mCacheImage.fill( QColor( 255, 255, 255, 0 ).rgba() );
308 QRectF thisPaintRect = QRectF( 0, 0, QGraphicsRectItem::rect().width(), QGraphicsRectItem::rect().height() );
310 painter->setClipRect( thisPaintRect );
316 QFont messageFont(
"", 12 );
317 painter->setFont( messageFont );
318 painter->setPen( QColor( 0, 0, 0, 125 ) );
319 painter->drawText( thisPaintRect,
tr(
"Map will be printed here" ) );
336 double scale = rect().width() / imagePixelWidth;
350 painter->translate( xTopLeftShift, yTopLeftShift );
352 painter->translate( xShiftMM, -yShiftMM );
353 painter->scale( scale, scale );
371 QPaintDevice* thePaintDevice = painter->device();
372 if ( !thePaintDevice )
401 painter->translate( xTopLeftShift, yTopLeftShift );
403 painter->translate( xShiftMM, -yShiftMM );
405 double dotsPerMM = thePaintDevice->logicalDpiX() / 25.4;
406 theSize *= dotsPerMM;
407 painter->scale( 1 / dotsPerMM, 1 / dotsPerMM );
408 draw( painter, requestRectangle, theSize, thePaintDevice->logicalDpiX() );
419 painter->setClipRect( thisPaintRect , Qt::NoClip );
449 + ( isSelected() ? 1 : 0 )
512 QGraphicsRectItem::update();
538 QStringList renderLayerSet;
556 if ( removeAt != -1 )
558 renderLayerSet.removeAt( removeAt );
563 return renderLayerSet;
570 calculator.
setDpi( 25.4 );
577 QRectF currentRect = rect();
578 QRectF newSceneRect = QRectF( pos().x(), pos().y(), currentRect.width() + dx, currentRect.height() + dy );
610 int zoomMode = settings.value(
"/qgis/wheel_action", 2 ).toInt();
616 double zoomFactor = settings.value(
"/qgis/zoom_factor", 2.0 ).toDouble();
632 else if ( zoomMode == 2 )
634 centerX = mapMouseX + ( centerX - mapMouseX ) * ( 1.0 / zoomFactor );
635 centerY = mapMouseY + ( centerY - mapMouseY ) * ( 1.0 / zoomFactor );
639 double newIntervalX, newIntervalY;
646 else if ( delta < 0 )
668 calculator.
setDpi( 25.4 );
681 double w = rectangle.width();
682 double h = rectangle.height();
707 QRectF currentRect = rect();
709 double newHeight = currentRect.width() * extent.
height() / extent.
width();
711 setSceneRect( QRectF( pos().x(), pos().y(), currentRect.width(), newHeight ) );
727 double currentWidthHeightRatio = rect().
width() / rect().height();
728 double newWidthHeightRatio = newExtent.
width() / newExtent.
height();
730 if ( currentWidthHeightRatio < newWidthHeightRatio )
733 double newHeight = newExtent.
width() / currentWidthHeightRatio;
734 double deltaHeight = newHeight - newExtent.
height();
738 else if ( currentWidthHeightRatio >= newWidthHeightRatio )
741 double newWidth = currentWidthHeightRatio * newExtent.
height();
742 double deltaWidth = newWidth - newExtent.
width();
798 double currentScaleDenominator =
scale();
800 if ( scaleDenominator == currentScaleDenominator || scaleDenominator == 0 )
805 double scaleRatio = scaleDenominator / currentScaleDenominator;
815 calculator.
setDpi( 25.4 );
816 scaleRatio = scaleDenominator / calculator.
calculate(
mExtent, rect().width() );
871 QStringList::const_iterator layer_it = layers.constBegin();
874 for ( ; layer_it != layers.constEnd(); ++layer_it )
880 if ( currentRasterLayer )
883 if (( rasterProvider = currentRasterLayer->
dataProvider() ) )
885 if ( rasterProvider->
name() ==
"wms" )
902 QStringList::const_iterator layer_it = layers.constBegin();
905 for ( ; layer_it != layers.constEnd(); ++layer_it )
910 if ( currentLayer->
blendMode() != QPainter::CompositionMode_SourceOver )
916 if ( currentVectorLayer )
922 if ( currentVectorLayer->
featureBlendMode() != QPainter::CompositionMode_SourceOver )
931 if (( layerSettings.
blendMode != QPainter::CompositionMode_SourceOver ) ||
952 connect( layerRegistry, SIGNAL( layerWillBeRemoved( QString ) ),
this, SLOT(
updateCachedImage() ) );
964 QDomElement composerMapElem = doc.createElement(
"ComposerMap" );
965 composerMapElem.setAttribute(
"id",
mId );
970 composerMapElem.setAttribute(
"previewMode",
"Cache" );
974 composerMapElem.setAttribute(
"previewMode",
"Render" );
978 composerMapElem.setAttribute(
"previewMode",
"Rectangle" );
983 composerMapElem.setAttribute(
"keepLayerSet",
"true" );
987 composerMapElem.setAttribute(
"keepLayerSet",
"false" );
992 composerMapElem.setAttribute(
"drawCanvasItems",
"true" );
996 composerMapElem.setAttribute(
"drawCanvasItems",
"false" );
1000 QDomElement overviewFrameElem = doc.createElement(
"overviewFrame" );
1005 overviewFrameElem.setAttribute(
"overviewInverted",
"true" );
1009 overviewFrameElem.setAttribute(
"overviewInverted",
"false" );
1012 overviewFrameElem.setAttribute(
"overviewCentered",
mOverviewCentered ?
"true" :
"false" );
1015 overviewFrameElem.appendChild( overviewFrameStyleElem );
1016 composerMapElem.appendChild( overviewFrameElem );
1020 QDomElement extentElem = doc.createElement(
"Extent" );
1025 composerMapElem.appendChild( extentElem );
1028 composerMapElem.setAttribute(
"mapRotation", QString::number(
mMapRotation ) );
1031 QDomElement layerSetElem = doc.createElement(
"LayerSet" );
1032 QStringList::const_iterator layerIt =
mLayerSet.constBegin();
1033 for ( ; layerIt !=
mLayerSet.constEnd(); ++layerIt )
1035 QDomElement layerElem = doc.createElement(
"Layer" );
1036 QDomText layerIdText = doc.createTextNode( *layerIt );
1037 layerElem.appendChild( layerIdText );
1038 layerSetElem.appendChild( layerElem );
1040 composerMapElem.appendChild( layerSetElem );
1046 QDomElement gridElem = doc.createElement(
"Grid" );
1048 gridElem.setAttribute(
"gridStyle",
mGridStyle );
1058 QDomElement framePenColorElem = doc.createElement(
"framePenColor" );
1063 gridElem.appendChild( framePenColorElem );
1065 QDomElement frameFillColor1Elem = doc.createElement(
"frameFillColor1" );
1070 gridElem.appendChild( frameFillColor1Elem );
1071 QDomElement frameFillColor2Elem = doc.createElement(
"frameFillColor2" );
1076 gridElem.appendChild( frameFillColor2Elem );
1080 gridElem.appendChild( gridLineStyleElem );
1083 QDomElement annotationElem = doc.createElement(
"Annotation" );
1098 QDomElement annotationFontColorElem = doc.createElement(
"fontColor" );
1103 annotationElem.appendChild( annotationFontColorElem );
1105 gridElem.appendChild( annotationElem );
1106 composerMapElem.appendChild( gridElem );
1109 QDomElement atlasElem = doc.createElement(
"AtlasMap" );
1113 composerMapElem.appendChild( atlasElem );
1115 elem.appendChild( composerMapElem );
1116 return _writeXML( composerMapElem, doc );
1121 if ( itemElem.isNull() )
1126 QString idRead = itemElem.attribute(
"id",
"not found" );
1127 if ( idRead !=
"not found" )
1129 mId = idRead.toInt();
1134 QString
previewMode = itemElem.attribute(
"previewMode" );
1135 if ( previewMode ==
"Cache" )
1139 else if ( previewMode ==
"Render" )
1148 QDomElement overviewFrameElem = itemElem.firstChildElement(
"overviewFrame" );
1149 if ( !overviewFrameElem.isNull() )
1154 QString overviewInvertedFlag = overviewFrameElem.attribute(
"overviewInverted" );
1155 if ( overviewInvertedFlag.compare(
"true", Qt::CaseInsensitive ) == 0 )
1164 if ( overviewFrameElem.attribute(
"overviewCentered" ).compare(
"true", Qt::CaseInsensitive ) == 0 )
1173 QDomElement overviewFrameSymbolElem = overviewFrameElem.firstChildElement(
"symbol" );
1174 if ( !overviewFrameSymbolElem.isNull() )
1182 QDomNodeList extentNodeList = itemElem.elementsByTagName(
"Extent" );
1183 if ( extentNodeList.size() > 0 )
1185 QDomElement extentElem = extentNodeList.at( 0 ).toElement();
1186 double xmin, xmax, ymin, ymax;
1187 xmin = extentElem.attribute(
"xmin" ).toDouble();
1188 xmax = extentElem.attribute(
"xmax" ).toDouble();
1189 ymin = extentElem.attribute(
"ymin" ).toDouble();
1190 ymax = extentElem.attribute(
"ymax" ).toDouble();
1195 if ( itemElem.attribute(
"mapRotation",
"0" ).toDouble() != 0 )
1197 mMapRotation = itemElem.attribute(
"mapRotation",
"0" ).toDouble();
1201 QString keepLayerSetFlag = itemElem.attribute(
"keepLayerSet" );
1202 if ( keepLayerSetFlag.compare(
"true", Qt::CaseInsensitive ) == 0 )
1211 QString drawCanvasItemsFlag = itemElem.attribute(
"drawCanvasItems",
"true" );
1212 if ( drawCanvasItemsFlag.compare(
"true", Qt::CaseInsensitive ) == 0 )
1222 QDomNodeList layerSetNodeList = itemElem.elementsByTagName(
"LayerSet" );
1224 if ( layerSetNodeList.size() > 0 )
1226 QDomElement layerSetElem = layerSetNodeList.at( 0 ).toElement();
1227 QDomNodeList layerIdNodeList = layerSetElem.elementsByTagName(
"Layer" );
1228 for (
int i = 0; i < layerIdNodeList.size(); ++i )
1230 layerSet << layerIdNodeList.at( i ).toElement().text();
1240 QDomNodeList gridNodeList = itemElem.elementsByTagName(
"Grid" );
1241 if ( gridNodeList.size() > 0 )
1243 QDomElement gridElem = gridNodeList.at( 0 ).toElement();
1244 mGridEnabled = ( gridElem.attribute(
"show",
"0" ) !=
"0" );
1246 mGridIntervalX = gridElem.attribute(
"intervalX",
"0" ).toDouble();
1247 mGridIntervalY = gridElem.attribute(
"intervalY",
"0" ).toDouble();
1248 mGridOffsetX = gridElem.attribute(
"offsetX",
"0" ).toDouble();
1249 mGridOffsetY = gridElem.attribute(
"offsetY",
"0" ).toDouble();
1250 mCrossLength = gridElem.attribute(
"crossLength",
"3" ).toDouble();
1252 mGridFrameWidth = gridElem.attribute(
"gridFrameWidth",
"2.0" ).toDouble();
1256 QDomNodeList gridFramePenColorList = gridElem.elementsByTagName(
"framePenColor" );
1257 if ( gridFramePenColorList.size() > 0 )
1259 QDomElement penColorElem = gridFramePenColorList.at( 0 ).toElement();
1260 int red = penColorElem.attribute(
"red",
"0" ).toInt();
1261 int green = penColorElem.attribute(
"green",
"0" ).toInt();
1262 int blue = penColorElem.attribute(
"blue",
"0" ).toInt();
1263 int alpha = penColorElem.attribute(
"alpha",
"255" ).toInt();
1271 QDomNodeList gridFrameFillColor1List = gridElem.elementsByTagName(
"frameFillColor1" );
1272 if ( gridFrameFillColor1List.size() > 0 )
1274 QDomElement fillColorElem = gridFrameFillColor1List.at( 0 ).toElement();
1275 int red = fillColorElem.attribute(
"red",
"0" ).toInt();
1276 int green = fillColorElem.attribute(
"green",
"0" ).toInt();
1277 int blue = fillColorElem.attribute(
"blue",
"0" ).toInt();
1278 int alpha = fillColorElem.attribute(
"alpha",
"255" ).toInt();
1286 QDomNodeList gridFrameFillColor2List = gridElem.elementsByTagName(
"frameFillColor2" );
1287 if ( gridFrameFillColor2List.size() > 0 )
1289 QDomElement fillColorElem = gridFrameFillColor2List.at( 0 ).toElement();
1290 int red = fillColorElem.attribute(
"red",
"0" ).toInt();
1291 int green = fillColorElem.attribute(
"green",
"0" ).toInt();
1292 int blue = fillColorElem.attribute(
"blue",
"0" ).toInt();
1293 int alpha = fillColorElem.attribute(
"alpha",
"255" ).toInt();
1303 QDomElement gridSymbolElem = gridElem.firstChildElement(
"symbol" );
1305 if ( gridSymbolElem.isNull( ) )
1311 gridElem.attribute(
"penColorGreen",
"0" ).toInt(),
1312 gridElem.attribute(
"penColorBlue",
"0" ).toInt() ) );
1319 QDomNodeList annotationNodeList = gridElem.elementsByTagName(
"Annotation" );
1320 if ( annotationNodeList.size() > 0 )
1322 QDomElement annotationElem = annotationNodeList.at( 0 ).toElement();
1337 QDomNodeList annotationFontColorList = annotationElem.elementsByTagName(
"fontColor" );
1338 if ( annotationFontColorList.size() > 0 )
1340 QDomElement fontColorElem = annotationFontColorList.at( 0 ).toElement();
1341 int red = fontColorElem.attribute(
"red",
"0" ).toInt();
1342 int green = fontColorElem.attribute(
"green",
"0" ).toInt();
1343 int blue = fontColorElem.attribute(
"blue",
"0" ).toInt();
1344 int alpha = fontColorElem.attribute(
"alpha",
"255" ).toInt();
1357 QDomNodeList atlasNodeList = itemElem.elementsByTagName(
"AtlasMap" );
1358 if ( atlasNodeList.size() > 0 )
1360 QDomElement atlasElem = atlasNodeList.at( 0 ).toElement();
1361 mAtlasDriven = ( atlasElem.attribute(
"atlasDriven",
"0" ) !=
"0" );
1362 if ( atlasElem.hasAttribute(
"fixedScale" ) )
1366 else if ( atlasElem.hasAttribute(
"scalingMode" ) )
1370 mAtlasMargin = atlasElem.attribute(
"margin",
"0.1" ).toDouble();
1374 QDomNodeList composerItemList = itemElem.elementsByTagName(
"ComposerItem" );
1375 if ( composerItemList.size() > 0 )
1377 QDomElement composerItemElem = composerItemList.at( 0 ).toElement();
1379 if ( composerItemElem.attribute(
"rotation",
"0" ).toDouble() != 0 )
1382 mMapRotation = composerItemElem.attribute(
"rotation",
"0" ).toDouble();
1406 QStringList currentLayerSet;
1416 for (
int i =
mLayerSet.size() - 1; i >= 0; --i )
1418 if ( !currentLayerSet.contains(
mLayerSet.at( i ) ) )
1427 QList< QPair< double, QLineF > > verticalLines;
1429 QList< QPair< double, QLineF > >::const_iterator vIt = verticalLines.constBegin();
1430 QList< QPair< double, QLineF > > horizontalLines;
1432 QList< QPair< double, QLineF > >::const_iterator hIt = horizontalLines.constBegin();
1434 QRectF thisPaintRect = QRectF( 0, 0, QGraphicsRectItem::rect().width(), QGraphicsRectItem::rect().height() );
1435 p->setClipRect( thisPaintRect );
1437 QPaintDevice* thePaintDevice = p->device();
1438 if ( !thePaintDevice )
1446 p->setRenderHint( QPainter::Antialiasing );
1449 double dotsPerMM = thePaintDevice->logicalDpiX() / 25.4;
1450 p->scale( 1 / dotsPerMM, 1 / dotsPerMM );
1455 ms.
setOutputSize( QSizeF( rect().width() * dotsPerMM, rect().height() * dotsPerMM ).toSize() );
1467 for ( ; vIt != verticalLines.constEnd(); ++vIt )
1469 line = QLineF( vIt->second.p1() * dotsPerMM, vIt->second.p2() * dotsPerMM ) ;
1473 for ( ; hIt != horizontalLines.constEnd(); ++hIt )
1475 line = QLineF( hIt->second.p1() * dotsPerMM, hIt->second.p2() * dotsPerMM ) ;
1481 QPointF intersectionPoint, crossEnd1, crossEnd2;
1482 for ( ; vIt != verticalLines.constEnd(); ++vIt )
1486 drawGridLine( QLineF( vIt->second.p1() * dotsPerMM, crossEnd1 * dotsPerMM ), context );
1489 hIt = horizontalLines.constBegin();
1490 for ( ; hIt != horizontalLines.constEnd(); ++hIt )
1492 if ( hIt->second.intersect( vIt->second, &intersectionPoint ) == QLineF::BoundedIntersection )
1496 drawGridLine( QLineF( crossEnd1 * dotsPerMM, crossEnd2 * dotsPerMM ), context );
1501 drawGridLine( QLineF( vIt->second.p2() * dotsPerMM, crossEnd2 * dotsPerMM ), context );
1504 hIt = horizontalLines.constBegin();
1505 for ( ; hIt != horizontalLines.constEnd(); ++hIt )
1509 drawGridLine( QLineF( hIt->second.p1() * dotsPerMM, crossEnd1 * dotsPerMM ), context );
1511 vIt = verticalLines.constBegin();
1512 for ( ; vIt != verticalLines.constEnd(); ++vIt )
1514 if ( vIt->second.intersect( hIt->second, &intersectionPoint ) == QLineF::BoundedIntersection )
1518 drawGridLine( QLineF( crossEnd1 * dotsPerMM, crossEnd2 * dotsPerMM ), context );
1523 drawGridLine( QLineF( hIt->second.p2() * dotsPerMM, crossEnd1 * dotsPerMM ), context );
1529 p->setClipRect( thisPaintRect , Qt::NoClip );
1546 QMap< double, double > leftGridFrame;
1547 QMap< double, double > rightGridFrame;
1548 QMap< double, double > topGridFrame;
1549 QMap< double, double > bottomGridFrame;
1571 poly << line.p1() << line.p2();
1586 QMap< double, double > pos = borderPos;
1588 if ( border ==
Left || border ==
Right )
1590 pos.insert( rect().height(), rect().height() );
1595 pos.insert( rect().width(), rect().width() );
1602 framePen.setJoinStyle( Qt::MiterJoin );
1603 p->setPen( framePen );
1605 QMap< double, double >::const_iterator posIt = pos.constBegin();
1606 for ( ; posIt != pos.constEnd(); ++posIt )
1609 if ( border ==
Left || border ==
Right )
1611 height = posIt.key() - currentCoord;
1619 width = posIt.key() - currentCoord;
1623 p->drawRect( QRectF( x, y, width, height ) );
1624 currentCoord = posIt.key();
1637 QString currentAnnotationString;
1638 QList< QPair< double, QLineF > >::const_iterator it = hLines.constBegin();
1639 for ( ; it != hLines.constEnd(); ++it )
1646 it = vLines.constBegin();
1647 for ( ; it != vLines.constEnd(); ++it )
1661 double xpos = pos.x();
1662 double ypos = pos.y();
1667 if ( frameBorder ==
Left )
1675 ypos += textWidth / 2.0;
1681 ypos += textHeight / 2.0;
1689 ypos += textWidth / 2.0;
1695 ypos += textHeight / 2.0;
1704 else if ( frameBorder ==
Right )
1711 ypos += textWidth / 2.0;
1717 ypos += textHeight / 2.0;
1725 ypos += textWidth / 2.0;
1731 ypos += textHeight / 2.0;
1739 else if ( frameBorder ==
Bottom )
1746 xpos -= textWidth / 2.0;
1750 xpos += textHeight / 2.0;
1760 xpos -= textWidth / 2.0;
1764 xpos += textHeight / 2.0;
1780 xpos -= textWidth / 2.0;
1785 xpos += textHeight / 2.0;
1794 xpos -= textWidth / 2.0;
1799 xpos += textHeight / 2.0;
1810 drawAnnotation( p, QPointF( xpos, ypos ), rotation, annotationString );
1816 p->translate( pos );
1817 p->rotate( rotation );
1834 QString annotationString;
1844 QStringList split = annotationString.split(
"," );
1847 return split.at( 0 );
1851 if ( split.size() < 2 )
1855 return split.at( 1 );
1869 QRectF mapBoundingRect = mapPolygon.boundingRect();
1872 double roundCorrection = mapBoundingRect.top() > 0 ? 1.0 : 0.0;
1879 double yCanvasCoord;
1881 while ( currentLevel <= mapBoundingRect.bottom() )
1883 yCanvasCoord = rect().height() * ( 1 - ( currentLevel - mapBoundingRect.top() ) / mapBoundingRect.height() );
1884 lines.push_back( qMakePair( currentLevel, QLineF( 0, yCanvasCoord, rect().width(), yCanvasCoord ) ) );
1890 QVector<QLineF> borderLines;
1891 borderLines << QLineF( mapPolygon.at( 0 ), mapPolygon.at( 1 ) );
1892 borderLines << QLineF( mapPolygon.at( 1 ), mapPolygon.at( 2 ) );
1893 borderLines << QLineF( mapPolygon.at( 2 ), mapPolygon.at( 3 ) );
1894 borderLines << QLineF( mapPolygon.at( 3 ), mapPolygon.at( 0 ) );
1896 QList<QPointF> intersectionList;
1898 while ( currentLevel <= mapBoundingRect.bottom() )
1900 intersectionList.clear();
1901 QLineF gridLine( mapBoundingRect.left(), currentLevel, mapBoundingRect.right(), currentLevel );
1903 QVector<QLineF>::const_iterator it = borderLines.constBegin();
1904 for ( ; it != borderLines.constEnd(); ++it )
1906 QPointF intersectionPoint;
1907 if ( it->intersect( gridLine, &intersectionPoint ) == QLineF::BoundedIntersection )
1909 intersectionList.push_back( intersectionPoint );
1910 if ( intersectionList.size() >= 2 )
1917 if ( intersectionList.size() >= 2 )
1919 lines.push_back( qMakePair( currentLevel, QLineF(
mapToItemCoords( intersectionList.at( 0 ) ),
mapToItemCoords( intersectionList.at( 1 ) ) ) ) );
1937 QRectF mapBoundingRect = mapPolygon.boundingRect();
1940 double roundCorrection = mapBoundingRect.left() > 0 ? 1.0 : 0.0;
1946 double xCanvasCoord;
1948 while ( currentLevel <= mapBoundingRect.right() )
1950 xCanvasCoord = rect().width() * ( currentLevel - mapBoundingRect.left() ) / mapBoundingRect.width();
1951 lines.push_back( qMakePair( currentLevel, QLineF( xCanvasCoord, 0, xCanvasCoord, rect().height() ) ) );
1957 QVector<QLineF> borderLines;
1958 borderLines << QLineF( mapPolygon.at( 0 ), mapPolygon.at( 1 ) );
1959 borderLines << QLineF( mapPolygon.at( 1 ), mapPolygon.at( 2 ) );
1960 borderLines << QLineF( mapPolygon.at( 2 ), mapPolygon.at( 3 ) );
1961 borderLines << QLineF( mapPolygon.at( 3 ), mapPolygon.at( 0 ) );
1963 QList<QPointF> intersectionList;
1965 while ( currentLevel <= mapBoundingRect.right() )
1967 intersectionList.clear();
1968 QLineF gridLine( currentLevel, mapBoundingRect.bottom(), currentLevel, mapBoundingRect.top() );
1970 QVector<QLineF>::const_iterator it = borderLines.constBegin();
1971 for ( ; it != borderLines.constEnd(); ++it )
1973 QPointF intersectionPoint;
1974 if ( it->intersect( gridLine, &intersectionPoint ) == QLineF::BoundedIntersection )
1976 intersectionList.push_back( intersectionPoint );
1977 if ( intersectionList.size() >= 2 )
1984 if ( intersectionList.size() >= 2 )
1986 lines.push_back( qMakePair( currentLevel, QLineF(
mapToItemCoords( intersectionList.at( 0 ) ),
mapToItemCoords( intersectionList.at( 1 ) ) ) ) );
2023 p.setCapStyle( Qt::FlatCap );
2041 QRectF rectangle = rect();
2043 rectangle.setLeft( rectangle.left() - extension );
2044 rectangle.setRight( rectangle.right() + extension );
2045 rectangle.setTop( rectangle.top() - extension );
2046 rectangle.setBottom( rectangle.bottom() + extension );
2049 prepareGeometryChange();
2080 poly.translate( -dx, -dy );
2086 double frameExtension =
mFrame ? pen().widthF() / 2.0 : 0.0;
2090 return frameExtension;
2093 QList< QPair< double, QLineF > > xLines;
2094 QList< QPair< double, QLineF > > yLines;
2099 if ( xGridReturn != 0 && yGridReturn != 0 )
2101 return frameExtension;
2105 double currentExtension = 0;
2106 QString currentAnnotationString;
2108 QList< QPair< double, QLineF > >::const_iterator it = xLines.constBegin();
2109 for ( ; it != xLines.constEnd(); ++it )
2113 maxExtension = qMax( maxExtension, currentExtension );
2116 it = yLines.constBegin();
2117 for ( ; it != yLines.constEnd(); ++it )
2121 maxExtension = qMax( maxExtension, currentExtension );
2146 dx = rotationPoint.
x() - extent.
xMinimum();
2147 dy = rotationPoint.
y() - extent.
yMaximum();
2149 poly << QPointF( rotationPoint.
x() - dx, rotationPoint.
y() - dy );
2152 dx = rotationPoint.
x() - extent.
xMaximum();
2153 dy = rotationPoint.
y() - extent.
yMaximum();
2155 poly << QPointF( rotationPoint.
x() - dx, rotationPoint.
y() - dy );
2158 dx = rotationPoint.
x() - extent.
xMaximum();
2159 dy = rotationPoint.
y() - extent.
yMinimum();
2161 poly << QPointF( rotationPoint.
x() - dx, rotationPoint.
y() - dy );
2164 dx = rotationPoint.
x() - extent.
xMinimum();
2165 dy = rotationPoint.
y() - extent.
yMinimum();
2167 poly << QPointF( rotationPoint.
x() - dx, rotationPoint.
y() - dy );
2188 QRectF bRect = poly.boundingRect();
2199 if ( extentWidth <= 0 )
2203 return rect().width() / extentWidth;
2288 double dxScaled = xShift * mmToMapUnits;
2289 double dyScaled = - yShift * mmToMapUnits;
2300 if ( mapPoly.size() < 1 )
2302 return QPointF( 0, 0 );
2307 double dx = mapCoords.x() - rotationPoint.
x();
2308 double dy = mapCoords.y() - rotationPoint.
y();
2310 QgsPoint backRotatedCoords( rotationPoint.
x() + dx, rotationPoint.
y() + dy );
2313 double xItem = rect().width() * ( backRotatedCoords.x() - unrotatedExtent.xMinimum() ) / unrotatedExtent.width();
2314 double yItem = rect().height() * ( 1 - ( backRotatedCoords.y() - unrotatedExtent.yMinimum() ) / unrotatedExtent.height() );
2315 return QPointF( xItem, yItem );
2320 if ( p.x() <= pen().widthF() )
2324 else if ( p.x() >= ( rect().width() - pen().widthF() ) )
2328 else if ( p.y() <= pen().widthF() )
2345 QList<QGraphicsItem*> itemList =
mMapCanvas->items();
2346 if ( itemList.size() < 1 )
2350 QGraphicsItem* currentItem = 0;
2352 for (
int i = itemList.size() - 1; i >= 0; --i )
2354 currentItem = itemList.at( i );
2356 if ( !currentItem || currentItem->data( 0 ).toString() !=
"AnnotationItem" )
2366 if ( !item || !
mMapCanvas || !item->isVisible() )
2374 double scaleFactor = 1.0 /
mMapCanvas->logicalDpiX() * 25.4;
2376 double itemX, itemY;
2377 QGraphicsItem* parent = item->parentItem();
2386 QPointF itemScenePos = item->scenePos();
2387 QPointF parentScenePos = parent->scenePos();
2391 itemX = mapPos.x() + ( itemScenePos.x() - parentScenePos.x() ) * scaleFactor;
2392 itemY = mapPos.y() + ( itemScenePos.y() - parentScenePos.y() ) * scaleFactor;
2394 painter->translate( itemX, itemY );
2397 painter->scale( scaleFactor, scaleFactor );
2400 item->setData( 1,
"composer" );
2401 item->paint( painter, itemStyle, 0 );
2402 item->setData( 1,
"" );
2410 return QPointF( 0, 0 );
2415 return QPointF( 0, 0 );
2418 QRectF graphicsSceneRect =
mMapCanvas->sceneRect();
2419 QPointF itemScenePos = item->scenePos();
2422 double mapX = itemScenePos.x() / graphicsSceneRect.
width() * mapRendererExtent.
width() + mapRendererExtent.
xMinimum();
2423 double mapY = mapRendererExtent.
yMaximum() - itemScenePos.y() / graphicsSceneRect.height() * mapRendererExtent.
height();
2515 QMap< double, double >& rightFrameEntries, QMap< double, double >& topFrameEntries, QMap< double, double >& bottomFrameEntries )
const
2517 QList< QPair< double, QPointF > > borderPositions;
2518 QList< QPair< double, QLineF > >::const_iterator it = hLines.constBegin();
2519 for ( ; it != hLines.constEnd(); ++it )
2521 borderPositions << qMakePair( it->first, it->second.p1() );
2522 borderPositions << qMakePair( it->first, it->second.p2() );
2524 it = vLines.constBegin();
2525 for ( ; it != vLines.constEnd(); ++it )
2527 borderPositions << qMakePair( it->first, it->second.p1() );
2528 borderPositions << qMakePair( it->first, it->second.p2() );
2531 QList< QPair< double, QPointF > >::const_iterator bIt = borderPositions.constBegin();
2532 for ( ; bIt != borderPositions.constEnd(); ++bIt )
2537 leftFrameEntries.insert( bIt->second.y(), bIt->first );
2541 rightFrameEntries.insert( bIt->second.y(), bIt->first );
2545 topFrameEntries.insert( bIt->second.x(), bIt->first );
2549 bottomFrameEntries.insert( bIt->second.x(), bIt->first );
2569 if ( !overviewFrameMap )
2580 QPolygonF intersectExtent = thisExtent.intersected( otherExtent );
2583 double dotsPerMM = p->device()->logicalDpiX() / 25.4;
2588 ms.
setOutputSize( QSizeF( rect().width() * dotsPerMM, rect().height() * dotsPerMM ).toSize() );
2598 p->scale( 1 / dotsPerMM, 1 / dotsPerMM );
2599 p->setRenderHint( QPainter::Antialiasing );
2605 QTransform mapTransform;
2606 QPolygonF thisRectPoly = QPolygonF( QRectF( 0, 0, dotsPerMM * rect().width(), dotsPerMM * rect().height() ) );
2609 thisRectPoly.pop_back();
2611 QTransform::quadToQuad( thisExtent, thisRectPoly, mapTransform );
2612 QPolygonF intersectPolygon;
2613 intersectPolygon = mapTransform.map( intersectExtent );
2615 QList<QPolygonF> rings;
2625 QPolygonF outerPolygon;
2626 outerPolygon << QPointF( 0, 0 ) << QPointF( rect().width() * dotsPerMM, 0 ) << QPointF( rect().width() * dotsPerMM, rect().height() * dotsPerMM ) << QPointF( 0, rect().height() * dotsPerMM ) << QPointF( 0, 0 );
2629 rings.append( intersectPolygon );
2641 properties.insert(
"color",
"255,0,0,255" );
2642 properties.insert(
"style",
"solid" );
2643 properties.insert(
"style_border",
"no" );
2652 properties.insert(
"color",
"0,0,0,255" );
2653 properties.insert(
"width",
"0.3" );
2654 properties.insert(
"capstyle",
"flat" );
2664 if ( format ==
"DM" && degreeUnits )
2668 else if ( format ==
"DMS" && degreeUnits )
2693 QList<const QgsComposerMap*>::const_iterator mapIt = mapList.constBegin();
2694 for ( ; mapIt != mapList.constEnd(); ++mapIt )
2696 if (( *mapIt )->id() > maxId )
2698 maxId = ( *mapIt )->id();
QString toDegreesMinutesSeconds(int thePrecision) const
Return a string representation as degrees minutes seconds.
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.
void setForceVectorOutput(bool force)
Added in QGIS v1.5.
void preparedForAtlas()
Is emitted when the map has been prepared for atlas rendering, just before actual rendering...
AtlasScalingMode
Scaling modes used for the serial rendering (atlas)
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 setDestinationCrs(const QgsCoordinateReferenceSystem &crs)
sets destination coordinate reference system
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)
bool mDrawing
set to true if in state of drawing.
Job implementation that renders everything sequentially using a custom painter.
double mGridIntervalY
Grid line interval in y-direction (map units)
double mMapRotation
Map rotation.
GridAnnotationDirection gridAnnotationDirection(QgsComposerMap::Border border) const
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
Returns true if the atlas is set to hide the coverage layer.
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) ...
Q_DECL_DEPRECATED QgsMapRenderer * mapRenderer()
Returns pointer to map renderer of qgis map canvas.
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 setOutputDpi(int dpi)
Set DPI used for conversion between real world units (e.g. mm) and pixels.
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.
void mapPolygon(const QgsRectangle &extent, QPolygonF &poly) const
mapPolygon variant using a given extent
const QgsMapSettings & mapSettings() const
Return setting of QGIS map canvas.
QPainter::CompositionMode bufferBlendMode
QStringList layerSet() const
Getter for stored layer set that is used if mKeepLayerSet is true.
double maxExtension() const
static QgsFillSymbolV2 * createSimple(const QgsStringMap &properties)
Create a fill symbol with one symbol layer: SimpleFill with specified properties. ...
void cache()
Create cache image.
Q_DECL_DEPRECATED 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.
#define Q_NOWARN_DEPRECATED_PUSH
Border
Enum for different frame borders.
QgsRectangle visibleExtent() const
Return the actual extent derived from requested extent that takes takes output image size into accoun...
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.
AtlasScalingMode mAtlasScalingMode
Current atlas scaling mode.
QGraphicsView * mMapCanvas
double mLastValidViewScaleFactor
Backup to restore item appearance if no view scale factor is available.
bool hasCrsTransformEnabled() const
returns true if projections are enabled for this layer set
void mapRotationChanged(double newRotation)
Is emitted on rotation change to notify north arrow pictures.
static QgsPalLayerSettings fromLayer(QgsVectorLayer *layer)
virtual void drawFrame(QPainter *p)
Draw black frame around item.
void updateCachedImage()
Called if map canvas has changed.
Flags flags() const
Return combination of flags used for rendering.
Q_DECL_DEPRECATED 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.
A non GUI class for rendering a map layer set onto a QPainter.
void setLayers(const QStringList &layers)
Set list of layer IDs for map rendering.
Enable layer transparency and blending effects.
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.
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
Vector graphics should not be cached and drawn as raster images.
QColor mGridFrameFillColor1
QColor mGridFramePenColor
void setFlag(Flag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected)
int mGridAnnotationPrecision
Digits after the dot.
The QgsMapSettings class contains configuration for rendering of the map.
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 bool staticWillUseLayer(QgsVectorLayer *layer)
called to find out whether the layer is used for labeling
static QDomElement saveSymbol(QString symbolName, QgsSymbolV2 *symbol, QDomDocument &doc)
Q_DECL_DEPRECATED const QgsMapRenderer * mapRenderer() const
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.
bool shouldDrawPart(PartType part) const
Test if a part of the copmosermap needs to be drawn, considering mCurrentExportLayer.
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.
double horizontalViewScaleFactor() const
Returns the zoom factor of the graphics view.
QRectF mCurrentRectangle
Current bounding rectangle.
double mCrossLength
The length of the cross sides for mGridStyle Cross.
double mGridFramePenThickness
QPainter::CompositionMode featureBlendMode() const
Read blend mode for layer.
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)
void startRender(QgsRenderContext &context, const QgsFields *fields=0)
virtual void drawSelectionBoxes(QPainter *p)
Draw selection boxes around item.
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 mFrame
True if item fram needs to be painted.
bool writeXML(QDomElement &elem, QDomDocument &doc) const
stores state in Dom node
Whether vector selections should be shown in the rendered map.
void setMapUnits(QGis::UnitType u)
Set units of map's geographical coordinates - used for scale calculation.
bool drawCanvasItems() const
void setCacheUpdated(bool u=false)
const QgsCoordinateReferenceSystem & destinationCrs() const
returns CRS of destination coordinate reference system
void setYMinimum(double y)
Set the minimum y value.
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)
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.
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry.
Q_DECL_DEPRECATED bool atlasFixedScale() const
Returns true if the map uses a fixed scale when in atlas mode.
QGis::UnitType mapUnits() const
Get units of map's geographical coordinates - used for scale calculation.
void drawText(QPainter *p, double x, double y, const QString &text, const QFont &font) const
Draws Text.
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 setOutputImageFormat(QImage::Format format)
sets format of internal QImage
void drawCanvasItem(QGraphicsItem *item, QPainter *painter, const QStyleOptionGraphicsItem *itemStyle)
Q_DECL_DEPRECATED 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
QPolygonF visibleExtentPolygon() const
Returns a polygon representing the current visible map extent, considering map extents and rotation...
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.
BlendMode
Blending modes enum defining the available composition modes that can be used when rendering a layer...
Enable drawing of vertex markers for layers in editing mode.
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.
QString qgsDoubleToString(const double &a, const int &precision=17)
PreviewMode previewMode() const
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.
#define Q_NOWARN_DEPRECATED_POP
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.
double mAtlasMargin
Margin size for atlas driven extents (percentage of feature size) - when in auto scaling mode...
void setBackgroundColor(const QColor &color)
Set the background color of the map.
void drawGridLine(const QLineF &line, QgsRenderContext &context)
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 setBackgroundColor(const QColor &backgroundColor)
Sets the background color for this item.
void setOverviewInverted(bool inverted)
Sets the overview's inversion mode.
Q_DECL_DEPRECATED double rotation() const
Returns the rotation used for drawing the map within the composer item.
bool _writeXML(QDomElement &itemElem, QDomDocument &doc) const
Writes parameter that are not subclass specific in document.
int mCurrentExportLayer
The layer that needs to be exported.
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 setOutputSize(const QSize &size)
Set the size of the resulting map image.
void setYMaximum(double y)
Set the maximum y value.
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings
virtual void drawBackground(QPainter *p)
Draw background.
bool mUpdatesEnabled
Whether updates to the map are enabled.
bool hasFrame() const
Whether this item has a frame or not.
QImage::Format outputImageFormat() const
format of internal QImage, default QImage::Format_ARGB32_Premultiplied
static QgsProject * instance()
access to canonical QgsProject instance
void setExtent(const QgsRectangle &rect)
Set coordinates of the rectangle which should be rendered.
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
Q_DECL_DEPRECATED void setAtlasFixedScale(bool fixed)
Set to true if the map should use a fixed scale when in atlas mode.
void resize(double dx, double dy)
resizes an item in x- and y direction (canvas coordinates)
QStringList layers() const
Get list of layer IDs for map rendering The layers are stored in the reverse order of how they are re...
QgsAtlasComposition & atlasComposition()
QgsMapLayer * mapLayer(QString theLayerId)
Retrieve a pointer to a loaded layer by id.
Enable vector simplification and other rendering optimizations.
QPainter::CompositionMode shadowBlendMode
static QgsSymbolV2 * loadSymbol(QDomElement &element)
QgsRasterDataProvider * dataProvider()
Returns the data provider.
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
Returns the coverage layer used for the atlas features.
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...
Represents a vector layer which manages a vector based data sets.
const QgsComposerMap * getComposerMapById(int id) const
Returns the composer map with specified id.
void setFlags(Flags flags)
Set combination of flags that will be used for rendering.
double xMinimum() const
Get the x minimum value (left side of rectangle)
PreviewMode mPreviewMode
Preview style.
Q_DECL_DEPRECATED void setRotation(double r)
Sets rotation for the map - this does not affect the composer item shape, only the way the map is dra...
QgsPoint center() const
Center point of the rectangle.
void renderSynchronously()
Render the map synchronously in this thread.
void setAlpha(qreal alpha)
Set alpha transparency 1 for opaque, 0 for invisible.
QPainter::CompositionMode mGridBlendMode
Blend mode for grid.
QStringList layersToRender() const
Returns a list of the layers to render for this map item.
int numberExportLayers() const
Get the number of layers that this item requires for exporting as layers.
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.
void setCrsTransformEnabled(bool enabled)
sets whether to use projections for this layer set
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)