mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 22:12:32 +00:00
black formating
This commit is contained in:
@@ -533,7 +533,7 @@ class BIM_PT_derived_coordinates(Panel):
|
|||||||
area_3d = next((area for area in context.screen.areas if area.type == "VIEW_3D"), None)
|
area_3d = next((area for area in context.screen.areas if area.type == "VIEW_3D"), None)
|
||||||
space_3d = next((space for space in area_3d.spaces if space.type == "VIEW_3D"), None)
|
space_3d = next((space for space in area_3d.spaces if space.type == "VIEW_3D"), None)
|
||||||
|
|
||||||
if bpy.context.scene.BIMModelProperties.measure_xyz_dimensions:
|
if bpy.context.scene.BIMModelProperties.measure_xyz_dimensions:
|
||||||
for axis, icon, idx in [("X", "STRIP_COLOR_01", 0), ("Y", "STRIP_COLOR_04", 1), ("Z", "STRIP_COLOR_05", 2)]:
|
for axis, icon, idx in [("X", "STRIP_COLOR_01", 0), ("Y", "STRIP_COLOR_04", 1), ("Z", "STRIP_COLOR_05", 2)]:
|
||||||
row.label(text="", icon=icon)
|
row.label(text="", icon=icon)
|
||||||
row.prop(context.active_object, "dimensions", text=axis, index=idx)
|
row.prop(context.active_object, "dimensions", text=axis, index=idx)
|
||||||
|
|||||||
@@ -1124,6 +1124,7 @@ class FaceAreaDecorator:
|
|||||||
self.draw_batch("LINES", data["verts"], decorator_color, data["edges"])
|
self.draw_batch("LINES", data["verts"], decorator_color, data["edges"])
|
||||||
self.draw_batch("TRIS", data["verts"], transparent_color(decorator_color, alpha=0.5), data["tris"])
|
self.draw_batch("TRIS", data["verts"], transparent_color(decorator_color, alpha=0.5), data["tris"])
|
||||||
|
|
||||||
|
|
||||||
class BoundingBoxDecorator:
|
class BoundingBoxDecorator:
|
||||||
is_installed = False
|
is_installed = False
|
||||||
handlers = []
|
handlers = []
|
||||||
@@ -1143,7 +1144,9 @@ class BoundingBoxDecorator:
|
|||||||
cls.uninstall()
|
cls.uninstall()
|
||||||
handler = cls()
|
handler = cls()
|
||||||
cls.handlers.append(
|
cls.handlers.append(
|
||||||
bpy.types.SpaceView3D.draw_handler_add(handler.draw_bounding_box_wire_cube, (context,), "WINDOW", "POST_VIEW")
|
bpy.types.SpaceView3D.draw_handler_add(
|
||||||
|
handler.draw_bounding_box_wire_cube, (context,), "WINDOW", "POST_VIEW"
|
||||||
|
)
|
||||||
)
|
)
|
||||||
cls.handlers.append(
|
cls.handlers.append(
|
||||||
bpy.types.SpaceView3D.draw_handler_add(handler.draw_dimension_text, (context,), "WINDOW", "POST_PIXEL")
|
bpy.types.SpaceView3D.draw_handler_add(handler.draw_dimension_text, (context,), "WINDOW", "POST_PIXEL")
|
||||||
@@ -1163,6 +1166,7 @@ class BoundingBoxDecorator:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def get_combined_bounding_box_corners(objects):
|
def get_combined_bounding_box_corners(objects):
|
||||||
import mathutils
|
import mathutils
|
||||||
|
|
||||||
if not objects:
|
if not objects:
|
||||||
return None, None, None
|
return None, None, None
|
||||||
if len(objects) == 1:
|
if len(objects) == 1:
|
||||||
@@ -1190,9 +1194,18 @@ class BoundingBoxDecorator:
|
|||||||
mathutils.Vector((max_corner.x, max_corner.y, min_corner.z)),
|
mathutils.Vector((max_corner.x, max_corner.y, min_corner.z)),
|
||||||
]
|
]
|
||||||
edges = [
|
edges = [
|
||||||
(0, 1, "Z"), (1, 2, "Y"), (2, 3, "Z"), (3, 0, "Y"),
|
(0, 1, "Z"),
|
||||||
(4, 5, "Z"), (5, 6, "Y"), (6, 7, "Z"), (7, 4, "Y"),
|
(1, 2, "Y"),
|
||||||
(0, 4, "X"), (1, 5, "X"), (2, 6, "X"), (3, 7, "X"),
|
(2, 3, "Z"),
|
||||||
|
(3, 0, "Y"),
|
||||||
|
(4, 5, "Z"),
|
||||||
|
(5, 6, "Y"),
|
||||||
|
(6, 7, "Z"),
|
||||||
|
(7, 4, "Y"),
|
||||||
|
(0, 4, "X"),
|
||||||
|
(1, 5, "X"),
|
||||||
|
(2, 6, "X"),
|
||||||
|
(3, 7, "X"),
|
||||||
]
|
]
|
||||||
axis_colors = {
|
axis_colors = {
|
||||||
"X": (0.956, 0.282, 0.322, 1),
|
"X": (0.956, 0.282, 0.322, 1),
|
||||||
@@ -1204,6 +1217,7 @@ class BoundingBoxDecorator:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def find_closest_trihedron(corners, edges, region, rv3d):
|
def find_closest_trihedron(corners, edges, region, rv3d):
|
||||||
from bpy_extras.view3d_utils import location_3d_to_region_2d
|
from bpy_extras.view3d_utils import location_3d_to_region_2d
|
||||||
|
|
||||||
min_y = float("inf")
|
min_y = float("inf")
|
||||||
best_origin = None
|
best_origin = None
|
||||||
for idx, corner in enumerate(corners):
|
for idx, corner in enumerate(corners):
|
||||||
@@ -1243,7 +1257,7 @@ class BoundingBoxDecorator:
|
|||||||
verts = [top_left, bottom_left, top_right, bottom_right]
|
verts = [top_left, bottom_left, top_right, bottom_right]
|
||||||
gpu.state.blend_set("ALPHA")
|
gpu.state.blend_set("ALPHA")
|
||||||
self.draw_batch("TRIS", verts, color, [(0, 1, 2), (1, 2, 3)])
|
self.draw_batch("TRIS", verts, color, [(0, 1, 2), (1, 2, 3)])
|
||||||
|
|
||||||
def draw_bounding_box_wire_cube(self, context):
|
def draw_bounding_box_wire_cube(self, context):
|
||||||
import gpu
|
import gpu
|
||||||
from gpu_extras.batch import batch_for_shader
|
from gpu_extras.batch import batch_for_shader
|
||||||
@@ -1281,7 +1295,6 @@ class BoundingBoxDecorator:
|
|||||||
self.line_shader.uniform_float("viewportSize", (context.region.width, context.region.height))
|
self.line_shader.uniform_float("viewportSize", (context.region.width, context.region.height))
|
||||||
self.shader = gpu.shader.from_builtin("UNIFORM_COLOR")
|
self.shader = gpu.shader.from_builtin("UNIFORM_COLOR")
|
||||||
|
|
||||||
|
|
||||||
selected_objects = [obj for obj in bpy.context.selected_objects if hasattr(obj, "bound_box")]
|
selected_objects = [obj for obj in bpy.context.selected_objects if hasattr(obj, "bound_box")]
|
||||||
if not selected_objects:
|
if not selected_objects:
|
||||||
return
|
return
|
||||||
@@ -1323,4 +1336,4 @@ class BoundingBoxDecorator:
|
|||||||
text_length = blf.dimensions(font_id, value_str)
|
text_length = blf.dimensions(font_id, value_str)
|
||||||
self.draw_text_background(context, screen_co, text_length)
|
self.draw_text_background(context, screen_co, text_length)
|
||||||
blf.draw(font_id, value_str)
|
blf.draw(font_id, value_str)
|
||||||
blf.disable(font_id, blf.SHADOW)
|
blf.disable(font_id, blf.SHADOW)
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ def update_measure_xyz(self: "BIMModelProperties", context: bpy.types.Context) -
|
|||||||
area_3d = next((area for area in context.screen.areas if area.type == "VIEW_3D"), None)
|
area_3d = next((area for area in context.screen.areas if area.type == "VIEW_3D"), None)
|
||||||
space_3d = next((space for space in area_3d.spaces if space.type == "VIEW_3D"), None) if area_3d else None
|
space_3d = next((space for space in area_3d.spaces if space.type == "VIEW_3D"), None) if area_3d else None
|
||||||
scene = context.scene
|
scene = context.scene
|
||||||
|
|
||||||
if self.measure_xyz_dimensions:
|
if self.measure_xyz_dimensions:
|
||||||
BoundingBoxDecorator.install(context)
|
BoundingBoxDecorator.install(context)
|
||||||
# Save previous state if not already saved
|
# Save previous state if not already saved
|
||||||
@@ -145,6 +145,8 @@ def update_measure_xyz(self: "BIMModelProperties", context: bpy.types.Context) -
|
|||||||
if prev_gizmo is not None:
|
if prev_gizmo is not None:
|
||||||
space_3d.show_gizmo_object_translate = prev_gizmo
|
space_3d.show_gizmo_object_translate = prev_gizmo
|
||||||
self.prev_show_gizmo_object_translate = False
|
self.prev_show_gizmo_object_translate = False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def update_cut_decorator(self: "BIMModelProperties", context: bpy.types.Context) -> None:
|
def update_cut_decorator(self: "BIMModelProperties", context: bpy.types.Context) -> None:
|
||||||
if self.show_cut_decorator:
|
if self.show_cut_decorator:
|
||||||
@@ -281,12 +283,8 @@ class BIMModelProperties(PropertyGroup):
|
|||||||
update=update_slab_direction_decorator,
|
update=update_slab_direction_decorator,
|
||||||
)
|
)
|
||||||
|
|
||||||
prev_transform_orientation_slot_type: bpy.props.StringProperty(
|
prev_transform_orientation_slot_type: bpy.props.StringProperty(name="Previous Gizmo Orientation Type")
|
||||||
name="Previous Gizmo Orientation Type"
|
prev_show_gizmo_object_translate: bpy.props.BoolProperty(name="Previous Gizmo Translate")
|
||||||
)
|
|
||||||
prev_show_gizmo_object_translate: bpy.props.BoolProperty(
|
|
||||||
name="Previous Gizmo Translate"
|
|
||||||
)
|
|
||||||
|
|
||||||
measure_xyz_dimensions: bpy.props.BoolProperty(
|
measure_xyz_dimensions: bpy.props.BoolProperty(
|
||||||
name="Measure XYZ Dimensions",
|
name="Measure XYZ Dimensions",
|
||||||
|
|||||||
@@ -2787,6 +2787,7 @@ class MeasureFaceAreaTool(bpy.types.Operator, PolylineOperator):
|
|||||||
FaceAreaDecorator.install(context)
|
FaceAreaDecorator.install(context)
|
||||||
return {"RUNNING_MODAL"}
|
return {"RUNNING_MODAL"}
|
||||||
|
|
||||||
|
|
||||||
class ClearMeasurement(bpy.types.Operator):
|
class ClearMeasurement(bpy.types.Operator):
|
||||||
bl_idname = "bim.clear_measurement"
|
bl_idname = "bim.clear_measurement"
|
||||||
bl_label = "Clear measurement from the screen"
|
bl_label = "Clear measurement from the screen"
|
||||||
|
|||||||
Reference in New Issue
Block a user