Final touches to frequency filters

This commit is contained in:
alessandro90
2018-10-14 11:00:56 +02:00
parent ea9efc41ef
commit c5f4bcf095
2 changed files with 57 additions and 22 deletions

33
main.py
View File

@@ -37,6 +37,7 @@ class MyApp(QMainWindow, Ui_MainWindow):
bands = ELF, SLF, ULF, VLF, LF, MF, HF, VHF, UHF, SHF, EHF bands = ELF, SLF, ULF, VLF, LF, MF, HF, VHF, UHF, SHF, EHF
active_color = "#39eaff" active_color = "#39eaff"
inactive_color = "#9f9f9f" inactive_color = "#9f9f9f"
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.setupUi(self) self.setupUi(self)
@@ -49,7 +50,7 @@ class MyApp(QMainWindow, Ui_MainWindow):
self.undefined_freq = False self.undefined_freq = False
self.undefined_band = False self.undefined_band = False
self.signal_names = [] self.signal_names = []
self.frequency_filters = ( self.frequency_filters_btns = (
self.elf_filter_btn, self.elf_filter_btn,
self.slf_filter_btn, self.slf_filter_btn,
self.ulf_filter_btn, self.ulf_filter_btn,
@@ -67,10 +68,9 @@ class MyApp(QMainWindow, Ui_MainWindow):
self.lower_freq_confidence.value() self.lower_freq_confidence.value()
) )
) )
self.apply_reset_freq_filter_btn.set_texts("Apply frequency filters", self.apply_reset_freq_filter_btn.set_texts("Apply", "Remove")
"Remove frequency filters")
self.apply_reset_freq_filter_btn.set_slave_filters( self.apply_reset_freq_filter_btn.set_slave_filters(
*self.frequency_filters, *self.frequency_filters_btns,
self.lower_freq_spinbox, self.lower_freq_spinbox,
self.upper_freq_spinbox, self.upper_freq_spinbox,
self.lower_freq_filter_unit, self.lower_freq_filter_unit,
@@ -79,6 +79,7 @@ class MyApp(QMainWindow, Ui_MainWindow):
self.upper_freq_confidence, self.upper_freq_confidence,
) )
self.apply_reset_freq_filter_btn.clicked.connect(self.display_signals) self.apply_reset_freq_filter_btn.clicked.connect(self.display_signals)
self.reset_frequency_filters_btn.clicked.connect(self.reset_frequency_filters)
UrlColors = namedtuple("UrlColors", ["inactive", "active", "clicked"]) UrlColors = namedtuple("UrlColors", ["inactive", "active", "clicked"])
self.url_button.colors = UrlColors("#9f9f9f", "#4c75ff", "#942ccc") self.url_button.colors = UrlColors("#9f9f9f", "#4c75ff", "#942ccc")
self.category_labels = [self.cat_mil, self.category_labels = [self.cat_mil,
@@ -133,6 +134,20 @@ class MyApp(QMainWindow, Ui_MainWindow):
BandLabel(self.ehf_left, self.ehf, self.ehf_right), BandLabel(self.ehf_left, self.ehf, self.ehf_right),
] ]
def reset_frequency_filters(self):
if self.apply_reset_freq_filter_btn.isChecked():
self.apply_reset_freq_filter_btn.setChecked(False)
self.apply_reset_freq_filter_btn.clicked.emit()
for f in self.frequency_filters_btns:
if f.isChecked():
f.setChecked(False)
self.lower_freq_spinbox.setValue(0)
self.upper_freq_spinbox.setValue(0)
self.lower_freq_filter_unit.setCurrentText("MHz")
self.upper_freq_filter_unit.setCurrentText("MHz")
self.lower_freq_confidence.setValue(5)
self.upper_freq_confidence.setValue(5)
def set_initial_size(self): def set_initial_size(self):
""" """
Function to handle high resolution screens. The function sets bigger sizes Function to handle high resolution screens. The function sets bigger sizes
@@ -243,13 +258,13 @@ class MyApp(QMainWindow, Ui_MainWindow):
band_filter_ok = False band_filter_ok = False
any_checked = False any_checked = False
for btn, band_limits in zip(self.frequency_filters, self.bands): for btn, band_limits in zip(self.frequency_filters_btns, self.bands):
if btn.isChecked(): if btn.isChecked():
any_checked = True any_checked = True
if signal_freqs[0] >= band_limits.lower \ if (signal_freqs[0] >= band_limits.lower \
and signal_freqs[0] < band_limits.upper \ and signal_freqs[0] < band_limits.upper) \
or signal_freqs[1] >= band_limits.lower \ or (signal_freqs[1] >= band_limits.lower \
and signal_freqs[1] < band_limits.upper: and signal_freqs[1] < band_limits.upper):
band_filter_ok = True band_filter_ok = True
lower_freq_filter = self.lower_freq_spinbox.value() lower_freq_filter = self.lower_freq_spinbox.value()
upper_freq_filter = self.upper_freq_spinbox.value() upper_freq_filter = self.upper_freq_spinbox.value()

View File

@@ -17,7 +17,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>ARTEMIS2</string> <string>ARTEMIS3</string>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">QWidget { <string notr="true">QWidget {
@@ -2330,6 +2330,14 @@ QPushButton:checked {
<bold>true</bold> <bold>true</bold>
</font> </font>
</property> </property>
<property name="currentText">
<string>MHz</string>
</property>
<item>
<property name="text">
<string>MHz</string>
</property>
</item>
<item> <item>
<property name="text"> <property name="text">
<string>Hz</string> <string>Hz</string>
@@ -2340,11 +2348,6 @@ QPushButton:checked {
<string>kHz</string> <string>kHz</string>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>MHz</string>
</property>
</item>
<item> <item>
<property name="text"> <property name="text">
<string>GHz</string> <string>GHz</string>
@@ -2586,6 +2589,9 @@ QPushButton:checked {
<bold>true</bold> <bold>true</bold>
</font> </font>
</property> </property>
<property name="currentText">
<string>MHz</string>
</property>
<property name="maxCount"> <property name="maxCount">
<number>4</number> <number>4</number>
</property> </property>
@@ -2595,6 +2601,11 @@ QPushButton:checked {
<property name="modelColumn"> <property name="modelColumn">
<number>0</number> <number>0</number>
</property> </property>
<item>
<property name="text">
<string>MHz</string>
</property>
</item>
<item> <item>
<property name="text"> <property name="text">
<string>Hz</string> <string>Hz</string>
@@ -2605,11 +2616,6 @@ QPushButton:checked {
<string>kHz</string> <string>kHz</string>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>MHz</string>
</property>
</item>
<item> <item>
<property name="text"> <property name="text">
<string>GHz</string> <string>GHz</string>
@@ -2636,13 +2642,27 @@ QPushButton:checked {
</font> </font>
</property> </property>
<property name="text"> <property name="text">
<string>Applay frequency filters</string> <string>Applay</string>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="reset_frequency_filters_btn">
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_4"> <widget class="QWidget" name="tab_4">
@@ -2695,7 +2715,7 @@ border: 1px solid gray;
border-radius: 5px;</string> border-radius: 5px;</string>
</property> </property>
<property name="text"> <property name="text">
<string>Remove all filters</string> <string>Reset all filters</string>
</property> </property>
</widget> </widget>
</item> </item>