Ilya af66debcde feat(view): graphics scene, node/port/edge items, undoable controller
Add the QGraphicsView layer: NodeItem (SVG symbol + title + draggable,
snap-to-grid), PortItem (relation-colored anchors with compatibility
hints), EdgeItem (orthogonal routing, arc hops on crossings, line styles,
head/tail decorations, animated flow dashes), and DiagramScene binding the
document to items with edge-drawing interaction and a grid background.
Add EditorController with a QUndoStack (add/connect/delete/move/edit) and
scene interaction tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-02 23:20:09 +02:00

30 lines
761 B
Python

"""Cached access to bundled SVG node symbols."""
from __future__ import annotations
import os
from PyQt6.QtSvg import QSvgRenderer
_NODES_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), "resources", "nodes")
_cache: dict[str, QSvgRenderer] = {}
def nodes_dir() -> str:
return _NODES_DIR
def renderer(svg_name: str) -> QSvgRenderer | None:
"""Return a cached, valid QSvgRenderer for ``svg_name`` or None."""
if not svg_name:
return None
r = _cache.get(svg_name)
if r is None:
path = os.path.join(_NODES_DIR, svg_name)
if not os.path.exists(path):
return None
r = QSvgRenderer(path)
if not r.isValid():
return None
_cache[svg_name] = r
return r