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 )
130 setToolTip(
tr(
"Map %1" ).arg(
mId ) );
137 double itemWidthHeightRatio = itemWidth / itemHeight;
138 double newWidthHeightRatio = extent.
width() / extent.
height();
140 if ( itemWidthHeightRatio <= newWidthHeightRatio )
143 double newHeight = extent.
width() / itemWidthHeightRatio;
144 double deltaHeight = newHeight - extent.
height();
151 double newWidth = itemWidthHeightRatio * extent.
height();
152 double deltaWidth = newWidth - extent.
width();
168 Q_UNUSED( forceWidthScale );
174 if ( size.width() == 0 || size.height() == 0 )
197 ( layerIdx >= 0 && layerIdx < theLayerSet.length() )
198 ? QStringList( theLayerSet[ theLayerSet.length() - layerIdx - 1 ] )
249 if ( horizontalVScaleFactor < 0 )
258 int w = widthMM * horizontalVScaleFactor;
259 int h = heightMM * horizontalVScaleFactor;
271 mCacheImage = QImage( w, h, QImage::Format_ARGB32 );
274 mCacheImage.setDotsPerMeterX( 1000 * w / widthMM );
275 mCacheImage.setDotsPerMeterY( 1000 * h / heightMM );
286 mCacheImage.fill( QColor( 255, 255, 255, 0 ).rgba() );
307 QRectF thisPaintRect = QRectF( 0, 0, QGraphicsRectItem::rect().width(), QGraphicsRectItem::rect().height() );
309 painter->setClipRect( thisPaintRect );
315 QFont messageFont(
"", 12 );
316 painter->setFont( messageFont );
317 painter->setPen( QColor( 0, 0, 0, 125 ) );
318 painter->drawText( thisPaintRect,
tr(
"Map will be printed here" ) );
335 double scale = rect().width() / imagePixelWidth;
349 painter->translate( xTopLeftShift, yTopLeftShift );
351 painter->translate( xShiftMM, -yShiftMM );
352 painter->scale( scale, scale );
370 QPaintDevice* thePaintDevice = painter->device();
371 if ( !thePaintDevice )
400 painter->translate( xTopLeftShift, yTopLeftShift );
402 painter->translate( xShiftMM, -yShiftMM );
404 double dotsPerMM = thePaintDevice->logicalDpiX() / 25.4;
405 theSize *= dotsPerMM;
406 painter->scale( 1 / dotsPerMM, 1 / dotsPerMM );
407 draw( painter, requestRectangle, theSize, thePaintDevice->logicalDpiX() );
418 painter->setClipRect( thisPaintRect , Qt::NoClip );
448 + ( isSelected() ? 1 : 0 )
511 QGraphicsRectItem::update();
537 QStringList renderLayerSet;
555 if ( removeAt != -1 )
557 renderLayerSet.removeAt( removeAt );
562 return renderLayerSet;
569 calculator.
setDpi( 25.4 );
576 QRectF currentRect = rect();
577 QRectF newSceneRect = QRectF( pos().x(), pos().y(), currentRect.width() + dx, currentRect.height() + dy );
609 int zoomMode = settings.value(
"/qgis/wheel_action", 2 ).toInt();
615 double zoomFactor = settings.value(
"/qgis/zoom_factor", 2.0 ).toDouble();
631 else if ( zoomMode == 2 )
633 centerX = mapMouseX + ( centerX - mapMouseX ) * ( 1.0 / zoomFactor );
634 centerY = mapMouseY + ( centerY - mapMouseY ) * ( 1.0 / zoomFactor );
638 double newIntervalX, newIntervalY;
645 else if ( delta < 0 )
667 calculator.
setDpi( 25.4 );
680 double w = rectangle.width();
681 double h = rectangle.height();
706 QRectF currentRect = rect();
708 double newHeight = currentRect.width() * extent.
height() / extent.
width();
710 setSceneRect( QRectF( pos().x(), pos().y(), currentRect.width(), newHeight ) );
726 double currentWidthHeightRatio = rect().
width() / rect().height();
727 double newWidthHeightRatio = newExtent.
width() / newExtent.
height();
729 if ( currentWidthHeightRatio < newWidthHeightRatio )
732 double newHeight = newExtent.
width() / currentWidthHeightRatio;
733 double deltaHeight = newHeight - newExtent.
height();
737 else if ( currentWidthHeightRatio >= newWidthHeightRatio )
740 double newWidth = currentWidthHeightRatio * newExtent.
height();
741 double deltaWidth = newWidth - newExtent.
width();
797 double currentScaleDenominator =
scale();
799 if ( scaleDenominator == currentScaleDenominator || scaleDenominator == 0 )
804 double scaleRatio = scaleDenominator / currentScaleDenominator;
814 calculator.
setDpi( 25.4 );
815 scaleRatio = scaleDenominator / calculator.
calculate(
mExtent, rect().width() );
870 QStringList::const_iterator layer_it = layers.constBegin();
873 for ( ; layer_it != layers.constEnd(); ++layer_it )
879 if ( currentRasterLayer )
882 if (( rasterProvider = currentRasterLayer->
dataProvider() ) )
884 if ( rasterProvider->
name() ==
"wms" )
901 QStringList::const_iterator layer_it = layers.constBegin();
904 for ( ; layer_it != layers.constEnd(); ++layer_it )
909 if ( currentLayer->
blendMode() != QPainter::CompositionMode_SourceOver )
915 if ( currentVectorLayer )
921 if ( currentVectorLayer->
featureBlendMode() != QPainter::CompositionMode_SourceOver )
930 if (( layerSettings.
blendMode != QPainter::CompositionMode_SourceOver ) ||
951 connect( layerRegistry, SIGNAL( layerWillBeRemoved( QString ) ),
this, SLOT(
updateCachedImage() ) );
963 QDomElement composerMapElem = doc.createElement(
"ComposerMap" );
964 composerMapElem.setAttribute(
"id",
mId );
969 composerMapElem.setAttribute(
"previewMode",
"Cache" );
973 composerMapElem.setAttribute(
"previewMode",
"Render" );
977 composerMapElem.setAttribute(
"previewMode",
"Rectangle" );
982 composerMapElem.setAttribute(
"keepLayerSet",
"true" );
986 composerMapElem.setAttribute(
"keepLayerSet",
"false" );
991 composerMapElem.setAttribute(
"drawCanvasItems",
"true" );
995 composerMapElem.setAttribute(
"drawCanvasItems",
"false" );
999 QDomElement overviewFrameElem = doc.createElement(
"overviewFrame" );
1004 overviewFrameElem.setAttribute(
"overviewInverted",
"true" );
1008 overviewFrameElem.setAttribute(
"overviewInverted",
"false" );
1011 overviewFrameElem.setAttribute(
"overviewCentered",
mOverviewCentered ?
"true" :
"false" );
1014 overviewFrameElem.appendChild( overviewFrameStyleElem );
1015 composerMapElem.appendChild( overviewFrameElem );
1019 QDomElement extentElem = doc.createElement(
"Extent" );
1024 composerMapElem.appendChild( extentElem );
1027 composerMapElem.setAttribute(
"mapRotation", QString::number(
mMapRotation ) );
1030 QDomElement layerSetElem = doc.createElement(
"LayerSet" );
1031 QStringList::const_iterator layerIt =
mLayerSet.constBegin();
1032 for ( ; layerIt !=
mLayerSet.constEnd(); ++layerIt )
1034 QDomElement layerElem = doc.createElement(
"Layer" );
1035 QDomText layerIdText = doc.createTextNode( *layerIt );
1036 layerElem.appendChild( layerIdText );
1037 layerSetElem.appendChild( layerElem );
1039 composerMapElem.appendChild( layerSetElem );
1045 QDomElement gridElem = doc.createElement(
"Grid" );
1047 gridElem.setAttribute(
"gridStyle",
mGridStyle );
1057 QDomElement framePenColorElem = doc.createElement(
"framePenColor" );
1062 gridElem.appendChild( framePenColorElem );
1064 QDomElement frameFillColor1Elem = doc.createElement(
"frameFillColor1" );
1069 gridElem.appendChild( frameFillColor1Elem );
1070 QDomElement frameFillColor2Elem = doc.createElement(
"frameFillColor2" );
1075 gridElem.appendChild( frameFillColor2Elem );
1079 gridElem.appendChild( gridLineStyleElem );
1082 QDomElement annotationElem = doc.createElement(
"Annotation" );
1097 QDomElement annotationFontColorElem = doc.createElement(
"fontColor" );
1102 annotationElem.appendChild( annotationFontColorElem );
1104 gridElem.appendChild( annotationElem );
1105 composerMapElem.appendChild( gridElem );
1108 QDomElement atlasElem = doc.createElement(
"AtlasMap" );
1112 composerMapElem.appendChild( atlasElem );
1114 elem.appendChild( composerMapElem );
1115 return _writeXML( composerMapElem, doc );
1120 if ( itemElem.isNull() )
1125 QString idRead = itemElem.attribute(
"id",
"not found" );
1126 if ( idRead !=
"not found" )
1128 mId = idRead.toInt();
1133 QString
previewMode = itemElem.attribute(
"previewMode" );
1134 if ( previewMode ==
"Cache" )
1138 else if ( previewMode ==
"Render" )
1147 QDomElement overviewFrameElem = itemElem.firstChildElement(
"overviewFrame" );
1148 if ( !overviewFrameElem.isNull() )
1153 QString overviewInvertedFlag = overviewFrameElem.attribute(
"overviewInverted" );
1154 if ( overviewInvertedFlag.compare(
"true", Qt::CaseInsensitive ) == 0 )
1163 if ( overviewFrameElem.attribute(
"overviewCentered" ).compare(
"true", Qt::CaseInsensitive ) == 0 )
1172 QDomElement overviewFrameSymbolElem = overviewFrameElem.firstChildElement(
"symbol" );
1173 if ( !overviewFrameSymbolElem.isNull() )
1181 QDomNodeList extentNodeList = itemElem.elementsByTagName(
"Extent" );
1182 if ( extentNodeList.size() > 0 )
1184 QDomElement extentElem = extentNodeList.at( 0 ).toElement();
1185 double xmin, xmax, ymin, ymax;
1186 xmin = extentElem.attribute(
"xmin" ).toDouble();
1187 xmax = extentElem.attribute(
"xmax" ).toDouble();
1188 ymin = extentElem.attribute(
"ymin" ).toDouble();
1189 ymax = extentElem.attribute(
"ymax" ).toDouble();
1194 if ( itemElem.attribute(
"mapRotation",
"0" ).toDouble() != 0 )
1196 mMapRotation = itemElem.attribute(
"mapRotation",
"0" ).toDouble();
1200 QString keepLayerSetFlag = itemElem.attribute(
"keepLayerSet" );
1201 if ( keepLayerSetFlag.compare(
"true", Qt::CaseInsensitive ) == 0 )
1210 QString drawCanvasItemsFlag = itemElem.attribute(
"drawCanvasItems",
"true" );
1211 if ( drawCanvasItemsFlag.compare(
"true", Qt::CaseInsensitive ) == 0 )
1221 QDomNodeList layerSetNodeList = itemElem.elementsByTagName(
"LayerSet" );
1223 if ( layerSetNodeList.size() > 0 )
1225 QDomElement layerSetElem = layerSetNodeList.at( 0 ).toElement();
1226 QDomNodeList layerIdNodeList = layerSetElem.elementsByTagName(
"Layer" );
1227 for (
int i = 0; i < layerIdNodeList.size(); ++i )
1229 layerSet << layerIdNodeList.at( i ).toElement().text();
1239 QDomNodeList gridNodeList = itemElem.elementsByTagName(
"Grid" );
1240 if ( gridNodeList.size() > 0 )
1242 QDomElement gridElem = gridNodeList.at( 0 ).toElement();
1243 mGridEnabled = ( gridElem.attribute(
"show",
"0" ) !=
"0" );
1245 mGridIntervalX = gridElem.attribute(
"intervalX",
"0" ).toDouble();
1246 mGridIntervalY = gridElem.attribute(
"intervalY",
"0" ).toDouble();
1247 mGridOffsetX = gridElem.attribute(
"offsetX",
"0" ).toDouble();
1248 mGridOffsetY = gridElem.attribute(
"offsetY",
"0" ).toDouble();
1249 mCrossLength = gridElem.attribute(
"crossLength",
"3" ).toDouble();
1251 mGridFrameWidth = gridElem.attribute(
"gridFrameWidth",
"2.0" ).toDouble();
1255 QDomNodeList gridFramePenColorList = gridElem.elementsByTagName(
"framePenColor" );
1256 if ( gridFramePenColorList.size() > 0 )
1258 QDomElement penColorElem = gridFramePenColorList.at( 0 ).toElement();
1259 int red = penColorElem.attribute(
"red",
"0" ).toInt();
1260 int green = penColorElem.attribute(
"green",
"0" ).toInt();
1261 int blue = penColorElem.attribute(
"blue",
"0" ).toInt();
1262 int alpha = penColorElem.attribute(
"alpha",
"255" ).toInt();
1270 QDomNodeList gridFrameFillColor1List = gridElem.elementsByTagName(
"frameFillColor1" );
1271 if ( gridFrameFillColor1List.size() > 0 )
1273 QDomElement fillColorElem = gridFrameFillColor1List.at( 0 ).toElement();
1274 int red = fillColorElem.attribute(
"red",
"0" ).toInt();
1275 int green = fillColorElem.attribute(
"green",
"0" ).toInt();
1276 int blue = fillColorElem.attribute(
"blue",
"0" ).toInt();
1277 int alpha = fillColorElem.attribute(
"alpha",
"255" ).toInt();
1285 QDomNodeList gridFrameFillColor2List = gridElem.elementsByTagName(
"frameFillColor2" );
1286 if ( gridFrameFillColor2List.size() > 0 )
1288 QDomElement fillColorElem = gridFrameFillColor2List.at( 0 ).toElement();
1289 int red = fillColorElem.attribute(
"red",
"0" ).toInt();
1290 int green = fillColorElem.attribute(
"green",
"0" ).toInt();
1291 int blue = fillColorElem.attribute(
"blue",
"0" ).toInt();
1292 int alpha = fillColorElem.attribute(
"alpha",
"255" ).toInt();
1302 QDomElement gridSymbolElem = gridElem.firstChildElement(
"symbol" );
1304 if ( gridSymbolElem.isNull( ) )
1310 gridElem.attribute(
"penColorGreen",
"0" ).toInt(),
1311 gridElem.attribute(
"penColorBlue",
"0" ).toInt() ) );
1318 QDomNodeList annotationNodeList = gridElem.elementsByTagName(
"Annotation" );
1319 if ( annotationNodeList.size() > 0 )
1321 QDomElement annotationElem = annotationNodeList.at( 0 ).toElement();
1336 QDomNodeList annotationFontColorList = annotationElem.elementsByTagName(
"fontColor" );
1337 if ( annotationFontColorList.size() > 0 )
1339 QDomElement fontColorElem = annotationFontColorList.at( 0 ).toElement();
1340 int red = fontColorElem.attribute(
"red",
"0" ).toInt();
1341 int green = fontColorElem.attribute(
"green",
"0" ).toInt();
1342 int blue = fontColorElem.attribute(
"blue",
"0" ).toInt();
1343 int alpha = fontColorElem.attribute(
"alpha",
"255" ).toInt();
1356 QDomNodeList atlasNodeList = itemElem.elementsByTagName(
"AtlasMap" );
1357 if ( atlasNodeList.size() > 0 )
1359 QDomElement atlasElem = atlasNodeList.at( 0 ).toElement();
1360 mAtlasDriven = ( atlasElem.attribute(
"atlasDriven",
"0" ) !=
"0" );
1361 if ( atlasElem.hasAttribute(
"fixedScale" ) )
1365 else if ( atlasElem.hasAttribute(
"scalingMode" ) )
1369 mAtlasMargin = atlasElem.attribute(
"margin",
"0.1" ).toDouble();
1373 QDomNodeList composerItemList = itemElem.elementsByTagName(
"ComposerItem" );
1374 if ( composerItemList.size() > 0 )
1376 QDomElement composerItemElem = composerItemList.at( 0 ).toElement();
1378 if ( composerItemElem.attribute(
"rotation",
"0" ).toDouble() != 0 )
1381 mMapRotation = composerItemElem.attribute(
"rotation",
"0" ).toDouble();
1405 QStringList currentLayerSet;
1415 for (
int i =
mLayerSet.size() - 1; i >= 0; --i )
1417 if ( !currentLayerSet.contains(
mLayerSet.at( i ) ) )
1426 QList< QPair< double, QLineF > > verticalLines;
1428 QList< QPair< double, QLineF > >::const_iterator vIt = verticalLines.constBegin();
1429 QList< QPair< double, QLineF > > horizontalLines;
1431 QList< QPair< double, QLineF > >::const_iterator hIt = horizontalLines.constBegin();
1433 QRectF thisPaintRect = QRectF( 0, 0, QGraphicsRectItem::rect().width(), QGraphicsRectItem::rect().height() );
1434 p->setClipRect( thisPaintRect );
1436 QPaintDevice* thePaintDevice = p->device();
1437 if ( !thePaintDevice )
1445 p->setRenderHint( QPainter::Antialiasing );
1448 double dotsPerMM = thePaintDevice->logicalDpiX() / 25.4;
1449 p->scale( 1 / dotsPerMM, 1 / dotsPerMM );
1454 ms.
setOutputSize( QSizeF( rect().width() * dotsPerMM, rect().height() * dotsPerMM ).toSize() );
1466 for ( ; vIt != verticalLines.constEnd(); ++vIt )
1468 line = QLineF( vIt->second.p1() * dotsPerMM, vIt->second.p2() * dotsPerMM ) ;
1472 for ( ; hIt != horizontalLines.constEnd(); ++hIt )
1474 line = QLineF( hIt->second.p1() * dotsPerMM, hIt->second.p2() * dotsPerMM ) ;
1480 QPointF intersectionPoint, crossEnd1, crossEnd2;
1481 for ( ; vIt != verticalLines.constEnd(); ++vIt )
1485 drawGridLine( QLineF( vIt->second.p1() * dotsPerMM, crossEnd1 * dotsPerMM ), context );
1488 hIt = horizontalLines.constBegin();
1489 for ( ; hIt != horizontalLines.constEnd(); ++hIt )
1491 if ( hIt->second.intersect( vIt->second, &intersectionPoint ) == QLineF::BoundedIntersection )
1495 drawGridLine( QLineF( crossEnd1 * dotsPerMM, crossEnd2 * dotsPerMM ), context );
1500 drawGridLine( QLineF( vIt->second.p2() * dotsPerMM, crossEnd2 * dotsPerMM ), context );
1503 hIt = horizontalLines.constBegin();
1504 for ( ; hIt != horizontalLines.constEnd(); ++hIt )
1508 drawGridLine( QLineF( hIt->second.p1() * dotsPerMM, crossEnd1 * dotsPerMM ), context );
1510 vIt = verticalLines.constBegin();
1511 for ( ; vIt != verticalLines.constEnd(); ++vIt )
1513 if ( vIt->second.intersect( hIt->second, &intersectionPoint ) == QLineF::BoundedIntersection )
1517 drawGridLine( QLineF( crossEnd1 * dotsPerMM, crossEnd2 * dotsPerMM ), context );
1522 drawGridLine( QLineF( hIt->second.p2() * dotsPerMM, crossEnd1 * dotsPerMM ), context );
1528 p->setClipRect( thisPaintRect , Qt::NoClip );
1545 QMap< double, double > leftGridFrame;
1546 QMap< double, double > rightGridFrame;
1547 QMap< double, double > topGridFrame;
1548 QMap< double, double > bottomGridFrame;
1570 poly << line.p1() << line.p2();
1585 QMap< double, double > pos = borderPos;
1587 if ( border ==
Left || border ==
Right )
1589 pos.insert( rect().height(), rect().height() );
1594 pos.insert( rect().width(), rect().width() );
1601 framePen.setJoinStyle( Qt::MiterJoin );
1602 p->setPen( framePen );
1604 QMap< double, double >::const_iterator posIt = pos.constBegin();
1605 for ( ; posIt != pos.constEnd(); ++posIt )
1608 if ( border ==
Left || border ==
Right )
1610 height = posIt.key() - currentCoord;
1618 width = posIt.key() - currentCoord;
1622 p->drawRect( QRectF( x, y, width, height ) );
1623 currentCoord = posIt.key();
1636 QString currentAnnotationString;
1637 QList< QPair< double, QLineF > >::const_iterator it = hLines.constBegin();
1638 for ( ; it != hLines.constEnd(); ++it )
1645 it = vLines.constBegin();
1646 for ( ; it != vLines.constEnd(); ++it )
1660 double xpos = pos.x();
1661 double ypos = pos.y();
1666 if ( frameBorder ==
Left )
1674 ypos += textWidth / 2.0;
1680 ypos += textHeight / 2.0;
1688 ypos += textWidth / 2.0;
1694 ypos += textHeight / 2.0;
1703 else if ( frameBorder ==
Right )
1710 ypos += textWidth / 2.0;
1716 ypos += textHeight / 2.0;
1724 ypos += textWidth / 2.0;
1730 ypos += textHeight / 2.0;
1738 else if ( frameBorder ==
Bottom )
1745 xpos -= textWidth / 2.0;
1749 xpos += textHeight / 2.0;
1759 xpos -= textWidth / 2.0;
1763 xpos += textHeight / 2.0;
1779 xpos -= textWidth / 2.0;
1784 xpos += textHeight / 2.0;
1793 xpos -= textWidth / 2.0;
1798 xpos += textHeight / 2.0;
1809 drawAnnotation( p, QPointF( xpos, ypos ), rotation, annotationString );
1815 p->translate( pos );
1816 p->rotate( rotation );
1833 QString annotationString;
1843 QStringList split = annotationString.split(
"," );
1846 return split.at( 0 );
1850 if ( split.size() < 2 )
1854 return split.at( 1 );
1868 QRectF mapBoundingRect = mapPolygon.boundingRect();
1871 double roundCorrection = mapBoundingRect.top() > 0 ? 1.0 : 0.0;
1878 double yCanvasCoord;
1880 while ( currentLevel <= mapBoundingRect.bottom() )
1882 yCanvasCoord = rect().height() * ( 1 - ( currentLevel - mapBoundingRect.top() ) / mapBoundingRect.height() );
1883 lines.push_back( qMakePair( currentLevel, QLineF( 0, yCanvasCoord, rect().width(), yCanvasCoord ) ) );
1889 QVector<QLineF> borderLines;
1890 borderLines << QLineF( mapPolygon.at( 0 ), mapPolygon.at( 1 ) );
1891 borderLines << QLineF( mapPolygon.at( 1 ), mapPolygon.at( 2 ) );
1892 borderLines << QLineF( mapPolygon.at( 2 ), mapPolygon.at( 3 ) );
1893 borderLines << QLineF( mapPolygon.at( 3 ), mapPolygon.at( 0 ) );
1895 QList<QPointF> intersectionList;
1897 while ( currentLevel <= mapBoundingRect.bottom() )
1899 intersectionList.clear();
1900 QLineF gridLine( mapBoundingRect.left(), currentLevel, mapBoundingRect.right(), currentLevel );
1902 QVector<QLineF>::const_iterator it = borderLines.constBegin();
1903 for ( ; it != borderLines.constEnd(); ++it )
1905 QPointF intersectionPoint;
1906 if ( it->intersect( gridLine, &intersectionPoint ) == QLineF::BoundedIntersection )
1908 intersectionList.push_back( intersectionPoint );
1909 if ( intersectionList.size() >= 2 )
1916 if ( intersectionList.size() >= 2 )
1918 lines.push_back( qMakePair( currentLevel, QLineF(
mapToItemCoords( intersectionList.at( 0 ) ),
mapToItemCoords( intersectionList.at( 1 ) ) ) ) );
1936 QRectF mapBoundingRect = mapPolygon.boundingRect();
1939 double roundCorrection = mapBoundingRect.left() > 0 ? 1.0 : 0.0;
1945 double xCanvasCoord;
1947 while ( currentLevel <= mapBoundingRect.right() )
1949 xCanvasCoord = rect().width() * ( currentLevel - mapBoundingRect.left() ) / mapBoundingRect.width();
1950 lines.push_back( qMakePair( currentLevel, QLineF( xCanvasCoord, 0, xCanvasCoord, rect().height() ) ) );
1956 QVector<QLineF> borderLines;
1957 borderLines << QLineF( mapPolygon.at( 0 ), mapPolygon.at( 1 ) );
1958 borderLines << QLineF( mapPolygon.at( 1 ), mapPolygon.at( 2 ) );
1959 borderLines << QLineF( mapPolygon.at( 2 ), mapPolygon.at( 3 ) );
1960 borderLines << QLineF( mapPolygon.at( 3 ), mapPolygon.at( 0 ) );
1962 QList<QPointF> intersectionList;
1964 while ( currentLevel <= mapBoundingRect.right() )
1966 intersectionList.clear();
1967 QLineF gridLine( currentLevel, mapBoundingRect.bottom(), currentLevel, mapBoundingRect.top() );
1969 QVector<QLineF>::const_iterator it = borderLines.constBegin();
1970 for ( ; it != borderLines.constEnd(); ++it )
1972 QPointF intersectionPoint;
1973 if ( it->intersect( gridLine, &intersectionPoint ) == QLineF::BoundedIntersection )
1975 intersectionList.push_back( intersectionPoint );
1976 if ( intersectionList.size() >= 2 )
1983 if ( intersectionList.size() >= 2 )
1985 lines.push_back( qMakePair( currentLevel, QLineF(
mapToItemCoords( intersectionList.at( 0 ) ),
mapToItemCoords( intersectionList.at( 1 ) ) ) ) );
2022 p.setCapStyle( Qt::FlatCap );
2040 QRectF rectangle = rect();
2042 rectangle.setLeft( rectangle.left() - extension );
2043 rectangle.setRight( rectangle.right() + extension );
2044 rectangle.setTop( rectangle.top() - extension );
2045 rectangle.setBottom( rectangle.bottom() + extension );
2048 prepareGeometryChange();
2079 poly.translate( -dx, -dy );
2085 double frameExtension =
mFrame ? pen().widthF() / 2.0 : 0.0;
2089 return frameExtension;
2092 QList< QPair< double, QLineF > > xLines;
2093 QList< QPair< double, QLineF > > yLines;
2098 if ( xGridReturn != 0 && yGridReturn != 0 )
2100 return frameExtension;
2104 double currentExtension = 0;
2105 QString currentAnnotationString;
2107 QList< QPair< double, QLineF > >::const_iterator it = xLines.constBegin();
2108 for ( ; it != xLines.constEnd(); ++it )
2112 maxExtension = qMax( maxExtension, currentExtension );
2115 it = yLines.constBegin();
2116 for ( ; it != yLines.constEnd(); ++it )
2120 maxExtension = qMax( maxExtension, currentExtension );
2145 dx = rotationPoint.
x() - extent.
xMinimum();
2146 dy = rotationPoint.
y() - extent.
yMaximum();
2148 poly << QPointF( rotationPoint.
x() - dx, rotationPoint.
y() - dy );
2151 dx = rotationPoint.
x() - extent.
xMaximum();
2152 dy = rotationPoint.
y() - extent.
yMaximum();
2154 poly << QPointF( rotationPoint.
x() - dx, rotationPoint.
y() - dy );
2157 dx = rotationPoint.
x() - extent.
xMaximum();
2158 dy = rotationPoint.
y() - extent.
yMinimum();
2160 poly << QPointF( rotationPoint.
x() - dx, rotationPoint.
y() - dy );
2163 dx = rotationPoint.
x() - extent.
xMinimum();
2164 dy = rotationPoint.
y() - extent.
yMinimum();
2166 poly << QPointF( rotationPoint.
x() - dx, rotationPoint.
y() - dy );
2187 QRectF bRect = poly.boundingRect();
2198 if ( extentWidth <= 0 )
2202 return rect().width() / extentWidth;
2287 double dxScaled = xShift * mmToMapUnits;
2288 double dyScaled = - yShift * mmToMapUnits;
2299 if ( mapPoly.size() < 1 )
2301 return QPointF( 0, 0 );
2306 double dx = mapCoords.x() - rotationPoint.
x();
2307 double dy = mapCoords.y() - rotationPoint.
y();
2309 QgsPoint backRotatedCoords( rotationPoint.
x() + dx, rotationPoint.
y() + dy );
2312 double xItem = rect().width() * ( backRotatedCoords.x() - unrotatedExtent.xMinimum() ) / unrotatedExtent.width();
2313 double yItem = rect().height() * ( 1 - ( backRotatedCoords.y() - unrotatedExtent.yMinimum() ) / unrotatedExtent.height() );
2314 return QPointF( xItem, yItem );
2319 if ( p.x() <= pen().widthF() )
2323 else if ( p.x() >= ( rect().width() - pen().widthF() ) )
2327 else if ( p.y() <= pen().widthF() )
2344 QList<QGraphicsItem*> itemList =
mMapCanvas->items();
2345 if ( itemList.size() < 1 )
2349 QGraphicsItem* currentItem = 0;
2351 for (
int i = itemList.size() - 1; i >= 0; --i )
2353 currentItem = itemList.at( i );
2355 if ( !currentItem || currentItem->data( 0 ).toString() !=
"AnnotationItem" )
2365 if ( !item || !
mMapCanvas || !item->isVisible() )
2373 double scaleFactor = 1.0 /
mMapCanvas->logicalDpiX() * 25.4;
2375 double itemX, itemY;
2376 QGraphicsItem* parent = item->parentItem();
2385 QPointF itemScenePos = item->scenePos();
2386 QPointF parentScenePos = parent->scenePos();
2390 itemX = mapPos.x() + ( itemScenePos.x() - parentScenePos.x() ) * scaleFactor;
2391 itemY = mapPos.y() + ( itemScenePos.y() - parentScenePos.y() ) * scaleFactor;
2393 painter->translate( itemX, itemY );
2396 painter->scale( scaleFactor, scaleFactor );
2399 item->setData( 1,
"composer" );
2400 item->paint( painter, itemStyle, 0 );
2401 item->setData( 1,
"" );
2409 return QPointF( 0, 0 );
2414 return QPointF( 0, 0 );
2417 QRectF graphicsSceneRect =
mMapCanvas->sceneRect();
2418 QPointF itemScenePos = item->scenePos();
2421 double mapX = itemScenePos.x() / graphicsSceneRect.
width() * mapRendererExtent.
width() + mapRendererExtent.
xMinimum();
2422 double mapY = mapRendererExtent.
yMaximum() - itemScenePos.y() / graphicsSceneRect.height() * mapRendererExtent.
height();
2514 QMap< double, double >& rightFrameEntries, QMap< double, double >& topFrameEntries, QMap< double, double >& bottomFrameEntries )
const
2516 QList< QPair< double, QPointF > > borderPositions;
2517 QList< QPair< double, QLineF > >::const_iterator it = hLines.constBegin();
2518 for ( ; it != hLines.constEnd(); ++it )
2520 borderPositions << qMakePair( it->first, it->second.p1() );
2521 borderPositions << qMakePair( it->first, it->second.p2() );
2523 it = vLines.constBegin();
2524 for ( ; it != vLines.constEnd(); ++it )
2526 borderPositions << qMakePair( it->first, it->second.p1() );
2527 borderPositions << qMakePair( it->first, it->second.p2() );
2530 QList< QPair< double, QPointF > >::const_iterator bIt = borderPositions.constBegin();
2531 for ( ; bIt != borderPositions.constEnd(); ++bIt )
2536 leftFrameEntries.insert( bIt->second.y(), bIt->first );
2540 rightFrameEntries.insert( bIt->second.y(), bIt->first );
2544 topFrameEntries.insert( bIt->second.x(), bIt->first );
2548 bottomFrameEntries.insert( bIt->second.x(), bIt->first );
2568 if ( !overviewFrameMap )
2579 QPolygonF intersectExtent = thisExtent.intersected( otherExtent );
2582 double dotsPerMM = p->device()->logicalDpiX() / 25.4;
2587 ms.
setOutputSize( QSizeF( rect().width() * dotsPerMM, rect().height() * dotsPerMM ).toSize() );
2597 p->scale( 1 / dotsPerMM, 1 / dotsPerMM );
2598 p->setRenderHint( QPainter::Antialiasing );
2604 QTransform mapTransform;
2605 QPolygonF thisRectPoly = QPolygonF( QRectF( 0, 0, dotsPerMM * rect().width(), dotsPerMM * rect().height() ) );
2608 thisRectPoly.pop_back();
2610 QTransform::quadToQuad( thisExtent, thisRectPoly, mapTransform );
2611 QPolygonF intersectPolygon;
2612 intersectPolygon = mapTransform.map( intersectExtent );
2614 QList<QPolygonF> rings;
2624 QPolygonF outerPolygon;
2625 outerPolygon << QPointF( 0, 0 ) << QPointF( rect().width() * dotsPerMM, 0 ) << QPointF( rect().width() * dotsPerMM, rect().height() * dotsPerMM ) << QPointF( 0, rect().height() * dotsPerMM ) << QPointF( 0, 0 );
2628 rings.append( intersectPolygon );
2640 properties.insert(
"color",
"255,0,0,255" );
2641 properties.insert(
"style",
"solid" );
2642 properties.insert(
"style_border",
"no" );
2651 properties.insert(
"color",
"0,0,0,255" );
2652 properties.insert(
"width",
"0.3" );
2653 properties.insert(
"capstyle",
"flat" );
2663 if ( format ==
"DM" && degreeUnits )
2667 else if ( format ==
"DMS" && degreeUnits )
2692 QList<const QgsComposerMap*>::const_iterator mapIt = mapList.constBegin();
2693 for ( ; mapIt != mapList.constEnd(); ++mapIt )
2695 if (( *mapIt )->id() > maxId )
2697 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
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.
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.
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
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.
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.
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)