mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 02:47:48 +00:00
Run black
This commit is contained in:
@@ -585,7 +585,7 @@ class PolylineDecorator:
|
||||
|
||||
# Area and Length text
|
||||
polyline_verts = [Vector((p.x, p.y, p.z)) for p in polyline_points]
|
||||
center = sum(polyline_verts, Vector()) / len(polyline_verts) # Center between all polyline points
|
||||
center = sum(polyline_verts, Vector()) / len(polyline_verts) # Center between all polyline points
|
||||
area_text_coords = view3d_utils.location_3d_to_region_2d(region, rv3d, center)
|
||||
total_length_text_coords = view3d_utils.location_3d_to_region_2d(region, rv3d, polyline_verts[-1])
|
||||
|
||||
@@ -596,13 +596,13 @@ class PolylineDecorator:
|
||||
value = polyline_data.area
|
||||
text = f"area: {value}"
|
||||
text_length = blf.dimensions(self.font_id, text)
|
||||
area_text_coords[0] -= (text_length[0]/2) # Center text horizontally
|
||||
area_text_coords[0] -= text_length[0] / 2 # Center text horizontally
|
||||
blf.position(self.font_id, area_text_coords[0], area_text_coords[1], 0)
|
||||
self.draw_text_background(context, area_text_coords, text_length)
|
||||
blf.draw(self.font_id, text)
|
||||
|
||||
# Length
|
||||
if measure_type in {"POLYLINE","AREA"}:
|
||||
if measure_type in {"POLYLINE", "AREA"}:
|
||||
if len(polyline_verts) < 2:
|
||||
return
|
||||
blf.position(self.font_id, total_length_text_coords[0], total_length_text_coords[1], 0)
|
||||
@@ -614,7 +614,6 @@ class PolylineDecorator:
|
||||
|
||||
blf.disable(self.font_id, blf.SHADOW)
|
||||
|
||||
|
||||
def draw_snap_point(self, context):
|
||||
self.line_shader = gpu.shader.from_builtin("POLYLINE_UNIFORM_COLOR")
|
||||
self.line_shader.bind() # required to be able to change uniforms of the shader
|
||||
|
||||
@@ -179,16 +179,16 @@ class PolylineOperator:
|
||||
|
||||
if event.shift and event.type in {"WHEELUPMOUSE", "WHEELDOWNMOUSE"}:
|
||||
if event.type in {"WHEELUPMOUSE"}:
|
||||
self.tool_state.snap_angle += 5
|
||||
self.tool_state.snap_angle += 5
|
||||
else:
|
||||
self.tool_state.snap_angle -= 5
|
||||
self.tool_state.snap_angle -= 5
|
||||
self.handle_mouse_move(context, event)
|
||||
detected_snaps = tool.Snap.detect_snapping_points(context, event, self.objs_2d_bbox, self.tool_state)
|
||||
self.snapping_points = tool.Snap.select_snapping_points(context, event, self.tool_state, detected_snaps)
|
||||
tool.Polyline.calculate_distance_and_angle(context, self.input_ui, self.tool_state)
|
||||
PolylineDecorator.update(event, self.tool_state, self.input_ui, self.snapping_points[0])
|
||||
tool.Blender.update_viewport()
|
||||
|
||||
|
||||
def handle_keyboard_input(self, context, event):
|
||||
|
||||
if self.tool_state.is_input_on and event.value == "PRESS" and event.type == "TAB":
|
||||
|
||||
@@ -108,7 +108,7 @@ class LaunchTypeManager(bpy.types.Operator):
|
||||
def draw(self, context):
|
||||
props = context.scene.BIMModelProperties
|
||||
row = self.layout.row(align=True)
|
||||
if AuthoringData.data['total_types'] > 1:
|
||||
if AuthoringData.data["total_types"] > 1:
|
||||
text = f"{AuthoringData.data['total_types']} {AuthoringData.data['ifc_element_type']}s"
|
||||
else:
|
||||
text = f"{AuthoringData.data['total_types']} {AuthoringData.data['ifc_element_type']}"
|
||||
@@ -168,7 +168,7 @@ class LaunchTypeManager(bpy.types.Operator):
|
||||
row = box.row()
|
||||
op = box.operator("bim.load_type_thumbnails", text="", icon="FILE_REFRESH", emboss=False)
|
||||
op.ifc_class = props.ifc_class
|
||||
|
||||
|
||||
row = box.row()
|
||||
row.alignment = "CENTER"
|
||||
op = row.operator("bim.set_active_type", text=relating_type["predefined_type"], emboss=False)
|
||||
|
||||
@@ -339,7 +339,7 @@ class CreateObjectUI:
|
||||
cls.layout.label(text=tool_name, icon="TOOL_SETTINGS")
|
||||
|
||||
if AuthoringData.data["ifc_classes"] and AuthoringData.data["relating_type_id"]:
|
||||
cls.draw_thumbnail(context)
|
||||
cls.draw_thumbnail(context)
|
||||
cls.draw_add_object_parameters(context)
|
||||
cls.draw_add_object(context)
|
||||
else:
|
||||
@@ -366,11 +366,11 @@ class CreateObjectUI:
|
||||
emboss=False,
|
||||
)
|
||||
row1.operator(
|
||||
"bim.launch_type_manager",
|
||||
icon=tool.Blender.TYPE_MANAGER_ICON, #"DOWNARROW_HLT",
|
||||
text="",
|
||||
emboss=False,
|
||||
)
|
||||
"bim.launch_type_manager",
|
||||
icon=tool.Blender.TYPE_MANAGER_ICON, # "DOWNARROW_HLT",
|
||||
text="",
|
||||
emboss=False,
|
||||
)
|
||||
|
||||
if ui_context != "TOOL_HEADER":
|
||||
|
||||
@@ -383,7 +383,7 @@ class CreateObjectUI:
|
||||
row.operator(
|
||||
"bim.launch_add_element",
|
||||
text=f"Create New {AuthoringData.data['ifc_element_type']}",
|
||||
)
|
||||
)
|
||||
|
||||
row = box.row(align=True)
|
||||
|
||||
@@ -396,13 +396,13 @@ class CreateObjectUI:
|
||||
row.alignment = "CENTER"
|
||||
row.template_icon(icon_value=0, scale=3.5)
|
||||
elif AuthoringData.data["ifc_element_type"]:
|
||||
row = cls.layout.row(align=True)
|
||||
op = row.operator(
|
||||
"bim.add_default_type",
|
||||
icon_value=custom_icon_previews["QUICK_DEFAULT"].icon_id,
|
||||
text=f"Quick Create {AuthoringData.data['ifc_element_type']}",
|
||||
)
|
||||
op.ifc_element_type = AuthoringData.data["ifc_element_type"]
|
||||
row = cls.layout.row(align=True)
|
||||
op = row.operator(
|
||||
"bim.add_default_type",
|
||||
icon_value=custom_icon_previews["QUICK_DEFAULT"].icon_id,
|
||||
text=f"Quick Create {AuthoringData.data['ifc_element_type']}",
|
||||
)
|
||||
op.ifc_element_type = AuthoringData.data["ifc_element_type"]
|
||||
|
||||
@classmethod
|
||||
def draw_add_object(cls, context):
|
||||
@@ -483,7 +483,9 @@ class CreateObjectUI:
|
||||
row1.template_icon(icon_value=AuthoringData.data["type_thumbnail"], scale=1)
|
||||
row2 = box.column(align=True)
|
||||
row2.operator("bim.launch_type_manager", text="", emboss=False)
|
||||
row1.operator("bim.launch_type_manager", text=AuthoringData.data["relating_type_name"], emboss=False)
|
||||
row1.operator(
|
||||
"bim.launch_type_manager", text=AuthoringData.data["relating_type_name"], emboss=False
|
||||
)
|
||||
else:
|
||||
row1.operator(
|
||||
"bim.launch_type_manager",
|
||||
@@ -494,7 +496,7 @@ class CreateObjectUI:
|
||||
|
||||
row1.operator(
|
||||
"bim.launch_type_manager",
|
||||
icon=tool.Blender.TYPE_MANAGER_ICON, #"DOWNARROW_HLT",
|
||||
icon=tool.Blender.TYPE_MANAGER_ICON, # "DOWNARROW_HLT",
|
||||
text="",
|
||||
emboss=False,
|
||||
)
|
||||
@@ -502,7 +504,11 @@ class CreateObjectUI:
|
||||
if ui_context != "TOOL_HEADER":
|
||||
row = box.row(align=True)
|
||||
row.alignment = "CENTER"
|
||||
row.operator("bim.launch_type_manager", text=AuthoringData.data["relating_type_description"], emboss=False,)
|
||||
row.operator(
|
||||
"bim.launch_type_manager",
|
||||
text=AuthoringData.data["relating_type_description"],
|
||||
emboss=False,
|
||||
)
|
||||
|
||||
if AuthoringData.data["type_thumbnail"]:
|
||||
row1 = box.row()
|
||||
@@ -514,18 +520,19 @@ class CreateObjectUI:
|
||||
else:
|
||||
op = box.operator(
|
||||
"bim.load_type_thumbnails",
|
||||
text="", icon="FILE_REFRESH",
|
||||
text="",
|
||||
icon="FILE_REFRESH",
|
||||
emboss=False,
|
||||
)
|
||||
)
|
||||
op.ifc_class = cls.props.ifc_class
|
||||
|
||||
|
||||
row = box.row(align=True)
|
||||
row.alignment = "CENTER"
|
||||
row.operator(
|
||||
"bim.launch_type_manager",
|
||||
text=AuthoringData.data["predefined_type"],
|
||||
emboss=False,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class EditObjectUI:
|
||||
|
||||
@@ -47,6 +47,7 @@ def transparent_color(color, alpha=0.1):
|
||||
color[3] = alpha
|
||||
return color
|
||||
|
||||
|
||||
class ProjectDecorator:
|
||||
installed = None
|
||||
|
||||
@@ -310,7 +311,6 @@ class MeasureDecorator:
|
||||
blf.shadow(self.font_id, 6, 0, 0, 0, 1)
|
||||
color = self.addon_prefs.decorations_colour
|
||||
|
||||
|
||||
blf.color(self.font_id, *color)
|
||||
measure_data = context.scene.BIMPolylineProperties.measurement_polyline
|
||||
for polyline_data in measure_data:
|
||||
@@ -360,7 +360,7 @@ class MeasureDecorator:
|
||||
|
||||
# Area and Length text
|
||||
polyline_verts = [Vector((p.x, p.y, p.z)) for p in polyline_points]
|
||||
center = sum(polyline_verts, Vector()) / len(polyline_verts) # Center between all polyline points
|
||||
center = sum(polyline_verts, Vector()) / len(polyline_verts) # Center between all polyline points
|
||||
area_text_coords = view3d_utils.location_3d_to_region_2d(region, rv3d, center)
|
||||
total_length_text_coords = view3d_utils.location_3d_to_region_2d(region, rv3d, polyline_verts[-1])
|
||||
|
||||
@@ -371,13 +371,13 @@ class MeasureDecorator:
|
||||
value = polyline_data.area
|
||||
text = f"area: {value}"
|
||||
text_length = blf.dimensions(self.font_id, text)
|
||||
area_text_coords[0] -= (text_length[0]/2) # Center text horizontally
|
||||
area_text_coords[0] -= text_length[0] / 2 # Center text horizontally
|
||||
blf.position(self.font_id, area_text_coords[0], area_text_coords[1], 0)
|
||||
self.draw_text_background(context, area_text_coords, text_length)
|
||||
blf.draw(self.font_id, text)
|
||||
|
||||
# Length
|
||||
if measure_type in {"POLYLINE","AREA"}:
|
||||
if measure_type in {"POLYLINE", "AREA"}:
|
||||
if len(polyline_verts) < 2:
|
||||
return
|
||||
blf.position(self.font_id, total_length_text_coords[0], total_length_text_coords[1], 0)
|
||||
@@ -389,7 +389,6 @@ class MeasureDecorator:
|
||||
|
||||
blf.disable(self.font_id, blf.SHADOW)
|
||||
|
||||
|
||||
def __call__(self, context):
|
||||
|
||||
self.addon_prefs = tool.Blender.get_addon_preferences()
|
||||
|
||||
@@ -2453,7 +2453,6 @@ class MeasureTool(bpy.types.Operator, PolylineOperator):
|
||||
if not polyline_data.measurement_type:
|
||||
polyline_data.measurement_type = measurement_type
|
||||
|
||||
|
||||
tool.Polyline.calculate_area(context, self.input_ui)
|
||||
|
||||
if event.type == "E":
|
||||
|
||||
@@ -233,7 +233,7 @@ class BIMProjectProperties(PropertyGroup):
|
||||
|
||||
class MeasureToolSettings(PropertyGroup):
|
||||
measurement_type_items = [
|
||||
("SINGLE", "SINGLE", "Single", "FIXED_SIZE",1),
|
||||
("SINGLE", "SINGLE", "Single", "FIXED_SIZE", 1),
|
||||
("POLYLINE", "POLYLINE", "Polyline", "DRIVER_ROTATIONAL_DIFFERENCE", 2),
|
||||
("AREA", "AREA", "Area", "OUTLINER_DATA_LIGHTPROBE", 3),
|
||||
]
|
||||
|
||||
@@ -321,8 +321,10 @@ class Snap(bonsai.core.tool.Snap):
|
||||
for obj, bbox_2d in objs_2d_bbox:
|
||||
if obj.type in {"MESH", "EMPTY"} and bbox_2d:
|
||||
if tool.Raycast.intersect_mouse_2d_bounding_box(mouse_pos, bbox_2d, offset):
|
||||
if obj.visible_in_viewport_get(context.space_data): # Check for local view and local collections for this viewport and object
|
||||
objs_to_raycast.append(obj)
|
||||
if obj.visible_in_viewport_get(
|
||||
context.space_data
|
||||
): # Check for local view and local collections for this viewport and object
|
||||
objs_to_raycast.append(obj)
|
||||
|
||||
# Obj
|
||||
snap_obj, hit, face_index = cast_rays_and_get_best_object(objs_to_raycast, mouse_pos)
|
||||
|
||||
Reference in New Issue
Block a user