| 971 | } |
| 972 | |
| 973 | NodePtr |
| 974 | AppInstance::createReader(const std::string& filename, |
| 975 | CreateNodeArgs& args) |
| 976 | { |
| 977 | std::string pluginID; |
| 978 | |
| 979 | #ifndef NATRON_ENABLE_IO_META_NODES |
| 980 | |
| 981 | std::map<std::string, std::string> readersForFormat; |
| 982 | appPTR->getCurrentSettings()->getFileFormatsForReadingAndReader(&readersForFormat); |
| 983 | QString fileCpy = QString::fromUtf8( filename.c_str() ); |
| 984 | QString extq = QtCompat::removeFileExtension(fileCpy).toLower(); |
| 985 | std::string ext = extq.toStdString(); |
| 986 | std::map<std::string, std::string>::iterator found = readersForFormat.find(ext); |
| 987 | if ( found == readersForFormat.end() ) { |
| 988 | Dialogs::errorDialog( tr("Reader").toStdString(), |
| 989 | tr("No plugin capable of decoding %1 was found").arg(extq).toStdString(), false ); |
| 990 | |
| 991 | return NodePtr(); |
| 992 | } |
| 993 | pluginID = found->second; |
| 994 | CreateNodeArgs args(QString::fromUtf8( found->second.c_str() ), reason, group); |
| 995 | #endif |
| 996 | |
| 997 | args.addParamDefaultValue<std::string>(kOfxImageEffectFileParamName, filename); |
| 998 | std::string canonicalFilename = filename; |
| 999 | getProject()->canonicalizePath(canonicalFilename); |
| 1000 | |
| 1001 | int firstFrame, lastFrame; |
| 1002 | Node::getOriginalFrameRangeForReader(pluginID, canonicalFilename, &firstFrame, &lastFrame); |
| 1003 | std::vector<int> originalRange(2); |
| 1004 | originalRange[0] = firstFrame; |
| 1005 | originalRange[1] = lastFrame; |
| 1006 | args.addParamDefaultValueN<int>(kReaderParamNameOriginalFrameRange, originalRange); |
| 1007 | |
| 1008 | return createNode(args); |
| 1009 | } |
| 1010 | |
| 1011 | NodePtr |
| 1012 | AppInstance::createWriter(const std::string& filename, |
no test coverage detected