mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 10:32:42 +00:00
cleanup
This commit is contained in:
committed by
Bruno Perdigão
parent
587fc63843
commit
84d55d8969
@@ -531,62 +531,63 @@ class PolylineDecorator:
|
|||||||
continue
|
continue
|
||||||
dim_text_pos = (Vector(self.polyline_points[i].position) + Vector(self.polyline_points[i - 1].position)) / 2
|
dim_text_pos = (Vector(self.polyline_points[i].position) + Vector(self.polyline_points[i - 1].position)) / 2
|
||||||
dim_text_coords = view3d_utils.location_3d_to_region_2d(region, rv3d, dim_text_pos)
|
dim_text_coords = view3d_utils.location_3d_to_region_2d(region, rv3d, dim_text_pos)
|
||||||
|
|
||||||
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_{i}"] = (dim_text_coords, text)
|
screen_coords[f"distance_{i}"] = (Vector(dim_text_coords), text)
|
||||||
# --- Show angles for polyline/poly area ---
|
|
||||||
if self.measure_type != "SINGLE" and len(self.polyline_points) > 2:
|
|
||||||
for i in range(len(self.polyline_points)):
|
|
||||||
if i == 0 or i == len(self.polyline_points) - 1:
|
|
||||||
continue
|
|
||||||
angle_text_pos = Vector(self.polyline_points[i].position)
|
|
||||||
angle_text_coords = view3d_utils.location_3d_to_region_2d(region, rv3d, angle_text_pos)
|
|
||||||
if angle_text_coords:
|
|
||||||
text = "a: " + self.polyline_points[i+1].angle
|
|
||||||
screen_coords[f"angle_{i}"] = (angle_text_coords, text)
|
|
||||||
|
|
||||||
|
if i == 1:
|
||||||
|
continue
|
||||||
|
angle_text_pos = Vector(self.polyline_points[i - 1].position)
|
||||||
|
angle_text_coords = view3d_utils.location_3d_to_region_2d(region, rv3d, angle_text_pos)
|
||||||
|
if angle_text_coords:
|
||||||
|
text = "a: " + self.polyline_points[i].angle
|
||||||
|
screen_coords[f"angle_{i}"] = (Vector(angle_text_coords), text)
|
||||||
|
|
||||||
# --- Show XYZ axis values for single measurement ---
|
|
||||||
if self.measure_type == "SINGLE":
|
if self.measure_type == "SINGLE":
|
||||||
axis_line, axis_line_center = self.calculate_measurement_x_y_and_z(context)
|
axis_line, axis_line_center = self.calculate_measurement_x_y_and_z(context)
|
||||||
if axis_line and axis_line_center:
|
for i, dim_text_pos in enumerate(axis_line_center):
|
||||||
for i, dim_text_pos in enumerate(axis_line_center):
|
dim_text_coords = view3d_utils.location_3d_to_region_2d(region, rv3d, dim_text_pos)
|
||||||
dim_text_coords = view3d_utils.location_3d_to_region_2d(region, rv3d, dim_text_pos)
|
if dim_text_coords:
|
||||||
if dim_text_coords:
|
value = round((axis_line[i][1] - axis_line[i][0]).length, 4)
|
||||||
value = round((axis_line[i][1] - axis_line[i][0]).length, 4)
|
direction = axis_line[i][1] - axis_line[i][0]
|
||||||
direction = axis_line[i][1] - axis_line[i][0]
|
if (i == 0 and direction.x < 0) or (i == 1 and direction.y < 0) or (i == 2 and direction.z < 0):
|
||||||
if (i == 0 and direction.x < 0) or (i == 1 and direction.y < 0) or (i == 2 and direction.z < 0):
|
value = -value
|
||||||
value = -value
|
prefix = "xyz"[i]
|
||||||
prefix = "xyz"[i]
|
formatted_value = tool.Polyline.format_input_ui_units(value)
|
||||||
formatted_value = tool.Polyline.format_input_ui_units(value)
|
text = f"{prefix}: {formatted_value}"
|
||||||
text = f"{prefix}: {formatted_value}"
|
screen_coords[f"xyz_{i}"] = (Vector(dim_text_coords), text)
|
||||||
screen_coords[f"xyz_{i}"] = (dim_text_coords, text)
|
|
||||||
|
|
||||||
#Area and Length text
|
# Area and Length text
|
||||||
polyline_verts = [Vector((p.x, p.y, p.z)) for p in self.polyline_points]
|
polyline_verts = [Vector((p.x, p.y, p.z)) for p in self.polyline_points]
|
||||||
|
|
||||||
# Area
|
# Area
|
||||||
if self.measure_type == "POLY_AREA" and self.polyline_data.area:
|
if self.measure_type == "POLY_AREA" and self.polyline_data.area:
|
||||||
if len(polyline_verts) >= 3:
|
if len(polyline_verts) < 3:
|
||||||
center = sum(polyline_verts, Vector()) / len(polyline_verts)
|
blf.disable(self.font_id, blf.SHADOW)
|
||||||
if polyline_verts[0] == polyline_verts[-1]:
|
return
|
||||||
center = sum(polyline_verts[:-1], Vector()) / len(polyline_verts[:-1])
|
center = sum(polyline_verts, Vector()) / len(polyline_verts)
|
||||||
area_text_coords = view3d_utils.location_3d_to_region_2d(region, rv3d, center)
|
if polyline_verts[0] == polyline_verts[-1]:
|
||||||
if area_text_coords:
|
center = sum(polyline_verts[:-1], Vector()) / len(polyline_verts[:-1])
|
||||||
value = self.polyline_data.area
|
area_text_coords = view3d_utils.location_3d_to_region_2d(region, rv3d, center)
|
||||||
text = f"area: {value}"
|
if area_text_coords:
|
||||||
screen_coords["area"] = (area_text_coords, text)
|
value = self.polyline_data.area
|
||||||
|
text = f"area: {value}"
|
||||||
|
text_length = blf.dimensions(self.font_id, text)
|
||||||
|
area_text_coords = list(area_text_coords)
|
||||||
|
area_text_coords[0] -= text_length[0] / 2
|
||||||
|
screen_coords["area"] = (Vector(area_text_coords), text)
|
||||||
|
|
||||||
# Length
|
# Length
|
||||||
if self.measure_type in {"POLYLINE", "POLY_AREA"}:
|
if self.measure_type in {"POLYLINE", "POLY_AREA"}:
|
||||||
if len(polyline_verts) >= 3:
|
if len(polyline_verts) < 3:
|
||||||
total_length_text_coords = view3d_utils.location_3d_to_region_2d(region, rv3d, polyline_verts[-1])
|
blf.disable(self.font_id, blf.SHADOW)
|
||||||
if total_length_text_coords:
|
return
|
||||||
value = self.polyline_data.total_length
|
total_length_text_coords = view3d_utils.location_3d_to_region_2d(region, rv3d, polyline_verts[-1])
|
||||||
text = f"length: {value}"
|
if total_length_text_coords:
|
||||||
screen_coords["length"] = (total_length_text_coords, text)
|
value = self.polyline_data.total_length
|
||||||
|
text = f"length: {value}"
|
||||||
|
screen_coords["length"] = (Vector(total_length_text_coords), text)
|
||||||
|
|
||||||
self.adjust_overlapping_labels(screen_coords)
|
self.adjust_overlapping_labels(screen_coords)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user