summaryrefslogtreecommitdiff
path: root/src/ui.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui.py')
-rw-r--r--src/ui.py51
1 files changed, 32 insertions, 19 deletions
diff --git a/src/ui.py b/src/ui.py
index 4f6b189..6fced54 100644
--- a/src/ui.py
+++ b/src/ui.py
@@ -39,14 +39,15 @@ class Pens:
from ui_widgets import *
-
-
class OptBox(QVBoxLayout):
def __init__(self, row, pol, rownum):
super().__init__()
+ self.rownum = rownum
# Name
self.name = MeinGroßLabel("Element %d" % rownum)
+ self.name.setContextMenuPolicy(Qt.CustomContextMenu)
+ self.name.customContextMenuRequested.connect(lambda pos: OptBox.open_menu(self, pos))
self.addWidget(self.name)
# Type / Enable box
@@ -92,6 +93,18 @@ class OptBox(QVBoxLayout):
box.addWidget(self.delta)
box.addWidget(QLabel("°"))
+ # Transmittance layout
+ box = QHBoxLayout()
+ self.addLayout(box)
+
+ box.addWidget(QLabel("T"))
+ self.t1 = QLineEdit("1")
+ self.t1.textChanged.connect(lambda: TableRow.t_change(row))
+ box.addWidget(self.t1)
+ self.t2 = QLineEdit("0")
+ self.t2.textChanged.connect(lambda: TableRow.t_change(row))
+ box.addWidget(self.t2)
+
# Angle
self.angle = AngleSlider("Angle")
self.angle.setValue(pol.angle * 180 / np.pi)
@@ -99,20 +112,12 @@ class OptBox(QVBoxLayout):
self.addLayout(self.angle)
self.addItem(ExpandingSpacer())
- # Add
- self.add_above = QPushButton("Add above")
- self.add_above.clicked.connect(lambda: half_assed_element_creation(rownum - 1))
- self.add_below = QPushButton("Add below")
- self.add_below.clicked.connect(lambda: half_assed_element_creation(rownum))
- self.delete = QPushButton("Delete")
- self.delete.clicked.connect(lambda: half_assed_element_deletion(rownum - 1))
-
- box = QHBoxLayout()
- box.addWidget(self.add_above)
- box.addWidget(self.add_below)
- box.addWidget(self.delete)
- self.addLayout(box)
-
+ def open_menu(self, pos):
+ menu = QMenu()
+ 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))
+ menu.exec_(self.name.mapToGlobal(pos))
class TableRow:
@@ -156,6 +161,15 @@ class TableRow:
row.pol.set_type(row.optbox.type.currentData())
update()
+ @staticmethod
+ def t_change(row):
+ try:
+ row.pol.t1 = float(row.optbox.t1.text())
+ row.pol.t2 = float(row.optbox.t2.text())
+ except ValueError:
+ pass
+ update()
+
def populate_table():
GUI.table = QGridLayout()
@@ -197,9 +211,8 @@ def update():
row.ellipse.is_used = not system.ignore[i]
row.ellipse.repaint()
- text = "%s (%f°)\nat %f°" \
- % (pol.type, pol.delta * 180 / np.pi,
- (pol.angle + pol.delta) * 180 / np.pi)
+ text = "%s at %f°" \
+ % (pol.type, (pol.angle + pol.delta) * 180 / np.pi)
row.info_angle.setText(text)
state = system.states[i]