forked from 1b-agent/opencadstudio-upstream
chore(properties): remove dead helpers left by property-builder rewrite
The spec-conforming property builders dropped the rows that used these helpers, leaving them unreferenced: hookline_dir_str (leader), length_and_area (lwpolyline), render_mode_label / STD_VIEWS / viewport_view_label (viewport). No behavior change. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
1043a3d561
commit
4398341632
3 files changed
-110
No files matched your search
@@ -184,13 +184,6 @@ fn creation_type_str(ct: &LeaderCreationType) -> &'static str {
|
||||
}
|
||||
}
|
||||
|
||||
fn hookline_dir_str(hd: &HooklineDirection) -> &'static str {
|
||||
match hd {
|
||||
HooklineDirection::Opposite => "Opposite",
|
||||
HooklineDirection::Same => "Same",
|
||||
}
|
||||
}
|
||||
|
||||
fn color_str(c: &acadrust::types::Color) -> String {
|
||||
match c.rgb() {
|
||||
Some((r, g, b)) => format!("RGB({},{},{})", r, g, b),
|
||||
|
||||
@@ -359,44 +359,6 @@ fn properties(pline: &LwPolyline) -> Vec<PropSection> {
|
||||
]
|
||||
}
|
||||
|
||||
/// Path length and enclosed area of a polyline, accounting for arc
|
||||
/// (bulge) segments. Length is the actual path — it excludes the implicit
|
||||
/// closing segment when the polyline is open. Area always treats the
|
||||
/// polyline as closed (last vertex joined back to the first), matching how
|
||||
/// CAD property panels report a polyline's area.
|
||||
fn length_and_area(pline: &LwPolyline) -> (f64, f64) {
|
||||
let n = pline.vertices.len();
|
||||
if n < 2 {
|
||||
return (0.0, 0.0);
|
||||
}
|
||||
let mut length = 0.0;
|
||||
let mut chord_area = 0.0; // shoelace over chords, signed
|
||||
let mut arc_area = 0.0; // bulge corrections, signed
|
||||
for i in 0..n {
|
||||
let v0 = &pline.vertices[i];
|
||||
let v1 = &pline.vertices[(i + 1) % n];
|
||||
let p0 = [v0.location.x, v0.location.y];
|
||||
let p1 = [v1.location.x, v1.location.y];
|
||||
// The wrap edge (last → first) is part of the closed-area shoelace
|
||||
// regardless, but only contributes to length when the polyline is
|
||||
// actually closed.
|
||||
chord_area += p0[0] * p1[1] - p1[0] * p0[1];
|
||||
let is_wrap = i + 1 == n;
|
||||
if is_wrap && !pline.is_closed {
|
||||
continue;
|
||||
}
|
||||
let chord = ((p1[0] - p0[0]).powi(2) + (p1[1] - p0[1]).powi(2)).sqrt();
|
||||
match crate::entities::common::BulgeArc::from_bulge(p0, p1, v0.bulge) {
|
||||
Some(arc) => {
|
||||
length += arc.radius * arc.sweep.abs();
|
||||
arc_area += 0.5 * arc.radius * arc.radius * (arc.sweep - arc.sweep.sin());
|
||||
}
|
||||
None => length += chord,
|
||||
}
|
||||
}
|
||||
(length, (chord_area / 2.0 + arc_area).abs())
|
||||
}
|
||||
|
||||
fn apply_geom_prop(pline: &mut LwPolyline, field: &str, value: &str) {
|
||||
let Some(v) = parse_f64(value) else {
|
||||
return;
|
||||
|
||||
@@ -68,15 +68,6 @@ const RENDER_MODES: &[(&str, ViewportRenderMode)] = &[
|
||||
),
|
||||
];
|
||||
|
||||
fn render_mode_label(mode: &ViewportRenderMode) -> &'static str {
|
||||
for (label, m) in RENDER_MODES {
|
||||
if m == mode {
|
||||
return label;
|
||||
}
|
||||
}
|
||||
"2D Wireframe"
|
||||
}
|
||||
|
||||
// ── Shade plot mode labels ────────────────────────────────────────────────
|
||||
|
||||
const SHADE_PLOT_LABELS: &[&str] = &["As Displayed", "Wireframe", "Hidden", "Rendered"];
|
||||
@@ -88,21 +79,6 @@ fn shade_plot_label(mode: i16) -> &'static str {
|
||||
.unwrap_or("As Displayed")
|
||||
}
|
||||
|
||||
// ── Standard view options ─────────────────────────────────────────────────
|
||||
|
||||
const STD_VIEWS: &[&str] = &[
|
||||
"Top",
|
||||
"Bottom",
|
||||
"Front",
|
||||
"Back",
|
||||
"Left",
|
||||
"Right",
|
||||
"SW Isometric",
|
||||
"SE Isometric",
|
||||
"NE Isometric",
|
||||
"NW Isometric",
|
||||
];
|
||||
|
||||
fn grips(vp: &Viewport) -> Vec<GripDef> {
|
||||
let (cx, cy, cz) = (vp.center.x, vp.center.y, vp.center.z);
|
||||
let hw = vp.width / 2.0;
|
||||
@@ -212,47 +188,6 @@ fn properties(vp: &Viewport) -> Vec<PropSection> {
|
||||
]
|
||||
}
|
||||
|
||||
/// Identify which standard view matches the viewport's view direction.
|
||||
fn viewport_view_label(vp: &Viewport) -> String {
|
||||
let d = &vp.view_direction;
|
||||
let dx = d.x;
|
||||
let dy = d.y;
|
||||
let dz = d.z;
|
||||
|
||||
// Use a simple threshold comparison to classify the view direction.
|
||||
if dx.abs() < 0.1 && dy.abs() < 0.1 && dz > 0.5 {
|
||||
return "Top".into();
|
||||
}
|
||||
if dx.abs() < 0.1 && dy.abs() < 0.1 && dz < -0.5 {
|
||||
return "Bottom".into();
|
||||
}
|
||||
if dx.abs() < 0.1 && dy < -0.5 && dz.abs() < 0.1 {
|
||||
return "Front".into();
|
||||
}
|
||||
if dx.abs() < 0.1 && dy > 0.5 && dz.abs() < 0.1 {
|
||||
return "Back".into();
|
||||
}
|
||||
if dx < -0.5 && dy.abs() < 0.1 && dz.abs() < 0.1 {
|
||||
return "Left".into();
|
||||
}
|
||||
if dx > 0.5 && dy.abs() < 0.1 && dz.abs() < 0.1 {
|
||||
return "Right".into();
|
||||
}
|
||||
if dx < -0.4 && dy < -0.4 && dz > 0.4 {
|
||||
return "SW Isometric".into();
|
||||
}
|
||||
if dx > 0.4 && dy < -0.4 && dz > 0.4 {
|
||||
return "SE Isometric".into();
|
||||
}
|
||||
if dx > 0.4 && dy > 0.4 && dz > 0.4 {
|
||||
return "NE Isometric".into();
|
||||
}
|
||||
if dx < -0.4 && dy > 0.4 && dz > 0.4 {
|
||||
return "NW Isometric".into();
|
||||
}
|
||||
"Custom".into()
|
||||
}
|
||||
|
||||
fn apply_geom_prop(vp: &mut Viewport, field: &str, value: &str) {
|
||||
use acadrust::types::Vector3;
|
||||
|
||||
|
||||
Reference in new issue
Block a user