forked from 1b-agent/opencadstudio-upstream
feat(mline): align creation and editing
This commit is contained in:
commit
343b6cda7d
15 files changed
+2857
-316
No files matched your search
+14
-14
@@ -13,27 +13,27 @@ impl OpenCADStudio {
|
||||
|
||||
"MLINE" => {
|
||||
use crate::modules::draw::draw::mline::MlineCommand;
|
||||
let style_name = self.tabs[i].scene.document.header.multiline_style.clone();
|
||||
let style = self.tabs[i]
|
||||
let header = &self.tabs[i].scene.document.header;
|
||||
let style_name = header.multiline_style.clone();
|
||||
let scale = header.multiline_scale;
|
||||
let justification = header.multiline_justification;
|
||||
let styles = self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.objects
|
||||
.iter()
|
||||
.find_map(|(handle, object)| match object {
|
||||
acadrust::objects::ObjectType::MLineStyle(style)
|
||||
if style.name.eq_ignore_ascii_case(&style_name) =>
|
||||
{
|
||||
Some((*handle, style.elements.len()))
|
||||
.filter_map(|(handle, object)| match object {
|
||||
acadrust::objects::ObjectType::MLineStyle(style) => {
|
||||
Some((*handle, style.clone()))
|
||||
}
|
||||
_ => None,
|
||||
});
|
||||
let (style_handle, element_count) = style
|
||||
.map(|(handle, count)| (Some(handle), count))
|
||||
.unwrap_or((None, 2));
|
||||
let cmd_obj = MlineCommand::with_style(
|
||||
})
|
||||
.collect();
|
||||
let cmd_obj = MlineCommand::with_styles(
|
||||
styles,
|
||||
style_name,
|
||||
style_handle,
|
||||
element_count,
|
||||
scale,
|
||||
justification,
|
||||
);
|
||||
self.command_line.push_info(&cmd_obj.prompt());
|
||||
self.tabs[i].active_cmd = Some(Box::new(cmd_obj));
|
||||
|
||||
@@ -286,6 +286,34 @@ impl OpenCADStudio {
|
||||
self.tabs[i].active_cmd = Some(Box::new(cmd_obj));
|
||||
}
|
||||
|
||||
"MLEDIT" => {
|
||||
use crate::modules::draw::modify::mledit::{
|
||||
MlineEditCommand, MlineEditTarget,
|
||||
};
|
||||
let document = &self.tabs[i].scene.document;
|
||||
let targets = document
|
||||
.entities()
|
||||
.filter_map(|entity| {
|
||||
let acadrust::EntityType::MLine(mline) = entity else {
|
||||
return None;
|
||||
};
|
||||
let style = crate::entities::mline::resolved_mline_style(mline, document)
|
||||
.cloned()
|
||||
.unwrap_or_else(acadrust::objects::MLineStyle::standard);
|
||||
Some((
|
||||
entity.common().handle.value(),
|
||||
MlineEditTarget {
|
||||
entity: mline.clone(),
|
||||
style,
|
||||
},
|
||||
))
|
||||
})
|
||||
.collect();
|
||||
let command = MlineEditCommand::new(targets);
|
||||
self.command_line.push_info(&command.prompt());
|
||||
self.tabs[i].active_cmd = Some(Box::new(command));
|
||||
}
|
||||
|
||||
"SPLINEDIT" => {
|
||||
use crate::modules::draw::modify::splinedit::SplineditCommand;
|
||||
let cmd_obj = SplineditCommand::new();
|
||||
|
||||
@@ -512,6 +512,8 @@ inventory::submit!(crate::command::CommandRegistration {
|
||||
"SHADEDGE",
|
||||
"MAXACTVP",
|
||||
"CMLJUST",
|
||||
"CMLSCALE",
|
||||
"CMLSTYLE",
|
||||
"TEXTQLTY",
|
||||
"SORTENTS",
|
||||
"FRAME",
|
||||
|
||||
@@ -920,6 +920,8 @@ impl OpenCADStudio {
|
||||
| "SHADEDGE"
|
||||
| "MAXACTVP"
|
||||
| "CMLJUST"
|
||||
| "CMLSCALE"
|
||||
| "CMLSTYLE"
|
||||
| "TEXTQLTY"
|
||||
| "SORTENTS"
|
||||
| "FRAME"
|
||||
@@ -1697,17 +1699,35 @@ impl OpenCADStudio {
|
||||
}
|
||||
},
|
||||
"CMLJUST" => match &value {
|
||||
Some(v) => v
|
||||
.parse::<i16>()
|
||||
.map(|x| {
|
||||
Some(v) => match v.parse::<i16>() {
|
||||
Ok(x @ 0..=2) => {
|
||||
h.multiline_justification = x;
|
||||
(format!("CMLJUST = {x}"), true)
|
||||
})
|
||||
.map_err(|_| "SETVAR: integer value required.".into()),
|
||||
Ok((format!("CMLJUST = {x}"), true))
|
||||
}
|
||||
_ => Err("SETVAR: integer value from 0 to 2 required.".into()),
|
||||
},
|
||||
None => {
|
||||
Ok((format!("CMLJUST = {}", h.multiline_justification), false))
|
||||
}
|
||||
},
|
||||
"CMLSCALE" => match &value {
|
||||
Some(v) => match v.parse::<f64>() {
|
||||
Ok(x) if x.is_finite() => {
|
||||
let changed = h.multiline_scale != x;
|
||||
h.multiline_scale = x;
|
||||
Ok((format!("CMLSCALE = {x}"), changed))
|
||||
}
|
||||
_ => Err("SETVAR: finite numeric value required.".into()),
|
||||
},
|
||||
None => Ok((format!("CMLSCALE = {}", h.multiline_scale), false)),
|
||||
},
|
||||
"CMLSTYLE" => match &value {
|
||||
Some(_) => Err(
|
||||
"SETVAR: CMLSTYLE is read-only here — use the MLSTYLE command."
|
||||
.into(),
|
||||
),
|
||||
None => Ok((format!("CMLSTYLE = {}", h.multiline_style), false)),
|
||||
},
|
||||
"TEXTQLTY" => match &value {
|
||||
Some(v) => v
|
||||
.parse::<i16>()
|
||||
|
||||
Reference in new issue
Block a user