mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 23:36:20 +00:00
Closes #7984: Resize sheet drawings from upper-left corner
Previously update_sheet_drawing_sizes anchored resizes to the center of each drawing. Now the top-left corner is fixed and size changes grow or shrink rightward and downward, with the view-title tracking the bottom edge by the full height delta. Generated with the assistance of an AI coding tool.
This commit is contained in:
@@ -194,18 +194,13 @@ class SheetBuilder:
|
|||||||
|
|
||||||
# Check if the dimensions have changed
|
# Check if the dimensions have changed
|
||||||
if current_width != view_width or current_height != view_height:
|
if current_width != view_width or current_height != view_height:
|
||||||
readjust = Vector((current_width - view_width, current_height - view_height)) / 2
|
height_delta = view_height - current_height
|
||||||
|
|
||||||
for image in drawing_view.findall(f"{SVG}image"):
|
for image in drawing_view.findall(f"{SVG}image"):
|
||||||
x = float(image.attrib["x"])
|
|
||||||
y = float(image.attrib["y"])
|
|
||||||
if image.attrib["data-type"] == "view-title":
|
if image.attrib["data-type"] == "view-title":
|
||||||
image.attrib["x"] = str(x + readjust.x)
|
# title sits below the drawing, so it tracks the bottom edge
|
||||||
# negate y offset because view-title comes AFTER foreground
|
image.attrib["y"] = str(float(image.attrib["y"]) + height_delta)
|
||||||
image.attrib["y"] = str(y - readjust.y)
|
|
||||||
else:
|
else:
|
||||||
image.attrib["x"] = str(x + readjust.x)
|
|
||||||
image.attrib["y"] = str(y + readjust.y)
|
|
||||||
image.attrib["width"] = str(view_width)
|
image.attrib["width"] = str(view_width)
|
||||||
image.attrib["height"] = str(view_height)
|
image.attrib["height"] = str(view_height)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user