Changeset - b389ff133420
[Not reviewed]
barplot
0 3 0
Hasan Yavuz Ă–ZDERYA - 8 years ago 2017-10-27 07:37:31
hy@ozderya.net
control bar plot background from menu
3 files changed with 30 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/barplot.cpp
Show inline comments
 
@@ -19,9 +19,10 @@
 

	
 
#include "barplot.h"
 
#include "barscaledraw.h"
 
#include "utils.h"
 

	
 
BarPlot::BarPlot(ChannelManager* channelMan, QWidget* parent) :
 
    QwtPlot(parent), barChart(channelMan)
 
BarPlot::BarPlot(ChannelManager* channelMan, PlotMenu* menu, QWidget* parent) :
 
    QwtPlot(parent), _menu(menu), barChart(channelMan)
 
{
 
    _channelMan = channelMan;
 
    barChart.attach(this);
 
@@ -31,6 +32,11 @@ BarPlot::BarPlot(ChannelManager* channel
 
    update();
 
    connect(_channelMan, &ChannelManager::dataAdded, this, &BarPlot::update);
 
    connect(_channelMan, &ChannelManager::numOfChannelsChanged, this, &BarPlot::update);
 

	
 
    // connect to menu
 
    connect(&menu->darkBackgroundAction, SELECT<bool>::OVERLOAD_OF(&QAction::toggled),
 
            this, &BarPlot::darkBackground);
 
    darkBackground(menu->darkBackgroundAction.isChecked());
 
}
 

	
 
void BarPlot::update()
 
@@ -52,3 +58,17 @@ void BarPlot::setYAxis(bool autoScaled, 
 
        setAxisScale(QwtPlot::yLeft, yMin, yMax);
 
    }
 
}
 

	
 

	
 
void BarPlot::darkBackground(bool enabled)
 
{
 
    if (enabled)
 
    {
 
        setCanvasBackground(QBrush(Qt::black));
 
    }
 
    else
 
    {
 
        setCanvasBackground(QBrush(Qt::white));
 
    }
 
    replot();
 
}
src/barplot.h
Show inline comments
 
@@ -23,6 +23,7 @@
 
#include <qwt_plot.h>
 

	
 
#include "channelmanager.h"
 
#include "plotmenu.h"
 
#include "barchart.h"
 

	
 
class BarPlot : public QwtPlot
 
@@ -30,14 +31,19 @@ class BarPlot : public QwtPlot
 
    Q_OBJECT
 

	
 
public:
 
    explicit BarPlot(ChannelManager* channelMan, QWidget* parent = 0);
 
    explicit BarPlot(ChannelManager* channelMan,
 
                     PlotMenu* menu,
 
                     QWidget* parent = 0);
 

	
 
public slots:
 
    /// Set the Y axis
 
    void setYAxis(bool autoScaled, double yMin = 0, double yMax = 1);
 
    /// Enable/disable dark background
 
    void darkBackground(bool enabled);
 

	
 
private:
 
    ChannelManager* _channelMan;
 
    PlotMenu* _menu;
 
    BarChart barChart;
 

	
 
    QVector<double> chartData() const;
src/mainwindow.cpp
Show inline comments
 
@@ -508,7 +508,7 @@ void MainWindow::showBarPlot(bool show)
 
{
 
    if (show)
 
    {
 
        auto plot = new BarPlot(&channelMan);
 
        auto plot = new BarPlot(&channelMan, &plotMenu);
 
        plot->setYAxis(plotControlPanel.autoScale(),
 
                       plotControlPanel.yMin(),
 
                       plotControlPanel.yMax());
0 comments (0 inline, 0 general)