mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 03:35:53 +01:00
Added distance & time info
This commit is contained in:
parent
7e2b27acf1
commit
da42f3ab33
@ -34,12 +34,12 @@
|
|||||||
<translation>Klesání</translation>
|
<translation>Klesání</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/elevationgraph.cpp" line="47"/>
|
<location filename="../src/elevationgraph.cpp" line="48"/>
|
||||||
<source>Minimum</source>
|
<source>Minimum</source>
|
||||||
<translation>Minimum</translation>
|
<translation>Minimum</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/elevationgraph.cpp" line="48"/>
|
<location filename="../src/elevationgraph.cpp" line="47"/>
|
||||||
<source>Maximum</source>
|
<source>Maximum</source>
|
||||||
<translation>Maximum</translation>
|
<translation>Maximum</translation>
|
||||||
</message>
|
</message>
|
||||||
@ -47,118 +47,123 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>GUI</name>
|
<name>GUI</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="70"/>
|
<location filename="../src/gui.cpp" line="84"/>
|
||||||
<source>About Qt</source>
|
<source>About Qt</source>
|
||||||
<translation>O Qt</translation>
|
<translation>O Qt</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="181"/>
|
<location filename="../src/gui.cpp" line="198"/>
|
||||||
<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>
|
<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>
|
<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>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="189"/>
|
<location filename="../src/gui.cpp" line="206"/>
|
||||||
<source>Open file</source>
|
<source>Open file</source>
|
||||||
<translation>Otevřít soubor</translation>
|
<translation>Otevřít soubor</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="84"/>
|
<location filename="../src/gui.cpp" line="98"/>
|
||||||
<source>Save as</source>
|
<source>Save as</source>
|
||||||
<translation>Uložit jako</translation>
|
<translation>Uložit jako</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="239"/>
|
<location filename="../src/gui.cpp" line="261"/>
|
||||||
<source>Open POI file</source>
|
<source>Open POI file</source>
|
||||||
<translation>Otevřít POI soubor</translation>
|
<translation>Otevřít POI soubor</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="75"/>
|
<location filename="../src/gui.cpp" line="89"/>
|
||||||
<source>Open</source>
|
<source>Open</source>
|
||||||
<translation>Otevřít</translation>
|
<translation>Otevřít</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="63"/>
|
<location filename="../src/gui.cpp" line="77"/>
|
||||||
<source>Quit</source>
|
<source>Quit</source>
|
||||||
<translation>Ukončit</translation>
|
<translation>Ukončit</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="79"/>
|
<location filename="../src/gui.cpp" line="93"/>
|
||||||
<source>Save</source>
|
<source>Save</source>
|
||||||
<translation>Uložit</translation>
|
<translation>Uložit</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="89"/>
|
<location filename="../src/gui.cpp" line="103"/>
|
||||||
<source>Close</source>
|
<source>Close</source>
|
||||||
<translation>Zavřít</translation>
|
<translation>Zavřít</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="96"/>
|
<location filename="../src/gui.cpp" line="110"/>
|
||||||
<source>Load file</source>
|
<source>Load file</source>
|
||||||
<translation>Nahrát soubor</translation>
|
<translation>Nahrát soubor</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="99"/>
|
<location filename="../src/gui.cpp" line="113"/>
|
||||||
<source>Show</source>
|
<source>Show</source>
|
||||||
<translation>Zobrazit</translation>
|
<translation>Zobrazit</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="106"/>
|
<location filename="../src/gui.cpp" line="120"/>
|
||||||
<location filename="../src/gui.cpp" line="129"/>
|
<location filename="../src/gui.cpp" line="143"/>
|
||||||
<source>File</source>
|
<source>File</source>
|
||||||
<translation>Soubor</translation>
|
<translation>Soubor</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="118"/>
|
<location filename="../src/gui.cpp" line="132"/>
|
||||||
<location filename="../src/gui.cpp" line="137"/>
|
<location filename="../src/gui.cpp" line="151"/>
|
||||||
<source>POI</source>
|
<source>POI</source>
|
||||||
<translation>POI</translation>
|
<translation>POI</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="122"/>
|
<location filename="../src/gui.cpp" line="136"/>
|
||||||
<source>Help</source>
|
<source>Help</source>
|
||||||
<translation>Nápověda</translation>
|
<translation>Nápověda</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="155"/>
|
<location filename="../src/gui.cpp" line="169"/>
|
||||||
<source>Elevation</source>
|
<source>Elevation</source>
|
||||||
<translation>Výška</translation>
|
<translation>Výška</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="156"/>
|
<location filename="../src/gui.cpp" line="170"/>
|
||||||
<source>Speed</source>
|
<source>Speed</source>
|
||||||
<translation>Rychlost</translation>
|
<translation>Rychlost</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="68"/>
|
<location filename="../src/gui.cpp" line="82"/>
|
||||||
<location filename="../src/gui.cpp" line="178"/>
|
<location filename="../src/gui.cpp" line="195"/>
|
||||||
<source>About GPXSee</source>
|
<source>About GPXSee</source>
|
||||||
<translation>O aplikaci GPXSee</translation>
|
<translation>O aplikaci GPXSee</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="180"/>
|
<location filename="../src/gui.cpp" line="197"/>
|
||||||
<source>GPX viewer and analyzer</source>
|
<source>GPX viewer and analyzer</source>
|
||||||
<translation>Prohlížeč a analyzátor GPX</translation>
|
<translation>Prohlížeč a analyzátor GPX</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="223"/>
|
<location filename="../src/gui.cpp" line="240"/>
|
||||||
<source>%1 tracks</source>
|
<source>%1 tracks</source>
|
||||||
<translation>Počet tras: %1</translation>
|
<translation>Počet tras: %1</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="229"/>
|
<location filename="../src/gui.cpp" line="245"/>
|
||||||
<location filename="../src/gui.cpp" line="243"/>
|
<source>km</source>
|
||||||
|
<translation>km</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/gui.cpp" line="251"/>
|
||||||
|
<location filename="../src/gui.cpp" line="265"/>
|
||||||
<source>Error</source>
|
<source>Error</source>
|
||||||
<translation>Chyba</translation>
|
<translation>Chyba</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="230"/>
|
<location filename="../src/gui.cpp" line="252"/>
|
||||||
<source>Error loading GPX file:
|
<source>Error loading GPX file:
|
||||||
%1</source>
|
%1</source>
|
||||||
<translation>Soubor GPX nelze otevřít:
|
<translation>Soubor GPX nelze otevřít:
|
||||||
%1</translation>
|
%1</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="244"/>
|
<location filename="../src/gui.cpp" line="266"/>
|
||||||
<source>Error loading POI file:
|
<source>Error loading POI file:
|
||||||
%1</source>
|
%1</source>
|
||||||
<translation>Soubor POI nelze otevřít:
|
<translation>Soubor POI nelze otevřít:
|
||||||
|
24
src/gpx.cpp
24
src/gpx.cpp
@ -29,16 +29,15 @@ bool GPX::loadFile(const QString &fileName)
|
|||||||
|
|
||||||
void GPX::elevationGraph(QVector<QPointF> &graph) const
|
void GPX::elevationGraph(QVector<QPointF> &graph) const
|
||||||
{
|
{
|
||||||
qreal dist = 0, ds, dh, acc;
|
qreal dist = 0, dh, acc;
|
||||||
|
|
||||||
if (!_data.size())
|
if (!_data.size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
graph.append(QPointF(0, _data.at(0).elevation));
|
graph.append(QPointF(0, _data.at(0).elevation));
|
||||||
for (int i = 1; i < _data.size(); i++) {
|
for (int i = 1; i < _data.size(); i++) {
|
||||||
ds = llDistance(_data.at(i).coordinates, _data.at(i-1).coordinates);
|
dist += llDistance(_data.at(i).coordinates, _data.at(i-1).coordinates);
|
||||||
dh = _data.at(i).elevation;
|
dh = _data.at(i).elevation;
|
||||||
dist += ds;
|
|
||||||
acc = (i == 1) ? dh : (ALPHA_E * dh) + (1.0 - ALPHA_E) * acc;
|
acc = (i == 1) ? dh : (ALPHA_E * dh) + (1.0 - ALPHA_E) * acc;
|
||||||
graph.append(QPointF(dist, acc));
|
graph.append(QPointF(dist, acc));
|
||||||
}
|
}
|
||||||
@ -73,3 +72,22 @@ void GPX::track(QVector<QPointF> &track) const
|
|||||||
track.append(p);
|
track.append(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qreal GPX::distance()
|
||||||
|
{
|
||||||
|
qreal dist = 0;
|
||||||
|
|
||||||
|
for (int i = 1; i < _data.size(); i++)
|
||||||
|
dist += llDistance(_data.at(i).coordinates, _data.at(i-1).coordinates);
|
||||||
|
|
||||||
|
return dist;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal GPX::time()
|
||||||
|
{
|
||||||
|
if (_data.size() < 2)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return (_data.at(0).timestamp.msecsTo(_data.at(_data.size() - 1).timestamp)
|
||||||
|
/ 1000.0);
|
||||||
|
}
|
||||||
|
@ -15,6 +15,8 @@ public:
|
|||||||
void elevationGraph(QVector<QPointF> &graph) const;
|
void elevationGraph(QVector<QPointF> &graph) const;
|
||||||
void speedGraph(QVector<QPointF> &graph) const;
|
void speedGraph(QVector<QPointF> &graph) const;
|
||||||
void track(QVector<QPointF> &track) const;
|
void track(QVector<QPointF> &track) const;
|
||||||
|
qreal distance();
|
||||||
|
qreal time();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Parser _parser;
|
Parser _parser;
|
||||||
|
42
src/gui.cpp
42
src/gui.cpp
@ -20,6 +20,18 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
|
static QString timeSpan(qreal time)
|
||||||
|
{
|
||||||
|
unsigned h, m, s;
|
||||||
|
|
||||||
|
h = time / 3600;
|
||||||
|
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'));
|
||||||
|
}
|
||||||
|
|
||||||
GUI::GUI()
|
GUI::GUI()
|
||||||
{
|
{
|
||||||
createActions();
|
createActions();
|
||||||
@ -47,6 +59,8 @@ GUI::GUI()
|
|||||||
|
|
||||||
_dirIndex = -1;
|
_dirIndex = -1;
|
||||||
_files = 0;
|
_files = 0;
|
||||||
|
_distance = 0;
|
||||||
|
_time = 0;
|
||||||
|
|
||||||
resize(600, 800);
|
resize(600, 800);
|
||||||
}
|
}
|
||||||
@ -164,12 +178,15 @@ void GUI::createTrackGraphs()
|
|||||||
|
|
||||||
void GUI::createStatusBar()
|
void GUI::createStatusBar()
|
||||||
{
|
{
|
||||||
_fileName = new QLabel();
|
_fileNameLabel = new QLabel();
|
||||||
_zoom = new QLabel();
|
_distanceLabel = new QLabel();
|
||||||
_zoom->setAlignment(Qt::AlignHCenter);
|
_timeLabel = new QLabel();
|
||||||
|
_distanceLabel->setAlignment(Qt::AlignHCenter);
|
||||||
|
_timeLabel->setAlignment(Qt::AlignHCenter);
|
||||||
|
|
||||||
statusBar()->addPermanentWidget(_fileName, 9);
|
statusBar()->addPermanentWidget(_fileNameLabel, 8);
|
||||||
statusBar()->addPermanentWidget(_zoom, 1);
|
statusBar()->addPermanentWidget(_distanceLabel, 1);
|
||||||
|
statusBar()->addPermanentWidget(_timeLabel, 1);
|
||||||
statusBar()->setSizeGripEnabled(false);
|
statusBar()->setSizeGripEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,9 +237,14 @@ bool GUI::openFile(const QString &fileName)
|
|||||||
_fileActionGroup->setEnabled(true);
|
_fileActionGroup->setEnabled(true);
|
||||||
|
|
||||||
if (++_files > 1)
|
if (++_files > 1)
|
||||||
_fileName->setText(tr("%1 tracks").arg(_files));
|
_fileNameLabel->setText(tr("%1 tracks").arg(_files));
|
||||||
else
|
else
|
||||||
_fileName->setText(fileName);
|
_fileNameLabel->setText(fileName);
|
||||||
|
_distance += gpx.distance();
|
||||||
|
_distanceLabel->setText(QString::number(_distance / 1000, 'f', 1)
|
||||||
|
+ " " + tr("km"));
|
||||||
|
_time += gpx.time();
|
||||||
|
_timeLabel->setText(timeSpan(_time));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -289,11 +311,15 @@ void GUI::saveFile(const QString &fileName)
|
|||||||
void GUI::closeFile()
|
void GUI::closeFile()
|
||||||
{
|
{
|
||||||
_files = 0;
|
_files = 0;
|
||||||
|
_distance = 0;
|
||||||
|
_time = 0;
|
||||||
|
|
||||||
_elevationGraph->clear();
|
_elevationGraph->clear();
|
||||||
_speedGraph->clear();
|
_speedGraph->clear();
|
||||||
_track->clear();
|
_track->clear();
|
||||||
_fileName->clear();
|
_fileNameLabel->clear();
|
||||||
|
_distanceLabel->clear();
|
||||||
|
_timeLabel->clear();
|
||||||
|
|
||||||
_fileActionGroup->setEnabled(false);
|
_fileActionGroup->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
@ -68,8 +68,9 @@ private:
|
|||||||
QAction *_openPOIAction;
|
QAction *_openPOIAction;
|
||||||
QAction *_showPOIAction;
|
QAction *_showPOIAction;
|
||||||
|
|
||||||
QLabel *_fileName;
|
QLabel *_fileNameLabel;
|
||||||
QLabel *_zoom;
|
QLabel *_distanceLabel;
|
||||||
|
QLabel *_timeLabel;
|
||||||
|
|
||||||
ElevationGraph *_elevationGraph;
|
ElevationGraph *_elevationGraph;
|
||||||
SpeedGraph *_speedGraph;
|
SpeedGraph *_speedGraph;
|
||||||
@ -82,6 +83,9 @@ private:
|
|||||||
|
|
||||||
QString _saveFileName;
|
QString _saveFileName;
|
||||||
unsigned _files;
|
unsigned _files;
|
||||||
|
|
||||||
|
qreal _distance;
|
||||||
|
qreal _time;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GUI_H
|
#endif // GUI_H
|
||||||
|
Loading…
Reference in New Issue
Block a user