forked from 1b-agent/opencadstudio-upstream
Cargo: codec e023bc3 (acadrust sync), kernel abca4e8, graph c63556f
The codec now holds wide EntityType variants boxed (MText, Helix, Dimension, Hatch, Viewport, MultiLeader, Surface, Table, Ole2Frame, Light, Extended). Constructors box their entity; nested patterns reach a dimension through entities::dimension::as_dimension(_mut). Also follows BlockAction::action_ids, LineTypeComplexData::source_flags and the decimal tab stop with an explicit character. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
218150c76a
commit
e4d04ef132
87 files changed
+380
-269
No files matched your search
@@ -2129,7 +2129,7 @@ mod tests {
|
||||
dimension.definition_point = Vector3::new(0.0, 5.0, 0.0);
|
||||
dimension.base.text_middle_point = Vector3::new(5.0, 5.0, 0.0);
|
||||
document
|
||||
.add_entity(EntityType::Dimension(Dimension::Linear(dimension)))
|
||||
.add_entity(EntityType::Dimension(Box::new(Dimension::Linear(dimension))))
|
||||
.unwrap();
|
||||
crate::modules::draw::modify::explode::bake_dimension_blocks(&mut document);
|
||||
|
||||
@@ -2152,7 +2152,7 @@ mod tests {
|
||||
dimension.base.text_middle_point = Vector3::new(5.0, 5.0, 0.0);
|
||||
app.tabs[app.active_tab]
|
||||
.scene
|
||||
.add_entity(EntityType::Dimension(Dimension::Linear(dimension)));
|
||||
.add_entity(EntityType::Dimension(Box::new(Dimension::Linear(dimension))));
|
||||
let path = std::env::temp_dir().join(format!(
|
||||
"ocs_verified_dimension_{}_{}.dwg",
|
||||
std::process::id(),
|
||||
@@ -2190,7 +2190,7 @@ mod tests {
|
||||
let i = app.active_tab;
|
||||
app.tabs[i]
|
||||
.scene
|
||||
.add_entity(EntityType::Dimension(Dimension::Linear(dimension)));
|
||||
.add_entity(EntityType::Dimension(Box::new(Dimension::Linear(dimension))));
|
||||
let path = std::env::temp_dir().join(format!(
|
||||
"ocs_verified_dimension_follow_up_{}_{}.dwg",
|
||||
std::process::id(),
|
||||
@@ -2240,7 +2240,7 @@ mod tests {
|
||||
app.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.add_entity(EntityType::Dimension(Dimension::Linear(d)))
|
||||
.add_entity(EntityType::Dimension(Box::new(Dimension::Linear(d))))
|
||||
.unwrap();
|
||||
let path = std::env::temp_dir().join(format!(
|
||||
"ocs_verified_dim_{}_{}.dwg",
|
||||
@@ -2330,7 +2330,7 @@ mod tests {
|
||||
viewport.width = 100.0;
|
||||
viewport.height = 50.0;
|
||||
viewport.turn_on();
|
||||
scene.add_entity(codec::EntityType::Viewport(viewport));
|
||||
scene.add_entity(codec::EntityType::Viewport(Box::new(viewport)));
|
||||
for entity in scene.document.entities_mut() {
|
||||
if let codec::EntityType::Viewport(viewport) = entity {
|
||||
viewport.status.grid_on = true;
|
||||
@@ -2774,7 +2774,7 @@ mod tests {
|
||||
codec::MText::with_value("\\A1;10.5000", codec::types::Vector3::new(10.0, 20.0, 0.0));
|
||||
app.tabs[i]
|
||||
.scene
|
||||
.add_entity(codec::EntityType::MText(mtext));
|
||||
.add_entity(codec::EntityType::MText(Box::new(mtext)));
|
||||
|
||||
let q = app.automation_op(
|
||||
r#"{"op":"query","type":"MTEXT","detail":"full","fields":["value","text","height","bounds"]}"#,
|
||||
@@ -3642,7 +3642,7 @@ mod tests {
|
||||
let mut dst_mtext = MText::new();
|
||||
dst_mtext.value = "DSTM".into();
|
||||
dst_mtext.height = 2.0;
|
||||
let dst_mtext_h = app.tabs[i].scene.add_entity(EntityType::MText(dst_mtext));
|
||||
let dst_mtext_h = app.tabs[i].scene.add_entity(EntityType::MText(Box::new(dst_mtext)));
|
||||
|
||||
// Drive the interactive command exactly as the viewport does:
|
||||
// phase 1 source pick, phase 2 destination selection.
|
||||
|
||||
@@ -1405,7 +1405,7 @@ mod paste_entities_kernel_tests {
|
||||
fn remaps_leader_annotation_link_to_pasted_handles() {
|
||||
let mut seed = codec::CadDocument::new();
|
||||
let note = seed
|
||||
.add_entity(codec::EntityType::MText(codec::entities::MText::new()))
|
||||
.add_entity(codec::EntityType::MText(Box::new(codec::entities::MText::new())))
|
||||
.unwrap();
|
||||
let mut leader = codec::entities::Leader::default();
|
||||
leader.annotation_handle = note;
|
||||
|
||||
@@ -36,10 +36,12 @@ impl OpenCADStudio {
|
||||
) {
|
||||
let i = self.active_tab;
|
||||
let valid = matches!(
|
||||
self.tabs[i].scene.document.get_entity(dimension),
|
||||
Some(codec::EntityType::Dimension(
|
||||
codec::entities::Dimension::Linear(_) | codec::entities::Dimension::Aligned(_)
|
||||
))
|
||||
self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.get_entity(dimension)
|
||||
.and_then(crate::entities::dimension::as_dimension),
|
||||
Some(codec::entities::Dimension::Linear(_) | codec::entities::Dimension::Aligned(_))
|
||||
);
|
||||
if !valid {
|
||||
self.command_line.push_error(
|
||||
@@ -415,8 +417,12 @@ fn apply_dimspace(
|
||||
requested_spacing: Option<f64>,
|
||||
) -> bool {
|
||||
use codec::entities::Dimension;
|
||||
let (axis, normal, definition, auto_spacing) = match scene.document.get_entity(base_h) {
|
||||
Some(codec::EntityType::Dimension(dimension @ Dimension::Linear(d))) => {
|
||||
let base = scene
|
||||
.document
|
||||
.get_entity(base_h)
|
||||
.and_then(crate::entities::dimension::as_dimension);
|
||||
let (axis, normal, definition, auto_spacing) = match base {
|
||||
Some(dimension @ Dimension::Linear(d)) => {
|
||||
let spacing = dimension_auto_spacing(
|
||||
&scene.document,
|
||||
dimension,
|
||||
@@ -433,7 +439,7 @@ fn apply_dimspace(
|
||||
spacing,
|
||||
)
|
||||
}
|
||||
Some(codec::EntityType::Dimension(dimension @ Dimension::Aligned(d))) => {
|
||||
Some(dimension @ Dimension::Aligned(d)) => {
|
||||
let spacing = dimension_auto_spacing(
|
||||
&scene.document,
|
||||
dimension,
|
||||
@@ -471,7 +477,7 @@ fn apply_dimspace(
|
||||
kernel::space::move_to_dimension_spacing([p.x, p.y, p.z], frame, target);
|
||||
*p = codec::types::Vector3::new(point[0], point[1], point[2]);
|
||||
};
|
||||
match dim {
|
||||
match &mut **dim {
|
||||
Dimension::Linear(d) => {
|
||||
slide(&mut d.definition_point);
|
||||
d.base.definition_point = d.definition_point;
|
||||
|
||||
@@ -39,10 +39,8 @@ impl OpenCADStudio {
|
||||
let delta_safe = self.delta_add_safe(i, &entity);
|
||||
let pending = self.begin_undo(i, label, 1, delta_safe);
|
||||
let is_associative_dimension = matches!(
|
||||
entity,
|
||||
codec::EntityType::Dimension(
|
||||
codec::entities::Dimension::Linear(_) | codec::entities::Dimension::Aligned(_)
|
||||
)
|
||||
crate::entities::dimension::as_dimension(&entity),
|
||||
Some(codec::entities::Dimension::Linear(_) | codec::entities::Dimension::Aligned(_))
|
||||
);
|
||||
let association_enabled = self.tabs[i].scene.document.header.dimension_associativity == 2;
|
||||
let committed = if preserve_commit_layer {
|
||||
@@ -257,10 +255,8 @@ impl OpenCADStudio {
|
||||
};
|
||||
let pending = self.begin_undo(i, label, 1, delta_safe);
|
||||
let is_associative_dimension = matches!(
|
||||
entity,
|
||||
codec::EntityType::Dimension(
|
||||
codec::entities::Dimension::Linear(_) | codec::entities::Dimension::Aligned(_)
|
||||
)
|
||||
crate::entities::dimension::as_dimension(&entity),
|
||||
Some(codec::entities::Dimension::Linear(_) | codec::entities::Dimension::Aligned(_))
|
||||
);
|
||||
let association_enabled = self.tabs[i].scene.document.header.dimension_associativity == 2;
|
||||
let committed = if preserve_commit_layer {
|
||||
@@ -324,8 +320,8 @@ impl OpenCADStudio {
|
||||
let label = self.history_label_from_active_cmd(i, "DIMENSION");
|
||||
let association_mode = self.tabs[i].scene.document.header.dimension_associativity;
|
||||
let single_source_dimension = matches!(
|
||||
&entity,
|
||||
codec::EntityType::Dimension(codec::entities::Dimension::Ordinate(_))
|
||||
crate::entities::dimension::as_dimension(&entity),
|
||||
Some(codec::entities::Dimension::Ordinate(_))
|
||||
);
|
||||
// A dimension placed on the sheet but measuring model geometry
|
||||
// through a viewport carries the compensation as a negative
|
||||
|
||||
@@ -160,7 +160,7 @@ impl OpenCADStudio {
|
||||
Operation::Rotate(degrees) => {
|
||||
dimension.base_mut().text_rotation = degrees.to_radians();
|
||||
}
|
||||
Operation::Oblique(degrees) => match dimension {
|
||||
Operation::Oblique(degrees) => match &mut **dimension {
|
||||
codec::entities::Dimension::Linear(value) => {
|
||||
value.ext_line_rotation = degrees.to_radians();
|
||||
}
|
||||
|
||||
@@ -463,7 +463,7 @@ impl OpenCADStudio {
|
||||
false
|
||||
}
|
||||
};
|
||||
match dim {
|
||||
match &mut **dim {
|
||||
Dimension::Linear(d) => {
|
||||
stretched |= mv(&mut d.first_point);
|
||||
stretched |= mv(&mut d.second_point);
|
||||
|
||||
@@ -21,7 +21,7 @@ impl OpenCADStudio {
|
||||
});
|
||||
let label = self.history_label_from_active_cmd(i, "MVIEW");
|
||||
let pending = self.begin_undo(i, label, 1, true);
|
||||
let handle = self.commit_entity_handle(codec::EntityType::Viewport(viewport));
|
||||
let handle = self.commit_entity_handle(codec::EntityType::Viewport(Box::new(viewport)));
|
||||
if let (Some(handle), Some(saved)) = (handle, saved_view) {
|
||||
if let Some(codec::EntityType::Viewport(viewport)) =
|
||||
self.tabs[i].scene.document.get_entity_mut(handle)
|
||||
@@ -244,7 +244,8 @@ impl OpenCADStudio {
|
||||
viewport.id = 2;
|
||||
viewport.clip_boundary_handle = clip_handle;
|
||||
viewport.status.non_rectangular_clipping = !clip_handle.is_null();
|
||||
let viewport_handle = self.commit_entity_handle(codec::EntityType::Viewport(viewport));
|
||||
let viewport_handle =
|
||||
self.commit_entity_handle(codec::EntityType::Viewport(Box::new(viewport)));
|
||||
if let Some(viewport_handle) = viewport_handle {
|
||||
if !created_boundary {
|
||||
let before = self.tabs[i]
|
||||
|
||||
@@ -294,7 +294,7 @@ impl OpenCADStudio {
|
||||
} else {
|
||||
line.layer
|
||||
};
|
||||
scene.add_entity(codec::EntityType::MText(mtext));
|
||||
scene.add_entity(codec::EntityType::MText(Box::new(mtext)));
|
||||
erase.extend(line.handles);
|
||||
}
|
||||
erase.sort();
|
||||
|
||||
@@ -2389,7 +2389,7 @@ impl OpenCADStudio {
|
||||
Vector3::new(mv.center.x - mv.target.x, mv.center.y - mv.target.y, 0.0);
|
||||
vp.view_height = mv.height;
|
||||
vp.custom_scale = scale;
|
||||
scene.add_entity(codec::EntityType::Viewport(vp));
|
||||
scene.add_entity(codec::EntityType::Viewport(Box::new(vp)));
|
||||
// A paper-space named view of the same name frames it.
|
||||
let mut named = codec::tables::View::new(title.as_str());
|
||||
named.handle = scene.document.allocate_handle();
|
||||
|
||||
@@ -126,10 +126,10 @@ mod tests {
|
||||
let i = app.active_tab;
|
||||
let first = app.tabs[i]
|
||||
.scene
|
||||
.add_entity(codec::EntityType::Viewport(codec::entities::Viewport::new()));
|
||||
.add_entity(codec::EntityType::Viewport(Box::new(codec::entities::Viewport::new())));
|
||||
let second = app.tabs[i]
|
||||
.scene
|
||||
.add_entity(codec::EntityType::Viewport(codec::entities::Viewport::new()));
|
||||
.add_entity(codec::EntityType::Viewport(Box::new(codec::entities::Viewport::new())));
|
||||
app.tabs[i].scene.active_viewport = Some(first);
|
||||
let _ = app.run_command_line("UCSFOLLOW 1");
|
||||
assert!(app.tabs[i].scene.ucs_follow());
|
||||
|
||||
@@ -1000,7 +1000,10 @@ impl OpenCADStudio {
|
||||
match self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.add_entity_to_layout(codec::EntityType::Viewport(vp), &layout_name)
|
||||
.add_entity_to_layout(
|
||||
codec::EntityType::Viewport(Box::new(vp)),
|
||||
&layout_name,
|
||||
)
|
||||
{
|
||||
Ok(handle) => {
|
||||
self.tabs[i].scene.auto_fit_viewport(handle);
|
||||
@@ -2207,7 +2210,7 @@ mod tests {
|
||||
locked_hatch.common.layer = "LOCKED_LAYER".into();
|
||||
let h_locked_hatch = app.tabs[i]
|
||||
.scene
|
||||
.add_entity_clone(EntityType::Hatch(locked_hatch));
|
||||
.add_entity_clone(EntityType::Hatch(Box::new(locked_hatch)));
|
||||
|
||||
let h_line = app.tabs[i]
|
||||
.scene
|
||||
|
||||
@@ -352,7 +352,7 @@ impl OpenCADStudio {
|
||||
|
||||
fn is_angular_dimension(entity: &EntityType) -> bool {
|
||||
matches!(
|
||||
entity,
|
||||
EntityType::Dimension(Dimension::Angular2Ln(_) | Dimension::Angular3Pt(_))
|
||||
crate::entities::dimension::as_dimension(entity),
|
||||
Some(Dimension::Angular2Ln(_) | Dimension::Angular3Pt(_))
|
||||
)
|
||||
}
|
||||
@@ -841,7 +841,7 @@ impl super::OpenCADStudio {
|
||||
// catastrophic cancellation. Insertion is a pure translation, so zeroing
|
||||
// it keeps the layout's shape, wrapping and alignment identical.
|
||||
mt.insertion_point = Vector3::new(0.0, 0.0, 0.0);
|
||||
let entity = EntityType::MText(mt.clone());
|
||||
let entity = EntityType::MText(Box::new(mt.clone()));
|
||||
let anno = 1.0;
|
||||
let bg = self.tabs[i].scene.bg_color;
|
||||
let wires: Vec<WireModel> = tessellate::tessellate(
|
||||
@@ -1753,7 +1753,8 @@ impl super::OpenCADStudio {
|
||||
));
|
||||
mt.insertion_point = codec::types::Vector3::new(position.x, position.y, position.z);
|
||||
self.push_undo_snapshot(i, "MTEXT");
|
||||
let handle = self.commit_entity_handle(plane.place_entity(EntityType::MText(mt)));
|
||||
let handle =
|
||||
self.commit_entity_handle(plane.place_entity(EntityType::MText(Box::new(mt))));
|
||||
if annotative {
|
||||
let scale = self.tabs[i].scene.creation_annotation_scale_handle();
|
||||
if let (Some(handle), Some(scale)) = (handle, scale) {
|
||||
@@ -1869,7 +1870,8 @@ impl super::OpenCADStudio {
|
||||
));
|
||||
mt.insertion_point = codec::types::Vector3::new(position.x, position.y, position.z);
|
||||
self.push_undo_snapshot(i, "MTEXT");
|
||||
let handle = self.commit_entity_handle(plane.place_entity(EntityType::MText(mt)));
|
||||
let handle =
|
||||
self.commit_entity_handle(plane.place_entity(EntityType::MText(Box::new(mt))));
|
||||
self.tabs[i].dirty = true;
|
||||
if annotative {
|
||||
let scale = self.tabs[i].scene.creation_annotation_scale_handle();
|
||||
@@ -1885,7 +1887,7 @@ impl super::OpenCADStudio {
|
||||
if let (Some(h), Some(ed)) = (handle, self.mtext_editor.as_mut()) {
|
||||
ed.editing = Some(h);
|
||||
if let Some(EntityType::MText(mtext)) = self.tabs[i].scene.document.get_entity(h) {
|
||||
ed.original = Some(mtext.clone());
|
||||
ed.original = Some((**mtext).clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -497,7 +497,7 @@ mod tests {
|
||||
vp.width = 200.;
|
||||
vp.height = 100.;
|
||||
vp.view_height = 50.;
|
||||
let handle = scene.add_entity(codec::EntityType::Viewport(vp));
|
||||
let handle = scene.add_entity(codec::EntityType::Viewport(Box::new(vp)));
|
||||
scene.active_viewport = Some(handle);
|
||||
let mut camera = scene.navigation_camera();
|
||||
camera.target = DVec3::new(120., 30., 8.);
|
||||
|
||||
@@ -943,7 +943,7 @@ impl<'a> HostSession<'a> {
|
||||
frame.common.layer = layer;
|
||||
}
|
||||
self.push_undo("Embed picture");
|
||||
let handle = self.add_entity(EntityType::Ole2Frame(frame));
|
||||
let handle = self.add_entity(EntityType::Ole2Frame(Box::new(frame)));
|
||||
if handle.is_null() {
|
||||
return Err("the picture frame could not be added".into());
|
||||
}
|
||||
@@ -6708,7 +6708,7 @@ mod tests {
|
||||
let EntityType::Dimension(dimension) = &mut after else {
|
||||
unreachable!()
|
||||
};
|
||||
if let codec::entities::Dimension::Linear(value) = dimension {
|
||||
if let codec::entities::Dimension::Linear(value) = &mut **dimension {
|
||||
value.second_point.x = 30.0;
|
||||
}
|
||||
ocs_plugin_api::entity_coverage::validate_entity_mutation(&before, &after).unwrap();
|
||||
@@ -7414,7 +7414,7 @@ mod tests {
|
||||
.unwrap();
|
||||
let mut viewport = codec::entities::Viewport::new();
|
||||
viewport.common.owner_handle = owner;
|
||||
let viewport_handle = host.add_entity(EntityType::Viewport(viewport));
|
||||
let viewport_handle = host.add_entity(EntityType::Viewport(Box::new(viewport)));
|
||||
let scale_handle = host.document_mut().allocate_handle();
|
||||
let mut scale = codec::objects::Scale::new("1:1", 1.0, 1.0);
|
||||
scale.handle = scale_handle;
|
||||
@@ -10861,7 +10861,7 @@ mod tests {
|
||||
bare.height = 30.0;
|
||||
let bare = host
|
||||
.document_mut()
|
||||
.add_entity(EntityType::Viewport(bare))
|
||||
.add_entity(EntityType::Viewport(Box::new(bare)))
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
host.document().get_entity(bare).map(|e| match e {
|
||||
|
||||
+37
-33
@@ -1489,12 +1489,14 @@ impl OpenCADStudio {
|
||||
if let Some((anno_field, insert_after)) = anno {
|
||||
let is_anno = crate::scene::annotative::is_annotative(doc, entity)
|
||||
|| match entity {
|
||||
codec::EntityType::Dimension(codec::entities::Dimension::Arc(
|
||||
dimension,
|
||||
)) => crate::scene::annotative::dim_style_is_annotative(
|
||||
doc,
|
||||
&dimension.base.style_name,
|
||||
),
|
||||
codec::EntityType::Dimension(dimension)
|
||||
if matches!(**dimension, codec::entities::Dimension::Arc(_)) =>
|
||||
{
|
||||
crate::scene::annotative::dim_style_is_annotative(
|
||||
doc,
|
||||
&dimension.base().style_name,
|
||||
)
|
||||
}
|
||||
codec::EntityType::Tolerance(_) => {
|
||||
crate::scene::annotative::annotation_style_is_annotative(doc, entity)
|
||||
}
|
||||
@@ -1530,7 +1532,9 @@ impl OpenCADStudio {
|
||||
"annotative",
|
||||
yes_no_choice(t.is_annotative || is_anno),
|
||||
),
|
||||
codec::EntityType::Dimension(codec::entities::Dimension::Arc(_)) => {
|
||||
codec::EntityType::Dimension(dimension)
|
||||
if matches!(**dimension, codec::entities::Dimension::Arc(_)) =>
|
||||
{
|
||||
set_row(
|
||||
&mut sections,
|
||||
"annotative",
|
||||
@@ -1683,10 +1687,14 @@ impl OpenCADStudio {
|
||||
format!("{} ({})", t!("Surface"), t!("Extrusion"))
|
||||
}
|
||||
// The reference names an angular dimension by its kind.
|
||||
codec::EntityType::Dimension(codec::entities::Dimension::Angular2Ln(_)) => {
|
||||
codec::EntityType::Dimension(dimension)
|
||||
if matches!(**dimension, codec::entities::Dimension::Angular2Ln(_)) =>
|
||||
{
|
||||
t!("Angular Dimension").into_owned()
|
||||
}
|
||||
codec::EntityType::Dimension(codec::entities::Dimension::Angular3Pt(_)) => {
|
||||
codec::EntityType::Dimension(dimension)
|
||||
if matches!(**dimension, codec::entities::Dimension::Angular3Pt(_)) =>
|
||||
{
|
||||
t!("3 Point Angular Dimension").into_owned()
|
||||
}
|
||||
codec::EntityType::Underlay(underlay) => match underlay.underlay_type {
|
||||
@@ -1719,22 +1727,14 @@ impl OpenCADStudio {
|
||||
title
|
||||
} else {
|
||||
use codec::entities::Dimension;
|
||||
match entity {
|
||||
codec::EntityType::Dimension(Dimension::Aligned(_)) => {
|
||||
t!("Aligned Dimensional Constraint")
|
||||
}
|
||||
codec::EntityType::Dimension(Dimension::Angular2Ln(_)) => {
|
||||
t!("Angular Dimension (Dynamic)")
|
||||
}
|
||||
codec::EntityType::Dimension(Dimension::Angular3Pt(_)) => {
|
||||
match crate::entities::dimension::as_dimension(entity) {
|
||||
Some(Dimension::Aligned(_)) => t!("Aligned Dimensional Constraint"),
|
||||
Some(Dimension::Angular2Ln(_)) => t!("Angular Dimension (Dynamic)"),
|
||||
Some(Dimension::Angular3Pt(_)) => {
|
||||
t!("3 Point Angular Dimension (Dynamic)")
|
||||
}
|
||||
codec::EntityType::Dimension(Dimension::Radius(_)) => {
|
||||
t!("Radius Dimensional Constraint")
|
||||
}
|
||||
codec::EntityType::Dimension(Dimension::Diameter(_)) => {
|
||||
t!("Diameter Dimensional Constraint")
|
||||
}
|
||||
Some(Dimension::Radius(_)) => t!("Radius Dimensional Constraint"),
|
||||
Some(Dimension::Diameter(_)) => t!("Diameter Dimensional Constraint"),
|
||||
_ => t!("Linear Dimensional Constraint"),
|
||||
}
|
||||
.into_owned()
|
||||
@@ -2743,7 +2743,7 @@ handles={handles_ms:.1} panel={:.1} ribbon={ribbon_ms:.1} tail={:.1} selected={}
|
||||
// scale are available.
|
||||
if let codec::EntityType::Dimension(dim) = contextual.as_ref() {
|
||||
if matches!(
|
||||
dim,
|
||||
&**dim,
|
||||
codec::entities::Dimension::Linear(_)
|
||||
| codec::entities::Dimension::Aligned(_)
|
||||
) && !dim.base().text_user_positioned
|
||||
@@ -2780,13 +2780,17 @@ handles={handles_ms:.1} panel={:.1} ribbon={ribbon_ms:.1} tail={:.1} selected={}
|
||||
}
|
||||
}
|
||||
}
|
||||
let dynamic_angle = match contextual.as_ref() {
|
||||
codec::EntityType::Dimension(
|
||||
dim @ (codec::entities::Dimension::Angular2Ln(_)
|
||||
| codec::entities::Dimension::Angular3Pt(_)),
|
||||
) if self.tabs[i].scene.is_dynamic_dimension(handle) => Some(dim),
|
||||
_ => None,
|
||||
};
|
||||
let contextual_dimension =
|
||||
crate::entities::dimension::as_dimension(contextual.as_ref());
|
||||
let dynamic_angle = contextual_dimension
|
||||
.filter(|dim| {
|
||||
matches!(
|
||||
dim,
|
||||
codec::entities::Dimension::Angular2Ln(_)
|
||||
| codec::entities::Dimension::Angular3Pt(_)
|
||||
)
|
||||
})
|
||||
.filter(|_| self.tabs[i].scene.is_dynamic_dimension(handle));
|
||||
if let Some(dim) = dynamic_angle {
|
||||
// A dynamic angle shows a triangle at each end of its arc
|
||||
// pointing away from it, and squares at the arc point and
|
||||
@@ -3060,8 +3064,8 @@ handles={handles_ms:.1} panel={:.1} ribbon={ribbon_ms:.1} tail={:.1} selected={}
|
||||
) -> Option<Handle> {
|
||||
let i = self.active_tab;
|
||||
let tracks_dimension_chain = matches!(
|
||||
&entity,
|
||||
codec::EntityType::Dimension(
|
||||
crate::entities::dimension::as_dimension(&entity),
|
||||
Some(
|
||||
codec::entities::Dimension::Linear(_)
|
||||
| codec::entities::Dimension::Aligned(_)
|
||||
| codec::entities::Dimension::Angular2Ln(_)
|
||||
|
||||
@@ -224,7 +224,7 @@ fn fixture_dimension_reference(app: &mut OpenCADStudio) -> String {
|
||||
dimension.base.style_name = "BO_ARROWSTYLE".to_string();
|
||||
app.tabs[i]
|
||||
.scene
|
||||
.add_entity(EntityType::Dimension(Dimension::Aligned(dimension)));
|
||||
.add_entity(EntityType::Dimension(Box::new(Dimension::Aligned(dimension))));
|
||||
name.to_string()
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ fn fixture_dimension_name_reference(app: &mut OpenCADStudio) -> String {
|
||||
dimension.base.style_name = "BO_ARROWNAMESTYLE".to_string();
|
||||
app.tabs[i]
|
||||
.scene
|
||||
.add_entity(EntityType::Dimension(Dimension::Aligned(dimension)));
|
||||
.add_entity(EntityType::Dimension(Box::new(Dimension::Aligned(dimension))));
|
||||
name.to_string()
|
||||
}
|
||||
|
||||
|
||||
@@ -2913,9 +2913,12 @@ impl OpenCADStudio {
|
||||
&value,
|
||||
);
|
||||
if applied && field == "dim_text_inside" {
|
||||
if let Some(codec::EntityType::Dimension(
|
||||
codec::entities::Dimension::LargeRadial(dimension),
|
||||
)) = app.tabs[i].scene.document.get_entity_mut(handle)
|
||||
let radial = app.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.get_entity_mut(handle)
|
||||
.and_then(crate::entities::dimension::as_dimension_mut);
|
||||
if let Some(codec::entities::Dimension::LargeRadial(dimension)) = radial
|
||||
{
|
||||
dimension.base.text_user_positioned = false;
|
||||
}
|
||||
@@ -4182,9 +4185,13 @@ impl OpenCADStudio {
|
||||
&val,
|
||||
);
|
||||
if applied && field == "dim_text_inside" {
|
||||
if let Some(codec::EntityType::Dimension(
|
||||
codec::entities::Dimension::LargeRadial(dimension),
|
||||
)) = self.tabs[i].scene.document.get_entity_mut(handle)
|
||||
if let Some(codec::entities::Dimension::LargeRadial(
|
||||
dimension,
|
||||
)) = self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.get_entity_mut(handle)
|
||||
.and_then(crate::entities::dimension::as_dimension_mut)
|
||||
{
|
||||
dimension.base.text_user_positioned = false;
|
||||
}
|
||||
|
||||
@@ -1084,7 +1084,7 @@ mod tests {
|
||||
.document
|
||||
.entities()
|
||||
.filter_map(|entity| match entity {
|
||||
EntityType::Hatch(hatch) => Some(hatch),
|
||||
EntityType::Hatch(hatch) => Some(&**hatch),
|
||||
_ => None,
|
||||
})
|
||||
.collect()
|
||||
|
||||
@@ -28,7 +28,7 @@ fn fixture() -> (OpenCADStudio, Handle, ViewportFrame) {
|
||||
viewport.custom_scale = 0.1;
|
||||
viewport.view_direction = Vector3::UNIT_Z;
|
||||
viewport.turn_on();
|
||||
let viewport = scene.add_entity(EntityType::Viewport(viewport));
|
||||
let viewport = scene.add_entity(EntityType::Viewport(Box::new(viewport)));
|
||||
let frame = scene.viewport_frame(viewport).unwrap();
|
||||
scene.document.header.dimension_associativity = 2;
|
||||
let i = app.active_tab;
|
||||
@@ -323,7 +323,7 @@ fn viewport_dimension_linear_aligned_and_radial_object_picks() {
|
||||
assert_eq!(
|
||||
preview_text(
|
||||
&app,
|
||||
&EntityType::Dimension(dimension(&app.tabs[i].scene.document).clone())
|
||||
&EntityType::Dimension(Box::new(dimension(&app.tabs[i].scene.document).clone()))
|
||||
),
|
||||
value,
|
||||
"{name}"
|
||||
@@ -361,7 +361,7 @@ fn viewport_dimension_angular_preserves_angle_without_length_factor() {
|
||||
let _ = app.feed_command(StepInput::Point(place));
|
||||
let doc = &app.tabs[app.active_tab].scene.document;
|
||||
assert_eq!(
|
||||
preview_text(&app, &EntityType::Dimension(dimension(doc).clone())),
|
||||
preview_text(&app, &EntityType::Dimension(Box::new(dimension(doc).clone()))),
|
||||
value
|
||||
);
|
||||
assert!((dimension(doc).measurement() - 90.0).abs() < 1e-5);
|
||||
@@ -1461,9 +1461,9 @@ fn viewport_dimension_invalid_paths_leave_no_partial_association() {
|
||||
Vector3::new(55.0, 60.0, 0.0),
|
||||
)));
|
||||
for (source, path) in [(model, vec![Handle::new(u64::MAX)]), (leaf, vec![root])] {
|
||||
let dim = scene.add_entity(EntityType::Dimension(Dimension::Aligned(
|
||||
let dim = scene.add_entity(EntityType::Dimension(Box::new(Dimension::Aligned(
|
||||
DimensionAligned::new(Vector3::new(50.0, 50.0, 0.0), Vector3::new(55.0, 50.0, 0.0)),
|
||||
)));
|
||||
))));
|
||||
let invalid = AcceptedSnap {
|
||||
paper_point: DVec3::new(50.0, 50.0, 0.0),
|
||||
model_point: DVec3::ZERO,
|
||||
|
||||
Reference in new issue
Block a user