1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 11:45:53 +01:00

Compare commits

..

No commits in common. "ca1c5765628aaabf548a8f17632812f653ffb04d" and "af0bb2e2689899a848c7d52f5b4bf803d77e47fe" have entirely different histories.

15 changed files with 30 additions and 147 deletions

View File

@ -1,4 +1,4 @@
version: 11.1.{build} version: 11.0.{build}
configuration: configuration:
- Release - Release

View File

@ -3,7 +3,7 @@ unix:!macx:!android {
} else { } else {
TARGET = GPXSee TARGET = GPXSee
} }
VERSION = 11.1 VERSION = 11.0
QT += core \ QT += core \
gui \ gui \

View File

@ -37,7 +37,7 @@ Unicode true
; The name of the installer ; The name of the installer
Name "GPXSee" Name "GPXSee"
; Program version ; Program version
!define VERSION "11.1" !define VERSION "11.0"
; The file to write ; The file to write
OutFile "GPXSee-${VERSION}_x64.exe" OutFile "GPXSee-${VERSION}_x64.exe"

View File

@ -2477,8 +2477,8 @@ void GUI::writeSettings()
settings.setValue(SHOW_TICKS_SETTING, settings.setValue(SHOW_TICKS_SETTING,
_showTicksAction->isChecked()); _showTicksAction->isChecked());
bool sm = _showMarkersAction->isChecked() bool sm = _showMarkersAction->isChecked()
|| _showMarkerDateAction->isChecked() | _showMarkerDateAction->isChecked()
|| _showMarkerCoordinatesAction->isChecked(); | _showMarkerCoordinatesAction->isChecked();
if (sm != SHOW_MARKERS_DEFAULT) if (sm != SHOW_MARKERS_DEFAULT)
settings.setValue(SHOW_MARKERS_SETTING, sm); settings.setValue(SHOW_MARKERS_SETTING, sm);
if (_showMarkerDateAction->isChecked() if (_showMarkerDateAction->isChecked()

View File

@ -663,8 +663,7 @@ void MapView::wheelEvent(QWheelEvent *event)
zoom((delta > 0) ? 1 : -1, event->position().toPoint(), shift); zoom((delta > 0) ? 1 : -1, event->position().toPoint(), shift);
#endif // QT 5.15 #endif // QT 5.15
/* Do not call QGraphicsView::wheelEvent() here as this would shift the QGraphicsView::wheelEvent(event);
view ! */
} }
void MapView::keyPressEvent(QKeyEvent *event) void MapView::keyPressEvent(QKeyEvent *event)

View File

@ -1,8 +1,7 @@
#include "navigationwidget.h"
#include <QEvent> #include <QEvent>
#include <QResizeEvent> #include <QResizeEvent>
#include <QPainter> #include <QPainter>
#include "mapview.h"
#include "navigationwidget.h"
#define MARGIN 5 #define MARGIN 5
#define SIZE 40 #define SIZE 40

View File

@ -2,8 +2,7 @@
#define NAVIGATIONWIDGET_H #define NAVIGATIONWIDGET_H
#include <QWidget> #include <QWidget>
#include "mapview.h"
class MapView;
#ifdef Q_OS_ANDROID #ifdef Q_OS_ANDROID
class NavigationWidget : public QWidget class NavigationWidget : public QWidget

View File

@ -717,7 +717,7 @@ QWidget *OptionsDialog::createSystemPage()
_pixmapCache = new QSpinBox(); _pixmapCache = new QSpinBox();
_pixmapCache->setMinimum(16); _pixmapCache->setMinimum(16);
_pixmapCache->setMaximum(2048); _pixmapCache->setMaximum(1024);
_pixmapCache->setSuffix(UNIT_SPACE + tr("MB")); _pixmapCache->setSuffix(UNIT_SPACE + tr("MB"));
_pixmapCache->setValue(_options.pixmapCache); _pixmapCache->setValue(_options.pixmapCache);

View File

@ -217,11 +217,7 @@
#define ENABLE_HTTP2_SETTING "enableHTTP2" #define ENABLE_HTTP2_SETTING "enableHTTP2"
#define ENABLE_HTTP2_DEFAULT true #define ENABLE_HTTP2_DEFAULT true
#define PIXMAP_CACHE_SETTING "pixmapCache" #define PIXMAP_CACHE_SETTING "pixmapCache"
#ifdef Q_OS_ANDROID
#define PIXMAP_CACHE_DEFAULT 256 /* MB */ #define PIXMAP_CACHE_DEFAULT 256 /* MB */
#else // Q_OS_ANDROID
#define PIXMAP_CACHE_DEFAULT 512 /* MB */
#endif // Q_OS_ANDROID
#define CONNECTION_TIMEOUT_SETTING "connectionTimeout" #define CONNECTION_TIMEOUT_SETTING "connectionTimeout"
#define CONNECTION_TIMEOUT_DEFAULT 30 /* s */ #define CONNECTION_TIMEOUT_DEFAULT 30 /* s */
#define HIRES_PRINT_SETTING "hiresPrint" #define HIRES_PRINT_SETTING "hiresPrint"

View File

@ -174,8 +174,6 @@ void RasterTile::render()
qDeleteAll(textItems); qDeleteAll(textItems);
_valid = true;
//painter.setPen(Qt::red); //painter.setPen(Qt::red);
//painter.setRenderHint(QPainter::Antialiasing, false); //painter.setRenderHint(QPainter::Antialiasing, false);
//painter.drawRect(QRect(_xy, _pixmap.size())); //painter.drawRect(QRect(_xy, _pixmap.size()));
@ -187,7 +185,7 @@ void RasterTile::ll2xy(QList<MapData::Poly> &polys)
MapData::Poly &poly = polys[i]; MapData::Poly &poly = polys[i];
for (int j = 0; j < poly.points.size(); j++) { for (int j = 0; j < poly.points.size(); j++) {
QPointF &p = poly.points[j]; QPointF &p = poly.points[j];
p = ll2xy(Coordinates(p.x(), p.y())); p = _map->ll2xy(Coordinates(p.x(), p.y()));
} }
} }
} }
@ -195,7 +193,7 @@ void RasterTile::ll2xy(QList<MapData::Poly> &polys)
void RasterTile::ll2xy(QList<MapData::Point> &points) void RasterTile::ll2xy(QList<MapData::Point> &points)
{ {
for (int i = 0; i < points.size(); i++) { for (int i = 0; i < points.size(); i++) {
QPointF p(ll2xy(points.at(i).coordinates)); QPointF p(_map->ll2xy(points.at(i).coordinates));
points[i].coordinates = Coordinates(p.x(), p.y()); points[i].coordinates = Coordinates(p.x(), p.y());
} }
} }
@ -212,8 +210,8 @@ void RasterTile::drawPolygons(QPainter *painter)
if (poly.raster.isValid()) { if (poly.raster.isValid()) {
RectC r(poly.raster.rect()); RectC r(poly.raster.rect());
QPointF tl(ll2xy(r.topLeft())); QPointF tl(_map->ll2xy(r.topLeft()));
QPointF br(ll2xy(r.bottomRight())); QPointF br(_map->ll2xy(r.bottomRight()));
QSizeF size(QRectF(tl, br).size()); QSizeF size(QRectF(tl, br).size());
bool insert = false; bool insert = false;

View File

@ -3,8 +3,6 @@
#include <QPixmap> #include <QPixmap>
#include "mapdata.h" #include "mapdata.h"
#include "map/projection.h"
#include "map/transform.h"
class QPainter; class QPainter;
class IMGMap; class IMGMap;
@ -17,25 +15,20 @@ class Style;
class RasterTile class RasterTile
{ {
public: public:
RasterTile(const Projection &proj, const Transform &transform, RasterTile(IMGMap *map, const Style *style, int zoom, const QRect &rect,
const Style *style, int zoom, const QRect &rect, qreal ratio, qreal ratio, const QString &key, const QList<MapData::Poly> &polygons,
const QString &key, const QList<MapData::Poly> &polygons,
const QList<MapData::Poly> &lines, QList<MapData::Point> &points) const QList<MapData::Poly> &lines, QList<MapData::Point> &points)
: _proj(proj), _transform(transform), _style(style), _zoom(zoom), : _map(map), _style(style), _zoom(zoom), _rect(rect), _ratio(ratio),
_rect(rect), _ratio(ratio), _key(key), _key(key), _pixmap(rect.width() * ratio, rect.height() * ratio),
_pixmap(rect.width() * ratio, rect.height() * ratio), _polygons(polygons), _polygons(polygons), _lines(lines), _points(points) {}
_lines(lines), _points(points), _valid(false) {}
const QString &key() const {return _key;} const QString &key() const {return _key;}
QPoint xy() const {return _rect.topLeft();} QPoint xy() const {return _rect.topLeft();}
const QPixmap &pixmap() const {return _pixmap;} const QPixmap &pixmap() const {return _pixmap;}
bool isValid() const {return _valid;}
void render(); void render();
private: private:
QPointF ll2xy(const Coordinates &c) const
{return _transform.proj2img(_proj.ll2xy(c));}
void ll2xy(QList<MapData::Poly> &polys); void ll2xy(QList<MapData::Poly> &polys);
void ll2xy(QList<MapData::Point> &points); void ll2xy(QList<MapData::Point> &points);
@ -49,8 +42,7 @@ private:
void processShields(QList<TextItem*> &textItems); void processShields(QList<TextItem*> &textItems);
void processStreetNames(QList<TextItem*> &textItems); void processStreetNames(QList<TextItem*> &textItems);
Projection _proj; IMGMap *_map;
Transform _transform;
const Style *_style; const Style *_style;
int _zoom; int _zoom;
QRect _rect; QRect _rect;
@ -60,7 +52,6 @@ private:
QList<MapData::Poly> _polygons; QList<MapData::Poly> _polygons;
QList<MapData::Poly> _lines; QList<MapData::Poly> _lines;
QList<MapData::Point> _points; QList<MapData::Point> _points;
bool _valid;
}; };
} }

View File

@ -100,8 +100,6 @@ int IMGMap::zoomFit(const QSize &size, const RectC &rect)
int IMGMap::zoomIn() int IMGMap::zoomIn()
{ {
cancelJobs();
_zoom = qMin(_zoom + 1, _data.first()->zooms().max()); _zoom = qMin(_zoom + 1, _data.first()->zooms().max());
updateTransform(); updateTransform();
return _zoom; return _zoom;
@ -109,8 +107,6 @@ int IMGMap::zoomIn()
int IMGMap::zoomOut() int IMGMap::zoomOut()
{ {
cancelJobs();
_zoom = qMax(_zoom - 1, _data.first()->zooms().min()); _zoom = qMax(_zoom - 1, _data.first()->zooms().min());
updateTransform(); updateTransform();
return _zoom; return _zoom;
@ -143,55 +139,10 @@ void IMGMap::updateTransform()
_bounds.adjust(0.5, 0, -0.5, 0); _bounds.adjust(0.5, 0, -0.5, 0);
} }
bool IMGMap::isRunning(const QString &key) const
{
for (int i = 0; i < _jobs.size(); i++) {
const QList<IMG::RasterTile> &tiles = _jobs.at(i)->tiles();
for (int j = 0; j < tiles.size(); j++)
if (tiles.at(j).key() == key)
return true;
}
return false;
}
void IMGMap::runJob(IMGMapJob *job)
{
_jobs.append(job);
connect(job, &IMGMapJob::finished, this, &IMGMap::jobFinished);
job->run();
}
void IMGMap::removeJob(IMGMapJob *job)
{
_jobs.removeOne(job);
job->deleteLater();
}
void IMGMap::jobFinished(IMGMapJob *job)
{
const QList<IMG::RasterTile> &tiles = job->tiles();
for (int i = 0; i < tiles.size(); i++) {
const IMG::RasterTile &mt = tiles.at(i);
if (mt.isValid())
QPixmapCache::insert(mt.key(), mt.pixmap());
}
removeJob(job);
emit tilesLoaded();
}
void IMGMap::cancelJobs()
{
for (int i = 0; i < _jobs.size(); i++)
_jobs.at(i)->cancel();
}
void IMGMap::draw(QPainter *painter, const QRectF &rect, Flags flags) void IMGMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
{ {
Q_UNUSED(flags);
QPointF tl(floor(rect.left() / TILE_SIZE) QPointF tl(floor(rect.left() / TILE_SIZE)
* TILE_SIZE, floor(rect.top() / TILE_SIZE) * TILE_SIZE); * TILE_SIZE, floor(rect.top() / TILE_SIZE) * TILE_SIZE);
QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y()); QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y());
@ -208,9 +159,6 @@ void IMGMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
QString key(_data.at(n)->fileName() + "-" + QString::number(_zoom) QString key(_data.at(n)->fileName() + "-" + QString::number(_zoom)
+ "_" + QString::number(ttl.x()) + "_" + QString::number(ttl.y())); + "_" + QString::number(ttl.x()) + "_" + QString::number(ttl.y()));
if (isRunning(key))
continue;
if (QPixmapCache::find(key, &pm)) if (QPixmapCache::find(key, &pm))
painter->drawPixmap(ttl, pm); painter->drawPixmap(ttl, pm);
else { else {
@ -234,8 +182,7 @@ void IMGMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
_data.at(n)->points(pointRectD.toRectC(_projection, 20), _data.at(n)->points(pointRectD.toRectC(_projection, 20),
_zoom, &points); _zoom, &points);
tiles.append(RasterTile(_projection, _transform, tiles.append(RasterTile(this, _data.at(n)->style(), _zoom,
_data.at(n)->style(), _zoom,
QRect(ttl, QSize(TILE_SIZE, TILE_SIZE)), _tileRatio, key, QRect(ttl, QSize(TILE_SIZE, TILE_SIZE)), _tileRatio, key,
polygons, lines, points)); polygons, lines, points));
} }
@ -243,8 +190,6 @@ void IMGMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
} }
} }
if (!tiles.isEmpty()) {
if (flags & Map::Block) {
QFuture<void> future = QtConcurrent::map(tiles, &RasterTile::render); QFuture<void> future = QtConcurrent::map(tiles, &RasterTile::render);
future.waitForFinished(); future.waitForFinished();
@ -254,9 +199,6 @@ void IMGMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
painter->drawPixmap(mt.xy(), pm); painter->drawPixmap(mt.xy(), pm);
QPixmapCache::insert(mt.key(), pm); QPixmapCache::insert(mt.key(), pm);
} }
} else
runJob(new IMGMapJob(tiles));
}
} }
void IMGMap::setDevicePixelRatio(qreal deviceRatio, qreal mapRatio) void IMGMap::setDevicePixelRatio(qreal deviceRatio, qreal mapRatio)

View File

@ -1,44 +1,12 @@
#ifndef IMGMAP_H #ifndef IMGMAP_H
#define IMGMAP_H #define IMGMAP_H
#include <QtConcurrent>
#include "map.h" #include "map.h"
#include "projection.h" #include "projection.h"
#include "transform.h" #include "transform.h"
#include "IMG/mapdata.h" #include "IMG/mapdata.h"
#include "IMG/rastertile.h"
class IMGMapJob : public QObject
{
Q_OBJECT
public:
IMGMapJob(const QList<IMG::RasterTile> &tiles)
: _tiles(tiles) {}
void run()
{
connect(&_watcher, &QFutureWatcher<void>::finished, this,
&IMGMapJob::handleFinished);
_future = QtConcurrent::map(_tiles, &IMG::RasterTile::render);
_watcher.setFuture(_future);
}
void cancel() {_future.cancel();}
const QList<IMG::RasterTile> &tiles() const {return _tiles;}
signals:
void finished(IMGMapJob *job);
private slots:
void handleFinished() {emit finished(this);}
private:
QFutureWatcher<void> _watcher;
QFuture<void> _future;
QList<IMG::RasterTile> _tiles;
};
class IMGMap : public Map class IMGMap : public Map
{ {
Q_OBJECT Q_OBJECT
@ -76,16 +44,9 @@ public:
static Map* create(const QString &path, const Projection &, bool *isDir); static Map* create(const QString &path, const Projection &, bool *isDir);
private slots:
void jobFinished(IMGMapJob *job);
private: private:
Transform transform(int zoom) const; Transform transform(int zoom) const;
void updateTransform(); void updateTransform();
bool isRunning(const QString &key) const;
void runJob(IMGMapJob *job);
void removeJob(IMGMapJob *job);
void cancelJobs();
QList<IMG::MapData *> _data; QList<IMG::MapData *> _data;
int _zoom; int _zoom;
@ -95,8 +56,6 @@ private:
RectC _dataBounds; RectC _dataBounds;
qreal _tileRatio; qreal _tileRatio;
QList<IMGMapJob*> _jobs;
bool _valid; bool _valid;
QString _errorString; QString _errorString;
}; };

View File

@ -1,5 +1,4 @@
#include <QPainter> #include <QPainter>
#include <QPixmapCache>
#include "common/wgs84.h" #include "common/wgs84.h"
#include "pcs.h" #include "pcs.h"
#include "rectd.h" #include "rectd.h"

View File

@ -2,6 +2,7 @@
#define MAPSFORGEMAP_H #define MAPSFORGEMAP_H
#include <QtConcurrent> #include <QtConcurrent>
#include <QPixmapCache>
#include "mapsforge/mapdata.h" #include "mapsforge/mapdata.h"
#include "mapsforge/rastertile.h" #include "mapsforge/rastertile.h"
#include "projection.h" #include "projection.h"