forked from 1b-agent/opencadstudio-upstream
Match ordered tangent constraint behavior
This commit is contained in:
1 parent
1d9fddbdd8
commit
a1e809b61b
7 files changed
+393
-7
No files matched your search
@@ -1345,7 +1345,44 @@ impl OpenCADStudio {
|
||||
self.tabs[i].active_cmd = Some(Box::new(new_cmd));
|
||||
}
|
||||
|
||||
"PCONSTRAINT" | "QCONSTRAINT" | "ECONSTRAINT" | "TCONSTRAINT" | "LCONSTRAINT"
|
||||
"TCONSTRAINT" => {
|
||||
use crate::command::CmdResult;
|
||||
use crate::modules::parametric::TangentConstraintCommand;
|
||||
|
||||
let handles = self.tabs[i].scene.selected_handles_in_order();
|
||||
if handles.is_empty() {
|
||||
let command = TangentConstraintCommand::new();
|
||||
self.command_line.push_info(&command.prompt());
|
||||
self.tabs[i].active_cmd = Some(Box::new(command));
|
||||
} else if handles.len() != 2 {
|
||||
self.command_line
|
||||
.push_output("Select exactly two tangent-compatible objects.");
|
||||
} else {
|
||||
let refs = handles
|
||||
.iter()
|
||||
.filter_map(|handle| {
|
||||
let entity = self.tabs[i].scene.document.get_entity(*handle)?;
|
||||
TangentConstraintCommand::preselected_reference(entity, *handle)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
if refs.len() == 2 {
|
||||
return Some(self.apply_cmd_result(CmdResult::AddTangentConstraint {
|
||||
first: refs[0],
|
||||
second: refs[1],
|
||||
label: "Tangent constraint",
|
||||
}));
|
||||
}
|
||||
self.tabs[i].scene.deselect_all();
|
||||
self.command_line.push_error(
|
||||
"Invalid selection for Tangent. Select a line, polyline segment, circle, arc or ellipse.",
|
||||
);
|
||||
let command = TangentConstraintCommand::new();
|
||||
self.command_line.push_info(&command.prompt());
|
||||
self.tabs[i].active_cmd = Some(Box::new(command));
|
||||
}
|
||||
}
|
||||
|
||||
"PCONSTRAINT" | "QCONSTRAINT" | "ECONSTRAINT" | "LCONSTRAINT"
|
||||
| "NRCONSTRAINT" => {
|
||||
let handles = self.tabs[i].scene.selected_handles_in_order();
|
||||
if handles.is_empty() {
|
||||
@@ -1365,7 +1402,6 @@ impl OpenCADStudio {
|
||||
"QCONSTRAINT" => {
|
||||
(ConstraintKind::Perpendicular, "Perpendicular constraint")
|
||||
}
|
||||
"TCONSTRAINT" => (ConstraintKind::Tangent, "Tangent constraint"),
|
||||
"LCONSTRAINT" => (ConstraintKind::Colinear, "Colinear constraint"),
|
||||
"NRCONSTRAINT" => (ConstraintKind::Normal, "Normal constraint"),
|
||||
_ => (ConstraintKind::Equal, "Equal constraint"),
|
||||
|
||||
Reference in new issue
Block a user