Commit 45da9517 authored by Bryant's avatar Bryant

Fixed the styling of all ChartPlot instances updating when the MainWindow updates.

parent 467280bb
......@@ -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()
......
......@@ -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<QString, QwtPlotCurve*>();
......@@ -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()
......
......@@ -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
......@@ -87,7 +87,6 @@ IncrementalPlot::IncrementalPlot(QWidget *parent):
ChartPlot(parent),
symmetric(false)
{
setAutoReplot(false);
setStyleText("solid crosses");
plotLayout()->setAlignCanvasToScales(true);
......
......@@ -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);
}
/**
......
......@@ -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
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment