Add missing Q_OBJECT macros

This commit is contained in:
Nyall Dawson 2025-08-12 15:10:00 +10:00
parent cf24023fa6
commit a9a77de725
2 changed files with 178 additions and 153 deletions

View File

@ -43,7 +43,6 @@ typedef Qt3DCore::QGeometry Qt3DQGeometry;
#include "qgs3dmapsettings.h"
#include "qgs3dutils.h"
#include "qgschunkloader.h"
#include "qgscoordinatereferencesystem.h"
#include "qgscoordinatetransform.h"
#include "qgsdistancearea.h"
@ -270,14 +269,11 @@ static QgsBox3D globeNodeIdToBox3D( QgsChunkNodeId n, const QgsCoordinateTransfo
// ---------------
class QgsGlobeChunkLoader : public QgsChunkLoader
{
public:
QgsGlobeChunkLoader( QgsChunkNode *node, QgsTerrainTextureGenerator *textureGenerator, const QgsCoordinateTransform &globeCrsToLatLon )
QgsGlobeChunkLoader::QgsGlobeChunkLoader( QgsChunkNode *node, QgsTerrainTextureGenerator *textureGenerator, const QgsCoordinateTransform &globeCrsToLatLon )
: QgsChunkLoader( node )
, mTextureGenerator( textureGenerator )
, mGlobeCrsToLatLon( globeCrsToLatLon )
{
{
connect( mTextureGenerator, &QgsTerrainTextureGenerator::tileReady, this, [this]( int job, const QImage &img ) {
if ( job == mJobId )
{
@ -290,10 +286,10 @@ class QgsGlobeChunkLoader : public QgsChunkLoader
globeNodeIdToLatLon( node->tileId(), latMin, latMax, lonMin, lonMax );
QgsRectangle extent( lonMin, latMin, lonMax, latMax );
mJobId = mTextureGenerator->render( extent, node->tileId(), node->tileId().text() );
}
}
Qt3DCore::QEntity *createEntity( Qt3DCore::QEntity *parent ) override
{
Qt3DCore::QEntity *QgsGlobeChunkLoader::createEntity( Qt3DCore::QEntity *parent )
{
if ( mNode->tileId() == QgsChunkNodeId( 0, 0, 0, 0 ) )
{
return new Qt3DCore::QEntity( parent );
@ -318,25 +314,15 @@ class QgsGlobeChunkLoader : public QgsChunkLoader
Qt3DCore::QEntity *e = makeGlobeMesh( lonMin, lonMax, latMin, latMax, slices, slices, mGlobeCrsToLatLon, mTexture, mNode->tileId().text() );
e->setParent( parent );
return e;
}
private:
QgsTerrainTextureGenerator *mTextureGenerator;
QgsCoordinateTransform mGlobeCrsToLatLon;
int mJobId;
QImage mTexture;
};
}
// ---------------
class QgsGlobeChunkLoaderFactory : public QgsChunkLoaderFactory
{
public:
QgsGlobeChunkLoaderFactory( Qgs3DMapSettings *mapSettings )
QgsGlobeChunkLoaderFactory::QgsGlobeChunkLoaderFactory( Qgs3DMapSettings *mapSettings )
: mMapSettings( mapSettings )
{
{
mTextureGenerator = new QgsTerrainTextureGenerator( *mapSettings );
// it does not matter what kind of ellipsoid is used, this is for rough estimates
@ -347,28 +333,28 @@ class QgsGlobeChunkLoaderFactory : public QgsChunkLoaderFactory
mRadiusX = mGlobeCrsToLatLon.transform( QgsVector3D( 0, 0, 0 ), Qgis::TransformDirection::Reverse ).x();
mRadiusY = mGlobeCrsToLatLon.transform( QgsVector3D( 90, 0, 0 ), Qgis::TransformDirection::Reverse ).y();
mRadiusZ = mGlobeCrsToLatLon.transform( QgsVector3D( 0, 90, 0 ), Qgis::TransformDirection::Reverse ).z();
}
}
~QgsGlobeChunkLoaderFactory()
{
QgsGlobeChunkLoaderFactory::~QgsGlobeChunkLoaderFactory()
{
delete mTextureGenerator;
}
}
QgsChunkLoader *createChunkLoader( QgsChunkNode *node ) const override
{
QgsChunkLoader *QgsGlobeChunkLoaderFactory::createChunkLoader( QgsChunkNode *node ) const
{
return new QgsGlobeChunkLoader( node, mTextureGenerator, mGlobeCrsToLatLon );
}
}
QgsChunkNode *createRootNode() const override
{
QgsChunkNode *QgsGlobeChunkLoaderFactory::createRootNode() const
{
QgsBox3D rootNodeBox3D( -mRadiusX, -mRadiusY, -mRadiusZ, +mRadiusX, +mRadiusY, +mRadiusZ );
// use very high error to force immediate switch to level 1 (two hemispheres)
QgsChunkNode *node = new QgsChunkNode( QgsChunkNodeId( 0, 0, 0, 0 ), rootNodeBox3D, 999'999 );
return node;
}
}
QVector<QgsChunkNode *> createChildren( QgsChunkNode *node ) const override
{
QVector<QgsChunkNode *> QgsGlobeChunkLoaderFactory::createChildren( QgsChunkNode *node ) const
{
QVector<QgsChunkNode *> children;
if ( node->tileId().d == 0 )
{
@ -406,28 +392,15 @@ class QgsGlobeChunkLoaderFactory : public QgsChunkLoaderFactory
}
return children;
}
private:
Qgs3DMapSettings *mMapSettings = nullptr;
QgsTerrainTextureGenerator *mTextureGenerator = nullptr; // owned by the factory
QgsDistanceArea mDistanceArea;
QgsCoordinateTransform mGlobeCrsToLatLon;
double mRadiusX, mRadiusY, mRadiusZ;
};
}
// ---------------
//! Handles asynchronous updates of globe's map images when layers change
class QgsGlobeMapUpdateJob : public QgsChunkQueueJob
{
public:
QgsGlobeMapUpdateJob( QgsTerrainTextureGenerator *textureGenerator, QgsChunkNode *node )
QgsGlobeMapUpdateJob::QgsGlobeMapUpdateJob( QgsTerrainTextureGenerator *textureGenerator, QgsChunkNode *node )
: QgsChunkQueueJob( node )
, mTextureGenerator( textureGenerator )
{
{
// extract our terrain texture image from the 3D entity
QVector<QgsGlobeMaterial *> materials = node->entity()->componentsOfType<QgsGlobeMaterial>();
Q_ASSERT( materials.count() == 1 );
@ -445,18 +418,13 @@ class QgsGlobeMapUpdateJob : public QgsChunkQueueJob
}
} );
mJobId = textureGenerator->render( terrainTexImage->imageExtent(), node->tileId(), terrainTexImage->imageDebugText() );
}
}
void cancel() override
{
void QgsGlobeMapUpdateJob::cancel()
{
if ( mJobId != -1 )
mTextureGenerator->cancelJob( mJobId );
}
private:
QgsTerrainTextureGenerator *mTextureGenerator = nullptr;
int mJobId;
};
}
// ---------------

View File

@ -34,9 +34,66 @@
#include "qgschunkedentity.h"
#include "qgschunkloader.h"
#include "qgscoordinatetransform.h"
#include "qgsdistancearea.h"
#include <QImage>
class QgsMapLayer;
class QgsGlobeMapUpdateJobFactory;
class QgsTerrainTextureGenerator;
class QgsGlobeChunkLoader : public QgsChunkLoader
{
Q_OBJECT
public:
QgsGlobeChunkLoader( QgsChunkNode *node, QgsTerrainTextureGenerator *textureGenerator, const QgsCoordinateTransform &globeCrsToLatLon );
Qt3DCore::QEntity *createEntity( Qt3DCore::QEntity *parent ) override;
private:
QgsTerrainTextureGenerator *mTextureGenerator;
QgsCoordinateTransform mGlobeCrsToLatLon;
int mJobId;
QImage mTexture;
};
//! Handles asynchronous updates of globe's map images when layers change
class QgsGlobeMapUpdateJob : public QgsChunkQueueJob
{
Q_OBJECT
public:
QgsGlobeMapUpdateJob( QgsTerrainTextureGenerator *textureGenerator, QgsChunkNode *node );
void cancel() override;
private:
QgsTerrainTextureGenerator *mTextureGenerator = nullptr;
int mJobId;
};
class QgsGlobeChunkLoaderFactory : public QgsChunkLoaderFactory
{
Q_OBJECT
public:
QgsGlobeChunkLoaderFactory( Qgs3DMapSettings *mapSettings );
~QgsGlobeChunkLoaderFactory();
QgsChunkLoader *createChunkLoader( QgsChunkNode *node ) const override;
QgsChunkNode *createRootNode() const override;
QVector<QgsChunkNode *> createChildren( QgsChunkNode *node ) const override;
private:
Qgs3DMapSettings *mMapSettings = nullptr;
QgsTerrainTextureGenerator *mTextureGenerator = nullptr; // owned by the factory
QgsDistanceArea mDistanceArea;
QgsCoordinateTransform mGlobeCrsToLatLon;
double mRadiusX, mRadiusY, mRadiusZ;
};
/**
* 3D chunked entity implementation to generate globe mesh with constant elevation