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

+121 -31
View File
@@ -5,8 +5,8 @@ use super::*;
use crate::io::xref_model::Pathtype;
use crate::modules::insert::pdf_import::{self, PdfFileImport};
use crate::ui::window::pdf_dialogs::{
click_page, item_thumbs, page_thumbs, LayerTarget, PdfAttachState, PdfDialogMsg, PdfImportFileState,
PointCloudAttachState, RotationChoice, UnderlayLayersState,
click_page, item_thumbs, page_thumbs, LayerTarget, PdfAttachState, PdfDialogMsg,
PdfImportFileState, PointCloudAttachState, RotationChoice, UnderlayLayersState,
};
/// "7.8740 × 3.9369" (inches) for a page.
@@ -22,7 +22,13 @@ fn item_size_text(kind: codec::entities::UnderlayType, path: &str, item: &str) -
return page_size_text(path, item);
}
crate::scene::model::underlay_vector::sheet(kind, path, item)
.map(|s| format!("{:.4} × {:.4}", s.rect[2] - s.rect[0], s.rect[3] - s.rect[1]))
.map(|s| {
format!(
"{:.4} × {:.4}",
s.rect[2] - s.rect[0],
s.rect[3] - s.rect[1]
)
})
.unwrap_or_default()
}
@@ -66,7 +72,11 @@ impl OpenCADStudio {
}
/// PDFATTACH / DWFATTACH / DGNATTACH after the file is chosen.
pub(in crate::app) fn open_underlay_attach_dialog(&mut self, kind: codec::entities::UnderlayType, path: &str) {
pub(in crate::app) fn open_underlay_attach_dialog(
&mut self,
kind: codec::entities::UnderlayType,
path: &str,
) {
let i = self.active_tab;
let mut existing: Vec<(String, String)> = Vec::new();
for object in self.tabs[i].scene.document.objects.values() {
@@ -94,7 +104,11 @@ impl OpenCADStudio {
state.selected = vec![0];
state.anchor = 0;
state.found_in = crate::entities::underlay::display_path(path);
let first = state.page_labels().into_iter().next().unwrap_or_else(|| "1".to_string());
let first = state
.page_labels()
.into_iter()
.next()
.unwrap_or_else(|| "1".to_string());
state.page_size = item_size_text(state.kind, path, &first);
state.sub_per_master = sub_per_master(state.kind, path, &first);
state.sub_units = false;
@@ -108,7 +122,14 @@ impl OpenCADStudio {
let Some(cloud) = crate::scene::model::point_cloud::load(path) else {
return;
};
let yes_no = |on: bool| if on { crate::t!("Yes") } else { crate::t!("No") }.into_owned();
let yes_no = |on: bool| {
if on {
crate::t!("Yes")
} else {
crate::t!("No")
}
.into_owned()
};
let data = format!(
"RGB: {} · {}: {} · {}: {}",
yes_no(cloud.has_rgb),
@@ -124,14 +145,28 @@ impl OpenCADStudio {
crate::t!("Segmentation"),
yes_no(false),
);
let factor = crate::app::properties::insert_unit_scale(self.tabs[self.active_tab].scene.document.header.insertion_units, 6)
.unwrap_or(1.0);
let factor = crate::app::properties::insert_unit_scale(
self.tabs[self.active_tab]
.scene
.document
.header
.insertion_units,
6,
)
.unwrap_or(1.0);
let full = path.to_string_lossy().into_owned();
let memory = crate::ui::window::pdf_dialogs::ATTACH_MEMORY.lock().ok().and_then(|m| m.clone()).unwrap_or_default();
let memory = crate::ui::window::pdf_dialogs::ATTACH_MEMORY
.lock()
.ok()
.and_then(|m| m.clone())
.unwrap_or_default();
let mut state = PointCloudAttachState {
path: full.clone(),
name: file_stem(&full),
preview: cloud.preview.clone().map(iced::widget::image::Handle::from_bytes),
preview: cloud
.preview
.clone()
.map(iced::widget::image::Handle::from_bytes),
summary: format!(
"{} · {}",
crate::tf!("{count} scans", count = cloud.scans),
@@ -141,9 +176,21 @@ impl OpenCADStudio {
data_more,
size: cloud
.bounds
.map(|[lo, hi]| format!("{:.4} × {:.4} × {:.4}", hi[0] - lo[0], hi[1] - lo[1], hi[2] - lo[2]))
.map(|[lo, hi]| {
format!(
"{:.4} × {:.4} × {:.4}",
hi[0] - lo[0],
hi[1] - lo[1],
hi[2] - lo[2]
)
})
.unwrap_or_default(),
unit: format!("{} · {} {}", crate::t!("Meters"), crate::t!("Unit factor"), crate::app::properties::format_unit_factor(factor)),
unit: format!(
"{} · {} {}",
crate::t!("Meters"),
crate::t!("Unit factor"),
crate::app::properties::format_unit_factor(factor)
),
found_in: crate::entities::underlay::display_path(&full),
saved_path: String::new(),
path_type: memory.path_type,
@@ -156,7 +203,9 @@ impl OpenCADStudio {
lock: false,
zoom: true,
};
state.saved_path = crate::entities::underlay::display_path(&self.pdf_stored_path(&full, state.path_type.0));
state.saved_path = crate::entities::underlay::display_path(
&self.pdf_stored_path(&full, state.path_type.0),
);
self.point_cloud_attach = Some(state);
self.active_modal = Some(crate::app::ModalKind::PointCloudAttach);
}
@@ -172,7 +221,11 @@ impl OpenCADStudio {
let insertion = if state.insert_on_screen {
None
} else {
match (number(&state.insert[0]), number(&state.insert[1]), number(&state.insert[2])) {
match (
number(&state.insert[0]),
number(&state.insert[1]),
number(&state.insert[2]),
) {
(Some(x), Some(y), Some(z)) => Some(glam::DVec3::new(x, y, z)),
_ => {
self.command_line.push_error("Requires numeric value.");
@@ -186,7 +239,8 @@ impl OpenCADStudio {
match number(&state.scale).filter(|v| *v > 0.0) {
Some(v) => Some(v),
None => {
self.command_line.push_error("Value must be positive and nonzero.");
self.command_line
.push_error("Value must be positive and nonzero.");
return Task::none();
}
}
@@ -258,10 +312,12 @@ impl OpenCADStudio {
name = format!("{name} ({})", same + 1);
}
let mut layers: Vec<String> = match u.underlay_type {
codec::entities::UnderlayType::Pdf => crate::scene::model::pdf_layers::layers(&def.file_path)
.into_iter()
.map(|l| l.name)
.collect(),
codec::entities::UnderlayType::Pdf => {
crate::scene::model::pdf_layers::layers(&def.file_path)
.into_iter()
.map(|l| l.name)
.collect()
}
kind => crate::scene::model::underlay_vector::layer_names(kind, &def.file_path),
};
layers.sort_by_key(|n| n.to_lowercase());
@@ -313,7 +369,9 @@ impl OpenCADStudio {
/// Writes the layers each underlay turns off, as one undo step.
fn apply_underlay_layers(&mut self, i: usize, targets: Vec<LayerTarget>) {
use crate::scene::model::pdf_layers::{hidden_layers, DGN_OVERRIDE_PLACEHOLDER, LAYER_OVERRIDE_APP};
use crate::scene::model::pdf_layers::{
hidden_layers, DGN_OVERRIDE_PLACEHOLDER, LAYER_OVERRIDE_APP,
};
let changed: Vec<LayerTarget> = targets
.into_iter()
.filter(|t| match self.tabs[i].scene.document.get_entity(t.handle) {
@@ -345,7 +403,9 @@ impl OpenCADStudio {
let mut record = codec::xdata::ExtendedDataRecord::new(LAYER_OVERRIDE_APP);
// A DGN underlay's names follow a placeholder string.
if u.underlay_type == codec::entities::UnderlayType::Dgn {
record.add_value(codec::xdata::XDataValue::String(DGN_OVERRIDE_PLACEHOLDER.to_string()));
record.add_value(codec::xdata::XDataValue::String(
DGN_OVERRIDE_PLACEHOLDER.to_string(),
));
}
for name in &target.hidden {
record.add_value(codec::xdata::XDataValue::String(name.clone()));
@@ -394,7 +454,11 @@ impl OpenCADStudio {
// ── Attach ────────────────────────────────────────────────────
PdfDialogMsg::AttachBrowse => {
let kind = self.pdf_attach.as_ref().map(|s| s.kind).unwrap_or(codec::entities::UnderlayType::Pdf);
let kind = self
.pdf_attach
.as_ref()
.map(|s| s.kind)
.unwrap_or(codec::entities::UnderlayType::Pdf);
if let Some(state) = &self.pdf_attach {
state.remember();
}
@@ -407,7 +471,11 @@ impl OpenCADStudio {
if let Some(s) = self.pdf_attach.as_mut() {
s.sub_units = sub;
// The scale offered follows the units, as on the command line.
s.scale = if sub { format!("{}", 1.0 / s.sub_per_master) } else { "1.0000".to_string() };
s.scale = if sub {
format!("{}", 1.0 / s.sub_per_master)
} else {
"1.0000".to_string()
};
}
}
PdfDialogMsg::AttachName(name) => {
@@ -517,7 +585,10 @@ impl OpenCADStudio {
| PdfDialogMsg::SecPreview(_)
| PdfDialogMsg::SecCreate) => return self.update_pc_section(message),
PdfDialogMsg::CloudPathType(choice) => {
let stored = self.point_cloud_attach.as_ref().map(|s| self.pdf_stored_path(&s.path, choice.0));
let stored = self
.point_cloud_attach
.as_ref()
.map(|s| self.pdf_stored_path(&s.path, choice.0));
if let (Some(s), Some(stored)) = (self.point_cloud_attach.as_mut(), stored) {
s.path_type = choice;
s.saved_path = crate::entities::underlay::display_path(&stored);
@@ -648,7 +719,12 @@ impl OpenCADStudio {
}
PdfDialogMsg::ImportPageText(text) => {
if let Some(s) = self.pdf_import_file.as_mut() {
if let Some(n) = text.trim().parse::<usize>().ok().filter(|n| (1..=s.pages.len()).contains(n)) {
if let Some(n) = text
.trim()
.parse::<usize>()
.ok()
.filter(|n| (1..=s.pages.len()).contains(n))
{
s.selected = n - 1;
s.page_size = page_size_mm(&s.path, &n.to_string());
}
@@ -674,8 +750,10 @@ impl OpenCADStudio {
let Some(state) = self.pdf_import_file.as_ref() else {
return Task::none();
};
let Some(scale) = state.scale.trim().parse::<f64>().ok().filter(|v| *v > 0.0) else {
self.command_line.push_error("Value must be positive and nonzero.");
let Some(scale) = state.scale.trim().parse::<f64>().ok().filter(|v| *v > 0.0)
else {
self.command_line
.push_error("Value must be positive and nonzero.");
return Task::none();
};
let state = self.pdf_import_file.take().expect("checked above");
@@ -695,7 +773,10 @@ impl OpenCADStudio {
self.tabs[i].active_cmd = Some(Box::new(command));
return self.focus_cmd_input();
}
self.run_pdf_import(i, crate::app::commands::pdf_import::PdfImportSource::File(import));
self.run_pdf_import(
i,
crate::app::commands::pdf_import::PdfImportSource::File(import),
);
}
}
Task::none()
@@ -710,7 +791,11 @@ impl OpenCADStudio {
let insertion = if state.insert_on_screen {
None
} else {
match (number(&state.insert[0]), number(&state.insert[1]), number(&state.insert[2])) {
match (
number(&state.insert[0]),
number(&state.insert[1]),
number(&state.insert[2]),
) {
(Some(x), Some(y), Some(z)) => Some(glam::DVec3::new(x, y, z)),
_ => {
self.command_line.push_error("Requires numeric value.");
@@ -724,7 +809,8 @@ impl OpenCADStudio {
match number(&state.scale).filter(|v| *v > 0.0) {
Some(v) => Some(v),
None => {
self.command_line.push_error("Value must be positive and nonzero.");
self.command_line
.push_error("Value must be positive and nonzero.");
return Task::none();
}
}
@@ -766,7 +852,11 @@ impl OpenCADStudio {
self.tabs[i].active_cmd = Some(Box::new(command));
if matches!(result, crate::command::CmdResult::NeedPoint) {
self.command_line.push_info(
&self.tabs[i].active_cmd.as_ref().map(|c| c.prompt()).unwrap_or_default(),
&self.tabs[i]
.active_cmd
.as_ref()
.map(|c| c.prompt())
.unwrap_or_default(),
);
return self.focus_cmd_input();
}