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:
Mark Liversedge
2015-05-09 18:49:49 +01:00
parent b0c4b7786f
commit 100c0be881
42 changed files with 456 additions and 587 deletions

View File

@@ -466,12 +466,12 @@ BingMap::createMarkers()
//
// INTERVAL MARKERS
//
if (context->athlete->allIntervalItems() == NULL) return; // none to do, we are all done then
if (myRideItem->intervals().count() == 0) return;
int interval=0;
foreach (const RideFileInterval x, myRideItem->ride()->intervals()) {
foreach (IntervalItem *x, myRideItem->intervals()) {
int offset = myRideItem->ride()->intervalBegin(x);
int offset = myRideItem->ride()->intervalBeginSecs(x->start);
code = QString("{ var latlng = new Microsoft.Maps.Location(%1,%2);\n"
"var pushpinOptions = { };\n"
"var pushpin = new Microsoft.Maps.Pushpin(latlng, pushpinOptions);\n"
@@ -481,7 +481,7 @@ BingMap::createMarkers()
" }")
.arg(myRideItem->ride()->dataPoints()[offset]->lat,0,'g',GPS_COORD_TO_STRING)
.arg(myRideItem->ride()->dataPoints()[offset]->lon,0,'g',GPS_COORD_TO_STRING)
.arg(x.name)
.arg(x->name)
.arg(interval);
view->page()->mainFrame()->evaluateJavaScript(code);
@@ -541,22 +541,8 @@ void BWebBridge::call(int count) { qDebug()<<"webBridge call:"<<count; }
int
BWebBridge::intervalCount()
{
int highlighted;
highlighted = 0;
RideItem *rideItem = gm->property("ride").value<RideItem*>();
if (context->athlete->allIntervalItems() == NULL ||
rideItem == NULL || rideItem->ride() == 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;
if (rideItem) return rideItem->intervalsSelected().count();
}
// get a latlon array for the i'th selected interval
@@ -564,41 +550,29 @@ QVariantList
BWebBridge::getLatLons(int i)
{
QVariantList latlons;
int highlighted=0;
RideItem *rideItem = gm->property("ride").value<RideItem*>();
if (context->athlete->allIntervalItems() == NULL ||
rideItem ==NULL || rideItem->ride() == NULL) return latlons; // not inited yet!
if (rideItem == NULL) return latlons;
if (i) {
// valid highlighted interval ?
if (i < 0 || i > rideItem->intervalsSelected().count()) {
// get for specific interval
for (int j=0; j<context->athlete->allIntervalItems()->childCount(); j++) {
IntervalItem *current = dynamic_cast<IntervalItem *>(context->athlete->allIntervalItems()->child(j));
if (current != NULL) {
if (current->isSelected() == true) {
++highlighted;
IntervalItem *current = rideItem->intervalsSelected().at(i);
// this one!
if (highlighted==i) {
// so this one is the interval we need.. lets
// snaffle up the points in this section
foreach (RideFilePoint *p1, rideItem->ride()->dataPoints()) {
if (p1->secs+rideItem->ride()->recIntSecs() > current->start
&& p1->secs< current->stop) {
// so this one is the interval we need.. lets
// snaffle up the points in this section
foreach (RideFilePoint *p1, rideItem->ride()->dataPoints()) {
if (p1->secs+rideItem->ride()->recIntSecs() > current->start
&& p1->secs< current->stop) {
if (p1->lat || p1->lon) {
latlons << p1->lat;
latlons << p1->lon;
}
}
}
return latlons;
}
if (p1->lat || p1->lon) {
latlons << p1->lat;
latlons << p1->lon;
}
}
}
return latlons;
} else {
// get latlons for entire route
@@ -627,6 +601,12 @@ BWebBridge::drawOverlays()
void
BWebBridge::toggleInterval(int x)
{
RideItem *rideItem = gm->property("ride").value<RideItem*>();
if (x < 0 || rideItem->intervals().count() >= x) return;
//XXX WHEN DECIDED HOW TO SELECT/UNSELECT INTERVALS
#if 0
IntervalItem *current = dynamic_cast<IntervalItem *>(context->athlete->allIntervalItems()->child(x));
if (current) current->setSelected(!current->isSelected());
#endif
}