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

Method getWritersWorkForCL

Engine/AppInstance.cpp:451–521  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

449}
450
451void
452AppInstance::getWritersWorkForCL(const CLArgs& cl,
453 std::list<AppInstance::RenderWork>& requests)
454{
455 const std::list<CLArgs::WriterArg>& writers = cl.getWriterArgs();
456
457 for (std::list<CLArgs::WriterArg>::const_iterator it = writers.begin(); it != writers.end(); ++it) {
458 NodePtr writerNode;
459 if (!it->mustCreate) {
460 std::string writerName = it->name.toStdString();
461 writerNode = getNodeByFullySpecifiedName(writerName);
462
463 if (!writerNode) {
464 QString s = tr("%1 does not belong to the project file. Please enter a valid Write node script-name.").arg(it->name);
465 throw std::invalid_argument( s.toStdString() );
466 } else {
467 if ( !writerNode->isOutputNode() ) {
468 QString s = tr("%1 is not an output node! It cannot render anything.").arg(it->name);
469 throw std::invalid_argument( s.toStdString() );
470 }
471 }
472
473 if ( !it->filename.isEmpty() ) {
474 KnobIPtr fileKnob = writerNode->getKnobByName(kOfxImageEffectFileParamName);
475 if (fileKnob) {
476 KnobOutputFile* outFile = dynamic_cast<KnobOutputFile*>( fileKnob.get() );
477 if (outFile) {
478 outFile->setValue( it->filename.toStdString() );
479 }
480 }
481 }
482 } else {
483 CreateNodeArgs args(PLUGINID_NATRON_WRITE, getProject());
484 args.setProperty<bool>(kCreateNodeArgsPropAddUndoRedoCommand, false);
485 args.setProperty<bool>(kCreateNodeArgsPropSettingsOpened, false);
486 args.setProperty<bool>(kCreateNodeArgsPropAutoConnect, false);
487 writerNode = createWriter( it->filename.toStdString(), args );
488 if (!writerNode) {
489 throw std::runtime_error( tr("Failed to create writer for %1.").arg(it->filename).toStdString() );
490 }
491
492 //Connect the writer to the corresponding Output node input
493 NodePtr output = getProject()->getNodeByFullySpecifiedName( it->name.toStdString() );
494 if (!output) {
495 throw std::invalid_argument( tr("%1 is not the name of a valid Output node of the script").arg(it->name).toStdString() );
496 }
497 GroupOutput* isGrpOutput = dynamic_cast<GroupOutput*>( output->getEffectInstance().get() );
498 if (!isGrpOutput) {
499 throw std::invalid_argument( tr("%1 is not the name of a valid Output node of the script").arg(it->name).toStdString() );
500 }
501 NodePtr outputInput = output->getRealInput(0);
502 if (outputInput) {
503 writerNode->connectInput(outputInput, 0);
504 }
505 }
506
507 assert(writerNode);
508 OutputEffectInstance* effect = dynamic_cast<OutputEffectInstance*>( writerNode->getEffectInstance().get() );

Callers

nothing calls this directly

Calls 15

maxFunction · 0.85
toStdStringMethod · 0.80
isOutputNodeMethod · 0.80
getEffectInstanceMethod · 0.80
getRealInputMethod · 0.80
hasFrameRangeMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
isEmptyMethod · 0.45
getKnobByNameMethod · 0.45
getMethod · 0.45
setValueMethod · 0.45

Tested by

no test coverage detected