Skip to content

Commit

Permalink
v0.10.3 release
Browse files Browse the repository at this point in the history
CSV import bugfixes
Preset marker improvements
  • Loading branch information
g4ixt committed Apr 26, 2024
1 parent 432f2ce commit 584d21a
Show file tree
Hide file tree
Showing 12 changed files with 350 additions and 42 deletions.
1 change: 1 addition & 0 deletions QtTSApreferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def setupUi(self, Preferences):
self.label_12.setObjectName("label_12")
self.gridLayout.addWidget(self.label_12, 3, 0, 1, 1)
self.filterBox = QtWidgets.QComboBox(self.layoutWidget)
self.filterBox.setEditable(False)
self.filterBox.setObjectName("filterBox")
self.gridLayout.addWidget(self.filterBox, 3, 1, 1, 1)
self.exportButton = QtWidgets.QPushButton(self.layoutWidget)
Expand Down
Binary file modified QtTSAprefs.db
Binary file not shown.
74 changes: 40 additions & 34 deletions QtTinySA.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,14 +684,14 @@ def updateMarker(self, frequencies, readings, fPeaks): # called by updateGUI()
else:
self.vline.label.setText(f'M{self.vline.name()} {self.vline.value():.3f}MHz {dBm:.1f}dBm')

def addFreqMarker(self, freq, colour, name): # adds simple frequency marker without full marker capability
def addFreqMarker(self, freq, colour, name, position): # adds simple freq marker without full marker capability
if ui.presetLabel.isChecked():
marker = ui.graphWidget.addLine(freq, 90, pen=pyqtgraph.mkPen(colour, width=0.5, style=QtCore.Qt.DashLine),
label=name, labelOpts={'position': 0.05, 'color': (colour)})
marker.label.setMovable(True)
self.marker = ui.graphWidget.addLine(freq, 90, pen=pyqtgraph.mkPen(colour, width=0.5, style=QtCore.Qt.DashLine),
label=name, labelOpts={'position': position, 'color': (colour)})
self.marker.label.setMovable(True)
else:
marker = ui.graphWidget.addLine(freq, 90, pen=pyqtgraph.mkPen(colour, width=0.5, style=QtCore.Qt.DashLine))
self.fifo.put(marker) # store the marker object in a queue
self.marker = ui.graphWidget.addLine(freq, 90, pen=pyqtgraph.mkPen(colour, width=0.5, style=QtCore.Qt.DashLine))
self.fifo.put(self.marker) # store the marker object in a queue

def delFreqMarkers(self):
for i in range(0, self.fifo.qsize()):
Expand Down Expand Up @@ -846,7 +846,7 @@ def readCSV(self, fileName):
for row in reader:
record = self.tm.record()
for key, value in row.items():
# relational mapping doesn't work for these fields
# don't understand how to make relation work for these fields
if key == 'preset':
value = presetID(value)
if key.lower() == 'colour':
Expand Down Expand Up @@ -1040,20 +1040,25 @@ def popUp(message, button, icon):


def freqMarkers():
presetmarker.tm.select()
S1.delFreqMarkers()
S2.delFreqMarkers()
if ui.presetMarker.isChecked():
for i in range(0, bands.tm.rowCount()):
try:
startF = bands.tm.record(i).value('StartF')
colour = bands.tm.record(i).value('colour')
name = bands.tm.record(i).value('name')
S1.addFreqMarker(startF, colour, name)
stopF = bands.tm.record(i).value('StopF')
if bandstype.tm.record(ui.filterBox.currentIndex()).value('type') == 'band':
S2.addFreqMarker(stopF, colour, '')
except ValueError:
continue
for i in range(0, presetmarker.tm.rowCount()):
try:
startF = presetmarker.tm.record(i).value('StartF')
colour = presetmarker.tm.record(i).value('colour')
name = presetmarker.tm.record(i).value('name')
if ui.presetMarker.isChecked() and presetmarker.tm.record(i).value('visible')\
and presetmarker.tm.record(i).value('type') != 'band':
S1.addFreqMarker(startF, colour, name, 0.05)
if ui.presetLabel.isChecked() and ui.presetLabel.checkState() == 2:
S1.marker.label.setAngle(90)
if presetmarker.tm.record(i).value('type') == 'band':
stopF = presetmarker.tm.record(i).value('StopF')
S1.addFreqMarker(startF, colour, name, 0.98)
S2.addFreqMarker(stopF, colour, name, 0.98)
except ValueError:
continue


def freqMarkerLabel():
Expand Down Expand Up @@ -1114,7 +1119,6 @@ def colourID(shade): # using the QSQLRelation directly doesn't work for colour.
###############################################################################
# Instantiate classes


tinySA = analyser()

app = QtWidgets.QApplication([]) # create QApplication for the GUI
Expand Down Expand Up @@ -1149,6 +1153,7 @@ def colourID(shade): # using the QSQLRelation directly doesn't work for colour.
colours = modelView('SVGColour')
maps = modelView('mapping')

presetmarker = modelView(('frequencies'))

###############################################################################
# GUI settings
Expand Down Expand Up @@ -1181,7 +1186,6 @@ def colourID(shade): # using the QSQLRelation directly doesn't work for colour.
S4.hline.setMovable(True)
S4.hline.label.setFormat("{value:.1f}")


###############################################################################
# Connect signals from buttons and sliders. Connections for freq and rbw boxes are in 'initialise' Fn

Expand Down Expand Up @@ -1218,9 +1222,10 @@ def colourID(shade): # using the QSQLRelation directly doesn't work for colour.
ui.m4_type.activated.connect(S4.mType)

# frequency band markers
ui.presetMarker.stateChanged.connect(freqMarkers)
ui.presetMarker.clicked.connect(freqMarkers)
ui.presetLabel.stateChanged.connect(freqMarkerLabel)
ui.mToBand.clicked.connect(addBandPressed)
ui.filterBox.currentTextChanged.connect(freqMarkers)

# trace checkboxes
ui.trace1.stateChanged.connect(S1.tEnable)
Expand Down Expand Up @@ -1276,30 +1281,32 @@ def colourID(shade): # using the QSQLRelation directly doesn't work for colour.
# table models - read/write views of the configuration data
maps.createTableModel()
maps.tm.select()
bands.createTableModel() # relational

bands.createTableModel()
bands.tm.setSort(3, QtCore.Qt.AscendingOrder)
bands.tm.setHeaderData(5, QtCore.Qt.Horizontal, 'visible')
bands.tm.setHeaderData(7, QtCore.Qt.Horizontal, 'LO')

bands.tm.setEditStrategy(QSqlRelationalTableModel.OnFieldChange)
bands.tm.setRelation(2, QSqlRelation('freqtype', 'ID', 'preset')) # set 'type' column to a freq type choice combo box
bands.tm.setRelation(5, QSqlRelation('boolean', 'ID', 'value')) # set 'view' column to a True/False choice combo box
boolean = QSqlRelationalDelegate(preferences.freqBands)
preferences.freqBands.setItemDelegate(boolean)

bands.tm.setRelation(6, QSqlRelation('SVGColour', 'ID', 'colour')) # set 'marker' column to a colours choice combo box
colour = QSqlRelationalDelegate(preferences.freqBands)
preferences.freqBands.setItemDelegate(colour)

bands.tm.setRelation(2, QSqlRelation('freqtype', 'ID', 'preset')) # set 'type' column to a freq type choice combo box
preset = QSqlRelationalDelegate(preferences.freqBands)
preferences.freqBands.setItemDelegate(preset)

presets = QSqlRelationalDelegate(preferences.freqBands)
preferences.freqBands.setItemDelegate(presets)
colHeader = preferences.freqBands.horizontalHeader()
colHeader.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents)

bandstype.createTableModel()
bandstype.tm.select()

colours.createTableModel()
colours.tm.select()

presetmarker.createTableModel()
presetmarker.tm.setRelation(6, QSqlRelation('SVGColour', 'ID', 'colour'))
presetmarker.tm.setRelation(2, QSqlRelation('freqtype', 'ID', 'type'))
presetmarker.tm.select()

# populate the band presets combo box
ui.band_box.setModel(bands.tm)
ui.band_box.setModelColumn(1)
Expand All @@ -1310,7 +1317,6 @@ def colourID(shade): # using the QSQLRelation directly doesn't work for colour.
preferences.filterBox.setModelColumn(1)
ui.filterBox.setModel(bandstype.tm)
ui.filterBox.setModelColumn(1)
bandstype.tm.select()

# connect the preferences dialogue box freq band table widget to the data model
preferences.freqBands.setModel(bands.tm)
Expand Down
9 changes: 5 additions & 4 deletions QtTinySpectrum.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'QtTinySpectrum_small.ui'
# Form implementation generated from reading ui file 'QtTinySpectrum.ui'
#
# Created by: PyQt5 UI code generator 5.15.10
#
Expand Down Expand Up @@ -500,6 +500,7 @@ def setupUi(self, MainWindow):
font = QtGui.QFont()
font.setPointSize(8)
self.presetLabel.setFont(font)
self.presetLabel.setTristate(True)
self.presetLabel.setObjectName("presetLabel")
self.gridLayout_2.addWidget(self.presetLabel, 2, 10, 1, 1)
self.marker3 = QtWidgets.QCheckBox(self.ViewNormal)
Expand Down Expand Up @@ -976,7 +977,7 @@ def retranslateUi(self, MainWindow):
self.filterBox.setToolTip(_translate("MainWindow", "Filter preset list"))
self.centre_freq.setToolTip(_translate("MainWindow", "Sweep Centre"))
self.scan_button.setText(_translate("MainWindow", "Run"))
self.presetMarker.setToolTip(_translate("MainWindow", "Mark preset freqs"))
self.presetMarker.setToolTip(_translate("MainWindow", "Show markers for preset freqs"))
self.presetMarker.setText(_translate("MainWindow", "Presets"))
self.band_box.setToolTip(_translate("MainWindow", "<html><head/><body><p>Preset Frequency list</p></body></html>"))
self.m4_type.setToolTip(_translate("MainWindow", "Marker Type"))
Expand All @@ -985,8 +986,8 @@ def retranslateUi(self, MainWindow):
self.m3_type.setToolTip(_translate("MainWindow", "Marker type"))
self.marker4.setText(_translate("MainWindow", "M4"))
self.start_freq.setToolTip(_translate("MainWindow", "Sweep Start"))
self.presetLabel.setToolTip(_translate("MainWindow", "Label preset freqs"))
self.presetLabel.setText(_translate("MainWindow", "Labels"))
self.presetLabel.setToolTip(_translate("MainWindow", "Show/hide/rotate preset marker labels"))
self.presetLabel.setText(_translate("MainWindow", "Label"))
self.marker3.setText(_translate("MainWindow", "M3"))
self.timeSpectrum.setToolTip(_translate("MainWindow", "3D spectrum"))
self.timeSpectrum.setText(_translate("MainWindow", "3D"))
Expand Down
9 changes: 6 additions & 3 deletions QtTinySpectrum.ui
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@
</font>
</property>
<property name="toolTip">
<string>Mark preset freqs</string>
<string>Show markers for preset freqs</string>
</property>
<property name="text">
<string>Presets</string>
Expand Down Expand Up @@ -1065,10 +1065,13 @@
</font>
</property>
<property name="toolTip">
<string>Label preset freqs</string>
<string>Show/hide/rotate preset marker labels</string>
</property>
<property name="text">
<string>Labels</string>
<string>Label</string>
</property>
<property name="tristate">
<bool>true</bool>
</property>
</widget>
</item>
Expand Down
41 changes: 41 additions & 0 deletions Sample_preset_markers/TV_channels.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name,preset,startF,stopF,value,colour
21,marker,474,,TRUE,orange
22,marker,482,,TRUE,orange
23,marker,490,,TRUE,orange
24,marker,498,,TRUE,orange
25,marker,506,,TRUE,orange
26,marker,514,,TRUE,orange
27,marker,522,,TRUE,orange
28,marker,530,,TRUE,orange
29,marker,538,,TRUE,orange
30,marker,546,,TRUE,orange
31,marker,554,,TRUE,orange
32,marker,562,,TRUE,orange
33,marker,570,,TRUE,orange
34,marker,578,,TRUE,orange
35,marker,586,,TRUE,orange
36,marker,594,,TRUE,orange
37,marker,602,,TRUE,orange
38,marker,610,,TRUE,orange
39,marker,618,,TRUE,orange
40,marker,626,,TRUE,orange
41,marker,634,,TRUE,orange
42,marker,642,,TRUE,orange
43,marker,650,,TRUE,orange
44,marker,658,,TRUE,orange
45,marker,666,,TRUE,orange
46,marker,674,,TRUE,orange
47,marker,682,,TRUE,orange
48,marker,690,,TRUE,orange
49,marker,698,,TRUE,orange
50,marker,706,,TRUE,orange
51,marker,714,,TRUE,orange
52,marker,722,,TRUE,orange
53,marker,730,,TRUE,orange
54,marker,738,,TRUE,orange
55,marker,746,,TRUE,orange
56,marker,754,,TRUE,orange
57,marker,762,,TRUE,orange
58,marker,770,,TRUE,orange
59,marker,778,,TRUE,orange
60,marker,786,,TRUE,orange
Binary file added Sample_preset_markers/TV_channels.ods
Binary file not shown.
3 changes: 3 additions & 0 deletions Sample_preset_markers/TV_channels_test.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name,preset,startF,stopF,value,colour
21,marker,470,478,True,crimson
22,marker,478,486,True,blue
79 changes: 79 additions & 0 deletions Sample_preset_markers/broadcast.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name,preset,startF,stopF,value,colour
FM,broadcast,87.5,108,True,lime
DAB,broadcast,175,230,True,lime
TV,broadcast,470,700,True,lime
5B,marker,176.64,,True,orange
5C,marker,178.352,,True,orange
5D,marker,180.064,,True,orange
6A,marker,181.936,,True,orange
6B,marker,183.648,,True,orange
6C,marker,185.36,,True,orange
6D,marker,187.072,,True,orange
7A,marker,188.928,,True,orange
7B,marker,190.64,,True,orange
7C,marker,192.352,,True,orange
7D,marker,194.064,,True,orange
8A,marker,195.936,,True,orange
8B,marker,197.648,,True,orange
8C,marker,199.36,,True,orange
8D,marker,201.072,,True,orange
9A,marker,202.928,,True,orange
9B,marker,204.64,,True,orange
9C,marker,206.352,,True,orange
9D,marker,208.064,,True,orange
10A,marker,209.936,,True,orange
10B,marker,211.648,,True,orange
10C,marker,213.36,,True,orange
10D,marker,215.072,,True,orange
11A,marker,216.928,,True,orange
11B,marker,218.64,,True,orange
11C,marker,220.352,,True,orange
11D,marker,222.064,,True,orange
12A,marker,223.936,,True,orange
12B,marker,225.648,,True,orange
12C,marker,227.36,,True,orange
12D,marker,229.072,,True,orange
13A,marker,230.784,,True,orange
13B,marker,232.496,,True,orange
13C,marker,234.208,,True,orange
13D,marker,235.776,,True,orange
21,marker,474,,True,orange
22,marker,482,,True,orange
23,marker,490,,True,orange
24,marker,498,,True,orange
25,marker,506,,True,orange
26,marker,514,,True,orange
27,marker,522,,True,orange
28,marker,530,,True,orange
29,marker,538,,True,orange
30,marker,546,,True,orange
31,marker,554,,True,orange
32,marker,562,,True,orange
33,marker,570,,True,orange
34,marker,578,,True,orange
35,marker,586,,True,orange
36,marker,594,,True,orange
37,marker,602,,True,orange
38,marker,610,,True,orange
39,marker,618,,True,orange
40,marker,626,,True,orange
41,marker,634,,True,orange
42,marker,642,,True,orange
43,marker,650,,True,orange
44,marker,658,,True,orange
45,marker,666,,True,orange
46,marker,674,,True,orange
47,marker,682,,True,orange
48,marker,690,,True,orange
49,marker,698,,True,orange
50,marker,706,,True,orange
51,marker,714,,True,orange
52,marker,722,,True,orange
53,marker,730,,True,orange
54,marker,738,,True,orange
55,marker,746,,True,orange
56,marker,754,,True,orange
57,marker,762,,True,orange
58,marker,770,,True,orange
59,marker,778,,True,orange
60,marker,786,,True,orange
Loading

0 comments on commit 584d21a

Please sign in to comment.