diff --git a/qspectrumanalyzer/__main__.py b/qspectrumanalyzer/__main__.py
index 4e9ad4e..2a87922 100644
--- a/qspectrumanalyzer/__main__.py
+++ b/qspectrumanalyzer/__main__.py
@@ -8,14 +8,14 @@ from qspectrumanalyzer import backends
from qspectrumanalyzer.version import __version__
from qspectrumanalyzer.data import DataStorage
from qspectrumanalyzer.plot import SpectrumPlotWidget, WaterfallPlotWidget
-from qspectrumanalyzer.utils import color_to_str, str_to_color, human_time
+from qspectrumanalyzer.utils import str_to_color, human_time
+
+from qspectrumanalyzer.settings import QSpectrumAnalyzerSettings
+from qspectrumanalyzer.smoothing import QSpectrumAnalyzerSmoothing
+from qspectrumanalyzer.persistence import QSpectrumAnalyzerPersistence
+from qspectrumanalyzer.colors import QSpectrumAnalyzerColors
+from qspectrumanalyzer.baseline import QSpectrumAnalyzerBaseline
-from qspectrumanalyzer.ui_qspectrumanalyzer_settings import Ui_QSpectrumAnalyzerSettings
-from qspectrumanalyzer.ui_qspectrumanalyzer_settings_help import Ui_QSpectrumAnalyzerSettingsHelp
-from qspectrumanalyzer.ui_qspectrumanalyzer_smooth import Ui_QSpectrumAnalyzerSmooth
-from qspectrumanalyzer.ui_qspectrumanalyzer_persistence import Ui_QSpectrumAnalyzerPersistence
-from qspectrumanalyzer.ui_qspectrumanalyzer_baseline import Ui_QSpectrumAnalyzerBaseline
-from qspectrumanalyzer.ui_qspectrumanalyzer_colors import Ui_QSpectrumAnalyzerColors
from qspectrumanalyzer.ui_qspectrumanalyzer import Ui_QSpectrumAnalyzerMainWindow
debug = False
@@ -25,244 +25,6 @@ signal.signal(signal.SIGINT, signal.SIG_DFL)
signal.signal(signal.SIGTERM, signal.SIG_DFL)
-class QSpectrumAnalyzerSettings(QtWidgets.QDialog, Ui_QSpectrumAnalyzerSettings):
- """QSpectrumAnalyzer settings dialog"""
- def __init__(self, parent=None):
- # Initialize UI
- super().__init__(parent)
- self.setupUi(self)
- self.params_help_dialog = None
- self.device_help_dialog = None
-
- # Load settings
- settings = QtCore.QSettings()
- self.executableEdit.setText(settings.value("executable", "soapy_power"))
- self.deviceEdit.setText(settings.value("device", ""))
- self.lnbSpinBox.setValue(settings.value("lnb_lo", 0, float) / 1e6)
- self.waterfallHistorySizeSpinBox.setValue(settings.value("waterfall_history_size", 100, int))
-
- backend = settings.value("backend", "soapy_power")
- try:
- backend_module = getattr(backends, backend)
- except AttributeError:
- backend_module = backends.soapy_power
-
- self.paramsEdit.setText(settings.value("params", backend_module.Info.additional_params))
- self.deviceHelpButton.setEnabled(bool(backend_module.Info.help_device))
-
- self.sampleRateSpinBox.setMinimum(backend_module.Info.sample_rate_min / 1e6)
- self.sampleRateSpinBox.setMaximum(backend_module.Info.sample_rate_max / 1e6)
- self.sampleRateSpinBox.setValue(settings.value("sample_rate", backend_module.Info.sample_rate, float) / 1e6)
-
- self.bandwidthSpinBox.setMinimum(backend_module.Info.bandwidth_min / 1e6)
- self.bandwidthSpinBox.setMaximum(backend_module.Info.bandwidth_max / 1e6)
- self.bandwidthSpinBox.setValue(settings.value("bandwidth", backend_module.Info.bandwidth, float) / 1e6)
-
- self.backendComboBox.blockSignals(True)
- self.backendComboBox.clear()
- for b in sorted(backends.__all__):
- self.backendComboBox.addItem(b)
-
- i = self.backendComboBox.findText(backend)
- if i == -1:
- self.backendComboBox.setCurrentIndex(0)
- else:
- self.backendComboBox.setCurrentIndex(i)
- self.backendComboBox.blockSignals(False)
-
- @QtCore.Slot()
- def on_executableButton_clicked(self):
- """Open file dialog when button is clicked"""
- filename = QtWidgets.QFileDialog.getOpenFileName(self, self.tr("Select executable - QSpectrumAnalyzer"))[0]
- if filename:
- self.executableEdit.setText(filename)
-
- @QtCore.Slot()
- def on_paramsHelpButton_clicked(self):
- """Open additional parameters help dialog when button is clicked"""
- try:
- backend_module = getattr(backends, self.backendComboBox.currentText())
- except AttributeError:
- backend_module = backends.soapy_power
-
- self.params_help_dialog = QSpectrumAnalyzerSettingsHelp(
- backend_module.Info.help_params(self.executableEdit.text()),
- parent=self
- )
-
- self.params_help_dialog.show()
- self.params_help_dialog.raise_()
- self.params_help_dialog.activateWindow()
-
- @QtCore.Slot()
- def on_deviceHelpButton_clicked(self):
- """Open device help dialog when button is clicked"""
- try:
- backend_module = getattr(backends, self.backendComboBox.currentText())
- except AttributeError:
- backend_module = backends.soapy_power
-
- self.device_help_dialog = QSpectrumAnalyzerSettingsHelp(
- backend_module.Info.help_device(self.executableEdit.text(), self.deviceEdit.text()),
- parent=self
- )
-
- self.device_help_dialog.show()
- self.device_help_dialog.raise_()
- self.device_help_dialog.activateWindow()
-
- @QtCore.Slot(str)
- def on_backendComboBox_currentIndexChanged(self, text):
- """Change executable when backend is changed"""
- self.executableEdit.setText(text)
- self.deviceEdit.setText("")
-
- try:
- backend_module = getattr(backends, text)
- except AttributeError:
- backend_module = backends.soapy_power
-
- self.paramsEdit.setText(backend_module.Info.additional_params)
- self.deviceHelpButton.setEnabled(bool(backend_module.Info.help_device))
- self.sampleRateSpinBox.setMinimum(backend_module.Info.sample_rate_min / 1e6)
- self.sampleRateSpinBox.setMaximum(backend_module.Info.sample_rate_max / 1e6)
- self.sampleRateSpinBox.setValue(backend_module.Info.sample_rate / 1e6)
- self.bandwidthSpinBox.setMinimum(backend_module.Info.bandwidth_min / 1e6)
- self.bandwidthSpinBox.setMaximum(backend_module.Info.bandwidth_max / 1e6)
- self.bandwidthSpinBox.setValue(backend_module.Info.bandwidth / 1e6)
-
- def accept(self):
- """Save settings when dialog is accepted"""
- settings = QtCore.QSettings()
- settings.setValue("backend", self.backendComboBox.currentText())
- settings.setValue("executable", self.executableEdit.text())
- settings.setValue("params", self.paramsEdit.text())
- settings.setValue("device", self.deviceEdit.text())
- settings.setValue("sample_rate", self.sampleRateSpinBox.value() * 1e6)
- settings.setValue("bandwidth", self.bandwidthSpinBox.value() * 1e6)
- settings.setValue("lnb_lo", self.lnbSpinBox.value() * 1e6)
- settings.setValue("waterfall_history_size", self.waterfallHistorySizeSpinBox.value())
- QtWidgets.QDialog.accept(self)
-
-
-class QSpectrumAnalyzerSettingsHelp(QtWidgets.QDialog, Ui_QSpectrumAnalyzerSettingsHelp):
- """QSpectrumAnalyzer settings help dialog"""
- def __init__(self, text, parent=None):
- # Initialize UI
- super().__init__(parent)
- self.setupUi(self)
-
- monospace_font = QtGui.QFont('monospace')
- monospace_font.setStyleHint(QtGui.QFont.Monospace)
- self.helpTextEdit.setFont(monospace_font)
- self.helpTextEdit.setPlainText(text)
-
-
-class QSpectrumAnalyzerSmooth(QtWidgets.QDialog, Ui_QSpectrumAnalyzerSmooth):
- """QSpectrumAnalyzer spectrum smoothing dialog"""
- def __init__(self, parent=None):
- # Initialize UI
- super().__init__(parent)
- self.setupUi(self)
-
- # Load settings
- settings = QtCore.QSettings()
- self.windowLengthSpinBox.setValue(settings.value("smooth_length", 11, int))
-
- window_function = settings.value("smooth_window", "hanning")
- i = self.windowFunctionComboBox.findText(window_function)
- if i == -1:
- self.windowFunctionComboBox.setCurrentIndex(0)
- else:
- self.windowFunctionComboBox.setCurrentIndex(i)
-
- def accept(self):
- """Save settings when dialog is accepted"""
- settings = QtCore.QSettings()
- settings.setValue("smooth_length", self.windowLengthSpinBox.value())
- settings.setValue("smooth_window", self.windowFunctionComboBox.currentText())
- QtWidgets.QDialog.accept(self)
-
-
-class QSpectrumAnalyzerPersistence(QtWidgets.QDialog, Ui_QSpectrumAnalyzerPersistence):
- """QSpectrumAnalyzer spectrum persistence dialog"""
- def __init__(self, parent=None):
- # Initialize UI
- super().__init__(parent)
- self.setupUi(self)
-
- # Load settings
- settings = QtCore.QSettings()
- self.persistenceLengthSpinBox.setValue(settings.value("persistence_length", 5, int))
-
- decay_function = settings.value("persistence_decay", "exponential")
- i = self.decayFunctionComboBox.findText(decay_function)
- if i == -1:
- self.decayFunctionComboBox.setCurrentIndex(0)
- else:
- self.decayFunctionComboBox.setCurrentIndex(i)
-
- def accept(self):
- """Save settings when dialog is accepted"""
- settings = QtCore.QSettings()
- settings.setValue("persistence_length", self.persistenceLengthSpinBox.value())
- settings.setValue("persistence_decay", self.decayFunctionComboBox.currentText())
- QtWidgets.QDialog.accept(self)
-
-
-class QSpectrumAnalyzerColors(QtWidgets.QDialog, Ui_QSpectrumAnalyzerColors):
- """QSpectrumAnalyzer colors dialog"""
- def __init__(self, parent=None):
- # Initialize UI
- super().__init__(parent)
- self.setupUi(self)
-
- # Load settings
- settings = QtCore.QSettings()
- self.mainColorButton.setColor(str_to_color(settings.value("main_color", "255, 255, 0, 255")))
- self.peakHoldMaxColorButton.setColor(str_to_color(settings.value("peak_hold_max_color", "255, 0, 0, 255")))
- self.peakHoldMinColorButton.setColor(str_to_color(settings.value("peak_hold_min_color", "0, 0, 255, 255")))
- self.averageColorButton.setColor(str_to_color(settings.value("average_color", "0, 255, 255, 255")))
- self.persistenceColorButton.setColor(str_to_color(settings.value("persistence_color", "0, 255, 0, 255")))
- self.baselineColorButton.setColor(str_to_color(settings.value("baseline_color", "255, 0, 255, 255")))
-
- def accept(self):
- """Save settings when dialog is accepted"""
- settings = QtCore.QSettings()
- settings.setValue("main_color", color_to_str(self.mainColorButton.color()))
- settings.setValue("peak_hold_max_color", color_to_str(self.peakHoldMaxColorButton.color()))
- settings.setValue("peak_hold_min_color", color_to_str(self.peakHoldMinColorButton.color()))
- settings.setValue("average_color", color_to_str(self.averageColorButton.color()))
- settings.setValue("persistence_color", color_to_str(self.persistenceColorButton.color()))
- settings.setValue("baseline_color", color_to_str(self.baselineColorButton.color()))
- QtWidgets.QDialog.accept(self)
-
-
-class QSpectrumAnalyzerBaseline(QtWidgets.QDialog, Ui_QSpectrumAnalyzerBaseline):
- """QSpectrumAnalyzer baseline dialog"""
- def __init__(self, parent=None):
- # Initialize UI
- super().__init__(parent)
- self.setupUi(self)
-
- # Load settings
- settings = QtCore.QSettings()
- self.baselineFileEdit.setText(settings.value("baseline_file", ""))
-
- @QtCore.Slot()
- def on_baselineFileButton_clicked(self):
- """Open file dialog when button is clicked"""
- filename = QtWidgets.QFileDialog.getOpenFileName(self, self.tr("Select baseline file - QSpectrumAnalyzer"))[0]
- if filename:
- self.baselineFileEdit.setText(filename)
-
- def accept(self):
- """Save settings when dialog is accepted"""
- settings = QtCore.QSettings()
- settings.setValue("baseline_file", self.baselineFileEdit.text())
- QtWidgets.QDialog.accept(self)
-
-
class QSpectrumAnalyzerMainWindow(QtWidgets.QMainWindow, Ui_QSpectrumAnalyzerMainWindow):
"""QSpectrumAnalyzer main window"""
def __init__(self, parent=None):
@@ -685,7 +447,7 @@ class QSpectrumAnalyzerMainWindow(QtWidgets.QMainWindow, Ui_QSpectrumAnalyzerMai
@QtCore.Slot()
def on_smoothButton_clicked(self):
- dialog = QSpectrumAnalyzerSmooth(self)
+ dialog = QSpectrumAnalyzerSmoothing(self)
if dialog.exec_():
settings = QtCore.QSettings()
self.data_storage.set_smooth(
diff --git a/qspectrumanalyzer/baseline.py b/qspectrumanalyzer/baseline.py
new file mode 100644
index 0000000..c20eda6
--- /dev/null
+++ b/qspectrumanalyzer/baseline.py
@@ -0,0 +1,28 @@
+from Qt import QtCore, QtWidgets
+
+from qspectrumanalyzer.ui_qspectrumanalyzer_baseline import Ui_QSpectrumAnalyzerBaseline
+
+
+class QSpectrumAnalyzerBaseline(QtWidgets.QDialog, Ui_QSpectrumAnalyzerBaseline):
+ """QSpectrumAnalyzer baseline dialog"""
+ def __init__(self, parent=None):
+ # Initialize UI
+ super().__init__(parent)
+ self.setupUi(self)
+
+ # Load settings
+ settings = QtCore.QSettings()
+ self.baselineFileEdit.setText(settings.value("baseline_file", ""))
+
+ @QtCore.Slot()
+ def on_baselineFileButton_clicked(self):
+ """Open file dialog when button is clicked"""
+ filename = QtWidgets.QFileDialog.getOpenFileName(self, self.tr("Select baseline file - QSpectrumAnalyzer"))[0]
+ if filename:
+ self.baselineFileEdit.setText(filename)
+
+ def accept(self):
+ """Save settings when dialog is accepted"""
+ settings = QtCore.QSettings()
+ settings.setValue("baseline_file", self.baselineFileEdit.text())
+ QtWidgets.QDialog.accept(self)
diff --git a/qspectrumanalyzer/colors.py b/qspectrumanalyzer/colors.py
new file mode 100644
index 0000000..4389fcd
--- /dev/null
+++ b/qspectrumanalyzer/colors.py
@@ -0,0 +1,33 @@
+from Qt import QtCore, QtWidgets
+
+from qspectrumanalyzer.utils import color_to_str, str_to_color
+
+from qspectrumanalyzer.ui_qspectrumanalyzer_colors import Ui_QSpectrumAnalyzerColors
+
+
+class QSpectrumAnalyzerColors(QtWidgets.QDialog, Ui_QSpectrumAnalyzerColors):
+ """QSpectrumAnalyzer colors dialog"""
+ def __init__(self, parent=None):
+ # Initialize UI
+ super().__init__(parent)
+ self.setupUi(self)
+
+ # Load settings
+ settings = QtCore.QSettings()
+ self.mainColorButton.setColor(str_to_color(settings.value("main_color", "255, 255, 0, 255")))
+ self.peakHoldMaxColorButton.setColor(str_to_color(settings.value("peak_hold_max_color", "255, 0, 0, 255")))
+ self.peakHoldMinColorButton.setColor(str_to_color(settings.value("peak_hold_min_color", "0, 0, 255, 255")))
+ self.averageColorButton.setColor(str_to_color(settings.value("average_color", "0, 255, 255, 255")))
+ self.persistenceColorButton.setColor(str_to_color(settings.value("persistence_color", "0, 255, 0, 255")))
+ self.baselineColorButton.setColor(str_to_color(settings.value("baseline_color", "255, 0, 255, 255")))
+
+ def accept(self):
+ """Save settings when dialog is accepted"""
+ settings = QtCore.QSettings()
+ settings.setValue("main_color", color_to_str(self.mainColorButton.color()))
+ settings.setValue("peak_hold_max_color", color_to_str(self.peakHoldMaxColorButton.color()))
+ settings.setValue("peak_hold_min_color", color_to_str(self.peakHoldMinColorButton.color()))
+ settings.setValue("average_color", color_to_str(self.averageColorButton.color()))
+ settings.setValue("persistence_color", color_to_str(self.persistenceColorButton.color()))
+ settings.setValue("baseline_color", color_to_str(self.baselineColorButton.color()))
+ QtWidgets.QDialog.accept(self)
diff --git a/qspectrumanalyzer/languages/qspectrumanalyzer_cs.ts b/qspectrumanalyzer/languages/qspectrumanalyzer_cs.ts
index 1d0dad2..d938478 100644
--- a/qspectrumanalyzer/languages/qspectrumanalyzer_cs.ts
+++ b/qspectrumanalyzer/languages/qspectrumanalyzer_cs.ts
@@ -3,7 +3,7 @@
QSpectrumAnalyzerBaseline
-
+
Select baseline file - QSpectrumAnalyzer
@@ -74,12 +74,12 @@
-
+
About - QSpectrumAnalyzer
-
+
QSpectrumAnalyzer {}
@@ -114,12 +114,12 @@
-
+
Frequency hops: {}
-
+
Total time: {} | Sweep time: {:.2f} s ({:.2f} FPS)
@@ -228,34 +228,34 @@
auto
-
-
- &Controls
-
-
-
-
- Fre&quency
-
-
-
-
- Se&ttings
-
-
Subtract baseline
-
- &Levels
+
+ Baseline
-
- Baseline
+
+ Controls
+
+
+
+
+ Frequency
+
+
+
+
+ Settings
+
+
+
+
+ Levels
@@ -290,7 +290,7 @@
QSpectrumAnalyzerSettings
-
+
Select executable - QSpectrumAnalyzer
@@ -394,44 +394,44 @@
- QSpectrumAnalyzerSmooth
+ QSpectrumAnalyzerSmoothing
-
+
Smoothing - QSpectrumAnalyzer
-
+
&Window function:
-
+
rectangular
-
+
hanning
-
+
hamming
-
+
bartlett
-
+
blackman
-
+
Window len>h:
diff --git a/qspectrumanalyzer/persistence.py b/qspectrumanalyzer/persistence.py
new file mode 100644
index 0000000..c007186
--- /dev/null
+++ b/qspectrumanalyzer/persistence.py
@@ -0,0 +1,29 @@
+from Qt import QtCore, QtWidgets
+
+from qspectrumanalyzer.ui_qspectrumanalyzer_persistence import Ui_QSpectrumAnalyzerPersistence
+
+
+class QSpectrumAnalyzerPersistence(QtWidgets.QDialog, Ui_QSpectrumAnalyzerPersistence):
+ """QSpectrumAnalyzer spectrum persistence dialog"""
+ def __init__(self, parent=None):
+ # Initialize UI
+ super().__init__(parent)
+ self.setupUi(self)
+
+ # Load settings
+ settings = QtCore.QSettings()
+ self.persistenceLengthSpinBox.setValue(settings.value("persistence_length", 5, int))
+
+ decay_function = settings.value("persistence_decay", "exponential")
+ i = self.decayFunctionComboBox.findText(decay_function)
+ if i == -1:
+ self.decayFunctionComboBox.setCurrentIndex(0)
+ else:
+ self.decayFunctionComboBox.setCurrentIndex(i)
+
+ def accept(self):
+ """Save settings when dialog is accepted"""
+ settings = QtCore.QSettings()
+ settings.setValue("persistence_length", self.persistenceLengthSpinBox.value())
+ settings.setValue("persistence_decay", self.decayFunctionComboBox.currentText())
+ QtWidgets.QDialog.accept(self)
diff --git a/qspectrumanalyzer/qspectrumanalyzer.ui b/qspectrumanalyzer/qspectrumanalyzer.ui
index 4587ab4..b65c947 100644
--- a/qspectrumanalyzer/qspectrumanalyzer.ui
+++ b/qspectrumanalyzer/qspectrumanalyzer.ui
@@ -90,7 +90,7 @@
QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable
- &Controls
+ Controls
2
@@ -151,7 +151,7 @@
QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable
- Fre&quency
+ Frequency
2
@@ -311,7 +311,7 @@
QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable
- Se&ttings
+ Settings
2
@@ -539,7 +539,7 @@
QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable
- &Levels
+ Levels
2
diff --git a/qspectrumanalyzer/qspectrumanalyzer_baseline.ui b/qspectrumanalyzer/qspectrumanalyzer_baseline.ui
new file mode 100644
index 0000000..ad495e8
--- /dev/null
+++ b/qspectrumanalyzer/qspectrumanalyzer_baseline.ui
@@ -0,0 +1,115 @@
+
+
+ QSpectrumAnalyzerBaseline
+
+
+
+ 0
+ 0
+ 500
+ 100
+
+
+
+ Baseline - QSpectrumAnalyzer
+
+
+ -
+
+
-
+
+
+ Baseline &file:
+
+
+ baselineFileEdit
+
+
+
+ -
+
+
-
+
+
+ -
+
+
+
+ 50
+ 0
+
+
+
+ ...
+
+
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 1
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+
+
+
+
+ baselineFileEdit
+ baselineFileButton
+
+
+
+
+ buttonBox
+ accepted()
+ QSpectrumAnalyzerBaseline
+ accept()
+
+
+ 224
+ 72
+
+
+ 157
+ 99
+
+
+
+
+ buttonBox
+ rejected()
+ QSpectrumAnalyzerBaseline
+ reject()
+
+
+ 292
+ 78
+
+
+ 286
+ 99
+
+
+
+
+
diff --git a/qspectrumanalyzer/qspectrumanalyzer_smooth.ui b/qspectrumanalyzer/qspectrumanalyzer_smoothing.ui
similarity index 94%
rename from qspectrumanalyzer/qspectrumanalyzer_smooth.ui
rename to qspectrumanalyzer/qspectrumanalyzer_smoothing.ui
index 69804a0..54f7b1d 100644
--- a/qspectrumanalyzer/qspectrumanalyzer_smooth.ui
+++ b/qspectrumanalyzer/qspectrumanalyzer_smoothing.ui
@@ -1,7 +1,7 @@
- QSpectrumAnalyzerSmooth
-
+ QSpectrumAnalyzerSmoothing
+
0
@@ -118,7 +118,7 @@
buttonBox
accepted()
- QSpectrumAnalyzerSmooth
+ QSpectrumAnalyzerSmoothing
accept()
@@ -134,7 +134,7 @@
buttonBox
rejected()
- QSpectrumAnalyzerSmooth
+ QSpectrumAnalyzerSmoothing
reject()
diff --git a/qspectrumanalyzer/settings.py b/qspectrumanalyzer/settings.py
new file mode 100644
index 0000000..151ae70
--- /dev/null
+++ b/qspectrumanalyzer/settings.py
@@ -0,0 +1,139 @@
+from Qt import QtCore, QtGui, QtWidgets
+
+from qspectrumanalyzer import backends
+
+from qspectrumanalyzer.ui_qspectrumanalyzer_settings import Ui_QSpectrumAnalyzerSettings
+from qspectrumanalyzer.ui_qspectrumanalyzer_settings_help import Ui_QSpectrumAnalyzerSettingsHelp
+
+
+class QSpectrumAnalyzerSettings(QtWidgets.QDialog, Ui_QSpectrumAnalyzerSettings):
+ """QSpectrumAnalyzer settings dialog"""
+ def __init__(self, parent=None):
+ # Initialize UI
+ super().__init__(parent)
+ self.setupUi(self)
+ self.params_help_dialog = None
+ self.device_help_dialog = None
+
+ # Load settings
+ settings = QtCore.QSettings()
+ self.executableEdit.setText(settings.value("executable", "soapy_power"))
+ self.deviceEdit.setText(settings.value("device", ""))
+ self.lnbSpinBox.setValue(settings.value("lnb_lo", 0, float) / 1e6)
+ self.waterfallHistorySizeSpinBox.setValue(settings.value("waterfall_history_size", 100, int))
+
+ backend = settings.value("backend", "soapy_power")
+ try:
+ backend_module = getattr(backends, backend)
+ except AttributeError:
+ backend_module = backends.soapy_power
+
+ self.paramsEdit.setText(settings.value("params", backend_module.Info.additional_params))
+ self.deviceHelpButton.setEnabled(bool(backend_module.Info.help_device))
+
+ self.sampleRateSpinBox.setMinimum(backend_module.Info.sample_rate_min / 1e6)
+ self.sampleRateSpinBox.setMaximum(backend_module.Info.sample_rate_max / 1e6)
+ self.sampleRateSpinBox.setValue(settings.value("sample_rate", backend_module.Info.sample_rate, float) / 1e6)
+
+ self.bandwidthSpinBox.setMinimum(backend_module.Info.bandwidth_min / 1e6)
+ self.bandwidthSpinBox.setMaximum(backend_module.Info.bandwidth_max / 1e6)
+ self.bandwidthSpinBox.setValue(settings.value("bandwidth", backend_module.Info.bandwidth, float) / 1e6)
+
+ self.backendComboBox.blockSignals(True)
+ self.backendComboBox.clear()
+ for b in sorted(backends.__all__):
+ self.backendComboBox.addItem(b)
+
+ i = self.backendComboBox.findText(backend)
+ if i == -1:
+ self.backendComboBox.setCurrentIndex(0)
+ else:
+ self.backendComboBox.setCurrentIndex(i)
+ self.backendComboBox.blockSignals(False)
+
+ @QtCore.Slot()
+ def on_executableButton_clicked(self):
+ """Open file dialog when button is clicked"""
+ filename = QtWidgets.QFileDialog.getOpenFileName(self, self.tr("Select executable - QSpectrumAnalyzer"))[0]
+ if filename:
+ self.executableEdit.setText(filename)
+
+ @QtCore.Slot()
+ def on_paramsHelpButton_clicked(self):
+ """Open additional parameters help dialog when button is clicked"""
+ try:
+ backend_module = getattr(backends, self.backendComboBox.currentText())
+ except AttributeError:
+ backend_module = backends.soapy_power
+
+ self.params_help_dialog = QSpectrumAnalyzerSettingsHelp(
+ backend_module.Info.help_params(self.executableEdit.text()),
+ parent=self
+ )
+
+ self.params_help_dialog.show()
+ self.params_help_dialog.raise_()
+ self.params_help_dialog.activateWindow()
+
+ @QtCore.Slot()
+ def on_deviceHelpButton_clicked(self):
+ """Open device help dialog when button is clicked"""
+ try:
+ backend_module = getattr(backends, self.backendComboBox.currentText())
+ except AttributeError:
+ backend_module = backends.soapy_power
+
+ self.device_help_dialog = QSpectrumAnalyzerSettingsHelp(
+ backend_module.Info.help_device(self.executableEdit.text(), self.deviceEdit.text()),
+ parent=self
+ )
+
+ self.device_help_dialog.show()
+ self.device_help_dialog.raise_()
+ self.device_help_dialog.activateWindow()
+
+ @QtCore.Slot(str)
+ def on_backendComboBox_currentIndexChanged(self, text):
+ """Change executable when backend is changed"""
+ self.executableEdit.setText(text)
+ self.deviceEdit.setText("")
+
+ try:
+ backend_module = getattr(backends, text)
+ except AttributeError:
+ backend_module = backends.soapy_power
+
+ self.paramsEdit.setText(backend_module.Info.additional_params)
+ self.deviceHelpButton.setEnabled(bool(backend_module.Info.help_device))
+ self.sampleRateSpinBox.setMinimum(backend_module.Info.sample_rate_min / 1e6)
+ self.sampleRateSpinBox.setMaximum(backend_module.Info.sample_rate_max / 1e6)
+ self.sampleRateSpinBox.setValue(backend_module.Info.sample_rate / 1e6)
+ self.bandwidthSpinBox.setMinimum(backend_module.Info.bandwidth_min / 1e6)
+ self.bandwidthSpinBox.setMaximum(backend_module.Info.bandwidth_max / 1e6)
+ self.bandwidthSpinBox.setValue(backend_module.Info.bandwidth / 1e6)
+
+ def accept(self):
+ """Save settings when dialog is accepted"""
+ settings = QtCore.QSettings()
+ settings.setValue("backend", self.backendComboBox.currentText())
+ settings.setValue("executable", self.executableEdit.text())
+ settings.setValue("params", self.paramsEdit.text())
+ settings.setValue("device", self.deviceEdit.text())
+ settings.setValue("sample_rate", self.sampleRateSpinBox.value() * 1e6)
+ settings.setValue("bandwidth", self.bandwidthSpinBox.value() * 1e6)
+ settings.setValue("lnb_lo", self.lnbSpinBox.value() * 1e6)
+ settings.setValue("waterfall_history_size", self.waterfallHistorySizeSpinBox.value())
+ QtWidgets.QDialog.accept(self)
+
+
+class QSpectrumAnalyzerSettingsHelp(QtWidgets.QDialog, Ui_QSpectrumAnalyzerSettingsHelp):
+ """QSpectrumAnalyzer settings help dialog"""
+ def __init__(self, text, parent=None):
+ # Initialize UI
+ super().__init__(parent)
+ self.setupUi(self)
+
+ monospace_font = QtGui.QFont('monospace')
+ monospace_font.setStyleHint(QtGui.QFont.Monospace)
+ self.helpTextEdit.setFont(monospace_font)
+ self.helpTextEdit.setPlainText(text)
diff --git a/qspectrumanalyzer/smoothing.py b/qspectrumanalyzer/smoothing.py
new file mode 100644
index 0000000..900b34e
--- /dev/null
+++ b/qspectrumanalyzer/smoothing.py
@@ -0,0 +1,29 @@
+from Qt import QtCore, QtWidgets
+
+from qspectrumanalyzer.ui_qspectrumanalyzer_smoothing import Ui_QSpectrumAnalyzerSmoothing
+
+
+class QSpectrumAnalyzerSmoothing(QtWidgets.QDialog, Ui_QSpectrumAnalyzerSmoothing):
+ """QSpectrumAnalyzer spectrum smoothing dialog"""
+ def __init__(self, parent=None):
+ # Initialize UI
+ super().__init__(parent)
+ self.setupUi(self)
+
+ # Load settings
+ settings = QtCore.QSettings()
+ self.windowLengthSpinBox.setValue(settings.value("smooth_length", 11, int))
+
+ window_function = settings.value("smooth_window", "hanning")
+ i = self.windowFunctionComboBox.findText(window_function)
+ if i == -1:
+ self.windowFunctionComboBox.setCurrentIndex(0)
+ else:
+ self.windowFunctionComboBox.setCurrentIndex(i)
+
+ def accept(self):
+ """Save settings when dialog is accepted"""
+ settings = QtCore.QSettings()
+ settings.setValue("smooth_length", self.windowLengthSpinBox.value())
+ settings.setValue("smooth_window", self.windowFunctionComboBox.currentText())
+ QtWidgets.QDialog.accept(self)
diff --git a/qspectrumanalyzer/ui_qspectrumanalyzer.py b/qspectrumanalyzer/ui_qspectrumanalyzer.py
index 2a8b1ad..39b3609 100644
--- a/qspectrumanalyzer/ui_qspectrumanalyzer.py
+++ b/qspectrumanalyzer/ui_qspectrumanalyzer.py
@@ -317,18 +317,18 @@ class Ui_QSpectrumAnalyzerMainWindow(object):
QSpectrumAnalyzerMainWindow.setWindowTitle(_translate("QSpectrumAnalyzerMainWindow", "QSpectrumAnalyzer"))
self.menu_File.setTitle(_translate("QSpectrumAnalyzerMainWindow", "&File"))
self.menu_Help.setTitle(_translate("QSpectrumAnalyzerMainWindow", "&Help"))
- self.controlsDockWidget.setWindowTitle(_translate("QSpectrumAnalyzerMainWindow", "&Controls"))
+ self.controlsDockWidget.setWindowTitle(_translate("QSpectrumAnalyzerMainWindow", "Controls"))
self.startButton.setText(_translate("QSpectrumAnalyzerMainWindow", "&Start"))
self.stopButton.setText(_translate("QSpectrumAnalyzerMainWindow", "S&top"))
self.singleShotButton.setText(_translate("QSpectrumAnalyzerMainWindow", "Si&ngle shot"))
- self.frequencyDockWidget.setWindowTitle(_translate("QSpectrumAnalyzerMainWindow", "Fre&quency"))
+ self.frequencyDockWidget.setWindowTitle(_translate("QSpectrumAnalyzerMainWindow", "Frequency"))
self.label_2.setText(_translate("QSpectrumAnalyzerMainWindow", "Start:"))
self.startFreqSpinBox.setSuffix(_translate("QSpectrumAnalyzerMainWindow", " MHz"))
self.label_3.setText(_translate("QSpectrumAnalyzerMainWindow", "Stop:"))
self.stopFreqSpinBox.setSuffix(_translate("QSpectrumAnalyzerMainWindow", " MHz"))
self.label.setText(_translate("QSpectrumAnalyzerMainWindow", "&Bin size:"))
self.binSizeSpinBox.setSuffix(_translate("QSpectrumAnalyzerMainWindow", " kHz"))
- self.settingsDockWidget.setWindowTitle(_translate("QSpectrumAnalyzerMainWindow", "Se&ttings"))
+ self.settingsDockWidget.setWindowTitle(_translate("QSpectrumAnalyzerMainWindow", "Settings"))
self.label_4.setText(_translate("QSpectrumAnalyzerMainWindow", "&Interval [s]:"))
self.label_6.setText(_translate("QSpectrumAnalyzerMainWindow", "&Gain [dB]:"))
self.label_5.setText(_translate("QSpectrumAnalyzerMainWindow", "Corr. [ppm]:"))
@@ -346,7 +346,7 @@ class Ui_QSpectrumAnalyzerMainWindow(object):
self.baselineCheckBox.setText(_translate("QSpectrumAnalyzerMainWindow", "Baseline"))
self.baselineButton.setText(_translate("QSpectrumAnalyzerMainWindow", "..."))
self.subtractBaselineCheckBox.setText(_translate("QSpectrumAnalyzerMainWindow", "Subtract baseline"))
- self.levelsDockWidget.setWindowTitle(_translate("QSpectrumAnalyzerMainWindow", "&Levels"))
+ self.levelsDockWidget.setWindowTitle(_translate("QSpectrumAnalyzerMainWindow", "Levels"))
self.action_Settings.setText(_translate("QSpectrumAnalyzerMainWindow", "&Settings..."))
self.action_Quit.setText(_translate("QSpectrumAnalyzerMainWindow", "&Quit"))
self.action_Quit.setShortcut(_translate("QSpectrumAnalyzerMainWindow", "Ctrl+Q"))
diff --git a/qspectrumanalyzer/ui_qspectrumanalyzer_baseline.py b/qspectrumanalyzer/ui_qspectrumanalyzer_baseline.py
new file mode 100644
index 0000000..50592f9
--- /dev/null
+++ b/qspectrumanalyzer/ui_qspectrumanalyzer_baseline.py
@@ -0,0 +1,53 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file 'qspectrumanalyzer/qspectrumanalyzer_baseline.ui'
+#
+# Created by: PyQt5 UI code generator 5.8
+#
+# WARNING! All changes made in this file will be lost!
+
+from Qt import QtCore, QtGui, QtWidgets
+
+class Ui_QSpectrumAnalyzerBaseline(object):
+ def setupUi(self, QSpectrumAnalyzerBaseline):
+ QSpectrumAnalyzerBaseline.setObjectName("QSpectrumAnalyzerBaseline")
+ QSpectrumAnalyzerBaseline.resize(500, 100)
+ self.verticalLayout = QtWidgets.QVBoxLayout(QSpectrumAnalyzerBaseline)
+ self.verticalLayout.setObjectName("verticalLayout")
+ self.formLayout = QtWidgets.QFormLayout()
+ self.formLayout.setObjectName("formLayout")
+ self.label = QtWidgets.QLabel(QSpectrumAnalyzerBaseline)
+ self.label.setObjectName("label")
+ self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.label)
+ self.horizontalLayout = QtWidgets.QHBoxLayout()
+ self.horizontalLayout.setObjectName("horizontalLayout")
+ self.baselineFileEdit = QtWidgets.QLineEdit(QSpectrumAnalyzerBaseline)
+ self.baselineFileEdit.setObjectName("baselineFileEdit")
+ self.horizontalLayout.addWidget(self.baselineFileEdit)
+ self.baselineFileButton = QtWidgets.QToolButton(QSpectrumAnalyzerBaseline)
+ self.baselineFileButton.setMinimumSize(QtCore.QSize(50, 0))
+ self.baselineFileButton.setObjectName("baselineFileButton")
+ self.horizontalLayout.addWidget(self.baselineFileButton)
+ self.formLayout.setLayout(0, QtWidgets.QFormLayout.FieldRole, self.horizontalLayout)
+ self.verticalLayout.addLayout(self.formLayout)
+ spacerItem = QtWidgets.QSpacerItem(20, 1, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
+ self.verticalLayout.addItem(spacerItem)
+ self.buttonBox = QtWidgets.QDialogButtonBox(QSpectrumAnalyzerBaseline)
+ self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
+ self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
+ self.buttonBox.setObjectName("buttonBox")
+ self.verticalLayout.addWidget(self.buttonBox)
+ self.label.setBuddy(self.baselineFileEdit)
+
+ self.retranslateUi(QSpectrumAnalyzerBaseline)
+ self.buttonBox.accepted.connect(QSpectrumAnalyzerBaseline.accept)
+ self.buttonBox.rejected.connect(QSpectrumAnalyzerBaseline.reject)
+ QtCore.QMetaObject.connectSlotsByName(QSpectrumAnalyzerBaseline)
+ QSpectrumAnalyzerBaseline.setTabOrder(self.baselineFileEdit, self.baselineFileButton)
+
+ def retranslateUi(self, QSpectrumAnalyzerBaseline):
+ _translate = QtCore.QCoreApplication.translate
+ QSpectrumAnalyzerBaseline.setWindowTitle(_translate("QSpectrumAnalyzerBaseline", "Baseline - QSpectrumAnalyzer"))
+ self.label.setText(_translate("QSpectrumAnalyzerBaseline", "Baseline &file:"))
+ self.baselineFileButton.setText(_translate("QSpectrumAnalyzerBaseline", "..."))
+
diff --git a/qspectrumanalyzer/ui_qspectrumanalyzer_smooth.py b/qspectrumanalyzer/ui_qspectrumanalyzer_smoothing.py
similarity index 66%
rename from qspectrumanalyzer/ui_qspectrumanalyzer_smooth.py
rename to qspectrumanalyzer/ui_qspectrumanalyzer_smoothing.py
index fc4f597..7c8da5e 100644
--- a/qspectrumanalyzer/ui_qspectrumanalyzer_smooth.py
+++ b/qspectrumanalyzer/ui_qspectrumanalyzer_smoothing.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Form implementation generated from reading ui file 'qspectrumanalyzer/qspectrumanalyzer_smooth.ui'
+# Form implementation generated from reading ui file 'qspectrumanalyzer/qspectrumanalyzer_smoothing.ui'
#
# Created by: PyQt5 UI code generator 5.8
#
@@ -8,18 +8,18 @@
from Qt import QtCore, QtGui, QtWidgets
-class Ui_QSpectrumAnalyzerSmooth(object):
- def setupUi(self, QSpectrumAnalyzerSmooth):
- QSpectrumAnalyzerSmooth.setObjectName("QSpectrumAnalyzerSmooth")
- QSpectrumAnalyzerSmooth.resize(250, 130)
- self.verticalLayout = QtWidgets.QVBoxLayout(QSpectrumAnalyzerSmooth)
+class Ui_QSpectrumAnalyzerSmoothing(object):
+ def setupUi(self, QSpectrumAnalyzerSmoothing):
+ QSpectrumAnalyzerSmoothing.setObjectName("QSpectrumAnalyzerSmoothing")
+ QSpectrumAnalyzerSmoothing.resize(250, 130)
+ self.verticalLayout = QtWidgets.QVBoxLayout(QSpectrumAnalyzerSmoothing)
self.verticalLayout.setObjectName("verticalLayout")
self.formLayout = QtWidgets.QFormLayout()
self.formLayout.setObjectName("formLayout")
- self.label = QtWidgets.QLabel(QSpectrumAnalyzerSmooth)
+ self.label = QtWidgets.QLabel(QSpectrumAnalyzerSmoothing)
self.label.setObjectName("label")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.label)
- self.windowFunctionComboBox = QtWidgets.QComboBox(QSpectrumAnalyzerSmooth)
+ self.windowFunctionComboBox = QtWidgets.QComboBox(QSpectrumAnalyzerSmoothing)
self.windowFunctionComboBox.setObjectName("windowFunctionComboBox")
self.windowFunctionComboBox.addItem("")
self.windowFunctionComboBox.addItem("")
@@ -27,10 +27,10 @@ class Ui_QSpectrumAnalyzerSmooth(object):
self.windowFunctionComboBox.addItem("")
self.windowFunctionComboBox.addItem("")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.windowFunctionComboBox)
- self.label_2 = QtWidgets.QLabel(QSpectrumAnalyzerSmooth)
+ self.label_2 = QtWidgets.QLabel(QSpectrumAnalyzerSmoothing)
self.label_2.setObjectName("label_2")
self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.label_2)
- self.windowLengthSpinBox = QtWidgets.QSpinBox(QSpectrumAnalyzerSmooth)
+ self.windowLengthSpinBox = QtWidgets.QSpinBox(QSpectrumAnalyzerSmoothing)
self.windowLengthSpinBox.setMinimum(3)
self.windowLengthSpinBox.setMaximum(1001)
self.windowLengthSpinBox.setProperty("value", 11)
@@ -39,7 +39,7 @@ class Ui_QSpectrumAnalyzerSmooth(object):
self.verticalLayout.addLayout(self.formLayout)
spacerItem = QtWidgets.QSpacerItem(20, 1, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.verticalLayout.addItem(spacerItem)
- self.buttonBox = QtWidgets.QDialogButtonBox(QSpectrumAnalyzerSmooth)
+ self.buttonBox = QtWidgets.QDialogButtonBox(QSpectrumAnalyzerSmoothing)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
@@ -47,22 +47,22 @@ class Ui_QSpectrumAnalyzerSmooth(object):
self.label.setBuddy(self.windowFunctionComboBox)
self.label_2.setBuddy(self.windowLengthSpinBox)
- self.retranslateUi(QSpectrumAnalyzerSmooth)
+ self.retranslateUi(QSpectrumAnalyzerSmoothing)
self.windowFunctionComboBox.setCurrentIndex(1)
- self.buttonBox.accepted.connect(QSpectrumAnalyzerSmooth.accept)
- self.buttonBox.rejected.connect(QSpectrumAnalyzerSmooth.reject)
- QtCore.QMetaObject.connectSlotsByName(QSpectrumAnalyzerSmooth)
- QSpectrumAnalyzerSmooth.setTabOrder(self.windowFunctionComboBox, self.windowLengthSpinBox)
- QSpectrumAnalyzerSmooth.setTabOrder(self.windowLengthSpinBox, self.buttonBox)
+ self.buttonBox.accepted.connect(QSpectrumAnalyzerSmoothing.accept)
+ self.buttonBox.rejected.connect(QSpectrumAnalyzerSmoothing.reject)
+ QtCore.QMetaObject.connectSlotsByName(QSpectrumAnalyzerSmoothing)
+ QSpectrumAnalyzerSmoothing.setTabOrder(self.windowFunctionComboBox, self.windowLengthSpinBox)
+ QSpectrumAnalyzerSmoothing.setTabOrder(self.windowLengthSpinBox, self.buttonBox)
- def retranslateUi(self, QSpectrumAnalyzerSmooth):
+ def retranslateUi(self, QSpectrumAnalyzerSmoothing):
_translate = QtCore.QCoreApplication.translate
- QSpectrumAnalyzerSmooth.setWindowTitle(_translate("QSpectrumAnalyzerSmooth", "Smoothing - QSpectrumAnalyzer"))
- self.label.setText(_translate("QSpectrumAnalyzerSmooth", "&Window function:"))
- self.windowFunctionComboBox.setItemText(0, _translate("QSpectrumAnalyzerSmooth", "rectangular"))
- self.windowFunctionComboBox.setItemText(1, _translate("QSpectrumAnalyzerSmooth", "hanning"))
- self.windowFunctionComboBox.setItemText(2, _translate("QSpectrumAnalyzerSmooth", "hamming"))
- self.windowFunctionComboBox.setItemText(3, _translate("QSpectrumAnalyzerSmooth", "bartlett"))
- self.windowFunctionComboBox.setItemText(4, _translate("QSpectrumAnalyzerSmooth", "blackman"))
- self.label_2.setText(_translate("QSpectrumAnalyzerSmooth", "Window len>h:"))
+ QSpectrumAnalyzerSmoothing.setWindowTitle(_translate("QSpectrumAnalyzerSmoothing", "Smoothing - QSpectrumAnalyzer"))
+ self.label.setText(_translate("QSpectrumAnalyzerSmoothing", "&Window function:"))
+ self.windowFunctionComboBox.setItemText(0, _translate("QSpectrumAnalyzerSmoothing", "rectangular"))
+ self.windowFunctionComboBox.setItemText(1, _translate("QSpectrumAnalyzerSmoothing", "hanning"))
+ self.windowFunctionComboBox.setItemText(2, _translate("QSpectrumAnalyzerSmoothing", "hamming"))
+ self.windowFunctionComboBox.setItemText(3, _translate("QSpectrumAnalyzerSmoothing", "bartlett"))
+ self.windowFunctionComboBox.setItemText(4, _translate("QSpectrumAnalyzerSmoothing", "blackman"))
+ self.label_2.setText(_translate("QSpectrumAnalyzerSmoothing", "Window len>h:"))