| 449 | } |
| 450 | |
| 451 | void |
| 452 | AppInstance::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() ); |
nothing calls this directly
no test coverage detected