Revert "Small tester UI fix #3487"

This reverts commit c7a1acf974.
This commit is contained in:
Dion Moult
2023-07-23 19:09:00 +10:00
parent 8dea80aff7
commit f5d5f44458
2 changed files with 38 additions and 45 deletions
@@ -29,41 +29,37 @@ from bpy.props import (
CollectionProperty, CollectionProperty,
) )
def purge(): def purge():
pass pass
def get_failure_entities(): def get_failure_entities():
return return
class Specification(PropertyGroup): class Specification(PropertyGroup):
name: StringProperty(name="Name") name: StringProperty(name="Name")
status : BoolProperty(default=False, name="Status") status: BoolProperty(default=False, name="Status")
class FailedEntities(PropertyGroup): class FailedEntities(PropertyGroup):
reason: StringProperty(name="Reason") reason: StringProperty(name="Reason")
element: StringProperty(name="Element") element: StringProperty(name="Element")
class IfcTesterProperties(PropertyGroup): class IfcTesterProperties(PropertyGroup):
specs: StringProperty(default="", name="IDS File") specs: StringProperty(default="", name="IDS File")
ifc_file: StringProperty(default="", name="IFC File") ifc_file: StringProperty(default="", name="IFC File")
should_load_from_memory: BoolProperty(default=False, name="Load from Memory")
should_load_from_memory: BoolProperty(default=False, name="Load from Memory",
description="Use the currently opened IFC project. Required for the detailed Tester UI")
generate_html_report: BoolProperty(default=False, name="Generate HTML report") generate_html_report: BoolProperty(default=False, name="Generate HTML report")
active_specification_index: IntProperty(name="Active Specification Index")
active_specification_index: IntProperty(name="Active Specification Index")
active_requirement_index: IntProperty(name="Active Requirement Index") active_requirement_index: IntProperty(name="Active Requirement Index")
old_index: IntProperty(name="", default=0) old_index: IntProperty(name="", default=0)
active_failed_entity_index: IntProperty(name="Active Failed Entity Index") active_failed_entity_index: IntProperty(name="Active Failed Entity Index")
report: StringProperty(default="", name="JSON report") report: StringProperty(default="", name="JSON report")
specifications: CollectionProperty(name="Specifications", type=Specification) specifications: CollectionProperty(name="Specifications", type=Specification)
failed_entities: CollectionProperty(name="FailedEntities", type=FailedEntities) failed_entities: CollectionProperty(name="FailedEntities", type=FailedEntities)
has_report : BoolProperty(default=False, name="") has_report: BoolProperty(default=False, name="")
has_entities : BoolProperty(default=False, name="") has_entities: BoolProperty(default=False, name="")
n_entities : IntProperty(name="", default=0) n_entities: IntProperty(name="", default=0)
@@ -34,19 +34,18 @@ class BIM_PT_tester(Panel):
self.layout.use_property_split = True self.layout.use_property_split = True
props = context.scene.IfcTesterProperties props = context.scene.IfcTesterProperties
row = self.layout.row() if tool.Ifc.get():
row.prop(self.props, "should_load_from_memory") row = self.layout.row()
row.enabled = bool(tool.Ifc.get()) row.prop(self.props, "should_load_from_memory")
row = self.layout.row() row = self.layout.row()
row.prop(props, "generate_html_report") row.prop(props, "generate_html_report")
if not tool.Ifc.get() or not props.should_load_from_memory: if not tool.Ifc.get() or not props.should_load_from_memory:
row = self.layout.row(align=True) row = self.layout.row(align=True)
row.prop(props, "ifc_file") row.prop(props, "ifc_file")
row.operator("bim.select_ifctester_ifc_file", icon="FILE_FOLDER", text="") row.operator("bim.select_ifctester_ifc_file", icon="FILE_FOLDER", text="")
row = self.layout.row(align=True) row = self.layout.row(align=True)
row.prop(props, "specs") row.prop(props, "specs")
row.operator("bim.select_specs", icon="FILE_FOLDER", text="") row.operator("bim.select_specs", icon="FILE_FOLDER", text="")
@@ -69,25 +68,25 @@ class BIM_PT_tester(Panel):
row.operator("bim.export_bcf", text="Export BCF", icon="EXPORT") row.operator("bim.export_bcf", text="Export BCF", icon="EXPORT")
def draw_editable_ui(self, context): def draw_editable_ui(self, context):
props = context.scene.IfcTesterProperties props = context.scene.IfcTesterProperties
i = props.active_specification_index i = props.active_specification_index
dic_report = json.loads(props.report) dic_report = json.loads(props.report)
total_successes = dic_report[i]['total_successes'] total_successes = dic_report[i]["total_successes"]
total = dic_report[i]['total'] total = dic_report[i]["total"]
percentage = dic_report[i]['percentage'] percentage = dic_report[i]["percentage"]
n_requirements = len(dic_report[i]['requirements']) n_requirements = len(dic_report[i]["requirements"])
row = self.layout.row() row = self.layout.row()
row.label(text = f"Passed: {total_successes}/{total} ({percentage}%)") row.label(text=f"Passed: {total_successes}/{total} ({percentage}%)")
row = self.layout.row() row = self.layout.row()
row.label(text = f"Requirements ({n_requirements}):") row.label(text=f"Requirements ({n_requirements}):")
c=0 c = 0
box = self.layout.box() box = self.layout.box()
for req in dic_report[i]['requirements']: for req in dic_report[i]["requirements"]:
row = box.row(align=True) row = box.row(align=True)
row.label(text=f" {c+1}. {req['description']}") row.label(text=f" {c+1}. {req['description']}")
if req['status']: if req["status"]:
row.label(text="PASS", icon="CHECKMARK") row.label(text="PASS", icon="CHECKMARK")
else: else:
row.label(text="FAIL", icon="CANCEL") row.label(text="FAIL", icon="CANCEL")
@@ -95,10 +94,10 @@ class BIM_PT_tester(Panel):
op.spec_index = i op.spec_index = i
op.req_index = c op.req_index = c
c += 1 c += 1
if props.old_index == i and props.n_entities > 0: if props.old_index == i and props.n_entities > 0:
row = self.layout.row() row = self.layout.row()
row.label(text = f"Failed entities [{props.n_entities}]:") row.label(text=f"Failed entities [{props.n_entities}]:")
self.layout.template_list( self.layout.template_list(
"BIM_UL_tester_failed_entities", "BIM_UL_tester_failed_entities",
"", "",
@@ -107,9 +106,8 @@ class BIM_PT_tester(Panel):
props, props,
"active_failed_entity_index", "active_failed_entity_index",
) )
class BIM_UL_tester_specifications(UIList): class BIM_UL_tester_specifications(UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname): def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
if item: if item:
@@ -120,23 +118,22 @@ class BIM_UL_tester_specifications(UIList):
else: else:
row.label(text="FAIL") row.label(text="FAIL")
class BIM_UL_tester_failed_entities(UIList): class BIM_UL_tester_failed_entities(UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname): def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
props = context.scene.IfcTesterProperties props = context.scene.IfcTesterProperties
if item: if item:
if props.should_load_from_memory: if props.should_load_from_memory:
ifc_file = tool.Ifc.get() ifc_file = tool.Ifc.get()
ifc_id = int(item.element[1:item.element.find('=')]) ifc_id = int(item.element[1 : item.element.find("=")])
entity = ifc_file.by_id(ifc_id) entity = ifc_file.by_id(ifc_id)
report_entity = f'[#{ifc_id}][{entity.is_a()}] {entity.Name}' report_entity = f"[#{ifc_id}][{entity.is_a()}] {entity.Name}"
else: else:
report_entity = item.element report_entity = item.element
row = layout.row(align=True) row = layout.row(align=True)
row.label(text=report_entity) row.label(text=report_entity)
row.label(text=item.reason) row.label(text=item.reason)
if props.should_load_from_memory: if props.should_load_from_memory:
op = row.operator("bim.select_entity", text="", icon="RESTRICT_SELECT_OFF") op = row.operator("bim.select_entity", text="", icon="RESTRICT_SELECT_OFF")
op.ifc_id = entity.id() op.ifc_id = entity.id()