Skip to content

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 ​

python
BlockKey(component: str, label: str)

source

A block of a component, as the viewport and the model tree name it.

SkeletonKey dataclass ​

python
SkeletonKey(component: str, block: str, edge: str)

source

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 ​

python
Session(project: Project | None = None, directory: Path | None = None)

source

One project, its saved location and the GUI's change listeners.

Session.subscribe method ​

python
subscribe(listener: Listener) -> None

source

Call listener after every change of the project.

Session.run method ​

python
run(
    method: str,
    *args: Any,
    progress: ProgressFn | None = None,
    cancel: CancelToken | None = None,
    **kwargs: Any,
) -> None

source

Call 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 ​

python
run_cli(command: Sequence[str]) -> str

source

Run 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 ​

python
run_journal(path: str | Path) -> None

source

Replace the project with the one a journal builds (shore run).

Session.view_file method ​

python
view_file(path: str | Path) -> None

source

Show 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 ​

python
undo() -> None

source

Session.redo method ​

python
redo() -> None

source

Session.open method ​

python
open(directory: str | Path, *, replay: bool = True) -> None

source

Replace the project with a saved one (ADR 0016; ADR 0033 without replay).

Session.new method ​

python
new() -> None

source

Session.save method ​

python
save(directory: str | Path | None = None) -> Path

source

Session.journal_lines method ​

python
journal_lines() -> list[str]

source

The journal's command lines (without the header).

Session.blocks method ​

python
blocks() -> list[tuple[BlockKey, HexBlock]]

source

Every block of every component with a mesh, components in project order.

Session.skeleton method ​

python
skeleton() -> list[tuple[SkeletonKey, Any]]

source

Every blocking edge of every component, with its nodes on the straight line between its skeleton vertices (Blocking.polylines).

Session.skeleton_markers method ​

python
skeleton_markers(kind: str) -> list[tuple[SkeletonKey, Any]]

source

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 ​

python
tree() -> list[tuple[str, bool, list[tuple[str, tuple[int, int, int], dict[str, str]]]]]

source

(component, is current, [(block label, shape, {face: BC name})]).

Session.associations method ​

python
associations(key: BlockKey) -> dict[str, str]

source

{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 ​

python
association_label(association: Any) -> str

source

"geometry" for a body, else "geometry: kind i, j" (indices re-found from the association's fingerprints in the current geometry).

Session.block method ​

python
block(key: BlockKey) -> HexBlock | None

source

surface_display function ​

python
surface_display(nodes: Any) -> Any

source

A structured surface (ni, nj, 3) as a geometry.base.Display: two triangles per quad, one body entity.

Released under the MIT License.