forked from 1b-agent/opencadstudio-upstream
feat(plugin): add CommitMany and CommitManyAndEnd for multi-entity interactive commands
This commit is contained in:
1 parent
358103c1e4
commit
d218ec1451
3 files changed
+26
-3
No files matched your search
@@ -645,8 +645,12 @@ pub enum CommandStep {
|
|||||||
NeedPoint,
|
NeedPoint,
|
||||||
/// Commit an entity to the document and keep collecting points.
|
/// Commit an entity to the document and keep collecting points.
|
||||||
Commit(EntityType),
|
Commit(EntityType),
|
||||||
|
/// Commit multiple entities to the document and keep collecting points.
|
||||||
|
CommitMany(Vec<EntityType>),
|
||||||
/// Commit an entity and end the command.
|
/// Commit an entity and end the command.
|
||||||
CommitAndEnd(EntityType),
|
CommitAndEnd(EntityType),
|
||||||
|
/// Commit multiple entities to the document and end the command.
|
||||||
|
CommitManyAndEnd(Vec<EntityType>),
|
||||||
/// End the command without committing.
|
/// End the command without committing.
|
||||||
Done,
|
Done,
|
||||||
/// Cancel the command.
|
/// Cancel the command.
|
||||||
|
|||||||
@@ -197,6 +197,7 @@ fn handle_host_request(
|
|||||||
CommandStep::Done
|
CommandStep::Done
|
||||||
| CommandStep::Cancel
|
| CommandStep::Cancel
|
||||||
| CommandStep::CommitAndEnd(_)
|
| CommandStep::CommitAndEnd(_)
|
||||||
|
| CommandStep::CommitManyAndEnd(_)
|
||||||
);
|
);
|
||||||
(Ok(s), is_done)
|
(Ok(s), is_done)
|
||||||
}
|
}
|
||||||
@@ -335,6 +336,7 @@ fn handle_host_request_v4(
|
|||||||
CommandStep::Done
|
CommandStep::Done
|
||||||
| CommandStep::Cancel
|
| CommandStep::Cancel
|
||||||
| CommandStep::CommitAndEnd(_)
|
| CommandStep::CommitAndEnd(_)
|
||||||
|
| CommandStep::CommitManyAndEnd(_)
|
||||||
);
|
);
|
||||||
(Ok(s), is_done)
|
(Ok(s), is_done)
|
||||||
}
|
}
|
||||||
|
|||||||
+20
-3
@@ -2797,7 +2797,12 @@ impl crate::command::CadCommand for PluginProcessInteractiveAdapter {
|
|||||||
.interactive_event(self.command_id, InteractiveEvent::Point([pt.x, pt.y, pt.z]))
|
.interactive_event(self.command_id, InteractiveEvent::Point([pt.x, pt.y, pt.z]))
|
||||||
.map(plugin_step_to_result)
|
.map(plugin_step_to_result)
|
||||||
.unwrap_or(crate::command::CmdResult::Cancel);
|
.unwrap_or(crate::command::CmdResult::Cancel);
|
||||||
if matches!(result, crate::command::CmdResult::CommitAndExit(_) | crate::command::CmdResult::Cancel) {
|
if matches!(
|
||||||
|
result,
|
||||||
|
crate::command::CmdResult::CommitAndExit(_)
|
||||||
|
| crate::command::CmdResult::CommitEntitiesAndExit(_)
|
||||||
|
| crate::command::CmdResult::Cancel
|
||||||
|
) {
|
||||||
self.is_done = true;
|
self.is_done = true;
|
||||||
}
|
}
|
||||||
self.refresh();
|
self.refresh();
|
||||||
@@ -2810,7 +2815,12 @@ impl crate::command::CadCommand for PluginProcessInteractiveAdapter {
|
|||||||
.interactive_event(self.command_id, InteractiveEvent::Enter)
|
.interactive_event(self.command_id, InteractiveEvent::Enter)
|
||||||
.map(plugin_step_to_result)
|
.map(plugin_step_to_result)
|
||||||
.unwrap_or(crate::command::CmdResult::Cancel);
|
.unwrap_or(crate::command::CmdResult::Cancel);
|
||||||
if matches!(result, crate::command::CmdResult::CommitAndExit(_) | crate::command::CmdResult::Cancel) {
|
if matches!(
|
||||||
|
result,
|
||||||
|
crate::command::CmdResult::CommitAndExit(_)
|
||||||
|
| crate::command::CmdResult::CommitEntitiesAndExit(_)
|
||||||
|
| crate::command::CmdResult::Cancel
|
||||||
|
) {
|
||||||
self.is_done = true;
|
self.is_done = true;
|
||||||
}
|
}
|
||||||
self.refresh();
|
self.refresh();
|
||||||
@@ -2836,7 +2846,12 @@ impl crate::command::CadCommand for PluginProcessInteractiveAdapter {
|
|||||||
)
|
)
|
||||||
.map(plugin_step_to_result)
|
.map(plugin_step_to_result)
|
||||||
.unwrap_or(crate::command::CmdResult::Cancel);
|
.unwrap_or(crate::command::CmdResult::Cancel);
|
||||||
if matches!(result, crate::command::CmdResult::CommitAndExit(_) | crate::command::CmdResult::Cancel) {
|
if matches!(
|
||||||
|
result,
|
||||||
|
crate::command::CmdResult::CommitAndExit(_)
|
||||||
|
| crate::command::CmdResult::CommitEntitiesAndExit(_)
|
||||||
|
| crate::command::CmdResult::Cancel
|
||||||
|
) {
|
||||||
self.is_done = true;
|
self.is_done = true;
|
||||||
}
|
}
|
||||||
self.refresh();
|
self.refresh();
|
||||||
@@ -2870,7 +2885,9 @@ fn plugin_step_to_result(step: ocs_plugin_api::host::CommandStep) -> crate::comm
|
|||||||
match step {
|
match step {
|
||||||
CommandStep::NeedPoint => CmdResult::NeedPoint,
|
CommandStep::NeedPoint => CmdResult::NeedPoint,
|
||||||
CommandStep::Commit(e) => CmdResult::CommitEntity(e),
|
CommandStep::Commit(e) => CmdResult::CommitEntity(e),
|
||||||
|
CommandStep::CommitMany(es) => CmdResult::CommitEntities(es),
|
||||||
CommandStep::CommitAndEnd(e) => CmdResult::CommitAndExit(e),
|
CommandStep::CommitAndEnd(e) => CmdResult::CommitAndExit(e),
|
||||||
|
CommandStep::CommitManyAndEnd(es) => CmdResult::CommitEntitiesAndExit(es),
|
||||||
CommandStep::Done | CommandStep::Cancel => CmdResult::Cancel,
|
CommandStep::Done | CommandStep::Cancel => CmdResult::Cancel,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user