Fem: Remove pipeline node from analysis view provider - fixes #11175

This commit is contained in:
marioalexis
2024-01-12 20:21:18 -03:00
committed by Chris Hennes
parent f0a734fed0
commit bdb82b8f8a
4 changed files with 43 additions and 10 deletions

View File

@@ -107,18 +107,35 @@ void ViewProviderFemPostPipeline::updateFunctionSize()
}
}
namespace
{
// Function to get the analysis container related to the object
ViewProviderFemAnalysis* getAnalyzeView(App::DocumentObject* obj)
{
ViewProviderFemAnalysis* analyzeView = nullptr;
App::DocumentObject* grp = App::GroupExtension::getGroupOfObject(obj);
if (Fem::FemAnalysis* analyze = Base::freecad_dynamic_cast<Fem::FemAnalysis>(grp)) {
analyzeView = Base::freecad_dynamic_cast<ViewProviderFemAnalysis>(
Gui::Application::Instance->getViewProvider(analyze));
}
return analyzeView;
};
} // namespace
bool ViewProviderFemPostPipeline::onDelete(const std::vector<std::string>& objs)
{
ViewProviderFemAnalysis* analyzeView = getAnalyzeView(this->getObject());
if (analyzeView) {
analyzeView->removeView(this);
}
return ViewProviderFemPostObject::onDelete(objs);
}
void ViewProviderFemPostPipeline::onSelectionChanged(const Gui::SelectionChanges& sel)
{
auto getAnalyzeView = [](App::DocumentObject* obj) {
ViewProviderFemAnalysis* analyzeView = nullptr;
App::DocumentObject* grp = App::GroupExtension::getGroupOfObject(obj);
if (Fem::FemAnalysis* analyze = Base::freecad_dynamic_cast<Fem::FemAnalysis>(grp)) {
analyzeView = Base::freecad_dynamic_cast<ViewProviderFemAnalysis>(
Gui::Application::Instance->getViewProvider(analyze));
}
return analyzeView;
};
// If a FemPostObject is selected in the document tree we must refresh its
// color bar.
// But don't do this if the object is invisible because other objects with a