Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/bonsai/bonsai/bim/module/geometry/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,30 @@
from bonsai.bim.module.layer.data import LayersData


class UIData:
data = {}
is_loaded = False

@classmethod
def load(cls):
cls.data = {"menu_icon_color_mode": cls.icon_color_mode("user_interface.wcol_menu.text")}
cls.is_loaded = True

@classmethod
def icon_color_mode(cls, color_path):
return tool.Blender.detect_icon_color_mode(color_path)


def mode_menu(self, context):
if not tool.Ifc.get():
return
if not UIData.is_loaded:
UIData.load()
ifc_icon = f"{UIData.data['menu_icon_color_mode']}_ifc"
row = self.layout.row(align=True)
if context.scene.BIMGeometryProperties.mode == "EDIT":
row.operator("bim.override_mode_set_object", icon="CANCEL", text="Discard Changes").should_save = False
row.prop(context.scene.BIMGeometryProperties, "mode", text="", icon_value=bonsai.bim.icons["IFC"].icon_id)
row.prop(context.scene.BIMGeometryProperties, "mode", text="", icon_value=bonsai.bim.icons[ifc_icon].icon_id)


def object_menu(self, context):
Expand Down
Binary file not shown.
23 changes: 22 additions & 1 deletion src/bonsai/bonsai/bim/module/project/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,24 @@ def file_import_menu(self, context):
op.should_start_fresh_session = False


def refresh():
UIData.is_loaded = False


class UIData:
data = {}
is_loaded = False

@classmethod
def load(cls):
cls.data = {"menu_item_icon_color_mode": cls.icon_color_mode("user_interface.wcol_menu_item.text")}
cls.is_loaded = True

@classmethod
def icon_color_mode(cls, color_path):
return tool.Blender.detect_icon_color_mode(color_path)


class BIM_MT_project(Menu):
bl_idname = "BIM_MT_project"
bl_label = "New IFC Project"
Expand All @@ -54,6 +72,9 @@ class BIM_MT_recent_projects(Menu):
bl_label = "Open Recent IFC Project"

def draw(self, context):
if not UIData.is_loaded:
UIData.load()
ifc_icon = f"{UIData.data['menu_item_icon_color_mode']}_ifc"
layout = self.layout
paths = tool.Project.get_recent_ifc_projects()
if not paths:
Expand All @@ -62,7 +83,7 @@ def draw(self, context):

for path in paths:
row = layout.row()
op = row.operator("bim.load_project", text=path.name, icon_value=bonsai.bim.icons["IFC"].icon_id)
op = row.operator("bim.load_project", text=path.name, icon_value=bonsai.bim.icons[ifc_icon].icon_id)
op.filepath = str(path)
op.should_start_fresh_session = True
op.use_detailed_tooltip = True
Expand Down
11 changes: 8 additions & 3 deletions src/bonsai/bonsai/bim/prop.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,16 @@ def set_value(self, value: Union[Any, str, float, bool, int]) -> None:
def get_tab(
self: "Union[BIMAreaProperties, BIMTabProperties]", context: bpy.types.Context
) -> list[tuple[str, str, str, str, int]]:
# Items are not very dynamic, but can't make them completely static
# because icons are not yet available during prop registration.

UIData = bonsai.bim.ui.UIData
if not UIData.is_loaded:
UIData.load()

icon_key = f"{UIData.data['menu_icon_color_mode']}_ifc"

if not hasattr(get_tab, "enum_items"):
get_tab.enum_items = [
("PROJECT", "Project Overview", "", bonsai.bim.icons["IFC"].icon_id, 0),
("PROJECT", "Project Overview", "", bonsai.bim.icons[icon_key].icon_id, 0),
("OBJECT", "Object Information", "", "FILE_3D", 1),
("GEOMETRY", "Geometry and Materials", "", "MATERIAL", 2),
("DRAWINGS", "Drawings and Documents", "", "DOCUMENTS", 3),
Expand Down
12 changes: 8 additions & 4 deletions src/bonsai/bonsai/bim/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ def draw(self, context):
UIData.load()
is_ifc_project = bool(tool.Ifc.get())
aprops = tool.Blender.get_area_props(context)
ifc_icon = f"{UIData.data['icon_color_mode']}_ifc"
ifc_icon = f"{UIData.data['tabs_icon_color_mode']}_ifc"

row = self.layout.row()
row.alignment = "CENTER"
Expand Down Expand Up @@ -1118,16 +1118,20 @@ class UIData:

@classmethod
def load(cls):
cls.data = {"version": cls.version(), "icon_color_mode": cls.icon_color_mode()}
cls.data = {
"version": cls.version(),
"tabs_icon_color_mode": cls.icon_color_mode("user_interface.wcol_regular.text"),
"menu_icon_color_mode": cls.icon_color_mode("user_interface.wcol_menu.text"),
}
cls.is_loaded = True

@classmethod
def version(cls):
return tool.Blender.get_bonsai_version()

@classmethod
def icon_color_mode(cls):
return tool.Blender.detect_icon_color_mode()
def icon_color_mode(cls, color_path):
return tool.Blender.detect_icon_color_mode(color_path)


def draw_statusbar(self, context):
Expand Down
Loading