forked from 1b-agent/opencadstudio-upstream
Merge pull request #1377 from helenkwok/fix/control-accepts-point-with-keywords
Control: a point step that takes keywords accepts points
This commit is contained in:
commit
97596de147
1 file changed
+43
-2
+43
-2
@@ -327,11 +327,18 @@ fn active_command_metadata(command: &dyn crate::command::CadCommand) -> Value {
|
|||||||
accepts.push("entity");
|
accepts.push("entity");
|
||||||
}
|
}
|
||||||
if accepts.is_empty() && !command.needs_tangent_pick() {
|
if accepts.is_empty() && !command.needs_tangent_pick() {
|
||||||
accepts.push(match command.input_kind() {
|
let kind = match command.input_kind() {
|
||||||
InputKind::Point => "point",
|
InputKind::Point => "point",
|
||||||
InputKind::SingleToken => "token",
|
InputKind::SingleToken => "token",
|
||||||
InputKind::FreeText => "text",
|
InputKind::FreeText => "text",
|
||||||
});
|
};
|
||||||
|
// A point step that also takes keyword letters (MOVE/COPY's base
|
||||||
|
// point with [Displacement]) reports SingleToken so the letters reach
|
||||||
|
// the command line, but it still takes a point.
|
||||||
|
if command.point_step_accepts_keywords() && kind != "point" {
|
||||||
|
accepts.push("point");
|
||||||
|
}
|
||||||
|
accepts.push(kind);
|
||||||
}
|
}
|
||||||
if options.iter().any(|option| !option.keyword.is_empty()) && !accepts.contains(&"token") {
|
if options.iter().any(|option| !option.keyword.is_empty()) && !accepts.contains(&"token") {
|
||||||
accepts.push("token");
|
accepts.push("token");
|
||||||
@@ -1491,6 +1498,40 @@ mod tests {
|
|||||||
assert!(app.opening.is_none());
|
assert!(app.opening.is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn point_steps_that_take_keywords_accept_points() {
|
||||||
|
let mut app = OpenCADStudio::new_for_test();
|
||||||
|
request(&mut app, json!({"op":"new"}));
|
||||||
|
request(&mut app, json!({"op":"run","cmd":"CIRCLE 0,0 3"}));
|
||||||
|
request(&mut app, json!({"op":"select","type":"CIRCLE"}));
|
||||||
|
let started = request(&mut app, json!({"op":"start","cmd":"MOVE"}));
|
||||||
|
assert_eq!(started["status"], "waiting_input", "{started}");
|
||||||
|
let command = &started["state"]["command"];
|
||||||
|
let accepts = command["accepts"].as_array().unwrap();
|
||||||
|
assert!(accepts.contains(&json!("point")), "{command}");
|
||||||
|
assert!(accepts.contains(&json!("token")), "{command}");
|
||||||
|
assert_eq!(command["input_example"]["kind"], "point");
|
||||||
|
let base = request(
|
||||||
|
&mut app,
|
||||||
|
json!({"op":"input","kind":"point","point":[0.,0.,0.]}),
|
||||||
|
);
|
||||||
|
assert_eq!(base["status"], "waiting_input", "{base}");
|
||||||
|
let moved = request(
|
||||||
|
&mut app,
|
||||||
|
json!({"op":"input","kind":"point","point":[0.,-10.,0.]}),
|
||||||
|
);
|
||||||
|
assert_eq!(moved["status"], "completed", "{moved}");
|
||||||
|
let circle = app.tabs[app.active_tab]
|
||||||
|
.scene
|
||||||
|
.document
|
||||||
|
.entities()
|
||||||
|
.find_map(|e| match e {
|
||||||
|
acadrust::EntityType::Circle(c) => Some(c.center.y),
|
||||||
|
_ => None,
|
||||||
|
});
|
||||||
|
assert_eq!(circle, Some(-10.0));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn embed_image_op_places_an_ole2frame_and_undoes_it() {
|
fn embed_image_op_places_an_ole2frame_and_undoes_it() {
|
||||||
let mut app = OpenCADStudio::new_for_test();
|
let mut app = OpenCADStudio::new_for_test();
|
||||||
|
|||||||
Reference in new issue
Block a user