MCPcopy Create free account
hub / github.com/NatronGitHub/openfx-misc / getBoxValues

Method getBoxValues

Reformat/Reformat.cpp:572–649  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

570} // ReformatPlugin::getInverseTransformCanonical
571
572bool
573ReformatPlugin::getBoxValues(const double time, int *w, int *h, double *par, bool *boxFixed) const
574{
575 ReformatTypeEnum type = (ReformatTypeEnum)_type->getValue();
576 assert(w && h && par && boxFixed);
577
578 switch (type) {
579 case eReformatTypeToFormat: {
580 if (gHostIsNatron) {
581 //size & par have been set by natron with the Format choice extension
582 _formatBoxSize->getValue(*w, *h);
583 *par = _formatBoxPAR->getValue();
584 } else {
585 EParamFormat format = (EParamFormat)_format->getValue();
586 assert(0 <= (int)format && (int)format < eParamFormatCount);
587 getFormatResolution(format, w, h, par);
588 assert(*par != -1);
589 }
590 *boxFixed = true;
591 break;
592 }
593 case eReformatTypeToBox: {
594 _boxSize->getValue(*w, *h);
595 *par = _boxPAR->getValue();
596 *boxFixed = _boxFixed->getValue();
597 // nothing to do, the user sets the box
598 return false;
599 break;
600 }
601 case eReformatTypeScale: {
602 OfxPointD scale = _scale->getValue();
603 if ( _scaleUniform->getValue() ) {
604 scale.y = scale.x;
605 }
606 OfxRectD srcRod;
607 if (_srcClip && _srcClip->isConnected()) {
608 *par = _srcClip->getPixelAspectRatio();
609 srcRod = _srcClip->getRegionOfDefinition(time);
610 } else {
611 OfxPointD siz = getProjectSize();
612 OfxPointD off = getProjectOffset();
613 srcRod.x1 = off.x;
614 srcRod.x2 = off.x + siz.x;
615 srcRod.y1 = off.y;
616 srcRod.y2 = off.y + siz.y;
617 *par = getProjectPixelAspectRatio();
618 }
619 // if turn, inverse both dimensions
620 if (_turn->getValueAtTime(time)) {
621 std::swap(srcRod.x1, srcRod.y1);
622 std::swap(srcRod.x2, srcRod.y2);
623 }
624 // scale the RoD
625 srcRod.x1 *= scale.x;
626 srcRod.x2 *= scale.x;
627 srcRod.y1 *= scale.y;
628 srcRod.y2 *= scale.y;
629 // round to the nearest pixel size

Callers

nothing calls this directly

Calls 3

isConnectedMethod · 0.80
getValueAtTimeMethod · 0.80
getRegionOfDefinitionMethod · 0.45

Tested by

no test coverage detected