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

Method refreshPluginSelectorKnob

Engine/WriteNode.cpp:884–929  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

882} // WriteNodePrivate::createWriteNode
883
884void
885WriteNodePrivate::refreshPluginSelectorKnob()
886{
887 boost::shared_ptr<KnobOutputFile> fileKnob = outputFileKnob.lock();
888
889 assert(fileKnob);
890 std::string filePattern = fileKnob->getValue();
891 std::vector<ChoiceOption> entries;
892 entries.push_back(ChoiceOption(kPluginSelectorParamEntryDefault, "", tr("Use the default plug-in chosen from the Preferences to write this file format").toStdString()));
893
894 QString qpattern = QString::fromUtf8( filePattern.c_str() );
895 std::string ext = QtCompat::removeFileExtension(qpattern).toLower().toStdString();
896 std::string pluginID;
897 if ( !ext.empty() ) {
898 pluginID = appPTR->getWriterPluginIDForFileType(ext);
899 IOPluginSetForFormat writersForFormat;
900 appPTR->getWritersForFormat(ext, &writersForFormat);
901
902 // Reverse it so that we sort them by decreasing score order
903 for (IOPluginSetForFormat::reverse_iterator it = writersForFormat.rbegin(); it != writersForFormat.rend(); ++it) {
904 Plugin* plugin = appPTR->getPluginBinary(QString::fromUtf8( it->pluginID.c_str() ), -1, -1, false);
905 std::stringstream ss;
906 ss << "Use " << plugin->getPluginLabel().toStdString() << " version ";
907 ss << plugin->getMajorVersion() << "." << plugin->getMinorVersion();
908 ss << " to write this file format";
909 entries.push_back( ChoiceOption(plugin->getPluginID().toStdString(), "", ss.str()));
910 }
911 }
912
913 boost::shared_ptr<KnobChoice> pluginChoice = pluginSelectorKnob.lock();
914
915 pluginChoice->populateChoices(entries);
916 pluginChoice->blockValueChanges();
917 pluginChoice->resetToDefaultValue(0);
918 pluginChoice->unblockValueChanges();
919 if (entries.size() <= 2) {
920 pluginChoice->setSecret(true);
921 } else {
922 pluginChoice->setSecret(false);
923 }
924
925 boost::shared_ptr<KnobString> pluginIDKnob = pluginIDStringKnob.lock();
926 pluginIDKnob->blockValueChanges();
927 pluginIDKnob->setValue(pluginID);
928 pluginIDKnob->unblockValueChanges();
929}
930
931bool
932WriteNode::isWriter() const

Callers 3

onEffectCreatedMethod · 0.45
knobChangedMethod · 0.45

Calls 15

ChoiceOptionFunction · 0.85
removeFileExtensionFunction · 0.85
toStdStringMethod · 0.80
emptyMethod · 0.80
getWritersForFormatMethod · 0.80
getPluginBinaryMethod · 0.80
populateChoicesMethod · 0.80
blockValueChangesMethod · 0.80
resetToDefaultValueMethod · 0.80
unblockValueChangesMethod · 0.80
lockMethod · 0.45

Tested by

no test coverage detected