|
| 1 | +// SPDX-License-Identifier: GPL-2.0+ |
| 2 | + |
| 3 | +#include "DsoConfigAnalysisPage.h" |
| 4 | + |
| 5 | +DsoConfigAnalysisPage::DsoConfigAnalysisPage(DsoSettings *settings, |
| 6 | + QWidget *parent) |
| 7 | + : QWidget(parent), settings(settings) { |
| 8 | + // Initialize lists for comboboxes |
| 9 | + QStringList windowFunctionStrings; |
| 10 | + windowFunctionStrings << tr("Rectangular") << tr("Hamming") << tr("Hann") |
| 11 | + << tr("Cosine") << tr("Lanczos") << tr("Bartlett") |
| 12 | + << tr("Triangular") << tr("Gauss") |
| 13 | + << tr("Bartlett-Hann") << tr("Blackman") |
| 14 | + //<< tr("Kaiser") |
| 15 | + << tr("Nuttall") << tr("Blackman-Harris") |
| 16 | + << tr("Blackman-Nuttall") << tr("Flat top"); |
| 17 | + |
| 18 | + // Initialize elements |
| 19 | + windowFunctionLabel = new QLabel(tr("Window function")); |
| 20 | + windowFunctionComboBox = new QComboBox(); |
| 21 | + windowFunctionComboBox->addItems(windowFunctionStrings); |
| 22 | + windowFunctionComboBox->setCurrentIndex( |
| 23 | + settings->scope.spectrumWindow); |
| 24 | + |
| 25 | + referenceLevelLabel = new QLabel(tr("Reference level")); |
| 26 | + referenceLevelSpinBox = new QDoubleSpinBox(); |
| 27 | + referenceLevelSpinBox->setDecimals(1); |
| 28 | + referenceLevelSpinBox->setMinimum(-40.0); |
| 29 | + referenceLevelSpinBox->setMaximum(100.0); |
| 30 | + referenceLevelSpinBox->setValue( |
| 31 | + settings->scope.spectrumReference); |
| 32 | + referenceLevelUnitLabel = new QLabel(tr("dBm")); |
| 33 | + referenceLevelLayout = new QHBoxLayout(); |
| 34 | + referenceLevelLayout->addWidget(referenceLevelSpinBox); |
| 35 | + referenceLevelLayout->addWidget(referenceLevelUnitLabel); |
| 36 | + |
| 37 | + minimumMagnitudeLabel = new QLabel(tr("Minimum magnitude")); |
| 38 | + minimumMagnitudeSpinBox = new QDoubleSpinBox(); |
| 39 | + minimumMagnitudeSpinBox->setDecimals(1); |
| 40 | + minimumMagnitudeSpinBox->setMinimum(-40.0); |
| 41 | + minimumMagnitudeSpinBox->setMaximum(100.0); |
| 42 | + minimumMagnitudeSpinBox->setValue(settings->scope.spectrumLimit); |
| 43 | + minimumMagnitudeUnitLabel = new QLabel(tr("dBm")); |
| 44 | + minimumMagnitudeLayout = new QHBoxLayout(); |
| 45 | + minimumMagnitudeLayout->addWidget(minimumMagnitudeSpinBox); |
| 46 | + minimumMagnitudeLayout->addWidget(minimumMagnitudeUnitLabel); |
| 47 | + |
| 48 | + spectrumLayout = new QGridLayout(); |
| 49 | + spectrumLayout->addWidget(windowFunctionLabel, 0, 0); |
| 50 | + spectrumLayout->addWidget(windowFunctionComboBox, 0, 1); |
| 51 | + spectrumLayout->addWidget(referenceLevelLabel, 1, 0); |
| 52 | + spectrumLayout->addLayout(referenceLevelLayout, 1, 1); |
| 53 | + spectrumLayout->addWidget(minimumMagnitudeLabel, 2, 0); |
| 54 | + spectrumLayout->addLayout(minimumMagnitudeLayout, 2, 1); |
| 55 | + |
| 56 | + spectrumGroup = new QGroupBox(tr("Spectrum")); |
| 57 | + spectrumGroup->setLayout(spectrumLayout); |
| 58 | + |
| 59 | + mainLayout = new QVBoxLayout(); |
| 60 | + mainLayout->addWidget(spectrumGroup); |
| 61 | + mainLayout->addStretch(1); |
| 62 | + |
| 63 | + setLayout(mainLayout); |
| 64 | +} |
| 65 | + |
| 66 | +/// \brief Saves the new settings. |
| 67 | +void DsoConfigAnalysisPage::saveSettings() { |
| 68 | + settings->scope.spectrumWindow = |
| 69 | + (Dso::WindowFunction)windowFunctionComboBox->currentIndex(); |
| 70 | + settings->scope.spectrumReference = |
| 71 | + referenceLevelSpinBox->value(); |
| 72 | + settings->scope.spectrumLimit = minimumMagnitudeSpinBox->value(); |
| 73 | +} |
0 commit comments