Compare commits
17 Commits
a0f2d80b4f
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 681a79a672 | |||
| 88bcc7f2e9 | |||
| 04d9cf6edf | |||
| 66dc481d6e | |||
| f8e361190b | |||
| 745376adfb | |||
| 13d4e6cb75 | |||
| 0f13cf5196 | |||
| d403d0a242 | |||
| c959a712f7 | |||
| f9a8f5d6b1 | |||
| 49ae1473f9 | |||
| b8e8a1300e | |||
| 26396a4f72 | |||
| 2cb43ab411 | |||
| 8df58026c4 | |||
| f0c2369df0 |
@@ -135,7 +135,7 @@ JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
LambdaBodyIndentation: Signature
|
||||
MacroBlockBegin: "PRIVATE_DEFINITION_START|STATIC_INITIALIZER_BEGIN"
|
||||
MacroBlockEnd: "PRIVATE_DEFINITION_END|STATIC_INITIALIZER_END"
|
||||
MacroBlockEnd: "PRIVATE_DEFINITION_END|PRIVATE_DEFINITION_END_NO_INITIALIZE|STATIC_INITIALIZER_END"
|
||||
MaxEmptyLinesToKeep: 2
|
||||
NamespaceIndentation: None
|
||||
ObjCBinPackProtocolList: Auto
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
cmake_policy(SET CMP0017 NEW) # need include() with .cmake
|
||||
cmake_policy(SET CMP0072 NEW) # FindOpenGL prefers GLVND by default
|
||||
project(QAD)
|
||||
set(QAD_MAJOR 2)
|
||||
set(QAD_MINOR 32)
|
||||
set(QAD_REVISION 1)
|
||||
set(QAD_REVISION 2)
|
||||
set(QAD_SUFFIX )
|
||||
set(QAD_COMPANY SHS)
|
||||
set(QAD_DOMAIN org.SHS)
|
||||
|
||||
@@ -137,6 +137,9 @@ endif()
|
||||
if (POLICY CMP0074)
|
||||
cmake_policy(SET CMP0074 NEW) # ignore <PackageName>_ROOT variables
|
||||
endif()
|
||||
if (POLICY CMP0177)
|
||||
cmake_policy(SET CMP0177 OLD)
|
||||
endif()
|
||||
set(__qt_bug_modules "UiTools")
|
||||
|
||||
set(__qt_modules_4 "CLucene;Core;Declarative;Gui;Help;main;Multimedia;Network;OpenGL;\
|
||||
@@ -723,7 +726,7 @@ macro(qad_target_link_libraries _NAME)
|
||||
list(APPEND _ARGS ${_i})
|
||||
endif()
|
||||
endforeach()
|
||||
target_link_libraries(${_TARGET} ${Qt${_v}_LIBRARIES} ${_ARGS})
|
||||
target_link_libraries(${_TARGET} ${_ARGS} ${Qt${_v}_LIBRARIES})
|
||||
#message("link ${_TARGET}: ${Qt${_v}_LIBRARIES} ${_ARGS}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
@@ -342,6 +342,7 @@ void Graphic::procGesture(QGesture * g) {
|
||||
QPointF dp = -pg->delta();
|
||||
dp.rx() /= getScaleX();
|
||||
dp.ry() /= getScaleY();
|
||||
dp.ry() = -dp.y();
|
||||
selrect.translate(dp);
|
||||
totalUpdate();
|
||||
} break;
|
||||
@@ -357,11 +358,7 @@ void Graphic::procGesture(QGesture * g) {
|
||||
} break;
|
||||
case Qt::TapAndHoldGesture: {
|
||||
QTapAndHoldGesture * pg = (QTapAndHoldGesture *)g;
|
||||
if (pg->state() == Qt::GestureStarted)
|
||||
QMetaObject::invokeMethod(
|
||||
this,
|
||||
[this]() { showMenu(); },
|
||||
Qt::QueuedConnection);
|
||||
if (pg->state() == Qt::GestureStarted) QMetaObject::invokeMethod(this, [this]() { showMenu(); }, Qt::QueuedConnection);
|
||||
} break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="qad_graphic.qrc">
|
||||
<normaloff>:/icons/zoom-original.png</normaloff>:/icons/zoom-original.png</iconset>
|
||||
<normaloff>:/icons/zoom-original.png</normaloff>:/icons/zoom-original.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -505,6 +505,9 @@
|
||||
<property name="shortcut">
|
||||
<string>Esc</string>
|
||||
</property>
|
||||
<property name="shortcutContext">
|
||||
<enum>Qt::WidgetShortcut</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCheck_all">
|
||||
<property name="icon">
|
||||
|
||||
@@ -182,6 +182,7 @@ void GraphicAnalysis::updateGraphic(int index) {
|
||||
void GraphicAnalysis::updateAllGraphic() {
|
||||
for (int i = 0; i < graphicsCount(); ++i)
|
||||
updateGraphic(i);
|
||||
updateGraphics();
|
||||
}
|
||||
|
||||
|
||||
@@ -261,11 +262,13 @@ void GraphicAnalysis::addPoint(const QPointF & p, int graphic, bool update_) {
|
||||
|
||||
void GraphicAnalysis::setGraphicTransformFunction(std::function<QPolygonF(const QPolygonF &)> f) {
|
||||
tf_gr = f;
|
||||
updateAllGraphic();
|
||||
}
|
||||
|
||||
|
||||
void GraphicAnalysis::setSpectrumTransformFunction(std::function<QPolygonF(const QPolygonF &)> f) {
|
||||
tf_fft = f;
|
||||
updateAllGraphic();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
#include "osm_math_p.h"
|
||||
|
||||
|
||||
MapItemBase::MapItemBase() {}
|
||||
MapItemBase::MapItemBase() {
|
||||
m_hints = QPainter::Antialiasing | QPainter::SmoothPixmapTransform;
|
||||
}
|
||||
|
||||
|
||||
MapItemBase::~MapItemBase() {
|
||||
@@ -19,6 +21,18 @@ void MapItemBase::setInteracive(bool newInteracive) {
|
||||
}
|
||||
|
||||
|
||||
void MapItemBase::setRenderHints(QPainter::RenderHints h) {
|
||||
m_hints = h;
|
||||
updateParent();
|
||||
}
|
||||
|
||||
|
||||
void MapItemBase::setRenderHint(QPainter::RenderHint h, bool on) {
|
||||
m_hints.setFlag(h, on);
|
||||
updateParent();
|
||||
}
|
||||
|
||||
|
||||
void MapItemBase::setVisible(bool newVisible) {
|
||||
m_visible = newVisible;
|
||||
updateParent();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
QAD - Qt ADvanced
|
||||
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
@@ -38,10 +38,13 @@ public:
|
||||
explicit MapItemBase();
|
||||
virtual ~MapItemBase();
|
||||
|
||||
|
||||
bool isInteracive() const { return m_interacive; }
|
||||
void setInteracive(bool newInteracive);
|
||||
|
||||
QPainter::RenderHints renderHints() const { return m_hints; }
|
||||
void setRenderHints(QPainter::RenderHints h);
|
||||
void setRenderHint(QPainter::RenderHint h, bool on = true);
|
||||
|
||||
bool isVisible() const { return m_visible; }
|
||||
void setVisible(bool newVisible);
|
||||
bool isHidden() const { return !isVisible(); }
|
||||
@@ -97,6 +100,7 @@ private:
|
||||
QPointF m_position, m_scale = {1., 1.}, m_offset;
|
||||
QRectF m_bounding;
|
||||
QCursor m_cursor;
|
||||
QPainter::RenderHints m_hints;
|
||||
QMap<int, QVariant> data_;
|
||||
};
|
||||
|
||||
|
||||
@@ -81,6 +81,12 @@ void MapView::setZoom(double z) {
|
||||
}
|
||||
|
||||
|
||||
void MapView::setContrast(double value) {
|
||||
contrast = piClampd(value, 0., 100.);
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
QString MapView::cachePath() const {
|
||||
return cache->cacheRoot();
|
||||
}
|
||||
@@ -104,6 +110,7 @@ void MapView::setTileObsoleteTime(int secs) {
|
||||
|
||||
|
||||
void MapView::setTileProvider(MapViewTileProviderBase * p) {
|
||||
if (p) max_level = p->maximumLevel();
|
||||
cache->clearCache();
|
||||
downloader->setTileProvider(p);
|
||||
drawBackground();
|
||||
@@ -116,8 +123,8 @@ MapViewTileProviderBase * MapView::tileProvider() const {
|
||||
|
||||
|
||||
void collectDownloadIndeces(MapViewTileCache * cache,
|
||||
QQueue<OSM::TileIndex> & indeces,
|
||||
OSM::TileIndex index,
|
||||
QQueue<MapViewTypes::TileIndex> & indeces,
|
||||
MapViewTypes::TileIndex index,
|
||||
int target_zoom_level,
|
||||
bool only_new) {
|
||||
if (only_new) {
|
||||
@@ -130,7 +137,7 @@ void collectDownloadIndeces(MapViewTileCache * cache,
|
||||
int y = index.y * 2;
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
for (int j = 0; j < 2; ++j) {
|
||||
collectDownloadIndeces(cache, indeces, (OSM::TileIndex){z, x + i, y + j}, target_zoom_level, only_new);
|
||||
collectDownloadIndeces(cache, indeces, (MapViewTypes::TileIndex){z, x + i, y + j}, target_zoom_level, only_new);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -142,10 +149,10 @@ void MapView::downloadCurrentView(int target_zoom_level, bool only_new, int para
|
||||
int ex = qMin(tiles_side, (int)ceil(view_rect.right() * tiles_side));
|
||||
int ey = qMin(tiles_side, (int)ceil(view_rect.bottom() * tiles_side));
|
||||
target_zoom_level = qMin(target_zoom_level, max_level);
|
||||
QQueue<OSM::TileIndex> indeces;
|
||||
QQueue<MapViewTypes::TileIndex> indeces;
|
||||
for (int ix = sx; ix < ex; ++ix) {
|
||||
for (int iy = sy; iy < ey; ++iy) {
|
||||
collectDownloadIndeces(cache, indeces, (OSM::TileIndex){zoom_level, ix, iy}, target_zoom_level, only_new);
|
||||
collectDownloadIndeces(cache, indeces, (MapViewTypes::TileIndex){zoom_level, ix, iy}, target_zoom_level, only_new);
|
||||
}
|
||||
}
|
||||
if (indeces.size() < 4) return;
|
||||
@@ -257,6 +264,11 @@ void MapView::wheelEvent(QWheelEvent * e) {
|
||||
void MapView::paintEvent(QPaintEvent *) {
|
||||
QPainter p(this);
|
||||
p.drawPixmap(0, 0, background);
|
||||
if (contrast < 100.) {
|
||||
auto col = palette().color(QPalette::Window);
|
||||
col.setAlphaF(1. - contrast / 100.);
|
||||
p.fillRect(rect(), col);
|
||||
}
|
||||
drawItems(p);
|
||||
updateMouse(mapFromGlobal(QCursor::pos()));
|
||||
}
|
||||
@@ -291,7 +303,7 @@ void MapView::drawBackground() {
|
||||
QRectF r((ix)*ts, (iy)*ts, ts, ts);
|
||||
r.translate(-offset);
|
||||
QRectF px_rct(QPointF(), tile_size /*QSizeF(tileSize, tileSize)*/);
|
||||
auto tile = cache->getTile((OSM::TileIndex){zoom_level, ix, iy}, px_rct);
|
||||
auto tile = cache->getTile((MapViewTypes::TileIndex){zoom_level, ix, iy}, px_rct);
|
||||
if (!tile.isEmpty()) {
|
||||
p.drawPixmap(r, tile.pixmap, px_rct);
|
||||
} else {
|
||||
@@ -308,8 +320,7 @@ void MapView::drawBackground() {
|
||||
|
||||
void MapView::drawItems(QPainter & p) {
|
||||
auto src_tr = p.transform();
|
||||
p.setRenderHint(QPainter::Antialiasing);
|
||||
p.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||
QPainter::RenderHints cur_hints;
|
||||
QPoint mouse = mapFromGlobal(QCursor::pos());
|
||||
MapItemBase * hover = nullptr;
|
||||
for (auto * i: items_) {
|
||||
@@ -320,6 +331,10 @@ void MapView::drawItems(QPainter & p) {
|
||||
p.translate(i->m_offset.x(), -i->m_offset.y());
|
||||
p.rotate(i->getRotation());
|
||||
if (!i->ignore_scale) p.scale(i->getScale().x(), i->getScale().y());
|
||||
if (cur_hints != i->renderHints()) {
|
||||
cur_hints = i->renderHints();
|
||||
p.setRenderHints(cur_hints);
|
||||
}
|
||||
i->draw(&p);
|
||||
QTransform mtr;
|
||||
mtr.rotate(-i->getRotation());
|
||||
@@ -360,7 +375,7 @@ void MapView::zoomLevelChanged(int new_level) {
|
||||
tiles_side = 1 << zoom_level;
|
||||
// for (int x = 0; x < tiles_side; ++x)
|
||||
// for (int y = 0; y < tiles_side; ++y)
|
||||
// downloader->queueTile(OSM::TileIndex{zoom_level, x, y});
|
||||
// downloader->queueTile(MapViewTypes::TileIndex{zoom_level, x, y});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ class QAD_MAP_EXPORT MapView: public QWidget {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QPointF center READ center WRITE setCenter)
|
||||
Q_PROPERTY(double zoom READ getZoom WRITE setZoom)
|
||||
Q_PROPERTY(double contrast READ getContrast WRITE setContrast)
|
||||
Q_PROPERTY(bool offlineMode READ isOfflineMode WRITE setOfflineMode)
|
||||
|
||||
friend class MapViewTileDownloader;
|
||||
@@ -58,6 +59,12 @@ public:
|
||||
double getZoom() const { return zoom_; }
|
||||
void setZoom(double z);
|
||||
|
||||
double getContrast() const { return contrast; }
|
||||
|
||||
/// 0 - 100
|
||||
void setContrast(double value);
|
||||
|
||||
/// {lat, lng}
|
||||
QPointF clickedCoordinate() const { return last_click_coord; }
|
||||
|
||||
QString cachePath() const;
|
||||
@@ -107,7 +114,7 @@ private:
|
||||
QVector<MapItemBase *> items_;
|
||||
QBrush brush_tr;
|
||||
bool is_pan = false, is_downloading = false, is_offline = false;
|
||||
double zoom_ = 1., scale_ = 1., px2m = 1.;
|
||||
double zoom_ = 1., scale_ = 1., px2m = 1., contrast = 100.;
|
||||
int zoom_level = 0, tiles_side = 1, max_level = 19;
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
|
||||
MapViewTileCache::MapViewTileCache(MapView * p): QThread() {
|
||||
qRegisterMetaType<OSM::TileIndex>();
|
||||
qRegisterMetaType<OSM::TilePixmap>();
|
||||
qRegisterMetaType<MapViewTypes::TileIndex>();
|
||||
qRegisterMetaType<MapViewTypes::TilePixmap>();
|
||||
parent = p;
|
||||
setCacheRoot(QAD::userPath(QAD::ltCache, "mapview") + "/");
|
||||
setAdditionalCacheSize(64);
|
||||
@@ -21,16 +21,16 @@ MapViewTileCache::~MapViewTileCache() {
|
||||
}
|
||||
|
||||
|
||||
void MapViewTileCache::tileDownloaded(OSM::TileIndex index, const QPixmap & pixmap) {
|
||||
auto * tile = new OSM::TilePixmap();
|
||||
void MapViewTileCache::tileDownloaded(MapViewTypes::TileIndex index, const QPixmap & pixmap) {
|
||||
auto * tile = new MapViewTypes::TilePixmap();
|
||||
tile->index = index;
|
||||
tile->pixmap = pixmap;
|
||||
saveTile(tile);
|
||||
}
|
||||
|
||||
|
||||
OSM::TilePixmap MapViewTileCache::getTile(OSM::TileIndex index, QRectF & rect_src) {
|
||||
OSM::TilePixmap ret = getTileFromCache(index);
|
||||
MapViewTypes::TilePixmap MapViewTileCache::getTile(MapViewTypes::TileIndex index, QRectF & rect_src) {
|
||||
MapViewTypes::TilePixmap ret = getTileFromCache(index);
|
||||
if (ret.isEmpty() || ret.obsolete) {
|
||||
if (!is_offline) parent->downloader->queueTile(index);
|
||||
}
|
||||
@@ -61,7 +61,7 @@ void MapViewTileCache::clearCache() {
|
||||
}
|
||||
|
||||
|
||||
bool MapViewTileCache::isTileFileExists(OSM::TileIndex index) const {
|
||||
bool MapViewTileCache::isTileFileExists(MapViewTypes::TileIndex index) const {
|
||||
QString hashdir = index.cacheDir();
|
||||
if (!cache_dir.exists(hashdir)) return false;
|
||||
QString hashname = hashdir + "/" + index.hashName();
|
||||
@@ -91,8 +91,8 @@ void MapViewTileCache::setOfflineMode(bool yes) {
|
||||
}
|
||||
|
||||
|
||||
OSM::TilePixmap MapViewTileCache::getTileFromCache(OSM::TileIndex index) {
|
||||
OSM::TilePixmap ret;
|
||||
MapViewTypes::TilePixmap MapViewTileCache::getTileFromCache(MapViewTypes::TileIndex index) {
|
||||
MapViewTypes::TilePixmap ret;
|
||||
ret.index = index;
|
||||
auto * tile = tile_cache[index.hash()];
|
||||
if (tile) {
|
||||
@@ -104,7 +104,7 @@ OSM::TilePixmap MapViewTileCache::getTileFromCache(OSM::TileIndex index) {
|
||||
if (cache_dir.exists(hashname)) {
|
||||
QString fname = cache_dir.absoluteFilePath(hashname);
|
||||
ret.pixmap.load(fname, "png");
|
||||
tile = new OSM::TilePixmap();
|
||||
tile = new MapViewTypes::TilePixmap();
|
||||
tile->index = index;
|
||||
tile->pixmap = ret.pixmap;
|
||||
if (secs_obsolete > 0) {
|
||||
@@ -125,7 +125,7 @@ void MapViewTileCache::updateCacheSize() {
|
||||
}
|
||||
|
||||
|
||||
void MapViewTileCache::saveTile(OSM::TilePixmap * tile) {
|
||||
void MapViewTileCache::saveTile(MapViewTypes::TilePixmap * tile) {
|
||||
tile_cache.insert(tile->index.hash(), tile, tile->pixmapBytes());
|
||||
emit tileReady(*tile);
|
||||
cond_mutex.lock();
|
||||
@@ -137,7 +137,7 @@ void MapViewTileCache::saveTile(OSM::TilePixmap * tile) {
|
||||
}
|
||||
|
||||
|
||||
void MapViewTileCache::writeToDisk(const OSM::TilePixmap & tile) {
|
||||
void MapViewTileCache::writeToDisk(const MapViewTypes::TilePixmap & tile) {
|
||||
QString hashdir = tile.index.cacheDir();
|
||||
if (!cache_dir.exists(hashdir)) cache_dir.mkdir(hashdir);
|
||||
QFile f(cache_dir.absoluteFilePath(hashdir + "/" + tile.index.hashName()));
|
||||
@@ -149,7 +149,7 @@ void MapViewTileCache::writeToDisk(const OSM::TilePixmap & tile) {
|
||||
|
||||
void MapViewTileCache::run() {
|
||||
while (!isInterruptionRequested()) {
|
||||
OSM::TilePixmap tile;
|
||||
MapViewTypes::TilePixmap tile;
|
||||
cond_mutex.lock();
|
||||
if (queue.isEmpty()) {
|
||||
cond.wait(&cond_mutex);
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef mapview_tile_cache_h
|
||||
#define mapview_tile_cache_h
|
||||
|
||||
#include "osm_types_p.h"
|
||||
#include "mapview_types.h"
|
||||
|
||||
#include <QCache>
|
||||
#include <QDir>
|
||||
@@ -48,11 +48,11 @@ public:
|
||||
}
|
||||
void setTileObsoleteTime(int secs) { secs_obsolete = secs; }
|
||||
|
||||
void tileDownloaded(OSM::TileIndex index, const QPixmap & pixmap);
|
||||
OSM::TilePixmap getTile(OSM::TileIndex index, QRectF & rect_src);
|
||||
void tileDownloaded(MapViewTypes::TileIndex index, const QPixmap & pixmap);
|
||||
MapViewTypes::TilePixmap getTile(MapViewTypes::TileIndex index, QRectF & rect_src);
|
||||
void clearCache();
|
||||
|
||||
bool isTileFileExists(OSM::TileIndex index) const;
|
||||
bool isTileFileExists(MapViewTypes::TileIndex index) const;
|
||||
|
||||
QString cacheRoot() const { return cache_root; }
|
||||
void setCacheRoot(const QString & p);
|
||||
@@ -61,10 +61,10 @@ public:
|
||||
void setOfflineMode(bool yes);
|
||||
|
||||
private:
|
||||
OSM::TilePixmap getTileFromCache(OSM::TileIndex index);
|
||||
MapViewTypes::TilePixmap getTileFromCache(MapViewTypes::TileIndex index);
|
||||
void updateCacheSize();
|
||||
void saveTile(OSM::TilePixmap * tile);
|
||||
void writeToDisk(const OSM::TilePixmap & tile);
|
||||
void saveTile(MapViewTypes::TilePixmap * tile);
|
||||
void writeToDisk(const MapViewTypes::TilePixmap & tile);
|
||||
void run() override;
|
||||
|
||||
MapView * parent;
|
||||
@@ -75,15 +75,15 @@ private:
|
||||
int secs_obsolete = -1;
|
||||
int fixed_size_b = 0, add_size_b = 0;
|
||||
bool is_offline = false;
|
||||
QQueue<OSM::TilePixmap> queue;
|
||||
QCache<quint64, OSM::TilePixmap> tile_cache;
|
||||
QQueue<MapViewTypes::TilePixmap> queue;
|
||||
QCache<quint64, MapViewTypes::TilePixmap> tile_cache;
|
||||
|
||||
public slots:
|
||||
|
||||
private slots:
|
||||
|
||||
signals:
|
||||
void tileReady(OSM::TilePixmap);
|
||||
void tileReady(MapViewTypes::TilePixmap);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
|
||||
MapViewTileDownloader::MapViewTileDownloader(MapView * p): QThread() {
|
||||
qRegisterMetaType<OSM::TileIndex>();
|
||||
qRegisterMetaType<MapViewTypes::TileIndex>();
|
||||
parent = p;
|
||||
start();
|
||||
}
|
||||
@@ -18,7 +18,7 @@ MapViewTileDownloader::~MapViewTileDownloader() {
|
||||
}
|
||||
|
||||
|
||||
bool MapViewTileDownloader::queueTile(OSM::TileIndex index, bool force) {
|
||||
bool MapViewTileDownloader::queueTile(MapViewTypes::TileIndex index, bool force) {
|
||||
// auto hash = tile.hash();
|
||||
bool ret = false;
|
||||
cond_mutex.lock();
|
||||
@@ -32,7 +32,7 @@ bool MapViewTileDownloader::queueTile(OSM::TileIndex index, bool force) {
|
||||
}
|
||||
|
||||
|
||||
void MapViewTileDownloader::queueTiles(QList<OSM::TileIndex> indeces) {
|
||||
void MapViewTileDownloader::queueTiles(QList<MapViewTypes::TileIndex> indeces) {
|
||||
cond_mutex.lock();
|
||||
queue << indeces;
|
||||
cond.wakeOne();
|
||||
@@ -62,13 +62,13 @@ void MapViewTileDownloader::setTileProvider(MapViewTileProviderBase * p) {
|
||||
}
|
||||
|
||||
|
||||
void MapViewTileDownloader::requestTile(OSM::TileIndex index) {
|
||||
void MapViewTileDownloader::requestTile(MapViewTypes::TileIndex index) {
|
||||
if (!provider) return;
|
||||
provider->requestTile(index);
|
||||
}
|
||||
|
||||
|
||||
void MapViewTileDownloader::tileReady(OSM::TileIndex index, QPixmap pm) {
|
||||
void MapViewTileDownloader::tileReady(MapViewTypes::TileIndex index, QPixmap pm) {
|
||||
if (!pm.isNull()) parent->cache->tileDownloaded(index, pm);
|
||||
cond_mutex.lock();
|
||||
in_progress.remove(index.hash());
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#define mapview_tile_downloader_h
|
||||
|
||||
#include "mapview_tile_provider_base.h"
|
||||
#include "osm_types_p.h"
|
||||
#include "mapview_types.h"
|
||||
|
||||
#include <QMutex>
|
||||
#include <QNetworkAccessManager>
|
||||
@@ -43,8 +43,8 @@ public:
|
||||
explicit MapViewTileDownloader(MapView * p);
|
||||
~MapViewTileDownloader();
|
||||
|
||||
bool queueTile(OSM::TileIndex index, bool force = false);
|
||||
void queueTiles(QList<OSM::TileIndex> indeces);
|
||||
bool queueTile(MapViewTypes::TileIndex index, bool force = false);
|
||||
void queueTiles(QList<MapViewTypes::TileIndex> indeces);
|
||||
void clearQueue();
|
||||
|
||||
void setTileProvider(MapViewTileProviderBase * p);
|
||||
@@ -52,19 +52,19 @@ public:
|
||||
|
||||
private:
|
||||
void run() override;
|
||||
void requestTile(OSM::TileIndex index);
|
||||
void requestTile(MapViewTypes::TileIndex index);
|
||||
|
||||
MapView * parent;
|
||||
MapViewTileProviderBase * provider = nullptr;
|
||||
QWaitCondition cond;
|
||||
QMutex cond_mutex;
|
||||
QQueue<OSM::TileIndex> queue;
|
||||
QQueue<MapViewTypes::TileIndex> queue;
|
||||
QSet<quint64> in_progress;
|
||||
|
||||
public slots:
|
||||
|
||||
private slots:
|
||||
void tileReady(OSM::TileIndex index, QPixmap pm);
|
||||
void tileReady(MapViewTypes::TileIndex index, QPixmap pm);
|
||||
void parametersChanged();
|
||||
|
||||
signals:
|
||||
|
||||
@@ -20,9 +20,10 @@
|
||||
#ifndef mapview_tile_provider_base_h
|
||||
#define mapview_tile_provider_base_h
|
||||
|
||||
#include "osm_types_p.h"
|
||||
#include "mapview_types.h"
|
||||
#include "qad_map_export.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QPixmap>
|
||||
#include <pivaluetree.h>
|
||||
|
||||
@@ -37,10 +38,11 @@ public:
|
||||
const PIValueTree & getParameters() const { return parameters; }
|
||||
void setParameters(const PIValueTree & vt);
|
||||
|
||||
virtual QString name() const = 0;
|
||||
virtual bool requestTile(OSM::TileIndex index) = 0;
|
||||
virtual QSize tileSize() = 0;
|
||||
virtual QString name() const = 0;
|
||||
virtual bool requestTile(MapViewTypes::TileIndex index) = 0;
|
||||
virtual QSize tileSize() = 0;
|
||||
virtual QString cacheDir() const { return name(); }
|
||||
virtual int maximumLevel() const = 0;
|
||||
|
||||
protected:
|
||||
void initParameters(const PIValueTree & vt);
|
||||
@@ -52,7 +54,7 @@ private:
|
||||
PIValueTree parameters;
|
||||
|
||||
signals:
|
||||
void tileReady(OSM::TileIndex index, QPixmap pm);
|
||||
void tileReady(MapViewTypes::TileIndex index, QPixmap pm);
|
||||
void parametersChanged();
|
||||
};
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
MapViewTileProvider_MapTiler::MapViewTileProvider_MapTiler() {
|
||||
nam = new QNetworkAccessManager();
|
||||
PIValueTree p;
|
||||
p.addChild(PIValueTree("url", "https://api.maptiler.com/maps"));
|
||||
p.addChild(PIValueTree("url", "https://api.maptiler.com/tiles"));
|
||||
p.addChild(PIValueTree("key", ""));
|
||||
p.addChild(PIValueTree("tileset", ""));
|
||||
initParameters(p);
|
||||
@@ -27,16 +27,20 @@ QString MapViewTileProvider_MapTiler::name() const {
|
||||
}
|
||||
|
||||
|
||||
bool MapViewTileProvider_MapTiler::requestTile(OSM::TileIndex index) {
|
||||
bool MapViewTileProvider_MapTiler::requestTile(MapViewTypes::TileIndex index) {
|
||||
QNetworkRequest req(url + QString("/%1/%2/%3/%4.jpg?key=%5").arg(tileset).arg(index.z).arg(index.x).arg(index.y).arg(key));
|
||||
req.setHeader(QNetworkRequest::UserAgentHeader, "Qt/5");
|
||||
auto * r = nam->get(req);
|
||||
if (!r) return false;
|
||||
// qDebug() << "Reqst:" << index.z << index.x << index.y;
|
||||
// qDebug() << "Reqst:" << index.z << index.x << index.y << req.url().toString();
|
||||
connect(r, &QNetworkReply::finished, this, [this, r, index]() {
|
||||
r->deleteLater();
|
||||
QPixmap tim;
|
||||
if (r->error() != QNetworkReply::NoError) {
|
||||
if (r->error() == QNetworkReply::ContentAccessDenied) {
|
||||
qDebug() << "Error:" << index.z << index.x << index.y << r->error();
|
||||
return;
|
||||
}
|
||||
qDebug() << "Retry:" << index.z << index.x << index.y << r->error();
|
||||
QTimer::singleShot(500, this, [this, index] { requestTile(index); });
|
||||
return;
|
||||
@@ -63,6 +67,11 @@ QString MapViewTileProvider_MapTiler::cacheDir() const {
|
||||
}
|
||||
|
||||
|
||||
int MapViewTileProvider_MapTiler::maximumLevel() const {
|
||||
return 20;
|
||||
}
|
||||
|
||||
|
||||
void MapViewTileProvider_MapTiler::applyParameters() {
|
||||
url = PI2QString(getParameters().childValue("url").toString());
|
||||
key = PI2QString(getParameters().childValue("key").toString());
|
||||
|
||||
@@ -33,9 +33,10 @@ public:
|
||||
~MapViewTileProvider_MapTiler();
|
||||
|
||||
QString name() const override;
|
||||
bool requestTile(OSM::TileIndex index) override;
|
||||
bool requestTile(MapViewTypes::TileIndex index) override;
|
||||
QSize tileSize() override;
|
||||
QString cacheDir() const override;
|
||||
int maximumLevel() const override;
|
||||
|
||||
protected:
|
||||
void applyParameters() override;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
MapViewTileProvider_OSM::MapViewTileProvider_OSM() {
|
||||
nam = new QNetworkAccessManager();
|
||||
PIValueTree p;
|
||||
p.addChild(PIValueTree("url", "http://tile.openstreetmap.org"));
|
||||
p.addChild(PIValueTree("url", "https://tile.openstreetmap.org"));
|
||||
initParameters(p);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ QString MapViewTileProvider_OSM::name() const {
|
||||
}
|
||||
|
||||
|
||||
bool MapViewTileProvider_OSM::requestTile(OSM::TileIndex index) {
|
||||
bool MapViewTileProvider_OSM::requestTile(MapViewTypes::TileIndex index) {
|
||||
QNetworkRequest req(url + QString("/%1/%2/%3.png").arg(index.z).arg(index.x).arg(index.y));
|
||||
req.setHeader(QNetworkRequest::UserAgentHeader, "Qt/5");
|
||||
auto * r = nam->get(req);
|
||||
@@ -51,6 +51,11 @@ QSize MapViewTileProvider_OSM::tileSize() {
|
||||
}
|
||||
|
||||
|
||||
int MapViewTileProvider_OSM::maximumLevel() const {
|
||||
return 19;
|
||||
}
|
||||
|
||||
|
||||
void MapViewTileProvider_OSM::applyParameters() {
|
||||
url = PI2QString(getParameters().childValue("url").toString());
|
||||
}
|
||||
|
||||
@@ -33,8 +33,9 @@ public:
|
||||
~MapViewTileProvider_OSM();
|
||||
|
||||
QString name() const override;
|
||||
bool requestTile(OSM::TileIndex index) override;
|
||||
bool requestTile(MapViewTypes::TileIndex index) override;
|
||||
QSize tileSize() override;
|
||||
int maximumLevel() const override;
|
||||
|
||||
protected:
|
||||
void applyParameters() override;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
QAD - Qt ADvanced
|
||||
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
@@ -17,11 +17,11 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "osm_types_p.h"
|
||||
#include "mapview_types.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
using namespace OSM;
|
||||
using namespace MapViewTypes;
|
||||
|
||||
|
||||
QString TileIndex ::hashName() const {
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
QAD - Qt ADvanced
|
||||
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
@@ -17,15 +17,17 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef osm_types_h
|
||||
#define osm_types_h
|
||||
#ifndef mapview_types_h
|
||||
#define mapview_types_h
|
||||
|
||||
#include "qad_map_export.h"
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QPixmap>
|
||||
|
||||
namespace OSM {
|
||||
namespace MapViewTypes {
|
||||
|
||||
struct TileIndex {
|
||||
struct QAD_MAP_EXPORT TileIndex {
|
||||
int z;
|
||||
int x;
|
||||
int y;
|
||||
@@ -34,7 +36,7 @@ struct TileIndex {
|
||||
QString cacheDir() const;
|
||||
};
|
||||
|
||||
struct TilePixmap {
|
||||
struct QAD_MAP_EXPORT TilePixmap {
|
||||
TileIndex index;
|
||||
QPixmap pixmap;
|
||||
bool obsolete = false;
|
||||
@@ -50,9 +52,9 @@ inline bool operator==(const TilePixmap & v0, const TilePixmap & v1) {
|
||||
return v0.index == v1.index;
|
||||
}
|
||||
|
||||
} // namespace OSM
|
||||
} // namespace MapViewTypes
|
||||
|
||||
Q_DECLARE_METATYPE(OSM::TileIndex);
|
||||
Q_DECLARE_METATYPE(OSM::TilePixmap);
|
||||
Q_DECLARE_METATYPE(MapViewTypes::TileIndex);
|
||||
Q_DECLARE_METATYPE(MapViewTypes::TilePixmap);
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "mapplugin.h"
|
||||
|
||||
#include "mapview.h"
|
||||
#include "mapview_tile_provider_osm.h"
|
||||
|
||||
#include <QtCore/QtPlugin>
|
||||
|
||||
@@ -26,6 +27,7 @@ bool MapPlugin::isInitialized() const {
|
||||
|
||||
QWidget * MapPlugin::createWidget(QWidget * parent) {
|
||||
MapView * w = new MapView(parent);
|
||||
w->setTileProvider(new MapViewTileProvider_OSM());
|
||||
return w;
|
||||
}
|
||||
|
||||
|
||||
@@ -887,6 +887,32 @@ inline PICout operator<<(PICout s, const QColor & v) {
|
||||
return s;
|
||||
}
|
||||
|
||||
inline PICout operator<<(PICout s, const QVector2D & v) {
|
||||
s << PIMathVectorT2d({v[0], v[1]});
|
||||
return s;
|
||||
}
|
||||
|
||||
inline PICout operator<<(PICout s, const QVector3D & v) {
|
||||
s << PIMathVectorT3d({v[0], v[1], v[2]});
|
||||
return s;
|
||||
}
|
||||
|
||||
inline PICout operator<<(PICout s, const QVector4D & v) {
|
||||
s << PIMathVectorT4d({v[0], v[1], v[2], v[3]});
|
||||
return s;
|
||||
}
|
||||
|
||||
template<int N, int M, typename T>
|
||||
inline PICout operator<<(PICout s, const QGenericMatrix<N, M, T> & v) {
|
||||
s << Q2PIMathMatrixT(v);
|
||||
return s;
|
||||
}
|
||||
|
||||
inline PICout operator<<(PICout s, const QMatrix4x4 & v) {
|
||||
s << Q2PIMathMatrixT(v);
|
||||
return s;
|
||||
}
|
||||
|
||||
#ifdef PIQT_HAS_GEOPOSITION
|
||||
inline PICout operator<<(PICout s, const QGeoCoordinate & v) {
|
||||
s << Q2PIGeoPosition(v);
|
||||
|
||||
@@ -608,7 +608,7 @@ void PIValueTreeEdit::applyVariantEdit(PIVariantEdit * ve, const PIValueTree & v
|
||||
ve->setAttributes(attributesWithRO(vt.attributes()));
|
||||
ve->setValue(vt.value());
|
||||
ve->setFullEditMode(is_full_edit);
|
||||
ve->setToolTip(PI2QString(vt.attribute(PIValueTree::Attribute::toolTip).toString()));
|
||||
ve->setToolTip(PIVariantEditorBase::vtTr(vt.attribute(PIValueTree::Attribute::toolTip).toString()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <QHeaderView>
|
||||
#include <QKeyEvent>
|
||||
#include <QScreen>
|
||||
|
||||
|
||||
QCodeEditCompleter::QCodeEditCompleter(QWidget * parent): QTreeWidget(parent) {
|
||||
@@ -79,8 +80,13 @@ void QCodeEditCompleter::invoke(QPoint global_pos) {
|
||||
setCurrentItem(topLevelItem(1));
|
||||
if (isHidden()) move(global_pos);
|
||||
if (topLevelItemCount() > 0) {
|
||||
const auto screen = qApp->screenAt(global_pos);
|
||||
setVisible(true);
|
||||
adjust();
|
||||
if (global_pos.y() + height() > screen->availableSize().height()) {
|
||||
global_pos.setY(global_pos.y() -height() - fontHeight(this));
|
||||
}
|
||||
move(global_pos);
|
||||
} else {
|
||||
hide();
|
||||
}
|
||||
|
||||
@@ -97,6 +97,8 @@ void SessionManager::save() {
|
||||
sr.setValue(buttons[i].first, buttons[i].second->isChecked(), false);
|
||||
for (int i = 0; i < stacks.size(); ++i)
|
||||
sr.setValue(stacks[i].first, stacks[i].second->currentIndex(), false);
|
||||
for (int i = 0; i < sliders.size(); ++i)
|
||||
sr.setValue(sliders[i].first, sliders[i].second->value(), false);
|
||||
for (int i = 0; i < actions.size(); ++i)
|
||||
sr.setValue(actions[i].first, actions[i].second->isChecked(), false);
|
||||
for (int i = 0; i < stringlists.size(); ++i)
|
||||
@@ -221,6 +223,8 @@ void SessionManager::load(bool onlyMainwindow) {
|
||||
for (int i = 0; i < stacks.size(); ++i)
|
||||
stacks[i].second->setCurrentIndex(
|
||||
qMin<int>(sr.getValue(stacks[i].first, stacks[i].second->currentIndex()).toInt(), stacks[i].second->count()));
|
||||
for (int i = 0; i < sliders.size(); ++i)
|
||||
sliders[i].second->setValue(sr.getValue(sliders[i].first, sliders[i].second->value()).toInt());
|
||||
for (int i = 0; i < actions.size(); ++i)
|
||||
actions[i].second->setChecked(sr.getValue(actions[i].first, actions[i].second->isChecked()).toBool());
|
||||
for (int i = 0; i < stringlists.size(); ++i)
|
||||
@@ -267,6 +271,7 @@ void SessionManager::clear(bool with_filename) {
|
||||
tabs.clear();
|
||||
buttons.clear();
|
||||
stacks.clear();
|
||||
sliders.clear();
|
||||
actions.clear();
|
||||
stringlists.clear();
|
||||
strings.clear();
|
||||
|
||||
@@ -66,6 +66,7 @@ public:
|
||||
void addEntry(QAction * e) { addEntry(e->objectName(), e); }
|
||||
void addEntry(QAbstractButton * e) { addEntry(e->objectName(), e); }
|
||||
void addEntry(QStackedWidget * e) { addEntry(e->objectName(), e); }
|
||||
void addEntry(QSlider * e) { addEntry(e->objectName(), e); }
|
||||
void addMainWidget(QWidget * e) { addMainWidget(e->objectName(), e); }
|
||||
void removeMainWidget(QWidget * e);
|
||||
|
||||
@@ -81,6 +82,7 @@ public:
|
||||
void addEntry(const QString & name, QGroupBox * e) { groups.push_back(QPair<QString, QGroupBox *>(name, e)); }
|
||||
void addEntry(const QString & name, QAbstractButton * e) { buttons.push_back(QPair<QString, QAbstractButton *>(name, e)); }
|
||||
void addEntry(const QString & name, QStackedWidget * e) { stacks.push_back(QPair<QString, QStackedWidget *>(name, e)); }
|
||||
void addEntry(const QString & name, QSlider * e) { sliders.push_back(QPair<QString, QSlider *>(name, e)); }
|
||||
void addEntry(const QString & name, QAction * e) { actions.push_back(QPair<QString, QAction *>(name, e)); }
|
||||
void addEntry(const QString & name, QStringList * e) { stringlists.push_back(QPair<QString, QStringList *>(name, e)); }
|
||||
void addEntry(const QString & name, QString * e) { strings.push_back(QPair<QString, QString *>(name, e)); }
|
||||
@@ -106,6 +108,7 @@ private:
|
||||
QVector<QPair<QString, QGroupBox *>> groups;
|
||||
QVector<QPair<QString, QAbstractButton *>> buttons;
|
||||
QVector<QPair<QString, QStackedWidget *>> stacks;
|
||||
QVector<QPair<QString, QSlider *>> sliders;
|
||||
QVector<QPair<QString, QAction *>> actions;
|
||||
QVector<QPair<QString, QStringList *>> stringlists;
|
||||
QVector<QPair<QString, QString *>> strings;
|
||||
|
||||
Reference in New Issue
Block a user