added stub simulation entry and logs

This commit is contained in:
2026-07-20 15:26:18 +02:00
parent 495edd42f4
commit 9ed8e371ef
20 changed files with 1047 additions and 123 deletions

View File

@@ -13,6 +13,7 @@ from bedit.gui.controllers.commands import (
DeleteSelectionCommand,
DeleteAnnotationsCommand,
EditGraphItemCommand,
EditSimulationSettingsCommand,
EditTextDefinitionCommand,
EditComponentAppearanceCommand,
EditComponentPropertiesCommand,
@@ -37,6 +38,7 @@ from bedit.core.model import (
Port,
clone_component,
)
from bedit.core.simulation import Simulation
from bedit.core.port_types import PortTypeRegistry
from bedit.core.serializer import JsonDocumentSerializer
@@ -60,8 +62,9 @@ class DocumentController(QObject):
filePathChanged = Signal(object)
modifiedChanged = Signal(bool)
def __init__(self, parent=None) -> None:
def __init__(self, parent=None, *, simulation: Simulation | None = None) -> None:
super().__init__(parent)
self.simulation = simulation or Simulation()
self.document: GraphDocument | None = None
self.active_component_id: str | None = None
self.file_path: Path | None = None
@@ -378,6 +381,23 @@ class DocumentController(QObject):
self.undo_stack.push(AddAnnotationCommand(self, self.active_component_id, annotation))
return annotation.id
def edit_simulation_settings(self, settings: dict) -> None:
component = self.active_component
if component is None or component.implementation_kind != "graph":
raise ValueError("Open a graph component before editing simulation settings")
old = deepcopy(component.graph.simulation_settings)
new = deepcopy(settings)
if old != new:
self.undo_stack.push(
EditSimulationSettingsCommand(self, component.id, old, new)
)
def compile_active_graph(self) -> None:
component = self.active_component
if component is None or component.implementation_kind != "graph":
raise ValueError("Open a graph component before compiling")
self.simulation.compile(component.to_dict())
def set_route_waypoints(self, item_kind: str, item_id: str, waypoints: list[QPointF]) -> None:
item = (
self.active_graph.connections
@@ -1032,6 +1052,12 @@ class DocumentController(QObject):
if owner_id == self.active_component_id:
self.graphItemChanged.emit(item_kind, item_id)
def _set_simulation_settings(self, owner_id: str, settings: dict) -> None:
owner = self.document.find_component(owner_id) if self.document else None
if owner is not None and owner.implementation_kind == "graph":
owner.graph.simulation_settings = deepcopy(settings)
self.documentReset.emit()
def _replace_component(self, old_id: str, replacement: Component) -> None:
if self.document is None:
return