QGIS API Documentation 3.38.0-Grenoble (exported)
Loading...
Searching...
No Matches
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 "qgis.h"
33#include <QTime>
34
35#define SIP_NO_FILE
36
37namespace Qt3DCore
38{
39 class QEntity;
40}
41
42struct QgsChunkListEntry;
43class QgsChunkLoader;
44class QgsChunkQueueJob;
45class QgsChunkQueueJobFactory;
46
47
60struct QgsChunkNodeId
61{
62
66 QgsChunkNodeId( int _d = -1, int _x = -1, int _y = -1, int _z = -1 )
67 : d( _d ), x( _x ), y( _y ), z( _z ) {}
68
74 QgsChunkNodeId( long long id )
75 : uniqueId( id )
76 {}
77
78 int d = 0;
79 int x = 0;
80 int y = 0;
81 int z = 0;
82 long long uniqueId = -1;
83
85 QString text() const
86 {
87 if ( uniqueId != -1 )
88 return QString::number( uniqueId );
89 else if ( z == -1 )
90 return QStringLiteral( "%1/%2/%3" ).arg( d ).arg( x ).arg( y ); // quadtree
91 else
92 return QStringLiteral( "%1/%2/%3/%4" ).arg( d ).arg( x ).arg( y ).arg( z ); // octree
93 }
94
95 bool operator==( const QgsChunkNodeId &other ) const
96 {
97 return ( uniqueId == -1 && other.uniqueId == -1 && d == other.d && x == other.x && y == other.y && z == other.z )
98 || ( uniqueId != -1 && uniqueId == other.uniqueId );
99 }
100
101 bool operator!=( const QgsChunkNodeId &other ) const
102 {
103 return !( *this == other );
104 }
105};
106
121class QgsChunkNode
122{
123 public:
124
126 QgsChunkNode( const QgsChunkNodeId &nodeId, const QgsAABB &bbox, float error, QgsChunkNode *parent = nullptr );
127
128 ~QgsChunkNode();
129
148 enum State
149 {
150 Skeleton,
151 QueuedForLoad,
152 Loading,
153 Loaded,
154 QueuedForUpdate,
155 Updating,
156 };
157
159 QgsAABB bbox() const { return mBbox; }
161 float error() const { return mError; }
163 QgsChunkNodeId tileId() const { return mNodeId; }
165 QgsChunkNode *parent() const { return mParent; }
167 int childCount() const { return mChildren.count(); }
169 QgsChunkNode *const *children() const { return mChildren.constData(); }
171 Qgis::TileRefinementProcess refinementProcess() const { return mRefinementProcess; }
173 State state() const { return mState; }
174
176 QgsChunkListEntry *loaderQueueEntry() const { return mLoaderQueueEntry; }
178 QgsChunkListEntry *replacementQueueEntry() const { return mReplacementQueueEntry; }
180 QgsChunkLoader *loader() const { return mLoader; }
182 Qt3DCore::QEntity *entity() const { return mEntity; }
184 QgsChunkQueueJob *updater() const { return mUpdater; }
185
187 bool allChildChunksResident( QTime currentTime ) const;
188
190 bool hasChildrenPopulated() const { return mChildrenPopulated; }
191
193 void populateChildren( const QVector<QgsChunkNode *> &children );
194
196 void setRefinementProcess( Qgis::TileRefinementProcess refinementProcess ) { mRefinementProcess = refinementProcess; }
197
199 int level() const;
200
202 QList<QgsChunkNode *> descendants();
203
204 //
205 // changes of states in the state machine (see State enum)
206 //
207
209 void setQueuedForLoad( QgsChunkListEntry *entry );
210
212 void cancelQueuedForLoad();
213
215 void setLoading( QgsChunkLoader *chunkLoader );
216
218 void cancelLoading();
219
221 void setLoaded( Qt3DCore::QEntity *mEntity );
222
224 void unloadChunk();
225
227 void setQueuedForUpdate( QgsChunkListEntry *entry, QgsChunkQueueJobFactory *updateJobFactory );
228
230 void cancelQueuedForUpdate();
231
233 void setUpdating();
234
236 void cancelUpdating();
237
239 void setUpdated();
240
242 void setExactBbox( const QgsAABB &box );
243
251 void updateParentBoundingBoxesRecursively() const;
252
254 void setHasData( bool hasData ) { mHasData = hasData; }
256 bool hasData() const { return mHasData; }
257
258 private:
259 QgsAABB mBbox;
260 float mError;
261
262 QgsChunkNodeId mNodeId;
263
264 QgsChunkNode *mParent;
265 QVector<QgsChunkNode *> mChildren;
266 bool mChildrenPopulated = false;
267
268 State mState;
269
271
272 QgsChunkListEntry *mLoaderQueueEntry;
273 QgsChunkListEntry *mReplacementQueueEntry;
274
275 QgsChunkLoader *mLoader;
276 Qt3DCore::QEntity *mEntity;
277
278 QgsChunkQueueJobFactory *mUpdaterFactory;
279 QgsChunkQueueJob *mUpdater;
280
281 QTime mEntityCreatedTime;
282 bool mHasData = true;
283};
284
286
287#endif // CHUNKNODE_H
TileRefinementProcess
Tiled scene tile refinement processes.
Definition qgis.h:4810
@ Replacement
When tile is refined then its children should be used in place of itself.
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)