summaryrefslogtreecommitdiff
path: root/src/ui_table.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui_table.py')
-rw-r--r--src/ui_table.py45
1 files changed, 23 insertions, 22 deletions
diff --git a/src/ui_table.py b/src/ui_table.py
index 3d9a6fa..08b99f3 100644
--- a/src/ui_table.py
+++ b/src/ui_table.py
@@ -12,8 +12,8 @@ class ElementEditorWindow(QMainWindow):
windows = list()
@staticmethod
- def open(pol):
- win = ElementEditorWindow(pol)
+ def open(system, pol):
+ win = ElementEditorWindow(system, pol)
win.show()
ElementEditorWindow.windows.append(win)
@@ -24,8 +24,9 @@ class ElementEditorWindow(QMainWindow):
win.close()
del(win)
- def __init__(self, pol):
+ def __init__(self, system, pol):
super().__init__(flags=Qt.Dialog)
+ self.system = system
self.pol = pol
self.setWindowTitle("Element editor")
@@ -73,7 +74,7 @@ class ElementEditorWindow(QMainWindow):
# Angle reference
self.ref = QComboBox()
self.populate_ref()
- self.ref.currentIndexChanged.connect(update)
+ self.ref.currentIndexChanged.connect(GUI.do_update)
root.addWidget(self.ref)
# Delta angle
@@ -94,12 +95,12 @@ class ElementEditorWindow(QMainWindow):
def change_type(self):
self.pol.set_type(self.type.currentData())
- update()
+ GUI.do_update()
def change_delta(self):
try:
self.pol.delta = self.delta.angle / 180 * np.pi
- update()
+ GUI.do_update()
except ValueError:
pass
@@ -107,19 +108,16 @@ class ElementEditorWindow(QMainWindow):
try:
self.pol.t1 = float(self.t1.text())
self.pol.t2 = float(self.t2.text())
- update()
+ GUI.do_update()
except ValueError:
pass
def populate_ref(self):
self.ref.addItem("Absolute", False)
- for i, _ in enumerate(system.elements):
- if i >= self.pol.rownum - 1:
- continue
- self.ref.addItem("Relative to #%d" % (i + 1), i)
+ for i, pol in enumerate(self.system.elements):
+ self.ref.addItem("Relative to %s" % pol.name)
- if self.pol.ref is not False and i == self.pol.ref:
- self.ref.setCurrentIndex(self.pol.ref + 1)
+ self.ref.setCurrentIndex(self.pol.ref)
@@ -143,13 +141,13 @@ class OptBox(QVBoxLayout):
# Angle
self.angle = AngleSlider()
self.angle.setValue(pol.angle * 180 / np.pi)
- self.angle.on_change = lambda: TableRow.angle_change(row)
+ self.angle.on_change = row.angle_change
self.addLayout(self.angle)
self.addItem(ExpandingSpacer())
def open_menu(self, pos):
menu = QMenu()
- menu.addAction("Edit", lambda: ElementEditorWindow.open(self.row.pol))
+ menu.addAction("Edit", lambda: ElementEditorWindow.open(self.row.parent.system, self.row.pol))
menu.addAction("Insert before", lambda: half_assed_element_creation(self.rownum - 1))
menu.addAction("Insert after", lambda: half_assed_element_creation(self.rownum))
menu.addAction("Delete", lambda: half_assed_element_deletion(self.rownum - 1))
@@ -188,11 +186,10 @@ class SystemTableRow:
self.info.addItem(ExpandingSpacer())
parent.setCellWidget(row_number, 2, LayoutWrapper(self.info))
- @staticmethod
- def angle_change(row):
- row.angle = row.optbox.angle.angle / 180 * np.pi
- row.pol.angle = row.angle
- update()
+ def angle_change(self):
+ self.angle = self.optbox.angle.angle / 180 * np.pi
+ self.pol.angle = self.angle
+ GUI.do_update()
@@ -204,8 +201,12 @@ class SystemTable(QTableWidget):
self.setColumnCount(3) # this won't change
self.hh = self.horizontalHeader()
- self.hh.setSectionResizeMode(QHeaderView.ResizeToContents)
- #self.hh.hide()
+ self.hh.setSectionResizeMode(0, QHeaderView.ResizeToContents)
+ self.hh.resizeSection(1, 170)
+ self.hh.setStretchLastSection(True)
+ self.setHorizontalHeaderLabels([
+ "Settings", "Ellipse", "State"
+ ])
self.vh = self.verticalHeader()
self.vh.setSectionResizeMode(QHeaderView.ResizeToContents)