mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
AllPlot isolate curve on mouse over
.. disabled the effect as its NASTY and flickery but saving the code anyway as we might do it by a mouse over the legend ??
This commit is contained in:
@@ -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<AllPlot *> 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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,12 +19,14 @@
|
||||
#ifndef _GC_AllPlot_h
|
||||
#define _GC_AllPlot_h 1
|
||||
#include "GoldenCheetah.h"
|
||||
#include "Colors.h"
|
||||
|
||||
#include <qwt_plot.h>
|
||||
#include <qwt_axis_id.h>
|
||||
#include <qwt_series_data.h>
|
||||
#include <qwt_plot_zoomer.h>
|
||||
#include <qwt_plot_curve.h>
|
||||
#include <qwt_plot_dict.h>
|
||||
#include <qwt_plot_marker.h>
|
||||
#include <qwt_point_3d.h>
|
||||
#include <qwt_compat.h>
|
||||
@@ -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<QwtPlotCurve *, QPen> 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<QwtPlotCurve*>(item),
|
||||
static_cast<QwtPlotCurve*>(item)->pen());
|
||||
}
|
||||
}
|
||||
|
||||
void isolate(QwtPlotCurve *curve) {
|
||||
|
||||
// make the curve colored but all others go dull
|
||||
QHashIterator<QwtPlotCurve *, QPen> 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<QwtPlotCurve *, QPen> 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);
|
||||
|
||||
Reference in New Issue
Block a user