mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 21:58:46 +00:00
Merge systems UI into one
We had two very similar systems panels that were part of the old UI.
This commit is contained in:
@@ -50,13 +50,11 @@ classes = (
|
|||||||
prop.BIMSystemProperties,
|
prop.BIMSystemProperties,
|
||||||
prop.BIMZoneProperties,
|
prop.BIMZoneProperties,
|
||||||
ui.BIM_PT_systems,
|
ui.BIM_PT_systems,
|
||||||
ui.BIM_PT_object_systems,
|
|
||||||
ui.BIM_PT_zones,
|
ui.BIM_PT_zones,
|
||||||
ui.BIM_PT_active_object_zones,
|
ui.BIM_PT_active_object_zones,
|
||||||
ui.BIM_PT_ports,
|
ui.BIM_PT_ports,
|
||||||
ui.BIM_PT_port,
|
ui.BIM_PT_port,
|
||||||
ui.BIM_UL_systems,
|
ui.BIM_UL_systems,
|
||||||
ui.BIM_UL_object_systems,
|
|
||||||
ui.BIM_UL_zones,
|
ui.BIM_UL_zones,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ class ObjectSystemData:
|
|||||||
def load(cls):
|
def load(cls):
|
||||||
cls.data = {
|
cls.data = {
|
||||||
"systems": cls.systems(),
|
"systems": cls.systems(),
|
||||||
"total_systems": cls.total_systems(),
|
|
||||||
# AFTER SYSTEMS
|
# AFTER SYSTEMS
|
||||||
"connected_elements": cls.connected_elements(),
|
"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()})
|
results.append({"id": system.id(), "name": system.Name or "Unnamed", "ifc_class": system.is_a()})
|
||||||
return results
|
return results
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def total_systems(cls):
|
|
||||||
return len(tool.System.get_systems())
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def connected_elements(cls):
|
def connected_elements(cls):
|
||||||
if not cls.element:
|
if not cls.element:
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class BIMSystemProperties(PropertyGroup):
|
|||||||
is_adding: BoolProperty(name="Is Adding", default=False)
|
is_adding: BoolProperty(name="Is Adding", default=False)
|
||||||
systems: CollectionProperty(name="Systems", type=System)
|
systems: CollectionProperty(name="Systems", type=System)
|
||||||
active_system_index: IntProperty(name="Active System Index")
|
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")
|
system_class: EnumProperty(items=get_system_class, name="Class")
|
||||||
should_draw_decorations: BoolProperty(
|
should_draw_decorations: BoolProperty(
|
||||||
name="Should Draw Decorations", description="Toggle system decorations", update=toggle_decorations
|
name="Should Draw Decorations", description="Toggle system decorations", update=toggle_decorations
|
||||||
|
|||||||
@@ -30,6 +30,15 @@ FLOW_DIRECTION_TO_ICON = {
|
|||||||
"NOTDEFINED": "CHECKBOX_DEHLT",
|
"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):
|
class BIM_PT_systems(Panel):
|
||||||
bl_label = "Systems"
|
bl_label = "Systems"
|
||||||
@@ -47,10 +56,27 @@ class BIM_PT_systems(Panel):
|
|||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
if not SystemData.is_loaded:
|
if not SystemData.is_loaded:
|
||||||
SystemData.load()
|
SystemData.load()
|
||||||
|
if not ObjectSystemData.is_loaded:
|
||||||
|
ObjectSystemData.load()
|
||||||
|
|
||||||
self.props = context.scene.BIMSystemProperties
|
self.props = context.scene.BIMSystemProperties
|
||||||
|
|
||||||
row = self.layout.row(align=True)
|
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:
|
if self.props.is_editing:
|
||||||
row.operator("bim.disable_system_editing_ui", text="", icon="CANCEL")
|
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="")
|
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):
|
class BIM_PT_ports(Panel):
|
||||||
bl_label = "Ports"
|
bl_label = "Ports"
|
||||||
bl_idname = "BIM_PT_ports"
|
bl_idname = "BIM_PT_ports"
|
||||||
@@ -368,18 +333,11 @@ class BIM_PT_active_object_zones(Panel):
|
|||||||
|
|
||||||
class BIM_UL_systems(UIList):
|
class BIM_UL_systems(UIList):
|
||||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
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:
|
if item:
|
||||||
row = layout.row(align=True)
|
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
|
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:
|
if context.scene.BIMSystemProperties.active_system_id == system_id:
|
||||||
op = row.operator("bim.select_system_products", text="", icon="RESTRICT_SELECT_OFF")
|
op = row.operator("bim.select_system_products", text="", icon="RESTRICT_SELECT_OFF")
|
||||||
op.system = system_id
|
op.system = system_id
|
||||||
@@ -399,22 +357,6 @@ class BIM_UL_systems(UIList):
|
|||||||
op.system = system_id
|
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):
|
class BIM_UL_zones(UIList):
|
||||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||||
if item:
|
if item:
|
||||||
|
|||||||
Reference in New Issue
Block a user