fix: address review findings on merged #293/#292 hatch+snap
Three defects found reviewing the just-merged PRs: - PLOTWINDOW forced corner snap (#293) only ran in the on_tick preview path, so the marker highlighted an endpoint but the click committed a plain snap — with the global OSNAP master (or Endpoint mode) off the corner landed at the raw cursor, defeating the feature. Apply the same snap_forced_corners branch at the click-commit recompute. - build_dxf_pattern (#292) wrote the pattern line's LOCAL step into the world-frame HatchPatternLine.offset. The new prebaked reader inverse-rotates offset assuming world frame, so app-created hatches (HATCH command) collapsed their spacing by cos(angle) — ANSI31 at 45deg rendered 2.245 instead of 3.175 on both viewport and PDF/plot export. Rotate the local step into world here so it round-trips and the stored offset is format-correct for other CAD apps. - far_from_origin_pattern_hatch_still_fills placed its offset ALONG the 45deg lines (projects to k~0), so it never exercised the span-cap fix and passed even with the old absolute-index clamp restored. Move the offset perpendicular to the lines so |k| >> the cap. Add app_created_hatch_roundtrips_catalog_spacing to guard the offset-frame fix (verified: fails at 2.245 without it, passes at 3.175 with it). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
dcef60c6b0
commit
cb41910f12
3 changed files with 97 additions and 5 deletions
|
|
@ -45,10 +45,20 @@ pub fn build_dxf_pattern(entry: &PatternEntry) -> DxfPattern {
|
|||
pat.description = entry.description.clone();
|
||||
for ln in &entry.pat_lines {
|
||||
let angle_rad = (ln.angle_deg as f64).to_radians();
|
||||
// The catalog stores the step (dx = shift along the line, dy =
|
||||
// perpendicular spacing) in the pattern LINE-LOCAL frame. The DWG
|
||||
// `HatchPatternLine.offset` is a WORLD-space vector — that is how real
|
||||
// files store it and how `family_from_stored_line` reads it back (it
|
||||
// inverse-rotates by the line angle). Emitting the raw local step here
|
||||
// made the reader recover a rotated, too-dense spacing (e.g. ANSI31 at
|
||||
// 45° collapsed 3.175 → 2.245). Rotate local → world by the line angle
|
||||
// so the offset is format-correct and round-trips to the exact spacing.
|
||||
let (ca, sa) = (angle_rad.cos(), angle_rad.sin());
|
||||
let (ldx, ldy) = (ln.dx as f64, ln.dy as f64);
|
||||
pat.lines.push(HatchPatternLine {
|
||||
angle: angle_rad,
|
||||
base_point: Vector2::new(ln.x0 as f64, ln.y0 as f64),
|
||||
offset: Vector2::new(ln.dx as f64, ln.dy as f64),
|
||||
offset: Vector2::new(ldx * ca - ldy * sa, ldx * sa + ldy * ca),
|
||||
dash_lengths: ln.dashes.iter().map(|&d| d as f64).collect(),
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue