QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
21 #include <QApplication>
25 #include <QGraphicsItem>
26 #include <QGraphicsScene>
27 #include <QGraphicsView>
30 #include <QPaintEvent>
33 #include <QTextStream>
34 #include <QResizeEvent>
37 #include <QStringList>
38 #include <QWheelEvent>
42 #include <QVariantAnimation>
43 #include <QPropertyAnimation>
131 : QGraphicsView( parent )
133 , mExpressionContextScope( tr(
"Map Canvas" ) )
135 mScene =
new QGraphicsScene();
137 setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
138 setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
139 setMouseTracking(
true );
140 setFocusPolicy( Qt::StrongFocus );
142 mResizeTimer =
new QTimer(
this );
143 mResizeTimer->setSingleShot(
true );
146 mRefreshTimer =
new QTimer(
this );
147 mRefreshTimer->setSingleShot(
true );
148 connect( mRefreshTimer, &QTimer::timeout,
this, &QgsMapCanvas::refreshMap );
151 mMap =
new QgsMapCanvasMap(
this );
181 emit transformContextChanged();
189 if ( mSettings.destinationCrs() !=
crs )
192 setDestinationCrs( crs );
205 double segmentationTolerance = settings.
value( QStringLiteral(
"qgis/segmentationTolerance" ),
"0.01745" ).toDouble();
207 mSettings.setSegmentationTolerance( segmentationTolerance );
208 mSettings.setSegmentationToleranceType( toleranceType );
210 mWheelZoomFactor = settings.
value( QStringLiteral(
"qgis/zoom_factor" ), 2 ).toDouble();
212 QSize s = viewport()->size();
213 mSettings.setOutputSize( s );
217 setSceneRect( 0, 0, s.width(), s.height() );
218 mScene->setSceneRect( QRectF( 0, 0, s.width(), s.height() ) );
220 moveCanvasContents(
true );
222 connect( &mMapUpdateTimer, &QTimer::timeout,
this, &QgsMapCanvas::mapUpdateTimeout );
223 mMapUpdateTimer.setInterval( 250 );
228 grabGesture( Qt::PinchGesture );
229 grabGesture( Qt::TapAndHoldGesture );
230 viewport()->setAttribute( Qt::WA_AcceptTouchEvents );
234 viewport()->setGraphicsEffect( mPreviewEffect );
238 connect( &mAutoRefreshTimer, &QTimer::timeout,
this, &QgsMapCanvas::autoRefreshTriggered );
242 setInteractive(
false );
246 setCanvasColor( mSettings.backgroundColor() );
248 setTemporalRange( mSettings.temporalRange() );
260 mLastNonZoomMapTool =
nullptr;
267 qDeleteAll( mScene->items() );
269 mScene->deleteLater();
286 for (
auto previewJob = mPreviewJobs.constBegin(); previewJob != mPreviewJobs.constEnd(); ++previewJob )
294 mPreviewJobs.clear();
302 factor = std::clamp( factor, magnifierMin, magnifierMax );
337 if ( index >= 0 && index <
layers.size() )
360 if ( mCurrentLayer ==
layer )
363 mCurrentLayer =
layer;
374 return nullptr != mJob;
387 if ( !mTheme.isEmpty() )
390 setLayersPrivate(
layers );
393 void QgsMapCanvas::setLayersPrivate(
const QList<QgsMapLayer *> &layers )
395 QList<QgsMapLayer *> oldLayers = mSettings.
layers();
398 if (
layers == oldLayers )
401 const auto constOldLayers = oldLayers;
415 const auto constLayers =
layers;
432 updateAutoRefreshTimer();
461 QgsDebugMsg( QStringLiteral(
"Transform error caught: %1" ).arg( e.
what() ) );
469 mBlockItemPositionUpdates++;
471 mBlockItemPositionUpdates--;
478 QgsDebugMsgLevel( QStringLiteral(
"refreshing after destination CRS changed" ), 2 );
498 mController = controller;
504 void QgsMapCanvas::temporalControllerModeChanged()
508 switch ( temporalNavigationObject->navigationMode() )
511 mSettings.
setFrameRate( temporalNavigationObject->framesPerSecond() );
512 mSettings.
setCurrentFrame( temporalNavigationObject->currentFrameNumber() );
540 if ( !allowOutdatedResults && mLabelingResultsOutdated )
543 return mLabelingResults.get();
548 if ( !allowOutdatedResults && mRenderedItemResultsOutdated )
551 return mRenderedItemResults.get();
574 mPreviousRenderedItemResults.reset();
579 return nullptr != mCache;
587 if ( mPreviousRenderedItemResults )
588 mPreviousRenderedItemResults.reset();
589 if ( mRenderedItemResults )
590 mRenderedItemResults.reset();
595 mUseParallelRendering = enabled;
600 return mUseParallelRendering;
605 mMapUpdateTimer.setInterval( timeMilliseconds );
610 return mMapUpdateTimer.interval();
616 return mCurrentLayer;
636 expressionContext << generator->createExpressionContextScope();
640 return expressionContext;
647 QgsDebugMsgLevel( QStringLiteral(
"CANVAS refresh - invalid settings -> nothing to do" ), 2 );
651 if ( !mRenderFlag || mFrozen )
657 if ( mRefreshScheduled )
659 QgsDebugMsgLevel( QStringLiteral(
"CANVAS refresh already scheduled" ), 2 );
663 mRefreshScheduled =
true;
668 mRefreshTimer->start( 1 );
670 mLabelingResultsOutdated =
true;
671 mRenderedItemResultsOutdated =
true;
674 void QgsMapCanvas::refreshMap()
676 Q_ASSERT( mRefreshScheduled );
688 switch ( temporalNavigationObject->navigationMode() )
691 mSettings.
setFrameRate( temporalNavigationObject->framesPerSecond() );
692 mSettings.
setCurrentFrame( temporalNavigationObject->currentFrameNumber() );
703 if ( !mTheme.isEmpty() )
716 QList<QgsMapLayer *> allLayers = renderSettings.
layers();
722 mJobCanceled =
false;
723 if ( mUseParallelRendering )
740 mRefreshScheduled =
false;
742 mMapUpdateTimer.start();
747 void QgsMapCanvas::mapThemeChanged(
const QString &theme )
749 if (
theme == mTheme )
754 setLayersPrivate(
QgsProject::instance()->mapThemeCollection()->mapThemeVisibleLayers( mTheme ) );
767 void QgsMapCanvas::mapThemeRenamed(
const QString &theme,
const QString &newTheme )
769 if ( mTheme.isEmpty() ||
theme != mTheme )
778 void QgsMapCanvas::rendererJobFinished()
780 QgsDebugMsgLevel( QStringLiteral(
"CANVAS finish! %1" ).arg( !mJobCanceled ), 2 );
782 mMapUpdateTimer.stop();
784 notifyRendererErrors( mJob->
errors() );
794 mLabelingResultsOutdated =
false;
798 if ( mRenderedItemResults )
802 if ( mPreviousRenderedItemResults )
808 if ( mCache && !mPreviousRenderedItemResults )
809 mPreviousRenderedItemResults = std::make_unique< QgsRenderedItemResults >( mJob->
mapSettings().
extent() );
811 if ( mRenderedItemResults && mPreviousRenderedItemResults )
816 mPreviousRenderedItemResults->transferResults( mRenderedItemResults.get() );
818 if ( mPreviousRenderedItemResults )
824 mRenderedItemResultsOutdated =
false;
834 QString logMsg = tr(
"Canvas refresh: %1 ms" ).arg( mJob->
renderingTime() );
838 if ( mDrawRenderingStats )
840 int w = img.width(), h = img.height();
841 QFont fnt = p.font();
844 int lh = p.fontMetrics().height() * 2;
845 QRect r( 0, h - lh, w, lh );
846 p.setPen( Qt::NoPen );
847 p.setBrush( QColor( 0, 0, 0, 110 ) );
849 p.setPen( Qt::white );
850 QString msg = QStringLiteral(
"%1 :: %2 ms" ).arg( mUseParallelRendering ? QStringLiteral(
"PARALLEL" ) : QStringLiteral(
"SEQUENTIAL" ) ).arg( mJob->
renderingTime() );
851 p.drawText( r, msg, QTextOption( Qt::AlignCenter ) );
856 mMap->setContent( img, imageRect( img, mSettings ) );
858 mLastLayerRenderTime.clear();
860 for (
auto it = times.constBegin(); it != times.constEnd(); ++it )
862 mLastLayerRenderTime.insert( it.key()->id(), it.value() );
864 if ( mUsePreviewJobs && !mRefreshAfterJob )
869 mRefreshAfterJob =
false;
879 if ( mRefreshAfterJob )
881 mRefreshAfterJob =
false;
882 clearTemporalCache();
883 clearElevationCache();
888 void QgsMapCanvas::previewJobFinished()
896 mPreviewJobs.removeAll( job );
898 int number = job->property(
"number" ).toInt();
901 startPreviewJob( number + 1 );
918 QgsLogger::warning( QStringLiteral(
"The renderer map has a wrong device pixel ratio" ) );
922 QgsRectangle rect( topLeft.
x(), topLeft.
y(), topLeft.
x() + img.width()*res, topLeft.
y() - img.height()*res );
928 return mUsePreviewJobs;
933 mUsePreviewJobs = enabled;
938 mDropHandlers = handlers;
941 void QgsMapCanvas::clearTemporalCache()
945 bool invalidateLabels =
false;
949 bool alreadyInvalidatedThisLayer =
false;
957 alreadyInvalidatedThisLayer =
true;
967 if ( vl->labelsEnabled() || vl->diagramsEnabled() )
968 invalidateLabels =
true;
974 if ( !alreadyInvalidatedThisLayer )
979 if ( invalidateLabels )
987 void QgsMapCanvas::clearElevationCache()
991 bool invalidateLabels =
false;
999 if ( vl->labelsEnabled() || vl->diagramsEnabled() )
1000 invalidateLabels =
true;
1010 if ( invalidateLabels )
1020 const QgsPointXY mapPoint =
event->originalMapPoint();
1024 QMenu *copyCoordinateMenu =
new QMenu( tr(
"Copy Coordinate" ), &menu );
1032 const QgsPointXY transformedPoint = ct.transform( mapPoint );
1035 int displayPrecision = 0;
1043 displayPrecision = 0;
1045 displayPrecision = 1;
1047 displayPrecision = 2;
1049 displayPrecision = 3;
1051 displayPrecision = 4;
1053 displayPrecision = 5;
1055 displayPrecision = 6;
1057 displayPrecision = 7;
1059 displayPrecision = 8;
1061 displayPrecision = 9;
1069 QString firstSuffix;
1070 QString secondSuffix;
1071 if ( axisList.size() >= 2 )
1077 QString firstNumber;
1078 QString secondNumber;
1081 firstNumber = QString::number( transformedPoint.
y(),
'f', displayPrecision );
1082 secondNumber = QString::number( transformedPoint.
x(),
'f', displayPrecision );
1086 firstNumber = QString::number( transformedPoint.
x(),
'f', displayPrecision );
1087 secondNumber = QString::number( transformedPoint.
y(),
'f', displayPrecision );
1090 QAction *copyCoordinateAction =
new QAction( QStringLiteral(
"%5 (%1%2, %3%4)" ).arg(
1091 firstNumber, firstSuffix, secondNumber, secondSuffix, identifier ), &menu );
1093 connect( copyCoordinateAction, &QAction::triggered,
this, [firstNumber, secondNumber, transformedPoint]
1095 QClipboard *clipboard = QApplication::clipboard();
1097 const QString coordinates = firstNumber +
',' + secondNumber;
1100 if ( clipboard->supportsSelection() )
1102 clipboard->setText( coordinates, QClipboard::Selection );
1104 clipboard->setText( coordinates, QClipboard::Clipboard );
1107 copyCoordinateMenu->addAction( copyCoordinateAction );
1121 const QString customCrsString = settings.
value( QStringLiteral(
"qgis/custom_coordinate_crs" ) ).toString();
1122 if ( !customCrsString.isEmpty() )
1130 copyCoordinateMenu->addSeparator();
1131 QAction *setCustomCrsAction =
new QAction( tr(
"Set Custom CRS…" ), &menu );
1132 connect( setCustomCrsAction, &QAction::triggered,
this, [ = ]
1136 if ( selector.exec() )
1141 copyCoordinateMenu->addAction( setCustomCrsAction );
1143 menu.addMenu( copyCoordinateMenu );
1151 menu.exec(
event->globalPos() );
1156 const QDateTime currentTime = QDateTime::currentDateTime();
1161 const QString errorKey = error.layerID +
':' + error.message;
1162 if ( mRendererErrors.contains( errorKey ) )
1164 const QDateTime sameErrorTime = mRendererErrors.value( errorKey );
1166 if ( sameErrorTime.secsTo( currentTime ) < 60 )
1170 mRendererErrors[errorKey] = currentTime;
1177 void QgsMapCanvas::updateDevicePixelFromScreen()
1183 if ( window()->windowHandle() )
1185 mSettings.
setOutputDpi( window()->windowHandle()->screen()->physicalDotsPerInch() );
1186 mSettings.
setDpiTarget( window()->windowHandle()->screen()->physicalDotsPerInch() );
1192 mSettings.
setOutputDpi( window()->windowHandle()->screen()->logicalDotsPerInch() );
1193 mSettings.
setDpiTarget( window()->windowHandle()->screen()->logicalDotsPerInch() );
1203 mSettings.
setIsTemporal( dateTimeRange.begin().isValid() || dateTimeRange.end().isValid() );
1210 clearTemporalCache();
1212 autoRefreshTriggered();
1222 mInteractionBlockers.append( blocker );
1227 mInteractionBlockers.removeAll( blocker );
1234 if ( block->blockCanvasInteraction( interaction ) )
1240 void QgsMapCanvas::mapUpdateTimeout()
1245 mMap->setContent( img, imageRect( img, mSettings ) );
1254 mJobCanceled =
true;
1275 image = theQPixmap->toImage();
1276 painter.begin( &image );
1286 image = mMap->contentImage().copy();
1287 painter.begin( &image );
1291 QStyleOptionGraphicsItem option;
1292 option.initFrom(
this );
1293 QGraphicsItem *item =
nullptr;
1294 QListIterator<QGraphicsItem *> i( items() );
1296 while ( i.hasPrevious() )
1298 item = i.previous();
1307 QPointF itemScenePos = item->scenePos();
1308 painter.translate( itemScenePos.x(), itemScenePos.y() );
1310 item->paint( &painter, &option );
1314 image.save( fileName, format.toLocal8Bit().data() );
1316 QFileInfo myInfo = QFileInfo( fileName );
1319 QString outputSuffix = myInfo.suffix();
1320 QString myWorldFileName = myInfo.absolutePath() +
'/' + myInfo.completeBaseName() +
'.'
1321 + outputSuffix.at( 0 ) + outputSuffix.at( myInfo.suffix().size() - 1 ) +
'w';
1322 QFile myWorldFile( myWorldFileName );
1323 if ( !myWorldFile.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
1327 QTextStream myStream( &myWorldFile );
1363 if ( ( r == current ) && magnified )
1376 QgsDebugMsgLevel( QStringLiteral(
"Empty extent - keeping old scale with new center!" ), 2 );
1384 if ( mScaleLocked && magnified )
1386 ScaleRestorer restorer(
this );
1403 for (
int i = mLastExtent.size() - 1; i > mLastExtentIndex; i-- )
1405 mLastExtent.removeAt( i );
1408 if ( !mLastExtent.isEmpty() && mLastExtent.last() != mSettings.
extent() )
1410 mLastExtent.append( mSettings.
extent() );
1414 if ( mLastExtent.size() > 100 )
1416 mLastExtent.removeAt( 0 );
1420 mLastExtentIndex = mLastExtent.size() - 1;
1469 return mCursorPoint;
1524 if ( mLastExtentIndex > 0 )
1527 mSettings.
setExtent( mLastExtent[mLastExtentIndex] );
1540 if ( mLastExtentIndex < mLastExtent.size() - 1 )
1543 mSettings.
setExtent( mLastExtent[mLastExtentIndex] );
1555 mLastExtent.clear();
1556 mLastExtent.append( mSettings.
extent() ) ;
1557 mLastExtentIndex = mLastExtent.size() - 1;
1575 double closestSquaredDistance = pow( extentRect.
width(), 2.0 ) + pow( extentRect.
height(), 2.0 );
1576 bool pointFound =
false;
1580 double sqrDist = point.
sqrDist( centerLayerCoordinates );
1581 if ( sqrDist > closestSquaredDistance || sqrDist < 4 * std::numeric_limits<double>::epsilon() )
1584 closestPoint = point;
1585 closestSquaredDistance = sqrDist;
1591 rect.scale( scaleFactor, &
center );
1604 layer = qobject_cast<QgsVectorLayer *>( mCurrentLayer );
1614 emit
messageEmitted( tr(
"Cannot zoom to selected feature(s)" ), tr(
"No extent could be determined." ), Qgis::MessageLevel::Warning );
1624 rect = optimalExtentForPointLayer(
layer, rect.
center() );
1643 rect =
layer->boundingBoxOfSelected();
1651 rect = optimalExtentForPointLayer(
layer, rect.
center() );
1656 if ( selectionExtent.
isNull() )
1658 emit
messageEmitted( tr(
"Cannot zoom to selected feature(s)" ), tr(
"No extent could be determined." ), Qgis::MessageLevel::Warning );
1667 return mSettings.
zRange();
1682 clearElevationCache();
1684 autoRefreshTriggered();
1720 if ( boundingBoxOfFeatureIds( ids,
layer, bbox, errorMsg ) )
1724 bbox = optimalExtentForPointLayer(
layer, bbox.
center() );
1730 emit
messageEmitted( tr(
"Zoom to feature id failed" ), errorMsg, Qgis::MessageLevel::Warning );
1744 if ( boundingBoxOfFeatureIds( ids,
layer, bbox, errorMsg ) )
1752 emit
messageEmitted( tr(
"Pan to feature id failed" ), errorMsg, Qgis::MessageLevel::Warning );
1761 int featureCount = 0;
1769 errorMsg = tr(
"Feature does not have a geometry" );
1773 errorMsg = tr(
"Feature geometry is empty" );
1775 if ( !errorMsg.isEmpty() )
1784 if ( featureCount != ids.count() )
1786 errorMsg = tr(
"Feature not found" );
1798 layer = qobject_cast<QgsVectorLayer *>( mCurrentLayer );
1807 emit
messageEmitted( tr(
"Cannot pan to selected feature(s)" ), tr(
"No extent could be determined." ), Qgis::MessageLevel::Warning );
1830 rect =
layer->boundingBoxOfSelected();
1838 rect = optimalExtentForPointLayer(
layer, rect.
center() );
1843 if ( selectionExtent.
isNull() )
1845 emit
messageEmitted( tr(
"Cannot pan to selected feature(s)" ), tr(
"No extent could be determined." ), Qgis::MessageLevel::Warning );
1854 const QColor &color1,
const QColor &color2,
1855 int flashes,
int duration )
1862 QList< QgsGeometry > geoms;
1878 if ( geometries.isEmpty() )
1896 QColor startColor = color1;
1897 if ( !startColor.isValid() )
1907 startColor.setAlpha( 255 );
1909 QColor endColor = color2;
1910 if ( !endColor.isValid() )
1912 endColor = startColor;
1913 endColor.setAlpha( 0 );
1917 QVariantAnimation *animation =
new QVariantAnimation(
this );
1918 connect( animation, &QVariantAnimation::finished,
this, [animation, rb]
1920 animation->deleteLater();
1923 connect( animation, &QPropertyAnimation::valueChanged,
this, [rb, geomType](
const QVariant & value )
1925 QColor
c = value.value<QColor>();
1934 c.setAlpha(
c.alpha() );
1940 animation->setDuration( duration * flashes );
1941 animation->setStartValue( endColor );
1942 double midStep = 0.2 / flashes;
1943 for (
int i = 0; i < flashes; ++i )
1945 double start =
static_cast< double >( i ) / flashes;
1946 animation->setKeyValueAt( start + midStep, startColor );
1947 double end =
static_cast< double >( i + 1 ) / flashes;
1949 animation->setKeyValueAt( end, endColor );
1951 animation->setEndValue( endColor );
1974 if ( !e->isAccepted() )
1979 double dx = std::fabs( currentExtent.
width() / 4 );
1980 double dy = std::fabs( currentExtent.
height() / 4 );
2012 if ( ! e->isAutoRepeat() )
2020 case Qt::Key_PageUp:
2025 case Qt::Key_PageDown:
2032 mUseParallelRendering = !mUseParallelRendering;
2037 mDrawRenderingStats = !mDrawRenderingStats;
2065 mTemporaryCursorOverride.reset();
2079 QgsDebugMsgLevel(
"Ignoring key release: " + QString::number( e->key() ), 2 );
2098 void QgsMapCanvas::beginZoomRect( QPoint pos )
2100 mZoomRect.setRect( 0, 0, 0, 0 );
2102 mZoomDragging =
true;
2104 QColor color( Qt::blue );
2105 color.setAlpha( 63 );
2106 mZoomRubberBand->setColor( color );
2107 mZoomRect.setTopLeft( pos );
2110 void QgsMapCanvas::stopZoomRect()
2112 if ( mZoomDragging )
2114 mZoomDragging =
false;
2115 mZoomRubberBand.reset(
nullptr );
2116 mTemporaryCursorOverride.reset();
2120 void QgsMapCanvas::endZoomRect( QPoint pos )
2125 mZoomRect.setRight( pos.x() );
2126 mZoomRect.setBottom( pos.y() );
2129 mZoomRect = mZoomRect.normalized();
2131 if ( mZoomRect.width() < 5 && mZoomRect.height() < 5 )
2138 const QSize &zoomRectSize = mZoomRect.size();
2139 const QSize &canvasSize = mSettings.
outputSize();
2140 double sfx =
static_cast< double >( zoomRectSize.width() ) / canvasSize.width();
2141 double sfy =
static_cast< double >( zoomRectSize.height() ) / canvasSize.height();
2142 double sf = std::max( sfx, sfy );
2150 void QgsMapCanvas::startPan()
2160 void QgsMapCanvas::stopPan()
2165 mTemporaryCursorOverride.reset();
2173 if ( e->button() == Qt::MiddleButton &&
2174 e->modifiers() & Qt::ShiftModifier )
2176 beginZoomRect( e->pos() );
2180 else if ( e->button() == Qt::MiddleButton )
2195 && e->modifiers() & Qt::ShiftModifier )
2197 beginZoomRect( e->pos() );
2203 showContextMenu( me.get() );
2226 if ( mZoomDragging &&
2227 e->button() == Qt::MiddleButton )
2229 endZoomRect( e->pos() );
2233 else if ( e->button() == Qt::MiddleButton )
2237 else if ( e->button() == Qt::BackButton )
2242 else if ( e->button() == Qt::ForwardButton )
2249 if ( mZoomDragging && e->button() == Qt::LeftButton )
2251 endZoomRect( e->pos() );
2261 QgsDebugMsgLevel( QStringLiteral(
"Right click in map tool zoom or pan, last tool is %1." ).arg(
2262 mLastNonZoomMapTool ? QStringLiteral(
"not null" ) : QStringLiteral(
"null" ) ), 2 );
2264 QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCurrentLayer );
2267 if ( mLastNonZoomMapTool
2272 mLastNonZoomMapTool =
nullptr;
2292 QGraphicsView::resizeEvent( e );
2293 mResizeTimer->start( 500 );
2295 double oldScale = mSettings.
scale();
2296 QSize lastSize = viewport()->size();
2299 mScene->setSceneRect( QRectF( 0, 0, lastSize.width(), lastSize.height() ) );
2305 double scaleFactor = oldScale / mSettings.
scale();
2323 QGraphicsView::paintEvent( e );
2328 if ( mBlockItemPositionUpdates )
2331 const QList<QGraphicsItem *> items = mScene->items();
2332 for ( QGraphicsItem *gi : items )
2349 QgsDebugMsgLevel(
"Wheel event delta " + QString::number( e->angleDelta().y() ), 2 );
2354 if ( e->isAccepted() )
2358 if ( e->angleDelta().y() == 0 )
2367 zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 120.0 * std::fabs( e->angleDelta().y() );
2369 if ( e->modifiers() & Qt::ControlModifier )
2372 zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 20.0;
2375 double signedWheelFactor = e->angleDelta().y() > 0 ? 1 / zoomFactor : zoomFactor;
2379 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
2384 QgsPointXY newCenter( mousePos.
x() + ( ( oldCenter.
x() - mousePos.
x() ) * signedWheelFactor ),
2385 mousePos.
y() + ( ( oldCenter.
y() - mousePos.
y() ) * signedWheelFactor ) );
2393 mWheelZoomFactor = factor;
2422 ScaleRestorer restorer(
this );
2436 if ( mScaleLocked != isLocked )
2438 mScaleLocked = isLocked;
2451 else if ( mZoomDragging )
2453 mZoomRect.setBottomRight( e->pos() );
2454 mZoomRubberBand->setToCanvasRectangle( mZoomRect );
2455 mZoomRubberBand->show();
2468 if ( !panOperationInProgress() )
2485 disconnect( mMapTool, &QObject::destroyed,
this, &QgsMapCanvas::mapToolDestroyed );
2495 mLastNonZoomMapTool = mMapTool;
2499 mLastNonZoomMapTool =
nullptr;
2509 connect( mMapTool, &QObject::destroyed,
this, &QgsMapCanvas::mapToolDestroyed );
2517 if ( mMapTool && mMapTool == tool )
2519 disconnect( mMapTool, &QObject::destroyed,
this, &QgsMapCanvas::mapToolDestroyed );
2524 setCursor( Qt::ArrowCursor );
2527 if ( mLastNonZoomMapTool && mLastNonZoomMapTool == tool )
2529 mLastNonZoomMapTool =
nullptr;
2547 QBrush bgBrush( color );
2548 setBackgroundBrush( bgBrush );
2551 palette.setColor( backgroundRole(), color );
2552 setPalette( palette );
2556 mScene->setBackgroundBrush( bgBrush );
2565 return mScene->backgroundBrush().color();
2577 bool hasSelectedFeatures =
false;
2584 hasSelectedFeatures =
true;
2589 if ( hasSelectedFeatures )
2655 if ( mTheme ==
theme )
2669 setLayersPrivate(
QgsProject::instance()->mapThemeCollection()->mapThemeVisibleLayers( mTheme ) );
2687 void QgsMapCanvas::connectNotify(
const char *signal )
2690 QgsDebugMsg(
"QgsMapCanvas connected to " + QString( signal ) );
2694 void QgsMapCanvas::layerRepaintRequested(
bool deferred )
2700 void QgsMapCanvas::autoRefreshTriggered()
2706 mRefreshAfterJob =
true;
2713 void QgsMapCanvas::updateAutoRefreshTimer()
2717 int minAutoRefreshInterval = -1;
2721 int layerRefreshInterval = 0;
2732 if ( rendererRefreshRate > 0 )
2734 layerRefreshInterval = 1000 / rendererRefreshRate;
2739 if ( layerRefreshInterval == 0 )
2742 minAutoRefreshInterval = minAutoRefreshInterval > 0 ? std::min( layerRefreshInterval, minAutoRefreshInterval ) : layerRefreshInterval;
2745 if ( minAutoRefreshInterval > 0 )
2747 mAutoRefreshTimer.setInterval( minAutoRefreshInterval );
2748 mAutoRefreshTimer.start();
2752 mAutoRefreshTimer.stop();
2756 void QgsMapCanvas::projectThemesChanged()
2758 if ( mTheme.isEmpty() )
2789 double dx = end.
x() - start.
x();
2790 double dy = end.
y() - start.
y();
2792 c.set(
c.x() - dx,
c.y() - dy );
2830 setSceneRect( -pnt.x(), -pnt.y(), viewport()->size().width(), viewport()->size().height() );
2838 bool allHandled =
true;
2841 bool handled =
false;
2844 if ( handler && handler->customUriProviderKey() == uri.providerKey )
2846 if ( handler->handleCustomUriCanvasDrop( uri,
this ) )
2870 updateDevicePixelFromScreen();
2872 QWindow *l_window = window()->windowHandle();
2875 connect( l_window, &QWindow::screenChanged,
this, [ = ]( QScreen * )
2877 disconnect( mScreenDpiChangedConnection );
2878 QWindow *windowInLambda = window()->windowHandle();
2879 if ( windowInLambda )
2881 mScreenDpiChangedConnection = connect( windowInLambda->screen(), &QScreen::physicalDotsPerInchChanged,
this, &QgsMapCanvas::updateDevicePixelFromScreen );
2882 updateDevicePixelFromScreen();
2886 mScreenDpiChangedConnection = connect( l_window->screen(), &QScreen::physicalDotsPerInchChanged,
this, &QgsMapCanvas::updateDevicePixelFromScreen );
2897 if ( !mPreviewEffect )
2902 mPreviewEffect->setEnabled( previewEnabled );
2907 if ( !mPreviewEffect )
2912 return mPreviewEffect->isEnabled();
2917 if ( !mPreviewEffect )
2922 mPreviewEffect->
setMode( mode );
2927 if ( !mPreviewEffect )
2932 return mPreviewEffect->
mode();
2937 if ( !mSnappingUtils )
2943 return mSnappingUtils;
2948 mSnappingUtils = utils;
2955 QDomNodeList nodes = doc.elementsByTagName( QStringLiteral(
"mapcanvas" ) );
2956 if ( nodes.count() )
2958 QDomNode node = nodes.item( 0 );
2961 if ( nodes.count() > 1 )
2963 for (
int i = 0; i < nodes.size(); ++i )
2965 QDomElement elementNode = nodes.at( i ).toElement();
2967 if ( elementNode.hasAttribute( QStringLiteral(
"name" ) ) && elementNode.attribute( QStringLiteral(
"name" ) ) == objectName() )
2969 node = nodes.at( i );
2977 if ( objectName() != QLatin1String(
"theMapCanvas" ) )
2988 QDomElement elem = node.toElement();
2989 if ( elem.hasAttribute( QStringLiteral(
"theme" ) ) )
2991 if (
QgsProject::instance()->mapThemeCollection()->hasMapTheme( elem.attribute( QStringLiteral(
"theme" ) ) ) )
2993 setTheme( elem.attribute( QStringLiteral(
"theme" ) ) );
2996 setAnnotationsVisible( elem.attribute( QStringLiteral(
"annotationsVisible" ), QStringLiteral(
"1" ) ).toInt() );
2999 const QDomNodeList scopeElements = elem.elementsByTagName( QStringLiteral(
"expressionContextScope" ) );
3000 if ( scopeElements.size() > 0 )
3002 const QDomElement scopeElement = scopeElements.at( 0 ).toElement();
3008 QgsDebugMsg( QStringLiteral(
"Couldn't read mapcanvas information from project" ) );
3023 QDomNodeList nl = doc.elementsByTagName( QStringLiteral(
"qgis" ) );
3026 QgsDebugMsg( QStringLiteral(
"Unable to find qgis element in project file" ) );
3029 QDomNode qgisNode = nl.item( 0 );
3031 QDomElement mapcanvasNode = doc.createElement( QStringLiteral(
"mapcanvas" ) );
3032 mapcanvasNode.setAttribute( QStringLiteral(
"name" ), objectName() );
3033 if ( !mTheme.isEmpty() )
3034 mapcanvasNode.setAttribute( QStringLiteral(
"theme" ), mTheme );
3035 mapcanvasNode.setAttribute( QStringLiteral(
"annotationsVisible" ), mAnnotationsVisible );
3036 qgisNode.appendChild( mapcanvasNode );
3038 mSettings.
writeXml( mapcanvasNode, doc );
3041 QDomElement scopeElement = doc.createElement( QStringLiteral(
"expressionContextScope" ) );
3043 tmpScope.
removeVariable( QStringLiteral(
"atlas_featurenumber" ) );
3049 mapcanvasNode.appendChild( scopeElement );
3056 if ( mScaleLocked && !ignoreScaleLock )
3058 ScaleRestorer restorer(
this );
3093 bool allHandled =
true;
3096 bool handled =
false;
3099 if ( handler->canHandleCustomUriCanvasDrop( uri,
this ) )
3125 return QGraphicsView::viewportEvent(
event );
3128 void QgsMapCanvas::mapToolDestroyed()
3136 if ( !QTouchDevice::devices().empty() )
3138 if ( e->type() == QEvent::Gesture )
3140 if ( QTapAndHoldGesture *tapAndHoldGesture = qobject_cast< QTapAndHoldGesture * >(
static_cast<QGestureEvent *
>( e )->gesture( Qt::TapAndHoldGesture ) ) )
3142 QPointF pos = tapAndHoldGesture->position();
3143 pos = mapFromGlobal( QPoint( pos.x(), pos.y() ) );
3151 return mMapTool->
gestureEvent(
static_cast<QGestureEvent *
>( e ) );
3157 return QGraphicsView::event( e );
3183 while ( mRefreshScheduled || mJob )
3185 QgsApplication::processEvents();
3201 QList<QgsMapCanvasAnnotationItem *> annotationItemList;
3202 const QList<QGraphicsItem *> items = mScene->items();
3203 for ( QGraphicsItem *gi : items )
3208 annotationItemList.push_back( aItem );
3212 return annotationItemList;
3217 mAnnotationsVisible = show;
3221 item->setVisible( show );
3235 void QgsMapCanvas::startPreviewJobs()
3244 schedulePreviewJob( 0 );
3247 void QgsMapCanvas::startPreviewJob(
int number )
3260 double dx = ( i - 1 ) * mapRect.
width();
3261 double dy = ( 1 - j ) * mapRect.
height();
3274 const QList<QgsMapLayer *>
layers = jobSettings.
layers();
3275 QList< QgsMapLayer * > previewLayers;
3284 QgsDebugMsgLevel( QStringLiteral(
"Layer %1 not rendered because it does not match the renderInPreview criterion %2" ).arg(
layer->
id() ).arg( mLastLayerRenderTime.value(
layer->
id() ) ), 3 );
3288 previewLayers <<
layer;
3293 job->setProperty(
"number", number );
3294 mPreviewJobs.append( job );
3299 void QgsMapCanvas::stopPreviewJobs()
3301 mPreviewTimer.stop();
3302 for (
auto previewJob = mPreviewJobs.constBegin(); previewJob != mPreviewJobs.constEnd(); ++previewJob )
3308 ( *previewJob )->cancelWithoutBlocking();
3311 mPreviewJobs.clear();
3314 void QgsMapCanvas::schedulePreviewJob(
int number )
3316 mPreviewTimer.setSingleShot(
true );
3317 mPreviewTimer.setInterval( PREVIEW_JOB_DELAY_MS );
3318 disconnect( mPreviewTimerConnection );
3319 mPreviewTimerConnection = connect( &mPreviewTimer, &QTimer::timeout,
this, [ = ]()
3321 startPreviewJob( number );
3323 mPreviewTimer.start();
3326 bool QgsMapCanvas::panOperationInProgress()
3331 if (
QgsMapToolPan *panTool = qobject_cast< QgsMapToolPan *>( mMapTool ) )
3333 if ( panTool->isDragging() )
3340 int QgsMapCanvas::nextZoomLevel(
const QList<double> &resolutions,
bool zoomIn )
const
3342 int resolutionLevel = -1;
3345 for (
int i = 0, n = resolutions.size(); i < n; ++i )
3347 if (
qgsDoubleNear( resolutions[i], currentResolution, 0.0001 ) )
3349 resolutionLevel =
zoomIn ? ( i - 1 ) : ( i + 1 );
3352 else if ( currentResolution <= resolutions[i] )
3354 resolutionLevel =
zoomIn ? ( i - 1 ) : i;
3358 return ( resolutionLevel < 0 || resolutionLevel >= resolutions.size() ) ? -1 : resolutionLevel;
3363 if ( !mZoomResolutions.isEmpty() )
3365 int zoomLevel = nextZoomLevel( mZoomResolutions,
true );
3366 if ( zoomLevel != -1 )
3371 return 1 / mWheelZoomFactor;
3376 if ( !mZoomResolutions.isEmpty() )
3378 int zoomLevel = nextZoomLevel( mZoomResolutions,
false );
3379 if ( zoomLevel != -1 )
3384 return mWheelZoomFactor;
QPoint rubberStartPoint
Beginning point of a rubber band.
void renderStarting()
Emitted when the canvas is about to be rendered.
void zRangeChanged()
Emitted when the map canvas z (elevation) range changes.
QgsRectangle projectExtent() const
Returns the associated project's full extent, in the canvas' CRS.
void mouseDoubleClickEvent(QMouseEvent *e) override
@ MaximumAngle
Maximum angle between generating radii (lines from arc center to output vertices)
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QgsCoordinateReferenceSystem crs
const QgsLabelingEngineSettings & labelingEngineSettings() const
Returns the global configuration of the labeling engine.
void renderErrorOccurred(const QString &error, QgsMapLayer *layer)
Emitted whenever an error is encountered during a map render operation.
void panToSelected(QgsVectorLayer *layer=nullptr)
Pan to the selected features of current (vector) layer keeping same extent.
void currentLayerChanged(QgsMapLayer *layer)
Emitted when the current layer is changed.
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs)
Sets the destination crs (coordinate reference system) for the map render.
void dropEvent(QDropEvent *event) override
@ RenderPartialOutput
Whether to make extra effort to update map image with partially rendered layers (better for interacti...
void waitWhileRendering()
Blocks until the rendering job has finished.
void zoomToPreviousExtent()
Zoom to the previous extent (view)
@ Animated
Temporal navigation relies on frames within a datetime range.
virtual QgsTemporalProperty::Flags flags() const
Returns flags associated to the temporal property.
double height() const SIP_HOLDGIL
Returns the height of the rectangle.
bool hasAutoRefreshEnabled() const
Returns true if auto refresh is enabled for the layer.
An interface for objects which block interactions with a QgsMapCanvas.
An interactive map canvas item which displays a QgsAnnotation.
virtual bool usedCachedLabels() const =0
Returns true if the render job was able to use a cached labeling solution.
QgsRectangle extent() const
Returns the current zoom extent of the map canvas.
@ UseRenderingOptimization
Enable vector simplification and other rendering optimizations.
QPoint mouseLastXY
Last seen point of the mouse.
void moveCanvasContents(bool reset=false)
called when panning is in action, reset indicates end of panning
void mapThemeRenamed(const QString &name, const QString &newName)
Emitted when a map theme within the collection is renamed.
QgsPointXY mapToLayerCoordinates(const QgsMapLayer *layer, QgsPointXY point) const
transform point coordinates from output CRS to layer's CRS
void setTheme(const QString &theme)
Sets a map theme to show in the canvas.
const QgsProjectViewSettings * viewSettings() const
Returns the project's view settings, which contains settings and properties relating to how a QgsProj...
void mapToolSet(QgsMapTool *newTool, QgsMapTool *oldTool)
Emit map tool changed with the old tool.
const QgsMapSettings & mapSettings() const
Returns map settings with which this job was started.
void refresh()
Repaints the canvas map.
void setVariable(const QString &name, const QVariant &value, bool isStatic=false)
Convenience method for setting a variable in the context scope by name name and value.
void setProject(QgsProject *project)
Sets the project linked to this canvas.
void setWheelFactor(double factor)
Sets wheel zoom factor (should be greater than 1)
bool isDrawing()
Find out whether rendering is in progress.
double mapUnitsPerPixel() const
Returns the current map units per pixel.
void readXml(QDomNode &node)
@ ICON_CIRCLE
A circle is used to highlight points (â—‹)
void combineExtentWith(const QgsRectangle &rect)
Expands the rectangle so that it covers both the original rectangle and the given rectangle.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void waitForFinished() override
Block until the job has finished.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
The class is used as a container of context for various read/write operations on other objects.
void destinationCrsChanged()
Emitted when map CRS has changed.
Abstract base class for spatial data provider implementations.
QSize outputSize() const
Returns the size of the resulting map image, in pixels.
void setFlag(Qgis::MapSettingsFlag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected)
void zoomScale(double scale, bool ignoreScaleLock=false)
Zooms the canvas to a specific scale.
void xyCoordinates(const QgsPointXY &p)
Emits current mouse position.
void setRotation(double rotation)
Sets the rotation of the resulting map image, in degrees clockwise.
QgsMapTool * mapTool()
Returns the currently active tool.
void zoomByFactor(double scaleFactor, const QgsPointXY *center=nullptr, bool ignoreScaleLock=false)
Zoom with the factor supplied.
virtual bool isActive() const =0
Tell whether the rendering job is currently running in background.
void zoomOut()
Zoom out with fixed factor.
QString userFriendlyIdentifier(IdentifierType type=MediumString) const
Returns a user friendly identifier for the CRS.
void zoomLastStatusChanged(bool)
Emitted when zoom last status changed.
QPoint mouseLastXY()
returns last position of mouse cursor
A QgsRectangle with associated coordinate reference system.
void updatePosition() override
called on changed extent or resize event to update position of the item
void mouseMoveEvent(QMouseEvent *e) override
#define QgsDebugMsgLevel(str, level)
constexpr double CANVAS_MAGNIFICATION_MIN
Minimum magnification level allowed in map canvases.
@ WKT_PREFERRED
Preferred format, matching the most recent WKT ISO standard. Currently an alias to WKT2_2019,...
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
void redrawAllLayers()
Clears all cached images and redraws all layers.
A class for drawing transient features (e.g. digitizing lines) on the map.
@ DrawLabeling
Enable drawing of labels on top of the map.
bool antiAliasingEnabled() const
true if antialiasing is enabled
float devicePixelRatio() const
Returns the device pixel ratio.
QgsPointXY center() const SIP_HOLDGIL
Returns the center point of the rectangle.
void readXml(const QDomElement &element, const QgsReadWriteContext &context)
Reads scope variables from an XML element.
virtual QImage renderedImage()=0
Gets a preview/resulting image.
const QgsCoordinateReferenceSystem & crs
bool mouseButtonDown
Flag to indicate status of mouse button.
static QCursor getThemeCursor(Cursor cursor)
Helper to get a theme cursor.
void setIsTemporal(bool enabled)
Sets whether the temporal range is enabled (i.e.
void messageEmitted(const QString &title, const QString &message, Qgis::MessageLevel=Qgis::MessageLevel::Info)
emit a message (usually to be displayed in a message bar)
void flashGeometries(const QList< QgsGeometry > &geometries, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem(), const QColor &startColor=QColor(255, 0, 0, 255), const QColor &endColor=QColor(255, 0, 0, 0), int flashes=3, int duration=500)
Causes a set of geometries to flash within the canvas.
void mouseReleaseEvent(QMouseEvent *e) override
void mapThemeChanged(const QString &theme)
Emitted when a map theme changes definition.
void temporalRangeChanged()
Emitted when the map canvas temporal range changes.
A generic dialog to prompt the user for a Coordinate Reference System.
void clear()
Invalidates the cache contents, clearing all cached images.
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
static QgsGeometry fromPointXY(const QgsPointXY &point) SIP_HOLDGIL
Creates a new geometry from a QgsPointXY object.
bool hasValidSettings() const
Check whether the map settings are valid and can be used for rendering.
Map canvas is a class for displaying all GIS data types on a canvas.
void panActionEnd(QPoint releasePoint)
Ends pan action and redraws the canvas.
void setMagnificationFactor(double factor, const QgsPointXY *center=nullptr)
Sets the factor of magnification to apply to the map canvas.
QgsRectangle fullExtent() const
returns current extent of layer set
void setSegmentationToleranceType(QgsAbstractGeometry::SegmentationToleranceType type)
Sets segmentation tolerance type (maximum angle or maximum difference between curve and approximation...
void writeXml(QDomNode &node, QDomDocument &doc)
QgsPointXY center() const
Gets map center, in geographical coordinates.
Class that stores computed placement from labeling engine.
bool writeXml(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Writes scope variables to an XML element.
QList< Qgis::CrsAxisDirection > axisOrdering() const
Returns an ordered list of the axis directions reflecting the native axis order for the CRS.
QgsCoordinateTransformContext transformContext
const QgsDateTimeRange & temporalRange() const
Returns the datetime range for the object.
QgsRectangle fullExtent() const
Returns the combined extent for all layers on the map canvas.
double mapUnitsPerPixel() const
Returns the distance in geographical coordinates that equals to one pixel in the map.
void setRotation(double degrees)
Set the rotation of the map canvas in clockwise degrees.
static QgsExpressionContextScope * mapSettingsScope(const QgsMapSettings &mapSettings)
Creates a new scope which contains variables and functions relating to a QgsMapSettings object.
void setMinimal() SIP_HOLDGIL
Set a rectangle so that min corner is at max and max corner is at min.
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsRectangle layerExtentToOutputExtent(const QgsMapLayer *layer, QgsRectangle extent) const
transform bounding box from layer's CRS to output CRS
void setStrokeColor(const QColor &color)
Sets the stroke color for the rubberband.
double scale() const
Returns the last reported scale of the canvas.
void rotationChanged(double)
Emitted when the rotation of the map changes.
void readProject(const QDomDocument &)
Emitted when a project is being read.
static double rendererFrameRate(const QgsFeatureRenderer *renderer)
Calculates the frame rate (in frames per second) at which the given renderer must be redrawn.
void setFrameRate(double rate)
Sets the frame rate of the map (in frames per second), for maps which are part of an animation.
void zoomWithCenter(int x, int y, bool zoomIn)
Zooms in/out with a given center.
double magnificationFactor() const
Returns the magnification factor.
void setFillColor(const QColor &color)
Sets the fill color for the rubberband.
QMap< QString, QString > layerStyleOverrides() const
Returns the map of map layer style overrides (key: layer ID, value: style name) where a different sty...
void zoomToProjectExtent()
Zoom to the full extent the project associated with this canvas.
This class is a composition of two QSettings instances:
void writeProject(QDomDocument &)
called to write map canvas settings to project
void selectionChangedSlot()
Receives signal about selection change, and pass it on with layer info.
virtual Q_INVOKABLE void reload()
Synchronises with changes in the datasource.
void panAction(QMouseEvent *event)
Called when mouse is moving and pan is activated.
void setZRange(const QgsDoubleRange &range)
Sets the range of z-values which will be visible in the map.
Abstract interface for generating an expression context scope.
void clearCache()
Make sure to remove any rendered images from cache (does nothing if cache is not enabled)
bool panSelectorDown
Flag to indicate the pan selector key is held down by user.
void setCurrentFrame(long long frame)
Sets the current frame of the map, for maps which are part of an animation.
const QgsRenderedItemResults * renderedItemResults(bool allowOutdatedResults=true) const
Gets access to the rendered item results (may be nullptr), which includes the results of rendering an...
QgsUnitTypes::DistanceUnit mapUnits() const
Convenience function for returning the current canvas map units.
SegmentationToleranceType
Segmentation tolerance as maximum angle or maximum difference between approximation and circle.
void setOutputDpi(double dpi)
Sets the dpi (dots per inch) used for conversion between real world units (e.g.
QList< QgsMimeDataUtils::Uri > UriList
void dragEnterEvent(QDragEnterEvent *e) override
@ IgnoreImpossibleTransformations
Indicates that impossible transformations (such as those which attempt to transform between two diffe...
DistanceUnit
Units of distance.
void paintEvent(QPaintEvent *e) override
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
QgsPointXY toMapCoordinates(int x, int y) const
Transforms device coordinates to map (world) coordinates.
QColor secondaryStrokeColor
void freeze(bool frozen=true)
Freeze/thaw the map canvas.
bool viewportEvent(QEvent *event) override
@ BallparkTransformsAreAppropriate
Indicates that approximate "ballpark" results are appropriate for this coordinate transform....
void wheelEvent(QWheelEvent *e) override
QgsMapCanvas(QWidget *parent=nullptr)
Constructor.
void setSegmentationTolerance(double tolerance)
Sets the segmentation tolerance applied when rendering curved geometries.
A rectangle specified with double values.
void setSegmentationToleranceType(QgsAbstractGeometry::SegmentationToleranceType type)
Sets segmentation tolerance type (maximum angle or maximum difference between curve and approximation...
This class is responsible for keeping cache of rendered images resulting from a map rendering job.
@ Antialiasing
Enable anti-aliasing for map rendering.
bool isEditable() const FINAL
Returns true if the provider is in editing mode.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
constexpr double CANVAS_MAGNIFICATION_MAX
Maximum magnification level allowed in map canvases.
QgsSnappingUtils * snappingUtils() const
Returns snapping utility class that is associated with map canvas.
void setPreviewJobsEnabled(bool enabled)
Sets whether canvas map preview jobs (low priority render jobs which render portions of the view just...
bool allowInteraction(QgsMapCanvasInteractionBlocker::Interaction interaction) const
Returns true if the specified interaction is currently permitted on the canvas.
void scaleChanged(double)
Emitted when the scale of the map changes.
@ RenderPreviewJob
Render is a 'canvas preview' render, and shortcuts should be taken to ensure fast rendering.
QgsRectangle extent() const
Returns geographical coordinates of the rectangle that should be rendered.
const QgsLabelingResults * labelingResults(bool allowOutdatedResults=true) const
Gets access to the labeling results (may be nullptr).
void writeProject(QDomDocument &)
Emitted when the project is being written.
bool isParallelRenderingEnabled() const
Check whether the layers are rendered in parallel or sequentially.
int renderingTime() const
Returns the total time it took to finish the job (in milliseconds).
virtual bool hasElevation() const
Returns true if the layer has an elevation or z component.
void scaleLockChanged(bool locked)
Emitted when the scale locked state of the map changes.
double sqrDist(double x, double y) const SIP_HOLDGIL
Returns the squared distance between this point a specified x, y coordinate.
void navigationModeChanged(QgsTemporalNavigationObject::NavigationMode mode)
Emitted whenever the navigation mode changes.
void setLayerRenderingTimeHints(const QHash< QString, int > &hints)
Sets approximate render times (in ms) for map layers.
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken.
Snapping utils instance that is connected to a canvas and updates the configuration (map settings + c...
void setCurrentLayer(QgsMapLayer *layer)
Errors errors() const
List of errors that happened during the rendering job - available when the rendering has been finishe...
Job implementation that renders all layers in parallel.
virtual void updatePosition()
called on changed extent or resize event to update position of the item
double xMaximum() const SIP_HOLDGIL
Returns the x maximum value (right side of rectangle).
double rotation() const
Gets the current map canvas rotation in clockwise degrees.
void scale(double scaleFactor, const QgsPointXY *c=nullptr)
Scale the rectangle around its center point.
static Qgis::CoordinateOrder defaultCoordinateOrderForCrs(const QgsCoordinateReferenceSystem &crs)
Returns the default coordinate order to use for the specified crs.
bool setEllipsoid(const QString &ellipsoid)
Sets the ellipsoid by its acronym.
void zoomIn()
Zoom in with fixed factor.
void readProject(const QDomDocument &)
called to read map canvas settings from project
This class wraps a request for features to a vector layer (or directly its vector data provider).
@ DrawEditingInfo
Enable drawing of vertex markers for layers in editing mode.
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
void enableAntiAliasing(bool flag)
used to determine if anti-aliasing is enabled or not
void showEvent(QShowEvent *event) override
Custom exception class for Coordinate Reference System related exceptions.
void cancelJobs()
Cancel any rendering job, in a blocking way.
void start()
Start the rendering job and immediately return.
void setBackgroundColor(const QColor &color)
Sets the background color of the map.
void setTemporalController(QgsTemporalController *controller)
Sets the temporal controller for this canvas.
An abstract class for items that can be placed on the map canvas.
QgsReferencedRectangle defaultViewExtent() const
Returns the default view extent, which should be used as the initial map extent when this project is ...
void setPreviewMode(QgsPreviewEffect::PreviewMode mode)
Sets a preview mode for the map canvas.
QHash< QgsMapLayer *, int > perLayerRenderingTime() const
Returns the render time (in ms) per layer.
void addGeometry(const QgsGeometry &geometry, QgsMapLayer *layer, bool doUpdate=true)
Adds the geometry of an existing feature to a rubberband This is useful for multi feature highlightin...
virtual Q_INVOKABLE QgsDataProvider * dataProvider()
Returns the layer's data provider, it may be nullptr.
int layerCount() const
Returns number of layers on the map.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum tran...
double rotation() const
Returns the rotation of the resulting map image, in degrees clockwise.
QStringList layerIds(bool expandGroupLayers=false) const
Returns the list of layer IDs which will be rendered in the map.
virtual void waitForFinished()=0
Block until the job has finished.
QMap< QString, QString > layerStyleOverrides() const
Returns the stored overrides of styles for layers.
bool testFlag(Qgis::MapSettingsFlag flag) const
Check whether a particular flag is enabled.
bool isActive() const
Returns true if the temporal property is active.
@ DistanceDegrees
Degrees, for planar geographic CRS distance measurements.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
QColor canvasColor() const
Read property of QColor bgColor.
Stores global configuration for labeling engine.
virtual QgsMapLayerElevationProperties::Flags flags() const
Returns flags associated to the elevation properties.
void selectionChanged(const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect)
Emitted when selection was changed.
void zoomToSelected(QgsVectorLayer *layer=nullptr)
Zoom to the extent of the selected features of provided (vector) layer.
QgsExpressionContextScope * defaultExpressionContextScope() const
Creates a new scope which contains default variables and functions relating to the map canvas.
void setDevicePixelRatio(float dpr)
Sets the device pixel ratio.
Interaction
Available interactions to block.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
void layersChanged()
Emitted when a new set of layers has been received.
void repaintRequested(bool deferredUpdate=false)
By emitting this signal the layer tells that either appearance or content have been changed and any v...
QgsMapLayer * layer(int index)
Returns the map layer at position index in the layer stack.
QgsReferencedRectangle fullExtent() const
Returns the full extent of the project, which represents the maximal limits of the project.
void setCache(QgsMapRendererCache *cache)
Assign a cache to be used for reading and storing rendered images of individual layers.
QgsUnitTypes::DistanceUnit mapUnits() const
Returns the units of the map's geographical coordinates - used for scale calculation.
void setMagnificationFactor(double factor, const QgsPointXY *center=nullptr)
Set the magnification factor.
void keyReleaseEvent(QKeyEvent *e) override
static QgsCoordinateReferenceSystemRegistry * coordinateReferenceSystemRegistry()
Returns the application's coordinate reference system (CRS) registry, which handles known CRS definit...
double measureLine(const QVector< QgsPointXY > &points) const
Measures the length of a line with multiple segments.
void projectColorsChanged()
Emitted whenever the project's color scheme has been changed.
void extentsChanged()
Emitted when the extents of the map change.
void setSegmentationTolerance(double tolerance)
Sets the segmentation tolerance applied when rendering curved geometries.
void mapThemesChanged()
Emitted when map themes within the collection are changed.
void updateCanvasItemPositions()
called on resize or changed extent to notify canvas items to change their rectangle
QgsDoubleRange zRange() const
Returns the range of z-values which will be visible in the map.
A controller base class for temporal objects, contains a signal for notifying updates of the objects ...
void mapRefreshCanceled()
Emitted when the pending map refresh has been canceled.
QgsUnitTypes::DistanceUnit lengthUnits() const
Returns the units of distance for length calculations made by this object.
static QgsImageCache * imageCache()
Returns the application's image cache, used for caching resampled versions of raster images.
virtual QgsMapLayerTemporalProperties * temporalProperties()
Returns the layer's temporal properties.
Job implementation that renders everything sequentially in one thread.
Stores settings related to the context in which a preview job runs.
void setTemporalRange(const QgsDateTimeRange &range)
Set datetime range for the map canvas.
std::unique_ptr< CanvasProperties > mCanvasProperties
Handle pattern for implementation object.
void setSelectionColor(const QColor &color)
Sets the color that is used for drawing of selected vector features.
void setXMinimum(double x) SIP_HOLDGIL
Set the minimum x value.
QgsRenderedItemResults * takeRenderedItemResults()
Takes the rendered item results from the map render job and returns them.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
void updateScale()
Emits signal scaleChanged to update scale in main window.
static void warning(const QString &msg)
Goes to qWarning.
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs)
Sets destination coordinate reference system.
void setCanvasColor(const QColor &_newVal)
Write property of QColor bgColor.
void setCenter(const QgsPointXY ¢er)
Set the center of the map canvas, in geographical coordinates.
void resizeEvent(QResizeEvent *e) override
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
QgsDoubleRange zRange() const
Returns the range of z-values which will be visible in the map.
const QgsLabelingEngineSettings & labelingEngineSettings() const
Returns global labeling engine settings from the internal map settings.
void enableMapTileRendering(bool flag)
sets map tile rendering flag
void zoomToFullExtent()
Zoom to the full extent of all layers currently visible in the canvas.
QColor selectionColor() const
Returns color for selected features.
double scale() const
Returns the calculated map scale.
void layerStyleOverridesChanged()
Emitted when the configuration of overridden layer styles changes.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
QgsMapThemeCollection mapThemeCollection
double maxRenderingTimeMs
Default maximum allowable render time, in ms.
void zoomToNextExtent()
Zoom to the next extent (view)
bool setReferencedExtent(const QgsReferencedRectangle &extent) SIP_THROW(QgsCsException)
Sets the canvas to the specified extent.
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
static QgsRectangle combinedExtent(const QList< QgsMapLayer * > &layers, const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &transformContext)
Returns the combined extent of a list of layers.
void refreshAllLayers()
Reload all layers (including refreshing layer properties from their data sources),...
void setSourceCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets source spatial reference system crs.
Scoped object for saving and restoring a QPainter object's state.
void transferResults(QgsRenderedItemResults *other, const QStringList &layerIds)
Transfers all results from an other QgsRenderedItemResults object where the items have layer IDs matc...
void setExtent(const QgsRectangle &r, bool magnified=false)
Sets the extent of the map canvas to the specified rectangle.
void transformContextChanged()
Emitted when the project transformContext() is changed.
void setMapTool(QgsMapTool *mapTool, bool clean=false)
Sets the map tool currently being used on the canvas.
QgsPreviewEffect::PreviewMode previewMode() const
Returns the current preview mode for the map canvas.
const QgsMapToPixel * getCoordinateTransform()
Gets the current coordinate transform.
QgsFeatureRequest & setNoAttributes()
Set that no attributes will be fetched.
void setParallelRenderingEnabled(bool enabled)
Set whether the layers are rendered in parallel or sequentially.
void panToFeatureIds(QgsVectorLayer *layer, const QgsFeatureIds &ids, bool alwaysRecenter=true)
Centers canvas extent to feature ids.
virtual bool isEmpty() const
Returns true if the geometry is empty.
const QgsAbstractGeometry * constGet() const SIP_HOLDGIL
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
QSet< QgsFeatureId > QgsFeatureIds
void rendererChanged()
Signal emitted when renderer is changed.
void keyPressEvent(QKeyEvent *e) override
@ HighQualityImageTransforms
Enable high quality image transformations, which results in better appearance of scaled or rotated ra...
void zoomToFeatureExtent(QgsRectangle &rect)
Zooms to feature extent.
void saveAsImage(const QString &fileName, QPixmap *QPixmap=nullptr, const QString &="PNG")
Save the contents of the map canvas to disk as an image.
This class represents a coordinate reference system (CRS).
virtual bool renderInPreview(const QgsDataProvider::PreviewContext &context)
Returns whether the layer must be rendered in preview jobs.
void setXMaximum(double x) SIP_HOLDGIL
Set the maximum x value.
Implements a temporal controller based on a frame by frame navigation and animation.
This class has all the configuration of snapping and can return answers to snapping queries.
QColor selectionColor() const
Returns the color that is used for drawing of selected vector features.
static QString worldFileContent(const QgsMapSettings &mapSettings)
Creates the content of a world file.
void setRenderFlag(bool flag)
Sets whether a user has disabled canvas renders via the GUI.
int mapUpdateInterval() const
Find out how often map preview should be updated while it is being rendered (in milliseconds)
Single scope for storing variables and functions for use within a QgsExpressionContext....
static QgsSvgCache * svgCache()
Returns the application's SVG cache, used for caching SVG images and handling parameter replacement w...
void setLabelingEngineSettings(const QgsLabelingEngineSettings &settings)
Sets the global configuration of the labeling engine.
void setLayers(const QList< QgsMapLayer * > &layers)
Sets the list of layers to render in the map.
void setScaleLocked(bool isLocked)
Lock the scale, so zooming can be performed using magnication.
void flashFeatureIds(QgsVectorLayer *layer, const QgsFeatureIds &ids, const QColor &startColor=QColor(255, 0, 0, 255), const QColor &endColor=QColor(255, 0, 0, 0), int flashes=3, int duration=500)
Causes a set of features with matching ids from a vector layer to flash within the canvas.
A class to represent a 2D point.
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination coordinate reference system for the map render.
Job implementation that renders everything sequentially using a custom painter.
void setYMaximum(double y) SIP_HOLDGIL
Set the maximum y value.
QgsPointXY asPoint() const
Returns the contents of the geometry as a 2-dimensional point.
void setDpiTarget(double dpi)
Sets the target dpi (dots per inch) to be taken into consideration when rendering.
void removeInteractionBlocker(QgsMapCanvasInteractionBlocker *blocker)
Removes an interaction blocker from the canvas.
void setMapUpdateInterval(int timeMilliseconds)
Set how often map preview should be updated while it is being rendered (in milliseconds)
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
void keyReleased(QKeyEvent *e)
Emit key release event.
const QgsDateTimeRange & temporalRange() const
Returns map canvas datetime range.
A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas....
void clearExtentHistory()
Clears the list of extents and sets current extent as first item.
QList< QgsMapLayer * > layers(bool expandGroupLayers=false) const
Returns the list of layers shown within the map canvas.
Intermediate base class adding functionality that allows client to query the rendered image.
QgsRange which stores a range of double values.
void updateTemporalRange(const QgsDateTimeRange &range)
Signals that a temporal range has changed and needs to be updated in all connected objects.
bool event(QEvent *e) override
QgsUnitTypes::DistanceUnit mapUnits
void setWidth(int width)
Sets the width of the line.
double yMaximum() const SIP_HOLDGIL
Returns the y maximum value (top side of rectangle).
static const QgsSettingsEntryBool settingsLogCanvasRefreshEvent
Settings entry log canvas refresh event.
void release()
Releases the cursor override early (i.e.
void setAnnotationsVisible(bool visible)
Sets whether annotations are visible in the canvas.
void canvasColorChanged()
Emitted when canvas background color changes.
static UriList decodeUriList(const QMimeData *data)
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
void tapAndHoldGestureOccurred(const QgsPointXY &mapPoint, QTapAndHoldGesture *gesture)
Emitted whenever a tap and hold gesture occurs at the specified map point.
void setCustomDropHandlers(const QVector< QPointer< QgsCustomDropHandler >> &handlers)
Sets a list of custom drop handlers to use when drop events occur on the canvas.
@ YX
Northing/Easting (or Latitude/Longitude for geographic CRS)
bool nextFeature(QgsFeature &f)
void setYMinimum(double y) SIP_HOLDGIL
Set the minimum y value.
void themeChanged(const QString &theme)
Emitted when the canvas has been assigned a different map theme.
QStringList layersRedrawnFromCache() const
Returns a list of the layer IDs for all layers which were redrawn from cached images.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
A geometry is the spatial representation of a feature.
Perform transforms between map coordinates and device coordinates.
void setLayerStyleOverrides(const QMap< QString, QString > &overrides)
Sets the map of map layer style overrides (key: layer ID, value: style name) where a different style ...
Represents a vector layer which manages a vector based data sets.
bool hasGeometry() const
Returns true if the feature has an associated geometry.
double width() const SIP_HOLDGIL
Returns the width of the rectangle.
QgsFeatureRequest & setLimit(long long limit)
Set the maximum number of features to request.
bool isCachingEnabled() const
Check whether images of rendered layers are curerently being cached.
void selectionChanged(QgsVectorLayer *layer)
Emitted when selection in any layer gets changed.
Base class for all map layer types. This is the base class for all map layer types (vector,...
bool isFrozen() const
Returns true if canvas is frozen.
QgsProject * project()
Returns the project linked to this canvas.
A class to represent a vector. Currently no Z axis / 2.5D support is implemented.
void magnificationChanged(double)
Emitted when the scale of the map changes.
double zoomOutFactor() const
Returns the zoom in factor.
Abstract base class that may be implemented to handle new types of data to be dropped in QGIS.
Scoped object for logging of the runtime for a single operation or group of operations.
void ellipsoidChanged(const QString &ellipsoid)
Emitted when the project ellipsoid is changed.
virtual void cancelWithoutBlocking()=0
Triggers cancellation of the rendering job without blocking.
bool previewModeEnabled() const
Returns whether a preview mode is enabled for the map canvas.
double defaultRotation() const
Returns the default map rotation (in clockwise degrees) for maps in the project.
void setFlags(Qgis::MapSettingsFlags flags)
Sets combination of flags that will be used for rendering.
void setPreviewModeEnabled(bool previewEnabled)
Enables a preview mode for the map canvas.
void clearCacheImage(const QString &cacheKey)
Removes an image from the cache with matching cacheKey.
void panDistanceBearingChanged(double distance, QgsUnitTypes::DistanceUnit unit, double bearing)
Emitted whenever the distance or bearing of an in-progress panning operation is changed.
void setIcon(IconType icon)
Sets the icon type to highlight point geometries.
void keyPressed(QKeyEvent *e)
Emit key press event.
void unsetMapTool(QgsMapTool *mapTool)
Unset the current map tool or last non zoom tool.
static GeometryType geometryType(Type type) SIP_HOLDGIL
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
void mousePressEvent(QMouseEvent *e) override
@ NavigationOff
Temporal navigation is disabled.
static QgsExpressionContextScope * atlasScope(const QgsLayoutAtlas *atlas)
Creates a new scope which contains variables and functions relating to a QgsLayoutAtlas.
void renderComplete(QPainter *)
Emitted when the canvas has rendered.
Deprecated to be deleted, stuff from here should be moved elsewhere.
void setTemporalRange(const QgsDateTimeRange &range)
Sets the temporal range for the object.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
A general purpose distance and area calculator, capable of performing ellipsoid based calculations.
void setMode(PreviewMode mode)
Sets the mode for the preview effect, which controls how the effect modifies a widgets appearance.
static QString axisDirectionToAbbreviatedString(Qgis::CrsAxisDirection axis)
Returns a translated abbreviation representing an axis direction.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
double magnificationFactor() const
Returns the magnification factor.
A graphics effect which can be applied to a widget to simulate various printing and color blindness m...
virtual QgsLabelingResults * takeLabelingResults()=0
Gets pointer to internal labeling engine (in order to get access to the results).
QgsMapLayer * currentLayer()
returns current layer (set by legend widget)
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
void setSnappingUtils(QgsSnappingUtils *utils)
Assign an instance of snapping utils to the map canvas.
bool hasMapTheme(const QString &name) const
Returns whether a map theme with a matching name exists.
void contextMenuAboutToShow(QMenu *menu, QgsMapMouseEvent *event)
Emitted before the map canvas context menu will be shown.
double lastRenderingTimeMs
Previous rendering time for the layer, in ms.
void zoomToFeatureIds(QgsVectorLayer *layer, const QgsFeatureIds &ids)
Set canvas extent to the bounding box of a set of features.
QList< QgsMapRendererJob::Error > Errors
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
void remoteImageFetched(const QString &url)
Emitted when the cache has finished retrieving an image file from a remote url.
static const QgsSettingsEntryBool settingsRespectScreenDPI
Settings entry respect screen dpi.
void zoomNextStatusChanged(bool)
Emitted when zoom next status changed.
int selectedFeatureCount() const
Returns the number of features that are selected in this layer.
Stores collated details of rendered items during a map rendering operation.
T enumValue(const QString &key, const T &defaultValue, const Section section=NoSection)
Returns the setting value for a setting based on an enum.
virtual bool isSpatial() const
Returns true if the layer is considered a spatial layer, ie it has some form of geometry associated w...
void setZRange(const QgsDoubleRange &range)
Sets the range of z-values which will be visible in the map.
void setLayers(const QList< QgsMapLayer * > &layers)
Sets the list of layers that should be shown in the canvas.
void setOutputSize(QSize size)
Sets the size of the resulting map image, in pixels.
void installInteractionBlocker(QgsMapCanvasInteractionBlocker *blocker)
Installs an interaction blocker onto the canvas, which may prevent certain map canvas interactions fr...
void panActionStart(QPoint releasePoint)
Starts a pan action.
@ FlagDontInvalidateCachedRendersWhenRangeChanges
Any cached rendering will not be invalidated when z range context is modified.
double mapUnitsPerPixel() const
Returns the mapUnitsPerPixel (map units per pixel) for the canvas.
void setPathResolver(const QgsPathResolver &resolver)
Sets the path resolver for conversion between relative and absolute paths during rendering operations...
@ View
Renderer used for displaying on screen.
The QgsMapSettings class contains configuration for rendering of the map. The rendering itself is don...
QgsRectangle visibleExtent() const
Returns the actual extent derived from requested extent that takes output image size into account.
void updateDefinition()
Updates the definition and parameters of the coordinate reference system to their latest values.
void invalidateCacheForLayer(QgsMapLayer *layer)
Invalidates cached images which relate to the specified map layer.
CanvasProperties()=default
Constructor for CanvasProperties.
QList< QgsMapCanvasAnnotationItem * > annotationItems() const
Returns a list of all annotation items in the canvas.
Wrapper for iterator of features from vector data provider or vector layer.
QgsPointXY layerToMapCoordinates(const QgsMapLayer *layer, QgsPointXY point) const
transform point coordinates from layer's CRS to output CRS
void setExtent(const QgsRectangle &rect, bool magnified=true)
Sets the coordinates of the rectangle which should be rendered.
void setSecondaryStrokeColor(const QColor &color)
Sets a secondary stroke color for the rubberband which will be drawn under the main stroke color.
bool isEmpty() const
Returns true if the rectangle is empty.
@ MediumString
A medium-length string, recommended for general purpose use.
const QgsMapToPixel & mapToPixel() const
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
@ FlagDontInvalidateCachedRendersWhenRangeChanges
Any cached rendering will not be invalidated when temporal range context is modified.
@ FixedRange
Temporal navigation relies on a fixed datetime range.
virtual QgsMapLayerElevationProperties * elevationProperties()
Returns the layer's elevation properties.
void setLayerStyleOverrides(const QMap< QString, QString > &overrides)
Sets the stored overrides of styles for rendering layers.
void autoRefreshIntervalChanged(int interval)
Emitted when the auto refresh interval changes.
double bearing(const QgsPointXY &p1, const QgsPointXY &p2) const SIP_THROW(QgsCsException)
Computes the bearing (in radians) between two points.
void setMapSettingsFlags(Qgis::MapSettingsFlags flags)
Resets the flags for the canvas' map settings.
QList< QgsMapLayer * > layers(bool expandGroupLayers=false) const
Returns the list of layers which will be rendered in the map.
Temporarily sets a cursor override for the QApplication for the lifetime of the object.
double zoomInFactor() const
Returns the zoom in factor.
static bool isUriList(const QMimeData *data)
PreviewMode mode() const
Returns the mode used for the preview effect.
void userCrsChanged(const QString &id)
Emitted whenever an existing user CRS definition is changed.
void setCachingEnabled(bool enabled)
Set whether to cache images of rendered layers.
void setLabelingEngineSettings(const QgsLabelingEngineSettings &settings)
Sets global labeling engine settings in the internal map settings.
const QgsTemporalController * temporalController() const
Gets access to the temporal controller that will be used to update the canvas temporal range.
@ RenderMapTile
Draw map such that there are no problems between adjacent tiles.
void finished()
emitted when asynchronous rendering is finished (or canceled).
void mapCanvasRefreshed()
Emitted when canvas finished a refresh request.
void setSelectionColor(const QColor &color)
Set color of selected vector features.
void layerStateChange()
This slot is connected to the visibility change of one or more layers.
void stopRendering()
stop rendering (if there is any right now)
void remoteSvgFetched(const QString &url)
Emitted when the cache has finished retrieving an SVG file from a remote url.
bool removeVariable(const QString &name)
Removes a variable from the context scope, if found.