mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 15:08:51 +00:00
Refactor PolylineDecorator to simplify label indexing and improve text spacing calculation
This commit is contained in:
committed by
Bruno Perdigão
parent
3c3525f205
commit
587fc63843
@@ -523,7 +523,6 @@ class PolylineDecorator:
|
|||||||
blf.color(self.font_id, *color)
|
blf.color(self.font_id, *color)
|
||||||
|
|
||||||
screen_coords = {}
|
screen_coords = {}
|
||||||
label_index = 0
|
|
||||||
|
|
||||||
for i in range(len(self.polyline_points)):
|
for i in range(len(self.polyline_points)):
|
||||||
if i < 1 and self.measure_type == "POLY_AREA":
|
if i < 1 and self.measure_type == "POLY_AREA":
|
||||||
@@ -536,9 +535,7 @@ class PolylineDecorator:
|
|||||||
if dim_text_coords:
|
if dim_text_coords:
|
||||||
formatted_value = self.polyline_points[i].dim
|
formatted_value = self.polyline_points[i].dim
|
||||||
text = "d: " + formatted_value
|
text = "d: " + formatted_value
|
||||||
screen_coords[f"distance_{label_index}"] = (dim_text_coords, text)
|
screen_coords[f"distance_{i}"] = (dim_text_coords, text)
|
||||||
label_index += 1
|
|
||||||
|
|
||||||
# --- Show angles for polyline/poly area ---
|
# --- Show angles for polyline/poly area ---
|
||||||
if self.measure_type != "SINGLE" and len(self.polyline_points) > 2:
|
if self.measure_type != "SINGLE" and len(self.polyline_points) > 2:
|
||||||
for i in range(len(self.polyline_points)):
|
for i in range(len(self.polyline_points)):
|
||||||
@@ -609,7 +606,11 @@ class PolylineDecorator:
|
|||||||
for label_key, (screen_co, text) in screen_coords.items():
|
for label_key, (screen_co, text) in screen_coords.items():
|
||||||
text_dimensions[label_key] = blf.dimensions(font_id, text)
|
text_dimensions[label_key] = blf.dimensions(font_id, text)
|
||||||
|
|
||||||
min_spacing = 12
|
if text_dimensions:
|
||||||
|
first_height = next(iter(text_dimensions.values()))[1]
|
||||||
|
min_spacing = max(2, first_height * 0.3)
|
||||||
|
else:
|
||||||
|
min_spacing = 2
|
||||||
|
|
||||||
label_keys = list(screen_coords.keys())
|
label_keys = list(screen_coords.keys())
|
||||||
for pass_num in range(3): # 3 passes to try to optimize complex overlaps
|
for pass_num in range(3): # 3 passes to try to optimize complex overlaps
|
||||||
|
|||||||
Reference in New Issue
Block a user