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

Function exportKnobValues

Engine/NodeGroup.cpp:1711–1960  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1709/* *INDENT-ON* */
1710
1711static bool
1712exportKnobValues(int indentLevel,
1713 const KnobIPtr knob,
1714 const QString& paramFullName,
1715 bool mustDefineParam,
1716 QTextStream& ts)
1717{
1718 bool hasExportedValue = false;
1719
1720 KnobStringBase* isStr = dynamic_cast<KnobStringBase*>( knob.get() );
1721 AnimatingKnobStringHelper* isAnimatedStr = dynamic_cast<AnimatingKnobStringHelper*>( knob.get() );
1722 KnobDoubleBase* isDouble = dynamic_cast<KnobDoubleBase*>( knob.get() );
1723 KnobIntBase* isInt = dynamic_cast<KnobIntBase*>( knob.get() );
1724 KnobBoolBase* isBool = dynamic_cast<KnobBoolBase*>( knob.get() );
1725 KnobParametric* isParametric = dynamic_cast<KnobParametric*>( knob.get() );
1726 KnobChoice* isChoice = dynamic_cast<KnobChoice*>( knob.get() );
1727 KnobGroup* isGrp = dynamic_cast<KnobGroup*>( knob.get() );
1728 KnobString* isStringKnob = dynamic_cast<KnobString*>( knob.get() );
1729
1730 ///Don't export this kind of parameter. Mainly this is the html label of the node which is 99% of times empty
1731 if ( isStringKnob &&
1732 isStringKnob->isMultiLine() &&
1733 isStringKnob->usesRichText() &&
1734 !isStringKnob->hasContentWithoutHtmlTags() &&
1735 !isStringKnob->isAnimationEnabled() &&
1736 isStringKnob->getExpression(0).empty() ) {
1737 return false;
1738 }
1739
1740 EffectInstance* holderIsEffect = dynamic_cast<EffectInstance*>( knob->getHolder() );
1741
1742 if (isChoice && holderIsEffect) {
1743 //Do not serialize mask channel selector if the mask is not enabled
1744 int maskInputNb = holderIsEffect->getNode()->isMaskChannelKnob(isChoice);
1745 if (maskInputNb != -1) {
1746 if ( !holderIsEffect->getNode()->isMaskEnabled(maskInputNb) ) {
1747 return false;
1748 }
1749 }
1750 }
1751
1752 int innerIdent = mustDefineParam ? 2 : 1;
1753
1754 for (int i = 0; i < knob->getDimension(); ++i) {
1755 if (isParametric) {
1756 if (!hasExportedValue) {
1757 hasExportedValue = true;
1758 if (mustDefineParam) {
1759 WRITE_INDENT(indentLevel); WRITE_STRING(QString::fromUtf8("param = ") + paramFullName);
1760 WRITE_INDENT(indentLevel); WRITE_STRING( QString::fromUtf8("if param is not None:") );
1761 }
1762 }
1763 CurvePtr curve = isParametric->getParametricCurve(i);
1764 double r, g, b;
1765 isParametric->getCurveColor(i, &r, &g, &b);
1766 WRITE_INDENT(innerIdent); WRITE_STRING( QString::fromUtf8("param.setCurveColor(") + NUM_INT(i) + QString::fromUtf8(", ") +
1767 NUM_COLOR(r) + QString::fromUtf8(", ") + NUM_COLOR(g) + QString::fromUtf8(", ") + NUM_COLOR(b) + QString::fromUtf8(")") );
1768 if (curve) {

Callers 3

exportUserKnobFunction · 0.85
exportRotoLayerFunction · 0.85
exportAllNodeKnobsFunction · 0.85

Calls 15

maxFunction · 0.85
isMultiLineMethod · 0.80
usesRichTextMethod · 0.80
emptyMethod · 0.80
isMaskChannelKnobMethod · 0.80
getParametricCurveMethod · 0.80
getKeyFrames_mt_safeMethod · 0.80
getInterpolationMethod · 0.80
getTimeMethod · 0.80
getLeftDerivativeMethod · 0.80
getRightDerivativeMethod · 0.80

Tested by

no test coverage detected