1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-07-04 14:49:30 +02:00

Compare commits

..

38 Commits
4.16 ... 4.18

Author SHA1 Message Date
5e74642dc8 Version++ 2018-01-06 21:53:13 +01:00
b1d1cae9dd Added support for negative altitude values.
Fixes #46
2018-01-06 21:51:07 +01:00
de2278ba04 Update gpxsee_sv.ts (#44)
New strings translated
2018-01-05 09:34:40 +01:00
e90f152432 Report correct file in error message 2018-01-05 00:06:07 +01:00
8deab1c9ca 6 + the leading A of course... 2018-01-04 17:36:22 +01:00
51e0f9a9c6 A records must only be >= 6, not 9
Fixes #42
2018-01-01 20:59:25 +01:00
e330abe180 Report the correct file on error 2017-12-23 11:10:39 +01:00
53a4b45b7b Fixed broken scene centering in some resize cases 2017-12-07 21:05:00 +01:00
53229681d2 Translations update 2017-12-03 16:52:12 +01:00
b2df7d207f Version++ 2017-12-03 14:21:52 +01:00
1ff2162811 Added the "always show map" option 2017-12-03 14:18:41 +01:00
0f10c7596b Removed some more unneeded code 2017-12-03 13:37:18 +01:00
4cc3bc28e2 Do not clear the image cache between files 2017-12-03 13:07:52 +01:00
3ce1918645 Speed up the osx build 2017-12-03 12:11:54 +01:00
d70f0cf9e0 Added missing QT path on OS X 2017-12-03 12:05:21 +01:00
34c5ba4669 Fixed typos 2017-12-03 11:52:41 +01:00
afbb8c3284 Added Travis CI OS X build 2017-12-03 11:20:30 +01:00
5bdc263cda Moved all the map bounds checking where it belongs 2017-12-03 10:41:07 +01:00
179f2f1451 Removed obsolete code 2017-12-03 10:24:24 +01:00
92e772a02b Fixed some corner case map drawing issues 2017-12-03 10:17:29 +01:00
cbdfe4c105 Added slider/marker color setting 2017-12-03 00:36:52 +01:00
a20a268975 includes cleanup 2017-12-02 20:33:29 +01:00
48e972f920 Include paths unification 2017-12-02 20:28:53 +01:00
c38f50538e Do not use the alpha channel for graphs 2017-12-02 18:24:44 +01:00
53147b5e6e Code cleanup 2017-12-01 22:24:04 +01:00
6c6e384862 Some more code cleanup 2017-12-01 21:27:12 +01:00
90b780a444 Code cleanup 2017-12-01 20:52:34 +01:00
56d1ac7ff2 Fixed broken zoom handling 2017-12-01 19:54:04 +01:00
00acd48009 Fixed some more track display corner cases + refactoring 2017-12-01 00:22:16 +01:00
e30078a63e Code cleanup 2017-11-27 23:50:55 +01:00
51c0c31838 Fixed broken map scale computation 2017-11-27 08:48:37 +01:00
bc218c9f65 Moved the datums initialization where it belongs 2017-11-26 22:52:50 +01:00
56e4c80999 Project structure refactoring 2017-11-26 18:54:03 +01:00
443b916301 Optimization 2017-11-19 23:01:17 +01:00
8675a0e945 Made the Lambert azimuthal equal-area projection naming consistent with other projections namings 2017-11-14 23:30:25 +01:00
0894fb0ddf Added support for Lambert Azimuthal Equal Area projections 2017-11-14 22:17:59 +01:00
73e15f8f11 Includes cleanup 2017-11-14 22:17:09 +01:00
0fe7843e52 Added debug output for tiles 2017-11-14 22:15:46 +01:00
190 changed files with 2159 additions and 1780 deletions

View File

@ -1,4 +1,4 @@
version: 4.16.{build} version: 4.18.{build}
configuration: Release configuration: Release
platform: Any CPU platform: Any CPU
environment: environment:

View File

@ -1,9 +1,18 @@
language: c++ language: c++
os:
- linux
- osx
before_install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get -qq update; fi
install: install:
- sudo apt-get install libqt4-dev - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install qt; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install libqt4-dev; fi
script: script:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then PATH=/usr/local/opt/qt/bin/:${PATH}; fi
- lrelease gpxsee.pro - lrelease gpxsee.pro
- qmake gpxsee.pro - qmake gpxsee.pro
- make - make

View File

@ -1,5 +1,5 @@
TARGET = GPXSee TARGET = GPXSee
VERSION = 4.16 VERSION = 4.18
QT += core \ QT += core \
gui \ gui \
network network
@ -7,179 +7,182 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
greaterThan(QT_MAJOR_VERSION, 4): QT += printsupport greaterThan(QT_MAJOR_VERSION, 4): QT += printsupport
lessThan(QT_VERSION, 5.4): QT += opengl lessThan(QT_VERSION, 5.4): QT += opengl
macx: QT += opengl macx: QT += opengl
INCLUDEPATH += ./src
HEADERS += src/config.h \ HEADERS += src/config.h \
src/icons.h \ src/common/staticassert.h \
src/gui.h \ src/common/coordinates.h \
src/poi.h \ src/common/range.h \
src/rtree.h \ src/common/rectc.h \
src/axisitem.h \ src/common/wgs84.h \
src/keys.h \ src/GUI/app.h \
src/slideritem.h \ src/GUI/icons.h \
src/markeritem.h \ src/GUI/gui.h \
src/infoitem.h \ src/GUI/axisitem.h \
src/elevationgraph.h \ src/GUI/keys.h \
src/speedgraph.h \ src/GUI/slideritem.h \
src/sliderinfoitem.h \ src/GUI/markeritem.h \
src/filebrowser.h \ src/GUI/infoitem.h \
src/map.h \ src/GUI/elevationgraph.h \
src/onlinemap.h \ src/GUI/speedgraph.h \
src/downloader.h \ src/GUI/sliderinfoitem.h \
src/units.h \ src/GUI/filebrowser.h \
src/scaleitem.h \ src/GUI/units.h \
src/waypoint.h \ src/GUI/scaleitem.h \
src/track.h \ src/GUI/graphview.h \
src/graphview.h \ src/GUI/waypointitem.h \
src/trackpoint.h \ src/GUI/palette.h \
src/waypointitem.h \ src/GUI/heartrategraph.h \
src/palette.h \ src/GUI/trackinfo.h \
src/heartrategraph.h \ src/GUI/exportdialog.h \
src/range.h \ src/GUI/fileselectwidget.h \
src/cpuarch.h \ src/GUI/margins.h \
src/settings.h \ src/GUI/temperaturegraph.h \
src/app.h \ src/GUI/graphtab.h \
src/trackinfo.h \ src/GUI/trackitem.h \
src/exportdialog.h \ src/GUI/tooltip.h \
src/fileselectwidget.h \ src/GUI/routeitem.h \
src/margins.h \ src/GUI/graphitem.h \
src/temperaturegraph.h \ src/GUI/pathitem.h \
src/graphtab.h \ src/GUI/griditem.h \
src/misc.h \ src/GUI/format.h \
src/trackitem.h \ src/GUI/cadencegraph.h \
src/tooltip.h \ src/GUI/powergraph.h \
src/route.h \ src/GUI/optionsdialog.h \
src/routeitem.h \ src/GUI/colorbox.h \
src/graphitem.h \ src/GUI/stylecombobox.h \
src/graph.h \ src/GUI/opengl.h \
src/pathitem.h \ src/GUI/timetype.h \
src/pathview.h \ src/GUI/percentslider.h \
src/griditem.h \ src/GUI/elevationgraphitem.h \
src/data.h \ src/GUI/speedgraphitem.h \
src/gpxparser.h \ src/GUI/heartrategraphitem.h \
src/tcxparser.h \ src/GUI/temperaturegraphitem.h \
src/parser.h \ src/GUI/cadencegraphitem.h \
src/csvparser.h \ src/GUI/powergraphitem.h \
src/coordinates.h \ src/GUI/oddspinbox.h \
src/tile.h \ src/GUI/settings.h \
src/rd.h \ src/GUI/nicenum.h \
src/wgs84.h \ src/GUI/cpuarch.h \
src/kmlparser.h \ src/GUI/searchpointer.h \
src/trackdata.h \ src/GUI/mapview.h \
src/routedata.h \ src/map/projection.h \
src/fitparser.h \ src/map/ellipsoid.h \
src/format.h \ src/map/datum.h \
src/path.h \ src/map/mercator.h \
src/assert.h \ src/map/transversemercator.h \
src/cadencegraph.h \ src/map/latlon.h \
src/powergraph.h \ src/map/utm.h \
src/igcparser.h \ src/map/lambertconic.h \
src/nmeaparser.h \ src/map/lambertazimuthal.h \
src/optionsdialog.h \ src/map/albersequal.h \
src/colorbox.h \ src/map/map.h \
src/stylecombobox.h \ src/map/maplist.h \
src/opengl.h \ src/map/onlinemap.h \
src/timetype.h \ src/map/downloader.h \
src/emptymap.h \ src/map/tile.h \
src/offlinemap.h \ src/map/emptymap.h \
src/matrix.h \ src/map/offlinemap.h \
src/tar.h \ src/map/tar.h \
src/atlas.h \ src/map/ozf.h \
src/projection.h \ src/map/atlas.h \
src/mercator.h \ src/map/matrix.h \
src/transversemercator.h \ src/map/misc.h \
src/latlon.h \ src/data/graph.h \
src/utm.h \ src/data/poi.h \
src/lambertconic.h \ src/data/waypoint.h \
src/ellipsoid.h \ src/data/track.h \
src/ozf.h \ src/data/route.h \
src/datum.h \ src/data/trackpoint.h \
src/maplist.h \ src/data/data.h \
src/albersequal.h \ src/data/parser.h \
src/oddspinbox.h \ src/data/trackdata.h \
src/rectc.h \ src/data/routedata.h \
src/searchpointer.h \ src/data/path.h \
src/percentslider.h \ src/data/rtree.h \
src/elevationgraphitem.h \ src/data/gpxparser.h \
src/speedgraphitem.h \ src/data/tcxparser.h \
src/heartrategraphitem.h \ src/data/csvparser.h \
src/temperaturegraphitem.h \ src/data/kmlparser.h \
src/cadencegraphitem.h \ src/data/fitparser.h \
src/powergraphitem.h src/data/igcparser.h \
src/data/nmeaparser.h \
src/data/str2int.h
SOURCES += src/main.cpp \ SOURCES += src/main.cpp \
src/gui.cpp \ src/common/coordinates.cpp \
src/poi.cpp \ src/common/rectc.cpp \
src/axisitem.cpp \ src/common/range.cpp \
src/slideritem.cpp \ src/GUI/app.cpp \
src/markeritem.cpp \ src/GUI/gui.cpp \
src/infoitem.cpp \ src/GUI/axisitem.cpp \
src/elevationgraph.cpp \ src/GUI/slideritem.cpp \
src/speedgraph.cpp \ src/GUI/markeritem.cpp \
src/sliderinfoitem.cpp \ src/GUI/infoitem.cpp \
src/filebrowser.cpp \ src/GUI/elevationgraph.cpp \
src/onlinemap.cpp \ src/GUI/speedgraph.cpp \
src/downloader.cpp \ src/GUI/sliderinfoitem.cpp \
src/scaleitem.cpp \ src/GUI/filebrowser.cpp \
src/track.cpp \ src/GUI/scaleitem.cpp \
src/graphview.cpp \ src/GUI/graphview.cpp \
src/waypointitem.cpp \ src/GUI/waypointitem.cpp \
src/palette.cpp \ src/GUI/palette.cpp \
src/heartrategraph.cpp \ src/GUI/heartrategraph.cpp \
src/range.cpp \ src/GUI/trackinfo.cpp \
src/app.cpp \ src/GUI/exportdialog.cpp \
src/trackinfo.cpp \ src/GUI/fileselectwidget.cpp \
src/exportdialog.cpp \ src/GUI/temperaturegraph.cpp \
src/fileselectwidget.cpp \ src/GUI/trackitem.cpp \
src/temperaturegraph.cpp \ src/GUI/tooltip.cpp \
src/trackpoint.cpp \ src/GUI/routeitem.cpp \
src/misc.cpp \ src/GUI/graphitem.cpp \
src/waypoint.cpp \ src/GUI/pathitem.cpp \
src/trackitem.cpp \ src/GUI/griditem.cpp \
src/tooltip.cpp \ src/GUI/format.cpp \
src/route.cpp \ src/GUI/cadencegraph.cpp \
src/routeitem.cpp \ src/GUI/powergraph.cpp \
src/graphitem.cpp \ src/GUI/optionsdialog.cpp \
src/pathitem.cpp \ src/GUI/colorbox.cpp \
src/pathview.cpp \ src/GUI/stylecombobox.cpp \
src/griditem.cpp \ src/GUI/oddspinbox.cpp \
src/data.cpp \ src/GUI/percentslider.cpp \
src/gpxparser.cpp \ src/GUI/elevationgraphitem.cpp \
src/tcxparser.cpp \ src/GUI/speedgraphitem.cpp \
src/csvparser.cpp \ src/GUI/heartrategraphitem.cpp \
src/coordinates.cpp \ src/GUI/temperaturegraphitem.cpp \
src/kmlparser.cpp \ src/GUI/cadencegraphitem.cpp \
src/fitparser.cpp \ src/GUI/powergraphitem.cpp \
src/format.cpp \ src/GUI/nicenum.cpp \
src/graph.cpp \ src/GUI/mapview.cpp \
src/cadencegraph.cpp \ src/map/maplist.cpp \
src/powergraph.cpp \ src/map/onlinemap.cpp \
src/igcparser.cpp \ src/map/downloader.cpp \
src/path.cpp \ src/map/emptymap.cpp \
src/nmeaparser.cpp \ src/map/offlinemap.cpp \
src/optionsdialog.cpp \ src/map/tar.cpp \
src/colorbox.cpp \ src/map/atlas.cpp \
src/stylecombobox.cpp \ src/map/ozf.cpp \
src/emptymap.cpp \ src/map/matrix.cpp \
src/offlinemap.cpp \ src/map/ellipsoid.cpp \
src/matrix.cpp \ src/map/datum.cpp \
src/tar.cpp \ src/map/projection.cpp \
src/atlas.cpp \ src/map/mercator.cpp \
src/mercator.cpp \ src/map/transversemercator.cpp \
src/transversemercator.cpp \ src/map/utm.cpp \
src/utm.cpp \ src/map/lambertconic.cpp \
src/lambertconic.cpp \ src/map/albersequal.cpp \
src/ellipsoid.cpp \ src/map/lambertazimuthal.cpp \
src/ozf.cpp \ src/data/data.cpp \
src/datum.cpp \ src/data/poi.cpp \
src/maplist.cpp \ src/data/track.cpp \
src/albersequal.cpp \ src/data/route.cpp \
src/oddspinbox.cpp \ src/data/path.cpp \
src/rectc.cpp \ src/data/gpxparser.cpp \
src/percentslider.cpp \ src/data/tcxparser.cpp \
src/elevationgraphitem.cpp \ src/data/csvparser.cpp \
src/speedgraphitem.cpp \ src/data/kmlparser.cpp \
src/heartrategraphitem.cpp \ src/data/fitparser.cpp \
src/temperaturegraphitem.cpp \ src/data/igcparser.cpp \
src/cadencegraphitem.cpp \ src/data/nmeaparser.cpp \
src/powergraphitem.cpp src/data/str2int.cpp
RESOURCES += gpxsee.qrc RESOURCES += gpxsee.qrc
TRANSLATIONS = lang/gpxsee_cs.ts \ TRANSLATIONS = lang/gpxsee_cs.ts \
lang/gpxsee_sv.ts \ lang/gpxsee_sv.ts \

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
; The name of the installer ; The name of the installer
Name "GPXSee" Name "GPXSee"
; Program version ; Program version
!define VERSION "4.16" !define VERSION "4.18"
; The file to write ; The file to write
OutFile "GPXSee-${VERSION}.exe" OutFile "GPXSee-${VERSION}.exe"

View File

@ -5,7 +5,7 @@
; The name of the installer ; The name of the installer
Name "GPXSee" Name "GPXSee"
; Program version ; Program version
!define VERSION "4.16" !define VERSION "4.18"
; The file to write ; The file to write
OutFile "GPXSee-${VERSION}_x64.exe" OutFile "GPXSee-${VERSION}_x64.exe"

109
src/GUI/app.cpp Normal file
View File

@ -0,0 +1,109 @@
#include <QtGlobal>
#include <QTranslator>
#include <QLocale>
#include <QFileOpenEvent>
#include <QNetworkProxyFactory>
#include <QLibraryInfo>
#include "map/onlinemap.h"
#include "map/downloader.h"
#include "map/ellipsoid.h"
#include "map/datum.h"
#include "opengl.h"
#include "gui.h"
#include "config.h"
#include "app.h"
App::App(int &argc, char **argv) : QApplication(argc, argv),
_argc(argc), _argv(argv)
{
QTranslator *gpxsee = new QTranslator(this);
QString locale = QLocale::system().name();
gpxsee->load(QString(":/lang/gpxsee_") + locale);
installTranslator(gpxsee);
QTranslator *qt = new QTranslator(this);
qt->load(QLocale::system(), "qt", "_", QLibraryInfo::location(
QLibraryInfo::TranslationsPath));
installTranslator(qt);
#ifdef Q_OS_MAC
setAttribute(Qt::AA_DontShowIconsInMenus);
#endif // Q_OS_MAC
QNetworkProxyFactory::setUseSystemConfiguration(true);
OnlineMap::setDownloader(new Downloader(this));
OPENGL_SET_SAMPLES(4);
loadDatums();
_gui = new GUI();
}
App::~App()
{
delete _gui;
}
void App::run()
{
_gui->show();
for (int i = 1; i < _argc; i++)
_gui->openFile(QString::fromLocal8Bit(_argv[i]));
exec();
}
bool App::event(QEvent *event)
{
if (event->type() == QEvent::FileOpen) {
QFileOpenEvent *e = static_cast<QFileOpenEvent *>(event);
return _gui->openFile(e->file());
}
return QApplication::event(event);
}
void App::loadDatums()
{
QString ef, df;
bool ok = false;
if (QFile::exists(USER_ELLIPSOID_FILE))
ef = USER_ELLIPSOID_FILE;
else if (QFile::exists(GLOBAL_ELLIPSOID_FILE))
ef = GLOBAL_ELLIPSOID_FILE;
else
qWarning("No ellipsoids file found.");
if (QFile::exists(USER_DATUM_FILE))
df = USER_DATUM_FILE;
else if (QFile::exists(GLOBAL_DATUM_FILE))
df = GLOBAL_DATUM_FILE;
else
qWarning("No datums file found.");
if (!ef.isNull() && !df.isNull()) {
if (!Ellipsoid::loadList(ef)) {
if (Ellipsoid::errorLine())
qWarning("%s: parse error on line %d: %s", qPrintable(ef),
Ellipsoid::errorLine(), qPrintable(Ellipsoid::errorString()));
else
qWarning("%s: %s", qPrintable(ef), qPrintable(
Ellipsoid::errorString()));
} else {
if (!Datum::loadList(df)) {
if (Datum::errorLine())
qWarning("%s: parse error on line %d: %s", qPrintable(df),
Datum::errorLine(), qPrintable(Datum::errorString()));
else
qWarning("%s: %s", qPrintable(df), qPrintable(
Datum::errorString()));
} else
ok = true;
}
}
if (!ok)
qWarning("Maps based on a datum different from WGS84 won't work.");
}

View File

@ -18,6 +18,8 @@ protected:
bool event(QEvent *event); bool event(QEvent *event);
private: private:
void loadDatums();
int &_argc; int &_argc;
char **_argv; char **_argv;
GUI *_gui; GUI *_gui;

View File

@ -1,7 +1,7 @@
#include <cmath> #include <cmath>
#include <QPainter> #include <QPainter>
#include "config.h" #include "config.h"
#include "misc.h" #include "nicenum.h"
#include "axisitem.h" #include "axisitem.h"

View File

@ -2,7 +2,7 @@
#define AXISITEM_H #define AXISITEM_H
#include <QGraphicsItem> #include <QGraphicsItem>
#include "range.h" #include "common/range.h"
class AxisItem : public QGraphicsItem class AxisItem : public QGraphicsItem
{ {

View File

@ -1,4 +1,4 @@
#include "data.h" #include "data/data.h"
#include "cadencegraphitem.h" #include "cadencegraphitem.h"
#include "cadencegraph.h" #include "cadencegraph.h"

View File

@ -1,6 +1,6 @@
#include <cmath> #include <cmath>
#include "data/data.h"
#include "config.h" #include "config.h"
#include "data.h"
#include "tooltip.h" #include "tooltip.h"
#include "elevationgraphitem.h" #include "elevationgraphitem.h"
#include "elevationgraph.h" #include "elevationgraph.h"

View File

@ -1,5 +1,5 @@
#include <QApplication> #include <QApplication>
#include "coordinates.h" #include "common/coordinates.h"
#include "format.h" #include "format.h"
QString Format::timeSpan(qreal time, bool full) QString Format::timeSpan(qreal time, bool full)

View File

@ -3,8 +3,8 @@
#include <QGraphicsObject> #include <QGraphicsObject>
#include <QPen> #include <QPen>
#include "data/graph.h"
#include "units.h" #include "units.h"
#include "graph.h"
class GraphItem : public QGraphicsObject class GraphItem : public QGraphicsObject
{ {

View File

@ -3,6 +3,7 @@
#include <QMouseEvent> #include <QMouseEvent>
#include <QPaintEngine> #include <QPaintEngine>
#include <QPaintDevice> #include <QPaintDevice>
#include "data/graph.h"
#include "opengl.h" #include "opengl.h"
#include "config.h" #include "config.h"
#include "axisitem.h" #include "axisitem.h"
@ -10,7 +11,6 @@
#include "sliderinfoitem.h" #include "sliderinfoitem.h"
#include "infoitem.h" #include "infoitem.h"
#include "griditem.h" #include "griditem.h"
#include "graph.h"
#include "graphitem.h" #include "graphitem.h"
#include "pathitem.h" #include "pathitem.h"
#include "format.h" #include "format.h"
@ -181,9 +181,12 @@ void GraphView::showSliderInfo(bool show)
void GraphView::addGraph(GraphItem *graph, PathItem *path, int id) void GraphView::addGraph(GraphItem *graph, PathItem *path, int id)
{ {
QColor color(_palette.nextColor());
color.setAlpha(255);
graph->setUnits(_units); graph->setUnits(_units);
graph->setId(id); graph->setId(id);
graph->setColor(_palette.nextColor()); graph->setColor(color);
graph->setWidth(_width); graph->setWidth(_width);
connect(this, SIGNAL(sliderPositionChanged(qreal)), graph, connect(this, SIGNAL(sliderPositionChanged(qreal)), graph,
@ -458,8 +461,11 @@ void GraphView::setPalette(const Palette &palette)
_palette = palette; _palette = palette;
_palette.reset(); _palette.reset();
for (int i = 0; i < _graphs.count(); i++) for (int i = 0; i < _graphs.count(); i++) {
_graphs.at(i)->setColor(_palette.nextColor()); QColor color(_palette.nextColor());
color.setAlpha(255);
_graphs.at(i)->setColor(color);
}
} }
void GraphView::setGraphWidth(int width) void GraphView::setGraphWidth(int width)
@ -484,3 +490,9 @@ void GraphView::useAntiAliasing(bool use)
{ {
setRenderHint(QPainter::Antialiasing, use); setRenderHint(QPainter::Antialiasing, use);
} }
void GraphView::setSliderColor(const QColor &color)
{
_slider->setColor(color);
_sliderInfo->setColor(color);
}

View File

@ -4,7 +4,7 @@
#include <QGraphicsView> #include <QGraphicsView>
#include <QList> #include <QList>
#include <QSet> #include <QSet>
#include "graph.h" #include "data/graph.h"
#include "palette.h" #include "palette.h"
#include "units.h" #include "units.h"
@ -38,6 +38,7 @@ public:
void useAntiAliasing(bool use); void useAntiAliasing(bool use);
void setSliderPosition(qreal pos); void setSliderPosition(qreal pos);
void setSliderColor(const QColor &color);
signals: signals:
void sliderPositionChanged(qreal); void sliderPositionChanged(qreal);

View File

@ -22,23 +22,20 @@
#include <QMimeData> #include <QMimeData>
#include <QUrl> #include <QUrl>
#include <QPixmapCache> #include <QPixmapCache>
#include "data/data.h"
#include "map/maplist.h"
#include "map/emptymap.h"
#include "config.h" #include "config.h"
#include "icons.h" #include "icons.h"
#include "keys.h" #include "keys.h"
#include "settings.h" #include "settings.h"
#include "data.h"
#include "ellipsoid.h"
#include "datum.h"
#include "map.h"
#include "maplist.h"
#include "emptymap.h"
#include "elevationgraph.h" #include "elevationgraph.h"
#include "speedgraph.h" #include "speedgraph.h"
#include "heartrategraph.h" #include "heartrategraph.h"
#include "temperaturegraph.h" #include "temperaturegraph.h"
#include "cadencegraph.h" #include "cadencegraph.h"
#include "powergraph.h" #include "powergraph.h"
#include "pathview.h" #include "mapview.h"
#include "trackinfo.h" #include "trackinfo.h"
#include "filebrowser.h" #include "filebrowser.h"
#include "cpuarch.h" #include "cpuarch.h"
@ -49,11 +46,10 @@
GUI::GUI() GUI::GUI()
{ {
loadDatums();
loadMaps(); loadMaps();
loadPOIs(); loadPOIs();
createPathView(); createMapView();
createGraphTabs(); createGraphTabs();
createStatusBar(); createStatusBar();
createActions(); createActions();
@ -65,7 +61,7 @@ GUI::GUI()
QSplitter *splitter = new QSplitter(); QSplitter *splitter = new QSplitter();
splitter->setOrientation(Qt::Vertical); splitter->setOrientation(Qt::Vertical);
splitter->setChildrenCollapsible(false); splitter->setChildrenCollapsible(false);
splitter->addWidget(_pathView); splitter->addWidget(_mapView);
splitter->addWidget(_graphTabWidget); splitter->addWidget(_graphTabWidget);
splitter->setContentsMargins(0, 0, 0, 0); splitter->setContentsMargins(0, 0, 0, 0);
splitter->setStretchFactor(0, 255); splitter->setStretchFactor(0, 255);
@ -87,11 +83,11 @@ GUI::GUI()
_sliderPos = 0; _sliderPos = 0;
updateGraphTabs();
updatePathView();
updateStatusBarInfo();
readSettings(); readSettings();
updateGraphTabs();
updateMapView();
updateStatusBarInfo();
} }
GUI::~GUI() GUI::~GUI()
@ -102,50 +98,6 @@ GUI::~GUI()
} }
} }
void GUI::loadDatums()
{
QString ef, df;
bool ok = false;
if (QFile::exists(USER_ELLIPSOID_FILE))
ef = USER_ELLIPSOID_FILE;
else if (QFile::exists(GLOBAL_ELLIPSOID_FILE))
ef = GLOBAL_ELLIPSOID_FILE;
else
qWarning("No ellipsoids file found.");
if (QFile::exists(USER_DATUM_FILE))
df = USER_DATUM_FILE;
else if (QFile::exists(GLOBAL_DATUM_FILE))
df = GLOBAL_DATUM_FILE;
else
qWarning("No datums file found.");
if (!ef.isNull() && !df.isNull()) {
if (!Ellipsoid::loadList(ef)) {
if (Ellipsoid::errorLine())
qWarning("%s: parse error on line %d: %s", qPrintable(ef),
Ellipsoid::errorLine(), qPrintable(Ellipsoid::errorString()));
else
qWarning("%s: %s", qPrintable(ef), qPrintable(
Ellipsoid::errorString()));
} else {
if (!Datum::loadList(df)) {
if (Datum::errorLine())
qWarning("%s: parse error on line %d: %s", qPrintable(ef),
Datum::errorLine(), qPrintable(Datum::errorString()));
else
qWarning("%s: %s", qPrintable(ef), qPrintable(
Datum::errorString()));
} else
ok = true;
}
}
if (!ok)
qWarning("Maps based on a datum different from WGS84 won't work.");
}
void GUI::loadMaps() void GUI::loadMaps()
{ {
_ml = new MapList(this); _ml = new MapList(this);
@ -334,17 +286,17 @@ void GUI::createActions()
connect(_closePOIAction, SIGNAL(triggered()), this, SLOT(closePOIFiles())); connect(_closePOIAction, SIGNAL(triggered()), this, SLOT(closePOIFiles()));
_overlapPOIAction = new QAction(tr("Overlap POIs"), this); _overlapPOIAction = new QAction(tr("Overlap POIs"), this);
_overlapPOIAction->setCheckable(true); _overlapPOIAction->setCheckable(true);
connect(_overlapPOIAction, SIGNAL(triggered(bool)), _pathView, connect(_overlapPOIAction, SIGNAL(triggered(bool)), _mapView,
SLOT(setPOIOverlap(bool))); SLOT(setPOIOverlap(bool)));
_showPOILabelsAction = new QAction(tr("Show POI labels"), this); _showPOILabelsAction = new QAction(tr("Show POI labels"), this);
_showPOILabelsAction->setCheckable(true); _showPOILabelsAction->setCheckable(true);
connect(_showPOILabelsAction, SIGNAL(triggered(bool)), _pathView, connect(_showPOILabelsAction, SIGNAL(triggered(bool)), _mapView,
SLOT(showPOILabels(bool))); SLOT(showPOILabels(bool)));
_showPOIAction = new QAction(QIcon(QPixmap(SHOW_POI_ICON)), _showPOIAction = new QAction(QIcon(QPixmap(SHOW_POI_ICON)),
tr("Show POIs"), this); tr("Show POIs"), this);
_showPOIAction->setCheckable(true); _showPOIAction->setCheckable(true);
_showPOIAction->setShortcut(SHOW_POI_SHORTCUT); _showPOIAction->setShortcut(SHOW_POI_SHORTCUT);
connect(_showPOIAction, SIGNAL(triggered(bool)), _pathView, connect(_showPOIAction, SIGNAL(triggered(bool)), _mapView,
SLOT(showPOI(bool))); SLOT(showPOI(bool)));
addAction(_showPOIAction); addAction(_showPOIAction);
createPOIFilesActions(); createPOIFilesActions();
@ -354,14 +306,14 @@ void GUI::createActions()
this); this);
_showMapAction->setCheckable(true); _showMapAction->setCheckable(true);
_showMapAction->setShortcut(SHOW_MAP_SHORTCUT); _showMapAction->setShortcut(SHOW_MAP_SHORTCUT);
connect(_showMapAction, SIGNAL(triggered(bool)), _pathView, connect(_showMapAction, SIGNAL(triggered(bool)), _mapView,
SLOT(showMap(bool))); SLOT(showMap(bool)));
addAction(_showMapAction); addAction(_showMapAction);
_loadMapAction = new QAction(QIcon(QPixmap(OPEN_FILE_ICON)), _loadMapAction = new QAction(QIcon(QPixmap(OPEN_FILE_ICON)),
tr("Load map..."), this); tr("Load map..."), this);
connect(_loadMapAction, SIGNAL(triggered()), this, SLOT(loadMap())); connect(_loadMapAction, SIGNAL(triggered()), this, SLOT(loadMap()));
_clearMapCacheAction = new QAction(tr("Clear tile cache"), this); _clearMapCacheAction = new QAction(tr("Clear tile cache"), this);
connect(_clearMapCacheAction, SIGNAL(triggered()), _pathView, connect(_clearMapCacheAction, SIGNAL(triggered()), _mapView,
SLOT(clearMapCache())); SLOT(clearMapCache()));
createMapActions(); createMapActions();
_nextMapAction = new QAction(tr("Next map"), this); _nextMapAction = new QAction(tr("Next map"), this);
@ -388,15 +340,15 @@ void GUI::createActions()
SLOT(showRoutes(bool))); SLOT(showRoutes(bool)));
_showWaypointsAction = new QAction(tr("Show waypoints"), this); _showWaypointsAction = new QAction(tr("Show waypoints"), this);
_showWaypointsAction->setCheckable(true); _showWaypointsAction->setCheckable(true);
connect(_showWaypointsAction, SIGNAL(triggered(bool)), _pathView, connect(_showWaypointsAction, SIGNAL(triggered(bool)), _mapView,
SLOT(showWaypoints(bool))); SLOT(showWaypoints(bool)));
_showWaypointLabelsAction = new QAction(tr("Waypoint labels"), this); _showWaypointLabelsAction = new QAction(tr("Waypoint labels"), this);
_showWaypointLabelsAction->setCheckable(true); _showWaypointLabelsAction->setCheckable(true);
connect(_showWaypointLabelsAction, SIGNAL(triggered(bool)), _pathView, connect(_showWaypointLabelsAction, SIGNAL(triggered(bool)), _mapView,
SLOT(showWaypointLabels(bool))); SLOT(showWaypointLabels(bool)));
_showRouteWaypointsAction = new QAction(tr("Route waypoints"), this); _showRouteWaypointsAction = new QAction(tr("Route waypoints"), this);
_showRouteWaypointsAction->setCheckable(true); _showRouteWaypointsAction->setCheckable(true);
connect(_showRouteWaypointsAction, SIGNAL(triggered(bool)), _pathView, connect(_showRouteWaypointsAction, SIGNAL(triggered(bool)), _mapView,
SLOT(showRouteWaypoints(bool))); SLOT(showRouteWaypoints(bool)));
// Graph actions // Graph actions
@ -586,14 +538,14 @@ void GUI::createToolBars()
_navigationToolBar->addAction(_lastAction); _navigationToolBar->addAction(_lastAction);
} }
void GUI::createPathView() void GUI::createMapView()
{ {
_pathView = new PathView(_map, _poi, this); _mapView = new MapView(_map, _poi, this);
_pathView->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, _mapView->setSizePolicy(QSizePolicy(QSizePolicy::Ignored,
QSizePolicy::Expanding)); QSizePolicy::Expanding));
_pathView->setMinimumHeight(200); _mapView->setMinimumHeight(200);
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
_pathView->setFrameShape(QFrame::NoFrame); _mapView->setFrameShape(QFrame::NoFrame);
#endif // Q_OS_WIN32 #endif // Q_OS_WIN32
} }
@ -755,7 +707,7 @@ bool GUI::openFile(const QString &fileName)
updateStatusBarInfo(); updateStatusBarInfo();
updateWindowTitle(); updateWindowTitle();
updateGraphTabs(); updateGraphTabs();
updatePathView(); updateMapView();
} else { } else {
if (_files.isEmpty()) if (_files.isEmpty())
_fileActionGroup->setEnabled(false); _fileActionGroup->setEnabled(false);
@ -771,7 +723,7 @@ bool GUI::loadFile(const QString &fileName)
QList<PathItem*> paths; QList<PathItem*> paths;
if (data.loadFile(fileName)) { if (data.loadFile(fileName)) {
paths = _pathView->loadData(data); paths = _mapView->loadData(data);
for (int i = 0; i < _tabs.count(); i++) for (int i = 0; i < _tabs.count(); i++)
_tabs.at(i)->loadData(data, paths); _tabs.at(i)->loadData(data, paths);
@ -807,7 +759,7 @@ bool GUI::loadFile(const QString &fileName)
updateStatusBarInfo(); updateStatusBarInfo();
updateWindowTitle(); updateWindowTitle();
updateGraphTabs(); updateGraphTabs();
updatePathView(); updateMapView();
QString error = tr("Error loading data file:") + "\n\n" QString error = tr("Error loading data file:") + "\n\n"
+ fileName + "\n\n" + data.errorString(); + fileName + "\n\n" + data.errorString();
@ -842,7 +794,7 @@ bool GUI::openPOIFile(const QString &fileName)
return false; return false;
} else { } else {
_pathView->showPOI(true); _mapView->showPOI(true);
_showPOIAction->setChecked(true); _showPOIAction->setChecked(true);
QAction *action = createPOIFileAction(_poi->files().indexOf(fileName)); QAction *action = createPOIFileAction(_poi->files().indexOf(fileName));
action->setChecked(true); action->setChecked(true);
@ -867,7 +819,7 @@ void GUI::openOptions()
{ {
#define SET_VIEW_OPTION(option, action) \ #define SET_VIEW_OPTION(option, action) \
if (options.option != _options.option) \ if (options.option != _options.option) \
_pathView->action(options.option) _mapView->action(options.option)
#define SET_TAB_OPTION(option, action) \ #define SET_TAB_OPTION(option, action) \
if (options.option != _options.option) \ if (options.option != _options.option) \
for (int i = 0; i < _tabs.count(); i++) \ for (int i = 0; i < _tabs.count(); i++) \
@ -898,11 +850,13 @@ void GUI::openOptions()
SET_VIEW_OPTION(poiColor, setPOIColor); SET_VIEW_OPTION(poiColor, setPOIColor);
SET_VIEW_OPTION(pathAntiAliasing, useAntiAliasing); SET_VIEW_OPTION(pathAntiAliasing, useAntiAliasing);
SET_VIEW_OPTION(useOpenGL, useOpenGL); SET_VIEW_OPTION(useOpenGL, useOpenGL);
SET_VIEW_OPTION(sliderColor, setMarkerColor);
SET_TAB_OPTION(palette, setPalette); SET_TAB_OPTION(palette, setPalette);
SET_TAB_OPTION(graphWidth, setGraphWidth); SET_TAB_OPTION(graphWidth, setGraphWidth);
SET_TAB_OPTION(graphAntiAliasing, useAntiAliasing); SET_TAB_OPTION(graphAntiAliasing, useAntiAliasing);
SET_TAB_OPTION(useOpenGL, useOpenGL); SET_TAB_OPTION(useOpenGL, useOpenGL);
SET_TAB_OPTION(sliderColor, setSliderColor);
SET_TRACK_OPTION(elevationFilter, setElevationFilter); SET_TRACK_OPTION(elevationFilter, setElevationFilter);
SET_TRACK_OPTION(speedFilter, setSpeedFilter); SET_TRACK_OPTION(speedFilter, setSpeedFilter);
@ -922,6 +876,8 @@ void GUI::openOptions()
reloadFile(); reloadFile();
_options = options; _options = options;
updateMapView();
} }
void GUI::printFile() void GUI::printFile()
@ -966,11 +922,11 @@ void GUI::plot(QPrinter *printer)
info.insert(tr("Name"), _pathName); info.insert(tr("Name"), _pathName);
if (_options.printItemCount) { if (_options.printItemCount) {
if (_trackCount > 1) if (_showTracksAction->isChecked() && _trackCount > 1)
info.insert(tr("Tracks"), QString::number(_trackCount)); info.insert(tr("Tracks"), QString::number(_trackCount));
if (_routeCount > 1) if (_showRoutesAction->isChecked() && _routeCount > 1)
info.insert(tr("Routes"), QString::number(_routeCount)); info.insert(tr("Routes"), QString::number(_routeCount));
if (_waypointCount > 2) if (_showWaypointsAction->isChecked() && _waypointCount > 2)
info.insert(tr("Waypoints"), QString::number(_waypointCount)); info.insert(tr("Waypoints"), QString::number(_waypointCount));
} }
@ -1014,7 +970,7 @@ void GUI::plot(QPrinter *printer)
ratio); ratio);
} else } else
gh = 0; gh = 0;
_pathView->plot(&p, QRectF(0, ih + mh, printer->width(), printer->height() _mapView->plot(&p, QRectF(0, ih + mh, printer->width(), printer->height()
- (ih + 2*mh + gh)), ratio, _options.hiresPrint); - (ih + 2*mh + gh)), ratio, _options.hiresPrint);
if (_graphTabWidget->isVisible() && _options.separateGraphPage) { if (_graphTabWidget->isVisible() && _options.separateGraphPage) {
@ -1054,7 +1010,7 @@ void GUI::reloadFile()
for (int i = 0; i < _tabs.count(); i++) for (int i = 0; i < _tabs.count(); i++)
_tabs.at(i)->clear(); _tabs.at(i)->clear();
_pathView->clear(); _mapView->clear();
_sliderPos = 0; _sliderPos = 0;
@ -1068,7 +1024,7 @@ void GUI::reloadFile()
updateStatusBarInfo(); updateStatusBarInfo();
updateWindowTitle(); updateWindowTitle();
updateGraphTabs(); updateGraphTabs();
updatePathView(); updateMapView();
if (_files.isEmpty()) if (_files.isEmpty())
_fileActionGroup->setEnabled(false); _fileActionGroup->setEnabled(false);
else else
@ -1091,7 +1047,7 @@ void GUI::closeFiles()
for (int i = 0; i < _tabs.count(); i++) for (int i = 0; i < _tabs.count(); i++)
_tabs.at(i)->clear(); _tabs.at(i)->clear();
_pathView->clear(); _mapView->clear();
_files.clear(); _files.clear();
} }
@ -1104,7 +1060,7 @@ void GUI::closeAll()
updateStatusBarInfo(); updateStatusBarInfo();
updateWindowTitle(); updateWindowTitle();
updateGraphTabs(); updateGraphTabs();
updatePathView(); updateMapView();
} }
void GUI::showGraphs(bool show) void GUI::showGraphs(bool show)
@ -1131,7 +1087,7 @@ void GUI::showToolbars(bool show)
void GUI::showFullscreen(bool show) void GUI::showFullscreen(bool show)
{ {
if (show) { if (show) {
_frameStyle = _pathView->frameStyle(); _frameStyle = _mapView->frameStyle();
_showGraphs = _showGraphsAction->isChecked(); _showGraphs = _showGraphsAction->isChecked();
statusBar()->hide(); statusBar()->hide();
@ -1139,7 +1095,7 @@ void GUI::showFullscreen(bool show)
showToolbars(false); showToolbars(false);
showGraphs(false); showGraphs(false);
_showGraphsAction->setChecked(false); _showGraphsAction->setChecked(false);
_pathView->setFrameStyle(QFrame::NoFrame); _mapView->setFrameStyle(QFrame::NoFrame);
showFullScreen(); showFullScreen();
} else { } else {
@ -1150,7 +1106,7 @@ void GUI::showFullscreen(bool show)
_showGraphsAction->setChecked(_showGraphs); _showGraphsAction->setChecked(_showGraphs);
if (_showGraphsAction->isEnabled()) if (_showGraphsAction->isEnabled())
showGraphs(_showGraphs); showGraphs(_showGraphs);
_pathView->setFrameStyle(_frameStyle); _mapView->setFrameStyle(_frameStyle);
showNormal(); showNormal();
} }
@ -1158,22 +1114,24 @@ void GUI::showFullscreen(bool show)
void GUI::showTracks(bool show) void GUI::showTracks(bool show)
{ {
_pathView->showTracks(show); _mapView->showTracks(show);
for (int i = 0; i < _tabs.size(); i++) for (int i = 0; i < _tabs.size(); i++)
_tabs.at(i)->showTracks(show); _tabs.at(i)->showTracks(show);
updateStatusBarInfo(); updateStatusBarInfo();
updateGraphTabs();
} }
void GUI::showRoutes(bool show) void GUI::showRoutes(bool show)
{ {
_pathView->showRoutes(show); _mapView->showRoutes(show);
for (int i = 0; i < _tabs.size(); i++) for (int i = 0; i < _tabs.size(); i++)
_tabs.at(i)->showRoutes(show); _tabs.at(i)->showRoutes(show);
updateStatusBarInfo(); updateStatusBarInfo();
updateGraphTabs();
} }
void GUI::showGraphGrids(bool show) void GUI::showGraphGrids(bool show)
@ -1258,7 +1216,7 @@ void GUI::updateWindowTitle()
void GUI::mapChanged(int index) void GUI::mapChanged(int index)
{ {
_map = _ml->maps().at(index); _map = _ml->maps().at(index);
_pathView->setMap(_map); _mapView->setMap(_map);
} }
void GUI::nextMap() void GUI::nextMap()
@ -1338,7 +1296,9 @@ void GUI::updateGraphTabs()
_graphTabWidget->insertTab(i, tab, _tabs.at(i)->label()); _graphTabWidget->insertTab(i, tab, _tabs.at(i)->label());
} }
if (_graphTabWidget->count()) { if (_graphTabWidget->count() &&
((_showTracksAction->isChecked() && _trackCount)
|| (_showRoutesAction->isChecked() && _routeCount))) {
if (_showGraphsAction->isChecked()) if (_showGraphsAction->isChecked())
_graphTabWidget->setHidden(false); _graphTabWidget->setHidden(false);
_showGraphsAction->setEnabled(true); _showGraphsAction->setEnabled(true);
@ -1348,10 +1308,12 @@ void GUI::updateGraphTabs()
} }
} }
void GUI::updatePathView() void GUI::updateMapView()
{ {
_pathView->setHidden(!(_pathView->trackCount() + _pathView->routeCount() if (_options.alwaysShowMap)
+ _pathView->waypointCount())); _mapView->setHidden(false);
else
_mapView->setHidden(!(_trackCount + _routeCount + _waypointCount));
} }
void GUI::setTimeType(TimeType type) void GUI::setTimeType(TimeType type)
@ -1367,7 +1329,7 @@ void GUI::setUnits(Units units)
_export.units = units; _export.units = units;
_options.units = units; _options.units = units;
_pathView->setUnits(units); _mapView->setUnits(units);
for (int i = 0; i <_tabs.count(); i++) for (int i = 0; i <_tabs.count(); i++)
_tabs.at(i)->setUnits(units); _tabs.at(i)->setUnits(units);
updateStatusBarInfo(); updateStatusBarInfo();
@ -1672,6 +1634,10 @@ void GUI::writeSettings()
if (_options.separateGraphPage != SEPARATE_GRAPH_PAGE_DEFAULT) if (_options.separateGraphPage != SEPARATE_GRAPH_PAGE_DEFAULT)
settings.setValue(SEPARATE_GRAPH_PAGE_SETTING, settings.setValue(SEPARATE_GRAPH_PAGE_SETTING,
_options.separateGraphPage); _options.separateGraphPage);
if (_options.sliderColor != SLIDER_COLOR_DEFAULT)
settings.setValue(SLIDER_COLOR_SETTING, _options.sliderColor);
if (_options.alwaysShowMap != ALWAYS_SHOW_MAP_DEFAULT)
settings.setValue(ALWAYS_SHOW_MAP_SETTING, _options.alwaysShowMap);
settings.endGroup(); settings.endGroup();
} }
@ -1740,17 +1706,17 @@ void GUI::readSettings()
settings.beginGroup(POI_SETTINGS_GROUP); settings.beginGroup(POI_SETTINGS_GROUP);
if (!settings.value(OVERLAP_POI_SETTING, OVERLAP_POI_DEFAULT).toBool()) if (!settings.value(OVERLAP_POI_SETTING, OVERLAP_POI_DEFAULT).toBool())
_pathView->setPOIOverlap(false); _mapView->setPOIOverlap(false);
else else
_overlapPOIAction->setChecked(true); _overlapPOIAction->setChecked(true);
if (!settings.value(LABELS_POI_SETTING, LABELS_POI_DEFAULT).toBool()) if (!settings.value(LABELS_POI_SETTING, LABELS_POI_DEFAULT).toBool())
_pathView->showPOILabels(false); _mapView->showPOILabels(false);
else else
_showPOILabelsAction->setChecked(true); _showPOILabelsAction->setChecked(true);
if (settings.value(SHOW_POI_SETTING, SHOW_POI_DEFAULT).toBool()) if (settings.value(SHOW_POI_SETTING, SHOW_POI_DEFAULT).toBool())
_showPOIAction->setChecked(true); _showPOIAction->setChecked(true);
else else
_pathView->showPOI(false); _mapView->showPOI(false);
for (int i = 0; i < _poiFilesActions.count(); i++) for (int i = 0; i < _poiFilesActions.count(); i++)
_poiFilesActions.at(i)->setChecked(true); _poiFilesActions.at(i)->setChecked(true);
int size = settings.beginReadArray(DISABLED_POI_FILE_SETTINGS_PREFIX); int size = settings.beginReadArray(DISABLED_POI_FILE_SETTINGS_PREFIX);
@ -1768,30 +1734,30 @@ void GUI::readSettings()
settings.beginGroup(DATA_SETTINGS_GROUP); settings.beginGroup(DATA_SETTINGS_GROUP);
if (!settings.value(SHOW_TRACKS_SETTING, SHOW_TRACKS_DEFAULT).toBool()) { if (!settings.value(SHOW_TRACKS_SETTING, SHOW_TRACKS_DEFAULT).toBool()) {
_pathView->showTracks(false); _mapView->showTracks(false);
for (int i = 0; i < _tabs.count(); i++) for (int i = 0; i < _tabs.count(); i++)
_tabs.at(i)->showTracks(false); _tabs.at(i)->showTracks(false);
} else } else
_showTracksAction->setChecked(true); _showTracksAction->setChecked(true);
if (!settings.value(SHOW_ROUTES_SETTING, SHOW_ROUTES_DEFAULT).toBool()) { if (!settings.value(SHOW_ROUTES_SETTING, SHOW_ROUTES_DEFAULT).toBool()) {
_pathView->showRoutes(false); _mapView->showRoutes(false);
for (int i = 0; i < _tabs.count(); i++) for (int i = 0; i < _tabs.count(); i++)
_tabs.at(i)->showRoutes(false); _tabs.at(i)->showRoutes(false);
} else } else
_showRoutesAction->setChecked(true); _showRoutesAction->setChecked(true);
if (!settings.value(SHOW_WAYPOINTS_SETTING, SHOW_WAYPOINTS_DEFAULT) if (!settings.value(SHOW_WAYPOINTS_SETTING, SHOW_WAYPOINTS_DEFAULT)
.toBool()) .toBool())
_pathView->showWaypoints(false); _mapView->showWaypoints(false);
else else
_showWaypointsAction->setChecked(true); _showWaypointsAction->setChecked(true);
if (!settings.value(SHOW_WAYPOINT_LABELS_SETTING, if (!settings.value(SHOW_WAYPOINT_LABELS_SETTING,
SHOW_WAYPOINT_LABELS_DEFAULT).toBool()) SHOW_WAYPOINT_LABELS_DEFAULT).toBool())
_pathView->showWaypointLabels(false); _mapView->showWaypointLabels(false);
else else
_showWaypointLabelsAction->setChecked(true); _showWaypointLabelsAction->setChecked(true);
if (!settings.value(SHOW_ROUTE_WAYPOINTS_SETTING, if (!settings.value(SHOW_ROUTE_WAYPOINTS_SETTING,
SHOW_ROUTE_WAYPOINTS_SETTING).toBool()) SHOW_ROUTE_WAYPOINTS_SETTING).toBool())
_pathView->showRouteWaypoints(false); _mapView->showRouteWaypoints(false);
else else
_showRouteWaypointsAction->setChecked(true); _showRouteWaypointsAction->setChecked(true);
settings.endGroup(); settings.endGroup();
@ -1885,27 +1851,33 @@ void GUI::readSettings()
PRINT_ITEM_COUNT_DEFAULT).toBool(); PRINT_ITEM_COUNT_DEFAULT).toBool();
_options.separateGraphPage = settings.value(SEPARATE_GRAPH_PAGE_SETTING, _options.separateGraphPage = settings.value(SEPARATE_GRAPH_PAGE_SETTING,
SEPARATE_GRAPH_PAGE_DEFAULT).toBool(); SEPARATE_GRAPH_PAGE_DEFAULT).toBool();
_options.sliderColor = settings.value(SLIDER_COLOR_SETTING,
SLIDER_COLOR_DEFAULT).value<QColor>();
_options.alwaysShowMap = settings.value(ALWAYS_SHOW_MAP_SETTING,
ALWAYS_SHOW_MAP_DEFAULT).toBool();
_pathView->setPalette(_options.palette); _mapView->setPalette(_options.palette);
_pathView->setMapOpacity(_options.mapOpacity); _mapView->setMapOpacity(_options.mapOpacity);
_pathView->setBackgroundColor(_options.backgroundColor); _mapView->setBackgroundColor(_options.backgroundColor);
_pathView->setTrackWidth(_options.trackWidth); _mapView->setTrackWidth(_options.trackWidth);
_pathView->setRouteWidth(_options.routeWidth); _mapView->setRouteWidth(_options.routeWidth);
_pathView->setTrackStyle(_options.trackStyle); _mapView->setTrackStyle(_options.trackStyle);
_pathView->setRouteStyle(_options.routeStyle); _mapView->setRouteStyle(_options.routeStyle);
_pathView->setWaypointSize(_options.waypointSize); _mapView->setWaypointSize(_options.waypointSize);
_pathView->setWaypointColor(_options.waypointColor); _mapView->setWaypointColor(_options.waypointColor);
_pathView->setPOISize(_options.poiSize); _mapView->setPOISize(_options.poiSize);
_pathView->setPOIColor(_options.poiColor); _mapView->setPOIColor(_options.poiColor);
_pathView->setRenderHint(QPainter::Antialiasing, _options.pathAntiAliasing); _mapView->setRenderHint(QPainter::Antialiasing, _options.pathAntiAliasing);
_mapView->setMarkerColor(_options.sliderColor);
if (_options.useOpenGL) if (_options.useOpenGL)
_pathView->useOpenGL(true); _mapView->useOpenGL(true);
for (int i = 0; i < _tabs.count(); i++) { for (int i = 0; i < _tabs.count(); i++) {
_tabs.at(i)->setPalette(_options.palette); _tabs.at(i)->setPalette(_options.palette);
_tabs.at(i)->setGraphWidth(_options.graphWidth); _tabs.at(i)->setGraphWidth(_options.graphWidth);
_tabs.at(i)->setRenderHint(QPainter::Antialiasing, _tabs.at(i)->setRenderHint(QPainter::Antialiasing,
_options.graphAntiAliasing); _options.graphAntiAliasing);
_tabs.at(i)->setSliderColor(_options.sliderColor);
if (_options.useOpenGL) if (_options.useOpenGL)
_tabs.at(i)->useOpenGL(true); _tabs.at(i)->useOpenGL(true);
} }

View File

@ -6,14 +6,13 @@
#include <QList> #include <QList>
#include <QDate> #include <QDate>
#include <QPrinter> #include <QPrinter>
#include "data/graph.h"
#include "data/poi.h"
#include "units.h" #include "units.h"
#include "timetype.h" #include "timetype.h"
#include "graph.h"
#include "poi.h"
#include "exportdialog.h" #include "exportdialog.h"
#include "optionsdialog.h" #include "optionsdialog.h"
class QMenu; class QMenu;
class QToolBar; class QToolBar;
class QTabWidget; class QTabWidget;
@ -24,7 +23,7 @@ class QSignalMapper;
class QPrinter; class QPrinter;
class FileBrowser; class FileBrowser;
class GraphTab; class GraphTab;
class PathView; class MapView;
class Map; class Map;
class MapList; class MapList;
@ -82,7 +81,6 @@ private slots:
private: private:
typedef QPair<QDate, QDate> DateRange; typedef QPair<QDate, QDate> DateRange;
void loadDatums();
void loadMaps(); void loadMaps();
void loadPOIs(); void loadPOIs();
void closeFiles(); void closeFiles();
@ -95,7 +93,7 @@ private:
void createMenus(); void createMenus();
void createToolBars(); void createToolBars();
void createStatusBar(); void createStatusBar();
void createPathView(); void createMapView();
void createGraphTabs(); void createGraphTabs();
void createBrowser(); void createBrowser();
@ -106,7 +104,7 @@ private:
void updateWindowTitle(); void updateWindowTitle();
void updateNavigationActions(); void updateNavigationActions();
void updateGraphTabs(); void updateGraphTabs();
void updatePathView(); void updateMapView();
TimeType timeType() const; TimeType timeType() const;
Units units() const; Units units() const;
@ -187,17 +185,17 @@ private:
QLabel *_distanceLabel; QLabel *_distanceLabel;
QLabel *_timeLabel; QLabel *_timeLabel;
PathView *_pathView; MapView *_mapView;
QTabWidget *_graphTabWidget; QTabWidget *_graphTabWidget;
QList<GraphTab*> _tabs; QList<GraphTab*> _tabs;
POI *_poi; POI *_poi;
MapList *_ml; MapList *_ml;
Map *_map;
FileBrowser *_browser; FileBrowser *_browser;
QList<QString> _files; QList<QString> _files;
Map *_map;
int _trackCount; int _trackCount;
int _routeCount; int _routeCount;
int _waypointCount; int _waypointCount;

View File

@ -1,4 +1,4 @@
#include "data.h" #include "data/data.h"
#include "heartrategraphitem.h" #include "heartrategraphitem.h"
#include "heartrategraph.h" #include "heartrategraph.h"

View File

@ -4,17 +4,16 @@
#include <QApplication> #include <QApplication>
#include <QPixmapCache> #include <QPixmapCache>
#include <QScrollBar> #include <QScrollBar>
#include "data/poi.h"
#include "data/data.h"
#include "map/map.h"
#include "opengl.h" #include "opengl.h"
#include "misc.h"
#include "poi.h"
#include "data.h"
#include "map.h"
#include "trackitem.h" #include "trackitem.h"
#include "routeitem.h" #include "routeitem.h"
#include "waypointitem.h" #include "waypointitem.h"
#include "scaleitem.h" #include "scaleitem.h"
#include "keys.h" #include "keys.h"
#include "pathview.h" #include "mapview.h"
#define MAX_DIGITAL_ZOOM 2 #define MAX_DIGITAL_ZOOM 2
@ -22,7 +21,7 @@
#define MARGIN 10.0 #define MARGIN 10.0
#define SCALE_OFFSET 7 #define SCALE_OFFSET 7
PathView::PathView(Map *map, POI *poi, QWidget *parent) MapView::MapView(Map *map, POI *poi, QWidget *parent)
: QGraphicsView(parent) : QGraphicsView(parent)
{ {
Q_ASSERT(map != 0); Q_ASSERT(map != 0);
@ -52,6 +51,7 @@ PathView::PathView(Map *map, POI *poi, QWidget *parent)
_units = Metric; _units = Metric;
_opacity = 1.0; _opacity = 1.0;
_backgroundColor = Qt::white; _backgroundColor = Qt::white;
_markerColor = Qt::red;
_showMap = true; _showMap = true;
_showTracks = true; _showTracks = true;
@ -80,7 +80,7 @@ PathView::PathView(Map *map, POI *poi, QWidget *parent)
centerOn(_scene->sceneRect().center()); centerOn(_scene->sceneRect().center());
} }
void PathView::centerOn(const QPointF &pos) void MapView::centerOn(const QPointF &pos)
{ {
QGraphicsView::centerOn(pos); QGraphicsView::centerOn(pos);
@ -98,7 +98,7 @@ void PathView::centerOn(const QPointF &pos)
_mapScale->setResolution(_res); _mapScale->setResolution(_res);
} }
PathItem *PathView::addTrack(const Track &track) PathItem *MapView::addTrack(const Track &track)
{ {
if (track.isNull()) { if (track.isNull()) {
_palette.nextColor(); _palette.nextColor();
@ -114,14 +114,16 @@ PathItem *PathView::addTrack(const Track &track)
ti->setUnits(_units); ti->setUnits(_units);
ti->setVisible(_showTracks); ti->setVisible(_showTracks);
ti->setDigitalZoom(_digitalZoom); ti->setDigitalZoom(_digitalZoom);
ti->setMarkerColor(_markerColor);
_scene->addItem(ti); _scene->addItem(ti);
addPOI(_poi->points(ti->path())); if (_showTracks)
addPOI(_poi->points(ti->path()));
return ti; return ti;
} }
PathItem *PathView::addRoute(const Route &route) PathItem *MapView::addRoute(const Route &route)
{ {
if (route.isNull()) { if (route.isNull()) {
_palette.nextColor(); _palette.nextColor();
@ -139,21 +141,23 @@ PathItem *PathView::addRoute(const Route &route)
ri->showWaypoints(_showRouteWaypoints); ri->showWaypoints(_showRouteWaypoints);
ri->showWaypointLabels(_showWaypointLabels); ri->showWaypointLabels(_showWaypointLabels);
ri->setDigitalZoom(_digitalZoom); ri->setDigitalZoom(_digitalZoom);
ri->setMarkerColor(_markerColor);
_scene->addItem(ri); _scene->addItem(ri);
addPOI(_poi->points(ri->path())); if (_showRoutes)
addPOI(_poi->points(ri->path()));
return ri; return ri;
} }
void PathView::addWaypoints(const QList<Waypoint> &waypoints) void MapView::addWaypoints(const QList<Waypoint> &waypoints)
{ {
for (int i = 0; i < waypoints.count(); i++) { for (int i = 0; i < waypoints.count(); i++) {
const Waypoint &w = waypoints.at(i); const Waypoint &w = waypoints.at(i);
WaypointItem *wi = new WaypointItem(w, _map); WaypointItem *wi = new WaypointItem(w, _map);
_waypoints.append(wi); _waypoints.append(wi);
updateWaypointsBoundingRect(wi->waypoint().coordinates()); _wr.unite(wi->waypoint().coordinates());
wi->setZValue(1); wi->setZValue(1);
wi->setSize(_waypointSize); wi->setSize(_waypointSize);
wi->setColor(_waypointColor); wi->setColor(_waypointColor);
@ -162,12 +166,13 @@ void PathView::addWaypoints(const QList<Waypoint> &waypoints)
wi->setVisible(_showWaypoints); wi->setVisible(_showWaypoints);
wi->setDigitalZoom(_digitalZoom); wi->setDigitalZoom(_digitalZoom);
_scene->addItem(wi); _scene->addItem(wi);
}
addPOI(_poi->points(waypoints)); if (_showWaypoints)
addPOI(_poi->points(w));
}
} }
QList<PathItem *> PathView::loadData(const Data &data) QList<PathItem *> MapView::loadData(const Data &data)
{ {
QList<PathItem *> paths; QList<PathItem *> paths;
qreal zoom = _map->zoom(); qreal zoom = _map->zoom();
@ -191,29 +196,23 @@ QList<PathItem *> PathView::loadData(const Data &data)
return paths; return paths;
} }
void PathView::updateWaypointsBoundingRect(const Coordinates &wp) qreal MapView::mapZoom() const
{
if (_wr.isNull())
_wr = RectC(wp, wp);
else
_wr.unite(wp);
}
qreal PathView::mapZoom() const
{ {
RectC br = _tr | _rr | _wr; RectC br = _tr | _rr | _wr;
return _map->zoomFit(viewport()->size() - QSize(2*MARGIN, 2*MARGIN), br); return _map->zoomFit(viewport()->size() - QSize(2*MARGIN, 2*MARGIN),
br.isNull() ? RectC(_map->xy2ll(sceneRect().topLeft()),
_map->xy2ll(sceneRect().bottomRight())) : br);
} }
QPointF PathView::contentCenter() const QPointF MapView::contentCenter() const
{ {
RectC br = _tr | _rr | _wr; RectC br = _tr | _rr | _wr;
return _map->ll2xy(br.center()); return br.isNull() ? sceneRect().center() : _map->ll2xy(br.center());
} }
void PathView::updatePOIVisibility() void MapView::updatePOIVisibility()
{ {
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it, jt; QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it, jt;
@ -234,7 +233,7 @@ void PathView::updatePOIVisibility()
} }
} }
void PathView::rescale() void MapView::rescale()
{ {
_scene->setSceneRect(_map->bounds()); _scene->setSceneRect(_map->bounds());
resetCachedContent(); resetCachedContent();
@ -253,7 +252,7 @@ void PathView::rescale()
updatePOIVisibility(); updatePOIVisibility();
} }
void PathView::setPalette(const Palette &palette) void MapView::setPalette(const Palette &palette)
{ {
_palette = palette; _palette = palette;
_palette.reset(); _palette.reset();
@ -264,7 +263,7 @@ void PathView::setPalette(const Palette &palette)
_routes.at(i)->setColor(_palette.nextColor()); _routes.at(i)->setColor(_palette.nextColor());
} }
void PathView::setMap(Map *map) void MapView::setMap(Map *map)
{ {
QPointF pos = mapToScene(viewport()->rect().center()); QPointF pos = mapToScene(viewport()->rect().center());
Coordinates center = _map->xy2ll(pos); Coordinates center = _map->xy2ll(pos);
@ -275,9 +274,10 @@ void PathView::setMap(Map *map)
_map = map; _map = map;
_map->load(); _map->load();
_map->setBackgroundColor(_backgroundColor);
connect(_map, SIGNAL(loaded()), this, SLOT(reloadMap())); connect(_map, SIGNAL(loaded()), this, SLOT(reloadMap()));
resetDigitalZoom(); digitalZoom(0);
_map->zoomFit(resolution, center); _map->zoomFit(resolution, center);
_scene->setSceneRect(_map->bounds()); _scene->setSceneRect(_map->bounds());
@ -300,7 +300,7 @@ void PathView::setMap(Map *map)
QPixmapCache::clear(); QPixmapCache::clear();
} }
void PathView::setPOI(POI *poi) void MapView::setPOI(POI *poi)
{ {
disconnect(_poi, SIGNAL(pointsChanged()), this, SLOT(updatePOI())); disconnect(_poi, SIGNAL(pointsChanged()), this, SLOT(updatePOI()));
connect(poi, SIGNAL(pointsChanged()), this, SLOT(updatePOI())); connect(poi, SIGNAL(pointsChanged()), this, SLOT(updatePOI()));
@ -310,7 +310,7 @@ void PathView::setPOI(POI *poi)
updatePOI(); updatePOI();
} }
void PathView::updatePOI() void MapView::updatePOI()
{ {
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it; QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
@ -320,16 +320,20 @@ void PathView::updatePOI()
} }
_pois.clear(); _pois.clear();
for (int i = 0; i < _tracks.size(); i++) if (_showTracks)
addPOI(_poi->points(_tracks.at(i)->path())); for (int i = 0; i < _tracks.size(); i++)
for (int i = 0; i < _routes.size(); i++) addPOI(_poi->points(_tracks.at(i)->path()));
addPOI(_poi->points(_routes.at(i)->path())); if (_showRoutes)
addPOI(_poi->points(_waypoints)); for (int i = 0; i < _routes.size(); i++)
addPOI(_poi->points(_routes.at(i)->path()));
if (_showWaypoints)
for (int i = 0; i< _waypoints.size(); i++)
addPOI(_poi->points(_waypoints.at(i)->waypoint()));
updatePOIVisibility(); updatePOIVisibility();
} }
void PathView::addPOI(const QVector<Waypoint> &waypoints) void MapView::addPOI(const QList<Waypoint> &waypoints)
{ {
for (int i = 0; i < waypoints.size(); i++) { for (int i = 0; i < waypoints.size(); i++) {
const Waypoint &w = waypoints.at(i); const Waypoint &w = waypoints.at(i);
@ -350,7 +354,7 @@ void PathView::addPOI(const QVector<Waypoint> &waypoints)
} }
} }
void PathView::setUnits(enum Units units) void MapView::setUnits(enum Units units)
{ {
_units = units; _units = units;
@ -368,37 +372,23 @@ void PathView::setUnits(enum Units units)
it.value()->setUnits(units); it.value()->setUnits(units);
} }
void PathView::clearMapCache() void MapView::clearMapCache()
{ {
_map->clearCache(); _map->clearCache();
resetCachedContent(); resetCachedContent();
} }
void PathView::resetDigitalZoom() void MapView::digitalZoom(int zoom)
{ {
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it; QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
_digitalZoom = 0; if (zoom) {
resetTransform(); _digitalZoom += zoom;
scale(pow(2, zoom), pow(2, zoom));
for (int i = 0; i < _tracks.size(); i++) } else {
_tracks.at(i)->setDigitalZoom(0); _digitalZoom = 0;
for (int i = 0; i < _routes.size(); i++) resetTransform();
_routes.at(i)->setDigitalZoom(0); }
for (int i = 0; i < _waypoints.size(); i++)
_waypoints.at(i)->setDigitalZoom(0);
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
it.value()->setDigitalZoom(0);
_mapScale->setDigitalZoom(0);
}
void PathView::digitalZoom(int zoom)
{
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
_digitalZoom += zoom;
scale(pow(2, zoom), pow(2, zoom));
for (int i = 0; i < _tracks.size(); i++) for (int i = 0; i < _tracks.size(); i++)
_tracks.at(i)->setDigitalZoom(_digitalZoom); _tracks.at(i)->setDigitalZoom(_digitalZoom);
@ -412,7 +402,7 @@ void PathView::digitalZoom(int zoom)
_mapScale->setDigitalZoom(_digitalZoom); _mapScale->setDigitalZoom(_digitalZoom);
} }
void PathView::zoom(int zoom, const QPoint &pos, const Coordinates &c) void MapView::zoom(int zoom, const QPoint &pos, const Coordinates &c)
{ {
bool shift = QApplication::keyboardModifiers() & Qt::ShiftModifier; bool shift = QApplication::keyboardModifiers() & Qt::ShiftModifier;
@ -438,7 +428,7 @@ void PathView::zoom(int zoom, const QPoint &pos, const Coordinates &c)
} }
} }
void PathView::wheelEvent(QWheelEvent *event) void MapView::wheelEvent(QWheelEvent *event)
{ {
static int deg = 0; static int deg = 0;
@ -451,7 +441,7 @@ void PathView::wheelEvent(QWheelEvent *event)
zoom((event->delta() > 0) ? 1 : -1, event->pos(), c); zoom((event->delta() > 0) ? 1 : -1, event->pos(), c);
} }
void PathView::mouseDoubleClickEvent(QMouseEvent *event) void MapView::mouseDoubleClickEvent(QMouseEvent *event)
{ {
if (event->button() != Qt::LeftButton && event->button() != Qt::RightButton) if (event->button() != Qt::LeftButton && event->button() != Qt::RightButton)
return; return;
@ -460,7 +450,7 @@ void PathView::mouseDoubleClickEvent(QMouseEvent *event)
zoom((event->button() == Qt::LeftButton) ? 1 : -1, event->pos(), c); zoom((event->button() == Qt::LeftButton) ? 1 : -1, event->pos(), c);
} }
void PathView::keyPressEvent(QKeyEvent *event) void MapView::keyPressEvent(QKeyEvent *event)
{ {
int z; int z;
@ -472,7 +462,7 @@ void PathView::keyPressEvent(QKeyEvent *event)
else if (event->matches(ZOOM_OUT)) else if (event->matches(ZOOM_OUT))
z = -1; z = -1;
else if (_digitalZoom && event->key() == Qt::Key_Escape) { else if (_digitalZoom && event->key() == Qt::Key_Escape) {
resetDigitalZoom(); digitalZoom(0);
return; return;
} else { } else {
QGraphicsView::keyPressEvent(event); QGraphicsView::keyPressEvent(event);
@ -482,7 +472,7 @@ void PathView::keyPressEvent(QKeyEvent *event)
zoom(z, pos, c); zoom(z, pos, c);
} }
void PathView::plot(QPainter *painter, const QRectF &target, qreal scale, void MapView::plot(QPainter *painter, const QRectF &target, qreal scale,
bool hires) bool hires)
{ {
QRect orig, adj; QRect orig, adj;
@ -558,7 +548,7 @@ void PathView::plot(QPainter *painter, const QRectF &target, qreal scale,
setUpdatesEnabled(true); setUpdatesEnabled(true);
} }
void PathView::clear() void MapView::clear()
{ {
_pois.clear(); _pois.clear();
_tracks.clear(); _tracks.clear();
@ -575,36 +565,40 @@ void PathView::clear()
_rr = RectC(); _rr = RectC();
_wr = RectC(); _wr = RectC();
resetDigitalZoom(); digitalZoom(0);
resetCachedContent();
QPixmapCache::clear();
} }
void PathView::showTracks(bool show) void MapView::showTracks(bool show)
{ {
_showTracks = show; _showTracks = show;
for (int i = 0; i < _tracks.count(); i++) for (int i = 0; i < _tracks.count(); i++)
_tracks.at(i)->setVisible(show); _tracks.at(i)->setVisible(show);
updatePOI();
} }
void PathView::showRoutes(bool show) void MapView::showRoutes(bool show)
{ {
_showRoutes = show; _showRoutes = show;
for (int i = 0; i < _routes.count(); i++) for (int i = 0; i < _routes.count(); i++)
_routes.at(i)->setVisible(show); _routes.at(i)->setVisible(show);
updatePOI();
} }
void PathView::showWaypoints(bool show) void MapView::showWaypoints(bool show)
{ {
_showWaypoints = show; _showWaypoints = show;
for (int i = 0; i < _waypoints.count(); i++) for (int i = 0; i < _waypoints.count(); i++)
_waypoints.at(i)->setVisible(show); _waypoints.at(i)->setVisible(show);
updatePOI();
} }
void PathView::showWaypointLabels(bool show) void MapView::showWaypointLabels(bool show)
{ {
_showWaypointLabels = show; _showWaypointLabels = show;
@ -615,7 +609,7 @@ void PathView::showWaypointLabels(bool show)
_routes.at(i)->showWaypointLabels(show); _routes.at(i)->showWaypointLabels(show);
} }
void PathView::showRouteWaypoints(bool show) void MapView::showRouteWaypoints(bool show)
{ {
_showRouteWaypoints = show; _showRouteWaypoints = show;
@ -623,13 +617,13 @@ void PathView::showRouteWaypoints(bool show)
_routes.at(i)->showWaypoints(show); _routes.at(i)->showWaypoints(show);
} }
void PathView::showMap(bool show) void MapView::showMap(bool show)
{ {
_showMap = show; _showMap = show;
resetCachedContent(); resetCachedContent();
} }
void PathView::showPOI(bool show) void MapView::showPOI(bool show)
{ {
_showPOI = show; _showPOI = show;
@ -640,7 +634,7 @@ void PathView::showPOI(bool show)
updatePOIVisibility(); updatePOIVisibility();
} }
void PathView::showPOILabels(bool show) void MapView::showPOILabels(bool show)
{ {
_showPOILabels = show; _showPOILabels = show;
@ -651,14 +645,14 @@ void PathView::showPOILabels(bool show)
updatePOIVisibility(); updatePOIVisibility();
} }
void PathView::setPOIOverlap(bool overlap) void MapView::setPOIOverlap(bool overlap)
{ {
_overlapPOIs = overlap; _overlapPOIs = overlap;
updatePOIVisibility(); updatePOIVisibility();
} }
void PathView::setTrackWidth(int width) void MapView::setTrackWidth(int width)
{ {
_trackWidth = width; _trackWidth = width;
@ -666,7 +660,7 @@ void PathView::setTrackWidth(int width)
_tracks.at(i)->setWidth(width); _tracks.at(i)->setWidth(width);
} }
void PathView::setRouteWidth(int width) void MapView::setRouteWidth(int width)
{ {
_routeWidth = width; _routeWidth = width;
@ -674,7 +668,7 @@ void PathView::setRouteWidth(int width)
_routes.at(i)->setWidth(width); _routes.at(i)->setWidth(width);
} }
void PathView::setTrackStyle(Qt::PenStyle style) void MapView::setTrackStyle(Qt::PenStyle style)
{ {
_trackStyle = style; _trackStyle = style;
@ -682,7 +676,7 @@ void PathView::setTrackStyle(Qt::PenStyle style)
_tracks.at(i)->setStyle(style); _tracks.at(i)->setStyle(style);
} }
void PathView::setRouteStyle(Qt::PenStyle style) void MapView::setRouteStyle(Qt::PenStyle style)
{ {
_routeStyle = style; _routeStyle = style;
@ -690,7 +684,7 @@ void PathView::setRouteStyle(Qt::PenStyle style)
_routes.at(i)->setStyle(style); _routes.at(i)->setStyle(style);
} }
void PathView::setWaypointSize(int size) void MapView::setWaypointSize(int size)
{ {
_waypointSize = size; _waypointSize = size;
@ -698,7 +692,7 @@ void PathView::setWaypointSize(int size)
_waypoints.at(i)->setSize(size); _waypoints.at(i)->setSize(size);
} }
void PathView::setWaypointColor(const QColor &color) void MapView::setWaypointColor(const QColor &color)
{ {
_waypointColor = color; _waypointColor = color;
@ -706,7 +700,7 @@ void PathView::setWaypointColor(const QColor &color)
_waypoints.at(i)->setColor(color); _waypoints.at(i)->setColor(color);
} }
void PathView::setPOISize(int size) void MapView::setPOISize(int size)
{ {
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it; QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
@ -716,7 +710,7 @@ void PathView::setPOISize(int size)
it.value()->setSize(size); it.value()->setSize(size);
} }
void PathView::setPOIColor(const QColor &color) void MapView::setPOIColor(const QColor &color)
{ {
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it; QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
@ -726,43 +720,46 @@ void PathView::setPOIColor(const QColor &color)
it.value()->setColor(color); it.value()->setColor(color);
} }
void PathView::setMapOpacity(int opacity) void MapView::setMapOpacity(int opacity)
{ {
_opacity = opacity / 100.0; _opacity = opacity / 100.0;
resetCachedContent(); resetCachedContent();
} }
void PathView::setBackgroundColor(const QColor &color) void MapView::setBackgroundColor(const QColor &color)
{ {
_backgroundColor = color; _backgroundColor = color;
_map->setBackgroundColor(color); _map->setBackgroundColor(color);
resetCachedContent(); resetCachedContent();
} }
void PathView::drawBackground(QPainter *painter, const QRectF &rect) void MapView::drawBackground(QPainter *painter, const QRectF &rect)
{ {
if (_showMap) { if (_showMap) {
if (_opacity < 1.0) { QRectF ir = rect.intersected(_map->bounds());
if (_opacity < 1.0 || ir != rect)
painter->fillRect(rect, _backgroundColor); painter->fillRect(rect, _backgroundColor);
if (_opacity < 1.0)
painter->setOpacity(_opacity); painter->setOpacity(_opacity);
}
_map->draw(painter, rect); _map->draw(painter, ir);
} else } else
painter->fillRect(rect, _backgroundColor); painter->fillRect(rect, _backgroundColor);
} }
void PathView::resizeEvent(QResizeEvent *event) void MapView::resizeEvent(QResizeEvent *event)
{ {
QGraphicsView::resizeEvent(event);
qreal zoom = _map->zoom(); qreal zoom = _map->zoom();
if (mapZoom() != zoom) if (mapZoom() != zoom)
rescale(); rescale();
centerOn(contentCenter()); centerOn(contentCenter());
QGraphicsView::resizeEvent(event);
} }
void PathView::paintEvent(QPaintEvent *event) void MapView::paintEvent(QPaintEvent *event)
{ {
QPointF scenePos = mapToScene(rect().bottomRight() + QPoint( QPointF scenePos = mapToScene(rect().bottomRight() + QPoint(
-(SCALE_OFFSET + _mapScale->boundingRect().width()), -(SCALE_OFFSET + _mapScale->boundingRect().width()),
@ -773,7 +770,7 @@ void PathView::paintEvent(QPaintEvent *event)
QGraphicsView::paintEvent(event); QGraphicsView::paintEvent(event);
} }
void PathView::scrollContentsBy(int dx, int dy) void MapView::scrollContentsBy(int dx, int dy)
{ {
QGraphicsView::scrollContentsBy(dx, dy); QGraphicsView::scrollContentsBy(dx, dy);
@ -786,7 +783,7 @@ void PathView::scrollContentsBy(int dx, int dy)
} }
} }
void PathView::useOpenGL(bool use) void MapView::useOpenGL(bool use)
{ {
if (use) if (use)
setViewport(new OPENGL_WIDGET); setViewport(new OPENGL_WIDGET);
@ -794,12 +791,22 @@ void PathView::useOpenGL(bool use)
setViewport(new QWidget); setViewport(new QWidget);
} }
void PathView::useAntiAliasing(bool use) void MapView::useAntiAliasing(bool use)
{ {
setRenderHint(QPainter::Antialiasing, use); setRenderHint(QPainter::Antialiasing, use);
} }
void PathView::reloadMap() void MapView::setMarkerColor(const QColor &color)
{
_markerColor = color;
for (int i = 0; i < _tracks.size(); i++)
_tracks.at(i)->setMarkerColor(color);
for (int i = 0; i < _routes.size(); i++)
_routes.at(i)->setMarkerColor(color);
}
void MapView::reloadMap()
{ {
resetCachedContent(); resetCachedContent();
} }

View File

@ -1,15 +1,15 @@
#ifndef TRACKVIEW_H #ifndef MAPVIEW_H
#define TRACKVIEW_H #define MAPVIEW_H
#include <QGraphicsView> #include <QGraphicsView>
#include <QVector> #include <QVector>
#include <QHash> #include <QHash>
#include <QList> #include <QList>
#include "common/rectc.h"
#include "data/waypoint.h"
#include "searchpointer.h"
#include "units.h" #include "units.h"
#include "palette.h" #include "palette.h"
#include "waypoint.h"
#include "rectc.h"
#include "searchpointer.h"
class Data; class Data;
class POI; class POI;
@ -22,12 +22,12 @@ class WaypointItem;
class ScaleItem; class ScaleItem;
class PathItem; class PathItem;
class PathView : public QGraphicsView class MapView : public QGraphicsView
{ {
Q_OBJECT Q_OBJECT
public: public:
PathView(Map *map, POI *poi, QWidget *parent = 0); MapView(Map *map, POI *poi, QWidget *parent = 0);
QList<PathItem*> loadData(const Data &data); QList<PathItem*> loadData(const Data &data);
@ -38,10 +38,6 @@ public:
void plot(QPainter *painter, const QRectF &target, qreal scale, bool hires); void plot(QPainter *painter, const QRectF &target, qreal scale, bool hires);
int trackCount() const {return _tracks.count();}
int routeCount() const {return _routes.count();}
int waypointCount() const {return _waypoints.count();}
void clear(); void clear();
void setTrackWidth(int width); void setTrackWidth(int width);
@ -56,6 +52,7 @@ public:
void setBackgroundColor(const QColor &color); void setBackgroundColor(const QColor &color);
void useOpenGL(bool use); void useOpenGL(bool use);
void useAntiAliasing(bool use); void useAntiAliasing(bool use);
void setMarkerColor(const QColor &color);
public slots: public slots:
void showMap(bool show); void showMap(bool show);
@ -77,7 +74,7 @@ private:
PathItem *addTrack(const Track &track); PathItem *addTrack(const Track &track);
PathItem *addRoute(const Route &route); PathItem *addRoute(const Route &route);
void addWaypoints(const QList<Waypoint> &waypoints); void addWaypoints(const QList<Waypoint> &waypoints);
void addPOI(const QVector<Waypoint> &waypoints); void addPOI(const QList<Waypoint> &waypoints);
void loadPOI(); void loadPOI();
void clearPOI(); void clearPOI();
@ -87,9 +84,7 @@ private:
void centerOn(const QPointF &pos); void centerOn(const QPointF &pos);
void zoom(int zoom, const QPoint &pos, const Coordinates &c); void zoom(int zoom, const QPoint &pos, const Coordinates &c);
void digitalZoom(int zoom); void digitalZoom(int zoom);
void resetDigitalZoom();
void updatePOIVisibility(); void updatePOIVisibility();
void updateWaypointsBoundingRect(const Coordinates &wp);
void mouseDoubleClickEvent(QMouseEvent *event); void mouseDoubleClickEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent *event); void wheelEvent(QWheelEvent *event);
@ -133,9 +128,10 @@ private:
int _poiSize; int _poiSize;
QColor _waypointColor; QColor _waypointColor;
QColor _poiColor; QColor _poiColor;
QColor _markerColor;
int _digitalZoom; int _digitalZoom;
bool _plot; bool _plot;
}; };
#endif // TRACKVIEW_H #endif // MAPVIEW_H

View File

@ -7,7 +7,7 @@
MarkerItem::MarkerItem(QGraphicsItem *parent) : QGraphicsItem(parent) MarkerItem::MarkerItem(QGraphicsItem *parent) : QGraphicsItem(parent)
{ {
_color = Qt::red;
} }
QRectF MarkerItem::boundingRect() const QRectF MarkerItem::boundingRect() const
@ -22,9 +22,15 @@ void MarkerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
Q_UNUSED(widget); Q_UNUSED(widget);
painter->setRenderHint(QPainter::Antialiasing, false); painter->setRenderHint(QPainter::Antialiasing, false);
painter->setPen(QPen(Qt::red, WIDTH)); painter->setPen(QPen(_color, WIDTH));
painter->drawLine(-SIZE/2, 0, SIZE/2, 0); painter->drawLine(-SIZE/2, 0, SIZE/2, 0);
painter->drawLine(0, -SIZE/2, 0, SIZE/2); painter->drawLine(0, -SIZE/2, 0, SIZE/2);
// painter->drawRect(boundingRect()); // painter->drawRect(boundingRect());
} }
void MarkerItem::setColor(const QColor &color)
{
_color = color;
update();
}

View File

@ -2,6 +2,7 @@
#define MARKERITEM_H #define MARKERITEM_H
#include <QGraphicsItem> #include <QGraphicsItem>
#include <QColor>
class MarkerItem : public QGraphicsItem class MarkerItem : public QGraphicsItem
{ {
@ -11,6 +12,11 @@ public:
QRectF boundingRect() const; QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget); QWidget *widget);
void setColor(const QColor &color);
private:
QColor _color;
}; };
#endif // MARKERITEM_H #endif // MARKERITEM_H

View File

@ -1,7 +1,5 @@
#include <cmath> #include <cmath>
#include <cctype> #include "nicenum.h"
#include "misc.h"
double niceNum(double x, int round) double niceNum(double x, int round)
{ {
@ -34,23 +32,3 @@ double niceNum(double x, int round)
return nf * pow(10.0, expv); return nf * pow(10.0, expv);
} }
int str2int(const char *str, int len)
{
int res = 0;
for (const char *sp = str; sp < str + len; sp++) {
if (::isdigit(*sp))
res = res * 10 + *sp - '0';
else
return -1;
}
return res;
}
QRectF scaled(const QRectF &rect, qreal factor)
{
return QRectF(QPointF(rect.left() * factor, rect.top() * factor),
QSizeF(rect.width() * factor, rect.height() * factor));
}

6
src/GUI/nicenum.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef MISC_H
#define MISC_H
double niceNum(double x, int round);
#endif // MISC_H

View File

@ -35,6 +35,28 @@ static QFrame *line()
} }
#endif #endif
QWidget *OptionsDialog::createGeneralPage()
{
_alwaysShowMap = new QCheckBox(tr("Always show the map"));
_alwaysShowMap->setChecked(_options->alwaysShowMap);
_alwaysShowMap->setToolTip("<p>" +
tr("Show the map even when no files are loaded.") + "</p>");
QFormLayout *showMapLayout = new QFormLayout();
showMapLayout->addWidget(_alwaysShowMap);
QWidget *generalTab = new QWidget();
QVBoxLayout *generalTabLayout = new QVBoxLayout();
generalTabLayout->addLayout(showMapLayout);
generalTabLayout->addStretch();
generalTab->setLayout(generalTabLayout);
QTabWidget *generalPage = new QTabWidget();
generalPage->addTab(generalTab, tr("General"));
return generalPage;
}
QWidget *OptionsDialog::createAppearancePage() QWidget *OptionsDialog::createAppearancePage()
{ {
// Paths // Paths
@ -157,11 +179,15 @@ QWidget *OptionsDialog::createAppearancePage()
// Graphs // Graphs
_sliderColor = new ColorBox();
_sliderColor->setColor(_options->sliderColor);
_graphWidth = new QSpinBox(); _graphWidth = new QSpinBox();
_graphWidth->setValue(_options->graphWidth); _graphWidth->setValue(_options->graphWidth);
_graphWidth->setMinimum(1); _graphWidth->setMinimum(1);
QFormLayout *graphLayout = new QFormLayout(); QFormLayout *graphLayout = new QFormLayout();
graphLayout->addRow(tr("Line width:"), _graphWidth); graphLayout->addRow(tr("Line width:"), _graphWidth);
graphLayout->addRow(tr("Slider color:"), _sliderColor);
_graphAA = new QCheckBox(tr("Use anti-aliasing")); _graphAA = new QCheckBox(tr("Use anti-aliasing"));
_graphAA->setChecked(_options->graphAntiAliasing); _graphAA->setChecked(_options->graphAntiAliasing);
@ -422,6 +448,7 @@ OptionsDialog::OptionsDialog(Options *options, QWidget *parent)
: QDialog(parent), _options(options) : QDialog(parent), _options(options)
{ {
QStackedWidget *pages = new QStackedWidget(); QStackedWidget *pages = new QStackedWidget();
pages->addWidget(createGeneralPage());
pages->addWidget(createAppearancePage()); pages->addWidget(createAppearancePage());
pages->addWidget(createDataPage()); pages->addWidget(createDataPage());
pages->addWidget(createPOIPage()); pages->addWidget(createPOIPage());
@ -430,6 +457,7 @@ OptionsDialog::OptionsDialog(Options *options, QWidget *parent)
QListWidget *menu = new QListWidget(); QListWidget *menu = new QListWidget();
menu->setIconSize(QSize(MENU_ICON_SIZE, MENU_ICON_SIZE)); menu->setIconSize(QSize(MENU_ICON_SIZE, MENU_ICON_SIZE));
new QListWidgetItem(QIcon(QPixmap(APP_ICON)), tr("General"), menu);
new QListWidgetItem(QIcon(QPixmap(APPEARANCE_ICON)), tr("Appearance"), new QListWidgetItem(QIcon(QPixmap(APPEARANCE_ICON)), tr("Appearance"),
menu); menu);
new QListWidgetItem(QIcon(QPixmap(DATA_ICON)), tr("Data"), menu); new QListWidgetItem(QIcon(QPixmap(DATA_ICON)), tr("Data"), menu);
@ -469,6 +497,8 @@ OptionsDialog::OptionsDialog(Options *options, QWidget *parent)
void OptionsDialog::accept() void OptionsDialog::accept()
{ {
_options->alwaysShowMap = _alwaysShowMap->isChecked();
_options->palette.setColor(_baseColor->color()); _options->palette.setColor(_baseColor->color());
_options->palette.setShift(_colorOffset->value()); _options->palette.setShift(_colorOffset->value());
_options->mapOpacity = _mapOpacity->value(); _options->mapOpacity = _mapOpacity->value();
@ -485,6 +515,7 @@ void OptionsDialog::accept()
_options->poiSize = _poiSize->value(); _options->poiSize = _poiSize->value();
_options->poiColor = _poiColor->color(); _options->poiColor = _poiColor->color();
_options->graphWidth = _graphWidth->value(); _options->graphWidth = _graphWidth->value();
_options->sliderColor = _sliderColor->color();
_options->graphAntiAliasing = _graphAA->isChecked(); _options->graphAntiAliasing = _graphAA->isChecked();
_options->elevationFilter = _elevationFilter->value(); _options->elevationFilter = _elevationFilter->value();

View File

@ -16,6 +16,8 @@ class QRadioButton;
class PercentSlider; class PercentSlider;
struct Options { struct Options {
// General
bool alwaysShowMap;
// Appearance // Appearance
Palette palette; Palette palette;
int trackWidth; int trackWidth;
@ -27,6 +29,7 @@ struct Options {
int waypointSize; int waypointSize;
int poiSize; int poiSize;
int graphWidth; int graphWidth;
QColor sliderColor;
bool pathAntiAliasing; bool pathAntiAliasing;
bool graphAntiAliasing; bool graphAntiAliasing;
int mapOpacity; int mapOpacity;
@ -69,6 +72,7 @@ public slots:
void accept(); void accept();
private: private:
QWidget *createGeneralPage();
QWidget *createAppearancePage(); QWidget *createAppearancePage();
QWidget *createDataPage(); QWidget *createDataPage();
QWidget *createPOIPage(); QWidget *createPOIPage();
@ -77,6 +81,8 @@ private:
Options *_options; Options *_options;
// General
QCheckBox *_alwaysShowMap;
// Appearance // Appearance
ColorBox *_baseColor; ColorBox *_baseColor;
QDoubleSpinBox *_colorOffset; QDoubleSpinBox *_colorOffset;
@ -92,6 +98,7 @@ private:
QSpinBox *_poiSize; QSpinBox *_poiSize;
ColorBox *_poiColor; ColorBox *_poiColor;
QSpinBox *_graphWidth; QSpinBox *_graphWidth;
ColorBox *_sliderColor;
QCheckBox *_graphAA; QCheckBox *_graphAA;
// Data // Data
OddSpinBox *_elevationFilter; OddSpinBox *_elevationFilter;

View File

@ -2,9 +2,9 @@
#include <QApplication> #include <QApplication>
#include <QCursor> #include <QCursor>
#include <QPainter> #include <QPainter>
#include "map/map.h"
#include "tooltip.h" #include "tooltip.h"
#include "map.h" #include "nicenum.h"
#include "misc.h"
#include "pathitem.h" #include "pathitem.h"
@ -167,6 +167,11 @@ void PathItem::moveMarker(qreal distance)
_marker->setVisible(false); _marker->setVisible(false);
} }
void PathItem::setMarkerColor(const QColor &color)
{
_marker->setColor(color);
}
void PathItem::hover(bool hover) void PathItem::hover(bool hover)
{ {
if (hover) { if (hover) {

View File

@ -3,9 +3,8 @@
#include <QGraphicsObject> #include <QGraphicsObject>
#include <QPen> #include <QPen>
#include "data/path.h"
#include "markeritem.h" #include "markeritem.h"
#include "path.h"
class Map; class Map;
@ -29,6 +28,7 @@ public:
void setWidth(qreal width); void setWidth(qreal width);
void setStyle(Qt::PenStyle style); void setStyle(Qt::PenStyle style);
void setDigitalZoom(int zoom); void setDigitalZoom(int zoom);
void setMarkerColor(const QColor &color);
public slots: public slots:
void moveMarker(qreal distance); void moveMarker(qreal distance);

View File

@ -1,4 +1,4 @@
#include "data.h" #include "data/data.h"
#include "powergraphitem.h" #include "powergraphitem.h"
#include "powergraph.h" #include "powergraph.h"

View File

@ -1,9 +1,9 @@
#include <QPainter> #include <QPainter>
#include "data/waypoint.h"
#include "map/map.h"
#include "format.h" #include "format.h"
#include "waypoint.h"
#include "waypointitem.h" #include "waypointitem.h"
#include "tooltip.h" #include "tooltip.h"
#include "map.h"
#include "routeitem.h" #include "routeitem.h"

View File

@ -1,8 +1,8 @@
#ifndef ROUTEITEM_H #ifndef ROUTEITEM_H
#define ROUTEITEM_H #define ROUTEITEM_H
#include "data/route.h"
#include "pathitem.h" #include "pathitem.h"
#include "route.h"
#include "units.h" #include "units.h"
class Map; class Map;

View File

@ -1,7 +1,7 @@
#include <cmath> #include <cmath>
#include <QPainter> #include <QPainter>
#include "config.h" #include "config.h"
#include "misc.h" #include "nicenum.h"
#include "scaleitem.h" #include "scaleitem.h"

View File

@ -144,5 +144,9 @@
#define PRINT_ITEM_COUNT_DEFAULT true #define PRINT_ITEM_COUNT_DEFAULT true
#define SEPARATE_GRAPH_PAGE_SETTING "separateGraphPage" #define SEPARATE_GRAPH_PAGE_SETTING "separateGraphPage"
#define SEPARATE_GRAPH_PAGE_DEFAULT false #define SEPARATE_GRAPH_PAGE_DEFAULT false
#define SLIDER_COLOR_SETTING "sliderColor"
#define SLIDER_COLOR_DEFAULT QColor(Qt::red)
#define ALWAYS_SHOW_MAP_SETTING "alwaysShowMap"
#define ALWAYS_SHOW_MAP_DEFAULT true
#endif // SETTINGS_H #endif // SETTINGS_H

View File

@ -8,6 +8,7 @@
SliderInfoItem::SliderInfoItem(QGraphicsItem *parent) : QGraphicsItem(parent) SliderInfoItem::SliderInfoItem(QGraphicsItem *parent) : QGraphicsItem(parent)
{ {
_side = Right; _side = Right;
_color = Qt::red;
} }
void SliderInfoItem::updateBoundingRect() void SliderInfoItem::updateBoundingRect()
@ -58,7 +59,7 @@ void SliderInfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
painter->setFont(font); painter->setFont(font);
painter->setRenderHint(QPainter::Antialiasing, false); painter->setRenderHint(QPainter::Antialiasing, false);
painter->setPen(Qt::red); painter->setPen(_color);
if (_side == Right) { if (_side == Right) {
painter->drawText(SIZE, -fm.descent()/2, _y); painter->drawText(SIZE, -fm.descent()/2, _y);
@ -88,3 +89,9 @@ void SliderInfoItem::setSide(Side side)
_side = side; _side = side;
updateBoundingRect(); updateBoundingRect();
} }
void SliderInfoItem::setColor(const QColor &color)
{
_color = color;
update();
}

View File

@ -16,6 +16,7 @@ public:
void setText(const QString &x, const QString &y); void setText(const QString &x, const QString &y);
void setSide(Side side); void setSide(Side side);
void setColor(const QColor &color);
private: private:
void updateBoundingRect(); void updateBoundingRect();
@ -23,6 +24,7 @@ private:
Side _side; Side _side;
QString _x, _y; QString _x, _y;
QRectF _boundingRect; QRectF _boundingRect;
QColor _color;
}; };
#endif // SLIDERINFOITEM_H #endif // SLIDERINFOITEM_H

View File

@ -8,6 +8,8 @@ SliderItem::SliderItem(QGraphicsItem *parent) : QGraphicsObject(parent)
{ {
setFlag(ItemIsMovable); setFlag(ItemIsMovable);
setFlag(ItemSendsGeometryChanges); setFlag(ItemSendsGeometryChanges);
_color = Qt::red;
} }
QRectF SliderItem::boundingRect() const QRectF SliderItem::boundingRect() const
@ -22,7 +24,7 @@ void SliderItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
Q_UNUSED(widget); Q_UNUSED(widget);
painter->setRenderHint(QPainter::Antialiasing, false); painter->setRenderHint(QPainter::Antialiasing, false);
painter->setPen(Qt::red); painter->setPen(_color);
painter->drawLine(0, 0, 0, -_area.height()); painter->drawLine(0, 0, 0, -_area.height());
// painter->drawRect(boundingRect()); // painter->drawRect(boundingRect());
@ -59,3 +61,9 @@ void SliderItem::setArea(const QRectF &area)
prepareGeometryChange(); prepareGeometryChange();
_area = area; _area = area;
} }
void SliderItem::setColor(const QColor &color)
{
_color = color;
update();
}

View File

@ -3,6 +3,8 @@
#include <QGraphicsObject> #include <QGraphicsObject>
class QColor;
class SliderItem : public QGraphicsObject class SliderItem : public QGraphicsObject
{ {
Q_OBJECT Q_OBJECT
@ -17,6 +19,8 @@ public:
const QRectF &area() const {return _area;} const QRectF &area() const {return _area;}
void setArea(const QRectF &area); void setArea(const QRectF &area);
void setColor(const QColor &color);
void clear(); void clear();
signals: signals:
@ -27,6 +31,7 @@ protected:
private: private:
QRectF _area; QRectF _area;
QColor _color;
}; };
#endif // SLIDERITEM_H #endif // SLIDERITEM_H

View File

@ -1,5 +1,5 @@
#include "data/data.h"
#include "config.h" #include "config.h"
#include "data.h"
#include "tooltip.h" #include "tooltip.h"
#include "speedgraphitem.h" #include "speedgraphitem.h"
#include "speedgraph.h" #include "speedgraph.h"

View File

@ -1,4 +1,4 @@
#include "data.h" #include "data/data.h"
#include "temperaturegraphitem.h" #include "temperaturegraphitem.h"
#include "temperaturegraph.h" #include "temperaturegraph.h"

View File

@ -1,7 +1,7 @@
#include <QPainter> #include <QPainter>
#include "map/map.h"
#include "format.h" #include "format.h"
#include "tooltip.h" #include "tooltip.h"
#include "map.h"
#include "trackitem.h" #include "trackitem.h"

View File

@ -3,7 +3,7 @@
#include <QDateTime> #include <QDateTime>
#include <QPen> #include <QPen>
#include "track.h" #include "data/track.h"
#include "pathitem.h" #include "pathitem.h"
#include "units.h" #include "units.h"

Some files were not shown because too many files have changed in this diff Show More