-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscopeplotbase.cpp
73 lines (67 loc) · 1.92 KB
/
scopeplotbase.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "scopeplotbase.h"
#include "scopeplot.h"
#include "analogplot.h"
#include "AnalogSignal.h"
#include "scopeplotcurve.h"
#include <QWidget>
#include <qwt_scale_map.h>
#include <qwt_plot_grid.h>
#include <qwt_legend.h>
#include <qwt_math.h>
#include <qcolor.h>
#include <qpainter.h>
#include <qframe.h>
#include <qwt_plot_spectrogram.h>
#include <qwt_plot_canvas.h>
#include <QDebug>
#include <QTimer>
#include <QColorDialog>
#include <qwt_plot_marker.h>
#include <qwt_plot_curve.h>
//#include "AnalogPlotZoomer.h"
ScopePlotBase::ScopePlotBase( QWidget *parent, AnalogPlot* pAnalogPlot )
:QwtPlot( parent ),
m_pAnalogPlot( pAnalogPlot )
{
setAutoReplot();
canvas()->installEventFilter(parent);
setCanvasBackground(QColor(Qt::black));
QwtLegend* legend = new QwtLegend();
//legend->setItemMode(QwtLegend::CheckableItem);
insertLegend( legend, QwtPlot::TopLegend);
//QObject::connect( this, SIGNAL(legendClicked(QwtPlotItem*) ), this, SLOT( legendClicked(QwtPlotItem *)) );
//QObject::connect( this, SIGNAL(legendChecked(QwtPlotItem*, bool) ), this, SLOT( legendChecked(QwtPlotItem *, bool)) );
m_pTimer = new QTimer;
m_pTimer->setSingleShot(true);
}
void ScopePlotBase::legendClicked(QwtPlotItem * plotItem)
{
QString name = plotItem->title().text();
QColorDialog dlgColor( plotItem->title().color() );
if( dlgColor.exec() == QDialog::Accepted )
{
m_pAnalogPlot->ChangeCurveColor( dlgColor.currentColor(), name );
}
}
void ScopePlotBase::legendChecked(QwtPlotItem * plotItem, bool on)
{
QString name = plotItem->title().text();
if (m_pTimer->isActive())
{
m_pTimer->stop();
legendClicked(plotItem);
}
else
{
m_pTimer->start(300);
}
ScopePlotCurve* pCurve = m_pAnalogPlot->GetPlotCurveFromName(name);
if (on)
{
pCurve->GetPlotCurve()->hide();
}
else
{
pCurve->GetPlotCurve()->show();
}
}