47#include <QElapsedTimer>
51#include "moc_qgsrasterlayerrenderer.cpp"
61void QgsRasterLayerRendererFeedback::onNewData()
63 if ( !renderPartialOutput() )
68 if ( mLastPreview.isValid() && mLastPreview.msecsTo( QTime::currentTime() ) < mMinimalPreviewInterval )
73 QgsDebugMsgLevel( QStringLiteral(
"new raster preview! %1" ).arg( mLastPreview.msecsTo( QTime::currentTime() ) ), 3 );
81 drawer.draw( *( mR->renderContext() ), mR->mRasterViewPort, &feedback );
82 mR->mReadyToCompose =
true;
83 QgsDebugMsgLevel( QStringLiteral(
"total raster preview time: %1 ms" ).arg( t.elapsed() ), 3 );
84 mLastPreview = QTime::currentTime();
91 , mLayerName( layer->name() )
92 , mLayerOpacity( layer->opacity() )
93 , mProviderCapabilities( layer->dataProvider()->providerCapabilities() )
94 , mInterfaceCapabilities( layer->dataProvider()->capabilities() )
96 , mEnableProfile( rendererContext.
flags() &
Qgis::RenderContextFlag::RecordProfile )
110 const QgsPointXY center = mapToPixel.toMapCoordinates(
111 static_cast<int>( mapToPixel.mapWidth() / 2.0 ),
112 static_cast<int>( mapToPixel.mapHeight() / 2.0 )
114 mapToPixel.setMapRotation( 0, center.x(), center.y() );
122 QgsDebugMsgLevel( QStringLiteral(
"coordinateTransform set -> project extents." ), 4 );
123 if ( rendererContext.extent().xMinimum() == std::numeric_limits<double>::lowest() &&
124 rendererContext.extent().yMinimum() == std::numeric_limits<double>::lowest() &&
125 rendererContext.extent().xMaximum() == std::numeric_limits<double>::max() &&
126 rendererContext.extent().yMaximum() == std::numeric_limits<double>::max() )
133 viewExtentInMapCrs = rendererContext.extent();
139 QgsCoordinateTransform ct = rendererContext.coordinateTransform();
140 ct.setBallparkTransformsAreAppropriate( true );
141 viewExtentInMapCrs = rendererContext.mapExtent();
146 viewExtentInMapCrs.setNull();
159 layerExtentInMapCrs.setNull();
165 viewExtentInMapCrs = rendererContext.extent();
166 layerExtentInMapCrs = layer->extent();
170 QgsRectangle visibleExtentOfRasterInMapCrs = layer->ignoreExtents() ? viewExtentInMapCrs : viewExtentInMapCrs.
intersect( layerExtentInMapCrs );
171 if ( visibleExtentOfRasterInMapCrs.
isEmpty() )
173 if ( rendererContext.coordinateTransform().isShortCircuited() )
177 QgsDebugMsgLevel( QStringLiteral(
"draw request outside view extent." ), 2 );
189 QgsCoordinateTransform layerToMapTransform = rendererContext.coordinateTransform();
190 layerToMapTransform.setBallparkTransformsAreAppropriate( true );
191 const QgsRectangle viewExtentInLayerCrs = layerToMapTransform.transformBoundingBox( rendererContext.mapExtent(), Qgis::TransformDirection::Reverse );
193 const QgsRectangle visibleExtentInLayerCrs = layer->ignoreExtents() ? viewExtentInLayerCrs : viewExtentInLayerCrs.intersect( layer->extent() );
194 if ( visibleExtentInLayerCrs.isEmpty() )
196 QgsDebugMsgLevel( QStringLiteral(
"draw request outside view extent." ), 2 );
201 visibleExtentOfRasterInMapCrs = layerToMapTransform.transformBoundingBox( visibleExtentInLayerCrs );
210 if ( visibleExtentOfRasterInMapCrs.
isEmpty() )
212 QgsDebugMsgLevel( QStringLiteral(
"draw request outside view extent." ), 2 );
217 QgsDebugMsgLevel(
"map extent in layer crs is " + rendererContext.extent().toString(), 4 );
218 QgsDebugMsgLevel(
"map extent in map crs is " + viewExtentInMapCrs.toString(), 4 );
219 QgsDebugMsgLevel(
"layer extent in map crs is " + layerExtentInMapCrs.toString(), 4 );
231 mRasterViewPort->
mDrawnExtent = visibleExtentOfRasterInMapCrs;
232 if ( rendererContext.coordinateTransform().isValid() )
234 mRasterViewPort->mSrcCRS = layer->crs();
235 mRasterViewPort->mDestCRS = rendererContext.coordinateTransform().destinationCrs();
236 mRasterViewPort->mTransformContext = rendererContext.transformContext();
240 mRasterViewPort->mSrcCRS = QgsCoordinateReferenceSystem();
241 mRasterViewPort->mDestCRS = QgsCoordinateReferenceSystem();
245 mRasterViewPort->mTopLeftPoint = mapToPixel.transform( visibleExtentOfRasterInMapCrs.
xMinimum(), visibleExtentOfRasterInMapCrs.
yMaximum() );
246 mRasterViewPort->mBottomRightPoint = mapToPixel.transform( visibleExtentOfRasterInMapCrs.
xMaximum(), visibleExtentOfRasterInMapCrs.
yMinimum() );
254 mRasterViewPort->mTopLeftPoint.setX( std::floor( mRasterViewPort->mTopLeftPoint.x() ) );
255 mRasterViewPort->mTopLeftPoint.setY( std::floor( mRasterViewPort->mTopLeftPoint.y() ) );
256 mRasterViewPort->mBottomRightPoint.setX( std::ceil( mRasterViewPort->mBottomRightPoint.x() ) );
257 mRasterViewPort->mBottomRightPoint.setY( std::ceil( mRasterViewPort->mBottomRightPoint.y() ) );
259 visibleExtentOfRasterInMapCrs.
set(
260 mapToPixel.toMapCoordinates( mRasterViewPort->mTopLeftPoint.x(),
261 mRasterViewPort->mBottomRightPoint.y() ),
262 mapToPixel.toMapCoordinates( mRasterViewPort->mBottomRightPoint.x(),
263 mRasterViewPort->mTopLeftPoint.y() )
267 mRasterViewPort->mWidth =
static_cast<qgssize>( std::abs( mRasterViewPort->mBottomRightPoint.x() - mRasterViewPort->mTopLeftPoint.x() ) );
268 mRasterViewPort->mHeight =
static_cast<qgssize>( std::abs( mRasterViewPort->mBottomRightPoint.y() - mRasterViewPort->mTopLeftPoint.y() ) );
270 double dpi = 25.4 * rendererContext.scaleFactor();
272 && rendererContext.dpiTarget() >= 0.0 )
274 const double dpiScaleFactor = rendererContext.dpiTarget() / dpi;
275 mRasterViewPort->mWidth *= dpiScaleFactor;
276 mRasterViewPort->mHeight *= dpiScaleFactor;
277 dpi = rendererContext.dpiTarget();
281 rendererContext.setDpiTarget( -1.0 );
288 QgsDebugMsgLevel( QStringLiteral(
"mapUnitsPerPixel = %1" ).arg( mapToPixel.mapUnitsPerPixel() ), 3 );
289 QgsDebugMsgLevel( QStringLiteral(
"mWidth = %1" ).arg( layer->width() ), 3 );
290 QgsDebugMsgLevel( QStringLiteral(
"mHeight = %1" ).arg( layer->height() ), 3 );
291 QgsDebugMsgLevel( QStringLiteral(
"visibleExtentOfRasterInMapCrs.xMinimum() = %1" ).arg( visibleExtentOfRasterInMapCrs.
xMinimum() ), 3 );
292 QgsDebugMsgLevel( QStringLiteral(
"visibleExtentOfRasterInMapCrs.xMaximum() = %1" ).arg( visibleExtentOfRasterInMapCrs.
xMaximum() ), 3 );
293 QgsDebugMsgLevel( QStringLiteral(
"visibleExtentOfRasterInMapCrs.yMinimum() = %1" ).arg( visibleExtentOfRasterInMapCrs.
yMinimum() ), 3 );
294 QgsDebugMsgLevel( QStringLiteral(
"visibleExtentOfRasterInMapCrs.yMaximum() = %1" ).arg( visibleExtentOfRasterInMapCrs.
yMaximum() ), 3 );
296 QgsDebugMsgLevel( QStringLiteral(
"mTopLeftPoint.x() = %1" ).arg( mRasterViewPort->mTopLeftPoint.x() ), 3 );
297 QgsDebugMsgLevel( QStringLiteral(
"mBottomRightPoint.x() = %1" ).arg( mRasterViewPort->mBottomRightPoint.x() ), 3 );
298 QgsDebugMsgLevel( QStringLiteral(
"mTopLeftPoint.y() = %1" ).arg( mRasterViewPort->mTopLeftPoint.y() ), 3 );
299 QgsDebugMsgLevel( QStringLiteral(
"mBottomRightPoint.y() = %1" ).arg( mRasterViewPort->mBottomRightPoint.y() ), 3 );
301 QgsDebugMsgLevel( QStringLiteral(
"mWidth = %1" ).arg( mRasterViewPort->mWidth ), 3 );
302 QgsDebugMsgLevel( QStringLiteral(
"mHeight = %1" ).arg( mRasterViewPort->mHeight ), 3 );
309 layer->dataProvider()->setDpi( std::floor( dpi * rendererContext.devicePixelRatio() ) );
312 mPipe = std::make_unique<QgsRasterPipe>( *layer->pipe() );
320 if ( rasterRenderer->needsRefresh( rendererContext.extent() ) )
322 QList<double> minValues;
323 QList<double> maxValues;
324 const QgsRasterMinMaxOrigin &minMaxOrigin = rasterRenderer->minMaxOrigin();
325 for ( const int bandIdx : rasterRenderer->usesBands() )
329 layer->computeMinMax( bandIdx, minMaxOrigin, minMaxOrigin.limits(),
330 rendererContext.extent(), static_cast<int>( QgsRasterLayer::SAMPLE_SIZE ),
332 minValues.append( min );
333 maxValues.append( max );
336 rasterRenderer->refresh( rendererContext.extent(), minValues, maxValues );
337 QgsRenderedLayerStatistics *layerStatistics = new QgsRenderedLayerStatistics( layer->id(), minValues, maxValues );
338 layerStatistics->setBoundingBox( rendererContext.extent() );
339 appendRenderedItemDetails( layerStatistics );
343 mPipe->evaluateDataDefinedProperties( rendererContext.expressionContext() );
348 if ( ( temporalProperties->isActive() && renderContext()->isTemporal() )
349 || ( elevationProperties->hasElevation() && !renderContext()->zRange().isInfinite() ) )
352 bool matched =
false;
355 rendererContext.temporalRange(),
356 rendererContext.zRange(),
359 if ( matched && matchedBand > 0 )
361 mPipe->renderer()->setInputBand( matchedBand );
365 if ( temporalProperties->isActive() && renderContext()->isTemporal() )
367 switch ( temporalProperties->mode() )
376 if ( mPipe->renderer()->usesBands().contains( temporalProperties->bandNumber() ) )
379 std::unique_ptr< QgsRasterTransparency > transparency;
381 transparency = std::make_unique< QgsRasterTransparency >( *rendererTransparency );
383 transparency = std::make_unique< QgsRasterTransparency >();
385 QVector<QgsRasterTransparency::TransparentSingleValuePixel> transparentPixels = transparency->transparentSingleValuePixelList();
387 const QDateTime &offset = temporalProperties->temporalRepresentationOffset();
388 const QgsInterval &scale = temporalProperties->temporalRepresentationScale();
391 if ( !temporalProperties->accumulatePixels() )
397 transparency->setTransparentSingleValuePixelList( transparentPixels );
398 mPipe->renderer()->setRasterTransparency( transparency.release() );
406 temporalCapabilities->setRequestedTemporalRange( rendererContext.temporalRange() );
407 temporalCapabilities->setIntervalHandlingMethod( temporalProperties->intervalHandlingMethod() );
414 temporalCapabilities->setRequestedTemporalRange( QgsDateTimeRange() );
415 temporalCapabilities->setIntervalHandlingMethod( temporalProperties->intervalHandlingMethod() );
420 if ( elevationProperties && elevationProperties->hasElevation() )
422 mDrawElevationMap = true;
423 mElevationScale = elevationProperties->zScale();
424 mElevationOffset = elevationProperties->zOffset();
425 mElevationBand = elevationProperties->bandNumber();
427 if ( !rendererContext.zRange().isInfinite() )
430 switch ( elevationProperties->mode() )
432 case Qgis::RasterElevationMode::FixedElevationRange:
437 case Qgis::RasterElevationMode::FixedRangePerBand:
438 case Qgis::RasterElevationMode::DynamicRangePerBand:
442 case Qgis::RasterElevationMode::RepresentsElevationSurface:
444 if ( mPipe->renderer()->usesBands().contains( mElevationBand ) )
447 if ( mPipe->renderer()->flags() & Qgis::RasterRendererFlag::UseNoDataForOutOfRangePixels )
449 std::unique_ptr< QgsRasterNuller> nuller;
450 if ( const QgsRasterNuller *existingNuller = mPipe->nuller() )
451 nuller.reset( existingNuller->clone() );
453 nuller = std::make_unique< QgsRasterNuller >();
457 QgsRasterRangeList nullRanges;
458 const double adjustedLower = ( rendererContext.zRange().lower() - mElevationOffset ) / mElevationScale;
459 const double adjustedUpper = ( rendererContext.zRange().upper() - mElevationOffset ) / mElevationScale;
460 nullRanges.append( QgsRasterRange( std::numeric_limits<double>::lowest(), adjustedLower, rendererContext.zRange().includeLower() ? QgsRasterRange::BoundsType::IncludeMin : QgsRasterRange::BoundsType::IncludeMinAndMax ) );
461 nullRanges.append( QgsRasterRange( adjustedUpper, std::numeric_limits<double>::max(), rendererContext.zRange().includeUpper() ? QgsRasterRange::BoundsType::IncludeMax : QgsRasterRange::BoundsType::IncludeMinAndMax ) );
462 nuller->setOutputNoDataValue( mElevationBand, static_cast< int >( adjustedLower - 1 ) );
463 nuller->setNoData( mElevationBand, nullRanges );
465 if ( !mPipe->insert( 1, nuller.release() ) )
467 QgsDebugError( QStringLiteral(
"Cannot set pipe nuller" ) );
472 std::unique_ptr< QgsRasterTransparency > transparency;
473 if ( const QgsRasterTransparency *rendererTransparency = mPipe->renderer()->rasterTransparency() )
474 transparency = std::make_unique< QgsRasterTransparency >( *rendererTransparency );
476 transparency = std::make_unique< QgsRasterTransparency >();
478 QVector<QgsRasterTransparency::TransparentSingleValuePixel> transparentPixels = transparency->transparentSingleValuePixelList();
482 const double adjustedLower = ( rendererContext.zRange().lower() - mElevationOffset ) / mElevationScale;
483 const double adjustedUpper = ( rendererContext.zRange().upper() - mElevationOffset ) / mElevationScale;
484 transparentPixels.append( QgsRasterTransparency::TransparentSingleValuePixel( std::numeric_limits<double>::lowest(), adjustedLower, 0, true, !rendererContext.zRange().includeLower() ) );
485 transparentPixels.append( QgsRasterTransparency::TransparentSingleValuePixel( adjustedUpper, std::numeric_limits<double>::max(), 0, !rendererContext.zRange().includeUpper(), true ) );
487 transparency->setTransparentSingleValuePixelList( transparentPixels );
488 mPipe->renderer()->setRasterTransparency( transparency.release() );
498 prepareLabeling( layer );
500 mFeedback->setRenderContext( rendererContext );
502 mPipe->moveToThread(
nullptr );
504 mPreparationTime = timer.elapsed();
511 delete mRasterViewPort;
518 std::unique_ptr< QgsScopedRuntimeProfile > profile;
519 if ( mEnableProfile )
521 profile = std::make_unique< QgsScopedRuntimeProfile >( mLayerName, QStringLiteral(
"rendering" ),
layerId() );
522 if ( mPreparationTime > 0 )
528 !( mInterfaceCapabilities &
532 mPipe->moveToThread( QThread::currentThread() );
537 std::unique_ptr< QgsScopedRuntimeProfile > preparingProfile;
538 if ( mEnableProfile )
540 preparingProfile = std::make_unique< QgsScopedRuntimeProfile >( QObject::tr(
"Preparing render" ), QStringLiteral(
"rendering" ) );
554 bool antialiasEnabled =
false;
555 if ( !mClippingRegions.empty() )
557 bool needsPainterClipPath =
false;
559 if ( needsPainterClipPath )
567 antialiasEnabled =
true;
573 bool restoreOldResamplingStage =
false;
582 mRasterViewPort->mSrcCRS != mRasterViewPort->mDestCRS &&
585 restoreOldResamplingStage =
true;
588 projector->
setCrs( mRasterViewPort->mSrcCRS, mRasterViewPort->mDestCRS, mRasterViewPort->mTransformContext );
591 preparingProfile.reset();
592 std::unique_ptr< QgsScopedRuntimeProfile > renderingProfile;
593 if ( mEnableProfile )
595 renderingProfile = std::make_unique< QgsScopedRuntimeProfile >( QObject::tr(
"Rendering" ), QStringLiteral(
"rendering" ) );
604 const QSize maxTileSize {provider->maximumTileSize()};
612 if ( mDrawElevationMap )
615 renderingProfile.reset();
617 if ( mLabelProvider && !
renderContext()->renderingStopped() )
619 std::unique_ptr< QgsScopedRuntimeProfile > labelingProfile;
620 if ( mEnableProfile )
622 labelingProfile = std::make_unique< QgsScopedRuntimeProfile >( QObject::tr(
"Labeling" ), QStringLiteral(
"rendering" ) );
627 if ( restoreOldResamplingStage )
629 mPipe->setResamplingStage( oldResamplingState );
632 const QStringList
errors = mFeedback->errors();
633 for (
const QString &error :
errors )
638 QgsDebugMsgLevel( QStringLiteral(
"total raster draw time (ms): %1" ).arg( time.elapsed(), 5 ), 4 );
641 mPipe->moveToThread(
nullptr );
643 return !mFeedback->isCanceled();
653 if ( !mRasterViewPort || !mPipe )
682void QgsRasterLayerRenderer::prepareLabeling(
QgsRasterLayer *layer )
692 std::unique_ptr< QgsRasterLayerLabelProvider > provider = labeling->provider( layer );
696 mLabelProvider = provider.release();
698 engine2->addProvider( mLabelProvider );
705void QgsRasterLayerRenderer::drawLabeling()
707 if ( mLabelProvider )
708 mLabelProvider->generateLabels( *
renderContext(), mPipe.get(), mRasterViewPort, mFeedback );
711void QgsRasterLayerRenderer::drawElevationMap()
713 QgsRasterDataProvider *dataProvider = mPipe->provider();
716 double dpiScalefactor;
721 dpiScalefactor = 1.0;
724 int outputHeight =
static_cast<int>(
static_cast<double>( mRasterViewPort->mHeight ) / dpiScalefactor *
renderContext()->
devicePixelRatio() );
727 int viewWidth =
static_cast<int>( viewSize.width() / dpiScalefactor );
728 int viewHeight =
static_cast<int>( viewSize.height() / dpiScalefactor );
730 bool canRenderElevation =
false;
731 std::unique_ptr<QgsRasterBlock> elevationBlock;
732 if ( mRasterViewPort->mSrcCRS == mRasterViewPort->mDestCRS )
734 elevationBlock.reset(
737 mRasterViewPort->mDrawnExtent,
741 canRenderElevation =
true;
751 if ( viewExtentInLayerCoordinate.
xMinimum() == std::numeric_limits<double>::lowest() &&
752 viewExtentInLayerCoordinate.
yMinimum() == std::numeric_limits<double>::lowest() &&
753 viewExtentInLayerCoordinate.
xMaximum() == std::numeric_limits<double>::max() &&
754 viewExtentInLayerCoordinate.
yMaximum() == std::numeric_limits<double>::max() )
756 viewExtentInLayerCoordinate = dataProvider->
extent();
759 double xLayerResol = viewExtentInLayerCoordinate.
width() /
static_cast<double>( viewWidth );
760 double yLayerResol = viewExtentInLayerCoordinate.
height() /
static_cast<double>( viewHeight );
762 double overSampling = 1;
763 if ( mPipe->resampleFilter() )
764 overSampling = mPipe->resampleFilter()->maxOversampling();
769 double providerXResol = dataProvider->
extent().
width() / dataProvider->
xSize();
771 overSampling = ( xLayerResol / providerXResol + yLayerResol / providerYResol ) / 2;
775 if ( overSampling > 1 )
785 int sourceWidth = viewWidth + 4;
786 int sourceHeight = viewHeight + 4;
787 viewExtentInLayerCoordinate = QgsRectangle(
788 viewExtentInLayerCoordinate.
xMinimum() - xLayerResol * 2,
789 viewExtentInLayerCoordinate.
yMinimum() - yLayerResol * 2,
790 viewExtentInLayerCoordinate.
xMaximum() + xLayerResol * 2,
791 viewExtentInLayerCoordinate.
yMaximum() + yLayerResol * 2 );
794 std::unique_ptr<QgsRasterBlock> sourcedata( dataProvider->
block( mElevationBand, viewExtentInLayerCoordinate, sourceWidth, sourceHeight, mFeedback ) );
799 elevationBlock = std::make_unique<QgsRasterBlock>( dataType,
803 elevationBlock->setNoDataValue( dataProvider->
sourceNoDataValue( mElevationBand ) );
810 QString coordinateOperation;
817 if ( coordinateOperation.isEmpty() )
819 mRasterViewPort->mSrcCRS, mRasterViewPort->mDestCRS );
822 coordinateOperation.toUtf8().constData() );
826 if ( canRenderElevation )
840 int top = elevMapHeight;
841 int left = elevMapWidth;
844 QList<QgsPointXY> corners;
845 corners << QgsPointXY( mRasterViewPort->mDrawnExtent.xMinimum(), mRasterViewPort->mDrawnExtent.yMinimum() )
846 << QgsPointXY( mRasterViewPort->mDrawnExtent.xMaximum(), mRasterViewPort->mDrawnExtent.yMaximum() )
847 << QgsPointXY( mRasterViewPort->mDrawnExtent.xMinimum(), mRasterViewPort->mDrawnExtent.yMaximum() )
848 << QgsPointXY( mRasterViewPort->mDrawnExtent.xMaximum(), mRasterViewPort->mDrawnExtent.yMinimum() );
850 for (
const QgsPointXY &corner : std::as_const( corners ) )
852 const QgsPointXY dpt = mtp.
transform( corner );
853 int x =
static_cast<int>( std::round( dpt.
x() ) );
854 int y =
static_cast<int>( std::round( dpt.
y() ) );
874 std::unique_ptr<QgsRasterBlock> rotatedElevationBlock =
875 std::make_unique<QgsRasterBlock>( elevationBlock->dataType(),
877 ( bottom - top ) *
renderContext()->devicePixelRatio() + 1 );
879 rotatedElevationBlock->setNoDataValue( elevationBlock->noDataValue() );
889 elevationBlock = std::move( rotatedElevationBlock );
892 topLeft = QPoint( left, top );
896 topLeft = mRasterViewPort->mTopLeftPoint.toQPointF().toPoint();
900 elevationBlock.get(),
Provides global constants and enumerations for use throughout the application.
@ Default
Allow raster-based rendering in situations where it is required for correct rendering or where it wil...
@ PreferVector
Prefer vector-based rendering, when the result will still be visually near-identical to a raster-base...
@ ForceVector
Always force vector-based rendering, even when the result will be visually different to a raster-base...
RasterResamplingStage
Stage at which raster resampling occurs.
@ Provider
Resampling occurs in Provider.
@ ProviderHintCanPerformProviderResampling
Provider can perform resampling (to be opposed to post rendering resampling).
@ DpiDependentData
Provider's rendering is dependent on requested pixel size of the viewport.
@ InternalLayerOpacityHandling
The renderer internally handles the raster layer's opacity, so the default layer level opacity handli...
@ Milliseconds
Milliseconds.
@ RepresentsTemporalValues
Pixel values represent an datetime.
@ RedrawLayerOnly
Redraw the layer when temporal range changes, but don't apply any filtering. Useful when raster symbo...
@ FixedRangePerBand
Layer has a fixed temporal range per band.
@ TemporalRangeFromDataProvider
Mode when raster layer delegates temporal range handling to the dataprovider.
@ FixedTemporalRange
Mode when temporal properties have fixed start and end datetimes.
@ FixedDateTime
Layer has a fixed date time instant.
@ Prefetch
Allow prefetching of out-of-view images.
@ Size
Original data source size (and thus resolution) is known, it is not always available,...
DataType
Raster data types.
@ UnknownDataType
Unknown or unspecified type.
@ RenderPreviewJob
Render is a 'canvas preview' render, and shortcuts should be taken to ensure fast rendering.
@ RenderPartialOutput
Whether to make extra effort to update map image with partially rendered layers (better for interacti...
@ Render3DMap
Render is for a 3D map.
Abstract base class for labeling settings for raster layers.
static QgsRuntimeProfiler * profiler()
Returns the application runtime profiler.
QString calculateCoordinateOperation(const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination) const
Returns the Proj coordinate operation string to use when transforming from the specified source CRS t...
bool mustReverseCoordinateOperation(const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination) const
Returns true if the coordinate operation returned by calculateCoordinateOperation() for the source to...
Custom exception class for Coordinate Reference System related exceptions.
QImage rawElevationImage() const
Returns raw elevation image with elevations encoded as color values.
void fillWithRasterBlock(QgsRasterBlock *block, int top, int left, double zScale=1.0, double offset=0.0)
Fills the elevation map with values contains in a raster block starting from position defined by top ...
Base class for feedback objects to be used for cancellation of something running in a worker thread.
static bool resampleSingleBandRaster(GDALDatasetH hSrcDS, GDALDatasetH hDstDS, GDALResampleAlg resampleAlg, const char *pszCoordinateOperation)
Resamples a single band raster to the destination dataset with different resolution (and possibly wit...
static GDALResampleAlg gdalResamplingAlgorithm(Qgis::RasterResamplingMethod method)
Returns the GDAL resampling method corresponding to the QGIS resampling method.
static gdal::dataset_unique_ptr blockToSingleBandMemoryDataset(int pixelWidth, int pixelHeight, const QgsRectangle &extent, void *block, GDALDataType dataType)
Converts a data block to a single band GDAL memory dataset.
A representation of the interval between two datetime values.
double originalDuration() const
Returns the original interval duration.
Qgis::TemporalUnit originalUnit() const
Returns the original interval temporal unit.
Provides map labeling functionality.
static QPainterPath calculatePainterClipRegion(const QList< QgsMapClippingRegion > ®ions, const QgsRenderContext &context, Qgis::LayerType layerType, bool &shouldClip)
Returns a QPainterPath representing the intersection of clipping regions from context which should be...
static QList< QgsMapClippingRegion > collectClippingRegionsForLayer(const QgsRenderContext &context, const QgsMapLayer *layer)
Collects the list of map clipping regions from a context which apply to a map layer.
bool mReadyToCompose
The flag must be set to false in renderer's constructor if wants to use the smarter map redraws funct...
QString layerId() const
Gets access to the ID of the layer rendered by this class.
virtual Qgis::MapLayerRendererFlags flags() const
Returns flags which control how the map layer rendering behaves.
QgsRenderContext * renderContext()
Returns the render context associated with the renderer.
QStringList errors() const
Returns list of errors (problems) that happened during the rendering.
QgsMapLayerRenderer(const QString &layerID, QgsRenderContext *context=nullptr)
Constructor for QgsMapLayerRenderer, with the associated layerID and render context.
void statusChanged(const QString &status)
Emit a signal with status (e.g. to be caught by QgisApp and display a msg on status bar).
Perform transforms between map coordinates and device coordinates.
QgsPointXY toMapCoordinates(int x, int y) const
Transforms device coordinates to map (world) coordinates.
QgsPointXY transform(const QgsPointXY &p) const
Transforms a point p from map (world) coordinates to device coordinates.
double mapRotation() const
Returns the current map rotation in degrees (clockwise).
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true, const char *file=__builtin_FILE(), const char *function=__builtin_FUNCTION(), int line=__builtin_LINE())
Adds a message to the log instance (and creates it if necessary).
double distance(double x, double y) const
Returns the distance between this point and a specified x, y coordinate.
Feedback object tailored for raster block reading.
void setPreviewOnly(bool preview)
set flag whether the block request is for preview purposes only
void setRenderPartialOutput(bool enable)
Set whether our painter is drawing to a temporary image used just by this layer.
Implementation of data provider temporal properties for QgsRasterDataProviders.
Base class for raster data providers.
Qgis::RasterResamplingMethod zoomedInResamplingMethod() const
Returns resampling method for zoomed-in operations.
virtual double sourceNoDataValue(int bandNo) const
Value representing no data value.
QgsRectangle extent() const override=0
Returns the extent of the layer.
Qgis::DataType dataType(int bandNo) const override=0
Returns data type for the band specified by number.
Qgis::RasterResamplingMethod zoomedOutResamplingMethod() const
Returns resampling method for zoomed-out operations.
QgsRasterBlock * block(int bandNo, const QgsRectangle &boundingBox, int width, int height, QgsRasterBlockFeedback *feedback=nullptr) override
Read block of data using given extent and size.
void statusChanged(const QString &) const
Emit a message to be displayed on status bar, usually used by network providers (WMS,...
The drawing pipe for raster layers.
void draw(QPainter *p, QgsRasterViewPort *viewPort, const QgsMapToPixel *qgsMapToPixel, QgsRasterBlockFeedback *feedback=nullptr)
Draws raster data.
virtual Qgis::RasterInterfaceCapabilities capabilities() const
Returns the capabilities supported by the interface.
virtual int xSize() const
Gets raster size.
virtual int ySize() const
Iterator for sequentially processing raster cells.
void setMaximumTileWidth(int w)
Sets the maximum tile width returned during iteration.
void setMaximumTileHeight(int h)
Sets the minimum tile height returned during iteration.
Raster layer specific subclass of QgsMapLayerElevationProperties.
void startRender(QgsRenderContext &context) final
To be called before rendering of labels begins.
Implementation of threaded rendering for raster layers.
bool render() override
Do the rendering (based on data stored in the class).
QgsRasterLayerRenderer(QgsRasterLayer *layer, QgsRenderContext &rendererContext)
bool forceRasterRender() const override
Returns true if the renderer must be rendered to a raster paint device (e.g.
~QgsRasterLayerRenderer() override
friend class QgsRasterLayerRendererFeedback
QgsFeedback * feedback() const override
Access to feedback object of the layer renderer (may be nullptr).
Implementation of map layer temporal properties for raster layers.
static int renderedBandForElevationAndTemporalRange(QgsRasterLayer *layer, const QgsDateTimeRange &temporalRange, const QgsDoubleRange &elevationRange, bool &matched)
Given a raster layer, returns the band which should be used for rendering the layer for a specified t...
Represents a raster layer.
const QgsAbstractRasterLayerLabeling * labeling() const
Access to const labeling configuration.
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn.
Implements approximate projection support for optimised raster transformation.
Q_DECL_DEPRECATED void setCrs(const QgsCoordinateReferenceSystem &srcCRS, const QgsCoordinateReferenceSystem &destCRS, int srcDatumTransform=-1, int destDatumTransform=-1)
Sets the source and destination CRS.
Raster renderer pipe that applies colors to a raster.
Defines the list of pixel values to be considered as transparent or semi transparent when rendering r...
A rectangle specified with double values.
Q_INVOKABLE QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
void set(const QgsPointXY &p1, const QgsPointXY &p2, bool normalize=true)
Sets the rectangle from two QgsPoints.
QgsRectangle intersect(const QgsRectangle &rect) const
Returns the intersection with the given rectangle.
Contains information about the context of a rendering operation.
double scaleFactor() const
Returns the scaling factor for the render to convert painter units to physical sizes.
QPainter * painter()
Returns the destination QPainter for the render operation.
double rendererScale() const
Returns the renderer map scale.
QgsCoordinateTransformContext transformContext() const
Returns the context's coordinate transform context, which stores various information regarding which ...
QgsElevationMap * elevationMap() const
Returns the destination elevation map for the render operation.
const QgsRectangle & extent() const
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the l...
bool testFlag(Qgis::RenderContextFlag flag) const
Check whether a particular flag is enabled.
float devicePixelRatio() const
Returns the device pixel ratio.
double dpiTarget() const
Returns the targeted DPI for rendering.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
QSize deviceOutputSize() const
Returns the device output size of the render.
QgsLabelingEngine * labelingEngine() const
Gets access to new labeling engine (may be nullptr).
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
void record(const QString &name, double time, const QString &group="startup", const QString &id=QString())
Manually adds a profile event with the given name and total time (in seconds).
Scoped object for saving and restoring a QPainter object's state.
Scoped object for setting the current thread name.
static Q_INVOKABLE double fromUnitToUnitFactor(Qgis::DistanceUnit fromUnit, Qgis::DistanceUnit toUnit)
Returns the conversion factor between the specified distance units.
std::unique_ptr< std::remove_pointer< GDALDatasetH >::type, GDALDatasetCloser > dataset_unique_ptr
Scoped GDAL dataset.
unsigned long long qgssize
Qgssize is used instead of size_t, because size_t is stdlib type, unknown by SIP, and it would be har...
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).
#define QgsDebugMsgLevel(str, level)
Defines the transparency for a range of single-band pixel values.
This class provides details of the viewable area that a raster will be rendered into.
QgsRectangle mDrawnExtent
Intersection of current map extent and layer extent, in map (destination) CRS.