diff --git a/src/AllPlot.cpp b/src/AllPlot.cpp index cc7c35de8..21bf5dca9 100644 --- a/src/AllPlot.cpp +++ b/src/AllPlot.cpp @@ -530,6 +530,9 @@ AllPlot::AllPlot(AllPlotWindow *parent, Context *context, RideFile::SeriesType s tooltip = NULL; _canvasPicker = NULL; + // curve color object + curveColors = new CurveColors(this); + // create a background object for shading bg = new AllPlotBackground(this); bg->attach(this); @@ -1932,6 +1935,9 @@ AllPlot::setDataFromPlot(AllPlot *plot, int startidx, int stopidx) //if (this->legend()) this->legend()->show(); //replot(); + + // remember the curves and colors + curveColors->saveState(); } void @@ -2245,6 +2251,9 @@ AllPlot::setDataFromPlot(AllPlot *plot) refreshZoneLabels(); #endif } + + // remember the curves and colors + curveColors->saveState(); } void @@ -2606,6 +2615,9 @@ AllPlot::setDataFromPlots(QList plots) #if 0 #endif #endif + + // remember the curves and colors + curveColors->saveState(); } // used to setup array of allplots where there is one for @@ -2772,6 +2784,9 @@ AllPlot::setDataFromObject(AllPlotObject *object, AllPlot *reference) } else bg->detach(); + // remember the curves and colors + curveColors->saveState(); + replot(); } @@ -2789,6 +2804,9 @@ AllPlot::setDataFromRide(RideItem *_rideItem) standard->curveTitle.setLabel(QwtText(QString(""), QwtText::PlainText)); // default to no title setDataFromRideFile(rideItem->ride(), standard); + + // remember the curves and colors + curveColors->saveState(); } void @@ -2968,6 +2986,8 @@ AllPlot::setDataFromRideFile(RideFile *ride, AllPlotObject *here) if (maxSECS > here->maxSECS) here->maxSECS = maxSECS; } + // remember the curves and colors + curveColors->saveState(); } void @@ -3338,7 +3358,7 @@ QRectF IntervalPlotData::boundingRect() const void AllPlot::pointHover(QwtPlotCurve *curve, int index) { - if (index >= 0 && curve != standard->intervalHighlighterCurve) { + if (index >= 0 && curve != standard->intervalHighlighterCurve && curve->isVisible()) { double yvalue = curve->sample(index).y(); double xvalue = curve->sample(index).x(); @@ -3361,10 +3381,18 @@ AllPlot::pointHover(QwtPlotCurve *curve, int index) // set that text up tooltip->setText(text); + // isolate me -- maybe do this via the legend ? + //curveColors->isolate(curve); + //replot(); + } else { // no point tooltip->setText(""); + + // get colors back -- maybe do this via the legend? + //curveColors->restoreState(); + //replot(); } } diff --git a/src/AllPlot.h b/src/AllPlot.h index 61a0f0b94..7db491790 100644 --- a/src/AllPlot.h +++ b/src/AllPlot.h @@ -19,12 +19,14 @@ #ifndef _GC_AllPlot_h #define _GC_AllPlot_h 1 #include "GoldenCheetah.h" +#include "Colors.h" #include #include #include #include #include +#include #include #include #include @@ -52,6 +54,56 @@ class Context; class LTMToolTip; class LTMCanvasPicker; +class CurveColors +{ + public: + CurveColors(QwtPlot *plot) : plot(plot) { + saveState(); + } + + void restoreState() { + + // make all the curves have the right pen + QHashIterator c(state); + while (c.hasNext()) { + c.next(); + c.key()->setPen(c.value()); + } + } + + void saveState() { + state.clear(); + + // get a list of plots and colors + foreach(QwtPlotItem *item, plot->itemList(QwtPlotItem::Rtti_PlotCurve)) { + state.insert(static_cast(item), + static_cast(item)->pen()); + } + } + + void isolate(QwtPlotCurve *curve) { + + // make the curve colored but all others go dull + QHashIterator c(state); + while (c.hasNext()) { + c.next(); + if (c.key() == curve) { + c.key()->setPen(c.value()); + } else { + + // dull others + QPen x = c.value(); + x.setColor(plot->canvasBackground().color()); + c.key()->setPen(x); + } + } + } + + private: + QwtPlot *plot; + QHash state; +}; + class AllPlot; class AllPlotObject : public QObject { @@ -189,6 +241,9 @@ class AllPlot : public QwtPlot void confirmTmpReference(double value, int axis, bool allowDelete); QwtPlotCurve* plotReferenceLine(const RideFilePoint *referencePoint); + // remembering state etc + CurveColors *curveColors; + public slots: void setShowPower(int id);