mainwindow.cpp
1.82 KB
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
#include "mainwindow.h"
#include "plot.h"
#include "knob.h"
#include "wheelbox.h"
#include <qwt_scale_engine.h>
#include <qlabel.h>
#include <qlayout.h>
MainWindow::MainWindow(QWidget *parent):
QWidget(parent)
{
const double intervalLength = 10.0; // seconds
d_plot = new Plot(this);
d_plot->setIntervalLength(intervalLength);
d_amplitudeKnob = new Knob("Amplitude", 0.0, 200.0, this);
d_amplitudeKnob->setValue(160.0);
d_frequencyKnob = new Knob("Frequency [Hz]", 0.1, 20.0, this);
d_frequencyKnob->setValue(17.8);
d_intervalWheel = new WheelBox("Displayed [s]", 1.0, 100.0, 1.0, this);
d_intervalWheel->setValue(intervalLength);
d_timerWheel = new WheelBox("Sample Interval [ms]", 0.0, 20.0, 0.1, this);
d_timerWheel->setValue(10.0);
QVBoxLayout* vLayout1 = new QVBoxLayout();
vLayout1->addWidget(d_intervalWheel);
vLayout1->addWidget(d_timerWheel);
vLayout1->addStretch(10);
vLayout1->addWidget(d_amplitudeKnob);
vLayout1->addWidget(d_frequencyKnob);
QHBoxLayout *layout = new QHBoxLayout(this);
layout->addWidget(d_plot, 10);
layout->addLayout(vLayout1);
connect(d_amplitudeKnob, SIGNAL(valueChanged(double)),
SIGNAL(amplitudeChanged(double)));
connect(d_frequencyKnob, SIGNAL(valueChanged(double)),
SIGNAL(frequencyChanged(double)));
connect(d_timerWheel, SIGNAL(valueChanged(double)),
SIGNAL(signalIntervalChanged(double)));
connect(d_intervalWheel, SIGNAL(valueChanged(double)),
d_plot, SLOT(setIntervalLength(double)) );
}
void MainWindow::start()
{
d_plot->start();
}
double MainWindow::frequency() const
{
return d_frequencyKnob->value();
}
double MainWindow::amplitude() const
{
return d_amplitudeKnob->value();
}
double MainWindow::signalInterval() const
{
return d_timerWheel->value();
}