Gui: Reduce code duplication in ViewProviderCoordinateSystem

This commit is contained in:
wmayer
2024-12-30 18:42:50 +01:00
parent 72cfd14768
commit 8d4ddac85e
2 changed files with 20 additions and 12 deletions

View File

@@ -183,30 +183,31 @@ void ViewProviderCoordinateSystem::setPlaneLabelVisibility(bool val)
}
void ViewProviderCoordinateSystem::setTemporaryScale(double factor)
void ViewProviderCoordinateSystem::applyDatumObjects(const DatumObjectFunc& func)
{
auto lcs = getObject<App::LocalCoordinateSystem>();
auto& objs = lcs->OriginFeatures.getValues();
const auto& objs = lcs->OriginFeatures.getValues();
for (auto* obj : objs) {
auto* vp = dynamic_cast<Gui::ViewProviderDatum*>(
Gui::Application::Instance->getViewProvider(obj));
if (vp) {
vp->setTemporaryScale(factor);
func(vp);
}
}
}
void ViewProviderCoordinateSystem::setTemporaryScale(double factor)
{
applyDatumObjects([factor](ViewProviderDatum* vp) {
vp->setTemporaryScale(factor);
});
}
void ViewProviderCoordinateSystem::resetTemporarySize()
{
auto lcs = getObject<App::LocalCoordinateSystem>();
auto& objs = lcs->OriginFeatures.getValues();
for (auto* obj : objs) {
auto* vp = dynamic_cast<Gui::ViewProviderDatum*>(
Gui::Application::Instance->getViewProvider(obj));
if (vp) {
vp->resetTemporarySize();
}
}
applyDatumObjects([](ViewProviderDatum* vp) {
vp->resetTemporarySize();
});
}
void ViewProviderCoordinateSystem::updateData(const App::Property* prop) {