From 424042474b3dd861b0456331c176e349f16d3a85 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 20 Oct 2023 11:59:31 +0500 Subject: [PATCH] Merge systems UI into one We had two very similar systems panels that were part of the old UI. --- .../blenderbim/bim/module/system/__init__.py | 2 - .../blenderbim/bim/module/system/data.py | 5 - .../blenderbim/bim/module/system/prop.py | 2 +- .../blenderbim/bim/module/system/ui.py | 116 +++++------------- 4 files changed, 30 insertions(+), 95 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/system/__init__.py b/src/blenderbim/blenderbim/bim/module/system/__init__.py index bb264dc9b8..cb1c8d24dc 100644 --- a/src/blenderbim/blenderbim/bim/module/system/__init__.py +++ b/src/blenderbim/blenderbim/bim/module/system/__init__.py @@ -50,13 +50,11 @@ classes = ( prop.BIMSystemProperties, prop.BIMZoneProperties, ui.BIM_PT_systems, - ui.BIM_PT_object_systems, ui.BIM_PT_zones, ui.BIM_PT_active_object_zones, ui.BIM_PT_ports, ui.BIM_PT_port, ui.BIM_UL_systems, - ui.BIM_UL_object_systems, ui.BIM_UL_zones, ) diff --git a/src/blenderbim/blenderbim/bim/module/system/data.py b/src/blenderbim/blenderbim/bim/module/system/data.py index bc88b4c22f..a2be0d98ec 100644 --- a/src/blenderbim/blenderbim/bim/module/system/data.py +++ b/src/blenderbim/blenderbim/bim/module/system/data.py @@ -70,7 +70,6 @@ class ObjectSystemData: def load(cls): cls.data = { "systems": cls.systems(), - "total_systems": cls.total_systems(), # AFTER SYSTEMS "connected_elements": cls.connected_elements(), } @@ -86,10 +85,6 @@ class ObjectSystemData: results.append({"id": system.id(), "name": system.Name or "Unnamed", "ifc_class": system.is_a()}) return results - @classmethod - def total_systems(cls): - return len(tool.System.get_systems()) - @classmethod def connected_elements(cls): if not cls.element: diff --git a/src/blenderbim/blenderbim/bim/module/system/prop.py b/src/blenderbim/blenderbim/bim/module/system/prop.py index 3b79421116..23c170c46f 100644 --- a/src/blenderbim/blenderbim/bim/module/system/prop.py +++ b/src/blenderbim/blenderbim/bim/module/system/prop.py @@ -64,7 +64,7 @@ class BIMSystemProperties(PropertyGroup): is_adding: BoolProperty(name="Is Adding", default=False) systems: CollectionProperty(name="Systems", type=System) active_system_index: IntProperty(name="Active System Index") - active_system_id: IntProperty(name="Active System Id") + active_system_id: IntProperty(name="Active System Id", description="Id of the currrently edited system") system_class: EnumProperty(items=get_system_class, name="Class") should_draw_decorations: BoolProperty( name="Should Draw Decorations", description="Toggle system decorations", update=toggle_decorations diff --git a/src/blenderbim/blenderbim/bim/module/system/ui.py b/src/blenderbim/blenderbim/bim/module/system/ui.py index 8d66c7d2a5..fea33a152a 100644 --- a/src/blenderbim/blenderbim/bim/module/system/ui.py +++ b/src/blenderbim/blenderbim/bim/module/system/ui.py @@ -30,6 +30,15 @@ FLOW_DIRECTION_TO_ICON = { "NOTDEFINED": "CHECKBOX_DEHLT", } +SYSTEM_ICONS = { + "IfcSystem": "EXTERNAL_DRIVE", + "IfcDistributionSystem": "NETWORK_DRIVE", + "IfcDistributionCircuit": "DRIVER", + "IfcBuildingSystem": "MOD_BUILD", + "IfcBuiltSystem": "MOD_BUILD", + "IfcZone": "CUBE", +} + class BIM_PT_systems(Panel): bl_label = "Systems" @@ -47,10 +56,27 @@ class BIM_PT_systems(Panel): def draw(self, context): if not SystemData.is_loaded: SystemData.load() + if not ObjectSystemData.is_loaded: + ObjectSystemData.load() + self.props = context.scene.BIMSystemProperties row = self.layout.row(align=True) - row.label(text="{} Systems Found".format(SystemData.data["total_systems"]), icon="OUTLINER") + row.prop(self.props, "should_draw_decorations") + + for system in ObjectSystemData.data["systems"]: + row = self.layout.row(align=True) + row.label(text=system["name"], icon=SYSTEM_ICONS[system["ifc_class"]]) + op = row.operator("bim.select_system_products", text="", icon="RESTRICT_SELECT_OFF") + op.system = system["id"] + op = row.operator("bim.unassign_system", text="", icon="X") + op.system = system["id"] + + if not ObjectSystemData.data["systems"]: + self.layout.label(text="No System associated with Active Object") + + row = self.layout.row(align=True) + row.label(text="{} Systems Found in Project".format(SystemData.data["total_systems"]), icon="OUTLINER") if self.props.is_editing: row.operator("bim.disable_system_editing_ui", text="", icon="CANCEL") @@ -81,67 +107,6 @@ class BIM_PT_systems(Panel): row.prop(attribute, "is_null", icon="RADIOBUT_OFF" if attribute.is_null else "RADIOBUT_ON", text="") -class BIM_PT_object_systems(Panel): - bl_label = "Systems" - bl_idname = "BIM_PT_object_systems" - bl_options = {"DEFAULT_CLOSED"} - bl_space_type = "PROPERTIES" - bl_region_type = "WINDOW" - bl_context = "object" - bl_order = 1 - bl_parent_id = "BIM_PT_tab_services_object" - - @classmethod - def poll(cls, context): - if not context.active_object: - return False - return tool.Ifc.get() and context.active_object.BIMObjectProperties.ifc_definition_id - - def draw(self, context): - if not ObjectSystemData.is_loaded: - ObjectSystemData.load() - self.props = context.scene.BIMSystemProperties - - row = self.layout.row(align=True) - row.prop(self.props, "should_draw_decorations") - - if self.props.is_editing: - row = self.layout.row() - row.alignment = "RIGHT" - row.operator("bim.disable_system_editing_ui", text="", icon="CANCEL") - self.layout.template_list( - "BIM_UL_object_systems", - "", - self.props, - "systems", - self.props, - "active_system_index", - ) - else: - row = self.layout.row(align=True) - row.label(text=f"{ObjectSystemData.data['total_systems']} Systems in IFC Project", icon="OUTLINER") - row.operator("bim.load_systems", text="", icon="GREASEPENCIL") - - system_icons = { - "IfcSystem": "EXTERNAL_DRIVE", - "IfcDistributionSystem": "NETWORK_DRIVE", - "IfcDistributionCircuit": "DRIVER", - "IfcBuildingSystem": "MOD_BUILD", - "IfcBuiltSystem": "MOD_BUILD", - "IfcZone": "CUBE", - } - for system in ObjectSystemData.data["systems"]: - row = self.layout.row(align=True) - row.label(text=system["name"], icon=system_icons[system["ifc_class"]]) - op = row.operator("bim.select_system_products", text="", icon="RESTRICT_SELECT_OFF") - op.system = system["id"] - op = row.operator("bim.unassign_system", text="", icon="X") - op.system = system["id"] - - if not ObjectSystemData.data["systems"]: - self.layout.label(text="No System associated with Active Object") - - class BIM_PT_ports(Panel): bl_label = "Ports" bl_idname = "BIM_PT_ports" @@ -368,18 +333,11 @@ class BIM_PT_active_object_zones(Panel): class BIM_UL_systems(UIList): def draw_item(self, context, layout, data, item, icon, active_data, active_propname): - system_icons = { - "IfcSystem": "EXTERNAL_DRIVE", - "IfcDistributionSystem": "NETWORK_DRIVE", - "IfcDistributionCircuit": "DRIVER", - "IfcBuildingSystem": "MOD_BUILD", - "IfcBuiltSystem": "MOD_BUILD", - "IfcZone": "CUBE", - } if item: row = layout.row(align=True) - row.label(text=item.name, icon=system_icons[item.ifc_class]) + row.label(text=item.name, icon=SYSTEM_ICONS[item.ifc_class]) system_id = item.ifc_definition_id + row.operator("bim.assign_system", text="", icon="ADD").system = item.ifc_definition_id if context.scene.BIMSystemProperties.active_system_id == system_id: op = row.operator("bim.select_system_products", text="", icon="RESTRICT_SELECT_OFF") op.system = system_id @@ -399,22 +357,6 @@ class BIM_UL_systems(UIList): op.system = system_id -class BIM_UL_object_systems(UIList): - def draw_item(self, context, layout, data, item, icon, active_data, active_propname): - system_icons = { - "IfcSystem": "EXTERNAL_DRIVE", - "IfcDistributionSystem": "NETWORK_DRIVE", - "IfcDistributionCircuit": "DRIVER", - "IfcBuildingSystem": "MOD_BUILD", - "IfcBuiltSystem": "MOD_BUILD", - "IfcZone": "CUBE", - } - if item: - row = layout.row(align=True) - row.label(text=item.name, icon=system_icons[item.ifc_class]) - row.operator("bim.assign_system", text="", icon="ADD").system = item.ifc_definition_id - - class BIM_UL_zones(UIList): def draw_item(self, context, layout, data, item, icon, active_data, active_propname): if item: