mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
True Interval Patch, second part
The best interval dialog rounded intervals to the nearest second due to a casting of a double to int. This was introduced by Mark L during the intervals code patch and is an error. All the plots have now been adjusted to correctly determine if a ride point is within an interval. Related cropping and binning issues in 3d plot an Histogram plot have also been corrected. fixes #15
This commit is contained in:
committed by
Sean Rhea
parent
cc441cc98a
commit
9da6488d53
@@ -229,12 +229,12 @@ BestIntervalDialog::findClicked()
|
||||
resultsTable->setItem(row, 2, n);
|
||||
|
||||
// hidden columns - start, stop
|
||||
QString strt = QString("%1").arg((int) interval.start); // can't use secs as it gets modified
|
||||
QString strt = QString("%1").arg(interval.start); // can't use secs as it gets modified
|
||||
QTableWidgetItem *st = new QTableWidgetItem;
|
||||
st->setText(strt);
|
||||
resultsTable->setItem(row, 3, st);
|
||||
|
||||
QString stp = QString("%1").arg((int)(interval.start + x));
|
||||
QString stp = QString("%1").arg(interval.start + x);
|
||||
QTableWidgetItem *sp = new QTableWidgetItem;
|
||||
sp->setText(stp);
|
||||
resultsTable->setItem(row, 4, sp);
|
||||
|
||||
@@ -358,14 +358,14 @@ ModelDataProvider::ModelDataProvider (BasicModelPlot &plot, ModelSettings *setti
|
||||
foreach(const RideFilePoint *point, settings->ride->ride()->dataPoints()) {
|
||||
|
||||
// get x and z bin values - round to nearest bin
|
||||
double dx = pointType(point, settings->x)/settings->xbin;
|
||||
int binx = settings->xbin * Qwt3D::round(dx);
|
||||
double dx = pointType(point, settings->x);
|
||||
int binx = settings->xbin * floor(dx / settings->xbin);
|
||||
|
||||
double dy = pointType(point, settings->y)/settings->ybin;
|
||||
int biny = settings->ybin * Qwt3D::round(dy);
|
||||
double dy = pointType(point, settings->y);
|
||||
int biny = settings->ybin * floor(dy / settings->ybin);
|
||||
|
||||
// ignore zero points
|
||||
if (settings->ignore && (binx==0 || biny==0)) continue;
|
||||
if (settings->ignore && (dx==0 || dy==0)) continue;
|
||||
|
||||
// get z value
|
||||
double zed=0;
|
||||
@@ -431,8 +431,8 @@ ModelDataProvider::ModelDataProvider (BasicModelPlot &plot, ModelSettings *setti
|
||||
// filter for interval
|
||||
for(int i=0; i<settings->intervals.count(); i++) {
|
||||
IntervalItem *curr = settings->intervals.at(i);
|
||||
if (point->secs >= curr->start && point->secs <= curr->stop) {
|
||||
|
||||
if ((point->secs + settings->ride->ride()->recIntSecs()) > curr->start
|
||||
&& point->secs < curr->stop) {
|
||||
// update colors
|
||||
int colcount = settings->colorProvider->num.value(lookup,0.0);
|
||||
double currentcol = settings->colorProvider->color.value(lookup, 0.0);
|
||||
@@ -576,7 +576,8 @@ ModelDataProvider::ModelDataProvider (BasicModelPlot &plot, ModelSettings *setti
|
||||
z = iz.value();
|
||||
|
||||
if (first == true) {
|
||||
minz = maxz = iz.value();
|
||||
minz = 0;
|
||||
maxz = iz.value();
|
||||
} else {
|
||||
if (z > maxz) maxz = z;
|
||||
if (z < minz) minz = z;
|
||||
|
||||
@@ -430,7 +430,8 @@ PfPvPlot::showIntervals(RideItem *_rideItem)
|
||||
IntervalItem *current = dynamic_cast<IntervalItem *>(mainWindow->allIntervalItems()->child(t));
|
||||
if ((current != NULL) && current->isSelected()) {
|
||||
++high;
|
||||
if (p1->secs>=current->start && p1->secs<=current->stop) {
|
||||
if (p1->secs+ride->recIntSecs() > current->start
|
||||
&& p1->secs< current->stop) {
|
||||
if (mergeIntervals())
|
||||
dataSetInterval[0].insert(std::make_pair<double, double>(aepf, cpv));
|
||||
else
|
||||
|
||||
@@ -362,7 +362,9 @@ PowerHist::recalc()
|
||||
if (!array)
|
||||
return;
|
||||
|
||||
int count = int(ceil((arrayLength - 1) / binw));
|
||||
// we add a bin on the end since the last "incomplete" bin
|
||||
// will be dropped otherwise
|
||||
int count = int(ceil((arrayLength - 1) / binw))+1;
|
||||
|
||||
// allocate space for data, plus beginning and ending point
|
||||
QVector<double> parameterValue(count+2);
|
||||
@@ -377,7 +379,7 @@ PowerHist::recalc()
|
||||
parameterValue[i] = high * delta;
|
||||
totalTime[i] = 1e-9; // nonzero to accomodate log plot
|
||||
totalTimeSelected[i] = 1e-9; // nonzero to accomodate log plot
|
||||
while (low < high) {
|
||||
while (low < high && low<arrayLength) {
|
||||
if (selectedArray && (*selectedArray).size()>low)
|
||||
totalTimeSelected[i] += dt * (*selectedArray)[low];
|
||||
totalTime[i] += dt * (*array)[low++];
|
||||
@@ -436,7 +438,7 @@ PowerHist::setData(RideItem *_rideItem)
|
||||
double speed_factor = (useMetricUnits ? 1.0 : 0.62137119);
|
||||
|
||||
foreach(const RideFilePoint *p1, ride->dataPoints()) {
|
||||
bool selected = isSelected(p1);
|
||||
bool selected = isSelected(p1, ride->recIntSecs());
|
||||
|
||||
int wattsIndex = int(floor(p1->watts / wattsDelta));
|
||||
if (wattsIndex >= 0 && wattsIndex < maxSize) {
|
||||
@@ -706,12 +708,12 @@ bool PowerHist::shadeZones() const
|
||||
);
|
||||
}
|
||||
|
||||
bool PowerHist::isSelected(const RideFilePoint *p) {
|
||||
bool PowerHist::isSelected(const RideFilePoint *p, double sample) {
|
||||
if (mainWindow->allIntervalItems() != NULL) {
|
||||
for (int i=0; i<mainWindow->allIntervalItems()->childCount(); i++) {
|
||||
IntervalItem *current = dynamic_cast<IntervalItem*>(mainWindow->allIntervalItems()->child(i));
|
||||
if (current != NULL) {
|
||||
if (current->isSelected() && p->secs>=current->start && p->secs<=current->stop) {
|
||||
if (current->isSelected() && p->secs+sample>current->start && p->secs<current->stop) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ class PowerHist : public QwtPlot
|
||||
static const int cadDigits = 0;
|
||||
|
||||
void setParameterAxisTitle();
|
||||
bool isSelected(const RideFilePoint *p);
|
||||
bool isSelected(const RideFilePoint *p, double);
|
||||
|
||||
bool useMetricUnits; // whether metric units are used (or imperial)
|
||||
};
|
||||
|
||||
@@ -131,7 +131,7 @@ RideFile *WkoFileReader::openRideFile(QFile &file, QStringList &errors) const
|
||||
continue; // out of bounds
|
||||
|
||||
if (references.at(i)->stop < datapoints.count())
|
||||
add.stop = datapoints.at(references.at(i)->stop)->secs;
|
||||
add.stop = datapoints.at(references.at(i)->stop)->secs + rideFile->recIntSecs()-.001;
|
||||
else
|
||||
continue; // out of bounds
|
||||
|
||||
|
||||
Reference in New Issue
Block a user