shore.gui.session
The GUI's owner of a project (ADR 0037): every action is a Project command.
Session holds no Qt object, so the GUI logic is tested headless. Widgets call its methods only; each state change goes through Project (and so into its journal, ADR 0004), and listeners are told what changed.
Long commands (march, builds) are run by the window on a worker thread, with the ADR 0004 progress and cancel hooks; Session.run itself is synchronous.
BlockKey dataclass
BlockKey(component: str, label: str)A block of a component, as the viewport and the model tree name it.
SkeletonKey dataclass
SkeletonKey(component: str, block: str, edge: str)A blocking entity of a component (ADR 0042, 0044): edge is an edge or face name of blocking block block, or "" for the block itself.
Session class
Session(project: Project | None = None, directory: Path | None = None)One project, its saved location and the GUI's change listeners.
Session.subscribe method
subscribe(listener: Listener) -> NoneCall listener after every change of the project.
Session.run method
run(
method: str,
*args: Any,
progress: ProgressFn | None = None,
cancel: CancelToken | None = None,
**kwargs: Any,
) -> NoneCall Project.<method>: one command, one journal line.
The project is unchanged if the command raises (the command layer restores a failed or cancelled march, and a command that fails while building leaves no state behind).
Session.run_cli method
run_cli(command: Sequence[str]) -> strRun a CLI command (["mesh", "body.stl", "--nk", "6"]) on this project (ADR 0062) and return its output.
Its Project commands land in this project's history, each one undoable. A command that fails (exit code not 0) is rolled back: the project is as it was, and the error carries the command's output.
Session.run_journal method
run_journal(path: str | Path) -> NoneReplace the project with the one a journal builds (shore run).
Session.view_file method
view_file(path: str | Path) -> NoneShow a file as shore view does: a .geo file loads as the current component's blocks (load_blocks, one journal line); a .npz surface (key "k0") is shown only, outside the project.
Session.undo method
undo() -> NoneSession.redo method
redo() -> NoneSession.open method
open(directory: str | Path, *, replay: bool = True) -> NoneReplace the project with a saved one (ADR 0016; ADR 0033 without replay).
Session.new method
new() -> NoneSession.save method
save(directory: str | Path | None = None) -> PathSession.journal_lines method
journal_lines() -> list[str]The journal's command lines (without the header).
Session.blocks method
blocks() -> list[tuple[BlockKey, HexBlock]]Every block of every component with a mesh, components in project order.
Session.skeleton method
skeleton() -> list[tuple[SkeletonKey, Any]]Every blocking edge of every component, with its nodes on the straight line between its skeleton vertices (Blocking.polylines).
Session.skeleton_markers method
skeleton_markers(kind: str) -> list[tuple[SkeletonKey, Any]]A marker per blocking face (kind="face": SkeletonKey(component, block, face)`, the face named by its first block) or block (`"block": SkeletonKey(component, block, "")), at its skeleton centre.
Session.tree method
tree() -> list[tuple[str, bool, list[tuple[str, tuple[int, int, int], dict[str, str]]]]](component, is current, [(block label, shape, {face: BC name})]).
Session.associations method
associations(key: BlockKey) -> dict[str, str]{entity: label} for the associated faces, edges and vertices ("v0"..) of a block; labels like "body" or "part: surface 2, 5".
Session.association_label method
association_label(association: Any) -> str"geometry" for a body, else "geometry: kind i, j" (indices re-found from the association's fingerprints in the current geometry).
Session.block method
block(key: BlockKey) -> HexBlock | Nonesurface_display function
surface_display(nodes: Any) -> AnyA structured surface (ni, nj, 3) as a geometry.base.Display: two triangles per quad, one body entity.