Changeset - 9bdc741a9793
[Not reviewed]
plot-manager
0 3 0
Hasan Yavuz Ă–ZDERYA - 9 years ago 2016-08-28 16:00:59
hy@ozderya.net
implemented plotMan.setAxis
3 files changed with 25 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/mainwindow.cpp
Show inline comments
 
@@ -124,7 +124,7 @@ MainWindow::MainWindow(QWidget *parent) 
 
            this, &MainWindow::onNumOfSamplesChanged);
 

	
 
    connect(&plotControlPanel, &PlotControlPanel::scaleChanged,
 
            ui->plot, &Plot::setAxis);
 
            plotMan, &PlotManager::setAxis);
 

	
 
    connect(&plotControlPanel, &PlotControlPanel::multiPlotChanged,
 
            plotMan, &PlotManager::setMulti);
 
@@ -170,10 +170,9 @@ MainWindow::MainWindow(QWidget *parent) 
 
        plotMan->addCurve(channelMan.channelName(i), channelMan.channelBuffer(i));
 
    }
 

	
 
    // TODO: plotman
 
    // init auto scale
 
    ui->plot->setAxis(plotControlPanel.autoScale(),
 
                      plotControlPanel.yMin(), plotControlPanel.yMax());
 
    plotMan->setAxis(plotControlPanel.autoScale(),
 
                     plotControlPanel.yMin(), plotControlPanel.yMax());
 

	
 
    // Init sps (sample per second) counter
 
    spsLabel.setText("0sps");
src/plotmanager.cpp
Show inline comments
 
@@ -33,9 +33,13 @@ PlotManager::PlotManager(QWidget* plotAr
 
    darkBackgroundAction("Dark Background", this),
 
    showLegendAction("Legend", this)
 
{
 
    _autoScaled = true;
 
    _yMin = 0;
 
    _yMax = 1;
 
    isDemoShown = false;
 

	
 
    // initalize layout and single widget
 
    isMulti = false;
 
    isDemoShown = false;
 
    scrollArea = NULL;
 
    setupLayout(isMulti);
 
    addPlotWidget();
 
@@ -176,6 +180,7 @@ Plot* PlotManager::addPlotWidget()
 
    plot->showMinorGrid(showMinorGridAction.isChecked());
 
    plot->showLegend(showLegendAction.isChecked());
 
    plot->showDemoIndicator(isDemoShown);
 
    plot->setAxis(_autoScaled, _yMin, _yMax);
 

	
 
    return plot;
 
}
 
@@ -312,3 +317,14 @@ void PlotManager::darkBackground(bool en
 
        plot->darkBackground(enabled);
 
    }
 
}
 

	
 
void PlotManager::setAxis(bool autoScaled, double yAxisMin, double yAxisMax)
 
{
 
    _autoScaled = autoScaled;
 
    _yMin = yAxisMin;
 
    _yMax = yAxisMax;
 
    for (auto plot : plotWidgets)
 
    {
 
        plot->setAxis(autoScaled, yAxisMin, yAxisMax);
 
    }
 
}
src/plotmanager.h
Show inline comments
 
@@ -61,6 +61,8 @@ public slots:
 
    void replot();
 
    /// Enable display of a "DEMO" label on each plot
 
    void showDemoIndicator(bool show = true);
 
    /// Set the Y axis
 
    void setAxis(bool autoScaled, double yMin = 0, double yMax = 1);
 

	
 
private:
 
    bool isMulti;
 
@@ -70,6 +72,9 @@ private:
 
    QList<QwtPlotCurve*> curves;
 
    QList<Plot*> plotWidgets;
 
    bool isDemoShown;
 
    bool _autoScaled;
 
    double _yMin;
 
    double _yMax;
 

	
 
    // menu actions
 
    QAction showGridAction;
0 comments (0 inline, 0 general)