void KstEquation::replaceDependency(KstVectorPtr oldVector, KstVectorPtr newVector) { QString oldTag = oldVector->tagName(); QString newTag = newVector->tagName(); // replace all occurences of oldTag with newTag QString newExp = _equation.replace("["+oldTag+"]", "["+newTag+"]"); // also replace all occurences of scalar stats for the oldVector QDictIterator<KstScalar> scalarDictIter(oldVector->scalars()); for (; scalarDictIter.current(); ++scalarDictIter) { QString oldTag = scalarDictIter.current()->tagName(); QString newTag = ((newVector->scalars())[scalarDictIter.currentKey()])->tagName(); newExp = newExp.replace("[" + oldTag + "]", "[" + newTag + "]"); } setEquation(newExp); // do the dependency replacements for _inputVectors, but don't call parent function as it // replaces _inputScalars for (KstVectorMap::Iterator j = _inputVectors.begin(); j != _inputVectors.end(); ++j) { if (j.data() == oldVector) { _inputVectors[j.key()] = newVector; } } }
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 }
void KstEquation::replaceDependency(KstMatrixPtr oldMatrix, KstMatrixPtr newMatrix) { QString newExp = _equation; // also replace all occurences of scalar stats for the oldMatrix QDictIterator<KstScalar> scalarDictIter(oldMatrix->scalars()); for (; scalarDictIter.current(); ++scalarDictIter) { QString oldTag = scalarDictIter.current()->tagName(); QString newTag = ((newMatrix->scalars())[scalarDictIter.currentKey()])->tagName(); newExp = newExp.replace("[" + oldTag + "]", "[" + newTag + "]"); } setEquation(newExp); }
void EventMonitorEntry::replaceDependency(KstMatrixPtr oldMatrix, KstMatrixPtr newMatrix) { QString newExp = _event; // also replace all occurences of scalar stats for the oldMatrix QHashIterator<QString, KstScalar*> scalarDictIter(oldMatrix->scalars()); while (scalarDictIter.hasNext()) { const QString oldTag = scalarDictIter.next().value()->tagName(); const QString newTag = newMatrix->scalars()[scalarDictIter.key()]->tagName(); newExp = newExp.replace("[" + oldTag + "]", "[" + newTag + "]"); } setEvent(newExp); setDirty(); }
void EventMonitorEntry::replaceDependency(KstMatrixPtr oldMatrix, KstMatrixPtr newMatrix) { QString newExp = _event; // also replace all occurences of scalar stats for the oldMatrix QDictIterator<KstScalar> scalarDictIter(oldMatrix->scalars()); for (; scalarDictIter.current(); ++scalarDictIter) { const QString oldTag = scalarDictIter.current()->tagName(); const QString newTag = newMatrix->scalars()[scalarDictIter.currentKey()]->tagName(); newExp = newExp.replace("[" + oldTag + "]", "[" + newTag + "]"); } setEvent(newExp); setDirty(); }
void EventMonitorEntry::replaceDependency(KstVectorPtr oldVector, KstVectorPtr newVector) { // replace all occurences of oldTag with newTag QString newExp = _event.replace("[" + oldVector->tagName() + "]", "[" + newVector->tagName() + "]"); // also replace all occurences of vector stats for the oldVector QHashIterator<QString, KstScalar*> scalarDictIter(oldVector->scalars()); while (scalarDictIter.hasNext()) { const QString oldTag = scalarDictIter.next().value()->tagName(); const QString newTag = newVector->scalars()[scalarDictIter.key()]->tagName(); newExp = newExp.replace("[" + oldTag + "]", "[" + newTag + "]"); } setEvent(newExp); setDirty(); // events have no _inputVectors }
void DataObject::replaceDependency(MatrixPtr oldMatrix, MatrixPtr newMatrix) { for (MatrixMap::Iterator j = _inputMatrices.begin(); j != _inputMatrices.end(); ++j) { if (j.value() == oldMatrix) { _inputMatrices[j.key()] = newMatrix; } } QHashIterator<QString, Scalar*> scalarDictIter(oldMatrix->scalars()); for (ScalarMap::Iterator j = _inputScalars.begin(); j != _inputScalars.end(); ++j) { while (scalarDictIter.hasNext()) { scalarDictIter.next(); if (scalarDictIter.value() == j.value()) { _inputScalars[j.key()] = (newMatrix->scalars())[scalarDictIter.key()]; } } } }
void DataObject::replaceDependency(VectorPtr oldVector, VectorPtr newVector) { for (VectorMap::Iterator j = _inputVectors.begin(); j != _inputVectors.end(); ++j) { if (j.value() == oldVector) { _inputVectors[j.key()] = newVector; } } QHashIterator<QString, Scalar*> scalarDictIter(oldVector->scalars()); for (ScalarMap::Iterator j = _inputScalars.begin(); j != _inputScalars.end(); ++j) { while (scalarDictIter.hasNext()) { scalarDictIter.next(); if (scalarDictIter.value() == j.value()) { _inputScalars[j.key()] = (newVector->scalars())[scalarDictIter.key()]; } } } }
bool DataObject::uses(ObjectPtr p) const { VectorPtr v = kst_cast<Vector>(p); if (v) { for (VectorMap::ConstIterator j = _inputVectors.begin(); j != _inputVectors.end(); ++j) { if (j.value() == v) { return true; } } QHashIterator<QString, Scalar*> scalarDictIter(v->scalars()); for (ScalarMap::ConstIterator j = _inputScalars.begin(); j != _inputScalars.end(); ++j) { while (scalarDictIter.hasNext()) { scalarDictIter.next(); if (scalarDictIter.value() == j.value()) { return true; } } } } else if (MatrixPtr matrix = kst_cast<Matrix>(p)) { for (MatrixMap::ConstIterator j = _inputMatrices.begin(); j != _inputMatrices.end(); ++j) { if (j.value() == matrix) { return true; } } QHashIterator<QString, Scalar*> scalarDictIter(matrix->scalars()); for (ScalarMap::ConstIterator j = _inputScalars.begin(); j != _inputScalars.end(); ++j) { while (scalarDictIter.hasNext()) { scalarDictIter.next(); if (scalarDictIter.value() == j.value()) { return true; } } } } else if (DataObjectPtr obj = kst_cast<DataObject>(p) ) { // check all connections from this object to p for (VectorMap::Iterator j = obj->outputVectors().begin(); j != obj->outputVectors().end(); ++j) { for (VectorMap::ConstIterator k = _inputVectors.begin(); k != _inputVectors.end(); ++k) { if (j.value() == k.value()) { return true; } } // also check dependencies on vector stats QHashIterator<QString, Scalar*> scalarDictIter(j.value()->scalars()); for (ScalarMap::ConstIterator k = _inputScalars.begin(); k != _inputScalars.end(); ++k) { while (scalarDictIter.hasNext()) { scalarDictIter.next(); if (scalarDictIter.value() == k.value()) { return true; } } } } for (MatrixMap::Iterator j = obj->outputMatrices().begin(); j != obj->outputMatrices().end(); ++j) { for (MatrixMap::ConstIterator k = _inputMatrices.begin(); k != _inputMatrices.end(); ++k) { if (j.value() == k.value()) { return true; } } // also check dependencies on vector stats QHashIterator<QString, Scalar*> scalarDictIter(j.value()->scalars()); for (ScalarMap::ConstIterator k = _inputScalars.begin(); k != _inputScalars.end(); ++k) { while (scalarDictIter.hasNext()) { scalarDictIter.next(); if (scalarDictIter.value() == k.value()) { return true; } } } } for (ScalarMap::Iterator j = obj->outputScalars().begin(); j != obj->outputScalars().end(); ++j) { for (ScalarMap::ConstIterator k = _inputScalars.begin(); k != _inputScalars.end(); ++k) { if (j.value() == k.value()) { return true; } } } for (StringMap::Iterator j = obj->outputStrings().begin(); j != obj->outputStrings().end(); ++j) { for (StringMap::ConstIterator k = _inputStrings.begin(); k != _inputStrings.end(); ++k) { if (j.value() == k.value()) { return true; } } } } return false; }
void DataObject::replaceDependency(DataObjectPtr oldObject, DataObjectPtr newObject) { // find all connections from this object to old object // vectors for (VectorMap::Iterator j = oldObject->outputVectors().begin(); j != oldObject->outputVectors().end(); ++j) { for (VectorMap::Iterator k = _inputVectors.begin(); k != _inputVectors.end(); ++k) { if (j.value().data() == k.value().data()) { // replace input with the output from newObject _inputVectors[k.key()] = (newObject->outputVectors())[j.key()]; } } // also replace dependencies on vector stats QHashIterator<QString, Scalar*> scalarDictIter(j.value()->scalars()); for (ScalarMap::Iterator k = _inputScalars.begin(); k != _inputScalars.end(); ++k) { while (scalarDictIter.hasNext()) { scalarDictIter.next(); if (scalarDictIter.value() == k.value()) { _inputScalars[k.key()] = (((newObject->outputVectors())[j.key()])->scalars())[scalarDictIter.key()]; } } } } // matrices for (MatrixMap::Iterator j = oldObject->outputMatrices().begin(); j != oldObject->outputMatrices().end(); ++j) { for (MatrixMap::Iterator k = _inputMatrices.begin(); k != _inputMatrices.end(); ++k) { if (j.value().data() == k.value().data()) { // replace input with the output from newObject _inputMatrices[k.key()] = (newObject->outputMatrices())[j.key()]; } } // also replace dependencies on matrix stats QHashIterator<QString, Scalar*> scalarDictIter(j.value()->scalars()); for (ScalarMap::Iterator k = _inputScalars.begin(); k != _inputScalars.end(); ++k) { while (scalarDictIter.hasNext()) { scalarDictIter.next(); if (scalarDictIter.value() == k.value()) { _inputScalars[k.key()] = (((newObject->outputMatrices())[j.key()])->scalars())[scalarDictIter.key()]; } } } } // scalars for (ScalarMap::Iterator j = oldObject->outputScalars().begin(); j != oldObject->outputScalars().end(); ++j) { for (ScalarMap::Iterator k = _inputScalars.begin(); k != _inputScalars.end(); ++k) { if (j.value().data() == k.value().data()) { // replace input with the output from newObject _inputScalars[k.key()] = (newObject->outputScalars())[j.key()]; } } } // strings for (StringMap::Iterator j = oldObject->outputStrings().begin(); j != oldObject->outputStrings().end(); ++j) { for (StringMap::Iterator k = _inputStrings.begin(); k != _inputStrings.end(); ++k) { if (j.value().data() == k.value().data()) { // replace input with the output from newObject _inputStrings[k.key()] = (newObject->outputStrings())[j.key()]; } } } }