-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRecordProcessorsPanel.cpp
More file actions
96 lines (90 loc) · 3.05 KB
/
Copy pathRecordProcessorsPanel.cpp
File metadata and controls
96 lines (90 loc) · 3.05 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include "RecordProcessorsPanel.h"
#include "ui_RecordProcessorsPanel.h"
#include "BinaryFileWriter.h"
RecordProcessorsPanel::RecordProcessorsPanel(QWidget *parent) :
QWidget(parent),
ui(new Ui::RecordProcessorsPanel)
{
ui->setupUi(this);
}
void RecordProcessorsPanel::initialize(ApplicationContext *context)
{
this->DigitizerGUIComponent::initialize(context);
this->context = context;
this->scopeUpdater = context->scopeUpdater;
this->autosetFileSaver();
this->ui->fileTypeSelector->connect(
this->ui->fileTypeSelector,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
[=](int index){
this->config->setFileSaveMode(static_cast<ApplicationConfiguration::FILE_SAVE_MODES>(index));
this->autosetFileSaver();
}
);
this->ui->updateScopeCB->connect(
this->ui->updateScopeCB, &QCheckBox::stateChanged,
[=](int state) {
this->config->setUpdateScopeEnabled(state?true:false);
this->autosetUpdateScope();
}
);
this->ui->softwareTrigger->connect(
this->ui->softwareTrigger, &QAbstractButton::clicked,
[=]() {
this->context->digitizer->SWTrig();
}
);
}
void RecordProcessorsPanel::reloadUI()
{
this->ui->fileTypeSelector->setCurrentIndex(this->config->getFileSaveMode());
this->ui->updateScopeCB->setChecked(this->config->getUpdateScopeEnabled());
}
void RecordProcessorsPanel::autosetFileSaver()
{
if(this->fileSaver)
{
this->digitizer->removeRecordProcessor(this->fileSaver.get());
}
switch(this->config->getFileSaveMode())
{
default:
spdlog::error("Unsupported file save mode. Defaulting to disabled.");
case ApplicationConfiguration::FILE_SAVE_MODES::DISABLED:
this->fileSaver.reset();
break;
case ApplicationConfiguration::FILE_SAVE_MODES::BINARY:
this->fileSaver = std::unique_ptr<IRecordProcessor>(new BinaryFileWriter(this->digitizer->getFileSizeLimit()));
break;
case ApplicationConfiguration::FILE_SAVE_MODES::BINARY_VERBOSE:
this->fileSaver = std::unique_ptr<IRecordProcessor>(new VerboseBinaryWriter(this->digitizer->getFileSizeLimit()));
break;
}
if(this->fileSaver)
{
this->digitizer->appendRecordProcessor(this->fileSaver.get());
}
this->context->fileSaver = this->fileSaver.get();
}
void RecordProcessorsPanel::autosetUpdateScope()
{
if(this->config->getUpdateScopeEnabled() && !this->scopeUpdaterAdded)
{
this->digitizer->appendRecordProcessor(this->scopeUpdater);
this->scopeUpdaterAdded = true;
}
else if(this->scopeUpdaterAdded)
{
this->digitizer->removeRecordProcessor(this->scopeUpdater);
this->scopeUpdaterAdded = false;
}
}
RecordProcessorsPanel::~RecordProcessorsPanel()
{
delete ui;
}
void RecordProcessorsPanel::enableVolatileSettings(bool enabled)
{
this->ui->updateScopeCB->setEnabled(enabled);
this->ui->fileTypeSelector->setEnabled(enabled);
}