MCPcopy Create free account
hub / github.com/MrKepzie/Natron / createNodeFromPythonModule

Method createNodeFromPythonModule

Engine/AppInstance.cpp:847–943  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

845};
846
847NodePtr
848AppInstance::createNodeFromPythonModule(Plugin* plugin,
849 const CreateNodeArgs& args)
850
851{
852 /*If the plug-in is a toolset, execute the toolset script and don't actually create a node*/
853 bool istoolsetScript = plugin->getToolsetScript();
854 NodePtr node;
855
856 boost::shared_ptr<NodeSerialization> serialization = args.getProperty<boost::shared_ptr<NodeSerialization> >(kCreateNodeArgsPropNodeSerialization);
857 boost::shared_ptr<NodeCollection> group = args.getProperty<boost::shared_ptr<NodeCollection> >(kCreateNodeArgsPropGroupContainer);
858 {
859 FlagIncrementer fs(&_imp->_creatingGroup, &_imp->creatingGroupMutex);
860 if (_imp->_creatingGroup == 1) {
861 bool createGui = !args.getProperty<bool>(kCreateNodeArgsPropNoNodeGUI) && !args.getProperty<bool>(kCreateNodeArgsPropOutOfProject);
862 _imp->_creatingInternalNode = !createGui;
863 }
864 CreatingNodeTreeFlag_RAII createNodeTree( shared_from_this() );
865 NodePtr containerNode;
866 if (!istoolsetScript) {
867 CreateNodeArgs groupArgs = args;
868 groupArgs.setProperty<std::string>(kCreateNodeArgsPropPluginID,PLUGINID_NATRON_GROUP);
869 groupArgs.setProperty<bool>(kCreateNodeArgsPropNodeGroupDisableCreateInitialNodes, true);
870 containerNode = createNode(groupArgs);
871 if (!containerNode) {
872 return containerNode;
873 }
874
875 if (!serialization && args.getProperty<std::string>(kCreateNodeArgsPropNodeInitialName).empty()) {
876 std::string containerName;
877 try {
878 if (group) {
879 group->initNodeName(plugin->getLabelWithoutSuffix().toStdString(), &containerName);
880 }
881 containerNode->setScriptName(containerName);
882 containerNode->setLabel(containerName);
883 } catch (...) {
884 }
885 }
886 }
887
888 AddCreateNode_RAII creatingNode_raii(_imp.get(), containerNode);
889 std::string containerFullySpecifiedName;
890 if (containerNode) {
891 containerFullySpecifiedName = containerNode->getFullyQualifiedName();
892 }
893
894
895 QString moduleName;
896 QString modulePath;
897 plugin->getPythonModuleNameAndPath(&moduleName, &modulePath);
898
899 int appID = getAppID() + 1;
900 std::stringstream ss;
901 ss << moduleName.toStdString();
902 ss << ".createInstance(app" << appID;
903 if (istoolsetScript) {
904 ss << ",\"\"";

Callers

nothing calls this directly

Calls 12

getToolsetScriptMethod · 0.80
emptyMethod · 0.80
initNodeNameMethod · 0.80
toStdStringMethod · 0.80
destroyNodeMethod · 0.80
loadKnobsMethod · 0.80
setScriptNameMethod · 0.45
setLabelMethod · 0.45
getMethod · 0.45
getFullyQualifiedNameMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected