libosmscout  1.1.1
TiledMapOverlay.h
Go to the documentation of this file.
1 #ifndef OSMSCOUT_CLIENT_QT_TILEMAPOVERLAY_H
2 #define OSMSCOUT_CLIENT_QT_TILEMAPOVERLAY_H
3 /*
4  OSMScout - a Qt backend for libosmscout and libosmscout-map
5  Copyright (C) 2017 Lukáš Karas
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Lesser General Public
9  License as published by the Free Software Foundation; either
10  version 2.1 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public
18  License along with this library; if not, write to the Free Software
19  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */
21 
22 #include <osmscout/MapOverlay.h>
23 #include <osmscout/TileCache.h>
25 
27 
28 #include <QImage>
29 
30 namespace osmscout {
31 
36 Q_OBJECT
37 
38 private:
39  QThread *thread;
40  OsmTileDownloader *tileDownloader;
41  OnlineTileProvider provider;
42 
43  mutable QMutex tileCacheMutex;
44  TileCache onlineTileCache;
45 
46 public slots:
47  void init();
48  void download(uint32_t, uint32_t, uint32_t);
49  void onProviderChanged(const OnlineTileProvider &newProvider);
50 
51  void tileDownloaded(uint32_t zoomLevel, uint32_t x, uint32_t y, QImage image, QByteArray downloadedData);
52  void tileDownloadFailed(uint32_t zoomLevel, uint32_t x, uint32_t y, bool zoomLevelOutOfRange);
53 
54 signals:
55  void downloaded(uint32_t zoomLevel, uint32_t x, uint32_t y);
56  void failed(uint32_t zoomLevel, uint32_t x, uint32_t y);
57 
58 public:
59  TileLoaderThread(QThread *thread);
60 
61  virtual ~TileLoaderThread();
62 
68  void accessCache(std::function<void(TileCache&)> fn);
69 
70 };
71 
76 {
77  Q_OBJECT
78  Q_PROPERTY(QJsonValue provider READ getProvider WRITE setProvider)
79  Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
80 
81 private:
82  QJsonValue providerJson;
83  TileLoaderThread *loader;
84  bool enabled;
85  QColor transparentColor;
86 
87 public slots:
88  void tileDownloaded(uint32_t zoomLevel, uint32_t x, uint32_t y);
89 
90 signals:
91  void providerChanged(const OnlineTileProvider &provider);
92 
93 public:
94  TiledMapOverlay(QQuickItem* parent = 0);
95  virtual ~TiledMapOverlay();
96 
97  virtual void paint(QPainter *painter);
98 
99  QJsonValue getProvider();
100  void setProvider(QJsonValue jv);
101 
102  bool isEnabled();
103  void setEnabled(bool b);
104 };
105 
106 }
107 
108 #endif // OSMSCOUT_CLIENT_QT_TILEMAPOVERLAY_H
Definition: OsmTileDownloader.h:40
Definition: OnlineTileProvider.h:39
#define OSMSCOUT_CLIENT_QT_API
Definition: ClientQtImportExport.h:45
Definition: Area.h:38
Definition: TiledMapOverlay.h:35
Definition: TiledMapOverlay.h:75
Definition: MapOverlay.h:34
Definition: TileCache.h:91