mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 11:45:53 +01:00
Optimization & code cleanup
This commit is contained in:
parent
69f9d05ccb
commit
3155e8436b
@ -34,7 +34,7 @@ void CadenceGraph::loadData(const Data &data, const QList<PathItem *> &paths)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
CadenceGraphItem *gi = new CadenceGraphItem(graph);
|
CadenceGraphItem *gi = new CadenceGraphItem(graph, _graphType);
|
||||||
GraphView::addGraph(gi, paths.at(i));
|
GraphView::addGraph(gi, paths.at(i));
|
||||||
|
|
||||||
_avg.append(QPointF(data.tracks().at(i)->distance(), gi->avg()));
|
_avg.append(QPointF(data.tracks().at(i)->distance(), gi->avg()));
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "tooltip.h"
|
#include "tooltip.h"
|
||||||
#include "cadencegraphitem.h"
|
#include "cadencegraphitem.h"
|
||||||
|
|
||||||
CadenceGraphItem::CadenceGraphItem(const Graph &graph, QGraphicsItem *parent)
|
CadenceGraphItem::CadenceGraphItem(const Graph &graph, GraphType type,
|
||||||
: GraphItem(graph, parent)
|
QGraphicsItem *parent) : GraphItem(graph, type, parent)
|
||||||
{
|
{
|
||||||
qreal sum = 0;
|
qreal sum = 0;
|
||||||
|
|
||||||
|
@ -8,7 +8,8 @@ class CadenceGraphItem : public GraphItem
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CadenceGraphItem(const Graph &graph, QGraphicsItem *parent = 0);
|
CadenceGraphItem(const Graph &graph, GraphType type,
|
||||||
|
QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
qreal max() const {return -bounds().top();}
|
qreal max() const {return -bounds().top();}
|
||||||
qreal avg() const {return _avg;}
|
qreal avg() const {return _avg;}
|
||||||
|
@ -44,7 +44,7 @@ ElevationGraph::ElevationGraph(QWidget *parent) : GraphTab(parent)
|
|||||||
_showRoutes = true;
|
_showRoutes = true;
|
||||||
_showTracks = true;
|
_showTracks = true;
|
||||||
|
|
||||||
setYUnits();
|
setYUnits(Metric);
|
||||||
setYLabel(tr("Elevation"));
|
setYLabel(tr("Elevation"));
|
||||||
setMinYRange(50.0);
|
setMinYRange(50.0);
|
||||||
}
|
}
|
||||||
@ -72,7 +72,7 @@ void ElevationGraph::loadGraph(const Graph &graph, Type type, PathItem *path)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ElevationGraphItem *gi = new ElevationGraphItem(graph);
|
ElevationGraphItem *gi = new ElevationGraphItem(graph, _graphType);
|
||||||
GraphView::addGraph(gi, path, type);
|
GraphView::addGraph(gi, path, type);
|
||||||
|
|
||||||
if (type == Track) {
|
if (type == Track) {
|
||||||
@ -116,9 +116,9 @@ void ElevationGraph::clear()
|
|||||||
GraphView::clear();
|
GraphView::clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElevationGraph::setYUnits()
|
void ElevationGraph::setYUnits(Units units)
|
||||||
{
|
{
|
||||||
if (_units == Metric) {
|
if (units == Metric) {
|
||||||
GraphView::setYUnits(tr("m"));
|
GraphView::setYUnits(tr("m"));
|
||||||
setYScale(1);
|
setYScale(1);
|
||||||
} else {
|
} else {
|
||||||
@ -127,14 +127,12 @@ void ElevationGraph::setYUnits()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElevationGraph::setUnits(enum Units units)
|
void ElevationGraph::setUnits(Units units)
|
||||||
{
|
{
|
||||||
GraphView::setUnits(units);
|
setYUnits(units);
|
||||||
|
|
||||||
setYUnits();
|
|
||||||
setInfo();
|
setInfo();
|
||||||
|
|
||||||
redraw();
|
GraphView::setUnits(units);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElevationGraph::showTracks(bool show)
|
void ElevationGraph::showTracks(bool show)
|
||||||
|
@ -25,7 +25,7 @@ private:
|
|||||||
qreal ascent() const;
|
qreal ascent() const;
|
||||||
qreal descent() const;
|
qreal descent() const;
|
||||||
|
|
||||||
void setYUnits();
|
void setYUnits(Units units);
|
||||||
void setInfo();
|
void setInfo();
|
||||||
|
|
||||||
void loadGraph(const Graph &graph, Type type, PathItem *path);
|
void loadGraph(const Graph &graph, Type type, PathItem *path);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "tooltip.h"
|
#include "tooltip.h"
|
||||||
#include "elevationgraphitem.h"
|
#include "elevationgraphitem.h"
|
||||||
|
|
||||||
ElevationGraphItem::ElevationGraphItem(const Graph &graph, QGraphicsItem *parent)
|
ElevationGraphItem::ElevationGraphItem(const Graph &graph, GraphType type,
|
||||||
: GraphItem(graph, parent)
|
QGraphicsItem *parent) : GraphItem(graph, type, parent)
|
||||||
{
|
{
|
||||||
_ascent = _descent = 0;
|
_ascent = _descent = 0;
|
||||||
|
|
||||||
|
@ -8,7 +8,8 @@ class ElevationGraphItem : public GraphItem
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ElevationGraphItem(const Graph &graph, QGraphicsItem *parent = 0);
|
ElevationGraphItem(const Graph &graph, GraphType type,
|
||||||
|
QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
qreal ascent() const {return _ascent;}
|
qreal ascent() const {return _ascent;}
|
||||||
qreal descent() const {return _descent;}
|
qreal descent() const {return _descent;}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "graphitem.h"
|
#include "graphitem.h"
|
||||||
|
|
||||||
|
|
||||||
GraphItem::GraphItem(const Graph &graph, QGraphicsItem *parent)
|
GraphItem::GraphItem(const Graph &graph, GraphType type, QGraphicsItem *parent)
|
||||||
: QGraphicsObject(parent)
|
: QGraphicsObject(parent)
|
||||||
{
|
{
|
||||||
_id = 0;
|
_id = 0;
|
||||||
@ -10,7 +10,7 @@ GraphItem::GraphItem(const Graph &graph, QGraphicsItem *parent)
|
|||||||
|
|
||||||
_pen = QPen(Qt::black, _width);
|
_pen = QPen(Qt::black, _width);
|
||||||
|
|
||||||
_type = Distance;
|
_type = type;
|
||||||
_graph = graph;
|
_graph = graph;
|
||||||
_sx = 1.0; _sy = 1.0;
|
_sx = 1.0; _sy = 1.0;
|
||||||
|
|
||||||
@ -56,6 +56,9 @@ void GraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||||||
|
|
||||||
void GraphItem::setGraphType(GraphType type)
|
void GraphItem::setGraphType(GraphType type)
|
||||||
{
|
{
|
||||||
|
if (type == _type)
|
||||||
|
return;
|
||||||
|
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
|
|
||||||
_type = type;
|
_type = type;
|
||||||
@ -66,12 +69,18 @@ void GraphItem::setGraphType(GraphType type)
|
|||||||
|
|
||||||
void GraphItem::setColor(const QColor &color)
|
void GraphItem::setColor(const QColor &color)
|
||||||
{
|
{
|
||||||
|
if (_pen.color() == color)
|
||||||
|
return;
|
||||||
|
|
||||||
_pen.setColor(color);
|
_pen.setColor(color);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphItem::setWidth(int width)
|
void GraphItem::setWidth(int width)
|
||||||
{
|
{
|
||||||
|
if (width == _width)
|
||||||
|
return;
|
||||||
|
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
|
|
||||||
_width = width;
|
_width = width;
|
||||||
|
@ -11,7 +11,7 @@ class GraphItem : public QGraphicsObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GraphItem(const Graph &graph, QGraphicsItem *parent = 0);
|
GraphItem(const Graph &graph, GraphType type, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
QPainterPath shape() const {return _shape;}
|
QPainterPath shape() const {return _shape;}
|
||||||
QRectF boundingRect() const {return _shape.boundingRect();}
|
QRectF boundingRect() const {return _shape.boundingRect();}
|
||||||
@ -19,18 +19,19 @@ public:
|
|||||||
QWidget *widget);
|
QWidget *widget);
|
||||||
|
|
||||||
const QRectF &bounds() const {return _bounds;}
|
const QRectF &bounds() const {return _bounds;}
|
||||||
void setScale(qreal sx, qreal sy);
|
|
||||||
|
|
||||||
|
void setScale(qreal sx, qreal sy);
|
||||||
void setGraphType(GraphType type);
|
void setGraphType(GraphType type);
|
||||||
int id() const {return _id;}
|
int id() const {return _id;}
|
||||||
void setId(int id) {_id = id;}
|
void setId(int id) {_id = id;}
|
||||||
void setColor(const QColor &color);
|
void setColor(const QColor &color);
|
||||||
void setWidth(int width);
|
void setWidth(int width);
|
||||||
|
virtual void setUnits(Units units) {Q_UNUSED(units);}
|
||||||
|
|
||||||
qreal yAtX(qreal x);
|
qreal yAtX(qreal x);
|
||||||
qreal distanceAtTime(qreal time);
|
qreal distanceAtTime(qreal time);
|
||||||
|
|
||||||
virtual void setUnits(Units units) {Q_UNUSED(units);}
|
void redraw();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void sliderPositionChanged(qreal);
|
void sliderPositionChanged(qreal);
|
||||||
|
@ -19,8 +19,9 @@ public:
|
|||||||
|
|
||||||
virtual QString label() const = 0;
|
virtual QString label() const = 0;
|
||||||
virtual void loadData(const Data &data, const QList<PathItem *> &paths) = 0;
|
virtual void loadData(const Data &data, const QList<PathItem *> &paths) = 0;
|
||||||
virtual void clear() {}
|
virtual void clear() {GraphView::clear();}
|
||||||
virtual void setUnits(enum Units units) {GraphView::setUnits(units);}
|
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 setTimeType(enum TimeType type) {Q_UNUSED(type)}
|
||||||
virtual void showTracks(bool show) {Q_UNUSED(show)}
|
virtual void showTracks(bool show) {Q_UNUSED(show)}
|
||||||
virtual void showRoutes(bool show) {Q_UNUSED(show)}
|
virtual void showRoutes(bool show) {Q_UNUSED(show)}
|
||||||
|
@ -145,6 +145,8 @@ void GraphView::setUnits(Units units)
|
|||||||
_graphs.at(i)->setUnits(units);
|
_graphs.at(i)->setUnits(units);
|
||||||
|
|
||||||
setXUnits();
|
setXUnits();
|
||||||
|
|
||||||
|
redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::setGraphType(GraphType type)
|
void GraphView::setGraphType(GraphType type)
|
||||||
@ -180,7 +182,6 @@ void GraphView::showSliderInfo(bool show)
|
|||||||
void GraphView::addGraph(GraphItem *graph, PathItem *path, int id)
|
void GraphView::addGraph(GraphItem *graph, PathItem *path, int id)
|
||||||
{
|
{
|
||||||
graph->setUnits(_units);
|
graph->setUnits(_units);
|
||||||
graph->setGraphType(_graphType);
|
|
||||||
graph->setId(id);
|
graph->setId(id);
|
||||||
graph->setColor(_palette.nextColor());
|
graph->setColor(_palette.nextColor());
|
||||||
graph->setWidth(_width);
|
graph->setWidth(_width);
|
||||||
@ -235,11 +236,6 @@ void GraphView::showGraph(bool show, int id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::redraw()
|
|
||||||
{
|
|
||||||
redraw(viewport()->size() - QSizeF(MARGIN, MARGIN));
|
|
||||||
}
|
|
||||||
|
|
||||||
QRectF GraphView::bounds() const
|
QRectF GraphView::bounds() const
|
||||||
{
|
{
|
||||||
QRectF br(_bounds);
|
QRectF br(_bounds);
|
||||||
@ -247,6 +243,11 @@ QRectF GraphView::bounds() const
|
|||||||
return br;
|
return br;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphView::redraw()
|
||||||
|
{
|
||||||
|
redraw(viewport()->size() - QSizeF(MARGIN, MARGIN));
|
||||||
|
}
|
||||||
|
|
||||||
void GraphView::redraw(const QSizeF &size)
|
void GraphView::redraw(const QSizeF &size)
|
||||||
{
|
{
|
||||||
QRectF r;
|
QRectF r;
|
||||||
@ -467,6 +468,8 @@ void GraphView::setGraphWidth(int width)
|
|||||||
|
|
||||||
for (int i = 0; i < _graphs.count(); i++)
|
for (int i = 0; i < _graphs.count(); i++)
|
||||||
_graphs.at(i)->setWidth(width);
|
_graphs.at(i)->setWidth(width);
|
||||||
|
|
||||||
|
redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::useOpenGL(bool use)
|
void GraphView::useOpenGL(bool use)
|
||||||
|
@ -25,19 +25,29 @@ public:
|
|||||||
GraphView(QWidget *parent = 0);
|
GraphView(QWidget *parent = 0);
|
||||||
~GraphView();
|
~GraphView();
|
||||||
|
|
||||||
void addGraph(GraphItem *graph, PathItem *path, int id = 0);
|
bool isEmpty() const {return _graphs.isEmpty();}
|
||||||
int count() const {return _graphs.count();}
|
|
||||||
void redraw();
|
|
||||||
void clear();
|
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 showGraph(bool show, int id = 0);
|
||||||
void setGraphType(GraphType type);
|
void setGraphType(GraphType type);
|
||||||
void setUnits(Units units);
|
void setUnits(Units units);
|
||||||
void showGrid(bool show);
|
|
||||||
void showSliderInfo(bool show);
|
|
||||||
|
|
||||||
void setPalette(const Palette &palette);
|
|
||||||
void setGraphWidth(int width);
|
|
||||||
|
|
||||||
const QString &yLabel() const {return _yLabel;}
|
const QString &yLabel() const {return _yLabel;}
|
||||||
const QString &yUnits() const {return _yUnits;}
|
const QString &yUnits() const {return _yUnits;}
|
||||||
@ -51,26 +61,14 @@ public:
|
|||||||
void setSliderPrecision(int precision) {_precision = precision;}
|
void setSliderPrecision(int precision) {_precision = precision;}
|
||||||
void setMinYRange(qreal range) {_minYRange = range;}
|
void setMinYRange(qreal range) {_minYRange = range;}
|
||||||
|
|
||||||
qreal sliderPosition() const {return _sliderPos;}
|
|
||||||
void setSliderPosition(qreal pos);
|
|
||||||
|
|
||||||
void plot(QPainter *painter, const QRectF &target, qreal scale);
|
|
||||||
|
|
||||||
void useOpenGL(bool use);
|
|
||||||
void useAntiAliasing(bool use);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void sliderPositionChanged(qreal);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
QRectF bounds() const;
|
QRectF bounds() const;
|
||||||
|
void redraw();
|
||||||
void redraw(const QSizeF &size);
|
void redraw(const QSizeF &size);
|
||||||
void addInfo(const QString &key, const QString &value);
|
void addInfo(const QString &key, const QString &value);
|
||||||
void clearInfo();
|
void clearInfo();
|
||||||
void skipColor() {_palette.nextColor();}
|
void skipColor() {_palette.nextColor();}
|
||||||
|
|
||||||
QList<GraphItem*> _graphs;
|
QList<GraphItem*> _graphs;
|
||||||
Units _units;
|
|
||||||
GraphType _graphType;
|
GraphType _graphType;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@ -89,6 +87,7 @@ private:
|
|||||||
void resizeEvent(QResizeEvent *);
|
void resizeEvent(QResizeEvent *);
|
||||||
void mousePressEvent(QMouseEvent *);
|
void mousePressEvent(QMouseEvent *);
|
||||||
|
|
||||||
|
Units _units;
|
||||||
qreal _xScale, _yScale;
|
qreal _xScale, _yScale;
|
||||||
qreal _yOffset;
|
qreal _yOffset;
|
||||||
QString _xUnits, _yUnits;
|
QString _xUnits, _yUnits;
|
||||||
|
16
src/gui.cpp
16
src/gui.cpp
@ -361,7 +361,7 @@ void GUI::createActions()
|
|||||||
tr("Load map..."), this);
|
tr("Load map..."), this);
|
||||||
connect(_loadMapAction, SIGNAL(triggered()), this, SLOT(loadMap()));
|
connect(_loadMapAction, SIGNAL(triggered()), this, SLOT(loadMap()));
|
||||||
_clearMapCacheAction = new QAction(tr("Clear tile cache"), this);
|
_clearMapCacheAction = new QAction(tr("Clear tile cache"), this);
|
||||||
connect(_clearMapCacheAction, SIGNAL(triggered()), this,
|
connect(_clearMapCacheAction, SIGNAL(triggered()), _pathView,
|
||||||
SLOT(clearMapCache()));
|
SLOT(clearMapCache()));
|
||||||
createMapActions();
|
createMapActions();
|
||||||
_nextMapAction = new QAction(tr("Next map"), this);
|
_nextMapAction = new QAction(tr("Next map"), this);
|
||||||
@ -1022,7 +1022,7 @@ void GUI::plot(QPrinter *printer)
|
|||||||
|
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
for (int i = 0; i < _tabs.size(); i++)
|
for (int i = 0; i < _tabs.size(); i++)
|
||||||
if (_tabs.at(i)->count())
|
if (!_tabs.at(i)->isEmpty())
|
||||||
cnt++;
|
cnt++;
|
||||||
|
|
||||||
qreal sp = ratio * 20;
|
qreal sp = ratio * 20;
|
||||||
@ -1031,7 +1031,7 @@ void GUI::plot(QPrinter *printer)
|
|||||||
|
|
||||||
qreal y = 0;
|
qreal y = 0;
|
||||||
for (int i = 0; i < _tabs.size(); i++) {
|
for (int i = 0; i < _tabs.size(); i++) {
|
||||||
if (_tabs.at(i)->count()) {
|
if (!_tabs.at(i)->isEmpty()) {
|
||||||
_tabs.at(i)->plot(&p, QRectF(0, y, printer->width(), gh),
|
_tabs.at(i)->plot(&p, QRectF(0, y, printer->width(), gh),
|
||||||
ratio);
|
ratio);
|
||||||
y += gh + sp;
|
y += gh + sp;
|
||||||
@ -1217,12 +1217,6 @@ void GUI::loadMap()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::clearMapCache()
|
|
||||||
{
|
|
||||||
_map->clearCache();
|
|
||||||
_pathView->redraw();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GUI::updateStatusBarInfo()
|
void GUI::updateStatusBarInfo()
|
||||||
{
|
{
|
||||||
if (_files.count() == 0)
|
if (_files.count() == 0)
|
||||||
@ -1334,13 +1328,13 @@ void GUI::updateGraphTabs()
|
|||||||
|
|
||||||
for (int i = 0; i < _tabs.size(); i++) {
|
for (int i = 0; i < _tabs.size(); i++) {
|
||||||
tab = _tabs.at(i);
|
tab = _tabs.at(i);
|
||||||
if (!tab->count() && (index = _graphTabWidget->indexOf(tab)) >= 0)
|
if (tab->isEmpty() && (index = _graphTabWidget->indexOf(tab)) >= 0)
|
||||||
_graphTabWidget->removeTab(index);
|
_graphTabWidget->removeTab(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < _tabs.size(); i++) {
|
for (int i = 0; i < _tabs.size(); i++) {
|
||||||
tab = _tabs.at(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());
|
_graphTabWidget->insertTab(i, tab, _tabs.at(i)->label());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,6 @@ private slots:
|
|||||||
void showTracks(bool show);
|
void showTracks(bool show);
|
||||||
void showRoutes(bool show);
|
void showRoutes(bool show);
|
||||||
void loadMap();
|
void loadMap();
|
||||||
void clearMapCache();
|
|
||||||
void nextMap();
|
void nextMap();
|
||||||
void prevMap();
|
void prevMap();
|
||||||
void openOptions();
|
void openOptions();
|
||||||
|
@ -34,7 +34,7 @@ void HeartRateGraph::loadData(const Data &data, const QList<PathItem *> &paths)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
HeartRateGraphItem *gi = new HeartRateGraphItem(graph);
|
HeartRateGraphItem *gi = new HeartRateGraphItem(graph, _graphType);
|
||||||
GraphView::addGraph(gi, paths.at(i));
|
GraphView::addGraph(gi, paths.at(i));
|
||||||
|
|
||||||
_avg.append(QPointF(data.tracks().at(i)->distance(), gi->avg()));
|
_avg.append(QPointF(data.tracks().at(i)->distance(), gi->avg()));
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "tooltip.h"
|
#include "tooltip.h"
|
||||||
#include "heartrategraphitem.h"
|
#include "heartrategraphitem.h"
|
||||||
|
|
||||||
HeartRateGraphItem::HeartRateGraphItem(const Graph &graph, QGraphicsItem *parent)
|
HeartRateGraphItem::HeartRateGraphItem(const Graph &graph, GraphType type,
|
||||||
: GraphItem(graph, parent)
|
QGraphicsItem *parent) : GraphItem(graph, type, parent)
|
||||||
{
|
{
|
||||||
qreal sum = 0;
|
qreal sum = 0;
|
||||||
|
|
||||||
|
@ -8,7 +8,8 @@ class HeartRateGraphItem : public GraphItem
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HeartRateGraphItem(const Graph &graph, QGraphicsItem *parent = 0);
|
HeartRateGraphItem(const Graph &graph, GraphType type,
|
||||||
|
QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
qreal max() const {return -bounds().top();}
|
qreal max() const {return -bounds().top();}
|
||||||
qreal avg() const {return _avg;}
|
qreal avg() const {return _avg;}
|
||||||
|
@ -56,13 +56,21 @@ OnlineMap::OnlineMap(const QString &name, const QString &url,
|
|||||||
_zooms = zooms;
|
_zooms = zooms;
|
||||||
_zoom = zooms.max();
|
_zoom = zooms.max();
|
||||||
|
|
||||||
connect(downloader, SIGNAL(finished()), this, SLOT(emitLoaded()));
|
|
||||||
|
|
||||||
QString path = TILES_DIR + QString("/") + name;
|
QString path = TILES_DIR + QString("/") + name;
|
||||||
if (!QDir().mkpath(path))
|
if (!QDir().mkpath(path))
|
||||||
qWarning("Error creating tiles dir: %s\n", qPrintable(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)
|
void OnlineMap::fillTile(Tile &tile)
|
||||||
{
|
{
|
||||||
tile.pixmap() = QPixmap(TILE_SIZE, TILE_SIZE);
|
tile.pixmap() = QPixmap(TILE_SIZE, TILE_SIZE);
|
||||||
|
@ -37,6 +37,9 @@ public:
|
|||||||
static void setDownloader(Downloader *downloader)
|
static void setDownloader(Downloader *downloader)
|
||||||
{OnlineMap::downloader = downloader;}
|
{OnlineMap::downloader = downloader;}
|
||||||
|
|
||||||
|
void load();
|
||||||
|
void unload();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void emitLoaded();
|
void emitLoaded();
|
||||||
|
|
||||||
|
@ -66,9 +66,10 @@ void PathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||||||
|
|
||||||
void PathItem::setMap(Map *map)
|
void PathItem::setMap(Map *map)
|
||||||
{
|
{
|
||||||
_map = map;
|
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
|
|
||||||
|
_map = map;
|
||||||
|
|
||||||
updatePainterPath(map);
|
updatePainterPath(map);
|
||||||
updateShape();
|
updateShape();
|
||||||
|
|
||||||
@ -77,12 +78,18 @@ void PathItem::setMap(Map *map)
|
|||||||
|
|
||||||
void PathItem::setColor(const QColor &color)
|
void PathItem::setColor(const QColor &color)
|
||||||
{
|
{
|
||||||
|
if (_pen.color() == color)
|
||||||
|
return;
|
||||||
|
|
||||||
_pen.setColor(color);
|
_pen.setColor(color);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathItem::setWidth(qreal width)
|
void PathItem::setWidth(qreal width)
|
||||||
{
|
{
|
||||||
|
if (_width == width)
|
||||||
|
return;
|
||||||
|
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
|
|
||||||
_width = width;
|
_width = width;
|
||||||
@ -93,12 +100,18 @@ void PathItem::setWidth(qreal width)
|
|||||||
|
|
||||||
void PathItem::setStyle(Qt::PenStyle style)
|
void PathItem::setStyle(Qt::PenStyle style)
|
||||||
{
|
{
|
||||||
|
if (_pen.style() == style)
|
||||||
|
return;
|
||||||
|
|
||||||
_pen.setStyle(style);
|
_pen.setStyle(style);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathItem::setDigitalZoom(int zoom)
|
void PathItem::setDigitalZoom(int zoom)
|
||||||
{
|
{
|
||||||
|
if (_digitalZoom == zoom)
|
||||||
|
return;
|
||||||
|
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
|
|
||||||
_digitalZoom = zoom;
|
_digitalZoom = zoom;
|
||||||
|
@ -44,7 +44,7 @@ PathView::PathView(Map *map, POI *poi, QWidget *parent)
|
|||||||
|
|
||||||
_map = map;
|
_map = map;
|
||||||
_poi = poi;
|
_poi = poi;
|
||||||
connect(_map, SIGNAL(loaded()), this, SLOT(redraw()));
|
connect(_map, SIGNAL(loaded()), this, SLOT(reloadMap()));
|
||||||
connect(_poi, SIGNAL(pointsChanged()), this, SLOT(updatePOI()));
|
connect(_poi, SIGNAL(pointsChanged()), this, SLOT(updatePOI()));
|
||||||
|
|
||||||
_units = Metric;
|
_units = Metric;
|
||||||
@ -269,11 +269,11 @@ void PathView::setMap(Map *map)
|
|||||||
qreal resolution = _map->resolution(pos);
|
qreal resolution = _map->resolution(pos);
|
||||||
|
|
||||||
_map->unload();
|
_map->unload();
|
||||||
disconnect(_map, SIGNAL(loaded()), this, SLOT(redraw()));
|
disconnect(_map, SIGNAL(loaded()), this, SLOT(reloadMap()));
|
||||||
|
|
||||||
_map = map;
|
_map = map;
|
||||||
_map->load();
|
_map->load();
|
||||||
connect(_map, SIGNAL(loaded()), this, SLOT(redraw()));
|
connect(_map, SIGNAL(loaded()), this, SLOT(reloadMap()));
|
||||||
|
|
||||||
resetDigitalZoom();
|
resetDigitalZoom();
|
||||||
|
|
||||||
@ -366,8 +366,9 @@ void PathView::setUnits(enum Units units)
|
|||||||
it.value()->setUnits(units);
|
it.value()->setUnits(units);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathView::redraw()
|
void PathView::clearMapCache()
|
||||||
{
|
{
|
||||||
|
_map->clearCache();
|
||||||
resetCachedContent();
|
resetCachedContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -795,3 +796,8 @@ void PathView::useAntiAliasing(bool use)
|
|||||||
{
|
{
|
||||||
setRenderHint(QPainter::Antialiasing, use);
|
setRenderHint(QPainter::Antialiasing, use);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PathView::reloadMap()
|
||||||
|
{
|
||||||
|
resetCachedContent();
|
||||||
|
}
|
||||||
|
@ -58,8 +58,6 @@ public:
|
|||||||
void useAntiAliasing(bool use);
|
void useAntiAliasing(bool use);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void redraw();
|
|
||||||
|
|
||||||
void showMap(bool show);
|
void showMap(bool show);
|
||||||
void showPOI(bool show);
|
void showPOI(bool show);
|
||||||
void setPOIOverlap(bool overlap);
|
void setPOIOverlap(bool overlap);
|
||||||
@ -69,9 +67,11 @@ public slots:
|
|||||||
void showRoutes(bool show);
|
void showRoutes(bool show);
|
||||||
void showWaypoints(bool show);
|
void showWaypoints(bool show);
|
||||||
void showRouteWaypoints(bool show);
|
void showRouteWaypoints(bool show);
|
||||||
|
void clearMapCache();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updatePOI();
|
void updatePOI();
|
||||||
|
void reloadMap();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PathItem *addTrack(const Track &track);
|
PathItem *addTrack(const Track &track);
|
||||||
|
@ -34,7 +34,7 @@ void PowerGraph::loadData(const Data &data, const QList<PathItem *> &paths)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
PowerGraphItem *gi = new PowerGraphItem(graph);
|
PowerGraphItem *gi = new PowerGraphItem(graph, _graphType);
|
||||||
GraphView::addGraph(gi, paths.at(i));
|
GraphView::addGraph(gi, paths.at(i));
|
||||||
|
|
||||||
_avg.append(QPointF(data.tracks().at(i)->distance(), gi->avg()));
|
_avg.append(QPointF(data.tracks().at(i)->distance(), gi->avg()));
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "tooltip.h"
|
#include "tooltip.h"
|
||||||
#include "powergraphitem.h"
|
#include "powergraphitem.h"
|
||||||
|
|
||||||
PowerGraphItem::PowerGraphItem(const Graph &graph, QGraphicsItem *parent)
|
PowerGraphItem::PowerGraphItem(const Graph &graph, GraphType type,
|
||||||
: GraphItem(graph, parent)
|
QGraphicsItem *parent) : GraphItem(graph, type, parent)
|
||||||
{
|
{
|
||||||
qreal sum = 0;
|
qreal sum = 0;
|
||||||
|
|
||||||
|
@ -8,7 +8,8 @@ class PowerGraphItem : public GraphItem
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PowerGraphItem(const Graph &graph, QGraphicsItem *parent = 0);
|
PowerGraphItem(const Graph &graph, GraphType type,
|
||||||
|
QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
qreal max() const {return -bounds().top();}
|
qreal max() const {return -bounds().top();}
|
||||||
qreal avg() const {return _avg;}
|
qreal avg() const {return _avg;}
|
||||||
|
@ -10,7 +10,7 @@ SpeedGraph::SpeedGraph(QWidget *parent) : GraphTab(parent)
|
|||||||
_timeType = Total;
|
_timeType = Total;
|
||||||
_showTracks = true;
|
_showTracks = true;
|
||||||
|
|
||||||
setYUnits();
|
setYUnits(Metric);
|
||||||
setYLabel(tr("Speed"));
|
setYLabel(tr("Speed"));
|
||||||
|
|
||||||
setSliderPrecision(1);
|
setSliderPrecision(1);
|
||||||
@ -38,7 +38,8 @@ void SpeedGraph::loadData(const Data &data, const QList<PathItem *> &paths)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpeedGraphItem *gi = new SpeedGraphItem(graph, track->movingTime());
|
SpeedGraphItem *gi = new SpeedGraphItem(graph, _graphType,
|
||||||
|
track->movingTime());
|
||||||
gi->setTimeType(_timeType);
|
gi->setTimeType(_timeType);
|
||||||
GraphView::addGraph(gi, paths.at(i));
|
GraphView::addGraph(gi, paths.at(i));
|
||||||
|
|
||||||
@ -76,9 +77,9 @@ void SpeedGraph::clear()
|
|||||||
GraphView::clear();
|
GraphView::clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpeedGraph::setYUnits()
|
void SpeedGraph::setYUnits(Units units)
|
||||||
{
|
{
|
||||||
if (_units == Metric) {
|
if (units == Metric) {
|
||||||
GraphView::setYUnits(tr("km/h"));
|
GraphView::setYUnits(tr("km/h"));
|
||||||
setYScale(MS2KMH);
|
setYScale(MS2KMH);
|
||||||
} else {
|
} else {
|
||||||
@ -87,14 +88,12 @@ void SpeedGraph::setYUnits()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpeedGraph::setUnits(enum Units units)
|
void SpeedGraph::setUnits(Units units)
|
||||||
{
|
{
|
||||||
GraphView::setUnits(units);
|
setYUnits(units);
|
||||||
|
|
||||||
setYUnits();
|
|
||||||
setInfo();
|
setInfo();
|
||||||
|
|
||||||
redraw();
|
GraphView::setUnits(units);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpeedGraph::setTimeType(enum TimeType type)
|
void SpeedGraph::setTimeType(enum TimeType type)
|
||||||
|
@ -21,7 +21,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
qreal avg() const;
|
qreal avg() const;
|
||||||
qreal max() const {return bounds().bottom();}
|
qreal max() const {return bounds().bottom();}
|
||||||
void setYUnits();
|
void setYUnits(Units units);
|
||||||
void setInfo();
|
void setInfo();
|
||||||
|
|
||||||
QList<QPointF> _avg;
|
QList<QPointF> _avg;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "tooltip.h"
|
#include "tooltip.h"
|
||||||
#include "speedgraphitem.h"
|
#include "speedgraphitem.h"
|
||||||
|
|
||||||
SpeedGraphItem::SpeedGraphItem(const Graph &graph, qreal movingTime,
|
SpeedGraphItem::SpeedGraphItem(const Graph &graph, GraphType type,
|
||||||
QGraphicsItem *parent) : GraphItem(graph, parent)
|
qreal movingTime, QGraphicsItem *parent) : GraphItem(graph, type, parent)
|
||||||
{
|
{
|
||||||
_units = Metric;
|
_units = Metric;
|
||||||
_timeType = Total;
|
_timeType = Total;
|
||||||
|
@ -9,7 +9,7 @@ class SpeedGraphItem : public GraphItem
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SpeedGraphItem(const Graph &graph, qreal movingTime,
|
SpeedGraphItem(const Graph &graph, GraphType type, qreal movingTime,
|
||||||
QGraphicsItem *parent = 0);
|
QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
qreal max() const {return -bounds().top();}
|
qreal max() const {return -bounds().top();}
|
||||||
|
@ -7,7 +7,7 @@ TemperatureGraph::TemperatureGraph(QWidget *parent) : GraphTab(parent)
|
|||||||
{
|
{
|
||||||
_showTracks = true;
|
_showTracks = true;
|
||||||
|
|
||||||
setYUnits();
|
setYUnits(Metric);
|
||||||
setYLabel(tr("Temperature"));
|
setYLabel(tr("Temperature"));
|
||||||
|
|
||||||
setSliderPrecision(1);
|
setSliderPrecision(1);
|
||||||
@ -36,7 +36,7 @@ void TemperatureGraph::loadData(const Data &data, const QList<PathItem *> &paths
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
TemperatureGraphItem *gi = new TemperatureGraphItem(graph);
|
TemperatureGraphItem *gi = new TemperatureGraphItem(graph, _graphType);
|
||||||
GraphView::addGraph(gi, paths.at(i));
|
GraphView::addGraph(gi, paths.at(i));
|
||||||
|
|
||||||
_avg.append(QPointF(data.tracks().at(i)->distance(), gi->avg()));
|
_avg.append(QPointF(data.tracks().at(i)->distance(), gi->avg()));
|
||||||
@ -70,9 +70,9 @@ void TemperatureGraph::clear()
|
|||||||
GraphView::clear();
|
GraphView::clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TemperatureGraph::setYUnits()
|
void TemperatureGraph::setYUnits(Units units)
|
||||||
{
|
{
|
||||||
if (_units == Metric) {
|
if (units == Metric) {
|
||||||
GraphView::setYUnits(QChar(0x00B0) + tr("C"));
|
GraphView::setYUnits(QChar(0x00B0) + tr("C"));
|
||||||
setYScale(1);
|
setYScale(1);
|
||||||
setYOffset(0);
|
setYOffset(0);
|
||||||
@ -83,14 +83,12 @@ void TemperatureGraph::setYUnits()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TemperatureGraph::setUnits(enum Units units)
|
void TemperatureGraph::setUnits(Units units)
|
||||||
{
|
{
|
||||||
GraphView::setUnits(units);
|
setYUnits(units);
|
||||||
|
|
||||||
setYUnits();
|
|
||||||
setInfo();
|
setInfo();
|
||||||
|
|
||||||
redraw();
|
GraphView::setUnits(units);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TemperatureGraph::showTracks(bool show)
|
void TemperatureGraph::showTracks(bool show)
|
||||||
|
@ -20,7 +20,7 @@ private:
|
|||||||
qreal avg() const;
|
qreal avg() const;
|
||||||
qreal min() const {return bounds().top();}
|
qreal min() const {return bounds().top();}
|
||||||
qreal max() const {return bounds().bottom();}
|
qreal max() const {return bounds().bottom();}
|
||||||
void setYUnits();
|
void setYUnits(Units units);
|
||||||
void setInfo();
|
void setInfo();
|
||||||
|
|
||||||
QList<QPointF> _avg;
|
QList<QPointF> _avg;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "tooltip.h"
|
#include "tooltip.h"
|
||||||
#include "temperaturegraphitem.h"
|
#include "temperaturegraphitem.h"
|
||||||
|
|
||||||
TemperatureGraphItem::TemperatureGraphItem(const Graph &graph,
|
TemperatureGraphItem::TemperatureGraphItem(const Graph &graph, GraphType type,
|
||||||
QGraphicsItem *parent) : GraphItem(graph, parent)
|
QGraphicsItem *parent) : GraphItem(graph, type, parent)
|
||||||
{
|
{
|
||||||
qreal sum = 0;
|
qreal sum = 0;
|
||||||
|
|
||||||
|
@ -8,7 +8,8 @@ class TemperatureGraphItem : public GraphItem
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TemperatureGraphItem(const Graph &graph, QGraphicsItem *parent = 0);
|
TemperatureGraphItem(const Graph &graph, GraphType type,
|
||||||
|
QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
qreal max() const {return -bounds().top();}
|
qreal max() const {return -bounds().top();}
|
||||||
qreal min() const {return -bounds().bottom();}
|
qreal min() const {return -bounds().bottom();}
|
||||||
|
Loading…
Reference in New Issue
Block a user