diff --git a/src/AllPlot.cpp b/src/AllPlot.cpp index 9d04efb6a..0233402a5 100644 --- a/src/AllPlot.cpp +++ b/src/AllPlot.cpp @@ -4177,6 +4177,7 @@ AllPlot::setDataFromPlots(QList plots) curveColors->saveState(); // remove all curves from the plot + for(int k=0; kU.count(); k++) standard->U[k].curve->detach(); standard->wCurve->detach(); standard->mCurve->detach(); standard->wattsCurve->detach(); @@ -4221,6 +4222,7 @@ AllPlot::setDataFromPlots(QList plots) standard->lpppCurve->detach(); standard->rpppCurve->detach(); + for(int k=0; kU.count(); k++) standard->U[k].curve->setVisible(false); standard->wCurve->setVisible(false); standard->mCurve->setVisible(false); standard->wattsCurve->setVisible(false); @@ -4672,6 +4674,14 @@ AllPlot::setDataFromPlots(QList plots) break; default: + if (scope > RideFile::none) { + + // user defined series + int index = scope - (RideFile::none+1); + ourCurve = static_cast(new QwtPlotGappedCurve(referencePlot->standard->U[index].name, 3)); + thereCurve = referencePlot->standard->U[index].curve; + title = referencePlot->standard->U[index].name; + } case RideFile::interval: case RideFile::vam: case RideFile::wattsKg: @@ -4701,10 +4711,13 @@ AllPlot::setDataFromPlots(QList plots) ourCurve->attach(this); // lets clone the data - QVector array; - for (size_t i=0; idata()->size(); i++) array << thereCurve->data()->sample(i); + QVector x,y; + for (size_t i=0; idata()->size(); i++) { + x << thereCurve->data()->sample(i).x(); + y << thereCurve->data()->sample(i).y(); + } - ourCurve->setSamples(array); + ourCurve->setSamples(x,y); ourCurve->setYAxis(yLeft); ourCurve->setBaseline(thereCurve->baseline()); @@ -4712,7 +4725,7 @@ AllPlot::setDataFromPlots(QList plots) if (ourCurve->minYValue() < MINY) MINY = ourCurve->minYValue(); // symbol when zoomed in super close - if (array.size() < 150) { + if (x.size() < 150) { QwtSymbol *sym = new QwtSymbol; sym->setPen(QPen(GColor(CPLOTMARKER))); sym->setStyle(QwtSymbol::Ellipse); @@ -4886,6 +4899,7 @@ AllPlot::setDataFromObject(AllPlotObject *object, AllPlot *reference) bydist = reference->bydist; // remove all curves from the plot + for(int k=0; kU.count(); k++) standard->U[k].curve->detach(); standard->wCurve->detach(); standard->mCurve->detach(); standard->wattsCurve->detach(); @@ -4926,6 +4940,7 @@ AllPlot::setDataFromObject(AllPlotObject *object, AllPlot *reference) standard->intervalHighlighterCurve->detach(); standard->intervalHoverCurve->detach(); + for(int k=0; kU.count(); k++) standard->U[k].curve->setVisible(false); standard->wCurve->setVisible(false); standard->mCurve->setVisible(false); standard->wattsCurve->setVisible(false); @@ -4979,6 +4994,17 @@ AllPlot::setDataFromObject(AllPlotObject *object, AllPlot *reference) setMatchLabels(standard); } + // show user data curves + for(int k=0; k< standard->U.count() && kU.count(); k++) { + + if (!object->U[k].smooth.empty()) { + + standard->U[k].curve->setSamples(xaxis.data(), object->U[k].smooth.data(), totalPoints); + standard->U[k].curve->attach(this); + standard->U[k].curve->setVisible(true); + } + } + if (!object->wattsArray.empty()) { standard->wattsCurve->setSamples(xaxis.data(), object->smoothWatts.data(), totalPoints); standard->wattsCurve->attach(this); @@ -5616,6 +5642,7 @@ AllPlot::setDataFromRideFile(RideFile *ride, AllPlotObject *here, QListuser, compareUserDataSeries) { + foreach(UserData *p, user) + delete p; + } + compareUserDataSeries.clear(); + // new ones .. if (context->isCompareIntervals) { + // generate the user data series for each interval + foreach(CompareInterval ci, context->compareIntervals) { + QList list; + foreach(UserData *u, userDataSeries) { + UserData *p = new UserData(u->name, u->units, u->formula, ci.color); // use context for interval + p->setRideItem(ci.rideItem); + list << p; + } + compareUserDataSeries << list; + } + // first, lets init fullPlot, just in case its never // been set (ie, switched to us before ever plotting a ride - if (myRideItem) fullPlot->setDataFromRide(myRideItem, QList()); //XXX + if (myRideItem) fullPlot->setDataFromRide(myRideItem, QList()); // and even if the current ride is blank, we're not // going to be blank !! @@ -1262,10 +1280,11 @@ AllPlotWindow::compareChanged() fullPlot->standard->setVisible(false); if (fullPlot->smooth < 1) fullPlot->smooth = 1; + int k=0; foreach(CompareInterval ci, context->compareIntervals) { - AllPlotObject *po = new AllPlotObject(fullPlot, QList()); //XXX - if (ci.isChecked()) fullPlot->setDataFromRideFile(ci.data, po, QList()); //XXX + AllPlotObject *po = new AllPlotObject(fullPlot, compareUserDataSeries[k]); + if (ci.isChecked()) fullPlot->setDataFromRideFile(ci.data, po, compareUserDataSeries[k]); // what was the maximum x value? if (po->maxKM > maxKM) maxKM = po->maxKM; @@ -1277,6 +1296,9 @@ AllPlotWindow::compareChanged() // remember compareIntervalCurves << po; + + // next + k++; } // what is the longest compareInterval? @@ -1284,10 +1306,12 @@ AllPlotWindow::compareChanged() else fullPlot->setAxisScale(QwtPlot::xBottom, 0, maxSECS/60); // now set it it in all the compare objects so they all get set - // to the same time / duration + // to the same time / duration and all the data is set too + k=0; foreach (AllPlotObject *po, compareIntervalCurves) { po->maxKM = maxKM; po->maxSECS = maxSECS; + k++; } if (fullPlot->bydist == false) { @@ -1325,6 +1349,8 @@ AllPlotWindow::compareChanged() AllPlot *ap = new AllPlot(this, this, context); ap->bydist = fullPlot->bydist; ap->setShadeZones(showPower->currentIndex() == 0); + + // user data series needs setting up ap->setDataFromObject(compareIntervalCurves[i], fullPlot); // simpler to keep the indexes aligned @@ -1407,6 +1433,13 @@ AllPlotWindow::compareChanged() if (showAP->isChecked()) { s.one = RideFile::aPower; s.two = RideFile::none; wanted << s;}; if (showBalance->isChecked()) { s.one = RideFile::lrbalance; s.two = RideFile::none; wanted << s;}; + // and the user series + for(int k=0; k(RideFile::none + 1 + k); + s.two = RideFile::none; + wanted << s; + } + /* if (showTE->isChecked()) { s.one = RideFile::lte; s.two = RideFile::none; wanted << s; @@ -1474,18 +1507,34 @@ AllPlotWindow::compareChanged() sd->enableComponent(QwtScaleDraw::Ticks, false); sd->enableComponent(QwtScaleDraw::Backbone, false); plot->setAxisScaleDraw(QwtPlot::yLeft, sd); - - // y-axis title and colour - if (x.one == RideFile::alt && x.two == RideFile::slope) { - plot->setAxisTitle(QwtPlot::yLeft, tr("Alt/Slope")); - plot->showAltSlopeState = allPlot->showAltSlopeState; - plot->setAltSlopePlotStyle(allPlot->standard->altSlopeCurve); - } else { - plot->setAxisTitle(QwtPlot::yLeft, RideFile::seriesName(x.one)); - } + + // default paletter override below if needed QPalette pal; pal.setColor(QPalette::WindowText, RideFile::colorFor(x.one)); pal.setColor(QPalette::Text, RideFile::colorFor(x.one)); + + // y-axis title and colour + if (x.one == RideFile::alt && x.two == RideFile::slope) { + + // alt/slope special case + plot->setAxisTitle(QwtPlot::yLeft, tr("Alt/Slope")); + plot->showAltSlopeState = allPlot->showAltSlopeState; + plot->setAltSlopePlotStyle(allPlot->standard->altSlopeCurve); + + } else { + + // user defined series + if (x.one > RideFile::none) { + int index = (int)(x.one) - (RideFile::none + 1); + plot->setAxisTitle(QwtPlot::yLeft, userDataSeries[index]->name); + pal.setColor(QPalette::WindowText, userDataSeries[index]->color); + pal.setColor(QPalette::Text, userDataSeries[index]->color); + } else { + // everything else + plot->setAxisTitle(QwtPlot::yLeft, RideFile::seriesName(x.one)); + } + } + plot->axisWidget(QwtPlot::yLeft)->setPalette(pal); // remember them diff --git a/src/AllPlotWindow.h b/src/AllPlotWindow.h index 7908ebc66..865f5476a 100644 --- a/src/AllPlotWindow.h +++ b/src/AllPlotWindow.h @@ -385,6 +385,7 @@ class AllPlotWindow : public GcChartWindow // user data series widgets QList userDataSeries; + QList > compareUserDataSeries; // comparing QList compareIntervalCurves; // one per compareInterval