From 50138a87b2a7cbc20d043b275f8e472d51fc28fb Mon Sep 17 00:00:00 2001 From: Sven Date: Fri, 26 Jun 2026 14:23:23 +0200 Subject: [PATCH] Needs a revisit to flatten the nested lines --- beamline_editor/nodes.py | 18 ++++++++++++++++++ beamline_editor/palette.py | 3 ++- elements.py | 2 ++ main.py | 2 ++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/beamline_editor/nodes.py b/beamline_editor/nodes.py index a5dcb6e..85dbfbe 100644 --- a/beamline_editor/nodes.py +++ b/beamline_editor/nodes.py @@ -46,6 +46,7 @@ _STYLES: dict[str, dict] = { "RF": {"top": "#AD1457", "bot": "#880E4F", "w": 64, "h": 44}, "Undulator": {"top": "#558B2F", "bot": "#33691E", "w": 88, "h": 36}, "Diagnostics": {"top": "#4527A0", "bot": "#311B92", "w": 64, "h": 44}, + "Vacuum": {"top": "#00838F", "bot": "#006064", "w": 64, "h": 36}, "Target": {"top": "#B71C1C", "bot": "#7B0000", "w": 36, "h": 36}, "Alignment": {"top": "#1565C0", "bot": "#0D3B8C", "w": 36, "h": 36}, "Branch": {"top": "#F9A825", "bot": "#C17900", "w": 40, "h": 40}, @@ -479,6 +480,22 @@ class BranchNode(BeamlineNode): p.drawLine(QPointF(cx + 2, cy), QPointF(cx + 9, cy + 7)) +class VacuumNode(BeamlineNode): + """Vacuum element — teal rect with a pump/vessel symbol.""" + def __init__(self, pos): super().__init__("Vacuum", pos) + def _draw_body(self, p): + p.setBrush(QBrush(self._gradient())) + p.setPen(QPen(QColor("#00838F"), 1.5)) + p.drawRoundedRect(QRectF(0, 0, self.W, self.H), 5, 5) + # simple pump symbol: circle with a vertical line + cx, cy = self.W / 2, self.H / 2 + r = min(cx, cy) - 6 + p.setBrush(Qt.NoBrush) + p.setPen(QPen(QColor("#80DEEA"), 1.5)) + p.drawEllipse(QPointF(cx, cy), r, r) + p.drawLine(QPointF(cx, cy - r - 4), QPointF(cx, cy + r + 4)) + + # ── Factory ─────────────────────────────────────────────────────────────────── _NODE_MAP: dict[str, type] = { @@ -490,6 +507,7 @@ _NODE_MAP: dict[str, type] = { "RF": RFNode, "Undulator": UndulatorNode, "Diagnostics": DiagnosticsNode, + "Vacuum": VacuumNode, "Reference": ReferenceNode, "Target": TargetNode, "Alignment": AlignmentNode, diff --git a/beamline_editor/palette.py b/beamline_editor/palette.py index 1902d05..15d595c 100644 --- a/beamline_editor/palette.py +++ b/beamline_editor/palette.py @@ -16,7 +16,8 @@ from .nodes import _STYLES ELEMENT_GROUPS: list[tuple[str, list[str]]] = [ ("Elements", ["Dipole", "Quadrupole", "Sextupole", - "Solenoid", "Corrector", "RF", "Undulator", "Diagnostics"]), + "Solenoid", "Corrector", "RF", "Undulator", "Diagnostics", + "Vacuum"]), ("Markers", ["Reference", "Start", "End", "Target", "Alignment", "Branch"]), ("Containers", ["Line", "Variable Line"]), ] diff --git a/elements.py b/elements.py index 7fffb78..e50eb24 100644 --- a/elements.py +++ b/elements.py @@ -200,6 +200,8 @@ class Vacuum(SimpleContainer): SimpleContainer.__init__(self, prop) if not ('Group' in prop): # prop.has_key('Group')): self.__dict__.update({'Group': 'Vacuum'}) + if not ('Group' in prop): # prop.has_key('Group')): + self.__dict__.update({'Tag': 'VLAP'}) self.__dict__.update({'angle': 0}) def writeElement(self, app): diff --git a/main.py b/main.py index 978a744..174c4c0 100644 --- a/main.py +++ b/main.py @@ -117,6 +117,8 @@ class BeamlineEditor(QtWidgets.QMainWindow, Ui_BeamlineGUI): ele = Undulator({}) case "Diagnostics": ele = Diagnostic({}) + case "Vacuum": + ele = Vacuum({}) case "Reference": ele = Marker({"Tag":"QREF"}) case "Start":