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

Function exportKnobValues

Engine/NodeGroup.cpp:1669–1918  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1667/* *INDENT-ON* */
1668
1669static bool
1670exportKnobValues(int indentLevel,
1671 const KnobPtr knob,
1672 const QString& paramFullName,
1673 bool mustDefineParam,
1674 QTextStream& ts)
1675{
1676 bool hasExportedValue = false;
1677
1678 Knob<std::string>* isStr = dynamic_cast<Knob<std::string>*>( knob.get() );
1679 AnimatingKnobStringHelper* isAnimatedStr = dynamic_cast<AnimatingKnobStringHelper*>( knob.get() );
1680 Knob<double>* isDouble = dynamic_cast<Knob<double>*>( knob.get() );
1681 Knob<int>* isInt = dynamic_cast<Knob<int>*>( knob.get() );
1682 Knob<bool>* isBool = dynamic_cast<Knob<bool>*>( knob.get() );
1683 KnobParametric* isParametric = dynamic_cast<KnobParametric*>( knob.get() );
1684 KnobChoice* isChoice = dynamic_cast<KnobChoice*>( knob.get() );
1685 KnobGroup* isGrp = dynamic_cast<KnobGroup*>( knob.get() );
1686 KnobString* isStringKnob = dynamic_cast<KnobString*>( knob.get() );
1687
1688 ///Don't export this kind of parameter. Mainly this is the html label of the node which is 99% of times empty
1689 if ( isStringKnob &&
1690 isStringKnob->isMultiLine() &&
1691 isStringKnob->usesRichText() &&
1692 !isStringKnob->hasContentWithoutHtmlTags() &&
1693 !isStringKnob->isAnimationEnabled() &&
1694 isStringKnob->getExpression(0).empty() ) {
1695 return false;
1696 }
1697
1698 EffectInstance* holderIsEffect = dynamic_cast<EffectInstance*>( knob->getHolder() );
1699
1700 if (isChoice && holderIsEffect) {
1701 //Do not serialize mask channel selector if the mask is not enabled
1702 int maskInputNb = holderIsEffect->getNode()->isMaskChannelKnob(isChoice);
1703 if (maskInputNb != -1) {
1704 if ( !holderIsEffect->getNode()->isMaskEnabled(maskInputNb) ) {
1705 return false;
1706 }
1707 }
1708 }
1709
1710 int innerIdent = mustDefineParam ? 2 : 1;
1711
1712 for (int i = 0; i < knob->getDimension(); ++i) {
1713 if (isParametric) {
1714 if (!hasExportedValue) {
1715 hasExportedValue = true;
1716 if (mustDefineParam) {
1717 WRITE_INDENT(indentLevel); WRITE_STRING(QString::fromUtf8("param = ") + paramFullName);
1718 WRITE_INDENT(indentLevel); WRITE_STRING( QString::fromUtf8("if param is not None:") );
1719 }
1720 }
1721 boost::shared_ptr<Curve> curve = isParametric->getParametricCurve(i);
1722 double r, g, b;
1723 isParametric->getCurveColor(i, &r, &g, &b);
1724 WRITE_INDENT(innerIdent); WRITE_STRING( QString::fromUtf8("param.setCurveColor(") + NUM_INT(i) + QString::fromUtf8(", ") +
1725 NUM_COLOR(r) + QString::fromUtf8(", ") + NUM_COLOR(g) + QString::fromUtf8(", ") + NUM_COLOR(b) + QString::fromUtf8(")") );
1726 if (curve) {

Callers 3

exportUserKnobFunction · 0.85
exportRotoLayerFunction · 0.85
exportAllNodeKnobsFunction · 0.85

Calls 15

maxFunction · 0.85
floorFunction · 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

Tested by

no test coverage detected