feat(model): complete wedge workflow

This commit is contained in:
Hakan Seven committed 2026-08-31 22:00:11 +03:00
commit 86ce44153b
4 files changed
+194 -103

No files matched your search

+25 -22
View File
@@ -64,13 +64,13 @@ fn history_flags(
Some((history.record_history, history.show_history))
}
pub fn is_box_primitive(
pub fn is_rectangular_primitive(
document: &acadrust::CadDocument,
handle: acadrust::Handle,
) -> bool {
matches!(
document.solid_history_operation(handle),
Some(SolidHistoryOperation::Box(_))
Some(SolidHistoryOperation::Box(_) | SolidHistoryOperation::Wedge(_))
)
}
@@ -80,13 +80,17 @@ pub fn has_specialized_primitive_properties(
) -> bool {
matches!(
document.solid_history_operation(handle),
Some(SolidHistoryOperation::Box(_) | SolidHistoryOperation::Sphere(_))
Some(
SolidHistoryOperation::Box(_)
| SolidHistoryOperation::Wedge(_)
| SolidHistoryOperation::Sphere(_)
)
)
}
pub fn reference_point(operation: &SolidHistoryOperation) -> Option<glam::DVec3> {
match operation {
SolidHistoryOperation::Box(value) => world_point(
SolidHistoryOperation::Box(value) | SolidHistoryOperation::Wedge(value) => world_point(
value.base.transform,
[value.length * 0.5, value.width * 0.5, 0.0],
),
@@ -162,10 +166,11 @@ fn sphere_properties(
]
}
fn box_properties(
fn rectangular_properties(
document: &acadrust::CadDocument,
handle: acadrust::Handle,
value: &SolidHistoryBox,
solid_type: &str,
) -> Vec<PropSection> {
let Some(position) = world_point(
value.base.transform,
@@ -185,7 +190,7 @@ fn box_properties(
Property {
label: t!("Solid type").into_owned(),
field: "solid_history_type",
value: PropValue::ReadOnly(t!("Box").into_owned()),
value: PropValue::ReadOnly(t!(solid_type).into_owned()),
},
crate::entities::common::edit_prop(
t!("Position X").as_ref(),
@@ -262,15 +267,15 @@ pub fn primitive_properties(
return Vec::new();
};
let props = match operation {
SolidHistoryOperation::Box(value) => return box_properties(document, handle, value),
SolidHistoryOperation::Box(value) => {
return rectangular_properties(document, handle, value, "Box")
}
SolidHistoryOperation::Wedge(value) => {
return rectangular_properties(document, handle, value, "Wedge")
}
SolidHistoryOperation::Sphere(value) => {
return sphere_properties(document, handle, value)
}
SolidHistoryOperation::Wedge(value) => vec![
history_prop(t!("Length").as_ref(), PROP_LENGTH, value.length),
history_prop(t!("Width").as_ref(), PROP_WIDTH, value.width),
history_prop(t!("Height").as_ref(), PROP_HEIGHT, value.height),
],
SolidHistoryOperation::Cylinder(value) | SolidHistoryOperation::Cone(value) => vec![
history_prop(t!("Radius").as_ref(), PROP_RADIUS, value.major_radius),
history_prop(t!("Height").as_ref(), PROP_HEIGHT, value.height),
@@ -365,7 +370,7 @@ pub fn apply_history_choice(
before != (history.record_history, history.show_history)
}
fn apply_box_geometry_property(
fn apply_rectangular_geometry_property(
value: &mut SolidHistoryBox,
field: &str,
text: &str,
@@ -468,8 +473,12 @@ pub fn apply_primitive_property(
field: &str,
value: &str,
) -> bool {
if let SolidHistoryOperation::Box(box_value) = operation {
if let Some(applied) = apply_box_geometry_property(box_value, field, value) {
if let SolidHistoryOperation::Box(rectangular_value)
| SolidHistoryOperation::Wedge(rectangular_value) = operation
{
if let Some(applied) =
apply_rectangular_geometry_property(rectangular_value, field, value)
{
return applied;
}
}
@@ -489,7 +498,7 @@ pub fn apply_primitive_property(
return false;
}
let positive = || (number > 0.0).then_some(number);
if let SolidHistoryOperation::Box(value) = operation {
if let SolidHistoryOperation::Box(value) | SolidHistoryOperation::Wedge(value) = operation {
let Some(next) = positive() else {
return false;
};
@@ -524,12 +533,6 @@ pub fn apply_primitive_property(
return true;
}
match operation {
SolidHistoryOperation::Wedge(value) => match field {
PROP_LENGTH => value.length = positive().unwrap_or(value.length),
PROP_WIDTH => value.width = positive().unwrap_or(value.width),
PROP_HEIGHT => value.height = positive().unwrap_or(value.height),
_ => return false,
},
SolidHistoryOperation::Cylinder(value) | SolidHistoryOperation::Cone(value) => match field {
PROP_RADIUS => {
let Some(radius) = positive() else {