QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
31 #include <QElapsedTimer>
38 , mMinimalPreviewInterval( 250 )
43 void QgsRasterLayerRendererFeedback::onNewData()
45 if ( !renderPartialOutput() )
50 if ( mLastPreview.isValid() && mLastPreview.msecsTo( QTime::currentTime() ) < mMinimalPreviewInterval )
55 QgsDebugMsgLevel( QStringLiteral(
"new raster preview! %1" ).arg( mLastPreview.msecsTo( QTime::currentTime() ) ), 3 );
63 drawer.draw( mR->renderContext()->painter(), mR->mRasterViewPort, &mR->renderContext()->mapToPixel(), &feedback );
64 mR->mReadyToCompose =
true;
65 QgsDebugMsgLevel( QStringLiteral(
"total raster preview time: %1 ms" ).arg( t.elapsed() ), 3 );
66 mLastPreview = QTime::currentTime();
73 , mProviderCapabilities( static_cast<
QgsRasterDataProvider::Capability>( layer->dataProvider()->capabilities() ) )
74 , mFeedback( new QgsRasterLayerRendererFeedback( this ) )
85 static_cast<int>( mapToPixel.
mapWidth() / 2.0 ),
86 static_cast<int>( mapToPixel.
mapHeight() / 2.0 )
96 QgsDebugMsgLevel( QStringLiteral(
"coordinateTransform set -> project extents." ), 4 );
97 if ( rendererContext.
extent().
xMinimum() == std::numeric_limits<double>::lowest() &&
98 rendererContext.
extent().
yMinimum() == std::numeric_limits<double>::lowest() &&
99 rendererContext.
extent().
xMaximum() == std::numeric_limits<double>::max() &&
100 rendererContext.
extent().
yMaximum() == std::numeric_limits<double>::max() )
107 myProjectedViewExtent = rendererContext.
extent();
139 myProjectedViewExtent = rendererContext.
extent();
140 myProjectedLayerExtent = layer->
extent();
145 if ( myRasterExtent.
isEmpty() )
147 QgsDebugMsgLevel( QStringLiteral(
"draw request outside view extent." ), 2 );
207 const double dpi = rendererContext.
painter() ? rendererContext.
painter()->device()->logicalDpiX() :
212 const double dpiScaleFactor = rendererContext.
dpiTarget() / dpi;
213 mRasterViewPort->
mWidth *= dpiScaleFactor;
214 mRasterViewPort->
mHeight *= dpiScaleFactor;
264 switch ( temporalProperties->
mode() )
266 case Qgis::RasterTemporalMode::FixedTemporalRange:
267 case Qgis::RasterTemporalMode::RedrawLayerOnly:
270 case Qgis::RasterTemporalMode::TemporalRangeFromDataProvider:
288 mFeedback->setRenderContext( rendererContext );
295 delete mRasterViewPort;
303 !( mProviderCapabilities &
304 QgsRasterInterface::Capability::Prefetch ) ) )
317 if ( !mClippingRegions.empty() )
319 bool needsPainterClipPath =
false;
321 if ( needsPainterClipPath )
326 bool restoreOldResamplingStage =
false;
338 restoreOldResamplingStage =
true;
352 if ( restoreOldResamplingStage )
357 const QStringList
errors = mFeedback->errors();
358 for (
const QString &error :
errors )
363 QgsDebugMsgLevel( QStringLiteral(
"total raster draw time (ms): %1" ).arg( time.elapsed(), 5 ), 4 );
366 return !mFeedback->isCanceled();
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.
QgsPointXY mBottomRightPoint
Coordinate (in output device coordinate system) of bottom right corner of the part of the raster that...
QgsCoordinateReferenceSystem crs
void setDpiTarget(double dpi)
Sets 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...
bool forceRasterRender() const override
Returns true if the renderer must be rendered to a raster paint device (e.g.
QgsExpressionContext & expressionContext()
Gets the expression context.
double mapUnitsPerPixel() const
Returns the current map units per pixel.
void set(const QgsPointXY &p1, const QgsPointXY &p2, bool normalize=true)
Sets the rectangle from two QgsPoints.
bool ignoreExtents() const
If the ignoreExtent flag is set, the layer will also render outside the bounding box reported by the ...
#define QgsDebugMsgLevel(str, level)
void setRequestedTemporalRange(const QgsDateTimeRange &range)
Sets the requested temporal range to retrieve when returning data from the associated data provider.
QStringList errors() const
Returns list of errors (problems) that happened during the rendering.
QgsCoordinateReferenceSystem mSrcCRS
Source coordinate system.
@ ProviderHintCanPerformProviderResampling
Provider can perform resampling (to be opposed to post rendering resampling) (since QGIS 3....
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
bool testFlag(Qgis::RenderContextFlag flag) const
Check whether a particular flag is enabled.
Qgis::RenderContextFlags flags() const
Returns combination of flags used for rendering.
void statusChanged(const QString &status)
Emit a signal with status (e.g. to be caught by QgisApp and display a msg on status bar)
Contains a pipeline of raster interfaces for sequential raster processing.
void setY(double y) SIP_HOLDGIL
Sets the y value of the point.
const QgsDateTimeRange & temporalRange() const
Returns the datetime range for the object.
RasterResamplingStage
Stage at which raster resampling occurs.
Contains information about the context of a rendering operation.
QgsRenderContext * renderContext()
Returns the render context associated with the renderer.
void setMinimal() SIP_HOLDGIL
Set a rectangle so that min corner is at max and max corner is at min.
bool mReadyToCompose
The flag must be set to false in renderer's constructor if wants to use the smarter map redraws funct...
QgsPointXY mTopLeftPoint
Coordinate (in output device coordinate system) of top left corner of the part of the raster that is ...
double scaleFactor() const
Returns the scaling factor for the render to convert painter units to physical sizes.
QgsPointXY toMapCoordinates(int x, int y) const
Transforms device coordinates to map (world) coordinates.
QgsRectangle intersect(const QgsRectangle &rect) const
Returns the intersection with the given rectangle.
const QgsRectangle & extent() const
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the l...
void setX(double x) SIP_HOLDGIL
Sets the x value of the point.
double dpiTarget() const
Returns the targeted DPI for rendering.
A rectangle specified with double values.
Implementation of map layer temporal properties for raster layers.
QgsRasterDataProvider * provider() const
Returns the data provider interface, or nullptr if no data provider is present in the pipe.
Base class for utility classes that encapsulate information necessary for rendering of map layers.
QgsRasterProjector implements approximate projection support for it calculates grid of points in sour...
double xMaximum() const SIP_HOLDGIL
Returns the x maximum value (right side of rectangle).
~QgsRasterLayerRenderer() override
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
void evaluateDataDefinedProperties(QgsExpressionContext &context)
Evaluates any data defined properties set on the pipe, applying their results to the corresponding in...
QgsFeedback * feedback() const override
Access to feedback object of the layer renderer (may be nullptr)
Custom exception class for Coordinate Reference System related exceptions.
int width() const
Returns the width of the (unclipped) raster.
void draw(QPainter *p, QgsRasterViewPort *viewPort, const QgsMapToPixel *qgsMapToPixel, QgsRasterBlockFeedback *feedback=nullptr)
Draws raster data.
Qgis::RasterResamplingStage resamplingStage() const
Returns which stage of the pipe should apply resampling.
bool isActive() const
Returns true if the temporal property is active.
QgsRasterRenderer * renderer() const
Returns the raster renderer interface, or nullptr if no raster renderer is present in the pipe.
@ RenderPreviewJob
Render is a 'canvas preview' render, and shortcuts should be taken to ensure fast rendering.
Raster renderer pipe that applies colors to a raster.
virtual QgsRasterDataProvider::ProviderCapabilities providerCapabilities() const
Returns flags containing the supported capabilities of the data provider.
QgsCoordinateTransformContext mTransformContext
Coordinate transform context.
static QPainterPath calculatePainterClipRegion(const QList< QgsMapClippingRegion > ®ions, const QgsRenderContext &context, QgsMapLayerType layerType, bool &shouldClip)
Returns a QPainterPath representing the intersection of clipping regions from context which should be...
void setIntervalHandlingMethod(Qgis::TemporalIntervalMatchMethod method)
Sets the desired method to use when resolving a temporal interval to matching layers or bands in the ...
Base class for feedback objects to be used for cancellation of something running in a worker thread.
int mapHeight() const
Returns current map height in pixels.
double mapRotation() const
Returns the current map rotation in degrees (clockwise).
int height() const
Returns the height of the (unclipped) raster.
virtual QgsRectangle extent() const
Returns the extent of the layer.
QgsMapLayerTemporalProperties * temporalProperties() override
Returns the layer's temporal properties.
@ RasterLayer
Raster layer.
void setDpi(int dpi)
Sets the output device resolution.
The drawing pipe for raster layers.
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).
Q_DECL_DEPRECATED void setCrs(const QgsCoordinateReferenceSystem &srcCRS, const QgsCoordinateReferenceSystem &destCRS, int srcDatumTransform=-1, int destDatumTransform=-1)
Sets the source and destination CRS.
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
@ RenderPartialOutput
Whether to make extra effort to update map image with partially rendered layers (better for interacti...
Represents a raster layer.
Scoped object for saving and restoring a QPainter object's state.
void setRenderPartialOutput(bool enable)
Set whether our painter is drawing to a temporary image used just by this layer.
Iterator for sequentially processing raster cells.
This class represents a coordinate reference system (CRS).
QgsPointXY transform(const QgsPointXY &p) const
Transforms a point p from map (world) coordinates to device coordinates.
void setResamplingStage(Qgis::RasterResamplingStage stage)
Sets which stage of the pipe should apply resampling.
QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
A class to represent a 2D point.
Qgis::RasterTemporalMode mode() const
Returns the temporal properties mode.
bool render() override
Do the rendering (based on data stored in the class).
QgsRasterInterface * last() const
Returns last interface in the pipe.
qgssize mHeight
Height, number of rows to be rendered.
double yMaximum() const SIP_HOLDGIL
Returns the y maximum value (top side of rectangle).
Implementation of threaded rendering for raster layers.
qgssize mWidth
Width, number of columns to be rendered.
Perform transforms between map coordinates and device coordinates.
int mapWidth() const
Returns the current map width in pixels.
QgsRasterPipe * pipe()
Returns the raster pipe.
QgsCoordinateTransformContext transformContext() const
Returns the context's coordinate transform context, which stores various information regarding which ...
Feedback object tailored for raster block reading.
Qgis::TemporalIntervalMatchMethod intervalHandlingMethod() const
Returns the desired method to use when resolving a temporal interval to matching layers or bands in t...
void statusChanged(const QString &) const
Emit a message to be displayed on status bar, usually used by network providers (WMS,...
void refreshRendererIfNeeded(QgsRasterRenderer *rasterRenderer, const QgsRectangle &extent)
Refresh renderer with new extent, if needed.
void setPreviewOnly(bool preview)
set flag whether the block request is for preview purposes only
@ Provider
Resampling occurs in Provider.
@ Render3DMap
Render is for a 3D map.
QgsRasterProjector * projector() const
Returns the projector interface, or nullptr if no projector is present in the pipe.
QPainter * painter()
Returns the destination QPainter for the render operation.
QgsCoordinateReferenceSystem mDestCRS
Target coordinate system.
bool isEmpty() const
Returns true if the rectangle is empty.
void setMapRotation(double degrees, double cx, double cy)
Sets map rotation in degrees (clockwise).
QgsRasterDataProviderTemporalCapabilities * temporalCapabilities() override
Returns the provider's temporal capabilities.
QgsRectangle mDrawnExtent
Intersection of current map extent and layer extent.
Base class for raster data providers.
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
QgsRasterLayerRenderer(QgsRasterLayer *layer, QgsRenderContext &rendererContext)
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...