diff --git a/ApplicationComponents/SaveAndLoadLidarState/lqLoadLidarStateReaction.cxx b/ApplicationComponents/SaveAndLoadLidarState/lqLoadLidarStateReaction.cxx index 41ae3f8b28323f2c8db64aafcadc6c7564dfaccd..512d1bc2f58db82a3fef3e60aaaf3bd145a7e328 100644 --- a/ApplicationComponents/SaveAndLoadLidarState/lqLoadLidarStateReaction.cxx +++ b/ApplicationComponents/SaveAndLoadLidarState/lqLoadLidarStateReaction.cxx @@ -91,6 +91,14 @@ void lqLoadLidarStateReaction::onTriggered() std::string propertyName = currentProp.propertyName; vtkSMProxy* lidarProxy = SearchProxyByName(lidarCurrentProxy, proxyName); + // If the proxy is not found, search proxy from the same proxygroup + // ex : Apply a property from an other LidarPacketInterpreter to the current one + if (lidarProxy == nullptr) + { + std::string proxyGroupName = GetGroupName(lidarCurrentProxy, proxyName); + lidarProxy = SearchProxyByGroupName(lidarCurrentProxy, proxyGroupName); + } + if (lidarProxy == nullptr) { std::string message = "No matching proxy found. Property " + propertyName + " of the proxy " + proxyName + " not applied"; diff --git a/ApplicationComponents/lqHelper.cxx b/ApplicationComponents/lqHelper.cxx index 0d2fb69b9bf03d3cd72168facb3d30ab85847902..361a6bd0dc7af516eb873a19cb3a5688bbcd13fa 100644 --- a/ApplicationComponents/lqHelper.cxx +++ b/ApplicationComponents/lqHelper.cxx @@ -6,9 +6,13 @@ #include "vtkLidarReader.h" #include "vtkLidarStream.h" +#include <vtkSMSessionProxyManager.h> #include <vtkSMBooleanDomain.h> #include <vtkSMPropertyIterator.h> #include <vtkSMPropertyHelper.h> +#include <vtkSMProxyDefinitionManager.h> +#include <vtkSMSessionProxyManager.h> +#include <vtkPVProxyDefinitionIterator.h> #include <pqApplicationCore.h> #include <pqPipelineSource.h> @@ -206,3 +210,34 @@ void UpdateProperty(vtkSMProxy * proxy, const std::string &propNameToFind, } } } + +//----------------------------------------------------------------------------- +std::string GetGroupName(vtkSMProxy * existingProxy, const std::string & proxyToFindName) +{ + vtkSMSessionProxyManager* pxm = existingProxy->GetSessionProxyManager(); + + if(!pxm) + { + std::cout << "Couldn't get the SM Session Proxy Manager" << std::endl; + return ""; + } + + vtkSMProxyDefinitionManager* pxdm = pxm->GetProxyDefinitionManager(); + + if(!pxdm) + { + std::cout << "Couldn't get the SM Proxy Definition Manager" << std::endl; + return ""; + } + + vtkPVProxyDefinitionIterator* iter = pxdm->NewIterator(); + for (iter->InitTraversal(); !iter->IsDoneWithTraversal(); iter->GoToNextItem()) + { + if(strcmp(iter->GetProxyName(), proxyToFindName.c_str()) == 0) + { + return iter->GetGroupName(); + } + } + return ""; +} + diff --git a/ApplicationComponents/lqHelper.h b/ApplicationComponents/lqHelper.h index 66f3d47d10ff0f151cb594b830cef9f65c280e31..6c068de9ca50ef820768405830d17a9688384051 100644 --- a/ApplicationComponents/lqHelper.h +++ b/ApplicationComponents/lqHelper.h @@ -60,4 +60,12 @@ vtkSMProperty* GetPropertyFromProxy(vtkSMProxy * proxy, const std::string &propN void UpdateProperty(vtkSMProxy * proxy, const std::string & propNameToFind, const std::vector<std::string> & values); +/** + * @brief GetGroupName Get the name of the first group where appear a proxy + * @param existingProxy a proxy of the pipeline, use to get the ProxyDefinitionManager + * @param proxyToFindName name of the proxy to look for + * @return the name of the first group where a corresponding proxy is found + */ +std::string GetGroupName(vtkSMProxy * existingProxy, const std::string & proxyToFindName); + #endif // LQHELPER_H