mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 21:42:19 +00:00
Refactor addon preferences to make it cleaner as per developer's feedback
This commit is contained in:
@@ -132,23 +132,16 @@ class BIM_PT_spatial_decomposition(Panel):
|
|||||||
op = col.operator("bim.set_default_container", icon="OUTLINER_COLLECTION", text="Set Default")
|
op = col.operator("bim.set_default_container", icon="OUTLINER_COLLECTION", text="Set Default")
|
||||||
op.container = ifc_definition_id
|
op.container = ifc_definition_id
|
||||||
|
|
||||||
# Only show container visibility operators if the preference is enabled
|
if tool.Blender.get_addon_preferences().container_hide_show_isolate:
|
||||||
from bonsai.bim.ui import BIM_ADDON_preferences
|
op = row.operator("bim.set_container_visibility", icon="FULLSCREEN_EXIT", text="")
|
||||||
|
op.mode = "ISOLATE"
|
||||||
addon = BIM_ADDON_preferences.get_addon_instance()
|
op.container = ifc_definition_id
|
||||||
if addon and getattr(addon, "preferences", None):
|
op = row.operator("bim.set_container_visibility", icon="HIDE_OFF", text="")
|
||||||
prefs = addon.preferences
|
op.mode = "SHOW"
|
||||||
value = getattr(prefs, "container_hide_show_isolate", None)
|
op.container = ifc_definition_id
|
||||||
if value:
|
op = row.operator("bim.set_container_visibility", icon="HIDE_ON", text="")
|
||||||
op = row.operator("bim.set_container_visibility", icon="FULLSCREEN_EXIT", text="")
|
op.mode = "HIDE"
|
||||||
op.mode = "ISOLATE"
|
op.container = ifc_definition_id
|
||||||
op.container = ifc_definition_id
|
|
||||||
op = row.operator("bim.set_container_visibility", icon="HIDE_OFF", text="")
|
|
||||||
op.mode = "SHOW"
|
|
||||||
op.container = ifc_definition_id
|
|
||||||
op = row.operator("bim.set_container_visibility", icon="HIDE_ON", text="")
|
|
||||||
op.mode = "HIDE"
|
|
||||||
op.container = ifc_definition_id
|
|
||||||
|
|
||||||
# The only operator that's enabled for IfcProject.
|
# The only operator that's enabled for IfcProject.
|
||||||
col = row.column(align=True)
|
col = row.column(align=True)
|
||||||
|
|||||||
+10
-28
@@ -678,34 +678,6 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
|
|||||||
description="Default parameters for BIM elements",
|
description="Default parameters for BIM elements",
|
||||||
)
|
)
|
||||||
|
|
||||||
addon_instance = None
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def set_addon_instance(cls):
|
|
||||||
import bpy
|
|
||||||
|
|
||||||
instance = None
|
|
||||||
for key in bpy.context.preferences.addons.keys():
|
|
||||||
if ".bonsai" in key:
|
|
||||||
instance = bpy.context.preferences.addons.get(key)
|
|
||||||
break
|
|
||||||
cls.addon_instance = instance
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def get_addon_instance(cls):
|
|
||||||
if cls.addon_instance is None:
|
|
||||||
cls.set_addon_instance()
|
|
||||||
return cls.addon_instance
|
|
||||||
|
|
||||||
def draw_extras_settings(self, layout: bpy.types.UILayout, context: bpy.types.Context) -> None:
|
|
||||||
layout.prop(self, "container_hide_show_isolate")
|
|
||||||
|
|
||||||
container_hide_show_isolate: BoolProperty(
|
|
||||||
name="Container hide/show/isolate",
|
|
||||||
description="Enable container hide/show/isolate feature in the UI",
|
|
||||||
default=False,
|
|
||||||
)
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
svg2pdf_command: str
|
svg2pdf_command: str
|
||||||
svg2dxf_command: str
|
svg2dxf_command: str
|
||||||
@@ -921,6 +893,16 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
|
|||||||
layout.prop(self, "bsdd_load_test_dictionaries")
|
layout.prop(self, "bsdd_load_test_dictionaries")
|
||||||
|
|
||||||
|
|
||||||
|
def draw_extras_settings(self, layout: bpy.types.UILayout, context: bpy.types.Context) -> None:
|
||||||
|
layout.prop(self, "container_hide_show_isolate")
|
||||||
|
|
||||||
|
container_hide_show_isolate: BoolProperty(
|
||||||
|
name="Container hide/show/isolate",
|
||||||
|
description="Enable container hide/show/isolate feature in the UI",
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# Scene panel groups
|
# Scene panel groups
|
||||||
class BIM_PT_tabs(Panel):
|
class BIM_PT_tabs(Panel):
|
||||||
bl_label = "Bonsai"
|
bl_label = "Bonsai"
|
||||||
|
|||||||
Reference in New Issue
Block a user