diff --git a/src/GUI/cadencegraph.cpp b/src/GUI/cadencegraph.cpp index b41f9715..e754f0de 100644 --- a/src/GUI/cadencegraph.cpp +++ b/src/GUI/cadencegraph.cpp @@ -47,7 +47,7 @@ QList CadenceGraph::loadData(const Data &data) const Track &track = data.tracks().at(i); const Graph &graph = track.cadence(); - if (!graph.isValid()) { + if (graph.isEmpty()) { _palette.nextColor(); graphs.append(0); } else { diff --git a/src/GUI/elevationgraph.cpp b/src/GUI/elevationgraph.cpp index bda29c27..734fd660 100644 --- a/src/GUI/elevationgraph.cpp +++ b/src/GUI/elevationgraph.cpp @@ -85,7 +85,7 @@ void ElevationGraph::setInfo() GraphItem *ElevationGraph::loadGraph(const Graph &graph, PathType type, const QColor &color, bool primary) { - if (!graph.isValid()) + if (graph.isEmpty()) return 0; ElevationGraphItem *gi = new ElevationGraphItem(graph, _graphType, _width, diff --git a/src/GUI/gearratiograph.cpp b/src/GUI/gearratiograph.cpp index ca7ef726..62e0ba1a 100644 --- a/src/GUI/gearratiograph.cpp +++ b/src/GUI/gearratiograph.cpp @@ -50,7 +50,7 @@ QList GearRatioGraph::loadData(const Data &data) for (int i = 0; i < data.tracks().count(); i++) { const Graph &graph = data.tracks().at(i).ratio(); - if (!graph.isValid()) { + if (graph.isEmpty()) { _palette.nextColor(); graphs.append(0); } else { diff --git a/src/GUI/graphitem.cpp b/src/GUI/graphitem.cpp index 13c372fa..dd820713 100644 --- a/src/GUI/graphitem.cpp +++ b/src/GUI/graphitem.cpp @@ -8,8 +8,6 @@ GraphItem::GraphItem(const Graph &graph, GraphType type, int width, const QColor &color, Qt::PenStyle style, QGraphicsItem *parent) : GraphicsItem(parent), _graph(graph), _type(type), _secondaryGraph(0) { - Q_ASSERT(_graph.isValid()); - _units = Metric; _sx = 0; _sy = 0; _color = color; diff --git a/src/GUI/heartrategraph.cpp b/src/GUI/heartrategraph.cpp index 5dc1d09a..7e23602e 100644 --- a/src/GUI/heartrategraph.cpp +++ b/src/GUI/heartrategraph.cpp @@ -47,7 +47,7 @@ QList HeartRateGraph::loadData(const Data &data) const Track &track = data.tracks().at(i); const Graph &graph = track.heartRate(); - if (!graph.isValid()) { + if (graph.isEmpty()) { _palette.nextColor(); graphs.append(0); } else { diff --git a/src/GUI/powergraph.cpp b/src/GUI/powergraph.cpp index f6c8f70d..b48b9cc7 100644 --- a/src/GUI/powergraph.cpp +++ b/src/GUI/powergraph.cpp @@ -47,7 +47,7 @@ QList PowerGraph::loadData(const Data &data) const Track &track = data.tracks().at(i); const Graph &graph = track.power(); - if (!graph.isValid()) { + if (graph.isEmpty()) { _palette.nextColor(); graphs.append(0); } else { diff --git a/src/GUI/speedgraph.cpp b/src/GUI/speedgraph.cpp index 6d4287ba..2f9c1574 100644 --- a/src/GUI/speedgraph.cpp +++ b/src/GUI/speedgraph.cpp @@ -50,7 +50,7 @@ void SpeedGraph::setInfo() GraphItem *SpeedGraph::loadGraph(const Graph &graph, const Track &track, const QColor &color, bool primary) { - if (!graph.isValid()) + if (graph.isEmpty()) return 0; SpeedGraphItem *gi = new SpeedGraphItem(graph, _graphType, _width, diff --git a/src/GUI/temperaturegraph.cpp b/src/GUI/temperaturegraph.cpp index af64503b..97ec630f 100644 --- a/src/GUI/temperaturegraph.cpp +++ b/src/GUI/temperaturegraph.cpp @@ -51,7 +51,7 @@ QList TemperatureGraph::loadData(const Data &data) const Track &track = data.tracks().at(i); const Graph &graph = track.temperature(); - if (!graph.isValid()) { + if (graph.isEmpty()) { _palette.nextColor(); graphs.append(0); } else { diff --git a/src/data/graph.h b/src/data/graph.h index 7860ff13..f5177596 100644 --- a/src/data/graph.h +++ b/src/data/graph.h @@ -46,16 +46,6 @@ typedef QVector GraphSegment; class Graph : public QList { public: - bool isValid() const - { - if (isEmpty()) - return false; - for (int i = 0; i < size(); i++) - if (at(i).size() < 2) - return false; - return true; - } - bool hasTime() const { for (int i = 0; i < size(); i++) { diff --git a/src/data/route.cpp b/src/data/route.cpp index 92b80761..252e6a88 100644 --- a/src/data/route.cpp +++ b/src/data/route.cpp @@ -68,16 +68,14 @@ GraphPair Route::elevation() const { if (_useDEM) { Graph dem(demElevation()); - if (dem.isValid()) - return GraphPair(dem, _show2ndElevation ? gpsElevation() : Graph()); - else - return GraphPair(gpsElevation(), Graph()); + return (dem.isEmpty()) + ? GraphPair(gpsElevation(), Graph()) + : GraphPair(dem, _show2ndElevation ? gpsElevation() : Graph()); } else { Graph gps(gpsElevation()); - if (gps.isValid()) - return GraphPair(gps, _show2ndElevation ? demElevation() : Graph()); - else - return GraphPair(demElevation(), Graph()); + return (gps.isEmpty()) + ? GraphPair(gps, _show2ndElevation ? demElevation() : Graph()) + : GraphPair(demElevation(), Graph()); } } diff --git a/src/data/track.cpp b/src/data/track.cpp index 9c32e495..331584af 100644 --- a/src/data/track.cpp +++ b/src/data/track.cpp @@ -266,7 +266,8 @@ Graph Track::gpsElevation() const sd.at(j).elevation())); } - ret.append(filter(gs, _elevationWindow)); + if (gs.size() >= 2) + ret.append(filter(gs, _elevationWindow)); } if (_data.style().color().isValid()) @@ -293,7 +294,8 @@ Graph Track::demElevation() const gs.append(GraphPoint(seg.distance.at(j), seg.time.at(j), dem)); } - ret.append(filter(gs, _elevationWindow)); + if (gs.size() >= 2) + ret.append(filter(gs, _elevationWindow)); } if (_data.style().color().isValid()) @@ -306,16 +308,14 @@ GraphPair Track::elevation() const { if (_useDEM) { Graph dem(demElevation()); - if (dem.isValid()) - return GraphPair(dem, _show2ndElevation ? gpsElevation() : Graph()); - else - return GraphPair(gpsElevation(), Graph()); + return (dem.isEmpty()) + ? GraphPair(gpsElevation(), Graph()) + : GraphPair(dem, _show2ndElevation ? gpsElevation() : Graph()); } else { Graph gps(gpsElevation()); - if (gps.isValid()) - return GraphPair(gps, _show2ndElevation ? demElevation() : Graph()); - else - return GraphPair(demElevation(), Graph()); + return (gps.isEmpty()) + ? GraphPair(demElevation(), Graph()) + : GraphPair(gps, _show2ndElevation ? demElevation() : Graph()); } } @@ -344,11 +344,13 @@ Graph Track::computedSpeed() const gs.append(GraphPoint(seg.distance.at(j), seg.time.at(j), v)); } - ret.append(filter(gs, _speedWindow)); - GraphSegment &filtered = ret.last(); + if (gs.size() >= 2) { + ret.append(filter(gs, _speedWindow)); + GraphSegment &filtered = ret.last(); - for (int j = 0; j < stop.size(); j++) - filtered[stop.at(j)].setY(0); + for (int j = 0; j < stop.size(); j++) + filtered[stop.at(j)].setY(0); + } } if (_data.style().color().isValid()) @@ -382,11 +384,13 @@ Graph Track::reportedSpeed() const gs.append(GraphPoint(seg.distance.at(j), seg.time.at(j), v)); } - ret.append(filter(gs, _speedWindow)); - GraphSegment &filtered = ret.last(); + if (gs.size() >= 2) { + ret.append(filter(gs, _speedWindow)); + GraphSegment &filtered = ret.last(); - for (int j = 0; j < stop.size(); j++) - filtered[stop.at(j)].setY(0); + for (int j = 0; j < stop.size(); j++) + filtered[stop.at(j)].setY(0); + } } if (_data.style().color().isValid()) @@ -399,18 +403,14 @@ GraphPair Track::speed() const { if (_useReportedSpeed) { Graph reported(reportedSpeed()); - if (reported.isValid()) - return GraphPair(reported, _show2ndSpeed ? computedSpeed() - : Graph()); - else - return GraphPair(computedSpeed(), Graph()); + return (reported.isEmpty()) + ? GraphPair(computedSpeed(), Graph()) + : GraphPair(reported, _show2ndSpeed ? computedSpeed() : Graph()); } else { Graph computed(computedSpeed()); - if (computed.isValid()) - return GraphPair(computed, _show2ndSpeed ? reportedSpeed() - : Graph()); - else - return GraphPair(reportedSpeed(), Graph()); + return (computed.isEmpty()) + ? GraphPair(reportedSpeed(), Graph()) + : GraphPair(computed, _show2ndSpeed ? reportedSpeed() : Graph()); } } @@ -430,7 +430,8 @@ Graph Track::heartRate() const gs.append(GraphPoint(seg.distance.at(j), seg.time.at(j), sd.at(j).heartRate())); - ret.append(filter(gs, _heartRateWindow)); + if (gs.size() >= 2) + ret.append(filter(gs, _heartRateWindow)); } if (_data.style().color().isValid()) @@ -456,7 +457,8 @@ Graph Track::temperature() const sd.at(j).temperature())); } - ret.append(gs); + if (gs.size() >= 2) + ret.append(gs); } if (_data.style().color().isValid()) @@ -481,7 +483,8 @@ Graph Track::ratio() const gs.append(GraphPoint(seg.distance.at(j), seg.time.at(j), sd.at(j).ratio())); - ret.append(gs); + if (gs.size() >= 2) + ret.append(gs); } if (_data.style().color().isValid()) @@ -515,11 +518,13 @@ Graph Track::cadence() const gs.append(GraphPoint(seg.distance.at(j), seg.time.at(j), c)); } - ret.append(filter(gs, _cadenceWindow)); - GraphSegment &filtered = ret.last(); + if (gs.size() >= 2) { + ret.append(filter(gs, _cadenceWindow)); + GraphSegment &filtered = ret.last(); - for (int j = 0; j < stop.size(); j++) - filtered[stop.at(j)].setY(0); + for (int j = 0; j < stop.size(); j++) + filtered[stop.at(j)].setY(0); + } } if (_data.style().color().isValid()) @@ -554,11 +559,13 @@ Graph Track::power() const gs.append(GraphPoint(seg.distance.at(j), seg.time.at(j), p)); } - ret.append(filter(gs, _powerWindow)); - GraphSegment &filtered = ret.last(); + if (gs.size() >= 2) { + ret.append(filter(gs, _powerWindow)); + GraphSegment &filtered = ret.last(); - for (int j = 0; j < stop.size(); j++) - filtered[stop.at(j)].setY(0); + for (int j = 0; j < stop.size(); j++) + filtered[stop.at(j)].setY(0); + } } if (_data.style().color().isValid())