forked from 1b-agent/opencadstudio-upstream
Merge pull request #1201 from Ramox81/codex/parity-revcloud-direct-finish-20260911
This commit is contained in:
commit
109ecdabde
1 file changed
+46
@@ -199,6 +199,12 @@ impl RevCloudCommand {
|
||||
entity.common_mut().handle = Handle::NULL;
|
||||
}
|
||||
}
|
||||
if replacement.is_none()
|
||||
&& matches!(self.creation, CreationMode::Rectangular | CreationMode::Polygonal)
|
||||
{
|
||||
self.message = None;
|
||||
return CmdResult::CommitAndExit(entity);
|
||||
}
|
||||
self.stage = Stage::Reverse(PendingCloud {
|
||||
entity,
|
||||
replacement,
|
||||
@@ -719,6 +725,9 @@ impl CadCommand for RevCloudCommand {
|
||||
return self.on_undo_step();
|
||||
}
|
||||
Stage::Create => match keyword.as_str() {
|
||||
"C" | "CLOSE" if self.creation == CreationMode::Polygonal => {
|
||||
return Some(if self.points.len() >= 3 { self.on_enter() } else { CmdResult::NeedPoint });
|
||||
}
|
||||
"A" | "ARC" | "ARCLENGTH" => self.stage = Stage::ArcLength,
|
||||
"O" | "OBJECT" => {
|
||||
self.stage = Stage::Object;
|
||||
@@ -936,3 +945,40 @@ fn style_from_entity(entity: &EntityType) -> Option<CloudStyle> {
|
||||
inventory::submit!(crate::command::CommandRegistration {
|
||||
names: &["REVCLOUD", "REVCLOUD_RECTANGULAR", "REVCLOUD_POLYGONAL", "REVCLOUD_FREEHAND"]
|
||||
});
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn command(mode: CreationMode) -> RevCloudCommand {
|
||||
let mut command = RevCloudCommand::new(1.0, FxHashMap::default());
|
||||
command.set_creation(mode);
|
||||
command
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rectangular_creation_commits_after_the_opposite_corner() {
|
||||
let mut command = command(CreationMode::Rectangular);
|
||||
assert!(matches!(command.on_point(DVec3::ZERO), CmdResult::NeedPoint));
|
||||
assert!(matches!(
|
||||
command.on_point(DVec3::new(10.0, 5.0, 0.0)),
|
||||
CmdResult::CommitAndExit(_)
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn polygon_close_keyword_commits_three_points() {
|
||||
let mut command = command(CreationMode::Polygonal);
|
||||
for point in [
|
||||
DVec3::ZERO,
|
||||
DVec3::new(10.0, 0.0, 0.0),
|
||||
DVec3::new(10.0, 10.0, 0.0),
|
||||
] {
|
||||
assert!(matches!(command.on_point(point), CmdResult::NeedPoint));
|
||||
}
|
||||
assert!(matches!(
|
||||
command.on_text_input("close"),
|
||||
Some(CmdResult::CommitAndExit(_))
|
||||
));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user