mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-10-02 13:04:49 +00:00
Ifc text viewport rotation for text with box alignment
This commit is contained in:
@@ -412,7 +412,7 @@ class BaseDecorator:
|
|||||||
ang = -Vector((1, 0)).angle_signed(text_dir)
|
ang = -Vector((1, 0)).angle_signed(text_dir)
|
||||||
cos = math.cos(ang)
|
cos = math.cos(ang)
|
||||||
sin = math.sin(ang)
|
sin = math.sin(ang)
|
||||||
rotated_y_axis = Vector([-sin, cos])
|
rotation_matrix = Matrix.Rotation(-ang, 2)
|
||||||
|
|
||||||
# Horrific prototype code
|
# Horrific prototype code
|
||||||
factor = self.camera_zoom_to_factor(context.space_data.region_3d.view_camera_zoom)
|
factor = self.camera_zoom_to_factor(context.space_data.region_3d.view_camera_zoom)
|
||||||
@@ -424,7 +424,7 @@ class BaseDecorator:
|
|||||||
# font_size = 16 <-- this is a good default
|
# font_size = 16 <-- this is a good default
|
||||||
# TODO: need to synchronize it better with svg
|
# TODO: need to synchronize it better with svg
|
||||||
font_size_px = int(0.004118616 * mm_to_px) * font_size_mm / 2.5
|
font_size_px = int(0.004118616 * mm_to_px) * font_size_mm / 2.5
|
||||||
pos = pos - line_no * font_size_px * rotated_y_axis
|
pos = pos - line_no * font_size_px * rotation_matrix[1]
|
||||||
|
|
||||||
blf.size(font_id, font_size_px, dpi)
|
blf.size(font_id, font_size_px, dpi)
|
||||||
|
|
||||||
@@ -432,20 +432,24 @@ class BaseDecorator:
|
|||||||
w, h = blf.dimensions(font_id, text)
|
w, h = blf.dimensions(font_id, text)
|
||||||
|
|
||||||
if box_alignment:
|
if box_alignment:
|
||||||
# TODO: need to work out the rotation too
|
box_alignment_offset = Vector((0, 0))
|
||||||
if "bottom" in box_alignment:
|
if "bottom" in box_alignment:
|
||||||
pass
|
pass
|
||||||
elif "top" in box_alignment:
|
elif "top" in box_alignment:
|
||||||
pos -= Vector((0, h))
|
box_alignment_offset += Vector((0, h))
|
||||||
else:
|
else:
|
||||||
pos -= Vector((0, h / 2)) # middle / center
|
# middle / center
|
||||||
|
box_alignment_offset += Vector((0, h / 2))
|
||||||
|
|
||||||
if "left" in box_alignment:
|
if "left" in box_alignment:
|
||||||
pass
|
pass
|
||||||
elif "right" in box_alignment:
|
elif "right" in box_alignment:
|
||||||
pos -= Vector((w, 0))
|
box_alignment_offset += Vector((w, 0))
|
||||||
else:
|
else:
|
||||||
pos -= Vector((w / 2, 0))
|
# middle / center
|
||||||
|
box_alignment_offset += Vector((w / 2, 0))
|
||||||
|
|
||||||
|
pos -= rotation_matrix.transposed() @ box_alignment_offset
|
||||||
else:
|
else:
|
||||||
if center:
|
if center:
|
||||||
# horizontal centering
|
# horizontal centering
|
||||||
|
|||||||
Reference in New Issue
Block a user