forked from 1b-agent/opencadstudio-upstream
Merge pull request #1187 from ramox81/codex/complete-splinedit-options
This commit is contained in:
commit
67768a3eca
5 files changed
+436
-165
No files matched your search
@@ -312,6 +312,33 @@ impl OpenCADStudio {
|
||||
true
|
||||
}
|
||||
|
||||
/// Refresh screen-space feature picking immediately before point dispatch.
|
||||
pub(super) fn refresh_command_point_pick_context(&mut self, i: usize) {
|
||||
if self.tabs[i].active_cmd.as_ref()
|
||||
.is_some_and(|command| command.wants_point_pick_context())
|
||||
{
|
||||
let scene = &self.tabs[i].scene;
|
||||
let size = scene.selection.borrow().vp_size;
|
||||
let edit = scene.viewport_edit_frame(size);
|
||||
let tile = edit.as_ref().map(|(_, rect)| *rect)
|
||||
.unwrap_or_else(|| scene.active_model_tile_bounds(size.0, size.1));
|
||||
let bounds = iced::Rectangle { x: 0.0, y: 0.0, width: tile.width, height: tile.height };
|
||||
let context = if bounds.width > 0.0 && bounds.height > 0.0 {
|
||||
let (view, eye) = if let Some((camera, _)) = edit {
|
||||
(camera.view_proj_rte(bounds), camera.eye())
|
||||
} else {
|
||||
let camera = scene.camera.borrow();
|
||||
(camera.view_proj_rte(bounds), camera.eye())
|
||||
};
|
||||
Some(crate::command::PointPickContext { view, eye, bounds,
|
||||
aperture_px: crate::ui::overlay::pick_box_aperture_px(self.pick_box) })
|
||||
} else { None };
|
||||
if let Some(command) = self.tabs[i].active_cmd.as_mut() {
|
||||
command.set_point_pick_context(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Drive the active command's step machine with one [`StepInput`], then
|
||||
/// apply the result. This is the single entry point every input source
|
||||
/// (command line, headless, dynamic input, plugin API, viewport) funnels
|
||||
@@ -390,10 +417,13 @@ impl OpenCADStudio {
|
||||
}
|
||||
}
|
||||
if let StepInput::SelectionComplete(handles) = &input {
|
||||
let exclude_locked = self.tabs[i].active_cmd.as_ref()
|
||||
.is_some_and(|command| command.selection_entities_exclude_locked());
|
||||
let entities = {
|
||||
let scene = &self.tabs[i].scene;
|
||||
handles
|
||||
.iter()
|
||||
.filter(|handle| !exclude_locked || !scene.is_layer_locked(**handle))
|
||||
.filter_map(|handle| {
|
||||
scene.document.get_entity(*handle).cloned().map(|entity| {
|
||||
let surface_area = scene
|
||||
@@ -414,6 +444,7 @@ impl OpenCADStudio {
|
||||
command.inject_selection_entities(entities);
|
||||
}
|
||||
}
|
||||
if matches!(&input, StepInput::Point(_)) { self.refresh_command_point_pick_context(i); }
|
||||
let ctrl = self.ctrl_down;
|
||||
let shift = self.shift_down;
|
||||
let result: Option<CmdResult> = {
|
||||
|
||||
@@ -329,7 +329,17 @@ impl OpenCADStudio {
|
||||
|
||||
"SPLINEDIT" => {
|
||||
use crate::modules::draw::modify::splinedit::SplineditCommand;
|
||||
let cmd_obj = SplineditCommand::new();
|
||||
let mut cmd_obj = SplineditCommand::new();
|
||||
let selected: Vec<_> = self.tabs[i].scene.selected.iter().copied().collect();
|
||||
if let [handle] = selected.as_slice() {
|
||||
if let Some(entity @ acadrust::EntityType::Spline(_)) =
|
||||
self.tabs[i].scene.document.get_entity(*handle).cloned()
|
||||
{
|
||||
if self.reject_locked_edit(i, *handle) { return Some(Task::none()); }
|
||||
cmd_obj.inject_picked_entity(entity);
|
||||
cmd_obj.on_entity_pick(*handle, glam::DVec3::ZERO);
|
||||
}
|
||||
}
|
||||
self.command_line.push_info(&cmd_obj.prompt());
|
||||
self.tabs[i].active_cmd = Some(Box::new(cmd_obj));
|
||||
}
|
||||
|
||||
@@ -3910,6 +3910,7 @@ impl OpenCADStudio {
|
||||
} else if self.tabs[i].active_cmd.as_ref()
|
||||
.is_some_and(|command| command.entity_pick_accepts_points())
|
||||
{
|
||||
self.refresh_command_point_pick_context(i);
|
||||
self.tabs[i].active_cmd.as_mut().map(|command| command.on_point(pick_wcs))
|
||||
} else if self.tabs[i]
|
||||
.active_cmd
|
||||
@@ -3986,6 +3987,7 @@ impl OpenCADStudio {
|
||||
// (LINE tangent to two circles, which needs both). When
|
||||
// it does, sync last_point to the command's resolved
|
||||
// anchor since it replaced the picked coordinate.
|
||||
self.refresh_command_point_pick_context(i);
|
||||
let handled = self.tabs[i]
|
||||
.active_cmd
|
||||
.as_mut()
|
||||
|
||||
Reference in new issue
Block a user