Replace grids/space elements visibility two toggles with one

See - https://i.imgur.com/5GssIDp.png (same for grids)
This commit is contained in:
Andrej730
2024-09-12 18:15:15 +05:00
parent e5a59d0bea
commit 845402ea9c
2 changed files with 42 additions and 10 deletions
+32 -2
View File
@@ -127,6 +127,14 @@ def update_spatial_is_locked(self, context):
tool.Geometry.unlock_object(obj)
def update_spatial_is_visible(self: "BIMSpatialDecompositionProperties", context: bpy.types.Context) -> None:
bpy.ops.bim.toggle_spatial_elements(is_visible=self.is_visible)
def update_grid_is_visible(self: "BIMGridProperties", context: bpy.types.Context) -> None:
bpy.ops.bim.toggle_grids(is_visible=self.is_visible)
def poll_container_obj(self, obj):
return obj is None or tool.Ifc.get_entity(obj)
@@ -174,7 +182,18 @@ class Element(PropertyGroup):
class BIMSpatialDecompositionProperties(PropertyGroup):
is_locked: BoolProperty(name="Is Locked", default=True, update=update_spatial_is_locked)
is_locked: BoolProperty(
name="Is Locked",
description="Prevent all spatial elements from being edited, removed, duplicated",
default=True,
update=update_spatial_is_locked,
)
is_visible: BoolProperty(
name="Is Visible",
description="Show or hide spatial elements, such as buildings, sites, etc",
default=True,
update=update_spatial_is_visible,
)
container_filter: StringProperty(name="Container Filter", default="", options={"TEXTEDIT_UPDATE"})
containers: CollectionProperty(name="Containers", type=BIMContainer)
contracted_containers: StringProperty(name="Contracted containers", default="[]")
@@ -211,5 +230,16 @@ class BIMSpatialDecompositionProperties(PropertyGroup):
class BIMGridProperties(PropertyGroup):
is_locked: BoolProperty(name="Is Locked", default=True, update=update_grid_is_locked)
is_locked: BoolProperty(
name="Is Locked",
description="Prevent all grids and grid axes from being edited, removed, duplicated",
default=True,
update=update_grid_is_locked,
)
is_visible: BoolProperty(
name="Is Visible",
description="Show or hide grids and grid axes",
default=True,
update=update_grid_is_visible,
)
grid_axes: CollectionProperty(name="Grid Axes", type=ObjProperty)
+10 -8
View File
@@ -103,12 +103,13 @@ class BIM_PT_spatial_decomposition(Panel):
return tool.Ifc.get()
def draw_header(self, context):
props = context.scene.BIMSpatialDecompositionProperties
row = self.layout.row(align=True)
row.label(text="") # empty text occupies the left of the row
row.operator("bim.toggle_spatial_elements", text="", icon="HIDE_OFF").is_visible = True
row.operator("bim.toggle_spatial_elements", text="", icon="HIDE_ON").is_visible = False
icon = "VIEW_LOCKED" if context.scene.BIMSpatialDecompositionProperties.is_locked else "VIEW_UNLOCKED"
row.prop(context.scene.BIMSpatialDecompositionProperties, "is_locked", text="", icon=icon)
icon = "HIDE_OFF" if props.is_visible else "HIDE_ON"
row.prop(props, "is_visible", text="", icon=icon)
icon = "VIEW_LOCKED" if props.is_locked else "VIEW_UNLOCKED"
row.prop(props, "is_locked", text="", icon=icon)
def draw(self, context):
if not SpatialDecompositionData.is_loaded:
@@ -218,12 +219,13 @@ class BIM_PT_grids(Panel):
self.layout.row().operator("mesh.add_grid", icon="ADD", text="Add Grids")
def draw_header(self, context):
props = context.scene.BIMGridProperties
row = self.layout.row(align=True)
row.label(text="") # empty text occupies the left of the row
row.operator("bim.toggle_grids", text="", icon="HIDE_OFF").is_visible = True
row.operator("bim.toggle_grids", text="", icon="HIDE_ON").is_visible = False
icon = "VIEW_LOCKED" if context.scene.BIMGridProperties.is_locked else "VIEW_UNLOCKED"
row.prop(context.scene.BIMGridProperties, "is_locked", text="", icon=icon)
icon = "HIDE_OFF" if props.is_visible else "HIDE_ON"
row.prop(props, "is_visible", text="", icon=icon)
icon = "VIEW_LOCKED" if props.is_locked else "VIEW_UNLOCKED"
row.prop(props, "is_locked", text="", icon=icon)
class BIM_UL_containers_manager(UIList):