Skip to content

Commit

Permalink
Gui: Reduce cognitive complexity of ViewProviderCoordinateSystem::set…
Browse files Browse the repository at this point in the history
…TemporaryVisibility
  • Loading branch information
wwmayer committed Dec 30, 2024
1 parent 8d4ddac commit 63088a2
Showing 1 changed file with 15 additions and 25 deletions.
40 changes: 15 additions & 25 deletions src/Gui/ViewProviderCoordinateSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<App::Origin*>( getObject() );
void ViewProviderCoordinateSystem::setTemporaryVisibility(bool axis, bool plane, bool points)
{
auto origin = getObject<App::Origin>();

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() );
Expand Down

0 comments on commit 63088a2

Please sign in to comment.