Customizable marker display fields

pull/71/head^2
Rune Broberg 2019-10-29 11:16:33 +01:00
rodzic 181c7ba79f
commit f4c88e2ee3
3 zmienionych plików z 63 dodań i 17 usunięć

Wyświetl plik

@ -33,7 +33,7 @@ class Marker(QtCore.QObject):
updated = pyqtSignal(object)
fieldSelection = ["actualfreq", "impedance", "vswr"]
fieldSelection = []
def __init__(self, name, initialColor, frequency=""):
super().__init__()
@ -53,12 +53,17 @@ class Marker(QtCore.QObject):
self.frequency_label = QtWidgets.QLabel("")
self.frequency_label.setMinimumWidth(100)
self.impedance_label = QtWidgets.QLabel("")
self.admittance_label = QtWidgets.QLabel("")
# self.admittance_label = QtWidgets.QLabel("")
self.parallel_r_label = QtWidgets.QLabel("")
self.parallel_x_label = QtWidgets.QLabel("")
self.parallel_c_label = QtWidgets.QLabel("")
self.parallel_l_label = QtWidgets.QLabel("")
self.returnloss_label = QtWidgets.QLabel("")
self.returnloss_label.setMinimumWidth(80)
self.vswr_label = QtWidgets.QLabel("")
self.series_r_label = QtWidgets.QLabel("")
self.series_lc_label = QtWidgets.QLabel("")
self.inductance_label = QtWidgets.QLabel("")
self.capacitance_label = QtWidgets.QLabel("")
self.gain_label = QtWidgets.QLabel("")
@ -68,9 +73,14 @@ class Marker(QtCore.QObject):
self.fields = {"actualfreq": ("Frequency:", self.frequency_label),
"impedance": ("Impedance:", self.impedance_label),
"admittance": ("Admittance:", self.admittance_label),
"serr": ("Series R:", self.series_r_label),
"serl": ("Series L:", self.inductance_label),
"serc": ("Series C:", self.capacitance_label),
"serlc": ("Series L/C:", self.series_lc_label),
"parr": ("Parallel R:", self.parallel_r_label),
"parc": ("Parallel C:", self.parallel_c_label),
"parl": ("Parallel L:", self.parallel_l_label),
"parlc": ("Parallel L/C:", self.parallel_x_label),
"returnloss": ("Return loss:", self.returnloss_label),
"vswr": ("VSWR:", self.vswr_label),
@ -248,22 +258,28 @@ class Marker(QtCore.QObject):
if re50 > 0:
rp = (re50 ** 2 + im50 ** 2) / re50
rp = round(rp, 4 - max(0, math.floor(math.log10(abs(rp)))))
rpstr = str(rp) + " \N{OHM SIGN}"
rpstr = str(rp)
re50 = round(re50, 4 - max(0, math.floor(math.log10(abs(re50)))))
else:
rpstr = "- \N{OHM SIGN}"
rpstr = "-"
re50 = 0
if im50 != 0:
xp = (re50 ** 2 + im50 ** 2) / im50
xp = round(xp, 4 - max(0, math.floor(math.log10(abs(xp)))))
xpcstr = RFTools.capacitanceEquivalent(xp, s11data[self.location].freq)
xplstr = RFTools.inductanceEquivalent(xp, s11data[self.location].freq)
if xp < 0:
xpstr = RFTools.capacitanceEquivalent(xp, s11data[self.location].freq)
xpstr = xpcstr
xp50str = " -j" + str(-1 * xp)
else:
xpstr = RFTools.inductanceEquivalent(xp, s11data[self.location].freq)
xpstr = xplstr
xp50str = " +j" + str(xp)
xp50str += " \N{OHM SIGN}"
else:
xpstr = "-"
xp50str = " +j ? \N{OHM SIGN}"
xpstr = xpcstr = xplstr = "-"
if im50 != 0:
im50 = round(im50, 4 - max(0, math.floor(math.log10(abs(im50)))))
@ -276,7 +292,9 @@ class Marker(QtCore.QObject):
self.frequency_label.setText(RFTools.formatFrequency(s11data[self.location].freq))
self.impedance_label.setText(str(re50) + im50str)
self.parallel_r_label.setText(rpstr)
self.admittance_label.setText(rpstr + xp50str)
self.series_r_label.setText(str(re50) + " \N{OHM SIGN}")
self.parallel_r_label.setText(rpstr + " \N{OHM SIGN}")
self.parallel_x_label.setText(xpstr)
if self.returnloss_is_positive:
returnloss = -round(RFTools.gain(s11data[self.location]), 3)
@ -287,6 +305,12 @@ class Marker(QtCore.QObject):
inductance = RFTools.inductanceEquivalent(im50, s11data[self.location].freq)
self.inductance_label.setText(inductance)
self.capacitance_label.setText(capacitance)
self.parallel_c_label.setText(xpcstr)
self.parallel_l_label.setText(xplstr)
if im50 > 0:
self.series_lc_label.setText(inductance)
else:
self.series_lc_label.setText(capacitance)
vswr = round(vswr, 3)
if vswr < 0:
vswr = "-"

Wyświetl plik

@ -1196,37 +1196,61 @@ class DisplaySettingsWindow(QtWidgets.QWidget):
# TODO: Make this tolerant of non-existant charts
chart00_selection = QtWidgets.QComboBox()
chart00_selection.addItems(selections)
chart00_selection.setCurrentIndex(selections.index(self.app.settings.value("Chart00", "S11 Smith Chart")))
chart00 = self.app.settings.value("Chart00", "S11 Smith Chart")
if chart00_selection.findText(chart00) > -1:
chart00_selection.setCurrentText(chart00)
else:
chart00_selection.setCurrentText("S11 Smith Chart")
chart00_selection.currentTextChanged.connect(lambda: self.changeChart(0, 0, chart00_selection.currentText()))
charts_layout.addWidget(chart00_selection, 0, 0)
chart01_selection = QtWidgets.QComboBox()
chart01_selection.addItems(selections)
chart01_selection.setCurrentIndex(selections.index(self.app.settings.value("Chart01", "S11 Return Loss")))
chart01 = self.app.settings.value("Chart01", "S11 Return Loss")
if chart01_selection.findText(chart01) > -1:
chart01_selection.setCurrentText(chart01)
else:
chart01_selection.setCurrentText("S11 Return Loss")
chart01_selection.currentTextChanged.connect(lambda: self.changeChart(0, 1, chart01_selection.currentText()))
charts_layout.addWidget(chart01_selection, 0, 1)
chart02_selection = QtWidgets.QComboBox()
chart02_selection.addItems(selections)
chart02_selection.setCurrentIndex(selections.index(self.app.settings.value("Chart02", "None")))
chart02 = self.app.settings.value("Chart02", "None")
if chart02_selection.findText(chart02) > -1:
chart02_selection.setCurrentText(chart02)
else:
chart02_selection.setCurrentText("None")
chart02_selection.currentTextChanged.connect(lambda: self.changeChart(0, 2, chart02_selection.currentText()))
charts_layout.addWidget(chart02_selection, 0, 2)
chart10_selection = QtWidgets.QComboBox()
chart10_selection.addItems(selections)
chart10_selection.setCurrentIndex(selections.index(self.app.settings.value("Chart10", "S21 Polar Plot")))
chart10 = self.app.settings.value("Chart10", "S21 Polar Plot")
if chart10_selection.findText(chart10) > -1:
chart10_selection.setCurrentText(chart10)
else:
chart10_selection.setCurrentText("S21 Polar Plot")
chart10_selection.currentTextChanged.connect(lambda: self.changeChart(1, 0, chart10_selection.currentText()))
charts_layout.addWidget(chart10_selection, 1, 0)
chart11_selection = QtWidgets.QComboBox()
chart11_selection.addItems(selections)
chart11_selection.setCurrentIndex(selections.index(self.app.settings.value("Chart11", "S21 Gain")))
chart11 = self.app.settings.value("Chart11", "S21 Gain")
if chart11_selection.findText(chart11) > -1:
chart11_selection.setCurrentText(chart11)
else:
chart11_selection.setCurrentText("S21 Gain")
chart11_selection.currentTextChanged.connect(lambda: self.changeChart(1, 1, chart11_selection.currentText()))
charts_layout.addWidget(chart11_selection, 1, 1)
chart12_selection = QtWidgets.QComboBox()
chart12_selection.addItems(selections)
chart12_selection.setCurrentIndex(selections.index(self.app.settings.value("Chart12", "None")))
chart12 = self.app.settings.value("Chart12", "None")
if chart12_selection.findText(chart12) > -1:
chart12_selection.setCurrentText(chart12)
else:
chart12_selection.setCurrentText("None")
chart12_selection.currentTextChanged.connect(lambda: self.changeChart(1, 2, chart12_selection.currentText()))
charts_layout.addWidget(chart12_selection, 1, 2)

Wyświetl plik

@ -141,8 +141,7 @@ class RFTools:
return "\N{INFINITY}"
raise ValueError("Frequency to big. More than 15 digits!")
if maxdigits < 3:
raise ValueError(
"At least 3 digits are needed, given ({})".format(maxdigits))
raise ValueError("At least 3 digits are needed, given ({})".format(maxdigits))
if freq < 1:
return " - " + ("Hz" if appendHz else "")
@ -150,8 +149,7 @@ class RFTools:
dot_pos = freqlen % 3 or 3
freqstr = freqstr[:dot_pos] + "." + freqstr[dot_pos:] + "00"
return freqstr[:maxdigits] + PREFIXES[si_index] + \
("Hz" if appendHz else "")
return freqstr[:maxdigits] + PREFIXES[si_index] + ("Hz" if appendHz else "")
@staticmethod
def parseFrequency(freq: str) -> int: