| 702 | } // WriteNodePrivate::createReadNodeAndConnectGraph |
| 703 | |
| 704 | void |
| 705 | WriteNodePrivate::createWriteNode(bool throwErrors, |
| 706 | const std::string& filename, |
| 707 | const boost::shared_ptr<NodeSerialization>& serialization) |
| 708 | { |
| 709 | if (creatingWriteNode) { |
| 710 | return; |
| 711 | } |
| 712 | |
| 713 | boost::shared_ptr<NodeGroup> isNodeGroup = boost::dynamic_pointer_cast<NodeGroup>( _publicInterface->shared_from_this() ); |
| 714 | NodePtr input = inputNode.lock(), output = outputNode.lock(); |
| 715 | //NodePtr maskInput; |
| 716 | assert( (input && output) || (!input && !output) ); |
| 717 | if (!output) { |
| 718 | CreateNodeArgs args(PLUGINID_NATRON_OUTPUT, isNodeGroup); |
| 719 | args.setProperty(kCreateNodeArgsPropNoNodeGUI, true); |
| 720 | args.setProperty(kCreateNodeArgsPropOutOfProject, true); |
| 721 | args.setProperty<bool>(kCreateNodeArgsPropAllowNonUserCreatablePlugins, true); |
| 722 | output = _publicInterface->getApp()->createNode(args); |
| 723 | try { |
| 724 | output->setScriptName("Output"); |
| 725 | } catch (...) { |
| 726 | } |
| 727 | |
| 728 | assert(output); |
| 729 | outputNode = output; |
| 730 | } |
| 731 | if (!input) { |
| 732 | CreateNodeArgs args(PLUGINID_NATRON_INPUT, isNodeGroup); |
| 733 | args.setProperty(kCreateNodeArgsPropNoNodeGUI, true); |
| 734 | args.setProperty(kCreateNodeArgsPropOutOfProject, true); |
| 735 | args.setProperty<std::string>(kCreateNodeArgsPropNodeInitialName, "Source"); |
| 736 | args.setProperty<bool>(kCreateNodeArgsPropAllowNonUserCreatablePlugins, true); |
| 737 | input = _publicInterface->getApp()->createNode(args); |
| 738 | assert(input); |
| 739 | inputNode = input; |
| 740 | } |
| 741 | |
| 742 | SetCreatingWriterRAIIFlag creatingNode__(this); |
| 743 | QString qpattern = QString::fromUtf8( filename.c_str() ); |
| 744 | std::string ext = QtCompat::removeFileExtension(qpattern).toLower().toStdString(); |
| 745 | boost::shared_ptr<KnobString> pluginIDKnob = pluginIDStringKnob.lock(); |
| 746 | std::string writerPluginID = pluginIDKnob->getValue(); |
| 747 | |
| 748 | if ( writerPluginID.empty() ) { |
| 749 | boost::shared_ptr<KnobChoice> pluginChoiceKnob = pluginSelectorKnob.lock(); |
| 750 | int pluginChoice_i = pluginChoiceKnob->getValue(); |
| 751 | if (pluginChoice_i == 0) { |
| 752 | //Use default |
| 753 | writerPluginID = appPTR->getWriterPluginIDForFileType(ext); |
| 754 | } else { |
| 755 | std::vector<ChoiceOption> entries = pluginChoiceKnob->getEntries_mt_safe(); |
| 756 | if ( (pluginChoice_i >= 0) && ( pluginChoice_i < (int)entries.size() ) ) { |
| 757 | writerPluginID = entries[pluginChoice_i].id; |
| 758 | } |
| 759 | } |
| 760 | } |
| 761 |
no test coverage detected