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
+1
-19
@@ -1,5 +1,4 @@
|
||||
use crate::command::CadCommand;
|
||||
use crate::io::linetypes;
|
||||
use crate::modules::draw::modify::block_edit::BlockEditSession;
|
||||
use crate::modules::draw::modify::refedit::RefEditSession;
|
||||
use crate::scene::pick::grip::GripEdit;
|
||||
@@ -567,24 +566,7 @@ impl DocumentTab {
|
||||
|
||||
pub(super) fn new_drawing(n: usize) -> Self {
|
||||
let mut scene = Scene::new();
|
||||
linetypes::populate_document(&mut scene.document);
|
||||
// Paper layouts start as A4 landscape.
|
||||
for obj in scene.document.objects.values_mut() {
|
||||
if let acadrust::objects::ObjectType::Layout(l) = obj {
|
||||
if l.name != "Model" {
|
||||
l.min_limits = (0.0, 0.0);
|
||||
l.max_limits = (297.0, 210.0);
|
||||
l.min_extents = (0.0, 0.0, 0.0);
|
||||
l.max_extents = (297.0, 210.0, 0.0);
|
||||
l.paper_width = 297.0;
|
||||
l.paper_height = 210.0;
|
||||
l.plot_paper_units = 1;
|
||||
l.plot_scale_numerator = 1.0;
|
||||
l.plot_scale_denominator = 1.0;
|
||||
l.paper_size = "ISO_A4_(297.00_x_210.00_MM)".into();
|
||||
}
|
||||
}
|
||||
}
|
||||
scene.populate_new_drawing_defaults();
|
||||
Self {
|
||||
id: NEXT_DOCUMENT_TAB_ID.fetch_add(1, Ordering::Relaxed),
|
||||
scene,
|
||||
|
||||
Reference in new issue
Block a user