Changeset - 11e2033df414
[Not reviewed]
default
0 3 0
Hasan Yavuz Ă–ZDERYA - 10 years ago 2016-03-20 12:15:46
hy@ozderya.net
added a simple legend
3 files changed with 5 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/mainwindow.cpp
Show inline comments
 
@@ -154,13 +154,13 @@ MainWindow::MainWindow(QWidget *parent) 
 
                     &MainWindow::onNumOfChannelsChanged);
 

	
 
    // init channel data and curve list
 
    for (unsigned int i = 0; i < numOfChannels; i++)
 
    {
 
        channelBuffers.append(new FrameBuffer(numOfSamples));
 
        curves.append(new QwtPlotCurve());
 
        curves.append(new QwtPlotCurve(QString("Channel %1").arg(i+1)));
 
        curves[i]->setSamples(channelBuffers[i]);
 
        curves[i]->setPen(Plot::makeColor(i));
 
        curves[i]->attach(ui->plot);
 
    }
 

	
 
    // init auto scale
 
@@ -341,13 +341,13 @@ void MainWindow::onNumOfChannelsChanged(
 
    if (numOfChannels > oldNum)
 
    {
 
        // add new channels
 
        for (unsigned int i = 0; i < numOfChannels - oldNum; i++)
 
        {
 
            channelBuffers.append(new FrameBuffer(numOfSamples));
 
            curves.append(new QwtPlotCurve());
 
            curves.append(new QwtPlotCurve(QString("Channel %1").arg(oldNum+i+1)));
 
            curves.last()->setSamples(channelBuffers.last());
 
            curves.last()->setPen(Plot::makeColor(curves.length()-1));
 
            curves.last()->attach(ui->plot);
 
        }
 
    }
 
    else if(numOfChannels < oldNum)
src/plot.cpp
Show inline comments
 
@@ -36,12 +36,13 @@ Plot::Plot(QWidget* parent) :
 
    isAutoScaled = true;
 

	
 
    QObject::connect(&zoomer, &Zoomer::unzoomed, this, &Plot::unzoomed);
 

	
 
    zoomer.setZoomBase();
 
    grid.attach(this);
 
    legend.attach(this);
 

	
 
    showGrid(false);
 
    darkBackground(false);
 

	
 
    _showGridAction.setToolTip("Show Grid");
 
    _showMinorGridAction.setToolTip("Show Minor Grid");
src/plot.h
Show inline comments
 
@@ -23,12 +23,13 @@
 
#include <QColor>
 
#include <QList>
 
#include <QAction>
 
#include <qwt_plot.h>
 
#include <qwt_plot_grid.h>
 
#include <qwt_plot_shapeitem.h>
 
#include <qwt_plot_legenditem.h>
 

	
 
#include "zoomer.h"
 
#include "scalezoomer.h"
 
#include "plotsnapshotoverlay.h"
 

	
 
class Plot : public QwtPlot
 
@@ -48,12 +49,13 @@ private:
 
    bool isAutoScaled;
 
    double yMin, yMax;
 
    Zoomer zoomer;
 
    ScaleZoomer sZoomer;
 
    QwtPlotGrid grid;
 
    PlotSnapshotOverlay* snapshotOverlay;
 
    QwtPlotLegendItem legend;
 

	
 
    QAction _showGridAction;
 
    QAction _showMinorGridAction;
 
    QAction _unzoomAction;
 
    QAction _darkBackgroundAction;
 

	
0 comments (0 inline, 0 general)