mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
BIMTabProperties fixes
1) Fixed non-existent tool.Blender.get_screen 2) ui.py - remove try/except for the case when tabs are not loaded yet as it's covered by BIMTabProperties 3) removed previous_tab, alt_tab props never used in ui 4) general method for getting area properties that includes BIMTabProperties automatically
This commit is contained in:
@@ -60,7 +60,7 @@ def update_tab(self: "BIMAreaProperties", context: bpy.types.Context) -> None:
|
||||
|
||||
def update_global_tab(self: "BIMTabProperties", context: bpy.types.Context) -> None:
|
||||
tool.Blender.setup_tabs()
|
||||
screen = tool.Blender.get_screen(context)
|
||||
screen = context.id_data
|
||||
aprops = screen.BIMAreaProperties[screen.areas[:].index(context.area)]
|
||||
aprops.tab = self.tab
|
||||
|
||||
@@ -400,10 +400,9 @@ class BIMAreaProperties(PropertyGroup):
|
||||
# BIMAreaProperties exists per area and is setup on load post. However, for new
|
||||
# or temporary screens, they may not be setup yet, so this global tab
|
||||
# properties is used as a fallback.
|
||||
# Need it basically only for UI - to display those props and allow changing tab from the dropdown.
|
||||
class BIMTabProperties(PropertyGroup):
|
||||
tab: EnumProperty(default=0, items=get_tab, name="Tab", update=update_global_tab)
|
||||
previous_tab: StringProperty(default="PROJECT", name="Previous Tab")
|
||||
alt_tab: StringProperty(default="OBJECT", name="Alt Tab")
|
||||
active_tab: BoolProperty(default=True, name="Active Tab")
|
||||
inactive_tab: BoolProperty(default=False, name="Inactive Tab")
|
||||
|
||||
|
||||
+43
-49
@@ -392,58 +392,52 @@ class BIM_PT_tabs(Panel):
|
||||
bl_options = {"HIDE_HEADER"}
|
||||
|
||||
def draw(self, context):
|
||||
try:
|
||||
is_ifc_project = bool(tool.Ifc.get())
|
||||
aprops = tool.Blender.get_area_props(context)
|
||||
if not aprops:
|
||||
# Fallback in case areas aren't setup yet.
|
||||
aprops = context.screen.BIMTabProperties
|
||||
is_ifc_project = bool(tool.Ifc.get())
|
||||
aprops = tool.Blender.get_area_props(context)
|
||||
|
||||
row = self.layout.row()
|
||||
row.alignment = "CENTER"
|
||||
row.operator(
|
||||
"bim.set_tab",
|
||||
text="",
|
||||
emboss=aprops.tab == "PROJECT",
|
||||
depress=True,
|
||||
icon_value=bonsai.bim.icons["IFC"].icon_id,
|
||||
).tab = "PROJECT"
|
||||
self.draw_tab_entry(row, "FILE_3D", "OBJECT", is_ifc_project, aprops.tab == "OBJECT")
|
||||
self.draw_tab_entry(row, "MATERIAL", "GEOMETRY", is_ifc_project, aprops.tab == "GEOMETRY")
|
||||
self.draw_tab_entry(row, "DOCUMENTS", "DRAWINGS", is_ifc_project, aprops.tab == "DRAWINGS")
|
||||
self.draw_tab_entry(row, "NETWORK_DRIVE", "SERVICES", is_ifc_project, aprops.tab == "SERVICES")
|
||||
self.draw_tab_entry(row, "EDITMODE_HLT", "STRUCTURE", is_ifc_project, aprops.tab == "STRUCTURE")
|
||||
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")
|
||||
row.operator("bim.switch_tab", text="", emboss=False, icon="UV_SYNC_SELECT")
|
||||
row = self.layout.row()
|
||||
row.alignment = "CENTER"
|
||||
row.operator(
|
||||
"bim.set_tab",
|
||||
text="",
|
||||
emboss=aprops.tab == "PROJECT",
|
||||
depress=True,
|
||||
icon_value=bonsai.bim.icons["IFC"].icon_id,
|
||||
).tab = "PROJECT"
|
||||
self.draw_tab_entry(row, "FILE_3D", "OBJECT", is_ifc_project, aprops.tab == "OBJECT")
|
||||
self.draw_tab_entry(row, "MATERIAL", "GEOMETRY", is_ifc_project, aprops.tab == "GEOMETRY")
|
||||
self.draw_tab_entry(row, "DOCUMENTS", "DRAWINGS", is_ifc_project, aprops.tab == "DRAWINGS")
|
||||
self.draw_tab_entry(row, "NETWORK_DRIVE", "SERVICES", is_ifc_project, aprops.tab == "SERVICES")
|
||||
self.draw_tab_entry(row, "EDITMODE_HLT", "STRUCTURE", is_ifc_project, aprops.tab == "STRUCTURE")
|
||||
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")
|
||||
row.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
|
||||
for tab in [
|
||||
"PROJECT",
|
||||
"OBJECT",
|
||||
"GEOMETRY",
|
||||
"DRAWINGS",
|
||||
"SERVICES",
|
||||
"STRUCTURE",
|
||||
"SCHEDULING",
|
||||
"FM",
|
||||
"QUALITY",
|
||||
"SWITCH",
|
||||
]:
|
||||
# Draw a little underscore below the active tab icon.
|
||||
if aprops.tab == tab:
|
||||
row.prop(aprops, "active_tab", text="", icon="BLANK1")
|
||||
else:
|
||||
row.prop(aprops, "inactive_tab", text="", icon="BLANK1", emboss=False)
|
||||
# Yes, that's right.
|
||||
row = self.layout.row()
|
||||
row.alignment = "CENTER"
|
||||
row.scale_y = 0.2
|
||||
for tab in [
|
||||
"PROJECT",
|
||||
"OBJECT",
|
||||
"GEOMETRY",
|
||||
"DRAWINGS",
|
||||
"SERVICES",
|
||||
"STRUCTURE",
|
||||
"SCHEDULING",
|
||||
"FM",
|
||||
"QUALITY",
|
||||
"SWITCH",
|
||||
]:
|
||||
# Draw a little underscore below the active tab icon.
|
||||
if aprops.tab == tab:
|
||||
row.prop(aprops, "active_tab", text="", icon="BLANK1")
|
||||
else:
|
||||
row.prop(aprops, "inactive_tab", text="", icon="BLANK1", emboss=False)
|
||||
|
||||
row = self.layout.row(align=True)
|
||||
row.prop(aprops, "tab", text="")
|
||||
except:
|
||||
pass # Prior to load_post, we may not have any area properties setup
|
||||
row = self.layout.row(align=True)
|
||||
row.prop(aprops, "tab", text="")
|
||||
|
||||
if bonsai.REINSTALLED_BBIM_VERSION:
|
||||
box = self.layout.box()
|
||||
|
||||
@@ -86,16 +86,17 @@ class Blender(bonsai.core.tool.Blender):
|
||||
area.spaces[0].region_3d.view_perspective = "CAMERA"
|
||||
|
||||
@classmethod
|
||||
def get_area_props(cls, context: bpy.types.Context) -> Any:
|
||||
def get_area_props(cls, context: bpy.types.Context) -> bpy.types.PropertyGroup:
|
||||
try:
|
||||
if context.screen.name.endswith("-nonnormal"): # Ctrl-space temporary fullscreen
|
||||
screen = bpy.data.screens[context.screen.name[0 : -len("-nonnormal")]]
|
||||
screen = bpy.data.screens[context.screen.name.removesuffix("-nonnormal")]
|
||||
# The original area object has its type changed to "EMPTY" apparently
|
||||
index = [a.type for a in screen.areas].index("EMPTY")
|
||||
return screen.BIMAreaProperties[index]
|
||||
return context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)]
|
||||
except:
|
||||
return
|
||||
except IndexError:
|
||||
# Fallback in case areas aren't setup yet.
|
||||
return context.screen.BIMTabProperties
|
||||
|
||||
@classmethod
|
||||
def set_active_object(cls, obj: bpy.types.Object) -> None:
|
||||
@@ -119,9 +120,7 @@ class Blender(bonsai.core.tool.Blender):
|
||||
@classmethod
|
||||
def is_tab(cls, context: bpy.types.Context, tab: str) -> bool:
|
||||
aprops = cls.get_area_props(context)
|
||||
if not aprops:
|
||||
return context.screen.BIMTabProperties.tab == tab
|
||||
if context.area.spaces.active.search_filter:
|
||||
if aprops.path_from_id() == "BIMAreaProperties" and context.area.spaces.active.search_filter:
|
||||
return True
|
||||
return aprops.tab == tab
|
||||
|
||||
|
||||
Reference in New Issue
Block a user