Skip to content

Commit 5a73716

Browse files
authored
Add syntaxForAddingRequiredPlugin function (#344)
1 parent 5977aa4 commit 5a73716

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

Plugin/src/SofaPython3/SceneLoaderPY3.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@ void SceneLoaderPY3::getExtensionList(ExtensionList* list)
7474
list->push_back("py");
7575
}
7676

77+
bool SceneLoaderPY3::syntaxForAddingRequiredPlugin(const std::string& pluginName,
78+
const std::vector<std::string>& listComponents, std::ostream& ss, sofa::simulation::Node* nodeWhereAdded)
79+
{
80+
ss << nodeWhereAdded->getName() << ".addObject('RequiredPlugin', name='" << pluginName << "')";
81+
if (!listComponents.empty())
82+
{
83+
ss << " # Needed to use components [" << sofa::helper::join(listComponents, ',');
84+
}
85+
ss << "]" << msgendl;
86+
return true;
87+
}
88+
7789
sofa::simulation::Node::SPtr SceneLoaderPY3::doLoad(const std::string& filename, const std::vector<std::string>& sceneArgs)
7890
{
7991
sofa::simulation::Node::SPtr root = sofa::simulation::Node::create("root");
@@ -100,7 +112,7 @@ void SceneLoaderPY3::loadSceneWithArguments(const char *filename,
100112

101113
if(!py::hasattr(module, "createScene"))
102114
{
103-
msg_error() << "Missing createScene function";
115+
msg_error("SofaPython3") << "Missing createScene function";
104116
return ;
105117
}
106118

Plugin/src/SofaPython3/SceneLoaderPY3.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ class SOFAPYTHON3_API SceneLoaderPY3 : public SceneLoader
5858

5959
/// get the list of file extensions
6060
virtual void getExtensionList(ExtensionList* list) override;
61+
62+
bool syntaxForAddingRequiredPlugin(const std::string& pluginName, const std::vector<std::string>& listComponents,
63+
std::ostream& ss, sofa::simulation::Node* nodeWhereAdded) override;
6164
};
6265

6366
} // namespace sofapython3

0 commit comments

Comments
 (0)