Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ container size and content produced by laying out one definition's interior).
###### `BuildLayout(ViewContext context, RenderOptions options)`

Entry point. Resolves the view's `expose` scope via `ExposeScopeResolver.ResolveExposedScope`,
selects the root part definition via `FindRoot(workspace, scope)`, builds the container-definition
selects the root part definition(s) via `FindRoots(workspace, scope)`, builds the container-definition
index via `BuildDefinitionIndex`, lays out the root's interior via `LayOutInterior` (applying
`scope`'s namespace-prefix filter only at the root's own direct children, depth 0; every deeper
recursive call passes `scope: null`, since a nested container's own interior's membership in the
Expand All @@ -40,9 +40,13 @@ _Per-Branch Depth-Limited Recursion_ below; the true root call passes `ancestorU
null`, since no branch decision exists yet at that point), and assembles the root container box
with the interior content nested as that box's own `Children` (mirroring the nesting `MakePartBox`
already uses for a container part, so the root box is never a bare sibling of its own content) into
the `LayoutTree`. When `FindRoot` selects no root, falls back to the **no-single-root scoped
fallback** described below when the resolved scope directly includes one or more top-level `part`
feature usages; otherwise returns a minimal 200×100 empty `LayoutTree`.
the `LayoutTree`. When `FindRoots` returns several roots, `LayOutRootsSideBySide` builds each
root's container box with `BuildRootBox` and places them left to right in declaration order,
separated by `6 × LabelPadding`, with aligned tops (SysML v2.1 Beta 2 8.2.3.11:
`interconnection-view = (interconnection-element)*`). When `FindRoots` selects no root, falls
back to the **no-single-root scoped fallback** described below when the resolved scope directly
includes one or more top-level `part` feature usages; otherwise returns a minimal 200×100 empty
`LayoutTree`.

###### Per-Branch Depth-Limited Recursion (`DetermineBranchUnlimitedRecursion`, `MatchesUnlimitedSubject`)

Expand Down Expand Up @@ -113,10 +117,10 @@ and §9.2.20.2.6 ("exposed features as nodes, nested features as nested nodes"),
can be one or more concrete `part` feature usages directly, with no enclosing definition of its own
— e.g. `expose PublishingSubsystem::*;` where `PublishingSubsystem` is itself only a namespace-like
`part def` whose sole nested `part markdownFormatter : MarkdownFormatter;` is the only thing worth
drawing. Before this fallback existed, `FindRoot` returning `null` always produced a totally empty
drawing. Before this fallback existed, `FindRoots` returning no root always produced a totally empty
canvas in this shape, even though the scope named something concrete.

When `FindRoot` returns `null` and a scope is resolved, `BuildLayout` calls
When `FindRoots` returns no root and a scope is resolved, `BuildLayout` calls
`CollectTopLevelScopedParts(workspace, scope, theme, defsByName)`, which scans
`workspace.Declarations` for every non-standard-library `SysmlFeatureNode` with
`FeatureKeyword == "part"` whose qualified name satisfies `ExposeScopeResolver.IsInSubjectScope`,
Expand Down Expand Up @@ -294,7 +298,7 @@ real 3-axis-gantry wiring model) are never collapsed onto one shared routed poly
connection keeps its own independently-routed connector with distinct waypoints (a separate
parallel lane), and its own pair of labeled ports.

###### `FindRoot(workspace, scope)`
###### `FindRoots(workspace, scope)`

Chooses the non-standard-library `part def` with the most connection usages (breaking ties by the
most part usages) as the definition whose interior to render, restricted — when a scope is
Expand All @@ -304,7 +308,11 @@ falls back to considering every candidate when `scope` is `null`. When multiple
relevant to a non-null scope (possible because a nested definition and its ancestor can both be
relevant), the most specific (deepest/longest qualified name) relevant candidate is preferred via
`ExposeScopeResolver.IsMoreSpecificCandidate`, with the connections/parts tie-break used only to
break ties among equally specific candidates; this ordering does not apply when `scope` is `null`.
break ties among equally specific candidates; this ordering does not apply when `scope` is `null`. When `scope` is
non-null and more than one candidate is an independent composition-graph root (composes at least
one part, is not used as another candidate's part type, and is not a namespace ancestor of another
such root), every one of them is returned, in declaration order, and drawn side by side; a single
root and the unscoped case are unchanged.

###### `CollectParts` and `ResolveConnections(root, partIndex)`

Expand All @@ -320,13 +328,13 @@ needed.

##### Expose Scoping

Because this strategy renders exactly one selected root's interior, scoping cannot narrow a
Because this strategy renders the interior of each selected root, scoping cannot narrow a
workspace-wide collection the way `GridViewLayoutStrategy` and `BrowserViewLayoutStrategy` do;
instead it restricts **which root is selected**, then narrows **which of that root's parts are
shown**, and finally — via `DetermineBranchUnlimitedRecursion`/`MatchesUnlimitedSubject` (see
_Per-Branch Depth-Limited Recursion_ above) — governs **how deep into each shown part's own
interior the diagram recurses, decided independently per branch**.
`FindRoot` only considers candidates `ExposeScopeResolver.IsRootRelevantToScope` accepts,
`FindRoots` only considers candidates `ExposeScopeResolver.IsRootRelevantToScope` accepts,
so exposing the current heuristic root itself, an inner part of it, or a definition that itself
contains the heuristic default all correctly select a root, while exposing an unrelated
definition yields no root and thus the minimal empty canvas. When more than one candidate is
Expand All @@ -338,7 +346,7 @@ the selected root's own part features to those within the resolved scope (via
`ExposeScopeResolver.IsInSubjectScope`), and `ResolveConnections`'s existing "skip connections
whose endpoint did not resolve" behavior transparently drops any connection touching an excluded
part — no new edge-side logic was required. A view with no `expose` statement (including the
synthesized `--auto` view, whose `ViewNode` is `null`) resolves no scope, so `FindRoot` considers
synthesized `--auto` view, whose `ViewNode` is `null`) resolves no scope, so `FindRoots` considers
every candidate, `CollectParts` keeps every part, and every branch's decided recursion flag is
always `true` — completely unchanged from the pre-scoping behavior.

Expand Down Expand Up @@ -388,7 +396,7 @@ diagnostics, so the returned `LayoutTree` carries no layout-quality warnings.
- `StdlibFilter` (Rendering Internal subsystem) — standard-library exclusion.
- `ExposeScopeResolver` (Layout Internal subsystem) — `ResolveExposedScope`,
`IsRootRelevantToScope`, `IsInSubjectScope`, and `IsMoreSpecificCandidate` supply the shared
`expose`-scoping used by `BuildLayout`, `FindRoot`, and `CollectParts`; `MatchesUnlimitedSubject`
`expose`-scoping used by `BuildLayout`, `FindRoots`, and `CollectParts`; `MatchesUnlimitedSubject`
(via `DetermineBranchUnlimitedRecursion`) is the primary per-branch depth-limiting gate, deciding
once per depth-0/top-level branch whether that branch's specific matching subject is recursive,
with `HasUnlimitedRecursion` retained only as the depth-0 fallback when no qualified name is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,31 @@ fundamentally different from `GridViewLayoutStrategy`'s matrix layout, not merel
variant of it; `asTextualNotation` is left unmapped because it is a non-graphical rendering
style with no corresponding `ILayoutStrategy` implementation.

When no render target matches, the router falls back to testing the view's name and its
A `Views::`-qualified render target (e.g. `render Views::asTreeDiagram;`) is matched by its
simple name.

When the view's own render target is not recognized, the router walks its view definitions
(`FromViewDefinitions`): the target of the view's resolved `Typing` edge (`view V : Def`), then
transitively the targets of each definition's `Supertype` edges, breadth-first and cycle-guarded.
The first definition reached that either declares a recognized `render` target or is one of the
standard view definitions (SysML v2.1 Beta 2 9.2.20) selects the strategy, because a view usage
inherits its definition's rendering (7.26.2):

- `StandardViewDefinitions::GeneralView` → general view strategy
- `StandardViewDefinitions::InterconnectionView` → interconnection strategy
- `StandardViewDefinitions::ActionFlowView` → action flow strategy
- `StandardViewDefinitions::StateTransitionView` → state transition strategy
- `StandardViewDefinitions::SequenceView` → sequence strategy
- `StandardViewDefinitions::GridView` → grid strategy
- `StandardViewDefinitions::BrowserView` → browser (tree) strategy

`GeometryView` has no strategy and is not mapped, so it falls through to the heuristic below.
Matching uses the resolved qualified name, so `view V : GeneralView` needs the standard library
name to be visible (for example through `private import StandardViewDefinitions::*;`) or written
qualified (`StandardViewDefinitions::GeneralView`).

When neither a render target nor a view definition selects a strategy, the router falls back to
testing the view's name and its
declared supertype names (case-insensitively) for a recognized view-kind marker, in a fixed
priority order: Interconnection, then StateTransition/State, then ActionFlow/Action, then
Grid/Matrix/Tabular, then Browser/Tree, then Sequence. The first marker that matches selects the
Expand All @@ -61,7 +85,8 @@ cannot be rendered; it is currently always null because every view resolves to a
##### Dependencies

- The view-strategy units in the Layout Internal subsystem (the strategies it returns).
- `SysmlViewNode` and `SysmlWorkspace` (Semantic subsystem) for the view's identity.
- `SysmlViewNode` and `SysmlWorkspace` (Semantic subsystem) for the view's identity, its
resolved `Typing`/`Supertype` edges, and its view definitions' declarations.

##### Callers

Expand Down
1 change: 1 addition & 0 deletions docs/reqstream/sysml2-tools-core/layout/internal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ sections:
- SysML2Tools-Core-Layout-Internal-InterconnectionViewLayoutStrategy-PerBranchRecursionIndependence
- SysML2Tools-Core-Layout-Internal-InterconnectionViewLayoutStrategy-NoExposeFallback
- SysML2Tools-Core-Layout-Internal-InterconnectionViewLayoutStrategy-ScopedSpecificityTieBreak
- SysML2Tools-Core-Layout-Internal-InterconnectionViewLayoutStrategy-MultipleRoots
- SysML2Tools-Core-Layout-Internal-InterconnectionViewLayoutStrategy-ScopedTopLevelFeatureFallback
- SysML2Tools-Core-Layout-Internal-InterconnectionViewLayoutStrategy-ScopedTopLevelFeatureFallbackConnections
- SysML2Tools-Core-Layout-Internal-InterconnectionViewLayoutStrategy-ScopedTopLevelFeatureFallbackEmptyCanvas
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,10 @@ sections:

- id: SysML2Tools-Core-Layout-Internal-InterconnectionViewLayoutStrategy-ScopedSpecificityTieBreak
title: >-
When more than one candidate root is relevant to the resolved expose scope,
InterconnectionViewLayoutStrategy shall select the most specific (deepest-qualified-name)
relevant candidate, using its connections/parts heuristic only to break ties among
When more than one candidate root is relevant to the resolved expose scope and they are
not independent composition roots, InterconnectionViewLayoutStrategy shall select the
most specific (deepest-qualified-name) relevant candidate, using its connections/parts
heuristic only to break ties among
equally specific candidates.
justification: |
Because SysML v2 definitions may nest, an ancestor definition and a nested descendant
Expand All @@ -297,7 +298,21 @@ sections:
defeating the intended scoping.
tests:
- InterconnectionView_BuildLayout_ExposeInnerPartOfNestedDefinition_SelectsNestedDefinitionNotAncestor
- InterconnectionView_BuildLayout_ExposeBothSameDepthSiblings_ScoreBreaksTieNotLength

- id: SysML2Tools-Core-Layout-Internal-InterconnectionViewLayoutStrategy-MultipleRoots
title: >-
When the resolved expose scope makes more than one independent composition root relevant,
InterconnectionViewLayoutStrategy shall draw every such root as its own container box, side
by side in declaration order with aligned tops, each holding only its own parts.
justification: |
SysML v2.1 Beta 2 8.2.3.11 defines the interconnection view as a repeated list of
interconnection elements, so a view exposing several systems (`expose A::**; expose B::**;`)
must show all of them rather than silently drawing only the first. A root that is merely a
namespace ancestor of another relevant root is not drawn separately, and a single root is
laid out exactly as before.
tests:
- InterconnectionView_BuildLayout_ExposeTwoIndependentRoots_DrawsBothSideBySide
- InterconnectionView_BuildLayout_ExposeInnerPartOfNestedDefinition_SelectsNestedDefinitionNotAncestor

- id: SysML2Tools-Core-Layout-Internal-InterconnectionViewLayoutStrategy-PortTitleCollisionAvoidance
title: >-
Expand Down
4 changes: 3 additions & 1 deletion docs/reqstream/sysml2-tools-core/rendering/internal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ sections:
- id: SysML2Tools-Core-Rendering-Internal-StrategySelection
title: >-
The internal rendering components shall select a view-specific layout strategy
for each view, based on the view's recognized kind, and shall fall back to the
for each view, based on the view's render target, its (standard) view definition, or its
recognized kind, and shall fall back to the
general view strategy when the kind is not recognized.
justification: |
A single dispatch point keeps the renderer agnostic of how many view kinds exist
Expand All @@ -22,6 +23,7 @@ sections:
- SysML2Tools-Core-Rendering-Internal-DiagramTypeRouter-KindDispatch
- SysML2Tools-Core-Rendering-Internal-DiagramTypeRouter-DefaultGeneral
- SysML2Tools-Core-Rendering-Internal-DiagramTypeRouter-RenderTargetOverride
- SysML2Tools-Core-Rendering-Internal-DiagramTypeRouter-StandardViewDefinition
- SysML2Tools-Core-Rendering-Internal-DiagramTypeRouter-RenderTargetUnrecognizedFallthrough
- SysML2Tools-Core-Rendering-Internal-DynamicViewSynthesizer-ViewTypeMapping
- SysML2Tools-Core-Rendering-Internal-DynamicViewSynthesizer-CompatibilityPreCheck
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,28 @@ sections:
- GetStrategy_BrowserNamedView_ReturnsBrowserStrategy
- GetStrategy_SequenceNamedView_ReturnsSequenceStrategy

- id: SysML2Tools-Core-Rendering-Internal-DiagramTypeRouter-StandardViewDefinition
title: >-
When a view declares no recognized render target, DiagramTypeRouter shall select the layout
strategy of the nearest view definition, reached through the view's resolved typing and then
the general view definitions it specializes, that declares a recognized render target or is
one of the standard view definitions GeneralView, InterconnectionView, ActionFlowView,
StateTransitionView, SequenceView, GridView, or BrowserView.
justification: |
SysML v2.1 Beta 2 9.2.20 defines the standard view definitions that select a view's
notation (`view X : InterconnectionView { ... }`), and 7.26.2 makes a view usage inherit
the rendering of its view definition. Honoring them lets models use the standard,
tool-independent form instead of relying on view naming conventions; an explicit render
on the view usage itself still takes precedence.
tests:
- GetStrategy_ViewTypedByStandardViewDefinition_RoutesToItsNotation
- GetStrategy_ViewTypedByUserViewDefinition_InheritsNotationAndRendering
- GetStrategy_RenderOnTypedView_OverridesViewDefinition

- id: SysML2Tools-Core-Rendering-Internal-DiagramTypeRouter-DefaultGeneral
title: >-
When a view matches no recognized view kind, DiagramTypeRouter shall select the
general view strategy.
When a view has no recognized render target or standard view definition and matches no
recognized view kind, DiagramTypeRouter shall select the general view strategy.
justification: |
A sensible default keeps every view renderable. The general view is the most
broadly applicable layout and is the natural fallback for an unspecified view kind.
Expand All @@ -41,8 +59,9 @@ sections:
title: >-
When a view declares a render target of asTreeDiagram, asInterconnectionDiagram,
asGeneralDiagram, asStateTransitionDiagram, asActionFlowDiagram, asSequenceDiagram, or
asGridDiagram, DiagramTypeRouter shall select the corresponding layout strategy, taking
precedence over the name/supertype heuristic.
asGridDiagram (optionally qualified as Views::<name>), DiagramTypeRouter shall select the
corresponding layout strategy, taking precedence over its view definition and the
name/supertype heuristic.
justification: |
A view's declared render target is an explicit, author-specified rendering-style
selection per the SysML v2 grammar. Honoring it ahead of the name/supertype heuristic
Expand Down
Loading
Loading