Changeset - 42da1825ce45
[Not reviewed]
plot-manager
0 3 0
Hasan Yavuz Ă–ZDERYA - 9 years ago 2016-08-25 01:34:48
hy@ozderya.net
implemented plotman.replot
3 files changed with 23 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/mainwindow.cpp
Show inline comments
 
@@ -138,13 +138,13 @@ MainWindow::MainWindow(QWidget *parent) 
 
    // init port signals
 
    QObject::connect(&(this->serialPort), SIGNAL(error(QSerialPort::SerialPortError)),
 
                     this, SLOT(onPortError(QSerialPort::SerialPortError)));
 

	
 
    // init data format and reader
 
    QObject::connect(&dataFormatPanel, &DataFormatPanel::dataAdded,
 
                     ui->plot, &QwtPlot::replot);
 
                     plotMan, &PlotManager::replot);
 

	
 
    QObject::connect(ui->actionPause, &QAction::triggered,
 
                     &dataFormatPanel, &DataFormatPanel::pause);
 

	
 
    // init data arrays and plot
 
    numOfSamples = plotControlPanel.numOfSamples();
 
@@ -294,20 +294,20 @@ required privileges or device is already
 
void MainWindow::clearPlot()
 
{
 
    for (unsigned ci = 0; ci < channelMan.numOfChannels(); ci++)
 
    {
 
        channelMan.channelBuffer(ci)->clear();
 
    }
 
    ui->plot->replot();
 
    plotMan->replot();
 
}
 

	
 
void MainWindow::onNumOfSamplesChanged(int value)
 
{
 
    numOfSamples = value;
 
    channelMan.setNumOfSamples(value);
 
    ui->plot->replot();
 
    plotMan->replot();
 
}
 

	
 
void MainWindow::onNumOfChannelsChanged(unsigned value)
 
{
 
    unsigned int oldNum = plotMan->numOfCurves();
 
    unsigned numOfChannels = value;
 
@@ -322,14 +322,13 @@ void MainWindow::onNumOfChannelsChanged(
 
    }
 
    else if(numOfChannels < oldNum)
 
    {
 
        plotMan->removeCurves(oldNum - numOfChannels);
 
    }
 

	
 
    // TODO: plotman.replot
 
    ui->plot->replot();
 
    plotMan->replot();
 
}
 

	
 
void MainWindow::onChannelNameChanged(unsigned channel, QString name)
 
{
 
    // This slot is triggered also when a new channel is added, in
 
    // this case curve list doesn't contain said channel. No worries,
 
@@ -356,25 +355,25 @@ void MainWindow::enableDemo(bool enabled
 
    {
 
        if (!serialPort.isOpen())
 
        {
 
            dataFormatPanel.enableDemo(true);
 
            ui->actionDemoMode->setChecked(true);
 
            demoIndicator.show();
 
            ui->plot->replot();
 
            plotMan->replot();
 
        }
 
        else
 
        {
 
            ui->actionDemoMode->setChecked(false);
 
        }
 
    }
 
    else
 
    {
 
        dataFormatPanel.enableDemo(false);
 
        ui->actionDemoMode->setChecked(false);
 
        demoIndicator.hide();
 
        ui->plot->replot();
 
        plotMan->replot();
 
    }
 
}
 

	
 
void MainWindow::onExportCsv()
 
{
 
    bool wasPaused = ui->actionPause->isChecked();
src/plotmanager.cpp
Show inline comments
 
@@ -201,6 +201,21 @@ Plot* PlotManager::plotWidget(unsigned c
 
    }
 
    else
 
    {
 
        return plotWidgets[0];
 
    }
 
}
 

	
 
void PlotManager::replot()
 
{
 
    if (isMulti)
 
    {
 
        for (auto plot : plotWidgets)
 
        {
 
            plot->replot();
 
        }
 
    }
 
    else
 
    {
 
        plotWidgets[0]->replot();
 
    }
 
}
src/plotmanager.h
Show inline comments
 
@@ -53,12 +53,14 @@ public:
 

	
 
signals:
 

	
 
public slots:
 
    /// Enable/Disable multiple plot display
 
    void setMulti(bool enabled);
 
    /// Update all plot widgets
 
    void replot();
 

	
 
private:
 
    bool isMulti;
 
    QWidget* _plotArea;
 
    QVBoxLayout* layout; ///< layout of the `plotArea`
 
    QScrollArea* scrollArea;
0 comments (0 inline, 0 general)