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
@@ -57,7 +57,11 @@ impl CountCommand {
|
||||
|
||||
/// COUNT whose area is already answered (`COUNT _C`).
|
||||
pub fn with_area(area: &str) -> Self {
|
||||
Self { area: area.to_string(), step: Step::Targets, ..Self::new(false) }
|
||||
Self {
|
||||
area: area.to_string(),
|
||||
step: Step::Targets,
|
||||
..Self::new(false)
|
||||
}
|
||||
}
|
||||
|
||||
fn area_done(&mut self, area: String) -> CmdResult {
|
||||
@@ -70,7 +74,12 @@ impl CountCommand {
|
||||
}
|
||||
|
||||
fn area_keyword(&mut self, text: &str) -> CmdResult {
|
||||
match text.trim().trim_start_matches('_').to_ascii_uppercase().as_str() {
|
||||
match text
|
||||
.trim()
|
||||
.trim_start_matches('_')
|
||||
.to_ascii_uppercase()
|
||||
.as_str()
|
||||
{
|
||||
"" | "C" | "CURRENT" | "CURRENT AREA" => self.area_done("C".into()),
|
||||
"E" | "ENTIRE" | "ENTIRE MODEL SPACE" => self.area_done("E".into()),
|
||||
"O" | "OBJECT" => {
|
||||
@@ -90,7 +99,11 @@ impl CountCommand {
|
||||
if self.targets.is_empty() {
|
||||
return CmdResult::Dispatch(format!("_COUNTRUN {} L", self.area));
|
||||
}
|
||||
let handles: Vec<String> = self.targets.iter().map(|h| format!("{:X}", h.value())).collect();
|
||||
let handles: Vec<String> = self
|
||||
.targets
|
||||
.iter()
|
||||
.map(|h| format!("{:X}", h.value()))
|
||||
.collect();
|
||||
CmdResult::Dispatch(format!("_COUNTRUN {} T {}", self.area, handles.join(",")))
|
||||
}
|
||||
}
|
||||
@@ -207,7 +220,12 @@ impl CadCommand for CountCommand {
|
||||
fn on_text_input(&mut self, text: &str) -> Option<CmdResult> {
|
||||
match self.step {
|
||||
Step::Area => Some(self.area_keyword(text)),
|
||||
Step::Targets => match text.trim().trim_start_matches('_').to_ascii_uppercase().as_str() {
|
||||
Step::Targets => match text
|
||||
.trim()
|
||||
.trim_start_matches('_')
|
||||
.to_ascii_uppercase()
|
||||
.as_str()
|
||||
{
|
||||
"L" | "LIST" | "LIST ALL BLOCKS" => {
|
||||
self.targets.clear();
|
||||
Some(self.finish_targets())
|
||||
@@ -235,7 +253,12 @@ impl CadCommand for CountCommand {
|
||||
let ring: Vec<DVec3> = match self.step {
|
||||
Step::Corner => {
|
||||
let a = self.points[0];
|
||||
vec![a, DVec3::new(pt.x, a.y, a.z), pt, DVec3::new(a.x, pt.y, a.z)]
|
||||
vec![
|
||||
a,
|
||||
DVec3::new(pt.x, a.y, a.z),
|
||||
pt,
|
||||
DVec3::new(a.x, pt.y, a.z),
|
||||
]
|
||||
}
|
||||
Step::PolyNext => {
|
||||
let mut ring = self.points.clone();
|
||||
@@ -246,7 +269,12 @@ impl CadCommand for CountCommand {
|
||||
};
|
||||
let mut points: Vec<[f64; 3]> = ring.iter().map(|p| p.to_array()).collect();
|
||||
points.push(points[0]);
|
||||
Some(WireModel::solid_f64("count_area".into(), points, WireModel::CYAN, false))
|
||||
Some(WireModel::solid_f64(
|
||||
"count_area".into(),
|
||||
points,
|
||||
WireModel::CYAN,
|
||||
false,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,27 +300,51 @@ enum TableStep {
|
||||
|
||||
impl CountTableCommand {
|
||||
pub fn new(blocks: Vec<String>, others: [usize; 3]) -> Self {
|
||||
Self { step: TableStep::Names, blocks, others, names: Vec::new(), pending: Vec::new() }
|
||||
Self {
|
||||
step: TableStep::Names,
|
||||
blocks,
|
||||
others,
|
||||
names: Vec::new(),
|
||||
pending: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
/// The palette's Create Table: the blocks are chosen, only the point is asked.
|
||||
pub fn placing(names: Vec<String>) -> Self {
|
||||
Self { step: TableStep::Point, blocks: Vec::new(), others: [0; 3], names, pending: Vec::new() }
|
||||
Self {
|
||||
step: TableStep::Point,
|
||||
blocks: Vec::new(),
|
||||
others: [0; 3],
|
||||
names,
|
||||
pending: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
/// `?`: the defined blocks matching the pattern, paged by 22 lines
|
||||
/// (`Press ENTER to continue:` in between), then the summary.
|
||||
fn listing(&mut self, pattern: &str) -> CmdResult {
|
||||
let pattern = if pattern.trim().is_empty() { "*" } else { pattern.trim() };
|
||||
let pattern = if pattern.trim().is_empty() {
|
||||
"*"
|
||||
} else {
|
||||
pattern.trim()
|
||||
};
|
||||
let mut names: Vec<&String> = self
|
||||
.blocks
|
||||
.iter()
|
||||
.filter(|name| pattern.split(',').any(|p| crate::io::xref_model::wildcard_match(name, p.trim())))
|
||||
.filter(|name| {
|
||||
pattern
|
||||
.split(',')
|
||||
.any(|p| crate::io::xref_model::wildcard_match(name, p.trim()))
|
||||
})
|
||||
.collect();
|
||||
names.sort_by_key(|name| list_order(name));
|
||||
self.pending = std::iter::once(String::new())
|
||||
.chain(std::iter::once("Defined blocks.".to_string()))
|
||||
.chain(names.iter().map(|name| format!(" {:<31}", format!("\"{name}\""))))
|
||||
.chain(
|
||||
names
|
||||
.iter()
|
||||
.map(|name| format!(" {:<31}", format!("\"{name}\""))),
|
||||
)
|
||||
.collect();
|
||||
self.next_page()
|
||||
}
|
||||
@@ -388,7 +440,13 @@ impl CadCommand for CountTableCommand {
|
||||
if self.step != TableStep::Point {
|
||||
return CmdResult::NeedPoint;
|
||||
}
|
||||
CmdResult::Dispatch(format!("_COUNTTABLEPLACE {:?},{:?},{:?} {}", pt.x, pt.y, pt.z, self.names.join("|")))
|
||||
CmdResult::Dispatch(format!(
|
||||
"_COUNTTABLEPLACE {:?},{:?},{:?} {}",
|
||||
pt.x,
|
||||
pt.y,
|
||||
pt.z,
|
||||
self.names.join("|")
|
||||
))
|
||||
}
|
||||
|
||||
fn on_enter(&mut self) -> CmdResult {
|
||||
@@ -407,7 +465,9 @@ pub struct UpdateFieldCommand {
|
||||
|
||||
impl UpdateFieldCommand {
|
||||
pub fn new() -> Self {
|
||||
Self { selected: Vec::new() }
|
||||
Self {
|
||||
selected: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -435,11 +495,24 @@ impl CadCommand for UpdateFieldCommand {
|
||||
|
||||
fn on_enter(&mut self) -> CmdResult {
|
||||
// An empty selection still runs (the reference keeps an undo step).
|
||||
let handles: Vec<String> = self.selected.iter().map(|h| format!("{:X}", h.value())).collect();
|
||||
let handles: Vec<String> = self
|
||||
.selected
|
||||
.iter()
|
||||
.map(|h| format!("{:X}", h.value()))
|
||||
.collect();
|
||||
CmdResult::Dispatch(format!("_UPDATEFIELDRUN {}", handles.join(",")))
|
||||
}
|
||||
}
|
||||
|
||||
inventory::submit!(crate::command::CommandRegistration {
|
||||
names: &["COUNT", "COUNTAREA", "COUNTCLOSE", "COUNTFIELD", "COUNTLIST", "COUNTLISTCLOSE", "COUNTTABLE", "UPDATEFIELD"]
|
||||
names: &[
|
||||
"COUNT",
|
||||
"COUNTAREA",
|
||||
"COUNTCLOSE",
|
||||
"COUNTFIELD",
|
||||
"COUNTLIST",
|
||||
"COUNTLISTCLOSE",
|
||||
"COUNTTABLE",
|
||||
"UPDATEFIELD"
|
||||
]
|
||||
});
|
||||
Reference in new issue
Block a user