60b9e9d188
* claim: #9686 Co-Authored-By: Claude <noreply@anthropic.com> * Edit Joint: joint.edit takes the two sides joint.edit accepts a and b in the form joint.create takes them (read by the same origin_param), so a joint can move its attachment without being deleted. A side left out keeps its place. The two sides must stay on different occurrences, checked as joint.create does. Limits, values, expressions and the name are kept; a relation's values start again where its parts are. joint.edit gets an input contract and reply type (schema/joints.rs), and leaves schema/unconverted.txt. Co-Authored-By: Claude <noreply@anthropic.com> * Edit Joint shows both sides and picks them again The Edit Joint dialog now shows the two sides in the same selection inputs as Joint, each pre-filled with the face or edge of its own component under the origin. OK sends joint.edit a or b only for a side picked again, so an untouched side keeps its origin exactly. Co-Authored-By: Claude <noreply@anthropic.com> * Edit Joint: a moved side turns the part as joint.create would joint.edit kept the joint's old angle when a side changed, so the part could turn by a half turn about its axis when the new origin's x lay the other way. When a side moves and no angle is given, the angle is worked out again as joint.create does (the least turn from where the part is now); a relation's angle is its tilt and stays. The mechanisms reference says joint.edit takes a and b. Co-Authored-By: Claude <noreply@anthropic.com> * Edit Joint: pre-fill sides by name, send the angle only when changed A side shows the face or edge its snap names, the piece nearest its stored pick when the name has several, else the one nearest that pick; it no longer searches outward from the frame origin, which could show the plate beside a hole for the hole's wall. A point or frame side shows nothing. OK sends the angle only when the user changed it, so a side moved without it turns the part as joint.create would. Co-Authored-By: Claude <noreply@anthropic.com> * Edit Joint: a moved side leaves an angle expression alone (#9686) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
28 lines
1.5 KiB
Rust
28 lines
1.5 KiB
Rust
use serde_json::json;
|
|
|
|
use super::{EditJointParams, EditJointResult};
|
|
use crate::Session;
|
|
use crate::schema::tests::{assert_keys, conforms};
|
|
use crate::schema::{input_schema_for, output_schema_for};
|
|
|
|
#[test]
|
|
fn schemas_and_the_key_check_agree() {
|
|
assert_keys(input_schema_for::<EditJointParams>(), &["a", "angle", "b", "flip", "joint", "name", "offset", "quiet", "suppressed", "type"]);
|
|
}
|
|
|
|
#[test]
|
|
fn replies_match_the_output_schema() {
|
|
let schema = output_schema_for::<EditJointResult>();
|
|
let schema = schema.as_value();
|
|
let mut s = Session::default();
|
|
s.execute("solid.box", &json!({"length": 10, "width": 10, "height": 10})).unwrap_or_else(|e| panic!("{e}"));
|
|
s.execute("component.create", &json!({"name": "B", "grounded": false})).unwrap_or_else(|e| panic!("{e}"));
|
|
s.execute("solid.box", &json!({"length": 10, "width": 10, "height": 10, "corner": [20, 0, 0]})).unwrap_or_else(|e| panic!("{e}"));
|
|
s.execute("joint.create", &json!({"type": "rigid", "name": "Stack", "a": {"face": [5, 5, 10]}, "b": {"face": [25, 5, 0]}}))
|
|
.unwrap_or_else(|e| panic!("{e}"));
|
|
let full = s.execute("joint.edit", &json!({"joint": "Stack", "flip": true})).unwrap_or_else(|e| panic!("{e}"));
|
|
assert!(conforms(schema, schema, &full), "{full} doesn't match {schema}");
|
|
let quiet = s.execute("joint.edit", &json!({"joint": "Stack", "quiet": true})).unwrap_or_else(|e| panic!("{e}"));
|
|
assert!(quiet.get("dof").is_none() && conforms(schema, schema, &quiet), "{quiet}");
|
|
}
|