From 0dee353b8e518f2c6260e59cf1cbe0f737067e2e Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Thu, 20 Jul 2023 18:07:49 +0500 Subject: [PATCH] A bit more descriptive port UI Before - https://i.imgur.com/ZhVRoJM.png After - https://i.imgur.com/tI1h2i7.png --- .../blenderbim/bim/module/system/ui.py | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/system/ui.py b/src/blenderbim/blenderbim/bim/module/system/ui.py index 9aea14b027..c59b41c043 100644 --- a/src/blenderbim/blenderbim/bim/module/system/ui.py +++ b/src/blenderbim/blenderbim/bim/module/system/ui.py @@ -183,15 +183,38 @@ class BIM_PT_port(Panel): def draw(self, context): self.props = context.scene.BIMSystemProperties - row = self.layout.row(align=True) + + element = tool.Ifc.get_entity(context.active_object) + port_class = element.is_a() + layout = self.layout + row = layout.row(align=True) + row.label(text=port_class) row.operator("bim.connect_port", icon="PLUGIN", text="") row.operator("bim.disconnect_port", icon="UNLINKED", text="") - row.operator("bim.set_flow_direction", icon="FORWARD", text="").direction = "SOURCE" - row.operator("bim.set_flow_direction", icon="BACK", text="").direction = "SINK" - row.operator("bim.set_flow_direction", icon="ARROW_LEFTRIGHT", text="").direction = "SOURCEANDSINK" - row.operator("bim.set_flow_direction", icon="RESTRICT_INSTANCED_ON", text="").direction = "NOTDEFINED" row.operator("bim.remove_port", icon="X", text="") + if port_class == "IfcDistributionPort": + current_flow_direction = str(element.FlowDirection) + row = layout.row(align=True) + row.label(text="Flow Direction:") + row.label(text=current_flow_direction) + + # TODO: replace with enum property? + flow_directions = ( + ("SOURCE", "FORWARD"), + ("SINK", "BACK"), + ("SOURCEANDSINK", "ARROW_LEFTRIGHT"), + ("NOTDEFINED", "RESTRICT_INSTANCED_ON"), + ) + + row = layout.row(align=True) + row.label(text="Change Flow Direction:") + for flow_direction, icon in flow_directions: + row = layout.row() + row.operator("bim.set_flow_direction", icon=icon, text=flow_direction).direction = flow_direction + if flow_direction == current_flow_direction: + row.enabled = False + class BIM_UL_systems(UIList): def draw_item(self, context, layout, data, item, icon, active_data, active_propname):