33 , mMinimalPreviewInterval( 250 )
38 void QgsRasterLayerRendererFeedback::onNewData()
40 if ( !renderPartialOutput() )
45 if ( mLastPreview.isValid() && mLastPreview.msecsTo( QTime::currentTime() ) < mMinimalPreviewInterval )
50 QgsDebugMsg( QStringLiteral(
"new raster preview! %1" ).arg( mLastPreview.msecsTo( QTime::currentTime() ) ) );
58 drawer.draw( mR->renderContext()->painter(), mR->mRasterViewPort, &mR->renderContext()->mapToPixel(), &feedback );
59 QgsDebugMsg( QStringLiteral(
"total raster preview time: %1 ms" ).arg( t.elapsed() ) );
60 mLastPreview = QTime::currentTime();
67 , mFeedback( new QgsRasterLayerRendererFeedback( this ) )
77 static_cast<int>( mapToPixel.
mapWidth() / 2.0 ),
78 static_cast<int>( mapToPixel.
mapHeight() / 2.0 )
88 QgsDebugMsgLevel( QStringLiteral(
"coordinateTransform set -> project extents." ), 4 );
89 if ( rendererContext.
extent().
xMinimum() == std::numeric_limits<double>::lowest() &&
90 rendererContext.
extent().
yMinimum() == std::numeric_limits<double>::lowest() &&
91 rendererContext.
extent().
xMaximum() == std::numeric_limits<double>::max() &&
92 rendererContext.
extent().
yMaximum() == std::numeric_limits<double>::max() )
99 myProjectedViewExtent = rendererContext.
extent();
127 myProjectedViewExtent = rendererContext.
extent();
128 myProjectedLayerExtent = layer->
extent();
133 if ( myRasterExtent.
isEmpty() )
135 QgsDebugMsg( QStringLiteral(
"draw request outside view extent." ) );
154 mRasterViewPort->mDrawnExtent = myRasterExtent;
157 mRasterViewPort->mSrcCRS = layer->
crs();
177 mRasterViewPort->mTopLeftPoint.
setX( std::floor( mRasterViewPort->mTopLeftPoint.x() ) );
178 mRasterViewPort->mTopLeftPoint.setY( std::floor( mRasterViewPort->mTopLeftPoint.y() ) );
179 mRasterViewPort->mBottomRightPoint.setX( std::ceil( mRasterViewPort->mBottomRightPoint.x() ) );
180 mRasterViewPort->mBottomRightPoint.setY( std::ceil( mRasterViewPort->mBottomRightPoint.y() ) );
184 mRasterViewPort->mBottomRightPoint.y() ),
186 mRasterViewPort->mTopLeftPoint.y() )
190 mRasterViewPort->mWidth =
static_cast<int>( mRasterViewPort->mBottomRightPoint.x() - mRasterViewPort->mTopLeftPoint.x() );
191 mRasterViewPort->mHeight =
static_cast<int>( mRasterViewPort->mBottomRightPoint.y() - mRasterViewPort->mTopLeftPoint.y() );
205 QgsDebugMsgLevel( QStringLiteral(
"mTopLeftPoint.x() = %1" ).arg( mRasterViewPort->mTopLeftPoint.x() ), 3 );
206 QgsDebugMsgLevel( QStringLiteral(
"mBottomRightPoint.x() = %1" ).arg( mRasterViewPort->mBottomRightPoint.x() ), 3 );
207 QgsDebugMsgLevel( QStringLiteral(
"mTopLeftPoint.y() = %1" ).arg( mRasterViewPort->mTopLeftPoint.y() ), 3 );
208 QgsDebugMsgLevel( QStringLiteral(
"mBottomRightPoint.y() = %1" ).arg( mRasterViewPort->mBottomRightPoint.y() ), 3 );
210 QgsDebugMsgLevel( QStringLiteral(
"mWidth = %1" ).arg( mRasterViewPort->mWidth ), 3 );
211 QgsDebugMsgLevel( QStringLiteral(
"mHeight = %1" ).arg( mRasterViewPort->mHeight ), 3 );
232 delete mRasterViewPort;
238 if ( !mRasterViewPort )
266 const QStringList
errors = mFeedback->errors();
267 for (
const QString &error : errors )
272 QgsDebugMsgLevel( QStringLiteral(
"total raster draw time (ms): %1" ).arg( time.elapsed(), 5 ), 4 );
int width() const
Returns the width of the (unclipped) raster.
~QgsRasterLayerRenderer() override
QgsFeedback * feedback() const override
Access to feedback object of the layer renderer (may be nullptr)
A rectangle specified with double values.
void setMapRotation(double degrees, double cx, double cy)
Set map rotation in degrees (clockwise)
void setMinimal()
Set a rectangle so that min corner is at max and max corner is at min.
Base class for processing modules.
Iterator for sequentially processing raster cells.
QgsCoordinateTransformContext transformContext() const
Returns the context's coordinate transform context, which stores various information regarding which ...
QgsRasterRenderer * renderer() const
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
QgsRasterPipe * pipe()
Returns the raster pipe.
A class to represent a 2D point.
QgsRasterProjector * projector() const
QgsRasterInterface * last() const
void setRenderPartialOutput(bool enable)
Set whether our painter is drawing to a temporary image used just by this layer.
Flags flags() const
Returns combination of flags used for rendering.
int height() const
Returns the height of the (unclipped) raster.
Implementation of threaded rendering for raster layers.
bool render() override
Do the rendering (based on data stored in the class)
virtual QgsRectangle extent() const
Returns the extent of the layer.
double mapRotation() const
Returns current map rotation in degrees.
QgsCoordinateReferenceSystem mDestCRS
Target coordinate system.
Base class for feedback objects to be used for cancellation of something running in a worker thread...
Perform transforms between map coordinates and device coordinates.
The drawing pipe for raster layers.
QgsPointXY transform(const QgsPointXY &p) const
Transform the point from map (world) coordinates to device coordinates.
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
int mapWidth() const
Returns current map width in pixels The information is only known if setRotation was used...
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
int mapHeight() const
Returns current map height in pixels.
void setPreviewOnly(bool preview)
set flag whether the block request is for preview purposes only
#define QgsDebugMsgLevel(str, level)
bool isEmpty() const
Returns true if the rectangle is empty.
const QgsRectangle & extent() const
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the l...
QgsRasterLayerRenderer(QgsRasterLayer *layer, QgsRenderContext &rendererContext)
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
QgsRectangle intersect(const QgsRectangle &rect) const
Returns the intersection with the given rectangle.
QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
double mapUnitsPerPixel() const
Returns current map units per pixel.
void setX(double x)
Sets the x value of the point.
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
QgsCoordinateReferenceSystem mSrcCRS
Source coordinate system.
double xMaximum() const
Returns the x maximum value (right side of rectangle).
QgsRasterProjector implements approximate projection support for it calculates grid of points in sour...
Render is a 'canvas preview' render, and shortcuts should be taken to ensure fast rendering...
Contains information about the context of a rendering operation.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
QgsCoordinateTransformContext mTransformContext
Coordinate transform context.
Whether to make extra effort to update map image with partially rendered layers (better for interacti...
This class represents a coordinate reference system (CRS).
bool ignoreExtents() const
If the ignoreExtent flag is set, the layer will also render outside the bounding box reported by the ...
double xMinimum() const
Returns the x minimum value (left side of rectangle).
Base class for utility classes that encapsulate information necessary for rendering of map layers...
double yMaximum() const
Returns the y maximum value (top side of rectangle).
QStringList errors() const
Returns list of errors (problems) that happened during the rendering.
void refreshRendererIfNeeded(QgsRasterRenderer *rasterRenderer, const QgsRectangle &extent)
Refresh renderer with new extent, if needed.
Custom exception class for Coordinate Reference System related exceptions.
This class provides details of the viewable area that a raster will be rendered into.
bool testFlag(Flag flag) const
Check whether a particular flag is enabled.
QgsRenderContext * renderContext()
Returns the render context associated with the renderer.
double scaleFactor() const
Returns the scaling factor for the render to convert painter units to physical sizes.
Feedback object tailored for raster block reading.
QgsPointXY toMapCoordinates(int x, int y) const
Transform device coordinates to map (world) coordinates.
Raster renderer pipe that applies colors to a raster.
void setDpi(int dpi)
Sets the output device resolution.
void set(const QgsPointXY &p1, const QgsPointXY &p2)
Sets the rectangle from two QgsPoints.
QgsCoordinateReferenceSystem crs
Q_DECL_DEPRECATED void setCrs(const QgsCoordinateReferenceSystem &srcCRS, const QgsCoordinateReferenceSystem &destCRS, int srcDatumTransform=-1, int destDatumTransform=-1)
Sets the source and destination CRS.