From 4e5503002a685a35aec14e620a6cf5471cf2f248 Mon Sep 17 00:00:00 2001 From: Carlos Villagrasa Date: Wed, 10 Aug 2022 13:23:13 +0200 Subject: [PATCH] Construction Type Browser, polishing of 2nd iteration (#2336) * Polish a bit the type browser UI * Remove SELECT from type browser * model and geometry module tests fixed * Polishing of type authoring layout redesign * Further polishing of type authoring layout --- src/blenderbim/blenderbim/bim/module/model/data.py | 10 ++++++++-- src/blenderbim/blenderbim/bim/module/model/prop.py | 8 +++----- .../blenderbim/bim/module/model/workspace.py | 1 + src/blenderbim/test/bim/feature/model.feature | 14 ++++---------- src/blenderbim/test/bim/test_feature.py | 12 ------------ 5 files changed, 16 insertions(+), 29 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/model/data.py b/src/blenderbim/blenderbim/bim/module/model/data.py index 93066affbd..f0309a3d80 100644 --- a/src/blenderbim/blenderbim/bim/module/model/data.py +++ b/src/blenderbim/blenderbim/bim/module/model/data.py @@ -55,7 +55,7 @@ class AuthoringData: @classmethod def load_relating_types_browser(cls): - cls.data["relating_types_browser_ids"] = cls.relating_types_browser() + cls.data["relating_types_ids_browser"] = cls.relating_types_browser() @classmethod def load_preview_constr_types(cls): @@ -105,8 +105,10 @@ class AuthoringData: @classmethod def assetize_constr_class(cls, ifc_class=None): + selected_ifc_class = cls.props.ifc_class + selected_relating_type_id = cls.props.relating_type_id if ifc_class is None: - ifc_class = cls.props.ifc_class + ifc_class = cls.props.ifc_class_browser relating_type_info = cls.relating_type_info(ifc_class) _ = cls.new_relating_type_info(ifc_class) if relating_type_info is None else relating_type_info constr_class_occurrences = cls.constr_class_entities(ifc_class) @@ -122,6 +124,10 @@ class AuthoringData: cls.assetize_object(obj, ifc_class, constr_class_entity) relating_type_info = cls.relating_type_info(ifc_class) relating_type_info.fully_loaded = True + cls.props.updating = True + cls.props.ifc_class = selected_ifc_class + cls.props.relating_type_id = selected_relating_type_id + cls.props.updating = False @classmethod def assetize_object(cls, obj, ifc_class, ifc_class_entity, from_selection=False): diff --git a/src/blenderbim/blenderbim/bim/module/model/prop.py b/src/blenderbim/blenderbim/bim/module/model/prop.py index 05a38e4458..0b345db3fe 100644 --- a/src/blenderbim/blenderbim/bim/module/model/prop.py +++ b/src/blenderbim/blenderbim/bim/module/model/prop.py @@ -36,7 +36,7 @@ def get_relating_type(self, context): def get_relating_type_browser(self, context): if not AuthoringData.is_loaded: AuthoringData.load() - return AuthoringData.data["relating_types_browser_ids"] + return AuthoringData.data["relating_types_ids_browser"] def update_icon_id(self, context, browser=False): @@ -49,16 +49,14 @@ def update_icon_id(self, context, browser=False): ) and relating_type is not None: if not AuthoringData.assetize_relating_type_from_selection(browser=browser): return - if ifc_class not in AuthoringData.data["preview_constr_types"]: - pass self.icon_id = AuthoringData.data["preview_constr_types"][ifc_class][relating_type_id]["icon_id"] def update_ifc_class(self, context): AuthoringData.load_ifc_classes() AuthoringData.load_relating_types() - if self.updating: - return + if not self.updating: + update_icon_id(self, context) def update_ifc_class_browser(self, context): diff --git a/src/blenderbim/blenderbim/bim/module/model/workspace.py b/src/blenderbim/blenderbim/bim/module/model/workspace.py index 295701231c..c2a0fff83c 100644 --- a/src/blenderbim/blenderbim/bim/module/model/workspace.py +++ b/src/blenderbim/blenderbim/bim/module/model/workspace.py @@ -73,6 +73,7 @@ class BimTool(WorkSpaceTool): if ifc_classes and relating_types_ids and not props.icon_id: # hack Dion won't like to show a preview also on the first time the sidebar is shown + bpy.app.timers.register(lambda: prop.update_ifc_class_browser(props, context)) bpy.app.timers.register(lambda: prop.update_relating_type(props, context)) ifc_class = props.ifc_class diff --git a/src/blenderbim/test/bim/feature/model.feature b/src/blenderbim/test/bim/feature/model.feature index 0db26c92c5..51ca4d4fbd 100644 --- a/src/blenderbim/test/bim/feature/model.feature +++ b/src/blenderbim/test/bim/feature/model.feature @@ -51,9 +51,7 @@ Scenario: Add type instance - add a mesh where existing instances have changed c Scenario: Preview one type on the Construction Type Browser Given an empty IFC project And I load the demo construction library - When I display the construction type browser - And I preview only one asset on the construction type browser - And I set "scene.BIMModelProperties.ifc_class" to "IfcColumnType" + When I set "scene.BIMModelProperties.ifc_class" to "IfcColumnType" And I set "scene.BIMModelProperties.relating_type" to "DEMO2" Then construction type is DEMO2 And objects starting with "IfcColumn/" do not exist @@ -63,18 +61,14 @@ Scenario: Preview one class on the construction type browser Given an empty IFC project And I load the demo construction library When I display the construction type browser - And I preview all available assets on the construction type browser - And I set "scene.BIMModelProperties.ifc_class" to "IfcWallType" - Then "scene.BIMModelProperties.ifc_class" is "IfcWallType" - And objects starting with "IfcWall/" do not exist + And I set "scene.BIMModelProperties.ifc_class_browser" to "IfcWallType" + Then objects starting with "IfcWall/" do not exist And all construction types for "IfcWallType" have a preview Scenario: Add one type from the Construction Type Browser Given an empty IFC project And I load the demo construction library - When I display the construction type browser - And I preview only one asset on the construction type browser - And I set "scene.BIMModelProperties.ifc_class" to "IfcColumnType" + When I set "scene.BIMModelProperties.ifc_class" to "IfcColumnType" And I set "scene.BIMModelProperties.relating_type" to "DEMO2" And I add the construction type Then the object "IfcColumn/Column" exists diff --git a/src/blenderbim/test/bim/test_feature.py b/src/blenderbim/test/bim/test_feature.py index 87409c5798..949ce74939 100644 --- a/src/blenderbim/test/bim/test_feature.py +++ b/src/blenderbim/test/bim/test_feature.py @@ -629,18 +629,6 @@ def i_display_the_construction_type_browser(): bpy.ops.bim.display_constr_types("INVOKE_DEFAULT") -@given("I preview only one asset on the construction type browser") -@when("I preview only one asset on the construction type browser") -def i_preview_one_construction_type(): - bpy.context.scene.BIMModelProperties.unfold_relating_types = False - - -@given("I preview all available assets on the construction type browser") -@when("I preview all available assets on the construction type browser") -def i_preview_all_construction_types(): - bpy.context.scene.BIMModelProperties.unfold_relating_types = True - - @given("I add the construction type") @when("I add the construction type") def i_add_the_active_construction_type():