mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 22:50:21 +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:
|
def update_global_tab(self: "BIMTabProperties", context: bpy.types.Context) -> None:
|
||||||
tool.Blender.setup_tabs()
|
tool.Blender.setup_tabs()
|
||||||
screen = tool.Blender.get_screen(context)
|
screen = context.id_data
|
||||||
aprops = screen.BIMAreaProperties[screen.areas[:].index(context.area)]
|
aprops = screen.BIMAreaProperties[screen.areas[:].index(context.area)]
|
||||||
aprops.tab = self.tab
|
aprops.tab = self.tab
|
||||||
|
|
||||||
@@ -400,10 +400,9 @@ class BIMAreaProperties(PropertyGroup):
|
|||||||
# BIMAreaProperties exists per area and is setup on load post. However, for new
|
# 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
|
# or temporary screens, they may not be setup yet, so this global tab
|
||||||
# properties is used as a fallback.
|
# 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):
|
class BIMTabProperties(PropertyGroup):
|
||||||
tab: EnumProperty(default=0, items=get_tab, name="Tab", update=update_global_tab)
|
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")
|
active_tab: BoolProperty(default=True, name="Active Tab")
|
||||||
inactive_tab: BoolProperty(default=False, name="Inactive Tab")
|
inactive_tab: BoolProperty(default=False, name="Inactive Tab")
|
||||||
|
|
||||||
|
|||||||
+43
-49
@@ -392,58 +392,52 @@ class BIM_PT_tabs(Panel):
|
|||||||
bl_options = {"HIDE_HEADER"}
|
bl_options = {"HIDE_HEADER"}
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
try:
|
is_ifc_project = bool(tool.Ifc.get())
|
||||||
is_ifc_project = bool(tool.Ifc.get())
|
aprops = tool.Blender.get_area_props(context)
|
||||||
aprops = tool.Blender.get_area_props(context)
|
|
||||||
if not aprops:
|
|
||||||
# Fallback in case areas aren't setup yet.
|
|
||||||
aprops = context.screen.BIMTabProperties
|
|
||||||
|
|
||||||
row = self.layout.row()
|
row = self.layout.row()
|
||||||
row.alignment = "CENTER"
|
row.alignment = "CENTER"
|
||||||
row.operator(
|
row.operator(
|
||||||
"bim.set_tab",
|
"bim.set_tab",
|
||||||
text="",
|
text="",
|
||||||
emboss=aprops.tab == "PROJECT",
|
emboss=aprops.tab == "PROJECT",
|
||||||
depress=True,
|
depress=True,
|
||||||
icon_value=bonsai.bim.icons["IFC"].icon_id,
|
icon_value=bonsai.bim.icons["IFC"].icon_id,
|
||||||
).tab = "PROJECT"
|
).tab = "PROJECT"
|
||||||
self.draw_tab_entry(row, "FILE_3D", "OBJECT", is_ifc_project, aprops.tab == "OBJECT")
|
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, "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, "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, "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, "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, "NLA", "SCHEDULING", is_ifc_project, aprops.tab == "SCHEDULING")
|
||||||
self.draw_tab_entry(row, "PACKAGE", "FM", True, aprops.tab == "FM")
|
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, "COMMUNITY", "QUALITY", True, aprops.tab == "QUALITY")
|
||||||
row.operator("bim.switch_tab", text="", emboss=False, icon="UV_SYNC_SELECT")
|
row.operator("bim.switch_tab", text="", emboss=False, icon="UV_SYNC_SELECT")
|
||||||
|
|
||||||
# Yes, that's right.
|
# Yes, that's right.
|
||||||
row = self.layout.row()
|
row = self.layout.row()
|
||||||
row.alignment = "CENTER"
|
row.alignment = "CENTER"
|
||||||
row.scale_y = 0.2
|
row.scale_y = 0.2
|
||||||
for tab in [
|
for tab in [
|
||||||
"PROJECT",
|
"PROJECT",
|
||||||
"OBJECT",
|
"OBJECT",
|
||||||
"GEOMETRY",
|
"GEOMETRY",
|
||||||
"DRAWINGS",
|
"DRAWINGS",
|
||||||
"SERVICES",
|
"SERVICES",
|
||||||
"STRUCTURE",
|
"STRUCTURE",
|
||||||
"SCHEDULING",
|
"SCHEDULING",
|
||||||
"FM",
|
"FM",
|
||||||
"QUALITY",
|
"QUALITY",
|
||||||
"SWITCH",
|
"SWITCH",
|
||||||
]:
|
]:
|
||||||
# Draw a little underscore below the active tab icon.
|
# Draw a little underscore below the active tab icon.
|
||||||
if aprops.tab == tab:
|
if aprops.tab == tab:
|
||||||
row.prop(aprops, "active_tab", text="", icon="BLANK1")
|
row.prop(aprops, "active_tab", text="", icon="BLANK1")
|
||||||
else:
|
else:
|
||||||
row.prop(aprops, "inactive_tab", text="", icon="BLANK1", emboss=False)
|
row.prop(aprops, "inactive_tab", text="", icon="BLANK1", emboss=False)
|
||||||
|
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.prop(aprops, "tab", text="")
|
row.prop(aprops, "tab", text="")
|
||||||
except:
|
|
||||||
pass # Prior to load_post, we may not have any area properties setup
|
|
||||||
|
|
||||||
if bonsai.REINSTALLED_BBIM_VERSION:
|
if bonsai.REINSTALLED_BBIM_VERSION:
|
||||||
box = self.layout.box()
|
box = self.layout.box()
|
||||||
|
|||||||
@@ -86,16 +86,17 @@ class Blender(bonsai.core.tool.Blender):
|
|||||||
area.spaces[0].region_3d.view_perspective = "CAMERA"
|
area.spaces[0].region_3d.view_perspective = "CAMERA"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_area_props(cls, context: bpy.types.Context) -> Any:
|
def get_area_props(cls, context: bpy.types.Context) -> bpy.types.PropertyGroup:
|
||||||
try:
|
try:
|
||||||
if context.screen.name.endswith("-nonnormal"): # Ctrl-space temporary fullscreen
|
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
|
# The original area object has its type changed to "EMPTY" apparently
|
||||||
index = [a.type for a in screen.areas].index("EMPTY")
|
index = [a.type for a in screen.areas].index("EMPTY")
|
||||||
return screen.BIMAreaProperties[index]
|
return screen.BIMAreaProperties[index]
|
||||||
return context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)]
|
return context.screen.BIMAreaProperties[context.screen.areas[:].index(context.area)]
|
||||||
except:
|
except IndexError:
|
||||||
return
|
# Fallback in case areas aren't setup yet.
|
||||||
|
return context.screen.BIMTabProperties
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def set_active_object(cls, obj: bpy.types.Object) -> None:
|
def set_active_object(cls, obj: bpy.types.Object) -> None:
|
||||||
@@ -119,9 +120,7 @@ class Blender(bonsai.core.tool.Blender):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def is_tab(cls, context: bpy.types.Context, tab: str) -> bool:
|
def is_tab(cls, context: bpy.types.Context, tab: str) -> bool:
|
||||||
aprops = cls.get_area_props(context)
|
aprops = cls.get_area_props(context)
|
||||||
if not aprops:
|
if aprops.path_from_id() == "BIMAreaProperties" and context.area.spaces.active.search_filter:
|
||||||
return context.screen.BIMTabProperties.tab == tab
|
|
||||||
if context.area.spaces.active.search_filter:
|
|
||||||
return True
|
return True
|
||||||
return aprops.tab == tab
|
return aprops.tab == tab
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user