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):
def setupUi(self, GraphWindow):
GraphWindow.setObjectName("GraphWindow")
GraphWindow.resize(680, 520)
GraphWindow.resize(865, 520)
GraphWindow.setBaseSize(QtCore.QSize(300, 10))
self.verticalLayout = QtWidgets.QVBoxLayout(GraphWindow)
self.verticalLayout.setContentsMargins(3, 3, 3, 3)
@ -96,6 +96,12 @@ class Ui_GraphWindow(object):
self.horizontalLayout.addWidget(self.line_3)
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
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.setCheckable(True)
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.setObjectName("xmax_lineedit")
self.horizontalLayout_2.addWidget(self.xmax_lineedit)
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_2.addItem(spacerItem1)
spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_2.addItem(spacerItem2)
self.label_3 = QtWidgets.QLabel(self.limit_widget)
self.label_3.setObjectName("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.setObjectName("title_lineedit")
self.horizontalLayout_3.addWidget(self.title_lineedit)
spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_3.addItem(spacerItem2)
spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_3.addItem(spacerItem3)
self.label_6 = QtWidgets.QLabel(self.label_widget)
self.label_6.setObjectName("label_6")
self.horizontalLayout_3.addWidget(self.label_6)
self.xaxis_linedit = QtWidgets.QLineEdit(self.label_widget)
self.xaxis_linedit.setObjectName("xaxis_linedit")
self.horizontalLayout_3.addWidget(self.xaxis_linedit)
spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_3.addItem(spacerItem3)
spacerItem4 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_3.addItem(spacerItem4)
self.label_7 = QtWidgets.QLabel(self.label_widget)
self.label_7.setObjectName("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.setContentsMargins(3, 3, 3, 3)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.treeWidget = QtWidgets.QTreeWidget(Form)
self.treeWidget.setRootIsDecorated(True)
self.treeWidget.setObjectName("treeWidget")
self.treeWidget.headerItem().setText(0, "1")
self.treeWidget.header().setVisible(False)
self.treeWidget.header().setHighlightSections(True)
self.verticalLayout_2.addWidget(self.treeWidget)
self.comboBox = QtWidgets.QComboBox(Form)
self.comboBox.setObjectName("comboBox")
self.verticalLayout_2.addWidget(self.comboBox)
self.listWidget = QtWidgets.QListWidget(Form)
self.listWidget.setObjectName("listWidget")
self.verticalLayout_2.addWidget(self.listWidget)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.newButton = QtWidgets.QPushButton(Form)

View File

@ -219,4 +219,4 @@ class Ellipse(GraphicsObject):
self.log_mode = [x_mode, y_mode]
self.informViewBoundsChanged()
self.informViewBoundsChanged()

View File

@ -341,6 +341,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
for w in self.area.subWindowList():
wdgt = w.widget()
if wdgt.id == gid:
w.disconnect()
wdgt.disconnect()
wdgt.scene.disconnect()
if wdgt == self.current_graph_widget:
@ -397,6 +398,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
subwindow.setMinimumHeight(400)
subwindow.setMinimumWidth(600)
self.datawidget.blockSignals(True)
self.datawidget.tree.blockSignals(True)
self.datawidget.add_graph(w.id, w.title)
@ -413,11 +415,12 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
self.ptsselectwidget.set_graphs(graph_list)
@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"""
if wd is not None:
if self.current_graph_widget is not None:
self.current_graph_widget.closable = True
self.current_graph_widget.graph_label.setText('')
if self.ptsselectwidget.isVisible():
self._select_ptswidget(False, False, False)
@ -431,6 +434,11 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
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
block = False
if self.ptsselectwidget.isVisible():

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>680</width>
<width>865</width>
<height>520</height>
</rect>
</property>
@ -250,6 +250,26 @@
</property>
</widget>
</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>
<spacer name="horizontalSpacer">
<property name="orientation">

View File

@ -27,22 +27,10 @@
<number>3</number>
</property>
<item>
<widget class="QTreeWidget" name="treeWidget">
<property name="rootIsDecorated">
<bool>true</bool>
</property>
<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>
<widget class="QComboBox" name="comboBox"/>
</item>
<item>
<widget class="QListWidget" name="listWidget"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">