18#include <Qt3DRender/QTextureImageDataGenerator>
24class TerrainTextureImageDataGenerator :
public Qt3DRender::QTextureImageDataGenerator
28 static QImage placeholderImage()
31 QImage i( 2, 2, QImage::Format_RGB32 );
32 i.setPixelColor( 0, 0, Qt::darkGray );
33 i.setPixelColor( 1, 0, Qt::lightGray );
34 i.setPixelColor( 0, 1, Qt::lightGray );
35 i.setPixelColor( 1, 1, Qt::darkGray );
39 TerrainTextureImageDataGenerator(
const QgsRectangle &extent,
const QString &debugText,
const QImage &img,
int version )
40 : mExtent( extent ), mDebugText( debugText ), mImage( img ), mVersion( version ) {}
42 Qt3DRender::QTextureImageDataPtr operator()()
override
44 Qt3DRender::QTextureImageDataPtr dataPtr = Qt3DRender::QTextureImageDataPtr::create();
45 dataPtr->setImage( mImage.isNull() ? placeholderImage() : mImage );
49 bool operator ==(
const QTextureImageDataGenerator &other )
const override
51 const TerrainTextureImageDataGenerator *otherFunctor = functor_cast<TerrainTextureImageDataGenerator>( &other );
52 return otherFunctor !=
nullptr && otherFunctor->mVersion == mVersion &&
53 mExtent == otherFunctor->mExtent;
58 QT3D_FUNCTOR( TerrainTextureImageDataGenerator )
73QgsTerrainTextureImage::QgsTerrainTextureImage(
const QImage &image,
const QgsRectangle &extent,
const QString &debugText, Qt3DCore::QNode *parent )
76 , mDebugText( debugText )
81Qt3DRender::QTextureImageDataGeneratorPtr QgsTerrainTextureImage::dataGenerator()
const
83 return Qt3DRender::QTextureImageDataGeneratorPtr(
new TerrainTextureImageDataGenerator( mExtent, mDebugText, mImage, mVersion ) );
86void QgsTerrainTextureImage::invalidate()
90 notifyDataGeneratorChanged();
93void QgsTerrainTextureImage::setImage(
const QImage &img )
97 notifyDataGeneratorChanged();
A rectangle specified with double values.
#define Q_NOWARN_DEPRECATED_POP
#define Q_NOWARN_DEPRECATED_PUSH
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)