Changeset - 5a149e786568
[Not reviewed]
default
0 4 0
Hasan Yavuz ÖZDERYA - 8 years ago 2017-04-30 12:59:48
hy@ozderya.net
fix for snapshot x axis being 0-1 at first display and glitch at later displays
4 files changed with 9 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/mainwindow.cpp
Show inline comments
 
@@ -136,13 +136,13 @@ MainWindow::MainWindow(QWidget *parent) 
 

	
 
    // plot control signals
 
    connect(&plotControlPanel, &PlotControlPanel::numOfSamplesChanged,
 
            this, &MainWindow::onNumOfSamplesChanged);
 

	
 
    connect(&plotControlPanel, &PlotControlPanel::numOfSamplesChanged,
 
            plotMan, &PlotManager::onNumOfSamplesChanged);
 
            plotMan, &PlotManager::setNumOfSamples);
 

	
 
    connect(&plotControlPanel, &PlotControlPanel::yScaleChanged,
 
            plotMan, &PlotManager::setYAxis);
 

	
 
    connect(&plotControlPanel, &PlotControlPanel::xScaleChanged,
 
            plotMan, &PlotManager::setXAxis);
 
@@ -218,13 +218,13 @@ MainWindow::MainWindow(QWidget *parent) 
 

	
 
    // init scales
 
    plotMan->setYAxis(plotControlPanel.autoScale(),
 
                      plotControlPanel.yMin(), plotControlPanel.yMax());
 
    plotMan->setXAxis(plotControlPanel.xAxisAsIndex(),
 
                      plotControlPanel.xMin(), plotControlPanel.xMax());
 
    plotMan->onNumOfSamplesChanged(numOfSamples);
 
    plotMan->setNumOfSamples(numOfSamples);
 

	
 
    // Init sps (sample per second) counter
 
    spsLabel.setText("0sps");
 
    spsLabel.setToolTip("samples per second (per channel)");
 
    ui->statusBar->addPermanentWidget(&spsLabel);
 
    QObject::connect(&dataFormatPanel,
src/plotmanager.cpp
Show inline comments
 
@@ -505,13 +505,13 @@ void PlotManager::flashSnapshotOverlay()
 
    for (auto plot : plotWidgets)
 
    {
 
        plot->flashSnapshotOverlay(darkBackgroundAction.isChecked());
 
    }
 
}
 

	
 
void PlotManager::onNumOfSamplesChanged(unsigned value)
 
void PlotManager::setNumOfSamples(unsigned value)
 
{
 
    _numOfSamples = value;
 
    for (auto plot : plotWidgets)
 
    {
 
        plot->setNumOfSamples(value);
 
        if (_xAxisAsIndex) plot->setXAxis(0, value);
src/plotmanager.h
Show inline comments
 
@@ -70,13 +70,13 @@ public slots:
 
    void setYAxis(bool autoScaled, double yMin = 0, double yMax = 1);
 
    /// Set the X axis
 
    void setXAxis(bool asIndex, double xMin = 0 , double xMax = 1);
 
    /// Display an animation for snapshot
 
    void flashSnapshotOverlay();
 
    /// Should be called to update zoom base
 
    void onNumOfSamplesChanged(unsigned value);
 
    void setNumOfSamples(unsigned value);
 

	
 
private:
 
    bool isMulti;
 
    QWidget* _plotArea;
 
    QVBoxLayout* layout; ///< layout of the `plotArea`
 
    QScrollArea* scrollArea;
src/snapshotview.cpp
Show inline comments
 
/*
 
  Copyright © 2015 Hasan Yavuz Özderya
 
  Copyright © 2017 Hasan Yavuz Özderya
 

	
 
  This file is part of serialplot.
 

	
 
  serialplot is free software: you can redistribute it and/or modify
 
  it under the terms of the GNU General Public License as published by
 
  the Free Software Foundation, either version 3 of the License, or
 
@@ -26,23 +26,25 @@ SnapshotView::SnapshotView(QWidget *pare
 
    renameDialog(this)
 
{
 
    _snapshot = snapshot;
 

	
 
    ui->setupUi(this);
 

	
 
    plotMan = new PlotManager(ui->plotArea, snapshot->infoModel());
 
    plotMan = new PlotManager(ui->plotArea, snapshot->infoModel(), this);
 

	
 
    ui->menuSnapshot->insertAction(ui->actionClose, snapshot->deleteAction());
 
    this->setWindowTitle(snapshot->displayName());
 

	
 
    // initialize curves
 
    unsigned numOfChannels = snapshot->data.size();
 
    unsigned numOfSamples = snapshot->data[0].size();
 
    for (unsigned ci = 0; ci < numOfChannels; ci++)
 
    {
 
        plotMan->addCurve(snapshot->channelName(ci), snapshot->data[ci]);
 
    }
 
    plotMan->setNumOfSamples(numOfSamples);
 

	
 
    renameDialog.setWindowTitle("Rename Snapshot");
 
    renameDialog.setLabelText("Enter new name:");
 
    connect(ui->actionRename, &QAction::triggered,
 
            this, &SnapshotView::showRenameDialog);
 

	
 
@@ -59,12 +61,13 @@ SnapshotView::SnapshotView(QWidget *pare
 
SnapshotView::~SnapshotView()
 
{
 
    for (auto curve : curves)
 
    {
 
        delete curve;
 
    }
 
    delete plotMan;
 
    delete ui;
 
}
 

	
 
void SnapshotView::closeEvent(QCloseEvent *event)
 
{
 
    QMainWindow::closeEvent(event);
0 comments (0 inline, 0 general)