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 <noreply@anthropic.com>
This commit is contained in:
1 parent
56c04408d6
commit
f537aff75c
430 files changed
+9925
-8540
No files matched your search
@@ -1,7 +1,7 @@
|
||||
//! Interactive Coincident input: ordered point/curve picks, repeated
|
||||
//! point-to-curve placement, and Coincident-only automatic inference.
|
||||
|
||||
use acadrust::{EntityType, Handle};
|
||||
use codec::{EntityType, Handle};
|
||||
use glam::DVec3;
|
||||
|
||||
use crate::command::{CadCommand, CmdOption, CmdResult, CoincidentPick};
|
||||
@@ -67,7 +67,7 @@ impl CoincidentConstraintCommand {
|
||||
fn picked_constraint_point(entity: &EntityType, point: DVec3) -> bool {
|
||||
crate::scene::parametric_constraints::is_parametric_point_near(
|
||||
entity,
|
||||
acadrust::types::Vector3::new(point.x, point.y, point.z),
|
||||
codec::types::Vector3::new(point.x, point.y, point.z),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ inventory::submit!(crate::command::CommandRegistration {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use acadrust::types::Vector3;
|
||||
use codec::types::Vector3;
|
||||
|
||||
#[test]
|
||||
fn multiple_keeps_the_first_curve_for_repeated_points() {
|
||||
@@ -313,7 +313,7 @@ mod tests {
|
||||
Some(CmdResult::NeedPoint)
|
||||
));
|
||||
command.inject_picked_entity(EntityType::Line(
|
||||
acadrust::entities::Line::from_points(Vector3::ZERO, Vector3::UNIT_X),
|
||||
codec::entities::Line::from_points(Vector3::ZERO, Vector3::UNIT_X),
|
||||
));
|
||||
let handle = Handle::new(7);
|
||||
assert!(matches!(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use acadrust::{EntityType, Handle};
|
||||
use codec::{EntityType, Handle};
|
||||
use glam::DVec3;
|
||||
|
||||
use crate::command::{CadCommand, CmdResult};
|
||||
@@ -55,8 +55,8 @@ impl ConcentricConstraintCommand {
|
||||
let planar = crate::entities::curve::entity_curve(entity)?;
|
||||
let local = planar.plane.project(point.to_array())?;
|
||||
let segments = planar.curve.segments();
|
||||
let (index, _) = cadkernel::geom2d::nearest_of(segments.iter(), local)?;
|
||||
matches!(segments.get(index), Some(cadkernel::geom2d::Curve::Arc(_)))
|
||||
let (index, _) = kernel::geom2d::nearest_of(segments.iter(), local)?;
|
||||
matches!(segments.get(index), Some(kernel::geom2d::Curve::Arc(_)))
|
||||
.then(|| ParametricRef::segment_center(handle, index))
|
||||
}
|
||||
_ => None,
|
||||
@@ -164,14 +164,14 @@ mod tests {
|
||||
#[test]
|
||||
fn polyline_pick_keeps_the_selected_arc_center() {
|
||||
let handle = Handle::new(13);
|
||||
let mut polyline = acadrust::entities::LwPolyline::new();
|
||||
let mut polyline = codec::entities::LwPolyline::new();
|
||||
polyline.vertices = vec![
|
||||
acadrust::entities::LwVertex::from_coords(0.0, 0.0),
|
||||
acadrust::entities::LwVertex::with_bulge(
|
||||
acadrust::types::Vector2::new(5.0, 0.0),
|
||||
codec::entities::LwVertex::from_coords(0.0, 0.0),
|
||||
codec::entities::LwVertex::with_bulge(
|
||||
codec::types::Vector2::new(5.0, 0.0),
|
||||
1.0,
|
||||
),
|
||||
acadrust::entities::LwVertex::from_coords(10.0, 0.0),
|
||||
codec::entities::LwVertex::from_coords(10.0, 0.0),
|
||||
];
|
||||
|
||||
let reference = ConcentricConstraintCommand::picked_reference(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use acadrust::Handle;
|
||||
use codec::Handle;
|
||||
use glam::DVec3;
|
||||
|
||||
use crate::command::{CadCommand, CmdOption, CmdResult};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use acadrust::{EntityType, Handle};
|
||||
use codec::{EntityType, Handle};
|
||||
use glam::DVec3;
|
||||
|
||||
use crate::command::{CadCommand, CmdOption, CmdResult, CoincidentPick};
|
||||
@@ -1432,8 +1432,8 @@ impl CadCommand for DimensionValueCommand {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use acadrust::entities::Line;
|
||||
use acadrust::types::Vector3;
|
||||
use codec::entities::Line;
|
||||
use codec::types::Vector3;
|
||||
|
||||
#[test]
|
||||
fn object_pick_takes_the_line_ends_then_asks_for_the_location() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use acadrust::{EntityType, Handle};
|
||||
use codec::{EntityType, Handle};
|
||||
use glam::DVec3;
|
||||
|
||||
use crate::command::{CadCommand, CmdOption, CmdResult};
|
||||
@@ -198,8 +198,8 @@ inventory::submit!(crate::command::CommandRegistration {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use acadrust::entities::Line;
|
||||
use acadrust::types::Vector3;
|
||||
use codec::entities::Line;
|
||||
use codec::types::Vector3;
|
||||
|
||||
fn line() -> EntityType {
|
||||
EntityType::Line(Line::from_points(Vector3::ZERO, Vector3::new(10.0, 0.0, 0.0)))
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//! click, the driver maps it to a `ParametricRef` and re-prompts on a miss,
|
||||
//! the way the reference does.
|
||||
|
||||
use acadrust::{EntityType, Handle};
|
||||
use codec::{EntityType, Handle};
|
||||
use glam::DVec3;
|
||||
|
||||
use crate::command::{CadCommand, CmdOption, CmdResult, CoincidentPick};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use acadrust::{EntityType, Handle};
|
||||
use codec::{EntityType, Handle};
|
||||
use glam::DVec3;
|
||||
|
||||
use crate::command::{
|
||||
@@ -79,12 +79,12 @@ impl HorizontalConstraintCommand {
|
||||
}
|
||||
}
|
||||
|
||||
fn direction(&self) -> acadrust::types::Vector3 {
|
||||
fn direction(&self) -> codec::types::Vector3 {
|
||||
let direction = match self.kind {
|
||||
ConstraintKind::Vertical => self.plane.y.normalize_or(DVec3::Y),
|
||||
_ => self.plane.x.normalize_or(DVec3::X),
|
||||
};
|
||||
acadrust::types::Vector3::new(direction.x, direction.y, direction.z)
|
||||
codec::types::Vector3::new(direction.x, direction.y, direction.z)
|
||||
}
|
||||
|
||||
fn invalid_object(&self) -> CmdResult {
|
||||
@@ -112,11 +112,11 @@ impl HorizontalConstraintCommand {
|
||||
}
|
||||
}
|
||||
|
||||
fn distance_to_axis(point: DVec3, endpoints: [acadrust::types::Vector3; 2]) -> f64 {
|
||||
cadkernel::space::Vec3::from(point.to_array())
|
||||
fn distance_to_axis(point: DVec3, endpoints: [codec::types::Vector3; 2]) -> f64 {
|
||||
kernel::space::Vec3::from(point.to_array())
|
||||
.distance_to_line(
|
||||
cadkernel::space::Vec3::new(endpoints[0].x, endpoints[0].y, endpoints[0].z),
|
||||
cadkernel::space::Vec3::new(endpoints[1].x, endpoints[1].y, endpoints[1].z),
|
||||
kernel::space::Vec3::new(endpoints[0].x, endpoints[0].y, endpoints[0].z),
|
||||
kernel::space::Vec3::new(endpoints[1].x, endpoints[1].y, endpoints[1].z),
|
||||
)
|
||||
.unwrap_or(f64::INFINITY)
|
||||
}
|
||||
@@ -305,7 +305,7 @@ impl CadCommand for HorizontalConstraintCommand {
|
||||
}
|
||||
}
|
||||
Step::FirstPoint | Step::SecondPoint(_) => {
|
||||
let world = acadrust::types::Vector3::new(point.x, point.y, point.z);
|
||||
let world = codec::types::Vector3::new(point.x, point.y, point.z);
|
||||
if !is_parametric_point_near(&entity, world) {
|
||||
return Self::invalid_point();
|
||||
}
|
||||
@@ -352,8 +352,8 @@ impl CadCommand for HorizontalConstraintCommand {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use acadrust::entities::Line;
|
||||
use acadrust::types::Vector3;
|
||||
use codec::entities::Line;
|
||||
use codec::types::Vector3;
|
||||
|
||||
#[test]
|
||||
fn object_pick_captures_the_working_x_direction() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use acadrust::{EntityType, Handle};
|
||||
use codec::{EntityType, Handle};
|
||||
use glam::DVec3;
|
||||
|
||||
use crate::command::{CadCommand, CmdResult};
|
||||
@@ -32,11 +32,11 @@ impl PerpendicularConstraintCommand {
|
||||
)
|
||||
}
|
||||
|
||||
fn distance_to_axis(point: DVec3, endpoints: [acadrust::types::Vector3; 2]) -> f64 {
|
||||
cadkernel::space::Vec3::from(point.to_array())
|
||||
fn distance_to_axis(point: DVec3, endpoints: [codec::types::Vector3; 2]) -> f64 {
|
||||
kernel::space::Vec3::from(point.to_array())
|
||||
.distance_to_line(
|
||||
cadkernel::space::Vec3::new(endpoints[0].x, endpoints[0].y, endpoints[0].z),
|
||||
cadkernel::space::Vec3::new(endpoints[1].x, endpoints[1].y, endpoints[1].z),
|
||||
kernel::space::Vec3::new(endpoints[0].x, endpoints[0].y, endpoints[0].z),
|
||||
kernel::space::Vec3::new(endpoints[1].x, endpoints[1].y, endpoints[1].z),
|
||||
)
|
||||
.unwrap_or(f64::INFINITY)
|
||||
}
|
||||
@@ -213,8 +213,8 @@ impl CadCommand for PerpendicularConstraintCommand {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use acadrust::entities::Line;
|
||||
use acadrust::types::Vector3;
|
||||
use codec::entities::Line;
|
||||
use codec::types::Vector3;
|
||||
|
||||
#[test]
|
||||
fn command_preserves_pick_order_for_the_solver() {
|
||||
@@ -252,11 +252,11 @@ mod tests {
|
||||
#[test]
|
||||
fn preselection_uses_the_first_straight_polyline_segment() {
|
||||
let handle = Handle::new(11);
|
||||
let mut polyline = acadrust::entities::LwPolyline::new();
|
||||
let mut polyline = codec::entities::LwPolyline::new();
|
||||
polyline.vertices = vec![
|
||||
acadrust::entities::LwVertex::with_bulge(acadrust::types::Vector2::new(0.0, 0.0), 1.0),
|
||||
acadrust::entities::LwVertex::from_coords(4.0, 0.0),
|
||||
acadrust::entities::LwVertex::from_coords(8.0, 0.0),
|
||||
codec::entities::LwVertex::with_bulge(codec::types::Vector2::new(0.0, 0.0), 1.0),
|
||||
codec::entities::LwVertex::from_coords(4.0, 0.0),
|
||||
codec::entities::LwVertex::from_coords(8.0, 0.0),
|
||||
];
|
||||
|
||||
let pick = PerpendicularConstraintCommand::preselected_reference(
|
||||
|
||||
@@ -16,7 +16,7 @@ use glam::DVec3;
|
||||
use crate::command::{CadCommand, CmdResult};
|
||||
use crate::modules::{IconKind, ModuleEvent, ToolDef};
|
||||
use crate::scene::parametric_constraints::ConstraintKind;
|
||||
use acadrust::types::Handle;
|
||||
use codec::types::Handle;
|
||||
|
||||
pub mod center_point_tool {
|
||||
use super::*;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use acadrust::{EntityType, Handle};
|
||||
use codec::{EntityType, Handle};
|
||||
use glam::DVec3;
|
||||
|
||||
use crate::command::{CadCommand, CmdResult};
|
||||
@@ -24,11 +24,11 @@ impl SmoothConstraintCommand {
|
||||
}
|
||||
}
|
||||
|
||||
fn point(point: acadrust::types::Vector3) -> DVec3 {
|
||||
fn point(point: codec::types::Vector3) -> DVec3 {
|
||||
DVec3::new(point.x, point.y, point.z)
|
||||
}
|
||||
|
||||
fn nearest_marker(points: &[acadrust::types::Vector3], point: DVec3) -> Option<i32> {
|
||||
fn nearest_marker(points: &[codec::types::Vector3], point: DVec3) -> Option<i32> {
|
||||
points
|
||||
.iter()
|
||||
.enumerate()
|
||||
@@ -77,7 +77,7 @@ impl SmoothConstraintCommand {
|
||||
let planar = crate::entities::curve::entity_curve(entity)?;
|
||||
let local = planar.plane.project(point.to_array())?;
|
||||
let segments = planar.curve.segments();
|
||||
let (segment, _) = cadkernel::geom2d::nearest_of(segments.iter(), local)?;
|
||||
let (segment, _) = kernel::geom2d::nearest_of(segments.iter(), local)?;
|
||||
let points = crate::scene::dimension_assoc::source_points(entity);
|
||||
let closed = match entity {
|
||||
EntityType::LwPolyline(polyline) => polyline.is_closed,
|
||||
@@ -114,7 +114,7 @@ impl SmoothConstraintCommand {
|
||||
.copied()
|
||||
.min_by(|left, right| {
|
||||
let target_points = crate::scene::dimension_assoc::source_points(second.0);
|
||||
let distance = |source: acadrust::types::Vector3| {
|
||||
let distance = |source: codec::types::Vector3| {
|
||||
target_points
|
||||
.iter()
|
||||
.map(|target| (source - *target).length_squared())
|
||||
@@ -239,14 +239,14 @@ mod tests {
|
||||
#[test]
|
||||
fn polyline_target_keeps_the_picked_arc_segment_and_endpoint() {
|
||||
let handle = Handle::new(7);
|
||||
let mut polyline = acadrust::entities::LwPolyline::new();
|
||||
let mut polyline = codec::entities::LwPolyline::new();
|
||||
polyline.vertices = vec![
|
||||
acadrust::entities::LwVertex::from_coords(0.0, 0.0),
|
||||
acadrust::entities::LwVertex::with_bulge(
|
||||
acadrust::types::Vector2::new(5.0, 0.0),
|
||||
codec::entities::LwVertex::from_coords(0.0, 0.0),
|
||||
codec::entities::LwVertex::with_bulge(
|
||||
codec::types::Vector2::new(5.0, 0.0),
|
||||
1.0,
|
||||
),
|
||||
acadrust::entities::LwVertex::from_coords(10.0, 0.0),
|
||||
codec::entities::LwVertex::from_coords(10.0, 0.0),
|
||||
];
|
||||
|
||||
let target = SmoothConstraintCommand::target_reference(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use acadrust::{EntityType, Handle};
|
||||
use codec::{EntityType, Handle};
|
||||
use glam::DVec3;
|
||||
|
||||
use crate::command::{
|
||||
@@ -83,7 +83,7 @@ impl SymmetricConstraintCommand {
|
||||
let planar = crate::entities::curve::entity_curve(entity)?;
|
||||
let local = planar.plane.project(point.to_array())?;
|
||||
let segments = planar.curve.segments();
|
||||
let (index, _) = cadkernel::geom2d::nearest_of(segments.iter(), local)?;
|
||||
let (index, _) = kernel::geom2d::nearest_of(segments.iter(), local)?;
|
||||
Some((index, Self::segment_family(entity, index)?))
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ impl CadCommand for SymmetricConstraintCommand {
|
||||
CmdResult::NeedPoint
|
||||
}
|
||||
Step::FirstPoint | Step::SecondPoint(_) => {
|
||||
let world = acadrust::types::Vector3::new(point.x, point.y, point.z);
|
||||
let world = codec::types::Vector3::new(point.x, point.y, point.z);
|
||||
if !is_parametric_point_near(&entity, world) {
|
||||
return Self::invalid_point();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use acadrust::{EntityType, Handle};
|
||||
use codec::{EntityType, Handle};
|
||||
use glam::DVec3;
|
||||
|
||||
use crate::command::{CadCommand, CmdResult};
|
||||
@@ -169,8 +169,8 @@ impl CadCommand for TangentConstraintCommand {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use acadrust::entities::{Circle, Line};
|
||||
use acadrust::types::Vector3;
|
||||
use codec::entities::{Circle, Line};
|
||||
use codec::types::Vector3;
|
||||
|
||||
#[test]
|
||||
fn command_preserves_pick_order_for_the_initial_anchor() {
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
//! submits) is still computed from a one-time read of current geometry —
|
||||
//! that part doesn't change.
|
||||
|
||||
use acadrust::entities::EntityType;
|
||||
use acadrust::types::Handle;
|
||||
use codec::entities::EntityType;
|
||||
use codec::types::Handle;
|
||||
use glam::DVec3;
|
||||
|
||||
use crate::command::{CadCommand, CmdResult, InputKind};
|
||||
@@ -439,16 +439,16 @@ mod tests {
|
||||
}
|
||||
|
||||
fn add_line(scene: &mut Scene) -> Handle {
|
||||
scene.add_entity(EntityType::Line(acadrust::entities::Line::from_points(
|
||||
acadrust::types::Vector3::new(0.0, 0.0, 0.0),
|
||||
acadrust::types::Vector3::new(6.0, 8.0, 0.0),
|
||||
scene.add_entity(EntityType::Line(codec::entities::Line::from_points(
|
||||
codec::types::Vector3::new(0.0, 0.0, 0.0),
|
||||
codec::types::Vector3::new(6.0, 8.0, 0.0),
|
||||
)))
|
||||
}
|
||||
|
||||
fn add_circle(scene: &mut Scene) -> Handle {
|
||||
scene.add_entity(EntityType::Circle(
|
||||
acadrust::entities::Circle::from_center_radius(
|
||||
acadrust::types::Vector3::new(0.0, 0.0, 0.0),
|
||||
codec::entities::Circle::from_center_radius(
|
||||
codec::types::Vector3::new(0.0, 0.0, 0.0),
|
||||
3.0,
|
||||
),
|
||||
))
|
||||
|
||||
Reference in new issue
Block a user