34 #include <QtConcurrent>
39 QgsVectorLayerChunkLoader::QgsVectorLayerChunkLoader(
const QgsVectorLayerChunkLoaderFactory *factory, QgsChunkNode *node )
40 : QgsChunkLoader( node )
42 , mContext( factory->mMap )
45 if ( node->level() < mFactory->mLeafLevel )
47 QTimer::singleShot( 0,
this, &QgsVectorLayerChunkLoader::finished );
57 QgsDebugMsg( QStringLiteral(
"Unknown 3D symbol type for vector layer: " ) + mFactory->mSymbol->type() );
60 mHandler.reset( handler );
64 mContext.setExpressionContext( exprContext );
66 QSet<QString> attributeNames;
67 if ( !mHandler->prepare( mContext, attributeNames ) )
69 QgsDebugMsg( QStringLiteral(
"Failed to prepare 3D feature handler!" ) );
86 QFuture<void> future = QtConcurrent::run( [req,
this]
88 QgsEventTracing::ScopedEvent e( QStringLiteral(
"3D" ), QStringLiteral(
"VL chunk load" ) );
96 mContext.expressionContext().setFeature( f );
97 mHandler->processFeature( f, mContext );
102 mFutureWatcher =
new QFutureWatcher<void>(
this );
103 mFutureWatcher->setFuture( future );
104 connect( mFutureWatcher, &QFutureWatcher<void>::finished,
this, &QgsChunkQueueJob::finished );
107 QgsVectorLayerChunkLoader::~QgsVectorLayerChunkLoader()
109 if ( mFutureWatcher && !mFutureWatcher->isFinished() )
111 disconnect( mFutureWatcher, &QFutureWatcher<void>::finished,
this, &QgsChunkQueueJob::finished );
112 mFutureWatcher->waitForFinished();
116 void QgsVectorLayerChunkLoader::cancel()
121 Qt3DCore::QEntity *QgsVectorLayerChunkLoader::createEntity( Qt3DCore::QEntity *parent )
123 if ( mNode->level() < mFactory->mLeafLevel )
125 return new Qt3DCore::QEntity( parent );
128 Qt3DCore::QEntity *entity =
new Qt3DCore::QEntity( parent );
129 mHandler->finalize( entity, mContext );
140 , mSymbol( symbol->clone() )
141 , mLeafLevel( leafLevel )
145 QgsChunkLoader *QgsVectorLayerChunkLoaderFactory::createChunkLoader( QgsChunkNode *node )
const
147 return new QgsVectorLayerChunkLoader(
this, node );
155 : QgsChunkedEntity(
Qgs3DUtils::layerToWorldExtent( vl->extent(), zMin, zMax, vl->
crs(), map.origin(), map.
crs(), map.transformContext() ),
158 tilingSettings.zoomLevelsCount() - 1,
159 new QgsVectorLayerChunkLoaderFactory( map, vl, symbol, tilingSettings.zoomLevelsCount() - 1 ), true )
164 QgsVectorLayerChunkedEntity::~QgsVectorLayerChunkedEntity()