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