forked from 1b-agent/opencadstudio-upstream
fix(plot): write page setups in the file format's canonical form
One writer (plot_settings_from_dialog) now serves both the layout's embedded settings and named page setups, so the two can no longer drift apart: - media are stored as the portrait sheet with the orientation in the rotation code (0/90/180/270; upside-down adds a half turn) instead of swapped width/height with rotation limited to 0/180 - standard scales are written by their code (1:1 … 100:1) with matching numerator/denominator; other scales as a readable custom ratio in the layout's own paper unit, converting from the drawing's scale-family unit (a metre drawing plotting "1:100" stores 10 mm = 1 unit, an inch layout stores 1 in = 2540 units); reading converts back and keeps a ratio the scale list has no name for instead of snapping to 1:1 - the layout's paper unit and every flag the dialog does not edit survive a round trip untouched; layout limits follow the paper-space unit - new drawings, new layouts, CLEAR and the automation "new" op share one default page setup (canonical A4 name, rotation 90, none_device, 1:1 layout plot) through Scene::reset_to_new_drawing Scene gains scale_family_unit_mm, scale_ratio and a scale-name ratio parser (ratios and architectural names). Round-trip tests cover orientation, standard/custom/fit scales, unit conversion, named-setup parity, preserved flags and the default layout. Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
1 parent
ef0c6bf403
commit
276e7c7bf1
8 files changed
+641
-263
No files matched your search
@@ -2709,4 +2709,25 @@ impl Scene {
|
||||
self.named_parameters = crate::scene::named_parameters::ParameterTable::new();
|
||||
self.bump_geometry();
|
||||
}
|
||||
|
||||
/// Reset to the drawing File → New produces. Every path that starts a
|
||||
/// fresh drawing (the New tab, CLEAR, the automation `new` op) goes
|
||||
/// through here so they all agree on what a blank drawing contains.
|
||||
pub fn reset_to_new_drawing(&mut self) {
|
||||
self.clear();
|
||||
self.populate_new_drawing_defaults();
|
||||
}
|
||||
|
||||
/// What a blank document gets on top of the codec's defaults: the
|
||||
/// standard linetypes and a compatible page setup on every paper layout.
|
||||
pub fn populate_new_drawing_defaults(&mut self) {
|
||||
crate::io::linetypes::populate_document(&mut self.document);
|
||||
for obj in self.document.objects.values_mut() {
|
||||
if let acadrust::objects::ObjectType::Layout(l) = obj {
|
||||
if l.name != "Model" {
|
||||
crate::scene::apply_default_page_setup(l, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user