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

Method createReadNodeAndConnectGraph

Engine/WriteNode.cpp:638–702  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

636}
637
638void
639WriteNodePrivate::createReadNodeAndConnectGraph(const std::string& filename)
640{
641 QString qpattern = QString::fromUtf8( filename.c_str() );
642 std::string ext = QtCompat::removeFileExtension(qpattern).toLower().toStdString();
643 boost::shared_ptr<NodeGroup> isNodeGroup = boost::dynamic_pointer_cast<NodeGroup>( _publicInterface->shared_from_this() );
644 std::string readerPluginID = appPTR->getReaderPluginIDForFileType(ext);
645 NodePtr writeNode = embeddedPlugin.lock();
646
647 readBackNode.reset();
648 if ( !readerPluginID.empty() ) {
649 CreateNodeArgs args(readerPluginID, isNodeGroup );
650 args.setProperty(kCreateNodeArgsPropNoNodeGUI, true);
651 args.setProperty(kCreateNodeArgsPropOutOfProject, true);
652 args.setProperty<std::string>(kCreateNodeArgsPropNodeInitialName, "internalDecoderNode");
653 args.setProperty<bool>(kCreateNodeArgsPropAllowNonUserCreatablePlugins, true);
654
655 //Set a pre-value for the inputfile knob only if it did not exist
656 if ( !filename.empty() ) {
657 args.addParamDefaultValue<std::string>(kOfxImageEffectFileParamName, filename);
658 }
659
660 if (writeNode) {
661 double first, last;
662 writeNode->getEffectInstance()->getFrameRange_public(writeNode->getEffectInstance()->getHash(), &first, &last);
663 std::vector<int> originalRange(2);
664 originalRange[0] = (int)first;
665 originalRange[1] = (int)last;
666 args.addParamDefaultValueN<int>(kReaderParamNameOriginalFrameRange, originalRange);
667 args.addParamDefaultValue<int>(kParamFirstFrame, (int)first);
668 args.addParamDefaultValue<int>(kParamFirstFrame, (int)last);
669 }
670
671
672 readBackNode = _publicInterface->getApp()->createNode(args);
673 }
674
675 NodePtr input = inputNode.lock(), output = outputNode.lock();
676 assert(input && output);
677 bool connectOutputToInput = true;
678 if (writeNode) {
679 writeNode->replaceInput(input, 0);
680 NodePtr readNode = readBackNode.lock();
681 if (readNode) {
682
683 bool readFile = readBackKnob.lock()->getValue();
684 if (readFile) {
685 output->replaceInput(readNode, 0);
686 connectOutputToInput = false;
687 }
688 readNode->replaceInput(input, 0);
689 // sync the output colorspace of the reader from input colorspace of the writer
690
691 KnobPtr outputWriteColorSpace = writeNode->getKnobByName(kOCIOParamOutputSpace);
692 KnobPtr inputReadColorSpace = readNode->getKnobByName(kNatronReadNodeOCIOParamInputSpace);
693 if (inputReadColorSpace && outputWriteColorSpace) {
694 inputReadColorSpace->slaveTo(0, outputWriteColorSpace, 0);
695 }

Callers 1

knobChangedMethod · 0.80

Calls 15

removeFileExtensionFunction · 0.85
toStdStringMethod · 0.80
emptyMethod · 0.80
setPropertyMethod · 0.80
getFrameRange_publicMethod · 0.80
getEffectInstanceMethod · 0.80
replaceInputMethod · 0.80
lockMethod · 0.45
resetMethod · 0.45
getHashMethod · 0.45
createNodeMethod · 0.45

Tested by

no test coverage detected