18 #include <Qt3DRender/QTextureImageDataGenerator>
24 class 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;
56 QT3D_FUNCTOR( TerrainTextureImageDataGenerator )
70 QgsTerrainTextureImage::QgsTerrainTextureImage(
const QImage &image,
const QgsRectangle &extent,
const QString &debugText, Qt3DCore::QNode *parent )
73 , mDebugText( debugText )
78 Qt3DRender::QTextureImageDataGeneratorPtr QgsTerrainTextureImage::dataGenerator()
const
80 return Qt3DRender::QTextureImageDataGeneratorPtr(
new TerrainTextureImageDataGenerator( mExtent, mDebugText, mImage, mVersion ) );
83 void QgsTerrainTextureImage::invalidate()
87 notifyDataGeneratorChanged();
90 void QgsTerrainTextureImage::setImage(
const QImage &img )
94 notifyDataGeneratorChanged();
A rectangle specified with double values.
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)