Skip to content
Snippets Groups Projects
Commit a11a9010 authored by MelanieCarriere's avatar MelanieCarriere
Browse files

[fix] Allow applying a property to a proxy of the same group in LoadLidarState

During loadLidarState function, the property was applied only if a proxy of the same name of the one saved was found in the pipeline.
For exemple :
If you save the LidarState with a LidarPacketInterpreter i1 and you open a file using a LidarPacketInterpreter i2
The properties saved from i1 couldn't be applied to i2.
This commit allows applying the property to a proxy of the same group.

If the property is not found in this proxy, the message is still display to the user.
parent 73e40f4f
No related branches found
No related tags found
1 merge request!149[fix] Allow applying a property to a proxy of the same group in LoadLidarState
Pipeline #202108 failed
Pipeline: LidarView

#202109

    ...@@ -91,6 +91,14 @@ void lqLoadLidarStateReaction::onTriggered() ...@@ -91,6 +91,14 @@ void lqLoadLidarStateReaction::onTriggered()
    std::string propertyName = currentProp.propertyName; std::string propertyName = currentProp.propertyName;
    vtkSMProxy* lidarProxy = SearchProxyByName(lidarCurrentProxy, proxyName); 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) if (lidarProxy == nullptr)
    { {
    std::string message = "No matching proxy found. Property " + propertyName + " of the proxy " + proxyName + " not applied"; std::string message = "No matching proxy found. Property " + propertyName + " of the proxy " + proxyName + " not applied";
    ......
    ...@@ -6,9 +6,13 @@ ...@@ -6,9 +6,13 @@
    #include "vtkLidarReader.h" #include "vtkLidarReader.h"
    #include "vtkLidarStream.h" #include "vtkLidarStream.h"
    #include <vtkSMSessionProxyManager.h>
    #include <vtkSMBooleanDomain.h> #include <vtkSMBooleanDomain.h>
    #include <vtkSMPropertyIterator.h> #include <vtkSMPropertyIterator.h>
    #include <vtkSMPropertyHelper.h> #include <vtkSMPropertyHelper.h>
    #include <vtkSMProxyDefinitionManager.h>
    #include <vtkSMSessionProxyManager.h>
    #include <vtkPVProxyDefinitionIterator.h>
    #include <pqApplicationCore.h> #include <pqApplicationCore.h>
    #include <pqPipelineSource.h> #include <pqPipelineSource.h>
    ...@@ -206,3 +210,34 @@ void UpdateProperty(vtkSMProxy * proxy, const std::string &propNameToFind, ...@@ -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 "";
    }
    ...@@ -60,4 +60,12 @@ vtkSMProperty* GetPropertyFromProxy(vtkSMProxy * proxy, const std::string &propN ...@@ -60,4 +60,12 @@ vtkSMProperty* GetPropertyFromProxy(vtkSMProxy * proxy, const std::string &propN
    void UpdateProperty(vtkSMProxy * proxy, const std::string & propNameToFind, void UpdateProperty(vtkSMProxy * proxy, const std::string & propNameToFind,
    const std::vector<std::string> & values); 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 #endif // LQHELPER_H
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment