Changeset - 432ae2fe0870
[Not reviewed]
Merge scrollbar-exp
0 5 0
Hasan Yavuz Ă–ZDERYA - 8 years ago 2017-08-16 09:23:56
hy@ozderya.net
Merge with default
5 files changed with 50 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/framebufferseries.cpp
Show inline comments
 
@@ -17,6 +17,7 @@
 
  along with serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include <math.h>
 
#include "framebufferseries.h"
 

	
 
FrameBufferSeries::FrameBufferSeries(FrameBuffer* buffer)
 
@@ -73,15 +74,15 @@ void FrameBufferSeries::setRectOfInteres
 
{
 
    if (xAsIndex)
 
    {
 
        int_index_start = rect.left();
 
        int_index_end = rect.right();
 
        int_index_start = floor(rect.left())-1;
 
        int_index_end = ceil(rect.right())+1;
 
    }
 
    else
 
    {
 
        double xsize = _xmax - _xmin;
 
        size_t bsize = _buffer->size();
 
        int_index_start =  bsize * (rect.left()-_xmin) / xsize;
 
        int_index_end = bsize * (rect.right()-_xmin) / xsize;
 
        int_index_start =  floor(bsize * (rect.left()-_xmin) / xsize)-1;
 
        int_index_end = ceil(bsize * (rect.right()-_xmin) / xsize)+1;
 
    }
 

	
 
    int_index_start = std::max(int_index_start, (size_t) 0);
src/plot.cpp
Show inline comments
 
@@ -73,6 +73,16 @@ Plot::Plot(QWidget* parent) :
 
    demoIndicator.setText(demoText);
 
    demoIndicator.hide();
 
    demoIndicator.attach(this);
 

	
 
    // init no channels are visible indicator
 
    QwtText noChannelText(" No Visible Channels ");
 
    noChannelText.setColor(QColor("white"));
 
    noChannelText.setBackgroundBrush(Qt::darkBlue);
 
    noChannelText.setBorderRadius(4);
 
    noChannelText.setRenderFlags(Qt::AlignHCenter | Qt::AlignVCenter);
 
    noChannelIndicator.setText(noChannelText);
 
    noChannelIndicator.hide();
 
    noChannelIndicator.attach(this);
 
}
 

	
 
Plot::~Plot()
 
@@ -164,6 +174,12 @@ void Plot::showDemoIndicator(bool show)
 
    replot();
 
}
 

	
 
void Plot::showNoChannel(bool show)
 
{
 
    noChannelIndicator.setVisible(show);
 
    replot();
 
}
 

	
 
void Plot::unzoom()
 
{
 
    zoomer.zoom(0);
src/plot.h
Show inline comments
 
@@ -57,6 +57,7 @@ public slots:
 
    void showMinorGrid(bool show = true);
 
    void showLegend(bool show = true);
 
    void showDemoIndicator(bool show = true);
 
    void showNoChannel(bool show = true);
 
    void unzoom();
 
    void darkBackground(bool enabled = true);
 
    void setYAxis(bool autoScaled, double yMin = 0, double yMax = 1);
 
@@ -88,6 +89,7 @@ private:
 
    PlotSnapshotOverlay* snapshotOverlay;
 
    QwtPlotLegendItem legend;
 
    QwtPlotTextLabel demoIndicator;
 
    QwtPlotTextLabel noChannelIndicator;
 
    ShowSymbols showSymbols;
 

	
 
    void resetAxes();
src/plotmanager.cpp
Show inline comments
 
@@ -17,6 +17,7 @@
 
  along with serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include <algorithm>
 
#include <QActionGroup>
 
#include <QMetaEnum>
 
#include <QtDebug>
 
@@ -46,6 +47,7 @@ PlotManager::PlotManager(QWidget* plotAr
 
    _infoModel = infoModel;
 
    _numOfSamples = 1;
 
    showSymbols = Plot::ShowSymbolsAuto;
 
    emptyPlot = NULL;
 

	
 
    // initalize layout and single widget
 
    isMulti = false;
 
@@ -156,6 +158,7 @@ PlotManager::~PlotManager()
 
    }
 

	
 
    if (scrollArea != NULL) delete scrollArea;
 
    if (emptyPlot != NULL) delete emptyPlot;
 
}
 

	
 
void PlotManager::onChannelInfoChanged(const QModelIndex &topLeft,
 
@@ -189,6 +192,8 @@ void PlotManager::onChannelInfoChanged(c
 
        }
 
    }
 

	
 
    checkNoVisChannels();
 

	
 
    // replot single widget
 
    if (!isMulti)
 
    {
 
@@ -198,6 +203,20 @@ void PlotManager::onChannelInfoChanged(c
 
    }
 
}
 

	
 
void PlotManager::checkNoVisChannels()
 
{
 
    // if all channels are hidden show indicator
 
    bool allhidden = std::none_of(curves.cbegin(), curves.cend(),
 
                                  [](QwtPlotCurve* c) {return c->isVisible();});
 

	
 
    plotWidgets[0]->showNoChannel(allhidden);
 
    if (isMulti)
 
    {
 
        plotWidgets[0]->showNoChannel(allhidden);
 
        plotWidgets[0]->setVisible(true);
 
    }
 
}
 

	
 
void PlotManager::setMulti(bool enabled)
 
{
 
    if (enabled == isMulti) return;
 
@@ -224,7 +243,9 @@ void PlotManager::setMulti(bool enabled)
 
        // add new widgets and attach
 
        for (auto curve : curves)
 
        {
 
            curve->attach(addPlotWidget());
 
            auto plot = addPlotWidget();
 
            plot->setVisible(curve->isVisible());
 
            curve->attach(plot);
 
        }
 
    }
 
    else
 
@@ -238,6 +259,8 @@ void PlotManager::setMulti(bool enabled)
 
            curve->attach(plot);
 
        }
 
    }
 

	
 
    checkNoVisChannels();
 
}
 

	
 
void PlotManager::setupLayout(bool multiPlot)
src/plotmanager.h
Show inline comments
 
@@ -96,6 +96,7 @@ private:
 
    QScrollArea* scrollArea;
 
    QList<QwtPlotCurve*> curves;
 
    QList<Plot*> plotWidgets;
 
    Plot* emptyPlot;  ///< for displaying when all channels are hidden
 
    ChannelInfoModel* _infoModel;
 
    bool isDemoShown;
 
    bool _autoScaled;
 
@@ -128,6 +129,8 @@ private:
 
    /// Common part of overloaded `addCurve` functions
 
    void _addCurve(QwtPlotCurve* curve);
 
    void setSymbols(Plot::ShowSymbols shown);
 
    /// Check and make sure "no visible channels" text is shown
 
    void checkNoVisChannels();
 

	
 
private slots:
 
    void showGrid(bool show = true);
0 comments (0 inline, 0 general)