MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / tryAddProjectFormat

Method tryAddProjectFormat

Engine/Project.cpp:1229–1277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1227}
1228
1229int
1230Project::tryAddProjectFormat(const Format & f, bool* existed)
1231{
1232 //assert( !_imp->formatMutex.tryLock() );
1233 if ( ( f.left() >= f.right() ) || ( f.bottom() >= f.top() ) ) {
1234 return -1;
1235 }
1236
1237 std::list<Format>::iterator foundFormat = std::find(_imp->builtinFormats.begin(), _imp->builtinFormats.end(), f);
1238 if ( foundFormat != _imp->builtinFormats.end() ) {
1239 *existed = true;
1240 return std::distance(_imp->builtinFormats.begin(), foundFormat);
1241 } else {
1242 foundFormat = std::find(_imp->additionalFormats.begin(), _imp->additionalFormats.end(), f);
1243 if ( foundFormat != _imp->additionalFormats.end() ) {
1244 *existed = true;
1245 return std::distance(_imp->additionalFormats.begin(), foundFormat) + _imp->builtinFormats.size();
1246 }
1247 }
1248
1249 std::vector<ChoiceOption> entries;
1250 for (std::list<Format>::iterator it = _imp->builtinFormats.begin(); it != _imp->builtinFormats.end(); ++it) {
1251 const Format & f = *it;
1252 QString formatStr = ProjectPrivate::generateStringFromFormat(f);
1253 if ( !f.getName().empty() ) {
1254 entries.push_back( ChoiceOption(f.getName(), formatStr.toStdString(), "") );
1255 } else {
1256 entries.push_back( ChoiceOption( formatStr.toStdString() ) );
1257 }
1258 }
1259 for (std::list<Format>::iterator it = _imp->additionalFormats.begin(); it != _imp->additionalFormats.end(); ++it) {
1260 const Format & f = *it;
1261 QString formatStr = ProjectPrivate::generateStringFromFormat(f);
1262 if ( !f.getName().empty() ) {
1263 entries.push_back( ChoiceOption(f.getName(), formatStr.toStdString(), "") );
1264 } else {
1265 entries.push_back( ChoiceOption( formatStr.toStdString() ) );
1266 }
1267 }
1268 QString formatStr = ProjectPrivate::generateStringFromFormat(f);
1269 _imp->additionalFormats.push_back(f);
1270 if ( !f.getName().empty() ) {
1271 _imp->formatKnob->appendChoice( ChoiceOption(f.getName(), formatStr.toStdString(), "") );
1272 } else {
1273 _imp->formatKnob->appendChoice( ChoiceOption( formatStr.toStdString() ) );
1274 }
1275
1276 return ( _imp->builtinFormats.size() + _imp->additionalFormats.size() ) - 1;
1277}
1278
1279void
1280Project::setProjectDefaultFormat(const Format & f)

Callers

nothing calls this directly

Calls 14

generateStringFromFormatFunction · 0.85
ChoiceOptionFunction · 0.85
emptyMethod · 0.80
getNameMethod · 0.80
toStdStringMethod · 0.80
appendChoiceMethod · 0.80
leftMethod · 0.45
rightMethod · 0.45
bottomMethod · 0.45
topMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected