From c7a7440cf099de114dfbdeda452b4ef446d17404 Mon Sep 17 00:00:00 2001 From: jupfi Date: Mon, 31 Jul 2023 15:43:54 +0200 Subject: [PATCH] Updated view for better readibility. --- src/nqrduck_autotm/controller.py | 2 + src/nqrduck_autotm/resources/autotm_widget.ui | 81 ++++++++++-------- src/nqrduck_autotm/view.py | 22 +++++ src/nqrduck_autotm/widget.py | 84 ++++++++++--------- 4 files changed, 114 insertions(+), 75 deletions(-) diff --git a/src/nqrduck_autotm/controller.py b/src/nqrduck_autotm/controller.py index c2a1324..e90e754 100644 --- a/src/nqrduck_autotm/controller.py +++ b/src/nqrduck_autotm/controller.py @@ -26,3 +26,5 @@ class AutoTMController(ModuleController): except serial.SerialException as e: logger.error("Failed to connect to device %s", device) logger.error(e) + + diff --git a/src/nqrduck_autotm/resources/autotm_widget.ui b/src/nqrduck_autotm/resources/autotm_widget.ui index 44fe3b0..d49e1be 100644 --- a/src/nqrduck_autotm/resources/autotm_widget.ui +++ b/src/nqrduck_autotm/resources/autotm_widget.ui @@ -23,7 +23,7 @@ - + 75 @@ -40,6 +40,13 @@ + + + + Refresh + + + @@ -48,37 +55,30 @@ - - - Connect - - - - - - - Refresh - - - - - - - Connected to: - - - - + + + + Connected to: + + + - + + + Connect + + + + + 75 @@ -91,10 +91,21 @@ - + + + + Mechanical + + + + + Electrical + + + - + 75 @@ -142,15 +153,15 @@ - - - - Start Sweep - - - + + + + Start Sweep + + + @@ -159,7 +170,7 @@ - + 75 @@ -182,7 +193,7 @@ 0 0 273 - 231 + 229 @@ -193,7 +204,7 @@ - + 0 diff --git a/src/nqrduck_autotm/view.py b/src/nqrduck_autotm/view.py index 6d439ac..6213bef 100644 --- a/src/nqrduck_autotm/view.py +++ b/src/nqrduck_autotm/view.py @@ -37,6 +37,28 @@ class AutoTMView(ModuleView): self._ui_form.scrollAreaWidgetContents.setLayout(QVBoxLayout()) self._ui_form.scrollAreaWidgetContents.layout().setAlignment(Qt.AlignmentFlag.AlignTop) + self.init_plot() + self.init_labels() + + def init_labels(self) -> None: + """Makes some of the labels bold for better readability. + """ + self._ui_form.titleconnectionLabel.setStyleSheet("font-weight: bold;") + self._ui_form.titlefrequencyLabel.setStyleSheet("font-weight: bold;") + self._ui_form.titletypeLabel.setStyleSheet("font-weight: bold;") + self._ui_form.titleinfoLabel.setStyleSheet("font-weight: bold;") + + def init_plot(self) -> None: + """Initialize the S11 plot. """ + ax = self._ui_form.S11Plot.canvas.ax + ax.set_xlabel("Frequency (MHz)") + ax.set_ylabel("S11 (dB)") + ax.set_title("S11") + ax.grid(True) + ax.set_xlim(0, 100) + ax.set_ylim(-100, 0) + self._ui_form.S11Plot.canvas.draw() + @pyqtSlot(list) def on_available_devices_changed(self, available_devices : list) -> None: """Update the available devices list in the view. """ diff --git a/src/nqrduck_autotm/widget.py b/src/nqrduck_autotm/widget.py index 986183c..a07b76e 100644 --- a/src/nqrduck_autotm/widget.py +++ b/src/nqrduck_autotm/widget.py @@ -22,52 +22,54 @@ class Ui_Form(object): self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.verticalLayout_2 = QtWidgets.QVBoxLayout() self.verticalLayout_2.setObjectName("verticalLayout_2") - self.label_2 = QtWidgets.QLabel(parent=Form) + self.titleconnectionLabel = QtWidgets.QLabel(parent=Form) font = QtGui.QFont() font.setBold(True) font.setWeight(75) - self.label_2.setFont(font) - self.label_2.setObjectName("label_2") - self.verticalLayout_2.addWidget(self.label_2) + self.titleconnectionLabel.setFont(font) + self.titleconnectionLabel.setObjectName("titleconnectionLabel") + self.verticalLayout_2.addWidget(self.titleconnectionLabel) self.gridLayout_2 = QtWidgets.QGridLayout() self.gridLayout_2.setObjectName("gridLayout_2") self.portBox = QtWidgets.QComboBox(parent=Form) self.portBox.setObjectName("portBox") self.gridLayout_2.addWidget(self.portBox, 0, 1, 1, 1) + self.refreshButton = QtWidgets.QPushButton(parent=Form) + self.refreshButton.setObjectName("refreshButton") + self.gridLayout_2.addWidget(self.refreshButton, 0, 2, 1, 1) self.label = QtWidgets.QLabel(parent=Form) self.label.setObjectName("label") self.gridLayout_2.addWidget(self.label, 0, 0, 1, 1) - self.connectButton = QtWidgets.QPushButton(parent=Form) - self.connectButton.setObjectName("connectButton") - self.gridLayout_2.addWidget(self.connectButton, 1, 1, 1, 1) - self.refreshButton = QtWidgets.QPushButton(parent=Form) - self.refreshButton.setObjectName("refreshButton") - self.gridLayout_2.addWidget(self.refreshButton, 1, 0, 1, 1) - self.label_10 = QtWidgets.QLabel(parent=Form) - self.label_10.setObjectName("label_10") - self.gridLayout_2.addWidget(self.label_10, 2, 0, 1, 1) self.connectionLabel = QtWidgets.QLabel(parent=Form) self.connectionLabel.setText("") self.connectionLabel.setObjectName("connectionLabel") - self.gridLayout_2.addWidget(self.connectionLabel, 2, 1, 1, 1) + self.gridLayout_2.addWidget(self.connectionLabel, 1, 1, 1, 1) + self.label_10 = QtWidgets.QLabel(parent=Form) + self.label_10.setObjectName("label_10") + self.gridLayout_2.addWidget(self.label_10, 1, 0, 1, 1) self.verticalLayout_2.addLayout(self.gridLayout_2) - self.label_3 = QtWidgets.QLabel(parent=Form) + self.connectButton = QtWidgets.QPushButton(parent=Form) + self.connectButton.setObjectName("connectButton") + self.verticalLayout_2.addWidget(self.connectButton) + self.titletypeLabel = QtWidgets.QLabel(parent=Form) font = QtGui.QFont() font.setBold(True) font.setWeight(75) - self.label_3.setFont(font) - self.label_3.setObjectName("label_3") - self.verticalLayout_2.addWidget(self.label_3) + self.titletypeLabel.setFont(font) + self.titletypeLabel.setObjectName("titletypeLabel") + self.verticalLayout_2.addWidget(self.titletypeLabel) self.comboBox = QtWidgets.QComboBox(parent=Form) self.comboBox.setObjectName("comboBox") + self.comboBox.addItem("") + self.comboBox.addItem("") self.verticalLayout_2.addWidget(self.comboBox) - self.label_4 = QtWidgets.QLabel(parent=Form) + self.titlefrequencyLabel = QtWidgets.QLabel(parent=Form) font = QtGui.QFont() font.setBold(True) font.setWeight(75) - self.label_4.setFont(font) - self.label_4.setObjectName("label_4") - self.verticalLayout_2.addWidget(self.label_4) + self.titlefrequencyLabel.setFont(font) + self.titlefrequencyLabel.setObjectName("titlefrequencyLabel") + self.verticalLayout_2.addWidget(self.titlefrequencyLabel) self.gridLayout = QtWidgets.QGridLayout() self.gridLayout.setObjectName("gridLayout") self.startEdit = QtWidgets.QLineEdit(parent=Form) @@ -88,39 +90,39 @@ class Ui_Form(object): self.label_5 = QtWidgets.QLabel(parent=Form) self.label_5.setObjectName("label_5") self.gridLayout.addWidget(self.label_5, 0, 0, 1, 1) + self.verticalLayout_2.addLayout(self.gridLayout) self.pushButton_2 = QtWidgets.QPushButton(parent=Form) self.pushButton_2.setObjectName("pushButton_2") - self.gridLayout.addWidget(self.pushButton_2, 2, 1, 1, 1) - self.verticalLayout_2.addLayout(self.gridLayout) + self.verticalLayout_2.addWidget(self.pushButton_2) self.pushButton_3 = QtWidgets.QPushButton(parent=Form) self.pushButton_3.setObjectName("pushButton_3") self.verticalLayout_2.addWidget(self.pushButton_3) - self.label_9 = QtWidgets.QLabel(parent=Form) + self.titleinfoLabel = QtWidgets.QLabel(parent=Form) font = QtGui.QFont() font.setBold(True) font.setWeight(75) - self.label_9.setFont(font) - self.label_9.setObjectName("label_9") - self.verticalLayout_2.addWidget(self.label_9) + self.titleinfoLabel.setFont(font) + self.titleinfoLabel.setObjectName("titleinfoLabel") + self.verticalLayout_2.addWidget(self.titleinfoLabel) self.scrollArea = QtWidgets.QScrollArea(parent=Form) self.scrollArea.setWidgetResizable(True) self.scrollArea.setObjectName("scrollArea") self.scrollAreaWidgetContents = QtWidgets.QWidget() - self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 273, 231)) + self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 273, 229)) self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") self.scrollArea.setWidget(self.scrollAreaWidgetContents) self.verticalLayout_2.addWidget(self.scrollArea) self.horizontalLayout_2.addLayout(self.verticalLayout_2) self.verticalLayout_5 = QtWidgets.QVBoxLayout() self.verticalLayout_5.setObjectName("verticalLayout_5") - self.S11 = MplWidget(parent=Form) + self.S11Plot = MplWidget(parent=Form) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.S11.sizePolicy().hasHeightForWidth()) - self.S11.setSizePolicy(sizePolicy) - self.S11.setObjectName("S11") - self.verticalLayout_5.addWidget(self.S11) + sizePolicy.setHeightForWidth(self.S11Plot.sizePolicy().hasHeightForWidth()) + self.S11Plot.setSizePolicy(sizePolicy) + self.S11Plot.setObjectName("S11Plot") + self.verticalLayout_5.addWidget(self.S11Plot) self.horizontalLayout_2.addLayout(self.verticalLayout_5) self.horizontalLayout_2.setStretch(1, 1) @@ -130,18 +132,20 @@ class Ui_Form(object): def retranslateUi(self, Form): _translate = QtCore.QCoreApplication.translate Form.setWindowTitle(_translate("Form", "Form")) - self.label_2.setText(_translate("Form", "Connection Settings:")) - self.label.setText(_translate("Form", "Port:")) - self.connectButton.setText(_translate("Form", "Connect")) + self.titleconnectionLabel.setText(_translate("Form", "Connection Settings:")) self.refreshButton.setText(_translate("Form", "Refresh")) + self.label.setText(_translate("Form", "Port:")) self.label_10.setText(_translate("Form", "Connected to:")) - self.label_3.setText(_translate("Form", "T&M Type:")) - self.label_4.setText(_translate("Form", "Frequency Sweep:")) + self.connectButton.setText(_translate("Form", "Connect")) + self.titletypeLabel.setText(_translate("Form", "T&M Type:")) + self.comboBox.setItemText(0, _translate("Form", "Mechanical")) + self.comboBox.setItemText(1, _translate("Form", "Electrical")) + self.titlefrequencyLabel.setText(_translate("Form", "Frequency Sweep:")) self.label_8.setText(_translate("Form", "MHz")) self.label_6.setText(_translate("Form", "MHz")) self.label_7.setText(_translate("Form", "Stop Frequency:")) self.label_5.setText(_translate("Form", "Start Frequency:")) self.pushButton_2.setText(_translate("Form", "Start Sweep")) self.pushButton_3.setText(_translate("Form", "T&M Settings")) - self.label_9.setText(_translate("Form", "Info Box:")) + self.titleinfoLabel.setText(_translate("Form", "Info Box:")) from nqrduck.contrib.mplwidget import MplWidget