mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-06 07:51:47 +00:00
added reset option
This commit is contained in:
@@ -137,6 +137,7 @@ classes = [
|
||||
operator.BIM_OT_toggle_tab_visibility,
|
||||
operator.BIM_OT_load_json_layout,
|
||||
operator.BIM_OT_save_json_layout,
|
||||
operator.BIM_OT_reset_ui_layout,
|
||||
prop.ObjProperty,
|
||||
prop.MultipleFileSelect,
|
||||
prop.Attribute,
|
||||
|
||||
@@ -1781,6 +1781,17 @@ class BIM_OT_manage_tab_visibility(bpy.types.Operator):
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
row = layout.row()
|
||||
row = self.layout.row(align=True)
|
||||
row.alignment = 'RIGHT'
|
||||
|
||||
row.operator("bim.reset_ui_layout", icon="FILE_REFRESH", text="")
|
||||
row.operator("bim.load_json_layout", icon="IMPORT", text="")
|
||||
row.operator("bim.save_json_layout", icon="EXPORT", text="")
|
||||
row = layout.row()
|
||||
row = self.layout.row(align=True)
|
||||
row.alignment = 'CENTER'
|
||||
|
||||
for tab_name, is_visible in TAB_VISIBILITY.items():
|
||||
row = layout.row()
|
||||
row.label(text=tab_name)
|
||||
@@ -1871,3 +1882,44 @@ class BIM_OT_save_json_layout(bpy.types.Operator):
|
||||
def invoke(self, context, event):
|
||||
context.window_manager.fileselect_add(self)
|
||||
return {"RUNNING_MODAL"}
|
||||
|
||||
class BIM_OT_reset_ui_layout(bpy.types.Operator):
|
||||
"""Reset UI Layout to Default"""
|
||||
bl_idname = "bim.reset_ui_layout"
|
||||
bl_label = "Reset UI Layout"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
def execute(self, context):
|
||||
global TAB_VISIBILITY, TAB_PANELS
|
||||
|
||||
# Reset TAB_VISIBILITY to its default state
|
||||
for tab_name in TAB_VISIBILITY.keys():
|
||||
TAB_VISIBILITY[tab_name] = True
|
||||
|
||||
# Reset only the BOOKMARK entry in TAB_PANELS to an empty dictionary
|
||||
TAB_PANELS["BOOKMARK"] = [{}]
|
||||
|
||||
# Reset visibility and bookmark states in Scene properties
|
||||
for tab_name, panels in TAB_PANELS.items():
|
||||
for panel in panels:
|
||||
panel_name = panel.get("bl_idname", "")
|
||||
if not panel_name:
|
||||
continue
|
||||
|
||||
# Reset visibility state
|
||||
show_prop_name = f"show_{panel_name.lower()}"
|
||||
if hasattr(context.scene, show_prop_name):
|
||||
setattr(context.scene, show_prop_name, True)
|
||||
|
||||
# Reset bookmark state
|
||||
bookmark_prop_name = f"bookmark_{panel_name.lower()}"
|
||||
if hasattr(context.scene, bookmark_prop_name):
|
||||
setattr(context.scene, bookmark_prop_name, False)
|
||||
|
||||
# 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"}, "UI layout reset to default.")
|
||||
return {"FINISHED"}
|
||||
+32
-26
@@ -1040,53 +1040,59 @@ class BIM_PT_tabs(Panel):
|
||||
aprops = tool.Blender.get_area_props(context)
|
||||
ifc_icon = f"{UIData.data['tabs_icon_color_mode']}_ifc"
|
||||
|
||||
row = self.layout.row(align=True)
|
||||
row.alignment = "RIGHT"
|
||||
row.operator("bim.load_json_layout", icon="IMPORT", text="")
|
||||
row.operator("bim.save_json_layout", icon="EXPORT", text="")
|
||||
row.operator("bim.manage_tab_visibility", icon="PREFERENCES", text="")
|
||||
|
||||
row = self.layout.row()
|
||||
row.alignment = "CENTER"
|
||||
split = self.layout.split(factor=0.9)
|
||||
col_left = split.column(align=True)
|
||||
row_left = col_left.row(align=True)
|
||||
row_left.alignment = "CENTER"
|
||||
if TAB_VISIBILITY["PROJECT"]:
|
||||
row.operator(
|
||||
row_left.operator(
|
||||
"bim.set_tab",
|
||||
text="",
|
||||
emboss=aprops.tab == "PROJECT",
|
||||
icon_value=bonsai.bim.icons[ifc_icon].icon_id,
|
||||
).tab = "PROJECT"
|
||||
if TAB_VISIBILITY["OBJECT"]:
|
||||
self.draw_tab_entry(row, "FILE_3D", "OBJECT", is_ifc_project, aprops.tab == "OBJECT")
|
||||
self.draw_tab_entry(row_left, "FILE_3D", "OBJECT", is_ifc_project, aprops.tab == "OBJECT")
|
||||
if TAB_VISIBILITY["GEOMETRY"]:
|
||||
self.draw_tab_entry(row, "MATERIAL", "GEOMETRY", is_ifc_project, aprops.tab == "GEOMETRY")
|
||||
self.draw_tab_entry(row_left, "MATERIAL", "GEOMETRY", is_ifc_project, aprops.tab == "GEOMETRY")
|
||||
if TAB_VISIBILITY["DRAWINGS"]:
|
||||
self.draw_tab_entry(row, "DOCUMENTS", "DRAWINGS", is_ifc_project, aprops.tab == "DRAWINGS")
|
||||
self.draw_tab_entry(row_left, "DOCUMENTS", "DRAWINGS", is_ifc_project, aprops.tab == "DRAWINGS")
|
||||
if TAB_VISIBILITY["SERVICES"]:
|
||||
self.draw_tab_entry(row, "NETWORK_DRIVE", "SERVICES", is_ifc_project, aprops.tab == "SERVICES")
|
||||
self.draw_tab_entry(row_left, "NETWORK_DRIVE", "SERVICES", is_ifc_project, aprops.tab == "SERVICES")
|
||||
if TAB_VISIBILITY["STRUCTURE"]:
|
||||
self.draw_tab_entry(row, "EDITMODE_HLT", "STRUCTURE", is_ifc_project, aprops.tab == "STRUCTURE")
|
||||
self.draw_tab_entry(row_left, "EDITMODE_HLT", "STRUCTURE", is_ifc_project, aprops.tab == "STRUCTURE")
|
||||
if TAB_VISIBILITY["SCHEDULING"]:
|
||||
self.draw_tab_entry(row, "NLA", "SCHEDULING", is_ifc_project, aprops.tab == "SCHEDULING")
|
||||
self.draw_tab_entry(row_left, "NLA", "SCHEDULING", is_ifc_project, aprops.tab == "SCHEDULING")
|
||||
if TAB_VISIBILITY["FM"]:
|
||||
self.draw_tab_entry(row, "PACKAGE", "FM", True, aprops.tab == "FM")
|
||||
self.draw_tab_entry(row_left, "PACKAGE", "FM", True, aprops.tab == "FM")
|
||||
if TAB_VISIBILITY["QUALITY"]:
|
||||
self.draw_tab_entry(row, "COMMUNITY", "QUALITY", True, aprops.tab == "QUALITY")
|
||||
self.draw_tab_entry(row_left, "COMMUNITY", "QUALITY", True, aprops.tab == "QUALITY")
|
||||
if TAB_VISIBILITY["BOOKMARK"]:
|
||||
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")
|
||||
self.draw_tab_entry(row_left, "SOLO_ON", "BOOKMARK", True, aprops.tab == "BOOKMARK") # New BOOKMARK tab
|
||||
row_left.operator("bim.switch_tab", text="", emboss=False, icon="UV_SYNC_SELECT")
|
||||
|
||||
# Yes, that's right.
|
||||
row = self.layout.row()
|
||||
row.alignment = "CENTER"
|
||||
row.scale_y = 0.2
|
||||
row_left = col_left.row(align=True)
|
||||
# Yes, that's right.
|
||||
row_left.alignment = "CENTER"
|
||||
row_left.scale_y = 0.2
|
||||
for tab in TAB_VISIBILITY.keys():
|
||||
# Draw a little underscore below the active tab icon.
|
||||
if TAB_VISIBILITY[tab]:
|
||||
if aprops.tab == tab:
|
||||
row.prop(aprops, "active_tab", text="", icon="BLANK1")
|
||||
row_left.prop(aprops, "active_tab", text="", icon="BLANK1")
|
||||
else:
|
||||
row.prop(aprops, "inactive_tab", text="", icon="BLANK1", emboss=False)
|
||||
row.prop(aprops, "inactive_tab", text="", icon="BLANK1", emboss=False) #space for Switch
|
||||
row_left.prop(aprops, "inactive_tab", text="", icon="BLANK1", emboss=False)
|
||||
row_left.prop(aprops, "inactive_tab", text="", icon="BLANK1", emboss=False) #space for Switch
|
||||
|
||||
|
||||
col_right = split.column(align=True)
|
||||
row_right = col_right.row(align=True)
|
||||
row_right.alignment = 'RIGHT'
|
||||
|
||||
row_right.operator("bim.manage_tab_visibility", icon="PREFERENCES", text="")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user