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
@@ -334,7 +334,7 @@ impl Camera {
|
||||
(origin, forward)
|
||||
}
|
||||
};
|
||||
cadkernel::space::plane::intersect_line_plane(
|
||||
kernel::space::plane::intersect_line_plane(
|
||||
(ray_origin - (plane_point - eye)).to_array(),
|
||||
ray_dir.to_array(),
|
||||
[0.0; 3],
|
||||
@@ -396,8 +396,8 @@ impl Camera {
|
||||
/// Carry the camera through a rigid model-space transform. BEDIT uses this
|
||||
/// when a transient UCS is baked into block-local geometry: the contents
|
||||
/// retain their on-screen framing while their canonical coordinates change.
|
||||
pub fn apply_rigid_transform(&mut self, transform: &acadrust::types::Transform) {
|
||||
let point = acadrust::types::Vector3::new(
|
||||
pub fn apply_rigid_transform(&mut self, transform: &codec::types::Transform) {
|
||||
let point = codec::types::Vector3::new(
|
||||
self.target.x,
|
||||
self.target.y,
|
||||
self.target.z,
|
||||
@@ -428,7 +428,7 @@ impl Camera {
|
||||
let mut new_min = DVec3::splat(f64::INFINITY);
|
||||
let mut new_max = DVec3::splat(f64::NEG_INFINITY);
|
||||
for corner in corners {
|
||||
let transformed = transform.apply(acadrust::types::Vector3::new(
|
||||
let transformed = transform.apply(codec::types::Vector3::new(
|
||||
corner.x,
|
||||
corner.y,
|
||||
corner.z,
|
||||
|
||||
+10
-10
@@ -1,7 +1,7 @@
|
||||
// Dispatch entry points for entity editing.
|
||||
|
||||
use acadrust::types::{Color as AcadColor, LineWeight, Transparency};
|
||||
use acadrust::{EntityType, Handle};
|
||||
use codec::types::{Color as AcadColor, LineWeight, Transparency};
|
||||
use codec::{EntityType, Handle};
|
||||
|
||||
use crate::command::EntityTransform;
|
||||
use crate::entities::traits::EntityTypeOps;
|
||||
@@ -232,13 +232,13 @@ pub fn apply_common_prop(entity: &mut EntityType, field: &str, value: &str) {
|
||||
/// stale verbatim block (matched by APPID handle) so the new value wins.
|
||||
/// Other applications' verbatim blocks are preserved for round-trip fidelity.
|
||||
pub fn set_entity_xdata(
|
||||
doc: &mut acadrust::CadDocument,
|
||||
handle: acadrust::Handle,
|
||||
doc: &mut codec::CadDocument,
|
||||
handle: codec::Handle,
|
||||
app: &str,
|
||||
values: Option<Vec<acadrust::xdata::XDataValue>>,
|
||||
values: Option<Vec<codec::xdata::XDataValue>>,
|
||||
) {
|
||||
if values.is_some() && !doc.app_ids.contains(app) {
|
||||
let mut a = acadrust::tables::AppId::new(app);
|
||||
let mut a = codec::tables::AppId::new(app);
|
||||
a.handle = doc.allocate_handle();
|
||||
let _ = doc.app_ids.add(a);
|
||||
}
|
||||
@@ -247,14 +247,14 @@ pub fn set_entity_xdata(
|
||||
return;
|
||||
};
|
||||
let common = entity.common_mut();
|
||||
let mut rebuilt = acadrust::xdata::ExtendedData::new();
|
||||
let mut rebuilt = codec::xdata::ExtendedData::new();
|
||||
for r in common.extended_data.records() {
|
||||
if r.application_name != app {
|
||||
rebuilt.add_record(r.clone());
|
||||
}
|
||||
}
|
||||
if let Some(vals) = values {
|
||||
let mut rec = acadrust::xdata::ExtendedDataRecord::new(app);
|
||||
let mut rec = codec::xdata::ExtendedDataRecord::new(app);
|
||||
for v in vals {
|
||||
rec.add_value(v);
|
||||
}
|
||||
@@ -404,11 +404,11 @@ pub fn apply_transform(entity: &mut EntityType, t: &EntityTransform) {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use acadrust::types::Vector3;
|
||||
use codec::types::Vector3;
|
||||
|
||||
#[test]
|
||||
fn line_thickness_follows_the_entity_geometry_rows() {
|
||||
let mut line = acadrust::entities::Line::from_points(Vector3::ZERO, Vector3::UNIT_X);
|
||||
let mut line = codec::entities::Line::from_points(Vector3::ZERO, Vector3::UNIT_X);
|
||||
line.thickness = 2.5;
|
||||
let sections = properties_sectioned(Handle::NULL, &EntityType::Line(line), &[]);
|
||||
|
||||
|
||||
+91
-91
@@ -1,9 +1,9 @@
|
||||
// GPU rendering primitives, shader::Program / shader::Primitive impls,
|
||||
// and entity render-style helpers for the Scene.
|
||||
|
||||
use acadrust::tables::LineType;
|
||||
use acadrust::types::{Color as AcadColor, LineWeight};
|
||||
use acadrust::{CadDocument, EntityType, Handle};
|
||||
use codec::tables::LineType;
|
||||
use codec::types::{Color as AcadColor, LineWeight};
|
||||
use codec::{CadDocument, EntityType, Handle};
|
||||
use glam::Mat4;
|
||||
use iced::mouse;
|
||||
use iced::widget::shader::{self, Viewport};
|
||||
@@ -239,9 +239,9 @@ pub struct ViewportData {
|
||||
/// so `prepare` can patch just those entities' slabs. `None` ⇒ full build.
|
||||
pub(in crate::scene) wire_patch: Option<(u64, Arc<crate::scene::WireGpuPatch>)>,
|
||||
/// Selected handles only (no hover) — solid meshes tint these blue.
|
||||
pub(in crate::scene) selected_handles: Arc<rustc_hash::FxHashSet<acadrust::Handle>>,
|
||||
pub(in crate::scene) selected_handles: Arc<rustc_hash::FxHashSet<codec::Handle>>,
|
||||
/// Currently hovered selectable unit — solid meshes tint it orange.
|
||||
pub(in crate::scene) hover_handles: Arc<rustc_hash::FxHashSet<acadrust::Handle>>,
|
||||
pub(in crate::scene) hover_handles: Arc<rustc_hash::FxHashSet<codec::Handle>>,
|
||||
/// Bumped on selection / hover change. Paired with `wire_content_id` to
|
||||
/// decide when the xray overlay batch needs rebuilding.
|
||||
pub(in crate::scene) selection_generation: u64,
|
||||
@@ -274,7 +274,7 @@ pub struct Primitive {
|
||||
}
|
||||
|
||||
/// Flags the render pipeline consumes, derived from
|
||||
/// [`acadrust::entities::ViewportRenderMode`]. Each shaded variant fills
|
||||
/// [`codec::entities::ViewportRenderMode`]. Each shaded variant fills
|
||||
/// 3D faces and meshes; the pure wireframes drop the fill and keep only
|
||||
/// edges. The optimized 2-D wireframe retains planar SOLID interiors and
|
||||
/// entity draw order; the 3-D wireframe uses true depth and outlines them.
|
||||
@@ -297,9 +297,9 @@ pub struct RenderModeFlags {
|
||||
}
|
||||
|
||||
pub fn render_mode_flags(
|
||||
mode: acadrust::entities::ViewportRenderMode,
|
||||
mode: codec::entities::ViewportRenderMode,
|
||||
) -> RenderModeFlags {
|
||||
use acadrust::entities::ViewportRenderMode as M;
|
||||
use codec::entities::ViewportRenderMode as M;
|
||||
match mode {
|
||||
M::Wireframe2D => RenderModeFlags {
|
||||
face3d_fill: false,
|
||||
@@ -672,11 +672,11 @@ impl shader::Primitive for Primitive {
|
||||
// scanned/parses all resident wires repeatedly here even
|
||||
// though WireArena emits just one changed entity.
|
||||
let mut regular_changed: rustc_hash::FxHashMap<
|
||||
acadrust::Handle,
|
||||
codec::Handle,
|
||||
Vec<&crate::scene::WireModel>,
|
||||
> = rustc_hash::FxHashMap::default();
|
||||
let mut mesh_changed: rustc_hash::FxHashMap<
|
||||
acadrust::Handle,
|
||||
codec::Handle,
|
||||
Vec<&crate::scene::WireModel>,
|
||||
> = rustc_hash::FxHashMap::default();
|
||||
if let Some(patch) = patch {
|
||||
@@ -767,7 +767,7 @@ impl shader::Primitive for Primitive {
|
||||
wire.name
|
||||
.parse::<u64>()
|
||||
.ok()
|
||||
.map(acadrust::Handle::new)
|
||||
.map(codec::Handle::new)
|
||||
})
|
||||
.collect();
|
||||
} else if inner.wire_arena_fallback_kind == Some(false) {
|
||||
@@ -804,7 +804,7 @@ impl shader::Primitive for Primitive {
|
||||
wire.name
|
||||
.parse::<u64>()
|
||||
.ok()
|
||||
.map(acadrust::Handle::new)
|
||||
.map(codec::Handle::new)
|
||||
})
|
||||
.collect();
|
||||
} else if inner.wire_arena_fallback_kind == Some(true) {
|
||||
@@ -1936,8 +1936,8 @@ fn normalized_direction(value: [f64; 3], fallback: [f32; 3]) -> [f32; 3] {
|
||||
}
|
||||
|
||||
fn solar_direction(
|
||||
sun: &acadrust::objects::Sun,
|
||||
geo: &acadrust::objects::GeoData,
|
||||
sun: &codec::objects::Sun,
|
||||
geo: &codec::objects::GeoData,
|
||||
) -> Option<[f32; 3]> {
|
||||
if sun.julian_day < 1_000_000 {
|
||||
return None;
|
||||
@@ -2036,7 +2036,7 @@ text_atlas={:.1} wire_arena={:.1} block_geometry={:.1}",
|
||||
}
|
||||
|
||||
impl Scene {
|
||||
fn model_tile_vport(&self, index: usize) -> Option<&acadrust::tables::VPort> {
|
||||
fn model_tile_vport(&self, index: usize) -> Option<&codec::tables::VPort> {
|
||||
let rect = self.model_tiles.borrow().get(index)?.rect;
|
||||
let lower_left = [rect.x as f64, (1.0 - rect.y - rect.height) as f64];
|
||||
let upper_right = [
|
||||
@@ -2084,8 +2084,8 @@ impl Scene {
|
||||
})
|
||||
}
|
||||
|
||||
fn geolocation(&self) -> Option<&acadrust::objects::GeoData> {
|
||||
use acadrust::objects::ObjectType;
|
||||
fn geolocation(&self) -> Option<&codec::objects::GeoData> {
|
||||
use codec::objects::ObjectType;
|
||||
|
||||
crate::entities::object_data::geo_objects(&self.object_data_cache)
|
||||
.iter()
|
||||
@@ -2105,9 +2105,9 @@ impl Scene {
|
||||
target_block: Handle,
|
||||
frozen: &rustc_hash::FxHashSet<Handle>,
|
||||
) -> Vec<SceneLight> {
|
||||
use acadrust::objects::{ClassObjectData, ObjectType};
|
||||
use codec::objects::{ClassObjectData, ObjectType};
|
||||
|
||||
fn converted(scene: &Scene, light: &acadrust::entities::Light) -> Option<SceneLight> {
|
||||
fn converted(scene: &Scene, light: &codec::entities::Light) -> Option<SceneLight> {
|
||||
if !light.status {
|
||||
return None;
|
||||
}
|
||||
@@ -2353,8 +2353,8 @@ impl Scene {
|
||||
None => self.document.objects.get(&light.handle).is_some_and(|object| {
|
||||
matches!(
|
||||
object,
|
||||
acadrust::objects::ObjectType::ClassObject(value)
|
||||
if matches!(&value.data, acadrust::objects::ClassObjectData::Sun(_))
|
||||
codec::objects::ObjectType::ClassObject(value)
|
||||
if matches!(&value.data, codec::objects::ClassObjectData::Sun(_))
|
||||
) && (!settings.sun_handle.is_valid()
|
||||
|| settings.sun_handle == light.handle)
|
||||
}),
|
||||
@@ -2507,13 +2507,13 @@ impl Scene {
|
||||
[r as f32 / 255.0, g as f32 / 255.0, b as f32 / 255.0]
|
||||
})
|
||||
};
|
||||
let from_entity = |value: &acadrust::entities::Viewport| ViewportLightingSettings {
|
||||
let from_entity = |value: &codec::entities::Viewport| ViewportLightingSettings {
|
||||
force_default: value.default_lighting,
|
||||
default_type: value.default_lighting_type,
|
||||
ambient: ambient(&value.ambient_color),
|
||||
sun_handle: value.sun_handle,
|
||||
};
|
||||
let from_table = |value: &acadrust::tables::VPort| ViewportLightingSettings {
|
||||
let from_table = |value: &codec::tables::VPort| ViewportLightingSettings {
|
||||
force_default: value.use_default_lights,
|
||||
default_type: value.default_lighting_type,
|
||||
ambient: ambient(&value.ambient_color),
|
||||
@@ -2784,7 +2784,7 @@ impl Scene {
|
||||
}
|
||||
|
||||
fn resolve_document_render_environment(&self) -> CachedDocumentRenderEnvironment {
|
||||
use acadrust::objects::{ClassObjectData, ObjectType};
|
||||
use codec::objects::{ClassObjectData, ObjectType};
|
||||
|
||||
let mut result = CachedDocumentRenderEnvironment::default();
|
||||
|
||||
@@ -2823,8 +2823,8 @@ impl Scene {
|
||||
|
||||
(env, pre)
|
||||
} else {
|
||||
let mut best_env: Option<(acadrust::Handle, &acadrust::objects::RenderEnvironment)> = None;
|
||||
let mut best_preset: Option<(acadrust::Handle, &acadrust::objects::RenderSettings)> = None;
|
||||
let mut best_env: Option<(codec::Handle, &codec::objects::RenderEnvironment)> = None;
|
||||
let mut best_preset: Option<(codec::Handle, &codec::objects::RenderSettings)> = None;
|
||||
|
||||
for (handle, object) in &self.document.objects {
|
||||
if let ObjectType::ClassObject(value) = object {
|
||||
@@ -2950,7 +2950,7 @@ impl Scene {
|
||||
canvas: [f32; 4],
|
||||
depth: usize,
|
||||
) -> ViewportBackgroundSettings {
|
||||
use acadrust::objects::{ClassObjectData, ObjectType};
|
||||
use codec::objects::{ClassObjectData, ObjectType};
|
||||
|
||||
if depth > 4 || !handle.is_valid() {
|
||||
return ViewportBackgroundSettings::canvas(canvas);
|
||||
@@ -3336,7 +3336,7 @@ impl Scene {
|
||||
boundary_exterior: None,
|
||||
boundary_sources: None,
|
||||
boundary_paths: None,
|
||||
style: acadrust::entities::HatchStyleType::Normal,
|
||||
style: codec::entities::HatchStyleType::Normal,
|
||||
pattern: pattern.clone(),
|
||||
name: "PLOTSTYLE".to_string(),
|
||||
color,
|
||||
@@ -3385,7 +3385,7 @@ pub(in crate::scene) fn linetype_name_for<'a>(document: &'a CadDocument, e: &'a
|
||||
|
||||
pub(in crate::scene) fn linetype_name_for_common_viewport<'a>(
|
||||
document: &'a CadDocument,
|
||||
common: &'a acadrust::entities::EntityCommon,
|
||||
common: &'a codec::entities::EntityCommon,
|
||||
viewport: Option<Handle>,
|
||||
) -> &'a str {
|
||||
let elt = &common.linetype;
|
||||
@@ -3395,7 +3395,7 @@ pub(in crate::scene) fn linetype_name_for_common_viewport<'a>(
|
||||
document,
|
||||
&common.layer,
|
||||
viewport,
|
||||
acadrust::objects::KnownXRecordKind::LayerViewportLinetypeOverride,
|
||||
codec::objects::KnownXRecordKind::LayerViewportLinetypeOverride,
|
||||
)
|
||||
.and_then(|value| value.as_handle())
|
||||
{
|
||||
@@ -3435,8 +3435,8 @@ fn viewport_override(
|
||||
document: &CadDocument,
|
||||
layer_name: &str,
|
||||
viewport: Option<Handle>,
|
||||
kind: acadrust::objects::KnownXRecordKind,
|
||||
) -> Option<acadrust::objects::XRecordValue> {
|
||||
kind: codec::objects::KnownXRecordKind,
|
||||
) -> Option<codec::objects::XRecordValue> {
|
||||
let viewport = viewport.filter(|handle| handle.is_valid())?;
|
||||
let layer = document.layers.get(layer_name)?;
|
||||
document
|
||||
@@ -3447,7 +3447,7 @@ fn viewport_override(
|
||||
|
||||
pub(crate) fn render_style_for_common_viewport(
|
||||
document: &CadDocument,
|
||||
common: &acadrust::entities::EntityCommon,
|
||||
common: &codec::entities::EntityCommon,
|
||||
viewport: Option<Handle>,
|
||||
) -> ([f32; 4], f32, [f32; 8], f32, u8) {
|
||||
let layer_name = &common.layer;
|
||||
@@ -3457,7 +3457,7 @@ pub(crate) fn render_style_for_common_viewport(
|
||||
.filter(|handle| handle.is_valid())
|
||||
.and_then(|handle| document.objects.get(&handle))
|
||||
.and_then(|object| match object {
|
||||
acadrust::objects::ObjectType::BookColor(book) => Some(&book.color),
|
||||
codec::objects::ObjectType::BookColor(book) => Some(&book.color),
|
||||
_ => None,
|
||||
});
|
||||
let ec = book_color.unwrap_or(&common.color);
|
||||
@@ -3467,7 +3467,7 @@ pub(crate) fn render_style_for_common_viewport(
|
||||
document,
|
||||
layer_name,
|
||||
viewport,
|
||||
acadrust::objects::KnownXRecordKind::LayerViewportColorOverride,
|
||||
codec::objects::KnownXRecordKind::LayerViewportColorOverride,
|
||||
)
|
||||
.and_then(|value| value.as_i32())
|
||||
.map(AcadColor::from_true_color_value)
|
||||
@@ -3495,10 +3495,10 @@ pub(crate) fn render_style_for_common_viewport(
|
||||
document,
|
||||
layer_name,
|
||||
viewport,
|
||||
acadrust::objects::KnownXRecordKind::LayerViewportAlphaOverride,
|
||||
codec::objects::KnownXRecordKind::LayerViewportAlphaOverride,
|
||||
)
|
||||
.and_then(|value| value.as_i32())
|
||||
.map(|value| acadrust::types::Transparency::from_alpha_value(value as u32))
|
||||
.map(|value| codec::types::Transparency::from_alpha_value(value as u32))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
@@ -3525,7 +3525,7 @@ pub(crate) fn render_style_for_common_viewport(
|
||||
document,
|
||||
layer_name,
|
||||
viewport,
|
||||
acadrust::objects::KnownXRecordKind::LayerViewportLineweightOverride,
|
||||
codec::objects::KnownXRecordKind::LayerViewportLineweightOverride,
|
||||
)
|
||||
.and_then(|value| value.as_i32())
|
||||
.map(|value| LineWeight::from_value(value as i16))
|
||||
@@ -3554,13 +3554,13 @@ pub(crate) fn render_style_for_viewport(
|
||||
|
||||
pub(crate) fn has_resolved_book_color_common(
|
||||
document: &CadDocument,
|
||||
common: &acadrust::entities::EntityCommon,
|
||||
common: &codec::entities::EntityCommon,
|
||||
) -> bool {
|
||||
common
|
||||
.color_book_handle
|
||||
.filter(|handle| handle.is_valid())
|
||||
.and_then(|handle| document.objects.get(&handle))
|
||||
.is_some_and(|object| matches!(object, acadrust::objects::ObjectType::BookColor(_)))
|
||||
.is_some_and(|object| matches!(object, codec::objects::ObjectType::BookColor(_)))
|
||||
}
|
||||
|
||||
pub(crate) fn has_resolved_book_color(document: &CadDocument, e: &EntityType) -> bool {
|
||||
@@ -3608,7 +3608,7 @@ pub(crate) fn layer_render_style_viewport(
|
||||
document,
|
||||
layer_name,
|
||||
viewport,
|
||||
acadrust::objects::KnownXRecordKind::LayerViewportColorOverride,
|
||||
codec::objects::KnownXRecordKind::LayerViewportColorOverride,
|
||||
)
|
||||
.and_then(|value| value.as_i32())
|
||||
.map(AcadColor::from_true_color_value)
|
||||
@@ -3625,10 +3625,10 @@ pub(crate) fn layer_render_style_viewport(
|
||||
document,
|
||||
layer_name,
|
||||
viewport,
|
||||
acadrust::objects::KnownXRecordKind::LayerViewportAlphaOverride,
|
||||
codec::objects::KnownXRecordKind::LayerViewportAlphaOverride,
|
||||
)
|
||||
.and_then(|value| value.as_i32())
|
||||
.map(|value| acadrust::types::Transparency::from_alpha_value(value as u32))
|
||||
.map(|value| codec::types::Transparency::from_alpha_value(value as u32))
|
||||
.or_else(|| layer.map(|layer| layer.transparency))
|
||||
.map(|transparency| 1.0 - transparency.as_percent() as f32)
|
||||
.unwrap_or(1.0)
|
||||
@@ -3643,7 +3643,7 @@ pub(crate) fn layer_render_style_viewport(
|
||||
document,
|
||||
layer_name,
|
||||
viewport,
|
||||
acadrust::objects::KnownXRecordKind::LayerViewportLinetypeOverride,
|
||||
codec::objects::KnownXRecordKind::LayerViewportLinetypeOverride,
|
||||
)
|
||||
.and_then(|value| value.as_handle())
|
||||
.and_then(|handle| document.line_types.iter().find(|line_type| line_type.handle == handle))
|
||||
@@ -3660,7 +3660,7 @@ pub(crate) fn layer_render_style_viewport(
|
||||
document,
|
||||
layer_name,
|
||||
viewport,
|
||||
acadrust::objects::KnownXRecordKind::LayerViewportLineweightOverride,
|
||||
codec::objects::KnownXRecordKind::LayerViewportLineweightOverride,
|
||||
)
|
||||
.and_then(|value| value.as_i32())
|
||||
.map(|value| LineWeight::from_value(value as i16))
|
||||
@@ -4053,7 +4053,7 @@ impl Scene {
|
||||
for index in [pair_start, pair_start + 1] {
|
||||
let high = edges[index];
|
||||
let low = edges_low.get(index).copied().unwrap_or([0.0; 3]);
|
||||
let local = acadrust::types::Vector3::new(
|
||||
let local = codec::types::Vector3::new(
|
||||
high[0] as f64 + low[0] as f64,
|
||||
high[1] as f64 + low[1] as f64,
|
||||
high[2] as f64 + low[2] as f64,
|
||||
@@ -4131,7 +4131,7 @@ impl Scene {
|
||||
continue;
|
||||
}
|
||||
let context_scale = match self.document.objects.get(&scale) {
|
||||
Some(acadrust::objects::ObjectType::Scale(value)) => {
|
||||
Some(codec::objects::ObjectType::Scale(value)) => {
|
||||
(value.inverse_factor() / self.annotation_scale_unit_factor()) as f32
|
||||
}
|
||||
_ => annotation_scale,
|
||||
@@ -4177,7 +4177,7 @@ impl Scene {
|
||||
pub fn build_viewports(
|
||||
&self,
|
||||
bounds: Rectangle,
|
||||
model_render_mode: acadrust::entities::ViewportRenderMode,
|
||||
model_render_mode: codec::entities::ViewportRenderMode,
|
||||
_hover_region: Option<usize>,
|
||||
show_viewcube: bool,
|
||||
show_interaction: bool,
|
||||
@@ -4240,7 +4240,7 @@ impl Scene {
|
||||
&self,
|
||||
bounds: Rectangle,
|
||||
tile_idx: usize,
|
||||
model_render_mode: acadrust::entities::ViewportRenderMode,
|
||||
model_render_mode: codec::entities::ViewportRenderMode,
|
||||
show_viewcube: bool,
|
||||
show_interaction: bool,
|
||||
viewcube_text_color: [f32; 4],
|
||||
@@ -4387,7 +4387,7 @@ impl Scene {
|
||||
// borders — NOT the projected viewport content (the GPU content
|
||||
// viewports draw that themselves).
|
||||
self.paper_sheet_wires_arc()
|
||||
} else if inst.handle == acadrust::Handle::NULL {
|
||||
} else if inst.handle == codec::Handle::NULL {
|
||||
self.entity_wires_arc()
|
||||
} else {
|
||||
self.model_wires_for_viewport_arc(inst.handle, full.height)
|
||||
@@ -4479,7 +4479,7 @@ impl Scene {
|
||||
// incremental patch's base id receives the same tag, preserving the
|
||||
// arena fast path after the first mode switch.
|
||||
let wire_mode_tag = u64::from(
|
||||
inst.render_mode == acadrust::entities::ViewportRenderMode::Wireframe3D,
|
||||
inst.render_mode == codec::entities::ViewportRenderMode::Wireframe3D,
|
||||
);
|
||||
let wire_content_id = base_wire_content_id
|
||||
.wrapping_mul(2)
|
||||
@@ -4535,7 +4535,7 @@ impl Scene {
|
||||
// layers too, matching the already-filtered resident wire set.
|
||||
let vp_frozen: rustc_hash::FxHashSet<Handle> = if !inst.paper_sheet
|
||||
&& inst.tile_idx.is_none()
|
||||
&& inst.handle != acadrust::Handle::NULL
|
||||
&& inst.handle != codec::Handle::NULL
|
||||
{
|
||||
match self.document.get_entity(inst.handle) {
|
||||
Some(EntityType::Viewport(vp)) => vp.frozen_layers.iter().cloned().collect(),
|
||||
@@ -4741,13 +4741,13 @@ impl Scene {
|
||||
0x1000_0000_0000_0000
|
||||
} else if inst.paper_sheet {
|
||||
0x2000_0000_0000_0000 | self.current_layout_block_handle().value()
|
||||
} else if inst.handle == acadrust::Handle::NULL {
|
||||
} else if inst.handle == codec::Handle::NULL {
|
||||
0x4000_0000_0000_0000 | self.current_layout_block_handle().value()
|
||||
} else {
|
||||
0x3000_0000_0000_0000 | inst.handle.value()
|
||||
};
|
||||
let draw_depths = if inst.render_mode
|
||||
== acadrust::entities::ViewportRenderMode::Wireframe3D
|
||||
== codec::entities::ViewportRenderMode::Wireframe3D
|
||||
{
|
||||
Arc::clone(&self.no_draw_depths)
|
||||
} else {
|
||||
@@ -4795,7 +4795,7 @@ impl Scene {
|
||||
// rectangle and need no stencil boundary.
|
||||
let clip_boundary_ndc = if !inst.paper_sheet
|
||||
&& inst.tile_idx.is_none()
|
||||
&& inst.handle != acadrust::Handle::NULL
|
||||
&& inst.handle != codec::Handle::NULL
|
||||
&& self.current_layout != "Model"
|
||||
{
|
||||
Arc::new(self.viewport_clip_boundary_ndc(inst.handle, uo, vo, us, vs))
|
||||
@@ -4912,7 +4912,7 @@ impl Scene {
|
||||
// ── Linetype pattern helper ───────────────────────────────────────────────
|
||||
|
||||
pub(crate) fn resolve_pattern(
|
||||
table: &acadrust::tables::Table<LineType>,
|
||||
table: &codec::tables::Table<LineType>,
|
||||
name: &str,
|
||||
scale: f32,
|
||||
) -> (f32, [f32; 8]) {
|
||||
@@ -4958,7 +4958,7 @@ pub(crate) fn resolve_pattern(
|
||||
/// Whether a wire belongs to a Face3D entity, by document handle lookup —
|
||||
/// so no changes to WireModel are needed.
|
||||
#[allow(dead_code)]
|
||||
fn is_face3d_wire(w: &WireModel, document: &acadrust::CadDocument) -> bool {
|
||||
fn is_face3d_wire(w: &WireModel, document: &codec::CadDocument) -> bool {
|
||||
w.name
|
||||
.parse::<u64>()
|
||||
.ok()
|
||||
@@ -4973,7 +4973,7 @@ fn is_face3d_wire(w: &WireModel, document: &acadrust::CadDocument) -> bool {
|
||||
#[allow(dead_code)]
|
||||
fn split_face3d_wires(
|
||||
wires: &[WireModel],
|
||||
document: &acadrust::CadDocument,
|
||||
document: &codec::CadDocument,
|
||||
) -> (Vec<WireModel>, Vec<WireModel>) {
|
||||
let face3d_handles: rustc_hash::FxHashSet<u64> = document
|
||||
.entities()
|
||||
@@ -5017,9 +5017,9 @@ fn split_face3d_wires_with_handles(
|
||||
#[cfg(test)]
|
||||
mod layer0_inherit_tests {
|
||||
use super::*;
|
||||
use acadrust::entities::Line;
|
||||
use acadrust::tables::Layer;
|
||||
use acadrust::types::{Color, Transparency};
|
||||
use codec::entities::Line;
|
||||
use codec::tables::Layer;
|
||||
use codec::types::{Color, Transparency};
|
||||
|
||||
// ACI: 1 = red, 3 = green, 7 = white. Distinct, so the assertions below
|
||||
// can tell "inherited the insert layer" from "kept layer 0".
|
||||
@@ -5139,9 +5139,9 @@ mod layer0_inherit_tests {
|
||||
let mut scene = Scene::new();
|
||||
assert!(!scene.has_face3d());
|
||||
|
||||
scene.add_entity(EntityType::Line(acadrust::entities::Line::from_points(
|
||||
acadrust::types::Vector3::new(0.0, 0.0, 0.0),
|
||||
acadrust::types::Vector3::new(10.0, 10.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(10.0, 10.0, 0.0),
|
||||
)));
|
||||
assert!(!scene.has_face3d());
|
||||
|
||||
@@ -5158,17 +5158,17 @@ mod layer0_inherit_tests {
|
||||
assert_eq!(bg.fog_params, bg2.fog_params);
|
||||
|
||||
// Test multiple Face3D additions and removals
|
||||
let face1 = acadrust::entities::Face3D::new(
|
||||
acadrust::types::Vector3::new(0.0, 0.0, 0.0),
|
||||
acadrust::types::Vector3::new(10.0, 0.0, 0.0),
|
||||
acadrust::types::Vector3::new(10.0, 10.0, 0.0),
|
||||
acadrust::types::Vector3::new(0.0, 10.0, 0.0),
|
||||
let face1 = codec::entities::Face3D::new(
|
||||
codec::types::Vector3::new(0.0, 0.0, 0.0),
|
||||
codec::types::Vector3::new(10.0, 0.0, 0.0),
|
||||
codec::types::Vector3::new(10.0, 10.0, 0.0),
|
||||
codec::types::Vector3::new(0.0, 10.0, 0.0),
|
||||
);
|
||||
let face2 = acadrust::entities::Face3D::new(
|
||||
acadrust::types::Vector3::new(10.0, 0.0, 0.0),
|
||||
acadrust::types::Vector3::new(20.0, 0.0, 0.0),
|
||||
acadrust::types::Vector3::new(20.0, 10.0, 0.0),
|
||||
acadrust::types::Vector3::new(10.0, 10.0, 0.0),
|
||||
let face2 = codec::entities::Face3D::new(
|
||||
codec::types::Vector3::new(10.0, 0.0, 0.0),
|
||||
codec::types::Vector3::new(20.0, 0.0, 0.0),
|
||||
codec::types::Vector3::new(20.0, 10.0, 0.0),
|
||||
codec::types::Vector3::new(10.0, 10.0, 0.0),
|
||||
);
|
||||
let fh1 = scene.add_entity(EntityType::Face3D(face1));
|
||||
assert!(scene.has_face3d());
|
||||
@@ -5186,11 +5186,11 @@ mod layer0_inherit_tests {
|
||||
assert!(!scene.has_face3d(), "has_face3d must become false when all Face3Ds are removed");
|
||||
|
||||
// bump_geometry_no_blocks must also invalidate has_face3d
|
||||
let fh3 = scene.add_entity(EntityType::Face3D(acadrust::entities::Face3D::new(
|
||||
acadrust::types::Vector3::new(0.0, 0.0, 0.0),
|
||||
acadrust::types::Vector3::new(1.0, 1.0, 1.0),
|
||||
acadrust::types::Vector3::new(2.0, 2.0, 2.0),
|
||||
acadrust::types::Vector3::new(3.0, 3.0, 3.0),
|
||||
let fh3 = scene.add_entity(EntityType::Face3D(codec::entities::Face3D::new(
|
||||
codec::types::Vector3::new(0.0, 0.0, 0.0),
|
||||
codec::types::Vector3::new(1.0, 1.0, 1.0),
|
||||
codec::types::Vector3::new(2.0, 2.0, 2.0),
|
||||
codec::types::Vector3::new(3.0, 3.0, 3.0),
|
||||
)));
|
||||
assert!(scene.has_face3d());
|
||||
scene.document.remove_entity(fh3);
|
||||
@@ -5200,18 +5200,18 @@ mod layer0_inherit_tests {
|
||||
|
||||
#[test]
|
||||
fn split_face3d_wires_correctness_and_parity() {
|
||||
let mut doc = acadrust::CadDocument::new();
|
||||
let face = acadrust::entities::Face3D::new(
|
||||
acadrust::types::Vector3::new(0.0, 0.0, 0.0),
|
||||
acadrust::types::Vector3::new(10.0, 0.0, 0.0),
|
||||
acadrust::types::Vector3::new(10.0, 10.0, 0.0),
|
||||
acadrust::types::Vector3::new(0.0, 10.0, 0.0),
|
||||
let mut doc = codec::CadDocument::new();
|
||||
let face = codec::entities::Face3D::new(
|
||||
codec::types::Vector3::new(0.0, 0.0, 0.0),
|
||||
codec::types::Vector3::new(10.0, 0.0, 0.0),
|
||||
codec::types::Vector3::new(10.0, 10.0, 0.0),
|
||||
codec::types::Vector3::new(0.0, 10.0, 0.0),
|
||||
);
|
||||
let face_h = doc.add_entity(EntityType::Face3D(face)).unwrap();
|
||||
|
||||
let line = acadrust::entities::Line::from_points(
|
||||
acadrust::types::Vector3::new(0.0, 0.0, 0.0),
|
||||
acadrust::types::Vector3::new(5.0, 5.0, 0.0),
|
||||
let line = codec::entities::Line::from_points(
|
||||
codec::types::Vector3::new(0.0, 0.0, 0.0),
|
||||
codec::types::Vector3::new(5.0, 5.0, 0.0),
|
||||
);
|
||||
let line_h = doc.add_entity(EntityType::Line(line)).unwrap();
|
||||
|
||||
@@ -5283,7 +5283,7 @@ mod layer0_inherit_tests {
|
||||
fn render_environment_objects_cache_and_apply() {
|
||||
let mut scene = Scene::new();
|
||||
|
||||
let mut renv = acadrust::objects::RenderEnvironment::default();
|
||||
let mut renv = codec::objects::RenderEnvironment::default();
|
||||
renv.fog_enabled = true;
|
||||
renv.fog_color = [100, 150, 200];
|
||||
renv.fog_background_enabled = true;
|
||||
@@ -5295,8 +5295,8 @@ mod layer0_inherit_tests {
|
||||
let handle = Handle::new(42);
|
||||
scene.document.objects.insert(
|
||||
handle,
|
||||
acadrust::objects::ObjectType::ClassObject(acadrust::objects::ClassObject::new(
|
||||
acadrust::objects::ClassObjectData::RenderEnvironment(renv),
|
||||
codec::objects::ObjectType::ClassObject(codec::objects::ClassObject::new(
|
||||
codec::objects::ClassObjectData::RenderEnvironment(renv),
|
||||
)),
|
||||
);
|
||||
scene.object_data_cache = crate::entities::object_data::build_cache(&scene.document);
|
||||
|
||||
+13
-13
@@ -1,4 +1,4 @@
|
||||
use acadrust::types::{Transform, Vector3};
|
||||
use codec::types::{Transform, Vector3};
|
||||
use glam::DVec3;
|
||||
|
||||
use crate::command::EntityTransform;
|
||||
@@ -10,7 +10,7 @@ fn to_v3(v: DVec3) -> Vector3 {
|
||||
|
||||
pub fn apply_standard_transform<T>(entity: &mut T, center: DVec3, axis: DVec3, angle_rad: f64)
|
||||
where
|
||||
T: acadrust::Entity,
|
||||
T: codec::Entity,
|
||||
{
|
||||
let t = Transform::from_translation(to_v3(-center))
|
||||
.then(&Transform::from_rotation(to_v3(axis.normalize_or(DVec3::Z)), angle_rad))
|
||||
@@ -20,7 +20,7 @@ where
|
||||
|
||||
pub fn apply_standard_scale<T>(entity: &mut T, center: DVec3, factor: f64)
|
||||
where
|
||||
T: acadrust::Entity,
|
||||
T: codec::Entity,
|
||||
{
|
||||
let s = factor;
|
||||
let t = Transform::from_scaling_with_origin(Vector3::new(s, s, s), to_v3(center));
|
||||
@@ -29,7 +29,7 @@ where
|
||||
|
||||
pub fn apply_standard_entity_transform<T, F>(entity: &mut T, t: &EntityTransform, mirror: F)
|
||||
where
|
||||
T: acadrust::Entity,
|
||||
T: codec::Entity,
|
||||
F: FnOnce(&mut T, DVec3, DVec3),
|
||||
{
|
||||
match t {
|
||||
@@ -57,11 +57,11 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
/// Reflection across the world-XY line through `p1`→`p2` as an acadrust
|
||||
/// `Transform`, for delegating MIRROR to acadrust's entity-aware
|
||||
/// Reflection across the world-XY line through `p1`→`p2` as an opencadcodec
|
||||
/// `Transform`, for delegating MIRROR to opencadcodec's entity-aware
|
||||
/// `apply_transform` paths (which handle direction flags, stored-angle
|
||||
/// conventions and bulges themselves). Degenerate line → identity.
|
||||
pub fn reflection_about_xy_line(p1: DVec3, p2: DVec3) -> acadrust::types::Transform {
|
||||
pub fn reflection_about_xy_line(p1: DVec3, p2: DVec3) -> codec::types::Transform {
|
||||
reflection_about_working_line(p1, p2, DVec3::Z)
|
||||
}
|
||||
|
||||
@@ -71,8 +71,8 @@ pub fn reflection_about_working_line(
|
||||
p1: DVec3,
|
||||
p2: DVec3,
|
||||
working_normal: DVec3,
|
||||
) -> acadrust::types::Transform {
|
||||
use acadrust::types::{Matrix4, Transform};
|
||||
) -> codec::types::Transform {
|
||||
use codec::types::{Matrix4, Transform};
|
||||
let line = p2 - p1;
|
||||
let plane_normal = line
|
||||
.cross(working_normal.normalize_or(DVec3::Z))
|
||||
@@ -191,11 +191,11 @@ mod mirror_delegation_tests {
|
||||
use super::*;
|
||||
use crate::command::EntityTransform;
|
||||
use crate::entities::traits::Transformable;
|
||||
use acadrust::entities::hatch::{BoundaryEdge, BoundaryPath, CircularArcEdge, LineEdge};
|
||||
use acadrust::entities::Hatch;
|
||||
use acadrust::types::Vector2;
|
||||
use codec::entities::hatch::{BoundaryEdge, BoundaryPath, CircularArcEdge, LineEdge};
|
||||
use codec::entities::Hatch;
|
||||
use codec::types::Vector2;
|
||||
|
||||
// MIRROR on a hatch goes through reflection_about_xy_line + acadrust's
|
||||
// MIRROR on a hatch goes through reflection_about_xy_line + opencadcodec's
|
||||
// transform_hatch. Mirror a Line→Arc→Line path across a vertical line and
|
||||
// assert the arc stays endpoint-continuous, flips its direction flag, and
|
||||
// keeps its sweep magnitude (the stored-angle conventions the old
|
||||
|
||||
@@ -20,7 +20,7 @@ pub struct ViewportPane<'a> {
|
||||
/// Render mode applied to the active Model tile or active paper viewport.
|
||||
/// The app may supply a temporary gallery-hover mode; inactive viewports
|
||||
/// keep the values stored on their own tile/entity.
|
||||
pub render_mode: acadrust::entities::ViewportRenderMode,
|
||||
pub render_mode: codec::entities::ViewportRenderMode,
|
||||
/// `Some(tile_idx)` → this widget renders a single Model pane (one shader
|
||||
/// per `pane_grid` pane, filling its own bounds). `None` → the unified
|
||||
/// full-canvas path (paper layout, or the whole-canvas Model fallback).
|
||||
@@ -35,7 +35,7 @@ impl<'a> ViewportPane<'a> {
|
||||
scene: &'a Scene,
|
||||
show_viewcube: bool,
|
||||
show_interaction: bool,
|
||||
render_mode: acadrust::entities::ViewportRenderMode,
|
||||
render_mode: codec::entities::ViewportRenderMode,
|
||||
viewcube_text_color: [f32; 4],
|
||||
) -> Self {
|
||||
Self {
|
||||
@@ -54,7 +54,7 @@ impl<'a> ViewportPane<'a> {
|
||||
scene: &'a Scene,
|
||||
show_viewcube: bool,
|
||||
show_interaction: bool,
|
||||
render_mode: acadrust::entities::ViewportRenderMode,
|
||||
render_mode: codec::entities::ViewportRenderMode,
|
||||
tile_idx: usize,
|
||||
viewcube_text_color: [f32; 4],
|
||||
) -> Self {
|
||||
|
||||
Reference in new issue
Block a user