QGIS API Documentation  3.2.0-Bonn (bc43194)
qgschunkedentity_p.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgschunkedentity_p.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_P_H
17 #define QGSCHUNKEDENTITY_P_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 <Qt3DCore/QEntity>
31 
32 class QgsAABB;
33 class QgsChunkNode;
34 class QgsChunkList;
35 class QgsChunkQueueJob;
36 class QgsChunkLoaderFactory;
37 class QgsChunkBoundsEntity;
38 class QgsChunkQueueJobFactory;
39 
40 #include <QVector3D>
41 #include <QMatrix4x4>
42 
43 #include <QTime>
44 
51 class QgsChunkedEntity : public Qt3DCore::QEntity
52 {
53  Q_OBJECT
54  public:
56  QgsChunkedEntity( const QgsAABB &rootBbox, float rootError, float mTau, int mMaxLevel, QgsChunkLoaderFactory *loaderFactory, Qt3DCore::QNode *parent = nullptr );
57  ~QgsChunkedEntity() override;
58 
60  struct SceneState
61  {
62  QVector3D cameraPos;
63  float cameraFov;
64  int screenSizePx;
65  QMatrix4x4 viewProjectionMatrix;
66  };
67 
69  void update( const SceneState &state );
70 
72  bool needsUpdate() const { return mNeedsUpdate; }
73 
75  void setShowBoundingBoxes( bool enabled );
76 
78  void updateNodes( const QList<QgsChunkNode *> &nodes, QgsChunkQueueJobFactory *updateJobFactory );
79 
81  QList<QgsChunkNode *> activeNodes() const { return mActiveNodes; }
83  QgsChunkNode *rootNode() const { return mRootNode; }
84 
86  int pendingJobsCount() const;
87 
88  protected:
90  void cancelActiveJob();
92  void setNeedsUpdate( bool needsUpdate ) { mNeedsUpdate = needsUpdate; }
93 
94  private:
95  void update( QgsChunkNode *node, const SceneState &state );
96 
98  void requestResidency( QgsChunkNode *node );
99 
100  void startJob();
101 
102  private slots:
103  void onActiveJobFinished();
104 
105  signals:
107  void pendingJobsCountChanged();
108 
109  protected:
111  QgsChunkNode *mRootNode = nullptr;
113  bool mNeedsUpdate = false;
115  float mTau;
117  int mMaxLevel;
119  QgsChunkLoaderFactory *mChunkLoaderFactory = nullptr;
121  QgsChunkList *mChunkLoaderQueue = nullptr;
123  QgsChunkList *mReplacementQueue = nullptr;
125  QList<QgsChunkNode *> mActiveNodes;
127  int mFrustumCulled = 0;
128 
129  // TODO: max. length for loading queue
130 
131  QTime mCurrentTime;
132 
134  int mMaxLoadedChunks = 512;
135 
137  QgsChunkBoundsEntity *mBboxesEntity = nullptr;
138 
140  QgsChunkQueueJob *mActiveJob = nullptr;
141 };
142 
144 
145 #endif // QGSCHUNKEDENTITY_P_H
3 Axis-aligned bounding box - in world coords.
Definition: qgsaabb.h:30