forked from 1b-agent/opencadstudio-upstream
Layouts reopen in the viewport they were saved in (#1670)
A save records the entered model viewport (or the sheet) as the layout's last active viewport, and opening the layout enters it again with its UCS. Picks up the codec fix that kept a last-active link from being read as the sheet viewport (codec d57097c, kernel b40fa59, graph 2360341). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
072aeb9dbf
commit
2c329b2889
9 files changed
+102
-13
No files matched your search
@@ -77,3 +77,44 @@ fn ctab_is_created_when_absent_then_updated_in_place() {
|
||||
Some("Layout3")
|
||||
);
|
||||
}
|
||||
|
||||
/// A layout saved with a model viewport entered reopens inside it; saved
|
||||
/// from paper space it reopens on the sheet (#1670).
|
||||
#[test]
|
||||
fn entered_viewport_survives_a_save_and_reload() {
|
||||
use codec::{entities::Viewport, EntityType};
|
||||
for format in ["dxf", "dwg"] {
|
||||
let mut scene = Scene::new();
|
||||
scene.set_current_layout("Layout1".to_string());
|
||||
let mut sheet = Viewport::new();
|
||||
sheet.id = 1;
|
||||
sheet.width = 420.0;
|
||||
sheet.height = 297.0;
|
||||
let sheet = scene.add_entity(EntityType::Viewport(sheet));
|
||||
let mut model = Viewport::new();
|
||||
model.id = 2;
|
||||
model.width = 100.0;
|
||||
model.height = 80.0;
|
||||
model.view_height = 80.0;
|
||||
let model = scene.add_entity(EntityType::Viewport(model));
|
||||
assert_ne!(sheet, model);
|
||||
|
||||
for entered in [Some(model), None] {
|
||||
scene.active_viewport = entered;
|
||||
scene.sync_active_viewport_to_document();
|
||||
let bytes =
|
||||
OpenCADStudio::io::save_to_bytes(&scene.document, format, scene.document.version)
|
||||
.expect("save");
|
||||
let doc = OpenCADStudio::io::load_bytes(&format!("roundtrip.{format}"), bytes)
|
||||
.expect("reload");
|
||||
let mut reopened = Scene::new();
|
||||
reopened.document = doc;
|
||||
reopened.current_layout = "Layout1".to_string();
|
||||
assert_eq!(
|
||||
reopened.saved_entered_viewport().is_some(),
|
||||
entered.is_some(),
|
||||
"{format}: entered {entered:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user