2026-03-22 14:56:27 +03:00
|
|
|
|
use acadrust::entities::Circle;
|
2026-08-02 22:09:25 +03:00
|
|
|
|
use crate::t;
|
2026-03-22 14:56:27 +03:00
|
|
|
|
|
|
|
|
|
|
use crate::command::EntityTransform;
|
|
|
|
|
|
use crate::entities::common::{
|
refactor(grip): square-only marker set + oriented stretch handles
Phase 1 of bringing the grip vocabulary in line with the standard
CAD convention: drop the per-position-type shape encoding (Diamond
for translate, Circle for parameter) and use a plain square for
every endpoint / vertex / centre grip. The behavioural midpoint vs
vertex distinction stays — it lives on `GripDef::is_midpoint` and
drives `Translate` vs `Absolute` in the grip-edit dispatcher — only
the marker shape collapses.
- `GripShape` keeps `Square`, `Rectangle`, `Triangle`. Diamond /
Circle are gone.
- `GripDef` gains `dir: Option<[f32; 2]>` — a world-XY direction
vector consumed by `Rectangle` to orient the box along its
segment.
- `entities::common` exposes `square_grip`, `center_grip` (same
square marker, flagged as translate), `rectangle_grip(id, world,
dir)` for oriented mid-segment handles, and a kept-for-Phase-2
`triangle_grip`.
- `overlay::GripMarker` / `grips_to_screen[_paper]` thread `dir`
through to the canvas painter; the Rectangle path rotates the
box around the grip centre using the world-XY direction (flipping
the sin for screen-Y).
Every existing `diamond_grip(id, w)` call becomes `center_grip(id,
w)` — the visual change is square-replacing-diamond at line
midpoints / arc midpoints / circle centres / ellipse centres /
viewport / hatch loop centroids / dimension grips / image corners /
multileader / ray / underlay / ole2frame / solid3d.
`LwPolyline` grows a stretch handle on every segment (straight or
arc), drawn as the new oriented rectangle. The grip-edit path
translates both segment endpoints for straight segments and
adjusts the arc bulge from the new midpoint for arc segments.
2026-05-29 02:07:34 +03:00
|
|
|
|
center_grip, edit_prop as edit, parse_f64, ro_prop as ro, square_grip,
|
2026-03-22 14:56:27 +03:00
|
|
|
|
};
|
refactor(entities): collapse trait wrapper boilerplate via macro
Every entity file ended with the same three-trait wrapper block:
impl Grippable for T {
fn grips(&self) -> Vec<GripDef> { grips(self) }
fn apply_grip(&mut self, ...) { apply_grip(self, ...) }
}
impl PropertyEditable for T { ... }
impl Transformable for T { ... }
— 23 lines of pure delegation around five same-named free functions.
Replace with `crate::impl_entity_basics!(T);` (a macro in
entities/traits.rs that expands to the three trait impls).
Applied where the file already follows the free-fn delegation
convention (Arc, Circle, Ellipse, Insert, Leader, Line, LwPolyline,
MultiLeader, Ole2Frame, Point, Spline, Viewport). Files that inlined
the trait method bodies directly (Ray, XLine, Shape, Solid, Tolerance,
MLine, Mesh, Solid3D/Region/Body, Table, RasterImage, Wipeout,
Underlay, Hatch, Polyline, Polyline2D, Polyline3D, Dimension) left
alone — they already skip the indirection. Text/MText/Attribute use
the with-text-style flavour and will move once that variant is needed
beyond the existing two manual impls.
A second macro `impl_entity_basics_with_text_styles!` is included for
the text-like flavour but no entity uses it yet.
Net: -204 lines.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-26 17:16:06 +03:00
|
|
|
|
use crate::entities::traits::TruckConvertible;
|
fix(pick): hit-test lineweight width and thickness walls
Selection tested a flat 8 px radius around each wire's centreline and
nothing else, so two things the user can see were not pickable.
A wire renders as a band `line_weight_px` wide, so pick now widens to that
rendered half-width via `pick_tolerance_px`, mirroring the wire shader's
`select(0.5, half_width, lwdisplay_enable)`. Behaviour is unchanged for
every standard weight (the widest, 2.11 mm, renders 7.97 px half-width —
just under the 8 px threshold); this keeps the two sides from drifting
apart if the display boost in `lineweight_to_px` ever changes.
Entities extruded by a DXF thickness draw their wall as four edges with
nothing in between, so the interior was a hole the cursor fell through.
WireModel gains `pick_tris`: triangles hit-testing treats as solid and the
renderer never uploads. Kept apart from `fill_tris` because that channel
reaches the GPU, and a wall that rendered shaded would change how every
thickness drawing looks. Ranked below `fill_tris` — those are drawn, these
are not, so where they overlap the drawn face is what the user means.
Walls are dropped when a wire is projected into a floating viewport:
`points` are reprojected and clipped into paper coords there, so cloned
model-space triangles would hit-test at a model-scale offset. Extruded
entities stay selectable by their edges, which do get projected.
The wall loop runs on every hover that misses everything else, so it
rejects on the wire's AABB first — an extruded circle is ~128 triangles
and a drawing full of thickness would otherwise project every wall on
each mouse move.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-17 14:58:55 +03:00
|
|
|
|
use crate::scene::convert::acad_to_truck::{extrusion_wall_tris, TruckEntity, TruckObject};
|
2026-06-16 11:33:46 +03:00
|
|
|
|
use crate::scene::model::object::{GripApply, GripDef, PropSection};
|
2026-08-09 00:43:44 +03:00
|
|
|
|
use crate::scene::model::wire_model::TangentGeom;
|
2026-03-22 14:56:27 +03:00
|
|
|
|
|
|
|
|
|
|
fn to_truck(circle: &Circle) -> TruckEntity {
|
|
|
|
|
|
let cx = circle.center.x;
|
|
|
|
|
|
let cy = circle.center.y;
|
|
|
|
|
|
let cz = circle.center.z;
|
|
|
|
|
|
let r = circle.radius;
|
2026-05-02 17:13:42 +03:00
|
|
|
|
let normal = (circle.normal.x, circle.normal.y, circle.normal.z);
|
|
|
|
|
|
|
2026-06-16 11:33:46 +03:00
|
|
|
|
let (ax, ay) = crate::scene::view::transform::ocs_axes(normal);
|
|
|
|
|
|
let (cwx, cwy, cwz) = crate::scene::view::transform::ocs_point_to_wcs((cx, cy, cz), normal);
|
2026-05-02 17:13:42 +03:00
|
|
|
|
|
2026-03-22 14:56:27 +03:00
|
|
|
|
let rf = r as f32;
|
2026-08-09 00:43:44 +03:00
|
|
|
|
// Centre and quadrants come from the entity's own curve, so the same
|
|
|
|
|
|
// definition answers here, in the tessellation and in a trim.
|
|
|
|
|
|
let snap = crate::entities::curve::snap_from(&crate::entities::curve::circle_curve(circle));
|
|
|
|
|
|
let snap_pts = snap.snap_pts;
|
2026-05-02 20:30:30 +03:00
|
|
|
|
let tangent = TangentGeom::Circle {
|
|
|
|
|
|
center: [cwx as f32, cwy as f32, cwz as f32],
|
|
|
|
|
|
radius: rf,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if circle.thickness.abs() > 1e-10 {
|
|
|
|
|
|
let t = circle.thickness;
|
|
|
|
|
|
let (nx, ny, nz) = normal;
|
|
|
|
|
|
let n = 64usize;
|
|
|
|
|
|
let tau = std::f64::consts::TAU;
|
|
|
|
|
|
let circ_pt = |a: f64| -> (f64, f64, f64) {
|
|
|
|
|
|
let (c, s) = (a.cos(), a.sin());
|
|
|
|
|
|
(
|
|
|
|
|
|
cwx + r * (c * ax.0 + s * ay.0),
|
|
|
|
|
|
cwy + r * (c * ax.1 + s * ay.1),
|
|
|
|
|
|
cwz + r * (c * ax.2 + s * ay.2),
|
|
|
|
|
|
)
|
|
|
|
|
|
};
|
fix(pick): hit-test lineweight width and thickness walls
Selection tested a flat 8 px radius around each wire's centreline and
nothing else, so two things the user can see were not pickable.
A wire renders as a band `line_weight_px` wide, so pick now widens to that
rendered half-width via `pick_tolerance_px`, mirroring the wire shader's
`select(0.5, half_width, lwdisplay_enable)`. Behaviour is unchanged for
every standard weight (the widest, 2.11 mm, renders 7.97 px half-width —
just under the 8 px threshold); this keeps the two sides from drifting
apart if the display boost in `lineweight_to_px` ever changes.
Entities extruded by a DXF thickness draw their wall as four edges with
nothing in between, so the interior was a hole the cursor fell through.
WireModel gains `pick_tris`: triangles hit-testing treats as solid and the
renderer never uploads. Kept apart from `fill_tris` because that channel
reaches the GPU, and a wall that rendered shaded would change how every
thickness drawing looks. Ranked below `fill_tris` — those are drawn, these
are not, so where they overlap the drawn face is what the user means.
Walls are dropped when a wire is projected into a floating viewport:
`points` are reprojected and clipped into paper coords there, so cloned
model-space triangles would hit-test at a model-scale offset. Extruded
entities stay selectable by their edges, which do get projected.
The wall loop runs on every hover that misses everything else, so it
rejects on the wire's AABB first — an extruded circle is ~128 triangles
and a drawing full of thickness would otherwise project every wall on
each mouse move.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-17 14:58:55 +03:00
|
|
|
|
let base: Vec<[f64; 3]> = (0..=n)
|
|
|
|
|
|
.map(|i| {
|
|
|
|
|
|
let (x, y, z) = circ_pt(i as f64 * tau / n as f64);
|
|
|
|
|
|
[x, y, z]
|
|
|
|
|
|
})
|
|
|
|
|
|
.collect();
|
2026-05-12 23:47:40 +03:00
|
|
|
|
let mut pts: Vec<[f64; 3]> = Vec::with_capacity((n + 1) * 2 + 4 * 3);
|
fix(pick): hit-test lineweight width and thickness walls
Selection tested a flat 8 px radius around each wire's centreline and
nothing else, so two things the user can see were not pickable.
A wire renders as a band `line_weight_px` wide, so pick now widens to that
rendered half-width via `pick_tolerance_px`, mirroring the wire shader's
`select(0.5, half_width, lwdisplay_enable)`. Behaviour is unchanged for
every standard weight (the widest, 2.11 mm, renders 7.97 px half-width —
just under the 8 px threshold); this keeps the two sides from drifting
apart if the display boost in `lineweight_to_px` ever changes.
Entities extruded by a DXF thickness draw their wall as four edges with
nothing in between, so the interior was a hole the cursor fell through.
WireModel gains `pick_tris`: triangles hit-testing treats as solid and the
renderer never uploads. Kept apart from `fill_tris` because that channel
reaches the GPU, and a wall that rendered shaded would change how every
thickness drawing looks. Ranked below `fill_tris` — those are drawn, these
are not, so where they overlap the drawn face is what the user means.
Walls are dropped when a wire is projected into a floating viewport:
`points` are reprojected and clipped into paper coords there, so cloned
model-space triangles would hit-test at a model-scale offset. Extruded
entities stay selectable by their edges, which do get projected.
The wall loop runs on every hover that misses everything else, so it
rejects on the wire's AABB first — an extruded circle is ~128 triangles
and a drawing full of thickness would otherwise project every wall on
each mouse move.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-17 14:58:55 +03:00
|
|
|
|
pts.extend_from_slice(&base);
|
2026-05-12 23:47:40 +03:00
|
|
|
|
pts.push([f64::NAN; 3]);
|
fix(pick): hit-test lineweight width and thickness walls
Selection tested a flat 8 px radius around each wire's centreline and
nothing else, so two things the user can see were not pickable.
A wire renders as a band `line_weight_px` wide, so pick now widens to that
rendered half-width via `pick_tolerance_px`, mirroring the wire shader's
`select(0.5, half_width, lwdisplay_enable)`. Behaviour is unchanged for
every standard weight (the widest, 2.11 mm, renders 7.97 px half-width —
just under the 8 px threshold); this keeps the two sides from drifting
apart if the display boost in `lineweight_to_px` ever changes.
Entities extruded by a DXF thickness draw their wall as four edges with
nothing in between, so the interior was a hole the cursor fell through.
WireModel gains `pick_tris`: triangles hit-testing treats as solid and the
renderer never uploads. Kept apart from `fill_tris` because that channel
reaches the GPU, and a wall that rendered shaded would change how every
thickness drawing looks. Ranked below `fill_tris` — those are drawn, these
are not, so where they overlap the drawn face is what the user means.
Walls are dropped when a wire is projected into a floating viewport:
`points` are reprojected and clipped into paper coords there, so cloned
model-space triangles would hit-test at a model-scale offset. Extruded
entities stay selectable by their edges, which do get projected.
The wall loop runs on every hover that misses everything else, so it
rejects on the wire's AABB first — an extruded circle is ~128 triangles
and a drawing full of thickness would otherwise project every wall on
each mouse move.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-17 14:58:55 +03:00
|
|
|
|
for &[x, y, z] in &base {
|
2026-05-12 23:47:40 +03:00
|
|
|
|
pts.push([x + t * nx, y + t * ny, z + t * nz]);
|
2026-05-02 20:30:30 +03:00
|
|
|
|
}
|
2026-05-12 23:47:40 +03:00
|
|
|
|
pts.push([f64::NAN; 3]);
|
2026-05-02 20:30:30 +03:00
|
|
|
|
for i in 0..4usize {
|
|
|
|
|
|
let (x, y, z) = circ_pt(i as f64 * std::f64::consts::FRAC_PI_2);
|
2026-05-12 23:47:40 +03:00
|
|
|
|
pts.push([x, y, z]);
|
|
|
|
|
|
pts.push([x + t * nx, y + t * ny, z + t * nz]);
|
2026-05-02 20:30:30 +03:00
|
|
|
|
if i < 3 {
|
2026-05-12 23:47:40 +03:00
|
|
|
|
pts.push([f64::NAN; 3]);
|
2026-05-02 20:30:30 +03:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return TruckEntity {
|
fix(pick): hit-test lineweight width and thickness walls
Selection tested a flat 8 px radius around each wire's centreline and
nothing else, so two things the user can see were not pickable.
A wire renders as a band `line_weight_px` wide, so pick now widens to that
rendered half-width via `pick_tolerance_px`, mirroring the wire shader's
`select(0.5, half_width, lwdisplay_enable)`. Behaviour is unchanged for
every standard weight (the widest, 2.11 mm, renders 7.97 px half-width —
just under the 8 px threshold); this keeps the two sides from drifting
apart if the display boost in `lineweight_to_px` ever changes.
Entities extruded by a DXF thickness draw their wall as four edges with
nothing in between, so the interior was a hole the cursor fell through.
WireModel gains `pick_tris`: triangles hit-testing treats as solid and the
renderer never uploads. Kept apart from `fill_tris` because that channel
reaches the GPU, and a wall that rendered shaded would change how every
thickness drawing looks. Ranked below `fill_tris` — those are drawn, these
are not, so where they overlap the drawn face is what the user means.
Walls are dropped when a wire is projected into a floating viewport:
`points` are reprojected and clipped into paper coords there, so cloned
model-space triangles would hit-test at a model-scale offset. Extruded
entities stay selectable by their edges, which do get projected.
The wall loop runs on every hover that misses everything else, so it
rejects on the wire's AABB first — an extruded circle is ~128 triangles
and a drawing full of thickness would otherwise project every wall on
each mouse move.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-17 14:58:55 +03:00
|
|
|
|
pick_tris: extrusion_wall_tris(&base, [t * nx, t * ny, t * nz]),
|
2026-05-02 20:30:30 +03:00
|
|
|
|
object: TruckObject::Lines(pts),
|
|
|
|
|
|
snap_pts,
|
|
|
|
|
|
tangent_geoms: vec![tangent],
|
|
|
|
|
|
key_vertices: vec![],
|
2026-05-06 23:24:26 +03:00
|
|
|
|
fill_tris: vec![],
|
2026-05-02 20:30:30 +03:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-23 17:16:57 +03:00
|
|
|
|
// Tessellate directly as a cos/sin polyline rather than a truck
|
|
|
|
|
|
// `circle_arc` (arc-through-three-points). At large WCS coordinates
|
|
|
|
|
|
// (e.g. −1.2M UTM) the three-point fit cancels catastrophically — the
|
|
|
|
|
|
// circle comes back with a ~3% radius wobble and uneven segment lengths,
|
|
|
|
|
|
// which then throws off a dashed linetype's dash spacing. Direct
|
|
|
|
|
|
// evaluation only adds a small ±r term to the centre, so it stays precise;
|
|
|
|
|
|
// the `Lines` path RTE-splits the absolute-f64 points into the
|
|
|
|
|
|
// double-single the shader reconstructs.
|
|
|
|
|
|
let tol = crate::scene::convert::truck_tess::current_curve_tol();
|
|
|
|
|
|
// Chord-height tolerance → segment count: sag = r·(1 − cos(π/N)).
|
|
|
|
|
|
let n = if r > tol {
|
|
|
|
|
|
(std::f64::consts::PI / (1.0 - tol / r).clamp(-1.0, 1.0).acos())
|
|
|
|
|
|
.ceil()
|
|
|
|
|
|
.clamp(16.0, 4096.0) as usize
|
|
|
|
|
|
} else {
|
|
|
|
|
|
16
|
|
|
|
|
|
};
|
|
|
|
|
|
let tau = std::f64::consts::TAU;
|
|
|
|
|
|
let mut pts: Vec<[f64; 3]> = Vec::with_capacity(n + 1);
|
|
|
|
|
|
for i in 0..=n {
|
|
|
|
|
|
let a = i as f64 * tau / n as f64;
|
|
|
|
|
|
let (s, c) = a.sin_cos();
|
|
|
|
|
|
pts.push([
|
|
|
|
|
|
cwx + r * (c * ax.0 + s * ay.0),
|
|
|
|
|
|
cwy + r * (c * ax.1 + s * ay.1),
|
|
|
|
|
|
cwz + r * (c * ax.2 + s * ay.2),
|
|
|
|
|
|
]);
|
|
|
|
|
|
}
|
2026-03-22 14:56:27 +03:00
|
|
|
|
TruckEntity {
|
fix(pick): hit-test lineweight width and thickness walls
Selection tested a flat 8 px radius around each wire's centreline and
nothing else, so two things the user can see were not pickable.
A wire renders as a band `line_weight_px` wide, so pick now widens to that
rendered half-width via `pick_tolerance_px`, mirroring the wire shader's
`select(0.5, half_width, lwdisplay_enable)`. Behaviour is unchanged for
every standard weight (the widest, 2.11 mm, renders 7.97 px half-width —
just under the 8 px threshold); this keeps the two sides from drifting
apart if the display boost in `lineweight_to_px` ever changes.
Entities extruded by a DXF thickness draw their wall as four edges with
nothing in between, so the interior was a hole the cursor fell through.
WireModel gains `pick_tris`: triangles hit-testing treats as solid and the
renderer never uploads. Kept apart from `fill_tris` because that channel
reaches the GPU, and a wall that rendered shaded would change how every
thickness drawing looks. Ranked below `fill_tris` — those are drawn, these
are not, so where they overlap the drawn face is what the user means.
Walls are dropped when a wire is projected into a floating viewport:
`points` are reprojected and clipped into paper coords there, so cloned
model-space triangles would hit-test at a model-scale offset. Extruded
entities stay selectable by their edges, which do get projected.
The wall loop runs on every hover that misses everything else, so it
rejects on the wire's AABB first — an extruded circle is ~128 triangles
and a drawing full of thickness would otherwise project every wall on
each mouse move.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-17 14:58:55 +03:00
|
|
|
|
pick_tris: Vec::new(),
|
2026-07-23 17:16:57 +03:00
|
|
|
|
object: TruckObject::Lines(pts),
|
2026-05-02 20:30:30 +03:00
|
|
|
|
snap_pts,
|
|
|
|
|
|
tangent_geoms: vec![tangent],
|
2026-03-22 14:56:27 +03:00
|
|
|
|
key_vertices: vec![],
|
2026-05-06 23:24:26 +03:00
|
|
|
|
fill_tris: vec![],
|
2026-03-22 14:56:27 +03:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn grips(circle: &Circle) -> Vec<GripDef> {
|
2026-06-11 00:04:37 +03:00
|
|
|
|
let ctr = glam::DVec3::new(circle.center.x, circle.center.y, circle.center.z);
|
|
|
|
|
|
let r = circle.radius;
|
2026-03-22 14:56:27 +03:00
|
|
|
|
vec![
|
refactor(grip): square-only marker set + oriented stretch handles
Phase 1 of bringing the grip vocabulary in line with the standard
CAD convention: drop the per-position-type shape encoding (Diamond
for translate, Circle for parameter) and use a plain square for
every endpoint / vertex / centre grip. The behavioural midpoint vs
vertex distinction stays — it lives on `GripDef::is_midpoint` and
drives `Translate` vs `Absolute` in the grip-edit dispatcher — only
the marker shape collapses.
- `GripShape` keeps `Square`, `Rectangle`, `Triangle`. Diamond /
Circle are gone.
- `GripDef` gains `dir: Option<[f32; 2]>` — a world-XY direction
vector consumed by `Rectangle` to orient the box along its
segment.
- `entities::common` exposes `square_grip`, `center_grip` (same
square marker, flagged as translate), `rectangle_grip(id, world,
dir)` for oriented mid-segment handles, and a kept-for-Phase-2
`triangle_grip`.
- `overlay::GripMarker` / `grips_to_screen[_paper]` thread `dir`
through to the canvas painter; the Rectangle path rotates the
box around the grip centre using the world-XY direction (flipping
the sin for screen-Y).
Every existing `diamond_grip(id, w)` call becomes `center_grip(id,
w)` — the visual change is square-replacing-diamond at line
midpoints / arc midpoints / circle centres / ellipse centres /
viewport / hatch loop centroids / dimension grips / image corners /
multileader / ray / underlay / ole2frame / solid3d.
`LwPolyline` grows a stretch handle on every segment (straight or
arc), drawn as the new oriented rectangle. The grip-edit path
translates both segment endpoints for straight segments and
adjusts the arc bulge from the new midpoint for arc segments.
2026-05-29 02:07:34 +03:00
|
|
|
|
center_grip(0, ctr),
|
2026-06-11 00:04:37 +03:00
|
|
|
|
square_grip(1, ctr + glam::DVec3::new(r, 0.0, 0.0)),
|
|
|
|
|
|
square_grip(2, ctr + glam::DVec3::new(0.0, r, 0.0)),
|
|
|
|
|
|
square_grip(3, ctr - glam::DVec3::new(r, 0.0, 0.0)),
|
|
|
|
|
|
square_grip(4, ctr - glam::DVec3::new(0.0, r, 0.0)),
|
2026-03-22 14:56:27 +03:00
|
|
|
|
]
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-02 22:46:19 +03:00
|
|
|
|
fn properties(circle: &Circle) -> Vec<PropSection> {
|
feat(properties): conform entity property groups to PROPERTIES.md
Rewrite each entity's property builder to the per-entity group/row spec:
the correct sections (Geometry, Misc, Text, Pattern, Lines & Arrows, Leaders,
Block, …) with the spec's rows and real computed values — Diameter,
Circumference, Area, Delta X/Y/Z, Angle, Total angle, Arc length, Radius ratio,
etc. — plus apply routing for the editable rows.
Covers ~26 entities (Line, Circle, Arc, Point, Ellipse, Spline, polylines,
Ray/XLine, Insert, Text, MText, Hatch, Leader, MultiLeader, Tolerance, Solid,
Solid3D/Region/Body, meshes, MLine, Raster/Wipeout, Underlay, Table, Viewport,
Attribute, OLE). The 3D Visualization/Material group and the full Dimension
spec are deferred (they need document access for material/dimstyle name
resolution). Rows whose data is not in the pinned acadrust revision are shown
as empty placeholders, to be filled when the dependency is bumped.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 23:03:18 +03:00
|
|
|
|
use std::f64::consts::PI;
|
|
|
|
|
|
let r = circle.radius;
|
2026-07-02 22:46:19 +03:00
|
|
|
|
vec![PropSection {
|
2026-08-02 22:09:25 +03:00
|
|
|
|
title: t!("Geometry").into_owned(),
|
2026-03-22 14:56:27 +03:00
|
|
|
|
props: vec![
|
2026-08-02 22:09:25 +03:00
|
|
|
|
edit(t!("Center X").as_ref(), "center_x", circle.center.x),
|
|
|
|
|
|
edit(t!("Center Y").as_ref(), "center_y", circle.center.y),
|
|
|
|
|
|
edit(t!("Center Z").as_ref(), "center_z", circle.center.z),
|
|
|
|
|
|
edit(t!("Radius").as_ref(), "radius", r),
|
|
|
|
|
|
edit(t!("Diameter").as_ref(), "diameter", r * 2.0),
|
|
|
|
|
|
edit(t!("Circumference").as_ref(), "circumference", 2.0 * PI * r),
|
|
|
|
|
|
edit(t!("Area").as_ref(), "area", PI * r * r),
|
|
|
|
|
|
ro(t!("Normal X").as_ref(), "normal_x", format!("{:.4}", circle.normal.x)),
|
|
|
|
|
|
ro(t!("Normal Y").as_ref(), "normal_y", format!("{:.4}", circle.normal.y)),
|
|
|
|
|
|
ro(t!("Normal Z").as_ref(), "normal_z", format!("{:.4}", circle.normal.z)),
|
2026-03-22 14:56:27 +03:00
|
|
|
|
],
|
2026-07-02 22:46:19 +03:00
|
|
|
|
}]
|
2026-03-22 14:56:27 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn apply_geom_prop(circle: &mut Circle, field: &str, value: &str) {
|
2026-07-08 20:39:31 +03:00
|
|
|
|
use std::f64::consts::PI;
|
2026-03-22 14:56:27 +03:00
|
|
|
|
let Some(v) = parse_f64(value) else {
|
|
|
|
|
|
return;
|
|
|
|
|
|
};
|
|
|
|
|
|
match field {
|
|
|
|
|
|
"center_x" => circle.center.x = v,
|
|
|
|
|
|
"center_y" => circle.center.y = v,
|
|
|
|
|
|
"center_z" => circle.center.z = v,
|
|
|
|
|
|
"radius" if v > 0.0 => circle.radius = v,
|
2026-07-08 20:39:31 +03:00
|
|
|
|
"diameter" if v > 0.0 => circle.radius = v / 2.0,
|
|
|
|
|
|
"circumference" if v > 0.0 => circle.radius = v / (2.0 * PI),
|
|
|
|
|
|
"area" if v > 0.0 => circle.radius = (v / PI).sqrt(),
|
2026-03-22 14:56:27 +03:00
|
|
|
|
_ => {}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn apply_grip(circle: &mut Circle, grip_id: usize, apply: GripApply) {
|
|
|
|
|
|
match (grip_id, apply) {
|
|
|
|
|
|
(0, GripApply::Absolute(p)) => {
|
|
|
|
|
|
circle.center.x = p.x as f64;
|
|
|
|
|
|
circle.center.y = p.y as f64;
|
|
|
|
|
|
circle.center.z = p.z as f64;
|
|
|
|
|
|
}
|
|
|
|
|
|
(0, GripApply::Translate(d)) => {
|
|
|
|
|
|
circle.center.x += d.x as f64;
|
|
|
|
|
|
circle.center.y += d.y as f64;
|
|
|
|
|
|
circle.center.z += d.z as f64;
|
|
|
|
|
|
}
|
|
|
|
|
|
(1..=4, GripApply::Absolute(p)) => {
|
2026-06-24 03:32:11 +03:00
|
|
|
|
let dx = p.x - circle.center.x;
|
|
|
|
|
|
let dy = p.y - circle.center.y;
|
|
|
|
|
|
circle.radius = (dx * dx + dy * dy).sqrt();
|
2026-03-22 14:56:27 +03:00
|
|
|
|
}
|
|
|
|
|
|
_ => {}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn apply_transform(circle: &mut Circle, t: &EntityTransform) {
|
2026-06-16 11:33:46 +03:00
|
|
|
|
crate::scene::view::transform::apply_standard_entity_transform(circle, t, |entity, p1, p2| {
|
|
|
|
|
|
crate::scene::view::transform::reflect_xy_point(
|
2026-03-22 14:56:27 +03:00
|
|
|
|
&mut entity.center.x,
|
|
|
|
|
|
&mut entity.center.y,
|
|
|
|
|
|
p1,
|
|
|
|
|
|
p2,
|
|
|
|
|
|
);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl TruckConvertible for Circle {
|
|
|
|
|
|
fn to_truck(&self, _document: &acadrust::CadDocument) -> Option<TruckEntity> {
|
|
|
|
|
|
Some(to_truck(self))
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
refactor(entities): collapse trait wrapper boilerplate via macro
Every entity file ended with the same three-trait wrapper block:
impl Grippable for T {
fn grips(&self) -> Vec<GripDef> { grips(self) }
fn apply_grip(&mut self, ...) { apply_grip(self, ...) }
}
impl PropertyEditable for T { ... }
impl Transformable for T { ... }
— 23 lines of pure delegation around five same-named free functions.
Replace with `crate::impl_entity_basics!(T);` (a macro in
entities/traits.rs that expands to the three trait impls).
Applied where the file already follows the free-fn delegation
convention (Arc, Circle, Ellipse, Insert, Leader, Line, LwPolyline,
MultiLeader, Ole2Frame, Point, Spline, Viewport). Files that inlined
the trait method bodies directly (Ray, XLine, Shape, Solid, Tolerance,
MLine, Mesh, Solid3D/Region/Body, Table, RasterImage, Wipeout,
Underlay, Hatch, Polyline, Polyline2D, Polyline3D, Dimension) left
alone — they already skip the indirection. Text/MText/Attribute use
the with-text-style flavour and will move once that variant is needed
beyond the existing two manual impls.
A second macro `impl_entity_basics_with_text_styles!` is included for
the text-like flavour but no entity uses it yet.
Net: -204 lines.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-26 17:16:06 +03:00
|
|
|
|
crate::impl_entity_basics!(Circle);
|
refactor(commands): per-entity MassProps + TextContent traits
Two free helpers in app/commands.rs lived as big match-on-EntityType
blocks: massprop_entity (Circle/Arc/Line/LwPolyline/Ellipse area +
perimeter + centroid, ~140 lines) and entity_text_content /
replace_entity_text (Text/MText/AttributeDefinition/AttributeEntity).
Move each to its own trait in entities/traits.rs and implement
per-entity:
MassPropsCalc — Circle, Arc, Line, LwPolyline, Ellipse
TextContent — Text, MText, AttributeDefinition, AttributeEntity
EntityTypeOps gets dispatch shims that route to the trait via the
existing macro, so callsites just call entity.mass_props() /
entity.text_content() / entity.replace_text(search, rep).
The remaining free helpers in commands.rs (entity_list_details,
entity_extra_info, entity_type_name, build_data_extraction_csv) are
single-command formatting helpers tightly coupled to LIST / EXTRACT /
text-format output. Distributing them as per-entity methods would
inflate every entity file with command-side formatting concerns
without making the command-side any cleaner — left in place.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-23 23:30:34 +03:00
|
|
|
|
|
|
|
|
|
|
impl crate::entities::traits::MassPropsCalc for Circle {
|
|
|
|
|
|
fn mass_props(&self) -> crate::entities::traits::MassProps {
|
|
|
|
|
|
use std::f64::consts::{PI, TAU};
|
|
|
|
|
|
let r = self.radius;
|
|
|
|
|
|
crate::entities::traits::MassProps {
|
|
|
|
|
|
area: PI * r * r,
|
|
|
|
|
|
perimeter: TAU * r,
|
|
|
|
|
|
cx: self.center.x,
|
|
|
|
|
|
cy: self.center.y,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|