v2.0.0
Loading...
Searching...
No Matches
filtersettingsview.cpp
Go to the documentation of this file.
1//=============================================================================================================
15
16//=============================================================================================================
17// INCLUDES
18//=============================================================================================================
19
20#include "filtersettingsview.h"
21
22#include "filterdesignview.h"
23
24#include "ui_filtersettingsview.h"
25
26//=============================================================================================================
27// QT INCLUDES
28//=============================================================================================================
29
30#include <QCheckBox>
31#include <QGridLayout>
32#include <QPushButton>
33#include <QSettings>
34
35//=============================================================================================================
36// EIGEN INCLUDES
37//=============================================================================================================
38
39//=============================================================================================================
40// USED NAMESPACES
41//=============================================================================================================
42
43using namespace DISPLIB;
44
45//=============================================================================================================
46// DEFINE MEMBER METHODS
47//=============================================================================================================
48
49FilterSettingsView::FilterSettingsView(const QString& sSettingsPath,
50 QWidget* parent,
51 Qt::WindowFlags f)
52: AbstractView(parent, f)
53, m_pUi(std::make_unique<Ui::FilterSettingsViewWidget>())
54{
55 m_sSettingsPath = sSettingsPath;
56 this->setWindowTitle("Filter Settings");
57
58 m_pUi->setupUi(this);
59
61
62 //Create and connect design viewer
63 m_pFilterView = FilterDesignView::SPtr::create(m_sSettingsPath,
64 nullptr,
65 Qt::Dialog);
66
67 connect(m_pFilterView.data(), &FilterDesignView::updateFilterFrom, [=, this](double dFrom) {
68 m_pUi->m_pDoubleSpinBoxFrom->setValue(dFrom);
69 });
70 connect(m_pFilterView.data(), &FilterDesignView::updateFilterTo, [=, this](double dTo) {
71 m_pUi->m_pDoubleSpinBoxTo->setValue(dTo);
72 });
73
76
77 m_pUi->m_pDoubleSpinBoxFrom->setValue(m_pFilterView->getFrom());
78 m_pUi->m_pDoubleSpinBoxTo->setValue(m_pFilterView->getTo());
79
80 //Connect GUI elements
81 connect(m_pUi->m_pCheckBoxActivateFilter, &QCheckBox::toggled,
83 connect(m_pUi->m_pPushButtonShowFilterOptions, &QPushButton::clicked,
85 connect(m_pUi->m_pDoubleSpinBoxFrom, &QDoubleSpinBox::editingFinished,
87 connect(m_pUi->m_pDoubleSpinBoxTo, &QDoubleSpinBox::editingFinished,
89 connect(m_pUi->m_pcomboBoxChannelTypes, &QComboBox::currentTextChanged,
91}
92
93//=============================================================================================================
94
99
100//=============================================================================================================
101
102QSharedPointer<FilterDesignView> FilterSettingsView::getFilterView()
103{
104 return m_pFilterView;
105}
106
107//=============================================================================================================
108
110{
111 return m_pUi->m_pCheckBoxActivateFilter->isChecked();
112}
113
114//=============================================================================================================
115
117{
118 //Update min max of spin boxes to nyquist
119 double nyquistFrequency = dSFreq / 2;
120
121 m_pUi->m_pDoubleSpinBoxFrom->setMaximum(nyquistFrequency);
122 m_pUi->m_pDoubleSpinBoxTo->setMaximum(nyquistFrequency);
123
124 if (m_pUi->m_pDoubleSpinBoxFrom->value() > dSFreq / 2) {
125 m_pUi->m_pDoubleSpinBoxFrom->setValue(dSFreq / 2);
126 }
127
128 if (m_pUi->m_pDoubleSpinBoxTo->value() > dSFreq / 2) {
129 m_pUi->m_pDoubleSpinBoxTo->setValue(dSFreq / 2);
130 }
131
132 m_pFilterView->setSamplingRate(dSFreq);
133}
134
135//=============================================================================================================
136
138{
139 if (m_sSettingsPath.isEmpty()) {
140 return;
141 }
142
143 QSettings settings("MNECPP");
144
145 settings.setValue(m_sSettingsPath + QString("/FilterSettingsView/filterActivated"), m_pUi->m_pCheckBoxActivateFilter->isChecked());
146 settings.setValue(m_sSettingsPath + QString("/FilterSettingsView/filterFrom"), m_pUi->m_pDoubleSpinBoxFrom->value());
147 settings.setValue(m_sSettingsPath + QString("/FilterSettingsView/filterTo"), m_pUi->m_pDoubleSpinBoxTo->value());
148 settings.setValue(m_sSettingsPath + QString("/FilterSettingsView/filterChannelType"), m_pUi->m_pcomboBoxChannelTypes->currentText());
149}
150
151//=============================================================================================================
152
154{
155 if (m_sSettingsPath.isEmpty()) {
156 return;
157 }
158
159 QSettings settings("MNECPP");
160
161 m_pUi->m_pCheckBoxActivateFilter->setChecked(settings.value(m_sSettingsPath + QString("/FilterSettingsView/filterActivated"), false).toBool());
162 m_pUi->m_pDoubleSpinBoxTo->setValue(settings.value(m_sSettingsPath + QString("/FilterSettingsView/filterTo"), 0).toDouble());
163 m_pUi->m_pDoubleSpinBoxFrom->setValue(settings.value(m_sSettingsPath + QString("/FilterSettingsView/filterFrom"), 0).toDouble());
164 m_pUi->m_pcomboBoxChannelTypes->setCurrentText(settings.value(m_sSettingsPath + QString("/FilterSettingsView/filterChannelType"), "All").toString());
165}
166
167//=============================================================================================================
168
170{
171 switch (mode) {
173 m_pUi->m_pPushButtonShowFilterOptions->hide();
174 break;
175 default: // default is research mode
176 m_pUi->m_pPushButtonShowFilterOptions->show();
177 break;
178 }
179}
180
181//=============================================================================================================
182
184{
185 switch (mode) {
187 break;
188 default: // default is realtime mode
189 break;
190 }
191}
192
193//=============================================================================================================
194
196{
197 if (m_pFilterView->isActiveWindow()) {
198 m_pFilterView->hide();
199 } else {
200 m_pFilterView->activateWindow();
201 m_pFilterView->show();
202 m_pFilterView->updateFilterPlot();
203 }
204}
205
206//=============================================================================================================
207
209{
210 emit filterActivationChanged(m_pUi->m_pCheckBoxActivateFilter->isChecked());
211
212 saveSettings();
213}
214
215//=============================================================================================================
216
218{
219 m_pFilterView->setFrom(m_pUi->m_pDoubleSpinBoxFrom->value());
220
221 saveSettings();
222}
223
224//=============================================================================================================
225
227{
228 if (m_pUi->m_pDoubleSpinBoxFrom->value() >= 2) {
229 m_pUi->m_pDoubleSpinBoxFrom->setMaximum(m_pUi->m_pDoubleSpinBoxTo->value() - 1);
230 } else {
231 m_pUi->m_pDoubleSpinBoxFrom->setMaximum(m_pUi->m_pDoubleSpinBoxTo->value());
232 }
233
234 m_pFilterView->setTo(m_pUi->m_pDoubleSpinBoxTo->value());
235
236 saveSettings();
237}
238
239//=============================================================================================================
240
242{
243 m_pFilterView->setChannelType(sType);
244
245 saveSettings();
246}
247
248//=============================================================================================================
249
Compact filter on/off + bandwidth panel that pops up the full DISPLIB::FilterDesignView on demand.
Interactive FIR / IIR filter design GUI with a live magnitude / phase preview.
2-D display widgets and visualisation helpers (charts, topography, colour maps).
AbstractView(QWidget *parent=0, Qt::WindowFlags f=Qt::Widget)
void guiStyleChanged(DISPLIB::AbstractView::StyleMode style)
void updateFilterFrom(double dFrom)
void updateFilterTo(double dTo)
void guiStyleChanged(DISPLIB::AbstractView::StyleMode style)
void filterActivationChanged(bool activated)
void onFilterChannelTypeChanged(const QString &sType)
QSharedPointer< FilterDesignView > getFilterView()
FilterSettingsView(const QString &sSettingsPath="", QWidget *parent=0, Qt::WindowFlags f=Qt::Widget)
void updateProcessingMode(ProcessingMode mode)
QSharedPointer< FilterDesignView > m_pFilterView
std::unique_ptr< Ui::FilterSettingsViewWidget > m_pUi