-
Notifications
You must be signed in to change notification settings - Fork 19
MDL roundtrip loses original view coordinates due to compose_views offset #401
Copy link
Copy link
Open
Description
Problem
When multiple MDL views are parsed, compose_views (in src/simlin-engine/src/mdl/view/processing.rs) stacks views vertically starting at (100, 120), applying an additive coordinate offset. This offset is NOT reversed during MDL writing. The roundtripped coordinates differ from the originals by a constant offset per view (e.g., +18 for x, +112 for y in view 1 of mark2.mdl).
This does not affect simulation correctness, but will confuse Vensim users who open a roundtripped file and find their diagram layout shifted.
Components affected
src/simlin-engine/src/mdl/view/processing.rs(compose_viewsfunction)src/simlin-engine/src/mdl/writer.rs(MDL serialization path)
Why it matters
- User experience: Vensim users expect opening a roundtripped MDL file to show the same layout they saved. Shifted coordinates break that expectation.
- Roundtrip fidelity: MDL roundtrip tests currently must accept coordinate offsets as known divergences rather than asserting exact equality.
Possible approaches
- Store original coordinates in ViewElementCompat -- preserve the pre-transformation coordinates alongside the composed ones, and use the originals when writing back to MDL.
- Skip coordinate transformation for MDL-sourced models -- avoid applying the compose_views offset when the source format is MDL, since Vensim handles multi-view layout itself.
- Reverse the transformation during writing -- compute the view segment's min_x/min_y and subtract the offset when serializing back to MDL.
Context
Identified during MDL roundtrip fidelity work on the mdl-roundtrip-fidelity branch. The mark2.mdl test model demonstrates the issue clearly with its multiple views.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels