-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplotmodewidget.cpp
70 lines (54 loc) · 1.83 KB
/
plotmodewidget.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
#include "plotmodewidget.h"
#include <QVBoxLayout>
#include <QGroupBox>
PlotmodeWidget::PlotmodeWidget(QWidget *parent)
: QWidget{parent}
{
plotmodeSelector = new QComboBox;
upsamplingCheckbox = new QCheckBox("upsampling");
connectSamples = new QCheckBox("Connect Dots");
connectSamples->setChecked(true);
auto plotmodeLayout = new QHBoxLayout;
auto mainLayout = new QVBoxLayout;
plotmodeLayout->addWidget(plotmodeSelector);
plotmodeLayout->addWidget(upsamplingCheckbox);
plotmodeLayout->addWidget(connectSamples);
for (const PlotmodeDefinition& p : PlotmodeManager::getPlotmodeMap())
{
plotmodeSelector->addItem(p.name, p.plotMode);
}
auto plotmodeBox = new QGroupBox("Plot Mode");
plotmodeBox->setLayout(plotmodeLayout);
mainLayout->addWidget(plotmodeBox);
mainLayout->addStretch();
setLayout(mainLayout);
connect(plotmodeSelector, QOverload<int>::of(&QComboBox::activated), this, [this](){
auto p = getPlotmode();
connectSamples->setEnabled(!connectSamplesSweepOnly || (p == Sweep));
emit plotmodeChanged(getPlotmode());
});
connect(upsamplingCheckbox, &QCheckBox::toggled, this, [this](){
emit upsamplingChanged(upsamplingCheckbox->isChecked());
});
connect(connectSamples, &QCheckBox::stateChanged, this, [this]{
emit connectSamplesChanged(connectSamples->isChecked());
});
}
Plotmode PlotmodeWidget::getPlotmode() const
{
return plotmodeSelector->currentData(PlotmodeRole).value<Plotmode>();
}
void PlotmodeWidget::setPlotmode(Plotmode newPlotmode)
{
connectSamples->setEnabled(!connectSamplesSweepOnly || (newPlotmode == Sweep));
for(int i = 0; i < plotmodeSelector->count(); i++) {
if(plotmodeSelector->itemData(i, PlotmodeRole).value<Plotmode>() == newPlotmode) {
plotmodeSelector->setCurrentIndex(i);
break;
}
}
}
void PlotmodeWidget::setconnectSamples(bool val)
{
connectSamples->setChecked(val);
}