Match Smooth connected-endpoint workflow

This commit is contained in:
ramox81 committed 2026-09-17 13:37:25 +03:00
1 parent 7c6665153c
commit dfa75f45b5
4 files changed
+221 -161

No files matched your search

+21 -30
View File
@@ -1213,41 +1213,32 @@ impl OpenCADStudio {
let command = SmoothConstraintCommand::new();
self.command_line.push_info(&command.prompt());
self.tabs[i].active_cmd = Some(Box::new(command));
} else if handles.len() != 2 {
self.tabs[i].scene.deselect_all();
self.command_line.push_error(
"Smooth requires an open spline first and a target curve second.",
);
let command = SmoothConstraintCommand::new();
self.command_line.push_info(&command.prompt());
self.tabs[i].active_cmd = Some(Box::new(command));
} else {
let first = self.tabs[i].scene.document.get_entity(handles[0]);
let second = self.tabs[i].scene.document.get_entity(handles[1]);
let refs = first.zip(second).and_then(|(first, second)| {
SmoothConstraintCommand::preselected_refs(
(first, handles[0]),
(second, handles[1]),
)
});
let Some(refs) = refs else {
let scope = self.tabs[i].current_parametric_scope();
let refs = (handles.len() == 1)
.then(|| {
self.tabs[i]
.scene
.smooth_refs_from_connected_spline(scope, handles[0], None)
})
.flatten();
if let Some(refs) = refs {
use crate::command::CmdResult;
use crate::scene::parametric_constraints::ConstraintKind;
return Some(self.apply_cmd_result(CmdResult::AddParametricConstraint {
kind: ConstraintKind::Smooth,
refs,
driving_param: None,
label: "Smooth constraint",
}));
} else {
self.tabs[i].scene.deselect_all();
self.command_line.push_error(
"Smooth requires an open spline first and a line, arc, polyline segment or open spline second.",
);
self.command_line
.push_error("No valid constraint point found.");
let command = SmoothConstraintCommand::new();
self.command_line.push_info(&command.prompt());
self.tabs[i].active_cmd = Some(Box::new(command));
return None;
};
use crate::command::CmdResult;
use crate::scene::parametric_constraints::ConstraintKind;
return Some(self.apply_cmd_result(CmdResult::AddParametricConstraint {
kind: ConstraintKind::Smooth,
refs,
driving_param: None,
label: "Smooth constraint",
}));
}
}
}