mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-02-22 18:20:49 +01:00
Compare commits
No commits in common. "c0f2c1b7adff789644959c417f4fe76bc96a00fa" and "a8299050c595c0ba61ce80c4b30d6d3dd97fc11d" have entirely different histories.
c0f2c1b7ad
...
a8299050c5
@ -29,12 +29,10 @@ AreaItem::AreaItem(const Area &area, Map *map, GraphicsItem *parent)
|
|||||||
_digitalZoom = 0;
|
_digitalZoom = 0;
|
||||||
|
|
||||||
if (_area.style().isValid()) {
|
if (_area.style().isValid()) {
|
||||||
_width = (_area.style().width() >= 0)
|
_width = (_area.style().pen().style() == Qt::NoPen)
|
||||||
? _area.style().width() : 2;
|
? 0 : _area.style().pen().width();
|
||||||
_pen = _area.style().stroke().isValid()
|
_pen = _area.style().pen();
|
||||||
? QPen(area.style().stroke(), _width) : QPen(Qt::NoPen);
|
_brush = _area.style().brush();
|
||||||
_brush = _area.style().fill().isValid()
|
|
||||||
? QBrush(_area.style().fill()) : QBrush(Qt::NoBrush);
|
|
||||||
} else {
|
} else {
|
||||||
_width = 2;
|
_width = 2;
|
||||||
_opacity = 0.5;
|
_opacity = 0.5;
|
||||||
@ -130,7 +128,7 @@ void AreaItem::setOpacity(qreal opacity)
|
|||||||
|
|
||||||
void AreaItem::setWidth(qreal width)
|
void AreaItem::setWidth(qreal width)
|
||||||
{
|
{
|
||||||
if (_area.style().width() >= 0)
|
if (_area.style().isValid())
|
||||||
return;
|
return;
|
||||||
if (_width == width)
|
if (_width == width)
|
||||||
return;
|
return;
|
||||||
|
@ -20,59 +20,60 @@ static int markerSize(const QString &str)
|
|||||||
|
|
||||||
static void setAreaProperties(Area &area, const QJsonValue &properties)
|
static void setAreaProperties(Area &area, const QJsonValue &properties)
|
||||||
{
|
{
|
||||||
|
if (!properties.isObject())
|
||||||
|
return;
|
||||||
|
QJsonObject o(properties.toObject());
|
||||||
|
|
||||||
|
if (o["name"].isString())
|
||||||
|
area.setName(o["name"].toString());
|
||||||
|
if (o["title"].isString())
|
||||||
|
area.setName(o["title"].toString());
|
||||||
|
if (o["description"].isString())
|
||||||
|
area.setDescription(o["description"].toString());
|
||||||
|
|
||||||
QColor strokeColor(0x55, 0x55, 0x55);
|
QColor strokeColor(0x55, 0x55, 0x55);
|
||||||
QColor fillColor(0x55, 0x55, 0x55, 0x99);
|
QColor fillColor(0x55, 0x55, 0x55);
|
||||||
double strokeWidth = 2;
|
double strokeWidth = 2;
|
||||||
|
|
||||||
if (properties.isObject()) {
|
if (o["stroke"].isString())
|
||||||
QJsonObject o(properties.toObject());
|
strokeColor = QColor(o["stroke"].toString());
|
||||||
|
if (o["stroke-opacity"].isDouble())
|
||||||
|
strokeColor.setAlphaF(o["stroke-opacity"].toDouble());
|
||||||
|
if (o["stroke-width"].isDouble())
|
||||||
|
strokeWidth = o["stroke-width"].toDouble();
|
||||||
|
if (o["fill"].isString())
|
||||||
|
fillColor = QColor(o["fill"].toString());
|
||||||
|
if (o["fill-opacity"].isDouble())
|
||||||
|
fillColor.setAlphaF(o["fill-opacity"].toDouble());
|
||||||
|
else
|
||||||
|
fillColor.setAlphaF(0.6);
|
||||||
|
|
||||||
if (o["name"].isString())
|
area.setStyle(PolygonStyle(QPen(strokeColor, strokeWidth),
|
||||||
area.setName(o["name"].toString());
|
QBrush(fillColor)));
|
||||||
if (o["title"].isString())
|
|
||||||
area.setName(o["title"].toString());
|
|
||||||
if (o["description"].isString())
|
|
||||||
area.setDescription(o["description"].toString());
|
|
||||||
|
|
||||||
if (o["stroke"].isString())
|
|
||||||
strokeColor = QColor(o["stroke"].toString());
|
|
||||||
if (o["stroke-opacity"].isDouble())
|
|
||||||
strokeColor.setAlphaF(o["stroke-opacity"].toDouble());
|
|
||||||
if (o["stroke-width"].isDouble())
|
|
||||||
strokeWidth = o["stroke-width"].toDouble();
|
|
||||||
if (o["fill"].isString())
|
|
||||||
fillColor = QColor(o["fill"].toString());
|
|
||||||
if (o["fill-opacity"].isDouble())
|
|
||||||
fillColor.setAlphaF(o["fill-opacity"].toDouble());
|
|
||||||
else
|
|
||||||
fillColor.setAlphaF(0.6);
|
|
||||||
}
|
|
||||||
|
|
||||||
area.setStyle(PolygonStyle(fillColor, strokeColor, strokeWidth));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setTrackProperties(TrackData &track, const QJsonValue &properties)
|
static void setTrackProperties(TrackData &track, const QJsonValue &properties)
|
||||||
{
|
{
|
||||||
|
if (!properties.isObject())
|
||||||
|
return;
|
||||||
|
QJsonObject o(properties.toObject());
|
||||||
|
|
||||||
|
if (o["name"].isString())
|
||||||
|
track.setName(o["name"].toString());
|
||||||
|
if (o["title"].isString())
|
||||||
|
track.setName(o["title"].toString());
|
||||||
|
if (o["description"].isString())
|
||||||
|
track.setDescription(o["description"].toString());
|
||||||
|
|
||||||
QColor color(0x55, 0x55, 0x55);
|
QColor color(0x55, 0x55, 0x55);
|
||||||
double width = 2;
|
double width = 2;
|
||||||
|
|
||||||
if (properties.isObject()) {
|
if (o["stroke"].isString())
|
||||||
QJsonObject o(properties.toObject());
|
color = QColor(o["stroke"].toString());
|
||||||
|
if (o["stroke-opacity"].isDouble())
|
||||||
if (o["name"].isString())
|
color.setAlphaF(o["stroke-opacity"].toDouble());
|
||||||
track.setName(o["name"].toString());
|
if (o["stroke-width"].isDouble())
|
||||||
if (o["title"].isString())
|
width = o["stroke-width"].toDouble();
|
||||||
track.setName(o["title"].toString());
|
|
||||||
if (o["description"].isString())
|
|
||||||
track.setDescription(o["description"].toString());
|
|
||||||
|
|
||||||
if (o["stroke"].isString())
|
|
||||||
color = QColor(o["stroke"].toString());
|
|
||||||
if (o["stroke-opacity"].isDouble())
|
|
||||||
color.setAlphaF(o["stroke-opacity"].toDouble());
|
|
||||||
if (o["stroke-width"].isDouble())
|
|
||||||
width = o["stroke-width"].toDouble();
|
|
||||||
}
|
|
||||||
|
|
||||||
track.setStyle(LineStyle(color, width));
|
track.setStyle(LineStyle(color, width));
|
||||||
}
|
}
|
||||||
@ -80,28 +81,28 @@ static void setTrackProperties(TrackData &track, const QJsonValue &properties)
|
|||||||
static void setWaypointProperties(Waypoint &waypoint,
|
static void setWaypointProperties(Waypoint &waypoint,
|
||||||
const QJsonValue &properties)
|
const QJsonValue &properties)
|
||||||
{
|
{
|
||||||
|
if (!properties.isObject())
|
||||||
|
return;
|
||||||
|
QJsonObject o(properties.toObject());
|
||||||
|
|
||||||
|
if (o["name"].isString())
|
||||||
|
waypoint.setName(o["name"].toString());
|
||||||
|
if (o["title"].isString())
|
||||||
|
waypoint.setName(o["title"].toString());
|
||||||
|
if (o["description"].isString())
|
||||||
|
waypoint.setDescription(o["description"].toString());
|
||||||
|
|
||||||
QColor color(0x7e, 0x7e, 0x7e);
|
QColor color(0x7e, 0x7e, 0x7e);
|
||||||
int size = MARKER_SIZE_MEDIUM;
|
int size = MARKER_SIZE_MEDIUM;
|
||||||
|
|
||||||
if (!properties.isObject()) {
|
if (o["marker-color"].isString())
|
||||||
QJsonObject o(properties.toObject());
|
color = QColor(o["marker-color"].toString());
|
||||||
|
if (o["marker-symbol"].isString())
|
||||||
|
waypoint.setSymbol(o["marker-symbol"].toString());
|
||||||
|
if (o["marker-size"].isString())
|
||||||
|
size = markerSize(o["marker-size"].toString());
|
||||||
|
|
||||||
if (o["name"].isString())
|
waypoint.setStyle(PointStyle(QPixmap(), color, size));
|
||||||
waypoint.setName(o["name"].toString());
|
|
||||||
if (o["title"].isString())
|
|
||||||
waypoint.setName(o["title"].toString());
|
|
||||||
if (o["description"].isString())
|
|
||||||
waypoint.setDescription(o["description"].toString());
|
|
||||||
|
|
||||||
if (o["marker-color"].isString())
|
|
||||||
color = QColor(o["marker-color"].toString());
|
|
||||||
if (o["marker-symbol"].isString())
|
|
||||||
waypoint.setSymbol(o["marker-symbol"].toString());
|
|
||||||
if (o["marker-size"].isString())
|
|
||||||
size = markerSize(o["marker-size"].toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
waypoint.setStyle(PointStyle(color, size));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -643,22 +643,15 @@ void KMLParser::placemark(const Ctx &ctx, QList<TrackData> &tracks,
|
|||||||
wp->setTimestamp(timestamp);
|
wp->setTimestamp(timestamp);
|
||||||
wp->setAddress(address);
|
wp->setAddress(address);
|
||||||
wp->setPhone(phone);
|
wp->setPhone(phone);
|
||||||
PointStyleMap::iterator it = pointStyles.find(id);
|
wp->setStyle(pointStyles.value(id));
|
||||||
wp->setStyle(it == pointStyles.end()
|
|
||||||
? PointStyle(QColor(0x55, 0x55, 0x55)) : *it);
|
|
||||||
} else if (tp) {
|
} else if (tp) {
|
||||||
tp->setName(name);
|
tp->setName(name);
|
||||||
tp->setDescription(desc);
|
tp->setDescription(desc);
|
||||||
LineStyleMap::iterator it = lineStyles.find(id);
|
tp->setStyle(lineStyles.value(id));
|
||||||
tp->setStyle(it == lineStyles.end()
|
|
||||||
? LineStyle(QColor(0x55, 0x55, 0x55), 2) : *it);
|
|
||||||
} else if (ap) {
|
} else if (ap) {
|
||||||
ap->setName(name);
|
ap->setName(name);
|
||||||
ap->setDescription(desc);
|
ap->setDescription(desc);
|
||||||
PolygonStyleMap::iterator it = polyStyles.find(id);
|
ap->setStyle(polyStyles.value(id));
|
||||||
ap->setStyle(it == polyStyles.end()
|
|
||||||
? PolygonStyle(QColor(0x55, 0x55, 0x55, 0x99),
|
|
||||||
QColor(0x55, 0x55, 0x55, 0x99), 2) : *it);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -676,21 +669,6 @@ QString KMLParser::icon()
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor KMLParser::color()
|
|
||||||
{
|
|
||||||
QString str(_reader.readElementText());
|
|
||||||
if (str.size() != 8)
|
|
||||||
return QColor();
|
|
||||||
|
|
||||||
bool aok, bok, gok, rok;
|
|
||||||
int a = str.mid(0, 2).toInt(&aok, 16);
|
|
||||||
int b = str.mid(2, 2).toInt(&bok, 16);
|
|
||||||
int g = str.mid(4, 2).toInt(&gok, 16);
|
|
||||||
int r = str.mid(6, 2).toInt(&rok, 16);
|
|
||||||
|
|
||||||
return (aok && bok && gok && rok) ? QColor(r, g, b, a) : QColor();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString KMLParser::styleUrl()
|
QString KMLParser::styleUrl()
|
||||||
{
|
{
|
||||||
QString id(_reader.readElementText());
|
QString id(_reader.readElementText());
|
||||||
@ -701,28 +679,28 @@ void KMLParser::iconStyle(const QDir &dir, const QString &id,
|
|||||||
PointStyleMap &styles)
|
PointStyleMap &styles)
|
||||||
{
|
{
|
||||||
QPixmap img;
|
QPixmap img;
|
||||||
QColor c(0x55, 0x55, 0x55);
|
QColor color(Qt::white);
|
||||||
|
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == QLatin1String("Icon"))
|
if (_reader.name() == QLatin1String("Icon"))
|
||||||
img = QPixmap(dir.absoluteFilePath(icon()));
|
img = QPixmap(dir.absoluteFilePath(icon()));
|
||||||
else if (_reader.name() == QLatin1String("color"))
|
else if (_reader.name() == QLatin1String("color"))
|
||||||
c = color();
|
color = QColor("#" + _reader.readElementText());
|
||||||
else
|
else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
styles.insert(id, PointStyle(img, c));
|
styles.insert(id, PointStyle(img, color));
|
||||||
}
|
}
|
||||||
|
|
||||||
void KMLParser::polyStyle(const QString &id, PolygonStyleMap &styles)
|
void KMLParser::polyStyle(const QString &id, PolygonStyleMap &styles)
|
||||||
{
|
{
|
||||||
QColor c(0x55, 0x55, 0x55, 0x99);
|
QColor color(Qt::white);
|
||||||
uint fill = 1, outline = 1;
|
uint fill = 1, outline = 1;
|
||||||
|
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == QLatin1String("color"))
|
if (_reader.name() == QLatin1String("color"))
|
||||||
c = color();
|
color = QColor("#" + _reader.readElementText());
|
||||||
else if (_reader.name() == QLatin1String("fill"))
|
else if (_reader.name() == QLatin1String("fill"))
|
||||||
fill = _reader.readElementText().toUInt();
|
fill = _reader.readElementText().toUInt();
|
||||||
else if (_reader.name() == QLatin1String("outline"))
|
else if (_reader.name() == QLatin1String("outline"))
|
||||||
@ -731,25 +709,29 @@ void KMLParser::polyStyle(const QString &id, PolygonStyleMap &styles)
|
|||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
styles.insert(id, PolygonStyle(fill ? c : QColor(),
|
QPen pen = (color.isValid() && outline)
|
||||||
outline ? c : QColor(), 2));
|
? QPen(color) : QPen(Qt::NoPen);
|
||||||
|
QBrush brush = (color.isValid() && fill)
|
||||||
|
? QBrush(color) : QBrush(Qt::NoBrush);
|
||||||
|
|
||||||
|
styles.insert(id, PolygonStyle(pen, brush));
|
||||||
}
|
}
|
||||||
|
|
||||||
void KMLParser::lineStyle(const QString &id, LineStyleMap &styles)
|
void KMLParser::lineStyle(const QString &id, LineStyleMap &styles)
|
||||||
{
|
{
|
||||||
QColor c(0x55, 0x55, 0x55);
|
QColor color(Qt::white);
|
||||||
double width = 2;
|
uint width = 1;
|
||||||
|
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == QLatin1String("color"))
|
if (_reader.name() == QLatin1String("color"))
|
||||||
c = color();
|
color = QColor("#" + _reader.readElementText());
|
||||||
else if (_reader.name() == QLatin1String("width"))
|
else if (_reader.name() == QLatin1String("width"))
|
||||||
width = _reader.readElementText().toDouble();
|
width = _reader.readElementText().toUInt();
|
||||||
else
|
else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
styles.insert(id, LineStyle(c, width));
|
styles.insert(id, LineStyle(color, width));
|
||||||
}
|
}
|
||||||
|
|
||||||
void KMLParser::styleMapPair(const QString &id, PointStyleMap &pointStyles,
|
void KMLParser::styleMapPair(const QString &id, PointStyleMap &pointStyles,
|
||||||
|
@ -63,7 +63,6 @@ private:
|
|||||||
QDateTime timeStamp();
|
QDateTime timeStamp();
|
||||||
qreal number();
|
qreal number();
|
||||||
QDateTime time();
|
QDateTime time();
|
||||||
QColor color();
|
|
||||||
QString icon();
|
QString icon();
|
||||||
QString styleUrl();
|
QString styleUrl();
|
||||||
void style(const QDir &dir, PointStyleMap &pointStyles,
|
void style(const QDir &dir, PointStyleMap &pointStyles,
|
||||||
|
@ -10,8 +10,6 @@ public:
|
|||||||
PointStyle() : _size(-1) {}
|
PointStyle() : _size(-1) {}
|
||||||
PointStyle(const QPixmap &icon, const QColor &color = QColor(), int size = -1)
|
PointStyle(const QPixmap &icon, const QColor &color = QColor(), int size = -1)
|
||||||
: _icon(icon), _color(color), _size(size) {}
|
: _icon(icon), _color(color), _size(size) {}
|
||||||
PointStyle(const QColor &color, int size = -1)
|
|
||||||
: _color(color), _size(size) {}
|
|
||||||
|
|
||||||
const QColor &color() const {return _color;}
|
const QColor &color() const {return _color;}
|
||||||
const QPixmap &icon() const {return _icon;}
|
const QPixmap &icon() const {return _icon;}
|
||||||
@ -25,35 +23,34 @@ private:
|
|||||||
|
|
||||||
class PolygonStyle {
|
class PolygonStyle {
|
||||||
public:
|
public:
|
||||||
PolygonStyle() : _width(-1) {}
|
PolygonStyle()
|
||||||
PolygonStyle(const QColor &fill, const QColor &stroke = QColor(),
|
: _pen(QPen(Qt::NoPen)), _brush(QBrush(Qt::NoBrush)) {}
|
||||||
qreal width = -1) : _fill(fill), _stroke(stroke), _width(width) {}
|
PolygonStyle(const QPen &pen, const QBrush &brush)
|
||||||
|
: _pen(pen), _brush(brush) {}
|
||||||
|
|
||||||
const QColor &fill() const {return _fill;}
|
const QPen &pen() const {return _pen;}
|
||||||
const QColor &stroke() const {return _stroke;}
|
const QBrush &brush() const {return _brush;}
|
||||||
qreal width() const {return _width;}
|
|
||||||
|
|
||||||
bool isValid() const
|
bool isValid() const
|
||||||
{return _fill.isValid() || _stroke.isValid();}
|
{return _pen.style() != Qt::NoPen || _brush.style() != Qt::NoBrush;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QColor _fill;
|
QPen _pen;
|
||||||
QColor _stroke;
|
QBrush _brush;
|
||||||
qreal _width;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class LineStyle {
|
class LineStyle {
|
||||||
public:
|
public:
|
||||||
LineStyle() : _width(-1) {}
|
LineStyle() : _width(-1) {}
|
||||||
LineStyle(const QColor &color, qreal width = -1)
|
LineStyle(const QColor &color, int width = -1)
|
||||||
: _color(color), _width(width) {}
|
: _color(color), _width(width) {}
|
||||||
|
|
||||||
const QColor &color() const {return _color;}
|
const QColor &color() const {return _color;}
|
||||||
qreal width() const {return _width;}
|
int width() const {return _width;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QColor _color;
|
QColor _color;
|
||||||
qreal _width;
|
int _width;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // STYLE_H
|
#endif // STYLE_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user