1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-06-26 19:19:16 +02:00

Replaced the Mapsforge default theme with our own theme

This commit is contained in:
2024-11-15 22:59:06 +01:00
parent 2fdbc25ca3
commit de9529ef02
158 changed files with 854 additions and 2977 deletions

View File

@ -513,8 +513,8 @@ void RasterTile::render()
QList<TextItem*> textItems;
QImage arrows[2];
arrows[ROAD] = Util::svg2img(":/map/arrow.svg", _ratio);
arrows[WATER] = Util::svg2img(":/map/water-arrow.svg", _ratio);
arrows[ROAD] = Util::svg2img(":/symbols/arrow.svg", _ratio);
arrows[WATER] = Util::svg2img(":/symbols/water-arrow.svg", _ratio);
fetchData(polygons, lines, points);
ll2xy(polygons);

View File

@ -275,27 +275,47 @@ void RasterTile::processLineLabels(const QVector<PainterPath> &paths,
bool limit = false;
if (p.ti) {
limit = (p.ti->key() == ID_ELE || p.ti->key() == ID_REF);
limit = (p.ti->key() == ID_ELE || p.ti->key() == ID_REF
|| (!p.si && p.ti->shield()));
if (limit && set.contains(*p.lbl))
continue;
}
PathItem *item = new PathItem(p.p->pp, p.lbl, img, _rect, font, color,
hColor, rotate);
if (item->isValid() && !item->collides(textItems)) {
textItems.append(item);
if (limit)
set.insert(*p.lbl);
} else {
delete item;
if (!p.si && p.ti && p.ti->shield()) {
if (p.ti && p.lbl && set.contains(*p.lbl))
continue;
if (p.p->pp.length() < _rect.width() / 3.0)
continue;
if (img && p.lbl) {
PathItem *item = new PathItem(p.p->pp, 0, img, _rect, 0, 0, 0,
rotate);
if (item->isValid() && !item->collides(textItems))
textItems.append(item);
else
delete item;
QPointF pos = p.p->pp.pointAtPercent(0.5);
PointItem *item = new PointItem(pos.toPoint(), p.lbl, font, color,
hColor);
if (item->isValid() && _rect.contains(item->boundingRect().toRect())
&& !item->collides(textItems)) {
textItems.append(item);
if (p.ti && p.lbl)
set.insert(*p.lbl);
} else
delete item;
} else {
PathItem *item = new PathItem(p.p->pp, p.lbl, img, _rect, font,
color, hColor, rotate);
if (item->isValid() && !item->collides(textItems)) {
textItems.append(item);
if (limit)
set.insert(*p.lbl);
} else {
delete item;
if (img && p.lbl) {
PathItem *item = new PathItem(p.p->pp, 0, img, _rect, 0, 0,
0, rotate);
if (item->isValid() && !item->collides(textItems))
textItems.append(item);
else
delete item;
}
}
}
}

View File

@ -174,6 +174,10 @@ private:
const QFont *font, const QImage *img, const QColor *color,
const QColor *haloColor) : TextPointItem(point,
label ? new QString(*label) : 0, font, img, color, haloColor, 0) {}
PointItem(const QPoint &point, const QByteArray *label,
const QFont *font, const QColor *color, const QColor *bgColor)
: TextPointItem(point, label ? new QString(*label) : 0, font, 0,
color, 0, bgColor) {}
~PointItem() {delete _text;}
};

View File

@ -457,6 +457,10 @@ void Style::text(QXmlStreamReader &reader, const MapData &data,
}
if (attr.hasAttribute("symbol-id"))
ri._symbolId = attr.value("symbol-id").toString();
if (line && attr.hasAttribute("text-orientation")) {
if (attr.value("text-orientation").toString() == "auto_down")
ri._shield = true;
}
ri._font.setFamily(fontFamily);
ri._font.setPixelSize(fontSize);
@ -798,7 +802,7 @@ void Style::load(const MapData &data, qreal ratio)
QString path(ProgramPaths::renderthemeFile());
if (!QFileInfo::exists(path) || !loadXml(path, data, ratio))
loadXml(":/mapsforge/default.xml", data, ratio);
loadXml(":/style/style.xml", data, ratio);
std::sort(_symbols.begin(), _symbols.end());
std::sort(_lineSymbols.begin(), _lineSymbols.end());

View File

@ -209,7 +209,7 @@ public:
public:
TextRender(const Rule &rule)
: Render(rule), _priority(0), _fillColor(Qt::black),
_strokeColor(Qt::black), _strokeWidth(0) {}
_strokeColor(Qt::black), _strokeWidth(0), _shield(false) {}
const QString &symbolId() const {return _symbolId;}
const QFont &font() const {return _font;}
@ -218,6 +218,7 @@ public:
qreal strokeWidth() const {return _strokeWidth;}
unsigned key() const {return _key;}
int priority() const {return _priority;}
bool shield() const {return _shield;}
bool operator<(const TextRender &other) const
{return _priority > other._priority;}
@ -230,6 +231,7 @@ public:
QColor _fillColor, _strokeColor;
qreal _strokeWidth;
QFont _font;
bool _shield;
unsigned _key;
};