Marble

VectorTileModel.h
1 /*
2  SPDX-License-Identifier: LGPL-2.1-or-later
3 
4  SPDX-FileCopyrightText: 2012 Ander Pijoan <[email protected]>
5  SPDX-FileCopyrightText: 2013 Bernhard Beschow <[email protected]>
6 */
7 
8 #ifndef MARBLE_VECTORTILEMODEL_H
9 #define MARBLE_VECTORTILEMODEL_H
10 
11 #include <QObject>
12 #include <QRunnable>
13 
14 #include <QMap>
15 
16 #include "TileId.h"
17 #include "GeoDataLatLonBox.h"
18 
19 class QThreadPool;
20 
21 namespace Marble
22 {
23 
24 class GeoDataDocument;
25 class GeoDataTreeModel;
26 class GeoSceneVectorTileDataset;
27 class GeoDataObject;
28 class TileLoader;
29 
30 class TileRunner : public QObject, public QRunnable
31 {
32  Q_OBJECT
33 
34 public:
35  TileRunner( TileLoader *loader, const GeoSceneVectorTileDataset *texture, const TileId &id );
36  void run() override;
37 
38 Q_SIGNALS:
39  void documentLoaded( const TileId &id, GeoDataDocument *document );
40 
41 private:
42  TileLoader *const m_loader;
43  const GeoSceneVectorTileDataset *const m_tileDataset;
44  const TileId m_id;
45 };
46 
47 class VectorTileModel : public QObject
48 {
49  Q_OBJECT
50 
51 public:
52  explicit VectorTileModel( TileLoader *loader, const GeoSceneVectorTileDataset *layer, GeoDataTreeModel *treeModel, QThreadPool *threadPool );
53 
54  void setViewport(const GeoDataLatLonBox &bbox);
55 
56  QString name() const;
57 
58  const GeoSceneVectorTileDataset *layer() const;
59 
60  void removeTile(GeoDataDocument* document);
61 
62  int tileZoomLevel() const;
63 
64  int cachedDocuments() const;
65 
66  void reload();
67 
68 public Q_SLOTS:
69  void updateTile( const TileId &id, GeoDataDocument *document );
70 
71  void clear();
72 
73 Q_SIGNALS:
74  void tileCompleted( const TileId &tileId );
75  void tileAdded(GeoDataDocument *document);
76  void tileRemoved(GeoDataDocument *document);
77 
78 private Q_SLOTS:
79  void cleanupTile(GeoDataObject* feature);
80 
81 private:
82  void removeTilesOutOfView(const GeoDataLatLonBox &boundingBox);
83  void queryTiles(int tileZoomLevel, const QRect &rect);
84 
85 private:
86  struct CacheDocument
87  {
88  /** The CacheDocument takes ownership of doc */
89  CacheDocument(GeoDataDocument *doc, VectorTileModel* vectorTileModel, const GeoDataLatLonBox &boundingBox);
90 
91  /** Remove the document from the tree and delete the document */
92  ~CacheDocument();
93 
94  GeoDataLatLonBox latLonBox() const { return m_boundingBox; }
95 
96  private:
97  Q_DISABLE_COPY( CacheDocument )
98 
99  GeoDataDocument *const m_document;
100  VectorTileModel *const m_vectorTileModel;
101  GeoDataLatLonBox m_boundingBox;
102  };
103 
104  TileLoader *const m_loader;
105  const GeoSceneVectorTileDataset *const m_layer;
106  GeoDataTreeModel *const m_treeModel;
107  QThreadPool *const m_threadPool;
108  int m_tileLoadLevel;
109  int m_tileZoomLevel;
110  QList<TileId> m_pendingDocuments;
111  QList<GeoDataDocument*> m_garbageQueue;
113  bool m_deleteDocumentsLater;
114 };
115 
116 }
117 
118 #endif // MARBLE_VECTORTILEMODEL_H
Q_OBJECTQ_OBJECT
Q_SLOTSQ_SLOTS
const QList< QKeySequence > & reload()
KGuiItem clear()
Binds a QML item to a specific geodetic location in screen coordinates.
KIOWIDGETS_EXPORT bool run(const QUrl &_url, bool _is_local)
Q_SIGNALSQ_SIGNALS
QString name(StandardShortcut id)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Oct 2 2023 03:52:10 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.