35 #include <QStyleOptionGraphicsItem> 40 mBackgroundUpdateTimer =
new QTimer(
this );
41 mBackgroundUpdateTimer->setSingleShot(
true );
42 connect( mBackgroundUpdateTimer, &QTimer::timeout,
this, &QgsLayoutItemMap::recreateCachedImageInBackground );
46 setCacheMode( QGraphicsItem::NoCache );
53 mGridStack = qgis::make_unique< QgsLayoutItemMapGridStack >( this );
54 mOverviewStack = qgis::make_unique< QgsLayoutItemMapOverviewStack >( this );
65 mPainterJob->cancel();
90 QList<QgsLayoutItemMap *> mapsList;
91 mLayout->layoutItems( mapsList );
100 if ( map->mMapId == mMapId )
103 maxId = std::max( maxId, map->mMapId );
108 mLayout->itemsModel()->updateItemDisplayName(
this );
120 return tr(
"Map %1" ).arg( mMapId );
132 mCachedLayerStyleOverridesPresetName.clear();
136 updateAtlasFeature();
141 if ( rect().isEmpty() )
146 calculator.
setDpi( 25.4 );
153 double currentScaleDenominator =
scale();
160 double scaleRatio = scaleDenominator / currentScaleDenominator;
161 mExtent.
scale( scaleRatio );
163 if ( mAtlasDriven && mAtlasScalingMode ==
Fixed )
170 calculator.
setDpi( 25.4 );
171 scaleRatio = scaleDenominator / calculator.
calculate( mExtent, rect().width() );
172 mExtent.
scale( scaleRatio );
186 if ( mExtent == extent )
196 QRectF currentRect = rect();
198 double newHeight = currentRect.width() * mExtent.
height() / mExtent.
width();
210 double currentWidthHeightRatio = 1.0;
211 if ( !currentExtent.
isNull() )
212 currentWidthHeightRatio = currentExtent.
width() / currentExtent.
height();
214 currentWidthHeightRatio = rect().width() / rect().height();
215 double newWidthHeightRatio = newExtent.
width() / newExtent.
height();
217 if ( currentWidthHeightRatio < newWidthHeightRatio )
220 double newHeight = newExtent.
width() / currentWidthHeightRatio;
221 double deltaHeight = newHeight - newExtent.
height();
228 double newWidth = currentWidthHeightRatio * newExtent.
height();
229 double deltaWidth = newWidth - newExtent.
width();
234 if ( mExtent == newExtent )
256 mapPolygon( mExtent, poly );
265 return mLayout->project()->crs();
276 return _qgis_listRefToRaw( mLayers );
281 mLayers = _qgis_listRawToRef( layers );
286 if ( overrides == mLayerStyleOverrides )
289 mLayerStyleOverrides = overrides;
296 mLayerStyleOverrides.clear();
297 for (
const QgsMapLayerRef &layerRef : qgis::as_const( mLayers ) )
303 mLayerStyleOverrides.insert( layer->id(), style.
xmlData() );
310 mLastRenderedImageOffsetX -= dx;
311 mLastRenderedImageOffsetY -= dy;
314 transformShift( dx, dy );
338 double mapY = mExtent.
yMinimum() + ( 1 - ( point.y() / rect().height() ) ) * ( mExtent.
yMaximum() - mExtent.
yMinimum() );
344 centerX = mapX + ( centerX - mapX ) * ( 1.0 / factor );
345 centerY = mapY + ( centerY - mapY ) * ( 1.0 / factor );
347 double newIntervalX, newIntervalY;
364 if ( mAtlasDriven && mAtlasScalingMode ==
Fixed )
371 calculator.
setDpi( 25.4 );
372 double scaleRatio =
scale() / calculator.
calculate( mExtent, rect().width() );
373 mExtent.
scale( scaleRatio );
389 if ( layer->dataProvider() && layer->dataProvider()->name() == QLatin1String(
"wms" ) )
425 if ( mOverviewStack->containsAdvancedEffects() )
431 if ( mGridStack->containsAdvancedEffects() )
443 mMapRotation = rotation;
444 mEvaluatedMapRotation = mMapRotation;
458 mAtlasDriven = enabled;
475 double margin = mAtlasMargin;
483 margin = ddMargin / 100;
495 if ( mGridStack->size() < 1 )
498 mGridStack->addGrid( grid );
500 return mGridStack->grid( 0 );
505 if ( mOverviewStack->size() < 1 )
508 mOverviewStack->addOverview( overview );
510 return mOverviewStack->overview( 0 );
521 mapElem.setAttribute( QStringLiteral(
"keepLayerSet" ), QStringLiteral(
"true" ) );
525 mapElem.setAttribute( QStringLiteral(
"keepLayerSet" ), QStringLiteral(
"false" ) );
528 if ( mDrawAnnotations )
530 mapElem.setAttribute( QStringLiteral(
"drawCanvasItems" ), QStringLiteral(
"true" ) );
534 mapElem.setAttribute( QStringLiteral(
"drawCanvasItems" ), QStringLiteral(
"false" ) );
538 QDomElement extentElem = doc.createElement( QStringLiteral(
"Extent" ) );
543 mapElem.appendChild( extentElem );
547 QDomElement crsElem = doc.createElement( QStringLiteral(
"crs" ) );
549 mapElem.appendChild( crsElem );
553 mapElem.setAttribute( QStringLiteral(
"followPreset" ), mFollowVisibilityPreset ? QStringLiteral(
"true" ) : QStringLiteral(
"false" ) );
554 mapElem.setAttribute( QStringLiteral(
"followPresetName" ), mFollowVisibilityPresetName );
557 mapElem.setAttribute( QStringLiteral(
"mapRotation" ), QString::number( mMapRotation ) );
560 QDomElement layerSetElem = doc.createElement( QStringLiteral(
"LayerSet" ) );
565 QDomElement layerElem = doc.createElement( QStringLiteral(
"Layer" ) );
566 QDomText layerIdText = doc.createTextNode( layerRef.layerId );
567 layerElem.appendChild( layerIdText );
569 layerElem.setAttribute( QStringLiteral(
"name" ), layerRef.name );
570 layerElem.setAttribute( QStringLiteral(
"source" ), layerRef.source );
571 layerElem.setAttribute( QStringLiteral(
"provider" ), layerRef.provider );
573 layerSetElem.appendChild( layerElem );
575 mapElem.appendChild( layerSetElem );
578 if ( mKeepLayerStyles )
580 QDomElement stylesElem = doc.createElement( QStringLiteral(
"LayerStyles" ) );
581 for (
auto styleIt = mLayerStyleOverrides.constBegin(); styleIt != mLayerStyleOverrides.constEnd(); ++styleIt )
583 QDomElement styleElem = doc.createElement( QStringLiteral(
"LayerStyle" ) );
588 styleElem.setAttribute( QStringLiteral(
"layerid" ), ref.layerId );
589 styleElem.setAttribute( QStringLiteral(
"name" ), ref.name );
590 styleElem.setAttribute( QStringLiteral(
"source" ), ref.source );
591 styleElem.setAttribute( QStringLiteral(
"provider" ), ref.provider );
595 stylesElem.appendChild( styleElem );
597 mapElem.appendChild( stylesElem );
601 mGridStack->writeXml( mapElem, doc, context );
604 mOverviewStack->writeXml( mapElem, doc, context );
607 QDomElement atlasElem = doc.createElement( QStringLiteral(
"AtlasMap" ) );
608 atlasElem.setAttribute( QStringLiteral(
"atlasDriven" ), mAtlasDriven );
609 atlasElem.setAttribute( QStringLiteral(
"scalingMode" ), mAtlasScalingMode );
610 atlasElem.setAttribute( QStringLiteral(
"margin" ),
qgsDoubleToString( mAtlasMargin ) );
611 mapElem.appendChild( atlasElem );
618 mUpdatesEnabled =
false;
621 QDomNodeList extentNodeList = itemElem.elementsByTagName( QStringLiteral(
"Extent" ) );
622 if ( !extentNodeList.isEmpty() )
624 QDomElement extentElem = extentNodeList.at( 0 ).toElement();
625 double xmin, xmax, ymin, ymax;
626 xmin = extentElem.attribute( QStringLiteral(
"xmin" ) ).toDouble();
627 xmax = extentElem.attribute( QStringLiteral(
"xmax" ) ).toDouble();
628 ymin = extentElem.attribute( QStringLiteral(
"ymin" ) ).toDouble();
629 ymax = extentElem.attribute( QStringLiteral(
"ymax" ) ).toDouble();
633 QDomNodeList crsNodeList = itemElem.elementsByTagName( QStringLiteral(
"crs" ) );
634 if ( !crsNodeList.isEmpty() )
636 QDomElement crsElem = crsNodeList.at( 0 ).toElement();
645 mMapRotation = itemElem.attribute( QStringLiteral(
"mapRotation" ), QStringLiteral(
"0" ) ).toDouble();
648 mFollowVisibilityPreset = itemElem.attribute( QStringLiteral(
"followPreset" ) ).compare( QLatin1String(
"true" ) ) == 0;
649 mFollowVisibilityPresetName = itemElem.attribute( QStringLiteral(
"followPresetName" ) );
652 QString keepLayerSetFlag = itemElem.attribute( QStringLiteral(
"keepLayerSet" ) );
653 if ( keepLayerSetFlag.compare( QLatin1String(
"true" ), Qt::CaseInsensitive ) == 0 )
655 mKeepLayerSet =
true;
659 mKeepLayerSet =
false;
662 QString drawCanvasItemsFlag = itemElem.attribute( QStringLiteral(
"drawCanvasItems" ), QStringLiteral(
"true" ) );
663 if ( drawCanvasItemsFlag.compare( QLatin1String(
"true" ), Qt::CaseInsensitive ) == 0 )
665 mDrawAnnotations =
true;
669 mDrawAnnotations =
false;
672 mLayerStyleOverrides.clear();
676 QDomNodeList layerSetNodeList = itemElem.elementsByTagName( QStringLiteral(
"LayerSet" ) );
677 if ( !layerSetNodeList.isEmpty() )
679 QDomElement layerSetElem = layerSetNodeList.at( 0 ).toElement();
680 QDomNodeList layerIdNodeList = layerSetElem.elementsByTagName( QStringLiteral(
"Layer" ) );
681 mLayers.reserve( layerIdNodeList.size() );
682 for (
int i = 0; i < layerIdNodeList.size(); ++i )
684 QDomElement layerElem = layerIdNodeList.at( i ).toElement();
685 QString layerId = layerElem.text();
686 QString layerName = layerElem.attribute( QStringLiteral(
"name" ) );
687 QString layerSource = layerElem.attribute( QStringLiteral(
"source" ) );
688 QString layerProvider = layerElem.attribute( QStringLiteral(
"provider" ) );
690 QgsMapLayerRef ref( layerId, layerName, layerSource, layerProvider );
697 QDomNodeList layerStylesNodeList = itemElem.elementsByTagName( QStringLiteral(
"LayerStyles" ) );
698 mKeepLayerStyles = !layerStylesNodeList.isEmpty();
699 if ( mKeepLayerStyles )
701 QDomElement layerStylesElem = layerStylesNodeList.at( 0 ).toElement();
702 QDomNodeList layerStyleNodeList = layerStylesElem.elementsByTagName( QStringLiteral(
"LayerStyle" ) );
703 for (
int i = 0; i < layerStyleNodeList.size(); ++i )
705 const QDomElement &layerStyleElement = layerStyleNodeList.at( i ).toElement();
706 QString layerId = layerStyleElement.attribute( QStringLiteral(
"layerid" ) );
707 QString layerName = layerStyleElement.attribute( QStringLiteral(
"name" ) );
708 QString layerSource = layerStyleElement.attribute( QStringLiteral(
"source" ) );
709 QString layerProvider = layerStyleElement.attribute( QStringLiteral(
"provider" ) );
710 QgsMapLayerRef ref( layerId, layerName, layerSource, layerProvider );
714 style.
readXml( layerStyleElement );
720 mNumCachedLayers = 0;
721 mCacheInvalidated =
true;
724 mOverviewStack->readXml( itemElem, doc, context );
727 mGridStack->readXml( itemElem, doc, context );
730 QDomNodeList atlasNodeList = itemElem.elementsByTagName( QStringLiteral(
"AtlasMap" ) );
731 if ( !atlasNodeList.isEmpty() )
733 QDomElement atlasElem = atlasNodeList.at( 0 ).toElement();
734 mAtlasDriven = ( atlasElem.attribute( QStringLiteral(
"atlasDriven" ), QStringLiteral(
"0" ) ) != QLatin1String(
"0" ) );
735 if ( atlasElem.hasAttribute( QStringLiteral(
"fixedScale" ) ) )
737 mAtlasScalingMode = ( atlasElem.attribute( QStringLiteral(
"fixedScale" ), QStringLiteral(
"0" ) ) != QLatin1String(
"0" ) ) ?
Fixed :
Auto;
739 else if ( atlasElem.hasAttribute( QStringLiteral(
"scalingMode" ) ) )
741 mAtlasScalingMode =
static_cast<AtlasScalingMode>( atlasElem.attribute( QStringLiteral(
"scalingMode" ) ).toInt() );
743 mAtlasMargin = atlasElem.attribute( QStringLiteral(
"margin" ), QStringLiteral(
"0.1" ) ).toDouble();
748 mUpdatesEnabled =
true;
754 if ( !
mLayout || !painter || !painter->device() || !mUpdatesEnabled )
763 QRectF thisPaintRect = rect();
769 if (
mLayout->renderContext().isPreviewRender() )
772 painter->setClipRect( thisPaintRect );
773 if ( !mCacheFinalImage || mCacheFinalImage->isNull() )
776 painter->setBrush( QBrush( QColor( 125, 125, 125, 125 ) ) );
777 painter->drawRect( thisPaintRect );
778 painter->setBrush( Qt::NoBrush );
780 messageFont.setPointSize( 12 );
781 painter->setFont( messageFont );
782 painter->setPen( QColor( 255, 255, 255, 255 ) );
783 painter->drawText( thisPaintRect, Qt::AlignCenter | Qt::AlignHCenter, tr(
"Rendering map" ) );
784 if ( mPainterJob && mCacheInvalidated && !mDrawingPreview )
788 mBackgroundUpdateTimer->start( 1 );
790 else if ( !mPainterJob && !mDrawingPreview )
794 mBackgroundUpdateTimer->start( 1 );
799 if ( mCacheInvalidated && !mDrawingPreview )
803 mBackgroundUpdateTimer->start( 1 );
808 double imagePixelWidth = mCacheFinalImage->width();
809 double scale = rect().width() / imagePixelWidth;
813 painter->translate( mLastRenderedImageOffsetX + mXOffset, mLastRenderedImageOffsetY + mYOffset );
814 painter->scale( scale, scale );
815 painter->drawImage( 0, 0, *mCacheFinalImage );
821 painter->setClipRect( thisPaintRect, Qt::NoClip );
823 if ( shouldDrawPart( OverviewMapExtent ) )
825 mOverviewStack->drawItems( painter );
827 if ( shouldDrawPart( Grid ) )
829 mGridStack->drawItems( painter );
832 if ( shouldDrawPart( Frame ) )
834 drawMapFrame( painter );
844 QPaintDevice *paintDevice = painter->device();
856 int widthInPixels =
static_cast< int >( std::round(
boundingRect().width() * layoutUnitsInInches * destinationDpi ) );
857 int heightInPixels =
static_cast< int >( std::round(
boundingRect().height() * layoutUnitsInInches * destinationDpi ) );
858 QImage image = QImage( widthInPixels, heightInPixels, QImage::Format_ARGB32 );
860 image.fill( Qt::transparent );
861 image.setDotsPerMeterX( static_cast< int >( std::round( 1000 * destinationDpi / 25.4 ) ) );
862 image.setDotsPerMeterY( static_cast< int >( std::round( 1000 * destinationDpi / 25.4 ) ) );
863 double dotsPerMM = destinationDpi / 25.4;
864 QPainter p( &image );
867 QRect imagePaintRect( static_cast< int >( std::round( tl.x() * dotsPerMM ) ),
868 static_cast< int >( std::round( tl.y() * dotsPerMM ) ),
869 static_cast< int >( std::round( thisPaintRect.width() * dotsPerMM ) ),
870 static_cast< int >( std::round( thisPaintRect.height() * dotsPerMM ) ) );
871 p.setClipRect( imagePaintRect );
873 p.translate( imagePaintRect.topLeft() );
877 if ( shouldDrawPart( Background ) )
879 p.scale( dotsPerMM, dotsPerMM );
880 drawMapBackground( &p );
881 p.scale( 1.0 / dotsPerMM, 1.0 / dotsPerMM );
884 drawMap( &p, cExtent, imagePaintRect.size(), image.logicalDpiX() );
889 p.scale( dotsPerMM, dotsPerMM );
891 if ( shouldDrawPart( OverviewMapExtent ) )
893 mOverviewStack->drawItems( &p );
895 if ( shouldDrawPart( Grid ) )
897 mGridStack->drawItems( &p );
902 painter->scale( 1 / dotsPerMM, 1 / dotsPerMM );
903 painter->drawImage( QPointF( -tl.x()* dotsPerMM, -tl.y() * dotsPerMM ), image );
904 painter->scale( dotsPerMM, dotsPerMM );
910 if ( shouldDrawPart( Background ) )
912 drawMapBackground( painter );
916 painter->setClipRect( thisPaintRect );
918 painter->translate( mXOffset, mYOffset );
920 double dotsPerMM = paintDevice->logicalDpiX() / 25.4;
922 painter->scale( 1 / dotsPerMM, 1 / dotsPerMM );
923 drawMap( painter, cExtent, size, paintDevice->logicalDpiX() );
927 painter->setClipRect( thisPaintRect, Qt::NoClip );
929 if ( shouldDrawPart( OverviewMapExtent ) )
931 mOverviewStack->drawItems( painter );
933 if ( shouldDrawPart( Grid ) )
935 mGridStack->drawItems( painter );
941 if ( shouldDrawPart( Frame ) )
943 drawMapFrame( painter );
964 void QgsLayoutItemMap::drawMap( QPainter *painter,
const QgsRectangle &
extent, QSizeF size,
double dpi )
984 void QgsLayoutItemMap::recreateCachedImageInBackground()
990 QPainter *oldPainter = mPainter.release();
991 QImage *oldImage = mCacheRenderingImage.release();
994 oldJob->deleteLater();
998 oldJob->cancelWithoutBlocking();
1002 mCacheRenderingImage.reset(
nullptr );
1005 Q_ASSERT( !mPainterJob );
1006 Q_ASSERT( !mPainter );
1007 Q_ASSERT( !mCacheRenderingImage );
1013 int w =
static_cast< int >( std::round( widthLayoutUnits * mPreviewScaleFactor ) );
1014 int h =
static_cast< int >( std::round( heightLayoutUnits * mPreviewScaleFactor ) );
1017 if ( w > 5000 || h > 5000 )
1022 h =
static_cast< int>( std::round( w * heightLayoutUnits / widthLayoutUnits ) );
1027 w =
static_cast< int >( std::round( h * widthLayoutUnits / heightLayoutUnits ) );
1031 if ( w <= 0 || h <= 0 )
1034 mCacheRenderingImage.reset(
new QImage( w, h, QImage::Format_ARGB32 ) );
1037 mCacheRenderingImage->setDotsPerMeterX( static_cast< int >( std::round( 1000 * w / widthLayoutUnits ) ) );
1038 mCacheRenderingImage->setDotsPerMeterY( static_cast< int >( std::round( 1000 * h / heightLayoutUnits ) ) );
1049 mCacheRenderingImage->fill( QColor( 255, 255, 255, 0 ).rgba() );
1052 mCacheInvalidated =
false;
1053 mPainter.reset(
new QPainter( mCacheRenderingImage.get() ) );
1057 mPainterJob->start();
1069 mDrawingPreview =
false;
1083 jobMapSettings.
setRotation( mEvaluatedMapRotation );
1087 if ( includeLayerSettings )
1091 if (
mLayout && -1 !=
mLayout->renderContext().currentExportLayer() )
1093 const int layerIdx =
mLayout->renderContext().currentExportLayer() - (
hasBackground() ? 1 : 0 );
1094 if ( layerIdx >= 0 && layerIdx < layers.length() )
1097 QgsMapLayer *ml = layers[ layers.length() - layerIdx - 1 ];
1111 if ( !
mLayout->renderContext().isPreviewRender() )
1133 return jobMapSettings;
1140 mOverviewStack->finalizeRestoreFromXml();
1141 mGridStack->finalizeRestoreFromXml();
1152 return mCurrentRectangle;
1180 QVariantList layersIds;
1190 const QList<QgsMapLayer *> layersInMap =
layersToRender( &context );
1192 layersIds.reserve( layersInMap.count() );
1193 layers.reserve( layersInMap.count() );
1196 layersIds << layer->id();
1202 scope->
addFunction( QStringLiteral(
"is_layer_visible" ),
new QgsExpressionContextUtils::GetLayerVisibility( layersInMap ) );
1210 if ( extentWidth <= 0 )
1214 return rect().width() / extentWidth;
1219 double dx = mXOffset;
1220 double dy = mYOffset;
1221 transformShift( dx, dy );
1223 poly.translate( -dx, -dy );
1230 if ( mapPoly.empty() )
1232 return QPointF( 0, 0 );
1237 double dx = mapCoords.x() - rotationPoint.
x();
1238 double dy = mapCoords.y() - rotationPoint.
y();
1240 QgsPointXY backRotatedCoords( rotationPoint.
x() + dx, rotationPoint.
y() + dy );
1243 double xItem = rect().width() * ( backRotatedCoords.x() - unrotatedExtent.xMinimum() ) / unrotatedExtent.width();
1244 double yItem = rect().height() * ( 1 - ( backRotatedCoords.y() - unrotatedExtent.yMinimum() ) / unrotatedExtent.height() );
1245 return QPointF( xItem, yItem );
1259 mapPolygon( newExtent, poly );
1260 QRectF bRect = poly.boundingRect();
1274 mCacheInvalidated =
true;
1280 QRectF rectangle = rect();
1281 double frameExtension =
frameEnabled() ? pen().widthF() / 2.0 : 0.0;
1283 double topExtension = 0.0;
1284 double rightExtension = 0.0;
1285 double bottomExtension = 0.0;
1286 double leftExtension = 0.0;
1289 mGridStack->calculateMaxGridExtension( topExtension, rightExtension, bottomExtension, leftExtension );
1291 topExtension = std::max( topExtension, frameExtension );
1292 rightExtension = std::max( rightExtension, frameExtension );
1293 bottomExtension = std::max( bottomExtension, frameExtension );
1294 leftExtension = std::max( leftExtension, frameExtension );
1296 rectangle.setLeft( rectangle.left() - leftExtension );
1297 rectangle.setRight( rectangle.right() + rightExtension );
1298 rectangle.setTop( rectangle.top() - topExtension );
1299 rectangle.setBottom( rectangle.bottom() + bottomExtension );
1300 if ( rectangle != mCurrentRectangle )
1302 prepareGeometryChange();
1303 mCurrentRectangle = rectangle;
1319 refreshMapExtents( &context );
1321 if ( mExtent != beforeExtent )
1328 mCacheInvalidated =
true;
1333 void QgsLayoutItemMap::layersAboutToBeRemoved(
const QList<QgsMapLayer *> &
layers )
1335 if ( !mLayers.isEmpty() || mLayerStyleOverrides.isEmpty() )
1339 mLayerStyleOverrides.remove( layer->id() );
1341 _qgis_removeLayers( mLayers, layers );
1345 void QgsLayoutItemMap::painterJobFinished()
1348 mPainterJob.reset(
nullptr );
1349 mPainter.reset(
nullptr );
1350 mCacheFinalImage = std::move( mCacheRenderingImage );
1351 mLastRenderedImageOffsetX = 0;
1352 mLastRenderedImageOffsetY = 0;
1356 void QgsLayoutItemMap::shapeChanged()
1361 double w = rect().width();
1362 double h = rect().height();
1365 double newWidth = mExtent.
width();
1367 double newHeight = newWidth * h / w;
1372 refreshMapExtents();
1379 void QgsLayoutItemMap::mapThemeChanged(
const QString &theme )
1381 if ( theme == mCachedLayerStyleOverridesPresetName )
1382 mCachedLayerStyleOverridesPresetName.clear();
1385 void QgsLayoutItemMap::connectUpdateSlot()
1393 this, &QgsLayoutItemMap::layersAboutToBeRemoved );
1397 if (
layers().isEmpty() )
1419 void QgsLayoutItemMap::updateToolTip()
1431 QList<QgsMapLayer *> renderLayers;
1433 if ( mFollowVisibilityPreset )
1435 QString presetName = mFollowVisibilityPresetName;
1440 if (
mLayout->project()->mapThemeCollection()->hasMapTheme( presetName ) )
1441 renderLayers =
mLayout->project()->mapThemeCollection()->mapThemeVisibleLayers( presetName );
1443 renderLayers =
mLayout->project()->mapThemeCollection()->masterVisibleLayers();
1445 else if ( !
layers().isEmpty() )
1451 renderLayers =
mLayout->project()->mapThemeCollection()->masterVisibleLayers();
1458 renderLayers.clear();
1460 const QStringList layerNames = ddLayers.split(
'|' );
1462 for (
const QString &name : layerNames )
1464 const QList< QgsMapLayer * > matchingLayers =
mLayout->project()->mapLayersByName( name );
1467 renderLayers << layer;
1476 int removeAt = renderLayers.indexOf(
mLayout->reportContext().layer() );
1477 if ( removeAt != -1 )
1479 renderLayers.removeAt( removeAt );
1483 return renderLayers;
1486 QMap<QString, QString> QgsLayoutItemMap::layerStyleOverridesToRender(
const QgsExpressionContext &context )
const 1488 if ( mFollowVisibilityPreset )
1490 QString presetName = mFollowVisibilityPresetName;
1495 if (
mLayout->project()->mapThemeCollection()->hasMapTheme( presetName ) )
1497 if ( presetName.isEmpty() || presetName != mCachedLayerStyleOverridesPresetName )
1500 mCachedPresetLayerStyleOverrides =
mLayout->project()->mapThemeCollection()->mapThemeStyleOverrides( presetName );
1501 mCachedLayerStyleOverridesPresetName = presetName;
1504 return mCachedPresetLayerStyleOverrides;
1507 return QMap<QString, QString>();
1509 else if ( mKeepLayerStyles )
1511 return mLayerStyleOverrides;
1515 return QMap<QString, QString>();
1519 QgsRectangle QgsLayoutItemMap::transformedExtent()
const 1521 double dx = mXOffset;
1522 double dy = mYOffset;
1523 transformShift( dx, dy );
1527 void QgsLayoutItemMap::mapPolygon(
const QgsRectangle &extent, QPolygonF &poly )
const 1537 poly << QPointF( poly.at( 0 ) );
1546 dx = rotationPoint.
x() - extent.
xMinimum();
1547 dy = rotationPoint.
y() - extent.
yMaximum();
1549 poly << QPointF( rotationPoint.
x() - dx, rotationPoint.
y() - dy );
1552 dx = rotationPoint.
x() - extent.
xMaximum();
1553 dy = rotationPoint.
y() - extent.
yMaximum();
1555 poly << QPointF( rotationPoint.
x() - dx, rotationPoint.
y() - dy );
1558 dx = rotationPoint.
x() - extent.
xMaximum();
1559 dy = rotationPoint.
y() - extent.
yMinimum();
1561 poly << QPointF( rotationPoint.
x() - dx, rotationPoint.
y() - dy );
1564 dx = rotationPoint.
x() - extent.
xMinimum();
1565 dy = rotationPoint.
y() - extent.
yMinimum();
1567 poly << QPointF( rotationPoint.
x() - dx, rotationPoint.
y() - dy );
1570 poly << QPointF( poly.at( 0 ) );
1573 void QgsLayoutItemMap::transformShift(
double &xShift,
double &yShift )
const 1576 double dxScaled = xShift * mmToMapUnits;
1577 double dyScaled = - yShift * mmToMapUnits;
1592 const QList< QgsAnnotation * > annotations =
mLayout->project()->annotationManager()->annotations();
1593 if ( annotations.isEmpty() )
1603 if ( !annotation || !annotation->isVisible() )
1607 if ( annotation->mapLayer() && !layers.contains( annotation->mapLayer() ) )
1610 drawAnnotation( annotation, rc );
1624 double itemX, itemY;
1627 QPointF mapPos = layoutMapPosForItem( annotation );
1636 context.
painter()->translate( itemX, itemY );
1639 double dotsPerMM = context.
painter()->device()->logicalDpiX() / 25.4;
1640 context.
painter()->scale( 1 / dotsPerMM, 1 / dotsPerMM );
1642 annotation->
render( context );
1646 QPointF QgsLayoutItemMap::layoutMapPosForItem(
const QgsAnnotation *annotation )
const 1649 return QPointF( 0, 0 );
1658 if ( annotationCrs !=
crs() )
1675 void QgsLayoutItemMap::drawMapFrame( QPainter *p )
1681 p->setBrush( Qt::NoBrush );
1682 p->setRenderHint( QPainter::Antialiasing,
true );
1683 p->drawRect( QRectF( 0, 0, rect().width(), rect().height() ) );
1688 void QgsLayoutItemMap::drawMapBackground( QPainter *p )
1693 p->setBrush( brush() );
1694 p->setPen( Qt::NoPen );
1695 p->setRenderHint( QPainter::Antialiasing,
true );
1696 p->drawRect( QRectF( 0, 0, rect().width(), rect().height() ) );
1701 bool QgsLayoutItemMap::shouldDrawPart( QgsLayoutItemMap::PartType part )
const 1703 int currentExportLayer =
mLayout->renderContext().currentExportLayer();
1705 if ( -1 == currentExportLayer )
1715 if ( SelectionBoxes == part )
1717 return currentExportLayer == idx;
1724 if ( Frame == part )
1726 return currentExportLayer == idx;
1730 if ( OverviewMapExtent == part )
1732 return currentExportLayer == idx;
1737 return currentExportLayer == idx;
1741 if ( Background == part )
1743 return currentExportLayer == 0;
1759 bool useDdXMin =
false;
1760 bool useDdXMax =
false;
1761 bool useDdYMin =
false;
1762 bool useDdYMax =
false;
1794 if ( newExtent != mExtent )
1800 double currentWidthHeightRatio = mExtent.
width() / mExtent.
height();
1801 double newWidthHeightRatio = newExtent.
width() / newExtent.
height();
1803 if ( currentWidthHeightRatio < newWidthHeightRatio )
1806 double newHeight = newExtent.
width() / currentWidthHeightRatio;
1807 double deltaHeight = newHeight - newExtent.
height();
1814 double newWidth = currentWidthHeightRatio * newExtent.
height();
1815 double deltaWidth = newWidth - newExtent.
width();
1820 mExtent = newExtent;
1830 newExtent = mExtent;
1833 if ( useDdXMax || useDdXMin || useDdYMax || useDdYMin )
1837 if ( useDdXMin && !useDdXMax )
1843 else if ( !useDdXMin && useDdXMax )
1849 if ( useDdYMin && !useDdYMax )
1855 else if ( !useDdYMin && useDdYMax )
1862 if ( newExtent != mExtent )
1864 mExtent = newExtent;
1881 void QgsLayoutItemMap::updateAtlasFeature()
1900 if ( mAtlasScalingMode ==
Fixed || mAtlasScalingMode ==
Predefined || isPointLayer )
1905 double originalScale = calc.
calculate( originalExtent, rect().width() );
1906 double geomCenterX = ( xa1 + xa2 ) / 2.0;
1907 double geomCenterY = ( ya1 + ya2 ) / 2.0;
1909 if ( mAtlasScalingMode ==
Fixed || isPointLayer )
1912 double xMin = geomCenterX - originalExtent.
width() / 2.0;
1913 double yMin = geomCenterY - originalExtent.
height() / 2.0;
1916 xMin + originalExtent.
width(),
1917 yMin + originalExtent.
height() );
1921 double newScale = calc.
calculate( newExtent, rect().width() );
1922 newExtent.
scale( originalScale / newScale );
1927 double newWidth = originalExtent.
width();
1928 double newHeight = originalExtent.
height();
1929 QVector<qreal> scales =
mLayout->reportContext().predefinedScales();
1930 for (
int i = 0; i < scales.size(); i++ )
1932 double ratio = scales[i] / originalScale;
1933 newWidth = originalExtent.
width() * ratio;
1934 newHeight = originalExtent.
height() * ratio;
1937 double xMin = geomCenterX - newWidth / 2.0;
1938 double yMin = geomCenterY - newHeight / 2.0;
1946 double newScale = calc.
calculate( newExtent, rect().width() );
1947 newExtent.
scale( scales[i] / newScale );
1957 else if ( mAtlasScalingMode ==
Auto )
1961 double geomRatio = bounds.
width() / bounds.
height();
1962 double mapRatio = originalExtent.
width() / originalExtent.
height();
1965 if ( geomRatio < mapRatio )
1968 double adjWidth = ( mapRatio * bounds.
height() - bounds.
width() ) / 2.0;
1973 else if ( geomRatio > mapRatio )
1976 double adjHeight = ( bounds.
width() / mapRatio - bounds.
height() ) / 2.0;
1982 const double evaluatedAtlasMargin =
atlasMargin();
1983 if ( evaluatedAtlasMargin > 0.0 )
1985 newExtent.
scale( 1 + evaluatedAtlasMargin );
2001 if ( mEvaluatedMapRotation != 0.0 )
2011 double dx = std::max( std::abs( prevCenter.
x() - bounds.
xMinimum() ),
2012 std::abs( prevCenter.
x() - bounds.
xMaximum() ) );
2013 double dy = std::max( std::abs( prevCenter.
y() - bounds.
yMinimum() ),
2014 std::abs( prevCenter.
y() - bounds.
yMaximum() ) );
2017 center.
x() + dx, center.
y() + dy );
QIcon icon() const override
Returns the item's icon.
QString displayName() const override
Gets item display name.
void setForceVectorOutput(bool force)
Sets whether rendering operations should use vector operations instead of any faster raster shortcuts...
The class is used as a container of context for various read/write operations on other objects...
static double scaleFactorFromItemStyle(const QStyleOptionGraphicsItem *style)
Extracts the scale factor from an item style.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
void draw(QgsLayoutItemRenderContext &context) override
Draws the item's contents using the specified item render context.
void finished()
emitted when asynchronous rendering is finished (or canceled).
Single variable definition for use within a QgsExpressionContextScope.
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs)
sets destination coordinate reference system
A rectangle specified with double values.
Base class for all map layer types.
void setExtent(const QgsRectangle &rect, bool magnified=true)
Set coordinates of the rectangle which should be rendered.
Job implementation that renders everything sequentially using a custom painter.
QgsCoordinateReferenceSystem mapPositionCrs() const
Returns the CRS of the map position, or an invalid CRS if the annotation does not have a fixed map po...
void setTransformContext(const QgsCoordinateTransformContext &context)
Sets the coordinate transform context, which stores various information regarding which datum transfo...
bool containsAdvancedEffects() const override
Returns true if the item contains contents with blend modes or transparency effects which can only be...
Base class for graphical items within a QgsLayout.
QgsMapSettings mapSettings(const QgsRectangle &extent, QSizeF size, double dpi, bool includeLayerSettings) const
Returns map settings that will be used for drawing of the map.
double calculate(const QgsRectangle &mapExtent, double canvasWidth)
Calculate the scale denominator.
An individual overview which is drawn above the map content in a QgsLayoutItemMap, and shows the extent of another QgsLayoutItemMap.
static Q_INVOKABLE QString toString(QgsUnitTypes::DistanceUnit unit)
Returns a translated string representing a distance unit.
QgsLayoutItemMap(QgsLayout *layout)
Constructor for QgsLayoutItemMap, with the specified parent layout.
void moveContent(double dx, double dy) override
Moves the content of the item, by a specified dx and dy in layout units.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
void setXMaximum(double x)
Set the maximum x value.
int type() const override
Use antialiasing while drawing.
bool writeXml(QDomNode &node, QDomDocument &doc) const
Stores state to the given Dom node in the given document.
void readXml(const QDomElement &styleElement)
Read style configuration (for project file reading)
void addFunction(const QString &name, QgsScopedExpressionFunction *function)
Adds a function to the scope.
QString valueAsString(int key, const QgsExpressionContext &context, const QString &defaultString=QString(), bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as a string...
Layer and style map theme.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
bool writePropertiesToElement(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const override
Stores item state within an XML DOM element.
void setExtent(const QgsRectangle &extent)
Sets a new extent for the map.
void layerOrderChanged()
Emitted when the layer order has changed.
A class to represent a 2D point.
void scale(double scaleFactor, const QgsPointXY *c=nullptr)
Scale the rectangle around its center point.
void extentChanged()
Is emitted when the map's extent changes.
QgsRectangle requestedExtent() const
Calculates the extent to request and the yShift of the top-left point in case of rotation.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
bool containsWmsLayer() const
Returns true if the map contains a WMS layer.
OperationResult rotate(double rotation, const QgsPointXY ¢er)
Rotate this geometry around the Z axis.
static QgsLayoutItemMap * create(QgsLayout *layout)
Returns a new map item for the specified layout.
TYPE * resolveWeakly(const QgsProject *project)
Resolves the map layer by attempting to find a matching layer in a project using a weak match...
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
void setOutputDpi(double dpi)
Sets DPI used for conversion between real world units (e.g. mm) and pixels.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
bool drawAnnotations() const
Returns whether annotations are drawn within the map.
void crsChanged()
Emitted when the CRS of the project has changed.
void setDpi(double dpi)
Sets the dpi (dots per inch) for the output resolution, to be used in scale calculations.
bool isVisible() const
Returns true if the annotation is visible and should be rendered.
void zoomContent(double factor, QPointF point) override
Zooms content of item.
A geometry is the spatial representation of a feature.
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
virtual void setFrameStrokeWidth(QgsLayoutMeasurement width)
Sets the frame stroke width.
static const QStringList containsAdvancedEffects(const QgsMapSettings &mapSettings)
Checks whether any of the layers attached to a map settings object contain advanced effects...
QPointF mapToItemCoords(QPointF mapCoords) const
Transforms map coordinates to item coordinates (considering rotation and move offset) ...
QgsUnitTypes::DistanceUnit mapUnits
void invalidateCache() override
void setLayerStyleOverrides(const QMap< QString, QString > &overrides)
Set map of map layer style overrides (key: layer ID, value: style name) where a different style shoul...
void preparedForAtlas()
Is emitted when the map has been prepared for atlas rendering, just before actual rendering...
QPointer< QgsMapLayer > QgsWeakMapLayerPointer
Weak pointer for QgsMapLayer.
Enable layer opacity and blending effects.
friend class QgsLayoutItemMapOverview
void addVariable(const QgsExpressionContextScope::StaticVariable &variable)
Adds a variable into the context scope.
virtual void refreshDataDefinedProperty(QgsLayoutObject::DataDefinedProperty property=QgsLayoutObject::AllProperties)
Refreshes a data defined property for the item by reevaluating the property's value and redrawing the...
Vector graphics should not be cached and drawn as raster images.
void setFlag(Flag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected)
Abstract base class for annotation items which are drawn over a map.
void setFrameStrokeWidth(QgsLayoutMeasurement width) override
Sets the frame stroke width.
The QgsMapSettings class contains configuration for rendering of the map.
PropertyValueType
Specifies whether the value returned by a function should be the original, user set value...
void readFromLayer(QgsMapLayer *layer)
Store layer's active style information in the instance.
void storeCurrentLayerStyles()
Stores the current project layer styles into style overrides.
void sizePositionChanged()
Emitted when the item's size or position changes.
Stores style information (renderer, opacity, labeling, diagrams etc.) applicable to a map layer...
static QgsGeometry fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
void mapThemeChanged(const QString &theme)
Emitted when a map theme changes definition.
static QgsRectangle fromCenterAndSize(QgsPointXY center, double width, double height)
Creates a new rectangle, given the specified center point and width and height.
Layout graphical items for displaying a map.
void setOutputSize(QSize size)
Sets the size of the resulting map image.
QString layerId
Original layer ID.
QgsPropertyCollection mDataDefinedProperties
void setTextRenderFormat(QgsRenderContext::TextRenderFormat format)
Sets the text render format, which dictates how text is rendered (e.g.
QgsMapThemeCollection mapThemeCollection
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
This class provides a method of storing measurements for use in QGIS layouts using a variety of diffe...
bool requiresRasterization() const override
Returns true if the item is drawn in such a way that forces the whole layout to be rasterized when ex...
double xMaximum() const
Returns the x maximum value (right side of rectangle).
Whether vector selections should be shown in the rendered map.
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
~QgsLayoutItemMap() override
void setYMinimum(double y)
Set the minimum y value.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void attemptSetSceneRect(const QRectF &rect, bool includesFrame=false)
Attempts to update the item's position and size to match the passed rect in layout coordinates...
double atlasMargin(QgsLayoutObject::PropertyValueType valueType=QgsLayoutObject::EvaluatedValue)
Returns the margin size (percentage) used when the map is in atlas mode.
static QgsRenderContext createRenderContextForMap(QgsLayoutItemMap *map, QPainter *painter, double dpi=-1)
Creates a render context suitable for the specified layout map and painter destination.
double mapRotation(QgsLayoutObject::PropertyValueType valueType=QgsLayoutObject::EvaluatedValue) const
Returns the rotation used for drawing the map within the layout item, in degrees clockwise.
Enable anti-aliasing for map rendering.
static GeometryType geometryType(Type type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
QPointer< QgsLayout > mLayout
void setMapUnits(QgsUnitTypes::DistanceUnit mapUnits)
Set the map units.
QgsPointXY center() const
Returns the center point of the rectangle.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Hide coverage layer in outputs.
bool hasBackground() const
Returns true if the item has a background.
QgsCoordinateReferenceSystem crs() const
Returns coordinate reference system used for rendering the map.
void setMoveContentPreviewOffset(double dx, double dy) override
Sets temporary offset for the item, by a specified dx and dy in layout units.
Reads and writes project states.
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets the map's preset crs (coordinate reference system).
QgsLayoutItem::Flags itemFlags() const override
Returns the item's flags, which indicate how the item behaves.
Single scope for storing variables and functions for use within a QgsExpressionContext.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
static void rotate(double angle, double &x, double &y)
Rotates a point / vector around the origin.
Enable drawing of vertex markers for layers in editing mode.
The extent is adjusted so that each feature is fully visible.
void render(QgsRenderContext &context) const
Renders the annotation to a target render context.
An individual grid which is drawn above the map content in a QgsLayoutItemMap.
void mapRotationChanged(double newRotation)
Is emitted when the map's rotation changes.
QPointF relativePosition() const
Returns the relative position of the annotation, if it is not attached to a fixed map position...
Use antialiasing when drawing items.
QString xmlData() const
Returns XML content of the style.
void setLayerStyleOverrides(const QMap< QString, QString > &overrides)
Sets the stored overrides of styles for layers.
void setRotation(double rotation)
Sets the rotation of the resulting map image, in degrees clockwise.
Contains settings and helpers relating to a render of a QgsLayoutItem.
QgsExpressionContext & expressionContext()
Gets the expression context.
Calculates scale for a given combination of canvas size, map extent, and monitor dpi.
void setAtlasDriven(bool enabled)
Sets whether the map extent will follow the current atlas feature.
void paint(QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget) override
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
double valueAsDouble(int key, const QgsExpressionContext &context, double defaultValue=0.0, bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as a double...
void setBackgroundColor(const QColor &color)
Sets the background color of the map.
Return the current evaluated value for the property.
void setLabelingEngineSettings(const QgsLabelingEngineSettings &settings)
Sets the global configuration of the labeling engine.
void writeXml(QDomElement &styleElement) const
Write style configuration (for project file writing)
QgsRectangle extent() const
Returns the current map extent.
Contains information about the context of a rendering operation.
Force output in vector format where possible, even if items require rasterization to keep their corre...
bool setEllipsoid(const QString &ellipsoid)
Sets the ellipsoid by its acronym.
bool shouldDrawItem() const
Returns whether the item should be drawn in the current context.
void setMapRotation(double rotation)
Sets the rotation for the map - this does not affect the layout item shape, only the way the map is d...
void refreshDataDefinedProperty(QgsLayoutObject::DataDefinedProperty property=QgsLayoutObject::AllProperties) override
QPainter * painter()
Returns the destination QPainter for the render operation.
void layersWillBeRemoved(const QStringList &layerIds)
Emitted when one or more layers are about to be removed from the registry.
QList< QgsMapLayer * > layers() const
Returns the stored layer set.
void setSelectionColor(const QColor &color)
Sets color that is used for drawing of selected vector features.
QgsLayoutItemMapOverview * overview()
Returns the map item's first overview.
Enable advanced effects such as blend modes.
virtual bool containsAdvancedEffects() const
Returns true if the item contains contents with blend modes or transparency effects which can only be...
double mapUnitsToLayoutUnits() const
Returns the conversion factor from map units to layout units.
void updateBoundingRect()
Updates the bounding rect of this item. Call this function before doing any changes related to annota...
void refreshed()
Is emitted when the layout has been refreshed and items should also be refreshed and updated...
void setYMaximum(double y)
Set the maximum y value.
The current scale of the map is used for each feature of the atlas.
friend class QgsLayoutItemMapGrid
virtual bool requiresRasterization() const
Returns true if the item is drawn in such a way that forces the whole layout to be rasterized when ex...
QColor backgroundColor() const
Returns the background color for this item.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
This class represents a coordinate reference system (CRS).
QPolygonF transformedMapPolygon() const
Returns extent that considers rotation and shift with mOffsetX / mOffsetY.
void assignFreeId()
Sets the map id() to a number not yet used in the layout.
QString authid() const
Returns the authority identifier for the CRS.
Flags flags() const
Returns combination of flags used for rendering.
void setPathResolver(const QgsPathResolver &resolver)
Sets the path resolver for conversion between relative and absolute paths during rendering operations...
bool readXml(const QDomNode &node)
Restores state from the given DOM node.
QString id() const
Returns the item's ID name.
double scale() const
Returns the map scale.
void layerStyleOverridesChanged()
Emitted when layer style overrides are changed...
Enable vector simplification and other rendering optimizations.
void setLayers(const QList< QgsMapLayer * > &layers)
Sets the stored layers set.
QList< QgsMapLayer * > layersToRender(const QgsExpressionContext *context=nullptr) const
Returns a list of the layers which will be rendered within this map item, considering any locked laye...
Item overrides the default layout item painting method.
Custom exception class for Coordinate Reference System related exceptions.
bool readPropertiesFromElement(const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context) override
Sets item state from a DOM element.
const QgsLayout * layout() const
Returns the layout the object is attached to.
QgsLayerTree * layerTreeRoot() const
Returns pointer to the root (invisible) node of the project's layer tree.
void zoomToExtent(const QgsRectangle &extent)
Zooms the map so that the specified extent is fully visible within the map item.
AtlasScalingMode
Scaling modes used for the serial rendering (atlas)
int numberExportLayers() const override
Returns the number of layers that this item requires for exporting during layered exports (e...
bool atlasDriven() const
Returns whether the map extent is set to follow the current atlas feature.
TYPE * resolve(const QgsProject *project)
Resolves the map layer by attempting to find a layer with matching ID within a project.
double width() const
Returns the width of the rectangle.
void changed()
Emitted when the object's properties change.
DataDefinedProperty
Data defined properties for different item types.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
void setScale(double scale, bool forceUpdate=true)
Sets new map scale and changes only the map extent.
void refresh() override
Refreshes the item, causing a recalculation of any property overrides and recalculation of its positi...
void finalizeRestoreFromXml() override
Called after all pending items have been restored from XML.
QRectF boundingRect() const override
void renderSynchronously()
Render the map synchronously in this thread.
bool frameEnabled() const
Returns true if the item includes a frame.
static QgsGeometry fromPointXY(const QgsPointXY &point)
Creates a new geometry from a QgsPointXY object.
QPolygonF visibleExtentPolygon() const
Returns a polygon representing the current visible map extent, considering map extents and rotation...
void setXMinimum(double x)
Set the minimum x value.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
double height() const
Returns the height of the rectangle.
A scale is chosen from the predefined scales.
QString toProj4() const
Returns a Proj4 string representation of this CRS.
void setLayers(const QList< QgsMapLayer * > &layers)
Set list of layers for map rendering.
QgsLayoutItemMapGrid * grid()
Returns the map item's first grid.