static KnobPtr findMaster(const KnobPtr & knob, const NodesList & allNodes, const std::string& masterKnobName, const std::string& masterNodeName, const std::string& masterTrackName, const std::map<std::string,std::string>& oldNewScriptNamesMapping) { ///we need to cycle through all the nodes of the project to find the real master NodePtr masterNode; std::string masterNodeNameToFind = masterNodeName; /* When copy pasting, the new node copied has a script-name different from what is inside the serialization because 2 nodes cannot co-exist with the same script-name. We keep in the map the script-names mapping */ std::map<std::string,std::string>::const_iterator foundMapping = oldNewScriptNamesMapping.find(masterNodeName); if (foundMapping != oldNewScriptNamesMapping.end()) { masterNodeNameToFind = foundMapping->second; } for (NodesList::const_iterator it2 = allNodes.begin(); it2 != allNodes.end(); ++it2) { if ((*it2)->getScriptName() == masterNodeNameToFind) { masterNode = *it2; break; } } if (!masterNode) { qDebug() << "Link slave/master for " << knob->getName().c_str() << " failed to restore the following linkage: " << masterNodeNameToFind.c_str(); return KnobPtr(); } if (!masterTrackName.empty()) { boost::shared_ptr<TrackerContext> context = masterNode->getTrackerContext(); if (context) { TrackMarkerPtr marker = context->getMarkerByName(masterTrackName); if (marker) { return marker->getKnobByName(masterKnobName); } } } else { ///now that we have the master node, find the corresponding knob const std::vector< KnobPtr > & otherKnobs = masterNode->getKnobs(); for (std::size_t j = 0; j < otherKnobs.size(); ++j) { if ( (otherKnobs[j]->getName() == masterKnobName) && otherKnobs[j]->getIsPersistant() ) { return otherKnobs[j]; break; } } } qDebug() << "Link slave/master for " << knob->getName().c_str() << " failed to restore the following linkage: " << masterNodeNameToFind.c_str(); return KnobPtr(); }
KnobPtr LinkToKnobDialog::getSelectedKnobs() const { QString str = _imp->knobSelectionCombo->itemText( _imp->knobSelectionCombo->activeIndex() ); std::map<QString, KnobPtr >::const_iterator it = _imp->allKnobs.find(str); if ( it != _imp->allKnobs.end() ) { return it->second; } else { return KnobPtr(); } }
KnobPtr MultipleKnobEditsUndoCommand::createCopyForKnob(const KnobPtr & originalKnob) { const std::string & typeName = originalKnob->typeName(); KnobPtr copy; int dimension = originalKnob->getDimension(); if ( typeName == KnobInt::typeNameStatic() ) { copy.reset( new KnobInt(NULL, std::string(), dimension, false) ); } else if ( typeName == KnobBool::typeNameStatic() ) { copy.reset( new KnobBool(NULL, std::string(), dimension, false) ); } else if ( typeName == KnobDouble::typeNameStatic() ) { copy.reset( new KnobDouble(NULL, std::string(), dimension, false) ); } else if ( typeName == KnobChoice::typeNameStatic() ) { copy.reset( new KnobChoice(NULL, std::string(), dimension, false) ); } else if ( typeName == KnobString::typeNameStatic() ) { copy.reset( new KnobString(NULL, std::string(), dimension, false) ); } else if ( typeName == KnobParametric::typeNameStatic() ) { copy.reset( new KnobParametric(NULL, std::string(), dimension, false) ); } else if ( typeName == KnobColor::typeNameStatic() ) { copy.reset( new KnobColor(NULL, std::string(), dimension, false) ); } else if ( typeName == KnobPath::typeNameStatic() ) { copy.reset( new KnobPath(NULL, std::string(), dimension, false) ); } else if ( typeName == KnobFile::typeNameStatic() ) { copy.reset( new KnobFile(NULL, std::string(), dimension, false) ); } else if ( typeName == KnobOutputFile::typeNameStatic() ) { copy.reset( new KnobOutputFile(NULL, std::string(), dimension, false) ); } ///If this is another type of knob this is wrong since they do not hold any value assert(copy); if (!copy) { return KnobPtr(); } copy->populate(); ///make a clone of the original knob at that time and stash it copy->clone(originalKnob); return copy; }