forked from 1b-agent/opencadstudio-upstream
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:
1 parent
56c04408d6
commit
f537aff75c
430 files changed
+9925
-8540
No files matched your search
+56
-56
@@ -2,9 +2,9 @@
|
||||
//
|
||||
// Shared grips and properties for modeler entities.
|
||||
|
||||
use acadrust::entities::{Body, Region, Solid3D, Surface};
|
||||
use acadrust::xdata::{ExtendedDataRecord, XDataValue};
|
||||
use cadkernel::space::polygon;
|
||||
use codec::entities::{Body, Region, Solid3D, Surface};
|
||||
use codec::xdata::{ExtendedDataRecord, XDataValue};
|
||||
use kernel::space::polygon;
|
||||
use crate::t;
|
||||
use crate::command::EntityTransform;
|
||||
use crate::entities::common::{
|
||||
@@ -14,7 +14,7 @@ use crate::entities::traits::{Grippable, PropertyEditable, Transformable};
|
||||
use crate::scene::model::object::{GripApply, GripDef, PropSection};
|
||||
|
||||
/// Shared transform for the ACIS volume entities. Translate / rotate / scale
|
||||
/// delegate to acadrust (which composes the move into the solid's ACIS
|
||||
/// delegate to opencadcodec (which composes the move into the solid's ACIS
|
||||
/// placement), and mirror delegates via a reflection transform. Without this
|
||||
/// the entity dispatcher treated solids as non-transformable, so a moved or
|
||||
/// pasted solid stayed at its original ACIS placement.
|
||||
@@ -24,7 +24,7 @@ macro_rules! impl_acis_transformable {
|
||||
fn apply_transform(&mut self, t: &EntityTransform) {
|
||||
crate::scene::view::transform::apply_standard_entity_transform(self, t, |e, p1, p2| {
|
||||
let m = crate::scene::view::transform::reflection_about_xy_line(p1, p2);
|
||||
acadrust::Entity::apply_transform(e, &m);
|
||||
codec::Entity::apply_transform(e, &m);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -37,14 +37,14 @@ impl_acis_transformable!(Surface);
|
||||
|
||||
// ── shared helpers ────────────────────────────────────────────────────────────
|
||||
|
||||
fn dvec3(v: &acadrust::types::Vector3) -> glam::DVec3 {
|
||||
fn dvec3(v: &codec::types::Vector3) -> glam::DVec3 {
|
||||
glam::DVec3::new(v.x, v.y, v.z)
|
||||
}
|
||||
|
||||
fn translate_acis_entity<T: acadrust::Entity>(entity: &mut T, d: glam::DVec3) {
|
||||
acadrust::Entity::translate(
|
||||
fn translate_acis_entity<T: codec::Entity>(entity: &mut T, d: glam::DVec3) {
|
||||
codec::Entity::translate(
|
||||
entity,
|
||||
acadrust::types::Vector3::new(d.x, d.y, d.z),
|
||||
codec::types::Vector3::new(d.x, d.y, d.z),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ pub(crate) fn surface_isoline_counts(surface: &Surface) -> [usize; 2] {
|
||||
]
|
||||
}
|
||||
|
||||
fn handle_text(handle: Option<acadrust::Handle>) -> String {
|
||||
fn handle_text(handle: Option<codec::Handle>) -> String {
|
||||
handle
|
||||
.filter(|handle| handle.is_valid())
|
||||
.map(|handle| format!("{:X}", handle.value()))
|
||||
@@ -125,20 +125,20 @@ fn handle_text(handle: Option<acadrust::Handle>) -> String {
|
||||
}
|
||||
|
||||
fn acis_sections(
|
||||
acis: &acadrust::entities::AcisData,
|
||||
wires: &[acadrust::entities::Wire],
|
||||
silhouettes: &[acadrust::entities::Silhouette],
|
||||
history: Option<acadrust::Handle>,
|
||||
acis: &codec::entities::AcisData,
|
||||
wires: &[codec::entities::Wire],
|
||||
silhouettes: &[codec::entities::Silhouette],
|
||||
history: Option<codec::Handle>,
|
||||
) -> Vec<PropSection> {
|
||||
let mut wire_types = [0usize; 5];
|
||||
let mut transformed = 0usize;
|
||||
let mut points = 0usize;
|
||||
for wire in wires {
|
||||
let index = match wire.wire_type {
|
||||
acadrust::entities::WireType::Silhouette => 1,
|
||||
acadrust::entities::WireType::VisibleEdge => 2,
|
||||
acadrust::entities::WireType::HiddenEdge => 3,
|
||||
acadrust::entities::WireType::Isoline => 4,
|
||||
codec::entities::WireType::Silhouette => 1,
|
||||
codec::entities::WireType::VisibleEdge => 2,
|
||||
codec::entities::WireType::HiddenEdge => 3,
|
||||
codec::entities::WireType::Isoline => 4,
|
||||
_ => 0,
|
||||
};
|
||||
wire_types[index] += 1;
|
||||
@@ -245,7 +245,7 @@ fn acis_sections(
|
||||
]
|
||||
}
|
||||
|
||||
fn position_section(prefix: &str, p: &acadrust::types::Vector3) -> PropSection {
|
||||
fn position_section(prefix: &str, p: &codec::types::Vector3) -> PropSection {
|
||||
let fields = match prefix {
|
||||
"rgn" => ["rgn_px", "rgn_py", "rgn_pz"],
|
||||
"bdy" => ["bdy_px", "bdy_py", "bdy_pz"],
|
||||
@@ -268,8 +268,8 @@ fn region_area_perimeter(region: &Region) -> (f64, f64) {
|
||||
let (plane, loops, true) = crate::scene::model::presspull_model::profile_geometry(
|
||||
&EntityType::Region(region.clone()),
|
||||
)? else { return None; };
|
||||
let unit = cadkernel::space::Plane::orthonormal(plane.origin, plane.x_axis, plane.normal()?)?;
|
||||
let transform = cadkernel::geom2d::Transform {
|
||||
let unit = kernel::space::Plane::orthonormal(plane.origin, plane.x_axis, plane.normal()?)?;
|
||||
let transform = kernel::geom2d::Transform {
|
||||
origin: unit.project(plane.origin)?.into(),
|
||||
x_axis: unit.project_vector(plane.x_axis)?.into(),
|
||||
y_axis: unit.project_vector(plane.y_axis)?.into(),
|
||||
@@ -332,13 +332,13 @@ impl PropertyEditable for Solid3D {
|
||||
return;
|
||||
};
|
||||
let delta = match field {
|
||||
"s3d_px" => acadrust::types::Vector3::new(v - self.point_of_reference.x, 0.0, 0.0),
|
||||
"s3d_py" => acadrust::types::Vector3::new(0.0, v - self.point_of_reference.y, 0.0),
|
||||
"s3d_pz" => acadrust::types::Vector3::new(0.0, 0.0, v - self.point_of_reference.z),
|
||||
"s3d_px" => codec::types::Vector3::new(v - self.point_of_reference.x, 0.0, 0.0),
|
||||
"s3d_py" => codec::types::Vector3::new(0.0, v - self.point_of_reference.y, 0.0),
|
||||
"s3d_pz" => codec::types::Vector3::new(0.0, 0.0, v - self.point_of_reference.z),
|
||||
_ => return,
|
||||
};
|
||||
if delta != acadrust::types::Vector3::ZERO {
|
||||
acadrust::Entity::translate(self, delta);
|
||||
if delta != codec::types::Vector3::ZERO {
|
||||
codec::Entity::translate(self, delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -412,35 +412,35 @@ impl PropertyEditable for Body {
|
||||
return;
|
||||
};
|
||||
let delta = match field {
|
||||
"bdy_px" => acadrust::types::Vector3::new(v - self.point_of_reference.x, 0.0, 0.0),
|
||||
"bdy_py" => acadrust::types::Vector3::new(0.0, v - self.point_of_reference.y, 0.0),
|
||||
"bdy_pz" => acadrust::types::Vector3::new(0.0, 0.0, v - self.point_of_reference.z),
|
||||
"bdy_px" => codec::types::Vector3::new(v - self.point_of_reference.x, 0.0, 0.0),
|
||||
"bdy_py" => codec::types::Vector3::new(0.0, v - self.point_of_reference.y, 0.0),
|
||||
"bdy_pz" => codec::types::Vector3::new(0.0, 0.0, v - self.point_of_reference.z),
|
||||
_ => return,
|
||||
};
|
||||
if delta != acadrust::types::Vector3::ZERO {
|
||||
acadrust::Entity::translate(self, delta);
|
||||
if delta != codec::types::Vector3::ZERO {
|
||||
codec::Entity::translate(self, delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn embedded_name(entity: Option<&acadrust::entities::EmbeddedEntity>) -> &'static str {
|
||||
fn embedded_name(entity: Option<&codec::entities::EmbeddedEntity>) -> &'static str {
|
||||
match entity {
|
||||
Some(acadrust::entities::EmbeddedEntity::Point(_)) => "Point",
|
||||
Some(acadrust::entities::EmbeddedEntity::Line(_)) => "Line",
|
||||
Some(acadrust::entities::EmbeddedEntity::Arc(_)) => "Arc",
|
||||
Some(acadrust::entities::EmbeddedEntity::Circle(_)) => "Circle",
|
||||
Some(acadrust::entities::EmbeddedEntity::Ellipse(_)) => "Ellipse",
|
||||
Some(acadrust::entities::EmbeddedEntity::Spline(_)) => "Spline",
|
||||
Some(acadrust::entities::EmbeddedEntity::LwPolyline(_)) => "Polyline",
|
||||
Some(acadrust::entities::EmbeddedEntity::Region(_)) => "Region",
|
||||
Some(acadrust::entities::EmbeddedEntity::Ray(_)) => "Ray",
|
||||
Some(acadrust::entities::EmbeddedEntity::XLine(_)) => "XLine",
|
||||
Some(acadrust::entities::EmbeddedEntity::Unknown { .. }) => "Unknown",
|
||||
Some(codec::entities::EmbeddedEntity::Point(_)) => "Point",
|
||||
Some(codec::entities::EmbeddedEntity::Line(_)) => "Line",
|
||||
Some(codec::entities::EmbeddedEntity::Arc(_)) => "Arc",
|
||||
Some(codec::entities::EmbeddedEntity::Circle(_)) => "Circle",
|
||||
Some(codec::entities::EmbeddedEntity::Ellipse(_)) => "Ellipse",
|
||||
Some(codec::entities::EmbeddedEntity::Spline(_)) => "Spline",
|
||||
Some(codec::entities::EmbeddedEntity::LwPolyline(_)) => "Polyline",
|
||||
Some(codec::entities::EmbeddedEntity::Region(_)) => "Region",
|
||||
Some(codec::entities::EmbeddedEntity::Ray(_)) => "Ray",
|
||||
Some(codec::entities::EmbeddedEntity::XLine(_)) => "XLine",
|
||||
Some(codec::entities::EmbeddedEntity::Unknown { .. }) => "Unknown",
|
||||
None => "None",
|
||||
}
|
||||
}
|
||||
|
||||
fn vector_text(vector: &acadrust::types::Vector3) -> String {
|
||||
fn vector_text(vector: &codec::types::Vector3) -> String {
|
||||
format!("{:.6}, {:.6}, {:.6}", vector.x, vector.y, vector.z)
|
||||
}
|
||||
|
||||
@@ -457,7 +457,7 @@ fn matrix_text(matrix: &[f64; 16]) -> String {
|
||||
.join(" ")
|
||||
}
|
||||
|
||||
fn sweep_options_text(options: &acadrust::entities::SurfaceSweepOptions) -> String {
|
||||
fn sweep_options_text(options: &codec::entities::SurfaceSweepOptions) -> String {
|
||||
format!(
|
||||
"draft {:.6} ({:.6}→{:.6}); twist {:.6}; scale {:.6}; align {:.6}; solid {}; flags {}/{}; align-start {}; bank {}; base {}; sweep-xform {}; path-xform {}; ref {}",
|
||||
options.draft_angle,
|
||||
@@ -479,7 +479,7 @@ fn sweep_options_text(options: &acadrust::entities::SurfaceSweepOptions) -> Stri
|
||||
}
|
||||
|
||||
fn surface_construction_section(surface: &Surface) -> PropSection {
|
||||
use acadrust::entities::SurfaceData;
|
||||
use codec::entities::SurfaceData;
|
||||
let mut props = vec![
|
||||
ro(t!("Kind").as_ref(), "srf_kind", format!("{:?}", surface.kind)),
|
||||
ro(t!("Modeler Format").as_ref(),
|
||||
@@ -724,9 +724,9 @@ fn surface_construction_section(surface: &Surface) -> PropSection {
|
||||
}
|
||||
}
|
||||
|
||||
fn translate_surface(surface: &mut Surface, delta: acadrust::types::Vector3) {
|
||||
fn translate_surface(surface: &mut Surface, delta: codec::types::Vector3) {
|
||||
let before = surface.point_of_reference;
|
||||
acadrust::Entity::translate(surface, delta);
|
||||
codec::Entity::translate(surface, delta);
|
||||
if surface.point_of_reference == before {
|
||||
surface.point_of_reference = before + delta;
|
||||
}
|
||||
@@ -744,7 +744,7 @@ impl Grippable for Surface {
|
||||
if let GripApply::Translate(delta) = apply {
|
||||
translate_surface(
|
||||
self,
|
||||
acadrust::types::Vector3::new(delta.x, delta.y, delta.z),
|
||||
codec::types::Vector3::new(delta.x, delta.y, delta.z),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -791,24 +791,24 @@ impl PropertyEditable for Surface {
|
||||
return;
|
||||
};
|
||||
let delta = match field {
|
||||
"srf_px" => acadrust::types::Vector3::new(
|
||||
"srf_px" => codec::types::Vector3::new(
|
||||
value - self.point_of_reference.x,
|
||||
0.0,
|
||||
0.0,
|
||||
),
|
||||
"srf_py" => acadrust::types::Vector3::new(
|
||||
"srf_py" => codec::types::Vector3::new(
|
||||
0.0,
|
||||
value - self.point_of_reference.y,
|
||||
0.0,
|
||||
),
|
||||
"srf_pz" => acadrust::types::Vector3::new(
|
||||
"srf_pz" => codec::types::Vector3::new(
|
||||
0.0,
|
||||
0.0,
|
||||
value - self.point_of_reference.z,
|
||||
),
|
||||
_ => return,
|
||||
};
|
||||
if delta != acadrust::types::Vector3::ZERO {
|
||||
if delta != codec::types::Vector3::ZERO {
|
||||
translate_surface(self, delta);
|
||||
}
|
||||
}
|
||||
@@ -822,13 +822,13 @@ impl PropertyEditable for Surface {
|
||||
|
||||
use crate::scene::model::mesh_model::MeshLodSet;
|
||||
use crate::scene::convert::solid3d_tess;
|
||||
use acadrust::{types::Vector3, EntityType};
|
||||
use codec::{types::Vector3, EntityType};
|
||||
|
||||
const DISPLAY_DEFLECTION_COEFFICIENT: f64 = 2.5e-4;
|
||||
|
||||
/// Shared world-space chord tolerance for solid display.
|
||||
pub fn display_deflection(
|
||||
header: &acadrust::document::HeaderVariables,
|
||||
header: &codec::document::HeaderVariables,
|
||||
facet_res: f64,
|
||||
) -> Option<f64> {
|
||||
let low = header.model_space_extents_min;
|
||||
@@ -911,7 +911,7 @@ pub fn tessellate_volume(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use cadkernel::geom2d::{Curve, Line};
|
||||
use kernel::geom2d::{Curve, Line};
|
||||
|
||||
fn ring(points: &[[f64; 2]]) -> Vec<Curve> {
|
||||
points.iter().copied().zip(points.iter().copied().cycle().skip(1))
|
||||
|
||||
Reference in new issue
Block a user