QGeoView  1.0
QGeoView documentation
QGVLayerTiles.h
1 /***************************************************************************
2  * QGeoView is a Qt / C ++ widget for visualizing geographic data.
3  * Copyright (C) 2018-2025 Andrey Yaroshenko.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this program; if not, see https://www.gnu.org/licenses.
17  ****************************************************************************/
18 
19 #pragma once
20 
21 #include "QGVLayer.h"
22 
23 #include <QElapsedTimer>
24 
25 class QGV_LIB_DECL QGVLayerTiles : public QGVLayer
26 {
27  Q_OBJECT
28 
29 public:
30  QGVLayerTiles();
31 
32  void setTilesMarginWithZoomChange(size_t value);
33  void setTilesMarginNoZoomChange(size_t value);
34  void setAnimationUpdateDelayMs(size_t value);
35  void setVisibleZoomLayersBelowCurrent(size_t value);
36  void setVisibleZoomLayersAboveCurrent(size_t value);
37  void setCameraUpdatesDuringAnimation(bool value);
38 
39 protected:
40  void onProjection(QGVMap* geoMap) override;
41  void onCamera(const QGVCameraState& oldState, const QGVCameraState& newState) override;
42  void onUpdate() override;
43  void onClean() override;
44  void onTile(const QGV::GeoTilePos& tilePos, QGVDrawItem* tileObj);
45 
46  virtual int minZoomlevel() const = 0;
47  virtual int maxZoomlevel() const = 0;
48  virtual int scaleToZoom(double scale) const;
49  virtual void request(const QGV::GeoTilePos& tilePos) = 0;
50  virtual void cancel(const QGV::GeoTilePos& tilePos) = 0;
51 
52 private:
53  void processCamera();
54  void removeAllAbove(const QGV::GeoTilePos& tilePos);
55  void removeWhenCovered(const QGV::GeoTilePos& tilePos);
56  void removeForPerfomance(const QGV::GeoTilePos& tilePos);
57  void addTile(const QGV::GeoTilePos& tilePos, QGVDrawItem* tileObj);
58  void removeTile(const QGV::GeoTilePos& tilePos);
59  bool isTileExists(const QGV::GeoTilePos& tilePos) const;
60  bool isTileFinished(const QGV::GeoTilePos& tilePos) const;
61  QList<QGV::GeoTilePos> existingTiles(int zoom) const;
62 
63 private:
64  int mCurZoom;
65  QRect mCurRect;
66  QMap<int, QMap<QGV::GeoTilePos, QGVDrawItem*>> mIndex;
67 
68  QElapsedTimer mLastAnimation;
69 
70  struct
71  {
72  size_t TilesMarginWithZoomChange = 1;
73  size_t TilesMarginNoZoomChange = 3;
74  size_t AnimationUpdateDelayMs = 200;
75  bool CameraUpdatesDuringAnimation = true;
76  size_t VisibleZoomLayersBelowCurrent = 10;
77  size_t VisibleZoomLayersAboveCurrent = 10;
78  } mPerfomanceProfile;
79 };
Definition: QGVCamera.h:30
Definition: QGVDrawItem.h:27
Definition: QGVLayerTiles.h:26
Definition: QGVLayer.h:24
Definition: QGVMap.h:35
Definition: QGVGlobal.h:164