Merge pull request #29173 from jgenunez/issue/28911-stairs-railing-visibility
BIM: keep stair railings in sync with stairs visibility
This commit is contained in:
@@ -2456,6 +2456,21 @@ class _ViewProviderStairs(ArchComponent.ViewProviderComponent):
|
||||
|
||||
return ":/icons/Arch_Stairs_Tree.svg"
|
||||
|
||||
def onChanged(self, vobj, prop):
|
||||
ArchComponent.ViewProviderComponent.onChanged(self, vobj, prop)
|
||||
|
||||
if prop != "Visibility":
|
||||
return
|
||||
|
||||
obj = getattr(vobj, "Object", None)
|
||||
if not obj:
|
||||
return
|
||||
|
||||
for railing_name in ("RailingLeft", "RailingRight"):
|
||||
railing = getattr(obj, railing_name, None)
|
||||
if railing and hasattr(railing, "ViewObject"):
|
||||
railing.ViewObject.Visibility = vobj.Visibility
|
||||
|
||||
def claimChildren(self):
|
||||
"Define which objects will appear as children in the tree view"
|
||||
|
||||
|
||||
@@ -254,6 +254,7 @@ SET(bimtests_SRCS
|
||||
bimtests/TestWebGLExportGui.py
|
||||
bimtests/TestArchImportersGui.py
|
||||
bimtests/TestArchBuildingPartGui.py
|
||||
bimtests/TestArchStairsGui.py
|
||||
bimtests/TestArchReport.py
|
||||
bimtests/TestArchReportGui.py
|
||||
)
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
from bimtests.TestArchImportersGui import TestArchImportersGui
|
||||
from bimtests.TestArchAxisGui import TestArchAxisGui
|
||||
from bimtests.TestArchBuildingPartGui import TestArchBuildingPartGui
|
||||
from bimtests.TestArchStairsGui import TestArchStairsGui
|
||||
from bimtests.TestArchReportGui import TestArchReportGui
|
||||
from bimtests.TestArchSiteGui import TestArchSiteGui
|
||||
from bimtests.TestArchWallGui import TestArchWallGui
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
# ***************************************************************************
|
||||
# * *
|
||||
# * Copyright (c) 2026 FreeCAD contributors *
|
||||
# * *
|
||||
# * This file is part of FreeCAD. *
|
||||
# * *
|
||||
# * FreeCAD is free software: you can redistribute it and/or modify it *
|
||||
# * under the terms of the GNU Lesser General Public License as *
|
||||
# * published by the Free Software Foundation, either version 2.1 of the *
|
||||
# * License, or (at your option) any later version. *
|
||||
# * *
|
||||
# * FreeCAD is distributed in the hope that it will be useful, but *
|
||||
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
# * Lesser General Public License for more details. *
|
||||
# * *
|
||||
# * You should have received a copy of the GNU Lesser General Public *
|
||||
# * License along with FreeCAD. If not, see *
|
||||
# * <https://www.gnu.org/licenses/>. *
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
|
||||
import Arch
|
||||
|
||||
from bimtests.TestArchBaseGui import TestArchBaseGui
|
||||
|
||||
|
||||
class TestArchStairsGui(TestArchBaseGui):
|
||||
|
||||
def _assert_visibility(self, stairs, expected):
|
||||
self.assertEqual(stairs.ViewObject.Visibility, expected)
|
||||
for railing in (stairs.RailingLeft, stairs.RailingRight):
|
||||
self.assertIsNotNone(railing)
|
||||
self.assertEqual(railing.ViewObject.Visibility, expected)
|
||||
|
||||
def test_stairs_railings_follow_parent_visibility(self):
|
||||
stairs = Arch.makeStairs(length=3500, width=800, height=2500, steps=14)
|
||||
self.document.recompute()
|
||||
|
||||
self.assertIsNotNone(stairs.RailingLeft)
|
||||
self.assertIsNotNone(stairs.RailingRight)
|
||||
self._assert_visibility(stairs, True)
|
||||
|
||||
stairs.ViewObject.Visibility = False
|
||||
self.pump_gui_events()
|
||||
self.document.recompute()
|
||||
self._assert_visibility(stairs, False)
|
||||
|
||||
stairs.ViewObject.Visibility = True
|
||||
self.pump_gui_events()
|
||||
self.document.recompute()
|
||||
self._assert_visibility(stairs, True)
|
||||
|
||||
level = Arch.makeBuildingPart()
|
||||
level.Group = [stairs]
|
||||
self.document.recompute()
|
||||
|
||||
level.ViewObject.Visibility = False
|
||||
self.pump_gui_events()
|
||||
self.document.recompute()
|
||||
self._assert_visibility(stairs, False)
|
||||
|
||||
level.ViewObject.Visibility = True
|
||||
self.pump_gui_events()
|
||||
self.document.recompute()
|
||||
self._assert_visibility(stairs, True)
|
||||
Reference in New Issue
Block a user