Skip to content

fix: GDK rounding for all shape primitives (#167)#422

Draft
rampageservices wants to merge 1 commit intogerbv:developfrom
SourceParts:fix/gdk-rounding-167
Draft

fix: GDK rounding for all shape primitives (#167)#422
rampageservices wants to merge 1 commit intogerbv:developfrom
SourceParts:fix/gdk-rounding-167

Conversation

@rampageservices
Copy link
Copy Markdown
Contributor

Summary

Extends the fix from PR #173 (which corrected arc bounding-box rounding) to all remaining shape primitives in the GDK renderer:

  • gerbv_gdk_draw_circlex - dia / 2round(x - dia / 2.0)
  • gerbv_gdk_draw_prim1 (macro circle) — same pattern
  • gerbv_gdk_draw_prim6 (moiré) — inline gdk_draw_arc call
  • gerbv_gdk_draw_prim7 (thermal) — inline gdk_draw_arc call
  • gerbv_gdk_draw_rectangle>> 1round(... / 2.0)
  • gerbv_gdk_draw_oval>> 1round(... / 2.0)

Integer division (/ 2 or >> 1) truncates toward zero, causing the bounding-box top-left corner to be off by one pixel for odd-valued dimensions. This makes concentric apertures (e.g. a pad with a drilled hole) appear misaligned at low zoom levels when using the GDK fast renderer.

Using round(... / 2.0) (which maps to ceil() via the local macro) matches the fix already applied to gerbv_gdk_draw_arc in #173.

Fixes #167

Test plan

  • cmake --build completes without warnings
  • ctest regression suite: same 11 pre-existing pixel-mismatch failures on both develop and this branch (no new failures)
  • Visual: load a Gerber with THT pads at low zoom in GDK mode, confirm pad/hole concentricity

Replace integer-truncating division (/ 2, >> 1) with round(... / 2.0)
when computing top-left coordinates for circles, macro primitives
(prim1, prim6, prim7), rectangles, and ovals in the GDK renderer.

Integer truncation causes off-by-one positioning of concentric
apertures (e.g. pad + hole) at low zoom levels, making them appear
misaligned. This extends the fix from PR gerbv#173 (which addressed arcs
only) to all remaining shape primitives.

Fixes gerbv#167
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gerbv incorrectly rounds aperture coordinates in fast render mode

1 participant