draftwright 0.1.1__tar.gz → 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: draftwright
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: Automated technical-drawing generation for build123d
5
5
  Project-URL: Homepage, https://github.com/pzfreo/draftwright
6
6
  Project-URL: Repository, https://github.com/pzfreo/draftwright
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "draftwright"
7
- version = "0.1.1"
7
+ version = "0.1.2"
8
8
  description = "Automated technical-drawing generation for build123d"
9
9
  readme = "README.md"
10
10
  license = { file = "LICENSE" }
@@ -1254,15 +1254,14 @@ def _auto_annotate(dwg, a):
1254
1254
  return a.PV_Y + (y - a.cy) * a.SCALE
1255
1255
 
1256
1256
  # Tighten right-strip outer_limits to the actual iso view left edge now
1257
- # that the iso has been projected and fitted. Guard: only apply if the
1258
- # limit is above the strip cursor an overflowing iso can produce
1259
- # _iso_x_limit < cursor, which would silence every right-strip allocation.
1257
+ # that the iso has been projected and fitted. Always apply so that any
1258
+ # future allocations are bounded; warn when the cursor has already passed
1259
+ # the limit (dims already placed may overlap the iso view).
1260
1260
  _iso_x0, _, _, _ = _iso_bbox(dwg)
1261
1261
  _iso_x_limit = _iso_x0 - 4
1262
1262
  for _rs in (a.fv_zones.right, a.pv_zones.right, a.sv_zones.right):
1263
- if _iso_x_limit > _rs._cursor:
1264
- _rs.outer_limit = min(_rs.outer_limit, _iso_x_limit)
1265
- else:
1263
+ _rs.outer_limit = min(_rs.outer_limit, _iso_x_limit)
1264
+ if _rs._cursor >= _iso_x_limit:
1266
1265
  _log.warning(
1267
1266
  "right-strip cursor %.1f >= iso_x limit %.1f: right-strip dims"
1268
1267
  " may overlap iso view (iso view overflows into annotation zone)",
@@ -2693,7 +2692,10 @@ def _fit_iso_view(dwg, a):
2693
2692
  if extent > 0
2694
2693
  ]
2695
2694
  needed = min(ratios, default=1.0)
2696
- factor = next((f for f in _ISO_SHRINK_FACTORS if f <= needed), _ISO_SHRINK_FACTORS[-1])
2695
+ # Apply a 2 % safety margin and floor to 4 decimal places to avoid
2696
+ # floating-point creep past the region boundary. The iso is NTS so
2697
+ # there is no need to constrain to "clean" fractions.
2698
+ factor = math.floor(needed * 0.98 * 10000) / 10000
2697
2699
  _project_iso(dwg, a, a.SCALE * factor)
2698
2700
  bb = _iso_bbox(dwg)
2699
2701
  if not _bbox_within(bb, region):
@@ -1167,10 +1167,13 @@ def test_shrunk_iso_keeps_world_to_page_mapping(shrunk_iso_drawing):
1167
1167
  vis, _hid = dwg.views["iso"]
1168
1168
  bb = vis.bounding_box()
1169
1169
  assert bb.min.X < centre[0] < bb.max.X and bb.min.Y < centre[1] < bb.max.Y
1170
- # This fixture shrinks the iso to 1/2 sheet scale (see the NTS test above).
1171
- # World +Z maps to page +Y; the offset must use the shrunk view scale.
1170
+ # World +Z maps to page +Y; the offset must use the shrunk view scale (not
1171
+ # the sheet scale). Derive the actual shrunk scale from _coords so the
1172
+ # test does not depend on a specific discretised shrink factor.
1173
+ shrunk_scale = dwg._coords["iso"]._scale
1174
+ assert shrunk_scale < dwg.scale, "iso should be shrunk below sheet scale"
1172
1175
  raised = dwg.at("iso", cx, cy, cz + 100)
1173
- assert raised[1] - centre[1] == pytest.approx(100 * dwg.scale * 0.5)
1176
+ assert raised[1] - centre[1] == pytest.approx(100 * shrunk_scale)
1174
1177
 
1175
1178
 
1176
1179
  @pytest.mark.timeout(60)
File without changes
File without changes
File without changes
File without changes
File without changes