summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/file.py6
-rw-r--r--src/phys.py7
-rw-r--r--src/ui.py28
-rw-r--r--src/ui_widgets.py2
4 files changed, 35 insertions, 8 deletions
diff --git a/src/file.py b/src/file.py
index 417c77b..3c69063 100644
--- a/src/file.py
+++ b/src/file.py
@@ -1,13 +1,13 @@
import re, sys, traceback, json
import phys
-file_format_version = 4
+file_format_version = 5
def save_system(path, system):
ser = dict()
+ ser["input_intensity"] = system.input_intensity
ser["version"] = file_format_version
- ser["ignore"] = system.ignore
ser["elements"] = []
for pol in system.elements:
el = {
@@ -36,7 +36,7 @@ def open_system(path):
raise ValueError("Bad file version: expected %d, found %d" \
% (file_format_version, ser["version"]))
- system.ignore = ser["ignore"]
+ system.input_intensity = float(ser["input_intensity"])
for el in ser["elements"]:
pol = phys.Polarizer(str(el["type"]))
diff --git a/src/phys.py b/src/phys.py
index cf30667..4e78fe2 100644
--- a/src/phys.py
+++ b/src/phys.py
@@ -94,6 +94,7 @@ class Polarizer:
class System:
def __init__(self):
self.elements = list()
+ self.input_intensity = 1
def recalculate(system):
system.states = [None] * len(system.elements)
@@ -102,6 +103,10 @@ class System:
state = None
for i, pol in enumerate(system.elements):
if pol.enable:
- state = pol.mul(state)
+ new_state = pol.mul(state)
+ if state is None and new_state is not None:
+ state = new_state * np.sqrt(system.input_intensity)
+ else:
+ state = new_state
system.states[i] = state
system.ellipses.append(Ellipse(state))
diff --git a/src/ui.py b/src/ui.py
index 33da1ea..ccdff63 100644
--- a/src/ui.py
+++ b/src/ui.py
@@ -236,6 +236,8 @@ class TableRow:
def populate_table():
+ GUI.input_intensity.setText("%g" % system.input_intensity)
+
GUI.table = QGridLayout()
GUI.table.setColumnStretch(1, 1)
GUI.table.setColumnStretch(2, 2)
@@ -444,17 +446,37 @@ def optimize(which):
GUI.table_rows[op_idx].optbox.angle.edit.setText("%g" % round(opt.x * 180 / np.pi, 3))
+
+def change_input_intensity():
+ try:
+ system.input_intensity = float(GUI.input_intensity.text())
+ update()
+ except ValueError:
+ pass
+
def setup(win, system_):
global system
system = system_
# Needless to say, I'm getting real tired of this whole Layout/Widget
# clusterfuck in Qt
- root = QHBoxLayout()
+ root = QVBoxLayout()
root_fucking_random_container = QWidget()
root_fucking_random_container.setLayout(root)
win.setCentralWidget(root_fucking_random_container)
+ # Top bar (input intensity)
+ box = QHBoxLayout()
+ root.addLayout(box)
+
+ box.addWidget(QLabel("Input intensity"))
+ GUI.input_intensity = QLineEdit("1")
+ GUI.input_intensity.textChanged.connect(change_input_intensity)
+ box.addWidget(GUI.input_intensity)
+
+ hbox = QHBoxLayout()
+ root.addLayout(hbox)
+
rhs = QVBoxLayout()
Widocques.image = QImage("jones.jpg")
@@ -479,8 +501,8 @@ def setup(win, system_):
GUI.table_frame.setLayout(GUI.table)
GUI.scroll.setWidget(GUI.table_frame)
- root.addWidget(GUI.scroll)
- root.addLayout(rhs)
+ hbox.addWidget(GUI.scroll)
+ hbox.addLayout(rhs)
setup_menubar(win)
diff --git a/src/ui_widgets.py b/src/ui_widgets.py
index 36ff333..9eabd2e 100644
--- a/src/ui_widgets.py
+++ b/src/ui_widgets.py
@@ -33,7 +33,7 @@ class EllipseWidget(QWidget):
QSizePolicy.MinimumExpanding))
def minimumSizeHint(self):
- return QSize(100, 100)
+ return QSize(170, 170)
def paintEvent(self, event):
P = QPainter(self)