style: apply cargo fmt across workspace

This commit is contained in:
Karim Jerbi committed 2026-10-11 03:14:29 +01:00
1 parent 85710e5454
commit 9cf9ff2c5c
531 files changed
+57740 -33906

No files matched your search

+78 -78
View File
@@ -1,7 +1,12 @@
use super::*;
impl OpenCADStudio {
pub(super) fn handle_lengthen_entity(&mut self, handle: Handle, pick_pt: glam::DVec3, mode: crate::modules::draw::modify::lengthen::LenMode) -> Option<Task<Message>> {
pub(super) fn handle_lengthen_entity(
&mut self,
handle: Handle,
pick_pt: glam::DVec3,
mode: crate::modules::draw::modify::lengthen::LenMode,
) -> Option<Task<Message>> {
let i = self.active_tab;
if self.reject_locked_edit(i, handle) {
return Some(Task::none());
@@ -35,7 +40,12 @@ impl OpenCADStudio {
None
}
pub(super) fn handle_divide_entity(&mut self, handle: Handle, n: usize, marker: Option<crate::command::CurveMarker>) {
pub(super) fn handle_divide_entity(
&mut self,
handle: Handle,
n: usize,
marker: Option<crate::command::CurveMarker>,
) {
let i = self.active_tab;
use crate::modules::draw::inquiry::divide::divide_entity;
let pts = self.tabs[i]
@@ -56,9 +66,8 @@ impl OpenCADStudio {
self.command_line
.push_output(crate::tf!("DIVIDE: {count} marker(s) placed.").as_ref());
} else {
self.command_line.push_error(
crate::t!("DIVIDE: entity type not supported or N < 2.").as_ref(),
);
self.command_line
.push_error(crate::t!("DIVIDE: entity type not supported or N < 2.").as_ref());
}
self.tabs[i].active_cmd = None;
self.tabs[i].snap_result = None;
@@ -105,12 +114,20 @@ impl OpenCADStudio {
self.restore_pre_cmd_tangent();
}
pub(super) fn handle_pedit_op(&mut self, handle: Handle, op: crate::modules::draw::modify::pedit::PeditOp) -> Task<Message> {
pub(super) fn handle_pedit_op(
&mut self,
handle: Handle,
op: crate::modules::draw::modify::pedit::PeditOp,
) -> Task<Message> {
let i = self.active_tab;
self.apply_pedit_result(i, handle, op)
}
pub(super) fn handle_join_to_source(&mut self, source: Handle, handles: Vec<Handle>) -> Option<Task<Message>> {
pub(super) fn handle_join_to_source(
&mut self,
source: Handle,
handles: Vec<Handle>,
) -> Option<Task<Message>> {
let i = self.active_tab;
if self.reject_locked_edit(i, source) {
return Some(Task::none());
@@ -192,8 +209,7 @@ impl OpenCADStudio {
self.tabs[i].snap_result = None;
self.restore_pre_cmd_tangent();
self.command_line.push_output(
crate::tf!("JOIN: {count_in} object(s) joined into {count_out}.")
.as_ref(),
crate::tf!("JOIN: {count_in} object(s) joined into {count_out}.").as_ref(),
);
self.refresh_properties();
}
@@ -210,7 +226,12 @@ impl OpenCADStudio {
None
}
pub(super) fn handle_break_entity(&mut self, handle: Handle, p1: glam::DVec3, p2: glam::DVec3) -> Option<Task<Message>> {
pub(super) fn handle_break_entity(
&mut self,
handle: Handle,
p1: glam::DVec3,
p2: glam::DVec3,
) -> Option<Task<Message>> {
let i = self.active_tab;
if self.reject_locked_edit(i, handle) {
return Some(Task::none());
@@ -224,13 +245,15 @@ impl OpenCADStudio {
match replacement {
Some(frags) => {
let unchanged = frags.len() == 1
&& self.tabs[i].scene.document.get_entity(handle).is_some_and(
|original| {
&& self.tabs[i]
.scene
.document
.get_entity(handle)
.is_some_and(|original| {
let mut fragment = frags[0].clone();
fragment.common_mut().handle = handle;
&fragment == original
},
);
});
if unchanged {
self.tabs[i].active_cmd = None;
self.tabs[i].snap_result = None;
@@ -282,7 +305,6 @@ impl OpenCADStudio {
None
}
pub(super) fn handle_hatchedit_apply(&mut self, result: CmdResult) -> Option<Task<Message>> {
let i = self.active_tab;
let CmdResult::HatcheditApply {
@@ -315,8 +337,7 @@ impl OpenCADStudio {
} else {
let plane = match self.tabs[i].scene.document.get_entity(handle) {
Some(codec::EntityType::Hatch(h)) => {
let storage =
crate::entities::curve::ocs_plane(h.normal, h.elevation);
let storage = crate::entities::curve::ocs_plane(h.normal, h.elevation);
crate::command::WorkingPlane::new(
glam::DVec3::from_array(storage.origin),
glam::DVec3::from_array(storage.x_axis),
@@ -325,10 +346,12 @@ impl OpenCADStudio {
}
_ => self.tabs[i].ucs_xform().working_plane(),
};
let mut sources =
self.tabs[i].scene.boundary_sources_on_plane(plane, 1e-6);
let mut sources = self.tabs[i].scene.boundary_sources_on_plane(plane, 1e-6);
sources.remove(&handle);
let command=crate::modules::draw::draw::hatchedit::HatcheditCommand::for_association(handle,name,scale,angle,plane,sources);
let command =
crate::modules::draw::draw::hatchedit::HatcheditCommand::for_association(
handle, name, scale, angle, plane, sources,
);
self.tabs[i].scene.deselect_all();
self.command_line.push_info(&command.prompt());
self.tabs[i].active_cmd = Some(Box::new(command));
@@ -336,19 +359,16 @@ impl OpenCADStudio {
return Some(Task::none());
}
if let HatchEditOperation::DrawOrderBoundary { above } = &operation {
let references: Vec<_> =
match self.tabs[i].scene.document.get_entity(handle) {
Some(codec::EntityType::Hatch(h)) => h
.paths
.iter()
.flat_map(|p| p.boundary_handles.iter())
.filter(|h| {
self.tabs[i].scene.document.get_entity(**h).is_some()
})
.map(|h| format!("{:X}", h.value()))
.collect(),
_ => Vec::new(),
};
let references: Vec<_> = match self.tabs[i].scene.document.get_entity(handle) {
Some(codec::EntityType::Hatch(h)) => h
.paths
.iter()
.flat_map(|p| p.boundary_handles.iter())
.filter(|h| self.tabs[i].scene.document.get_entity(**h).is_some())
.map(|h| format!("{:X}", h.value()))
.collect(),
_ => Vec::new(),
};
self.tabs[i].active_cmd = None;
if references.is_empty() {
self.command_line
@@ -392,15 +412,15 @@ impl OpenCADStudio {
name
}
});
if layer.as_ref().is_some_and(|name| {
self.tabs[i].scene.document.layers.get(name).is_none()
}) {
if layer
.as_ref()
.is_some_and(|name| self.tabs[i].scene.document.layers.get(name).is_none())
{
self.discard_last_undo_entry(i);
self.command_line.push_error("HATCHEDIT: layer not found.");
return Some(Task::none());
}
if let Some(entity) = self.tabs[i].scene.document.get_entity_mut(handle)
{
if let Some(entity) = self.tabs[i].scene.document.get_entity_mut(handle) {
let common = entity.common_mut();
if let Some(value) = color {
common.color = value;
@@ -440,13 +460,9 @@ impl OpenCADStudio {
self.tabs[i].scene.document.get_entity_mut(handle)
{
if !name.is_empty() && name != hatch.pattern.name {
if let Some(entry) =
crate::scene::model::hatch_patterns::find(&name)
{
if let Some(entry) = crate::scene::model::hatch_patterns::find(&name) {
let mut pattern =
crate::scene::model::hatch_patterns::build_dxf_pattern(
entry,
);
crate::scene::model::hatch_patterns::build_dxf_pattern(entry);
crate::entities::hatch::scale_pattern_geometry(
&mut pattern,
scale.max(1.0e-6) as f64,
@@ -466,8 +482,7 @@ impl OpenCADStudio {
entry.gpu,
crate::scene::model::hatch_model::HatchPattern::Solid
);
hatch.pattern_type =
codec::entities::HatchPatternType::Predefined;
hatch.pattern_type = codec::entities::HatchPatternType::Predefined;
hatch.gradient_color.enabled = false;
}
} else {
@@ -533,18 +548,13 @@ impl OpenCADStudio {
|| paths.iter().any(|path| {
path.boundary_handles.is_empty()
|| path.boundary_handles.iter().any(|source| {
self.tabs[i]
.scene
.document
.get_entity(*source)
.is_none()
self.tabs[i].scene.document.get_entity(*source).is_none()
})
})
{
self.discard_last_undo_entry(i);
self.command_line.push_error(
"HATCHEDIT: associated boundary is no longer available.",
);
self.command_line
.push_error("HATCHEDIT: associated boundary is no longer available.");
return Some(Task::none());
}
self.tabs[i].scene.replace_hatch_association(handle, paths);
@@ -552,10 +562,8 @@ impl OpenCADStudio {
HatchEditOperation::RecreateBoundary { associate, region } => {
let source = self.tabs[i].scene.document.get_entity(handle).cloned();
if let Some(codec::EntityType::Hatch(source)) = source {
let storage = crate::entities::curve::ocs_plane(
source.normal,
source.elevation,
);
let storage =
crate::entities::curve::ocs_plane(source.normal, source.elevation);
let plane = crate::command::WorkingPlane::new(
glam::DVec3::from_array(storage.origin),
glam::DVec3::from_array(storage.x_axis),
@@ -573,13 +581,11 @@ impl OpenCADStudio {
})
.collect::<Option<Vec<_>>>();
let Some(loops) = loops.filter(|loops| {
!loops.is_empty()
&& loops.iter().all(|ring| !ring.is_empty())
!loops.is_empty() && loops.iter().all(|ring| !ring.is_empty())
}) else {
self.discard_last_undo_entry(i);
self.command_line.push_error(
"HATCHEDIT: boundary cannot form a region.",
);
self.command_line
.push_error("HATCHEDIT: boundary cannot form a region.");
return Some(Task::none());
};
let contained = loops
@@ -612,8 +618,7 @@ impl OpenCADStudio {
.map(|(outer, depth)| {
let mut indices = vec![outer];
indices.extend((0..loops.len()).filter(|inner| {
depths[*inner] == *depth + 1
&& contained[*inner][outer]
depths[*inner] == *depth + 1 && contained[*inner][outer]
}));
indices
})
@@ -632,9 +637,8 @@ impl OpenCADStudio {
.collect::<Option<Vec<_>>>();
let Some(entities) = entities else {
self.discard_last_undo_entry(i);
self.command_line.push_error(
"HATCHEDIT: boundary cannot form a region.",
);
self.command_line
.push_error("HATCHEDIT: boundary cannot form a region.");
return Some(Task::none());
};
(entities, groups)
@@ -642,21 +646,18 @@ impl OpenCADStudio {
let rings = crate::scene::hatch_boundary_rings(&source);
if rings.len() != source.paths.len() {
self.discard_last_undo_entry(i);
self.command_line.push_error(
"HATCHEDIT: boundary cannot form a polyline.",
);
self.command_line
.push_error("HATCHEDIT: boundary cannot form a polyline.");
return Some(Task::none());
}
let entities = crate::scene::boundary_entities(&rings, plane);
if entities.len() != source.paths.len() {
self.discard_last_undo_entry(i);
self.command_line.push_error(
"HATCHEDIT: boundary cannot form a polyline.",
);
self.command_line
.push_error("HATCHEDIT: boundary cannot form a polyline.");
return Some(Task::none());
}
let groups =
(0..entities.len()).map(|index| vec![index]).collect();
let groups = (0..entities.len()).map(|index| vec![index]).collect();
(entities, groups)
};
let mut path_handles = vec![None; source.paths.len()];
@@ -681,8 +682,7 @@ impl OpenCADStudio {
path.flags.set_external(true);
}
}
hatch.is_associative =
path_handles.iter().all(Option::is_some);
hatch.is_associative = path_handles.iter().all(Option::is_some);
}
}
self.tabs[i]