void TrackMarker::setMotionModelFromGui(int index) { KnobChoicePtr knob = _imp->motionModel.lock(); if (!knob) { return; } KeyFrame k; std::pair<int, KnobIPtr> master = knob->getMaster(0); if (master.second) { knob->unSlave(0, true); } knob->onValueChanged(index, ViewSpec::all(), 0, eValueChangedReasonNatronGuiEdited, &k); if (master.second) { master.second->cloneAndUpdateGui(knob); knob->slaveTo(0, master.second, master.first); } }
void TrackMarkerPM::initializeKnobs() { TrackMarker::initializeKnobs(); NodePtr thisNode = getContext()->getNode(); QObject::connect( getContext().get(), SIGNAL(onNodeInputChanged(int)), this, SLOT(onTrackerNodeInputChanged(int)) ); NodePtr node; { CreateNodeArgs args( PLUGINID_OFX_TRACKERPM, NodeCollectionPtr() ); args.setProperty<bool>(kCreateNodeArgsPropOutOfProject, true); args.setProperty<bool>(kCreateNodeArgsPropNoNodeGUI, true); args.setProperty<std::string>(kCreateNodeArgsPropNodeInitialName, "TrackerPMNode"); node = getContext()->getNode()->getApp()->createNode(args); if (!node) { throw std::runtime_error("Couldn't create plug-in " PLUGINID_OFX_TRACKERPM); } if (thisNode) { NodePtr inputNode = thisNode->getInput(0); if (inputNode) { node->connectInput(inputNode, 0); } } trackerNode = node; } trackPrevButton = getNodeKnob<KnobButton>(node, kTrackerPMParamTrackingPrevious); trackNextButton = getNodeKnob<KnobButton>(node, kTrackerPMParamTrackingNext); KnobDoublePtr center = getNodeKnob<KnobDouble>(node, kTrackerPMParamTrackingCenterPoint); centerKnob = center; // Slave the center knob and unslave when tracking for (int i = 0; i < center->getDimension(); ++i) { center->slaveTo(i, getCenterKnob(), i); } KnobDoublePtr offset = getNodeKnob<KnobDouble>(node, kTrackerPMParamTrackingOffset); // Slave the offset knob for (int i = 0; i < offset->getDimension(); ++i) { offset->slaveTo(i, getOffsetKnob(), i); } offsetKnob = offset; // Ref frame is set for each refFrameKnob = getNodeKnob<KnobInt>(node, kTrackerPMParamTrackingReferenceFrame); // Enable reference frame KnobBoolPtr enableRefFrameKnob = getNodeKnob<KnobBool>(node, kTrackerPMParamTrackingEnableReferenceFrame); enableRefFrameKnob->setValue(true); KnobChoicePtr scoreType = getNodeKnob<KnobChoice>(node, kTrackerPMParamScore); scoreType->slaveTo(0, getContext()->getCorrelationScoreTypeKnob(), 0); scoreTypeKnob = scoreType; KnobDoublePtr correlationScore = getNodeKnob<KnobDouble>(node, kTrackerPMParamTrackingCorrelationScore); correlationScoreKnob = correlationScore; KnobDoublePtr patternBtmLeft = getNodeKnob<KnobDouble>(node, kTrackerPMParamTrackingPatternBoxBtmLeft); patternBtmLeftKnob = patternBtmLeft; // Slave the search window and pattern of the node to the parameters of the marker for (int i = 0; i < patternBtmLeft->getDimension(); ++i) { patternBtmLeft->slaveTo(i, getPatternBtmLeftKnob(), i); } KnobDoublePtr patternTopRight = getNodeKnob<KnobDouble>(node, kTrackerPMParamTrackingPatternBoxTopRight); patternTopRightKnob = patternTopRight; for (int i = 0; i < patternTopRight->getDimension(); ++i) { patternTopRight->slaveTo(i, getPatternTopRightKnob(), i); } KnobDoublePtr searchWindowBtmLeft = getNodeKnob<KnobDouble>(node, kTrackerPMParamTrackingSearchBoxBtmLeft); searchWindowBtmLeftKnob = searchWindowBtmLeft; for (int i = 0; i < searchWindowBtmLeft->getDimension(); ++i) { searchWindowBtmLeft->slaveTo(i, getSearchWindowBottomLeftKnob(), i); } KnobDoublePtr searchWindowTopRight = getNodeKnob<KnobDouble>(node, kTrackerPMParamTrackingSearchBoxTopRight); searchWindowTopRightKnob = searchWindowTopRight; for (int i = 0; i < searchWindowTopRight->getDimension(); ++i) { searchWindowTopRight->slaveTo(i, getSearchWindowTopRightKnob(), i); } } // TrackMarkerPM::initializeKnobs