# HG changeset patch # User Hasan Yavuz Ă–ZDERYA # Date 2017-10-25 14:35:25 # Node ID da1c905338e1ec75235a89aacb4ea98ebb5dc6f9 # Parent c9828daaa5699b334fd3d8d03d96ba4842a41757 set y axis of bar plot diff --git a/src/barplot.cpp b/src/barplot.cpp --- a/src/barplot.cpp +++ b/src/barplot.cpp @@ -40,3 +40,15 @@ void BarPlot::update() barChart.resample(); replot(); } + +void BarPlot::setYAxis(bool autoScaled, double yMin, double yMax) +{ + if (autoScaled) + { + setAxisAutoScale(QwtPlot::yLeft); + } + else + { + setAxisScale(QwtPlot::yLeft, yMin, yMax); + } +} diff --git a/src/barplot.h b/src/barplot.h --- a/src/barplot.h +++ b/src/barplot.h @@ -32,6 +32,10 @@ class BarPlot : public QwtPlot public: explicit BarPlot(ChannelManager* channelMan, QWidget* parent = 0); +public slots: + /// Set the Y axis + void setYAxis(bool autoScaled, double yMin = 0, double yMax = 1); + private: ChannelManager* _channelMan; BarChart barChart; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -155,6 +155,10 @@ MainWindow::MainWindow(QWidget *parent) connect(&plotControlPanel, &PlotControlPanel::plotWidthChanged, plotMan, &PlotManager::setPlotWidth); + // secondary (bar) plot signals + connect(&plotControlPanel, &PlotControlPanel::yScaleChanged, + &barPlot, &BarPlot::setYAxis); + QObject::connect(ui->actionClear, SIGNAL(triggered(bool)), this, SLOT(clearPlot()));