QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgschunkedentity.h
Go to the documentation of this file.
1/***************************************************************************
2 qgschunkedentity.h
3 --------------------------------------
4 Date : July 2017
5 Copyright : (C) 2017 by Martin Dobias
6 Email : wonder dot sk at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSCHUNKEDENTITY_H
17#define QGSCHUNKEDENTITY_H
18
20
21//
22// W A R N I N G
23// -------------
24//
25// This file is not part of the QGIS API. It exists purely as an
26// implementation detail. This header file may change from version to
27// version without notice, or even be removed.
28//
29
30#include <numeric>
31
32#include "qgs3dmapsceneentity.h"
33
34#define SIP_NO_FILE
35
36class QgsAABB;
37class QgsChunkNode;
38class QgsChunkList;
39class QgsChunkQueueJob;
40class QgsChunkLoaderFactory;
41class QgsChunkBoundsEntity;
42class QgsChunkQueueJobFactory;
43class QgsRay3D;
45
46
47#include <QVector3D>
48#include <QMatrix4x4>
49
50#include <QTime>
51
52#include "qgschunknode.h"
53#include "qgsraycasthit.h"
54
55
61class QgsChunkedEntity : public Qgs3DMapSceneEntity
62{
63 Q_OBJECT
64 public:
66 QgsChunkedEntity( Qgs3DMapSettings *mapSettings, float tau, QgsChunkLoaderFactory *loaderFactory, bool ownsFactory, int primitivesBudget = std::numeric_limits<int>::max(), Qt3DCore::QNode *parent = nullptr );
67 ~QgsChunkedEntity() override;
68
70 void handleSceneUpdate( const SceneContext &sceneContext ) override;
71
73 int pendingJobsCount() const override;
74
76 bool needsUpdate() const override { return mNeedsUpdate; }
77
78 QgsRange<float> getNearFarPlaneRange( const QMatrix4x4 &viewMatrix ) const override;
79
81 void setShowBoundingBoxes( bool enabled );
82
84 void updateNodes( const QList<QgsChunkNode *> &nodes, QgsChunkQueueJobFactory *updateJobFactory );
85
87 QList<QgsChunkNode *> activeNodes() const { return mActiveNodes; }
89 QgsChunkNode *rootNode() const { return mRootNode; }
90
100 virtual QList<QgsRayCastHit> rayIntersection( const QgsRay3D &ray, const QgsRayCastContext &context ) const;
101
102 protected:
104 void cancelActiveJob( QgsChunkQueueJob *job );
105 void cancelActiveJobs();
107 void setNeedsUpdate( bool needsUpdate ) { mNeedsUpdate = needsUpdate; }
108
109 private:
110 void update( QgsChunkNode *node, const SceneContext &sceneContext );
111
113 void pruneLoaderQueue( const SceneContext &sceneContext );
114
116 void requestResidency( QgsChunkNode *node );
117
118 void startJobs();
119 QgsChunkQueueJob *startJob( QgsChunkNode *node );
120
121 int unloadNodes();
122
123 private slots:
124 void onActiveJobFinished();
125
126 protected:
128 QgsChunkNode *mRootNode = nullptr;
130 bool mNeedsUpdate = false;
131
139 float mTau;
141 QgsChunkLoaderFactory *mChunkLoaderFactory = nullptr;
143 bool mOwnsFactory = true;
145 QgsChunkList *mChunkLoaderQueue = nullptr;
147 QgsChunkList *mReplacementQueue = nullptr;
149 QList<QgsChunkNode *> mActiveNodes;
151 int mFrustumCulled = 0;
152
153 // TODO: max. length for loading queue
154
155 QTime mCurrentTime;
156
158 QgsChunkBoundsEntity *mBboxesEntity = nullptr;
159
161 QList<QgsChunkQueueJob *> mActiveJobs;
162
163 bool mIsValid = true;
164
165 int mPrimitivesBudget = std::numeric_limits<int>::max();
166};
167
169
170#endif // QGSCHUNKEDENTITY_H
Axis-aligned bounding box - in world coords.
Definition qgsaabb.h:35
A representation of a ray in 3D.
Definition qgsray3d.h:31
Responsible for defining parameters of the ray casting operations in 3D map canvases.