add graph title

This commit is contained in:
Dominik Demuth 2023-02-21 18:55:41 +01:00
parent 3bb99f4406
commit a17a4e0c01
6 changed files with 54 additions and 33 deletions

View File

@ -14,7 +14,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_GraphWindow(object): class Ui_GraphWindow(object):
def setupUi(self, GraphWindow): def setupUi(self, GraphWindow):
GraphWindow.setObjectName("GraphWindow") GraphWindow.setObjectName("GraphWindow")
GraphWindow.resize(680, 520) GraphWindow.resize(865, 520)
GraphWindow.setBaseSize(QtCore.QSize(300, 10)) GraphWindow.setBaseSize(QtCore.QSize(300, 10))
self.verticalLayout = QtWidgets.QVBoxLayout(GraphWindow) self.verticalLayout = QtWidgets.QVBoxLayout(GraphWindow)
self.verticalLayout.setContentsMargins(3, 3, 3, 3) self.verticalLayout.setContentsMargins(3, 3, 3, 3)
@ -96,6 +96,12 @@ class Ui_GraphWindow(object):
self.horizontalLayout.addWidget(self.line_3) self.horizontalLayout.addWidget(self.line_3)
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem) self.horizontalLayout.addItem(spacerItem)
self.graph_label = QtWidgets.QLabel(self.widget)
self.graph_label.setText("")
self.graph_label.setObjectName("graph_label")
self.horizontalLayout.addWidget(self.graph_label)
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem1)
self.limit_button = QtWidgets.QToolButton(self.widget) self.limit_button = QtWidgets.QToolButton(self.widget)
self.limit_button.setCheckable(True) self.limit_button.setCheckable(True)
self.limit_button.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) self.limit_button.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
@ -139,8 +145,8 @@ class Ui_GraphWindow(object):
self.xmax_lineedit = QtWidgets.QLineEdit(self.limit_widget) self.xmax_lineedit = QtWidgets.QLineEdit(self.limit_widget)
self.xmax_lineedit.setObjectName("xmax_lineedit") self.xmax_lineedit.setObjectName("xmax_lineedit")
self.horizontalLayout_2.addWidget(self.xmax_lineedit) self.horizontalLayout_2.addWidget(self.xmax_lineedit)
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_2.addItem(spacerItem1) self.horizontalLayout_2.addItem(spacerItem2)
self.label_3 = QtWidgets.QLabel(self.limit_widget) self.label_3 = QtWidgets.QLabel(self.limit_widget)
self.label_3.setObjectName("label_3") self.label_3.setObjectName("label_3")
self.horizontalLayout_2.addWidget(self.label_3) self.horizontalLayout_2.addWidget(self.label_3)
@ -176,16 +182,16 @@ class Ui_GraphWindow(object):
self.title_lineedit = QtWidgets.QLineEdit(self.label_widget) self.title_lineedit = QtWidgets.QLineEdit(self.label_widget)
self.title_lineedit.setObjectName("title_lineedit") self.title_lineedit.setObjectName("title_lineedit")
self.horizontalLayout_3.addWidget(self.title_lineedit) self.horizontalLayout_3.addWidget(self.title_lineedit)
spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_3.addItem(spacerItem2) self.horizontalLayout_3.addItem(spacerItem3)
self.label_6 = QtWidgets.QLabel(self.label_widget) self.label_6 = QtWidgets.QLabel(self.label_widget)
self.label_6.setObjectName("label_6") self.label_6.setObjectName("label_6")
self.horizontalLayout_3.addWidget(self.label_6) self.horizontalLayout_3.addWidget(self.label_6)
self.xaxis_linedit = QtWidgets.QLineEdit(self.label_widget) self.xaxis_linedit = QtWidgets.QLineEdit(self.label_widget)
self.xaxis_linedit.setObjectName("xaxis_linedit") self.xaxis_linedit.setObjectName("xaxis_linedit")
self.horizontalLayout_3.addWidget(self.xaxis_linedit) self.horizontalLayout_3.addWidget(self.xaxis_linedit)
spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) spacerItem4 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_3.addItem(spacerItem3) self.horizontalLayout_3.addItem(spacerItem4)
self.label_7 = QtWidgets.QLabel(self.label_widget) self.label_7 = QtWidgets.QLabel(self.label_widget)
self.label_7.setObjectName("label_7") self.label_7.setObjectName("label_7")
self.horizontalLayout_3.addWidget(self.label_7) self.horizontalLayout_3.addWidget(self.label_7)

View File

@ -18,13 +18,12 @@ class Ui_Form(object):
self.verticalLayout_2 = QtWidgets.QVBoxLayout(Form) self.verticalLayout_2 = QtWidgets.QVBoxLayout(Form)
self.verticalLayout_2.setContentsMargins(3, 3, 3, 3) self.verticalLayout_2.setContentsMargins(3, 3, 3, 3)
self.verticalLayout_2.setObjectName("verticalLayout_2") self.verticalLayout_2.setObjectName("verticalLayout_2")
self.treeWidget = QtWidgets.QTreeWidget(Form) self.comboBox = QtWidgets.QComboBox(Form)
self.treeWidget.setRootIsDecorated(True) self.comboBox.setObjectName("comboBox")
self.treeWidget.setObjectName("treeWidget") self.verticalLayout_2.addWidget(self.comboBox)
self.treeWidget.headerItem().setText(0, "1") self.listWidget = QtWidgets.QListWidget(Form)
self.treeWidget.header().setVisible(False) self.listWidget.setObjectName("listWidget")
self.treeWidget.header().setHighlightSections(True) self.verticalLayout_2.addWidget(self.listWidget)
self.verticalLayout_2.addWidget(self.treeWidget)
self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout") self.horizontalLayout.setObjectName("horizontalLayout")
self.newButton = QtWidgets.QPushButton(Form) self.newButton = QtWidgets.QPushButton(Form)

View File

@ -341,6 +341,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
for w in self.area.subWindowList(): for w in self.area.subWindowList():
wdgt = w.widget() wdgt = w.widget()
if wdgt.id == gid: if wdgt.id == gid:
w.disconnect()
wdgt.disconnect() wdgt.disconnect()
wdgt.scene.disconnect() wdgt.scene.disconnect()
if wdgt == self.current_graph_widget: if wdgt == self.current_graph_widget:
@ -397,6 +398,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
subwindow.setMinimumHeight(400) subwindow.setMinimumHeight(400)
subwindow.setMinimumWidth(600) subwindow.setMinimumWidth(600)
self.datawidget.blockSignals(True) self.datawidget.blockSignals(True)
self.datawidget.tree.blockSignals(True) self.datawidget.tree.blockSignals(True)
self.datawidget.add_graph(w.id, w.title) self.datawidget.add_graph(w.id, w.title)
@ -413,11 +415,12 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
self.ptsselectwidget.set_graphs(graph_list) self.ptsselectwidget.set_graphs(graph_list)
@QtCore.pyqtSlot(QtWidgets.QMdiSubWindow, name='on_area_subWindowActivated') @QtCore.pyqtSlot(QtWidgets.QMdiSubWindow, name='on_area_subWindowActivated')
def change_window(self, wd): def change_window(self, wd: QtWidgets.QMdiSubWindow | None):
""" Called every time focus moves from or to a subwindow. Returns None if current focus is not on a subwindow""" """ Called every time focus moves from or to a subwindow. Returns None if current focus is not on a subwindow"""
if wd is not None: if wd is not None:
if self.current_graph_widget is not None: if self.current_graph_widget is not None:
self.current_graph_widget.closable = True self.current_graph_widget.closable = True
self.current_graph_widget.graph_label.setText('')
if self.ptsselectwidget.isVisible(): if self.ptsselectwidget.isVisible():
self._select_ptswidget(False, False, False) self._select_ptswidget(False, False, False)
@ -431,6 +434,11 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
self.change_mouse_mode(self.actionMouse_behaviour.isChecked()) self.change_mouse_mode(self.actionMouse_behaviour.isChecked())
if wd.isMaximized():
self.current_graph_widget.graph_label.setText(self.current_graph_widget.title)
else:
self.current_graph_widget.graph_label.setText('')
pick = False pick = False
block = False block = False
if self.ptsselectwidget.isVisible(): if self.ptsselectwidget.isVisible():

View File

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>680</width> <width>865</width>
<height>520</height> <height>520</height>
</rect> </rect>
</property> </property>
@ -250,6 +250,26 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="graph_label">
<property name="text">
<string/>
</property>
</widget>
</item>
<item> <item>
<spacer name="horizontalSpacer"> <spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">

View File

@ -27,22 +27,10 @@
<number>3</number> <number>3</number>
</property> </property>
<item> <item>
<widget class="QTreeWidget" name="treeWidget"> <widget class="QComboBox" name="comboBox"/>
<property name="rootIsDecorated"> </item>
<bool>true</bool> <item>
</property> <widget class="QListWidget" name="listWidget"/>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<attribute name="headerHighlightSections">
<bool>true</bool>
</attribute>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">