mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-04-15 05:32:21 +00:00
SpinScan L/R different colors
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
#include <QDir>
|
||||
#include "Settings.h"
|
||||
|
||||
static Colors ColorList[59], DefaultColorList[59];
|
||||
static Colors ColorList[60], DefaultColorList[60];
|
||||
|
||||
static void copyArray(Colors source[], Colors target[])
|
||||
{
|
||||
@@ -33,8 +33,9 @@ static void copyArray(Colors source[], Colors target[])
|
||||
|
||||
static bool setupColors()
|
||||
{
|
||||
// XXX remove when we can guarantee extended initialisation support in gcc (c++0x not supported by Qt currently)
|
||||
Colors init[59] = {
|
||||
// consider removing when we can guarantee extended initialisation support in gcc
|
||||
// (c++0x not supported by Qt currently and not planned for 4.8 or 5.0)
|
||||
Colors init[60] = {
|
||||
{ "Plot Background", "COLORPLOTBACKGROUND", Qt::white },
|
||||
{ "Ride Plot Background", "COLORRIDEPLOTBACKGROUND", Qt::black },
|
||||
{ "Plot Thumbnail Background", "COLORPLOTTHUMBNAIL", Qt::gray },
|
||||
@@ -92,7 +93,8 @@ static bool setupColors()
|
||||
{ "Chart Bar Selected", "CTILEBARSELECT", Qt::yellow },
|
||||
{ "ToolBar Background", "CTOOLBAR", Qt::white },
|
||||
{ "Activity History Group", "CRIDEGROUP", QColor(236,246,255) },
|
||||
{ "SpinScan Foreground", "CSPINSCAN", Qt::gray },
|
||||
{ "SpinScan Left", "CSPINSCANLEFT", Qt::gray },
|
||||
{ "SpinScan Right", "CSPINSCANRIGHT", Qt::cyan },
|
||||
{ "", "", QColor(0,0,0) },
|
||||
};
|
||||
|
||||
|
||||
@@ -132,6 +132,7 @@ class ColorEngine : public QObject
|
||||
#define CTILEBARSELECT 54
|
||||
#define CTOOLBAR 55
|
||||
#define CRIDEGROUP 56
|
||||
#define CSPINSCAN 57
|
||||
#define CSPINSCANLEFT 57
|
||||
#define CSPINSCANRIGHT 58
|
||||
|
||||
#endif
|
||||
|
||||
@@ -39,13 +39,13 @@ static const double xspin[97] = {
|
||||
};
|
||||
|
||||
// Power history
|
||||
double SpinScanData::x(size_t i) const { return xspin[i]; }
|
||||
double SpinScanData::y(size_t i) const { return (i%4 == 2 || i%4 == 3) ? spinData[i/4] : 0; }
|
||||
size_t SpinScanData::size() const { return 97; }
|
||||
QwtData *SpinScanData::copy() const { return new SpinScanData(spinData); }
|
||||
double SpinScanData::x(size_t i) const { return xspin[i+(isleft?0:48)]; }
|
||||
double SpinScanData::y(size_t i) const { return (i%4 == 2 || i%4 == 3) ? spinData[(i+(isleft?0:48))/4] : 0; }
|
||||
size_t SpinScanData::size() const { return 48; }
|
||||
QwtData *SpinScanData::copy() const { return new SpinScanData(spinData, isleft); }
|
||||
void SpinScanData::init() { }
|
||||
|
||||
SpinScanPlot::SpinScanPlot(uint8_t *spinData) : spinCurve(NULL), spinData(spinData)
|
||||
SpinScanPlot::SpinScanPlot(uint8_t *spinData) : leftCurve(NULL), rightCurve(NULL), spinData(spinData)
|
||||
{
|
||||
setInstanceName("SpinScan Plot");
|
||||
|
||||
@@ -57,8 +57,8 @@ SpinScanPlot::SpinScanPlot(uint8_t *spinData) : spinCurve(NULL), spinData(spinDa
|
||||
QPalette pal;
|
||||
setAxisScale(yLeft, 0, 90); // max 8 bit plus a little
|
||||
setAxisScale(xBottom, 0, 24); // max 8 bit plus a little
|
||||
pal.setColor(QPalette::WindowText, GColor(CSPINSCAN));
|
||||
pal.setColor(QPalette::Text, GColor(CSPINSCAN));
|
||||
pal.setColor(QPalette::WindowText, GColor(CSPINSCANLEFT));
|
||||
pal.setColor(QPalette::Text, GColor(CSPINSCANLEFT));
|
||||
axisWidget(QwtPlot::yLeft)->setPalette(pal);
|
||||
axisWidget(QwtPlot::yLeft)->scaleDraw()->setTickLength(QwtScaleDiv::MajorTick, 3);
|
||||
|
||||
@@ -66,12 +66,18 @@ SpinScanPlot::SpinScanPlot(uint8_t *spinData) : spinCurve(NULL), spinData(spinDa
|
||||
enableAxis(yLeft, true);
|
||||
|
||||
// 30s Power curve
|
||||
spinCurve = new QwtPlotCurve("SpinScan");
|
||||
spinCurve->setRenderHint(QwtPlotItem::RenderAntialiased); // too cpu intensive
|
||||
spinCurve->attach(this);
|
||||
spinCurve->setYAxis(QwtPlot::yLeft);
|
||||
rightCurve = new QwtPlotCurve("SpinScan Left");
|
||||
rightCurve->setRenderHint(QwtPlotItem::RenderAntialiased); // too cpu intensive
|
||||
rightCurve->attach(this);
|
||||
rightCurve->setYAxis(QwtPlot::yLeft);
|
||||
leftCurve = new QwtPlotCurve("SpinScan Right");
|
||||
leftCurve->setRenderHint(QwtPlotItem::RenderAntialiased); // too cpu intensive
|
||||
leftCurve->attach(this);
|
||||
leftCurve->setYAxis(QwtPlot::yLeft);
|
||||
|
||||
leftSpinScanData = new SpinScanData(spinData, true);
|
||||
rightSpinScanData = new SpinScanData(spinData, false);
|
||||
|
||||
spinScanData = new SpinScanData(spinData);
|
||||
canvas()->setFrameStyle(QFrame::NoFrame);
|
||||
configChanged(); // set colors
|
||||
}
|
||||
@@ -95,11 +101,19 @@ SpinScanPlot::configChanged()
|
||||
{
|
||||
setCanvasBackground(GColor(CRIDEPLOTBACKGROUND));
|
||||
|
||||
QColor col = GColor(CSPINSCAN);
|
||||
spinCurve->setPen(Qt::NoPen);
|
||||
QColor col = GColor(CSPINSCANLEFT);
|
||||
col.setAlpha(120);
|
||||
QBrush brush = QBrush(col);
|
||||
spinCurve->setBrush(brush);
|
||||
leftCurve->setBrush(brush);
|
||||
leftCurve->setPen(Qt::NoPen);
|
||||
//spinCurve->setStyle(QwtPlotCurve::Steps);
|
||||
spinCurve->setData(*spinScanData);
|
||||
leftCurve->setData(*leftSpinScanData);
|
||||
|
||||
QColor col2 = GColor(CSPINSCANRIGHT);
|
||||
col2.setAlpha(120);
|
||||
QBrush brush2 = QBrush(col2);
|
||||
rightCurve->setBrush(brush2);
|
||||
rightCurve->setPen(Qt::NoPen);
|
||||
//spinCurve->setStyle(QwtPlotCurve::Steps);
|
||||
rightCurve->setData(*rightSpinScanData);
|
||||
}
|
||||
|
||||
@@ -35,9 +35,11 @@
|
||||
|
||||
class SpinScanData : public QwtData
|
||||
{
|
||||
bool isleft;
|
||||
uint8_t *spinData;
|
||||
|
||||
public:
|
||||
SpinScanData(uint8_t *spinData) : spinData(spinData) { init(); }
|
||||
SpinScanData(uint8_t *spinData, bool isleft) : isleft(isleft), spinData(spinData) { init(); }
|
||||
|
||||
double x(size_t i) const ;
|
||||
double y(size_t i) const ;
|
||||
@@ -54,11 +56,13 @@ class SpinScanPlot : public QwtPlot
|
||||
private:
|
||||
|
||||
QwtPlotGrid *grid;
|
||||
QwtPlotCurve *spinCurve;
|
||||
QwtPlotCurve *leftCurve;
|
||||
QwtPlotCurve *rightCurve;
|
||||
|
||||
public:
|
||||
void setAxisTitle(int axis, QString label);
|
||||
SpinScanData *spinScanData;
|
||||
SpinScanData *leftSpinScanData;
|
||||
SpinScanData *rightSpinScanData;
|
||||
|
||||
SpinScanPlot(uint8_t *);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user