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

Method refreshPluginSelectorKnob

Engine/ReadNode.cpp:815–863  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

813}
814
815void
816ReadNodePrivate::refreshPluginSelectorKnob()
817{
818 boost::shared_ptr<KnobFile> fileKnob = inputFileKnob.lock();
819
820 assert(fileKnob);
821 std::string filePattern = fileKnob->getValue();
822 std::vector<ChoiceOption> entries, help;
823 entries.push_back(ChoiceOption(kPluginSelectorParamEntryDefault, "", ReadNode::tr("Use the default plug-in chosen from the Preferences to read this file format").toStdString()));
824
825 QString qpattern = QString::fromUtf8( filePattern.c_str() );
826 std::string ext = QtCompat::removeFileExtension(qpattern).toLower().toStdString();
827 std::string pluginID;
828 if ( !ext.empty() ) {
829 pluginID = appPTR->getReaderPluginIDForFileType(ext);
830 IOPluginSetForFormat readersForFormat;
831 appPTR->getReadersForFormat(ext, &readersForFormat);
832
833 // Reverse it so that we sort them by decreasing score order
834 for (IOPluginSetForFormat::reverse_iterator it = readersForFormat.rbegin(); it != readersForFormat.rend(); ++it) {
835 Plugin* plugin = appPTR->getPluginBinary(QString::fromUtf8( it->pluginID.c_str() ), -1, -1, false);
836 std::stringstream ss;
837 ss << "Use " << plugin->getPluginLabel().toStdString() << " version ";
838 ss << plugin->getMajorVersion() << "." << plugin->getMinorVersion();
839 ss << " to read this file format";
840 entries.push_back( ChoiceOption(plugin->getPluginID().toStdString(), "", ss.str()));
841 }
842 }
843
844 boost::shared_ptr<KnobChoice> pluginChoice = pluginSelectorKnob.lock();
845
846 pluginChoice->populateChoices(entries);
847 pluginChoice->blockValueChanges();
848 pluginChoice->resetToDefaultValue(0);
849 pluginChoice->unblockValueChanges();
850 if (entries.size() <= 2) {
851 pluginChoice->setSecret(true);
852 } else {
853 pluginChoice->setSecret(false);
854 }
855
856 boost::shared_ptr<KnobString> pluginIDKnob = pluginIDStringKnob.lock();
857 pluginIDKnob->blockValueChanges();
858 pluginIDKnob->setValue(pluginID);
859 pluginIDKnob->unblockValueChanges();
860
861 refreshFileInfoVisibility(pluginID);
862
863} // ReadNodePrivate::refreshPluginSelectorKnob
864
865bool
866ReadNode::isReader() const

Callers 3

onEffectCreatedMethod · 0.45
knobChangedMethod · 0.45

Calls 15

ChoiceOptionFunction · 0.85
removeFileExtensionFunction · 0.85
toStdStringMethod · 0.80
emptyMethod · 0.80
getReadersForFormatMethod · 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