diff --git a/src/bonsai/bonsai/bim/__init__.py b/src/bonsai/bonsai/bim/__init__.py index 2b6b8f59ba..f60c9df09f 100644 --- a/src/bonsai/bonsai/bim/__init__.py +++ b/src/bonsai/bonsai/bim/__init__.py @@ -233,7 +233,7 @@ def on_register(scene): is_registering = False def register_panel_visibility_properties(): - for panel_name in operator.TAB_PANELS.values(): + for panel_name in ui.TAB_PANELS.values(): for panel in panel_name: prop_name = f"show_{panel.lower()}" setattr( @@ -245,14 +245,28 @@ def register_panel_visibility_properties(): default=True, # Panels are visible by default ), ) + prop_name = f"bookmark_{panel.lower()}" + setattr( + bpy.types.Scene, + prop_name, + bpy.props.BoolProperty( + name=f"Bookmark {panel}", + description=f"Move to Bookmark or not {panel} panel", + default=False, # Panels are visible by default + ), + ) def unregister_panel_visibility_properties(): - for panel_name in operator.TAB_PANELS.values(): + for panel_name in ui.TAB_PANELS.values(): for panel in panel_name: prop_name = f"show_{panel.lower()}" if hasattr(bpy.types.Scene, prop_name): delattr(bpy.types.Scene, prop_name) + prop_name = f"bookmark_{panel.lower()}" + if hasattr(bpy.types.Scene, prop_name): + delattr(bpy.types.Scene, prop_name) + # Classes that need to be registered after modules (due to cross-module dependencies) late_classes = ( diff --git a/src/bonsai/bonsai/bim/operator.py b/src/bonsai/bonsai/bim/operator.py index 6dbe1d6107..f507120831 100644 --- a/src/bonsai/bonsai/bim/operator.py +++ b/src/bonsai/bonsai/bim/operator.py @@ -33,6 +33,7 @@ import bonsai.bim import bonsai.tool as tool import bonsai.bim.handler from enum import Enum +from bonsai.bim.ui import TAB_PANELS from bpy_extras.io_utils import ImportHelper from bonsai.bim import import_ifc from bonsai.bim.prop import StrProperty @@ -1606,63 +1607,6 @@ class BIM_OT_attribute_remove_subitem(bpy.types.Operator): return {"FINISHED"} -TAB_PANELS = { - "PROJECT": [ -# "BIM_PT_tab_new_project_wizard", - "BIM_PT_tab_project_info", - "BIM_PT_tab_spatial", - "BIM_PT_tab_project_setup", - "BIM_PT_tab_geometry", - "BIM_PT_tab_stakeholders", - "BIM_PT_tab_grouping_and_filtering", - ], - "OBJECT": [ - "BIM_PT_tab_object_metadata", - "BIM_PT_tab_misc", - ], - "GEOMETRY": [ - "BIM_PT_tab_placement", - "BIM_PT_tab_representations", - "BIM_PT_tab_geometric_relationships", - "BIM_PT_tab_parametric_geometry", - "BIM_PT_tab_object_materials", - "BIM_PT_tab_materials", - "BIM_PT_tab_styles", - "BIM_PT_tab_profiles", - ], - "DRAWINGS": [ - "BIM_PT_tab_sheets", - "BIM_PT_tab_drawings", - "BIM_PT_tab_schedules", - "BIM_PT_tab_references", - ], - "SERVICES": [ - "BIM_PT_tab_services", - "BIM_PT_tab_zones", - "BIM_PT_tab_solar_analysis", - "BIM_PT_tab_lighting", - ], - "STRUCTURE": [ - "BIM_PT_tab_structural", - ], - "SCHEDULING": [ - "BIM_PT_tab_status", - "BIM_PT_tab_qto", - "BIM_PT_tab_resources", - "BIM_PT_tab_cost", - "BIM_PT_tab_sequence", - ], - "FM": [ - "BIM_PT_tab_handover", - "BIM_PT_tab_operations", - ], - "QUALITY": [ - "BIM_PT_tab_quality_control", - "BIM_PT_tab_clash_detection", - "BIM_PT_tab_collaboration", - "BIM_PT_tab_sandbox", - ], -} class BIM_UL_tab_panels(bpy.types.UIList): """UIList for Tab Panels""" @@ -1686,7 +1630,6 @@ class BIM_UL_tab_panels(bpy.types.UIList): icon="SOLO_ON" if item.get("bookmarked", False) else "SOLO_OFF", ).action = f"BOOKMARK_{item.name}" - class BIM_OT_toggle_panel_visibility(bpy.types.Operator): """Toggle Panel Visibility""" bl_idname = "bim.toggle_panel_visibility" @@ -1734,10 +1677,40 @@ class BIM_OT_bookmark_panel(bpy.types.Operator): # Extract the panel name from the action panel_name = self.action.replace("BOOKMARK_", "") - # Logic to bookmark the panel (placeholder) - print(f"Bookmarked panel: {panel_name}") + # Find the corresponding panel in the tab_panels collection + for item in context.scene.tab_panels: + if item.name == panel_name: + # Toggle the bookmarked state + item["bookmarked"] = not item.get("bookmarked", False) - self.report({"INFO"}, f"Bookmarked {panel_name}.") + # Update the corresponding BoolProperty on the Scene + prop_name = f"bookmark_{panel_name.lower()}" + if hasattr(context.scene, prop_name): + setattr(context.scene, prop_name, item["bookmarked"]) + print(f"Toggled bookmark for panel: {panel_name} to {'bookmarked' if item['bookmarked'] else 'Not bookmarked'}") + else: + print(f"Property '{prop_name}' not found on Scene.") + + # Add or remove the panel from the TAB_PANELS["BOOKMARK"] list + if item["bookmarked"]: + if panel_name not in TAB_PANELS["BOOKMARK"]: + TAB_PANELS["BOOKMARK"].append(panel_name) + print(f"Added {panel_name} to BOOKMARK tab.") + else: + if panel_name in TAB_PANELS["BOOKMARK"]: + TAB_PANELS["BOOKMARK"].remove(panel_name) + print(f"Removed {panel_name} from BOOKMARK tab.") + # Remove the panel from the tab_panels collection if in BOOKMARK tab + if context.scene.active_tab_name == "BOOKMARK": + context.scene.tab_panels.remove(context.scene.tab_panels.find(panel_name)) + break + + # Redraw the UI to reflect the changes + for area in bpy.context.window.screen.areas: + if area.type == "PROPERTIES": + area.tag_redraw() + + self.report({"INFO"}, f"Toggled bookmark for {panel_name}.") return {"FINISHED"} @@ -1758,7 +1731,15 @@ class BIM_OT_manage_tab_panels(bpy.types.Operator): for panel_name in TAB_PANELS.get(self.tab_name, []): item = context.scene.tab_panels.add() item.name = panel_name - item["visible"] = True # Initialize the visibility state as visible + + # Use the registered properties to set visibility and bookmark states + show_prop_name = f"show_{panel_name.lower()}" + bookmark_prop_name = f"bookmark_{panel_name.lower()}" + + # Retrieve the visibility and bookmark states from the Scene properties + item["visible"] = getattr(context.scene, show_prop_name, True) + item["bookmarked"] = getattr(context.scene, bookmark_prop_name, False) + print(f"Tab Panels for {self.tab_name}: {[item.name for item in context.scene.tab_panels]}") return context.window_manager.invoke_props_dialog(self, width=400) @@ -1771,9 +1752,15 @@ class BIM_OT_manage_tab_panels(bpy.types.Operator): row = layout.row() row.template_list("BIM_UL_tab_panels", "", context.scene, "tab_panels", context.scene, "active_tab_panel_index") - - def execute(self, context): - # Logic to handle the confirmation of the dialog + # Save the visibility and bookmark states back to the Scene properties + for item in context.scene.tab_panels: + show_prop_name = f"show_{item.name.lower()}" + bookmark_prop_name = f"bookmark_{item.name.lower()}" + + # Update the Scene properties with the current states + setattr(context.scene, show_prop_name, item["visible"]) + setattr(context.scene, bookmark_prop_name, item["bookmarked"]) + self.report({"INFO"}, f"Panels for {self.tab_name} managed successfully.") return {"FINISHED"} diff --git a/src/bonsai/bonsai/bim/prop.py b/src/bonsai/bonsai/bim/prop.py index 4663f7ca6a..b10aacdc97 100644 --- a/src/bonsai/bonsai/bim/prop.py +++ b/src/bonsai/bonsai/bim/prop.py @@ -493,7 +493,7 @@ def get_tab( ("SCHEDULING", "Costing and Scheduling", "", "NLA", 6), ("FM", "Facility Management", "", "PACKAGE", 7), ("QUALITY", "Quality and Coordination", "", "COMMUNITY", 8), - ("BOOKMARKS", "Bookmarks", "", "SOLO_ON", 9), + ("BOOKMARK", "Bookmark", "", "SOLO_ON", 9), None, ("BLENDER", "Blender Properties", "", "BLENDER", 10), ] diff --git a/src/bonsai/bonsai/bim/ui.py b/src/bonsai/bonsai/bim/ui.py index 55308ed421..bb5056844f 100644 --- a/src/bonsai/bonsai/bim/ui.py +++ b/src/bonsai/bonsai/bim/ui.py @@ -62,6 +62,66 @@ if TYPE_CHECKING: from bonsai.bim.module.project.prop import BIMProjectProperties +TAB_PANELS = { + "PROJECT": [ +# "BIM_PT_tab_new_project_wizard", + "BIM_PT_tab_project_info", + "BIM_PT_tab_spatial", + "BIM_PT_tab_project_setup", + "BIM_PT_tab_geometry", + "BIM_PT_tab_stakeholders", + "BIM_PT_tab_grouping_and_filtering", + ], + "OBJECT": [ + "BIM_PT_tab_object_metadata", + "BIM_PT_tab_misc", + ], + "GEOMETRY": [ + "BIM_PT_tab_placement", + "BIM_PT_tab_representations", + "BIM_PT_tab_geometric_relationships", + "BIM_PT_tab_parametric_geometry", + "BIM_PT_tab_object_materials", + "BIM_PT_tab_materials", + "BIM_PT_tab_styles", + "BIM_PT_tab_profiles", + ], + "DRAWINGS": [ + "BIM_PT_tab_sheets", + "BIM_PT_tab_drawings", + "BIM_PT_tab_schedules", + "BIM_PT_tab_references", + ], + "SERVICES": [ + "BIM_PT_tab_services", + "BIM_PT_tab_zones", + "BIM_PT_tab_solar_analysis", + "BIM_PT_tab_lighting", + ], + "STRUCTURE": [ + "BIM_PT_tab_structural", + ], + "SCHEDULING": [ + "BIM_PT_tab_status", + "BIM_PT_tab_qto", + "BIM_PT_tab_resources", + "BIM_PT_tab_cost", + "BIM_PT_tab_sequence", + ], + "FM": [ + "BIM_PT_tab_handover", + "BIM_PT_tab_operations", + ], + "QUALITY": [ + "BIM_PT_tab_quality_control", + "BIM_PT_tab_clash_detection", + "BIM_PT_tab_collaboration", + "BIM_PT_tab_sandbox", + ], + "BOOKMARK": [], +} + + class IFCFileSelector: layout: bpy.types.UILayout @@ -964,7 +1024,7 @@ class BIM_PT_tabs(Panel): self.draw_tab_entry(row, "NLA", "SCHEDULING", is_ifc_project, aprops.tab == "SCHEDULING") self.draw_tab_entry(row, "PACKAGE", "FM", True, aprops.tab == "FM") self.draw_tab_entry(row, "COMMUNITY", "QUALITY", True, aprops.tab == "QUALITY") - self.draw_tab_entry(row, "SOLO_ON", "BOOKMARKS", True, aprops.tab == "BOOKMARKS") # New BOOKMARKS tab + self.draw_tab_entry(row, "SOLO_ON", "BOOKMARK", True, aprops.tab == "BOOKMARK") # New BOOKMARK tab row.operator("bim.switch_tab", text="", emboss=False, icon="UV_SYNC_SELECT") # Yes, that's right. @@ -981,7 +1041,7 @@ class BIM_PT_tabs(Panel): "SCHEDULING", "FM", "QUALITY", - "BOOKMARKS", # Include BOOKMARKS in the list + "BOOKMARK", "SWITCH", ]: # Draw a little underscore below the active tab icon. @@ -993,7 +1053,7 @@ class BIM_PT_tabs(Panel): row = self.layout.row(align=True) row.prop(aprops, "tab", text="") - # Add gear icons for all tabs except BOOKMARKS and SWITCH_TAB + # Add gear icons for all tabs except SWITCH_TAB for tab in [ "PROJECT", "OBJECT", @@ -1004,6 +1064,7 @@ class BIM_PT_tabs(Panel): "SCHEDULING", "FM", "QUALITY", + "BOOKMARK", ]: if aprops.tab == tab: # row = self.layout.row(align=True) @@ -1114,11 +1175,13 @@ class BIM_PT_tab_project_info(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_project_info", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - - # Existing conditions - if not tool.Blender.is_tab(context, "PROJECT"): + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + if not tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")): return False bim_props = tool.Blender.get_bim_props() pprops = tool.Project.get_project_props() @@ -1142,9 +1205,13 @@ class BIM_PT_tab_spatial(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_spatial", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - return tool.Blender.is_tab(context, "PROJECT") and tool.Ifc.get() + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) and tool.Ifc.get() def draw(self, context): pass @@ -1159,9 +1226,13 @@ class BIM_PT_tab_project_setup(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_project_setup", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - return tool.Blender.is_tab(context, "PROJECT") + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) def draw(self, context): pass @@ -1177,15 +1248,20 @@ class BIM_PT_tab_stakeholders(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_stakeholders", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - return tool.Blender.is_tab(context, "PROJECT") and tool.Ifc.get() + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) and tool.Ifc.get() def draw(self, context): pass class BIM_PT_tab_collaboration(Panel): + bl_idname = "BIM_PT_tab_collaboration" bl_label = "Collaboration" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1193,9 +1269,13 @@ class BIM_PT_tab_collaboration(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_collaboration", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - return tool.Blender.is_tab(context, "QUALITY") + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) def draw(self, context): pass @@ -1211,9 +1291,13 @@ class BIM_PT_tab_grouping_and_filtering(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_grouping_and_filtering", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - return tool.Blender.is_tab(context, "PROJECT") and tool.Ifc.get() + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) and tool.Ifc.get() def draw(self, context): pass @@ -1236,15 +1320,20 @@ class BIM_PT_tab_geometry(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_geometry", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - return tool.Blender.is_tab(context, "PROJECT") and tool.Ifc.get() + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) and tool.Ifc.get() def draw(self, context): pass class BIM_PT_tab_status(Panel): + bl_idname = "BIM_PT_tab_status" bl_label = "Status" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1252,15 +1341,20 @@ class BIM_PT_tab_status(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_status", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - return tool.Blender.is_tab(context, "SCHEDULING") and tool.Ifc.get() + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) and tool.Ifc.get() def draw(self, context): pass class BIM_PT_tab_qto(Panel): + bl_idname = "BIM_PT_tab_qto" bl_label = "Quantity Take-off" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1268,15 +1362,20 @@ class BIM_PT_tab_qto(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_qto", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - return tool.Blender.is_tab(context, "SCHEDULING") and tool.Ifc.get() + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) and tool.Ifc.get() def draw(self, context): pass class BIM_PT_tab_resources(Panel): + bl_idname = "BIM_PT_tab_resources" bl_label = "Resources" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1284,15 +1383,20 @@ class BIM_PT_tab_resources(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_resources", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - return tool.Blender.is_tab(context, "SCHEDULING") and tool.Ifc.get() + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) and tool.Ifc.get() def draw(self, context): pass class BIM_PT_tab_cost(Panel): + bl_idname = "BIM_PT_tab_cost" bl_label = "Cost" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1300,15 +1404,20 @@ class BIM_PT_tab_cost(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_cost", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - return tool.Blender.is_tab(context, "SCHEDULING") and tool.Ifc.get() + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) and tool.Ifc.get() def draw(self, context): pass class BIM_PT_tab_sequence(Panel): + bl_idname = "BIM_PT_tab_sequence" bl_label = "Construction Scheduling" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1316,15 +1425,20 @@ class BIM_PT_tab_sequence(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_sequence", True): - return False - return tool.Blender.is_tab(context, "SCHEDULING") and tool.Ifc.get() + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): + return False + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) and tool.Ifc.get() def draw(self, context): pass class BIM_PT_tab_structural(Panel): + bl_idname = "BIM_PT_tab_structural" bl_label = "Structural" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1332,15 +1446,20 @@ class BIM_PT_tab_structural(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_structural", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - return tool.Blender.is_tab(context, "STRUCTURE") and tool.Ifc.get() + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) and tool.Ifc.get() def draw(self, context): pass class BIM_PT_tab_services(Panel): + bl_idname = "BIM_PT_tab_services" bl_label = "Services" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1348,15 +1467,20 @@ class BIM_PT_tab_services(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_services", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - return tool.Blender.is_tab(context, "SERVICES") and tool.Ifc.get() + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) and tool.Ifc.get() def draw(self, context): pass class BIM_PT_tab_lighting(Panel): + bl_idname = "BIM_PT_tab_lighting" bl_label = "Lighting" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1364,15 +1488,20 @@ class BIM_PT_tab_lighting(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_lighting", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - return tool.Blender.is_tab(context, "SERVICES") and tool.Ifc.get() + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) and tool.Ifc.get() def draw(self, context): pass class BIM_PT_tab_zones(Panel): + bl_idname = "BIM_PT_tab_zones" bl_label = "Zones" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1380,15 +1509,20 @@ class BIM_PT_tab_zones(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_zones", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - return tool.Blender.is_tab(context, "SERVICES") and tool.Ifc.get() + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) and tool.Ifc.get() def draw(self, context): pass class BIM_PT_tab_solar_analysis(Panel): + bl_idname = "BIM_PT_tab_solar_analysis" bl_label = "Solar Analysis" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1396,15 +1530,20 @@ class BIM_PT_tab_solar_analysis(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_solar_analysis", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - return tool.Blender.is_tab(context, "SERVICES") and tool.Ifc.get() + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) and tool.Ifc.get() def draw(self, context): pass class BIM_PT_tab_quality_control(Panel): + bl_idname = "BIM_PT_tab_quality_control" bl_label = "Quality Control" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1412,15 +1551,20 @@ class BIM_PT_tab_quality_control(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_quality_control", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - return tool.Blender.is_tab(context, "QUALITY") + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) def draw(self, context): pass class BIM_PT_tab_clash_detection(Panel): + bl_idname = "BIM_PT_tab_clash_detection" bl_label = "Clash Detection" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1428,15 +1572,20 @@ class BIM_PT_tab_clash_detection(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_clash_detection", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - return tool.Blender.is_tab(context, "QUALITY") + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) def draw(self, context): pass class BIM_PT_tab_sandbox(Panel): + bl_idname = "BIM_PT_tab_sandbox" bl_label = "Sandbox" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1445,9 +1594,13 @@ class BIM_PT_tab_sandbox(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_sandbox", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - return tool.Blender.is_tab(context, "QUALITY") + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) def draw(self, context): row = self.layout.row() @@ -1456,6 +1609,7 @@ class BIM_PT_tab_sandbox(Panel): # Object panel groups class BIM_PT_tab_object_metadata(Panel): + bl_idname = "BIM_PT_tab_object_metadata" bl_label = "Object" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1464,11 +1618,16 @@ class BIM_PT_tab_object_metadata(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_object_metadata", True): - return False + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): + return False + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + props = tool.Project.get_project_props() return ( - tool.Blender.is_tab(context, "OBJECT") + tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) and tool.Ifc.get() and (obj := context.active_object) # Hide links empty handles. @@ -1484,6 +1643,7 @@ class BIM_PT_tab_object_metadata(Panel): class BIM_PT_tab_placement(Panel): + bl_idname = "BIM_PT_tab_placement" bl_label = "Placement" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1492,10 +1652,15 @@ class BIM_PT_tab_placement(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_placement", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return ( - tool.Blender.is_tab(context, "GEOMETRY") + tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) and tool.Ifc.get() and (obj := context.active_object) and tool.Ifc.get_entity(obj) @@ -1506,6 +1671,7 @@ class BIM_PT_tab_placement(Panel): class BIM_PT_tab_representations(Panel): + bl_idname = "BIM_PT_tab_representations" bl_label = "Representations" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1514,10 +1680,14 @@ class BIM_PT_tab_representations(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_representations", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") return ( - tool.Blender.is_tab(context, "GEOMETRY") + tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) and tool.Ifc.get() and tool.Geometry.get_active_or_representation_obj() ) @@ -1527,6 +1697,7 @@ class BIM_PT_tab_representations(Panel): class BIM_PT_tab_geometric_relationships(Panel): + bl_idname = "BIM_PT_tab_geometric_relationships" bl_label = "Geometric Relationships" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1536,15 +1707,20 @@ class BIM_PT_tab_geometric_relationships(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_geometric_relationships", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - return tool.Blender.is_tab(context, "GEOMETRY") and tool.Ifc.get() + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) and tool.Ifc.get() def draw(self, context): pass class BIM_PT_tab_parametric_geometry(Panel): + bl_idname = "BIM_PT_tab_parametric_geometry" bl_label = "Parametric Geometry" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1554,10 +1730,14 @@ class BIM_PT_tab_parametric_geometry(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_parametric_geometry", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") return ( - tool.Blender.is_tab(context, "GEOMETRY") + tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) and tool.Ifc.get() and (obj := context.active_object) and tool.Ifc.get_entity(obj) @@ -1568,6 +1748,7 @@ class BIM_PT_tab_parametric_geometry(Panel): class BIM_PT_tab_object_materials(Panel): + bl_idname = "BIM_PT_tab_object_materials" bl_label = "Object Materials" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1576,10 +1757,14 @@ class BIM_PT_tab_object_materials(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_object_materials", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") return ( - tool.Blender.is_tab(context, "GEOMETRY") + tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) and tool.Ifc.get() and (obj := context.active_object) and tool.Ifc.get_entity(obj) @@ -1590,6 +1775,7 @@ class BIM_PT_tab_object_materials(Panel): class BIM_PT_tab_materials(Panel): + bl_idname = "BIM_PT_tab_materials" bl_label = "Materials" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1598,15 +1784,20 @@ class BIM_PT_tab_materials(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_materials", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - return tool.Blender.is_tab(context, "GEOMETRY") and tool.Ifc.get() + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) and tool.Ifc.get() def draw(self, context): pass class BIM_PT_tab_styles(Panel): + bl_idname = "BIM_PT_tab_styles" bl_label = "Styles" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1615,15 +1806,20 @@ class BIM_PT_tab_styles(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_styles", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - return tool.Blender.is_tab(context, "GEOMETRY") and tool.Ifc.get() + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) and tool.Ifc.get() def draw(self, context): pass class BIM_PT_tab_profiles(Panel): + bl_idname = "BIM_PT_tab_profiles" bl_label = "Profiles" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1632,15 +1828,20 @@ class BIM_PT_tab_profiles(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_profiles", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - return tool.Blender.is_tab(context, "GEOMETRY") and tool.Ifc.get() + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) and tool.Ifc.get() def draw(self, context): pass class BIM_PT_tab_sheets(Panel): + bl_idname = "BIM_PT_tab_sheets" bl_label = "Sheets" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1649,15 +1850,20 @@ class BIM_PT_tab_sheets(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_sheets", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - return tool.Blender.is_tab(context, "DRAWINGS") and tool.Ifc.get() + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) and tool.Ifc.get() def draw(self, context): pass class BIM_PT_tab_drawings(Panel): + bl_idname = "BIM_PT_tab_drawings" bl_label = "Drawings" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1666,15 +1872,20 @@ class BIM_PT_tab_drawings(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_drawings", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - return tool.Blender.is_tab(context, "DRAWINGS") and tool.Ifc.get() + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) and tool.Ifc.get() def draw(self, context): pass class BIM_PT_tab_schedules(Panel): + bl_idname = "BIM_PT_tab_schedules" bl_label = "Schedules" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1683,15 +1894,20 @@ class BIM_PT_tab_schedules(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_schedules", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - return tool.Blender.is_tab(context, "DRAWINGS") and tool.Ifc.get() + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) and tool.Ifc.get() def draw(self, context): pass class BIM_PT_tab_references(Panel): + bl_idname = "BIM_PT_tab_references" bl_label = "References" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1700,15 +1916,20 @@ class BIM_PT_tab_references(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_references", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - return tool.Blender.is_tab(context, "DRAWINGS") and tool.Ifc.get() + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) and tool.Ifc.get() def draw(self, context): pass class BIM_PT_tab_misc(Panel): + bl_idname = "BIM_PT_tab_misc" bl_label = "Misc." bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1718,15 +1939,20 @@ class BIM_PT_tab_misc(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_misc", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - return tool.Blender.is_tab(context, "OBJECT") and tool.Ifc.get() + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) and tool.Ifc.get() def draw(self, context): pass class BIM_PT_tab_handover(Panel): + bl_idname = "BIM_PT_tab_handover" bl_label = "Commissioning and Handover" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1735,15 +1961,20 @@ class BIM_PT_tab_handover(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_handover", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - return tool.Blender.is_tab(context, "FM") + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) def draw(self, context): pass class BIM_PT_tab_operations(Panel): + bl_idname = "BIM_PT_tab_operations" bl_label = "Operations and Maintenance" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" @@ -1752,9 +1983,13 @@ class BIM_PT_tab_operations(Panel): @classmethod def poll(cls, context): - if not getattr(context.scene, "show_bim_pt_tab_operations", True): + prop_bookmark = f"bookmark_{cls.bl_idname.lower()}" + prop_visible = f"show_{cls.bl_idname.lower()}" + if not getattr(context.scene, prop_visible, True): return False - return tool.Blender.is_tab(context, "FM") + if getattr(context.scene, prop_bookmark, False): + return tool.Blender.is_tab(context, "BOOKMARK") + return tool.Blender.is_tab(context, next((tab for tab, panels in TAB_PANELS.items() if cls.bl_idname in panels), "BOOKMARK")) def draw(self, context): pass