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>
This commit is contained in:
Hakan SevenandClaude Sonnet 4.6 committed 2026-04-03 15:31:05 +03:00
1 parent 27b5e124c7
commit 0aef1fc12f
27 files changed
+2217 -100

No files matched your search

+23 -2
View File
@@ -38,8 +38,9 @@ impl TruckConvertible for MLine {
// Parallel offset lines — one at +scale/2 and one at -scale/2
// along each vertex's miter direction.
if scale.abs() > 1e-6 {
for sign in [-0.5_f32, 0.5_f32] {
let offset = scale * sign;
let half = scale * 0.5;
for sign in [-1.0_f32, 1.0_f32] {
let offset = half * sign;
pts.push([f32::NAN; 3]);
for v in &self.vertices {
let mx = v.miter.x as f32;
@@ -63,6 +64,26 @@ impl TruckConvertible for MLine {
]);
}
}
// 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)],
[px + mx * half, py + my * half, pz + mz * half ],
]
};
pts.extend_from_slice(&cap_v(&self.vertices[0]));
pts.extend_from_slice(&cap_v(&self.vertices[n - 1]));
}
}
let key_verts: Vec<[f32; 3]> = self
+82 -14
View File
@@ -251,23 +251,91 @@ impl TruckConvertible for Wipeout {
impl Grippable for Wipeout {
fn grips(&self) -> Vec<GripDef> {
let corners = image_corners(
&self.insertion_point,
&self.u_vector,
&self.v_vector,
self.size.x,
self.size.y,
);
vec![
square_grip(0, Vec3::from(corners[0])),
diamond_grip(1, Vec3::from(corners[1])),
diamond_grip(2, Vec3::from(corners[2])),
diamond_grip(3, Vec3::from(corners[3])),
]
// If polygonal clipping is active, expose individual polygon vertices as grips.
let is_polygon = self.clipping_enabled
&& self.clip_boundary_vertices.len() >= 3
&& matches!(
self.clip_type,
acadrust::entities::WipeoutClipType::Polygonal
);
if is_polygon {
let ox = self.insertion_point.x as f32;
let oy = self.insertion_point.y as f32;
let oz = self.insertion_point.z as f32;
self.clip_boundary_vertices
.iter()
.enumerate()
.map(|(i, v)| {
let wx = (self.u_vector.x * v.x * self.size.x
+ self.v_vector.x * v.y * self.size.y) as f32;
let wy = (self.u_vector.y * v.x * self.size.x
+ self.v_vector.y * v.y * self.size.y) as f32;
let wz = (self.u_vector.z * v.x * self.size.x
+ self.v_vector.z * v.y * self.size.y) as f32;
if i == 0 {
square_grip(i, Vec3::new(ox + wx, oy + wy, oz + wz))
} else {
diamond_grip(i, Vec3::new(ox + wx, oy + wy, oz + wz))
}
})
.collect()
} else {
let corners = image_corners(
&self.insertion_point,
&self.u_vector,
&self.v_vector,
self.size.x,
self.size.y,
);
vec![
square_grip(0, Vec3::from(corners[0])),
diamond_grip(1, Vec3::from(corners[1])),
diamond_grip(2, Vec3::from(corners[2])),
diamond_grip(3, Vec3::from(corners[3])),
]
}
}
fn apply_grip(&mut self, grip_id: usize, apply: GripApply) {
if grip_id == 0 {
let is_polygon = self.clipping_enabled
&& self.clip_boundary_vertices.len() >= 3
&& matches!(
self.clip_type,
acadrust::entities::WipeoutClipType::Polygonal
);
if is_polygon {
// Move the clicked polygon vertex in world space → back-project to pixel space.
if let Some(v) = self.clip_boundary_vertices.get_mut(grip_id) {
// Compute current world position of this vertex.
let ox = self.insertion_point.x;
let oy = self.insertion_point.y;
let oz = self.insertion_point.z;
let cur_wx = ox + self.u_vector.x * v.x * self.size.x + self.v_vector.x * v.y * self.size.y;
let cur_wy = oy + self.u_vector.y * v.x * self.size.x + self.v_vector.y * v.y * self.size.y;
let cur_wz = oz + self.u_vector.z * v.x * self.size.x + self.v_vector.z * v.y * self.size.y;
let new_w = match apply {
GripApply::Translate(d) => {
[cur_wx + d.x as f64, cur_wy + d.y as f64, cur_wz + d.z as f64]
}
GripApply::Absolute(p) => [p.x as f64, p.y as f64, p.z as f64],
};
// Back-project: solve for pixel coords using u_vector and v_vector.
// In 2D (XY plane): new_w - insertion_point = u_vec * vx * sx + v_vec * vy * sy
let dx = new_w[0] - self.insertion_point.x;
let dy = new_w[1] - self.insertion_point.y;
let ux = self.u_vector.x * self.size.x;
let uy = self.u_vector.y * self.size.x;
let vx = self.v_vector.x * self.size.y;
let vy = self.v_vector.y * self.size.y;
let det = ux * vy - uy * vx;
if det.abs() > 1e-12 {
v.x = (dx * vy - dy * vx) / det;
v.y = (ux * dy - uy * dx) / det;
}
}
} else if grip_id == 0 {
match apply {
GripApply::Translate(d) => {
self.insertion_point.x += d.x as f64;
+34 -7
View File
@@ -71,22 +71,49 @@ impl TruckConvertible for Table {
// Cell text — lifted into Lines points via 2D strokes
let text_height = 0.18_f32;
let margin = text_height * 0.5_f32;
for (ri, row) in self.rows.iter().enumerate() {
let row_top = row_offsets[ri];
let row_bot = row_offsets.get(ri + 1).copied().unwrap_or(row_top + row.height as f32);
let row_mid = (row_top + row_bot) * 0.5;
let row_top = row_offsets[ri];
let row_bot = row_offsets.get(ri + 1).copied().unwrap_or(row_top + row.height as f32);
let row_mid = (row_top + row_bot) * 0.5;
for (ci, cell) in row.cells.iter().enumerate() {
let text = cell.text_value();
if text.is_empty() {
continue;
}
let col_left = col_offsets[ci];
let col_mid = col_left + self.columns.get(ci).map(|c| c.width as f32 * 0.5).unwrap_or(0.5);
let cell_center = origin + h * col_mid + v_down * row_mid;
let col_left = col_offsets[ci];
let col_width = self.columns.get(ci).map(|c| c.width as f32).unwrap_or(1.0);
let col_right = col_left + col_width;
// Alignment: CellStyle.alignment i32 encodes 1-9 (AutoCAD convention):
// 1=TopLeft 2=TopCenter 3=TopRight
// 4=MiddleLeft 5=MiddleCenter 6=MiddleRight
// 7=BottomLeft 8=BottomCenter 9=BottomRight
// 0/default = MiddleCenter (5)
let align = cell.style.as_ref().map_or(5, |s| s.alignment);
let horiz = ((align - 1).rem_euclid(3)) + 1; // 1=left, 2=center, 3=right
let vert = ((align - 1) / 3) + 1; // 1=top, 2=middle, 3=bottom
let text_w = cxf::measure_text(text, text_height, 1.0, "txt");
let x_offset = match horiz {
1 => col_left + margin, // left
3 => col_right - margin - text_w, // right
_ => col_left + (col_width - text_w) * 0.5, // center (default)
};
let y_offset = match vert {
1 => row_top + margin, // top
3 => row_bot - margin - text_height, // bottom
_ => row_mid - text_height * 0.5, // middle (default)
};
let text_origin = origin + h * x_offset + v_down * y_offset;
let strokes = cxf::tessellate_text_ex(
[cell_center.x, cell_center.y],
[text_origin.x, text_origin.y],
text_height,
0.0,
1.0,