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(new 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 Q_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
100
101//=============================================================================================================
102
103QSharedPointer<FilterDesignView> FilterSettingsView::getFilterView()
104{
105 return m_pFilterView;
106}
107
108//=============================================================================================================
109
111{
112 return m_pUi->m_pCheckBoxActivateFilter->isChecked();
113}
114
115//=============================================================================================================
116
118{
119 //Update min max of spin boxes to nyquist
120 double nyquistFrequency = dSFreq/2;
121
122 m_pUi->m_pDoubleSpinBoxFrom->setMaximum(nyquistFrequency);
123 m_pUi->m_pDoubleSpinBoxTo->setMaximum(nyquistFrequency);
124
125 if(m_pUi->m_pDoubleSpinBoxFrom->value() > dSFreq/2) {
126 m_pUi->m_pDoubleSpinBoxFrom->setValue(dSFreq/2);
127 }
128
129 if(m_pUi->m_pDoubleSpinBoxTo->value() > dSFreq/2) {
130 m_pUi->m_pDoubleSpinBoxTo->setValue(dSFreq/2);
131 }
132
133 m_pFilterView->setSamplingRate(dSFreq);
134}
135
136//=============================================================================================================
137
139{
140 if(m_sSettingsPath.isEmpty()) {
141 return;
142 }
143
144 QSettings settings("MNECPP");
145
146 settings.setValue(m_sSettingsPath + QString("/FilterSettingsView/filterActivated"), m_pUi->m_pCheckBoxActivateFilter->isChecked());
147 settings.setValue(m_sSettingsPath + QString("/FilterSettingsView/filterFrom"), m_pUi->m_pDoubleSpinBoxFrom->value());
148 settings.setValue(m_sSettingsPath + QString("/FilterSettingsView/filterTo"), m_pUi->m_pDoubleSpinBoxTo->value());
149 settings.setValue(m_sSettingsPath + QString("/FilterSettingsView/filterChannelType"), m_pUi->m_pcomboBoxChannelTypes->currentText());
150}
151
152//=============================================================================================================
153
155{
156 if(m_sSettingsPath.isEmpty()) {
157 return;
158 }
159
160 QSettings settings("MNECPP");
161
162 m_pUi->m_pCheckBoxActivateFilter->setChecked(settings.value(m_sSettingsPath + QString("/FilterSettingsView/filterActivated"), false).toBool());
163 m_pUi->m_pDoubleSpinBoxTo->setValue(settings.value(m_sSettingsPath + QString("/FilterSettingsView/filterTo"), 0).toDouble());
164 m_pUi->m_pDoubleSpinBoxFrom->setValue(settings.value(m_sSettingsPath + QString("/FilterSettingsView/filterFrom"), 0).toDouble());
165 m_pUi->m_pcomboBoxChannelTypes->setCurrentText(settings.value(m_sSettingsPath + QString("/FilterSettingsView/filterChannelType"), "All").toString());
166}
167
168//=============================================================================================================
169
171{
172 switch(mode) {
174 m_pUi->m_pPushButtonShowFilterOptions->hide();
175 break;
176 default: // default is research mode
177 m_pUi->m_pPushButtonShowFilterOptions->show();
178 break;
179 }
180}
181
182//=============================================================================================================
183
185{
186 switch(mode) {
188 break;
189 default: // default is realtime mode
190 break;
191 }
192}
193
194//=============================================================================================================
195
197{
198 if(m_pFilterView->isActiveWindow()) {
199 m_pFilterView->hide();
200 } else {
201 m_pFilterView->activateWindow();
202 m_pFilterView->show();
203 m_pFilterView->updateFilterPlot();
204 }
205}
206
207//=============================================================================================================
208
210{
211 emit filterActivationChanged(m_pUi->m_pCheckBoxActivateFilter->isChecked());
212
213 saveSettings();
214}
215
216//=============================================================================================================
217
219{
220 m_pFilterView->setFrom(m_pUi->m_pDoubleSpinBoxFrom->value());
221
222 saveSettings();
223}
224
225//=============================================================================================================
226
228{
229 if(m_pUi->m_pDoubleSpinBoxFrom->value() >= 2) {
230 m_pUi->m_pDoubleSpinBoxFrom->setMaximum(m_pUi->m_pDoubleSpinBoxTo->value()-1);
231 } else {
232 m_pUi->m_pDoubleSpinBoxFrom->setMaximum(m_pUi->m_pDoubleSpinBoxTo->value());
233 }
234
235 m_pFilterView->setTo(m_pUi->m_pDoubleSpinBoxTo->value());
236
237 saveSettings();
238}
239
240//=============================================================================================================
241
243{
244 m_pFilterView->setChannelType(sType);
245
246 saveSettings();
247}
248
249//=============================================================================================================
250
252{
253
254}
Interactive FIR / IIR filter design GUI with a live magnitude / phase preview.
Compact filter on/off + bandwidth panel that pops up the full FilterDesignView on demand.
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)
Ui::FilterSettingsViewWidget * m_pUi
QSharedPointer< FilterDesignView > m_pFilterView