QGIS API Documentation 3.99.0-Master (a8f284845db)
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 "qgs3dmapsceneentity.h"
31#include "qgsraycasthit.h"
32
33#include <QMatrix4x4>
34#include <QTime>
35
36#define SIP_NO_FILE
37
38class QgsAABB;
39class QgsChunkNode;
40class QgsChunkList;
41class QgsChunkQueueJob;
42class QgsChunkLoaderFactory;
43class QgsChunkBoundsEntity;
44class QgsChunkQueueJobFactory;
45class QgsRay3D;
47
48
54class QgsChunkedEntity : public Qgs3DMapSceneEntity
55{
56 Q_OBJECT
57 public:
59 QgsChunkedEntity( Qgs3DMapSettings *mapSettings, float tau, QgsChunkLoaderFactory *loaderFactory, bool ownsFactory, int primitivesBudget = std::numeric_limits<int>::max(), Qt3DCore::QNode *parent = nullptr );
60 ~QgsChunkedEntity() override;
61
63 void handleSceneUpdate( const SceneContext &sceneContext ) override;
64
66 int pendingJobsCount() const override;
67
69 bool needsUpdate() const override { return mNeedsUpdate; }
70
71 QgsRange<float> getNearFarPlaneRange( const QMatrix4x4 &viewMatrix ) const override;
72
74 void setShowBoundingBoxes( bool enabled );
75
77 void updateNodes( const QList<QgsChunkNode *> &nodes, QgsChunkQueueJobFactory *updateJobFactory );
78
80 QList<QgsChunkNode *> activeNodes() const { return mActiveNodes; }
82 QgsChunkNode *rootNode() const { return mRootNode; }
83
93 virtual QList<QgsRayCastHit> rayIntersection( const QgsRay3D &ray, const QgsRayCastContext &context ) const;
94
95 protected:
97 void cancelActiveJob( QgsChunkQueueJob *job );
98 void cancelActiveJobs();
100 void setNeedsUpdate( bool needsUpdate ) { mNeedsUpdate = needsUpdate; }
101
102 private:
103 void update( QgsChunkNode *node, const SceneContext &sceneContext );
104
106 void pruneLoaderQueue( const SceneContext &sceneContext );
107
109 void requestResidency( QgsChunkNode *node );
110
111 void startJobs();
112 QgsChunkQueueJob *startJob( QgsChunkNode *node );
113
114 int unloadNodes();
115
116 private slots:
117 void onActiveJobFinished();
118
119 protected:
121 QgsChunkNode *mRootNode = nullptr;
123 bool mNeedsUpdate = false;
124
132 float mTau;
134 QgsChunkLoaderFactory *mChunkLoaderFactory = nullptr;
136 bool mOwnsFactory = true;
138 QgsChunkList *mChunkLoaderQueue = nullptr;
140 QgsChunkList *mReplacementQueue = nullptr;
142 QList<QgsChunkNode *> mActiveNodes;
144 int mFrustumCulled = 0;
145
146 // TODO: max. length for loading queue
147
148 QTime mCurrentTime;
149
151 QgsChunkBoundsEntity *mBboxesEntity = nullptr;
152
154 QList<QgsChunkQueueJob *> mActiveJobs;
155
156 bool mIsValid = true;
157
158 int mPrimitivesBudget = std::numeric_limits<int>::max();
159};
160
162
163#endif // QGSCHUNKEDENTITY_H
Axis-aligned bounding box - in world coords.
Definition qgsaabb.h:33
A representation of a ray in 3D.
Definition qgsray3d.h:31
Responsible for defining parameters of the ray casting operations in 3D map canvases.