| 4466 | } |
| 4467 | |
| 4468 | void |
| 4469 | Node::onFileNameParameterChanged(KnobI* fileKnob) |
| 4470 | { |
| 4471 | if ( _imp->effect->isReader() ) { |
| 4472 | ///Refresh the preview automatically if the filename changed |
| 4473 | incrementKnobsAge(); //< since evaluate() is called after knobChanged we have to do this by hand |
| 4474 | //computePreviewImage( getApp()->getTimeLine()->currentFrame() ); |
| 4475 | |
| 4476 | ///union the project frame range if not locked with the reader frame range |
| 4477 | bool isLocked = getApp()->getProject()->isFrameRangeLocked(); |
| 4478 | if (!isLocked) { |
| 4479 | double leftBound = std::numeric_limits<int>::min(), rightBound = std::numeric_limits<int>::max(); |
| 4480 | _imp->effect->getFrameRange_public(getHashValue(), &leftBound, &rightBound, true); |
| 4481 | |
| 4482 | if ( (leftBound != std::numeric_limits<int>::min()) && (rightBound != std::numeric_limits<int>::max()) ) { |
| 4483 | if ( getGroup() || getIOContainer() ) { |
| 4484 | getApp()->getProject()->unionFrameRangeWith(leftBound, rightBound); |
| 4485 | } |
| 4486 | } |
| 4487 | } |
| 4488 | } else if ( _imp->effect->isWriter() ) { |
| 4489 | KnobIPtr sublabelKnob = getKnobByName(kNatronOfxParamStringSublabelName); |
| 4490 | KnobOutputFile* isFile = dynamic_cast<KnobOutputFile*>(fileKnob); |
| 4491 | if (isFile && sublabelKnob) { |
| 4492 | KnobStringBase* isString = dynamic_cast<KnobStringBase*>( sublabelKnob.get() ); |
| 4493 | |
| 4494 | std::string pattern = isFile->getValue(); |
| 4495 | if (isString) { |
| 4496 | std::size_t foundSlash = pattern.find_last_of("/"); |
| 4497 | if (foundSlash != std::string::npos) { |
| 4498 | pattern = pattern.substr(foundSlash + 1); |
| 4499 | } |
| 4500 | |
| 4501 | isString->setValue(pattern); |
| 4502 | } |
| 4503 | } |
| 4504 | |
| 4505 | /* |
| 4506 | Check if the filename param has a %V in it, in which case make sure to hide the Views parameter |
| 4507 | */ |
| 4508 | KnobOutputFile* fileParam = dynamic_cast<KnobOutputFile*>(fileKnob); |
| 4509 | if (fileParam) { |
| 4510 | std::string pattern = fileParam->getValue(); |
| 4511 | std::size_t foundViewPattern = pattern.find_first_of("%v"); |
| 4512 | if (foundViewPattern == std::string::npos) { |
| 4513 | foundViewPattern = pattern.find_first_of("%V"); |
| 4514 | } |
| 4515 | if (foundViewPattern != std::string::npos) { |
| 4516 | //We found view pattern |
| 4517 | KnobIPtr viewsKnob = getKnobByName(kWriteOIIOParamViewsSelector); |
| 4518 | if (viewsKnob) { |
| 4519 | KnobChoice* viewsSelector = dynamic_cast<KnobChoice*>( viewsKnob.get() ); |
| 4520 | if (viewsSelector) { |
| 4521 | viewsSelector->setSecret(true); |
| 4522 | } |
| 4523 | } |
| 4524 | } |
| 4525 | } |
no test coverage detected