mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 03:35:53 +01:00
Added initial support for track/route graphs differentiation
This commit is contained in:
parent
d20d94ef05
commit
7993e4dcb3
@ -49,7 +49,8 @@ HEADERS += src/config.h \
|
||||
src/trackitem.h \
|
||||
src/tooltip.h \
|
||||
src/route.h \
|
||||
src/routeitem.h
|
||||
src/routeitem.h \
|
||||
src/graphitem.h
|
||||
SOURCES += src/main.cpp \
|
||||
src/gui.cpp \
|
||||
src/gpx.cpp \
|
||||
|
@ -4,55 +4,55 @@
|
||||
<context>
|
||||
<name>ElevationGraph</name>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="14"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="48"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="15"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="49"/>
|
||||
<location filename="../src/elevationgraph.h" line="15"/>
|
||||
<source>Elevation</source>
|
||||
<translation>Výška</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="85"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="145"/>
|
||||
<source>km</source>
|
||||
<translation>km</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="82"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="102"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="142"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="162"/>
|
||||
<source>m</source>
|
||||
<translation>m</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="22"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="59"/>
|
||||
<source>Ascent</source>
|
||||
<translation>Stoupání</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="24"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="61"/>
|
||||
<source>Descent</source>
|
||||
<translation>Klesání</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="28"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="65"/>
|
||||
<source>Minimum</source>
|
||||
<translation>Minimum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="93"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="153"/>
|
||||
<source>mi</source>
|
||||
<translation>mi</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="90"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="105"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="150"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="165"/>
|
||||
<source>ft</source>
|
||||
<translation>ft</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/elevationgraph.cpp" line="26"/>
|
||||
<location filename="../src/elevationgraph.cpp" line="63"/>
|
||||
<source>Maximum</source>
|
||||
<translation>Maximum</translation>
|
||||
</message>
|
||||
@ -163,17 +163,17 @@
|
||||
<context>
|
||||
<name>GUI</name>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="486"/>
|
||||
<location filename="../src/gui.cpp" line="484"/>
|
||||
<source>GPXSee is distributed under the terms of the GNU General Public License version 3. For more info about GPXSee visit the project homepage at </source>
|
||||
<translation>Program GPXSee je distribuován pod podmínkami licence GNU General Public License verze 3. Pro více informací navštivte stránky programu na adrese </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="550"/>
|
||||
<location filename="../src/gui.cpp" line="548"/>
|
||||
<source>Open file</source>
|
||||
<translation>Otevřít soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="631"/>
|
||||
<location filename="../src/gui.cpp" line="628"/>
|
||||
<source>Open POI file</source>
|
||||
<translation>Otevřít POI soubor</translation>
|
||||
</message>
|
||||
@ -189,8 +189,8 @@
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="190"/>
|
||||
<location filename="../src/gui.cpp" line="502"/>
|
||||
<location filename="../src/gui.cpp" line="503"/>
|
||||
<location filename="../src/gui.cpp" line="500"/>
|
||||
<location filename="../src/gui.cpp" line="501"/>
|
||||
<source>Keyboard controls</source>
|
||||
<translation>Ovládací klávesy</translation>
|
||||
</message>
|
||||
@ -217,8 +217,8 @@
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="188"/>
|
||||
<location filename="../src/gui.cpp" line="525"/>
|
||||
<location filename="../src/gui.cpp" line="526"/>
|
||||
<location filename="../src/gui.cpp" line="523"/>
|
||||
<location filename="../src/gui.cpp" line="524"/>
|
||||
<source>Data sources</source>
|
||||
<translation>Zdroje dat</translation>
|
||||
</message>
|
||||
@ -260,20 +260,30 @@
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="265"/>
|
||||
<location filename="../src/gui.cpp" line="269"/>
|
||||
<location filename="../src/gui.cpp" line="512"/>
|
||||
<location filename="../src/gui.cpp" line="510"/>
|
||||
<source>Next map</source>
|
||||
<translation>Následující mapa</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="276"/>
|
||||
<source>Show tracks</source>
|
||||
<translation>Zobrazit cesty</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="280"/>
|
||||
<source>Show routes</source>
|
||||
<translation>Zobrazit trasy</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="284"/>
|
||||
<source>Show waypoints</source>
|
||||
<translation>Zobrazit navigační body</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="288"/>
|
||||
<source>Waypoint labels</source>
|
||||
<translation>Názvy navigačních bodů</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="292"/>
|
||||
<source>Route Waypoints</source>
|
||||
<translation>Body tras</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="298"/>
|
||||
<source>Show graphs</source>
|
||||
@ -360,39 +370,38 @@
|
||||
<translation>Nápověda</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="514"/>
|
||||
<location filename="../src/gui.cpp" line="512"/>
|
||||
<source>Previous map</source>
|
||||
<translation>Předchozí mapa</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="718"/>
|
||||
<location filename="../src/gui.cpp" line="721"/>
|
||||
<location filename="../src/gui.cpp" line="716"/>
|
||||
<location filename="../src/gui.cpp" line="719"/>
|
||||
<source>Date</source>
|
||||
<translation>Datum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="280"/>
|
||||
<location filename="../src/gui.cpp" line="730"/>
|
||||
<location filename="../src/gui.cpp" line="728"/>
|
||||
<source>Routes</source>
|
||||
<translation>Trasy</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="903"/>
|
||||
<location filename="../src/gui.cpp" line="918"/>
|
||||
<source>No GPX files loaded</source>
|
||||
<translation>Nejsou načteny žádné GPX soubory</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="910"/>
|
||||
<location filename="../src/gui.cpp" line="922"/>
|
||||
<source>%1 files</source>
|
||||
<translation>%1 souborů</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="505"/>
|
||||
<location filename="../src/gui.cpp" line="503"/>
|
||||
<source>Next file</source>
|
||||
<translation>Následující soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="482"/>
|
||||
<location filename="../src/gui.cpp" line="480"/>
|
||||
<source>Version </source>
|
||||
<translation>Verze </translation>
|
||||
</message>
|
||||
@ -407,71 +416,74 @@
|
||||
<translation>Exportovat do PDF...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="284"/>
|
||||
<location filename="../src/gui.cpp" line="732"/>
|
||||
<location filename="../src/gui.cpp" line="730"/>
|
||||
<source>Waypoints</source>
|
||||
<translation>Navigační body</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="506"/>
|
||||
<location filename="../src/gui.cpp" line="504"/>
|
||||
<source>Previous file</source>
|
||||
<translation>Předchozí soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="508"/>
|
||||
<location filename="../src/gui.cpp" line="292"/>
|
||||
<source>Route waypoints</source>
|
||||
<translation>Body tras</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="506"/>
|
||||
<source>First file</source>
|
||||
<translation>První soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="509"/>
|
||||
<location filename="../src/gui.cpp" line="507"/>
|
||||
<source>Last file</source>
|
||||
<translation>Poslední soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="510"/>
|
||||
<location filename="../src/gui.cpp" line="508"/>
|
||||
<source>Append modifier</source>
|
||||
<translation>Modifikátor nahradit/přidat</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="529"/>
|
||||
<location filename="../src/gui.cpp" line="527"/>
|
||||
<source>Map (tiles) source URLs are read on program startup from the following file:</source>
|
||||
<translation>URL mapových zdrojů (dlaždic) jsou načteny při startu programu z následujícího souboru:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="532"/>
|
||||
<location filename="../src/gui.cpp" line="530"/>
|
||||
<source>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:</source>
|
||||
<translation>Formát souboru je jeden mapový záznam na řádku, kde mapový záznam sestává ze jména mapy a URL dlaždic navzájem oddělených tabulátorem. Souřadnice dlaždice jsou v URL nahrazeny řetězci $x a $y, úroven přiblížení (zoom) pak řetězcem $z. Příklad:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="540"/>
|
||||
<location filename="../src/gui.cpp" line="538"/>
|
||||
<source>To make GPXSee load a POI file automatically on startup, add the file to the following directory:</source>
|
||||
<translation>POI soubory, které se mají automaticky nahrát při startu programu jsou načítány z následujícího adresáře:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="551"/>
|
||||
<location filename="../src/gui.cpp" line="549"/>
|
||||
<source>GPX files (*.gpx);;All files (*)</source>
|
||||
<translation>Soubory GPX (*.gpx);;Všechny soubory (*)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="622"/>
|
||||
<location filename="../src/gui.cpp" line="648"/>
|
||||
<location filename="../src/gui.cpp" line="619"/>
|
||||
<location filename="../src/gui.cpp" line="645"/>
|
||||
<source>Line: %1</source>
|
||||
<translation>Řádka: %1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="632"/>
|
||||
<location filename="../src/gui.cpp" line="629"/>
|
||||
<source>GPX files (*.gpx);;CSV files (*.csv);;All files (*)</source>
|
||||
<translation>Soubory GPX (*.gpx);;Soubory CSV (*.csv);;Všechny soubory (*)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="276"/>
|
||||
<location filename="../src/gui.cpp" line="728"/>
|
||||
<location filename="../src/gui.cpp" line="726"/>
|
||||
<source>Tracks</source>
|
||||
<translation>Cesty</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="193"/>
|
||||
<location filename="../src/gui.cpp" line="480"/>
|
||||
<location filename="../src/gui.cpp" line="478"/>
|
||||
<source>About GPXSee</source>
|
||||
<translation>O aplikaci GPXSee</translation>
|
||||
</message>
|
||||
@ -481,40 +493,40 @@
|
||||
<translation>Navigace</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="528"/>
|
||||
<location filename="../src/gui.cpp" line="526"/>
|
||||
<source>Map sources</source>
|
||||
<translation>Mapové zdroje</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="539"/>
|
||||
<location filename="../src/gui.cpp" line="537"/>
|
||||
<source>POIs</source>
|
||||
<translation>POI body</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="735"/>
|
||||
<location filename="../src/gui.cpp" line="733"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="737"/>
|
||||
<location filename="../src/gui.cpp" line="735"/>
|
||||
<source>Time</source>
|
||||
<translation>Čas</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="624"/>
|
||||
<location filename="../src/gui.cpp" line="649"/>
|
||||
<location filename="../src/gui.cpp" line="621"/>
|
||||
<location filename="../src/gui.cpp" line="646"/>
|
||||
<source>Error</source>
|
||||
<translation>Chyba</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="619"/>
|
||||
<location filename="../src/gui.cpp" line="616"/>
|
||||
<source>Error loading GPX file:
|
||||
%1</source>
|
||||
<translation>Soubor GPX nelze otevřít:
|
||||
%1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="645"/>
|
||||
<location filename="../src/gui.cpp" line="642"/>
|
||||
<source>Error loading POI file:
|
||||
%1</source>
|
||||
<translation>Soubor POI nelze otevřít:
|
||||
|
@ -1,12 +1,46 @@
|
||||
#include <cmath>
|
||||
#include "config.h"
|
||||
#include "gpx.h"
|
||||
#include "elevationgraph.h"
|
||||
|
||||
|
||||
static qreal nMin(qreal a, qreal b)
|
||||
{
|
||||
if (!std::isnan(a) && !std::isnan(b))
|
||||
return qMin(a, b);
|
||||
else if (!std::isnan(a))
|
||||
return a;
|
||||
else if (!std::isnan(b))
|
||||
return b;
|
||||
else
|
||||
return NAN;
|
||||
}
|
||||
|
||||
static qreal nMax(qreal a, qreal b)
|
||||
{
|
||||
if (!std::isnan(a) && !std::isnan(b))
|
||||
return qMax(a, b);
|
||||
else if (!std::isnan(a))
|
||||
return a;
|
||||
else if (!std::isnan(b))
|
||||
return b;
|
||||
else
|
||||
return NAN;
|
||||
}
|
||||
|
||||
ElevationGraph::ElevationGraph(QWidget *parent) : GraphTab(parent)
|
||||
{
|
||||
_ascent = 0;
|
||||
_descent = 0;
|
||||
_trackAscent = 0;
|
||||
_routeAscent = 0;
|
||||
_trackDescent = 0;
|
||||
_routeDescent = 0;
|
||||
_trackMin = NAN;
|
||||
_trackMax = NAN;
|
||||
_routeMin = NAN;
|
||||
_routeMax = NAN;
|
||||
|
||||
_showRoutes = true;
|
||||
_showTracks = true;
|
||||
|
||||
_units = Metric;
|
||||
|
||||
@ -19,25 +53,31 @@ ElevationGraph::ElevationGraph(QWidget *parent) : GraphTab(parent)
|
||||
|
||||
void ElevationGraph::setInfo()
|
||||
{
|
||||
GraphView::addInfo(tr("Ascent"), QString::number(_ascent * yScale(), 'f', 0)
|
||||
+ UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Descent"), QString::number(_descent * yScale(), 'f',
|
||||
0) + UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale(), 'f', 0)
|
||||
+ UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Minimum"), QString::number(min() * yScale(), 'f', 0)
|
||||
+ UNIT_SPACE + yUnits());
|
||||
if (std::isnan(max()) || std::isnan(min()))
|
||||
clearInfo();
|
||||
else {
|
||||
GraphView::addInfo(tr("Ascent"), QString::number(ascent() * yScale(),
|
||||
'f', 0) + UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Descent"), QString::number(descent() * yScale(),
|
||||
'f', 0) + UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Maximum"), QString::number(max() * yScale(), 'f',
|
||||
0) + UNIT_SPACE + yUnits());
|
||||
GraphView::addInfo(tr("Minimum"), QString::number(min() * yScale(), 'f',
|
||||
0) + UNIT_SPACE + yUnits());
|
||||
}
|
||||
}
|
||||
|
||||
void ElevationGraph::loadPath(const QVector<QPointF> &data)
|
||||
void ElevationGraph::loadPath(const QVector<QPointF> &data, Type type)
|
||||
{
|
||||
qreal ascent = 0, descent = 0;
|
||||
qreal min, max;
|
||||
|
||||
if (data.count() < 2) {
|
||||
skipColor();
|
||||
return;
|
||||
}
|
||||
|
||||
max = min = data.at(0).y();
|
||||
for (int j = 1; j < data.size(); j++) {
|
||||
qreal cur = data.at(j).y();
|
||||
qreal prev = data.at(j-1).y();
|
||||
@ -46,20 +86,34 @@ void ElevationGraph::loadPath(const QVector<QPointF> &data)
|
||||
ascent += cur - prev;
|
||||
if (cur < prev)
|
||||
descent += prev - cur;
|
||||
|
||||
if (cur < min)
|
||||
min = cur;
|
||||
if (cur > max)
|
||||
max = cur;
|
||||
}
|
||||
|
||||
_ascent += ascent;
|
||||
_descent += descent;
|
||||
if (type == Track) {
|
||||
_trackAscent += ascent;
|
||||
_trackDescent += descent;
|
||||
_trackMax = nMax(_trackMax, max);
|
||||
_trackMin = nMin(_trackMin, min);
|
||||
} else {
|
||||
_routeAscent += ascent;
|
||||
_routeDescent += descent;
|
||||
_routeMax = nMax(_routeMax, max);
|
||||
_routeMin = nMin(_routeMin, min);
|
||||
}
|
||||
|
||||
loadData(data);
|
||||
loadData(data, type);
|
||||
}
|
||||
|
||||
void ElevationGraph::loadGPX(const GPX &gpx)
|
||||
{
|
||||
for (int i = 0; i < gpx.tracks().count(); i++)
|
||||
loadPath(gpx.tracks().at(i)->elevation());
|
||||
loadPath(gpx.tracks().at(i)->elevation(), Track);
|
||||
for (int i = 0; i < gpx.routes().count(); i++)
|
||||
loadPath(gpx.routes().at(i)->elevation());
|
||||
loadPath(gpx.routes().at(i)->elevation(), Route);
|
||||
|
||||
setXUnits();
|
||||
setInfo();
|
||||
@ -69,8 +123,14 @@ void ElevationGraph::loadGPX(const GPX &gpx)
|
||||
|
||||
void ElevationGraph::clear()
|
||||
{
|
||||
_ascent = 0;
|
||||
_descent = 0;
|
||||
_trackAscent = 0;
|
||||
_routeAscent = 0;
|
||||
_trackDescent = 0;
|
||||
_routeDescent = 0;
|
||||
_trackMin = NAN;
|
||||
_trackMax = NAN;
|
||||
_routeMin = NAN;
|
||||
_trackMax = NAN;
|
||||
|
||||
GraphView::clear();
|
||||
}
|
||||
@ -117,3 +177,79 @@ void ElevationGraph::setUnits(enum Units units)
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
void ElevationGraph::showTracks(bool show)
|
||||
{
|
||||
_showTracks = show;
|
||||
|
||||
setInfo();
|
||||
showGraph(show, Track);
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
void ElevationGraph::showRoutes(bool show)
|
||||
{
|
||||
_showRoutes = show;
|
||||
|
||||
setInfo();
|
||||
showGraph(show, Route);
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
qreal ElevationGraph::ascent() const
|
||||
{
|
||||
qreal val = 0;
|
||||
|
||||
if (_showRoutes)
|
||||
val += _routeAscent;
|
||||
if (_showTracks)
|
||||
val += _trackAscent;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
qreal ElevationGraph::descent() const
|
||||
{
|
||||
qreal val = 0;
|
||||
|
||||
if (_showRoutes)
|
||||
val += _routeDescent;
|
||||
if (_showTracks)
|
||||
val += _trackDescent;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
qreal ElevationGraph::max() const
|
||||
{
|
||||
qreal val;
|
||||
|
||||
if (_showRoutes && _showTracks)
|
||||
val = nMax(_routeMax, _trackMax);
|
||||
else if (_showTracks)
|
||||
val = _trackMax;
|
||||
else if (_showRoutes)
|
||||
val = _routeMax;
|
||||
else
|
||||
val = NAN;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
qreal ElevationGraph::min() const
|
||||
{
|
||||
qreal val;
|
||||
|
||||
if (_showRoutes && _showTracks)
|
||||
val = nMin(_routeMin, _trackMin);
|
||||
else if (_showTracks)
|
||||
val = _trackMin;
|
||||
else if (_showRoutes)
|
||||
val = _routeMin;
|
||||
else
|
||||
val = NAN;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
@ -16,21 +16,30 @@ public:
|
||||
void loadGPX(const GPX &gpx);
|
||||
void clear();
|
||||
void setUnits(enum Units units);
|
||||
void showTracks(bool show);
|
||||
void showRoutes(bool show);
|
||||
|
||||
private:
|
||||
qreal ascent() const {return _ascent;}
|
||||
qreal descent() const {return _descent;}
|
||||
qreal max() const {return bounds().bottom();}
|
||||
qreal min() const {return bounds().top();}
|
||||
enum Type {Track, Route};
|
||||
|
||||
qreal max() const;
|
||||
qreal min() const;
|
||||
qreal ascent() const;
|
||||
qreal descent() const;
|
||||
|
||||
void setXUnits();
|
||||
void setYUnits();
|
||||
void setInfo();
|
||||
|
||||
void loadPath(const QVector<QPointF> &data);
|
||||
void loadPath(const QVector<QPointF> &data, Type type);
|
||||
|
||||
qreal _trackAscent, _trackDescent;
|
||||
qreal _routeAscent, _routeDescent;
|
||||
qreal _trackMax, _routeMax;
|
||||
qreal _trackMin, _routeMin;
|
||||
|
||||
qreal _ascent, _descent;
|
||||
enum Units _units;
|
||||
bool _showTracks, _showRoutes;
|
||||
};
|
||||
|
||||
#endif // ELEVATIONGRAPH_H
|
||||
|
19
src/graphitem.h
Normal file
19
src/graphitem.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef GRAPHITEM_H
|
||||
#define GRAPHITEM_H
|
||||
|
||||
#include <QGraphicsPathItem>
|
||||
|
||||
class GraphItem : public QGraphicsPathItem
|
||||
{
|
||||
public:
|
||||
GraphItem(const QPainterPath &path, QGraphicsItem * parent = 0)
|
||||
: QGraphicsPathItem(path, parent) {_id = 0;}
|
||||
|
||||
int id() {return _id;}
|
||||
void setId(int id) {_id = id;}
|
||||
|
||||
private:
|
||||
int _id;
|
||||
};
|
||||
|
||||
#endif // GRAPHITEM_H
|
@ -18,6 +18,8 @@ public:
|
||||
virtual void loadGPX(const GPX &gpx) = 0;
|
||||
virtual void clear() = 0;
|
||||
virtual void setUnits(enum Units units) = 0;
|
||||
virtual void showTracks(bool show) = 0;
|
||||
virtual void showRoutes(bool show) = 0;
|
||||
};
|
||||
|
||||
#endif // GRAPHTAB_H
|
||||
|
@ -1,4 +1,3 @@
|
||||
#include <QGraphicsView>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QEvent>
|
||||
#include <QPaintEngine>
|
||||
@ -8,6 +7,7 @@
|
||||
#include "slideritem.h"
|
||||
#include "sliderinfoitem.h"
|
||||
#include "infoitem.h"
|
||||
#include "graphitem.h"
|
||||
#include "graphview.h"
|
||||
|
||||
|
||||
@ -33,20 +33,17 @@ GraphView::GraphView(QWidget *parent)
|
||||
|
||||
_xAxis = new AxisItem(AxisItem::X);
|
||||
_yAxis = new AxisItem(AxisItem::Y);
|
||||
|
||||
_slider = new SliderItem();
|
||||
_slider->setZValue(2.0);
|
||||
_sliderInfo = new SliderInfoItem(_slider);
|
||||
_sliderInfo->setZValue(2.0);
|
||||
_info = new InfoItem();
|
||||
|
||||
connect(_slider, SIGNAL(positionChanged(const QPointF&)), this,
|
||||
SLOT(emitSliderPositionChanged(const QPointF&)));
|
||||
connect(_scene, SIGNAL(mouseClicked(const QPointF&)), this,
|
||||
SLOT(newSliderPosition(const QPointF&)));
|
||||
|
||||
_info = new InfoItem();
|
||||
|
||||
_sliderInfo = new SliderInfoItem(_slider);
|
||||
_sliderInfo->setZValue(2.0);
|
||||
|
||||
_xScale = 1;
|
||||
_yScale = 1;
|
||||
_yOffset = 0;
|
||||
@ -63,10 +60,8 @@ GraphView::~GraphView()
|
||||
delete _xAxis;
|
||||
if (_yAxis->scene() != _scene)
|
||||
delete _yAxis;
|
||||
|
||||
if (_slider->scene() != _scene)
|
||||
delete _slider;
|
||||
|
||||
if (_info->scene() != _scene)
|
||||
delete _info;
|
||||
}
|
||||
@ -117,10 +112,10 @@ void GraphView::setYUnits(const QString &units)
|
||||
createYLabel();
|
||||
}
|
||||
|
||||
void GraphView::loadData(const QVector<QPointF> &data)
|
||||
void GraphView::loadData(const QVector<QPointF> &data, int id)
|
||||
{
|
||||
QPainterPath path;
|
||||
QGraphicsPathItem *pi;
|
||||
GraphItem *pi;
|
||||
|
||||
|
||||
if (data.size() < 2)
|
||||
@ -137,14 +132,29 @@ void GraphView::loadData(const QVector<QPointF> &data)
|
||||
updateBounds(p);
|
||||
}
|
||||
|
||||
pi = new QGraphicsPathItem(path);
|
||||
pi = new GraphItem(path);
|
||||
QBrush brush(_palette.color(), Qt::SolidPattern);
|
||||
QPen pen(brush, 0);
|
||||
pi->setPen(pen);
|
||||
pi->setId(id);
|
||||
if (_hide.contains(id))
|
||||
pi->hide();
|
||||
_scene->addItem(pi);
|
||||
_graphs.append(pi);
|
||||
}
|
||||
|
||||
void GraphView::showGraph(bool show, int id)
|
||||
{
|
||||
for (int i = 0; i < _graphs.count(); i++)
|
||||
if (_graphs.at(i)->id() == id)
|
||||
_graphs.at(i)->setVisible(show);
|
||||
|
||||
if (show)
|
||||
_hide.remove(id);
|
||||
else
|
||||
_hide.insert(id);
|
||||
}
|
||||
|
||||
void GraphView::redraw()
|
||||
{
|
||||
if (!_graphs.isEmpty())
|
||||
@ -209,13 +219,8 @@ void GraphView::redraw(const QSizeF &size)
|
||||
_scene->addItem(_yAxis);
|
||||
|
||||
_slider->setArea(r);
|
||||
if (_sliderPos > _bounds.right() || _sliderPos < _bounds.left())
|
||||
_slider->setVisible(false);
|
||||
_slider->setPos((_sliderPos / _bounds.width()) * _slider->area().width(),
|
||||
r.bottom());
|
||||
_scene->addItem(_slider);
|
||||
|
||||
updateSliderInfo();
|
||||
updateSliderPosition();
|
||||
|
||||
r = _scene->itemsBoundingRect();
|
||||
_info->setPos(r.topLeft() + QPointF(r.width()/2
|
||||
@ -301,6 +306,17 @@ static qreal yAtX(const QPainterPath &path, qreal x)
|
||||
return l.pointAt((x - l.p1().x()) / (l.p2().x() - l.p1().x())).y();
|
||||
}
|
||||
|
||||
void GraphView::updateSliderPosition()
|
||||
{
|
||||
Q_ASSERT(_sliderPos <= _bounds.right() && _sliderPos >= _bounds.left());
|
||||
|
||||
_slider->setPos((_sliderPos / _bounds.width()) * _slider->area().width(),
|
||||
_slider->area().bottom());
|
||||
//_slider->setVisible(false);
|
||||
|
||||
updateSliderInfo();
|
||||
}
|
||||
|
||||
void GraphView::updateSliderInfo()
|
||||
{
|
||||
_sliderInfo->setVisible(_graphs.size() == 1);
|
||||
@ -333,33 +349,26 @@ void GraphView::emitSliderPositionChanged(const QPointF &pos)
|
||||
return;
|
||||
|
||||
_sliderPos = (pos.x() / _slider->area().width()) * _bounds.width();
|
||||
emit sliderPositionChanged(_sliderPos);
|
||||
|
||||
updateSliderInfo();
|
||||
updateSliderPosition();
|
||||
emit sliderPositionChanged(_sliderPos);
|
||||
}
|
||||
|
||||
void GraphView::setSliderPosition(qreal pos)
|
||||
{
|
||||
_sliderPos = pos;
|
||||
|
||||
if (_graphs.isEmpty())
|
||||
return;
|
||||
|
||||
if (pos > _bounds.right() || pos < _bounds.left())
|
||||
_slider->setVisible(false);
|
||||
else {
|
||||
_slider->setPos((pos / _bounds.width()) * _slider->area().width(), 0);
|
||||
_slider->setVisible(true);
|
||||
}
|
||||
_sliderPos = pos;
|
||||
|
||||
updateSliderPosition();
|
||||
emit sliderPositionChanged(_sliderPos);
|
||||
}
|
||||
|
||||
void GraphView::newSliderPosition(const QPointF &pos)
|
||||
{
|
||||
if (_slider->area().contains(pos)) {
|
||||
_slider->setPos(pos);
|
||||
_slider->setVisible(true);
|
||||
if (_slider->area().contains(pos))
|
||||
emitSliderPositionChanged(pos);
|
||||
}
|
||||
}
|
||||
|
||||
void GraphView::addInfo(const QString &key, const QString &value)
|
||||
|
@ -5,14 +5,15 @@
|
||||
#include <QGraphicsScene>
|
||||
#include <QVector>
|
||||
#include <QList>
|
||||
#include <QSet>
|
||||
#include <QPointF>
|
||||
#include "palette.h"
|
||||
|
||||
|
||||
class AxisItem;
|
||||
class SliderItem;
|
||||
class SliderInfoItem;
|
||||
class InfoItem;
|
||||
class GraphItem;
|
||||
|
||||
class Scene : public QGraphicsScene
|
||||
{
|
||||
@ -34,12 +35,12 @@ public:
|
||||
GraphView(QWidget *parent = 0);
|
||||
~GraphView();
|
||||
|
||||
void loadData(const QVector<QPointF> &data);
|
||||
|
||||
void loadData(const QVector<QPointF> &data, int id = 0);
|
||||
int count() const {return _graphs.count();}
|
||||
void redraw();
|
||||
void clear();
|
||||
|
||||
int count() const {return _graphs.count();}
|
||||
void showGraph(bool show, int id = 0);
|
||||
|
||||
const QString &xLabel() const {return _xLabel;}
|
||||
const QString &yLabel() const {return _yLabel;}
|
||||
@ -70,11 +71,11 @@ signals:
|
||||
|
||||
protected:
|
||||
const QRectF &bounds() const {return _bounds;}
|
||||
void resizeEvent(QResizeEvent *);
|
||||
void redraw(const QSizeF &size);
|
||||
void addInfo(const QString &key, const QString &value);
|
||||
void clearInfo();
|
||||
void skipColor() {_palette.color();}
|
||||
void resizeEvent(QResizeEvent *);
|
||||
|
||||
private slots:
|
||||
void emitSliderPositionChanged(const QPointF &pos);
|
||||
@ -84,6 +85,7 @@ private:
|
||||
void createXLabel();
|
||||
void createYLabel();
|
||||
void updateBounds(const QPointF &point);
|
||||
void updateSliderPosition();
|
||||
void updateSliderInfo();
|
||||
|
||||
qreal _xScale, _yScale;
|
||||
@ -101,7 +103,9 @@ private:
|
||||
SliderInfoItem *_sliderInfo;
|
||||
InfoItem *_info;
|
||||
|
||||
QList<QGraphicsPathItem*> _graphs;
|
||||
QList<GraphItem*> _graphs;
|
||||
QSet<int> _hide;
|
||||
bool _hideAll;
|
||||
QRectF _bounds;
|
||||
Palette _palette;
|
||||
};
|
||||
|
28
src/gui.cpp
28
src/gui.cpp
@ -273,15 +273,15 @@ void GUI::createActions()
|
||||
}
|
||||
|
||||
// Data actions
|
||||
_showTracksAction = new QAction(tr("Tracks"), this);
|
||||
_showTracksAction = new QAction(tr("Show tracks"), this);
|
||||
_showTracksAction->setCheckable(true);
|
||||
connect(_showTracksAction, SIGNAL(triggered(bool)), this,
|
||||
SLOT(showTracks(bool)));
|
||||
_showRoutesAction = new QAction(tr("Routes"), this);
|
||||
_showRoutesAction = new QAction(tr("Show routes"), this);
|
||||
_showRoutesAction->setCheckable(true);
|
||||
connect(_showRoutesAction, SIGNAL(triggered(bool)), this,
|
||||
SLOT(showRoutes(bool)));
|
||||
_showWaypointsAction = new QAction(tr("Waypoints"), this);
|
||||
_showWaypointsAction = new QAction(tr("Show waypoints"), this);
|
||||
_showWaypointsAction->setCheckable(true);
|
||||
connect(_showWaypointsAction, SIGNAL(triggered(bool)), _track,
|
||||
SLOT(showWaypoints(bool)));
|
||||
@ -289,7 +289,7 @@ void GUI::createActions()
|
||||
_showWaypointLabelsAction->setCheckable(true);
|
||||
connect(_showWaypointLabelsAction, SIGNAL(triggered(bool)), _track,
|
||||
SLOT(showWaypointLabels(bool)));
|
||||
_showRouteWaypointsAction = new QAction(tr("Route Waypoints"), this);
|
||||
_showRouteWaypointsAction = new QAction(tr("Route waypoints"), this);
|
||||
_showRouteWaypointsAction->setCheckable(true);
|
||||
connect(_showRouteWaypointsAction, SIGNAL(triggered(bool)), _track,
|
||||
SLOT(showRouteWaypoints(bool)));
|
||||
@ -889,12 +889,20 @@ void GUI::showFullscreen(bool checked)
|
||||
void GUI::showTracks(bool show)
|
||||
{
|
||||
_track->showTracks(show);
|
||||
|
||||
for (int i = 0; i < _tabs.size(); i++)
|
||||
_tabs.at(i)->showTracks(show);
|
||||
|
||||
updateStatusBarInfo();
|
||||
}
|
||||
|
||||
void GUI::showRoutes(bool show)
|
||||
{
|
||||
_track->showRoutes(show);
|
||||
|
||||
for (int i = 0; i < _tabs.size(); i++)
|
||||
_tabs.at(i)->showRoutes(show);
|
||||
|
||||
updateStatusBarInfo();
|
||||
}
|
||||
|
||||
@ -1251,13 +1259,17 @@ void GUI::readSettings()
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(DATA_SETTINGS_GROUP);
|
||||
if (settings.value(SHOW_TRACKS_SETTING, true).toBool() == false)
|
||||
if (settings.value(SHOW_TRACKS_SETTING, true).toBool() == false) {
|
||||
_track->showTracks(false);
|
||||
else
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
_tabs.at(i)->showTracks(false);
|
||||
} else
|
||||
_showTracksAction->setChecked(true);
|
||||
if (settings.value(SHOW_ROUTES_SETTING, true).toBool() == false)
|
||||
if (settings.value(SHOW_ROUTES_SETTING, true).toBool() == false) {
|
||||
_track->showRoutes(false);
|
||||
else
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
_tabs.at(i)->showRoutes(false);
|
||||
} else
|
||||
_showRoutesAction->setChecked(true);
|
||||
if (settings.value(SHOW_WAYPOINTS_SETTING, true).toBool() == false)
|
||||
_track->showWaypoints(false);
|
||||
|
@ -100,3 +100,15 @@ void HeartRateGraph::setUnits(enum Units units)
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
void HeartRateGraph::showTracks(bool show)
|
||||
{
|
||||
if (show)
|
||||
setInfo();
|
||||
else
|
||||
clearInfo();
|
||||
|
||||
showGraph(show);
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
@ -16,6 +16,8 @@ public:
|
||||
void loadGPX(const GPX &gpx);
|
||||
void clear();
|
||||
void setUnits(enum Units units);
|
||||
void showTracks(bool show);
|
||||
void showRoutes(bool show) {Q_UNUSED(show);}
|
||||
|
||||
private:
|
||||
qreal avg() const;
|
||||
|
@ -108,3 +108,15 @@ void SpeedGraph::setUnits(enum Units units)
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
void SpeedGraph::showTracks(bool show)
|
||||
{
|
||||
if (show)
|
||||
setInfo();
|
||||
else
|
||||
clearInfo();
|
||||
|
||||
showGraph(show);
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
@ -17,6 +17,8 @@ public:
|
||||
void loadGPX(const GPX &gpx);
|
||||
void clear();
|
||||
void setUnits(enum Units units);
|
||||
void showTracks(bool show);
|
||||
void showRoutes(bool show) {Q_UNUSED(show);}
|
||||
|
||||
private:
|
||||
qreal avg() const;
|
||||
|
@ -116,3 +116,15 @@ void TemperatureGraph::setUnits(enum Units units)
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
void TemperatureGraph::showTracks(bool show)
|
||||
{
|
||||
if (show)
|
||||
setInfo();
|
||||
else
|
||||
clearInfo();
|
||||
|
||||
showGraph(show);
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
@ -16,6 +16,8 @@ public:
|
||||
void loadGPX(const GPX &gpx);
|
||||
void clear();
|
||||
void setUnits(enum Units units);
|
||||
void showTracks(bool show);
|
||||
void showRoutes(bool show) {Q_UNUSED(show);}
|
||||
|
||||
private:
|
||||
qreal avg() const;
|
||||
|
Loading…
Reference in New Issue
Block a user