QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
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(
60 Qgs3DMapSettings *mapSettings, float tau, QgsChunkLoaderFactory *loaderFactory, bool ownsFactory, int primitivesBudget = std::numeric_limits<int>::max(), Qt3DCore::QNode *parent = nullptr
61 );
62 ~QgsChunkedEntity() override;
63
65 void handleSceneUpdate( const SceneContext &sceneContext ) override;
66
68 int pendingJobsCount() const override;
69
71 bool needsUpdate() const override { return mNeedsUpdate; }
72
73 QgsRange<float> getNearFarPlaneRange( const QMatrix4x4 &viewMatrix ) const override;
74
76 void setShowBoundingBoxes( bool enabled );
77
79 void updateNodes( const QList<QgsChunkNode *> &nodes, QgsChunkQueueJobFactory *updateJobFactory );
80
82 QList<QgsChunkNode *> activeNodes() const { return mActiveNodes; }
84 QgsChunkNode *rootNode() const { return mRootNode; }
85
95 virtual QList<QgsRayCastHit> rayIntersection( const QgsRay3D &ray, const QgsRayCastContext &context ) const;
96
97 protected:
99 void cancelActiveJob( QgsChunkQueueJob *job );
100 void cancelActiveJobs();
102 void setNeedsUpdate( bool needsUpdate ) { mNeedsUpdate = needsUpdate; }
103
104 private:
105 void update( QgsChunkNode *node, const SceneContext &sceneContext );
106
108 void pruneLoaderQueue( const SceneContext &sceneContext );
109
111 void requestResidency( QgsChunkNode *node );
112
113 void startJobs();
114 QgsChunkQueueJob *startJob( QgsChunkNode *node );
115
116 int unloadNodes();
117
118 private slots:
119 void onActiveJobFinished();
120
121 protected:
123 QgsChunkNode *mRootNode = nullptr;
125 bool mNeedsUpdate = false;
126
134 float mTau;
136 QgsChunkLoaderFactory *mChunkLoaderFactory = nullptr;
138 bool mOwnsFactory = true;
140 QgsChunkList *mChunkLoaderQueue = nullptr;
142 QgsChunkList *mReplacementQueue = nullptr;
144 QList<QgsChunkNode *> mActiveNodes;
146 int mFrustumCulled = 0;
147
148 // TODO: max. length for loading queue
149
150 QTime mCurrentTime;
151
153 QgsChunkBoundsEntity *mBboxesEntity = nullptr;
154
156 QList<QgsChunkQueueJob *> mActiveJobs;
157
158 bool mIsValid = true;
159
160 int mPrimitivesBudget = std::numeric_limits<int>::max();
161};
162
164
165#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.