feat: node graph overlay; move to opencadcodec/opencadkernel/opencadgraph

The codec and kernel repositories and crates are renamed opencadcodec and
opencadkernel. Inside OCS they are depended on under short keys, so code
reads `codec::`, `kernel::` and the new `graph::` (opencadgraph, the node
graph engine). File-format and protocol spellings stay as they were: the
ACIS product id `acadrust`, the ACADRUST_* switches and the plugin
version keys `acadrust_version` / `acadrust_source`.

A button left of MCP on the command line opens a translucent node graph
over the viewport, with a palette of object, input, math, logic, list,
text and geometry nodes added by click or drag. An object node owns
drawing entities and its rows are the Properties panel's own rows for
them: the single-object page is extracted from refresh_properties as
entity_property_sections, values use the control protocol's
property_json, and writes go through set_property_value with a property
target override, so the panel, MCP and the graph share one read/write
path. A list reaching an object row makes one entity per element. Each
graph action is one undo step; the canvas pans and zooms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 5.5 committed 2026-09-25 07:34:23 +03:00
1 parent 56c04408d6
commit f537aff75c
430 files changed
+9925 -8540

No files matched your search

+51 -51
View File
@@ -156,11 +156,11 @@ fn err(msg: impl std::fmt::Display) -> Value {
json!({ "ok": false, "error": msg.to_string() })
}
fn v3(v: acadrust::types::Vector3) -> Value {
fn v3(v: codec::types::Vector3) -> Value {
json!([v.x, v.y, v.z])
}
pub(crate) fn entity_type_matches(entity: &acadrust::EntityType, requested: &str) -> bool {
pub(crate) fn entity_type_matches(entity: &codec::EntityType, requested: &str) -> bool {
if crate::entities::names::ui_name(entity).eq_ignore_ascii_case(requested) {
return true;
}
@@ -170,8 +170,8 @@ pub(crate) fn entity_type_matches(entity: &acadrust::EntityType, requested: &str
/// One entity as JSON. Summary mode carries identity only, geometry adds the
/// entity's defining values, and full also includes its world bounds.
pub(crate) fn entity_json(e: &acadrust::EntityType, detail: &str) -> Value {
use acadrust::EntityType as E;
pub(crate) fn entity_json(e: &codec::EntityType, detail: &str) -> Value {
use codec::EntityType as E;
let c = e.common();
let mut obj = json!({
"handle": format!("{:X}", c.handle.value()),
@@ -217,7 +217,7 @@ pub(crate) fn entity_json(e: &acadrust::EntityType, detail: &str) -> Value {
map.insert("value".into(), json!(t.value));
map.insert(
"text".into(),
json!(acadrust::entities::mtext_format::parse_mtext(&t.value, true)
json!(codec::entities::mtext_format::parse_mtext(&t.value, true)
.to_plain_text()),
);
map.insert("position".into(), v3(t.insertion_point));
@@ -252,7 +252,7 @@ pub(crate) fn entity_json(e: &acadrust::EntityType, detail: &str) -> Value {
.edges
.iter()
.filter_map(|edge| match edge {
acadrust::entities::BoundaryEdge::Polyline(polyline) => Some(
codec::entities::BoundaryEdge::Polyline(polyline) => Some(
json!(polyline
.vertices
.iter()
@@ -305,7 +305,7 @@ fn request_point(req: &Value, key: &str) -> Option<[f64; 2]> {
(x.is_finite() && y.is_finite()).then_some([x, y])
}
fn request_handle(value: &Value) -> Option<acadrust::Handle> {
fn request_handle(value: &Value) -> Option<codec::Handle> {
value
.as_str()
.and_then(|value| {
@@ -315,7 +315,7 @@ fn request_handle(value: &Value) -> Option<acadrust::Handle> {
.unwrap_or(value);
u64::from_str_radix(value, 16).ok()
})
.map(acadrust::Handle::new)
.map(codec::Handle::new)
}
fn projected_fields(mut entity: Value, fields: Option<&Vec<Value>>) -> Value {
@@ -330,10 +330,10 @@ fn projected_fields(mut entity: Value, fields: Option<&Vec<Value>>) -> Value {
pub(super) fn requested_save_target(
req: &Value,
default_version: acadrust::DxfVersion,
default_version: codec::DxfVersion,
default_is_dxf: bool,
path: Option<&std::path::Path>,
) -> Result<(acadrust::DxfVersion, bool), String> {
) -> Result<(codec::DxfVersion, bool), String> {
let version = match req["target_version"].as_str() {
Some(value) => crate::io::parse_target_version(value)?,
None => default_version,
@@ -362,7 +362,7 @@ pub(super) fn requested_save_target(
Ok((version, is_dxf))
}
fn document_manifest(document: &acadrust::CadDocument) -> Value {
fn document_manifest(document: &codec::CadDocument) -> Value {
let mut by_type: BTreeMap<String, u64> = BTreeMap::new();
let mut by_layer: BTreeMap<String, u64> = BTreeMap::new();
let mut total = 0u64;
@@ -754,7 +754,7 @@ impl OpenCADStudio {
if let Ok(v) = u64::from_str_radix(h, 16) {
self.tabs[i]
.scene
.select_entity(acadrust::Handle::new(v), false);
.select_entity(codec::Handle::new(v), false);
}
}
}
@@ -762,7 +762,7 @@ impl OpenCADStudio {
let type_filter = req["type"].as_str();
let layer_filter = req["layer"].as_str();
if type_filter.is_some() || layer_filter.is_some() {
let handles: Vec<acadrust::Handle> = self.tabs[i]
let handles: Vec<codec::Handle> = self.tabs[i]
.scene
.document
.entities()
@@ -922,10 +922,10 @@ impl OpenCADStudio {
let Some(second_curve) = crate::entities::curve::entity_curve_xy(second_entity) else {
return err("query intersections second entity is not a planar curve");
};
let crossings = cadkernel::geom2d::intersect(
let crossings = kernel::geom2d::intersect(
&first_curve,
&second_curve,
cadkernel::geom2d::Tolerance::default(),
kernel::geom2d::Tolerance::default(),
);
return json!({
"ok":true,
@@ -1082,10 +1082,10 @@ impl OpenCADStudio {
let Some(curve) = curve.as_ref().filter(|curve| curve.is_closed()) else {
continue;
};
if !cadkernel::geom2d::contains(
if !kernel::geom2d::contains(
std::slice::from_ref(curve),
point,
cadkernel::geom2d::Tolerance::default(),
kernel::geom2d::Tolerance::default(),
) {
continue;
}
@@ -1093,7 +1093,7 @@ impl OpenCADStudio {
let nearest = near.and_then(|point| {
curve
.as_ref()
.map(|curve| cadkernel::geom2d::closest_point(curve, point))
.map(|curve| kernel::geom2d::closest_point(curve, point))
});
if near.is_some() && nearest.is_none() {
continue;
@@ -1185,12 +1185,12 @@ impl OpenCADStudio {
if !seen_handles.insert(common.handle.value()) {
duplicate_handles.insert(format!("{:X}", common.handle.value()));
}
if let acadrust::EntityType::Insert(insert) = entity {
if let codec::EntityType::Insert(insert) = entity {
if !block_names.contains(&insert.block_name.to_ascii_uppercase()) {
missing_blocks.insert(insert.block_name.clone());
}
}
if matches!(entity, acadrust::EntityType::Unknown(_)) {
if matches!(entity, codec::EntityType::Unknown(_)) {
unknown_entities += 1;
}
if let Err(error) = serde_json::to_value(entity) {
@@ -1451,8 +1451,8 @@ mod tests {
#[cfg(not(target_arch = "wasm32"))]
#[test]
fn plugin_edit_publication_is_not_repeated_at_message_boundary() {
use acadrust::entities::Point;
use acadrust::EntityType;
use codec::entities::Point;
use codec::EntityType;
let mut app = super::OpenCADStudio::new_for_test();
app.automation_op(r#"{"op":"new"}"#);
@@ -1525,11 +1525,11 @@ mod tests {
fn explicit_target_version_parser_never_silently_defaults() {
assert_eq!(
crate::io::parse_target_version("R14").unwrap(),
acadrust::DxfVersion::AC1014
codec::DxfVersion::AC1014
);
assert_eq!(
crate::io::parse_target_version("AC1015").unwrap(),
acadrust::DxfVersion::AC1015
codec::DxfVersion::AC1015
);
assert!(crate::io::parse_target_version("R12").is_err());
assert!(crate::io::parse_target_version("future").is_err());
@@ -1590,14 +1590,14 @@ mod tests {
let scene = &mut app.tabs[i].scene;
scene.document.add_layout("Review").unwrap();
scene.set_current_layout("Review".to_string());
let mut viewport = acadrust::entities::Viewport::new();
let mut viewport = codec::entities::Viewport::new();
viewport.id = 2;
viewport.width = 100.0;
viewport.height = 50.0;
viewport.status.is_on = true;
scene.add_entity(acadrust::EntityType::Viewport(viewport));
scene.add_entity(codec::EntityType::Viewport(viewport));
for entity in scene.document.entities_mut() {
if let acadrust::EntityType::Viewport(viewport) = entity {
if let codec::EntityType::Viewport(viewport) = entity {
viewport.status.grid_on = true;
}
}
@@ -1752,7 +1752,7 @@ mod tests {
.document
.entities()
.filter_map(|e| match e {
acadrust::EntityType::Text(t) => Some(t.value.clone()),
codec::EntityType::Text(t) => Some(t.value.clone()),
_ => None,
})
.collect();
@@ -1817,8 +1817,8 @@ mod tests {
#[test]
fn block_reference_query_exposes_instance_attributes() {
use acadrust::entities::{AttributeEntity, EntityType, Insert};
use acadrust::types::Vector3;
use codec::entities::{AttributeEntity, EntityType, Insert};
use codec::types::Vector3;
let mut app = OpenCADStudio::new_for_test();
app.automation_op(r#"{"op":"new"}"#);
@@ -1931,11 +1931,11 @@ mod tests {
let mut app = OpenCADStudio::new_for_test();
app.automation_op(r#"{"op":"new"}"#);
let i = app.active_tab;
let mut line = acadrust::entities::Line::new();
line.start = acadrust::types::Vector3::new(0.0, 0.0, 0.0);
line.end = acadrust::types::Vector3::new(10.0, 0.0, 0.0);
let handle = app.tabs[i].scene.document.add_entity(acadrust::EntityType::Line(line)).unwrap();
let mut br = acadrust::tables::BlockRecord::new("A_CPT");
let mut line = codec::entities::Line::new();
line.start = codec::types::Vector3::new(0.0, 0.0, 0.0);
line.end = codec::types::Vector3::new(10.0, 0.0, 0.0);
let handle = app.tabs[i].scene.document.add_entity(codec::EntityType::Line(line)).unwrap();
let mut br = codec::tables::BlockRecord::new("A_CPT");
br.handle = app.tabs[i].scene.document.allocate_handle();
br.entity_handles = vec![handle];
app.tabs[i].scene.document.block_records.add(br).unwrap();
@@ -2025,11 +2025,11 @@ mod tests {
let mut app = OpenCADStudio::new_for_test();
app.automation_op(r#"{"op":"new"}"#);
let i = app.active_tab;
let mtext = acadrust::MText::with_value(
let mtext = codec::MText::with_value(
"\\A1;10.5000",
acadrust::types::Vector3::new(10.0, 20.0, 0.0),
codec::types::Vector3::new(10.0, 20.0, 0.0),
);
app.tabs[i].scene.add_entity(acadrust::EntityType::MText(mtext));
app.tabs[i].scene.add_entity(codec::EntityType::MText(mtext));
let q = app.automation_op(
r#"{"op":"query","type":"MTEXT","detail":"full","fields":["value","text","height","bounds"]}"#,
@@ -2491,7 +2491,7 @@ mod tests {
.document
.entities()
.find_map(|entity| match entity {
acadrust::EntityType::Line(line) => Some(line),
codec::EntityType::Line(line) => Some(line),
_ => None,
})
.expect("LINE should create one segment");
@@ -2516,7 +2516,7 @@ mod tests {
.document
.entities()
.find_map(|entity| match entity {
acadrust::EntityType::Circle(circle) => Some(circle),
codec::EntityType::Circle(circle) => Some(circle),
_ => None,
})
.expect("CIRCLE should create one entity");
@@ -2772,7 +2772,7 @@ mod tests {
// properties (style, height) to TEXT and MTEXT destinations, not just
// the generic layer/color/linetype set. Regression for #361.
use crate::command::StepInput;
use acadrust::{EntityType, MText, Text};
use codec::{EntityType, MText, Text};
let mut app = OpenCADStudio::new_for_test();
app.automation_op(r#"{"op":"new"}"#);
@@ -2991,10 +2991,10 @@ mod tests {
#[test]
fn open_finalizes_and_purges_like_the_ui_open_path() {
let mut app = OpenCADStudio::new_for_test();
let stale = acadrust::Handle::from(9999);
let stale = codec::Handle::from(9999);
app.tabs[app.active_tab].scene.solid_models.insert(
stale,
cadkernel::brep::make::cuboid([0.0; 3], [1.0; 3]).unwrap(),
kernel::brep::make::cuboid([0.0; 3], [1.0; 3]).unwrap(),
);
let path = std::env::temp_dir().join(format!(
"ocs_automation_finalize_test_{}.dxf",
@@ -3002,16 +3002,16 @@ mod tests {
));
let _ = std::fs::remove_file(&path);
let mut doc = acadrust::CadDocument::new();
let mut good = acadrust::entities::Circle::new();
good.center = acadrust::types::Vector3::new(5.0, 5.0, 0.0);
let mut doc = codec::CadDocument::new();
let mut good = codec::entities::Circle::new();
good.center = codec::types::Vector3::new(5.0, 5.0, 0.0);
good.radius = 2.0;
doc.add_entity(acadrust::EntityType::Circle(good)).unwrap();
let mut corrupt = acadrust::entities::Circle::new();
corrupt.center = acadrust::types::Vector3::new(1.0, 1.0, 0.0);
doc.add_entity(codec::EntityType::Circle(good)).unwrap();
let mut corrupt = codec::entities::Circle::new();
corrupt.center = codec::types::Vector3::new(1.0, 1.0, 0.0);
// An absurd radius is rejected; a zero radius is valid.
corrupt.radius = 1.0e11;
doc.add_entity(acadrust::EntityType::Circle(corrupt))
doc.add_entity(codec::EntityType::Circle(corrupt))
.unwrap();
let bytes = crate::io::save_to_bytes(&doc, "dxf", doc.version)
.expect("save a document containing a corrupt entity");
@@ -3042,7 +3042,7 @@ mod tests {
app.tabs[i].scene.solid_models.insert(
stale,
cadkernel::brep::make::cuboid([0.0; 3], [1.0; 3]).unwrap(),
kernel::brep::make::cuboid([0.0; 3], [1.0; 3]).unwrap(),
);
assert_eq!(app.automation_op(r#"{"op":"new"}"#)["ok"], true);
assert!(app.tabs[i].scene.solid_models.is_empty());