mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
switch RideFile::dataPoints to QVector
...so that we can binary search within them. Also, switch a lot of QListIterators to Qt foreach.
This commit is contained in:
@@ -519,9 +519,7 @@ AllPlot::setData(RideItem *_rideItem)
|
||||
if (!altArray.empty()) altCurve->attach(this);
|
||||
|
||||
arrayLength = 0;
|
||||
QListIterator<RideFilePoint*> i(ride->dataPoints());
|
||||
while (i.hasNext()) {
|
||||
RideFilePoint *point = i.next();
|
||||
foreach (const RideFilePoint *point, ride->dataPoints()) {
|
||||
timeArray[arrayLength] = point->secs;
|
||||
if (!wattsArray.empty())
|
||||
wattsArray[arrayLength] = max(0, point->watts);
|
||||
|
||||
@@ -115,9 +115,7 @@ BestIntervalDialog::findClicked()
|
||||
int expectedSamples = (int) floor(windowSizeSecs / secsDelta);
|
||||
double totalWatts = 0.0;
|
||||
|
||||
QListIterator<RideFilePoint*> i(ride->dataPoints());
|
||||
while (i.hasNext()) {
|
||||
const RideFilePoint *point = i.next();
|
||||
foreach (const RideFilePoint *point, ride->dataPoints()) {
|
||||
while (!window.empty()
|
||||
&& (point->secs >= window.first()->secs + windowSizeSecs)) {
|
||||
totalWatts -= window.first()->watts;
|
||||
|
||||
@@ -102,11 +102,8 @@ class XPower : public RideMetric {
|
||||
*/
|
||||
|
||||
|
||||
QListIterator<RideFilePoint*> i(ride->dataPoints());
|
||||
|
||||
int count = 0;
|
||||
while (i.hasNext()) {
|
||||
const RideFilePoint *point = i.next();
|
||||
foreach (const RideFilePoint *point, ride->dataPoints()) {
|
||||
|
||||
// if there are missing data then add in the contribution
|
||||
// from the exponentially decaying smoothed power
|
||||
@@ -205,9 +202,7 @@ class BikeScore : public RideMetric {
|
||||
return;
|
||||
if (ride->deviceType() == QString("Manual CSV")) {
|
||||
// manual entry, use BS from dataPoints
|
||||
QListIterator<RideFilePoint*> i(ride->dataPoints());
|
||||
const RideFilePoint *point = i.next();
|
||||
score = point->bs;
|
||||
score = ride->dataPoints().first()->bs;
|
||||
}
|
||||
else {
|
||||
assert(deps.contains("skiba_xpower"));
|
||||
|
||||
@@ -120,9 +120,7 @@ update_cpi_file(const cpi_file_info *info, QProgressDialog *progress,
|
||||
return;
|
||||
cpint_data data;
|
||||
data.rec_int_ms = (int) round(rideFile->recIntSecs() * 1000.0);
|
||||
QListIterator<RideFilePoint*> i(rideFile->dataPoints());
|
||||
while (i.hasNext()) {
|
||||
const RideFilePoint *p = i.next();
|
||||
foreach (const RideFilePoint *p, rideFile->dataPoints()) {
|
||||
double secs = round(p->secs * 1000.0) / 1000;
|
||||
if (secs > 0)
|
||||
data.points.append(cpint_point(secs, (int) round(p->watts)));
|
||||
|
||||
@@ -301,9 +301,7 @@ PfPvPlot::setData(RideItem *_rideItem)
|
||||
long tot_cad_points = 0;
|
||||
|
||||
|
||||
QListIterator<RideFilePoint*> i(ride->dataPoints());
|
||||
while (i.hasNext()) {
|
||||
const RideFilePoint *p1 = i.next();
|
||||
foreach(const RideFilePoint *p1, ride->dataPoints()) {
|
||||
|
||||
if (p1->watts != 0 && p1->cad != 0) {
|
||||
double aepf = (p1->watts * 60.0) / (p1->cad * cl_ * 2.0 * PI);
|
||||
|
||||
@@ -397,14 +397,11 @@ PowerHist::setData(RideItem *_rideItem)
|
||||
kphArray.resize(0);
|
||||
cadArray.resize(0);
|
||||
|
||||
QListIterator<RideFilePoint*> j(ride->dataPoints());
|
||||
|
||||
// unit conversion factor for imperial units for selected parameters
|
||||
double torque_factor = (useMetricUnits ? 1.0 : 0.73756215);
|
||||
double speed_factor = (useMetricUnits ? 1.0 : 0.62137119);
|
||||
|
||||
while (j.hasNext()) {
|
||||
const RideFilePoint *p1 = j.next();
|
||||
foreach(const RideFilePoint *p1, ride->dataPoints()) {
|
||||
|
||||
int wattsIndex = int(floor(p1->watts / wattsDelta));
|
||||
if (wattsIndex >= 0 && wattsIndex < maxSize) {
|
||||
|
||||
@@ -39,9 +39,7 @@ void RideFile::writeAsCsv(QFile &file, bool bIsMetric) const
|
||||
convertUnit = 1.0;
|
||||
}
|
||||
|
||||
QListIterator<RideFilePoint*> i(dataPoints());
|
||||
while (i.hasNext()) {
|
||||
RideFilePoint *point = i.next();
|
||||
foreach (const RideFilePoint *point, dataPoints()) {
|
||||
if (point->secs == 0.0)
|
||||
continue;
|
||||
out << point->secs/60.0;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <QFile>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include <QVector>
|
||||
|
||||
// This file defines four classes:
|
||||
//
|
||||
@@ -68,7 +69,7 @@ class RideFile
|
||||
|
||||
QDateTime startTime_; // time of day that the ride started
|
||||
double recIntSecs_; // recording interval in seconds
|
||||
QList<RideFilePoint*> dataPoints_;
|
||||
QVector<RideFilePoint*> dataPoints_;
|
||||
RideFileDataPresent dataPresent;
|
||||
QString deviceType_;
|
||||
|
||||
@@ -80,14 +81,13 @@ class RideFile
|
||||
deviceType_("unknown") {}
|
||||
|
||||
virtual ~RideFile() {
|
||||
QListIterator<RideFilePoint*> i(dataPoints_);
|
||||
while (i.hasNext())
|
||||
delete i.next();
|
||||
foreach(RideFilePoint *point, dataPoints_)
|
||||
delete point;
|
||||
}
|
||||
|
||||
const QDateTime &startTime() const { return startTime_; }
|
||||
double recIntSecs() const { return recIntSecs_; }
|
||||
const QList<RideFilePoint*> dataPoints() const { return dataPoints_; }
|
||||
const QVector<RideFilePoint*> dataPoints() const { return dataPoints_; }
|
||||
inline const RideFileDataPresent *areDataPresent() const { return &dataPresent; }
|
||||
const QString &deviceType() const { return deviceType_; }
|
||||
|
||||
|
||||
@@ -300,10 +300,7 @@ RideItem::htmlSummary()
|
||||
|
||||
double time_start, time_end, km_start, km_end, int_dur;
|
||||
|
||||
QListIterator<RideFilePoint*> i(ride->dataPoints());
|
||||
while (i.hasNext()) {
|
||||
RideFilePoint *point = i.next();
|
||||
|
||||
foreach (const RideFilePoint *point, ride->dataPoints()) {
|
||||
double secs_delta = ride->recIntSecs();
|
||||
|
||||
if (point->interval != last_interval) {
|
||||
|
||||
@@ -48,11 +48,8 @@ struct RideMetric {
|
||||
struct PointwiseRideMetric : public RideMetric {
|
||||
void compute(const RideFile *ride, const Zones *zones, int zoneRange,
|
||||
const QHash<QString,RideMetric*> &) {
|
||||
QListIterator<RideFilePoint*> i(ride->dataPoints());
|
||||
while (i.hasNext()) {
|
||||
const RideFilePoint *point = i.next();
|
||||
foreach (const RideFilePoint *point, ride->dataPoints())
|
||||
perPoint(point, ride->recIntSecs(), ride, zones, zoneRange);
|
||||
}
|
||||
}
|
||||
virtual void perPoint(const RideFilePoint *point, double secsDelta,
|
||||
const RideFile *ride, const Zones *zones,
|
||||
|
||||
@@ -86,9 +86,8 @@ SplitRideDialog::SplitRideDialog(MainWindow *mainWindow)
|
||||
int nDataPoint = 0;
|
||||
const RideFile *ride = mainWindow->currentRide();
|
||||
|
||||
for (QListIterator<RideFilePoint*> i(ride->dataPoints()); i.hasNext(); ++nDataPoint)
|
||||
foreach (const RideFilePoint *point, ride->dataPoints())
|
||||
{
|
||||
const RideFilePoint *point = i.next();
|
||||
if (dLastSeconds>=0 &&
|
||||
((point->secs-dLastSeconds)>=30 || nLastInterval!=point->interval))
|
||||
{
|
||||
@@ -110,6 +109,7 @@ SplitRideDialog::SplitRideDialog(MainWindow *mainWindow)
|
||||
|
||||
dLastSeconds = point->secs;
|
||||
nLastInterval = point->interval;
|
||||
++nDataPoint;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user