void TrackMarker::setEnabledFromGui(double /*time*/, bool enabled) { KnobBoolPtr knob = _imp->enabled.lock(); if (!knob) { return; } KeyFrame k; std::pair<int, KnobIPtr> master = knob->getMaster(0); if (master.second) { knob->unSlave(0, true); } knob->onValueChanged(enabled, ViewSpec::all(), 0, eValueChangedReasonNatronGuiEdited, &k); if (master.second) { master.second->cloneAndUpdateGui(knob); knob->slaveTo(0, master.second, master.first); } getContext()->solveTransformParamsIfAutomatic(); }
void TrackerNodePrivate::exportTrackDataFromExportOptions() { //bool transformLink = _imp->exportLink.lock()->getValue(); KnobChoicePtr transformTypeKnob = transformType.lock(); assert(transformTypeKnob); int transformType_i = transformTypeKnob->getValue(); TrackerTransformNodeEnum transformType = (TrackerTransformNodeEnum)transformType_i; KnobChoicePtr motionTypeKnob = motionType.lock(); if (!motionTypeKnob) { return; } int motionType_i = motionTypeKnob->getValue(); TrackerMotionTypeEnum mt = (TrackerMotionTypeEnum)motionType_i; if (mt == eTrackerMotionTypeNone) { Dialogs::errorDialog( tr("Tracker Export").toStdString(), tr("Please select the export mode with the Motion Type parameter").toStdString() ); return; } bool linked = exportLink.lock()->getValue(); QString pluginID; switch (transformType) { case eTrackerTransformNodeCornerPin: pluginID = QString::fromUtf8(PLUGINID_OFX_CORNERPIN); break; case eTrackerTransformNodeTransform: pluginID = QString::fromUtf8(PLUGINID_OFX_TRANSFORM); break; } NodePtr thisNode = publicInterface->getNode(); AppInstancePtr app = thisNode->getApp(); CreateNodeArgsPtr args(CreateNodeArgs::create( pluginID.toStdString(), thisNode->getGroup() )); args->setProperty<bool>(kCreateNodeArgsPropAutoConnect, false); args->setProperty<bool>(kCreateNodeArgsPropSettingsOpened, false); NodePtr createdNode = app->createNode(args); if (!createdNode) { return; } // Move the new node double thisNodePos[2]; double thisNodeSize[2]; thisNode->getPosition(&thisNodePos[0], &thisNodePos[1]); thisNode->getSize(&thisNodeSize[0], &thisNodeSize[1]); createdNode->setPosition(thisNodePos[0] + thisNodeSize[0] * 2., thisNodePos[1]); int timeForFromPoints = referenceFrame.lock()->getValue(); switch (transformType) { case eTrackerTransformNodeCornerPin: { KnobDoublePtr cornerPinToPoints[4]; KnobDoublePtr cornerPinFromPoints[4]; for (unsigned int i = 0; i < 4; ++i) { cornerPinFromPoints[i] = getCornerPinPoint(createdNode, true, i); assert(cornerPinFromPoints[i]); for (int j = 0; j < cornerPinFromPoints[i]->getNDimensions(); ++j) { cornerPinFromPoints[i]->setValue(fromPoints[i].lock()->getValueAtTime(timeForFromPoints, DimIdx(j)), ViewSetSpec::all(), DimIdx(j)); } cornerPinToPoints[i] = getCornerPinPoint(createdNode, false, i); assert(cornerPinToPoints[i]); if (!linked) { cornerPinToPoints[i]->copyKnob( toPoints[i].lock() ); } else { bool ok = cornerPinToPoints[i]->slaveTo(toPoints[i].lock()); (void)ok; assert(ok); } } { KnobIPtr knob = createdNode->getKnobByName(kCornerPinParamMatrix); if (knob) { KnobDoublePtr isType = toKnobDouble(knob); if (isType) { isType->copyKnob(cornerPinMatrix.lock() ); } } } break; } case eTrackerTransformNodeTransform: { KnobIPtr translateKnob = createdNode->getKnobByName(kTransformParamTranslate); if (translateKnob) { KnobDoublePtr isDbl = toKnobDouble(translateKnob); if (isDbl) { if (!linked) { isDbl->copyKnob(translate.lock() ); } else { isDbl->slaveTo(translate.lock()); } } } KnobIPtr scaleKnob = createdNode->getKnobByName(kTransformParamScale); if (scaleKnob) { KnobDoublePtr isDbl = toKnobDouble(scaleKnob); if (isDbl) { if (!linked) { isDbl->copyKnob(scale.lock() ); } else { isDbl->slaveTo(scale.lock()); } } } KnobIPtr rotateKnob = createdNode->getKnobByName(kTransformParamRotate); if (rotateKnob) { KnobDoublePtr isDbl = toKnobDouble(rotateKnob); if (isDbl) { if (!linked) { isDbl->copyKnob(rotate.lock()); } else { isDbl->slaveTo(rotate.lock()); } } } KnobIPtr centerKnob = createdNode->getKnobByName(kTransformParamCenter); if (centerKnob) { KnobDoublePtr isDbl = toKnobDouble(centerKnob); if (isDbl) { isDbl->copyKnob( center.lock() ); } } break; } } // switch KnobIPtr cpInvertKnob = createdNode->getKnobByName(kTransformParamInvert); if (cpInvertKnob) { KnobBoolPtr isBool = toKnobBool(cpInvertKnob); if (isBool) { if (!linked) { isBool->copyKnob(invertTransform.lock()); } else { isBool->slaveTo(invertTransform.lock()); } } } { KnobIPtr knob = createdNode->getKnobByName(kTransformParamMotionBlur); if (knob) { KnobDoublePtr isType = toKnobDouble(knob); if (isType) { isType->copyKnob(motionBlur.lock()); } } } { KnobIPtr knob = createdNode->getKnobByName(kTransformParamShutter); if (knob) { KnobDoublePtr isType = toKnobDouble(knob); if (isType) { isType->copyKnob(shutter.lock()); } } } { KnobIPtr knob = createdNode->getKnobByName(kTransformParamShutterOffset); if (knob) { KnobChoicePtr isType = toKnobChoice(knob); if (isType) { isType->copyKnob(shutterOffset.lock()); } } } { KnobIPtr knob = createdNode->getKnobByName(kTransformParamCustomShutterOffset); if (knob) { KnobDoublePtr isType = toKnobDouble(knob); if (isType) { isType->copyKnob(customShutterOffset.lock()); } } } } // exportTrackDataFromExportOptions