2026-04-02 19:06:20 +03:00
|
|
|
use acadrust::entities::MLine;
|
|
|
|
|
use glam::Vec3;
|
|
|
|
|
|
|
|
|
|
use crate::command::EntityTransform;
|
|
|
|
|
use crate::entities::common::{edit_prop as edit, ro_prop as ro, square_grip};
|
|
|
|
|
use crate::entities::traits::{Grippable, PropertyEditable, Transformable, TruckConvertible};
|
|
|
|
|
use crate::scene::acad_to_truck::{TruckEntity, TruckObject};
|
|
|
|
|
use crate::scene::object::{GripApply, GripDef, PropSection, PropValue, Property};
|
2026-05-02 19:59:37 +03:00
|
|
|
use crate::scene::wire_model::SnapHint;
|
2026-04-02 19:06:20 +03:00
|
|
|
|
|
|
|
|
impl TruckConvertible for MLine {
|
|
|
|
|
fn to_truck(&self, _document: &acadrust::CadDocument) -> Option<TruckEntity> {
|
|
|
|
|
if self.vertices.is_empty() {
|
|
|
|
|
return None;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let n = self.vertices.len();
|
|
|
|
|
let closed = self.flags.contains(acadrust::entities::MLineFlags::CLOSED);
|
|
|
|
|
|
|
|
|
|
// Spine: center line connecting all vertex positions.
|
|
|
|
|
// Also attempt to draw parallel offset lines (±scale/2 in miter direction)
|
|
|
|
|
// when scale_factor is non-zero.
|
|
|
|
|
let scale = self.scale_factor as f32;
|
|
|
|
|
|
|
|
|
|
let mut pts: Vec<[f32; 3]> = Vec::new();
|
|
|
|
|
|
|
|
|
|
// Center spine.
|
|
|
|
|
for v in &self.vertices {
|
2026-05-12 10:36:15 +03:00
|
|
|
pts.push([
|
|
|
|
|
v.position.x as f32,
|
|
|
|
|
v.position.y as f32,
|
|
|
|
|
v.position.z as f32,
|
|
|
|
|
]);
|
2026-04-02 19:06:20 +03:00
|
|
|
}
|
|
|
|
|
if closed && n >= 2 {
|
|
|
|
|
pts.push([
|
|
|
|
|
self.vertices[0].position.x as f32,
|
|
|
|
|
self.vertices[0].position.y as f32,
|
|
|
|
|
self.vertices[0].position.z as f32,
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Parallel offset lines — one at +scale/2 and one at -scale/2
|
|
|
|
|
// along each vertex's miter direction.
|
|
|
|
|
if scale.abs() > 1e-6 {
|
Feat: ROADMAP Phase 1-5 batch — trim/extend, plot scale, viewport UX, mline caps, table alignment
- TRIM/EXTEND: Ray and XLine entities supported as cutting boundaries and trim targets;
trim results in Ray→Line/Ray, XLine→Ray/Ray or Line; hover preview added
- Plot scale override: Fit/1:1/1:2/1:5/1:10/1:20/1:50/1:100/2:1 buttons added to Page Setup
panel; PageSetupCommit applies scale to PlotSettings
- Viewport UX: locked viewport gets orange border; selected viewport gets white border
- Named view → viewport assignment: Choice dropdown in properties panel copies
view_target/direction/height to the viewport entity
- MLine caps: perpendicular start/end cap lines added for open (non-closed) MLines
- Wipeout polygon grips: boundary vertices become editable grips when clipping_enabled+Polygonal;
world→pixel back-projection on drag
- Table cell alignment: CellStyle.alignment (1-9) drives left/center/right + top/middle/bottom
text positioning; cxf::measure_text() helper added
- New commands/features: DIMCONTINUE (DCO), DIMBASELINE (DBA), TOLERANCE (TOL), TABLE,
ATTDEF, ATTEDIT, ATTDISP, BREAKATPOINT (BAP), PLOTWINDOW (PW), MLINE (ML);
DIMSTYLE/DIMCURRENT/CLAYER/LTSCALE/CELTSCALE/SCALETEXT/XDATA/UCSICON/REGEN/DRAWORDER extended
- PLINE arc mode: A/L/CLOSE text input, bulge computation, arc preview
- Warning cleanup: removed unused imports and unreachable patterns
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 15:31:05 +03:00
|
|
|
let half = scale * 0.5;
|
|
|
|
|
for sign in [-1.0_f32, 1.0_f32] {
|
|
|
|
|
let offset = half * sign;
|
2026-04-02 19:06:20 +03:00
|
|
|
pts.push([f32::NAN; 3]);
|
|
|
|
|
for v in &self.vertices {
|
|
|
|
|
let mx = v.miter.x as f32;
|
|
|
|
|
let my = v.miter.y as f32;
|
|
|
|
|
let mz = v.miter.z as f32;
|
|
|
|
|
pts.push([
|
|
|
|
|
v.position.x as f32 + mx * offset,
|
|
|
|
|
v.position.y as f32 + my * offset,
|
|
|
|
|
v.position.z as f32 + mz * offset,
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
if closed && n >= 2 {
|
|
|
|
|
let v0 = &self.vertices[0];
|
|
|
|
|
let mx = v0.miter.x as f32;
|
|
|
|
|
let my = v0.miter.y as f32;
|
|
|
|
|
let mz = v0.miter.z as f32;
|
|
|
|
|
pts.push([
|
|
|
|
|
v0.position.x as f32 + mx * offset,
|
|
|
|
|
v0.position.y as f32 + my * offset,
|
|
|
|
|
v0.position.z as f32 + mz * offset,
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|
Feat: ROADMAP Phase 1-5 batch — trim/extend, plot scale, viewport UX, mline caps, table alignment
- TRIM/EXTEND: Ray and XLine entities supported as cutting boundaries and trim targets;
trim results in Ray→Line/Ray, XLine→Ray/Ray or Line; hover preview added
- Plot scale override: Fit/1:1/1:2/1:5/1:10/1:20/1:50/1:100/2:1 buttons added to Page Setup
panel; PageSetupCommit applies scale to PlotSettings
- Viewport UX: locked viewport gets orange border; selected viewport gets white border
- Named view → viewport assignment: Choice dropdown in properties panel copies
view_target/direction/height to the viewport entity
- MLine caps: perpendicular start/end cap lines added for open (non-closed) MLines
- Wipeout polygon grips: boundary vertices become editable grips when clipping_enabled+Polygonal;
world→pixel back-projection on drag
- Table cell alignment: CellStyle.alignment (1-9) drives left/center/right + top/middle/bottom
text positioning; cxf::measure_text() helper added
- New commands/features: DIMCONTINUE (DCO), DIMBASELINE (DBA), TOLERANCE (TOL), TABLE,
ATTDEF, ATTEDIT, ATTDISP, BREAKATPOINT (BAP), PLOTWINDOW (PW), MLINE (ML);
DIMSTYLE/DIMCURRENT/CLAYER/LTSCALE/CELTSCALE/SCALETEXT/XDATA/UCSICON/REGEN/DRAWORDER extended
- PLINE arc mode: A/L/CLOSE text input, bulge computation, arc preview
- Warning cleanup: removed unused imports and unreachable patterns
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 15:31:05 +03:00
|
|
|
|
|
|
|
|
// Start and end caps: perpendicular line connecting the two offset lines
|
|
|
|
|
// at the first and last vertex of an open MLine.
|
|
|
|
|
if !closed {
|
|
|
|
|
let cap_v = |v: &acadrust::entities::MLineVertex| {
|
|
|
|
|
let mx = v.miter.x as f32;
|
|
|
|
|
let my = v.miter.y as f32;
|
|
|
|
|
let mz = v.miter.z as f32;
|
|
|
|
|
let px = v.position.x as f32;
|
|
|
|
|
let py = v.position.y as f32;
|
|
|
|
|
let pz = v.position.z as f32;
|
|
|
|
|
[
|
|
|
|
|
[f32::NAN; 3],
|
|
|
|
|
[px + mx * (-half), py + my * (-half), pz + mz * (-half)],
|
2026-05-12 10:36:15 +03:00
|
|
|
[px + mx * half, py + my * half, pz + mz * half],
|
Feat: ROADMAP Phase 1-5 batch — trim/extend, plot scale, viewport UX, mline caps, table alignment
- TRIM/EXTEND: Ray and XLine entities supported as cutting boundaries and trim targets;
trim results in Ray→Line/Ray, XLine→Ray/Ray or Line; hover preview added
- Plot scale override: Fit/1:1/1:2/1:5/1:10/1:20/1:50/1:100/2:1 buttons added to Page Setup
panel; PageSetupCommit applies scale to PlotSettings
- Viewport UX: locked viewport gets orange border; selected viewport gets white border
- Named view → viewport assignment: Choice dropdown in properties panel copies
view_target/direction/height to the viewport entity
- MLine caps: perpendicular start/end cap lines added for open (non-closed) MLines
- Wipeout polygon grips: boundary vertices become editable grips when clipping_enabled+Polygonal;
world→pixel back-projection on drag
- Table cell alignment: CellStyle.alignment (1-9) drives left/center/right + top/middle/bottom
text positioning; cxf::measure_text() helper added
- New commands/features: DIMCONTINUE (DCO), DIMBASELINE (DBA), TOLERANCE (TOL), TABLE,
ATTDEF, ATTEDIT, ATTDISP, BREAKATPOINT (BAP), PLOTWINDOW (PW), MLINE (ML);
DIMSTYLE/DIMCURRENT/CLAYER/LTSCALE/CELTSCALE/SCALETEXT/XDATA/UCSICON/REGEN/DRAWORDER extended
- PLINE arc mode: A/L/CLOSE text input, bulge computation, arc preview
- Warning cleanup: removed unused imports and unreachable patterns
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 15:31:05 +03:00
|
|
|
]
|
|
|
|
|
};
|
|
|
|
|
pts.extend_from_slice(&cap_v(&self.vertices[0]));
|
|
|
|
|
pts.extend_from_slice(&cap_v(&self.vertices[n - 1]));
|
|
|
|
|
}
|
2026-04-02 19:06:20 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let key_verts: Vec<[f32; 3]> = self
|
|
|
|
|
.vertices
|
|
|
|
|
.iter()
|
2026-05-12 10:36:15 +03:00
|
|
|
.map(|v| {
|
|
|
|
|
[
|
|
|
|
|
v.position.x as f32,
|
|
|
|
|
v.position.y as f32,
|
|
|
|
|
v.position.z as f32,
|
|
|
|
|
]
|
|
|
|
|
})
|
2026-04-02 19:06:20 +03:00
|
|
|
.collect();
|
|
|
|
|
|
2026-05-02 19:59:37 +03:00
|
|
|
let snap_pts = self
|
|
|
|
|
.vertices
|
|
|
|
|
.iter()
|
|
|
|
|
.map(|v| {
|
|
|
|
|
(
|
2026-05-12 10:36:15 +03:00
|
|
|
Vec3::new(
|
|
|
|
|
v.position.x as f32,
|
|
|
|
|
v.position.y as f32,
|
|
|
|
|
v.position.z as f32,
|
|
|
|
|
),
|
2026-05-02 19:59:37 +03:00
|
|
|
SnapHint::Node,
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
.collect();
|
|
|
|
|
|
2026-04-02 19:06:20 +03:00
|
|
|
Some(TruckEntity {
|
|
|
|
|
object: TruckObject::Lines(pts),
|
2026-05-02 19:59:37 +03:00
|
|
|
snap_pts,
|
2026-04-02 19:06:20 +03:00
|
|
|
tangent_geoms: vec![],
|
|
|
|
|
key_vertices: key_verts,
|
2026-05-06 23:24:26 +03:00
|
|
|
fill_tris: vec![],
|
2026-04-02 19:06:20 +03:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Grippable for MLine {
|
|
|
|
|
fn grips(&self) -> Vec<GripDef> {
|
|
|
|
|
self.vertices
|
|
|
|
|
.iter()
|
|
|
|
|
.enumerate()
|
|
|
|
|
.map(|(i, v)| {
|
|
|
|
|
square_grip(
|
|
|
|
|
i,
|
2026-05-12 10:36:15 +03:00
|
|
|
Vec3::new(
|
|
|
|
|
v.position.x as f32,
|
|
|
|
|
v.position.y as f32,
|
|
|
|
|
v.position.z as f32,
|
|
|
|
|
),
|
2026-04-02 19:06:20 +03:00
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
.collect()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn apply_grip(&mut self, grip_id: usize, apply: GripApply) {
|
|
|
|
|
if let Some(v) = self.vertices.get_mut(grip_id) {
|
|
|
|
|
match apply {
|
|
|
|
|
GripApply::Translate(d) => {
|
|
|
|
|
v.position.x += d.x as f64;
|
|
|
|
|
v.position.y += d.y as f64;
|
|
|
|
|
v.position.z += d.z as f64;
|
|
|
|
|
}
|
|
|
|
|
GripApply::Absolute(p) => {
|
|
|
|
|
v.position.x = p.x as f64;
|
|
|
|
|
v.position.y = p.y as f64;
|
|
|
|
|
v.position.z = p.z as f64;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl PropertyEditable for MLine {
|
|
|
|
|
fn geometry_properties(&self, _text_style_names: &[String]) -> PropSection {
|
|
|
|
|
PropSection {
|
|
|
|
|
title: "Geometry".into(),
|
|
|
|
|
props: vec![
|
|
|
|
|
ro("Style", "ml_style", self.style_name.clone()),
|
|
|
|
|
ro("Vertices", "ml_verts", self.vertices.len().to_string()),
|
|
|
|
|
edit("Scale", "ml_scale", self.scale_factor),
|
|
|
|
|
Property {
|
|
|
|
|
label: "Closed".into(),
|
|
|
|
|
field: "ml_closed",
|
|
|
|
|
value: PropValue::BoolToggle {
|
|
|
|
|
field: "ml_closed",
|
|
|
|
|
value: self.flags.contains(acadrust::entities::MLineFlags::CLOSED),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn apply_geom_prop(&mut self, field: &str, value: &str) {
|
|
|
|
|
match field {
|
|
|
|
|
"ml_closed" => {
|
|
|
|
|
let closed = if value == "toggle" {
|
|
|
|
|
!self.flags.contains(acadrust::entities::MLineFlags::CLOSED)
|
|
|
|
|
} else {
|
|
|
|
|
value == "true"
|
|
|
|
|
};
|
2026-05-12 10:36:15 +03:00
|
|
|
self.flags
|
|
|
|
|
.set(acadrust::entities::MLineFlags::CLOSED, closed);
|
2026-04-02 19:06:20 +03:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
_ => {}
|
|
|
|
|
}
|
2026-05-12 10:36:15 +03:00
|
|
|
let Ok(v) = value.trim().parse::<f64>() else {
|
|
|
|
|
return;
|
|
|
|
|
};
|
2026-04-02 19:06:20 +03:00
|
|
|
if field == "ml_scale" && v != 0.0 {
|
|
|
|
|
self.scale_factor = v;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Transformable for MLine {
|
|
|
|
|
fn apply_transform(&mut self, t: &EntityTransform) {
|
|
|
|
|
crate::scene::transform::apply_standard_entity_transform(self, t, |entity, p1, p2| {
|
|
|
|
|
for v in &mut entity.vertices {
|
|
|
|
|
crate::scene::transform::reflect_xy_point(
|
|
|
|
|
&mut v.position.x,
|
|
|
|
|
&mut v.position.y,
|
|
|
|
|
p1,
|
|
|
|
|
p2,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
crate::scene::transform::reflect_xy_point(
|
|
|
|
|
&mut entity.start_point.x,
|
|
|
|
|
&mut entity.start_point.y,
|
|
|
|
|
p1,
|
|
|
|
|
p2,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|