mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 02:47:48 +00:00
black formatting
This commit is contained in:
@@ -3435,6 +3435,7 @@ class UnassignRepresentationLayer(bpy.types.Operator, tool.Ifc.Operator):
|
||||
ifcopenshell.api.layer.unassign_layer(ifc_file, [representation], layer)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class CreateInstance(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_idname = "bim.create_instance"
|
||||
bl_label = "IFC Create Instance"
|
||||
@@ -3468,4 +3469,3 @@ class CreateInstance(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bpy.ops.bim.hotkey(hotkey="S_A")
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@@ -1261,7 +1261,6 @@ class BoundingBoxDecorator:
|
||||
|
||||
def draw_bounding_box_wire_cube(self, context):
|
||||
|
||||
|
||||
self.line_shader = gpu.shader.from_builtin("POLYLINE_UNIFORM_COLOR")
|
||||
self.line_shader.bind()
|
||||
self.line_shader.uniform_float("viewportSize", (context.region.width, context.region.height))
|
||||
@@ -1316,21 +1315,21 @@ class BoundingBoxDecorator:
|
||||
blf.color(font_id, *color)
|
||||
|
||||
closest_indices = self.find_closest_trihedron(corners, edges, region, rv3d)
|
||||
|
||||
|
||||
screen_coords = {}
|
||||
for axis_idx, axis in enumerate("XYZ"):
|
||||
pair = closest_indices[axis]
|
||||
if pair is not None:
|
||||
i1, i2 = pair
|
||||
offset_factor = 0.6 - (axis_idx * 0.1)
|
||||
offset_factor = 0.6 - (axis_idx * 0.1)
|
||||
center = corners[i1].lerp(corners[i2], offset_factor)
|
||||
value = getattr(dims, axis.lower())
|
||||
screen_co = location_3d_to_region_2d(region, rv3d, center)
|
||||
if screen_co is not None:
|
||||
screen_coords[axis] = (screen_co, value)
|
||||
|
||||
|
||||
self.adjust_overlapping_labels(screen_coords)
|
||||
|
||||
|
||||
for axis, (screen_co, value) in screen_coords.items():
|
||||
blf.position(font_id, screen_co.x, screen_co.y, 0)
|
||||
blf.color(font_id, 1, 1, 1, 1)
|
||||
@@ -1338,7 +1337,7 @@ class BoundingBoxDecorator:
|
||||
text_length = blf.dimensions(font_id, value_str)
|
||||
self.draw_text_background(context, screen_co, text_length)
|
||||
blf.draw(font_id, value_str)
|
||||
|
||||
|
||||
blf.disable(font_id, blf.SHADOW)
|
||||
|
||||
def adjust_overlapping_labels(self, screen_coords):
|
||||
@@ -1347,9 +1346,9 @@ class BoundingBoxDecorator:
|
||||
for axis, (screen_co, value) in screen_coords.items():
|
||||
value_str = f"D{axis.lower()}: " + format_distance(value, hide_units=False)
|
||||
text_dimensions[axis] = blf.dimensions(font_id, value_str)
|
||||
|
||||
|
||||
min_spacing = 5
|
||||
|
||||
|
||||
axes = list(screen_coords.keys())
|
||||
for i in range(len(axes)):
|
||||
for j in range(i + 1, len(axes)):
|
||||
@@ -1358,26 +1357,30 @@ class BoundingBoxDecorator:
|
||||
co2, _ = screen_coords[axis2]
|
||||
dim1 = text_dimensions[axis1]
|
||||
dim2 = text_dimensions[axis2]
|
||||
|
||||
|
||||
bounds1 = {
|
||||
"left": co1.x - min_spacing,
|
||||
"right": co1.x + dim1[0] + min_spacing,
|
||||
"top": co1.y + dim1[1] + min_spacing,
|
||||
"bottom": co1.y - min_spacing
|
||||
"bottom": co1.y - min_spacing,
|
||||
}
|
||||
bounds2 = {
|
||||
"left": co2.x - min_spacing,
|
||||
"right": co2.x + dim2[0] + min_spacing,
|
||||
"top": co2.y + dim2[1] + min_spacing,
|
||||
"bottom": co2.y - min_spacing
|
||||
"bottom": co2.y - min_spacing,
|
||||
}
|
||||
|
||||
if (bounds1["left"] < bounds2["right"] and bounds1["right"] > bounds2["left"] and
|
||||
bounds1["bottom"] < bounds2["top"] and bounds1["top"] > bounds2["bottom"]):
|
||||
|
||||
|
||||
if (
|
||||
bounds1["left"] < bounds2["right"]
|
||||
and bounds1["right"] > bounds2["left"]
|
||||
and bounds1["bottom"] < bounds2["top"]
|
||||
and bounds1["top"] > bounds2["bottom"]
|
||||
):
|
||||
|
||||
x_overlap = min(bounds1["right"], bounds2["right"]) - max(bounds1["left"], bounds2["left"])
|
||||
y_overlap = min(bounds1["top"], bounds2["top"]) - max(bounds1["bottom"], bounds2["bottom"])
|
||||
|
||||
|
||||
if x_overlap < y_overlap:
|
||||
if co1.x < co2.x:
|
||||
co1.x -= x_overlap / 2 + min_spacing
|
||||
@@ -1391,4 +1394,4 @@ class BoundingBoxDecorator:
|
||||
co2.y += y_overlap / 2 + min_spacing
|
||||
else:
|
||||
co1.y += y_overlap / 2 + min_spacing
|
||||
co2.y -= y_overlap / 2 + min_spacing
|
||||
co2.y -= y_overlap / 2 + min_spacing
|
||||
|
||||
@@ -147,7 +147,6 @@ def update_measure_xyz(self: "BIMModelProperties", context: bpy.types.Context) -
|
||||
self.prev_show_gizmo_object_translate = False
|
||||
|
||||
|
||||
|
||||
def update_cut_decorator(self: "BIMModelProperties", context: bpy.types.Context) -> None:
|
||||
if self.show_cut_decorator:
|
||||
CutDecorator.install(bpy.context)
|
||||
@@ -286,11 +285,7 @@ class BIMModelProperties(PropertyGroup):
|
||||
prev_transform_orientation_slot_type: bpy.props.StringProperty(name="Previous Gizmo Orientation Type")
|
||||
prev_show_gizmo_object_translate: bpy.props.BoolProperty(name="Previous Gizmo Translate")
|
||||
|
||||
show_bounding_box: bpy.props.BoolProperty(
|
||||
name="Measure XYZ Dimensions",
|
||||
default=False,
|
||||
update=update_measure_xyz
|
||||
)
|
||||
show_bounding_box: bpy.props.BoolProperty(name="Measure XYZ Dimensions", default=False, update=update_measure_xyz)
|
||||
show_cut_decorator: bpy.props.BoolProperty(
|
||||
name="Show Cut Decorator",
|
||||
default=True,
|
||||
|
||||
@@ -1334,7 +1334,7 @@ class BIM_PT_decorators_overlay(Panel):
|
||||
row = col.row(align=True)
|
||||
row.prop(model_props, "show_slab_direction", text="Slab Direction")
|
||||
row = col.row(align=True)
|
||||
row.prop(model_props, "show_bounding_box", text="Bounding Box Dimensions")
|
||||
row.prop(model_props, "show_bounding_box", text="Bounding Box Dimensions")
|
||||
row = col.row(align=True)
|
||||
row.prop(model_props, "show_cut_decorator", text="Cut Decorator")
|
||||
row.prop(model_props, "show_cut_decorator_fill", text="Fill Cut Decorator")
|
||||
|
||||
Reference in New Issue
Block a user