mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-07-04 14:49:30 +02:00
Compare commits
68 Commits
Author | SHA1 | Date | |
---|---|---|---|
e76439bb6e | |||
b54aeff369 | |||
72968efeef | |||
ec3f529b0f | |||
57a171ee8c | |||
d3193abd0b | |||
6809853a8a | |||
3155e8436b | |||
69f9d05ccb | |||
e24a3cd99a | |||
a94fa9f0ea | |||
c4f2a44410 | |||
da4a51e7fa | |||
bb47a34823 | |||
11196c0e35 | |||
00ef815738 | |||
64f685cf60 | |||
7ab13ec8e5 | |||
d3fbbecb2d | |||
7bc83603ca | |||
2cd35b139e | |||
a74afa54fd | |||
753c4e8db0 | |||
d0b3f48caf | |||
e47cd1be7e | |||
d1ba35f012 | |||
b9489afbfe | |||
a7506cfd82 | |||
c060abe6a7 | |||
b457fc430c | |||
89947851fd | |||
7d40dfddb2 | |||
151ae03b53 | |||
9fd8b84c3b | |||
47683e5447 | |||
84bcf07bd4 | |||
cc694971be | |||
ba856d7eb6 | |||
b14eeb58ab | |||
8e932b966c | |||
35818ce16e | |||
6ef7537dff | |||
abbb823890 | |||
0a4f8a46d4 | |||
fd2823c703 | |||
d16b61051f | |||
e69f17aad5 | |||
33b1e179d3 | |||
5efb9f8a4e | |||
ebf39f11bd | |||
8b7422b70a | |||
ef3da2e156 | |||
6e13c2b704 | |||
f3e4719439 | |||
7b6789e78d | |||
95442461fc | |||
729cbd641c | |||
2e2dad8d04 | |||
4e3b6c2eb2 | |||
6430933a96 | |||
3e14d4afda | |||
ebb30a3fca | |||
bd20d40ba7 | |||
77823fba14 | |||
dcc5cbe9bc | |||
cd3c99b065 | |||
83189a4e65 | |||
797fd7f02b |
52
.appveyor.yml
Normal file
52
.appveyor.yml
Normal file
@ -0,0 +1,52 @@
|
||||
version: 4.16.{build}
|
||||
configuration: Release
|
||||
platform: Any CPU
|
||||
environment:
|
||||
NSISDIR: C:\Program Files (x86)\NSIS
|
||||
matrix:
|
||||
- QTDIR: C:\Qt\5.9\msvc2015
|
||||
PLATFORM: x86
|
||||
NSI: gpxsee.nsi
|
||||
OPENSSLDIR: C:\OpenSSL-Win32\bin
|
||||
- QTDIR: C:\Qt\5.9\msvc2015_64
|
||||
PLATFORM: x86_amd64
|
||||
NSI: gpxsee64.nsi
|
||||
OPENSSLDIR: C:\OpenSSL-Win64\bin
|
||||
install:
|
||||
- cmd: >-
|
||||
set PATH=%QTDIR%\bin;%NSISDIR%;%PATH%
|
||||
|
||||
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %PLATFORM%
|
||||
build_script:
|
||||
- cmd: >-
|
||||
lrelease gpxsee.pro
|
||||
|
||||
qmake gpxsee.pro
|
||||
|
||||
nmake release
|
||||
|
||||
|
||||
md installer
|
||||
|
||||
copy release\GPXSee.exe installer
|
||||
|
||||
windeployqt --no-svg --release installer\GPXSee.exe
|
||||
|
||||
copy pkg\%NSI% installer
|
||||
|
||||
copy pkg\datums.csv installer
|
||||
|
||||
copy pkg\ellipsoids.csv installer
|
||||
|
||||
copy pkg\maps.txt installer
|
||||
|
||||
copy licence.txt installer
|
||||
|
||||
copy %OPENSSLDIR%\libeay32.dll installer
|
||||
|
||||
copy %OPENSSLDIR%\ssleay32.dll installer
|
||||
|
||||
|
||||
makensis.exe installer\%NSI%
|
||||
artifacts:
|
||||
- path: installer\GPXSee-*.exe
|
9
.travis.yml
Normal file
9
.travis.yml
Normal file
@ -0,0 +1,9 @@
|
||||
language: c++
|
||||
|
||||
install:
|
||||
- sudo apt-get install libqt4-dev
|
||||
|
||||
script:
|
||||
- lrelease gpxsee.pro
|
||||
- qmake gpxsee.pro
|
||||
- make
|
BIN
cert/mac/gpxsee.cer
Normal file
BIN
cert/mac/gpxsee.cer
Normal file
Binary file not shown.
20
gpxsee.pro
20
gpxsee.pro
@ -1,5 +1,5 @@
|
||||
TARGET = GPXSee
|
||||
VERSION = 4.10
|
||||
VERSION = 4.16
|
||||
QT += core \
|
||||
gui \
|
||||
network
|
||||
@ -96,7 +96,14 @@ HEADERS += src/config.h \
|
||||
src/albersequal.h \
|
||||
src/oddspinbox.h \
|
||||
src/rectc.h \
|
||||
src/searchpointer.h
|
||||
src/searchpointer.h \
|
||||
src/percentslider.h \
|
||||
src/elevationgraphitem.h \
|
||||
src/speedgraphitem.h \
|
||||
src/heartrategraphitem.h \
|
||||
src/temperaturegraphitem.h \
|
||||
src/cadencegraphitem.h \
|
||||
src/powergraphitem.h
|
||||
SOURCES += src/main.cpp \
|
||||
src/gui.cpp \
|
||||
src/poi.cpp \
|
||||
@ -165,7 +172,14 @@ SOURCES += src/main.cpp \
|
||||
src/maplist.cpp \
|
||||
src/albersequal.cpp \
|
||||
src/oddspinbox.cpp \
|
||||
src/rectc.cpp
|
||||
src/rectc.cpp \
|
||||
src/percentslider.cpp \
|
||||
src/elevationgraphitem.cpp \
|
||||
src/speedgraphitem.cpp \
|
||||
src/heartrategraphitem.cpp \
|
||||
src/temperaturegraphitem.cpp \
|
||||
src/cadencegraphitem.cpp \
|
||||
src/powergraphitem.cpp
|
||||
RESOURCES += gpxsee.qrc
|
||||
TRANSLATIONS = lang/gpxsee_cs.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
@ -5,7 +5,7 @@
|
||||
; The name of the installer
|
||||
Name "GPXSee"
|
||||
; Program version
|
||||
!define VERSION "4.10"
|
||||
!define VERSION "4.16"
|
||||
|
||||
; The file to write
|
||||
OutFile "GPXSee-${VERSION}.exe"
|
||||
|
@ -5,7 +5,7 @@
|
||||
; The name of the installer
|
||||
Name "GPXSee"
|
||||
; Program version
|
||||
!define VERSION "4.10"
|
||||
!define VERSION "4.16"
|
||||
|
||||
; The file to write
|
||||
OutFile "GPXSee-${VERSION}_x64.exe"
|
||||
|
@ -1,4 +1,5 @@
|
||||
Open Topo Map https://a.tile.opentopomap.org/$z/$x/$y.png
|
||||
Open Street Map http://tile.openstreetmap.org/$z/$x/$y.png
|
||||
USGS Topo https://navigator.er.usgs.gov/tiles/tcr.cgi/$z/$x/$y.png
|
||||
USGS Imagery https://navigator.er.usgs.gov/tiles/aerial_Imagery.cgi/$z/$x/$y
|
||||
Open Topo Map https://a.tile.opentopomap.org/$z/$x/$y.png 17
|
||||
4UMaps http://4umaps.eu/$z/$x/$y.png 15
|
||||
Open Street Map http://tile.openstreetmap.org/$z/$x/$y.png 19
|
||||
USGS Topo https://navigator.er.usgs.gov/tiles/tcr.cgi/$z/$x/$y.png 15
|
||||
USGS Imagery https://navigator.er.usgs.gov/tiles/aerial_Imagery.cgi/$z/$x/$y 15
|
||||
|
@ -303,15 +303,14 @@ void Atlas::draw(QPainter *painter, const QRectF &rect)
|
||||
{
|
||||
// All in one map
|
||||
for (int i = _zooms.at(_zoom).first; i <= _zooms.at(_zoom).second; i++) {
|
||||
QRectF ir = rect.intersected(_bounds.at(i).second);
|
||||
if (ir == rect) {
|
||||
if (_bounds.at(i).second.contains(rect)) {
|
||||
draw(painter, rect, i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Multiple maps
|
||||
painter->fillRect(rect, Qt::white);
|
||||
painter->fillRect(rect, _backgroundColor);
|
||||
for (int i = _zooms.at(_zoom).first; i <= _zooms.at(_zoom).second; i++) {
|
||||
QRectF ir = rect.intersected(_bounds.at(i).second);
|
||||
if (!ir.isNull())
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "data.h"
|
||||
#include "cadencegraphitem.h"
|
||||
#include "cadencegraph.h"
|
||||
|
||||
|
||||
CadenceGraph::CadenceGraph(QWidget *parent) : GraphTab(parent)
|
||||
{
|
||||
_units = Metric;
|
||||
_showTracks = true;
|
||||
|
||||
GraphView::setYUnits(tr("1/min"));
|
||||
@ -28,21 +28,16 @@ void CadenceGraph::loadData(const Data &data, const QList<PathItem *> &paths)
|
||||
{
|
||||
for (int i = 0; i < data.tracks().count(); i++) {
|
||||
const Graph &graph = data.tracks().at(i)->cadence();
|
||||
qreal sum = 0, w = 0;
|
||||
|
||||
if (graph.size() < 2) {
|
||||
skipColor();
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int j = 1; j < graph.size(); j++) {
|
||||
qreal ds = graph.at(j).s() - graph.at(j-1).s();
|
||||
sum += graph.at(j).y() * ds;
|
||||
w += ds;
|
||||
}
|
||||
_avg.append(QPointF(data.tracks().at(i)->distance(), sum/w));
|
||||
CadenceGraphItem *gi = new CadenceGraphItem(graph, _graphType);
|
||||
GraphView::addGraph(gi, paths.at(i));
|
||||
|
||||
GraphView::loadGraph(graph, paths.at(i));
|
||||
_avg.append(QPointF(data.tracks().at(i)->distance(), gi->avg()));
|
||||
}
|
||||
|
||||
for (int i = 0; i < data.routes().count(); i++)
|
||||
|
@ -13,7 +13,6 @@ public:
|
||||
QString label() const {return tr("Cadence");}
|
||||
void loadData(const Data &data, const QList<PathItem *> &paths);
|
||||
void clear();
|
||||
void setUnits(enum Units) {}
|
||||
void showTracks(bool show);
|
||||
void showRoutes(bool show) {Q_UNUSED(show);}
|
||||
|
||||
@ -24,7 +23,6 @@ private:
|
||||
|
||||
QList<QPointF> _avg;
|
||||
|
||||
enum Units _units;
|
||||
bool _showTracks;
|
||||
};
|
||||
|
||||
|
26
src/cadencegraphitem.cpp
Normal file
26
src/cadencegraphitem.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include "tooltip.h"
|
||||
#include "cadencegraphitem.h"
|
||||
|
||||
CadenceGraphItem::CadenceGraphItem(const Graph &graph, GraphType type,
|
||||
QGraphicsItem *parent) : GraphItem(graph, type, parent)
|
||||
{
|
||||
qreal sum = 0;
|
||||
|
||||
for (int j = 1; j < graph.size(); j++)
|
||||
sum += graph.at(j).y() * (graph.at(j).s() - graph.at(j-1).s());
|
||||
_avg = sum/graph.last().s();
|
||||
|
||||
setToolTip(toolTip());
|
||||
}
|
||||
|
||||
QString CadenceGraphItem::toolTip() const
|
||||
{
|
||||
ToolTip tt;
|
||||
|
||||
tt.insert(tr("Maximum"), QString::number(max(), 'f', 1)
|
||||
+ UNIT_SPACE + tr("1/min"));
|
||||
tt.insert(tr("Average"), QString::number(avg(), 'f', 1)
|
||||
+ UNIT_SPACE + tr("1/min"));
|
||||
|
||||
return tt.toString();
|
||||
}
|
23
src/cadencegraphitem.h
Normal file
23
src/cadencegraphitem.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef CADENCEGRAPHITEM_H
|
||||
#define CADENCEGRAPHITEM_H
|
||||
|
||||
#include "graphitem.h"
|
||||
|
||||
class CadenceGraphItem : public GraphItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CadenceGraphItem(const Graph &graph, GraphType type,
|
||||
QGraphicsItem *parent = 0);
|
||||
|
||||
qreal max() const {return -bounds().top();}
|
||||
qreal avg() const {return _avg;}
|
||||
|
||||
private:
|
||||
QString toolTip() const;
|
||||
|
||||
qreal _avg;
|
||||
};
|
||||
|
||||
#endif // CADENCEGRAPHITEM_H
|
@ -9,6 +9,8 @@
|
||||
ColorBox::ColorBox(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
_color = Qt::red;
|
||||
_alpha = true;
|
||||
|
||||
setSizePolicy(QSizePolicy::QSizePolicy::Minimum, QSizePolicy::Fixed);
|
||||
}
|
||||
|
||||
@ -51,9 +53,9 @@ void ColorBox::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() != Qt::LeftButton)
|
||||
return;
|
||||
|
||||
QColor color = QColorDialog::getColor(_color, this, QString(),
|
||||
QColorDialog::ShowAlphaChannel);
|
||||
QColorDialog::ColorDialogOptions options = _alpha
|
||||
? QColorDialog::ShowAlphaChannel : (QColorDialog::ColorDialogOptions)0;
|
||||
QColor color = QColorDialog::getColor(_color, this, QString(), options);
|
||||
if (color.isValid()) {
|
||||
_color = color;
|
||||
update();
|
||||
|
@ -12,6 +12,7 @@ public:
|
||||
|
||||
const QColor &color() const {return _color;}
|
||||
void setColor(const QColor &color);
|
||||
void enableAlphaChannel(bool enable) {_alpha = enable;}
|
||||
|
||||
QSize sizeHint() const;
|
||||
|
||||
@ -24,6 +25,7 @@ protected:
|
||||
|
||||
private:
|
||||
QColor _color;
|
||||
bool _alpha;
|
||||
};
|
||||
|
||||
#endif // COLORBOX_H
|
||||
|
@ -10,8 +10,7 @@
|
||||
#define APP_HOMEPAGE "http://www.gpxsee.org"
|
||||
|
||||
#define FONT_FAMILY "Arial"
|
||||
#define FONT_SIZE 12
|
||||
#define SCREEN_DPI 96.0
|
||||
#define FONT_SIZE 12 // px
|
||||
|
||||
#define ELLIPSOID_FILE QString("ellipsoids.csv")
|
||||
#define DATUM_FILE QString("datums.csv")
|
||||
|
@ -19,11 +19,9 @@ qreal Coordinates::distanceTo(const Coordinates &c) const
|
||||
|
||||
QDebug operator<<(QDebug dbg, const Coordinates &coordinates)
|
||||
{
|
||||
const bool ais = dbg.autoInsertSpaces();
|
||||
dbg.nospace() << "Coordinates(" << coordinates.lon() << ", "
|
||||
<< coordinates.lat() << ")";
|
||||
dbg.setAutoInsertSpaces(ais);
|
||||
return dbg.maybeSpace();
|
||||
return dbg.space();
|
||||
}
|
||||
|
||||
QPair<Coordinates, Coordinates> Coordinates::boundingRect(qreal distance) const
|
||||
|
23
src/data.cpp
23
src/data.cpp
@ -11,21 +11,30 @@
|
||||
#include "data.h"
|
||||
|
||||
|
||||
static GPXParser gpx;
|
||||
static TCXParser tcx;
|
||||
static KMLParser kml;
|
||||
static FITParser fit;
|
||||
static CSVParser csv;
|
||||
static IGCParser igc;
|
||||
static NMEAParser nmea;
|
||||
|
||||
static QHash<QString, Parser*> parsers()
|
||||
{
|
||||
QHash<QString, Parser*> hash;
|
||||
|
||||
hash.insert("gpx", new GPXParser());
|
||||
hash.insert("tcx", new TCXParser());
|
||||
hash.insert("kml", new KMLParser());
|
||||
hash.insert("fit", new FITParser());
|
||||
hash.insert("csv", new CSVParser());
|
||||
hash.insert("igc", new IGCParser());
|
||||
hash.insert("nmea", new NMEAParser());
|
||||
hash.insert("gpx", &gpx);
|
||||
hash.insert("tcx", &tcx);
|
||||
hash.insert("kml", &kml);
|
||||
hash.insert("fit", &fit);
|
||||
hash.insert("csv", &csv);
|
||||
hash.insert("igc", &igc);
|
||||
hash.insert("nmea", &nmea);
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
QHash<QString, Parser*> Data::_parsers = parsers();
|
||||
|
||||
Data::~Data()
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include <cmath>
|
||||
#include "config.h"
|
||||
#include "data.h"
|
||||
#include "tooltip.h"
|
||||
#include "elevationgraphitem.h"
|
||||
#include "elevationgraph.h"
|
||||
|
||||
|
||||
@ -42,11 +44,8 @@ ElevationGraph::ElevationGraph(QWidget *parent) : GraphTab(parent)
|
||||
_showRoutes = true;
|
||||
_showTracks = true;
|
||||
|
||||
_units = Metric;
|
||||
|
||||
setYUnits();
|
||||
setYUnits(Metric);
|
||||
setYLabel(tr("Elevation"));
|
||||
|
||||
setMinYRange(50.0);
|
||||
}
|
||||
|
||||
@ -68,43 +67,25 @@ void ElevationGraph::setInfo()
|
||||
|
||||
void ElevationGraph::loadGraph(const Graph &graph, Type type, PathItem *path)
|
||||
{
|
||||
qreal ascent = 0, descent = 0;
|
||||
qreal min, max;
|
||||
|
||||
if (graph.size() < 2) {
|
||||
skipColor();
|
||||
return;
|
||||
}
|
||||
|
||||
max = min = graph.at(0).y();
|
||||
for (int j = 1; j < graph.size(); j++) {
|
||||
qreal cur = graph.at(j).y();
|
||||
qreal prev = graph.at(j-1).y();
|
||||
|
||||
if (cur > prev)
|
||||
ascent += cur - prev;
|
||||
if (cur < prev)
|
||||
descent += prev - cur;
|
||||
|
||||
if (cur < min)
|
||||
min = cur;
|
||||
if (cur > max)
|
||||
max = cur;
|
||||
}
|
||||
ElevationGraphItem *gi = new ElevationGraphItem(graph, _graphType);
|
||||
GraphView::addGraph(gi, path, type);
|
||||
|
||||
if (type == Track) {
|
||||
_trackAscent += ascent;
|
||||
_trackDescent += descent;
|
||||
_trackMax = nMax(_trackMax, max);
|
||||
_trackMin = nMin(_trackMin, min);
|
||||
_trackAscent += gi->ascent();
|
||||
_trackDescent += gi->descent();
|
||||
_trackMax = nMax(_trackMax, gi->max());
|
||||
_trackMin = nMin(_trackMin, gi->min());
|
||||
} else {
|
||||
_routeAscent += ascent;
|
||||
_routeDescent += descent;
|
||||
_routeMax = nMax(_routeMax, max);
|
||||
_routeMin = nMin(_routeMin, min);
|
||||
_routeAscent += gi->ascent();
|
||||
_routeDescent += gi->descent();
|
||||
_routeMax = nMax(_routeMax, gi->max());
|
||||
_routeMin = nMin(_routeMin, gi->min());
|
||||
}
|
||||
|
||||
GraphView::loadGraph(graph, path, type);
|
||||
}
|
||||
|
||||
void ElevationGraph::loadData(const Data &data, const QList<PathItem *> &paths)
|
||||
@ -135,9 +116,9 @@ void ElevationGraph::clear()
|
||||
GraphView::clear();
|
||||
}
|
||||
|
||||
void ElevationGraph::setYUnits()
|
||||
void ElevationGraph::setYUnits(Units units)
|
||||
{
|
||||
if (_units == Metric) {
|
||||
if (units == Metric) {
|
||||
GraphView::setYUnits(tr("m"));
|
||||
setYScale(1);
|
||||
} else {
|
||||
@ -146,15 +127,12 @@ void ElevationGraph::setYUnits()
|
||||
}
|
||||
}
|
||||
|
||||
void ElevationGraph::setUnits(enum Units units)
|
||||
void ElevationGraph::setUnits(Units units)
|
||||
{
|
||||
_units = units;
|
||||
|
||||
setYUnits();
|
||||
setYUnits(units);
|
||||
setInfo();
|
||||
GraphView::setUnits(units);
|
||||
|
||||
redraw();
|
||||
GraphView::setUnits(units);
|
||||
}
|
||||
|
||||
void ElevationGraph::showTracks(bool show)
|
||||
|
@ -25,7 +25,7 @@ private:
|
||||
qreal ascent() const;
|
||||
qreal descent() const;
|
||||
|
||||
void setYUnits();
|
||||
void setYUnits(Units units);
|
||||
void setInfo();
|
||||
|
||||
void loadGraph(const Graph &graph, Type type, PathItem *path);
|
||||
@ -35,7 +35,6 @@ private:
|
||||
qreal _trackMax, _routeMax;
|
||||
qreal _trackMin, _routeMin;
|
||||
|
||||
enum Units _units;
|
||||
bool _showTracks, _showRoutes;
|
||||
};
|
||||
|
||||
|
43
src/elevationgraphitem.cpp
Normal file
43
src/elevationgraphitem.cpp
Normal file
@ -0,0 +1,43 @@
|
||||
#include "tooltip.h"
|
||||
#include "elevationgraphitem.h"
|
||||
|
||||
ElevationGraphItem::ElevationGraphItem(const Graph &graph, GraphType type,
|
||||
QGraphicsItem *parent) : GraphItem(graph, type, parent)
|
||||
{
|
||||
_ascent = _descent = 0;
|
||||
|
||||
for (int j = 1; j < graph.size(); j++) {
|
||||
qreal cur = graph.at(j).y();
|
||||
qreal prev = graph.at(j-1).y();
|
||||
|
||||
if (cur > prev)
|
||||
_ascent += cur - prev;
|
||||
if (cur < prev)
|
||||
_descent += prev - cur;
|
||||
}
|
||||
|
||||
setToolTip(toolTip(Metric));
|
||||
}
|
||||
|
||||
QString ElevationGraphItem::toolTip(Units units) const
|
||||
{
|
||||
ToolTip tt;
|
||||
qreal scale = (units == Metric) ? 1.0 : M2FT;
|
||||
QString su = (units == Metric) ? tr("m") : tr("ft");
|
||||
|
||||
tt.insert(tr("Ascent"), QString::number(ascent() * scale, 'f', 0)
|
||||
+ UNIT_SPACE + su);
|
||||
tt.insert(tr("Descent"), QString::number(descent() * scale, 'f', 0)
|
||||
+ UNIT_SPACE + su);
|
||||
tt.insert(tr("Maximum"), QString::number(max() * scale, 'f', 0)
|
||||
+ UNIT_SPACE + su);
|
||||
tt.insert(tr("Minimum"), QString::number(min() * scale, 'f', 0)
|
||||
+ UNIT_SPACE + su);
|
||||
|
||||
return tt.toString();
|
||||
}
|
||||
|
||||
void ElevationGraphItem::setUnits(Units units)
|
||||
{
|
||||
setToolTip(toolTip(units));
|
||||
}
|
27
src/elevationgraphitem.h
Normal file
27
src/elevationgraphitem.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef ELEVATIONGRAPHITEM_H
|
||||
#define ELEVATIONGRAPHITEM_H
|
||||
|
||||
#include "graphitem.h"
|
||||
|
||||
class ElevationGraphItem : public GraphItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ElevationGraphItem(const Graph &graph, GraphType type,
|
||||
QGraphicsItem *parent = 0);
|
||||
|
||||
qreal ascent() const {return _ascent;}
|
||||
qreal descent() const {return _descent;}
|
||||
qreal min() const {return -bounds().bottom();}
|
||||
qreal max() const {return -bounds().top();}
|
||||
|
||||
void setUnits(Units units);
|
||||
|
||||
private:
|
||||
QString toolTip(Units units) const;
|
||||
|
||||
qreal _ascent, _descent;
|
||||
};
|
||||
|
||||
#endif // ELEVATIONGRAPHITEM_H
|
@ -70,7 +70,7 @@ qreal EmptyMap::zoomOut()
|
||||
|
||||
void EmptyMap::draw(QPainter *painter, const QRectF &rect)
|
||||
{
|
||||
painter->fillRect(rect, Qt::white);
|
||||
painter->fillRect(rect, _backgroundColor);
|
||||
}
|
||||
|
||||
QPointF EmptyMap::ll2xy(const Coordinates &c)
|
||||
|
@ -26,15 +26,28 @@ ExportDialog::ExportDialog(Export *exp, QWidget *parent)
|
||||
_fileSelect->setFile(_export->fileName);
|
||||
|
||||
_paperSize = new QComboBox();
|
||||
_paperSize->addItem("A2", QPrinter::A2);
|
||||
_paperSize->addItem("A3", QPrinter::A3);
|
||||
_paperSize->addItem("A4", QPrinter::A4);
|
||||
_paperSize->addItem("A5", QPrinter::A5);
|
||||
_paperSize->addItem("A6", QPrinter::A6);
|
||||
_paperSize->addItem("B3", QPrinter::B3);
|
||||
_paperSize->addItem("B4", QPrinter::B4);
|
||||
_paperSize->addItem("B5", QPrinter::B5);
|
||||
_paperSize->addItem("B6", QPrinter::B6);
|
||||
_paperSize->addItem("Tabloid", QPrinter::Tabloid);
|
||||
_paperSize->addItem("Legal", QPrinter::Legal);
|
||||
_paperSize->addItem("Letter", QPrinter::Letter);
|
||||
if ((index = _paperSize->findData(_export->paperSize)) >= 0)
|
||||
_paperSize->setCurrentIndex(index);
|
||||
|
||||
_resolution = new QComboBox();
|
||||
_resolution->addItem("300 DPI", 300);
|
||||
_resolution->addItem("600 DPI", 600);
|
||||
_resolution->addItem("1200 DPI", 1200);
|
||||
if ((index = _resolution->findData(_export->resolution)) >= 0)
|
||||
_resolution->setCurrentIndex(index);
|
||||
|
||||
_portrait = new QRadioButton(tr("Portrait"));
|
||||
_landscape = new QRadioButton(tr("Landscape"));
|
||||
QHBoxLayout *orientationLayout = new QHBoxLayout();
|
||||
@ -81,6 +94,7 @@ ExportDialog::ExportDialog(Export *exp, QWidget *parent)
|
||||
#endif // Q_OS_MAC
|
||||
QFormLayout *pageSetupLayout = new QFormLayout;
|
||||
pageSetupLayout->addRow(tr("Page size:"), _paperSize);
|
||||
pageSetupLayout->addRow(tr("Resolution:"), _resolution);
|
||||
pageSetupLayout->addRow(tr("Orientation:"), orientationLayout);
|
||||
pageSetupLayout->addRow(tr("Margins:"), marginsLayout);
|
||||
#ifdef Q_OS_MAC
|
||||
@ -161,9 +175,11 @@ void ExportDialog::accept()
|
||||
? QPrinter::Portrait : QPrinter::Landscape;
|
||||
QPrinter::PaperSize paperSize = static_cast<QPrinter::PaperSize>
|
||||
(_paperSize->itemData(_paperSize->currentIndex()).toInt());
|
||||
int resolution = _resolution->itemData(_resolution->currentIndex()).toInt();
|
||||
|
||||
_export->fileName = _fileSelect->file();
|
||||
_export->paperSize = paperSize;
|
||||
_export->resolution = resolution;
|
||||
_export->orientation = orientation;
|
||||
if (_export->units == Imperial)
|
||||
_export->margins = MarginsF(_leftMargin->value() / MM2IN,
|
||||
|
@ -16,6 +16,7 @@ struct Export {
|
||||
QPrinter::PaperSize paperSize;
|
||||
QPrinter::Orientation orientation;
|
||||
MarginsF margins;
|
||||
int resolution;
|
||||
|
||||
Units units;
|
||||
};
|
||||
@ -37,6 +38,7 @@ private:
|
||||
|
||||
FileSelectWidget *_fileSelect;
|
||||
QComboBox *_paperSize;
|
||||
QComboBox *_resolution;
|
||||
QRadioButton *_portrait;
|
||||
QRadioButton *_landscape;
|
||||
QDoubleSpinBox *_topMargin;
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "coordinates.h"
|
||||
#include "format.h"
|
||||
|
||||
QString Format::timeSpan(qreal time)
|
||||
QString Format::timeSpan(qreal time, bool full)
|
||||
{
|
||||
unsigned h, m, s;
|
||||
|
||||
@ -10,8 +10,12 @@ QString Format::timeSpan(qreal time)
|
||||
m = (time - (h * 3600)) / 60;
|
||||
s = time - (h * 3600) - (m * 60);
|
||||
|
||||
return QString("%1:%2:%3").arg(h).arg(m, 2, 10, QChar('0'))
|
||||
.arg(s, 2, 10, QChar('0'));
|
||||
if (full || h)
|
||||
return QString("%1:%2:%3").arg(h, 2, 10, QChar('0'))
|
||||
.arg(m, 2, 10, QChar('0')).arg(s, 2, 10, QChar('0'));
|
||||
else
|
||||
return QString("%1:%2").arg(m, 2, 10, QChar('0'))
|
||||
.arg(s, 2, 10, QChar('0'));
|
||||
}
|
||||
|
||||
QString Format::distance(qreal value, Units units)
|
||||
|
@ -8,7 +8,7 @@ class Coordinates;
|
||||
|
||||
namespace Format
|
||||
{
|
||||
QString timeSpan(qreal time);
|
||||
QString timeSpan(qreal time, bool full = true);
|
||||
QString distance(qreal value, Units units);
|
||||
QString elevation(qreal value, Units units);
|
||||
QString coordinates(const Coordinates &value);
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
QDebug operator<<(QDebug dbg, const GraphPoint &point)
|
||||
{
|
||||
const bool ais = dbg.autoInsertSpaces();
|
||||
dbg.nospace() << "GraphPoint(" << point.s() << ", " << point.t() << ", "
|
||||
<< point.y() << ")";
|
||||
dbg.setAutoInsertSpaces(ais);
|
||||
return dbg.maybeSpace();
|
||||
return dbg.space();
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "graphitem.h"
|
||||
|
||||
|
||||
GraphItem::GraphItem(const Graph &graph, QGraphicsItem *parent)
|
||||
GraphItem::GraphItem(const Graph &graph, GraphType type, QGraphicsItem *parent)
|
||||
: QGraphicsObject(parent)
|
||||
{
|
||||
_id = 0;
|
||||
@ -10,7 +10,7 @@ GraphItem::GraphItem(const Graph &graph, QGraphicsItem *parent)
|
||||
|
||||
_pen = QPen(Qt::black, _width);
|
||||
|
||||
_type = Distance;
|
||||
_type = type;
|
||||
_graph = graph;
|
||||
_sx = 1.0; _sy = 1.0;
|
||||
|
||||
@ -25,7 +25,17 @@ GraphItem::GraphItem(const Graph &graph, QGraphicsItem *parent)
|
||||
setZValue(1.0);
|
||||
|
||||
updatePath();
|
||||
updateShape();
|
||||
updateBounds();
|
||||
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
|
||||
void GraphItem::updateShape()
|
||||
{
|
||||
QPainterPathStroker s;
|
||||
s.setWidth(_width + 1);
|
||||
_shape = s.createStroke(_path);
|
||||
}
|
||||
|
||||
void GraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
@ -46,25 +56,37 @@ void GraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
|
||||
void GraphItem::setGraphType(GraphType type)
|
||||
{
|
||||
if (type == _type)
|
||||
return;
|
||||
|
||||
prepareGeometryChange();
|
||||
|
||||
_type = type;
|
||||
updatePath();
|
||||
updateShape();
|
||||
updateBounds();
|
||||
}
|
||||
|
||||
void GraphItem::setColor(const QColor &color)
|
||||
{
|
||||
if (_pen.color() == color)
|
||||
return;
|
||||
|
||||
_pen.setColor(color);
|
||||
update();
|
||||
}
|
||||
|
||||
void GraphItem::setWidth(int width)
|
||||
{
|
||||
if (width == _width)
|
||||
return;
|
||||
|
||||
prepareGeometryChange();
|
||||
|
||||
_width = width;
|
||||
_pen.setWidth(width);
|
||||
|
||||
updateShape();
|
||||
}
|
||||
|
||||
qreal GraphItem::yAtX(qreal x)
|
||||
@ -143,9 +165,9 @@ void GraphItem::emitSliderPositionChanged(qreal pos)
|
||||
emit sliderPositionChanged(pos);
|
||||
}
|
||||
|
||||
void GraphItem::selected(bool selected)
|
||||
void GraphItem::hover(bool hover)
|
||||
{
|
||||
if (selected) {
|
||||
if (hover) {
|
||||
_pen.setWidth(_width + 1);
|
||||
setZValue(zValue() + 1.0);
|
||||
} else {
|
||||
@ -165,6 +187,7 @@ void GraphItem::setScale(qreal sx, qreal sy)
|
||||
|
||||
_sx = sx; _sy = sy;
|
||||
updatePath();
|
||||
updateShape();
|
||||
}
|
||||
|
||||
void GraphItem::updatePath()
|
||||
@ -199,3 +222,25 @@ void GraphItem::updateBounds()
|
||||
|
||||
_bounds = QRectF(QPointF(left, top), QPointF(right, bottom));
|
||||
}
|
||||
|
||||
void GraphItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
_pen.setWidthF(_width + 1);
|
||||
setZValue(zValue() + 1.0);
|
||||
update();
|
||||
|
||||
emit selected(true);
|
||||
}
|
||||
|
||||
void GraphItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
_pen.setWidthF(_width);
|
||||
setZValue(zValue() - 1.0);
|
||||
update();
|
||||
|
||||
emit selected(false);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include <QGraphicsObject>
|
||||
#include <QPen>
|
||||
#include "units.h"
|
||||
#include "graph.h"
|
||||
|
||||
class GraphItem : public QGraphicsObject
|
||||
@ -10,34 +11,42 @@ class GraphItem : public QGraphicsObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GraphItem(const Graph &graph, QGraphicsItem *parent = 0);
|
||||
GraphItem(const Graph &graph, GraphType type, QGraphicsItem *parent = 0);
|
||||
|
||||
QRectF boundingRect() const
|
||||
{return _path.boundingRect();}
|
||||
QPainterPath shape() const {return _shape;}
|
||||
QRectF boundingRect() const {return _shape.boundingRect();}
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget);
|
||||
|
||||
const QRectF &bounds() const {return _bounds;}
|
||||
void setScale(qreal sx, qreal sy);
|
||||
|
||||
void setScale(qreal sx, qreal sy);
|
||||
void setGraphType(GraphType type);
|
||||
int id() const {return _id;}
|
||||
void setId(int id) {_id = id;}
|
||||
void setColor(const QColor &color);
|
||||
void setWidth(int width);
|
||||
virtual void setUnits(Units units) {Q_UNUSED(units);}
|
||||
|
||||
qreal yAtX(qreal x);
|
||||
qreal distanceAtTime(qreal time);
|
||||
|
||||
void redraw();
|
||||
|
||||
signals:
|
||||
void sliderPositionChanged(qreal);
|
||||
void selected(bool);
|
||||
|
||||
public slots:
|
||||
void emitSliderPositionChanged(qreal);
|
||||
void selected(bool selected);
|
||||
void hover(bool hover);
|
||||
|
||||
private:
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||
|
||||
void updatePath();
|
||||
void updateShape();
|
||||
void updateBounds();
|
||||
|
||||
int _id;
|
||||
@ -48,6 +57,7 @@ private:
|
||||
GraphType _type;
|
||||
|
||||
QPainterPath _path;
|
||||
QPainterPath _shape;
|
||||
QRectF _bounds;
|
||||
qreal _sx, _sy;
|
||||
|
||||
|
@ -19,8 +19,9 @@ public:
|
||||
|
||||
virtual QString label() const = 0;
|
||||
virtual void loadData(const Data &data, const QList<PathItem *> &paths) = 0;
|
||||
virtual void clear() {}
|
||||
virtual void setUnits(enum Units units) {Q_UNUSED(units)}
|
||||
virtual void clear() {GraphView::clear();}
|
||||
virtual void setUnits(enum Units units) {GraphView::setUnits(units);}
|
||||
virtual void setGraphType(GraphType type) {GraphView::setGraphType(type);}
|
||||
virtual void setTimeType(enum TimeType type) {Q_UNUSED(type)}
|
||||
virtual void showTracks(bool show) {Q_UNUSED(show)}
|
||||
virtual void showRoutes(bool show) {Q_UNUSED(show)}
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "graph.h"
|
||||
#include "graphitem.h"
|
||||
#include "pathitem.h"
|
||||
#include "format.h"
|
||||
#include "graphview.h"
|
||||
|
||||
|
||||
@ -139,7 +140,13 @@ void GraphView::setXUnits()
|
||||
void GraphView::setUnits(Units units)
|
||||
{
|
||||
_units = units;
|
||||
|
||||
for (int i = 0; i < _graphs.count(); i++)
|
||||
_graphs.at(i)->setUnits(units);
|
||||
|
||||
setXUnits();
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
void GraphView::setGraphType(GraphType type)
|
||||
@ -167,29 +174,31 @@ void GraphView::showGrid(bool show)
|
||||
_grid->setVisible(show);
|
||||
}
|
||||
|
||||
void GraphView::loadGraph(const Graph &graph, PathItem *path, int id)
|
||||
void GraphView::showSliderInfo(bool show)
|
||||
{
|
||||
if (graph.size() < 2)
|
||||
return;
|
||||
_sliderInfo->setVisible(show);
|
||||
}
|
||||
|
||||
GraphItem *gi = new GraphItem(graph);
|
||||
gi->setGraphType(_graphType);
|
||||
gi->setId(id);
|
||||
gi->setColor(_palette.nextColor());
|
||||
gi->setWidth(_width);
|
||||
void GraphView::addGraph(GraphItem *graph, PathItem *path, int id)
|
||||
{
|
||||
graph->setUnits(_units);
|
||||
graph->setId(id);
|
||||
graph->setColor(_palette.nextColor());
|
||||
graph->setWidth(_width);
|
||||
|
||||
connect(this, SIGNAL(sliderPositionChanged(qreal)), gi,
|
||||
connect(this, SIGNAL(sliderPositionChanged(qreal)), graph,
|
||||
SLOT(emitSliderPositionChanged(qreal)));
|
||||
connect(gi, SIGNAL(sliderPositionChanged(qreal)), path,
|
||||
connect(graph, SIGNAL(sliderPositionChanged(qreal)), path,
|
||||
SLOT(moveMarker(qreal)));
|
||||
connect(path, SIGNAL(selected(bool)), gi, SLOT(selected(bool)));
|
||||
connect(path, SIGNAL(selected(bool)), graph, SLOT(hover(bool)));
|
||||
connect(graph, SIGNAL(selected(bool)), path, SLOT(hover(bool)));
|
||||
|
||||
_graphs.append(gi);
|
||||
_graphs.append(graph);
|
||||
|
||||
if (!_hide.contains(id)) {
|
||||
_visible.append(gi);
|
||||
_scene->addItem(gi);
|
||||
_bounds |= gi->bounds();
|
||||
_visible.append(graph);
|
||||
_scene->addItem(graph);
|
||||
_bounds |= graph->bounds();
|
||||
setXUnits();
|
||||
}
|
||||
}
|
||||
@ -227,11 +236,6 @@ void GraphView::showGraph(bool show, int id)
|
||||
}
|
||||
}
|
||||
|
||||
void GraphView::redraw()
|
||||
{
|
||||
redraw(viewport()->size() - QSizeF(MARGIN, MARGIN));
|
||||
}
|
||||
|
||||
QRectF GraphView::bounds() const
|
||||
{
|
||||
QRectF br(_bounds);
|
||||
@ -239,6 +243,11 @@ QRectF GraphView::bounds() const
|
||||
return br;
|
||||
}
|
||||
|
||||
void GraphView::redraw()
|
||||
{
|
||||
redraw(viewport()->size() - QSizeF(MARGIN, MARGIN));
|
||||
}
|
||||
|
||||
void GraphView::redraw(const QSizeF &size)
|
||||
{
|
||||
QRectF r;
|
||||
@ -326,11 +335,9 @@ void GraphView::mousePressEvent(QMouseEvent *e)
|
||||
QGraphicsView::mousePressEvent(e);
|
||||
}
|
||||
|
||||
void GraphView::plot(QPainter *painter, const QRectF &target)
|
||||
void GraphView::plot(QPainter *painter, const QRectF &target, qreal scale)
|
||||
{
|
||||
qreal ratio = painter->paintEngine()->paintDevice()->logicalDpiX()
|
||||
/ SCREEN_DPI;
|
||||
QSizeF canvas = QSizeF(target.width() / ratio, target.height() / ratio);
|
||||
QSizeF canvas = QSizeF(target.width() / scale, target.height() / scale);
|
||||
|
||||
setUpdatesEnabled(false);
|
||||
redraw(canvas);
|
||||
@ -374,22 +381,26 @@ void GraphView::updateSliderPosition()
|
||||
_slider->setVisible(false);
|
||||
}
|
||||
|
||||
updateSliderInfo();
|
||||
if (_slider->isVisible())
|
||||
updateSliderInfo();
|
||||
}
|
||||
|
||||
void GraphView::updateSliderInfo()
|
||||
{
|
||||
_sliderInfo->setVisible(_visible.count() == 1);
|
||||
if (!_sliderInfo->isVisible())
|
||||
return;
|
||||
qreal r, y;
|
||||
|
||||
QRectF br(_visible.first()->bounds());
|
||||
if (br.height() < _minYRange)
|
||||
br.adjust(0, -(_minYRange/2 - br.height()/2), 0,
|
||||
_minYRange/2 - br.height()/2);
|
||||
if (_visible.count() > 1) {
|
||||
r = 0;
|
||||
y = 0;
|
||||
} else {
|
||||
QRectF br(_visible.first()->bounds());
|
||||
if (br.height() < _minYRange)
|
||||
br.adjust(0, -(_minYRange/2 - br.height()/2), 0,
|
||||
_minYRange/2 - br.height()/2);
|
||||
|
||||
qreal y = _visible.first()->yAtX(_sliderPos);
|
||||
qreal r = (y - br.bottom()) / br.height();
|
||||
y = _visible.first()->yAtX(_sliderPos);
|
||||
r = (y - br.bottom()) / br.height();
|
||||
}
|
||||
|
||||
qreal pos = (_sliderPos / bounds().width()) * _slider->area().width();
|
||||
SliderInfoItem::Side s = (pos + _sliderInfo->boundingRect().width()
|
||||
@ -397,8 +408,11 @@ void GraphView::updateSliderInfo()
|
||||
|
||||
_sliderInfo->setSide(s);
|
||||
_sliderInfo->setPos(QPointF(0, _slider->boundingRect().height() * r));
|
||||
_sliderInfo->setText(QString::number(-y * _yScale + _yOffset, 'f',
|
||||
_precision));
|
||||
_sliderInfo->setText(_graphType == Time ? Format::timeSpan(_sliderPos,
|
||||
bounds().width() > 3600) : QString::number(_sliderPos * _xScale, 'f', 1)
|
||||
+ UNIT_SPACE + _xUnits, (_visible.count() > 1) ? QString()
|
||||
: QString::number(-y * _yScale + _yOffset, 'f', _precision) + UNIT_SPACE
|
||||
+ _yUnits);
|
||||
}
|
||||
|
||||
void GraphView::emitSliderPositionChanged(const QPointF &pos)
|
||||
@ -454,6 +468,8 @@ void GraphView::setGraphWidth(int width)
|
||||
|
||||
for (int i = 0; i < _graphs.count(); i++)
|
||||
_graphs.at(i)->setWidth(width);
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
void GraphView::useOpenGL(bool use)
|
||||
@ -463,3 +479,8 @@ void GraphView::useOpenGL(bool use)
|
||||
else
|
||||
setViewport(new QWidget);
|
||||
}
|
||||
|
||||
void GraphView::useAntiAliasing(bool use)
|
||||
{
|
||||
setRenderHint(QPainter::Antialiasing, use);
|
||||
}
|
||||
|
@ -4,9 +4,9 @@
|
||||
#include <QGraphicsView>
|
||||
#include <QList>
|
||||
#include <QSet>
|
||||
#include "graph.h"
|
||||
#include "palette.h"
|
||||
#include "units.h"
|
||||
#include "graph.h"
|
||||
|
||||
|
||||
class AxisItem;
|
||||
@ -25,18 +25,29 @@ public:
|
||||
GraphView(QWidget *parent = 0);
|
||||
~GraphView();
|
||||
|
||||
void loadGraph(const Graph &graph, PathItem *path, int id = 0);
|
||||
int count() const {return _graphs.count();}
|
||||
void redraw();
|
||||
bool isEmpty() const {return _graphs.isEmpty();}
|
||||
void clear();
|
||||
|
||||
void plot(QPainter *painter, const QRectF &target, qreal scale);
|
||||
|
||||
void setPalette(const Palette &palette);
|
||||
void setGraphWidth(int width);
|
||||
void showGrid(bool show);
|
||||
void showSliderInfo(bool show);
|
||||
void useOpenGL(bool use);
|
||||
void useAntiAliasing(bool use);
|
||||
|
||||
void setSliderPosition(qreal pos);
|
||||
|
||||
signals:
|
||||
void sliderPositionChanged(qreal);
|
||||
|
||||
protected:
|
||||
void addGraph(GraphItem *graph, PathItem *path, int id = 0);
|
||||
|
||||
void showGraph(bool show, int id = 0);
|
||||
void setGraphType(GraphType type);
|
||||
void setUnits(Units units);
|
||||
void showGrid(bool show);
|
||||
|
||||
void setPalette(const Palette &palette);
|
||||
void setGraphWidth(int width);
|
||||
|
||||
const QString &yLabel() const {return _yLabel;}
|
||||
const QString &yUnits() const {return _yUnits;}
|
||||
@ -50,23 +61,16 @@ public:
|
||||
void setSliderPrecision(int precision) {_precision = precision;}
|
||||
void setMinYRange(qreal range) {_minYRange = range;}
|
||||
|
||||
qreal sliderPosition() const {return _sliderPos;}
|
||||
void setSliderPosition(qreal pos);
|
||||
|
||||
void plot(QPainter *painter, const QRectF &target);
|
||||
|
||||
void useOpenGL(bool use);
|
||||
|
||||
signals:
|
||||
void sliderPositionChanged(qreal);
|
||||
|
||||
protected:
|
||||
QRectF bounds() const;
|
||||
void redraw();
|
||||
void redraw(const QSizeF &size);
|
||||
void addInfo(const QString &key, const QString &value);
|
||||
void clearInfo();
|
||||
void skipColor() {_palette.nextColor();}
|
||||
|
||||
QList<GraphItem*> _graphs;
|
||||
GraphType _graphType;
|
||||
|
||||
private slots:
|
||||
void emitSliderPositionChanged(const QPointF &pos);
|
||||
void newSliderPosition(const QPointF &pos);
|
||||
@ -83,6 +87,7 @@ private:
|
||||
void resizeEvent(QResizeEvent *);
|
||||
void mousePressEvent(QMouseEvent *);
|
||||
|
||||
Units _units;
|
||||
qreal _xScale, _yScale;
|
||||
qreal _yOffset;
|
||||
QString _xUnits, _yUnits;
|
||||
@ -99,15 +104,11 @@ private:
|
||||
InfoItem *_info;
|
||||
GridItem *_grid;
|
||||
|
||||
QList<GraphItem*> _graphs;
|
||||
QList<GraphItem*> _visible;
|
||||
QSet<int> _hide;
|
||||
QRectF _bounds;
|
||||
Palette _palette;
|
||||
int _width;
|
||||
|
||||
Units _units;
|
||||
GraphType _graphType;
|
||||
};
|
||||
|
||||
#endif // GRAPHVIEW_H
|
||||
|
246
src/gui.cpp
246
src/gui.cpp
@ -187,7 +187,7 @@ void GUI::loadMaps()
|
||||
}
|
||||
}
|
||||
|
||||
_map = _ml->maps().isEmpty() ? new EmptyMap(this) : _ml->maps().first();
|
||||
_map = new EmptyMap(this);
|
||||
}
|
||||
|
||||
void GUI::loadPOIs()
|
||||
@ -361,7 +361,7 @@ void GUI::createActions()
|
||||
tr("Load map..."), this);
|
||||
connect(_loadMapAction, SIGNAL(triggered()), this, SLOT(loadMap()));
|
||||
_clearMapCacheAction = new QAction(tr("Clear tile cache"), this);
|
||||
connect(_clearMapCacheAction, SIGNAL(triggered()), this,
|
||||
connect(_clearMapCacheAction, SIGNAL(triggered()), _pathView,
|
||||
SLOT(clearMapCache()));
|
||||
createMapActions();
|
||||
_nextMapAction = new QAction(tr("Next map"), this);
|
||||
@ -412,14 +412,12 @@ void GUI::createActions()
|
||||
_distanceGraphAction = new QAction(tr("Distance"), this);
|
||||
_distanceGraphAction->setCheckable(true);
|
||||
_distanceGraphAction->setActionGroup(ag);
|
||||
_distanceGraphAction->setShortcut(DISTANCE_GRAPH_SHORTCUT);
|
||||
connect(_distanceGraphAction, SIGNAL(triggered()), this,
|
||||
SLOT(setDistanceGraph()));
|
||||
addAction(_distanceGraphAction);
|
||||
_timeGraphAction = new QAction(tr("Time"), this);
|
||||
_timeGraphAction->setCheckable(true);
|
||||
_timeGraphAction->setActionGroup(ag);
|
||||
_timeGraphAction->setShortcut(TIME_GRAPH_SHORTCUT);
|
||||
connect(_timeGraphAction, SIGNAL(triggered()), this,
|
||||
SLOT(setTimeGraph()));
|
||||
addAction(_timeGraphAction);
|
||||
@ -427,6 +425,10 @@ void GUI::createActions()
|
||||
_showGraphGridAction->setCheckable(true);
|
||||
connect(_showGraphGridAction, SIGNAL(triggered(bool)), this,
|
||||
SLOT(showGraphGrids(bool)));
|
||||
_showGraphSliderInfoAction = new QAction(tr("Show slider info"), this);
|
||||
_showGraphSliderInfoAction->setCheckable(true);
|
||||
connect(_showGraphSliderInfoAction, SIGNAL(triggered(bool)), this,
|
||||
SLOT(showGraphSliderInfo(bool)));
|
||||
|
||||
// Settings actions
|
||||
_showToolbarsAction = new QAction(tr("Show toolbars"), this);
|
||||
@ -515,6 +517,7 @@ void GUI::createMenus()
|
||||
graphMenu->addAction(_timeGraphAction);
|
||||
graphMenu->addSeparator();
|
||||
graphMenu->addAction(_showGraphGridAction);
|
||||
graphMenu->addAction(_showGraphSliderInfoAction);
|
||||
graphMenu->addSeparator();
|
||||
graphMenu->addAction(_showGraphsAction);
|
||||
|
||||
@ -671,7 +674,12 @@ void GUI::keys()
|
||||
+ tr("Last file") + "</td><td><i>" + QKeySequence(LAST_KEY).toString()
|
||||
+ "</i></td></tr><tr><td>" + tr("Append file")
|
||||
+ "</td><td><i>" + QKeySequence(MODIFIER).toString() + tr("Next/Previous")
|
||||
+ "</i></td></tr><tr><td></td><td></td></tr><tr><td>" + tr("Next map")
|
||||
+ "</i></td></tr><tr><td></td><td></td></tr><tr><td>"
|
||||
+ tr("Toggle graph type") + "</td><td><i>"
|
||||
+ QKeySequence(TOGGLE_GRAPH_TYPE_KEY).toString() + "</i></td></tr><tr><td>"
|
||||
+ tr("Toggle time type") + "</td><td><i>"
|
||||
+ QKeySequence(TOGGLE_TIME_TYPE_KEY).toString()
|
||||
+ "<tr><td></td><td></td></tr><tr><td>" + tr("Next map")
|
||||
+ "</td><td><i>" + NEXT_MAP_SHORTCUT.toString() + "</i></td></tr><tr><td>"
|
||||
+ tr("Previous map") + "</td><td><i>" + PREV_MAP_SHORTCUT.toString()
|
||||
+ "</i></td></tr><tr><td></td><td></td></tr><tr><td>" + tr("Zoom in")
|
||||
@ -696,10 +704,11 @@ void GUI::dataSources()
|
||||
"following file:")
|
||||
+ "</p><p><code>" + USER_MAP_FILE + "</code></p><p>"
|
||||
+ tr("The file format is one map entry per line, consisting of the map "
|
||||
"name and tiles URL delimited by a TAB character. The tile X and Y "
|
||||
"coordinates are replaced with $x and $y in the URL and the zoom "
|
||||
"level is replaced with $z. An example map file could look like:")
|
||||
+ "</p><p><code>Map1 http://tile.server.com/map/$z/$x/$y.png"
|
||||
"name, tiles URL and an optional maximal zoom level delimited by "
|
||||
"a TAB character. The tile X and Y coordinates are replaced with $x "
|
||||
"and $y in the URL and the zoom level is replaced with $z. An example "
|
||||
"map file could look like:")
|
||||
+ "</p><p><code>Map1 http://tile.server.com/map/$z/$x/$y.png 15"
|
||||
"<br/>Map2 http://mapserver.org/map/$z-$x-$y</code></p>"
|
||||
|
||||
+ "<h4>" + tr("Offline maps") + "</h4><p>"
|
||||
@ -854,17 +863,21 @@ void GUI::closePOIFiles()
|
||||
_poi->clear();
|
||||
}
|
||||
|
||||
void GUI::printFile()
|
||||
{
|
||||
QPrinter printer(QPrinter::HighResolution);
|
||||
QPrintDialog dialog(&printer, this);
|
||||
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
plot(&printer);
|
||||
}
|
||||
|
||||
void GUI::openOptions()
|
||||
{
|
||||
#define SET_VIEW_OPTION(option, action) \
|
||||
if (options.option != _options.option) \
|
||||
_pathView->action(options.option)
|
||||
#define SET_TAB_OPTION(option, action) \
|
||||
if (options.option != _options.option) \
|
||||
for (int i = 0; i < _tabs.count(); i++) \
|
||||
_tabs.at(i)->action(options.option)
|
||||
#define SET_TRACK_OPTION(option, action) \
|
||||
if (options.option != _options.option) { \
|
||||
Track::action(options.option); \
|
||||
reload = true; \
|
||||
}
|
||||
|
||||
Options options(_options);
|
||||
bool reload = false;
|
||||
|
||||
@ -872,71 +885,36 @@ void GUI::openOptions()
|
||||
if (dialog.exec() != QDialog::Accepted)
|
||||
return;
|
||||
|
||||
if (options.palette != _options.palette) {
|
||||
_pathView->setPalette(options.palette);
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
_tabs.at(i)->setPalette(options.palette);
|
||||
}
|
||||
if (options.trackWidth != _options.trackWidth)
|
||||
_pathView->setTrackWidth(options.trackWidth);
|
||||
if (options.routeWidth != _options.routeWidth)
|
||||
_pathView->setRouteWidth(options.routeWidth);
|
||||
if (options.trackStyle != _options.trackStyle)
|
||||
_pathView->setTrackStyle(options.trackStyle);
|
||||
if (options.routeStyle != _options.routeStyle)
|
||||
_pathView->setRouteStyle(options.routeStyle);
|
||||
if (options.pathAntiAliasing != _options.pathAntiAliasing)
|
||||
_pathView->setRenderHint(QPainter::Antialiasing,
|
||||
options.pathAntiAliasing);
|
||||
if (options.graphWidth != _options.graphWidth)
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
_tabs.at(i)->setGraphWidth(options.graphWidth);
|
||||
if (options.graphAntiAliasing != _options.graphAntiAliasing)
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
_tabs.at(i)->setRenderHint(QPainter::Antialiasing,
|
||||
options.graphAntiAliasing);
|
||||
SET_VIEW_OPTION(palette, setPalette);
|
||||
SET_VIEW_OPTION(mapOpacity, setMapOpacity);
|
||||
SET_VIEW_OPTION(backgroundColor, setBackgroundColor);
|
||||
SET_VIEW_OPTION(trackWidth, setTrackWidth);
|
||||
SET_VIEW_OPTION(routeWidth, setRouteWidth);
|
||||
SET_VIEW_OPTION(trackStyle, setTrackStyle);
|
||||
SET_VIEW_OPTION(routeStyle, setRouteStyle);
|
||||
SET_VIEW_OPTION(waypointSize, setWaypointSize);
|
||||
SET_VIEW_OPTION(waypointColor, setWaypointColor);
|
||||
SET_VIEW_OPTION(poiSize, setPOISize);
|
||||
SET_VIEW_OPTION(poiColor, setPOIColor);
|
||||
SET_VIEW_OPTION(pathAntiAliasing, useAntiAliasing);
|
||||
SET_VIEW_OPTION(useOpenGL, useOpenGL);
|
||||
|
||||
if (options.elevationFilter != _options.elevationFilter) {
|
||||
Track::setElevationFilter(options.elevationFilter);
|
||||
reload = true;
|
||||
}
|
||||
if (options.speedFilter != _options.speedFilter) {
|
||||
Track::setSpeedFilter(options.speedFilter);
|
||||
reload = true;
|
||||
}
|
||||
if (options.heartRateFilter != _options.heartRateFilter) {
|
||||
Track::setHeartRateFilter(options.heartRateFilter);
|
||||
reload = true;
|
||||
}
|
||||
if (options.cadenceFilter != _options.cadenceFilter) {
|
||||
Track::setCadenceFilter(options.cadenceFilter);
|
||||
reload = true;
|
||||
}
|
||||
if (options.powerFilter != _options.powerFilter) {
|
||||
Track::setPowerFilter(options.powerFilter);
|
||||
reload = true;
|
||||
}
|
||||
if (options.outlierEliminate != _options.outlierEliminate) {
|
||||
Track::setOutlierElimination(options.outlierEliminate);
|
||||
reload = true;
|
||||
}
|
||||
if (options.pauseSpeed != _options.pauseSpeed) {
|
||||
Track::setPauseSpeed(options.pauseSpeed);
|
||||
reload = true;
|
||||
}
|
||||
if (options.pauseInterval != _options.pauseInterval) {
|
||||
Track::setPauseInterval(options.pauseInterval);
|
||||
reload = true;
|
||||
}
|
||||
SET_TAB_OPTION(palette, setPalette);
|
||||
SET_TAB_OPTION(graphWidth, setGraphWidth);
|
||||
SET_TAB_OPTION(graphAntiAliasing, useAntiAliasing);
|
||||
SET_TAB_OPTION(useOpenGL, useOpenGL);
|
||||
|
||||
SET_TRACK_OPTION(elevationFilter, setElevationFilter);
|
||||
SET_TRACK_OPTION(speedFilter, setSpeedFilter);
|
||||
SET_TRACK_OPTION(heartRateFilter, setHeartRateFilter);
|
||||
SET_TRACK_OPTION(cadenceFilter, setCadenceFilter);
|
||||
SET_TRACK_OPTION(powerFilter, setPowerFilter);
|
||||
SET_TRACK_OPTION(outlierEliminate, setOutlierElimination);
|
||||
SET_TRACK_OPTION(pauseSpeed, setPauseSpeed);
|
||||
SET_TRACK_OPTION(pauseInterval, setPauseInterval);
|
||||
|
||||
if (options.poiRadius != _options.poiRadius)
|
||||
_poi->setRadius(options.poiRadius);
|
||||
|
||||
if (options.useOpenGL != _options.useOpenGL) {
|
||||
_pathView->useOpenGL(options.useOpenGL);
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
_tabs.at(i)->useOpenGL(options.useOpenGL);
|
||||
}
|
||||
if (options.pixmapCache != _options.pixmapCache)
|
||||
QPixmapCache::setCacheLimit(options.pixmapCache * 1024);
|
||||
|
||||
@ -946,6 +924,15 @@ void GUI::openOptions()
|
||||
_options = options;
|
||||
}
|
||||
|
||||
void GUI::printFile()
|
||||
{
|
||||
QPrinter printer(QPrinter::HighResolution);
|
||||
QPrintDialog dialog(&printer, this);
|
||||
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
plot(&printer);
|
||||
}
|
||||
|
||||
void GUI::exportFile()
|
||||
{
|
||||
ExportDialog dialog(&_export, this);
|
||||
@ -956,6 +943,7 @@ void GUI::exportFile()
|
||||
printer.setOutputFormat(QPrinter::PdfFormat);
|
||||
printer.setCreator(QString(APP_NAME) + QString(" ")
|
||||
+ QString(APP_VERSION));
|
||||
printer.setResolution(_export.resolution);
|
||||
printer.setOrientation(_export.orientation);
|
||||
printer.setOutputFileName(_export.fileName);
|
||||
printer.setPaperSize(_export.paperSize);
|
||||
@ -1005,35 +993,36 @@ void GUI::plot(QPrinter *printer)
|
||||
if (tm > 0 && _options.printMovingTime)
|
||||
info.insert(tr("Moving time"), Format::timeSpan(tm));
|
||||
|
||||
|
||||
ratio = p.paintEngine()->paintDevice()->logicalDpiX() / SCREEN_DPI;
|
||||
qreal fsr = 1085.0 / (qMax(printer->width(), printer->height())
|
||||
/ (qreal)printer->resolution());
|
||||
ratio = p.paintEngine()->paintDevice()->logicalDpiX() / fsr;
|
||||
if (info.isEmpty()) {
|
||||
ih = 0;
|
||||
mh = 0;
|
||||
} else {
|
||||
ih = info.contentSize().height() * ratio;
|
||||
mh = ih / 2;
|
||||
info.plot(&p, QRectF(0, 0, printer->width(), ih));
|
||||
info.plot(&p, QRectF(0, 0, printer->width(), ih), ratio);
|
||||
}
|
||||
if (_graphTabWidget->isVisible() && !_options.separateGraphPage) {
|
||||
qreal r = (((qreal)(printer)->width()) / (qreal)(printer->height()));
|
||||
gh = (printer->width() > printer->height())
|
||||
? 0.15 * r * (printer->height() - ih - 2*mh)
|
||||
: 0.15 * (printer->height() - ih - 2*mh);
|
||||
gh = qMax(gh, ratio * 150);
|
||||
GraphTab *gt = static_cast<GraphTab*>(_graphTabWidget->currentWidget());
|
||||
gt->plot(&p, QRectF(0, printer->height() - gh, printer->width(), gh));
|
||||
gt->plot(&p, QRectF(0, printer->height() - gh, printer->width(), gh),
|
||||
ratio);
|
||||
} else
|
||||
gh = 0;
|
||||
_pathView->plot(&p, QRectF(0, ih + mh, printer->width(), printer->height()
|
||||
- (ih + 2*mh + gh)));
|
||||
- (ih + 2*mh + gh)), ratio, _options.hiresPrint);
|
||||
|
||||
if (_graphTabWidget->isVisible() && _options.separateGraphPage) {
|
||||
printer->newPage();
|
||||
|
||||
int cnt = 0;
|
||||
for (int i = 0; i < _tabs.size(); i++)
|
||||
if (_tabs.at(i)->count())
|
||||
if (!_tabs.at(i)->isEmpty())
|
||||
cnt++;
|
||||
|
||||
qreal sp = ratio * 20;
|
||||
@ -1042,8 +1031,9 @@ void GUI::plot(QPrinter *printer)
|
||||
|
||||
qreal y = 0;
|
||||
for (int i = 0; i < _tabs.size(); i++) {
|
||||
if (_tabs.at(i)->count()) {
|
||||
_tabs.at(i)->plot(&p, QRectF(0, y, printer->width(), gh));
|
||||
if (!_tabs.at(i)->isEmpty()) {
|
||||
_tabs.at(i)->plot(&p, QRectF(0, y, printer->width(), gh),
|
||||
ratio);
|
||||
y += gh + sp;
|
||||
}
|
||||
}
|
||||
@ -1192,6 +1182,12 @@ void GUI::showGraphGrids(bool show)
|
||||
_tabs.at(i)->showGrid(show);
|
||||
}
|
||||
|
||||
void GUI::showGraphSliderInfo(bool show)
|
||||
{
|
||||
for (int i = 0; i < _tabs.size(); i++)
|
||||
_tabs.at(i)->showSliderInfo(show);
|
||||
}
|
||||
|
||||
void GUI::loadMap()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Open map file"),
|
||||
@ -1221,12 +1217,6 @@ void GUI::loadMap()
|
||||
}
|
||||
}
|
||||
|
||||
void GUI::clearMapCache()
|
||||
{
|
||||
_map->clearCache();
|
||||
_pathView->redraw();
|
||||
}
|
||||
|
||||
void GUI::updateStatusBarInfo()
|
||||
{
|
||||
if (_files.count() == 0)
|
||||
@ -1338,13 +1328,13 @@ void GUI::updateGraphTabs()
|
||||
|
||||
for (int i = 0; i < _tabs.size(); i++) {
|
||||
tab = _tabs.at(i);
|
||||
if (!tab->count() && (index = _graphTabWidget->indexOf(tab)) >= 0)
|
||||
if (tab->isEmpty() && (index = _graphTabWidget->indexOf(tab)) >= 0)
|
||||
_graphTabWidget->removeTab(index);
|
||||
}
|
||||
|
||||
for (int i = 0; i < _tabs.size(); i++) {
|
||||
tab = _tabs.at(i);
|
||||
if (tab->count() && _graphTabWidget->indexOf(tab) < 0)
|
||||
if (!tab->isEmpty() && _graphTabWidget->indexOf(tab) < 0)
|
||||
_graphTabWidget->insertTab(i, tab, _tabs.at(i)->label());
|
||||
}
|
||||
|
||||
@ -1451,6 +1441,19 @@ void GUI::keyPressEvent(QKeyEvent *event)
|
||||
file = _browser->last();
|
||||
break;
|
||||
|
||||
case TOGGLE_GRAPH_TYPE_KEY:
|
||||
if (_timeGraphAction->isChecked())
|
||||
_distanceGraphAction->activate(QAction::Trigger);
|
||||
else
|
||||
_timeGraphAction->activate(QAction::Trigger);
|
||||
break;
|
||||
case TOGGLE_TIME_TYPE_KEY:
|
||||
if (_movingTimeAction->isChecked())
|
||||
_totalTimeAction->activate(QAction::Trigger);
|
||||
else
|
||||
_movingTimeAction->activate(QAction::Trigger);
|
||||
break;
|
||||
|
||||
case Qt::Key_Escape:
|
||||
if (_fullscreenAction->isChecked()) {
|
||||
_fullscreenAction->setChecked(false);
|
||||
@ -1539,6 +1542,10 @@ void GUI::writeSettings()
|
||||
if (_showGraphGridAction->isChecked() != SHOW_GRAPH_GRIDS_DEFAULT)
|
||||
settings.setValue(SHOW_GRAPH_GRIDS_SETTING,
|
||||
_showGraphGridAction->isChecked());
|
||||
if (_showGraphSliderInfoAction->isChecked()
|
||||
!= SHOW_GRAPH_SLIDER_INFO_DEFAULT)
|
||||
settings.setValue(SHOW_GRAPH_SLIDER_INFO_SETTING,
|
||||
_showGraphSliderInfoAction->isChecked());
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(POI_SETTINGS_GROUP);
|
||||
@ -1579,6 +1586,8 @@ void GUI::writeSettings()
|
||||
settings.beginGroup(EXPORT_SETTINGS_GROUP);
|
||||
if (_export.orientation != PAPER_ORIENTATION_DEFAULT)
|
||||
settings.setValue(PAPER_ORIENTATION_SETTING, _export.orientation);
|
||||
if (_export.resolution != RESOLUTION_DEFAULT)
|
||||
settings.setValue(RESOLUTION_SETTING, _export.resolution);
|
||||
if (_export.paperSize != PAPER_SIZE_DEFAULT)
|
||||
settings.setValue(PAPER_SIZE_SETTING, _export.paperSize);
|
||||
if (_export.margins.left() != MARGIN_LEFT_DEFAULT)
|
||||
@ -1598,6 +1607,10 @@ void GUI::writeSettings()
|
||||
settings.setValue(PALETTE_COLOR_SETTING, _options.palette.color());
|
||||
if (_options.palette.shift() != PALETTE_SHIFT_DEFAULT)
|
||||
settings.setValue(PALETTE_SHIFT_SETTING, _options.palette.shift());
|
||||
if (_options.mapOpacity != MAP_OPACITY_DEFAULT)
|
||||
settings.setValue(MAP_OPACITY_SETTING, _options.mapOpacity);
|
||||
if (_options.backgroundColor != BACKGROUND_COLOR_DEFAULT)
|
||||
settings.setValue(BACKGROUND_COLOR_SETTING, _options.backgroundColor);
|
||||
if (_options.trackWidth != TRACK_WIDTH_DEFAULT)
|
||||
settings.setValue(TRACK_WIDTH_SETTING, _options.trackWidth);
|
||||
if (_options.routeWidth != ROUTE_WIDTH_DEFAULT)
|
||||
@ -1606,6 +1619,14 @@ void GUI::writeSettings()
|
||||
settings.setValue(TRACK_STYLE_SETTING, (int)_options.trackStyle);
|
||||
if (_options.routeStyle != ROUTE_STYLE_DEFAULT)
|
||||
settings.setValue(ROUTE_STYLE_SETTING, (int)_options.routeStyle);
|
||||
if (_options.waypointSize != WAYPOINT_SIZE_DEFAULT)
|
||||
settings.setValue(WAYPOINT_SIZE_SETTING, _options.waypointSize);
|
||||
if (_options.waypointColor != WAYPOINT_COLOR_DEFAULT)
|
||||
settings.setValue(WAYPOINT_COLOR_SETTING, _options.waypointColor);
|
||||
if (_options.poiSize != POI_SIZE_DEFAULT)
|
||||
settings.setValue(POI_SIZE_SETTING, _options.poiSize);
|
||||
if (_options.poiColor != POI_COLOR_DEFAULT)
|
||||
settings.setValue(POI_COLOR_SETTING, _options.poiColor);
|
||||
if (_options.graphWidth != GRAPH_WIDTH_DEFAULT)
|
||||
settings.setValue(GRAPH_WIDTH_SETTING, _options.graphWidth);
|
||||
if (_options.pathAntiAliasing != PATH_AA_DEFAULT)
|
||||
@ -1634,6 +1655,8 @@ void GUI::writeSettings()
|
||||
settings.setValue(USE_OPENGL_SETTING, _options.useOpenGL);
|
||||
if (_options.pixmapCache != PIXMAP_CACHE_DEFAULT)
|
||||
settings.setValue(PIXMAP_CACHE_SETTING, _options.pixmapCache);
|
||||
if (_options.hiresPrint != HIRES_PRINT_DEFAULT)
|
||||
settings.setValue(HIRES_PRINT_SETTING, _options.hiresPrint);
|
||||
if (_options.printName != PRINT_NAME_DEFAULT)
|
||||
settings.setValue(PRINT_NAME_SETTING, _options.printName);
|
||||
if (_options.printDate != PRINT_DATE_DEFAULT)
|
||||
@ -1688,9 +1711,7 @@ void GUI::readSettings()
|
||||
_showMapAction->setChecked(true);
|
||||
if (_ml->maps().count()) {
|
||||
int index = mapIndex(settings.value(CURRENT_MAP_SETTING).toString());
|
||||
_mapActions.at(index)->setChecked(true);
|
||||
_map = _ml->maps().at(index);
|
||||
_pathView->setMap(_map);
|
||||
_mapActions.at(index)->trigger();
|
||||
}
|
||||
settings.endGroup();
|
||||
|
||||
@ -1710,6 +1731,11 @@ void GUI::readSettings()
|
||||
showGraphGrids(false);
|
||||
else
|
||||
_showGraphGridAction->setChecked(true);
|
||||
if (!settings.value(SHOW_GRAPH_SLIDER_INFO_SETTING,
|
||||
SHOW_GRAPH_SLIDER_INFO_DEFAULT).toBool())
|
||||
showGraphSliderInfo(false);
|
||||
else
|
||||
_showGraphSliderInfoAction->setChecked(true);
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(POI_SETTINGS_GROUP);
|
||||
@ -1773,6 +1799,8 @@ void GUI::readSettings()
|
||||
settings.beginGroup(EXPORT_SETTINGS_GROUP);
|
||||
_export.orientation = (QPrinter::Orientation) settings.value(
|
||||
PAPER_ORIENTATION_SETTING, PAPER_ORIENTATION_DEFAULT).toInt();
|
||||
_export.resolution = settings.value(RESOLUTION_SETTING, RESOLUTION_DEFAULT)
|
||||
.toInt();
|
||||
_export.paperSize = (QPrinter::PaperSize) settings.value(PAPER_SIZE_SETTING,
|
||||
PAPER_SIZE_DEFAULT).toInt();
|
||||
qreal ml = settings.value(MARGIN_LEFT_SETTING, MARGIN_LEFT_DEFAULT)
|
||||
@ -1793,6 +1821,10 @@ void GUI::readSettings()
|
||||
qreal ps = settings.value(PALETTE_SHIFT_SETTING, PALETTE_SHIFT_DEFAULT)
|
||||
.toDouble();
|
||||
_options.palette = Palette(pc, ps);
|
||||
_options.mapOpacity = settings.value(MAP_OPACITY_SETTING,
|
||||
MAP_OPACITY_DEFAULT).toInt();
|
||||
_options.backgroundColor = settings.value(BACKGROUND_COLOR_SETTING,
|
||||
BACKGROUND_COLOR_DEFAULT).value<QColor>();
|
||||
_options.trackWidth = settings.value(TRACK_WIDTH_SETTING,
|
||||
TRACK_WIDTH_DEFAULT).toInt();
|
||||
_options.routeWidth = settings.value(ROUTE_WIDTH_SETTING,
|
||||
@ -1803,6 +1835,14 @@ void GUI::readSettings()
|
||||
(int)ROUTE_STYLE_DEFAULT).toInt();
|
||||
_options.pathAntiAliasing = settings.value(PATH_AA_SETTING, PATH_AA_DEFAULT)
|
||||
.toBool();
|
||||
_options.waypointSize = settings.value(WAYPOINT_SIZE_SETTING,
|
||||
WAYPOINT_SIZE_DEFAULT).toInt();
|
||||
_options.waypointColor = settings.value(WAYPOINT_COLOR_SETTING,
|
||||
WAYPOINT_COLOR_DEFAULT).value<QColor>();
|
||||
_options.poiSize = settings.value(POI_SIZE_SETTING, POI_SIZE_DEFAULT)
|
||||
.toInt();
|
||||
_options.poiColor = settings.value(POI_COLOR_SETTING, POI_COLOR_DEFAULT)
|
||||
.value<QColor>();
|
||||
_options.graphWidth = settings.value(GRAPH_WIDTH_SETTING,
|
||||
GRAPH_WIDTH_DEFAULT).toInt();
|
||||
_options.graphAntiAliasing = settings.value(GRAPH_AA_SETTING,
|
||||
@ -1829,6 +1869,8 @@ void GUI::readSettings()
|
||||
.toBool();
|
||||
_options.pixmapCache = settings.value(PIXMAP_CACHE_SETTING,
|
||||
PIXMAP_CACHE_DEFAULT).toInt();
|
||||
_options.hiresPrint = settings.value(HIRES_PRINT_SETTING,
|
||||
HIRES_PRINT_DEFAULT).toBool();
|
||||
_options.printName = settings.value(PRINT_NAME_SETTING, PRINT_NAME_DEFAULT)
|
||||
.toBool();
|
||||
_options.printDate = settings.value(PRINT_DATE_SETTING, PRINT_DATE_DEFAULT)
|
||||
@ -1845,10 +1887,16 @@ void GUI::readSettings()
|
||||
SEPARATE_GRAPH_PAGE_DEFAULT).toBool();
|
||||
|
||||
_pathView->setPalette(_options.palette);
|
||||
_pathView->setMapOpacity(_options.mapOpacity);
|
||||
_pathView->setBackgroundColor(_options.backgroundColor);
|
||||
_pathView->setTrackWidth(_options.trackWidth);
|
||||
_pathView->setRouteWidth(_options.routeWidth);
|
||||
_pathView->setTrackStyle(_options.trackStyle);
|
||||
_pathView->setRouteStyle(_options.routeStyle);
|
||||
_pathView->setWaypointSize(_options.waypointSize);
|
||||
_pathView->setWaypointColor(_options.waypointColor);
|
||||
_pathView->setPOISize(_options.poiSize);
|
||||
_pathView->setPOIColor(_options.poiColor);
|
||||
_pathView->setRenderHint(QPainter::Antialiasing, _options.pathAntiAliasing);
|
||||
if (_options.useOpenGL)
|
||||
_pathView->useOpenGL(true);
|
||||
|
@ -51,12 +51,12 @@ private slots:
|
||||
void closePOIFiles();
|
||||
void showGraphs(bool show);
|
||||
void showGraphGrids(bool show);
|
||||
void showGraphSliderInfo(bool show);
|
||||
void showToolbars(bool show);
|
||||
void showFullscreen(bool show);
|
||||
void showTracks(bool show);
|
||||
void showRoutes(bool show);
|
||||
void loadMap();
|
||||
void clearMapCache();
|
||||
void nextMap();
|
||||
void prevMap();
|
||||
void openOptions();
|
||||
@ -156,6 +156,7 @@ private:
|
||||
QAction *_clearMapCacheAction;
|
||||
QAction *_showGraphsAction;
|
||||
QAction *_showGraphGridAction;
|
||||
QAction *_showGraphSliderInfoAction;
|
||||
QAction *_distanceGraphAction;
|
||||
QAction *_timeGraphAction;
|
||||
QAction *_showToolbarsAction;
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "data.h"
|
||||
#include "heartrategraphitem.h"
|
||||
#include "heartrategraph.h"
|
||||
|
||||
|
||||
HeartRateGraph::HeartRateGraph(QWidget *parent) : GraphTab(parent)
|
||||
{
|
||||
_units = Metric;
|
||||
_showTracks = true;
|
||||
|
||||
GraphView::setYUnits(tr("1/min"));
|
||||
@ -28,21 +28,16 @@ void HeartRateGraph::loadData(const Data &data, const QList<PathItem *> &paths)
|
||||
{
|
||||
for (int i = 0; i < data.tracks().count(); i++) {
|
||||
const Graph &graph = data.tracks().at(i)->heartRate();
|
||||
qreal sum = 0, w = 0;
|
||||
|
||||
if (graph.size() < 2) {
|
||||
skipColor();
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int j = 1; j < graph.size(); j++) {
|
||||
qreal ds = graph.at(j).s() - graph.at(j-1).s();
|
||||
sum += graph.at(j).y() * ds;
|
||||
w += ds;
|
||||
}
|
||||
_avg.append(QPointF(data.tracks().at(i)->distance(), sum/w));
|
||||
HeartRateGraphItem *gi = new HeartRateGraphItem(graph, _graphType);
|
||||
GraphView::addGraph(gi, paths.at(i));
|
||||
|
||||
GraphView::loadGraph(graph, paths.at(i));
|
||||
_avg.append(QPointF(data.tracks().at(i)->distance(), gi->avg()));
|
||||
}
|
||||
|
||||
for (int i = 0; i < data.routes().count(); i++)
|
||||
|
@ -22,7 +22,6 @@ private:
|
||||
|
||||
QList<QPointF> _avg;
|
||||
|
||||
enum Units _units;
|
||||
bool _showTracks;
|
||||
};
|
||||
|
||||
|
26
src/heartrategraphitem.cpp
Normal file
26
src/heartrategraphitem.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include "tooltip.h"
|
||||
#include "heartrategraphitem.h"
|
||||
|
||||
HeartRateGraphItem::HeartRateGraphItem(const Graph &graph, GraphType type,
|
||||
QGraphicsItem *parent) : GraphItem(graph, type, parent)
|
||||
{
|
||||
qreal sum = 0;
|
||||
|
||||
for (int j = 1; j < graph.size(); j++)
|
||||
sum += graph.at(j).y() * (graph.at(j).s() - graph.at(j-1).s());
|
||||
_avg = sum/graph.last().s();
|
||||
|
||||
setToolTip(toolTip());
|
||||
}
|
||||
|
||||
QString HeartRateGraphItem::toolTip() const
|
||||
{
|
||||
ToolTip tt;
|
||||
|
||||
tt.insert(tr("Maximum"), QString::number(max(), 'f', 0)
|
||||
+ UNIT_SPACE + tr("1/min"));
|
||||
tt.insert(tr("Average"), QString::number(avg(), 'f', 0)
|
||||
+ UNIT_SPACE + tr("1/min"));
|
||||
|
||||
return tt.toString();
|
||||
}
|
23
src/heartrategraphitem.h
Normal file
23
src/heartrategraphitem.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef HEARTRATEGRAPHITEM_H
|
||||
#define HEARTRATEGRAPHITEM_H
|
||||
|
||||
#include "graphitem.h"
|
||||
|
||||
class HeartRateGraphItem : public GraphItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HeartRateGraphItem(const Graph &graph, GraphType type,
|
||||
QGraphicsItem *parent = 0);
|
||||
|
||||
qreal max() const {return -bounds().top();}
|
||||
qreal avg() const {return _avg;}
|
||||
|
||||
private:
|
||||
QString toolTip() const;
|
||||
|
||||
qreal _avg;
|
||||
};
|
||||
|
||||
#endif // HEARTRATEGRAPHITEM_H
|
@ -13,6 +13,9 @@
|
||||
#define ZOOM_IN QKeySequence::ZoomIn
|
||||
#define ZOOM_OUT QKeySequence::ZoomOut
|
||||
|
||||
#define TOGGLE_GRAPH_TYPE_KEY Qt::Key_X
|
||||
#define TOGGLE_TIME_TYPE_KEY Qt::Key_T
|
||||
|
||||
#define QUIT_SHORTCUT QKeySequence(QKeySequence::Quit)
|
||||
#define OPEN_SHORTCUT QKeySequence(QKeySequence::Open)
|
||||
#define CLOSE_SHORTCUT QKeySequence(QKeySequence::Close)
|
||||
@ -23,8 +26,6 @@
|
||||
#define NEXT_MAP_SHORTCUT QKeySequence(QKeySequence::Forward)
|
||||
#define PREV_MAP_SHORTCUT QKeySequence(QKeySequence::Back)
|
||||
#define SHOW_GRAPHS_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_G)
|
||||
#define DISTANCE_GRAPH_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_D)
|
||||
#define TIME_GRAPH_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_T)
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
#define FULLSCREEN_SHORTCUT QKeySequence(Qt::META + Qt::CTRL + Qt::Key_F)
|
||||
|
@ -225,10 +225,127 @@ void KMLParser::point(Waypoint &waypoint)
|
||||
_reader.raiseError("Missing Point coordinates");
|
||||
}
|
||||
|
||||
void KMLParser::heartRate(TrackData &track, int start)
|
||||
{
|
||||
int i = start;
|
||||
const char error[] = "Heartrate data count mismatch";
|
||||
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "value") {
|
||||
if (i < track.size())
|
||||
track[i++].setHeartRate(number());
|
||||
else {
|
||||
_reader.raiseError(error);
|
||||
return;
|
||||
}
|
||||
} else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
|
||||
if (i != track.size())
|
||||
_reader.raiseError(error);
|
||||
}
|
||||
|
||||
void KMLParser::cadence(TrackData &track, int start)
|
||||
{
|
||||
int i = start;
|
||||
const char error[] = "Cadence data count mismatch";
|
||||
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "value") {
|
||||
if (i < track.size())
|
||||
track[i++].setCadence(number());
|
||||
else {
|
||||
_reader.raiseError(error);
|
||||
return;
|
||||
}
|
||||
} else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
|
||||
if (i != track.size())
|
||||
_reader.raiseError(error);
|
||||
}
|
||||
|
||||
void KMLParser::speed(TrackData &track, int start)
|
||||
{
|
||||
int i = start;
|
||||
const char error[] = "Speed data count mismatch";
|
||||
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "value") {
|
||||
if (i < track.size())
|
||||
track[i++].setSpeed(number());
|
||||
else {
|
||||
_reader.raiseError(error);
|
||||
return;
|
||||
}
|
||||
} else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
|
||||
if (i != track.size())
|
||||
_reader.raiseError(error);
|
||||
}
|
||||
|
||||
void KMLParser::temperature(TrackData &track, int start)
|
||||
{
|
||||
int i = start;
|
||||
const char error[] = "Temperature data count mismatch";
|
||||
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "value") {
|
||||
if (i < track.size())
|
||||
track[i++].setTemperature(number());
|
||||
else {
|
||||
_reader.raiseError(error);
|
||||
return;
|
||||
}
|
||||
} else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
|
||||
if (i != track.size())
|
||||
_reader.raiseError(error);
|
||||
}
|
||||
|
||||
void KMLParser::schemaData(TrackData &track, int start)
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "SimpleArrayData") {
|
||||
QXmlStreamAttributes attr = _reader.attributes();
|
||||
QStringRef name = attr.value("name");
|
||||
|
||||
if (name == "Heartrate")
|
||||
heartRate(track, start);
|
||||
else if (name == "Cadence")
|
||||
cadence(track, start);
|
||||
else if (name == "Speed")
|
||||
speed(track, start);
|
||||
else if (name == "Temperature")
|
||||
temperature(track, start);
|
||||
else
|
||||
_reader.skipCurrentElement();
|
||||
} else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
void KMLParser::extendedData(TrackData &track, int start)
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "SchemaData")
|
||||
schemaData(track, start);
|
||||
else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
void KMLParser::track(TrackData &track)
|
||||
{
|
||||
const char mismatchError[] = "gx:coord/when element count mismatch";
|
||||
int i = track.size();
|
||||
const char error[] = "gx:coord/when element count mismatch";
|
||||
int first = track.size();
|
||||
int i = first;
|
||||
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "when") {
|
||||
@ -236,19 +353,31 @@ void KMLParser::track(TrackData &track)
|
||||
track.last().setTimestamp(time());
|
||||
} else if (_reader.name() == "coord") {
|
||||
if (i == track.size()) {
|
||||
_reader.raiseError(mismatchError);
|
||||
_reader.raiseError(error);
|
||||
return;
|
||||
} else if (!coord(track[i])) {
|
||||
_reader.raiseError("Invalid coordinates");
|
||||
return;
|
||||
}
|
||||
i++;
|
||||
} else
|
||||
} else if (_reader.name() == "ExtendedData")
|
||||
extendedData(track, first);
|
||||
else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
|
||||
if (i != track.size())
|
||||
_reader.raiseError(mismatchError);
|
||||
_reader.raiseError(error);
|
||||
}
|
||||
|
||||
void KMLParser::multiTrack(TrackData &t)
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "Track")
|
||||
track(t);
|
||||
else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
void KMLParser::multiGeometry(QList<TrackData> &tracks,
|
||||
@ -308,6 +437,12 @@ void KMLParser::placemark(QList<TrackData> &tracks, QList<Waypoint> &waypoints)
|
||||
t.setName(name);
|
||||
t.setDescription(desc);
|
||||
track(t);
|
||||
} else if (_reader.name() == "MultiTrack") {
|
||||
tracks.append(TrackData());
|
||||
TrackData &t = tracks.last();
|
||||
t.setName(name);
|
||||
t.setDescription(desc);
|
||||
multiTrack(t);
|
||||
} else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
@ -344,6 +479,8 @@ void KMLParser::kml(QList<TrackData> &tracks, QList<Waypoint> &waypoints)
|
||||
document(tracks, waypoints);
|
||||
else if (_reader.name() == "Placemark")
|
||||
placemark(tracks, waypoints);
|
||||
else if (_reader.name() == "Folder")
|
||||
folder(tracks, waypoints);
|
||||
else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
|
@ -23,11 +23,18 @@ private:
|
||||
void multiGeometry(QList<TrackData> &tracks, QList<Waypoint> &waypoints,
|
||||
const QString &name, const QString &desc, const QDateTime timestamp);
|
||||
void track(TrackData &track);
|
||||
void multiTrack(TrackData &t);
|
||||
void lineString(TrackData &track);
|
||||
void point(Waypoint &waypoint);
|
||||
bool pointCoordinates(Waypoint &waypoint);
|
||||
bool lineCoordinates(TrackData &track);
|
||||
bool coord(Trackpoint &trackpoint);
|
||||
void extendedData(TrackData &track, int start);
|
||||
void schemaData(TrackData &track, int start);
|
||||
void heartRate(TrackData &track, int start);
|
||||
void cadence(TrackData &track, int start);
|
||||
void speed(TrackData &track, int start);
|
||||
void temperature(TrackData &track, int start);
|
||||
QDateTime timeStamp();
|
||||
qreal number();
|
||||
QDateTime time();
|
||||
|
@ -75,7 +75,7 @@ Coordinates LambertConic::xy2ll(const QPointF &p) const
|
||||
double dx = p.x() - _fe;
|
||||
double dy = p.y() - _fn - _R0;
|
||||
double R = sqrt(dx * dx + dy * dy);
|
||||
double q = _q0 - log(R / _R0) / _n;
|
||||
double q = _q0 - log(fabs(R / _R0)) / _n;
|
||||
|
||||
return Coordinates(rad2deg(deg2rad(_cm) + dl / _n), rad2deg(iq(_e, q)));
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QRectF>
|
||||
#include <QColor>
|
||||
|
||||
class QPainter;
|
||||
class Coordinates;
|
||||
@ -14,7 +15,7 @@ class Map : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Map(QObject *parent = 0) : QObject(parent) {}
|
||||
Map(QObject *parent = 0) : QObject(parent) {_backgroundColor = Qt::white;}
|
||||
|
||||
virtual const QString &name() const = 0;
|
||||
|
||||
@ -37,8 +38,13 @@ public:
|
||||
virtual void load() {}
|
||||
virtual void unload() {}
|
||||
|
||||
void setBackgroundColor(const QColor &color) {_backgroundColor = color;}
|
||||
|
||||
signals:
|
||||
void loaded();
|
||||
|
||||
protected:
|
||||
QColor _backgroundColor;
|
||||
};
|
||||
|
||||
#endif // MAP_H
|
||||
|
@ -1,24 +1,38 @@
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include "range.h"
|
||||
#include "atlas.h"
|
||||
#include "offlinemap.h"
|
||||
#include "onlinemap.h"
|
||||
#include "maplist.h"
|
||||
|
||||
|
||||
#define ZOOM_MAX 18
|
||||
#define ZOOM_MIN 2
|
||||
|
||||
Map *MapList::loadListEntry(const QByteArray &line)
|
||||
{
|
||||
int max;
|
||||
|
||||
QList<QByteArray> list = line.split('\t');
|
||||
if (list.size() != 2)
|
||||
if (list.size() < 2)
|
||||
return 0;
|
||||
|
||||
QByteArray ba1 = list[0].trimmed();
|
||||
QByteArray ba2 = list[1].trimmed();
|
||||
QByteArray ba1 = list.at(0).trimmed();
|
||||
QByteArray ba2 = list.at(1).trimmed();
|
||||
if (ba1.isEmpty() || ba2.isEmpty())
|
||||
return 0;
|
||||
|
||||
if (list.size() == 3) {
|
||||
bool ok;
|
||||
max = QString(list.at(2).trimmed()).toInt(&ok);
|
||||
if (!ok)
|
||||
return 0;
|
||||
} else
|
||||
max = ZOOM_MAX;
|
||||
|
||||
return new OnlineMap(QString::fromUtf8(ba1.data(), ba1.size()),
|
||||
QString::fromLatin1(ba2.data(), ba2.size()), this);
|
||||
QString::fromLatin1(ba2.data(), ba2.size()), Range(ZOOM_MIN, max), this);
|
||||
}
|
||||
|
||||
bool MapList::loadList(const QString &path)
|
||||
|
@ -118,8 +118,6 @@ void Matrix::zeroize()
|
||||
|
||||
QDebug operator<<(QDebug dbg, const Matrix &matrix)
|
||||
{
|
||||
const bool ais = dbg.autoInsertSpaces();
|
||||
|
||||
dbg.nospace() << "Matrix(" << endl;
|
||||
for (size_t i = 0; i < matrix.h(); i++) {
|
||||
for (size_t j = 0; j < matrix.w(); j++)
|
||||
@ -128,7 +126,5 @@ QDebug operator<<(QDebug dbg, const Matrix &matrix)
|
||||
}
|
||||
dbg << ")";
|
||||
|
||||
dbg.setAutoInsertSpaces(ais);
|
||||
|
||||
return dbg.maybeSpace();
|
||||
return dbg.space();
|
||||
}
|
||||
|
@ -507,16 +507,16 @@ bool NMEAParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||
|
||||
if (validSentence(line, len)) {
|
||||
if (!memcmp(line + 3, "RMC,", 4)) {
|
||||
if (!readRMC(track, line + 7, len))
|
||||
if (!readRMC(track, line + 7, len - 7))
|
||||
return false;
|
||||
} else if (!memcmp(line + 3, "GGA,", 4)) {
|
||||
if (!readGGA(track, line + 7, len))
|
||||
if (!readGGA(track, line + 7, len - 7))
|
||||
return false;
|
||||
} else if (!memcmp(line + 3, "WPL,", 4)) {
|
||||
if (!readWPL(waypoints, line + 7, len))
|
||||
if (!readWPL(waypoints, line + 7, len - 7))
|
||||
return false;
|
||||
} else if (!memcmp(line + 3, "ZDA,", 4)) {
|
||||
if (!readZDA(line + 7, len))
|
||||
if (!readZDA(line + 7, len - 7))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -229,6 +229,24 @@ bool OfflineMap::createProjection(const QString &datum,
|
||||
else if (projection == "(SG) Swedish Grid")
|
||||
_projection = new TransverseMercator(d.ellipsoid(), 0, 15.808278, 1,
|
||||
1500000, 0);
|
||||
else if (projection == "(I) France Zone I")
|
||||
_projection = new LambertConic(d.ellipsoid(), 48.598523, 50.395912,
|
||||
49.5, 2.337229, 1 /*0.99987734*/, 600000, 1200000);
|
||||
else if (projection == "(II) France Zone II")
|
||||
_projection = new LambertConic(d.ellipsoid(), 45.898919, 47.696014,
|
||||
46.8, 2.337229, 1 /*0.99987742*/, 600000, 2200000);
|
||||
else if (projection == "(III) France Zone III")
|
||||
_projection = new LambertConic(d.ellipsoid(), 43.199291, 44.996094,
|
||||
44.1, 2.337229, 1 /*0.99987750*/, 600000, 3200000);
|
||||
else if (projection == "(IV) France Zone IV")
|
||||
_projection = new LambertConic(d.ellipsoid(), 41.560388, 42.767663,
|
||||
42.165, 2.337229, 1 /*0.99994471*/, 234.358, 4185861.369);
|
||||
else if (projection == "(VICGRID) Victoria Australia")
|
||||
_projection = new LambertConic(d.ellipsoid(), -36, -38, -37, 145, 1,
|
||||
2500000, 4500000);
|
||||
else if (projection == "(VG94) VICGRID94 Victoria Australia")
|
||||
_projection = new LambertConic(d.ellipsoid(), -36, -38, -37, 145, 1,
|
||||
2500000, 2500000);
|
||||
else {
|
||||
_errorString = QString("%1: Unknown map projection").arg(projection);
|
||||
return false;
|
||||
@ -591,7 +609,8 @@ void OfflineMap::drawTiled(QPainter *painter, const QRectF &rect)
|
||||
int y = tl.y() + j * _tileSize.height();
|
||||
|
||||
if (!QRectF(QPointF(x, y), _tileSize).intersects(bounds())) {
|
||||
painter->fillRect(QRectF(QPoint(x, y), _tileSize), Qt::white);
|
||||
painter->fillRect(QRectF(QPoint(x, y), _tileSize),
|
||||
_backgroundColor);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -613,7 +632,8 @@ void OfflineMap::drawTiled(QPainter *painter, const QRectF &rect)
|
||||
if (pixmap.isNull()) {
|
||||
qWarning("%s: error loading tile image", qPrintable(
|
||||
_tileName.arg(QString::number(x), QString::number(y))));
|
||||
painter->fillRect(QRectF(QPoint(x, y), _tileSize), Qt::white);
|
||||
painter->fillRect(QRectF(QPoint(x, y), _tileSize),
|
||||
_backgroundColor);
|
||||
} else
|
||||
painter->drawPixmap(QPoint(x, y), pixmap);
|
||||
}
|
||||
@ -634,7 +654,7 @@ void OfflineMap::drawOZF(QPainter *painter, const QRectF &rect)
|
||||
|
||||
if (!QRectF(QPointF(x, y), _ozf.tileSize()).intersects(bounds())) {
|
||||
painter->fillRect(QRectF(QPoint(x, y), _ozf.tileSize()),
|
||||
Qt::white);
|
||||
_backgroundColor);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -650,7 +670,7 @@ void OfflineMap::drawOZF(QPainter *painter, const QRectF &rect)
|
||||
if (pixmap.isNull()) {
|
||||
qWarning("%s: error loading tile image", qPrintable(key));
|
||||
painter->fillRect(QRectF(QPoint(x, y), _ozf.tileSize()),
|
||||
Qt::white);
|
||||
_backgroundColor);
|
||||
} else
|
||||
painter->drawPixmap(QPoint(x, y), pixmap);
|
||||
}
|
||||
@ -660,7 +680,7 @@ void OfflineMap::drawOZF(QPainter *painter, const QRectF &rect)
|
||||
void OfflineMap::drawImage(QPainter *painter, const QRectF &rect)
|
||||
{
|
||||
if (!_img || _img->isNull())
|
||||
painter->fillRect(rect, Qt::white);
|
||||
painter->fillRect(rect, _backgroundColor);
|
||||
else {
|
||||
QRect r(rect.toRect());
|
||||
painter->drawImage(r.left(), r.top(), *_img, r.left(), r.top(),
|
||||
|
@ -12,8 +12,6 @@
|
||||
#include "onlinemap.h"
|
||||
|
||||
|
||||
#define ZOOM_MAX 18
|
||||
#define ZOOM_MIN 3
|
||||
#define TILE_SIZE 256
|
||||
|
||||
static QPoint mercator2tile(const QPointF &m, int z)
|
||||
@ -36,24 +34,49 @@ static int scale2zoom(qreal scale)
|
||||
return (int)log2(360.0/(scale * (qreal)TILE_SIZE));
|
||||
}
|
||||
|
||||
static bool loadTileFile(Tile &tile, const QString &file)
|
||||
{
|
||||
if (!tile.pixmap().load(file)) {
|
||||
qWarning("%s: error loading tile file\n", qPrintable(file));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Downloader *OnlineMap::downloader;
|
||||
|
||||
OnlineMap::OnlineMap(const QString &name, const QString &url, QObject *parent)
|
||||
: Map(parent)
|
||||
OnlineMap::OnlineMap(const QString &name, const QString &url,
|
||||
const Range &zooms, QObject *parent) : Map(parent)
|
||||
{
|
||||
_name = name;
|
||||
_url = url;
|
||||
_block = false;
|
||||
_zoom = ZOOM_MAX;
|
||||
|
||||
connect(downloader, SIGNAL(finished()), this, SLOT(emitLoaded()));
|
||||
_zooms = zooms;
|
||||
_zoom = zooms.max();
|
||||
|
||||
QString path = TILES_DIR + QString("/") + name;
|
||||
if (!QDir().mkpath(path))
|
||||
qWarning("Error creating tiles dir: %s\n", qPrintable(path));
|
||||
}
|
||||
|
||||
void OnlineMap::load()
|
||||
{
|
||||
connect(downloader, SIGNAL(finished()), this, SLOT(emitLoaded()));
|
||||
}
|
||||
|
||||
void OnlineMap::unload()
|
||||
{
|
||||
disconnect(downloader, SIGNAL(finished()), this, SLOT(emitLoaded()));
|
||||
}
|
||||
|
||||
void OnlineMap::fillTile(Tile &tile)
|
||||
{
|
||||
tile.pixmap() = QPixmap(TILE_SIZE, TILE_SIZE);
|
||||
tile.pixmap().fill(_backgroundColor);
|
||||
}
|
||||
|
||||
void OnlineMap::emitLoaded()
|
||||
{
|
||||
emit loaded();
|
||||
@ -115,23 +138,7 @@ void OnlineMap::loadTilesSync(QList<Tile> &list)
|
||||
}
|
||||
}
|
||||
|
||||
void OnlineMap::fillTile(Tile &tile)
|
||||
{
|
||||
tile.pixmap() = QPixmap(TILE_SIZE, TILE_SIZE);
|
||||
tile.pixmap().fill();
|
||||
}
|
||||
|
||||
bool OnlineMap::loadTileFile(Tile &tile, const QString &file)
|
||||
{
|
||||
if (!tile.pixmap().load(file)) {
|
||||
qWarning("%s: error loading tile file\n", qPrintable(file));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QString OnlineMap::tileUrl(const Tile &tile)
|
||||
QString OnlineMap::tileUrl(const Tile &tile) const
|
||||
{
|
||||
QString url(_url);
|
||||
|
||||
@ -142,7 +149,7 @@ QString OnlineMap::tileUrl(const Tile &tile)
|
||||
return url;
|
||||
}
|
||||
|
||||
QString OnlineMap::tileFile(const Tile &tile)
|
||||
QString OnlineMap::tileFile(const Tile &tile) const
|
||||
{
|
||||
QString file = TILES_DIR + QString("/%1/%2-%3-%4").arg(name())
|
||||
.arg(tile.zoom()).arg(tile.xy().x()).arg(tile.xy().y());
|
||||
@ -166,20 +173,26 @@ QRectF OnlineMap::bounds() const
|
||||
1.0/zoom2scale(_zoom));
|
||||
}
|
||||
|
||||
int OnlineMap::limitZoom(int zoom) const
|
||||
{
|
||||
if (zoom < _zooms.min())
|
||||
return _zooms.min();
|
||||
if (zoom > _zooms.max())
|
||||
return _zooms.max();
|
||||
|
||||
return zoom;
|
||||
}
|
||||
|
||||
qreal OnlineMap::zoomFit(const QSize &size, const RectC &br)
|
||||
{
|
||||
if (!br.isValid())
|
||||
_zoom = ZOOM_MAX;
|
||||
_zoom = _zooms.max();
|
||||
else {
|
||||
QRectF tbr(Mercator().ll2xy(br.topLeft()),
|
||||
Mercator().ll2xy(br.bottomRight()));
|
||||
QPointF sc(tbr.width() / size.width(), tbr.height() / size.height());
|
||||
|
||||
_zoom = scale2zoom(qMax(sc.x(), sc.y()));
|
||||
if (_zoom < ZOOM_MIN)
|
||||
_zoom = ZOOM_MIN;
|
||||
if (_zoom > ZOOM_MAX)
|
||||
_zoom = ZOOM_MAX;
|
||||
_zoom = limitZoom(scale2zoom(qMax(sc.x(), sc.y())));
|
||||
}
|
||||
|
||||
return _zoom;
|
||||
@ -187,13 +200,8 @@ qreal OnlineMap::zoomFit(const QSize &size, const RectC &br)
|
||||
|
||||
qreal OnlineMap::zoomFit(qreal resolution, const Coordinates &c)
|
||||
{
|
||||
_zoom = (int)(log2((WGS84_RADIUS * 2 * M_PI * cos(deg2rad(c.lat())))
|
||||
/ resolution) - log2(TILE_SIZE));
|
||||
|
||||
if (_zoom < ZOOM_MIN)
|
||||
_zoom = ZOOM_MIN;
|
||||
if (_zoom > ZOOM_MAX)
|
||||
_zoom = ZOOM_MAX;
|
||||
_zoom = limitZoom((int)(log2((WGS84_RADIUS * 2 * M_PI
|
||||
* cos(deg2rad(c.lat()))) / resolution) - log2(TILE_SIZE)));
|
||||
|
||||
return _zoom;
|
||||
}
|
||||
@ -208,13 +216,13 @@ qreal OnlineMap::resolution(const QPointF &p) const
|
||||
|
||||
qreal OnlineMap::zoomIn()
|
||||
{
|
||||
_zoom = qMin(_zoom + 1, ZOOM_MAX);
|
||||
_zoom = qMin(_zoom + 1, _zooms.max());
|
||||
return _zoom;
|
||||
}
|
||||
|
||||
qreal OnlineMap::zoomOut()
|
||||
{
|
||||
_zoom = qMax(_zoom - 1, ZOOM_MIN);
|
||||
_zoom = qMax(_zoom - 1, _zooms.min());
|
||||
return _zoom;
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include "map.h"
|
||||
#include "tile.h"
|
||||
#include "range.h"
|
||||
|
||||
class Downloader;
|
||||
|
||||
@ -11,7 +12,8 @@ class OnlineMap : public Map
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OnlineMap(const QString &name, const QString &url, QObject *parent = 0);
|
||||
OnlineMap(const QString &name, const QString &url, const Range &zooms,
|
||||
QObject *parent = 0);
|
||||
|
||||
const QString &name() const {return _name;}
|
||||
|
||||
@ -35,17 +37,21 @@ public:
|
||||
static void setDownloader(Downloader *downloader)
|
||||
{OnlineMap::downloader = downloader;}
|
||||
|
||||
void load();
|
||||
void unload();
|
||||
|
||||
private slots:
|
||||
void emitLoaded();
|
||||
|
||||
private:
|
||||
QString tileUrl(const Tile &tile);
|
||||
QString tileFile(const Tile &tile);
|
||||
bool loadTileFile(Tile &tile, const QString &file);
|
||||
void fillTile(Tile &tile);
|
||||
QString tileUrl(const Tile &tile) const;
|
||||
QString tileFile(const Tile &tile) const;
|
||||
void loadTilesAsync(QList<Tile> &list);
|
||||
void loadTilesSync(QList<Tile> &list);
|
||||
int limitZoom(int zoom) const;
|
||||
|
||||
Range _zooms;
|
||||
int _zoom;
|
||||
QString _name;
|
||||
QString _url;
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <QGroupBox>
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QRadioButton>
|
||||
#include <QLabel>
|
||||
#include <QSysInfo>
|
||||
#include "config.h"
|
||||
@ -16,14 +17,27 @@
|
||||
#include "colorbox.h"
|
||||
#include "stylecombobox.h"
|
||||
#include "oddspinbox.h"
|
||||
#include "percentslider.h"
|
||||
#include "optionsdialog.h"
|
||||
|
||||
|
||||
#define MENU_MARGIN 20
|
||||
#define MENU_ICON_SIZE 32
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
static QFrame *line()
|
||||
{
|
||||
QFrame *l = new QFrame();
|
||||
l->setFrameShape(QFrame::HLine);
|
||||
l->setFrameShadow(QFrame::Sunken);
|
||||
|
||||
return l;
|
||||
}
|
||||
#endif
|
||||
|
||||
QWidget *OptionsDialog::createAppearancePage()
|
||||
{
|
||||
// Paths
|
||||
_baseColor = new ColorBox();
|
||||
_baseColor->setColor(_options->palette.color());
|
||||
_colorOffset = new QDoubleSpinBox();
|
||||
@ -31,14 +45,13 @@ QWidget *OptionsDialog::createAppearancePage()
|
||||
_colorOffset->setMaximum(1.0);
|
||||
_colorOffset->setSingleStep(0.01);
|
||||
_colorOffset->setValue(_options->palette.shift());
|
||||
|
||||
QFormLayout *paletteLayout = new QFormLayout();
|
||||
paletteLayout->addRow(tr("Base color:"), _baseColor);
|
||||
paletteLayout->addRow(tr("Palette shift:"), _colorOffset);
|
||||
|
||||
QWidget *colorTab = new QWidget();
|
||||
colorTab->setLayout(paletteLayout);
|
||||
|
||||
#ifndef Q_OS_MAC
|
||||
QGroupBox *colorBox = new QGroupBox(tr("Colors"));
|
||||
colorBox->setLayout(paletteLayout);
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
_trackWidth = new QSpinBox();
|
||||
_trackWidth->setValue(_options->trackWidth);
|
||||
@ -46,12 +59,15 @@ QWidget *OptionsDialog::createAppearancePage()
|
||||
_trackStyle = new StyleComboBox();
|
||||
_trackStyle->setValue(_options->trackStyle);
|
||||
QFormLayout *trackLayout = new QFormLayout();
|
||||
#ifdef Q_OS_MAC
|
||||
trackLayout->addRow(tr("Track width:"), _trackWidth);
|
||||
trackLayout->addRow(tr("Track style:"), _trackStyle);
|
||||
#ifndef Q_OS_MAC
|
||||
#else // Q_OS_MAC
|
||||
trackLayout->addRow(tr("Width:"), _trackWidth);
|
||||
trackLayout->addRow(tr("Style:"), _trackStyle);
|
||||
QGroupBox *trackBox = new QGroupBox(tr("Tracks"));
|
||||
trackBox->setLayout(trackLayout);
|
||||
#endif
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
_routeWidth = new QSpinBox();
|
||||
_routeWidth->setValue(_options->routeWidth);
|
||||
@ -59,9 +75,12 @@ QWidget *OptionsDialog::createAppearancePage()
|
||||
_routeStyle = new StyleComboBox();
|
||||
_routeStyle->setValue(_options->routeStyle);
|
||||
QFormLayout *routeLayout = new QFormLayout();
|
||||
#ifdef Q_OS_MAC
|
||||
routeLayout->addRow(tr("Route width:"), _routeWidth);
|
||||
routeLayout->addRow(tr("Route style:"), _routeStyle);
|
||||
#ifndef Q_OS_MAC
|
||||
#else // Q_OS_MAC
|
||||
routeLayout->addRow(tr("Width:"), _routeWidth);
|
||||
routeLayout->addRow(tr("Style:"), _routeStyle);
|
||||
QGroupBox *routeBox = new QGroupBox(tr("Routes"));
|
||||
routeBox->setLayout(routeLayout);
|
||||
#endif // Q_OS_MAC
|
||||
@ -74,18 +93,14 @@ QWidget *OptionsDialog::createAppearancePage()
|
||||
QWidget *pathTab = new QWidget();
|
||||
QVBoxLayout *pathTabLayout = new QVBoxLayout();
|
||||
#ifdef Q_OS_MAC
|
||||
QFrame *l1 = new QFrame();
|
||||
l1->setFrameShape(QFrame::HLine);
|
||||
l1->setFrameShadow(QFrame::Sunken);
|
||||
QFrame *l2 = new QFrame();
|
||||
l2->setFrameShape(QFrame::HLine);
|
||||
l2->setFrameShadow(QFrame::Sunken);
|
||||
|
||||
pathTabLayout->addLayout(paletteLayout);
|
||||
pathTabLayout->addWidget(line());
|
||||
pathTabLayout->addLayout(trackLayout);
|
||||
pathTabLayout->addWidget(l1);
|
||||
pathTabLayout->addWidget(line());
|
||||
pathTabLayout->addLayout(routeLayout);
|
||||
pathTabLayout->addWidget(l2);
|
||||
pathTabLayout->addWidget(line());
|
||||
#else // Q_OS_MAC
|
||||
pathTabLayout->addWidget(colorBox);
|
||||
pathTabLayout->addWidget(trackBox);
|
||||
pathTabLayout->addWidget(routeBox);
|
||||
#endif // Q_OS_MAC
|
||||
@ -93,6 +108,55 @@ QWidget *OptionsDialog::createAppearancePage()
|
||||
pathTabLayout->addStretch();
|
||||
pathTab->setLayout(pathTabLayout);
|
||||
|
||||
|
||||
// Waypoints
|
||||
_waypointSize = new QSpinBox();
|
||||
_waypointSize->setMinimum(1);
|
||||
_waypointSize->setValue(_options->waypointSize);
|
||||
_waypointColor = new ColorBox();
|
||||
_waypointColor->setColor(_options->waypointColor);
|
||||
QFormLayout *waypointLayout = new QFormLayout();
|
||||
#ifdef Q_OS_MAC
|
||||
waypointLayout->addRow(tr("Waypoint color:"), _waypointColor);
|
||||
waypointLayout->addRow(tr("Waypoint size:"), _waypointSize);
|
||||
#else // Q_OS_MAC
|
||||
waypointLayout->addRow(tr("Color:"), _waypointColor);
|
||||
waypointLayout->addRow(tr("Size:"), _waypointSize);
|
||||
QGroupBox *waypointBox = new QGroupBox(tr("Waypoints"));
|
||||
waypointBox->setLayout(waypointLayout);
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
_poiSize = new QSpinBox();
|
||||
_poiSize->setMinimum(1);
|
||||
_poiSize->setValue(_options->poiSize);
|
||||
_poiColor = new ColorBox();
|
||||
_poiColor->setColor(_options->poiColor);
|
||||
QFormLayout *poiLayout = new QFormLayout();
|
||||
#ifdef Q_OS_MAC
|
||||
poiLayout->addRow(tr("POI color:"), _poiColor);
|
||||
poiLayout->addRow(tr("POI size:"), _poiSize);
|
||||
#else // Q_OS_MAC
|
||||
poiLayout->addRow(tr("Color:"), _poiColor);
|
||||
poiLayout->addRow(tr("Size:"), _poiSize);
|
||||
QGroupBox *poiBox = new QGroupBox(tr("POIs"));
|
||||
poiBox->setLayout(poiLayout);
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
QWidget *pointTab = new QWidget();
|
||||
QVBoxLayout *pointTabLayout = new QVBoxLayout();
|
||||
#ifdef Q_OS_MAC
|
||||
pointTabLayout->addLayout(waypointLayout);
|
||||
pointTabLayout->addWidget(line());
|
||||
pointTabLayout->addLayout(poiLayout);
|
||||
#else // Q_OS_MAC
|
||||
pointTabLayout->addWidget(waypointBox);
|
||||
pointTabLayout->addWidget(poiBox);
|
||||
#endif // Q_OS_MAC
|
||||
pointTabLayout->addStretch();
|
||||
pointTab->setLayout(pointTabLayout);
|
||||
|
||||
|
||||
// Graphs
|
||||
_graphWidth = new QSpinBox();
|
||||
_graphWidth->setValue(_options->graphWidth);
|
||||
_graphWidth->setMinimum(1);
|
||||
@ -104,7 +168,6 @@ QWidget *OptionsDialog::createAppearancePage()
|
||||
QFormLayout *graphAALayout = new QFormLayout();
|
||||
graphAALayout->addWidget(_graphAA);
|
||||
|
||||
|
||||
QWidget *graphTab = new QWidget();
|
||||
QVBoxLayout *graphTabLayout = new QVBoxLayout();
|
||||
graphTabLayout->addLayout(graphLayout);
|
||||
@ -112,10 +175,29 @@ QWidget *OptionsDialog::createAppearancePage()
|
||||
graphTabLayout->addStretch();
|
||||
graphTab->setLayout(graphTabLayout);
|
||||
|
||||
|
||||
// Map
|
||||
_mapOpacity = new PercentSlider();
|
||||
_mapOpacity->setValue(_options->mapOpacity);
|
||||
_backgroundColor = new ColorBox();
|
||||
_backgroundColor->setColor(_options->backgroundColor);
|
||||
_backgroundColor->enableAlphaChannel(false);
|
||||
QFormLayout *mapLayout = new QFormLayout();
|
||||
mapLayout->addRow(tr("Background color:"), _backgroundColor);
|
||||
mapLayout->addRow(tr("Map opacity:"), _mapOpacity);
|
||||
|
||||
QWidget *mapTab = new QWidget();
|
||||
QVBoxLayout *mapTabLayout = new QVBoxLayout();
|
||||
mapTabLayout->addLayout(mapLayout);
|
||||
mapTabLayout->addStretch();
|
||||
mapTab->setLayout(mapTabLayout);
|
||||
|
||||
|
||||
QTabWidget *appearancePage = new QTabWidget();
|
||||
appearancePage->addTab(colorTab, tr("Colors"));
|
||||
appearancePage->addTab(pathTab, tr("Paths"));
|
||||
appearancePage->addTab(pointTab, tr("Points"));
|
||||
appearancePage->addTab(graphTab, tr("Graphs"));
|
||||
appearancePage->addTab(mapTab, tr("Map"));
|
||||
|
||||
return appearancePage;
|
||||
}
|
||||
@ -164,14 +246,9 @@ QWidget *OptionsDialog::createDataPage()
|
||||
QWidget *filterTab = new QWidget();
|
||||
QVBoxLayout *filterTabLayout = new QVBoxLayout();
|
||||
#ifdef Q_OS_MAC
|
||||
QLabel *label = new QLabel(tr("Smoothing:"));
|
||||
QFrame *line = new QFrame();
|
||||
line->setFrameShape(QFrame::HLine);
|
||||
line->setFrameShadow(QFrame::Sunken);
|
||||
|
||||
filterTabLayout->addWidget(label);
|
||||
filterTabLayout->addWidget(new QLabel(tr("Smoothing:")));
|
||||
filterTabLayout->addLayout(smoothLayout);
|
||||
filterTabLayout->addWidget(line);
|
||||
filterTabLayout->addWidget(line());
|
||||
filterTabLayout->addLayout(outlierLayout);
|
||||
#else // Q_OS_MAC
|
||||
filterTabLayout->addWidget(smoothBox);
|
||||
@ -239,6 +316,36 @@ QWidget *OptionsDialog::createPOIPage()
|
||||
|
||||
QWidget *OptionsDialog::createExportPage()
|
||||
{
|
||||
_wysiwyg = new QRadioButton(tr("WYSIWYG"));
|
||||
_hires = new QRadioButton(tr("High-Resolution"));
|
||||
if (_options->hiresPrint)
|
||||
_hires->setChecked(true);
|
||||
else
|
||||
_wysiwyg->setChecked(true);
|
||||
QLabel *lw = new QLabel(tr("The printed area is approximately the display"
|
||||
" area. The map zoom level does not change."));
|
||||
QLabel *lh = new QLabel(tr("The zoom level will be changed so that"
|
||||
" the whole content (tracks/waypoints) fits to the printed area and"
|
||||
" the map resolution is as close as possible to the print resolution."));
|
||||
QFont f = lw->font();
|
||||
f.setPointSize(f.pointSize() - 1);
|
||||
lw->setWordWrap(true);
|
||||
lh->setWordWrap(true);
|
||||
lw->setFont(f);
|
||||
lh->setFont(f);
|
||||
|
||||
QVBoxLayout *modeTabLayout = new QVBoxLayout();
|
||||
modeTabLayout->addWidget(_wysiwyg);
|
||||
modeTabLayout->addWidget(lw);
|
||||
modeTabLayout->addSpacing(10);
|
||||
modeTabLayout->addWidget(_hires);
|
||||
modeTabLayout->addWidget(lh);
|
||||
modeTabLayout->addStretch();
|
||||
|
||||
QWidget *modeTab = new QWidget();
|
||||
modeTab->setLayout(modeTabLayout);
|
||||
|
||||
|
||||
_name = new QCheckBox(tr("Name"));
|
||||
_name->setChecked(_options->printName);
|
||||
_date = new QCheckBox(tr("Date"));
|
||||
@ -274,6 +381,7 @@ QWidget *OptionsDialog::createExportPage()
|
||||
|
||||
|
||||
QTabWidget *exportPage = new QTabWidget();
|
||||
exportPage->addTab(modeTab, tr("Print mode"));
|
||||
exportPage->addTab(headerTab, tr("Header"));
|
||||
exportPage->addTab(graphTab, tr("Graphs"));
|
||||
|
||||
@ -283,12 +391,6 @@ QWidget *OptionsDialog::createExportPage()
|
||||
QWidget *OptionsDialog::createSystemPage()
|
||||
{
|
||||
_useOpenGL = new QCheckBox(tr("Use OpenGL"));
|
||||
#ifdef Q_OS_WIN32
|
||||
if (QSysInfo::WindowsVersion < QSysInfo::WV_VISTA) {
|
||||
_useOpenGL->setChecked(false);
|
||||
_useOpenGL->setEnabled(false);
|
||||
} else
|
||||
#endif // Q_OS_WIN32
|
||||
_useOpenGL->setChecked(_options->useOpenGL);
|
||||
|
||||
_pixmapCache = new QSpinBox();
|
||||
@ -369,6 +471,8 @@ void OptionsDialog::accept()
|
||||
{
|
||||
_options->palette.setColor(_baseColor->color());
|
||||
_options->palette.setShift(_colorOffset->value());
|
||||
_options->mapOpacity = _mapOpacity->value();
|
||||
_options->backgroundColor = _backgroundColor->color();
|
||||
_options->trackWidth = _trackWidth->value();
|
||||
_options->trackStyle = (Qt::PenStyle) _trackStyle->itemData(
|
||||
_trackStyle->currentIndex()).toInt();
|
||||
@ -376,6 +480,10 @@ void OptionsDialog::accept()
|
||||
_options->routeStyle = (Qt::PenStyle) _routeStyle->itemData(
|
||||
_routeStyle->currentIndex()).toInt();
|
||||
_options->pathAntiAliasing = _pathAA->isChecked();
|
||||
_options->waypointSize = _waypointSize->value();
|
||||
_options->waypointColor = _waypointColor->color();
|
||||
_options->poiSize = _poiSize->value();
|
||||
_options->poiColor = _poiColor->color();
|
||||
_options->graphWidth = _graphWidth->value();
|
||||
_options->graphAntiAliasing = _graphAA->isChecked();
|
||||
|
||||
@ -385,16 +493,21 @@ void OptionsDialog::accept()
|
||||
_options->cadenceFilter = _cadenceFilter->value();
|
||||
_options->powerFilter = _powerFilter->value();
|
||||
_options->outlierEliminate = _outlierEliminate->isChecked();
|
||||
_options->pauseSpeed = (_options->units == Imperial)
|
||||
qreal pauseSpeed = (_options->units == Imperial)
|
||||
? _pauseSpeed->value() / MS2MIH : _pauseSpeed->value() / MS2KMH;
|
||||
if (qAbs(pauseSpeed - _options->pauseSpeed) > 0.01)
|
||||
_options->pauseSpeed = pauseSpeed;
|
||||
_options->pauseInterval = _pauseInterval->value();
|
||||
|
||||
_options->poiRadius = (_options->units == Imperial)
|
||||
qreal poiRadius = (_options->units == Imperial)
|
||||
? _poiRadius->value() * MIINM : _poiRadius->value() * KMINM;
|
||||
if (qAbs(poiRadius - _options->poiRadius) > 0.01)
|
||||
_options->poiRadius = poiRadius;
|
||||
|
||||
_options->useOpenGL = _useOpenGL->isChecked();
|
||||
_options->pixmapCache = _pixmapCache->value();
|
||||
|
||||
_options->hiresPrint = _hires->isChecked();
|
||||
_options->printName = _name->isChecked();
|
||||
_options->printDate = _date->isChecked();
|
||||
_options->printDistance = _distance->isChecked();
|
||||
|
@ -12,6 +12,8 @@ class QSpinBox;
|
||||
class QDoubleSpinBox;
|
||||
class QComboBox;
|
||||
class QCheckBox;
|
||||
class QRadioButton;
|
||||
class PercentSlider;
|
||||
|
||||
struct Options {
|
||||
// Appearance
|
||||
@ -20,9 +22,15 @@ struct Options {
|
||||
int routeWidth;
|
||||
Qt::PenStyle trackStyle;
|
||||
Qt::PenStyle routeStyle;
|
||||
QColor waypointColor;
|
||||
QColor poiColor;
|
||||
int waypointSize;
|
||||
int poiSize;
|
||||
int graphWidth;
|
||||
bool pathAntiAliasing;
|
||||
bool graphAntiAliasing;
|
||||
int mapOpacity;
|
||||
QColor backgroundColor;
|
||||
// Data
|
||||
int elevationFilter;
|
||||
int speedFilter;
|
||||
@ -38,6 +46,7 @@ struct Options {
|
||||
bool useOpenGL;
|
||||
int pixmapCache;
|
||||
// Print/Export
|
||||
bool hiresPrint;
|
||||
bool printName;
|
||||
bool printDate;
|
||||
bool printDistance;
|
||||
@ -71,11 +80,17 @@ private:
|
||||
// Appearance
|
||||
ColorBox *_baseColor;
|
||||
QDoubleSpinBox *_colorOffset;
|
||||
PercentSlider *_mapOpacity;
|
||||
ColorBox *_backgroundColor;
|
||||
QSpinBox *_trackWidth;
|
||||
StyleComboBox *_trackStyle;
|
||||
QSpinBox *_routeWidth;
|
||||
StyleComboBox *_routeStyle;
|
||||
QCheckBox *_pathAA;
|
||||
QSpinBox *_waypointSize;
|
||||
ColorBox *_waypointColor;
|
||||
QSpinBox *_poiSize;
|
||||
ColorBox *_poiColor;
|
||||
QSpinBox *_graphWidth;
|
||||
QCheckBox *_graphAA;
|
||||
// Data
|
||||
@ -93,6 +108,8 @@ private:
|
||||
QSpinBox *_pixmapCache;
|
||||
QCheckBox *_useOpenGL;
|
||||
// Print/Export
|
||||
QRadioButton *_wysiwyg;
|
||||
QRadioButton *_hires;
|
||||
QCheckBox *_name;
|
||||
QCheckBox *_date;
|
||||
QCheckBox *_distance;
|
||||
|
58
src/ozf.cpp
58
src/ozf.cpp
@ -1,3 +1,4 @@
|
||||
#include <cstring>
|
||||
#include <QtEndian>
|
||||
#include <QFile>
|
||||
#include "ozf.h"
|
||||
@ -52,8 +53,8 @@ bool OZF::read(void *data, size_t size, size_t decryptSize)
|
||||
bool OZF::initOZF3()
|
||||
{
|
||||
quint8 randomNumber, initial;
|
||||
quint32 keyblock;
|
||||
quint8 h1[8];
|
||||
quint8 h2[16], h2d[16];
|
||||
|
||||
|
||||
if (!_file.seek(14))
|
||||
@ -75,41 +76,23 @@ bool OZF::initOZF3()
|
||||
return false;
|
||||
_tileSize = *(h1 + 6);
|
||||
|
||||
if (!_file.seek(15 + randomNumber))
|
||||
if (!_file.seek(15 + randomNumber + 4))
|
||||
return false;
|
||||
if (!readValue(keyblock))
|
||||
if (_file.read((char*)h2, sizeof(h2)) != (qint64)sizeof(h2))
|
||||
return false;
|
||||
|
||||
switch (keyblock & 0xFF) {
|
||||
case 0xf1:
|
||||
initial += 0x8a;
|
||||
break;
|
||||
case 0x18:
|
||||
case 0x54:
|
||||
initial += 0xa0;
|
||||
break;
|
||||
case 0x56:
|
||||
initial += 0xb9;
|
||||
break;
|
||||
case 0x43:
|
||||
initial += 0x6a;
|
||||
break;
|
||||
case 0x83:
|
||||
initial += 0xa4;
|
||||
break;
|
||||
case 0xc5:
|
||||
initial += 0x7e;
|
||||
break;
|
||||
case 0x38:
|
||||
initial += 0xc1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
for (int i = 0; i < 256; i++) {
|
||||
memcpy(h2d, h2, sizeof(h2d));
|
||||
decrypt(h2d, sizeof(h2d), (quint8)i);
|
||||
|
||||
if ((quint32)*h2d == 40 && (quint16)*(h2d + 12) == 1
|
||||
&& (quint16)*(h2d + 14) == 8) {
|
||||
_key = (quint8)i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
_key = initial;
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool OZF::initOZF2()
|
||||
@ -135,8 +118,10 @@ bool OZF::readHeaders()
|
||||
} else if (magic == OZF3_MAGIC) {
|
||||
if (!initOZF3())
|
||||
return false;
|
||||
} else
|
||||
} else {
|
||||
qWarning("%s: not a OZF2/OZF3 file", qPrintable(_file.fileName()));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -152,7 +137,8 @@ bool OZF::readTileTable()
|
||||
return false;
|
||||
if (!readValue(tableOffset))
|
||||
return false;
|
||||
zooms = (_file.size() - tableOffset - sizeof(quint32)) / sizeof(quint32);
|
||||
zooms = (int)((_file.size() - tableOffset - sizeof(quint32))
|
||||
/ sizeof(quint32));
|
||||
|
||||
for (int i = 0; i < zooms - 2; i++) {
|
||||
if (!_file.seek(tableOffset + i * sizeof(quint32)))
|
||||
@ -196,7 +182,7 @@ bool OZF::readTileTable()
|
||||
_zooms.append(zoom);
|
||||
}
|
||||
|
||||
return true;
|
||||
return _zooms.isEmpty() ? false : true;
|
||||
}
|
||||
|
||||
bool OZF::load(const QString &path)
|
||||
@ -209,13 +195,13 @@ bool OZF::load(const QString &path)
|
||||
return false;
|
||||
|
||||
if (!readHeaders()) {
|
||||
qWarning("%s: not a OZF2/OZF3 file", qPrintable(_file.fileName()));
|
||||
qWarning("%s: Invalid header", qPrintable(_file.fileName()));
|
||||
_file.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!readTileTable()) {
|
||||
qWarning("%s: file format error", qPrintable(_file.fileName()));
|
||||
qWarning("%s: Invalid tile table", qPrintable(_file.fileName()));
|
||||
_file.close();
|
||||
return false;
|
||||
}
|
||||
|
@ -39,9 +39,7 @@ void Palette::reset()
|
||||
|
||||
QDebug operator<<(QDebug dbg, const Palette &palette)
|
||||
{
|
||||
const bool ais = dbg.autoInsertSpaces();
|
||||
dbg.nospace() << "Palette(" << palette.color() << ", " << palette.shift()
|
||||
<< ")";
|
||||
dbg.setAutoInsertSpaces(ais);
|
||||
return dbg.maybeSpace();
|
||||
return dbg.space();
|
||||
}
|
||||
|
@ -14,9 +14,7 @@ RectC Path::boundingRect() const
|
||||
|
||||
QDebug operator<<(QDebug dbg, const PathPoint &point)
|
||||
{
|
||||
const bool ais = dbg.autoInsertSpaces();
|
||||
dbg.nospace() << "PathPoint(" << point.distance() << ", "
|
||||
<< point.coordinates() << ")";
|
||||
dbg.setAutoInsertSpaces(ais);
|
||||
return dbg.maybeSpace();
|
||||
return dbg.space();
|
||||
}
|
||||
|
@ -66,9 +66,10 @@ void PathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
|
||||
void PathItem::setMap(Map *map)
|
||||
{
|
||||
_map = map;
|
||||
prepareGeometryChange();
|
||||
|
||||
_map = map;
|
||||
|
||||
updatePainterPath(map);
|
||||
updateShape();
|
||||
|
||||
@ -77,12 +78,18 @@ void PathItem::setMap(Map *map)
|
||||
|
||||
void PathItem::setColor(const QColor &color)
|
||||
{
|
||||
if (_pen.color() == color)
|
||||
return;
|
||||
|
||||
_pen.setColor(color);
|
||||
update();
|
||||
}
|
||||
|
||||
void PathItem::setWidth(qreal width)
|
||||
{
|
||||
if (_width == width)
|
||||
return;
|
||||
|
||||
prepareGeometryChange();
|
||||
|
||||
_width = width;
|
||||
@ -93,12 +100,18 @@ void PathItem::setWidth(qreal width)
|
||||
|
||||
void PathItem::setStyle(Qt::PenStyle style)
|
||||
{
|
||||
if (_pen.style() == style)
|
||||
return;
|
||||
|
||||
_pen.setStyle(style);
|
||||
update();
|
||||
}
|
||||
|
||||
void PathItem::setDigitalZoom(int zoom)
|
||||
{
|
||||
if (_digitalZoom == zoom)
|
||||
return;
|
||||
|
||||
prepareGeometryChange();
|
||||
|
||||
_digitalZoom = zoom;
|
||||
@ -154,6 +167,19 @@ void PathItem::moveMarker(qreal distance)
|
||||
_marker->setVisible(false);
|
||||
}
|
||||
|
||||
void PathItem::hover(bool hover)
|
||||
{
|
||||
if (hover) {
|
||||
_pen.setWidth(_width + 1);
|
||||
setZValue(zValue() + 1.0);
|
||||
} else {
|
||||
_pen.setWidth(_width);
|
||||
setZValue(zValue() - 1.0);
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void PathItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
@ -32,6 +32,7 @@ public:
|
||||
|
||||
public slots:
|
||||
void moveMarker(qreal distance);
|
||||
void hover(bool hover);
|
||||
|
||||
signals:
|
||||
void selected(bool);
|
||||
|
224
src/pathview.cpp
224
src/pathview.cpp
@ -3,6 +3,7 @@
|
||||
#include <QWheelEvent>
|
||||
#include <QApplication>
|
||||
#include <QPixmapCache>
|
||||
#include <QScrollBar>
|
||||
#include "opengl.h"
|
||||
#include "misc.h"
|
||||
#include "poi.h"
|
||||
@ -16,7 +17,7 @@
|
||||
#include "pathview.h"
|
||||
|
||||
|
||||
#define MAX_DIGITAL_ZOOM 1
|
||||
#define MAX_DIGITAL_ZOOM 2
|
||||
#define MIN_DIGITAL_ZOOM -3
|
||||
#define MARGIN 10.0
|
||||
#define SCALE_OFFSET 7
|
||||
@ -39,13 +40,18 @@ PathView::PathView(Map *map, POI *poi, QWidget *parent)
|
||||
|
||||
_mapScale = new ScaleItem();
|
||||
_mapScale->setZValue(2.0);
|
||||
_scene->addItem(_mapScale);
|
||||
|
||||
_map = map;
|
||||
_map->load();
|
||||
connect(_map, SIGNAL(loaded()), this, SLOT(reloadMap()));
|
||||
|
||||
_poi = poi;
|
||||
connect(_map, SIGNAL(loaded()), this, SLOT(redraw()));
|
||||
connect(_poi, SIGNAL(pointsChanged()), this, SLOT(updatePOI()));
|
||||
|
||||
_units = Metric;
|
||||
_opacity = 1.0;
|
||||
_backgroundColor = Qt::white;
|
||||
|
||||
_showMap = true;
|
||||
_showTracks = true;
|
||||
@ -60,18 +66,36 @@ PathView::PathView(Map *map, POI *poi, QWidget *parent)
|
||||
_routeWidth = 3;
|
||||
_trackStyle = Qt::SolidLine;
|
||||
_routeStyle = Qt::DashLine;
|
||||
_waypointSize = 8;
|
||||
_waypointColor = Qt::black;
|
||||
_poiSize = 8;
|
||||
_poiColor = Qt::black;
|
||||
|
||||
_plot = false;
|
||||
_digitalZoom = 0;
|
||||
|
||||
_map->setBackgroundColor(_backgroundColor);
|
||||
_scene->setSceneRect(_map->bounds());
|
||||
_res = _map->resolution(_scene->sceneRect().center());
|
||||
|
||||
centerOn(_scene->sceneRect().center());
|
||||
}
|
||||
|
||||
PathView::~PathView()
|
||||
void PathView::centerOn(const QPointF &pos)
|
||||
{
|
||||
if (_mapScale->scene() != _scene)
|
||||
delete _mapScale;
|
||||
QGraphicsView::centerOn(pos);
|
||||
|
||||
/* Fix the offset caused by QGraphicsView::centerOn() approximation */
|
||||
QPointF center = mapToScene(viewport()->rect().center());
|
||||
QPoint offset((int)(pos.x() - center.x()), (int)(pos.y() - center.y()));
|
||||
if (qAbs(offset.x()) == 1)
|
||||
horizontalScrollBar()->setValue(horizontalScrollBar()->value()
|
||||
+ offset.x());
|
||||
if (qAbs(offset.y()) == 1)
|
||||
verticalScrollBar()->setValue(verticalScrollBar()->value()
|
||||
+ offset.y());
|
||||
|
||||
_res = _map->resolution(pos);
|
||||
_mapScale->setResolution(_res);
|
||||
}
|
||||
|
||||
PathItem *PathView::addTrack(const Track &track)
|
||||
@ -131,6 +155,8 @@ void PathView::addWaypoints(const QList<Waypoint> &waypoints)
|
||||
_waypoints.append(wi);
|
||||
updateWaypointsBoundingRect(wi->waypoint().coordinates());
|
||||
wi->setZValue(1);
|
||||
wi->setSize(_waypointSize);
|
||||
wi->setColor(_waypointColor);
|
||||
wi->showLabel(_showWaypointLabels);
|
||||
wi->setUnits(_units);
|
||||
wi->setVisible(_showWaypoints);
|
||||
@ -144,7 +170,7 @@ void PathView::addWaypoints(const QList<Waypoint> &waypoints)
|
||||
QList<PathItem *> PathView::loadData(const Data &data)
|
||||
{
|
||||
QList<PathItem *> paths;
|
||||
qreal scale = _map->zoom();
|
||||
qreal zoom = _map->zoom();
|
||||
|
||||
for (int i = 0; i < data.tracks().count(); i++)
|
||||
paths.append(addTrack(*(data.tracks().at(i))));
|
||||
@ -155,18 +181,12 @@ QList<PathItem *> PathView::loadData(const Data &data)
|
||||
if (_tracks.empty() && _routes.empty() && _waypoints.empty())
|
||||
return paths;
|
||||
|
||||
if (mapScale() != scale)
|
||||
if (mapZoom() != zoom)
|
||||
rescale();
|
||||
else
|
||||
updatePOIVisibility();
|
||||
|
||||
QPointF center = contentCenter();
|
||||
centerOn(center);
|
||||
|
||||
_res = _map->resolution(center);
|
||||
_mapScale->setResolution(_res);
|
||||
if (_mapScale->scene() != _scene)
|
||||
_scene->addItem(_mapScale);
|
||||
centerOn(contentCenter());
|
||||
|
||||
return paths;
|
||||
}
|
||||
@ -179,11 +199,11 @@ void PathView::updateWaypointsBoundingRect(const Coordinates &wp)
|
||||
_wr.unite(wp);
|
||||
}
|
||||
|
||||
qreal PathView::mapScale() const
|
||||
qreal PathView::mapZoom() const
|
||||
{
|
||||
RectC br = _tr | _rr | _wr;
|
||||
|
||||
return _map->zoomFit(viewport()->size() - QSize(MARGIN/2, MARGIN/2), br);
|
||||
return _map->zoomFit(viewport()->size() - QSize(2*MARGIN, 2*MARGIN), br);
|
||||
}
|
||||
|
||||
QPointF PathView::contentCenter() const
|
||||
@ -251,11 +271,11 @@ void PathView::setMap(Map *map)
|
||||
qreal resolution = _map->resolution(pos);
|
||||
|
||||
_map->unload();
|
||||
disconnect(_map, SIGNAL(loaded()), this, SLOT(redraw()));
|
||||
disconnect(_map, SIGNAL(loaded()), this, SLOT(reloadMap()));
|
||||
|
||||
_map = map;
|
||||
_map->load();
|
||||
connect(_map, SIGNAL(loaded()), this, SLOT(redraw()));
|
||||
connect(_map, SIGNAL(loaded()), this, SLOT(reloadMap()));
|
||||
|
||||
resetDigitalZoom();
|
||||
|
||||
@ -274,11 +294,7 @@ void PathView::setMap(Map *map)
|
||||
it.value()->setMap(_map);
|
||||
updatePOIVisibility();
|
||||
|
||||
pos = _map->ll2xy(center);
|
||||
centerOn(pos);
|
||||
|
||||
_res = _map->resolution(pos);
|
||||
_mapScale->setResolution(_res);
|
||||
centerOn(_map->ll2xy(center));
|
||||
|
||||
resetCachedContent();
|
||||
QPixmapCache::clear();
|
||||
@ -323,6 +339,8 @@ void PathView::addPOI(const QVector<Waypoint> &waypoints)
|
||||
|
||||
WaypointItem *pi = new WaypointItem(w, _map);
|
||||
pi->setZValue(1);
|
||||
pi->setSize(_poiSize);
|
||||
pi->setColor(_poiColor);
|
||||
pi->showLabel(_showPOILabels);
|
||||
pi->setVisible(_showPOI);
|
||||
pi->setDigitalZoom(_digitalZoom);
|
||||
@ -350,8 +368,9 @@ void PathView::setUnits(enum Units units)
|
||||
it.value()->setUnits(units);
|
||||
}
|
||||
|
||||
void PathView::redraw()
|
||||
void PathView::clearMapCache()
|
||||
{
|
||||
_map->clearCache();
|
||||
resetCachedContent();
|
||||
}
|
||||
|
||||
@ -410,15 +429,8 @@ void PathView::zoom(int zoom, const QPoint &pos, const Coordinates &c)
|
||||
ns = (zoom > 0) ? _map->zoomIn() : _map->zoomOut();
|
||||
|
||||
if (ns != os) {
|
||||
QPoint offset = pos - viewport()->rect().center();
|
||||
|
||||
rescale();
|
||||
|
||||
QPointF center = _map->ll2xy(c) - offset;
|
||||
centerOn(center);
|
||||
|
||||
_res = _map->resolution(center);
|
||||
_mapScale->setResolution(_res);
|
||||
centerOn(_map->ll2xy(c) - (pos - viewport()->rect().center()));
|
||||
} else {
|
||||
if (shift)
|
||||
digitalZoom(zoom);
|
||||
@ -470,13 +482,23 @@ void PathView::keyPressEvent(QKeyEvent *event)
|
||||
zoom(z, pos, c);
|
||||
}
|
||||
|
||||
void PathView::plot(QPainter *painter, const QRectF &target)
|
||||
void PathView::plot(QPainter *painter, const QRectF &target, qreal scale,
|
||||
bool hires)
|
||||
{
|
||||
QRect orig, adj;
|
||||
qreal ratio, diff;
|
||||
qreal ratio, diff, origRes, q;
|
||||
QPointF origScene, origPos;
|
||||
Coordinates origLL;
|
||||
|
||||
|
||||
// Enter plot mode
|
||||
setUpdatesEnabled(false);
|
||||
_plot = true;
|
||||
_map->setBlockingMode(true);
|
||||
|
||||
// Compute sizes & ratios
|
||||
orig = viewport()->rect();
|
||||
origPos = _mapScale->pos();
|
||||
|
||||
if (orig.height() * (target.width() / target.height()) - orig.width() < 0) {
|
||||
ratio = target.height() / target.width();
|
||||
@ -487,20 +509,50 @@ void PathView::plot(QPainter *painter, const QRectF &target)
|
||||
diff = (orig.height() * ratio) - orig.width();
|
||||
adj = orig.adjusted(-diff/2, 0, diff/2, 0);
|
||||
}
|
||||
q = (target.width() / scale) / adj.width();
|
||||
|
||||
setUpdatesEnabled(false);
|
||||
_plot = true;
|
||||
_map->setBlockingMode(true);
|
||||
// Adjust the view for printing
|
||||
if (hires) {
|
||||
origScene = mapToScene(orig.center());
|
||||
origLL = _map->xy2ll(origScene);
|
||||
origRes = _map->resolution(origScene);
|
||||
|
||||
QPointF pos = _mapScale->pos();
|
||||
_mapScale->setPos(mapToScene(QPoint(adj.bottomRight() + QPoint(
|
||||
-(SCALE_OFFSET + _mapScale->boundingRect().width()),
|
||||
-(SCALE_OFFSET + _mapScale->boundingRect().height())))));
|
||||
QPointF s(painter->device()->logicalDpiX()
|
||||
/ (qreal)metric(QPaintDevice::PdmDpiX),
|
||||
painter->device()->logicalDpiY()
|
||||
/ (qreal)metric(QPaintDevice::PdmDpiY));
|
||||
adj = QRect(0, 0, adj.width() * s.x(), adj.height() * s.y());
|
||||
_map->zoomFit(adj.size(), _tr | _rr | _wr);
|
||||
rescale();
|
||||
|
||||
QPointF center = contentCenter();
|
||||
centerOn(center);
|
||||
adj.moveCenter(mapFromScene(center));
|
||||
|
||||
_mapScale->setDigitalZoom(-log2(s.x() / q));
|
||||
_mapScale->setPos(mapToScene(QPoint(adj.bottomRight() + QPoint(
|
||||
-(SCALE_OFFSET + _mapScale->boundingRect().width()) * (s.x() / q),
|
||||
-(SCALE_OFFSET + _mapScale->boundingRect().height()) * (s.x() / q)))));
|
||||
} else {
|
||||
_mapScale->setDigitalZoom(-log2(1.0 / q));
|
||||
_mapScale->setPos(mapToScene(QPoint(adj.bottomRight() + QPoint(
|
||||
-(SCALE_OFFSET + _mapScale->boundingRect().width()) / q ,
|
||||
-(SCALE_OFFSET + _mapScale->boundingRect().height()) / q))));
|
||||
}
|
||||
|
||||
// Print the view
|
||||
render(painter, target, adj);
|
||||
|
||||
_mapScale->setPos(pos);
|
||||
// Revert view changes to display mode
|
||||
if (hires) {
|
||||
_map->zoomFit(origRes, origLL);
|
||||
rescale();
|
||||
centerOn(origScene);
|
||||
}
|
||||
_mapScale->setDigitalZoom(0);
|
||||
_mapScale->setPos(origPos);
|
||||
|
||||
// Exit plot mode
|
||||
_map->setBlockingMode(false);
|
||||
_plot = false;
|
||||
setUpdatesEnabled(true);
|
||||
@ -508,14 +560,15 @@ void PathView::plot(QPainter *painter, const QRectF &target)
|
||||
|
||||
void PathView::clear()
|
||||
{
|
||||
if (_mapScale->scene() == _scene)
|
||||
_scene->removeItem(_mapScale);
|
||||
|
||||
_pois.clear();
|
||||
_tracks.clear();
|
||||
_routes.clear();
|
||||
_waypoints.clear();
|
||||
|
||||
_scene->removeItem(_mapScale);
|
||||
_scene->clear();
|
||||
_scene->addItem(_mapScale);
|
||||
|
||||
_palette.reset();
|
||||
|
||||
_tr = RectC();
|
||||
@ -637,25 +690,74 @@ void PathView::setRouteStyle(Qt::PenStyle style)
|
||||
_routes.at(i)->setStyle(style);
|
||||
}
|
||||
|
||||
void PathView::setWaypointSize(int size)
|
||||
{
|
||||
_waypointSize = size;
|
||||
|
||||
for (int i = 0; i < _waypoints.size(); i++)
|
||||
_waypoints.at(i)->setSize(size);
|
||||
}
|
||||
|
||||
void PathView::setWaypointColor(const QColor &color)
|
||||
{
|
||||
_waypointColor = color;
|
||||
|
||||
for (int i = 0; i < _waypoints.size(); i++)
|
||||
_waypoints.at(i)->setColor(color);
|
||||
}
|
||||
|
||||
void PathView::setPOISize(int size)
|
||||
{
|
||||
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
|
||||
|
||||
_poiSize = size;
|
||||
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||
it.value()->setSize(size);
|
||||
}
|
||||
|
||||
void PathView::setPOIColor(const QColor &color)
|
||||
{
|
||||
QHash<SearchPointer<Waypoint>, WaypointItem*>::const_iterator it;
|
||||
|
||||
_poiColor = color;
|
||||
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||
it.value()->setColor(color);
|
||||
}
|
||||
|
||||
void PathView::setMapOpacity(int opacity)
|
||||
{
|
||||
_opacity = opacity / 100.0;
|
||||
resetCachedContent();
|
||||
}
|
||||
|
||||
void PathView::setBackgroundColor(const QColor &color)
|
||||
{
|
||||
_backgroundColor = color;
|
||||
_map->setBackgroundColor(color);
|
||||
resetCachedContent();
|
||||
}
|
||||
|
||||
void PathView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||
{
|
||||
if (_showMap)
|
||||
if (_showMap) {
|
||||
if (_opacity < 1.0) {
|
||||
painter->fillRect(rect, _backgroundColor);
|
||||
painter->setOpacity(_opacity);
|
||||
}
|
||||
_map->draw(painter, rect);
|
||||
else
|
||||
painter->fillRect(rect, Qt::white);
|
||||
} else
|
||||
painter->fillRect(rect, _backgroundColor);
|
||||
}
|
||||
|
||||
void PathView::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
qreal scale = _map->zoom();
|
||||
if (mapScale() != scale)
|
||||
qreal zoom = _map->zoom();
|
||||
if (mapZoom() != zoom)
|
||||
rescale();
|
||||
|
||||
QPointF center = contentCenter();
|
||||
centerOn(center);
|
||||
|
||||
_res = _map->resolution(center);
|
||||
_mapScale->setResolution(_res);
|
||||
centerOn(contentCenter());
|
||||
|
||||
QGraphicsView::resizeEvent(event);
|
||||
}
|
||||
@ -691,3 +793,13 @@ void PathView::useOpenGL(bool use)
|
||||
else
|
||||
setViewport(new QWidget);
|
||||
}
|
||||
|
||||
void PathView::useAntiAliasing(bool use)
|
||||
{
|
||||
setRenderHint(QPainter::Antialiasing, use);
|
||||
}
|
||||
|
||||
void PathView::reloadMap()
|
||||
{
|
||||
resetCachedContent();
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ class PathView : public QGraphicsView
|
||||
|
||||
public:
|
||||
PathView(Map *map, POI *poi, QWidget *parent = 0);
|
||||
~PathView();
|
||||
|
||||
QList<PathItem*> loadData(const Data &data);
|
||||
|
||||
@ -37,7 +36,7 @@ public:
|
||||
void setMap(Map *map);
|
||||
void setUnits(enum Units units);
|
||||
|
||||
void plot(QPainter *painter, const QRectF &target);
|
||||
void plot(QPainter *painter, const QRectF &target, qreal scale, bool hires);
|
||||
|
||||
int trackCount() const {return _tracks.count();}
|
||||
int routeCount() const {return _routes.count();}
|
||||
@ -45,11 +44,20 @@ public:
|
||||
|
||||
void clear();
|
||||
|
||||
void setTrackWidth(int width);
|
||||
void setRouteWidth(int width);
|
||||
void setTrackStyle(Qt::PenStyle style);
|
||||
void setRouteStyle(Qt::PenStyle style);
|
||||
void setWaypointSize(int size);
|
||||
void setWaypointColor(const QColor &color);
|
||||
void setPOISize(int size);
|
||||
void setPOIColor(const QColor &color);
|
||||
void setMapOpacity(int opacity);
|
||||
void setBackgroundColor(const QColor &color);
|
||||
void useOpenGL(bool use);
|
||||
void useAntiAliasing(bool use);
|
||||
|
||||
public slots:
|
||||
void redraw();
|
||||
|
||||
void showMap(bool show);
|
||||
void showPOI(bool show);
|
||||
void setPOIOverlap(bool overlap);
|
||||
@ -59,13 +67,11 @@ public slots:
|
||||
void showRoutes(bool show);
|
||||
void showWaypoints(bool show);
|
||||
void showRouteWaypoints(bool show);
|
||||
void setTrackWidth(int width);
|
||||
void setRouteWidth(int width);
|
||||
void setTrackStyle(Qt::PenStyle style);
|
||||
void setRouteStyle(Qt::PenStyle style);
|
||||
void clearMapCache();
|
||||
|
||||
private slots:
|
||||
void updatePOI();
|
||||
void reloadMap();
|
||||
|
||||
private:
|
||||
PathItem *addTrack(const Track &track);
|
||||
@ -75,9 +81,10 @@ private:
|
||||
void loadPOI();
|
||||
void clearPOI();
|
||||
|
||||
qreal mapScale() const;
|
||||
qreal mapZoom() const;
|
||||
QPointF contentCenter() const;
|
||||
void rescale();
|
||||
void centerOn(const QPointF &pos);
|
||||
void zoom(int zoom, const QPoint &pos, const Coordinates &c);
|
||||
void digitalZoom(int zoom);
|
||||
void resetDigitalZoom();
|
||||
@ -107,6 +114,8 @@ private:
|
||||
Palette _palette;
|
||||
Units _units;
|
||||
|
||||
qreal _opacity;
|
||||
QColor _backgroundColor;
|
||||
bool _showMap;
|
||||
bool _showTracks;
|
||||
bool _showRoutes;
|
||||
@ -120,6 +129,10 @@ private:
|
||||
int _routeWidth;
|
||||
Qt::PenStyle _trackStyle;
|
||||
Qt::PenStyle _routeStyle;
|
||||
int _waypointSize;
|
||||
int _poiSize;
|
||||
QColor _waypointColor;
|
||||
QColor _poiColor;
|
||||
|
||||
int _digitalZoom;
|
||||
bool _plot;
|
||||
|
48
src/percentslider.cpp
Normal file
48
src/percentslider.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
#include <QSlider>
|
||||
#include <QLabel>
|
||||
#include <QHBoxLayout>
|
||||
#include "units.h"
|
||||
#include "percentslider.h"
|
||||
|
||||
|
||||
static QString format(int value)
|
||||
{
|
||||
return QString::number(value) + UNIT_SPACE + QString("%");
|
||||
}
|
||||
|
||||
PercentSlider::PercentSlider(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
_slider = new QSlider(Qt::Horizontal);
|
||||
_label = new QLabel();
|
||||
|
||||
_slider->setMinimum(0);
|
||||
_slider->setMaximum(100);
|
||||
|
||||
QFontMetrics fm(_label->font());
|
||||
_label->setFixedWidth(fm.boundingRect(format(_slider->maximum())).width());
|
||||
_label->setAlignment(Qt::AlignRight);
|
||||
|
||||
connect(_slider, SIGNAL(sliderMoved(int)), this, SLOT(updateLabel(int)));
|
||||
|
||||
QHBoxLayout *layout = new QHBoxLayout();
|
||||
layout->addWidget(_slider);
|
||||
layout->addWidget(_label);
|
||||
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
void PercentSlider::updateLabel(int value)
|
||||
{
|
||||
_label->setText(format(value));
|
||||
}
|
||||
|
||||
int PercentSlider::value() const
|
||||
{
|
||||
return _slider->value();
|
||||
}
|
||||
|
||||
void PercentSlider::setValue(int value)
|
||||
{
|
||||
_slider->setValue(value);
|
||||
_label->setText(format(value));
|
||||
}
|
29
src/percentslider.h
Normal file
29
src/percentslider.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef PERCENTSLIDER_H
|
||||
#define PERCENTSLIDER_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QSlider;
|
||||
class QLabel;
|
||||
|
||||
class PercentSlider : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PercentSlider(QWidget *parent = 0);
|
||||
|
||||
int value() const;
|
||||
|
||||
public slots:
|
||||
void setValue(int value);
|
||||
|
||||
private slots:
|
||||
void updateLabel(int value);
|
||||
|
||||
private:
|
||||
QSlider *_slider;
|
||||
QLabel *_label;
|
||||
};
|
||||
|
||||
#endif // PERCENTSLIDER_H
|
@ -1,10 +1,10 @@
|
||||
#include "data.h"
|
||||
#include "powergraphitem.h"
|
||||
#include "powergraph.h"
|
||||
|
||||
|
||||
PowerGraph::PowerGraph(QWidget *parent) : GraphTab(parent)
|
||||
{
|
||||
_units = Metric;
|
||||
_showTracks = true;
|
||||
|
||||
GraphView::setYUnits(tr("W"));
|
||||
@ -28,21 +28,16 @@ void PowerGraph::loadData(const Data &data, const QList<PathItem *> &paths)
|
||||
{
|
||||
for (int i = 0; i < data.tracks().count(); i++) {
|
||||
const Graph &graph = data.tracks().at(i)->power();
|
||||
qreal sum = 0, w = 0;
|
||||
|
||||
if (graph.size() < 2) {
|
||||
skipColor();
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int j = 1; j < graph.size(); j++) {
|
||||
qreal ds = graph.at(j).s() - graph.at(j-1).s();
|
||||
sum += graph.at(j).y() * ds;
|
||||
w += ds;
|
||||
}
|
||||
_avg.append(QPointF(data.tracks().at(i)->distance(), sum/w));
|
||||
PowerGraphItem *gi = new PowerGraphItem(graph, _graphType);
|
||||
GraphView::addGraph(gi, paths.at(i));
|
||||
|
||||
GraphView::loadGraph(graph, paths.at(i));
|
||||
_avg.append(QPointF(data.tracks().at(i)->distance(), gi->avg()));
|
||||
}
|
||||
|
||||
for (int i = 0; i < data.routes().count(); i++)
|
||||
|
@ -22,7 +22,6 @@ private:
|
||||
|
||||
QList<QPointF> _avg;
|
||||
|
||||
enum Units _units;
|
||||
bool _showTracks;
|
||||
};
|
||||
|
||||
|
26
src/powergraphitem.cpp
Normal file
26
src/powergraphitem.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include "tooltip.h"
|
||||
#include "powergraphitem.h"
|
||||
|
||||
PowerGraphItem::PowerGraphItem(const Graph &graph, GraphType type,
|
||||
QGraphicsItem *parent) : GraphItem(graph, type, parent)
|
||||
{
|
||||
qreal sum = 0;
|
||||
|
||||
for (int j = 1; j < graph.size(); j++)
|
||||
sum += graph.at(j).y() * (graph.at(j).s() - graph.at(j-1).s());
|
||||
_avg = sum/graph.last().s();
|
||||
|
||||
setToolTip(toolTip());
|
||||
}
|
||||
|
||||
QString PowerGraphItem::toolTip() const
|
||||
{
|
||||
ToolTip tt;
|
||||
|
||||
tt.insert(tr("Maximum"), QString::number(max(), 'f', 1)
|
||||
+ UNIT_SPACE + tr("1/min"));
|
||||
tt.insert(tr("Average"), QString::number(avg(), 'f', 1)
|
||||
+ UNIT_SPACE + tr("1/min"));
|
||||
|
||||
return tt.toString();
|
||||
}
|
23
src/powergraphitem.h
Normal file
23
src/powergraphitem.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef POWERGRAPHITEM_H
|
||||
#define POWERGRAPHITEM_H
|
||||
|
||||
#include "graphitem.h"
|
||||
|
||||
class PowerGraphItem : public GraphItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PowerGraphItem(const Graph &graph, GraphType type,
|
||||
QGraphicsItem *parent = 0);
|
||||
|
||||
qreal max() const {return -bounds().top();}
|
||||
qreal avg() const {return _avg;}
|
||||
|
||||
private:
|
||||
QString toolTip() const;
|
||||
|
||||
qreal _avg;
|
||||
};
|
||||
|
||||
#endif // POWERGRAPHITEM_H
|
@ -8,10 +8,14 @@ void RangeF::resize(qreal size)
|
||||
_max += adj;
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug dbg, const Range &range)
|
||||
{
|
||||
dbg.nospace() << "Range(" << range.min() << ", " << range.max() << ")";
|
||||
return dbg.space();
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug dbg, const RangeF &range)
|
||||
{
|
||||
const bool ais = dbg.autoInsertSpaces();
|
||||
dbg.nospace() << "RangeF(" << range.min() << ", " << range.max() << ")";
|
||||
dbg.setAutoInsertSpaces(ais);
|
||||
return dbg.maybeSpace();
|
||||
return dbg.space();
|
||||
}
|
||||
|
15
src/range.h
15
src/range.h
@ -4,6 +4,20 @@
|
||||
#include <QtGlobal>
|
||||
#include <QDebug>
|
||||
|
||||
class Range
|
||||
{
|
||||
public:
|
||||
Range() {_min = 0; _max = 0;}
|
||||
Range(int min, int max) {_min = min, _max = max;}
|
||||
|
||||
int min() const {return _min;}
|
||||
int max() const {return _max;}
|
||||
int size() const {return (_max - _min);}
|
||||
|
||||
private:
|
||||
int _min, _max;
|
||||
};
|
||||
|
||||
class RangeF
|
||||
{
|
||||
public:
|
||||
@ -20,6 +34,7 @@ private:
|
||||
qreal _min, _max;
|
||||
};
|
||||
|
||||
QDebug operator<<(QDebug dbg, const Range &range);
|
||||
QDebug operator<<(QDebug dbg, const RangeF &range);
|
||||
|
||||
#endif // RANGE_H
|
||||
|
@ -58,8 +58,6 @@ void RectC::unite(const Coordinates &c)
|
||||
|
||||
QDebug operator<<(QDebug dbg, const RectC &rect)
|
||||
{
|
||||
const bool ais = dbg.autoInsertSpaces();
|
||||
dbg.nospace() << "RectC(" << rect.topLeft() << ", " << rect.size() << ")";
|
||||
dbg.setAutoInsertSpaces(ais);
|
||||
return dbg.maybeSpace();
|
||||
return dbg.space();
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "routeitem.h"
|
||||
|
||||
|
||||
QString RouteItem::toolTip(Units units)
|
||||
QString RouteItem::toolTip(Units units) const
|
||||
{
|
||||
ToolTip tt;
|
||||
|
||||
|
@ -14,7 +14,6 @@ class RouteItem : public PathItem
|
||||
public:
|
||||
RouteItem(const Route &route, Map *map, QGraphicsItem *parent = 0);
|
||||
|
||||
//void setScale(qreal scale);
|
||||
void setMap(Map *map);
|
||||
|
||||
void setUnits(Units units);
|
||||
@ -22,7 +21,7 @@ public:
|
||||
void showWaypointLabels(bool show);
|
||||
|
||||
private:
|
||||
QString toolTip(Units units);
|
||||
QString toolTip(Units units) const;
|
||||
|
||||
QString _name;
|
||||
QString _desc;
|
||||
|
@ -132,7 +132,7 @@ void ScaleItem::setUnits(enum Units units)
|
||||
update();
|
||||
}
|
||||
|
||||
void ScaleItem::setDigitalZoom(int zoom)
|
||||
void ScaleItem::setDigitalZoom(qreal zoom)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
_digitalZoom = zoom;
|
||||
|
@ -15,7 +15,7 @@ public:
|
||||
|
||||
void setResolution(qreal res);
|
||||
void setUnits(enum Units units);
|
||||
void setDigitalZoom(int zoom);
|
||||
void setDigitalZoom(qreal zoom);
|
||||
|
||||
private:
|
||||
void updateBoundingRect();
|
||||
@ -28,7 +28,7 @@ private:
|
||||
Units _units;
|
||||
bool _scale;
|
||||
|
||||
int _digitalZoom;
|
||||
qreal _digitalZoom;
|
||||
|
||||
QRectF _boundingRect;
|
||||
};
|
||||
|
@ -25,6 +25,8 @@
|
||||
#define GRAPH_TYPE_DEFAULT Distance
|
||||
#define SHOW_GRAPH_GRIDS_SETTING "grid"
|
||||
#define SHOW_GRAPH_GRIDS_DEFAULT true
|
||||
#define SHOW_GRAPH_SLIDER_INFO_SETTING "sliderInfo"
|
||||
#define SHOW_GRAPH_SLIDER_INFO_DEFAULT true
|
||||
|
||||
#define MAP_SETTINGS_GROUP "Map"
|
||||
#define CURRENT_MAP_SETTING "map"
|
||||
@ -70,12 +72,18 @@
|
||||
#define EXPORT_FILENAME_SETTING "fileName"
|
||||
#define EXPORT_FILENAME_DEFAULT QString("%1/export.pdf"). \
|
||||
arg(QDir::currentPath())
|
||||
#define RESOLUTION_SETTING "resolution"
|
||||
#define RESOLUTION_DEFAULT 600
|
||||
|
||||
#define OPTIONS_SETTINGS_GROUP "Options"
|
||||
#define PALETTE_COLOR_SETTING "paletteColor"
|
||||
#define PALETTE_COLOR_DEFAULT QColor(Qt::blue)
|
||||
#define PALETTE_SHIFT_SETTING "paletteShift"
|
||||
#define PALETTE_SHIFT_DEFAULT 0.62
|
||||
#define MAP_OPACITY_SETTING "mapOpacity"
|
||||
#define MAP_OPACITY_DEFAULT 100
|
||||
#define BACKGROUND_COLOR_SETTING "backgroundColor"
|
||||
#define BACKGROUND_COLOR_DEFAULT QColor(Qt::white)
|
||||
#define TRACK_WIDTH_SETTING "trackWidth"
|
||||
#define TRACK_WIDTH_DEFAULT 3
|
||||
#define ROUTE_WIDTH_SETTING "routeWidth"
|
||||
@ -84,6 +92,14 @@
|
||||
#define TRACK_STYLE_DEFAULT Qt::SolidLine
|
||||
#define ROUTE_STYLE_SETTING "routeStyle"
|
||||
#define ROUTE_STYLE_DEFAULT Qt::DotLine
|
||||
#define WAYPOINT_SIZE_SETTING "waypointSize"
|
||||
#define WAYPOINT_SIZE_DEFAULT 8
|
||||
#define WAYPOINT_COLOR_SETTING "waypointColor"
|
||||
#define WAYPOINT_COLOR_DEFAULT QColor(Qt::black)
|
||||
#define POI_SIZE_SETTING "poiSize"
|
||||
#define POI_SIZE_DEFAULT 8
|
||||
#define POI_COLOR_SETTING "poiColor"
|
||||
#define POI_COLOR_DEFAULT QColor(Qt::black)
|
||||
#define GRAPH_WIDTH_SETTING "graphWidth"
|
||||
#define GRAPH_WIDTH_DEFAULT 1
|
||||
#define PATH_AA_SETTING "pathAntiAliasing"
|
||||
@ -112,6 +128,8 @@
|
||||
#define USE_OPENGL_DEFAULT false
|
||||
#define PIXMAP_CACHE_SETTING "pixmapCache"
|
||||
#define PIXMAP_CACHE_DEFAULT 64 /* MB */
|
||||
#define HIRES_PRINT_SETTING "hiresPrint"
|
||||
#define HIRES_PRINT_DEFAULT false
|
||||
#define PRINT_NAME_SETTING "printName"
|
||||
#define PRINT_NAME_DEFAULT true
|
||||
#define PRINT_DATE_SETTING "printDate"
|
||||
|
@ -17,10 +17,12 @@ void SliderInfoItem::updateBoundingRect()
|
||||
font.setFamily(FONT_FAMILY);
|
||||
QFontMetrics fm(font);
|
||||
|
||||
qreal width = qMax(fm.width(_x), fm.width(_y));
|
||||
qreal height = 2 * fm.height() - 2*fm.descent();
|
||||
|
||||
_boundingRect = (_side == Right)
|
||||
? QRectF(-SIZE/2, 0, fm.width(_text) + SIZE, fm.height())
|
||||
: QRectF(-(fm.width(_text) + SIZE/2), 0, fm.width(_text) + SIZE,
|
||||
fm.height());
|
||||
? QRectF(-SIZE/2, -height/2, width + 1.5*SIZE, height)
|
||||
: QRectF(-(width + SIZE), -height/2, width + 1.5*SIZE, height);
|
||||
}
|
||||
|
||||
void SliderInfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
|
||||
@ -32,25 +34,48 @@ void SliderInfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
|
||||
font.setPixelSize(FONT_SIZE);
|
||||
font.setFamily(FONT_FAMILY);
|
||||
QFontMetrics fm(font);
|
||||
QRectF rx, ry;
|
||||
|
||||
|
||||
qreal width = qMax(fm.width(_x), fm.width(_y));
|
||||
if (_side == Right) {
|
||||
ry = QRectF(SIZE, -fm.height() + fm.descent(), fm.width(_y),
|
||||
fm.height() - fm.descent());
|
||||
rx = QRectF(SIZE, 0, fm.width(_x), fm.height()
|
||||
- fm.descent());
|
||||
} else {
|
||||
ry = QRectF(-(width + SIZE), -fm.height() + fm.descent(), fm.width(_y),
|
||||
fm.height() - fm.descent());
|
||||
rx = QRectF(-(width + SIZE), 0, fm.width(_x), fm.height()
|
||||
- fm.descent());
|
||||
}
|
||||
|
||||
painter->setPen(Qt::NoPen);
|
||||
painter->setBrush(QBrush(QColor(255, 255, 255, 196)));
|
||||
painter->drawRect(ry);
|
||||
painter->drawRect(rx);
|
||||
painter->setBrush(Qt::NoBrush);
|
||||
|
||||
painter->setFont(font);
|
||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||
painter->setPen(Qt::red);
|
||||
|
||||
if (_side == Right)
|
||||
painter->drawText(SIZE, fm.height() - fm.descent(), _text);
|
||||
else
|
||||
painter->drawText(-(fm.width(_text) + SIZE/2),
|
||||
fm.height() - fm.descent(), _text);
|
||||
if (_side == Right) {
|
||||
painter->drawText(SIZE, -fm.descent()/2, _y);
|
||||
painter->drawText(SIZE, fm.height() - fm.descent()*1.5, _x);
|
||||
} else {
|
||||
painter->drawText(-(width + SIZE), -fm.descent()/2, _y);
|
||||
painter->drawText(-(width + SIZE), fm.height() - fm.descent()*1.5, _x);
|
||||
}
|
||||
painter->drawLine(QPointF(-SIZE/2, 0), QPointF(SIZE/2, 0));
|
||||
|
||||
//painter->drawRect(boundingRect());
|
||||
}
|
||||
|
||||
void SliderInfoItem::setText(const QString &text)
|
||||
void SliderInfoItem::setText(const QString &x, const QString &y)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
_text = text;
|
||||
_x = x; _y = y;
|
||||
updateBoundingRect();
|
||||
}
|
||||
|
||||
|
@ -14,14 +14,14 @@ public:
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget);
|
||||
|
||||
void setText(const QString &text);
|
||||
void setText(const QString &x, const QString &y);
|
||||
void setSide(Side side);
|
||||
|
||||
private:
|
||||
void updateBoundingRect();
|
||||
|
||||
Side _side;
|
||||
QString _text;
|
||||
QString _x, _y;
|
||||
QRectF _boundingRect;
|
||||
};
|
||||
|
||||
|
@ -1,15 +1,16 @@
|
||||
#include "config.h"
|
||||
#include "data.h"
|
||||
#include "tooltip.h"
|
||||
#include "speedgraphitem.h"
|
||||
#include "speedgraph.h"
|
||||
|
||||
|
||||
SpeedGraph::SpeedGraph(QWidget *parent) : GraphTab(parent)
|
||||
{
|
||||
_units = Metric;
|
||||
_timeType = Total;
|
||||
_showTracks = true;
|
||||
|
||||
setYUnits();
|
||||
setYUnits(Metric);
|
||||
setYLabel(tr("Speed"));
|
||||
|
||||
setSliderPrecision(1);
|
||||
@ -29,18 +30,21 @@ void SpeedGraph::setInfo()
|
||||
void SpeedGraph::loadData(const Data &data, const QList<PathItem *> &paths)
|
||||
{
|
||||
for (int i = 0; i < data.tracks().count(); i++) {
|
||||
const Graph &graph = data.tracks().at(i)->speed();
|
||||
const Track *track = data.tracks().at(i);
|
||||
const Graph &graph = track->speed();
|
||||
|
||||
if (graph.size() < 2) {
|
||||
skipColor();
|
||||
continue;
|
||||
}
|
||||
|
||||
_avg.append(QPointF(data.tracks().at(i)->distance(),
|
||||
data.tracks().at(i)->distance() / data.tracks().at(i)->time()));
|
||||
_avgM.append(QPointF(data.tracks().at(i)->distance(),
|
||||
data.tracks().at(i)->distance() / data.tracks().at(i)->movingTime()));
|
||||
SpeedGraphItem *gi = new SpeedGraphItem(graph, _graphType,
|
||||
track->movingTime());
|
||||
gi->setTimeType(_timeType);
|
||||
GraphView::addGraph(gi, paths.at(i));
|
||||
|
||||
GraphView::loadGraph(graph, paths.at(i));
|
||||
_avg.append(QPointF(track->distance(), gi->avg()));
|
||||
_mavg.append(QPointF(track->distance(), gi->mavg()));
|
||||
}
|
||||
|
||||
for (int i = 0; i < data.routes().count(); i++)
|
||||
@ -55,7 +59,7 @@ qreal SpeedGraph::avg() const
|
||||
{
|
||||
qreal sum = 0, w = 0;
|
||||
QList<QPointF>::const_iterator it;
|
||||
const QList<QPointF> &list = (_timeType == Moving) ? _avgM : _avg;
|
||||
const QList<QPointF> &list = (_timeType == Moving) ? _mavg : _avg;
|
||||
|
||||
for (it = list.begin(); it != list.end(); it++) {
|
||||
sum += it->y() * it->x();
|
||||
@ -68,14 +72,14 @@ qreal SpeedGraph::avg() const
|
||||
void SpeedGraph::clear()
|
||||
{
|
||||
_avg.clear();
|
||||
_avgM.clear();
|
||||
_mavg.clear();
|
||||
|
||||
GraphView::clear();
|
||||
}
|
||||
|
||||
void SpeedGraph::setYUnits()
|
||||
void SpeedGraph::setYUnits(Units units)
|
||||
{
|
||||
if (_units == Metric) {
|
||||
if (units == Metric) {
|
||||
GraphView::setYUnits(tr("km/h"));
|
||||
setYScale(MS2KMH);
|
||||
} else {
|
||||
@ -84,21 +88,21 @@ void SpeedGraph::setYUnits()
|
||||
}
|
||||
}
|
||||
|
||||
void SpeedGraph::setUnits(enum Units units)
|
||||
void SpeedGraph::setUnits(Units units)
|
||||
{
|
||||
_units = units;
|
||||
|
||||
setYUnits();
|
||||
setYUnits(units);
|
||||
setInfo();
|
||||
GraphView::setUnits(units);
|
||||
|
||||
redraw();
|
||||
GraphView::setUnits(units);
|
||||
}
|
||||
|
||||
void SpeedGraph::setTimeType(enum TimeType type)
|
||||
{
|
||||
_timeType = type;
|
||||
|
||||
for (int i = 0; i < _graphs.size(); i++)
|
||||
static_cast<SpeedGraphItem*>(_graphs.at(i))->setTimeType(type);
|
||||
|
||||
setInfo();
|
||||
redraw();
|
||||
}
|
||||
|
@ -14,20 +14,19 @@ public:
|
||||
QString label() const {return tr("Speed");}
|
||||
void loadData(const Data &data, const QList<PathItem *> &paths);
|
||||
void clear();
|
||||
void setUnits(enum Units units);
|
||||
void setTimeType(enum TimeType type);
|
||||
void setUnits(Units units);
|
||||
void setTimeType(TimeType type);
|
||||
void showTracks(bool show);
|
||||
|
||||
private:
|
||||
qreal avg() const;
|
||||
qreal max() const {return bounds().bottom();}
|
||||
void setYUnits();
|
||||
void setYUnits(Units units);
|
||||
void setInfo();
|
||||
|
||||
QList<QPointF> _avg;
|
||||
QList<QPointF> _avgM;
|
||||
QList<QPointF> _mavg;
|
||||
|
||||
enum Units _units;
|
||||
enum TimeType _timeType;
|
||||
bool _showTracks;
|
||||
};
|
||||
|
40
src/speedgraphitem.cpp
Normal file
40
src/speedgraphitem.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
#include "tooltip.h"
|
||||
#include "speedgraphitem.h"
|
||||
|
||||
SpeedGraphItem::SpeedGraphItem(const Graph &graph, GraphType type,
|
||||
qreal movingTime, QGraphicsItem *parent) : GraphItem(graph, type, parent)
|
||||
{
|
||||
_units = Metric;
|
||||
_timeType = Total;
|
||||
|
||||
_avg = graph.last().s() / graph.last().t();
|
||||
_mavg = graph.last().s() / movingTime;
|
||||
|
||||
setToolTip(toolTip());
|
||||
}
|
||||
|
||||
QString SpeedGraphItem::toolTip() const
|
||||
{
|
||||
ToolTip tt;
|
||||
qreal scale = (_units == Metric) ? MS2KMH : MS2MIH;
|
||||
QString su = (_units == Metric) ? tr("km/h") : tr("mi/h");
|
||||
|
||||
tt.insert(tr("Maximum"), QString::number(max() * scale, 'f', 1)
|
||||
+ UNIT_SPACE + su);
|
||||
tt.insert(tr("Average"), QString::number((_timeType == Total)
|
||||
? avg() * scale : mavg() * scale, 'f', 1) + UNIT_SPACE + su);
|
||||
|
||||
return tt.toString();
|
||||
}
|
||||
|
||||
void SpeedGraphItem::setUnits(Units units)
|
||||
{
|
||||
_units = units;
|
||||
setToolTip(toolTip());
|
||||
}
|
||||
|
||||
void SpeedGraphItem::setTimeType(TimeType type)
|
||||
{
|
||||
_timeType = type;
|
||||
setToolTip(toolTip());
|
||||
}
|
31
src/speedgraphitem.h
Normal file
31
src/speedgraphitem.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef SPEEDGRAPHITEM_H
|
||||
#define SPEEDGRAPHITEM_H
|
||||
|
||||
#include "timetype.h"
|
||||
#include "graphitem.h"
|
||||
|
||||
class SpeedGraphItem : public GraphItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SpeedGraphItem(const Graph &graph, GraphType type, qreal movingTime,
|
||||
QGraphicsItem *parent = 0);
|
||||
|
||||
qreal max() const {return -bounds().top();}
|
||||
qreal avg() const {return _avg;}
|
||||
qreal mavg() const {return _mavg;}
|
||||
|
||||
void setUnits(Units units);
|
||||
void setTimeType(TimeType type);
|
||||
|
||||
private:
|
||||
QString toolTip() const;
|
||||
|
||||
qreal _avg, _mavg;
|
||||
|
||||
Units _units;
|
||||
TimeType _timeType;
|
||||
};
|
||||
|
||||
#endif // SPEEDGRAPHITEM_H
|
@ -56,6 +56,16 @@ Coordinates TCXParser::position()
|
||||
return pos;
|
||||
}
|
||||
|
||||
void TCXParser::heartRateBpm(Trackpoint &trackpoint)
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "Value")
|
||||
trackpoint.setHeartRate(number());
|
||||
else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
void TCXParser::extensions(Trackpoint &trackpoint)
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
@ -78,7 +88,7 @@ void TCXParser::trackpointData(Trackpoint &trackpoint)
|
||||
else if (_reader.name() == "Time")
|
||||
trackpoint.setTimestamp(time());
|
||||
else if (_reader.name() == "HeartRateBpm")
|
||||
trackpoint.setHeartRate(number());
|
||||
heartRateBpm(trackpoint);
|
||||
else if (_reader.name() == "Cadence")
|
||||
trackpoint.setCadence(number());
|
||||
else if (_reader.name() == "Extensions")
|
||||
@ -173,7 +183,7 @@ void TCXParser::courses(QList<TrackData> &tracks, QList<Waypoint> &waypoints)
|
||||
}
|
||||
}
|
||||
|
||||
void TCXParser::activities(QList<TrackData> &tracks)
|
||||
void TCXParser::sport(QList<TrackData> &tracks)
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "Activity") {
|
||||
@ -184,6 +194,29 @@ void TCXParser::activities(QList<TrackData> &tracks)
|
||||
}
|
||||
}
|
||||
|
||||
void TCXParser::multiSportSession(QList<TrackData> &tracks)
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "FirstSport" || _reader.name() == "NextSport")
|
||||
sport(tracks);
|
||||
else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
void TCXParser::activities(QList<TrackData> &tracks)
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "Activity") {
|
||||
tracks.append(TrackData());
|
||||
activity(tracks.back());
|
||||
} else if (_reader.name() == "MultiSportSession")
|
||||
multiSportSession(tracks);
|
||||
else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
void TCXParser::tcx(QList<TrackData> &tracks, QList<Waypoint> &waypoints)
|
||||
{
|
||||
while (_reader.readNextStartElement()) {
|
||||
|
@ -19,6 +19,8 @@ private:
|
||||
void tcx(QList<TrackData> &tracks, QList<Waypoint> &waypoints);
|
||||
void courses(QList<TrackData> &tracks, QList<Waypoint> &waypoints);
|
||||
void activities(QList<TrackData> &tracks);
|
||||
void multiSportSession(QList<TrackData> &tracks);
|
||||
void sport(QList<TrackData> &tracks);
|
||||
void course(QList<Waypoint> &waypoints, TrackData &track);
|
||||
void activity(TrackData &track);
|
||||
void lap(TrackData &track);
|
||||
@ -26,6 +28,7 @@ private:
|
||||
void trackpointData(Trackpoint &trackpoint);
|
||||
void waypointData(Waypoint &waypoint);
|
||||
void extensions(Trackpoint &trackpoint);
|
||||
void heartRateBpm(Trackpoint &trackpoint);
|
||||
Coordinates position();
|
||||
qreal number();
|
||||
QDateTime time();
|
||||
|
@ -1,13 +1,13 @@
|
||||
#include "data.h"
|
||||
#include "temperaturegraphitem.h"
|
||||
#include "temperaturegraph.h"
|
||||
|
||||
|
||||
TemperatureGraph::TemperatureGraph(QWidget *parent) : GraphTab(parent)
|
||||
{
|
||||
_units = Metric;
|
||||
_showTracks = true;
|
||||
|
||||
setYUnits();
|
||||
setYUnits(Metric);
|
||||
setYLabel(tr("Temperature"));
|
||||
|
||||
setSliderPrecision(1);
|
||||
@ -30,21 +30,16 @@ void TemperatureGraph::loadData(const Data &data, const QList<PathItem *> &paths
|
||||
{
|
||||
for (int i = 0; i < data.tracks().count(); i++) {
|
||||
const Graph &graph = data.tracks().at(i)->temperature();
|
||||
qreal sum = 0, w = 0;
|
||||
|
||||
if (graph.size() < 2) {
|
||||
skipColor();
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int j = 1; j < graph.size(); j++) {
|
||||
qreal ds = graph.at(j).s() - graph.at(j-1).s();
|
||||
sum += graph.at(j).y() * ds;
|
||||
w += ds;
|
||||
}
|
||||
_avg.append(QPointF(data.tracks().at(i)->distance(), sum/w));
|
||||
TemperatureGraphItem *gi = new TemperatureGraphItem(graph, _graphType);
|
||||
GraphView::addGraph(gi, paths.at(i));
|
||||
|
||||
GraphView::loadGraph(graph, paths.at(i));
|
||||
_avg.append(QPointF(data.tracks().at(i)->distance(), gi->avg()));
|
||||
}
|
||||
|
||||
for (int i = 0; i < data.routes().count(); i++)
|
||||
@ -75,9 +70,9 @@ void TemperatureGraph::clear()
|
||||
GraphView::clear();
|
||||
}
|
||||
|
||||
void TemperatureGraph::setYUnits()
|
||||
void TemperatureGraph::setYUnits(Units units)
|
||||
{
|
||||
if (_units == Metric) {
|
||||
if (units == Metric) {
|
||||
GraphView::setYUnits(QChar(0x00B0) + tr("C"));
|
||||
setYScale(1);
|
||||
setYOffset(0);
|
||||
@ -88,15 +83,12 @@ void TemperatureGraph::setYUnits()
|
||||
}
|
||||
}
|
||||
|
||||
void TemperatureGraph::setUnits(enum Units units)
|
||||
void TemperatureGraph::setUnits(Units units)
|
||||
{
|
||||
_units = units;
|
||||
|
||||
setYUnits();
|
||||
setYUnits(units);
|
||||
setInfo();
|
||||
GraphView::setUnits(units);
|
||||
|
||||
redraw();
|
||||
GraphView::setUnits(units);
|
||||
}
|
||||
|
||||
void TemperatureGraph::showTracks(bool show)
|
||||
|
@ -20,12 +20,11 @@ private:
|
||||
qreal avg() const;
|
||||
qreal min() const {return bounds().top();}
|
||||
qreal max() const {return bounds().bottom();}
|
||||
void setYUnits();
|
||||
void setYUnits(Units units);
|
||||
void setInfo();
|
||||
|
||||
QList<QPointF> _avg;
|
||||
|
||||
enum Units _units;
|
||||
bool _showTracks;
|
||||
};
|
||||
|
||||
|
37
src/temperaturegraphitem.cpp
Normal file
37
src/temperaturegraphitem.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
#include "tooltip.h"
|
||||
#include "temperaturegraphitem.h"
|
||||
|
||||
TemperatureGraphItem::TemperatureGraphItem(const Graph &graph, GraphType type,
|
||||
QGraphicsItem *parent) : GraphItem(graph, type, parent)
|
||||
{
|
||||
qreal sum = 0;
|
||||
|
||||
for (int j = 1; j < graph.size(); j++)
|
||||
sum += graph.at(j).y() * (graph.at(j).s() - graph.at(j-1).s());
|
||||
_avg = sum/graph.last().s();
|
||||
|
||||
setToolTip(toolTip(Metric));
|
||||
}
|
||||
|
||||
QString TemperatureGraphItem::toolTip(Units units) const
|
||||
{
|
||||
ToolTip tt;
|
||||
qreal scale = (units == Metric) ? 1.0 : C2FS;
|
||||
qreal offset = (units == Metric) ? 0 : C2FO;
|
||||
QString su = (units == Metric) ?
|
||||
QChar(0x00B0) + tr("C") : QChar(0x00B0) + tr("F");
|
||||
|
||||
tt.insert(tr("Average"), QString::number(avg() * scale + offset, 'f', 1)
|
||||
+ UNIT_SPACE + su);
|
||||
tt.insert(tr("Maximum"), QString::number(max() * scale + offset, 'f', 1)
|
||||
+ UNIT_SPACE + su);
|
||||
tt.insert(tr("Minimum"), QString::number(min() * scale + offset, 'f', 1)
|
||||
+ UNIT_SPACE + su);
|
||||
|
||||
return tt.toString();
|
||||
}
|
||||
|
||||
void TemperatureGraphItem::setUnits(Units units)
|
||||
{
|
||||
setToolTip(toolTip(units));
|
||||
}
|
26
src/temperaturegraphitem.h
Normal file
26
src/temperaturegraphitem.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef TEMPERATUREGRAPHITEM_H
|
||||
#define TEMPERATUREGRAPHITEM_H
|
||||
|
||||
#include "graphitem.h"
|
||||
|
||||
class TemperatureGraphItem : public GraphItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TemperatureGraphItem(const Graph &graph, GraphType type,
|
||||
QGraphicsItem *parent = 0);
|
||||
|
||||
qreal max() const {return -bounds().top();}
|
||||
qreal min() const {return -bounds().bottom();}
|
||||
qreal avg() const {return _avg;}
|
||||
|
||||
void setUnits(Units units);
|
||||
|
||||
private:
|
||||
QString toolTip(Units units) const;
|
||||
|
||||
qreal _avg;
|
||||
};
|
||||
|
||||
#endif // TEMPERATUREGRAPHITEM_H
|
@ -16,11 +16,9 @@ void TrackInfo::insert(const QString &key, const QString &value)
|
||||
_info->insert(key, value);
|
||||
}
|
||||
|
||||
void TrackInfo::plot(QPainter *painter, const QRectF &target)
|
||||
void TrackInfo::plot(QPainter *painter, const QRectF &target, qreal scale)
|
||||
{
|
||||
qreal ratio = painter->paintEngine()->paintDevice()->logicalDpiX()
|
||||
/ SCREEN_DPI;
|
||||
QSizeF canvas = QSizeF(target.width() / ratio, target.height() / ratio);
|
||||
QSizeF canvas = QSizeF(target.width() / scale, target.height() / scale);
|
||||
QSizeF diff = QSizeF(qAbs(canvas.width() - sceneRect().width()),
|
||||
qAbs(canvas.height() - sceneRect().height()));
|
||||
QRectF adj = sceneRect().adjusted(0, -diff.height()/2, diff.width(),
|
||||
|
@ -13,7 +13,7 @@ public:
|
||||
TrackInfo(QObject *parent = 0);
|
||||
|
||||
void insert(const QString &key, const QString &value);
|
||||
void plot(QPainter *painter, const QRectF &target);
|
||||
void plot(QPainter *painter, const QRectF &target, qreal scale);
|
||||
bool isEmpty() const;
|
||||
QSizeF contentSize() const;
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "trackitem.h"
|
||||
|
||||
|
||||
QString TrackItem::toolTip(Units units)
|
||||
QString TrackItem::toolTip(Units units) const
|
||||
{
|
||||
ToolTip tt;
|
||||
|
||||
|
@ -19,7 +19,7 @@ public:
|
||||
void setUnits(Units units);
|
||||
|
||||
private:
|
||||
QString toolTip(Units units);
|
||||
QString toolTip(Units units) const;
|
||||
|
||||
QString _name;
|
||||
QString _desc;
|
||||
|
@ -2,11 +2,9 @@
|
||||
|
||||
QDebug operator<<(QDebug dbg, const Trackpoint &trackpoint)
|
||||
{
|
||||
const bool ais = dbg.autoInsertSpaces();
|
||||
dbg.nospace() << "Trackpoint(" << trackpoint.coordinates() << ", "
|
||||
<< trackpoint.timestamp() << ", " << trackpoint.elevation() << ", "
|
||||
<< trackpoint.speed() << ", " << trackpoint.heartRate() << ", "
|
||||
<< trackpoint.temperature() << ")";
|
||||
dbg.setAutoInsertSpaces(ais);
|
||||
return dbg.maybeSpace();
|
||||
return dbg.space();
|
||||
}
|
||||
|
@ -25,10 +25,6 @@ enum Units {
|
||||
#define C2FS 1.8 // Celsius to Farenheit - scale
|
||||
#define C2FO 32.0 // Celsius to Farenheit - offset
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
#define UNIT_SPACE QString(" ")
|
||||
#else // Q_OS_WIN32
|
||||
#define UNIT_SPACE QString::fromUtf8("\xE2\x80\x89")
|
||||
#endif // Q_OS_WIN32
|
||||
|
||||
#endif // UNITS_H
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
QDebug operator<<(QDebug dbg, const Waypoint &waypoint)
|
||||
{
|
||||
const bool ais = dbg.autoInsertSpaces();
|
||||
dbg.nospace() << "Waypoint(" << waypoint.coordinates() << ", "
|
||||
<< waypoint.name() << ", " << waypoint.description() << ")";
|
||||
dbg.setAutoInsertSpaces(ais);
|
||||
return dbg.maybeSpace();
|
||||
return dbg.space();
|
||||
}
|
||||
|
@ -6,8 +6,10 @@
|
||||
#include "waypointitem.h"
|
||||
|
||||
|
||||
#define POINT_SIZE 8
|
||||
#define HOVER_SIZE 10
|
||||
#define HS(size) \
|
||||
((int)((qreal)size * 1.2))
|
||||
#define FS(size) \
|
||||
((int)((qreal)size * 1.41))
|
||||
|
||||
QString WaypointItem::toolTip(Units units)
|
||||
{
|
||||
@ -36,6 +38,8 @@ WaypointItem::WaypointItem(const Waypoint &waypoint, Map *map,
|
||||
_waypoint = waypoint;
|
||||
_showLabel = true;
|
||||
_hover = false;
|
||||
_size = 8;
|
||||
_color = Qt::black;
|
||||
|
||||
updateShape();
|
||||
|
||||
@ -48,11 +52,11 @@ WaypointItem::WaypointItem(const Waypoint &waypoint, Map *map,
|
||||
void WaypointItem::updateShape()
|
||||
{
|
||||
QPainterPath p;
|
||||
qreal pointSize = _hover ? HOVER_SIZE : POINT_SIZE;
|
||||
qreal pointSize = _hover ? HS(_size) : _size;
|
||||
|
||||
if (_showLabel) {
|
||||
QFont font;
|
||||
font.setPixelSize(FONT_SIZE);
|
||||
font.setPixelSize(FS(_size));
|
||||
font.setFamily(FONT_FAMILY);
|
||||
if (_hover)
|
||||
font.setBold(true);
|
||||
@ -74,11 +78,13 @@ void WaypointItem::paint(QPainter *painter,
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
|
||||
qreal pointSize = _hover ? HOVER_SIZE : POINT_SIZE;
|
||||
qreal pointSize = _hover ? HS(_size) : _size;
|
||||
|
||||
painter->setPen(_color);
|
||||
|
||||
if (_showLabel) {
|
||||
QFont font;
|
||||
font.setPixelSize(FONT_SIZE);
|
||||
font.setPixelSize(FS(_size));
|
||||
font.setFamily(FONT_FAMILY);
|
||||
if (_hover)
|
||||
font.setBold(true);
|
||||
@ -90,7 +96,7 @@ void WaypointItem::paint(QPainter *painter,
|
||||
+ ts.height(), _waypoint.name());
|
||||
}
|
||||
|
||||
painter->setBrush(Qt::SolidPattern);
|
||||
painter->setBrush(QBrush(_color, Qt::SolidPattern));
|
||||
painter->drawEllipse(-pointSize/2, -pointSize/2, pointSize, pointSize);
|
||||
|
||||
/*
|
||||
@ -100,6 +106,19 @@ void WaypointItem::paint(QPainter *painter,
|
||||
*/
|
||||
}
|
||||
|
||||
void WaypointItem::setSize(int size)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
_size = size;
|
||||
updateShape();
|
||||
}
|
||||
|
||||
void WaypointItem::setColor(const QColor &color)
|
||||
{
|
||||
_color = color;
|
||||
update();
|
||||
}
|
||||
|
||||
void WaypointItem::setUnits(enum Units units)
|
||||
{
|
||||
setToolTip(toolTip(units));
|
||||
|
@ -16,6 +16,8 @@ public:
|
||||
|
||||
void setMap(Map *map) {setPos(map->ll2xy(_waypoint.coordinates()));}
|
||||
void setUnits(Units units);
|
||||
void setSize(int size);
|
||||
void setColor(const QColor &color);
|
||||
void showLabel(bool show);
|
||||
void setDigitalZoom(int zoom) {setScale(pow(2, -zoom));}
|
||||
|
||||
@ -34,6 +36,8 @@ private:
|
||||
QPainterPath _shape;
|
||||
Waypoint _waypoint;
|
||||
|
||||
QColor _color;
|
||||
int _size;
|
||||
bool _hover;
|
||||
bool _showLabel;
|
||||
};
|
||||
|
Reference in New Issue
Block a user