QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsrasterlayerrenderer.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrasterlayerrenderer.cpp
3  --------------------------------------
4  Date : December 2013
5  Copyright : (C) 2013 by Martin Dobias
6  Email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #include "qgsrasterlayerrenderer.h"
17 
18 #include "qgsmessagelog.h"
19 #include "qgsrasterdataprovider.h"
20 #include "qgsrasterdrawer.h"
21 #include "qgsrasteriterator.h"
22 #include "qgsrasterlayer.h"
23 #include "qgsrasterprojector.h"
24 #include "qgsrendercontext.h"
25 #include "qgsproject.h"
26 #include "qgsexception.h"
28 #include "qgsmapclippingutils.h"
29 #include "qgsrasterpipe.h"
30 
31 #include <QElapsedTimer>
32 #include <QPointer>
33 
35 
36 QgsRasterLayerRendererFeedback::QgsRasterLayerRendererFeedback( QgsRasterLayerRenderer *r )
37  : mR( r )
38  , mMinimalPreviewInterval( 250 )
39 {
40  setRenderPartialOutput( r->renderContext()->testFlag( Qgis::RenderContextFlag::RenderPartialOutput ) );
41 }
42 
43 void QgsRasterLayerRendererFeedback::onNewData()
44 {
45  if ( !renderPartialOutput() )
46  return; // we were not asked for partial renders and we may not have a temporary image for overwriting...
47 
48  // update only once upon a time
49  // (preview itself takes some time)
50  if ( mLastPreview.isValid() && mLastPreview.msecsTo( QTime::currentTime() ) < mMinimalPreviewInterval )
51  return;
52 
53  // TODO: update only the area that got new data
54 
55  QgsDebugMsgLevel( QStringLiteral( "new raster preview! %1" ).arg( mLastPreview.msecsTo( QTime::currentTime() ) ), 3 );
56  QElapsedTimer t;
57  t.start();
58  QgsRasterBlockFeedback feedback;
59  feedback.setPreviewOnly( true );
60  feedback.setRenderPartialOutput( true );
61  QgsRasterIterator iterator( mR->mPipe->last() );
62  QgsRasterDrawer drawer( &iterator, mR->renderContext()->dpiTarget() );
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();
67 }
68 
72  : QgsMapLayerRenderer( layer->id(), &rendererContext )
73  , mProviderCapabilities( static_cast<QgsRasterDataProvider::Capability>( layer->dataProvider()->capabilities() ) )
74  , mFeedback( new QgsRasterLayerRendererFeedback( this ) )
75 {
76  mReadyToCompose = false;
77  QgsMapToPixel mapToPixel = rendererContext.mapToPixel();
78  if ( rendererContext.mapToPixel().mapRotation() )
79  {
80  // unset rotation for the sake of local computations.
81  // Rotation will be handled by QPainter later
82  // TODO: provide a method of QgsMapToPixel to fetch map center
83  // in geographical units
84  const QgsPointXY center = mapToPixel.toMapCoordinates(
85  static_cast<int>( mapToPixel.mapWidth() / 2.0 ),
86  static_cast<int>( mapToPixel.mapHeight() / 2.0 )
87  );
88  mapToPixel.setMapRotation( 0, center.x(), center.y() );
89  }
90 
91  QgsRectangle myProjectedViewExtent;
92  QgsRectangle myProjectedLayerExtent;
93 
94  if ( rendererContext.coordinateTransform().isValid() )
95  {
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() )
101  {
102  // We get in this situation if the view CRS is geographical and the
103  // extent goes beyond -180,-90,180,90. To avoid reprojection issues to the
104  // layer CRS, then this dummy extent is returned by QgsMapRendererJob::reprojectToLayerExtent()
105  // Don't try to reproject it now to view extent as this would return
106  // a null rectangle.
107  myProjectedViewExtent = rendererContext.extent();
108  }
109  else
110  {
111  try
112  {
113  QgsCoordinateTransform ct = rendererContext.coordinateTransform();
115  myProjectedViewExtent = ct.transformBoundingBox( rendererContext.extent() );
116  }
117  catch ( QgsCsException &cs )
118  {
119  QgsMessageLog::logMessage( QObject::tr( "Could not reproject view extent: %1" ).arg( cs.what() ), QObject::tr( "Raster" ) );
120  myProjectedViewExtent.setMinimal();
121  }
122  }
123 
124  try
125  {
126  QgsCoordinateTransform ct = rendererContext.coordinateTransform();
128  myProjectedLayerExtent = ct.transformBoundingBox( layer->extent() );
129  }
130  catch ( QgsCsException &cs )
131  {
132  QgsMessageLog::logMessage( QObject::tr( "Could not reproject layer extent: %1" ).arg( cs.what() ), QObject::tr( "Raster" ) );
133  myProjectedLayerExtent.setMinimal();
134  }
135  }
136  else
137  {
138  QgsDebugMsgLevel( QStringLiteral( "coordinateTransform not set" ), 4 );
139  myProjectedViewExtent = rendererContext.extent();
140  myProjectedLayerExtent = layer->extent();
141  }
142 
143  // clip raster extent to view extent
144  QgsRectangle myRasterExtent = layer->ignoreExtents() ? myProjectedViewExtent : myProjectedViewExtent.intersect( myProjectedLayerExtent );
145  if ( myRasterExtent.isEmpty() )
146  {
147  QgsDebugMsgLevel( QStringLiteral( "draw request outside view extent." ), 2 );
148  // nothing to do
149  return;
150  }
151 
152  QgsDebugMsgLevel( "theViewExtent is " + rendererContext.extent().toString(), 4 );
153  QgsDebugMsgLevel( "myProjectedViewExtent is " + myProjectedViewExtent.toString(), 4 );
154  QgsDebugMsgLevel( "myProjectedLayerExtent is " + myProjectedLayerExtent.toString(), 4 );
155  QgsDebugMsgLevel( "myRasterExtent is " + myRasterExtent.toString(), 4 );
156 
157  //
158  // The first thing we do is set up the QgsRasterViewPort. This struct stores all the settings
159  // relating to the size (in pixels and coordinate system units) of the raster part that is
160  // in view in the map window. It also stores the origin.
161  //
162  //this is not a class level member because every time the user pans or zooms
163  //the contents of the rasterViewPort will change
164  mRasterViewPort = new QgsRasterViewPort();
165 
166  mRasterViewPort->mDrawnExtent = myRasterExtent;
167  if ( rendererContext.coordinateTransform().isValid() )
168  {
169  mRasterViewPort->mSrcCRS = layer->crs();
170  mRasterViewPort->mDestCRS = rendererContext.coordinateTransform().destinationCrs();
171  mRasterViewPort->mTransformContext = rendererContext.transformContext();
172  }
173  else
174  {
175  mRasterViewPort->mSrcCRS = QgsCoordinateReferenceSystem(); // will be invalid
176  mRasterViewPort->mDestCRS = QgsCoordinateReferenceSystem(); // will be invalid
177  }
178 
179  // get dimensions of clipped raster image in device coordinate space (this is the size of the viewport)
180  mRasterViewPort->mTopLeftPoint = mapToPixel.transform( myRasterExtent.xMinimum(), myRasterExtent.yMaximum() );
181  mRasterViewPort->mBottomRightPoint = mapToPixel.transform( myRasterExtent.xMaximum(), myRasterExtent.yMinimum() );
182 
183  // align to output device grid, i.e. std::floor/ceil to integers
184  // TODO: this should only be done if paint device is raster - screen, image
185  // for other devices (pdf) it can have floating point origin
186  // we could use floating point for raster devices as well, but respecting the
187  // output device grid should make it more effective as the resampling is done in
188  // the provider anyway
189  mRasterViewPort->mTopLeftPoint.setX( std::floor( mRasterViewPort->mTopLeftPoint.x() ) );
190  mRasterViewPort->mTopLeftPoint.setY( std::floor( mRasterViewPort->mTopLeftPoint.y() ) );
191  mRasterViewPort->mBottomRightPoint.setX( std::ceil( mRasterViewPort->mBottomRightPoint.x() ) );
192  mRasterViewPort->mBottomRightPoint.setY( std::ceil( mRasterViewPort->mBottomRightPoint.y() ) );
193  // recalc myRasterExtent to aligned values
194  myRasterExtent.set(
195  mapToPixel.toMapCoordinates( mRasterViewPort->mTopLeftPoint.x(),
196  mRasterViewPort->mBottomRightPoint.y() ),
197  mapToPixel.toMapCoordinates( mRasterViewPort->mBottomRightPoint.x(),
198  mRasterViewPort->mTopLeftPoint.y() )
199  );
200 
201  //raster viewport top left / bottom right are already rounded to int
202  mRasterViewPort->mWidth = static_cast<qgssize>( std::abs( mRasterViewPort->mBottomRightPoint.x() - mRasterViewPort->mTopLeftPoint.x() ) );
203  mRasterViewPort->mHeight = static_cast<qgssize>( std::abs( mRasterViewPort->mBottomRightPoint.y() - mRasterViewPort->mTopLeftPoint.y() ) );
204 
205  // painter could be null (in parallel rendering for instance) so we fallback on scaleFactor which
206  // should be equal to outputDpi and so logicalDpiX (except for QPicture)
207  const double dpi = rendererContext.painter() ? rendererContext.painter()->device()->logicalDpiX() :
208  25.4 * rendererContext.scaleFactor();
209  if ( mProviderCapabilities & QgsRasterDataProvider::DpiDependentData
210  && rendererContext.dpiTarget() >= 0.0 )
211  {
212  const double dpiScaleFactor = rendererContext.dpiTarget() / dpi;
213  mRasterViewPort->mWidth *= dpiScaleFactor;
214  mRasterViewPort->mHeight *= dpiScaleFactor;
215  }
216  else
217  {
218  rendererContext.setDpiTarget( -1.0 );
219  }
220 
221  //the drawable area can start to get very very large when you get down displaying 2x2 or smaller, this is because
222  //mapToPixel.mapUnitsPerPixel() is less then 1,
223  //so we will just get the pixel data and then render these special cases differently in paintImageToCanvas()
224 
225  QgsDebugMsgLevel( QStringLiteral( "mapUnitsPerPixel = %1" ).arg( mapToPixel.mapUnitsPerPixel() ), 3 );
226  QgsDebugMsgLevel( QStringLiteral( "mWidth = %1" ).arg( layer->width() ), 3 );
227  QgsDebugMsgLevel( QStringLiteral( "mHeight = %1" ).arg( layer->height() ), 3 );
228  QgsDebugMsgLevel( QStringLiteral( "myRasterExtent.xMinimum() = %1" ).arg( myRasterExtent.xMinimum() ), 3 );
229  QgsDebugMsgLevel( QStringLiteral( "myRasterExtent.xMaximum() = %1" ).arg( myRasterExtent.xMaximum() ), 3 );
230  QgsDebugMsgLevel( QStringLiteral( "myRasterExtent.yMinimum() = %1" ).arg( myRasterExtent.yMinimum() ), 3 );
231  QgsDebugMsgLevel( QStringLiteral( "myRasterExtent.yMaximum() = %1" ).arg( myRasterExtent.yMaximum() ), 3 );
232 
233  QgsDebugMsgLevel( QStringLiteral( "mTopLeftPoint.x() = %1" ).arg( mRasterViewPort->mTopLeftPoint.x() ), 3 );
234  QgsDebugMsgLevel( QStringLiteral( "mBottomRightPoint.x() = %1" ).arg( mRasterViewPort->mBottomRightPoint.x() ), 3 );
235  QgsDebugMsgLevel( QStringLiteral( "mTopLeftPoint.y() = %1" ).arg( mRasterViewPort->mTopLeftPoint.y() ), 3 );
236  QgsDebugMsgLevel( QStringLiteral( "mBottomRightPoint.y() = %1" ).arg( mRasterViewPort->mBottomRightPoint.y() ), 3 );
237 
238  QgsDebugMsgLevel( QStringLiteral( "mWidth = %1" ).arg( mRasterViewPort->mWidth ), 3 );
239  QgsDebugMsgLevel( QStringLiteral( "mHeight = %1" ).arg( mRasterViewPort->mHeight ), 3 );
240 
241  // /\/\/\ - added to handle zoomed-in rasters
242 
243  // TODO R->mLastViewPort = *mRasterViewPort;
244 
245  // TODO: is it necessary? Probably WMS only?
246  layer->dataProvider()->setDpi( dpi );
247 
248  // copy the whole raster pipe!
249  mPipe = new QgsRasterPipe( *layer->pipe() );
250  QObject::connect( mPipe->provider(), &QgsRasterDataProvider::statusChanged, layer, &QgsRasterLayer::statusChanged );
251  QgsRasterRenderer *rasterRenderer = mPipe->renderer();
252  if ( rasterRenderer
253  && !( rendererContext.flags() & Qgis::RenderContextFlag::RenderPreviewJob )
254  && !( rendererContext.flags() & Qgis::RenderContextFlag::Render3DMap ) )
255  {
256  layer->refreshRendererIfNeeded( rasterRenderer, rendererContext.extent() );
257  }
258 
259  mPipe->evaluateDataDefinedProperties( rendererContext.expressionContext() );
260 
261  const QgsRasterLayerTemporalProperties *temporalProperties = qobject_cast< const QgsRasterLayerTemporalProperties * >( layer->temporalProperties() );
262  if ( temporalProperties->isActive() && renderContext()->isTemporal() )
263  {
264  switch ( temporalProperties->mode() )
265  {
266  case Qgis::RasterTemporalMode::FixedTemporalRange:
267  case Qgis::RasterTemporalMode::RedrawLayerOnly:
268  break;
269 
270  case Qgis::RasterTemporalMode::TemporalRangeFromDataProvider:
271  // in this mode we need to pass on the desired render temporal range to the data provider
272  if ( mPipe->provider()->temporalCapabilities() )
273  {
274  mPipe->provider()->temporalCapabilities()->setRequestedTemporalRange( rendererContext.temporalRange() );
276  }
277  break;
278  }
279  }
280  else if ( mPipe->provider()->temporalCapabilities() )
281  {
282  mPipe->provider()->temporalCapabilities()->setRequestedTemporalRange( QgsDateTimeRange() );
284  }
285 
287 
288  mFeedback->setRenderContext( rendererContext );
289 }
290 
292 {
293  delete mFeedback;
294 
295  delete mRasterViewPort;
296  delete mPipe;
297 }
298 
300 {
301  // Skip rendering of out of view tiles (xyz)
302  if ( !mRasterViewPort || ( renderContext()->testFlag( Qgis::RenderContextFlag::RenderPreviewJob ) &&
303  !( mProviderCapabilities &
304  QgsRasterInterface::Capability::Prefetch ) ) )
305  return true;
306 
307  QElapsedTimer time;
308  time.start();
309  //
310  //
311  // The goal here is to make as many decisions as possible early on (outside of the rendering loop)
312  // so that we can maximise performance of the rendering process. So now we check which drawing
313  // procedure to use :
314  //
315 
316  const QgsScopedQPainterState painterSate( renderContext()->painter() );
317  if ( !mClippingRegions.empty() )
318  {
319  bool needsPainterClipPath = false;
320  const QPainterPath path = QgsMapClippingUtils::calculatePainterClipRegion( mClippingRegions, *renderContext(), QgsMapLayerType::RasterLayer, needsPainterClipPath );
321  if ( needsPainterClipPath )
322  renderContext()->painter()->setClipPath( path, Qt::IntersectClip );
323  }
324 
325  QgsRasterProjector *projector = mPipe->projector();
326  bool restoreOldResamplingStage = false;
327  const Qgis::RasterResamplingStage oldResamplingState = mPipe->resamplingStage();
328 
329  // TODO add a method to interface to get provider and get provider
330  // params in QgsRasterProjector
331  if ( projector )
332  {
333  // Force provider resampling if reprojection is needed
335  mRasterViewPort->mSrcCRS != mRasterViewPort->mDestCRS &&
336  oldResamplingState != Qgis::RasterResamplingStage::Provider )
337  {
338  restoreOldResamplingStage = true;
340  }
341  projector->setCrs( mRasterViewPort->mSrcCRS, mRasterViewPort->mDestCRS, mRasterViewPort->mTransformContext );
342  }
343 
344  // important -- disable SmoothPixmapTransform for raster layer renders. We want individual pixels to be clearly defined!
345  renderContext()->painter()->setRenderHint( QPainter::SmoothPixmapTransform, false );
346 
347  // Drawer to pipe?
348  QgsRasterIterator iterator( mPipe->last() );
349  QgsRasterDrawer drawer( &iterator, renderContext()->dpiTarget() );
350  drawer.draw( renderContext()->painter(), mRasterViewPort, &renderContext()->mapToPixel(), mFeedback );
351 
352  if ( restoreOldResamplingStage )
353  {
354  mPipe->setResamplingStage( oldResamplingState );
355  }
356 
357  const QStringList errors = mFeedback->errors();
358  for ( const QString &error : errors )
359  {
360  mErrors.append( error );
361  }
362 
363  QgsDebugMsgLevel( QStringLiteral( "total raster draw time (ms): %1" ).arg( time.elapsed(), 5 ), 4 );
364  mReadyToCompose = true;
365 
366  return !mFeedback->isCanceled();
367 }
368 
370 {
371  return mFeedback;
372 }
373 
375 {
376  // preview of intermediate raster rendering results requires a temporary output image
378 }
QgsMapClippingUtils::collectClippingRegionsForLayer
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.
Definition: qgsmapclippingutils.cpp:24
QgsRasterViewPort::mBottomRightPoint
QgsPointXY mBottomRightPoint
Coordinate (in output device coordinate system) of bottom right corner of the part of the raster that...
Definition: qgsrasterviewport.h:65
QgsMapLayer::crs
QgsCoordinateReferenceSystem crs
Definition: qgsmaplayer.h:79
qgsrasterprojector.h
QgsPointXY::y
double y
Definition: qgspointxy.h:63
QgsRenderContext::setDpiTarget
void setDpiTarget(double dpi)
Sets the targeted dpi for rendering.
Definition: qgsrendercontext.h:480
QgsRenderContext::mapToPixel
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
Definition: qgsrendercontext.h:258
qgsrasterlayer.h
QgsRasterLayerRenderer::forceRasterRender
bool forceRasterRender() const override
Returns true if the renderer must be rendered to a raster paint device (e.g.
Definition: qgsrasterlayerrenderer.cpp:374
QgsRenderContext::expressionContext
QgsExpressionContext & expressionContext()
Gets the expression context.
Definition: qgsrendercontext.h:625
QgsMapToPixel::mapUnitsPerPixel
double mapUnitsPerPixel() const
Returns the current map units per pixel.
Definition: qgsmaptopixel.h:229
QgsRectangle::set
void set(const QgsPointXY &p1, const QgsPointXY &p2, bool normalize=true)
Sets the rectangle from two QgsPoints.
Definition: qgsrectangle.h:122
QgsRasterLayer::ignoreExtents
bool ignoreExtents() const
If the ignoreExtent flag is set, the layer will also render outside the bounding box reported by the ...
Definition: qgsrasterlayer.cpp:1077
qgsrasterpipe.h
QgsDebugMsgLevel
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39
QgsRasterDataProviderTemporalCapabilities::setRequestedTemporalRange
void setRequestedTemporalRange(const QgsDateTimeRange &range)
Sets the requested temporal range to retrieve when returning data from the associated data provider.
Definition: qgsrasterdataprovidertemporalcapabilities.cpp:61
qgsrasterdrawer.h
QgsMapLayerRenderer::errors
QStringList errors() const
Returns list of errors (problems) that happened during the rendering.
Definition: qgsmaplayerrenderer.h:101
QgsRasterViewPort::mSrcCRS
QgsCoordinateReferenceSystem mSrcCRS
Source coordinate system.
Definition: qgsrasterviewport.h:77
QgsRasterDataProvider::ProviderHintCanPerformProviderResampling
@ ProviderHintCanPerformProviderResampling
Provider can perform resampling (to be opposed to post rendering resampling) (since QGIS 3....
Definition: qgsrasterdataprovider.h:104
QgsRectangle::yMinimum
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
Definition: qgsrectangle.h:198
QgsCoordinateTransform::transformBoundingBox
QgsRectangle transformBoundingBox(const QgsRectangle &rectangle, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool handle180Crossover=false) const SIP_THROW(QgsCsException)
Transforms a rectangle from the source CRS to the destination CRS.
Definition: qgscoordinatetransform.cpp:560
QgsRenderContext::testFlag
bool testFlag(Qgis::RenderContextFlag flag) const
Check whether a particular flag is enabled.
Definition: qgsrendercontext.cpp:229
QgsRenderContext::flags
Qgis::RenderContextFlags flags() const
Returns combination of flags used for rendering.
Definition: qgsrendercontext.cpp:224
QgsMapLayer::statusChanged
void statusChanged(const QString &status)
Emit a signal with status (e.g. to be caught by QgisApp and display a msg on status bar)
QgsRasterPipe
Contains a pipeline of raster interfaces for sequential raster processing.
Definition: qgsrasterpipe.h:49
QgsPointXY::setY
void setY(double y) SIP_HOLDGIL
Sets the y value of the point.
Definition: qgspointxy.h:132
QgsTemporalRangeObject::temporalRange
const QgsDateTimeRange & temporalRange() const
Returns the datetime range for the object.
Definition: qgstemporalrangeobject.cpp:43
Qgis::RasterResamplingStage
RasterResamplingStage
Stage at which raster resampling occurs.
Definition: qgis.h:720
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:59
QgsMapLayerRenderer::renderContext
QgsRenderContext * renderContext()
Returns the render context associated with the renderer.
Definition: qgsmaplayerrenderer.h:111
QgsRectangle::setMinimal
void setMinimal() SIP_HOLDGIL
Set a rectangle so that min corner is at max and max corner is at min.
Definition: qgsrectangle.h:172
QgsMapLayerRenderer::mReadyToCompose
bool mReadyToCompose
The flag must be set to false in renderer's constructor if wants to use the smarter map redraws funct...
Definition: qgsmaplayerrenderer.h:171
QgsRasterViewPort::mTopLeftPoint
QgsPointXY mTopLeftPoint
Coordinate (in output device coordinate system) of top left corner of the part of the raster that is ...
Definition: qgsrasterviewport.h:59
QgsRasterViewPort
Definition: qgsrasterviewport.h:34
QgsRenderContext::scaleFactor
double scaleFactor() const
Returns the scaling factor for the render to convert painter units to physical sizes.
Definition: qgsrendercontext.h:266
QgsMapToPixel::toMapCoordinates
QgsPointXY toMapCoordinates(int x, int y) const
Transforms device coordinates to map (world) coordinates.
Definition: qgsmaptopixel.h:173
QgsRectangle::intersect
QgsRectangle intersect(const QgsRectangle &rect) const
Returns the intersection with the given rectangle.
Definition: qgsrectangle.h:333
QgsCoordinateTransform::isValid
bool isValid() const
Returns true if the coordinate transform is valid, ie both the source and destination CRS have been s...
Definition: qgscoordinatetransform.cpp:900
QgsRenderContext::extent
const QgsRectangle & extent() const
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the l...
Definition: qgsrendercontext.h:239
QgsPointXY::setX
void setX(double x) SIP_HOLDGIL
Sets the x value of the point.
Definition: qgspointxy.h:122
QgsRenderContext::dpiTarget
double dpiTarget() const
Returns the targeted DPI for rendering.
Definition: qgsrendercontext.h:274
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
QgsRasterLayerTemporalProperties
Implementation of map layer temporal properties for raster layers.
Definition: qgsrasterlayertemporalproperties.h:35
QgsRasterPipe::provider
QgsRasterDataProvider * provider() const
Returns the data provider interface, or nullptr if no data provider is present in the pipe.
Definition: qgsrasterpipe.cpp:267
QgsMapLayerRenderer
Base class for utility classes that encapsulate information necessary for rendering of map layers.
Definition: qgsmaplayerrenderer.h:54
QgsCoordinateTransform::destinationCrs
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination coordinate reference system, which the transform will transform coordinates t...
Definition: qgscoordinatetransform.cpp:267
qgsrasteriterator.h
QgsRasterProjector
QgsRasterProjector implements approximate projection support for it calculates grid of points in sour...
Definition: qgsrasterprojector.h:47
QgsRectangle::xMaximum
double xMaximum() const SIP_HOLDGIL
Returns the x maximum value (right side of rectangle).
Definition: qgsrectangle.h:183
QgsRasterLayerRenderer::~QgsRasterLayerRenderer
~QgsRasterLayerRenderer() override
Definition: qgsrasterlayerrenderer.cpp:291
QgsRenderContext::coordinateTransform
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
Definition: qgsrendercontext.h:178
QgsRasterPipe::evaluateDataDefinedProperties
void evaluateDataDefinedProperties(QgsExpressionContext &context)
Evaluates any data defined properties set on the pipe, applying their results to the corresponding in...
Definition: qgsrasterpipe.cpp:411
QgsRasterLayerRenderer::feedback
QgsFeedback * feedback() const override
Access to feedback object of the layer renderer (may be nullptr)
Definition: qgsrasterlayerrenderer.cpp:369
QgsCsException
Custom exception class for Coordinate Reference System related exceptions.
Definition: qgsexception.h:65
QgsRasterLayer::width
int width() const
Returns the width of the (unclipped) raster.
Definition: qgsrasterlayer.cpp:2618
QgsRasterDrawer::draw
void draw(QPainter *p, QgsRasterViewPort *viewPort, const QgsMapToPixel *qgsMapToPixel, QgsRasterBlockFeedback *feedback=nullptr)
Draws raster data.
Definition: qgsrasterdrawer.cpp:38
QgsRasterPipe::resamplingStage
Qgis::RasterResamplingStage resamplingStage() const
Returns which stage of the pipe should apply resampling.
Definition: qgsrasterpipe.h:225
QgsTemporalProperty::isActive
bool isActive() const
Returns true if the temporal property is active.
Definition: qgstemporalproperty.cpp:36
QgsCoordinateTransform::setBallparkTransformsAreAppropriate
void setBallparkTransformsAreAppropriate(bool appropriate)
Sets whether approximate "ballpark" results are appropriate for this coordinate transform.
Definition: qgscoordinatetransform.cpp:939
QgsRasterPipe::renderer
QgsRasterRenderer * renderer() const
Returns the raster renderer interface, or nullptr if no raster renderer is present in the pipe.
Definition: qgsrasterpipe.cpp:272
Qgis::RenderContextFlag::RenderPreviewJob
@ RenderPreviewJob
Render is a 'canvas preview' render, and shortcuts should be taken to ensure fast rendering.
QgsRasterRenderer
Raster renderer pipe that applies colors to a raster.
Definition: qgsrasterrenderer.h:40
QgsRasterDataProvider::providerCapabilities
virtual QgsRasterDataProvider::ProviderCapabilities providerCapabilities() const
Returns flags containing the supported capabilities of the data provider.
Definition: qgsrasterdataprovider.cpp:250
QgsRasterViewPort::mTransformContext
QgsCoordinateTransformContext mTransformContext
Coordinate transform context.
Definition: qgsrasterviewport.h:85
QgsMapClippingUtils::calculatePainterClipRegion
static QPainterPath calculatePainterClipRegion(const QList< QgsMapClippingRegion > &regions, const QgsRenderContext &context, QgsMapLayerType layerType, bool &shouldClip)
Returns a QPainterPath representing the intersection of clipping regions from context which should be...
Definition: qgsmapclippingutils.cpp:127
QgsRasterDataProviderTemporalCapabilities::setIntervalHandlingMethod
void setIntervalHandlingMethod(Qgis::TemporalIntervalMatchMethod method)
Sets the desired method to use when resolving a temporal interval to matching layers or bands in the ...
Definition: qgsrasterdataprovidertemporalcapabilities.cpp:86
QgsFeedback
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:44
QgsMapToPixel::mapHeight
int mapHeight() const
Returns current map height in pixels.
Definition: qgsmaptopixel.h:247
QgsMapToPixel::mapRotation
double mapRotation() const
Returns the current map rotation in degrees (clockwise).
Definition: qgsmaptopixel.h:269
QgsRasterLayer::height
int height() const
Returns the height of the (unclipped) raster.
Definition: qgsrasterlayer.cpp:2624
QgsMapLayer::extent
virtual QgsRectangle extent() const
Returns the extent of the layer.
Definition: qgsmaplayer.cpp:305
QgsRasterLayer::temporalProperties
QgsMapLayerTemporalProperties * temporalProperties() override
Returns the layer's temporal properties.
Definition: qgsrasterlayer.cpp:1082
QgsException::what
QString what() const
Definition: qgsexception.h:48
QgsMapLayerType::RasterLayer
@ RasterLayer
Raster layer.
QgsRasterDataProvider::setDpi
void setDpi(int dpi)
Sets the output device resolution.
Definition: qgsrasterdataprovider.h:453
qgsrendercontext.h
QgsRasterDrawer
The drawing pipe for raster layers.
Definition: qgsrasterdrawer.h:37
QgsMapLayerRenderer::mErrors
QStringList mErrors
Definition: qgsmaplayerrenderer.h:152
QgsMessageLog::logMessage
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).
Definition: qgsmessagelog.cpp:27
QgsRasterProjector::setCrs
Q_DECL_DEPRECATED void setCrs(const QgsCoordinateReferenceSystem &srcCRS, const QgsCoordinateReferenceSystem &destCRS, int srcDatumTransform=-1, int destDatumTransform=-1)
Sets the source and destination CRS.
QgsRectangle::xMinimum
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
Definition: qgsrectangle.h:188
Qgis::RenderContextFlag::RenderPartialOutput
@ RenderPartialOutput
Whether to make extra effort to update map image with partially rendered layers (better for interacti...
QgsRasterLayer
Represents a raster layer.
Definition: qgsrasterlayer.h:76
QgsScopedQPainterState
Scoped object for saving and restoring a QPainter object's state.
Definition: qgsrendercontext.h:1336
QgsRasterBlockFeedback::setRenderPartialOutput
void setRenderPartialOutput(bool enable)
Set whether our painter is drawing to a temporary image used just by this layer.
Definition: qgsrasterinterface.h:91
QgsRasterIterator
Iterator for sequentially processing raster cells.
Definition: qgsrasteriterator.h:34
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:211
QgsMapToPixel::transform
QgsPointXY transform(const QgsPointXY &p) const
Transforms a point p from map (world) coordinates to device coordinates.
Definition: qgsmaptopixel.h:90
QgsRasterPipe::setResamplingStage
void setResamplingStage(Qgis::RasterResamplingStage stage)
Sets which stage of the pipe should apply resampling.
Definition: qgsrasterpipe.cpp:390
qgsrasterlayerrenderer.h
QgsRasterDataProvider::DpiDependentData
@ DpiDependentData
Definition: qgsrasterdataprovider.h:106
QgsRectangle::toString
QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
Definition: qgsrectangle.cpp:127
QgsPointXY
A class to represent a 2D point.
Definition: qgspointxy.h:58
QgsRasterLayerTemporalProperties::mode
Qgis::RasterTemporalMode mode() const
Returns the temporal properties mode.
Definition: qgsrasterlayertemporalproperties.cpp:89
QgsRasterLayerRenderer::render
bool render() override
Do the rendering (based on data stored in the class).
Definition: qgsrasterlayerrenderer.cpp:299
QgsRasterPipe::last
QgsRasterInterface * last() const
Returns last interface in the pipe.
Definition: qgsrasterpipe.h:157
QgsRasterViewPort::mHeight
qgssize mHeight
Height, number of rows to be rendered.
Definition: qgsrasterviewport.h:71
QgsRectangle::yMaximum
double yMaximum() const SIP_HOLDGIL
Returns the y maximum value (top side of rectangle).
Definition: qgsrectangle.h:193
QgsRasterLayerRenderer
Implementation of threaded rendering for raster layers.
Definition: qgsrasterlayerrenderer.h:70
QgsRasterViewPort::mWidth
qgssize mWidth
Width, number of columns to be rendered.
Definition: qgsrasterviewport.h:68
QgsMapToPixel
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:38
QgsMapToPixel::mapWidth
int mapWidth() const
Returns the current map width in pixels.
Definition: qgsmaptopixel.h:239
QgsRasterLayer::pipe
QgsRasterPipe * pipe()
Returns the raster pipe.
Definition: qgsrasterlayer.h:295
QgsRenderContext::transformContext
QgsCoordinateTransformContext transformContext() const
Returns the context's coordinate transform context, which stores various information regarding which ...
Definition: qgsrendercontext.cpp:184
QgsPointXY::x
double x
Definition: qgspointxy.h:62
QgsRasterBlockFeedback
Feedback object tailored for raster block reading.
Definition: qgsrasterinterface.h:41
QgsRasterLayerTemporalProperties::intervalHandlingMethod
Qgis::TemporalIntervalMatchMethod intervalHandlingMethod() const
Returns the desired method to use when resolving a temporal interval to matching layers or bands in t...
Definition: qgsrasterlayertemporalproperties.cpp:106
QgsRasterDataProvider::statusChanged
void statusChanged(const QString &) const
Emit a message to be displayed on status bar, usually used by network providers (WMS,...
QgsRasterLayer::refreshRendererIfNeeded
void refreshRendererIfNeeded(QgsRasterRenderer *rasterRenderer, const QgsRectangle &extent)
Refresh renderer with new extent, if needed.
Definition: qgsrasterlayer.cpp:1274
qgsmapclippingutils.h
QgsRasterBlockFeedback::setPreviewOnly
void setPreviewOnly(bool preview)
set flag whether the block request is for preview purposes only
Definition: qgsrasterinterface.h:79
Qgis::RasterResamplingStage::Provider
@ Provider
Resampling occurs in Provider.
qgsrasterlayertemporalproperties.h
qgsexception.h
Qgis::RenderContextFlag::Render3DMap
@ Render3DMap
Render is for a 3D map.
QgsRasterPipe::projector
QgsRasterProjector * projector() const
Returns the projector interface, or nullptr if no projector is present in the pipe.
Definition: qgsrasterpipe.cpp:292
QgsRenderContext::painter
QPainter * painter()
Returns the destination QPainter for the render operation.
Definition: qgsrendercontext.h:112
QgsCoordinateTransform
Class for doing transforms between two map coordinate systems.
Definition: qgscoordinatetransform.h:57
QgsRasterViewPort::mDestCRS
QgsCoordinateReferenceSystem mDestCRS
Target coordinate system.
Definition: qgsrasterviewport.h:80
QgsRectangle::isEmpty
bool isEmpty() const
Returns true if the rectangle is empty.
Definition: qgsrectangle.h:469
QgsMapToPixel::setMapRotation
void setMapRotation(double degrees, double cx, double cy)
Sets map rotation in degrees (clockwise).
Definition: qgsmaptopixel.cpp:95
QgsRasterDataProvider::temporalCapabilities
QgsRasterDataProviderTemporalCapabilities * temporalCapabilities() override
Returns the provider's temporal capabilities.
Definition: qgsrasterdataprovider.cpp:412
QgsRasterViewPort::mDrawnExtent
QgsRectangle mDrawnExtent
Intersection of current map extent and layer extent.
Definition: qgsrasterviewport.h:74
QgsRasterDataProvider
Base class for raster data providers.
Definition: qgsrasterdataprovider.h:88
qgsproject.h
QgsRasterLayer::dataProvider
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
Definition: qgsrasterlayer.cpp:257
qgsrasterdataprovider.h
QgsRasterLayerRenderer::QgsRasterLayerRenderer
QgsRasterLayerRenderer(QgsRasterLayer *layer, QgsRenderContext &rendererContext)
Definition: qgsrasterlayerrenderer.cpp:71
qgsmessagelog.h
qgssize
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...
Definition: qgis.h:2791