mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-14 16:39:57 +00:00
Auto Interval Discovery (Part 2 of 3)
In this part we have updated all the charts to reference
the RideItem::intervals() members instead of the TreeWidget
and RideFile::intervals().
The code to create/change/delete intervals is not included
so selecting and editing on charts/sidebar is disabled til
part 3 of the update, but hover should work properly.
Still left todo in future updates;
* Updates to the interval sidebar to list intervals
in a tree (by interval type) with a color selector
* Code to create, edit, delete etc the intervals via
the rideitem/intervalitem and see them reflected in
the ridefile
* Update to search for all the different types of
IntervalItems including routes and sustained intervals
This commit is contained in:
@@ -388,19 +388,7 @@ PfPvPlot::refreshZoneItems()
|
||||
// how many intervals selected?
|
||||
int PfPvPlot::intervalCount() const
|
||||
{
|
||||
int highlighted;
|
||||
highlighted = 0;
|
||||
if (context->athlete->allIntervalItems() == NULL) return 0; // not inited yet!
|
||||
|
||||
for (int i=0; i<context->athlete->allIntervalItems()->childCount(); i++) {
|
||||
IntervalItem *current = dynamic_cast<IntervalItem *>(context->athlete->allIntervalItems()->child(i));
|
||||
if (current != NULL) {
|
||||
if (current->isSelected() == true) {
|
||||
++highlighted;
|
||||
}
|
||||
}
|
||||
}
|
||||
return highlighted;
|
||||
return rideItem->intervalsSelected().count();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -411,7 +399,7 @@ PfPvPlot::mouseTrack(double cad, double watts)
|
||||
double aepf = (watts * 60.0) / (cad * cl_ * 2.0 * PI);
|
||||
double cpv = (cad * cl_ * 2.0 * PI) / 60.0;
|
||||
|
||||
if (rideItem && rideItem->ride() && rideItem->ride()->intervals().count() >= intervalMarkers.count()) {
|
||||
if (rideItem && rideItem->ride() && rideItem->intervals().count() >= intervalMarkers.count()) {
|
||||
// are we hovering "close" to an interval marker ?
|
||||
int index = 0;
|
||||
foreach (QwtPlotMarker *is, intervalMarkers) {
|
||||
@@ -420,7 +408,7 @@ PfPvPlot::mouseTrack(double cad, double watts)
|
||||
double y = is->yValue() - aepf;
|
||||
|
||||
if ((x > -0.05f && x < 0.05f) && (y > -3 && y < 3)) {
|
||||
context->notifyIntervalHover(rideItem->ride()->intervals()[index]);
|
||||
context->notifyIntervalHover(rideItem->intervals()[index]);
|
||||
}
|
||||
|
||||
index++;
|
||||
@@ -443,7 +431,7 @@ PfPvPlot::refreshIntervalMarkers()
|
||||
|
||||
// do we have a ride with intervals to refresh ?
|
||||
int count=0;
|
||||
if (rideItem && rideItem->ride() && rideItem->ride()->dataPoints().count() && (count = rideItem->ride()->intervals().count())) {
|
||||
if (rideItem && rideItem->ride() && rideItem->ride()->dataPoints().count() && (count = rideItem->intervals().count())) {
|
||||
|
||||
// accumulating...
|
||||
QVector<accum> intervalAccumulator(count);
|
||||
@@ -459,10 +447,10 @@ PfPvPlot::refreshIntervalMarkers()
|
||||
// accumulate values for each interval here ....
|
||||
for(int i=0; i < count; i++) {
|
||||
|
||||
RideFileInterval v = rideItem->ride()->intervals()[i];
|
||||
IntervalItem *v = rideItem->intervals()[i];
|
||||
|
||||
// in our interval ?
|
||||
if (p1->secs >= v.start && p1->secs <= v.stop) {
|
||||
if (p1->secs >= v->start && p1->secs <= v->stop) {
|
||||
intervalAccumulator[i].aepf += aepf;
|
||||
intervalAccumulator[i].cpv += cpv;
|
||||
intervalAccumulator[i].count++;
|
||||
@@ -678,7 +666,7 @@ PfPvPlot::setData(RideItem *_rideItem)
|
||||
}
|
||||
|
||||
void
|
||||
PfPvPlot::intervalHover(RideFileInterval x)
|
||||
PfPvPlot::intervalHover(IntervalItem *x)
|
||||
{
|
||||
if (!isVisible()) return;
|
||||
if (context->isCompareIntervals) return;
|
||||
@@ -696,7 +684,7 @@ PfPvPlot::intervalHover(RideFileInterval x)
|
||||
QVector<double> aepfArray, cpvArray;
|
||||
foreach(const RideFilePoint *p1, rideItem->ride()->dataPoints()) {
|
||||
|
||||
if (p1->secs < x.start || p1->secs > x.stop) continue;
|
||||
if (p1->secs < x->start || p1->secs > x->stop) continue;
|
||||
|
||||
if (p1->watts != 0 && p1->cad != 0) {
|
||||
double aepf = (p1->watts * 60.0) / (p1->cad * cl_ * 2.0 * PI);
|
||||
@@ -710,8 +698,8 @@ PfPvPlot::intervalHover(RideFileInterval x)
|
||||
// which interval is it or how many ?
|
||||
int count = 0;
|
||||
int ours = 0;
|
||||
foreach(RideFileInterval p, rideItem->ride()->intervals()) {
|
||||
if (p.start == x.start && p.stop == x.stop) ours = count;
|
||||
foreach(IntervalItem *p, rideItem->intervals()) {
|
||||
if (p->start == x->start && p->stop == x->stop) ours = count;
|
||||
count++;
|
||||
}
|
||||
|
||||
@@ -775,11 +763,11 @@ PfPvPlot::showIntervals(RideItem *_rideItem)
|
||||
double aepf = (p1->watts * 60.0) / (p1->cad * cl_ * 2.0 * PI);
|
||||
double cpv = (p1->cad * cl_ * 2.0 * PI) / 60.0;
|
||||
|
||||
for (int high=-1, t=0; t<context->athlete->allIntervalItems()->childCount(); t++) {
|
||||
for (int high=-1, t=0; t<rideItem->intervals().count(); t++) {
|
||||
|
||||
IntervalItem *current = dynamic_cast<IntervalItem *>(context->athlete->allIntervalItems()->child(t));
|
||||
IntervalItem *current = dynamic_cast<IntervalItem *>(rideItem->intervals().at(t));
|
||||
|
||||
if ((current != NULL) && current->isSelected()) {
|
||||
if ((current != NULL) && current->selected) {
|
||||
++high;
|
||||
if (p1->secs+ride->recIntSecs() > current->start && p1->secs< current->stop) {
|
||||
if (mergeIntervals())
|
||||
@@ -818,15 +806,13 @@ PfPvPlot::showIntervals(RideItem *_rideItem)
|
||||
// ensure same colors are used for each interval selected
|
||||
int num_intervals_defined=0;
|
||||
QVector<int> intervalmap;
|
||||
if (context->athlete->allIntervalItems() != NULL) {
|
||||
|
||||
num_intervals_defined = context->athlete->allIntervalItems()->childCount();
|
||||
num_intervals_defined = rideItem->intervals().count();
|
||||
|
||||
for (int g=0; g<context->athlete->allIntervalItems()->childCount(); g++) {
|
||||
IntervalItem *curr = dynamic_cast<IntervalItem *>(context->athlete->allIntervalItems()->child(g));
|
||||
if (curr->isSelected()) intervalmap.append(g);
|
||||
}
|
||||
}
|
||||
for (int g=0; g<rideItem->intervals().count(); g++) {
|
||||
IntervalItem *curr = dynamic_cast<IntervalItem *>(rideItem->intervals().at(g));
|
||||
if (curr->selected) intervalmap.append(g);
|
||||
}
|
||||
|
||||
// honor display sequencing
|
||||
QMap<int, int> intervalOrder;
|
||||
@@ -834,12 +820,12 @@ PfPvPlot::showIntervals(RideItem *_rideItem)
|
||||
|
||||
if (mergeIntervals()) intervalOrder.insert(1,0);
|
||||
else {
|
||||
for (int i=0; i<context->athlete->allIntervalItems()->childCount(); i++) {
|
||||
for (int i=0; i<rideItem->intervals().count(); i++) {
|
||||
|
||||
IntervalItem *current = dynamic_cast<IntervalItem *>(context->athlete->allIntervalItems()->child(i));
|
||||
IntervalItem *current = dynamic_cast<IntervalItem *>(rideItem->intervals().at(i));
|
||||
|
||||
if (current != NULL && current->isSelected() == true) {
|
||||
intervalOrder.insert(current->displaySequence, count++);
|
||||
if (current != NULL && current->selected == true) {
|
||||
intervalOrder.insert(current->displaySequence, count++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user