diff --git a/doc/api_break.dox b/doc/api_break.dox index f6de8947d9d..e290bb12435 100644 --- a/doc/api_break.dox +++ b/doc/api_break.dox @@ -1495,6 +1495,7 @@ QgsRasterDataProvider {#qgis_api_break_3_0_QgsRasterDataProvider} - useSrcNoDataValue() has been renamed to useSourceNoDataValue() - setUseSrcNoDataValue() has been renamed to setUseSourceNoDataValue() - srcNoDataValue() has been renamed to sourceNoDataValue() +- draw() has been removed from the interface as it was not used anywhere. QgsRasterInterface {#qgis_api_break_3_0_QgsRasterInterface} diff --git a/python/core/raster/qgsrasterdataprovider.sip b/python/core/raster/qgsrasterdataprovider.sip index e3ebb7c3cf3..27c142bb368 100644 --- a/python/core/raster/qgsrasterdataprovider.sip +++ b/python/core/raster/qgsrasterdataprovider.sip @@ -52,15 +52,6 @@ class QgsRasterDataProvider : QgsDataProvider, QgsRasterInterface /* It makes no sense to set input on provider */ bool setInput( QgsRasterInterface* input ); - /** \brief Renders the layer as an image - * \note When render caching (/qgis/enable_render_caching) is on the wms - * provider doesn't wait for the reply of the getmap request or all - * tiles replies and can return incomplete images. - * Temporarily disable render caching if you require the complete - * wms image in the first call. - */ - virtual QImage* draw( const QgsRectangle & viewExtent, int pixelWidth, int pixelHeight ) = 0; - /** Get the extent of the data source. * @return QgsRectangle containing the extent of the layer */ diff --git a/src/core/raster/qgsrasterdataprovider.h b/src/core/raster/qgsrasterdataprovider.h index 13fdc37c152..82e5fe6c3e6 100644 --- a/src/core/raster/qgsrasterdataprovider.h +++ b/src/core/raster/qgsrasterdataprovider.h @@ -91,15 +91,6 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider, public QgsRast /* It makes no sense to set input on provider */ bool setInput( QgsRasterInterface* input ) override { Q_UNUSED( input ); return false; } - /** \brief Renders the layer as an image - * \note When render caching (/qgis/enable_render_caching) is on the wms - * provider doesn't wait for the reply of the getmap request or all - * tiles replies and can return incomplete images. - * Temporarily disable render caching if you require the complete - * wms image in the first call. - */ - virtual QImage* draw( const QgsRectangle & viewExtent, int pixelWidth, int pixelHeight ) = 0; - virtual QgsRectangle extent() const override = 0; //! Returns data type for the band specified by number diff --git a/src/providers/arcgisrest/qgsamsprovider.cpp b/src/providers/arcgisrest/qgsamsprovider.cpp index 043aecda871..adab274068d 100644 --- a/src/providers/arcgisrest/qgsamsprovider.cpp +++ b/src/providers/arcgisrest/qgsamsprovider.cpp @@ -238,11 +238,11 @@ QString QgsAmsProvider::metadata() return dumpVariantMap( mServiceInfo, tr( "Service Info" ) ) + dumpVariantMap( mLayerInfo, tr( "Layer Info" ) ); } -QImage* QgsAmsProvider::draw( const QgsRectangle & viewExtent, int pixelWidth, int pixelHeight ) +void QgsAmsProvider::draw( const QgsRectangle & viewExtent, int pixelWidth, int pixelHeight ) { if ( !mCachedImage.isNull() && mCachedImageExtent == viewExtent ) { - return &mCachedImage; + return; } QgsDataSourceUri dataSource( dataSourceUri() ); @@ -269,7 +269,7 @@ QImage* QgsAmsProvider::draw( const QgsRectangle & viewExtent, int pixelWidth, i { mCachedImage = QImage(); mCachedImage.fill( Qt::transparent ); - return &mCachedImage; + return; } int level = 0; double resolution = lodEntries.front().toMap()[QStringLiteral( "resolution" )].toDouble(); @@ -343,7 +343,7 @@ QImage* QgsAmsProvider::draw( const QgsRectangle & viewExtent, int pixelWidth, i mCachedImage = mCachedImage.convertToFormat( QImage::Format_ARGB32 ); } } - return &mCachedImage; + return; } QImage QgsAmsProvider::getLegendGraphic( double /*scale*/, bool forceRefresh, const QgsRectangle * /*visibleExtent*/ ) @@ -442,12 +442,11 @@ void QgsAmsProvider::readBlock( int /*bandNo*/, const QgsRectangle & viewExtent, Q_UNUSED( feedback ); // TODO: make use of the feedback object // TODO: optimize to avoid writing to QImage - // returned image is actually mCachedImage, no need to delete - QImage *image = draw( viewExtent, width, height ); - if ( image->width() != width || image->height() != height ) + draw( viewExtent, width, height ); + if ( mCachedImage.width() != width || mCachedImage.height() != height ) { QgsDebugMsg( "Unexpected image size for block" ); return; } - std::memcpy( data, image->bits(), image->bytesPerLine() * image->height() ); + std::memcpy( data, mCachedImage.constBits(), mCachedImage.bytesPerLine() * mCachedImage.height() ); } diff --git a/src/providers/arcgisrest/qgsamsprovider.h b/src/providers/arcgisrest/qgsamsprovider.h index 5fc85fa4da3..deaaab99f31 100644 --- a/src/providers/arcgisrest/qgsamsprovider.h +++ b/src/providers/arcgisrest/qgsamsprovider.h @@ -80,7 +80,6 @@ class QgsAmsProvider : public QgsRasterDataProvider Qgis::DataType sourceDataType( int /*bandNo*/ ) const override { return Qgis::ARGB32; } QgsRasterInterface* clone() const override; QString metadata() override; - QImage* draw( const QgsRectangle & viewExtent, int pixelWidth, int pixelHeight ) override; bool supportsLegendGraphic() const override { return true; } QImage getLegendGraphic( double scale = 0, bool forceRefresh = false, const QgsRectangle * visibleExtent = 0 ) override; QgsImageFetcher* getLegendGraphicFetcher( const QgsMapSettings* mapSettings ) override; @@ -89,6 +88,8 @@ class QgsAmsProvider : public QgsRasterDataProvider protected: void readBlock( int bandNo, const QgsRectangle & viewExtent, int width, int height, void *data, QgsRasterBlockFeedback* feedback = nullptr ) override; + void draw( const QgsRectangle & viewExtent, int pixelWidth, int pixelHeight ); + private: bool mValid; QgsAmsLegendFetcher* mLegendFetcher; diff --git a/src/providers/gdal/qgsgdalprovider.cpp b/src/providers/gdal/qgsgdalprovider.cpp index 83fac352740..249ea878d92 100644 --- a/src/providers/gdal/qgsgdalprovider.cpp +++ b/src/providers/gdal/qgsgdalprovider.cpp @@ -373,20 +373,6 @@ QString QgsGdalProvider::metadata() } -// Not supported by GDAL -QImage* QgsGdalProvider::draw( QgsRectangle const & viewExtent, int pixelWidth, int pixelHeight ) -{ - Q_UNUSED( viewExtent ); - QgsDebugMsg( "pixelWidth = " + QString::number( pixelWidth ) ); - QgsDebugMsg( "pixelHeight = " + QString::number( pixelHeight ) ); - QgsDebugMsg( "viewExtent: " + viewExtent.toString() ); - - QImage *image = new QImage( pixelWidth, pixelHeight, QImage::Format_ARGB32 ); - image->fill( QColor( Qt::gray ).rgb() ); - - return image; -} - QgsRasterBlock* QgsGdalProvider::block( int theBandNo, const QgsRectangle &theExtent, int theWidth, int theHeight, QgsRasterBlockFeedback* feedback ) { QgsRasterBlock *block = new QgsRasterBlock( dataType( theBandNo ), theWidth, theHeight ); diff --git a/src/providers/gdal/qgsgdalprovider.h b/src/providers/gdal/qgsgdalprovider.h index c59a1c7a1cd..b1f58617c05 100644 --- a/src/providers/gdal/qgsgdalprovider.h +++ b/src/providers/gdal/qgsgdalprovider.h @@ -76,7 +76,6 @@ class QgsGdalProvider : public QgsRasterDataProvider, QgsGdalProviderBase QgsGdalProvider * clone() const override; - QImage* draw( QgsRectangle const & viewExtent, int pixelWidth, int pixelHeight ) override; QString name() const override; QString description() const override; virtual QgsCoordinateReferenceSystem crs() const override; diff --git a/src/providers/grass/qgsgrassrasterprovider.cpp b/src/providers/grass/qgsgrassrasterprovider.cpp index a83c3df7c3e..afead4c9a37 100644 --- a/src/providers/grass/qgsgrassrasterprovider.cpp +++ b/src/providers/grass/qgsgrassrasterprovider.cpp @@ -178,50 +178,6 @@ QgsRasterInterface * QgsGrassRasterProvider::clone() const return provider; } -QImage* QgsGrassRasterProvider::draw( QgsRectangle const & viewExtent, int pixelWidth, int pixelHeight ) -{ - QgsDebugMsg( "pixelWidth = " + QString::number( pixelWidth ) ); - QgsDebugMsg( "pixelHeight = " + QString::number( pixelHeight ) ); - QgsDebugMsg( "viewExtent: " + viewExtent.toString() ); - clearLastError(); - - QImage *image = new QImage( pixelWidth, pixelHeight, QImage::Format_ARGB32 ); - image->fill( QColor( Qt::gray ).rgb() ); - - QStringList arguments; - arguments.append( "map=" + mMapName + "@" + mMapset ); - - arguments.append(( QStringLiteral( "window=%1,%2,%3,%4,%5,%6" ) - .arg( QgsRasterBlock::printValue( viewExtent.xMinimum() ), - QgsRasterBlock::printValue( viewExtent.yMinimum() ), - QgsRasterBlock::printValue( viewExtent.xMaximum() ), - QgsRasterBlock::printValue( viewExtent.yMaximum() ) ) - .arg( pixelWidth ).arg( pixelHeight ) ) ); - QString cmd = QgsApplication::libexecPath() + "grass/modules/qgis.d.rast"; - QByteArray data; - try - { - data = QgsGrass::runModule( mGisdbase, mLocation, mMapset, cmd, arguments ); - } - catch ( QgsGrass::Exception &e ) - { - QString error = tr( "Cannot draw raster" ) + " : " + e.what(); - QgsDebugMsg( error ); - appendError( error ); - // We don't set mValid to false, because the raster can be recreated and work next time - return image; - } - QgsDebugMsg( QString( "%1 bytes read from modules stdout" ).arg( data.size() ) ); - uchar * ptr = image->bits(); - // byteCount() in Qt >= 4.6 - //int size = image->byteCount() < data.size() ? image->byteCount() : data.size(); - int size = pixelWidth * pixelHeight * 4 < data.size() ? pixelWidth * pixelHeight * 4 : data.size(); - memcpy( ptr, data.data(), size ); - - return image; -} - - void QgsGrassRasterProvider::readBlock( int bandNo, int xBlock, int yBlock, void *block ) { Q_UNUSED( xBlock ); diff --git a/src/providers/grass/qgsgrassrasterprovider.h b/src/providers/grass/qgsgrassrasterprovider.h index 146085bdaef..ee8b5a7f6df 100644 --- a/src/providers/grass/qgsgrassrasterprovider.h +++ b/src/providers/grass/qgsgrassrasterprovider.h @@ -106,10 +106,6 @@ class GRASS_LIB_EXPORT QgsGrassRasterProvider : public QgsRasterDataProvider QgsRasterInterface * clone() const override; - /** \brief Renders the layer as an image - */ - QImage* draw( QgsRectangle const & viewExtent, int pixelWidth, int pixelHeight ) override; - /** Return a provider name * * Essentially just returns the provider key. Should be used to build file diff --git a/src/providers/wcs/qgswcsprovider.cpp b/src/providers/wcs/qgswcsprovider.cpp index 749d1e6e341..a249ba1249e 100644 --- a/src/providers/wcs/qgswcsprovider.cpp +++ b/src/providers/wcs/qgswcsprovider.cpp @@ -1598,21 +1598,6 @@ QMap QgsWcsProvider::supportedMimes() return mimes; } -// Not supported by WCS -// TODO: remove from QgsRasterDataProvider? -QImage* QgsWcsProvider::draw( QgsRectangle const & viewExtent, int pixelWidth, int pixelHeight ) -{ - Q_UNUSED( viewExtent ); - QgsDebugMsg( "pixelWidth = " + QString::number( pixelWidth ) ); - QgsDebugMsg( "pixelHeight = " + QString::number( pixelHeight ) ); - QgsDebugMsg( "viewExtent: " + viewExtent.toString() ); - - QImage *image = new QImage( pixelWidth, pixelHeight, QImage::Format_ARGB32 ); - image->fill( QColor( Qt::gray ).rgb() ); - - return image; -} - QGISEXTERN QgsWcsProvider * classFactory( const QString *uri ) { return new QgsWcsProvider( *uri ); diff --git a/src/providers/wcs/qgswcsprovider.h b/src/providers/wcs/qgswcsprovider.h index 212f1f8cd01..35d455a2051 100644 --- a/src/providers/wcs/qgswcsprovider.h +++ b/src/providers/wcs/qgswcsprovider.h @@ -142,21 +142,6 @@ class QgsWcsProvider : public QgsRasterDataProvider, QgsGdalProviderBase // TODO: Document this better. - /** \brief Renders the layer as an image - * - * \return A QImage - if the attempt to retrieve data for the draw was unsuccessful, returns 0 - * and more information can be found in lastError() and lastErrorTitle() - * - * \todo Add pixel depth parameter (intended to match the display or printer device) - * - * \note Ownership of the returned QImage remains with this provider and its lifetime - * is guaranteed only until the next call to draw() or destruction of this provider. - * - * \warning A pointer to an QImage is used, as a plain QImage seems to have difficulty being - * shared across library boundaries - */ - QImage *draw( QgsRectangle const & viewExtent, int pixelWidth, int pixelHeight ) override; - void readBlock( int bandNo, QgsRectangle const & viewExtent, int width, int height, void *data, QgsRasterBlockFeedback* feedback = nullptr ) override; void readBlock( int theBandNo, int xBlock, int yBlock, void *block ) override; diff --git a/src/providers/wms/qgswmsprovider.cpp b/src/providers/wms/qgswmsprovider.cpp index 2a31d545009..3e6e19834d0 100644 --- a/src/providers/wms/qgswmsprovider.cpp +++ b/src/providers/wms/qgswmsprovider.cpp @@ -497,11 +497,6 @@ void QgsWmsProvider::setFormatQueryItem( QUrl &url ) setQueryItem( url, QStringLiteral( "FORMAT" ), mSettings.mImageMimeType ); } -QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, int pixelHeight ) -{ - return draw( viewExtent, pixelWidth, pixelHeight, nullptr ); -} - static bool _fuzzyContainsRect( const QRectF& r1, const QRectF& r2 ) { diff --git a/src/providers/wms/qgswmsprovider.h b/src/providers/wms/qgswmsprovider.h index 937c5670539..9e02686b448 100644 --- a/src/providers/wms/qgswmsprovider.h +++ b/src/providers/wms/qgswmsprovider.h @@ -145,8 +145,6 @@ class QgsWmsProvider : public QgsRasterDataProvider */ void setConnectionName( QString const & connName ); - QImage *draw( QgsRectangle const & viewExtent, int pixelWidth, int pixelHeight ) override; - void readBlock( int bandNo, QgsRectangle const & viewExtent, int width, int height, void *data, QgsRasterBlockFeedback* feedback = nullptr ) override; //void readBlock( int bandNo, QgsRectangle const & viewExtent, int width, int height, QgsCoordinateReferenceSystem theSrcCRS, QgsCoordinateReferenceSystem theDestCRS, void *data );