forked from 1b-agent/opencadstudio-upstream
style: apply cargo fmt across workspace
This commit is contained in:
1 parent
85710e5454
commit
9cf9ff2c5c
531 files changed
+57740
-33906
No files matched your search
+49
-46
@@ -38,8 +38,10 @@ impl OpenCADStudio {
|
||||
base: glam::DVec3,
|
||||
) -> usize {
|
||||
// Clone + dep-capture live in the shared kernel; storage stays here.
|
||||
let (entities, deps) =
|
||||
super::super::command_driver::copy_to_clipboard_kernel(&self.tabs[i].scene.document, handles);
|
||||
let (entities, deps) = super::super::command_driver::copy_to_clipboard_kernel(
|
||||
&self.tabs[i].scene.document,
|
||||
handles,
|
||||
);
|
||||
let count = entities.len();
|
||||
self.clipboard_base = base;
|
||||
self.clipboard = entities;
|
||||
@@ -492,7 +494,8 @@ impl OpenCADStudio {
|
||||
// INSERT opens the Blocks palette on the drawing's blocks;
|
||||
// -INSERT runs on the command line.
|
||||
"INSERT" => {
|
||||
self.command_line.push_output("*Insert a block from the Blocks palette");
|
||||
self.command_line
|
||||
.push_output("*Insert a block from the Blocks palette");
|
||||
self.open_blocks_palette(Some(crate::ui::window::block_palette::Tab::Current));
|
||||
}
|
||||
|
||||
@@ -519,7 +522,8 @@ impl OpenCADStudio {
|
||||
cmd if cmd.starts_with("_-INSERTFILE ") => {
|
||||
use crate::command::CadCommand;
|
||||
use crate::modules::insert::insert_block::InsertBlockCommand;
|
||||
let path = std::path::PathBuf::from(cmd["_-INSERTFILE ".len()..].trim().trim_matches('"'));
|
||||
let path =
|
||||
std::path::PathBuf::from(cmd["_-INSERTFILE ".len()..].trim().trim_matches('"'));
|
||||
match self.import_file_as_block(path) {
|
||||
Ok(name) => {
|
||||
let units = self
|
||||
@@ -645,11 +649,10 @@ impl OpenCADStudio {
|
||||
.iter()
|
||||
.any(|a| a.tag.eq_ignore_ascii_case(tag))
|
||||
{
|
||||
ins.attributes
|
||||
.push(codec::entities::AttributeEntity::new(
|
||||
tag.clone(),
|
||||
default.clone(),
|
||||
));
|
||||
ins.attributes.push(codec::entities::AttributeEntity::new(
|
||||
tag.clone(),
|
||||
default.clone(),
|
||||
));
|
||||
}
|
||||
}
|
||||
synced += 1;
|
||||
@@ -702,7 +705,12 @@ impl OpenCADStudio {
|
||||
// A block picked in the ribbon gallery.
|
||||
cmd if cmd.starts_with("_BLOCKINSERT ") => {
|
||||
let name = cmd["_BLOCKINSERT ".len()..].trim().to_string();
|
||||
return Some(self.palette_insert(crate::ui::window::block_palette::Item::Current(name), None));
|
||||
return Some(
|
||||
self.palette_insert(
|
||||
crate::ui::window::block_palette::Item::Current(name),
|
||||
None,
|
||||
),
|
||||
);
|
||||
}
|
||||
cmd if cmd.starts_with("_BLOCKSPALETTE ") => {
|
||||
use crate::ui::window::block_palette::Tab;
|
||||
@@ -737,10 +745,16 @@ impl OpenCADStudio {
|
||||
}
|
||||
// A file named after it skips the picker.
|
||||
cmd if cmd.starts_with("_PDFIMPORTFILE ") => {
|
||||
let path = cmd["_PDFIMPORTFILE ".len()..].trim().trim_matches('"').to_string();
|
||||
let path = cmd["_PDFIMPORTFILE ".len()..]
|
||||
.trim()
|
||||
.trim_matches('"')
|
||||
.to_string();
|
||||
match std::fs::read(&path) {
|
||||
Ok(bytes) => {
|
||||
crate::scene::model::pdf_raster::register_source(&path, std::sync::Arc::new(bytes));
|
||||
crate::scene::model::pdf_raster::register_source(
|
||||
&path,
|
||||
std::sync::Arc::new(bytes),
|
||||
);
|
||||
self.open_pdf_import_file(&path);
|
||||
}
|
||||
Err(_) => self.command_line.push_error(&format!("{path} not found.")),
|
||||
@@ -760,8 +774,11 @@ impl OpenCADStudio {
|
||||
"POINTCLOUDCROP" | "POINTCLOUDUNCROP" => {
|
||||
use crate::command::CadCommand;
|
||||
use crate::modules::insert::pc_crop::PointCloudCropCommand;
|
||||
let command =
|
||||
if cmd == "POINTCLOUDUNCROP" { PointCloudCropCommand::uncrop() } else { PointCloudCropCommand::new() };
|
||||
let command = if cmd == "POINTCLOUDUNCROP" {
|
||||
PointCloudCropCommand::uncrop()
|
||||
} else {
|
||||
PointCloudCropCommand::new()
|
||||
};
|
||||
self.command_line.push_info(&command.prompt());
|
||||
self.tabs[i].active_cmd = Some(Box::new(command));
|
||||
}
|
||||
@@ -810,7 +827,10 @@ impl OpenCADStudio {
|
||||
// PDFATTACH picks the file; -PDFATTACH asks for it on the command
|
||||
// line. A path after either names the file at once.
|
||||
cmd if matches!(
|
||||
cmd.split_whitespace().next().map(|v| v.to_ascii_uppercase()).as_deref(),
|
||||
cmd.split_whitespace()
|
||||
.next()
|
||||
.map(|v| v.to_ascii_uppercase())
|
||||
.as_deref(),
|
||||
Some("PDFATTACH") | Some("-PDFATTACH")
|
||||
) =>
|
||||
{
|
||||
@@ -859,14 +879,12 @@ impl OpenCADStudio {
|
||||
} else {
|
||||
format!("{}/new_block.dwg", default_folder.replace('\\', "/"))
|
||||
};
|
||||
self.wblock = Some(
|
||||
crate::ui::window::wblock::WblockState::new(
|
||||
existing_blocks,
|
||||
handles,
|
||||
default_unit,
|
||||
default_path,
|
||||
),
|
||||
);
|
||||
self.wblock = Some(crate::ui::window::wblock::WblockState::new(
|
||||
existing_blocks,
|
||||
handles,
|
||||
default_unit,
|
||||
default_path,
|
||||
));
|
||||
self.active_modal = Some(crate::app::ModalKind::WriteBlock);
|
||||
}
|
||||
|
||||
@@ -1079,8 +1097,7 @@ impl OpenCADStudio {
|
||||
self.tabs[i].xref_unloaded.remove(key);
|
||||
self.tabs[i].xref_stat_cache.remove(key);
|
||||
}
|
||||
let handles: rustc_hash::FxHashSet<codec::types::Handle> = self.tabs
|
||||
[i]
|
||||
let handles: rustc_hash::FxHashSet<codec::types::Handle> = self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.block_records
|
||||
@@ -1928,12 +1945,8 @@ mod tests {
|
||||
.objects
|
||||
.insert(h, ObjectType::ImageDefinition(def));
|
||||
// Reference it so collect_entries lists it.
|
||||
let mut img = codec::entities::RasterImage::new(
|
||||
"img.png",
|
||||
codec::types::Vector3::ZERO,
|
||||
8.0,
|
||||
8.0,
|
||||
);
|
||||
let mut img =
|
||||
codec::entities::RasterImage::new("img.png", codec::types::Vector3::ZERO, 8.0, 8.0);
|
||||
img.definition_handle = Some(h);
|
||||
app.tabs[i]
|
||||
.scene
|
||||
@@ -1963,12 +1976,8 @@ mod tests {
|
||||
.document
|
||||
.objects
|
||||
.insert(h, ObjectType::ImageDefinition(def));
|
||||
let mut img = codec::entities::RasterImage::new(
|
||||
"img.png",
|
||||
codec::types::Vector3::ZERO,
|
||||
8.0,
|
||||
8.0,
|
||||
);
|
||||
let mut img =
|
||||
codec::entities::RasterImage::new("img.png", codec::types::Vector3::ZERO, 8.0, 8.0);
|
||||
img.definition_handle = Some(h);
|
||||
app.tabs[i]
|
||||
.scene
|
||||
@@ -2069,9 +2078,7 @@ mod tests {
|
||||
.unwrap();
|
||||
let mut line = codec::entities::Line::new();
|
||||
line.common.layer = "WALLS".to_string();
|
||||
xref_doc
|
||||
.add_entity(codec::EntityType::Line(line))
|
||||
.unwrap();
|
||||
xref_doc.add_entity(codec::EntityType::Line(line)).unwrap();
|
||||
let bytes = crate::io::save_to_bytes(&xref_doc, "dwg", xref_doc.version).unwrap();
|
||||
let xref_path = dir.join("plan.dwg");
|
||||
std::fs::write(&xref_path, &bytes).unwrap();
|
||||
@@ -2104,9 +2111,7 @@ mod tests {
|
||||
let mut line = codec::entities::Line::new();
|
||||
line.common.plotstyle_flags = 0b11;
|
||||
line.common.plotstyle_handle = Some(xref_doc.allocate_handle());
|
||||
xref_doc
|
||||
.add_entity(codec::EntityType::Line(line))
|
||||
.unwrap();
|
||||
xref_doc.add_entity(codec::EntityType::Line(line)).unwrap();
|
||||
let bytes = crate::io::save_to_bytes(&xref_doc, "dwg", xref_doc.version).unwrap();
|
||||
let xref_path = dir.join("plan.dwg");
|
||||
std::fs::write(&xref_path, &bytes).unwrap();
|
||||
@@ -2347,9 +2352,7 @@ mod tests {
|
||||
.unwrap();
|
||||
let mut line = codec::entities::Line::new();
|
||||
line.common.layer = "WALLS".to_string();
|
||||
xref_doc
|
||||
.add_entity(codec::EntityType::Line(line))
|
||||
.unwrap();
|
||||
xref_doc.add_entity(codec::EntityType::Line(line)).unwrap();
|
||||
let bytes = crate::io::save_to_bytes(&xref_doc, "dwg", xref_doc.version).unwrap();
|
||||
let xref_path = dir.join("plan.dwg");
|
||||
std::fs::write(&xref_path, &bytes).unwrap();
|
||||
|
||||
Reference in new issue
Block a user