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 <noreply@anthropic.com>
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

+34 -34
View File
@@ -1,4 +1,4 @@
use acadrust::entities::{Polyline, Polyline2D, Polyline3D};
use codec::entities::{Polyline, Polyline2D, Polyline3D};
use crate::t;
use crate::command::EntityTransform;
@@ -10,7 +10,7 @@ use crate::entities::traits::{Grippable, PropertyEditable, Transformable, Render
use crate::scene::convert::acad_to_render::{extrusion_wall_tris, RenderEntity, RenderObject};
use crate::scene::model::object::{GripApply, GripDef, PropSection, PropValue, Property};
use crate::scene::model::wire_model::TangentGeom;
use cadkernel::space::{NurbsCurve3, Vec3};
use kernel::space::{NurbsCurve3, Vec3};
// ── Polyline (old-style 3D heavy polyline) ────────────────────────────────────
@@ -38,7 +38,7 @@ fn tessellate_polyline(pl: &Polyline) -> RenderEntity {
}
impl RenderConvertible for Polyline {
fn to_render(&self, _document: &acadrust::CadDocument) -> Option<RenderEntity> {
fn to_render(&self, _document: &codec::CadDocument) -> Option<RenderEntity> {
Some(tessellate_polyline(self))
}
}
@@ -178,8 +178,8 @@ impl Transformable for Polyline {
/// falls back to the stored vertices rather than drawing nothing.
pub fn drawn_vertices2d(
pl: &Polyline2D,
) -> Option<Vec<acadrust::entities::Vertex2D>> {
use acadrust::entities::polyline::VertexFlags;
) -> Option<Vec<codec::entities::Vertex2D>> {
use codec::entities::polyline::VertexFlags;
let has_fit = pl.vertices.iter().any(|v| {
v.flags.bits()
& (VertexFlags::SPLINE_VERTEX.bits() | VertexFlags::EXTRA_VERTEX.bits())
@@ -199,7 +199,7 @@ pub fn drawn_vertices2d(
fn tessellate_polyline2d(pl: &Polyline2D, fill_mode: bool) -> RenderEntity {
let filtered = drawn_vertices2d(pl);
let verts: &[acadrust::entities::Vertex2D] = filtered.as_deref().unwrap_or(&pl.vertices);
let verts: &[codec::entities::Vertex2D] = filtered.as_deref().unwrap_or(&pl.vertices);
if verts.is_empty() {
return RenderEntity {
pick_tris: Vec::new(),
@@ -221,14 +221,14 @@ fn tessellate_polyline2d(pl: &Polyline2D, fill_mode: bool) -> RenderEntity {
let to_wcs = |x: f64, y: f64| -> (f64, f64, f64) {
crate::scene::view::transform::ocs_point_to_wcs((x, y, elev), normal)
};
let to_pt = |v: &acadrust::entities::Vertex2D| -> [f64; 3] {
let to_pt = |v: &codec::entities::Vertex2D| -> [f64; 3] {
let (wx, wy, wz) = to_wcs(v.location.x, v.location.y);
[wx, wy, wz]
};
if !fill_mode {
let continuous = pl.flags.bits()
& acadrust::entities::PolylineFlags::LINETYPE_CONTINUOUS.bits()
& codec::entities::PolylineFlags::LINETYPE_CONTINUOUS.bits()
!= 0;
let mut boundary = crate::entities::common::wide_band_outline(
&band_verts_2d(pl),
@@ -298,7 +298,7 @@ fn tessellate_polyline2d(pl: &Polyline2D, fill_mode: bool) -> RenderEntity {
{
tgs.push(crate::entities::common::bulge_arc_to_tangent(&arc, &to_wcs, normal));
for s in arc
.tessellate_angle(cadkernel::tessellation::DEFAULT_ANGLE)
.tessellate_angle(kernel::tessellation::DEFAULT_ANGLE)
.into_iter()
.skip(1)
{
@@ -414,12 +414,12 @@ fn tessellate_polyline2d(pl: &Polyline2D, fill_mode: bool) -> RenderEntity {
/// Effective segment widths for a Polyline2D band.
fn band_verts_2d(
pl: &acadrust::entities::Polyline2D,
pl: &codec::entities::Polyline2D,
) -> Vec<([f64; 2], f64, f64, f64)> {
let default_start = pl.start_width;
let default_end = pl.end_width;
let filtered = drawn_vertices2d(pl);
let verts: &[acadrust::entities::Vertex2D] = filtered.as_deref().unwrap_or(&pl.vertices);
let verts: &[codec::entities::Vertex2D] = filtered.as_deref().unwrap_or(&pl.vertices);
verts
.iter()
.map(|v| {
@@ -453,7 +453,7 @@ fn tapered_band_verts_2d(
}
fn centerline_metadata_2d(
verts: &[acadrust::entities::Vertex2D],
verts: &[codec::entities::Vertex2D],
closed: bool,
to_wcs: &dyn Fn(f64, f64) -> (f64, f64, f64),
normal: (f64, f64, f64),
@@ -492,7 +492,7 @@ fn centerline_metadata_2d(
}
impl RenderConvertible for Polyline2D {
fn to_render(&self, document: &acadrust::CadDocument) -> Option<RenderEntity> {
fn to_render(&self, document: &codec::CadDocument) -> Option<RenderEntity> {
Some(tessellate_polyline2d(self, document.header.fill_mode))
}
}
@@ -610,7 +610,7 @@ impl Grippable for Polyline2D {
}
pub(crate) fn polyline2d_vertex_segment_widths(
vertex: &acadrust::entities::Vertex2D,
vertex: &codec::entities::Vertex2D,
default_start: f64,
default_end: f64,
) -> (f64, f64) {
@@ -623,7 +623,7 @@ pub(crate) fn polyline2d_vertex_segment_widths(
pub(crate) fn polyline2d_global_width(pline: &Polyline2D) -> Option<f64> {
let filtered = drawn_vertices2d(pline);
let verts: &[acadrust::entities::Vertex2D] =
let verts: &[codec::entities::Vertex2D] =
filtered.as_deref().unwrap_or(&pline.vertices);
let count = verts.len();
let seg_count = if pline.is_closed() {
@@ -834,7 +834,7 @@ impl PropertyEditable for Polyline2D {
} else {
self.flags.bits() & !128
};
self.flags = acadrust::entities::polyline::PolylineFlags::from_bits(bits);
self.flags = codec::entities::polyline::PolylineFlags::from_bits(bits);
}
_ => {}
}
@@ -900,7 +900,7 @@ pub(crate) fn polyline3d_control_vertex_count(pl: &Polyline3D) -> usize {
polyline3d_control_indices(pl).len()
}
pub(crate) fn polyline3d_controls(pl: &Polyline3D) -> Vec<acadrust::entities::Vertex3DPolyline> {
pub(crate) fn polyline3d_controls(pl: &Polyline3D) -> Vec<codec::entities::Vertex3DPolyline> {
polyline3d_control_indices(pl)
.into_iter()
.filter_map(|index| pl.vertices.get(index).cloned())
@@ -955,7 +955,7 @@ fn polyline3d_spline_samples(
} else {
NurbsCurve3::new(degree, controls.to_vec(), Vec::new(), None)?
};
let mut samples = curve.tessellate_angle(cadkernel::tessellation::DEFAULT_ANGLE);
let mut samples = curve.tessellate_angle(kernel::tessellation::DEFAULT_ANGLE);
if closed
&& samples.len() >= 2
&& Vec3::from(samples[0]).distance(Vec3::from(samples[samples.len() - 1])) <= 1.0e-9
@@ -966,7 +966,7 @@ fn polyline3d_spline_samples(
}
fn rebuild_polyline3d_fit(pl: &mut Polyline3D) -> bool {
use acadrust::entities::polyline3d::SmoothSurfaceType as SST;
use codec::entities::polyline3d::SmoothSurfaceType as SST;
let mut controls = polyline3d_controls(pl);
if pl.smooth_type == SST::None {
@@ -1009,7 +1009,7 @@ fn rebuild_polyline3d_fit(pl: &mut Polyline3D) -> bool {
.map(|vertex| vertex.layer.clone())
.unwrap_or_else(|| "0".to_string());
let curve_vertices = samples.into_iter().map(|point| {
let mut vertex = acadrust::entities::Vertex3DPolyline::from_xyz(
let mut vertex = codec::entities::Vertex3DPolyline::from_xyz(
point[0], point[1], point[2],
);
vertex.layer = vertex_layer.clone();
@@ -1023,7 +1023,7 @@ fn rebuild_polyline3d_fit(pl: &mut Polyline3D) -> bool {
}
fn tessellate_polyline3d(pl: &Polyline3D) -> RenderEntity {
let to_pt = |v: &acadrust::entities::Vertex3DPolyline| -> [f64; 3] {
let to_pt = |v: &codec::entities::Vertex3DPolyline| -> [f64; 3] {
[v.position.x, v.position.y, v.position.z]
};
@@ -1068,7 +1068,7 @@ fn tessellate_polyline3d(pl: &Polyline3D) -> RenderEntity {
}
impl RenderConvertible for Polyline3D {
fn to_render(&self, _document: &acadrust::CadDocument) -> Option<RenderEntity> {
fn to_render(&self, _document: &codec::CadDocument) -> Option<RenderEntity> {
Some(tessellate_polyline3d(self))
}
}
@@ -1104,7 +1104,7 @@ impl Grippable for Polyline3D {
}
}
if self.smooth_type
!= acadrust::entities::polyline3d::SmoothSurfaceType::None
!= codec::entities::polyline3d::SmoothSurfaceType::None
{
let _ = rebuild_polyline3d_fit(self);
}
@@ -1113,7 +1113,7 @@ impl Grippable for Polyline3D {
fn grip_menu(&self, _grip_id: usize) -> Vec<crate::scene::model::object::GripMenuItem> {
use crate::scene::model::object::{GripMenuAction, GripMenuItem};
use acadrust::entities::polyline3d::SmoothSurfaceType as SST;
use codec::entities::polyline3d::SmoothSurfaceType as SST;
let mut items = vec![
GripMenuItem {
@@ -1142,7 +1142,7 @@ impl Grippable for Polyline3D {
fn apply_grip_menu(&mut self, grip_id: usize, action: crate::scene::model::object::GripMenuAction) {
use crate::scene::model::object::GripMenuAction as A;
use acadrust::entities::polyline3d::SmoothSurfaceType as SST;
use codec::entities::polyline3d::SmoothSurfaceType as SST;
let mut controls = polyline3d_controls(self);
let n = controls.len();
@@ -1161,7 +1161,7 @@ impl Grippable for Polyline3D {
new_v.position.y = next.y;
new_v.position.z = next.z;
}
new_v.handle = acadrust::Handle::NULL;
new_v.handle = codec::Handle::NULL;
controls.push(new_v);
} else {
let i1 = (grip_id + 1) % n;
@@ -1175,7 +1175,7 @@ impl Grippable for Polyline3D {
new_v.position.x = midpoint.x;
new_v.position.y = midpoint.y;
new_v.position.z = midpoint.z;
new_v.handle = acadrust::Handle::NULL;
new_v.handle = codec::Handle::NULL;
controls.insert(grip_id + 1, new_v);
}
self.vertices = controls;
@@ -1201,7 +1201,7 @@ impl Grippable for Polyline3D {
impl PropertyEditable for Polyline3D {
fn geometry_properties(&self, _text_style_names: &[String]) -> Vec<PropSection> {
use acadrust::entities::polyline3d::SmoothSurfaceType as SST;
use codec::entities::polyline3d::SmoothSurfaceType as SST;
let control_indices = polyline3d_control_indices(self);
let n = control_indices.len();
let vi = if n == 0 {
@@ -1297,13 +1297,13 @@ impl PropertyEditable for Polyline3D {
self.open();
}
if self.smooth_type
!= acadrust::entities::polyline3d::SmoothSurfaceType::None
!= codec::entities::polyline3d::SmoothSurfaceType::None
{
let _ = rebuild_polyline3d_fit(self);
}
}
"pl3_smooth" => {
use acadrust::entities::polyline3d::SmoothSurfaceType as SST;
use codec::entities::polyline3d::SmoothSurfaceType as SST;
let next = match value {
"None" => SST::None,
"Quadratic" => SST::QuadraticBSpline,
@@ -1372,13 +1372,13 @@ impl Transformable for Polyline3D {
/// Solid-fill bands for a wide Polyline2D, plus the `world_origin` they are
/// relative to (the first vertex). See `lwpolyline::wide_fills` — offsets are
/// f32 from `origin` so the band stays precise at UTM-scale coordinates.
pub(crate) fn wide_fills(pl: &acadrust::entities::Polyline2D) -> ([f64; 2], Vec<Vec<[f32; 2]>>) {
pub(crate) fn wide_fills(pl: &codec::entities::Polyline2D) -> ([f64; 2], Vec<Vec<[f32; 2]>>) {
// The stored widths are the band's FULL width and `polyline_segment_fill`
// offsets ±hw about the centreline — halve them. See `lwpolyline::wide_fills`.
let hw_default_start = pl.start_width as f32 * 0.5;
let hw_default_end = pl.end_width as f32 * 0.5;
let filtered = drawn_vertices2d(pl);
let verts: &[acadrust::entities::Vertex2D] = filtered.as_deref().unwrap_or(&pl.vertices);
let verts: &[codec::entities::Vertex2D] = filtered.as_deref().unwrap_or(&pl.vertices);
let n = verts.len();
if n < 2 {
return ([0.0; 2], vec![]);
@@ -1423,8 +1423,8 @@ pub(crate) fn wide_fills(pl: &acadrust::entities::Polyline2D) -> ([f64; 2], Vec<
mod tests {
use super::*;
use crate::entities::traits::PropertyEditable;
use acadrust::entities::{Polyline2D, Vertex2D};
use acadrust::Vector3;
use codec::entities::{Polyline2D, Vertex2D};
use codec::Vector3;
fn make_test_polyline2d(count: usize, start_w: f64, end_w: f64) -> Polyline2D {
let mut pl = Polyline2D::default();