forked from 1b-agent/opencadstudio-upstream
fix(offset): the offset just created can be hovered and offset again
A running command only knew the entities that existed when it started; committed results are now handed back to it, and OFFSET adds them to its pick set. Fixes #673 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4c1ddec646
commit
97a5bc1d39
3 files changed
+25
No files matched your search
@@ -62,6 +62,7 @@ impl OpenCADStudio {
|
||||
}
|
||||
if let Some(handle) = committed {
|
||||
self.apply_continuous_constraints(i, &[handle]);
|
||||
self.notify_entities_committed(i, &[handle]);
|
||||
}
|
||||
self.tabs[i].dirty = true;
|
||||
let prompt = self.tabs[i].active_cmd.as_ref().map(|c| c.prompt());
|
||||
@@ -123,6 +124,7 @@ impl OpenCADStudio {
|
||||
committed.extend(handle);
|
||||
}
|
||||
self.apply_continuous_constraints(i, &committed);
|
||||
self.notify_entities_committed(i, &committed);
|
||||
self.tabs[i].dirty = true;
|
||||
self.tabs[i].scene.clear_preview_wire();
|
||||
let prompt = self.tabs[i].active_cmd.as_ref().map(|c| c.prompt());
|
||||
@@ -135,6 +137,18 @@ impl OpenCADStudio {
|
||||
None
|
||||
}
|
||||
|
||||
/// Hand the stored copies of freshly committed entities to the command
|
||||
/// that is still running.
|
||||
fn notify_entities_committed(&mut self, i: usize, handles: &[codec::Handle]) {
|
||||
let entities: Vec<codec::EntityType> = handles
|
||||
.iter()
|
||||
.filter_map(|handle| self.tabs[i].scene.document.get_entity(*handle).cloned())
|
||||
.collect();
|
||||
if let Some(command) = self.tabs[i].active_cmd.as_mut() {
|
||||
command.on_entities_committed(&entities);
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn handle_commit_entities_and_exit(
|
||||
&mut self,
|
||||
mut entities: Vec<codec::EntityType>,
|
||||
|
||||
@@ -2688,6 +2688,12 @@ pub trait CadCommand: Send {
|
||||
/// Commands that stay active across replaces should update their internal snapshots here.
|
||||
fn on_entity_replaced(&mut self, _old: Handle, _new_handles: &[Handle]) {}
|
||||
|
||||
/// Called after `CmdResult::CommitEntity` / `CommitEntities` added
|
||||
/// entities while the command stays active, with the entities as stored
|
||||
/// (fresh handles). Commands that pick from a snapshot add them here so
|
||||
/// their own results can be hovered and picked next. (#673)
|
||||
fn on_entities_committed(&mut self, _entities: &[codec::EntityType]) {}
|
||||
|
||||
/// Called after a PEDIT operation changed its target.
|
||||
fn on_pedit_applied(&mut self) {}
|
||||
|
||||
|
||||
@@ -818,6 +818,11 @@ impl CadCommand for OffsetCommand {
|
||||
}
|
||||
}
|
||||
|
||||
fn on_entities_committed(&mut self, entities: &[EntityType]) {
|
||||
self.all_entities.extend(entities.iter().cloned());
|
||||
self.entity_index = ModifyEntityIndex::build(&self.all_entities);
|
||||
}
|
||||
|
||||
fn on_hover_entity(&mut self, handle: Handle, _pt: DVec3) -> Vec<WireModel> {
|
||||
if handle.is_null() || !matches!(self.step, Step::SelectObject { .. }) {
|
||||
return vec![];
|
||||
|
||||
Reference in new issue
Block a user