kopia lustrzana https://github.com/NanoVNA-Saver/nanovna-saver
First attempts at allowing popping out of charts
rodzic
03c1ade459
commit
bbaf56ab60
|
@ -20,6 +20,7 @@ import numpy as np
|
|||
import logging
|
||||
|
||||
from PyQt5 import QtWidgets, QtGui, QtCore
|
||||
from PyQt5.QtCore import pyqtSignal
|
||||
|
||||
from .Marker import Marker
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -46,6 +47,8 @@ class Chart(QtWidgets.QWidget):
|
|||
minChartHeight = 200
|
||||
minChartWidth = 200
|
||||
|
||||
popoutRequested = pyqtSignal(object)
|
||||
|
||||
def __init__(self, name):
|
||||
super().__init__()
|
||||
self.name = name
|
||||
|
@ -54,6 +57,9 @@ class Chart(QtWidgets.QWidget):
|
|||
self.action_save_screenshot = QtWidgets.QAction("Save image")
|
||||
self.action_save_screenshot.triggered.connect(self.saveScreenshot)
|
||||
self.addAction(self.action_save_screenshot)
|
||||
self.action_popout = QtWidgets.QAction("Popout chart")
|
||||
self.action_popout.triggered.connect(lambda: self.popoutRequested.emit(self))
|
||||
self.addAction(self.action_popout)
|
||||
|
||||
def setSweepColor(self, color : QtGui.QColor):
|
||||
self.sweepColor = color
|
||||
|
@ -171,6 +177,23 @@ class Chart(QtWidgets.QWidget):
|
|||
if filename != "":
|
||||
self.grab().save(filename)
|
||||
|
||||
def copy(self):
|
||||
new_chart = self.__class__(self.name)
|
||||
new_chart.data = self.data
|
||||
new_chart.reference = self.reference
|
||||
new_chart.sweepColor = self.sweepColor
|
||||
new_chart.secondarySweepColor = self.secondarySweepColor
|
||||
new_chart.referenceColor = self.referenceColor
|
||||
new_chart.secondaryReferenceColor = self.secondaryReferenceColor
|
||||
new_chart.setBackgroundColor(self.backgroundColor)
|
||||
new_chart.textColor = self.textColor
|
||||
new_chart.foregroundColor = self.foregroundColor
|
||||
new_chart.markers = self.markers
|
||||
new_chart.bands = self.bands
|
||||
new_chart.drawLines = self.drawLines
|
||||
new_chart.resize(self.width(), self.height())
|
||||
return new_chart
|
||||
|
||||
|
||||
class FrequencyChart(Chart):
|
||||
fstart = 0
|
||||
|
@ -272,6 +295,9 @@ class FrequencyChart(Chart):
|
|||
self.menu.addMenu(self.y_menu)
|
||||
self.menu.addSeparator()
|
||||
self.menu.addAction(self.action_save_screenshot)
|
||||
self.action_popout = QtWidgets.QAction("Popout chart")
|
||||
self.action_popout.triggered.connect(lambda: self.popoutRequested.emit(self))
|
||||
self.menu.addAction(self.action_popout)
|
||||
|
||||
def contextMenuEvent(self, event):
|
||||
self.action_set_fixed_start.setText("Start (" + Chart.shortenFrequency(self.minFrequency) + ")")
|
||||
|
|
|
@ -139,12 +139,15 @@ class NanoVNASaver(QtWidgets.QWidget):
|
|||
self.s21charts.append(self.s21Phase)
|
||||
|
||||
# List of all charts that can be selected for display
|
||||
self.charts = self.s11charts + self.s21charts
|
||||
self.charts.append(self.tdr_chart)
|
||||
self.selectable_charts = self.s11charts + self.s21charts
|
||||
self.selectable_charts.append(self.tdr_chart)
|
||||
|
||||
for c in self.selectable_charts:
|
||||
c.popoutRequested.connect(self.popoutChart)
|
||||
|
||||
# List of all charts that subscribe to updates (including duplicates!)
|
||||
self.subscribing_charts = []
|
||||
self.subscribing_charts.extend(self.charts)
|
||||
self.subscribing_charts.extend(self.selectable_charts)
|
||||
|
||||
self.charts_layout = QtWidgets.QGridLayout()
|
||||
|
||||
|
@ -996,6 +999,14 @@ class NanoVNASaver(QtWidgets.QWidget):
|
|||
self.showError(self.worker.error_message)
|
||||
self.stopSerial()
|
||||
|
||||
def popoutChart(self, chart: Chart):
|
||||
logger.debug("Requested popout for chart: %s", chart.name)
|
||||
new_chart = chart.copy()
|
||||
self.subscribing_charts.append(new_chart)
|
||||
new_chart.popoutRequested.connect(self.popoutChart)
|
||||
new_chart.show()
|
||||
new_chart.setWindowTitle(new_chart.name)
|
||||
|
||||
def closeEvent(self, a0: QtGui.QCloseEvent) -> None:
|
||||
self.worker.stopped = True
|
||||
self.settings.setValue("Marker1Color", self.markers[0].color)
|
||||
|
@ -1178,7 +1189,7 @@ class DisplaySettingsWindow(QtWidgets.QWidget):
|
|||
|
||||
selections = []
|
||||
|
||||
for c in self.app.charts:
|
||||
for c in self.app.selectable_charts:
|
||||
selections.append(c.name)
|
||||
|
||||
selections.append("None")
|
||||
|
@ -1267,7 +1278,7 @@ class DisplaySettingsWindow(QtWidgets.QWidget):
|
|||
|
||||
def changeChart(self, x, y, chart):
|
||||
found = None
|
||||
for c in self.app.charts:
|
||||
for c in self.app.selectable_charts:
|
||||
if c.name == chart:
|
||||
found = c
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue