mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 11:45:53 +01:00
Compare commits
2 Commits
cc20a9cd59
...
7bd03b0f2e
Author | SHA1 | Date | |
---|---|---|---|
7bd03b0f2e | |||
8990f2cfcf |
@ -241,11 +241,13 @@ void Style::area(QXmlStreamReader &reader, const QString &dir, qreal ratio,
|
|||||||
reader.skipCurrentElement();
|
reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Style::line(QXmlStreamReader &reader, qreal baseStrokeWidth,
|
void Style::line(QXmlStreamReader &reader, const QString &dir, qreal ratio,
|
||||||
const Rule &rule)
|
qreal baseStrokeWidth, const Rule &rule)
|
||||||
{
|
{
|
||||||
PathRender ri(rule, _paths.size() + _circles.size() + _hillShading.isValid());
|
PathRender ri(rule, _paths.size() + _circles.size() + _hillShading.isValid());
|
||||||
const QXmlStreamAttributes &attr = reader.attributes();
|
const QXmlStreamAttributes &attr = reader.attributes();
|
||||||
|
QString file;
|
||||||
|
int height = 0, width = 0, percent = 100;
|
||||||
bool ok;
|
bool ok;
|
||||||
|
|
||||||
ri._brush = Qt::NoBrush;
|
ri._brush = Qt::NoBrush;
|
||||||
@ -309,6 +311,32 @@ void Style::line(QXmlStreamReader &reader, qreal baseStrokeWidth,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (attr.hasAttribute("src"))
|
||||||
|
file = resourcePath(attr.value("src").toString(), dir);
|
||||||
|
if (attr.hasAttribute("symbol-height")) {
|
||||||
|
height = attr.value("symbol-height").toInt(&ok);
|
||||||
|
if (!ok || height < 0) {
|
||||||
|
reader.raiseError("invalid symbol-height value");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (attr.hasAttribute("symbol-width")) {
|
||||||
|
width = attr.value("symbol-width").toInt(&ok);
|
||||||
|
if (!ok || width < 0) {
|
||||||
|
reader.raiseError("invalid symbol-width value");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (attr.hasAttribute("symbol-percent")) {
|
||||||
|
percent = attr.value("symbol-percent").toInt(&ok);
|
||||||
|
if (!ok || percent < 0) {
|
||||||
|
reader.raiseError("invalid symbol-percent value");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!file.isNull())
|
||||||
|
ri._img = image(file, width, height, percent, ratio);
|
||||||
|
|
||||||
if (ri.rule()._type == Rule::AnyType || ri.rule()._type == Rule::WayType)
|
if (ri.rule()._type == Rule::AnyType || ri.rule()._type == Rule::WayType)
|
||||||
_paths.append(ri);
|
_paths.append(ri);
|
||||||
|
|
||||||
@ -549,7 +577,7 @@ void Style::rule(QXmlStreamReader &reader, const QString &dir,
|
|||||||
else if (reader.name() == QLatin1String("area"))
|
else if (reader.name() == QLatin1String("area"))
|
||||||
area(reader, dir, ratio, baseStrokeWidth, r);
|
area(reader, dir, ratio, baseStrokeWidth, r);
|
||||||
else if (reader.name() == QLatin1String("line"))
|
else if (reader.name() == QLatin1String("line"))
|
||||||
line(reader, baseStrokeWidth, r);
|
line(reader, dir, ratio, baseStrokeWidth, r);
|
||||||
else if (reader.name() == QLatin1String("circle"))
|
else if (reader.name() == QLatin1String("circle"))
|
||||||
circle(reader, baseStrokeWidth, r);
|
circle(reader, baseStrokeWidth, r);
|
||||||
else if (reader.name() == QLatin1String("pathText")) {
|
else if (reader.name() == QLatin1String("pathText")) {
|
||||||
@ -852,11 +880,11 @@ QList<const Style::Symbol*> Style::areaSymbols(int zoom) const
|
|||||||
|
|
||||||
QPen Style::PathRender::pen(int zoom) const
|
QPen Style::PathRender::pen(int zoom) const
|
||||||
{
|
{
|
||||||
if (_strokeColor.isValid()) {
|
if (!_img.isNull() || _strokeColor.isValid()) {
|
||||||
qreal width = (_scale > None && zoom >= 12)
|
qreal width = (_scale > None && zoom >= 12)
|
||||||
? pow(1.5, zoom - 12) * _strokeWidth : _strokeWidth;
|
? pow(1.5, zoom - 12) * _strokeWidth : _strokeWidth;
|
||||||
QPen p(QBrush(_strokeColor), width, Qt::SolidLine, _strokeCap,
|
QBrush brush = _img.isNull() ? QBrush(_strokeColor) : QBrush(_img);
|
||||||
_strokeJoin);
|
QPen p(brush, width, Qt::SolidLine, _strokeCap, _strokeJoin);
|
||||||
if (!_strokeDasharray.isEmpty()) {
|
if (!_strokeDasharray.isEmpty()) {
|
||||||
QVector<qreal>pattern(_strokeDasharray);
|
QVector<qreal>pattern(_strokeDasharray);
|
||||||
for (int i = 0; i < _strokeDasharray.size(); i++) {
|
for (int i = 0; i < _strokeDasharray.size(); i++) {
|
||||||
|
@ -173,6 +173,7 @@ public:
|
|||||||
QVector<qreal> _strokeDasharray;
|
QVector<qreal> _strokeDasharray;
|
||||||
Qt::PenCapStyle _strokeCap;
|
Qt::PenCapStyle _strokeCap;
|
||||||
Qt::PenJoinStyle _strokeJoin;
|
Qt::PenJoinStyle _strokeJoin;
|
||||||
|
QImage _img;
|
||||||
QBrush _brush;
|
QBrush _brush;
|
||||||
bool _area, _curve;
|
bool _area, _curve;
|
||||||
Scale _scale;
|
Scale _scale;
|
||||||
@ -320,7 +321,8 @@ private:
|
|||||||
const Rule &parent);
|
const Rule &parent);
|
||||||
void area(QXmlStreamReader &reader, const QString &dir, qreal ratio,
|
void area(QXmlStreamReader &reader, const QString &dir, qreal ratio,
|
||||||
qreal baseStrokeWidth, const Rule &rule);
|
qreal baseStrokeWidth, const Rule &rule);
|
||||||
void line(QXmlStreamReader &reader, qreal baseStrokeWidth, const Rule &rule);
|
void line(QXmlStreamReader &reader, const QString &dir, qreal ratio,
|
||||||
|
qreal baseStrokeWidth, const Rule &rule);
|
||||||
void circle(QXmlStreamReader &reader, qreal baseStrokeWidth,
|
void circle(QXmlStreamReader &reader, qreal baseStrokeWidth,
|
||||||
const Rule &rule);
|
const Rule &rule);
|
||||||
void hillshading(QXmlStreamReader &reader, const QSet<QString> &cats);
|
void hillshading(QXmlStreamReader &reader, const QSet<QString> &cats);
|
||||||
|
Loading…
Reference in New Issue
Block a user