mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 21:42:19 +00:00
ExpandedGroups - encapsulate in BIMGroupProperties
This commit is contained in:
@@ -32,7 +32,6 @@ classes = (
|
|||||||
operator.SetGroupVisibility,
|
operator.SetGroupVisibility,
|
||||||
operator.ToggleGroup,
|
operator.ToggleGroup,
|
||||||
operator.UnassignGroup,
|
operator.UnassignGroup,
|
||||||
prop.ExpandedGroups,
|
|
||||||
prop.Group,
|
prop.Group,
|
||||||
prop.BIMGroupProperties,
|
prop.BIMGroupProperties,
|
||||||
ui.BIM_PT_groups,
|
ui.BIM_PT_groups,
|
||||||
@@ -43,9 +42,7 @@ classes = (
|
|||||||
|
|
||||||
def register():
|
def register():
|
||||||
bpy.types.Scene.BIMGroupProperties = bpy.props.PointerProperty(type=prop.BIMGroupProperties)
|
bpy.types.Scene.BIMGroupProperties = bpy.props.PointerProperty(type=prop.BIMGroupProperties)
|
||||||
bpy.types.Scene.ExpandedGroups = bpy.props.PointerProperty(type=prop.ExpandedGroups)
|
|
||||||
|
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
del bpy.types.Scene.BIMGroupProperties
|
del bpy.types.Scene.BIMGroupProperties
|
||||||
del bpy.types.Scene.ExpandedGroups
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class LoadGroups(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
self.props = tool.Blender.get_group_props()
|
self.props = tool.Blender.get_group_props()
|
||||||
self.expanded_groups = json.loads(context.scene.ExpandedGroups.json_string)
|
self.expanded_groups = json.loads(self.props.expanded_groups_json)
|
||||||
self.props.groups.clear()
|
self.props.groups.clear()
|
||||||
|
|
||||||
groups = [
|
groups = [
|
||||||
@@ -79,12 +79,13 @@ class ToggleGroup(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
option: bpy.props.StringProperty(name="Expand or Collapse")
|
option: bpy.props.StringProperty(name="Expand or Collapse")
|
||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
expanded_groups = set(json.loads(context.scene.ExpandedGroups.json_string))
|
props = tool.Blender.get_group_props()
|
||||||
|
expanded_groups = set(json.loads(props.expanded_groups_json))
|
||||||
if self.option == "Expand":
|
if self.option == "Expand":
|
||||||
expanded_groups.add(self.ifc_definition_id)
|
expanded_groups.add(self.ifc_definition_id)
|
||||||
elif self.ifc_definition_id in expanded_groups:
|
elif self.ifc_definition_id in expanded_groups:
|
||||||
expanded_groups.remove(self.ifc_definition_id)
|
expanded_groups.remove(self.ifc_definition_id)
|
||||||
context.scene.ExpandedGroups.json_string = json.dumps(list(expanded_groups))
|
props.expanded_groups_json = json.dumps(list(expanded_groups))
|
||||||
bpy.ops.bim.load_groups()
|
bpy.ops.bim.load_groups()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|||||||
@@ -38,13 +38,6 @@ def update_active_group_index(self, context):
|
|||||||
refresh_pset()
|
refresh_pset()
|
||||||
|
|
||||||
|
|
||||||
class ExpandedGroups(StrProperty):
|
|
||||||
json_string: StringProperty(name="JSON String", default="[]")
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
json_string: str
|
|
||||||
|
|
||||||
|
|
||||||
class Group(PropertyGroup):
|
class Group(PropertyGroup):
|
||||||
name: StringProperty(name="Name")
|
name: StringProperty(name="Name")
|
||||||
ifc_definition_id: IntProperty(name="IFC Definition ID")
|
ifc_definition_id: IntProperty(name="IFC Definition ID")
|
||||||
@@ -66,6 +59,7 @@ class BIMGroupProperties(PropertyGroup):
|
|||||||
groups: CollectionProperty(name="Groups", type=Group)
|
groups: CollectionProperty(name="Groups", type=Group)
|
||||||
active_group_index: IntProperty(name="Active Group Index", update=update_active_group_index)
|
active_group_index: IntProperty(name="Active Group Index", update=update_active_group_index)
|
||||||
active_group_id: IntProperty(name="Active Group Id")
|
active_group_id: IntProperty(name="Active Group Id")
|
||||||
|
expanded_groups_json: StringProperty(name="JSON String", default="[]")
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
group_attributes: bpy.types.bpy_prop_collection_idprop[Attribute]
|
group_attributes: bpy.types.bpy_prop_collection_idprop[Attribute]
|
||||||
@@ -73,6 +67,7 @@ class BIMGroupProperties(PropertyGroup):
|
|||||||
groups: bpy.types.bpy_prop_collection_idprop[Group]
|
groups: bpy.types.bpy_prop_collection_idprop[Group]
|
||||||
active_group_index: int
|
active_group_index: int
|
||||||
active_group_id: int
|
active_group_id: int
|
||||||
|
expanded_groups_json: str
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def active_group(self) -> Union[Group, None]:
|
def active_group(self) -> Union[Group, None]:
|
||||||
|
|||||||
Reference in New Issue
Block a user