From 63088a29a9d4d8a1a3bf1b6b765b21866dca72c0 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 30 Dec 2024 19:03:58 +0100 Subject: [PATCH] Gui: Reduce cognitive complexity of ViewProviderCoordinateSystem::setTemporaryVisibility --- src/Gui/ViewProviderCoordinateSystem.cpp | 40 +++++++++--------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/src/Gui/ViewProviderCoordinateSystem.cpp b/src/Gui/ViewProviderCoordinateSystem.cpp index 1d3fb7eaf14a..8333b1e76e5f 100644 --- a/src/Gui/ViewProviderCoordinateSystem.cpp +++ b/src/Gui/ViewProviderCoordinateSystem.cpp @@ -97,51 +97,41 @@ void ViewProviderCoordinateSystem::setDisplayMode(const char* ModeName) ViewProviderDocumentObject::setDisplayMode(ModeName); } -void ViewProviderCoordinateSystem::setTemporaryVisibility(bool axis, bool plane, bool points) { - auto origin = static_cast( getObject() ); +void ViewProviderCoordinateSystem::setTemporaryVisibility(bool axis, bool plane, bool points) +{ + auto origin = getObject(); bool saveState = tempVisMap.empty(); try { // Remember & Set axis visibility for(App::DocumentObject* obj : origin->axes()) { - if (obj) { - Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider(obj); - if(vp) { - if (saveState) { - tempVisMap[vp] = vp->isVisible(); - } - vp->setVisible(axis); + if (auto vp = Gui::Application::Instance->getViewProvider(obj)) { + if (saveState) { + tempVisMap[vp] = vp->isVisible(); } + vp->setVisible(axis); } } // Remember & Set plane visibility for(App::DocumentObject* obj : origin->planes()) { - if (obj) { - Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider(obj); - if(vp) { - if (saveState) { - tempVisMap[vp] = vp->isVisible(); - } - vp->setVisible(plane); + if (auto vp = Gui::Application::Instance->getViewProvider(obj)) { + if (saveState) { + tempVisMap[vp] = vp->isVisible(); } + vp->setVisible(plane); } } // Remember & Set origin point visibility App::DocumentObject* obj = origin->getOrigin(); - if (obj) { - Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider(obj); - if (vp) { - if (saveState) { - tempVisMap[vp] = vp->isVisible(); - } - vp->setVisible(points); + if (auto vp = Gui::Application::Instance->getViewProvider(obj)) { + if (saveState) { + tempVisMap[vp] = vp->isVisible(); } + vp->setVisible(points); } - - } catch (const Base::Exception &ex) { Base::Console().Error ("%s\n", ex.what() );