kopia lustrzana https://github.com/NanoVNA-Saver/nanovna-saver
Selectable sweep color, and a darker default color.
Alpha-channel can be selected for sweep and marker colors. .gitignore updated to ignore pyinstaller files.pull/6/head
rodzic
cb4409d2f1
commit
d0338c0533
|
@ -1,2 +1,5 @@
|
|||
/venv/
|
||||
.idea
|
||||
/build/
|
||||
/dist/
|
||||
/nanovna-saver.spec
|
||||
|
|
|
@ -58,6 +58,8 @@ class LogMagChart(QtWidgets.QWidget):
|
|||
|
||||
self.marker1Color = QtGui.QColor(255, 0, 20)
|
||||
self.marker2Color = QtGui.QColor(20, 0, 255)
|
||||
self.sweepColor = QtGui.QColor(220, 200, 30, 128)
|
||||
|
||||
|
||||
def resizeEvent(self, a0: QtGui.QResizeEvent) -> None:
|
||||
self.chartWidth = a0.size().width()-20-self.leftMargin
|
||||
|
@ -80,7 +82,7 @@ class LogMagChart(QtWidgets.QWidget):
|
|||
def drawValues(self, qp: QtGui.QPainter):
|
||||
if len(self.data) == 0:
|
||||
return
|
||||
pen = QtGui.QPen(QtGui.QColor(220, 200, 30, 128))
|
||||
pen = QtGui.QPen(self.sweepColor)
|
||||
pen.setWidth(2)
|
||||
highlighter = QtGui.QPen(QtGui.QColor(20, 0, 255))
|
||||
highlighter.setWidth(3)
|
||||
|
@ -169,4 +171,8 @@ class LogMagChart(QtWidgets.QWidget):
|
|||
return frequency
|
||||
if frequency < 5000000:
|
||||
return str(round(frequency / 1000)) + "k"
|
||||
return str(round(frequency / 1000000, 1)) + "M"
|
||||
return str(round(frequency / 1000000, 1)) + "M"
|
||||
|
||||
def setSweepColor(self, color : QtGui.QColor):
|
||||
self.sweepColor = color
|
||||
self.update()
|
11
Marker.py
11
Marker.py
|
@ -43,7 +43,7 @@ class Marker(QtCore.QObject):
|
|||
self.btnColorPicker = QtWidgets.QPushButton("█")
|
||||
self.btnColorPicker.setFixedWidth(20)
|
||||
self.setColor(initialColor)
|
||||
self.btnColorPicker.clicked.connect(lambda: self.setColor(QtWidgets.QColorDialog.getColor()))
|
||||
self.btnColorPicker.clicked.connect(lambda: self.setColor(QtWidgets.QColorDialog.getColor(self.color, options=QtWidgets.QColorDialog.ShowAlphaChannel)))
|
||||
|
||||
self.layout = QtWidgets.QHBoxLayout()
|
||||
self.layout.addWidget(self.frequencyInput)
|
||||
|
@ -58,10 +58,11 @@ class Marker(QtCore.QObject):
|
|||
return
|
||||
|
||||
def setColor(self, color):
|
||||
self.color = color
|
||||
p = self.btnColorPicker.palette()
|
||||
p.setColor(QtGui.QPalette.ButtonText, self.color)
|
||||
self.btnColorPicker.setPalette(p)
|
||||
if color.isValid():
|
||||
self.color = color
|
||||
p = self.btnColorPicker.palette()
|
||||
p.setColor(QtGui.QPalette.ButtonText, self.color)
|
||||
self.btnColorPicker.setPalette(p)
|
||||
|
||||
def getRow(self):
|
||||
return (QtWidgets.QLabel(self.name), self.layout)
|
||||
|
|
|
@ -54,12 +54,16 @@ class NanoVNASaver(QtWidgets.QWidget):
|
|||
self.serialPort = "COM11"
|
||||
# self.serialSpeed = "115200"
|
||||
|
||||
self.color = QtGui.QColor(160, 140, 20, 128)
|
||||
|
||||
self.setWindowTitle("NanoVNA Saver")
|
||||
layout = QtWidgets.QGridLayout()
|
||||
self.setLayout(layout)
|
||||
|
||||
self.smithChart = SmithChart("S11")
|
||||
self.s21SmithChart = SmithChart("S21")
|
||||
self.s11LogMag = LogMagChart("S11 Return Loss")
|
||||
self.s21LogMag = LogMagChart("S21 Gain")
|
||||
|
||||
left_column = QtWidgets.QVBoxLayout()
|
||||
right_column = QtWidgets.QVBoxLayout()
|
||||
|
@ -92,6 +96,13 @@ class NanoVNASaver(QtWidgets.QWidget):
|
|||
|
||||
sweep_control_layout.addRow(QtWidgets.QLabel("Sweep count"), self.sweepCountInput)
|
||||
|
||||
self.btnColorPicker = QtWidgets.QPushButton("█")
|
||||
self.btnColorPicker.setFixedWidth(20)
|
||||
self.setSweepColor(self.color)
|
||||
self.btnColorPicker.clicked.connect(lambda: self.setSweepColor(QtWidgets.QColorDialog.getColor(self.color, options=QtWidgets.QColorDialog.ShowAlphaChannel)))
|
||||
|
||||
sweep_control_layout.addRow("Sweep color", self.btnColorPicker)
|
||||
|
||||
self.sweepProgressBar = QtWidgets.QProgressBar()
|
||||
self.sweepProgressBar.setMaximum(100)
|
||||
self.sweepProgressBar.setValue(0)
|
||||
|
@ -260,8 +271,6 @@ class NanoVNASaver(QtWidgets.QWidget):
|
|||
|
||||
self.lister = QtWidgets.QPlainTextEdit()
|
||||
self.lister.setFixedHeight(100)
|
||||
self.s11LogMag = LogMagChart("S11 Return Loss")
|
||||
self.s21LogMag = LogMagChart("S21 Gain")
|
||||
charts = QtWidgets.QGridLayout()
|
||||
charts.addWidget(self.smithChart, 0, 0)
|
||||
charts.addWidget(self.s21SmithChart, 1, 0)
|
||||
|
@ -542,4 +551,16 @@ class NanoVNASaver(QtWidgets.QWidget):
|
|||
peak = np.max(td) # We should check that this is an actual *peak*, and not just a vague maximum
|
||||
index_peak = np.argmax(td)
|
||||
|
||||
self.tdr_result_label.setText(str(round(distance_axis[index_peak]/2, 3)) + " m")
|
||||
self.tdr_result_label.setText(str(round(distance_axis[index_peak]/2, 3)) + " m")
|
||||
|
||||
def setSweepColor(self, color : QtGui.QColor):
|
||||
if color.isValid():
|
||||
self.color = color
|
||||
p = self.btnColorPicker.palette()
|
||||
p.setColor(QtGui.QPalette.ButtonText, color)
|
||||
self.btnColorPicker.setPalette(p)
|
||||
|
||||
self.smithChart.setSweepColor(color)
|
||||
self.s21SmithChart.setSweepColor(color)
|
||||
self.s11LogMag.setSweepColor(color)
|
||||
self.s21LogMag.setSweepColor(color)
|
|
@ -46,6 +46,7 @@ class SmithChart(QtWidgets.QWidget):
|
|||
|
||||
self.marker1Color = QtGui.QColor(255, 0, 20)
|
||||
self.marker2Color = QtGui.QColor(20, 0, 255)
|
||||
self.sweepColor = QtGui.QColor(220, 200, 30, 128)
|
||||
|
||||
def resizeEvent(self, a0: QtGui.QResizeEvent) -> None:
|
||||
self.chartWidth = min(a0.size().width()-40, a0.size().height()-40)
|
||||
|
@ -87,7 +88,7 @@ class SmithChart(QtWidgets.QWidget):
|
|||
qp.drawArc(centerX - self.chartWidth*2, centerY, self.chartWidth*5, -self.chartHeight*5, int(-93.85 * 16), int(-18.85 * 16)) # Im(Z) = 0.2
|
||||
|
||||
def drawValues(self, qp: QtGui.QPainter):
|
||||
pen = QtGui.QPen(QtGui.QColor(220, 200, 30, 128))
|
||||
pen = QtGui.QPen(self.sweepColor)
|
||||
pen.setWidth(2)
|
||||
highlighter = QtGui.QPen(QtGui.QColor(20, 0, 255))
|
||||
highlighter.setWidth(3)
|
||||
|
@ -120,4 +121,8 @@ class SmithChart(QtWidgets.QWidget):
|
|||
self.markers = markers
|
||||
|
||||
def heightForWidth(self, a0: int) -> int:
|
||||
return a0
|
||||
return a0
|
||||
|
||||
def setSweepColor(self, color : QtGui.QColor):
|
||||
self.sweepColor = color
|
||||
self.update()
|
Ładowanie…
Reference in New Issue