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

+67 -67
View File
@@ -1,13 +1,13 @@
use acadrust::entities::{EmbeddedEntity, Solid3D};
use acadrust::objects::{
use codec::entities::{EmbeddedEntity, Solid3D};
use codec::objects::{
DynamicBlockData, ObjectType, SolidHistoryBox, SolidHistoryBrep, SolidHistoryChamfer,
SolidHistoryCone, SolidHistoryCylinder, SolidHistoryFillet, SolidHistoryLoft,
SolidHistoryLoftParameters, SolidHistoryNodeBase, SolidHistoryOperation,
SolidHistoryPyramid, SolidHistoryRevolve, SolidHistorySphere, SolidHistorySweep,
SolidHistoryTorus,
};
use acadrust::EntityType;
use cadkernel::brep::{Body, Surface};
use codec::EntityType;
use kernel::brep::{Body, Surface};
use crate::command::EntityTransform;
use crate::entities::traits::EntityTypeOps;
@@ -129,8 +129,8 @@ fn compact_surface_number(mut value: String) -> String {
}
fn history_flags(
document: &acadrust::CadDocument,
handle: acadrust::Handle,
document: &codec::CadDocument,
handle: codec::Handle,
) -> Option<(bool, bool, i16)> {
let graph = document.solid_history_graph(handle)?;
let ObjectType::DynamicBlock(object) = document.objects.get(&graph.root)? else {
@@ -222,8 +222,8 @@ fn revolve_direction_property(
}
pub fn has_specialized_primitive_properties(
document: &acadrust::CadDocument,
handle: acadrust::Handle,
document: &codec::CadDocument,
handle: codec::Handle,
) -> bool {
matches!(
primitive_property_operation(document, handle).as_ref(),
@@ -247,8 +247,8 @@ pub fn has_specialized_primitive_properties(
/// operations refine that primitive without replacing its editable type,
/// position, or dimensions.
pub fn primitive_property_operation(
document: &acadrust::CadDocument,
handle: acadrust::Handle,
document: &codec::CadDocument,
handle: codec::Handle,
) -> Option<SolidHistoryOperation> {
document
.solid_history_operations(handle)
@@ -261,12 +261,12 @@ pub fn primitive_property_operation(
/// no stable primitive dimensions to expose, but it still uses the compact
/// Solid History palette rather than the internal ACIS/cache diagnostics.
pub fn has_compact_solid_properties(
document: &acadrust::CadDocument,
handle: acadrust::Handle,
document: &codec::CadDocument,
handle: codec::Handle,
) -> bool {
match document.get_entity(handle) {
Some(acadrust::EntityType::Solid3D(_)) => true,
Some(acadrust::EntityType::Surface(_)) => matches!(
Some(codec::EntityType::Solid3D(_)) => true,
Some(codec::EntityType::Surface(_)) => matches!(
primitive_property_operation(document, handle),
Some(SolidHistoryOperation::Extrusion(_))
),
@@ -285,7 +285,7 @@ pub fn reference_point(operation: &SolidHistoryOperation) -> Option<glam::DVec3>
}
SolidHistoryOperation::Cone(value) => world_point(value.base.transform, [0.0; 3]),
SolidHistoryOperation::Cylinder(value) => world_point(value.base.transform, [0.0; 3]),
SolidHistoryOperation::Sweep(value) => cadkernel::acis::sweep_history_reference_point(value)
SolidHistoryOperation::Sweep(value) => kernel::acis::sweep_history_reference_point(value)
.ok().map(glam::DVec3::from_array),
SolidHistoryOperation::Extrusion(value) => world_point(
value.base.transform,
@@ -306,8 +306,8 @@ pub fn reference_point(operation: &SolidHistoryOperation) -> Option<glam::DVec3>
}
fn revolve_properties(
document: &acadrust::CadDocument,
handle: acadrust::Handle,
document: &codec::CadDocument,
handle: codec::Handle,
value: &SolidHistoryRevolve,
) -> Vec<PropSection> {
let Some(axis_position) = world_point(
@@ -416,8 +416,8 @@ fn revolve_properties(
}
fn extrusion_properties(
document: &acadrust::CadDocument,
handle: acadrust::Handle,
document: &codec::CadDocument,
handle: codec::Handle,
value: &SolidHistorySweep,
) -> Vec<PropSection> {
let direction = matrix(value.base.transform).map(|transform| {
@@ -629,8 +629,8 @@ fn extrusion_properties(
/// direction and taper used by the extrusion history rebuild.
pub fn extrusion_surface_data(
value: &SolidHistorySweep,
) -> Option<acadrust::entities::SurfaceData> {
use acadrust::entities::{SurfaceData, SurfaceSweepOptions};
) -> Option<codec::entities::SurfaceData> {
use codec::entities::{SurfaceData, SurfaceSweepOptions};
if value.path_entity.is_some() {
return None;
@@ -663,8 +663,8 @@ pub fn extrusion_surface_data(
}
fn sweep_properties(
document: &acadrust::CadDocument,
handle: acadrust::Handle,
document: &codec::CadDocument,
handle: codec::Handle,
value: &SolidHistorySweep,
) -> Vec<PropSection> {
let (record_history, object_show_history, show_history_mode) =
@@ -672,7 +672,7 @@ fn sweep_properties(
let (show_history, show_history_editable) =
displayed_history_state(object_show_history, show_history_mode);
let show_value = if show_history { "Yes" } else { "No" };
let length = cadkernel::acis::sweep_history_path_length(value).ok()
let length = kernel::acis::sweep_history_path_length(value).ok()
.map(crate::entities::common::format_length)
.unwrap_or_default();
vec![
@@ -776,8 +776,8 @@ pub fn loft_closed_editable(value: &SolidHistoryLoft) -> bool {
}
fn loft_properties(
document: &acadrust::CadDocument,
handle: acadrust::Handle,
document: &codec::CadDocument,
handle: codec::Handle,
value: &SolidHistoryLoft,
) -> Vec<PropSection> {
let parameters = loft_parameters(value);
@@ -901,8 +901,8 @@ fn loft_properties(
}
fn sweep_path_length(value: &SolidHistorySweep) -> Option<f64> {
use acadrust::entities::EmbeddedEntity;
use acadrust::EntityType;
use codec::entities::EmbeddedEntity;
use codec::EntityType;
let path_entity = value.path_entity.as_ref()?;
if let EmbeddedEntity::Spline(path) = path_entity {
@@ -946,7 +946,7 @@ fn sweep_path_length(value: &SolidHistorySweep) -> Option<f64> {
{
return None;
}
let placement = cadkernel::brep::Placement {
let placement = kernel::brep::Placement {
x_axis: [transform[0], transform[1], transform[2]],
y_axis: [transform[4], transform[5], transform[6]],
z_axis: [transform[8], transform[9], transform[10]],
@@ -957,8 +957,8 @@ fn sweep_path_length(value: &SolidHistorySweep) -> Option<f64> {
}
fn torus_properties(
document: &acadrust::CadDocument,
handle: acadrust::Handle,
document: &codec::CadDocument,
handle: codec::Handle,
value: &SolidHistoryTorus,
) -> Vec<PropSection> {
let Some(position) = world_point(value.base.transform, [0.0; 3]) else {
@@ -1026,8 +1026,8 @@ fn torus_properties(
}
fn cone_properties(
document: &acadrust::CadDocument,
handle: acadrust::Handle,
document: &codec::CadDocument,
handle: codec::Handle,
value: &SolidHistoryCone,
) -> Vec<PropSection> {
let Some(position) = world_point(value.base.transform, [0.0; 3]) else {
@@ -1160,8 +1160,8 @@ fn cone_properties(
}
fn brep_properties(
document: &acadrust::CadDocument,
handle: acadrust::Handle,
document: &codec::CadDocument,
handle: codec::Handle,
) -> Vec<PropSection> {
let (record_history, object_show_history, show_history_mode) =
history_flags(document, handle).unwrap_or((false, false, 1));
@@ -1195,8 +1195,8 @@ fn brep_properties(
}
fn cylinder_properties(
document: &acadrust::CadDocument,
handle: acadrust::Handle,
document: &codec::CadDocument,
handle: codec::Handle,
value: &SolidHistoryCylinder,
) -> Vec<PropSection> {
let Some(position) = world_point(value.base.transform, [0.0; 3]) else {
@@ -1333,8 +1333,8 @@ fn pyramid_display_rotation(value: &SolidHistoryPyramid) -> Option<f64> {
}
fn pyramid_properties(
document: &acadrust::CadDocument,
handle: acadrust::Handle,
document: &codec::CadDocument,
handle: codec::Handle,
value: &SolidHistoryPyramid,
) -> Vec<PropSection> {
let Some(position) = world_point(value.base.transform, [0.0; 3]) else {
@@ -1433,8 +1433,8 @@ fn pyramid_properties(
}
fn sphere_properties(
document: &acadrust::CadDocument,
handle: acadrust::Handle,
document: &codec::CadDocument,
handle: codec::Handle,
value: &SolidHistorySphere,
) -> Vec<PropSection> {
let Some(position) = world_point(value.base.transform, [0.0; 3]) else {
@@ -1510,8 +1510,8 @@ fn sphere_properties(
}
fn rectangular_properties(
document: &acadrust::CadDocument,
handle: acadrust::Handle,
document: &codec::CadDocument,
handle: codec::Handle,
value: &SolidHistoryBox,
solid_type: &str,
) -> Vec<PropSection> {
@@ -1606,12 +1606,12 @@ fn rectangular_properties(
}
pub fn primitive_properties(
document: &acadrust::CadDocument,
handle: acadrust::Handle,
document: &codec::CadDocument,
handle: codec::Handle,
) -> Vec<PropSection> {
if !matches!(
document.get_entity(handle),
Some(acadrust::EntityType::Solid3D(_) | acadrust::EntityType::Surface(_))
Some(codec::EntityType::Solid3D(_) | codec::EntityType::Surface(_))
) {
return Vec::new();
}
@@ -1772,7 +1772,7 @@ fn apply_extrusion_geometry_property(
if (updated - direction).length_squared() <= 1e-24 {
return Some(false);
}
value.direction = acadrust::types::Vector3::new(updated.x, updated.y, updated.z);
value.direction = codec::types::Vector3::new(updated.x, updated.y, updated.z);
value.end_draft_distance = height;
Some(true)
}
@@ -1837,7 +1837,7 @@ fn apply_revolve_geometry_property(
if !local.is_finite() {
return Some(false);
}
value.axis_point = acadrust::types::Vector3::new(local.x, local.y, local.z);
value.axis_point = codec::types::Vector3::new(local.x, local.y, local.z);
return Some(true);
}
@@ -1895,7 +1895,7 @@ fn apply_revolve_geometry_property(
if (local - current).length_squared() <= 1e-24 {
return Some(false);
}
value.direction = acadrust::types::Vector3::new(local.x, local.y, local.z);
value.direction = codec::types::Vector3::new(local.x, local.y, local.z);
return Some(true);
}
@@ -1903,8 +1903,8 @@ fn apply_revolve_geometry_property(
}
pub fn apply_history_choice(
document: &mut acadrust::CadDocument,
handle: acadrust::Handle,
document: &mut codec::CadDocument,
handle: codec::Handle,
field: &str,
value: &str,
) -> bool {
@@ -2667,7 +2667,7 @@ fn matrix(transform: [f64; 16]) -> Option<glam::DMat4> {
(matrix.is_finite() && matrix.determinant().abs() > 1e-12).then_some(matrix)
}
fn codec_matrix(transform: &acadrust::types::Transform) -> glam::DMat4 {
fn codec_matrix(transform: &codec::types::Transform) -> glam::DMat4 {
let matrix = transform.matrix.m;
glam::DMat4::from_cols_array(&[
matrix[0][0], matrix[1][0], matrix[2][0], matrix[3][0],
@@ -2764,8 +2764,8 @@ fn embedded_entity(value: &EmbeddedEntity) -> Option<EntityType> {
/// Visible LOFT construction curves, owned by the parent display entity.
/// Copies are transformed to WCS and never inserted into the document.
pub fn loft_visible_history_entities(
document: &acadrust::CadDocument,
handle: acadrust::Handle,
document: &codec::CadDocument,
handle: codec::Handle,
) -> Vec<EntityType> {
let Some((_, object_show_history, show_history_mode)) = history_flags(document, handle) else {
return Vec::new();
@@ -2783,8 +2783,8 @@ pub fn loft_visible_history_entities(
return Vec::new();
};
let columns = transform.to_cols_array_2d();
let affine = acadrust::types::Transform::from_matrix(
acadrust::types::Matrix4 {
let affine = codec::types::Transform::from_matrix(
codec::types::Matrix4 {
m: std::array::from_fn(|row| std::array::from_fn(|column| columns[column][row])),
},
);
@@ -2911,8 +2911,8 @@ fn apply_extrusion_profile_grip(
}
fn sweep_placement_matrices(value: &SolidHistorySweep) -> Option<(glam::DMat4, glam::DMat4)> {
let (profile, path) = cadkernel::acis::sweep_history_placements(value).ok()?;
let matrix = |place: cadkernel::brep::Placement| {
let (profile, path) = kernel::acis::sweep_history_placements(value).ok()?;
let matrix = |place: kernel::brep::Placement| {
glam::DMat4::from_cols(
glam::DVec3::from_array(place.x_axis).extend(0.0),
glam::DVec3::from_array(place.y_axis).extend(0.0),
@@ -3286,12 +3286,12 @@ fn extrusion_draft_rebuilds(value: &SolidHistorySweep, angle: f64) -> bool {
let Some(profile) = candidate.sweep_entity.as_ref() else {
return false;
};
let Ok((_, _, closed)) = cadkernel::acis::sweep_profile_geometry(
let Ok((_, _, closed)) = kernel::acis::sweep_profile_geometry(
profile, candidate.sweep_entity_transform,
) else {
return false;
};
cadkernel::acis::rebuild_extrusion_with_mode(&candidate, !closed).is_ok()
kernel::acis::rebuild_extrusion_with_mode(&candidate, !closed).is_ok()
}
fn grip(
@@ -3356,8 +3356,8 @@ pub fn fillet_radius_grip(body: &Body, radius: f64) -> Option<GripDef> {
}
pub fn chamfer_distance_grips(
document: &acadrust::CadDocument,
handle: acadrust::Handle,
document: &codec::CadDocument,
handle: codec::Handle,
value: &SolidHistoryChamfer,
) -> Vec<GripDef> {
let Some(operations) = document.solid_history_operations(handle) else {
@@ -3369,7 +3369,7 @@ pub fn chamfer_distance_grips(
else {
return Vec::new();
};
let Ok(source) = cadkernel::acis::rebuild_history(&operations[..chamfer_index]) else {
let Ok(source) = kernel::acis::rebuild_history(&operations[..chamfer_index]) else {
return Vec::new();
};
let edges = source.edge_keys().collect::<Vec<_>>();
@@ -3454,8 +3454,8 @@ pub fn chamfer_distance_grips(
}
pub fn primitive_grips(
document: &acadrust::CadDocument,
handle: acadrust::Handle,
document: &codec::CadDocument,
handle: codec::Handle,
) -> Vec<GripDef> {
let Some(operation) = document.solid_history_operation(handle) else {
return Vec::new();
@@ -3920,7 +3920,7 @@ pub fn apply_primitive_grip(
_ => return false,
},
SolidHistoryOperation::Revolve(value) if grip_id == GRIP_REVOLVE_AXIS => {
value.axis_point = acadrust::types::Vector3::new(local.x, local.y, local.z);
value.axis_point = codec::types::Vector3::new(local.x, local.y, local.z);
}
SolidHistoryOperation::Extrusion(value) => match grip_id {
GRIP_HEIGHT => {
@@ -3948,7 +3948,7 @@ pub fn apply_primitive_grip(
if (direction - current).length_squared() <= 1e-24 {
return false;
}
value.direction = acadrust::types::Vector3::new(
value.direction = codec::types::Vector3::new(
direction.x,
direction.y,
direction.z,