mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-08 00:05:09 -04:00
Add missing Q_OBJECT macros
This commit is contained in:
parent
cf24023fa6
commit
a9a77de725
@ -43,7 +43,6 @@ typedef Qt3DCore::QGeometry Qt3DQGeometry;
|
|||||||
|
|
||||||
#include "qgs3dmapsettings.h"
|
#include "qgs3dmapsettings.h"
|
||||||
#include "qgs3dutils.h"
|
#include "qgs3dutils.h"
|
||||||
#include "qgschunkloader.h"
|
|
||||||
#include "qgscoordinatereferencesystem.h"
|
#include "qgscoordinatereferencesystem.h"
|
||||||
#include "qgscoordinatetransform.h"
|
#include "qgscoordinatetransform.h"
|
||||||
#include "qgsdistancearea.h"
|
#include "qgsdistancearea.h"
|
||||||
@ -270,14 +269,11 @@ static QgsBox3D globeNodeIdToBox3D( QgsChunkNodeId n, const QgsCoordinateTransfo
|
|||||||
// ---------------
|
// ---------------
|
||||||
|
|
||||||
|
|
||||||
class QgsGlobeChunkLoader : public QgsChunkLoader
|
QgsGlobeChunkLoader::QgsGlobeChunkLoader( QgsChunkNode *node, QgsTerrainTextureGenerator *textureGenerator, const QgsCoordinateTransform &globeCrsToLatLon )
|
||||||
{
|
|
||||||
public:
|
|
||||||
QgsGlobeChunkLoader( QgsChunkNode *node, QgsTerrainTextureGenerator *textureGenerator, const QgsCoordinateTransform &globeCrsToLatLon )
|
|
||||||
: QgsChunkLoader( node )
|
: QgsChunkLoader( node )
|
||||||
, mTextureGenerator( textureGenerator )
|
, mTextureGenerator( textureGenerator )
|
||||||
, mGlobeCrsToLatLon( globeCrsToLatLon )
|
, mGlobeCrsToLatLon( globeCrsToLatLon )
|
||||||
{
|
{
|
||||||
connect( mTextureGenerator, &QgsTerrainTextureGenerator::tileReady, this, [this]( int job, const QImage &img ) {
|
connect( mTextureGenerator, &QgsTerrainTextureGenerator::tileReady, this, [this]( int job, const QImage &img ) {
|
||||||
if ( job == mJobId )
|
if ( job == mJobId )
|
||||||
{
|
{
|
||||||
@ -290,10 +286,10 @@ class QgsGlobeChunkLoader : public QgsChunkLoader
|
|||||||
globeNodeIdToLatLon( node->tileId(), latMin, latMax, lonMin, lonMax );
|
globeNodeIdToLatLon( node->tileId(), latMin, latMax, lonMin, lonMax );
|
||||||
QgsRectangle extent( lonMin, latMin, lonMax, latMax );
|
QgsRectangle extent( lonMin, latMin, lonMax, latMax );
|
||||||
mJobId = mTextureGenerator->render( extent, node->tileId(), node->tileId().text() );
|
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 ) )
|
if ( mNode->tileId() == QgsChunkNodeId( 0, 0, 0, 0 ) )
|
||||||
{
|
{
|
||||||
return new Qt3DCore::QEntity( parent );
|
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() );
|
Qt3DCore::QEntity *e = makeGlobeMesh( lonMin, lonMax, latMin, latMax, slices, slices, mGlobeCrsToLatLon, mTexture, mNode->tileId().text() );
|
||||||
e->setParent( parent );
|
e->setParent( parent );
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
QgsTerrainTextureGenerator *mTextureGenerator;
|
|
||||||
QgsCoordinateTransform mGlobeCrsToLatLon;
|
|
||||||
int mJobId;
|
|
||||||
QImage mTexture;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// ---------------
|
// ---------------
|
||||||
|
|
||||||
|
|
||||||
class QgsGlobeChunkLoaderFactory : public QgsChunkLoaderFactory
|
QgsGlobeChunkLoaderFactory::QgsGlobeChunkLoaderFactory( Qgs3DMapSettings *mapSettings )
|
||||||
{
|
|
||||||
public:
|
|
||||||
QgsGlobeChunkLoaderFactory( Qgs3DMapSettings *mapSettings )
|
|
||||||
: mMapSettings( mapSettings )
|
: mMapSettings( mapSettings )
|
||||||
{
|
{
|
||||||
mTextureGenerator = new QgsTerrainTextureGenerator( *mapSettings );
|
mTextureGenerator = new QgsTerrainTextureGenerator( *mapSettings );
|
||||||
|
|
||||||
// it does not matter what kind of ellipsoid is used, this is for rough estimates
|
// 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();
|
mRadiusX = mGlobeCrsToLatLon.transform( QgsVector3D( 0, 0, 0 ), Qgis::TransformDirection::Reverse ).x();
|
||||||
mRadiusY = mGlobeCrsToLatLon.transform( QgsVector3D( 90, 0, 0 ), Qgis::TransformDirection::Reverse ).y();
|
mRadiusY = mGlobeCrsToLatLon.transform( QgsVector3D( 90, 0, 0 ), Qgis::TransformDirection::Reverse ).y();
|
||||||
mRadiusZ = mGlobeCrsToLatLon.transform( QgsVector3D( 0, 90, 0 ), Qgis::TransformDirection::Reverse ).z();
|
mRadiusZ = mGlobeCrsToLatLon.transform( QgsVector3D( 0, 90, 0 ), Qgis::TransformDirection::Reverse ).z();
|
||||||
}
|
}
|
||||||
|
|
||||||
~QgsGlobeChunkLoaderFactory()
|
QgsGlobeChunkLoaderFactory::~QgsGlobeChunkLoaderFactory()
|
||||||
{
|
{
|
||||||
delete mTextureGenerator;
|
delete mTextureGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsChunkLoader *createChunkLoader( QgsChunkNode *node ) const override
|
QgsChunkLoader *QgsGlobeChunkLoaderFactory::createChunkLoader( QgsChunkNode *node ) const
|
||||||
{
|
{
|
||||||
return new QgsGlobeChunkLoader( node, mTextureGenerator, mGlobeCrsToLatLon );
|
return new QgsGlobeChunkLoader( node, mTextureGenerator, mGlobeCrsToLatLon );
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsChunkNode *createRootNode() const override
|
QgsChunkNode *QgsGlobeChunkLoaderFactory::createRootNode() const
|
||||||
{
|
{
|
||||||
QgsBox3D rootNodeBox3D( -mRadiusX, -mRadiusY, -mRadiusZ, +mRadiusX, +mRadiusY, +mRadiusZ );
|
QgsBox3D rootNodeBox3D( -mRadiusX, -mRadiusY, -mRadiusZ, +mRadiusX, +mRadiusY, +mRadiusZ );
|
||||||
// use very high error to force immediate switch to level 1 (two hemispheres)
|
// 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 );
|
QgsChunkNode *node = new QgsChunkNode( QgsChunkNodeId( 0, 0, 0, 0 ), rootNodeBox3D, 999'999 );
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<QgsChunkNode *> createChildren( QgsChunkNode *node ) const override
|
QVector<QgsChunkNode *> QgsGlobeChunkLoaderFactory::createChildren( QgsChunkNode *node ) const
|
||||||
{
|
{
|
||||||
QVector<QgsChunkNode *> children;
|
QVector<QgsChunkNode *> children;
|
||||||
if ( node->tileId().d == 0 )
|
if ( node->tileId().d == 0 )
|
||||||
{
|
{
|
||||||
@ -406,28 +392,15 @@ class QgsGlobeChunkLoaderFactory : public QgsChunkLoaderFactory
|
|||||||
}
|
}
|
||||||
|
|
||||||
return children;
|
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
|
QgsGlobeMapUpdateJob::QgsGlobeMapUpdateJob( QgsTerrainTextureGenerator *textureGenerator, QgsChunkNode *node )
|
||||||
class QgsGlobeMapUpdateJob : public QgsChunkQueueJob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
QgsGlobeMapUpdateJob( QgsTerrainTextureGenerator *textureGenerator, QgsChunkNode *node )
|
|
||||||
: QgsChunkQueueJob( node )
|
: QgsChunkQueueJob( node )
|
||||||
, mTextureGenerator( textureGenerator )
|
, mTextureGenerator( textureGenerator )
|
||||||
{
|
{
|
||||||
// extract our terrain texture image from the 3D entity
|
// extract our terrain texture image from the 3D entity
|
||||||
QVector<QgsGlobeMaterial *> materials = node->entity()->componentsOfType<QgsGlobeMaterial>();
|
QVector<QgsGlobeMaterial *> materials = node->entity()->componentsOfType<QgsGlobeMaterial>();
|
||||||
Q_ASSERT( materials.count() == 1 );
|
Q_ASSERT( materials.count() == 1 );
|
||||||
@ -445,18 +418,13 @@ class QgsGlobeMapUpdateJob : public QgsChunkQueueJob
|
|||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
mJobId = textureGenerator->render( terrainTexImage->imageExtent(), node->tileId(), terrainTexImage->imageDebugText() );
|
mJobId = textureGenerator->render( terrainTexImage->imageExtent(), node->tileId(), terrainTexImage->imageDebugText() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void cancel() override
|
void QgsGlobeMapUpdateJob::cancel()
|
||||||
{
|
{
|
||||||
if ( mJobId != -1 )
|
if ( mJobId != -1 )
|
||||||
mTextureGenerator->cancelJob( mJobId );
|
mTextureGenerator->cancelJob( mJobId );
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
QgsTerrainTextureGenerator *mTextureGenerator = nullptr;
|
|
||||||
int mJobId;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// ---------------
|
// ---------------
|
||||||
|
@ -34,9 +34,66 @@
|
|||||||
|
|
||||||
#include "qgschunkedentity.h"
|
#include "qgschunkedentity.h"
|
||||||
|
|
||||||
|
#include "qgschunkloader.h"
|
||||||
|
#include "qgscoordinatetransform.h"
|
||||||
|
#include "qgsdistancearea.h"
|
||||||
|
#include <QImage>
|
||||||
|
|
||||||
class QgsMapLayer;
|
class QgsMapLayer;
|
||||||
class QgsGlobeMapUpdateJobFactory;
|
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
|
* 3D chunked entity implementation to generate globe mesh with constant elevation
|
||||||
|
Loading…
x
Reference in New Issue
Block a user