1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-07-24 15:34:24 +02:00

Compare commits

..

14 Commits

Author SHA1 Message Date
9a8070bd06 Added missing hillshading cleanup 2024-11-03 17:59:25 +01:00
b721a829b2 Code cleanup 2024-11-01 09:16:32 +01:00
244a7670e7 Increase the distance precision for tracks < 10km/nm/nmi to two decimal digits 2024-10-31 01:31:08 +01:00
3ec36336c1 Added missing label text checks 2024-10-29 00:35:41 +01:00
86b85e5afc Limit area labels to one per tile 2024-10-28 13:00:56 +01:00
77f51098f6 Code cleanup
While QWidget:palette() and QPalette() should technically provide the same
results due to the way how the default QPalette gets applied, make it clean
and obvious what we want to achieve.
2024-10-23 18:31:56 +02:00
4848190377 Includes cleanup 2024-10-23 08:01:45 +02:00
6da8ec3525 Micro-optimization 2024-10-23 08:01:14 +02:00
5a71deda15 Optimization 2024-10-22 09:06:09 +02:00
5b5e00038f Code cleanup 2024-10-22 07:43:42 +02:00
b348ad6288 DEM locking cleanup 2024-10-21 23:05:09 +02:00
e2b6dcf8d3 Merge branch 'origin/master' into Weblate. 2024-10-20 19:22:29 +02:00
776104a9fa Add missing English localization to the NSIS installer
Add missing English localization to the NSIS installer and rename the "zh"
translation file to "zh_CN" due to Taiwan having it's own language variant
(available as QT core translation).

The existence (copy during install) of the "en" translation file should
hopefully fix #569.
2024-10-20 19:15:01 +02:00
941aa6d83b Translated using Weblate (Hungarian)
Currently translated at 100.0% (488 of 488 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/hu/
2024-10-20 18:22:11 +02:00
20 changed files with 111 additions and 85 deletions

View File

@ -494,7 +494,7 @@ TRANSLATIONS = lang/gpxsee_en.ts \
lang/gpxsee_hu.ts \
lang/gpxsee_it.ts \
lang/gpxsee_eo.ts \
lang/gpxsee_zh.ts \
lang/gpxsee_zh_CN.ts \
lang/gpxsee_ca.ts \
lang/gpxsee_ko.ts

View File

@ -117,7 +117,7 @@
<message>
<location filename="../src/data/data.cpp" line="169"/>
<source>JPEG images</source>
<translation>JPEG fájlok</translation>
<translation>JPEG képek</translation>
</message>
<message>
<location filename="../src/data/data.cpp" line="170"/>
@ -295,7 +295,7 @@
<location filename="../src/GUI/fileselectwidget.cpp" line="46"/>
<location filename="../src/GUI/fileselectwidget.cpp" line="51"/>
<source>Select file</source>
<translation>Fájl választása</translation>
<translation>Fájl kiválasztása</translation>
</message>
<message>
<location filename="../src/GUI/fileselectwidget.cpp" line="61"/>
@ -305,12 +305,12 @@
<message>
<location filename="../src/GUI/fileselectwidget.cpp" line="71"/>
<source>%1 is a directory.</source>
<translation>A(z) %1 egy mappa.</translation>
<translation>%1 egy mappa.</translation>
</message>
<message>
<location filename="../src/GUI/fileselectwidget.cpp" line="75"/>
<source>%1 is not writable.</source>
<translation>A(z) %1 írásvédett.</translation>
<translation>%1 írásvédett.</translation>
</message>
</context>
<context>
@ -356,7 +356,7 @@
<location filename="../src/GUI/gui.cpp" line="974"/>
<location filename="../src/GUI/gui.cpp" line="992"/>
<source>Paths</source>
<translation>Adatmappák</translation>
<translation>Elérési útvonalak</translation>
</message>
<message>
<location filename="../src/GUI/gui.cpp" line="211"/>
@ -369,7 +369,7 @@
<location filename="../src/GUI/gui.cpp" line="215"/>
<location filename="../src/GUI/gui.cpp" line="901"/>
<source>About GPXSee</source>
<translation>GPXSee névjegye</translation>
<translation>A GPXSee névjegye</translation>
</message>
<message>
<location filename="../src/GUI/gui.cpp" line="221"/>
@ -429,7 +429,7 @@
<message>
<location filename="../src/GUI/gui.cpp" line="297"/>
<source>Unselect all files</source>
<translation>Összes kijelölés megszüntetése</translation>
<translation>Összes kijelölésének visszavonása</translation>
</message>
<message>
<location filename="../src/GUI/gui.cpp" line="302"/>

View File

@ -342,9 +342,10 @@ SectionEnd
SectionGroup "Localization" SEC_LOCALIZATION
!insertmacro LOCALIZATION "Catalan" "ca"
!insertmacro LOCALIZATION "Chinese (Simplified)" "zh"
!insertmacro LOCALIZATION "Chinese (Simplified)" "zh_CN"
!insertmacro LOCALIZATION "Czech" "cs"
!insertmacro LOCALIZATION "Danish" "da"
!insertmacro LOCALIZATION "English" "en"
!insertmacro LOCALIZATION "Esperanto" "eo"
!insertmacro LOCALIZATION "Finnish" "fi"
!insertmacro LOCALIZATION "French" "fr"

View File

@ -1,4 +1,4 @@
#include <QtWidgets>
#include <QWidget>
#include "flowlayout.h"
struct FlowLayoutItem

View File

@ -52,6 +52,9 @@ QString Format::distance(qreal value, Units units)
if (value < MIINM)
return l.toString(value * M2FT, 'f', 0) + UNIT_SPACE
+ qApp->translate("Format", "ft");
else if (value < 10 * MIINM)
return l.toString(value * M2MI, 'f', 2) + UNIT_SPACE
+ qApp->translate("Format", "mi");
else
return l.toString(value * M2MI, 'f', 1) + UNIT_SPACE
+ qApp->translate("Format", "mi");
@ -59,6 +62,9 @@ QString Format::distance(qreal value, Units units)
if (value < NMIINM)
return l.toString(value * M2FT, 'f', 0) + UNIT_SPACE
+ qApp->translate("Format", "ft");
else if (value < 10 * NMIINM)
return l.toString(value * M2NMI, 'f', 2) + UNIT_SPACE
+ qApp->translate("Format", "nmi");
else
return l.toString(value * M2NMI, 'f', 1) + UNIT_SPACE
+ qApp->translate("Format", "nmi");
@ -66,6 +72,9 @@ QString Format::distance(qreal value, Units units)
if (value < KMINM)
return l.toString(value, 'f', 0) + UNIT_SPACE
+ qApp->translate("Format", "m");
else if (value < 10 * KMINM)
return l.toString(value * M2KM, 'f', 2) + UNIT_SPACE
+ qApp->translate("Format", "km");
else
return l.toString(value * M2KM, 'f', 1) + UNIT_SPACE
+ qApp->translate("Format", "km");

View File

@ -46,6 +46,8 @@ static inline QPoint POS(QMouseEvent *e)
GraphView::GraphView(QWidget *parent)
: QGraphicsView(parent)
{
const QPalette &p = palette();
_scene = new GraphicsScene(this);
setScene(_scene);
@ -53,7 +55,7 @@ GraphView::GraphView(QWidget *parent)
setRenderHint(QPainter::Antialiasing, true);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setBackgroundBrush(QBrush(palette().brush(QPalette::Base)));
setBackgroundBrush(QBrush(p.brush(QPalette::Base)));
viewport()->setAttribute(Qt::WA_AcceptTouchEvents);
grabGesture(Qt::PinchGesture);
@ -72,8 +74,7 @@ GraphView::GraphView(QWidget *parent)
_info = new InfoItem();
_grid = new GridItem();
_message = new QGraphicsSimpleTextItem(tr("Data not available"));
_message->setBrush(QPalette().brush(QPalette::Disabled,
QPalette::WindowText));
_message->setBrush(p.brush(QPalette::Disabled, QPalette::WindowText));
connect(_slider, &SliderItem::positionChanged, this,
&GraphView::emitSliderPositionChanged);
@ -627,9 +628,9 @@ void GraphView::setSliderColor(const QColor &color)
void GraphView::changeEvent(QEvent *e)
{
if (e->type() == QEvent::PaletteChange) {
_message->setBrush(QPalette().brush(QPalette::Disabled,
QPalette::WindowText));
setBackgroundBrush(QBrush(palette().brush(QPalette::Base)));
const QPalette &p = palette();
_message->setBrush(p.brush(QPalette::Disabled, QPalette::WindowText));
setBackgroundBrush(QBrush(p.brush(QPalette::Base)));
}
QGraphicsView::changeEvent(e);

View File

@ -2019,10 +2019,7 @@ void GUI::demLoaded()
}
_demRects.clear();
DEM::lock();
DEM::clearCache();
DEM::unlock();
reloadFiles();
reloadMap();
@ -3070,9 +3067,7 @@ void GUI::loadOptions()
Downloader::setTimeout(_options.connectionTimeout);
QPixmapCache::setCacheLimit(_options.pixmapCache * 1024);
DEM::lock();
DEM::setCacheSize(_options.demCache * 1024);
DEM::unlock();
HillShading::setAlpha(_options.hillshadingAlpha);
HillShading::setBlur(_options.hillshadingBlur);
@ -3211,11 +3206,8 @@ void GUI::updateOptions(const Options &options)
if (options.pixmapCache != _options.pixmapCache)
QPixmapCache::setCacheLimit(options.pixmapCache * 1024);
if (options.demCache != _options.demCache) {
DEM::lock();
if (options.demCache != _options.demCache)
DEM::setCacheSize(options.demCache * 1024);
DEM::unlock();
}
SET_HS_OPTION(hillshadingAlpha, setAlpha);
SET_HS_OPTION(hillshadingBlur, setBlur);

View File

@ -322,7 +322,7 @@ bool JLS::decode(const SubFile *file, SubFile::Handle &hdl, Matrix<qint16> &img)
if (!readLine(bs))
return false;
memcpy(&img.at(i, 0), _current + 1, _w * sizeof(quint16));
memcpy(img.row(i), _current + 1, _w * sizeof(quint16));
quint16 *tmp = _last;
_last = _current;

View File

@ -461,18 +461,15 @@ void RasterTile::fetchData(QList<MapData::Poly> &polygons,
MatrixD RasterTile::elevation(int extend) const
{
MatrixD m(_rect.height() + 2 * extend, _rect.width() + 2 * extend);
QVector<Coordinates> ll;
int left = _rect.left() - extend;
int right = _rect.right() + extend;
int top = _rect.top() - extend;
int bottom = _rect.bottom() + extend;
ll.reserve(m.w() * m.h());
for (int y = top; y <= bottom; y++)
for (int x = left; x <= right; x++)
ll.append(xy2ll(QPointF(x, y)));
MatrixC ll(_rect.height() + 2 * extend, _rect.width() + 2 * extend);
for (int y = top, i = 0; y <= bottom; y++)
for (int x = left; x <= right; x++, i++)
ll.at(i) = xy2ll(QPointF(x, y));
if (_data->hasDEM()) {
RectC rect;
@ -487,16 +484,13 @@ MatrixD RasterTile::elevation(int extend) const
-rect.height() / factor), _zoom, &tiles);
DEMTree tree(tiles);
MatrixD m(ll.h(), ll.w());
for (int i = 0; i < ll.size(); i++)
m.at(i) = tree.elevation(ll.at(i));
} else {
DEM::lock();
for (int i = 0; i < ll.size(); i++)
m.at(i) = DEM::elevation(ll.at(i));
DEM::unlock();
}
return m;
return m;
} else
return DEM::elevation(ll);
}
void RasterTile::drawHillShading(QPainter *painter) const

View File

@ -23,12 +23,20 @@
static unsigned int isqrt(unsigned int x)
{
unsigned int r = 0;
unsigned int l = 0;
unsigned int m;
unsigned int r = x + 1;
while ((r + 1) * (r + 1) <= x)
r++;
while (l != r - 1) {
m = (l + r) / 2;
return r;
if (m * m <= x)
l = m;
else
r = m;
}
return l;
}
static double interpolate(double dx, double dy, double p0, double p1, double p2,
@ -46,7 +54,6 @@ static double value(int col, int row, int samples, const QByteArray &data)
return (val == -32768) ? NAN : val;
}
QMutex DEM::_lock;
DEM::Entry::Entry(const QByteArray &data) : _data(data)
{
@ -70,12 +77,16 @@ QString DEM::Tile::fileName() const
return QString("%1%2.hgt").arg(latStr(), lonStr());
}
QMutex DEM::_lock;
QString DEM::_dir;
DEM::TileCache DEM::_data;
void DEM::setCacheSize(int size)
{
_lock.lock();
_data.setMaxCost(size);
_lock.unlock();
}
void DEM::setDir(const QString &path)
@ -85,7 +96,9 @@ void DEM::setDir(const QString &path)
void DEM::clearCache()
{
_lock.lock();
_data.clear();
_lock.unlock();
}
double DEM::height(const Coordinates &c, const Entry *e)
@ -126,11 +139,8 @@ DEM::Entry *DEM::loadTile(const Tile &tile)
}
}
double DEM::elevation(const Coordinates &c)
double DEM::elevationLockFree(const Coordinates &c)
{
if (_dir.isEmpty())
return NAN;
Tile tile(floor(c.lon()), floor(c.lat()));
Entry *e = _data.object(tile);
double ele;
@ -145,6 +155,33 @@ double DEM::elevation(const Coordinates &c)
return ele;
}
double DEM::elevation(const Coordinates &c)
{
if (_dir.isEmpty())
return NAN;
_lock.lock();
double ele = elevationLockFree(c);
_lock.unlock();
return ele;
}
MatrixD DEM::elevation(const MatrixC &m)
{
if (_dir.isEmpty())
return MatrixD(m.h(), m.w(), NAN);
MatrixD ret(m.h(), m.w());
_lock.lock();
for (int i = 0; i < m.size(); i++)
ret.at(i) = elevationLockFree(m.at(i));
_lock.unlock();
return ret;
}
QList<Area> DEM::tiles()
{
static const QRegularExpression re(

View File

@ -7,8 +7,7 @@
#include <QMutex>
#include "common/hash.h"
#include "data/area.h"
class Coordinates;
#include "matrix.h"
class DEM
{
@ -38,8 +37,7 @@ public:
static void clearCache();
static double elevation(const Coordinates &c);
static void lock() {_lock.lock();}
static void unlock() {_lock.unlock();}
static MatrixD elevation(const MatrixC &m);
static QList<Area> tiles();
@ -61,6 +59,7 @@ private:
static double height(const Coordinates &c, const Entry *e);
static Entry *loadTile(const Tile &tile);
static double elevationLockFree(const Coordinates &c);
static QString _dir;
static TileCache _data;

View File

@ -1,6 +1,5 @@
#include <cmath>
#include <QLineF>
#include "dem.h"
#include "map.h"
@ -80,14 +79,3 @@ qreal Map::resolution(const QRectF &rect)
return ds/ps;
}
double Map::elevation(const Coordinates &c)
{
double ele;
DEM::lock();
ele = DEM::elevation(c);
DEM::unlock();
return ele;
}

View File

@ -7,6 +7,7 @@
#include <QFlags>
#include "common/rectc.h"
#include "common/util.h"
#include "dem.h"
class QPainter;
@ -58,7 +59,7 @@ public:
virtual void draw(QPainter *painter, const QRectF &rect, Flags flags) = 0;
virtual double elevation(const Coordinates &c);
virtual double elevation(const Coordinates &c) {return DEM::elevation(c);}
virtual void clearCache() {}

View File

@ -153,6 +153,7 @@ void RasterTile::processAreaLabels(const QVector<PainterPath> &paths,
QList<const Style::TextRender*> labels(_style->areaLabels(_zoom));
QList<const Style::Symbol*> symbols(_style->areaSymbols(_zoom));
QList<PathText> items;
QSet<QByteArray> set;
for (int i = 0; i < paths.size(); i++) {
const PainterPath &path = paths.at(i);
@ -199,12 +200,17 @@ void RasterTile::processAreaLabels(const QVector<PainterPath> &paths,
QPointF pos = p.p->path->labelPos.isNull()
? centroid(p.p->pp) : ll2xy(p.p->path->labelPos);
if (p.ti && p.lbl && set.contains(*p.lbl))
continue;
PointItem *item = new PointItem(pos.toPoint(), p.lbl, font, img, color,
hColor);
if (item->isValid() && _rect.contains(item->boundingRect().toRect())
&& !item->collides(textItems))
&& !item->collides(textItems)) {
textItems.append(item);
else
if (p.ti && p.lbl)
set.insert(*p.lbl);
} else
delete item;
}
}
@ -470,26 +476,17 @@ void RasterTile::fetchData(QList<MapData::Path> &paths,
MatrixD RasterTile::elevation(int extend) const
{
MatrixD m(_rect.height() + 2 * extend, _rect.width() + 2 * extend);
int left = _rect.left() - extend;
int right = _rect.right() + extend;
int top = _rect.top() - extend;
int bottom = _rect.bottom() + extend;
QVector<Coordinates> ll;
ll.reserve(m.w() * m.h());
for (int y = top; y <= bottom; y++) {
for (int x = left; x <= right; x++)
ll.append(xy2ll(QPointF(x, y)));
}
MatrixC ll(_rect.height() + 2 * extend, _rect.width() + 2 * extend);
for (int y = top, i = 0; y <= bottom; y++)
for (int x = left; x <= right; x++, i++)
ll.at(i) = xy2ll(QPointF(x, y));
DEM::lock();
for (int i = 0; i < ll.size(); i++)
m.at(i) = DEM::elevation(ll.at(i));
DEM::unlock();
return m;
return DEM::elevation(ll);
}
void RasterTile::render()

View File

@ -770,6 +770,7 @@ void Style::clear()
_areaLabels = QList<TextRender>();
_symbols = QList<Symbol>();
_lineSymbols = QList<Symbol>();
_hillShading = HillShadingRender();
}
QList<const Style::PathRender *> Style::paths(int zoom, bool closed,

View File

@ -5,6 +5,8 @@
#include <QVector>
#include <QDebug>
class Coordinates;
template <class T>
class Matrix
{
@ -19,6 +21,7 @@ public:
T &at(int n) {return _m[n];}
T &at(int i, int j) {return _m[_w * i + j];}
T const &at(int i, int j) const {return _m.at(_w * i + j);}
T *row(int i) {return &_m[_w * i];}
bool isNull() const {return (_h == 0 || _w == 0);}
int size() const {return _m.size();}
@ -39,6 +42,8 @@ public:
MatrixD augemented(const MatrixD &M) const;
};
typedef Matrix<Coordinates> MatrixC;
#ifndef QT_NO_DEBUG
template <class T>
inline QDebug operator<<(QDebug dbg, const Matrix<T> &matrix)

View File

@ -1,4 +1,5 @@
#include <QtCore>
#include <cmath>
#include <QtMath>
#include "common/wgs84.h"
#include "osm.h"

View File

@ -1,4 +1,4 @@
#include <QtCore>
#include <QtMath>
#include <QDir>
#include <QPainter>
#include <QPixmapCache>

View File

@ -1,4 +1,4 @@
#include <QtCore>
#include <QtMath>
#include <QPainter>
#include <QDir>
#include <QPixmapCache>