From 756d60d3df53e185a13676260554bbc65df279be Mon Sep 17 00:00:00 2001 From: tetektoza Date: Tue, 13 May 2025 00:55:57 +0200 Subject: [PATCH] BIM: Additional improvements for Activate button in BIM Views This patch introduces a few things: - changes Activate button to be first in the list - puts it in bold text, also adding (Default) to point it is default action - removes all of the hiding logic upon double click and leaving Activate by default to be called after double-clicking a BuildingPart --- src/Mod/BIM/bimcommands/BimViews.py | 57 +++++++---------------------- 1 file changed, 14 insertions(+), 43 deletions(-) diff --git a/src/Mod/BIM/bimcommands/BimViews.py b/src/Mod/BIM/bimcommands/BimViews.py index 4a9dcf4b28..d708fe5363 100644 --- a/src/Mod/BIM/bimcommands/BimViews.py +++ b/src/Mod/BIM/bimcommands/BimViews.py @@ -86,15 +86,22 @@ class BIM_Views: # set button self.dialog.menu = QtGui.QMenu() - for button in [("AddLevel", translate("BIM","Add level")), + for button in [("Activate", translate("BIM","Activate (default)")), + ("AddLevel", translate("BIM","Add level")), ("AddProxy", translate("BIM","Add proxy")), ("Delete", translate("BIM","Delete")), ("Toggle", translate("BIM","Toggle on/off")), ("Isolate", translate("BIM","Isolate")), ("SaveView", translate("BIM","Save view position")), - ("Rename", translate("BIM","Rename")), - ("Activate", translate("BIM","Activate"))]: + ("Rename", translate("BIM","Rename"))]: action = QtGui.QAction(button[1]) + + # Make the "Activate" button bold, as this is the default one + if button[0] == "Activate": + font = action.font() + font.setBold(True) + action.setFont(font) + self.dialog.menu.addAction(action) setattr(self.dialog,"button"+button[0], action) @@ -423,8 +430,8 @@ class BIM_Views: if vm.tree.selectedItems(): item = vm.tree.selectedItems()[-1] vm.tree.editItem(item, 0) - - def activate(self, item): + @staticmethod + def activate(): vm = findWidget() if vm: if vm.tree.selectedItems(): @@ -595,7 +602,6 @@ def findWidget(): def show(item, column=None): "item has been double-clicked" - import Draft obj = None @@ -648,43 +654,8 @@ def show(item, column=None): vparam.SetBool("Gradient", False) vparam.SetBool("RadialGradient", False) else: - - # case 3: This is maybe a BuildingPart. Place the WP on it - FreeCADGui.runCommand("Draft_SelectPlane") - if PARAMS.GetBool("BimViewsSwitchBackground", False): - vparam.SetBool("Simple", False) - vparam.SetBool("Gradient", False) - vparam.SetBool("RadialGradient", True) - if Draft.getType(obj) == "BuildingPart": - if obj.IfcType == "Building Storey": - # hide all other storeys - obj.ViewObject.Visibility = True - bldgs = [o for o in obj.InList if Draft.getType(o) == "BuildingPart" and o.IfcType == "Building"] - if len(bldgs) == 1: - bldg = bldgs[0] - storeys = [o for o in bldg.OutList if Draft.getType(o) == "BuildingPart" and o.IfcType == "Building Storey"] - for storey in storeys: - if storey != obj: - storey.ViewObject.Visibility = False - elif obj.IfcType == "Building": - # show all storeys - storeys = [o for o in obj.OutList if Draft.getType(o) == "BuildingPart" and o.IfcType == "Building Storey"] - for storey in storeys: - storey.ViewObject.Visibility = True - elif Draft.getType(obj) == "IfcBuildingStorey": - obj.ViewObject.Visibility = True - bldgs = [o for o in obj.InList if Draft.getType(o) == "IfcBuilding"] - if len(bldgs) == 1: - bldg = bldgs[0] - storeys = [o for o in bldg.OutList if Draft.getType(o) == "IfcBuildingStorey"] - for storey in storeys: - if storey != obj: - storey.ViewObject.Visibility = False - elif hasattr(obj, "IfcType") and obj.IfcType == "IfcBuilding": - # show all storeys - storeys = [o for o in obj.OutList if Draft.getType(o) == "IfcBuildingStorey"] - for storey in storeys: - storey.ViewObject.Visibility = True + # case 3: This is maybe a BuildingPart. Place the WP on it") + BIM_Views.activate() # perform stored interactions if getattr(obj.ViewObject, "SetWorkingPlane", False):