Move code using ui index from data to ui #4028

As UI indices changes doesn't trigger data.py updates and information on screen is not synced with the active item anymore.
This commit is contained in:
Andrej730
2023-11-20 12:24:06 +05:00
parent 229c7285c2
commit 0b7442b288
2 changed files with 10 additions and 20 deletions
@@ -101,8 +101,6 @@ class RepresentationItemsData:
def load(cls):
cls.data = {
"total_items": cls.total_items(),
"active_surface_style": cls.active_surface_style(),
"active_layer": cls.active_layer(),
}
cls.is_loaded = True
@@ -124,18 +122,6 @@ class RepresentationItemsData:
result += 1
return result
@classmethod
def active_surface_style(cls):
props = bpy.context.active_object.BIMGeometryProperties
if props.active_item_index < len(props.items):
return props.items[props.active_item_index].surface_style
@classmethod
def active_layer(cls):
props = bpy.context.active_object.BIMGeometryProperties
if props.active_item_index < len(props.items):
return props.items[props.active_item_index].layer
class ConnectionsData:
data = {}
@@ -181,17 +181,21 @@ class BIM_PT_representation_items(Panel):
self.layout.template_list("BIM_UL_representation_items", "", props, "items", props, "active_item_index")
item_is_active = props.active_item_index < len(props.items)
if item_is_active:
surface_style = props.items[props.active_item_index].surface_style
presentation_layer = props.items[props.active_item_index].layer
else:
surface_style, presentation_layer = None, None
row = self.layout.row()
if RepresentationItemsData.data["active_surface_style"]:
row.label(text=RepresentationItemsData.data["active_surface_style"], icon="MATERIAL")
if surface_style:
row.label(text=surface_style, icon="MATERIAL")
else:
row.label(text="No Surface Style", icon="MESH_UVSPHERE")
row = self.layout.row()
if RepresentationItemsData.data["active_layer"]:
row.label(text=RepresentationItemsData.data["active_layer"], icon="STICKY_UVS_LOC")
else:
row.label(text="No Presentation Layer", icon="STICKY_UVS_LOC")
row.label(text=presentation_layer or "No Presentation Layer", icon="STICKY_UVS_LOC")
class BIM_PT_connections(Panel):