bool CModelAdd::copyInitialExpression(const CModelEntity * sourceEntity, CModelEntity * newEntity) { bool info = false; const CExpression* pExpression = sourceEntity->getInitialExpressionPtr(); if (pExpression == NULL) return info; CExpression* tmp; tmp = new CExpression(*pExpression, mmModel); const std::vector<CEvaluationNode*>& objectNodes = tmp->getNodeList(); size_t j, jmax = objectNodes.size(); for (j = 0; j < jmax; ++j) { if (CEvaluationNode::type(objectNodes[j]->getType()) == CEvaluationNode::OBJECT) { CEvaluationNodeObject* pObjectNode = dynamic_cast<CEvaluationNodeObject*>(objectNodes[j]); if (pObjectNode == NULL) return info; CCopasiObjectName cn = pObjectNode->getObjectCN(); const CCopasiObject* mObject = static_cast< const CCopasiObject * >(mmModel->getObjectDataModel()->getObject(cn)); if (mObject == NULL) return info; std::string host = ""; if (mObject->isReference()) { host = ",Reference=" + mObject->getObjectName(); mObject = mObject->getObjectParent(); } if (mObject == NULL) return info; std::string key = keyMap[(dynamic_cast<const CModelEntity * >(mObject))->getKey()]; CCopasiObject* pObject = (CCopasiRootContainer::getKeyFactory()->get(key)); cn = pObject->getCN() + host; pObjectNode->setData("<" + cn + ">"); } } tmp->updateTree(); newEntity->setInitialExpression(tmp->getInfix().c_str()); return info; }