diff --git a/src/AllPlot.cpp b/src/AllPlot.cpp index 0c43fef89..158ebc278 100644 --- a/src/AllPlot.cpp +++ b/src/AllPlot.cpp @@ -2393,6 +2393,7 @@ AllPlot::setDataFromPlots(QList plots) compares.clear(); double MAXY = -100; + double MINY = 0; // add all the curves int index=0; @@ -2591,6 +2592,7 @@ AllPlot::setDataFromPlots(QList plots) ourCurve->setBaseline(thereCurve->baseline()); if (ourCurve->maxYValue() > MAXY) MAXY = ourCurve->maxYValue(); + if (ourCurve->minYValue() < MINY) MINY = ourCurve->minYValue(); // symbol when zoomed in super close if (array.size() < 150) { @@ -2628,6 +2630,7 @@ AllPlot::setDataFromPlots(QList plots) ourCurve2->setBaseline(thereCurve2->baseline()); if (ourCurve2->maxYValue() > MAXY) MAXY = ourCurve2->maxYValue(); + if (ourCurve2->minYValue() < MINY) MINY = ourCurve2->minYValue(); // symbol when zoomed in super close if (array.size() < 150) { @@ -2684,7 +2687,7 @@ AllPlot::setDataFromPlots(QList plots) setAxisScaleDraw(QwtPlot::yLeft, sd); // set the y-axis for largest value we saw +10% - setAxisScale(QwtPlot::yLeft, 0, MAXY * 1.10f); + setAxisScale(QwtPlot::yLeft, MINY * 1.10f , MAXY * 1.10f); // hide other y axes setAxisVisible(QwtAxisId(QwtAxis::yLeft, 1), false); diff --git a/src/RideFileCache.cpp b/src/RideFileCache.cpp index be2a81ce0..2bc05117a 100644 --- a/src/RideFileCache.cpp +++ b/src/RideFileCache.cpp @@ -44,6 +44,7 @@ RideFileCache::RideFileCache(Context *context, QString fileName, RideFile *passe cadMeanMax.resize(0); nmMeanMax.resize(0); kphMeanMax.resize(0); + kphdMeanMax.resize(0); xPowerMeanMax.resize(0); npMeanMax.resize(0); vamMeanMax.resize(0); @@ -54,6 +55,7 @@ RideFileCache::RideFileCache(Context *context, QString fileName, RideFile *passe cadDistribution.resize(0); nmDistribution.resize(0); kphDistribution.resize(0); + kphdDistribution.resize(0); xPowerDistribution.resize(0); npDistribution.resize(0); wattsKgDistribution.resize(0); @@ -127,6 +129,7 @@ RideFileCache::RideFileCache(RideFile *ride) : cadMeanMax.resize(0); nmMeanMax.resize(0); kphMeanMax.resize(0); + kphdMeanMax.resize(0); xPowerMeanMax.resize(0); npMeanMax.resize(0); vamMeanMax.resize(0); @@ -137,6 +140,7 @@ RideFileCache::RideFileCache(RideFile *ride) : cadDistribution.resize(0); nmDistribution.resize(0); kphDistribution.resize(0); + kphdDistribution.resize(0); xPowerDistribution.resize(0); npDistribution.resize(0); wattsKgDistribution.resize(0); @@ -158,6 +162,7 @@ RideFileCache::RideFileCache(RideFile *ride) : doubleArray(cadMeanMaxDouble, cadMeanMax, RideFile::cad); doubleArray(nmMeanMaxDouble, nmMeanMax, RideFile::nm); doubleArray(kphMeanMaxDouble, kphMeanMax, RideFile::kph); + doubleArray(kphdMeanMaxDouble, kphdMeanMax, RideFile::kphd); doubleArray(npMeanMaxDouble, npMeanMax, RideFile::NP); doubleArray(vamMeanMaxDouble, vamMeanMax, RideFile::vam); doubleArray(xPowerMeanMaxDouble, xPowerMeanMax, RideFile::xPower); @@ -169,6 +174,7 @@ RideFileCache::RideFileCache(RideFile *ride) : doubleArray(cadDistributionDouble, cadDistribution, RideFile::cad); doubleArray(nmDistributionDouble, nmDistribution, RideFile::nm); doubleArray(kphDistributionDouble, kphDistribution, RideFile::kph); + doubleArray(kphdDistributionDouble, kphdDistribution, RideFile::kphd); doubleArray(xPowerDistributionDouble, xPowerDistribution, RideFile::xPower); doubleArray(npDistributionDouble, npDistribution, RideFile::NP); doubleArray(wattsKgDistributionDouble, wattsKgDistribution, RideFile::wattsKg); @@ -184,6 +190,7 @@ RideFileCache::decimalsFor(RideFile::SeriesType series) case RideFile::hr : return 0; break; case RideFile::km : return 3; break; case RideFile::kph : return 1; break; + case RideFile::kphd : return 3; break; case RideFile::nm : return 2; break; case RideFile::watts : return 0; break; case RideFile::xPower : return 0; break; @@ -233,6 +240,10 @@ RideFileCache::meanMaxDates(RideFile::SeriesType series) return kphMeanMaxDate; break; + case RideFile::kphd: + return kphdMeanMaxDate; + break; + case RideFile::xPower: return xPowerMeanMaxDate; break; @@ -285,6 +296,10 @@ RideFileCache::meanMaxArray(RideFile::SeriesType series) return kphMeanMaxDouble; break; + case RideFile::kphd: + return kphdMeanMaxDouble; + break; + case RideFile::xPower: return xPowerMeanMaxDouble; break; @@ -337,6 +352,10 @@ RideFileCache::distributionArray(RideFile::SeriesType series) return kphDistributionDouble; break; + case RideFile::kphd: + return kphdDistributionDouble; + break; + case RideFile::aPower: return aPowerDistributionDouble; break; @@ -429,6 +448,7 @@ void RideFileCache::RideFileCache::compute() MeanMaxComputer thread3(ride, cadMeanMax, RideFile::cad); thread3.start(); MeanMaxComputer thread4(ride, nmMeanMax, RideFile::nm); thread4.start(); MeanMaxComputer thread5(ride, kphMeanMax, RideFile::kph); thread5.start(); + MeanMaxComputer thread11(ride, kphdMeanMax, RideFile::kphd); thread11.start(); MeanMaxComputer thread6(ride, xPowerMeanMax, RideFile::xPower); thread6.start(); MeanMaxComputer thread7(ride, npMeanMax, RideFile::NP); thread7.start(); MeanMaxComputer thread8(ride, vamMeanMax, RideFile::vam); thread8.start(); @@ -441,6 +461,7 @@ void RideFileCache::RideFileCache::compute() computeDistribution(cadDistribution, RideFile::cad); computeDistribution(nmDistribution, RideFile::nm); computeDistribution(kphDistribution, RideFile::kph); + computeDistribution(kphdDistribution, RideFile::kphd); computeDistribution(wattsKgDistribution, RideFile::wattsKg); computeDistribution(aPowerDistribution, RideFile::aPower); @@ -455,6 +476,7 @@ void RideFileCache::RideFileCache::compute() thread8.wait(); thread9.wait(); thread10.wait(); + thread11.wait(); } //---------------------------------------------------------------------- @@ -1014,6 +1036,7 @@ RideFileCache::RideFileCache(Context *context, QDate start, QDate end, bool filt cadMeanMax.resize(0); nmMeanMax.resize(0); kphMeanMax.resize(0); + kphdMeanMax.resize(0); xPowerMeanMax.resize(0); npMeanMax.resize(0); vamMeanMax.resize(0); @@ -1024,6 +1047,7 @@ RideFileCache::RideFileCache(Context *context, QDate start, QDate end, bool filt cadDistribution.resize(0); nmDistribution.resize(0); kphDistribution.resize(0); + kphdDistribution.resize(0); xPowerDistribution.resize(0); npDistribution.resize(0); wattsKgDistribution.resize(0); @@ -1058,6 +1082,7 @@ RideFileCache::RideFileCache(Context *context, QDate start, QDate end, bool filt meanMaxAggregate(cadMeanMaxDouble, rideCache.cadMeanMaxDouble, cadMeanMaxDate, rideDate); meanMaxAggregate(nmMeanMaxDouble, rideCache.nmMeanMaxDouble, nmMeanMaxDate, rideDate); meanMaxAggregate(kphMeanMaxDouble, rideCache.kphMeanMaxDouble, kphMeanMaxDate, rideDate); + meanMaxAggregate(kphdMeanMaxDouble, rideCache.kphdMeanMaxDouble, kphdMeanMaxDate, rideDate); meanMaxAggregate(xPowerMeanMaxDouble, rideCache.xPowerMeanMaxDouble, xPowerMeanMaxDate, rideDate); meanMaxAggregate(npMeanMaxDouble, rideCache.npMeanMaxDouble, npMeanMaxDate, rideDate); meanMaxAggregate(vamMeanMaxDouble, rideCache.vamMeanMaxDouble, vamMeanMaxDate, rideDate); @@ -1069,6 +1094,7 @@ RideFileCache::RideFileCache(Context *context, QDate start, QDate end, bool filt distAggregate(cadDistributionDouble, rideCache.cadDistributionDouble); distAggregate(nmDistributionDouble, rideCache.nmDistributionDouble); distAggregate(kphDistributionDouble, rideCache.kphDistributionDouble); + distAggregate(kphdDistributionDouble, rideCache.kphdDistributionDouble); distAggregate(xPowerDistributionDouble, rideCache.xPowerDistributionDouble); distAggregate(npDistributionDouble, rideCache.npDistributionDouble); distAggregate(wattsKgDistributionDouble, rideCache.wattsKgDistributionDouble); @@ -1116,6 +1142,7 @@ RideFileCache::serialize(QDataStream *out) head.cadMeanMaxCount = cadMeanMax.size(); head.nmMeanMaxCount = nmMeanMax.size(); head.kphMeanMaxCount = kphMeanMax.size(); + head.kphdMeanMaxCount = kphdMeanMax.size(); head.xPowerMeanMaxCount = xPowerMeanMax.size(); head.npMeanMaxCount = npMeanMax.size(); head.vamMeanMaxCount = vamMeanMax.size(); @@ -1128,6 +1155,7 @@ RideFileCache::serialize(QDataStream *out) head.cadDistCount = cadDistribution.size(); head.nmDistrCount = nmDistribution.size(); head.kphDistCount = kphDistribution.size(); + head.kphdDistCount = kphdDistribution.size(); head.wattsKgDistCount = wattsKgDistribution.size(); head.aPowerDistCount = aPowerDistribution.size(); @@ -1139,6 +1167,7 @@ RideFileCache::serialize(QDataStream *out) out->writeRawData((const char *) cadMeanMax.data(), sizeof(float) * cadMeanMax.size()); out->writeRawData((const char *) nmMeanMax.data(), sizeof(float) * nmMeanMax.size()); out->writeRawData((const char *) kphMeanMax.data(), sizeof(float) * kphMeanMax.size()); + out->writeRawData((const char *) kphdMeanMax.data(), sizeof(float) * kphdMeanMax.size()); out->writeRawData((const char *) xPowerMeanMax.data(), sizeof(float) * xPowerMeanMax.size()); out->writeRawData((const char *) npMeanMax.data(), sizeof(float) * npMeanMax.size()); out->writeRawData((const char *) vamMeanMax.data(), sizeof(float) * vamMeanMax.size()); @@ -1151,6 +1180,7 @@ RideFileCache::serialize(QDataStream *out) out->writeRawData((const char *) cadDistribution.data(), sizeof(float) * cadDistribution.size()); out->writeRawData((const char *) nmDistribution.data(), sizeof(float) * nmDistribution.size()); out->writeRawData((const char *) kphDistribution.data(), sizeof(float) * kphDistribution.size()); + out->writeRawData((const char *) kphdDistribution.data(), sizeof(float) * kphdDistribution.size()); out->writeRawData((const char *) xPowerDistribution.data(), sizeof(float) * xPowerDistribution.size()); out->writeRawData((const char *) npDistribution.data(), sizeof(float) * npDistribution.size()); out->writeRawData((const char *) wattsKgDistribution.data(), sizeof(float) * wattsKgDistribution.size()); @@ -1179,6 +1209,7 @@ RideFileCache::readCache() cadMeanMax.resize(head.cadMeanMaxCount); nmMeanMax.resize(head.nmMeanMaxCount); kphMeanMax.resize(head.kphMeanMaxCount); + kphdMeanMax.resize(head.kphdMeanMaxCount); npMeanMax.resize(head.npMeanMaxCount); vamMeanMax.resize(head.vamMeanMaxCount); xPowerMeanMax.resize(head.xPowerMeanMaxCount); @@ -1190,6 +1221,7 @@ RideFileCache::readCache() cadDistribution.resize(head.cadDistCount); nmDistribution.resize(head.nmDistrCount); kphDistribution.resize(head.kphDistCount); + kphdDistribution.resize(head.kphdDistCount); xPowerDistribution.resize(head.xPowerDistCount); npDistribution.resize(head.npDistCount); wattsKgDistribution.resize(head.wattsKgDistCount); @@ -1201,6 +1233,7 @@ RideFileCache::readCache() inFile.readRawData((char *) cadMeanMax.data(), sizeof(float) * cadMeanMax.size()); inFile.readRawData((char *) nmMeanMax.data(), sizeof(float) * nmMeanMax.size()); inFile.readRawData((char *) kphMeanMax.data(), sizeof(float) * kphMeanMax.size()); + inFile.readRawData((char *) kphdMeanMax.data(), sizeof(float) * kphdMeanMax.size()); inFile.readRawData((char *) xPowerMeanMax.data(), sizeof(float) * xPowerMeanMax.size()); inFile.readRawData((char *) npMeanMax.data(), sizeof(float) * npMeanMax.size()); inFile.readRawData((char *) vamMeanMax.data(), sizeof(float) * vamMeanMax.size()); @@ -1214,6 +1247,7 @@ RideFileCache::readCache() inFile.readRawData((char *) cadDistribution.data(), sizeof(float) * cadDistribution.size()); inFile.readRawData((char *) nmDistribution.data(), sizeof(float) * nmDistribution.size()); inFile.readRawData((char *) kphDistribution.data(), sizeof(float) * kphDistribution.size()); + inFile.readRawData((char *) kphdDistribution.data(), sizeof(float) * kphdDistribution.size()); inFile.readRawData((char *) xPowerDistribution.data(), sizeof(float) * xPowerDistribution.size()); inFile.readRawData((char *) npDistribution.data(), sizeof(float) * npDistribution.size()); inFile.readRawData((char *) wattsKgDistribution.data(), sizeof(float) * wattsKgDistribution.size()); @@ -1230,6 +1264,7 @@ RideFileCache::readCache() doubleArray(cadMeanMaxDouble, cadMeanMax, RideFile::cad); doubleArray(nmMeanMaxDouble, nmMeanMax, RideFile::nm); doubleArray(kphMeanMaxDouble, kphMeanMax, RideFile::kph); + doubleArray(kphdMeanMaxDouble, kphdMeanMax, RideFile::kphd); doubleArray(npMeanMaxDouble, npMeanMax, RideFile::NP); doubleArray(vamMeanMaxDouble, vamMeanMax, RideFile::vam); doubleArray(xPowerMeanMaxDouble, xPowerMeanMax, RideFile::xPower); @@ -1241,6 +1276,7 @@ RideFileCache::readCache() doubleArray(cadDistributionDouble, cadDistribution, RideFile::cad); doubleArray(nmDistributionDouble, nmDistribution, RideFile::nm); doubleArray(kphDistributionDouble, kphDistribution, RideFile::kph); + doubleArray(kphdDistributionDouble, kphdDistribution, RideFile::kphd); doubleArray(xPowerDistributionDouble, xPowerDistribution, RideFile::xPower); doubleArray(npDistributionDouble, npDistribution, RideFile::NP); doubleArray(wattsKgDistributionDouble, wattsKgDistribution, RideFile::wattsKg); @@ -1271,6 +1307,7 @@ static long offsetForMeanMax(RideFileCacheHeader head, RideFile::SeriesType seri case RideFile::vam : offset += head.npMeanMaxCount * sizeof(float); case RideFile::NP : offset += head.xPowerMeanMaxCount * sizeof(float); case RideFile::xPower : offset += head.kphMeanMaxCount * sizeof(float); + case RideFile::kphd : offset += head.kphdMeanMaxCount * sizeof(float); case RideFile::kph : offset += head.nmMeanMaxCount * sizeof(float); case RideFile::nm : offset += head.cadMeanMaxCount * sizeof(float); case RideFile::cad : offset += head.hrMeanMaxCount * sizeof(float); @@ -1294,6 +1331,7 @@ static long offsetForTiz(RideFileCacheHeader head, RideFile::SeriesType series) offset += head.vamMeanMaxCount * sizeof(float); offset += head.npMeanMaxCount * sizeof(float); offset += head.xPowerMeanMaxCount * sizeof(float); + offset += head.kphdMeanMaxCount * sizeof(float); offset += head.kphMeanMaxCount * sizeof(float); offset += head.nmMeanMaxCount * sizeof(float); offset += head.cadMeanMaxCount * sizeof(float); @@ -1306,6 +1344,7 @@ static long offsetForTiz(RideFileCacheHeader head, RideFile::SeriesType series) offset += head.cadDistCount * sizeof(float); offset += head.nmDistrCount * sizeof(float); offset += head.kphDistCount * sizeof(float); + offset += head.kphdDistCount * sizeof(float); offset += head.xPowerDistCount * sizeof(float); offset += head.npDistCount * sizeof(float); offset += head.wattsKgDistCount * sizeof(float); @@ -1328,6 +1367,7 @@ static long countForMeanMax(RideFileCacheHeader head, RideFile::SeriesType serie case RideFile::NP : return head.npMeanMaxCount; case RideFile::xPower : return head.xPowerMeanMaxCount; case RideFile::kph : return head.kphMeanMaxCount; + case RideFile::kphd : return head.kphdMeanMaxCount; case RideFile::nm : return head.nmMeanMaxCount; case RideFile::cad : return head.cadMeanMaxCount; case RideFile::hr : return head.hrMeanMaxCount; diff --git a/src/RideFileCache.h b/src/RideFileCache.h index 344927c0e..91967b24c 100644 --- a/src/RideFileCache.h +++ b/src/RideFileCache.h @@ -40,7 +40,7 @@ typedef double data_t; // arrays when plotting CP curves and histograms. It is precoputed // to save time and cached in a file .cpx // -static const unsigned int RideFileCacheVersion = 11; +static const unsigned int RideFileCacheVersion = 12; // revision history: // version date description // 1 29-Apr-11 Initial - header, mean-max & distribution data blocks @@ -54,6 +54,7 @@ static const unsigned int RideFileCacheVersion = 11; // 9 06-Nov-13 Added aPower // 10 13-Feb-14 Added Moderate, Heavy and Severe domains // 11 17-Feb-14 Changed 3zone model to have 85% CP < middle < CP +// 12 21-Feb-14 Added Acceleration (speed) // The cache file (.cpx) has a binary format: // 1 x Header data - describing the version and contents of the cache @@ -74,6 +75,7 @@ struct RideFileCacheHeader { cadMeanMaxCount, nmMeanMaxCount, kphMeanMaxCount, + kphdMeanMaxCount, xPowerMeanMaxCount, npMeanMaxCount, vamMeanMaxCount, @@ -84,6 +86,7 @@ struct RideFileCacheHeader { cadDistCount, nmDistrCount, kphDistCount, + kphdDistCount, xPowerDistCount, npDistCount, wattsKgDistCount, @@ -198,6 +201,7 @@ class RideFileCache QVector cadMeanMax; // RideFile::cad QVector nmMeanMax; // RideFile::nm QVector kphMeanMax; // RideFile::kph + QVector kphdMeanMax; // RideFile::kphd QVector xPowerMeanMax; // RideFile::kph QVector npMeanMax; // RideFile::kph QVector vamMeanMax; // RideFile::vam @@ -209,6 +213,7 @@ class RideFileCache QVector cadMeanMaxDouble; // RideFile::cad QVector nmMeanMaxDouble; // RideFile::nm QVector kphMeanMaxDouble; // RideFile::kph + QVector kphdMeanMaxDouble; // RideFile::kphd QVector xPowerMeanMaxDouble; // RideFile::kph QVector npMeanMaxDouble; // RideFile::kph QVector vamMeanMaxDouble; // RideFile::kph @@ -220,6 +225,7 @@ class RideFileCache QVector cadMeanMaxDate; // RideFile::cad QVector nmMeanMaxDate; // RideFile::nm QVector kphMeanMaxDate; // RideFile::kph + QVector kphdMeanMaxDate; // RideFile::kph QVector xPowerMeanMaxDate; // RideFile::kph QVector npMeanMaxDate; // RideFile::kph QVector vamMeanMaxDate; // RideFile::vam @@ -239,6 +245,7 @@ class RideFileCache QVector cadDistribution; // RideFile::cad QVector nmDistribution; // RideFile::nm QVector kphDistribution; // RideFile::kph + QVector kphdDistribution; // RideFile::kphd QVector xPowerDistribution; // RideFile::kph QVector npDistribution; // RideFile::kph QVector wattsKgDistribution; // RideFile::wattsKg @@ -249,6 +256,7 @@ class RideFileCache QVector cadDistributionDouble; // RideFile::cad QVector nmDistributionDouble; // RideFile::nm QVector kphDistributionDouble; // RideFile::kph + QVector kphdDistributionDouble; // RideFile::kph QVector xPowerDistributionDouble; // RideFile::kph QVector npDistributionDouble; // RideFile::kph QVector wattsKgDistributionDouble; // RideFile::wattsKg