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

+9 -9
View File
@@ -1,5 +1,5 @@
use crate::t;
use acadrust::Handle;
use codec::Handle;
use glam::DVec3;
use crate::command::{CadCommand, CmdResult};
@@ -205,15 +205,15 @@ mod tests {
use super::*;
use crate::scene::{CreateBlockOptions, Scene};
use crate::ui::window::block_definition::BlockObjectMode;
use acadrust::entities::Line;
use acadrust::types::{Transform, Vector3};
use codec::entities::Line;
use codec::types::{Transform, Vector3};
fn make_test_scene() -> (Scene, Handle) {
let mut scene = Scene::new();
let mut line = Line::new();
line.start = Vector3::new(0.0, 0.0, 0.0);
line.end = Vector3::new(10.0, 10.0, 0.0);
let h = scene.add_entity(acadrust::EntityType::Line(line));
let h = scene.add_entity(codec::EntityType::Line(line));
(scene, h)
}
@@ -279,7 +279,7 @@ mod tests {
// Insert entity exists in drawing
let insert_entity = scene.document.get_entity(insert_h);
assert!(insert_entity.is_some());
if let Some(acadrust::EntityType::Insert(ins)) = insert_entity {
if let Some(codec::EntityType::Insert(ins)) = insert_entity {
assert_eq!(ins.block_name, "BLK_CONVERT");
} else {
panic!("Expected Insert entity");
@@ -352,7 +352,7 @@ mod tests {
let mut line2 = Line::new();
line2.start = Vector3::new(5.0, 5.0, 0.0);
line2.end = Vector3::new(15.0, 15.0, 0.0);
scene.add_entity(acadrust::EntityType::Line(line2))
scene.add_entity(codec::EntityType::Line(line2))
};
let options2 = CreateBlockOptions {
@@ -560,7 +560,7 @@ mod tests {
// In Convert mode, the insert entity must be placed at the picked base point
let insert_entity = scene.document.get_entity(insert_h).unwrap();
if let acadrust::EntityType::Insert(ins) = insert_entity {
if let codec::EntityType::Insert(ins) = insert_entity {
assert_eq!(ins.block_name, "ON_SCREEN_BASE_TEST");
assert!((ins.insert_point.x - 10.0).abs() < 1e-6);
assert!((ins.insert_point.y - 10.0).abs() < 1e-6);
@@ -580,10 +580,10 @@ mod tests {
.document
.entities()
.find(|e| {
e.common().owner_handle == br.handle && matches!(e, acadrust::EntityType::Line(_))
e.common().owner_handle == br.handle && matches!(e, codec::EntityType::Line(_))
})
.unwrap();
if let acadrust::EntityType::Line(l) = block_line {
if let codec::EntityType::Line(l) = block_line {
assert!((l.start.x - (-10.0)).abs() < 1e-6);
assert!((l.start.y - (-10.0)).abs() < 1e-6);
assert!((l.end.x - 0.0).abs() < 1e-6);
+5 -5
View File
@@ -1,6 +1,6 @@
use acadrust::entities::{AttributeDefinition, AttributeEntity, Entity, Insert};
use acadrust::types::Vector3;
use acadrust::EntityType;
use codec::entities::{AttributeDefinition, AttributeEntity, Entity, Insert};
use codec::types::Vector3;
use codec::EntityType;
use glam::{DVec3, Vec3};
use crate::t;
@@ -341,7 +341,7 @@ impl CadCommand for InsertBlockCommand {
fn attreq_set_attdefs(
&mut self,
attdefs: Vec<AttributeDefinition>,
) -> Option<acadrust::EntityType> {
) -> Option<codec::EntityType> {
self.step = Step::FillAttr {
attdefs,
idx: 0,
@@ -350,7 +350,7 @@ impl CadCommand for InsertBlockCommand {
self.advance_automatic_attributes()
}
fn attreq_take_insert(&mut self) -> Option<acadrust::EntityType> {
fn attreq_take_insert(&mut self) -> Option<codec::EntityType> {
self.pending_insert
.take()
.map(|ins| EntityType::Insert(ins))
+3 -3
View File
@@ -6,9 +6,9 @@
//! entity is a single [`Insert`] with its array fields set, which the renderer
//! replicates over `row_count × column_count` using the row/column spacing.
use acadrust::entities::Insert;
use acadrust::types::Vector3;
use acadrust::EntityType;
use codec::entities::Insert;
use codec::types::Vector3;
use codec::EntityType;
use glam::DVec3;
use crate::t;
+5 -5
View File
@@ -13,10 +13,10 @@
use std::sync::Mutex;
use acadrust::entities::{Underlay, UnderlayDisplayFlags};
use acadrust::objects::{Dictionary, ObjectType, UnderlayDefinition};
use acadrust::types::{Handle, Vector3};
use acadrust::{CadDocument, EntityType};
use codec::entities::{Underlay, UnderlayDisplayFlags};
use codec::objects::{Dictionary, ObjectType, UnderlayDefinition};
use codec::types::{Handle, Vector3};
use codec::{CadDocument, EntityType};
use glam::DVec3;
use crate::command::{CadCommand, CmdOption, CmdResult, InputKind, WorkingPlane};
@@ -493,7 +493,7 @@ fn same_path(a: &str, b: &str) -> bool {
pub fn ensure_pdf_definition(document: &mut CadDocument, path: &str, page: &str) -> Handle {
let existing = document.objects.iter().find_map(|(handle, object)| match object {
ObjectType::UnderlayDefinition(def)
if matches!(def.underlay_type, acadrust::entities::UnderlayType::Pdf)
if matches!(def.underlay_type, codec::entities::UnderlayType::Pdf)
&& same_path(&def.file_path, path)
&& crate::entities::underlay::page_of(def) == page =>
{
+3 -3
View File
@@ -11,9 +11,9 @@
// The boundary is stored in underlay units; the clip-inside bit follows the
// Invert choice.
use acadrust::entities::{Underlay, UnderlayDisplayFlags, UnderlayType};
use acadrust::types::{Handle, Vector2};
use acadrust::EntityType;
use codec::entities::{Underlay, UnderlayDisplayFlags, UnderlayType};
use codec::types::{Handle, Vector2};
use codec::EntityType;
use glam::DVec3;
use crate::command::{CadCommand, CmdOption, CmdResult, InputKind};
+4 -4
View File
@@ -14,12 +14,12 @@
// (other fills solid hatches), text runs MTEXT in a "PDF <font>" style and
// raster images PNG files referenced by IMAGE objects.
use acadrust::entities::{
use codec::entities::{
AttachmentPoint, BoundaryEdge, BoundaryPath, Circle, Hatch, LwPolyline, MText, PolylineEdge,
Solid, Spline, Underlay, UnderlayType,
};
use acadrust::types::{Color, Handle, LineWeight, Vector2, Vector3};
use acadrust::EntityType;
use codec::types::{Color, Handle, LineWeight, Vector2, Vector3};
use codec::EntityType;
use glam::DVec3;
use crate::command::{CadCommand, CmdOption, CmdResult, InputKind};
@@ -746,7 +746,7 @@ pub fn convert(
color
}
};
let fill_transparency = acadrust::types::Transparency::from_alpha_value(0x0200_007F);
let fill_transparency = codec::types::Transparency::from_alpha_value(0x0200_007F);
let mut strokes: Vec<Stroke> = Vec::new();
let mut curves: Vec<EntityType> = Vec::new();
+18 -18
View File
@@ -2,7 +2,7 @@
use std::sync::{Mutex, OnceLock};
use acadrust::{entities::Solid3D, EntityType, Handle};
use codec::{entities::Solid3D, EntityType, Handle};
use glam::DVec3;
use crate::command::{
@@ -166,16 +166,16 @@ impl ExtrudeCommand {
}
fn preview_body_wires(
body: &cadkernel::brep::Body,
body: &kernel::brep::Body,
color: [f32; 4],
isolines: usize,
) -> Vec<WireModel> {
// This overlay only consumes curves. Do not triangulate the body's faces
// on every cursor event just to discard the resulting surface mesh.
let wireframe = cadkernel::brep::mesh::tessellate_wireframe(
let wireframe = kernel::brep::mesh::tessellate_wireframe(
body,
cadkernel::brep::mesh::TessellationTolerance::new(
cadkernel::tessellation::DEFAULT_ANGLE,
kernel::brep::mesh::TessellationTolerance::new(
kernel::tessellation::DEFAULT_ANGLE,
1e-9,
)
.with_isolines(isolines),
@@ -899,12 +899,12 @@ impl CadCommand for PresspullCommand {
crate::scene::model::presspull_model::profile_geometry(&entity)
.map(|(plane, loops, _)| (plane, loops)),
PresspullTargetKind::Face { body, face, .. } =>
cadkernel::brep::planar_face_profile(&body, face)
kernel::brep::planar_face_profile(&body, face)
.map(|profile| (profile.plane, profile.loops)),
};
if let Some((plane, loops)) = geometry {
self.hover_cache = loops.into_iter().flatten().filter_map(|curve| {
let points = curve.tessellate_angle(cadkernel::tessellation::DEFAULT_ANGLE)
let points = curve.tessellate_angle(kernel::tessellation::DEFAULT_ANGLE)
.into_iter().map(|point| plane.point_at(point)).collect::<Vec<_>>();
(points.len() >= 2).then(|| {
let mut wire = WireModel::solid_f64(
@@ -918,7 +918,7 @@ impl CadCommand for PresspullCommand {
self.hover_cache.clone()
}
fn on_entity_pick(&mut self, handle: acadrust::Handle, point: DVec3) -> CmdResult {
fn on_entity_pick(&mut self, handle: codec::Handle, point: DVec3) -> CmdResult {
if !self.needs_entity_pick() {
return CmdResult::NeedPoint;
}
@@ -1278,7 +1278,7 @@ impl RevolveCommand {
}
fn revolve_axis(entity: &EntityType) -> Option<(DVec3, DVec3)> {
let point = |value: &acadrust::types::Vector3| DVec3::new(value.x, value.y, value.z);
let point = |value: &codec::types::Vector3| DVec3::new(value.x, value.y, value.z);
let (start, direction) = match entity {
EntityType::Line(line) => (point(&line.start), point(&line.end) - point(&line.start)),
EntityType::Ray(ray) => (point(&ray.base_point), point(&ray.direction)),
@@ -1346,7 +1346,7 @@ impl CadCommand for RevolveCommand {
fn needs_entity_pick(&self) -> bool {
self.step == RevolveStep::AxisObject
}
fn on_entity_pick(&mut self, handle: acadrust::Handle, _pt: DVec3) -> CmdResult {
fn on_entity_pick(&mut self, handle: codec::Handle, _pt: DVec3) -> CmdResult {
if handle.is_null() {
return CmdResult::NeedPoint;
}
@@ -2777,8 +2777,8 @@ pub fn empty_solid3d() -> EntityType {
}
pub fn empty_extruded_surface(direction: DVec3, taper_angle: f64) -> EntityType {
use acadrust::entities::{Surface, SurfaceData, SurfaceKind};
use acadrust::types::Vector3;
use codec::entities::{Surface, SurfaceData, SurfaceKind};
use codec::types::Vector3;
let mut surface = Surface::new(SurfaceKind::Extruded);
surface.u_isolines = 6;
@@ -2803,8 +2803,8 @@ pub fn empty_revolved_surface(
angle: f64,
start_angle: f64,
) -> EntityType {
use acadrust::entities::{Surface, SurfaceData, SurfaceKind};
use acadrust::types::Vector3;
use codec::entities::{Surface, SurfaceData, SurfaceKind};
use codec::types::Vector3;
let mut surface = Surface::new(SurfaceKind::Revolved);
let axis = (axis_end - axis_start).normalize_or(DVec3::Z);
@@ -2853,7 +2853,7 @@ mod extrude_command_tests {
command.set_preselection(
vec![(
Handle::new(1),
EntityType::Circle(acadrust::entities::Circle::new()),
EntityType::Circle(codec::entities::Circle::new()),
)],
DVec3::ZERO,
Some(DVec3::Z),
@@ -2875,7 +2875,7 @@ mod revolve_tests {
#[test]
fn cursor_angle_is_measured_about_the_model_axis() {
let profile = EntityType::Line(acadrust::entities::Line::from_coords(
let profile = EntityType::Line(codec::entities::Line::from_coords(
2.0, 0.0, 0.0, 2.0, 4.0, 0.0,
));
let mut command = RevolveCommand::new([1.0; 4], 0);
@@ -2908,8 +2908,8 @@ mod thicken_command_tests {
fn thicken_filters_selection_recovers_from_invalid_text_and_measures_two_points() {
let handle = Handle::new(42);
let mut command = ThickenCommand::new(vec![
(Handle::new(1), EntityType::Line(acadrust::entities::Line::default())),
(handle, EntityType::Surface(acadrust::entities::Surface::new(acadrust::entities::SurfaceKind::Plane))),
(Handle::new(1), EntityType::Line(codec::entities::Line::default())),
(handle, EntityType::Surface(codec::entities::Surface::new(codec::entities::SurfaceKind::Plane))),
]);
assert!(!command.is_selection_gathering());
assert_eq!(command.handles, vec![handle]);
+14 -14
View File
@@ -4,7 +4,7 @@
// block name → copies the named block definition to a new document
// * → copies currently selected model-space entities
use acadrust::{CadDocument, EntityType};
use codec::{CadDocument, EntityType};
use crate::t;
use crate::modules::{IconKind, ModuleEvent, ToolDef};
@@ -68,8 +68,8 @@ pub fn extract_block_into(
continue;
}
let mut clone = entity.clone();
clone.common_mut().handle = acadrust::types::Handle::NULL;
clone.common_mut().owner_handle = acadrust::types::Handle::NULL;
clone.common_mut().handle = codec::types::Handle::NULL;
clone.common_mut().owner_handle = codec::types::Handle::NULL;
let _ = out.add_entity(clone);
}
}
@@ -89,7 +89,7 @@ pub fn extract_block_into(
/// (the "selected entities" mode, `*`).
pub fn extract_entities_to_doc(
src: &CadDocument,
handles: &[acadrust::Handle],
handles: &[codec::Handle],
) -> Result<CadDocument, String> {
let mut out = CadDocument::new();
extract_entities_into(src, handles, &mut out)?;
@@ -99,7 +99,7 @@ pub fn extract_entities_to_doc(
/// Extract the listed entities into `out` (fresh document or template base).
pub fn extract_entities_into(
src: &CadDocument,
handles: &[acadrust::Handle],
handles: &[codec::Handle],
out: &mut CadDocument,
) -> Result<(), String> {
if handles.is_empty() {
@@ -119,8 +119,8 @@ pub fn extract_entities_into(
}
}
let mut clone = entity.clone();
clone.common_mut().handle = acadrust::types::Handle::NULL;
clone.common_mut().owner_handle = acadrust::types::Handle::NULL;
clone.common_mut().handle = codec::types::Handle::NULL;
clone.common_mut().owner_handle = codec::types::Handle::NULL;
let _ = out.add_entity(clone);
}
}
@@ -150,8 +150,8 @@ pub fn normalize_to_origin(out: &mut CadDocument) {
if min.iter().any(|v| !v.is_finite()) {
return;
}
let shift = crate::command::EntityTransform::Affine(acadrust::types::Transform::from_translation(
acadrust::types::Vector3::new(-min[0], -min[1], -min[2]),
let shift = crate::command::EntityTransform::Affine(codec::types::Transform::from_translation(
codec::types::Vector3::new(-min[0], -min[1], -min[2]),
));
for entity in out.entities_mut() {
crate::scene::view::dispatch::apply_transform(entity, &shift);
@@ -187,7 +187,7 @@ impl crate::command::CadCommand for WblockPickBasePointCommand {
/// applying `base_point` translation and `unit` insertion units.
pub fn extract_entities_to_doc_with_base(
src: &CadDocument,
handles: &[acadrust::Handle],
handles: &[codec::Handle],
base_point: glam::DVec3,
unit: i16,
) -> Result<CadDocument, String> {
@@ -196,7 +196,7 @@ pub fn extract_entities_to_doc_with_base(
extract_entities_into(src, handles, &mut out)?;
if base_point != glam::DVec3::ZERO {
let shift = crate::command::EntityTransform::Affine(
acadrust::types::Transform::from_translation(acadrust::types::Vector3::new(
codec::types::Transform::from_translation(codec::types::Vector3::new(
-base_point.x,
-base_point.y,
-base_point.z,
@@ -212,8 +212,8 @@ pub fn extract_entities_to_doc_with_base(
#[cfg(test)]
mod tests {
use super::*;
use acadrust::entities::Line;
use acadrust::types::Vector3;
use codec::entities::Line;
use codec::types::Vector3;
#[test]
fn test_extract_entities_with_base_point_and_units() {
@@ -252,7 +252,7 @@ mod tests {
line.end = Vector3::new(3.0, 4.0, 0.0);
let h = doc.add_entity(EntityType::Line(line)).unwrap();
let mut block_record = acadrust::tables::BlockRecord::new("MY_BLOCK".to_string());
let mut block_record = codec::tables::BlockRecord::new("MY_BLOCK".to_string());
block_record.entity_handles.push(h);
let _ = doc.block_records.add(block_record);
+7 -7
View File
@@ -12,10 +12,10 @@
// The definition is created when the INSERT is committed (see the command
// driver), so one undo removes both.
use acadrust::entities::Insert;
use acadrust::tables::block_record::{BlockFlags, BlockRecord};
use acadrust::types::Vector3;
use acadrust::EntityType;
use codec::entities::Insert;
use codec::tables::block_record::{BlockFlags, BlockRecord};
use codec::types::Vector3;
use codec::EntityType;
use glam::DVec3;
use crate::command::{CadCommand, CmdOption, CmdResult, InputKind, WorkingPlane};
@@ -684,7 +684,7 @@ pub fn prepare_xref_definition(
}
.or(file_dir);
if let Some(base_dir) = base_dir {
let keys: rustc_hash::FxHashSet<acadrust::types::Handle> = [key].into_iter().collect();
let keys: rustc_hash::FxHashSet<codec::types::Handle> = [key].into_iter().collect();
let _ = crate::io::xref::resolve_xrefs_for_keys(&mut scene.document, &base_dir, &keys);
}
@@ -713,7 +713,7 @@ mod tests {
XAttachCommand,
};
use crate::command::{CadCommand, CmdResult};
use acadrust::EntityType;
use codec::EntityType;
use glam::DVec3;
#[test]
@@ -770,7 +770,7 @@ mod tests {
assert!(cmd.prompt().contains("Specify insertion point"));
}
fn committed(result: Option<CmdResult>) -> acadrust::entities::Insert {
fn committed(result: Option<CmdResult>) -> codec::entities::Insert {
match result {
Some(CmdResult::CommitAndExit(EntityType::Insert(ins))) => ins,
_ => panic!("expected CommitAndExit(Insert)"),
+3 -3
View File
@@ -15,9 +15,9 @@
// CLIP asks for one object: a block reference continues as XCLIP, a PDF
// underlay as PDFCLIP, anything else is "*Invalid selection*".
use acadrust::entities::UnderlayType;
use acadrust::types::Handle;
use acadrust::EntityType;
use codec::entities::UnderlayType;
use codec::types::Handle;
use codec::EntityType;
use glam::DVec3;
use crate::command::{CadCommand, CmdOption, CmdResult, InputKind};