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

Compare commits

..

19 Commits

Author SHA1 Message Date
55de85579c Move the tables to the function where they are used 2024-04-20 19:57:52 +02:00
86f98aca42 Make it clear the tables are not modified during runtime 2024-04-20 19:50:33 +02:00
56425a3318 Always use the GPXSee icon theme on Mac and Windows 2024-04-20 16:23:23 +02:00
d045fed086 Swtch to Qt 6.7 in Windows CI builds 2024-04-19 20:19:47 +02:00
31cd65f15e Remove the zoom offset hack
Now that we are back to the map data defined tile size, it makes no sense any
more. Additionaly it crashes with world maps as zoom 0 becomes -1...
2024-04-18 20:35:31 +02:00
089ccfde71 Code cleanup 2024-04-18 20:35:05 +02:00
a0ce50e7e4 Use QVectors instead of plain arrays 2024-04-16 10:26:17 +02:00
031d82f689 Code cleanup 2024-04-16 09:17:18 +02:00
99f620f101 Fixed capitalization algorithm 2024-04-16 08:52:54 +02:00
5f3203d638 Switched the OS X Qt6 build to Qt 6.7.0 2024-04-15 00:03:09 +02:00
33cc1df601 Update to OpenSSL 3.2 2024-04-14 23:49:40 +02:00
5ef29bf827 Some more code cleanup 2024-04-14 23:32:44 +02:00
6f029d81a0 Code cleanup 2024-04-14 22:15:30 +02:00
90395a32dd Improve the capitalization algorithm 2024-04-14 17:33:49 +02:00
d4b10b091c Fit the extension placeholder into the template 2024-04-14 15:09:12 +02:00
6210d1b983 Switched back to diagonal pattern for national parks 2024-04-14 14:50:34 +02:00
5e71715f22 Translated using Weblate (Chinese (Simplified))
Currently translated at 100.0% (474 of 474 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/zh_Hans/
2024-04-06 18:02:00 +02:00
648f90f230 Improve FIT locations support 2024-04-03 02:30:26 +02:00
324168340b Do not blur the icons when resizing them 2024-04-03 02:18:00 +02:00
13 changed files with 134 additions and 116 deletions

View File

@ -12,8 +12,8 @@ environment:
- QTDIR: C:\Qt\5.15\msvc2019_64
OPENSSLDIR: C:\OpenSSL-v111-Win64\bin
NSISDEF: /DOPENSSL /DANGLE
- QTDIR: C:\Qt\6.5\msvc2019_64
OPENSSLDIR: C:\OpenSSL-v30-Win64\bin
- QTDIR: C:\Qt\6.7\msvc2019_64
OPENSSLDIR: C:\OpenSSL-v32-Win64\bin
NSISDEF: /DQT6 /DOPENSSL
install:

View File

@ -39,7 +39,7 @@ jobs:
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
version: '6.6.1'
version: '6.7.0'
modules: qtpositioning qtserialport qtimageformats
- name: Create localization
run: lrelease gpxsee.pro

View File

@ -4,7 +4,7 @@ while read e; do
IFS=":"; set $e
EXT=`echo $1 | tr /a-z/ /A-Z/`
sed -e "s/\$EXTENSION/$EXT/" -e "s/\$COLOR/$2/" icon-template.svg > $1.svg
sed -e "s/\$EXT/$EXT/" -e "s/\$COLOR/$2/" icon-template.svg > $1.svg
ICONSET=$1.iconset
mkdir $ICONSET

View File

@ -4,7 +4,7 @@ while read e; do
IFS=":"; set $e
EXT=`echo $1 | tr /a-z/ /A-Z/`
sed -e "s/\$EXTENSION/$EXT/" -e "s/\$COLOR/$2/" icon-template.svg > $1.svg
sed -e "s/\$EXT/$EXT/" -e "s/\$COLOR/$2/" icon-template.svg > $1.svg
convert -density 400 -background none $1.svg -define icon:auto-resize $1.ico
rm $1.svg
done < extensions

View File

@ -13,8 +13,8 @@
<g transform="translate(16.573463,124.9782)">
<rect y="0" x="0" id="textrect" height="50" width="120" style="fill:$COLOR;fill-opacity:1;stroke:none;"/>
<!--
<text y="28" x="60" dominant-baseline="central" text-anchor="middle" style="fill:#FFFFFF;font-size:39px;font-family:Helvetica;font-weight:bold;">$EXTENSION</text>
<text y="28" x="60" dominant-baseline="central" text-anchor="middle" style="fill:#FFFFFF;font-size:39px;font-family:Helvetica;font-weight:bold;">$EXT</text>
-->
<text y="25" x="60" dy="0.36em" text-anchor="middle" style="fill:#FFFFFF;font-size:39px;font-family:Helvetica;font-weight:bold;">$EXTENSION</text>
<text y="25" x="60" dy="0.36em" text-anchor="middle" style="fill:#FFFFFF;font-size:39px;font-family:Helvetica;font-weight:bold;">$EXT</text>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -571,12 +571,12 @@
<message>
<location filename="../src/GUI/gui.cpp" line="457"/>
<source>Download data DEM</source>
<translation type="unfinished"></translation>
<translation> DEM </translation>
</message>
<message>
<location filename="../src/GUI/gui.cpp" line="463"/>
<source>Download map DEM</source>
<translation type="unfinished"></translation>
<translation> DEM </translation>
</message>
<message>
<location filename="../src/GUI/gui.cpp" line="468"/>
@ -586,7 +586,7 @@
<message>
<location filename="../src/GUI/gui.cpp" line="471"/>
<source>Show hillshading</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
<message>
<location filename="../src/GUI/gui.cpp" line="480"/>
@ -1034,13 +1034,13 @@
<message>
<location filename="../src/GUI/gui.cpp" line="1986"/>
<source>DEM tiles download limit exceeded. If you really need data for such a huge area, download the files manually.</source>
<translation type="unfinished"></translation>
<translation> DEM </translation>
</message>
<message numerus="yes">
<location filename="../src/GUI/gui.cpp" line="1989"/>
<source>Download %n DEM tiles?</source>
<translation type="unfinished">
<numerusform></numerusform>
<translation>
<numerusform> %n DEM </numerusform>
</translation>
</message>
<message>

View File

@ -29,9 +29,9 @@ App::App(int &argc, char **argv) : QApplication(argc, argv)
{
#if defined(Q_OS_WIN32) || defined(Q_OS_MAC)
setApplicationName(APP_NAME);
#else
#else // Q_OS_WIN32 || Q_OS_MAC
setApplicationName(QString(APP_NAME).toLower());
#endif
#endif // Q_OS_WIN32 || Q_OS_MAC
setApplicationVersion(APP_VERSION);
QTranslator *app = new QTranslator(this);
@ -65,6 +65,9 @@ App::App(int &argc, char **argv) : QApplication(argc, argv)
loadPCSs();
Waypoint::loadSymbolIcons(ProgramPaths::symbolsDir());
#if defined(Q_OS_WIN32) || defined(Q_OS_MAC)
QIcon::setThemeName(APP_NAME);
#endif // Q_OS_WIN32 || Q_OS_MAC
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
QIcon::setFallbackThemeName(APP_NAME);
#endif // QT 5.12

View File

@ -170,8 +170,7 @@ void WaypointItem::paint(QPainter *painter,
if (_font.bold())
painter->drawPixmap(-_icon->width() * 0.625, icon.isNull()
? -_icon->height() * 1.25 : -_icon->height() * 0.625,
_icon->scaled(_icon->width() * 1.25, _icon->height() * 1.25,
Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
_icon->scaled(_icon->width() * 1.25, _icon->height() * 1.25));
else
painter->drawPixmap(-_icon->width()/2.0, icon.isNull()
? -_icon->height() : -_icon->height()/2, *_icon);

View File

@ -124,7 +124,22 @@ static QMap<int, QString> coursePointSymbolsInit()
return map;
}
static QMap<int, QString> locationPointSymbolsInit()
{
QMap<int, QString> map;
/* The location symbols are a typical GARMIN mess. Every GPS unit
has probably its own list, so we only add a few generic icons seen
"in the wild" most often. */
map.insert(94, "Flag, Blue");
map.insert(95, "Flag, Green");
map.insert(96, "Flag, Red");
return map;
}
static QMap<int, QString> coursePointSymbols = coursePointSymbolsInit();
static QMap<int, QString> locationPointSymbols = locationPointSymbolsInit();
bool FITParser::readData(QFile *file, char *data, size_t size)
@ -271,7 +286,7 @@ bool FITParser::readField(CTX &ctx, Field *field, QVariant &val, bool &valid)
ctx.len -= field->size;
ret = (ba.size() == field->size);
val = ret ? ba : QString();
valid = !ba.isEmpty();}
valid = (!ba.isEmpty() && ba.at(0) != 0);}
break;
default:
ret = skipValue(ctx, field->size);
@ -388,6 +403,9 @@ bool FITParser::parseData(CTX &ctx, const MessageDefinition *def)
waypoint.rcoordinates().setLon(
(val.toInt() / (double)0x7fffffff) * 180);
break;
case 3:
waypoint.setSymbol(locationPointSymbols.value(val.toUInt()));
break;
case 4:
waypoint.setElevation((val.toUInt() / 5.0) - 500);
break;

View File

@ -7,53 +7,36 @@ using namespace IMG;
enum Charset {Normal, Symbol, Special};
static quint8 NORMAL_CHARS[] = {
' ', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z', '~', '~', '~', ' ', ' ',
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', '~', '~', '~', '~', '~', '~'
};
static quint8 SYMBOL_CHARS[] = {
'@', '!', '"', '#', '$', '%', '&', '\'',
'(', ')', '*', '+', ',', '-', '.', '/',
'~', '~', '~', '~', '~', '~', '~', '~',
'~', '~', ':', ';', '<', '=', '>', '?',
'~', '~', '~', '~', '~', '~', '~', '~',
'~', '~', '~', '[', '\\', ']', '^', '_'
};
static quint8 SPECIAL_CHARS[] = {
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
'x', 'y', 'z', '~', '~', '~', '~', '~',
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', '~', '~', '~', '~', '~', '~'
};
static bool isAllUpperCase(const QString &str)
{
if (str.isEmpty())
return false;
for (int i = 0; i < str.size(); i++)
if (str.at(i).isLetter() && !(str.at(i).isUpper()
|| str.at(i) == QChar(0x00DF)))
for (int i = 0; i < str.size(); i++) {
QChar c(str.at(i));
if (c.isLetter() && !(c.isUpper() || c == QChar(0x00DF)))
return false;
}
return true;
}
static QString capitalized(const QString &str)
{
QString ret(str);
for (int i = 0; i < str.size(); i++)
if (i && !str.at(i-1).isSpace())
ret[i] = str.at(i).toLower();
else
ret[i] = str.at(i);
QString ret;
ret.resize(str.size());
if (!str.isEmpty())
ret[0] = str.at(0);
for (int i = 1; i < str.size(); i++) {
QChar last(str.at(i-1));
QChar c(str.at(i));
ret[i] = (last.isSpace() || last == '(') ? c : c.toLower();
}
return ret;
}
@ -65,11 +48,10 @@ static QByteArray ft2m(const QByteArray &str)
return ok ? QByteArray::number(qRound(number * 0.3048)) : str;
}
LBLFile::~LBLFile()
{
delete _huffmanText;
delete[] _table;
delete[] _rasters;
}
bool LBLFile::load(Handle &hdl, const RGNFile *rgn, Handle &rgnHdl)
@ -93,10 +75,10 @@ bool LBLFile::load(Handle &hdl, const RGNFile *rgn, Handle &rgnHdl)
return false;
if (size && recordSize) {
_table = new quint32[size / recordSize];
_table.resize(size / recordSize);
if (!seek(hdl, offset))
return false;
for (quint32 i = 0; i < size / recordSize; i++) {
for (quint32 i = 0; i < _table.size(); i++) {
if (!readVUInt32(hdl, recordSize, _table[i]))
return false;
}
@ -129,12 +111,10 @@ bool LBLFile::load(Handle &hdl, const RGNFile *rgn, Handle &rgnHdl)
void LBLFile::clear()
{
_table = QVector<quint32>();
_rasters = QVector<Image>();
delete _huffmanText;
delete[] _table;
delete[] _rasters;
_huffmanText = 0;
_table = 0;
_rasters = 0;
}
Label LBLFile::str2label(const QVector<quint8> &str, bool capitalize,
@ -183,6 +163,30 @@ Label LBLFile::str2label(const QVector<quint8> &str, bool capitalize,
Label LBLFile::label6b(const SubFile *file, Handle &fileHdl, quint32 size,
bool capitalize, bool convert) const
{
static const quint8 NORMAL_CHARS[] = {
' ', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z', '~', '~', '~', ' ', ' ',
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', '~', '~', '~', '~', '~', '~'
};
static const quint8 SYMBOL_CHARS[] = {
'@', '!', '"', '#', '$', '%', '&', '\'',
'(', ')', '*', '+', ',', '-', '.', '/',
'~', '~', '~', '~', '~', '~', '~', '~',
'~', '~', ':', ';', '<', '=', '>', '?',
'~', '~', '~', '~', '~', '~', '~', '~',
'~', '~', '~', '[', '\\', ']', '^', '_'
};
static const quint8 SPECIAL_CHARS[] = {
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
'x', 'y', 'z', '~', '~', '~', '~', '~',
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', '~', '~', '~', '~', '~', '~'
};
Shield::Type shieldType = Shield::None;
QByteArray label, shieldLabel;
QByteArray *bap = &label;
@ -266,42 +270,41 @@ Label LBLFile::label8b(const SubFile *file, Handle &fileHdl, quint32 size,
Label LBLFile::labelHuffman(Handle &hdl, const SubFile *file, Handle &fileHdl,
quint32 size, bool capitalize, bool convert)
{
QVector<quint8> tpl;
if (!_huffmanText->decode(file, fileHdl, size, tpl))
return Label();
if (!_table.size())
return str2label(tpl, capitalize, convert);
QVector<quint8> str;
if (!_huffmanText->decode(file, fileHdl, size, str))
return Label();
if (!_table)
return str2label(str, capitalize, convert);
for (int i = 0; i < tpl.size(); i++) {
quint8 c(tpl.at(i));
quint32 val = (c < _table.size()) ? _table.at(c) : 0;
QVector<quint8> str2;
for (int i = 0; i < str.size(); i++) {
quint32 val = _table[str.at(i)];
if (val) {
quint32 off = _base.offset + ((val & 0x7fffff) << _shift);
if (!seek(hdl, off))
if (str.size() && str.back() == '\0')
str.back() = ' ';
else if (str.size())
str.append(' ');
quint32 offset = _base.offset + ((val & 0x7fffff) << _shift);
quint32 limit = _base.offset + _base.size - offset;
if (!seek(hdl, offset))
return Label();
if (str2.size() && str2.back() == '\0')
str2[str2.size() - 1] = ' ';
else if (str2.size())
str2.append(' ');
if (!_huffmanText->decode(this, hdl, _base.offset + _base.size - off,
str2))
if (!_huffmanText->decode(this, hdl, limit, str))
return Label();
} else {
if (str.at(i) == 7) {
str2.append(0);
break;
}
if (str2.size() && str2.back() == '\0')
str2[str2.size() - 1] = ' ';
str2.append(str.at(i));
if (str.size() && str.back() == '\0')
str.back() = ' ';
str.append(c);
}
}
return str2label(str2, capitalize, convert);
return str2label(str, capitalize, convert);
}
Label LBLFile::label(Handle &hdl, quint32 offset, bool poi, bool capitalize,
@ -347,15 +350,15 @@ bool LBLFile::loadRasterTable(Handle &hdl, quint32 offset, quint32 size,
quint32 recordSize)
{
quint32 prev, cur;
quint32 imgCount = size / recordSize;
_imgCount = size / recordSize;
_imgIdSize = byteSize(_imgCount - 1);
_rasters = new Image[_imgCount];
_imgIdSize = byteSize(imgCount - 1);
_rasters.resize(imgCount);
if (!(seek(hdl, offset) && readVUInt32(hdl, recordSize, prev)))
return false;
for (quint32 i = 1; i < _imgCount; i++) {
for (quint32 i = 1; i < imgCount; i++) {
if (!readVUInt32(hdl, recordSize, cur))
return false;
@ -365,8 +368,8 @@ bool LBLFile::loadRasterTable(Handle &hdl, quint32 offset, quint32 size,
prev = cur;
}
_rasters[_imgCount-1].offset = prev;
_rasters[_imgCount-1].size = _img.size - prev;
_rasters[imgCount-1].offset = prev;
_rasters[imgCount-1].size = _img.size - prev;
return true;
}
@ -375,14 +378,14 @@ QPixmap LBLFile::image(Handle &hdl, quint32 id) const
{
QPixmap pm;
if (id >= _imgCount)
if (id >= _rasters.size())
return pm;
if (!seek(hdl, _img.offset + _rasters[id].offset))
if (!seek(hdl, _img.offset + _rasters.at(id).offset))
return pm;
QByteArray ba;
ba.resize(_rasters[id].size);
if (!read(hdl, ba.data(), _rasters[id].size))
ba.resize(_rasters.at(id).size);
if (!read(hdl, ba.data(), ba.size()))
return pm;
pm.loadFromData(ba, "jpeg");

View File

@ -16,14 +16,14 @@ class LBLFile : public SubFile
{
public:
LBLFile(const IMGData *img)
: SubFile(img), _huffmanText(0), _table(0), _rasters(0), _imgIdSize(0),
_poiShift(0), _shift(0), _encoding(0) {}
: SubFile(img), _huffmanText(0), _imgIdSize(0), _poiShift(0), _shift(0),
_encoding(0) {}
LBLFile(const QString *path)
: SubFile(path), _huffmanText(0), _table(0), _rasters(0), _imgIdSize(0),
_poiShift(0), _shift(0), _encoding(0) {}
: SubFile(path), _huffmanText(0), _imgIdSize(0), _poiShift(0), _shift(0),
_encoding(0) {}
LBLFile(const SubFile *gmp, quint32 offset)
: SubFile(gmp, offset), _huffmanText(0), _table(0), _rasters(0),
_imgIdSize(0), _poiShift(0), _shift(0), _encoding(0) {}
: SubFile(gmp, offset), _huffmanText(0), _imgIdSize(0), _poiShift(0),
_shift(0), _encoding(0) {}
~LBLFile();
bool load(Handle &hdl, const RGNFile *rgn, Handle &rgnHdl);
@ -55,11 +55,10 @@ private:
quint32 recordSize);
HuffmanText *_huffmanText;
quint32 *_table;
Image *_rasters;
QVector<Image> _rasters;
QVector<quint32> _table;
TextCodec _codec;
Section _base, _poi, _img;
quint32 _imgCount;
quint8 _imgIdSize;
quint8 _poiShift;
quint8 _shift;

View File

@ -187,7 +187,7 @@ void Style::defaultPolygonStyle()
_polygons[TYPE(0x14)] = Polygon(QBrush(QColor(0xca, 0xdf, 0xaf)));
_polygons[TYPE(0x15)] = Polygon(QBrush(QColor(0xca, 0xdf, 0xaf)));
_polygons[TYPE(0x16)] = Polygon(QBrush(QColor(0x9a, 0xc2, 0x69),
Qt::Dense5Pattern));
Qt::BDiagPattern));
_polygons[TYPE(0x17)] = Polygon(QBrush(QColor(0xe4, 0xef, 0xcf)));
_polygons[TYPE(0x18)] = Polygon(QBrush(QColor(0xe3, 0xed, 0xc6)));
_polygons[TYPE(0x19)] = Polygon(QBrush(QColor(0xe3, 0xed, 0xc6)),
@ -195,9 +195,9 @@ void Style::defaultPolygonStyle()
_polygons[TYPE(0x1a)] = Polygon(QBrush(QColor(0, 0, 0), Qt::Dense6Pattern),
QPen(QColor(0xcd, 0xcc, 0xc4), 1));
_polygons[TYPE(0x1e)] = Polygon(QBrush(QColor(0x9a, 0xc2, 0x69),
Qt::Dense5Pattern));
Qt::BDiagPattern));
_polygons[TYPE(0x1f)] = Polygon(QBrush(QColor(0x9a, 0xc2, 0x69),
Qt::Dense5Pattern));
Qt::BDiagPattern));
_polygons[TYPE(0x28)] = Polygon(QBrush(QColor(0x9f, 0xc4, 0xe1)));
_polygons[TYPE(0x32)] = Polygon(QBrush(QColor(0x9f, 0xc4, 0xe1)));
_polygons[TYPE(0x3c)] = Polygon(QBrush(QColor(0x9f, 0xc4, 0xe1)));

View File

@ -23,17 +23,13 @@ namespace Mapsforge {
class RasterTile
{
public:
/* Most Mapsforge themes expect the zoom levels to be offset by one from
the standard OSM zoom levels! We decrease the zoom level internaly
here when initializing _zoom and return the propper (increased) value
back in zoom() */
RasterTile(const Projection &proj, const Transform &transform,
const Style *style, MapData *data, int zoom, const QRect &rect,
qreal ratio, bool hillShading)
: _proj(proj), _transform(transform), _style(style), _data(data),
_zoom(zoom - 1), _rect(rect), _ratio(ratio), _hillShading(hillShading) {}
_zoom(zoom), _rect(rect), _ratio(ratio), _hillShading(hillShading) {}
int zoom() const {return _zoom + 1;}
int zoom() const {return _zoom;}
QPoint xy() const {return _rect.topLeft();}
const QPixmap &pixmap() const {return _pixmap;}