From 45da95172d5d511c4a0519f9dc89c473b4e7d83f Mon Sep 17 00:00:00 2001 From: Bryant Date: Tue, 4 Jun 2013 15:19:01 -0700 Subject: [PATCH] Fixed the styling of all ChartPlot instances updating when the MainWindow updates. --- src/ui/QGCDataPlot2D.cc | 4 ++++ src/ui/linechart/ChartPlot.cc | 8 ++------ src/ui/linechart/ChartPlot.h | 10 +++++----- src/ui/linechart/IncrementalPlot.cc | 1 - src/ui/linechart/LinechartPlot.cc | 11 +++++------ src/ui/linechart/LinechartPlot.h | 2 +- src/ui/linechart/LinechartWidget.cc | 9 +++++++-- 7 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/ui/QGCDataPlot2D.cc b/src/ui/QGCDataPlot2D.cc index d1834d8bd..02dc9d172 100644 --- a/src/ui/QGCDataPlot2D.cc +++ b/src/ui/QGCDataPlot2D.cc @@ -70,6 +70,10 @@ QGCDataPlot2D::QGCDataPlot2D(QWidget *parent) : connect(ui->gridCheckBox, SIGNAL(clicked(bool)), plot, SLOT(showGrid(bool))); connect(ui->regressionButton, SIGNAL(clicked()), this, SLOT(calculateRegression())); connect(ui->style, SIGNAL(currentIndexChanged(QString)), plot, SLOT(setStyleText(QString))); + + // Allow style changes to propagate through this widget + connect(MainWindow::instance(), SIGNAL(styleChanged(MainWindow::QGC_MAINWINDOW_STYLE)), + plot, SLOT(styleChanged(MainWindow::QGC_MAINWINDOW_STYLE))); } void QGCDataPlot2D::reloadFile() diff --git a/src/ui/linechart/ChartPlot.cc b/src/ui/linechart/ChartPlot.cc index 87894f35e..3ec8f9226 100644 --- a/src/ui/linechart/ChartPlot.cc +++ b/src/ui/linechart/ChartPlot.cc @@ -27,10 +27,10 @@ const QColor ChartPlot::baseColors[numColors] = { ChartPlot::ChartPlot(QWidget *parent): QwtPlot(parent), nextColorIndex(0), - symbolWidth(1.2f), + symbolWidth(2.0f), curveWidth(2.0f), gridWidth(0.8f), - zoomerWidth(3.0f) + zoomerWidth(2.0f) { // Initialize the list of curves. curves = QMap(); @@ -54,10 +54,6 @@ ChartPlot::ChartPlot(QWidget *parent): // Now that all objects have been initialized, color everything. applyColorScheme(MainWindow::instance()->getStyle()); - - // And make sure we're listening for future style changes - connect(MainWindow::instance(), SIGNAL(styleChanged(MainWindow::QGC_MAINWINDOW_STYLE)), - this, SLOT(applyColorScheme(MainWindow::QGC_MAINWINDOW_STYLE))); } ChartPlot::~ChartPlot() diff --git a/src/ui/linechart/ChartPlot.h b/src/ui/linechart/ChartPlot.h index cef45096e..fad515190 100644 --- a/src/ui/linechart/ChartPlot.h +++ b/src/ui/linechart/ChartPlot.h @@ -22,6 +22,11 @@ public: /** @brief Reset color map */ void shuffleColors(); +public slots: + + /** @brief Generate coloring for this plot canvas based on current window theme */ + void applyColorScheme(MainWindow::QGC_MAINWINDOW_STYLE style); + protected: const static int numColors = 20; const static QColor baseColors[numColors]; @@ -35,11 +40,6 @@ protected: float curveWidth; ///< Width of curve lines in pixels float gridWidth; ///< Width of gridlines in pixels float zoomerWidth; ///< Width of zoomer selection box - -protected slots: - - /** @brief Generate coloring for this plot canvas based on current window theme */ - void applyColorScheme(MainWindow::QGC_MAINWINDOW_STYLE style); }; #endif // CHARTPLOT_H diff --git a/src/ui/linechart/IncrementalPlot.cc b/src/ui/linechart/IncrementalPlot.cc index 6ef4c4375..6eeb5dd5a 100644 --- a/src/ui/linechart/IncrementalPlot.cc +++ b/src/ui/linechart/IncrementalPlot.cc @@ -87,7 +87,6 @@ IncrementalPlot::IncrementalPlot(QWidget *parent): ChartPlot(parent), symmetric(false) { - setAutoReplot(false); setStyleText("solid crosses"); plotLayout()->setAlignCanvasToScales(true); diff --git a/src/ui/linechart/LinechartPlot.cc b/src/ui/linechart/LinechartPlot.cc index 098f451fe..9a6c995fe 100644 --- a/src/ui/linechart/LinechartPlot.cc +++ b/src/ui/linechart/LinechartPlot.cc @@ -60,8 +60,6 @@ LinechartPlot::LinechartPlot(QWidget *parent, int plotid, quint64 interval): yScaleEngine = new QwtLinearScaleEngine(); setAxisScaleEngine(QwtPlot::yLeft, yScaleEngine); - setAutoReplot(false); - // Set left scale //setAxisOptions(QwtPlot::yLeft, QwtAutoScale::Logarithmic); @@ -462,9 +460,7 @@ void LinechartPlot::showCurve(QString id) //} /** - * @brief Set the color of a curve - * - * This method emits the colorSet(id, color) signal. + * @brief Set the color of a curve and its symbols. * * @param id The id-string of the curve * @param color The newly assigned color @@ -472,7 +468,10 @@ void LinechartPlot::showCurve(QString id) void LinechartPlot::setCurveColor(QString id, QColor color) { QwtPlotCurve* curve = curves.value(id); - curve->setPen(color); + curve->setPen(QPen(QBrush(color), curveWidth)); + QwtSymbol x = curve->symbol(); + x.setPen(QPen(QBrush(color), symbolWidth)); + curve->setSymbol(x); } /** diff --git a/src/ui/linechart/LinechartPlot.h b/src/ui/linechart/LinechartPlot.h index 66af4d2ce..470d64b05 100644 --- a/src/ui/linechart/LinechartPlot.h +++ b/src/ui/linechart/LinechartPlot.h @@ -216,7 +216,7 @@ public slots: void setVisible(QString id, bool visible); /** - * @brief Set the color of a curve + * @brief Set the color of a curve and its symbols. * * @param id The id-string of the curve * @param color The newly assigned color diff --git a/src/ui/linechart/LinechartWidget.cc b/src/ui/linechart/LinechartWidget.cc index 38a8efc54..2a11f5c29 100644 --- a/src/ui/linechart/LinechartWidget.cc +++ b/src/ui/linechart/LinechartWidget.cc @@ -141,6 +141,12 @@ LinechartWidget::LinechartWidget(int systemid, QWidget *parent) : QWidget(parent //connect(this, SIGNAL(plotWindowPositionUpdated(int)), scrollbar, SLOT(setValue(int))); //connect(scrollbar, SIGNAL(sliderMoved(int)), this, SLOT(setPlotWindowPosition(int))); + + // And make sure we're listening for future style changes + connect(MainWindow::instance(), SIGNAL(styleChanged(MainWindow::QGC_MAINWINDOW_STYLE)), + this, SLOT(applyColorScheme(MainWindow::QGC_MAINWINDOW_STYLE))); + connect(MainWindow::instance(), SIGNAL(styleChanged()), this, SLOT(recolor())); + updateTimer->setInterval(updateInterval); connect(updateTimer, SIGNAL(timeout()), this, SLOT(refresh())); connect(ui.uasSelectionBox, SIGNAL(currentIndexChanged(int)), this, SLOT(selectActiveSystem(int))); @@ -771,8 +777,7 @@ void LinechartWidget::removeCurve(QString curve) void LinechartWidget::recolor() { - activePlot->shuffleColors(); - + activePlot->applyColorScheme(MainWindow::instance()->getStyle()); foreach (QString key, colorIcons.keys()) { QWidget* colorIcon = colorIcons.value(key, 0); -- 2.22.0