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

Added support for waypoint icons

This commit is contained in:
2021-10-10 08:38:38 +02:00
parent 5fdbf2e5d6
commit fb8f0c4372
184 changed files with 854 additions and 282 deletions

View File

@ -13,6 +13,7 @@
#include "map/gcs.h"
#include "map/pcs.h"
#include "data/dem.h"
#include "data/waypoint.h"
#include "gui.h"
#include "mapaction.h"
#include "app.h"
@ -57,6 +58,7 @@ App::App(int &argc, char **argv) : QApplication(argc, argv)
loadDatums();
loadPCSs();
Waypoint::loadSymbolIcons(ProgramPaths::symbolsDir());
_gui = new GUI();
}

View File

@ -269,6 +269,11 @@ void GUI::createActions()
_overlapPOIAction->setCheckable(true);
connect(_overlapPOIAction, &QAction::triggered, _mapView,
&MapView::showOverlappedPOIs);
_showPOIIconsAction = new QAction(tr("Show POI icons"), this);
_showPOIIconsAction->setMenuRole(QAction::NoRole);
_showPOIIconsAction->setCheckable(true);
connect(_showPOIIconsAction, &QAction::triggered, _mapView,
&MapView::showPOIIcons);
_showPOILabelsAction = new QAction(tr("Show POI labels"), this);
_showPOILabelsAction->setMenuRole(QAction::NoRole);
_showPOILabelsAction->setCheckable(true);
@ -343,6 +348,11 @@ void GUI::createActions()
_showAreasAction->setMenuRole(QAction::NoRole);
_showAreasAction->setCheckable(true);
connect(_showAreasAction, &QAction::triggered, this, &GUI::showAreas);
_showWaypointIconsAction = new QAction(tr("Waypoint icons"), this);
_showWaypointIconsAction->setMenuRole(QAction::NoRole);
_showWaypointIconsAction->setCheckable(true);
connect(_showWaypointIconsAction, &QAction::triggered, _mapView,
&MapView::showWaypointIcons);
_showWaypointLabelsAction = new QAction(tr("Waypoint labels"), this);
_showWaypointLabelsAction->setMenuRole(QAction::NoRole);
_showWaypointLabelsAction->setCheckable(true);
@ -572,6 +582,7 @@ void GUI::createMenus()
graphMenu->addAction(_showGraphsAction);
QMenu *dataMenu = menuBar()->addMenu(tr("&Data"));
dataMenu->addAction(_showWaypointIconsAction);
dataMenu->addAction(_showWaypointLabelsAction);
dataMenu->addAction(_showRouteWaypointsAction);
dataMenu->addAction(_showTicksAction);
@ -592,6 +603,7 @@ void GUI::createMenus()
_poiMenu->addAction(_selectAllPOIAction);
_poiMenu->addAction(_unselectAllPOIAction);
_poiMenu->addSeparator();
_poiMenu->addAction(_showPOIIconsAction);
_poiMenu->addAction(_showPOILabelsAction);
_poiMenu->addAction(_overlapPOIAction);
_poiMenu->addSeparator();
@ -2145,6 +2157,9 @@ void GUI::writeSettings()
if (_showPOILabelsAction->isChecked() != SHOW_POI_LABELS_DEFAULT)
settings.setValue(SHOW_POI_LABELS_SETTING,
_showPOILabelsAction->isChecked());
if (_showPOIIconsAction->isChecked() != SHOW_POI_ICONS_DEFAULT)
settings.setValue(SHOW_POI_ICONS_SETTING,
_showPOIIconsAction->isChecked());
int j = 0;
QList<QAction*> poiActions(_poisActionGroup->actions());
@ -2171,6 +2186,9 @@ void GUI::writeSettings()
_showWaypointsAction->isChecked());
if (_showAreasAction->isChecked() != SHOW_AREAS_DEFAULT)
settings.setValue(SHOW_AREAS_SETTING, _showAreasAction->isChecked());
if (_showWaypointIconsAction->isChecked() != SHOW_WAYPOINT_ICONS_DEFAULT)
settings.setValue(SHOW_WAYPOINT_ICONS_SETTING,
_showWaypointIconsAction->isChecked());
if (_showWaypointLabelsAction->isChecked() != SHOW_WAYPOINT_LABELS_DEFAULT)
settings.setValue(SHOW_WAYPOINT_LABELS_SETTING,
_showWaypointLabelsAction->isChecked());
@ -2433,6 +2451,9 @@ void GUI::readSettings(QString &activeMap, QStringList &disabledPOIs)
_mapView->showOverlappedPOIs(false);
else
_overlapPOIAction->setChecked(true);
if (settings.value(SHOW_POI_ICONS_SETTING, SHOW_POI_ICONS_DEFAULT)
.toBool())
_showPOIIconsAction->trigger();
if (!settings.value(SHOW_POI_LABELS_SETTING, SHOW_POI_LABELS_DEFAULT)
.toBool())
_mapView->showPOILabels(false);
@ -2473,6 +2494,9 @@ void GUI::readSettings(QString &activeMap, QStringList &disabledPOIs)
_mapView->showAreas(false);
else
_showAreasAction->setChecked(true);
if (settings.value(SHOW_WAYPOINT_ICONS_SETTING,
SHOW_WAYPOINT_ICONS_DEFAULT).toBool())
_showWaypointIconsAction->trigger();
if (!settings.value(SHOW_WAYPOINT_LABELS_SETTING,
SHOW_WAYPOINT_LABELS_DEFAULT).toBool())
_mapView->showWaypointLabels(false);

View File

@ -196,6 +196,7 @@ private:
QAction *_showPOIAction;
QAction *_overlapPOIAction;
QAction *_showPOILabelsAction;
QAction *_showPOIIconsAction;
QAction *_showMapAction;
QAction *_fullscreenAction;
QAction *_loadMapAction;
@ -225,6 +226,7 @@ private:
QAction *_showRoutesAction;
QAction *_showWaypointsAction;
QAction *_showWaypointLabelsAction;
QAction *_showWaypointIconsAction;
QAction *_showAreasAction;
QAction *_showRouteWaypointsAction;
QAction *_hideMarkersAction;

View File

@ -89,8 +89,10 @@ MapView::MapView(Map *map, POI *poi, QWidget *parent)
_showAreas = true;
_showWaypoints = true;
_showWaypointLabels = true;
_showWaypointIcons = false;
_showPOI = true;
_showPOILabels = true;
_showPOIIcons = false;
_overlapPOIs = true;
_showRouteWaypoints = true;
_showMarkers = true;
@ -169,6 +171,7 @@ PathItem *MapView::addRoute(const Route &route)
ri->setVisible(_showRoutes);
ri->showWaypoints(_showRouteWaypoints);
ri->showWaypointLabels(_showWaypointLabels);
ri->showWaypointIcons(_showWaypointLabels);
ri->setDigitalZoom(_digitalZoom);
ri->setMarkerColor(_markerColor);
ri->showMarker(_showMarkers);
@ -217,6 +220,7 @@ void MapView::addWaypoints(const QVector<Waypoint> &waypoints)
wi->setSize(_waypointSize);
wi->setColor(_waypointColor);
wi->showLabel(_showWaypointLabels);
wi->showIcon(_showWaypointIcons);
wi->setVisible(_showWaypoints);
wi->setDigitalZoom(_digitalZoom);
_scene->addItem(wi);
@ -478,6 +482,7 @@ void MapView::addPOI(const QList<Waypoint> &waypoints)
pi->setSize(_poiSize);
pi->setColor(_poiColor);
pi->showLabel(_showPOILabels);
pi->showIcon(_showPOIIcons);
pi->setVisible(_showPOI);
pi->setDigitalZoom(_digitalZoom);
_scene->addItem(pi);
@ -492,9 +497,9 @@ void MapView::setUnits(Units units)
PathItem::setUnits(units);
for (int i = 0; i < _tracks.count(); i++)
_tracks[i]->updateTicks();
_tracks.at(i)->updateTicks();
for (int i = 0; i < _routes.count(); i++)
_routes[i]->updateTicks();
_routes.at(i)->updateTicks();
_mapScale->setUnits(units);
}
@ -505,9 +510,9 @@ void MapView::setCoordinatesFormat(CoordinatesFormat format)
PathItem::setCoordinatesFormat(format);
for (int i = 0; i < _tracks.count(); i++)
_tracks[i]->updateMarkerInfo();
_tracks.at(i)->updateMarkerInfo();
for (int i = 0; i < _routes.count(); i++)
_routes[i]->updateMarkerInfo();
_routes.at(i)->updateMarkerInfo();
_coordinates->setFormat(format);
}
@ -518,9 +523,9 @@ void MapView::setTimeZone(const QTimeZone &zone)
PathItem::setTimeZone(zone);
for (int i = 0; i < _tracks.count(); i++)
_tracks[i]->updateMarkerInfo();
_tracks.at(i)->updateMarkerInfo();
for (int i = 0; i < _routes.count(); i++)
_routes[i]->updateMarkerInfo();
_routes.at(i)->updateMarkerInfo();
}
void MapView::clearMapCache()
@ -819,6 +824,16 @@ void MapView::showWaypointLabels(bool show)
_routes.at(i)->showWaypointLabels(show);
}
void MapView::showWaypointIcons(bool show)
{
_showWaypointIcons = show;
for (int i = 0; i < _waypoints.size(); i++)
_waypoints.at(i)->showIcon(show);
for (int i = 0; i < _routes.size(); i++)
_routes.at(i)->showWaypointIcons(show);
}
void MapView::showRouteWaypoints(bool show)
{
_showRouteWaypoints = show;
@ -884,6 +899,17 @@ void MapView::showPOILabels(bool show)
updatePOIVisibility();
}
void MapView::showPOIIcons(bool show)
{
_showPOIIcons = show;
for (POIHash::const_iterator it = _pois.constBegin();
it != _pois.constEnd(); it++)
it.value()->showIcon(show);
updatePOIVisibility();
}
void MapView::showCoordinates(bool show)
{
_coordinates->setVisible(show);

View File

@ -95,12 +95,14 @@ public slots:
void showMap(bool show);
void showPOI(bool show);
void showPOILabels(bool show);
void showPOIIcons(bool show);
void showCoordinates(bool show);
void showTicks(bool show);
void showMarkers(bool show);
void showMarkerInfo(MarkerInfoItem::Type type);
void showOverlappedPOIs(bool show);
void showWaypointLabels(bool show);
void showWaypointIcons(bool show);
void showTracks(bool show);
void showRoutes(bool show);
void showAreas(bool show);
@ -165,7 +167,7 @@ private:
bool _showMap, _showTracks, _showRoutes, _showAreas, _showWaypoints,
_showWaypointLabels, _showPOI, _showPOILabels, _showRouteWaypoints,
_showMarkers, _showPathTicks;
_showMarkers, _showPathTicks, _showPOIIcons, _showWaypointIcons;
MarkerInfoItem::Type _markerInfoType;
bool _overlapPOIs;
int _trackWidth, _routeWidth, _areaWidth;

View File

@ -53,7 +53,7 @@ RouteItem::RouteItem(const Route &route, Map *map, QGraphicsItem *parent)
void RouteItem::setMap(Map *map)
{
for (int i = 0; i < _waypoints.count(); i++)
_waypoints[i]->setMap(map);
_waypoints.at(i)->setMap(map);
PathItem::setMap(map);
}
@ -61,19 +61,25 @@ void RouteItem::setMap(Map *map)
void RouteItem::showWaypoints(bool show)
{
for (int i = 0; i < _waypoints.count(); i++)
_waypoints[i]->setVisible(show);
_waypoints.at(i)->setVisible(show);
}
void RouteItem::showWaypointLabels(bool show)
{
for (int i = 0; i < _waypoints.count(); i++)
_waypoints[i]->showLabel(show);
_waypoints.at(i)->showLabel(show);
}
void RouteItem::showWaypointIcons(bool show)
{
for (int i = 0; i < _waypoints.count(); i++)
_waypoints.at(i)->showIcon(show);
}
void RouteItem::setDigitalZoom(int zoom)
{
for (int i = 0; i < _waypoints.count(); i++)
_waypoints[i]->setDigitalZoom(zoom);
_waypoints.at(i)->setDigitalZoom(zoom);
PathItem::setDigitalZoom(zoom);
}

View File

@ -20,6 +20,7 @@ public:
void showWaypoints(bool show);
void showWaypointLabels(bool show);
void showWaypointIcons(bool show);
ToolTip info() const;
QDateTime date() const {return QDateTime();}

View File

@ -40,6 +40,9 @@
#define POI_SETTINGS_GROUP "POI"
#define OVERLAP_POI_SETTING "overlap"
#define OVERLAP_POI_DEFAULT false
#define SHOW_POI_ICONS_SETTING "icons"
#define SHOW_POI_ICONS_DEFAULT true
#define SHOW_POI_LABELS_SETTING "labels"
#define SHOW_POI_LABELS_DEFAULT true
#define SHOW_POI_SETTING "show"
@ -58,6 +61,8 @@
#define SHOW_AREAS_DEFAULT true
#define SHOW_ROUTE_WAYPOINTS_SETTING "routeWaypoints"
#define SHOW_ROUTE_WAYPOINTS_DEFAULT true
#define SHOW_WAYPOINT_ICONS_SETTING "waypointIcons"
#define SHOW_WAYPOINT_ICONS_DEFAULT false
#define SHOW_WAYPOINT_LABELS_SETTING "waypointLabels"
#define SHOW_WAYPOINT_LABELS_DEFAULT true
#define SHOW_MARKERS_SETTING "positionMarkers"

View File

@ -44,6 +44,8 @@ ToolTip WaypointItem::info() const
&& _waypoint.comment() != _waypoint.description())
tt.insert(qApp->translate("WaypointItem", "Comment"),
_waypoint.comment());
if (!_waypoint.symbol().isEmpty())
tt.insert(qApp->translate("WaypointItem", "Symbol"), _waypoint.symbol());
if (!_waypoint.address().isEmpty()) {
QString addr(_waypoint.address());
addr.replace('\n', "<br/>");
@ -63,6 +65,7 @@ ToolTip WaypointItem::info() const
}
tt.insert(qApp->translate("WaypointItem", "Links"), links);
}
tt.setImages(_waypoint.images());
return tt;
@ -73,9 +76,14 @@ WaypointItem::WaypointItem(const Waypoint &waypoint, Map *map,
{
_waypoint = waypoint;
_showLabel = true;
_showIcon = false;
_size = 8;
_color = Qt::black;
_icon = (_waypoint.icon().isNull())
? Waypoint::symbolIcon(_waypoint.symbol())
: &_waypoint.icon();
_font.setPixelSize(FS(_size));
_font.setFamily(FONT_FAMILY);
@ -95,11 +103,22 @@ void WaypointItem::updateCache()
QFontMetrics fm(_font);
_labelBB = fm.tightBoundingRect(_waypoint.name());
p.addRect(-pointSize/2, -pointSize/2, pointSize, pointSize);
p.addRect(pointSize/2, pointSize/2, _labelBB.width(), _labelBB.height()
+ fm.descent());
} else
p.addRect(-pointSize/2, -pointSize/2, pointSize, pointSize);
if (_showIcon && _icon) {
p.addRect(-_icon->width()/2.0, -_icon->height(), _icon->width(),
_icon->height());
p.addRect(0, 0, _labelBB.width(), _labelBB.height() + fm.descent());
} else {
p.addRect(-pointSize/2, -pointSize/2, pointSize, pointSize);
p.addRect(pointSize/2, pointSize/2, _labelBB.width(),
_labelBB.height() + fm.descent());
}
} else {
if (_showIcon && _icon)
p.addRect(-_icon->width()/2, -_icon->height(), _icon->width(),
_icon->height());
else
p.addRect(-pointSize/2, -pointSize/2, pointSize, pointSize);
}
_shape = p;
}
@ -115,12 +134,19 @@ void WaypointItem::paint(QPainter *painter,
if (_showLabel) {
painter->setFont(_font);
painter->drawText(pointSize/2 - qMax(_labelBB.x(), 0), pointSize/2
+ _labelBB.height(), _waypoint.name());
if (_showIcon && _icon)
painter->drawText(-qMax(_labelBB.x(), 0), _labelBB.height(),
_waypoint.name());
else
painter->drawText(pointSize/2 - qMax(_labelBB.x(), 0), pointSize/2
+ _labelBB.height(), _waypoint.name());
}
painter->setBrush(QBrush(_color, Qt::SolidPattern));
painter->drawEllipse(-pointSize/2, -pointSize/2, pointSize, pointSize);
if (_showIcon && _icon)
painter->drawPixmap(-_icon->width()/2.0, -_icon->height(), *_icon);
else
painter->drawEllipse(-pointSize/2, -pointSize/2, pointSize, pointSize);
/*
painter->setPen(Qt::red);
@ -159,6 +185,16 @@ void WaypointItem::showLabel(bool show)
updateCache();
}
void WaypointItem::showIcon(bool show)
{
if (_showIcon == show)
return;
prepareGeometryChange();
_showIcon = show;
updateCache();
}
void WaypointItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);

View File

@ -23,6 +23,7 @@ public:
void setSize(int size);
void setColor(const QColor &color);
void showLabel(bool show);
void showIcon(bool show);
void setDigitalZoom(int zoom) {setScale(pow(2, -zoom));}
QPainterPath shape() const {return _shape;}
@ -50,8 +51,10 @@ private:
QColor _color;
int _size;
bool _showLabel;
bool _showIcon;
QFont _font;
QRect _labelBB;
const QPixmap *_icon;
static Units _units;
static CoordinatesFormat _format;

View File

@ -11,6 +11,8 @@
#define TILES_DIR "tiles"
#define TRANSLATIONS_DIR "translations"
#define STYLE_DIR "style"
#define SYMBOLS_DIR "symbols"
#define ELLIPSOID_FILE "ellipsoids.csv"
#define GCS_FILE "gcs.csv"
#define PCS_FILE "pcs.csv"
@ -68,6 +70,16 @@ QString ProgramPaths::styleDir(bool writable)
STYLE_DIR, QStandardPaths::LocateDirectory);
}
QString ProgramPaths::symbolsDir(bool writable)
{
if (writable)
return QDir(QStandardPaths::writableLocation(
QStandardPaths::AppDataLocation)).filePath(SYMBOLS_DIR);
else
return QStandardPaths::locate(QStandardPaths::AppDataLocation,
SYMBOLS_DIR, QStandardPaths::LocateDirectory);
}
QString ProgramPaths::tilesDir()
{
return QDir(QStandardPaths::writableLocation(

View File

@ -10,6 +10,7 @@ namespace ProgramPaths
QString csvDir(bool writable = false);
QString demDir(bool writable = false);
QString styleDir(bool writable = false);
QString symbolsDir(bool writable = false);
QString tilesDir();
QString translationsDir();
QString ellipsoidsFile();

View File

@ -10,6 +10,7 @@
#include <QTemporaryDir>
#include "common/garmin.h"
#include "common/textcodec.h"
#include "common/color.h"
#include "address.h"
#include "gpiparser.h"
@ -36,6 +37,14 @@ private:
QString _str;
};
#ifndef QT_NO_DEBUG
QDebug operator<<(QDebug dbg, const TranslatedString &ts)
{
dbg.nospace() << "TS(" << ts.lang() << ", " << ts.str() << ")";
return dbg.space();
}
#endif // QT_NO_DEBUG
class CryptDevice : public QIODevice
{
public:
@ -530,8 +539,22 @@ static quint32 readCamera(DataStream &stream, QVector<Waypoint> &waypoints,
return rs + rh.size;
}
static quint32 readIconId(DataStream &stream, quint16 &id)
{
RecordHeader rh;
quint8 rs;
rs = stream.readRecordHeader(rh);
stream >> id;
if (2 != rh.size)
stream.setStatus(QDataStream::ReadCorruptData);
return rs + rh.size;
}
static quint32 readPOI(DataStream &stream, QVector<Waypoint> &waypoints,
const QString &fileName, int &imgId)
const QString &fileName, int &imgId, QVector<QPair<int, quint16> > &icons)
{
RecordHeader rh;
quint8 rs;
@ -551,7 +574,13 @@ static quint32 readPOI(DataStream &stream, QVector<Waypoint> &waypoints,
waypoints.last().setName(obj.first().str());
while (stream.status() == QDataStream::Ok && ds < rh.size) {
switch(stream.nextHeaderType()) {
quint16 type = stream.nextHeaderType();
switch(type) {
case 4:
{quint16 id;
ds += readIconId(stream, id);
icons.append(QPair<int, quint16>(waypoints.size() - 1, id));}
break;
case 10:
ds += readDescription(stream, waypoints.last());
break;
@ -579,7 +608,8 @@ static quint32 readPOI(DataStream &stream, QVector<Waypoint> &waypoints,
}
static quint32 readSpatialIndex(DataStream &stream, QVector<Waypoint> &waypoints,
QList<Area> &polygons, const QString &fileName, int &imgId)
QList<Area> &polygons, const QString &fileName, int &imgId,
QVector<QPair<int, quint16> > &icons)
{
RecordHeader rh;
quint32 ds, s5;
@ -595,11 +625,12 @@ static quint32 readSpatialIndex(DataStream &stream, QVector<Waypoint> &waypoints
while (stream.status() == QDataStream::Ok && ds < rh.size) {
switch(stream.nextHeaderType()) {
case 2:
ds += readPOI(stream, waypoints, fileName, imgId);
ds += readPOI(stream, waypoints, fileName, imgId,
icons);
break;
case 8:
ds += readSpatialIndex(stream, waypoints, polygons,
fileName, imgId);
fileName, imgId, icons);
break;
case 19:
ds += readCamera(stream, waypoints, polygons);
@ -616,31 +647,89 @@ static quint32 readSpatialIndex(DataStream &stream, QVector<Waypoint> &waypoints
return rs + rh.size;
}
static quint32 readSymbol(DataStream &stream, QPixmap &pixmap)
{
RecordHeader rh;
quint8 rs, u8, bpp, transparent;
quint32 ds = 36, u32, imageSize, paletteSize, bgColor;
quint16 id, height, width, lineSize;
QByteArray data;
QVector<QRgb> palette;
QImage img;
rs = stream.readRecordHeader(rh);
stream >> id >> height >> width >> lineSize >> bpp >> u8 >> u8 >> u8
>> imageSize >> u32 >> paletteSize >> bgColor >> transparent >> u8 >> u8
>> u8 >> u32;
if (imageSize) {
data.resize(imageSize);
stream.readRawData(data.data(), data.size());
ds += data.size();
}
if (paletteSize) {
quint32 rgb;
palette.resize(paletteSize);
for (quint32 i = 0; i < paletteSize; i++) {
stream >> rgb;
palette[i] = (transparent && rgb == bgColor)
? QRgb(0)
: Color::rgb((rgb & 0x000000FF), (rgb & 0x0000FF00) >> 8,
(rgb & 0x00FF0000) >> 16);
}
ds += paletteSize * 4;
}
if (paletteSize) {
img = QImage((uchar*)data.data(), width, height, lineSize,
QImage::Format_Indexed8);
img.setColorTable(palette);
} else
img = QImage((uchar*)data.data(), width, height, lineSize,
QImage::Format_RGB32);
pixmap = QPixmap::fromImage(img);
if (ds != rh.size)
stream.setStatus(QDataStream::ReadCorruptData);
return rs + rh.size;
}
static void readPOIDatabase(DataStream &stream, QVector<Waypoint> &waypoints,
QList<Area> &polygons, const QString &fileName, int &imgId)
{
RecordHeader rh;
QList<TranslatedString> obj;
quint32 ds;
QVector<QPair<int, quint16> > il;
QVector<QPixmap> icons;
stream.readRecordHeader(rh);
ds = stream.readTranslatedObjects(obj);
ds += readSpatialIndex(stream, waypoints, polygons, fileName, imgId);
ds += readSpatialIndex(stream, waypoints, polygons, fileName, imgId, il);
if (rh.flags & 0x8) {
while (stream.status() == QDataStream::Ok && ds < rh.size) {
switch(stream.nextHeaderType()) {
quint16 type = stream.nextHeaderType();
switch(type) {
case 5:
icons.append(QPixmap());
ds += readSymbol(stream, icons.last());
break;
case 8:
ds += readSpatialIndex(stream, waypoints, polygons,
fileName, imgId);
fileName, imgId, il);
break;
case 5: // symbol
case 7: // category
default:
ds += stream.skipRecord();
}
}
}
for (int i = 0; i < il.size(); i++) {
const QPair<int, quint16> &e = il.at(i);
if (e.second < icons.size())
waypoints[e.first].setIcon(icons.at(e.second));
}
if (ds != rh.size)
stream.setStatus(QDataStream::ReadCorruptData);
}
@ -652,7 +741,7 @@ bool GPIParser::readData(DataStream &stream, QVector<Waypoint> &waypoints,
while (stream.status() == QDataStream::Ok) {
switch (stream.nextHeaderType()) {
case 0x09: // POI database
case 0x09:
readPOIDatabase(stream, waypoints, polygons, fileName,
imgId);
break;
@ -661,8 +750,6 @@ bool GPIParser::readData(DataStream &stream, QVector<Waypoint> &waypoints,
if (stream.status() == QDataStream::Ok)
return true;
break;
case 0x16: // route
case 0x15: // info header
default:
stream.skipRecord();
}

View File

@ -205,6 +205,8 @@ void GPXParser::waypointData(Waypoint &waypoint, SegmentData *autoRoute)
link10.setText(_reader.readElementText());
else if (_reader.name() == QLatin1String("extensions"))
waypointExtensions(waypoint, autoRoute);
else if (_reader.name() == QLatin1String("sym"))
waypoint.setSymbol(_reader.readElementText());
else
_reader.skipCurrentElement();
}

View File

@ -1,8 +1,11 @@
#include <QDir>
#include <QFileInfo>
#include "dem.h"
#include "waypoint.h"
bool Waypoint::_useDEM = false;
bool Waypoint::_show2ndElevation = false;
QHash<QString, QPixmap> Waypoint::_symbolIcons;
QPair<qreal, qreal> Waypoint::elevations() const
{
@ -21,3 +24,26 @@ QPair<qreal, qreal> Waypoint::elevations() const
return QPair<qreal, qreal>(DEM::elevation(coordinates()), NAN);
}
}
void Waypoint::loadSymbolIcons(const QString &dir)
{
QDir d(dir);
QFileInfoList files(d.entryInfoList(QDir::Files | QDir::Readable));
for (int i = 0; i < files.size(); i++) {
QPixmap pm(files.at(i).absoluteFilePath());
if (pm.isNull())
qWarning("%s: error loading image",
qPrintable(files.at(i).absoluteFilePath()));
else
_symbolIcons.insert(files.at(i).baseName(), pm);
}
}
const QPixmap *Waypoint::symbolIcon(const QString &symbol)
{
if (symbol.isEmpty())
return 0;
QHash<QString, QPixmap>::const_iterator it(_symbolIcons.find(symbol));
return (it == _symbolIcons.constEnd()) ? 0 : &*it;
}

View File

@ -5,6 +5,7 @@
#include <QDateTime>
#include <QHash>
#include <QVector>
#include <QPixmap>
#include <QDebug>
#include "common/config.h"
#include "common/coordinates.h"
@ -24,10 +25,12 @@ public:
const QString &comment() const {return _comment;}
const QString &address() const {return _address;}
const QString &phone() const {return _phone;}
const QString &symbol() const {return _symbol;}
const QVector<QString> &images() const {return _images;}
const QVector<Link> &links() const {return _links;}
const QDateTime &timestamp() const {return _timestamp;}
qreal elevation() const {return _elevation;}
const QPixmap &icon() const {return _icon;}
QPair<qreal, qreal> elevations() const;
@ -39,10 +42,12 @@ public:
void setComment(const QString &comment) {_comment = comment;}
void setAddress(const QString &address) {_address = address;}
void setPhone(const QString &phone) {_phone = phone;}
void setSymbol(const QString &symbol) {_symbol = symbol;}
void setTimestamp(const QDateTime &timestamp) {_timestamp = timestamp;}
void setElevation(qreal elevation) {_elevation = elevation;}
void addImage(const QString &path) {_images.append(path);}
void addLink(const Link &link) {_links.append(link);}
void setIcon(const QPixmap &icon) {_icon = icon;}
bool hasElevation() const {return !std::isnan(_elevation);}
@ -54,6 +59,9 @@ public:
static void showSecondaryElevation(bool show)
{_show2ndElevation = show;}
static const QPixmap *symbolIcon(const QString &symbol);
static void loadSymbolIcons(const QString &dir);
private:
Coordinates _coordinates;
QString _name;
@ -61,13 +69,16 @@ private:
QString _comment;
QString _address;
QString _phone;
QString _symbol;
QVector<QString> _images;
QVector<Link> _links;
QDateTime _timestamp;
qreal _elevation;
QPixmap _icon;
static bool _useDEM;
static bool _show2ndElevation;
static QHash<QString, QPixmap> _symbolIcons;
};
inline HASH_T qHash(const Waypoint &key)

View File

@ -239,137 +239,137 @@ void Style::defaultPointStyle()
_points[TYPE(0x03)].setTextFontSize(Large);
// POI
_points[0x2a00] = Point(QImage(":/POI/restaurant-11.png"));
_points[0x2a01] = Point(QImage(":/POI/restaurant-11.png"));
_points[0x2a02] = Point(QImage(":/POI/restaurant-noodle-11.png"));
_points[0x2a03] = Point(QImage(":/POI/bbq-11.png"));
_points[0x2a04] = Point(QImage(":/POI/restaurant-noodle-11.png"));
_points[0x2a05] = Point(QImage(":/POI/bakery-11.png"));
_points[0x2a06] = Point(QImage(":/POI/restaurant-11.png"));
_points[0x2a07] = Point(QImage(":/POI/fast-food-11.png"));
_points[0x2a08] = Point(QImage(":/POI/restaurant-pizza-11.png"));
_points[0x2a09] = Point(QImage(":/POI/restaurant-11.png"));
_points[0x2a0a] = Point(QImage(":/POI/restaurant-pizza-11.png"));
_points[0x2a0b] = Point(QImage(":/POI/restaurant-seafood-11.png"));
_points[0x2a0c] = Point(QImage(":/POI/restaurant-11.png"));
_points[0x2a0d] = Point(QImage(":/POI/bakery-11.png"));
_points[0x2a0e] = Point(QImage(":/POI/cafe-11.png"));
_points[0x2a0f] = Point(QImage(":/POI/restaurant-11.png"));
_points[0x2a10] = Point(QImage(":/POI/restaurant-11.png"));
_points[0x2a11] = Point(QImage(":/POI/restaurant-11.png"));
_points[0x2a12] = Point(QImage(":/POI/restaurant-11.png"));
_points[0x2a13] = Point(QImage(":/POI/restaurant-11.png"));
_points[0x2a00] = Point(QImage(":/IMG/restaurant-11.png"));
_points[0x2a01] = Point(QImage(":/IMG/restaurant-11.png"));
_points[0x2a02] = Point(QImage(":/IMG/restaurant-noodle-11.png"));
_points[0x2a03] = Point(QImage(":/IMG/bbq-11.png"));
_points[0x2a04] = Point(QImage(":/IMG/restaurant-noodle-11.png"));
_points[0x2a05] = Point(QImage(":/IMG/bakery-11.png"));
_points[0x2a06] = Point(QImage(":/IMG/restaurant-11.png"));
_points[0x2a07] = Point(QImage(":/IMG/fast-food-11.png"));
_points[0x2a08] = Point(QImage(":/IMG/restaurant-pizza-11.png"));
_points[0x2a09] = Point(QImage(":/IMG/restaurant-11.png"));
_points[0x2a0a] = Point(QImage(":/IMG/restaurant-pizza-11.png"));
_points[0x2a0b] = Point(QImage(":/IMG/restaurant-seafood-11.png"));
_points[0x2a0c] = Point(QImage(":/IMG/restaurant-11.png"));
_points[0x2a0d] = Point(QImage(":/IMG/bakery-11.png"));
_points[0x2a0e] = Point(QImage(":/IMG/cafe-11.png"));
_points[0x2a0f] = Point(QImage(":/IMG/restaurant-11.png"));
_points[0x2a10] = Point(QImage(":/IMG/restaurant-11.png"));
_points[0x2a11] = Point(QImage(":/IMG/restaurant-11.png"));
_points[0x2a12] = Point(QImage(":/IMG/restaurant-11.png"));
_points[0x2a13] = Point(QImage(":/IMG/restaurant-11.png"));
_points[0x2b01] = Point(QImage(":/POI/lodging-11.png"));
_points[0x2b02] = Point(QImage(":/POI/lodging-11.png"));
_points[0x2b03] = Point(QImage(":/POI/campsite-11.png"));
_points[0x2b04] = Point(QImage(":/POI/village-11.png"));
_points[0x2b06] = Point(QImage(":/POI/shelter-11.png"));
_points[0x2b01] = Point(QImage(":/IMG/lodging-11.png"));
_points[0x2b02] = Point(QImage(":/IMG/lodging-11.png"));
_points[0x2b03] = Point(QImage(":/IMG/campsite-11.png"));
_points[0x2b04] = Point(QImage(":/IMG/village-11.png"));
_points[0x2b06] = Point(QImage(":/IMG/shelter-11.png"));
_points[0x2c01] = Point(QImage(":/POI/amusement-park-11.png"));
_points[0x2c02] = Point(QImage(":/POI/museum-11.png"));
_points[0x2c03] = Point(QImage(":/POI/library-11.png"));
_points[0x2c04] = Point(QImage(":/POI/landmark-11.png"));
_points[0x2c05] = Point(QImage(":/POI/school-11.png"));
_points[0x2c06] = Point(QImage(":/POI/garden-11.png"));
_points[0x2c07] = Point(QImage(":/POI/zoo-11.png"));
_points[0x2c08] = Point(QImage(":/POI/soccer-11.png"));
_points[0x2c0a] = Point(QImage(":/POI/bar-11.png"));
_points[0x2c0b] = Point(QImage(":/POI/place-of-worship-11.png"));
_points[0x2c0d] = Point(QImage(":/POI/religious-muslim-11.png"));
_points[0x2c0e] = Point(QImage(":/POI/religious-christian-11.png"));
_points[0x2c10] = Point(QImage(":/POI/religious-jewish-11.png"));
_points[0x2d01] = Point(QImage(":/POI/theatre-11.png"));
_points[0x2d02] = Point(QImage(":/POI/bar-11.png"));
_points[0x2d03] = Point(QImage(":/POI/cinema-11.png"));
_points[0x2d04] = Point(QImage(":/POI/casino-11.png"));
_points[0x2d05] = Point(QImage(":/POI/golf-11.png"));
_points[0x2d06] = Point(QImage(":/POI/skiing-11.png"));
_points[0x2d07] = Point(QImage(":/POI/bowling-alley-11.png"));
_points[0x2d09] = Point(QImage(":/POI/swimming-11.png"));
_points[0x2d0a] = Point(QImage(":/POI/fitness-centre-11.png"));
_points[0x2d0b] = Point(QImage(":/POI/airfield-11.png"));
_points[0x2c01] = Point(QImage(":/IMG/amusement-park-11.png"));
_points[0x2c02] = Point(QImage(":/IMG/museum-11.png"));
_points[0x2c03] = Point(QImage(":/IMG/library-11.png"));
_points[0x2c04] = Point(QImage(":/IMG/landmark-11.png"));
_points[0x2c05] = Point(QImage(":/IMG/school-11.png"));
_points[0x2c06] = Point(QImage(":/IMG/garden-11.png"));
_points[0x2c07] = Point(QImage(":/IMG/zoo-11.png"));
_points[0x2c08] = Point(QImage(":/IMG/soccer-11.png"));
_points[0x2c0a] = Point(QImage(":/IMG/bar-11.png"));
_points[0x2c0b] = Point(QImage(":/IMG/place-of-worship-11.png"));
_points[0x2c0d] = Point(QImage(":/IMG/religious-muslim-11.png"));
_points[0x2c0e] = Point(QImage(":/IMG/religious-christian-11.png"));
_points[0x2c10] = Point(QImage(":/IMG/religious-jewish-11.png"));
_points[0x2d01] = Point(QImage(":/IMG/theatre-11.png"));
_points[0x2d02] = Point(QImage(":/IMG/bar-11.png"));
_points[0x2d03] = Point(QImage(":/IMG/cinema-11.png"));
_points[0x2d04] = Point(QImage(":/IMG/casino-11.png"));
_points[0x2d05] = Point(QImage(":/IMG/golf-11.png"));
_points[0x2d06] = Point(QImage(":/IMG/skiing-11.png"));
_points[0x2d07] = Point(QImage(":/IMG/bowling-alley-11.png"));
_points[0x2d09] = Point(QImage(":/IMG/swimming-11.png"));
_points[0x2d0a] = Point(QImage(":/IMG/fitness-centre-11.png"));
_points[0x2d0b] = Point(QImage(":/IMG/airfield-11.png"));
_points[0x2e02] = Point(QImage(":/POI/grocery-11.png"));
_points[0x2e03] = Point(QImage(":/POI/shop-11.png"));
_points[0x2e05] = Point(QImage(":/POI/pharmacy-11.png"));
_points[0x2e06] = Point(QImage(":/POI/convenience-11.png"));
_points[0x2e07] = Point(QImage(":/POI/clothing-store-11.png"));
_points[0x2e08] = Point(QImage(":/POI/garden-centre-11.png"));
_points[0x2e09] = Point(QImage(":/POI/furniture-11.png"));
_points[0x2e0a] = Point(QImage(":/POI/shop-11.png"));
_points[0x2e0c] = Point(QImage(":/POI/shop-11.png"));
_points[0x2e02] = Point(QImage(":/IMG/grocery-11.png"));
_points[0x2e03] = Point(QImage(":/IMG/shop-11.png"));
_points[0x2e05] = Point(QImage(":/IMG/pharmacy-11.png"));
_points[0x2e06] = Point(QImage(":/IMG/convenience-11.png"));
_points[0x2e07] = Point(QImage(":/IMG/clothing-store-11.png"));
_points[0x2e08] = Point(QImage(":/IMG/garden-centre-11.png"));
_points[0x2e09] = Point(QImage(":/IMG/furniture-11.png"));
_points[0x2e0a] = Point(QImage(":/IMG/shop-11.png"));
_points[0x2e0c] = Point(QImage(":/IMG/shop-11.png"));
_points[0x2f01] = Point(QImage(":/POI/fuel-11.png"));
_points[0x2f02] = Point(QImage(":/POI/car-rental-11.png"));
_points[0x2f03] = Point(QImage(":/POI/car-repair-11.png"));
_points[0x2f04] = Point(QImage(":/POI/airport-11.png"));
_points[0x2f05] = Point(QImage(":/POI/post-11.png"));
_points[0x2f06] = Point(QImage(":/POI/bank-11.png"));
_points[0x2f07] = Point(QImage(":/POI/car-11.png"));
_points[0x2f08] = Point(QImage(":/POI/bus-11.png"));
_points[0x2f09] = Point(QImage(":/POI/harbor-11.png"));
_points[0x2f0b] = Point(QImage(":/POI/parking-11.png"));
_points[0x2f01] = Point(QImage(":/IMG/fuel-11.png"));
_points[0x2f02] = Point(QImage(":/IMG/car-rental-11.png"));
_points[0x2f03] = Point(QImage(":/IMG/car-repair-11.png"));
_points[0x2f04] = Point(QImage(":/IMG/airport-11.png"));
_points[0x2f05] = Point(QImage(":/IMG/post-11.png"));
_points[0x2f06] = Point(QImage(":/IMG/bank-11.png"));
_points[0x2f07] = Point(QImage(":/IMG/car-11.png"));
_points[0x2f08] = Point(QImage(":/IMG/bus-11.png"));
_points[0x2f09] = Point(QImage(":/IMG/harbor-11.png"));
_points[0x2f0b] = Point(QImage(":/IMG/parking-11.png"));
_points[0x2f0b].setTextFontSize(None);
_points[0x2f0c] = Point(QImage(":/POI/toilet-11.png"));
_points[0x2f0c] = Point(QImage(":/IMG/toilet-11.png"));
_points[0x2f0c].setTextFontSize(None);
_points[0x2f10] = Point(QImage(":/POI/hairdresser-11.png"));
_points[0x2f10] = Point(QImage(":/IMG/hairdresser-11.png"));
_points[0x2f12].setTextFontSize(None);
_points[0x2f13] = Point(QImage(":/POI/hardware-11.png"));
_points[0x2f17] = Point(QImage(":/POI/bus-11.png"));
_points[0x2f13] = Point(QImage(":/IMG/hardware-11.png"));
_points[0x2f17] = Point(QImage(":/IMG/bus-11.png"));
_points[0x3001] = Point(QImage(":/POI/police-11.png"));
_points[0x3002] = Point(QImage(":/POI/hospital-11.png"));
_points[0x3003] = Point(QImage(":/POI/town-hall-11.png"));
_points[0x3006] = Point(QImage(":/POI/entrance-alt1-11.png"));
_points[0x3007] = Point(QImage(":/POI/town-hall-11.png"));
_points[0x3008] = Point(QImage(":/POI/fire-station-11.png"));
_points[0x3001] = Point(QImage(":/IMG/police-11.png"));
_points[0x3002] = Point(QImage(":/IMG/hospital-11.png"));
_points[0x3003] = Point(QImage(":/IMG/town-hall-11.png"));
_points[0x3006] = Point(QImage(":/IMG/entrance-alt1-11.png"));
_points[0x3007] = Point(QImage(":/IMG/town-hall-11.png"));
_points[0x3008] = Point(QImage(":/IMG/fire-station-11.png"));
_points[0x4000] = Point(QImage(":/POI/golf-11.png"));
_points[0x4300] = Point(QImage(":/POI/harbor-11.png"));
_points[0x4400] = Point(QImage(":/POI/fuel-11.png"));
_points[0x4500] = Point(QImage(":/POI/restaurant-11.png"));
_points[0x4600] = Point(QImage(":/POI/bar-11.png"));
_points[0x4900] = Point(QImage(":/POI/park-11.png"));
_points[0x4a00] = Point(QImage(":/POI/picnic-site-11.png"));
_points[0x4c00] = Point(QImage(":/POI/information-11.png"));
_points[0x4800] = Point(QImage(":/POI/campsite-11.png"));
_points[0x4a00] = Point(QImage(":/POI/picnic-site-11.png"));
_points[0x4b00] = Point(QImage(":/POI/hospital-11.png"));
_points[0x4c00] = Point(QImage(":/POI/information-11.png"));
_points[0x4d00] = Point(QImage(":/POI/parking-11.png"));
_points[0x4000] = Point(QImage(":/IMG/golf-11.png"));
_points[0x4300] = Point(QImage(":/IMG/harbor-11.png"));
_points[0x4400] = Point(QImage(":/IMG/fuel-11.png"));
_points[0x4500] = Point(QImage(":/IMG/restaurant-11.png"));
_points[0x4600] = Point(QImage(":/IMG/bar-11.png"));
_points[0x4900] = Point(QImage(":/IMG/park-11.png"));
_points[0x4a00] = Point(QImage(":/IMG/picnic-site-11.png"));
_points[0x4c00] = Point(QImage(":/IMG/information-11.png"));
_points[0x4800] = Point(QImage(":/IMG/campsite-11.png"));
_points[0x4a00] = Point(QImage(":/IMG/picnic-site-11.png"));
_points[0x4b00] = Point(QImage(":/IMG/hospital-11.png"));
_points[0x4c00] = Point(QImage(":/IMG/information-11.png"));
_points[0x4d00] = Point(QImage(":/IMG/parking-11.png"));
_points[0x4d00].setTextFontSize(None);
_points[0x4e00] = Point(QImage(":/POI/toilet-11.png"));
_points[0x4e00] = Point(QImage(":/IMG/toilet-11.png"));
_points[0x4e00].setTextFontSize(None);
_points[0x5000] = Point(QImage(":/POI/drinking-water-11.png"));
_points[0x5000] = Point(QImage(":/IMG/drinking-water-11.png"));
_points[0x5000].setTextFontSize(None);
_points[0x5100] = Point(QImage(":/POI/telephone-11.png"));
_points[0x5200] = Point(QImage(":/POI/viewpoint-11.png"));
_points[0x5300] = Point(QImage(":/POI/skiing-11.png"));
_points[0x5400] = Point(QImage(":/POI/swimming-11.png"));
_points[0x5500] = Point(QImage(":/POI/dam-11.png"));
_points[0x5700] = Point(QImage(":/POI/danger-11.png"));
_points[0x5800] = Point(QImage(":/POI/roadblock-11.png"));
_points[0x5900] = Point(QImage(":/POI/airport-11.png"));
_points[0x5901] = Point(QImage(":/POI/airport-11.png"));
_points[0x5904] = Point(QImage(":/POI/heliport-11.png"));
_points[0x5100] = Point(QImage(":/IMG/telephone-11.png"));
_points[0x5200] = Point(QImage(":/IMG/viewpoint-11.png"));
_points[0x5300] = Point(QImage(":/IMG/skiing-11.png"));
_points[0x5400] = Point(QImage(":/IMG/swimming-11.png"));
_points[0x5500] = Point(QImage(":/IMG/dam-11.png"));
_points[0x5700] = Point(QImage(":/IMG/danger-11.png"));
_points[0x5800] = Point(QImage(":/IMG/roadblock-11.png"));
_points[0x5900] = Point(QImage(":/IMG/airport-11.png"));
_points[0x5901] = Point(QImage(":/IMG/airport-11.png"));
_points[0x5904] = Point(QImage(":/IMG/heliport-11.png"));
_points[0x6401] = Point(QImage(":/POI/bridge-11.png"));
_points[0x6402] = Point(QImage(":/POI/building-alt1-11.png"));
_points[0x6403] = Point(QImage(":/POI/cemetery-11.png"));
_points[0x6404] = Point(QImage(":/POI/religious-christian-11.png"));
_points[0x6407] = Point(QImage(":/POI/dam-11.png"));
_points[0x6408] = Point(QImage(":/POI/hospital-11.png"));
_points[0x6409] = Point(QImage(":/POI/dam-11.png"));
_points[0x640d] = Point(QImage(":/POI/communications-tower-11.png"));
_points[0x640e] = Point(QImage(":/POI/park-11.png"));
_points[0x640f] = Point(QImage(":/POI/post-11.png"));
_points[0x6411] = Point(QImage(":/POI/communications-tower-11.png"));
_points[0x6401] = Point(QImage(":/IMG/bridge-11.png"));
_points[0x6402] = Point(QImage(":/IMG/building-alt1-11.png"));
_points[0x6403] = Point(QImage(":/IMG/cemetery-11.png"));
_points[0x6404] = Point(QImage(":/IMG/religious-christian-11.png"));
_points[0x6407] = Point(QImage(":/IMG/dam-11.png"));
_points[0x6408] = Point(QImage(":/IMG/hospital-11.png"));
_points[0x6409] = Point(QImage(":/IMG/dam-11.png"));
_points[0x640d] = Point(QImage(":/IMG/communications-tower-11.png"));
_points[0x640e] = Point(QImage(":/IMG/park-11.png"));
_points[0x640f] = Point(QImage(":/IMG/post-11.png"));
_points[0x6411] = Point(QImage(":/IMG/communications-tower-11.png"));
_points[0x6508] = Point(QImage(":/POI/waterfall-11.png"));
_points[0x6513] = Point(QImage(":/POI/wetland-11.png"));
_points[0x6604] = Point(QImage(":/POI/beach-11.png"));
_points[0x6616] = Point(QImage(":/POI/mountain-11.png"));
_points[0x6508] = Point(QImage(":/IMG/waterfall-11.png"));
_points[0x6513] = Point(QImage(":/IMG/wetland-11.png"));
_points[0x6604] = Point(QImage(":/IMG/beach-11.png"));
_points[0x6616] = Point(QImage(":/IMG/mountain-11.png"));
// NT types

View File

@ -1,11 +1,11 @@
#include <cctype>
#include <QFileInfo>
#include <QPainter>
#include "common/color.h"
#include "image.h"
#include "gcs.h"
#include "pcs.h"
#include "calibrationpoint.h"
#include "color.h"
#include "bsbmap.h"

View File

@ -1,7 +1,7 @@
#include <cstring>
#include <QtEndian>
#include <QFile>
#include "color.h"
#include "common/color.h"
#include "ozf.h"

View File

@ -6,11 +6,11 @@
#include <QtEndian>
#include "common/rectc.h"
#include "common/wgs84.h"
#include "common/color.h"
#include "calibrationpoint.h"
#include "utm.h"
#include "pcs.h"
#include "rectd.h"
#include "color.h"
#include "rmap.h"