From 6e414a47740eeededca3336764a5f4c8b5f4cac2 Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Fri, 23 Jan 2015 16:22:54 +0000 Subject: [PATCH] Fix train chart refreshing .. when config changes --- src/DialWindow.cpp | 1 + src/RealtimePlot.cpp | 11 +++++++++-- src/RealtimePlot.h | 6 +++++- src/RealtimePlotWindow.cpp | 10 +++++++++- src/RealtimePlotWindow.h | 1 + 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/DialWindow.cpp b/src/DialWindow.cpp index 4d7a77ff8..6c4752623 100644 --- a/src/DialWindow.cpp +++ b/src/DialWindow.cpp @@ -603,6 +603,7 @@ void DialWindow::seriesChanged() .arg(background.name()) .arg(foreground.name()); valueLabel->setStyleSheet(sh); + repaint(); } void diff --git a/src/RealtimePlot.cpp b/src/RealtimePlot.cpp index 07a18b18e..c42204e05 100644 --- a/src/RealtimePlot.cpp +++ b/src/RealtimePlot.cpp @@ -212,7 +212,7 @@ QRectF RealtimehhbData::boundingRect() const //void RealtimeLodData::addData(double v) { lodData[lodCur++] = v; if (lodCur==50) lodCur=0; } -RealtimePlot::RealtimePlot() : +RealtimePlot::RealtimePlot(Context *context) : pwrCurve(NULL), showPowerState(Qt::Checked), showPow30sState(Qt::Checked), @@ -224,7 +224,8 @@ RealtimePlot::RealtimePlot() : showHHbState(Qt::Checked), showtHbState(Qt::Checked), showSmO2State(Qt::Checked), - smooth(0) + smooth(0), + context(context) { //insertLegend(new QwtLegend(), QwtPlot::BottomLegend); pwr30Data = new Realtime30PwrData; @@ -360,6 +361,10 @@ RealtimePlot::RealtimePlot() : // lodCurve->attach(this); // lodCurve->setYAxis(QwtPlot::yLeft); static_cast(canvas())->setFrameStyle(QFrame::NoFrame); + + connect(context, SIGNAL(configChanged(qint32)), this, SLOT(configChanged(qint32))); + + // set to current config configChanged(CONFIG_APPEARANCE); // set colors } @@ -422,6 +427,8 @@ RealtimePlot::configChanged(qint32) QPen thbpen = QPen(GColor(CTHB)); thbpen.setWidth(width); thbCurve->setPen(thbpen); + + replot(); } void diff --git a/src/RealtimePlot.h b/src/RealtimePlot.h index c610e1fd2..2ab76bd37 100644 --- a/src/RealtimePlot.h +++ b/src/RealtimePlot.h @@ -30,6 +30,7 @@ #include #include #include "Settings.h" +#include "Context.h" #define MAXSAMPLES 300 @@ -294,7 +295,7 @@ class RealtimePlot : public QwtPlot RealtimehhbData *hhbData; Realtimesmo2Data *smo2Data; - RealtimePlot(); + RealtimePlot(Context *context); int smooth; public slots: @@ -310,6 +311,9 @@ class RealtimePlot : public QwtPlot void showtHb(int state); void showSmO2(int state); void setSmoothing(int value); + + private: + Context *context; }; diff --git a/src/RealtimePlotWindow.cpp b/src/RealtimePlotWindow.cpp index d37ef79a3..241e86197 100644 --- a/src/RealtimePlotWindow.cpp +++ b/src/RealtimePlotWindow.cpp @@ -92,7 +92,7 @@ RealtimePlotWindow::RealtimePlotWindow(Context *context) : cl->addStretch(); QVBoxLayout *layout = new QVBoxLayout(this); - rtPlot = new RealtimePlot(); + rtPlot = new RealtimePlot(context); layout->addWidget(rtPlot); // common controls @@ -111,6 +111,7 @@ RealtimePlotWindow::RealtimePlotWindow(Context *context) : // get updates.. connect(context, SIGNAL(telemetryUpdate(RealtimeData)), this, SLOT(telemetryUpdate(RealtimeData))); + connect(context, SIGNAL(configChanged(qint32)), this, SLOT(configChanged(qint32))); // lets initialise all the smoothing variables hrtot = hrindex = cadtot = cadindex = spdtot = spdindex = alttot = altindex = powtot = powindex = 0; @@ -124,6 +125,13 @@ RealtimePlotWindow::RealtimePlotWindow(Context *context) : telemetryUpdate(RealtimeData()); } +void +RealtimePlotWindow::configChanged(qint32) +{ + setProperty("color", GColor(CTRAINPLOTBACKGROUND)); + repaint(); +} + void RealtimePlotWindow::start() { diff --git a/src/RealtimePlotWindow.h b/src/RealtimePlotWindow.h index 01c0e8ffb..9db7fc426 100644 --- a/src/RealtimePlotWindow.h +++ b/src/RealtimePlotWindow.h @@ -74,6 +74,7 @@ class RealtimePlotWindow : public GcWindow // trap signals void telemetryUpdate(RealtimeData rtData); // got new data + void configChanged(qint32); void start(); void stop(); void pause();