QGIS API Documentation  3.4.15-Madeira (e83d02e274)
qgschunknode_p.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgschunknode_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 QGSCHUNKNODE_P_H
17 #define QGSCHUNKNODE_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 "qgsaabb.h"
31 
32 #include <QTime>
33 
34 namespace Qt3DCore
35 {
36  class QEntity;
37 }
38 
39 struct QgsChunkListEntry;
40 class QgsChunkLoader;
41 class QgsChunkQueueJob;
42 class QgsChunkQueueJobFactory;
43 
44 
59 class QgsChunkNode
60 {
61  public:
63  QgsChunkNode( int tileX, int tileY, int tileZ, const QgsAABB &bbox, float error, QgsChunkNode *parent = nullptr );
64 
65  ~QgsChunkNode();
66 
85  enum State
86  {
87  Skeleton,
88  QueuedForLoad,
89  Loading,
90  Loaded,
91  QueuedForUpdate,
92  Updating,
93  };
94 
96  QgsAABB bbox() const { return mBbox; }
98  float error() const { return mError; }
100  int tileX() const { return mTileX; }
102  int tileY() const { return mTileY; }
104  int tileZ() const { return mTileZ; }
106  QgsChunkNode *parent() const { return mParent; }
108  QgsChunkNode *const *children() const { return mChildren; }
110  State state() const { return mState; }
111 
113  QgsChunkListEntry *loaderQueueEntry() const { return mLoaderQueueEntry; }
115  QgsChunkListEntry *replacementQueueEntry() const { return mReplacementQueueEntry; }
117  QgsChunkLoader *loader() const { return mLoader; }
119  Qt3DCore::QEntity *entity() const { return mEntity; }
121  QgsChunkQueueJob *updater() const { return mUpdater; }
122 
124  bool allChildChunksResident( QTime currentTime ) const;
125 
127  void ensureAllChildrenExist();
128 
130  int level() const;
131 
133  QList<QgsChunkNode *> descendants();
134 
135  //
136  // changes of states in the state machine (see State enum)
137  //
138 
140  void setQueuedForLoad( QgsChunkListEntry *entry );
141 
143  void cancelQueuedForLoad();
144 
146  void setLoading( QgsChunkLoader *chunkLoader );
147 
149  void cancelLoading();
150 
152  void setLoaded( Qt3DCore::QEntity *mEntity );
153 
155  void unloadChunk();
156 
158  void setQueuedForUpdate( QgsChunkListEntry *entry, QgsChunkQueueJobFactory *updateJobFactory );
159 
161  void cancelQueuedForUpdate();
162 
164  void setUpdating();
165 
167  void cancelUpdating();
168 
170  void setUpdated();
171 
173  void setExactBbox( const QgsAABB &box );
174 
176  void setHasData( bool hasData ) { mHasData = hasData; }
178  bool hasData() const { return mHasData; }
179 
180  private:
181  QgsAABB mBbox;
182  float mError;
183 
184  int mTileX, mTileY, mTileZ;
185 
186  QgsChunkNode *mParent;
187  QgsChunkNode *mChildren[4];
188 
189  State mState;
190 
191  QgsChunkListEntry *mLoaderQueueEntry;
192  QgsChunkListEntry *mReplacementQueueEntry;
193 
194  QgsChunkLoader *mLoader;
195  Qt3DCore::QEntity *mEntity;
196 
197  QgsChunkQueueJobFactory *mUpdaterFactory;
198  QgsChunkQueueJob *mUpdater;
199 
200  QTime mEntityCreatedTime;
201  bool mHasData = true;
202 };
203 
205 
206 #endif // CHUNKNODE_H
3 Axis-aligned bounding box - in world coords.
Definition: qgsaabb.h:30