libosmscout 1.1.1
Loading...
Searching...
No Matches
TiledMapRenderer.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_CLIENT_QT_TILEDMAPRENDERER_H
2#define OSMSCOUT_CLIENT_QT_TILEDMAPRENDERER_H
3
4/*
5 OSMScout - a Qt backend for libosmscout and libosmscout-map
6 Copyright (C) 2010 Tim Teulings
7 Copyright (C) 2017 Lukas Karas
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24#include <QObject>
25#include <QSettings>
26
28
29#include <osmscoutclient/DBThread.h>
30
34
36
37#include <atomic>
38
39namespace osmscout {
40
42 Q_OBJECT
43
44private:
45 QString tileCacheDirectory;
46
47 // tile caches
48 // Rendered tile is combined from both sources.
49 //
50 // Online cache may contain NULL images (QImage::isNull() is true) for areas
51 // covered by offline db and offline cache can contain NULL images
52 // for areas not covered by db.
53 //
54 // When offlineTileCache is invalidated, cache keeps unchanged,
55 // just its epoch is increased. When there is retrieved pixmap with
56 // old epoch from cache, it is used, but rendering request is triggered.
57 //
58 // Offline tiles should be in ARGB format on db area interface.
59 mutable QMutex tileCacheMutex;
60 TileCache onlineTileCache;
61 TileCache offlineTileCache;
62
63 OsmTileDownloader *tileDownloader=nullptr;
64
65 std::atomic_bool onlineTilesEnabled;
66 std::atomic_bool offlineTilesEnabled;
67
68 int screenWidth;
69 int screenHeight;
70
71 // data loading request
72 DBLoadJob *loadJob=nullptr;
73 uint32_t loadXFrom;
74 uint32_t loadXTo;
75 uint32_t loadYFrom;
76 uint32_t loadYTo;
77 MagnificationLevel loadZ;
78 size_t loadEpoch; // guarded by lock
79
80 QColor unknownColor;
81 QColor tileGridColor;
82
83 Slot<OnlineTileProvider> onlineTileProviderSlot{ std::bind(&TiledMapRenderer::onlineTileProviderSignal, this, std::placeholders::_1) };
84 Slot<bool> onlineTileEnabledSlot{ std::bind(&TiledMapRenderer::onlineTilesEnabledSignal, this, std::placeholders::_1) };
85 Slot<bool> offlineMapChangedSlot{ std::bind(&TiledMapRenderer::offlineMapChangedSignal, this, std::placeholders::_1) };
86
87signals:
88 void onlineTileProviderSignal(OnlineTileProvider provider);
91
92public slots:
93 virtual void Initialize();
94 virtual void InvalidateVisualCache();
96 virtual void onDatabaseLoaded(osmscout::GeoBox boundingBox);
97
98 void onlineTileRequest(uint32_t zoomLevel, uint32_t xtile, uint32_t ytile);
99 void offlineTileRequest(uint32_t zoomLevel, uint32_t xtile, uint32_t ytile);
100 void tileDownloaded(uint32_t zoomLevel, uint32_t x, uint32_t y, QImage image, QByteArray downloadedData);
101 void tileDownloadFailed(uint32_t zoomLevel, uint32_t x, uint32_t y, bool zoomLevelOutOfRange);
102 void onLoadJobFinished(QMap<QString,QMap<osmscout::TileKey,osmscout::TileRef>>);
103
104 void onlineTileProviderChanged(const OnlineTileProvider &);
106
108
109private:
110
111 DatabaseCoverage databaseCoverageOfTile(uint32_t zoomLevel, uint32_t xtile, uint32_t ytile);
112
113public:
115 SettingsRef settings,
116 DBThreadRef dbThread,
117 QString iconDirectory,
118 QString tileCacheDirectory,
119 size_t onlineTileCacheSize,
120 size_t offlineTileCacheSize);
121
123
130 virtual bool RenderMap(QPainter& painter,
131 const MapViewStruct& request);
132};
133
134}
135
136#endif /* OSMSCOUT_CLIENT_QT_TILEDMAPRENDERER_H */
#define OSMSCOUT_CLIENT_QT_API
Definition ClientQtImportExport.h:45
Definition DBLoadJob.h:47
QThread * thread
Definition MapRenderer.h:89
MapRenderer(QThread *thread, SettingsRef settings, DBThreadRef dbThread, QString iconDirectory)
QString iconDirectory
Definition MapRenderer.h:104
SettingsRef settings
Definition MapRenderer.h:90
DBThreadRef dbThread
Definition MapRenderer.h:91
Definition OsmTileDownloader.h:42
Definition Signal.h:98
Definition TileCache.h:92
void onlineTilesEnabledSignal(bool)
void offlineMapChangedSignal(bool)
void tileDownloaded(uint32_t zoomLevel, uint32_t x, uint32_t y, QImage image, QByteArray downloadedData)
void offlineTileRequest(uint32_t zoomLevel, uint32_t xtile, uint32_t ytile)
void tileDownloadFailed(uint32_t zoomLevel, uint32_t x, uint32_t y, bool zoomLevelOutOfRange)
TiledMapRenderer(QThread *thread, SettingsRef settings, DBThreadRef dbThread, QString iconDirectory, QString tileCacheDirectory, size_t onlineTileCacheSize, size_t offlineTileCacheSize)
void onlineTileProviderChanged(const OnlineTileProvider &)
virtual void InvalidateVisualCache()
void onlineTileRequest(uint32_t zoomLevel, uint32_t xtile, uint32_t ytile)
void onlineTilesEnabledChanged(bool)
virtual void onDatabaseLoaded(osmscout::GeoBox boundingBox)
virtual bool RenderMap(QPainter &painter, const MapViewStruct &request)
virtual void onStylesheetFilenameChanged()
void onlineTileProviderSignal(OnlineTileProvider provider)
void onLoadJobFinished(QMap< QString, QMap< osmscout::TileKey, osmscout::TileRef > >)
Definition Area.h:39