fix(styles): apply active creation defaults

Resolve style properties before editors and previews open.
Use absolute annotation multipliers for style-driven objects.

Refs #401

Refs #431
This commit is contained in:
Hakan Seven 2026-08-03 16:43:37 +03:00
commit de2707a23e
14 changed files with 676 additions and 129 deletions

View file

@ -8,6 +8,7 @@
pub mod annotative;
pub mod cache;
pub mod convert;
pub mod creation_style;
pub mod model;
pub mod pick;
pub mod pipeline;
@ -3800,6 +3801,28 @@ impl Scene {
self.scale_handle_ensuring("1:1")
}
pub(crate) fn creation_annotation_multiplier(&self) -> f64 {
if self.current_layout == "Model" {
return self.annotation_scale.max(1.0e-9) as f64;
}
let Some(handle) = self.active_viewport else {
return 1.0;
};
let Some(EntityType::Viewport(viewport)) = self.document.get_entity(handle) else {
return 1.0;
};
let paper_to_model = vp_effective_scale(
viewport.custom_scale,
viewport.view_height,
viewport.height,
);
if paper_to_model.is_finite() && paper_to_model > 1.0e-9 {
1.0 / paper_to_model
} else {
1.0
}
}
pub fn set_annotation_scale_named(&mut self, name: &str) -> Option<Handle> {
let handle = self.scale_handle_ensuring(name)?;
let ObjectType::Scale(scale) = self.document.objects.get(&handle)? else {