void KstDataObject::replaceDependency(KstDataObjectPtr oldObject, KstDataObjectPtr newObject) { // // find all connections from this object to old object // for (KstVectorMap::Iterator j = oldObject->outputVectors().begin(); j != oldObject->outputVectors().end(); ++j) { for (KstVectorMap::Iterator k = _inputVectors.begin(); k != _inputVectors.end(); ++k) { if (*j == *k) { // replace input with the output from newObject _inputVectors[k.key()] = (newObject->outputVectors())[j.key()]; } } // also replace dependencies on vector stats for (KstScalarMap::Iterator k = _inputScalars.begin(); k != _inputScalars.end(); ++k) { for (ScalarCollection::const_iterator l = (*j)->scalars().begin(); l != (*j)->scalars().end(); ++l) { if (*l == *k) { _inputScalars[k.key()] = (((newObject->outputVectors())[j.key()])->scalars())[l.key()]; } } } } for (KstMatrixMap::Iterator j = oldObject->outputMatrices().begin(); j != oldObject->outputMatrices().end(); ++j) { for (KstMatrixMap::Iterator k = _inputMatrices.begin(); k != _inputMatrices.end(); ++k) { if (*j == *k) { // replace input with the output from newObject _inputMatrices[k.key()] = (newObject->outputMatrices())[j.key()]; } } // also replace dependencies on matrix stats for (KstScalarMap::Iterator k = _inputScalars.begin(); k != _inputScalars.end(); ++k) { for (ScalarCollection::const_iterator l=(*j)->scalars().begin(); l != (*j)->scalars().end(); ++l) { if (*l == *k) { _inputScalars[k.key()] = (((newObject->outputMatrices())[j.key()])->scalars())[l.key()]; } } } } for (KstScalarMap::Iterator j = oldObject->outputScalars().begin(); j != oldObject->outputScalars().end(); ++j) { for (KstScalarMap::Iterator k = _inputScalars.begin(); k != _inputScalars.end(); ++k) { if (*j == *k) { // replace input with the output from newObject _inputScalars[k.key()] = (newObject->outputScalars())[j.key()]; } } } for (KstStringMap::Iterator j = oldObject->outputStrings().begin(); j != oldObject->outputStrings().end(); ++j) { for (KstStringMap::Iterator k = _inputStrings.begin(); k != _inputStrings.end(); ++k) { if (*j == *k) { // replace input with the output from newObject _inputStrings[k.key()] = (newObject->outputStrings())[j.key()]; } } } }
void KstEquation::replaceDependency(KstDataObjectPtr oldObject, KstDataObjectPtr newObject) { QString newExp = _equation; // replace all occurences of outputVectors, outputScalars from oldObject for (KstVectorMap::Iterator j = oldObject->outputVectors().begin(); j != oldObject->outputVectors().end(); ++j) { QString oldTag = j.data()->tagName(); QString newTag = ((newObject->outputVectors())[j.key()])->tagName(); newExp = newExp.replace("[" + oldTag + "]", "[" + newTag + "]"); } for (KstScalarMap::Iterator j = oldObject->outputScalars().begin(); j != oldObject->outputScalars().end(); ++j) { QString oldTag = j.data()->tagName(); QString newTag = ((newObject->outputScalars())[j.key()])->tagName(); newExp = newExp.replace("[" + oldTag + "]", "[" + newTag + "]"); } // and dependencies on matrix stats (there won't be matrices themselves in the expression) for (KstMatrixMap::Iterator j = oldObject->outputMatrices().begin(); j != oldObject->outputMatrices().end(); ++j) { QDictIterator<KstScalar> scalarDictIter(j.data()->scalars()); for (; scalarDictIter.current(); ++scalarDictIter) { QString oldTag = scalarDictIter.current()->tagName(); QString newTag = ((((newObject->outputMatrices())[j.key()])->scalars())[scalarDictIter.currentKey()])->tagName(); newExp = newExp.replace("[" + oldTag + "]", "[" + newTag + "]"); } } // only replace _inputVectors for (KstVectorMap::Iterator j = oldObject->outputVectors().begin(); j != oldObject->outputVectors().end(); ++j) { for (KstVectorMap::Iterator k = _inputVectors.begin(); k != _inputVectors.end(); ++k) { if (j.data().data() == k.data().data()) { // replace input with the output from newObject _inputVectors[k.key()] = (newObject->outputVectors())[j.key()]; } } // and dependencies on vector stats QDictIterator<KstScalar> scalarDictIter(j.data()->scalars()); for (; scalarDictIter.current(); ++scalarDictIter) { QString oldTag = scalarDictIter.current()->tagName(); QString newTag = ((((newObject->outputVectors())[j.key()])->scalars())[scalarDictIter.currentKey()])->tagName(); newExp = newExp.replace("[" + oldTag + "]", "[" + newTag + "]"); } } setEquation(newExp); }
void EventMonitorEntry::replaceDependency(KstDataObjectPtr oldObject, KstDataObjectPtr newObject) { QString newExp = _event; // replace all occurences of outputVectors, outputScalars from oldObject for (KstVectorMap::ConstIterator j = oldObject->outputVectors().begin(); j != oldObject->outputVectors().end(); ++j) { const QString oldTag = j.value()->tagName(); const QString newTag = newObject->outputVectors()[j.key()]->tagName(); newExp = newExp.replace("[" + oldTag + "]", "[" + newTag + "]"); } for (KstScalarMap::ConstIterator j = oldObject->outputScalars().begin(); j != oldObject->outputScalars().end(); ++j) { const QString oldTag = j.value()->tagName(); const QString newTag = newObject->outputScalars()[j.key()]->tagName(); newExp = newExp.replace("[" + oldTag + "]", "[" + newTag + "]"); } // and dependencies on vector stats for (KstVectorMap::ConstIterator j = oldObject->outputVectors().begin(); j != oldObject->outputVectors().end(); ++j) { const QHash<QString, KstScalar*>& scalarMap(newObject->outputVectors()[j.key()]->scalars()); QHashIterator<QString, KstScalar*> scalarDictIter(j.value()->scalars()); while (scalarDictIter.hasNext()) { const QString oldTag = scalarDictIter.next().value()->tagName(); const QString newTag = scalarMap[scalarDictIter.key()]->tagName(); newExp = newExp.replace("[" + oldTag + "]", "[" + newTag + "]"); } } // and dependencies on matrix stats for (KstMatrixMap::ConstIterator j = oldObject->outputMatrices().begin(); j != oldObject->outputMatrices().end(); ++j) { const QHash<QString, KstScalar*>& scalarMap(newObject->outputMatrices()[j.key()]->scalars()); QHashIterator<QString, KstScalar*> scalarDictIter(j.value()->scalars()); while (scalarDictIter.hasNext()) { const QString oldTag = scalarDictIter.next().value()->tagName(); const QString newTag = scalarMap[scalarDictIter.key()]->tagName(); newExp = newExp.replace("[" + oldTag + "]", "[" + newTag + "]"); } } setEvent(newExp); setDirty(); // events have no _inputVectors }