本文整理汇总了C++中CCopasiDataModel::getModel方法的典型用法代码示例。如果您正苦于以下问题:C++ CCopasiDataModel::getModel方法的具体用法?C++ CCopasiDataModel::getModel怎么用?C++ CCopasiDataModel::getModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCopasiDataModel
的用法示例。
在下文中一共展示了CCopasiDataModel::getModel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: insertRows
bool CQSpecieDM::insertRows(int position, int rows, const QModelIndex&)
{
CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];
if (pDataModel->getModel()->getCompartments().size() == 0)
{
pDataModel->getModel()->createCompartment("compartment");
emit notifyGUI(ListViews::COMPARTMENT, ListViews::ADD, pDataModel->getModel()->getCompartments()[0]->getKey());
}
beginInsertRows(QModelIndex(), position, position + rows - 1);
for (int row = 0; row < rows; ++row)
{
mpSpecies =
pDataModel->getModel()->createMetabolite(TO_UTF8(createNewName("species", COL_NAME_SPECIES)), "", 1.0, CModelEntity::REACTIONS);
if (mNotify)
{
emit notifyGUI(ListViews::METABOLITE, ListViews::ADD, mpSpecies->getKey());
}
}
endInsertRows();
return true;
}
示例2: deleteCompartment
void CQCompartment::deleteCompartment()
{
assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];
assert(pDataModel != NULL);
CModel * pModel = pDataModel->getModel();
if (pModel == NULL) return;
if (mpCompartment == NULL) return;
QMessageBox::StandardButton choice =
CQMessageBox::confirmDelete(this, "compartment",
FROM_UTF8(mpCompartment->getObjectName()),
mpCompartment->getDeletedObjects());
switch (choice)
{
case QMessageBox::Ok:
{
pDataModel->getModel()->removeCompartment(mKey);
protectedNotify(ListViews::COMPARTMENT, ListViews::DELETE, mKey);
protectedNotify(ListViews::COMPARTMENT, ListViews::DELETE, ""); //Refresh all as there may be dependencies.
break;
}
default:
break;
}
mpListView->switchToOtherWidget(111, "");
}
示例3: slotBtnDelete
void CQCompartment::slotBtnDelete()
{
assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];
assert(pDataModel != NULL);
CModel * pModel = pDataModel->getModel();
if (pModel == NULL) return;
if (mpCompartment == NULL) return;
QMessageBox::StandardButton choice =
CQMessageBox::confirmDelete(this, "compartment",
FROM_UTF8(mpCompartment->getObjectName()),
mpCompartment->getDeletedObjects());
switch (choice)
{
case QMessageBox::Ok:
{
unsigned C_INT32 Index =
pDataModel->getModel()->getCompartments().getIndex(mpCompartment->getObjectName());
pDataModel->getModel()->removeCompartment(mKey);
std::string deletedKey = mKey;
//std::string moveToKey = "";
unsigned C_INT32 Size =
pDataModel->getModel()->getCompartments().size();
QObject *pParent = parent();
CTabWidget * pTabWidget = NULL;
while (pParent != NULL &&
(pTabWidget = dynamic_cast< CTabWidget *>(pParent)) == NULL)
{
pParent = pParent->parent();
}
if (pTabWidget != NULL)
{
if (Size > 0)
pTabWidget->enter(pDataModel->getModel()->getCompartments()[std::min(Index, Size - 1)]->getKey());
else
pTabWidget->enter("");
}
protectedNotify(ListViews::COMPARTMENT, ListViews::DELETE, deletedKey);
protectedNotify(ListViews::COMPARTMENT, ListViews::DELETE, ""); //Refresh all as there may be dependencies.
break;
}
default:
break;
}
}
示例4:
void test000053::test4_bug1000()
{
// load the CPS file
// export to SBML
// check the resulting SBML model
CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000053::MODEL_STRING_4));
const CModel* pModel = pDataModel->getModel();
CPPUNIT_ASSERT(pModel != NULL);
CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
CPPUNIT_ASSERT(pModel->getModelValues().size() == 0);
CPPUNIT_ASSERT(pModel->getReactions().size() == 0);
CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
const CMetab* pMetab = pModel->getMetabolites()[0];
CPPUNIT_ASSERT(pMetab != NULL);
CPPUNIT_ASSERT(pMetab->getObjectName() == "A");
CPPUNIT_ASSERT(pMetab->getStatus() == CModelEntity::ASSIGNMENT);
const CExpression* pExpr = pMetab->getExpressionPtr();
CPPUNIT_ASSERT(pExpr != NULL);
const CEvaluationNode* pRoot = pExpr->getRoot();
CPPUNIT_ASSERT(pRoot != NULL);
CPPUNIT_ASSERT(pRoot->mainType() == CEvaluationNode::T_NUMBER);
CPPUNIT_ASSERT((pRoot->subType()) == CEvaluationNode::S_DOUBLE);
const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pRoot);
CPPUNIT_ASSERT(pNumberNode != NULL);
CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 1.5) / 1.5) < 1e-6);
}
示例5: editSlider
void SliderDialog::editSlider()
{
SliderSettingsDialog* pSettingsDialog = new SliderSettingsDialog(this);
// set the list of sliders that is already known
CCopasiObject* object = (CCopasiObject*)getTaskForFolderId(mCurrentFolderId);
if (!object) return;
CCopasiDataModel * pDataModel = object->getObjectDataModel();
assert(pDataModel != NULL);
pSettingsDialog->setModel(pDataModel->getModel());
std::vector<CSlider*>* pVector = getCSlidersForCurrentFolderId();
pSettingsDialog->setDefinedSliders(*pVector);
//pSettingsDialog->disableObjectChoosing(true);
pSettingsDialog->setSlider(mpCurrSlider->getCSlider());
if (pSettingsDialog->exec() == QDialog::Accepted)
{
addSlider(pSettingsDialog->getSlider());
mpCurrSlider->updateSliderData();
/*
if ((!mpCurrSlider->isEnabled()) && mpCurrSlider->getCSlider()->compile())
{
mpCurrSlider->setEnabled(true);
}
*/
}
delete pSettingsDialog;
delete pVector;
}
示例6: catch
void test000080::test_mass_action_recognition_bug()
{
CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
try
{
CPPUNIT_ASSERT(pDataModel->importSBMLFromString(test000080::MODEL_STRING1));
}
catch (...)
{
// there should not be an exception
CPPUNIT_ASSERT(false);
}
const CModel* pModel = pDataModel->getModel();
CPPUNIT_ASSERT(pModel != NULL);
CPPUNIT_ASSERT(pModel->getReactions().size() == 1);
const CReaction* pReaction = pModel->getReactions()[0];
CPPUNIT_ASSERT(pReaction != NULL);
const CFunction* pFun = pReaction->getFunction();
CPPUNIT_ASSERT(pFun != NULL);
CPPUNIT_ASSERT(pFun->getType() == CEvaluationTree::UserDefined);
}
示例7: CCopasiUndoCommand
RemoveGlobalQuantityRowsCommand::RemoveGlobalQuantityRowsCommand(
QModelIndexList rows, CQGlobalQuantityDM * pGlobalQuantityDM, const QModelIndex&)
: CCopasiUndoCommand("Global Quantity", GLOBALQUANTITY_REMOVE)
, mpGlobalQuantityDM(pGlobalQuantityDM)
, mRows(rows)
, mpGlobalQuantityData()
, mFirstTime(true)
{
CCopasiDataModel * pDataModel = pGlobalQuantityDM->getDataModel();
assert(pDataModel != NULL);
CModel * pModel = pDataModel->getModel();
assert(pModel != NULL);
QModelIndexList::const_iterator i;
for (i = rows.begin(); i != rows.end(); ++i)
{
CModelValue* pModelValue = &pModel->getModelValues()[i->row()];
if (pGlobalQuantityDM->isDefaultRow(*i) || pModelValue == NULL)
continue;
UndoGlobalQuantityData *data = new UndoGlobalQuantityData(pModelValue);
mpGlobalQuantityData.append(data);
}
setText(QObject::tr(": Removed Global Quantity"));
}
示例8: initObjects
void CCopasiTask::initObjects()
{
addObjectReference("Output counter", mOutputCounter, CCopasiObject::ValueInt);
new CCopasiTimer(CCopasiTimer::WALL, this);
new CCopasiTimer(CCopasiTimer::PROCESS, this);
CCopasiDataModel *pDataModel = getObjectDataModel();
if (pDataModel != NULL)
{
if (pDataModel->getModel() != NULL)
{
setMathContainer(&pDataModel->getModel()->getMathContainer());
}
}
}
示例9: assert
RemoveAllReactionRowsCommand::RemoveAllReactionRowsCommand(CQReactionDM * pReaDM, const QModelIndex&)
{
mpReactionDM = pReaDM;
assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];
assert(pDataModel != NULL);
CModel * pModel = pDataModel->getModel();
assert(pModel != NULL);
for (int i = 0; i != pReaDM->rowCount() - 1; ++i)
{
UndoReactionData *data = new UndoReactionData();
CReactionInterface* ri = new CReactionInterface((*CCopasiRootContainer::getDatamodelList())[0]->getModel());
if (pModel->getReactions()[i])
{
data->setName(pModel->getReactions()[i]->getObjectName());
ri->initFromReaction(pModel->getReactions()[i]->getKey());
data->setRi(ri);
mpReaData.append(data);
}
}
mType = REACTIONREMOVEALL;
setEntityType("Reaction");
this->setText(removeAllReactionRowsText());
}
示例10: setFilter
void CCopasiSelectionDialog::setFilter(const CQSimpleSelectionTree::ObjectClasses & classes)
{
CCopasiDataModel * pDataModel = ListViews::dataModel(this);
assert(pDataModel != NULL);
this->mpSelectionWidget->populateTree(pDataModel->getModel(), classes);
}
示例11: redo
void insertReactionRowsCommand::redo()
{
mpReactionDM->insertNewReactionRow(mPosition, mRows, QModelIndex());
assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];
assert(pDataModel != NULL);
CModel * pModel = pDataModel->getModel();
assert(pModel != NULL);
mpReaction = pModel->getReactions()[mPosition];
std::string sName = mpReaction->getObjectName();
if (mpReactionData != NULL)
mpReactionData->setName(sName);
CReactionInterface* ri = new CReactionInterface((*CCopasiRootContainer::getDatamodelList())[0]->getModel());
ri->initFromReaction(mpReaction);
if (mpReactionData != NULL)
mpReactionData->setRi(ri);
setUndoState(true);
setAction("Add to list");
if (mpReactionData != NULL)
setName(mpReactionData->getName());
else setName(sName);
}
示例12: redo
void InsertCompartmentRowsCommand::redo()
{
if (firstTime)
{
mpCompartmentDM->insertNewCompartmentRow(mPosition, mRows, QModelIndex());
assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];
assert(pDataModel != NULL);
CModel * pModel = pDataModel->getModel();
assert(pModel != NULL);
CCompartment *pCompartment = pModel->getCompartments()[mPosition];
mpCompartmentData->setName(pCompartment->getObjectName());
mpCompartmentData->setStatus(pCompartment->getStatus());
mpCompartmentData->setInitialValue(pCompartment->getInitialValue());
firstTime = false;
}
else
{
mpCompartmentDM->addCompartmentRow(mpCompartmentData);
}
setUndoState(true);
setAction("Add to list");
setName(mpCompartmentData->getName());
}
示例13:
void test000046::test_stoichiometricExpression()
{
CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING));
CModel* pModel = pDataModel->getModel();
CPPUNIT_ASSERT(pModel != NULL);
CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::mMol);
CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
const CCompartment* pCompartment = pModel->getCompartments()[0];
CPPUNIT_ASSERT(pCompartment != NULL);
CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
CMetab* pA = pModel->getMetabolites()[0];
CPPUNIT_ASSERT(pA != NULL);
CPPUNIT_ASSERT(pA->getStatus() == CModelEntity::REACTIONS);
const CMetab* pB = pModel->getMetabolites()[1];
CPPUNIT_ASSERT(pB != NULL);
CPPUNIT_ASSERT(pB->getStatus() == CModelEntity::REACTIONS);
CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
const CModelValue* pModelValue = pModel->getModelValues()[0];
CPPUNIT_ASSERT(pModelValue != NULL);
CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::FIXED);
CPPUNIT_ASSERT(fabs((pModelValue->getInitialValue() - 3.7) / 3.7) < 1e-3);
CPPUNIT_ASSERT(pModel->getReactions().size() == 1);
const CReaction* pReaction1 = pModel->getReactions()[0];
CPPUNIT_ASSERT(pReaction1 != NULL);
CPPUNIT_ASSERT(pReaction1->isReversible() == true);
// check the kinetic law
const CFunction* pKineticFunction = pReaction1->getFunction();
CPPUNIT_ASSERT(pKineticFunction != NULL);
const CMassAction* pMassAction = dynamic_cast<const CMassAction*>(pKineticFunction);
CPPUNIT_ASSERT(pMassAction != NULL);
const CChemEq* pChemEq = &pReaction1->getChemEq();
CPPUNIT_ASSERT(pChemEq != NULL);
CPPUNIT_ASSERT(pChemEq->getCompartmentNumber() == 1);
CPPUNIT_ASSERT(pChemEq->getSubstrates().size() == 1);
const CChemEqElement* pElement = pChemEq->getSubstrates()[0];
CPPUNIT_ASSERT(pElement != NULL);
CPPUNIT_ASSERT(fabs((pElement->getMultiplicity() - 1.85) / 1.85) < 1e-3);
CPPUNIT_ASSERT(pElement->getMetabolite() == pA);
CPPUNIT_ASSERT(pChemEq->getProducts().size() == 1);
pElement = pChemEq->getProducts()[0];
CPPUNIT_ASSERT(pElement != NULL);
CPPUNIT_ASSERT(fabs((pElement->getMultiplicity() - 3.35) / 3.35) / 3.35 < 1e-3);
CPPUNIT_ASSERT(pElement->getMetabolite() == pB);
CPPUNIT_ASSERT(pChemEq->getModifiers().size() == 0);
//CPPUNIT_ASSERT(CCopasiMessage::size() == 5);
CCopasiMessage message = CCopasiMessage::getLastMessage();
CPPUNIT_ASSERT(message.getType() == CCopasiMessage::WARNING);
std::string s = message.getText();
CPPUNIT_ASSERT(!s.empty());
CPPUNIT_ASSERT(s.find(std::string("One or more stoichiometric expressions were evaluated and converted to constants values.")) != std::string::npos);
// the other four messages are libSBML unit warnings I don't care about right
// now.
}
示例14:
void test000047::test_delay()
{
CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING));
CModel* pModel = pDataModel->getModel();
CPPUNIT_ASSERT(pModel != NULL);
CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CUnit::mMol);
CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CUnit::ml);
CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CUnit::s);
CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
const CCompartment* pCompartment = pModel->getCompartments()[0];
CPPUNIT_ASSERT(pCompartment != NULL);
CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
const CMetab* pB = pModel->getMetabolites()[1];
CPPUNIT_ASSERT(pB != NULL);
CPPUNIT_ASSERT(pB->getStatus() == CModelEntity::FIXED);
CMetab* pA = pModel->getMetabolites()[0];
CPPUNIT_ASSERT(pA != NULL);
CPPUNIT_ASSERT(pA->getStatus() == CModelEntity::ASSIGNMENT);
const CExpression* pExpr = pA->getExpressionPtr();
CPPUNIT_ASSERT(pExpr != NULL);
const CEvaluationNode* pNode = pExpr->getRoot();
CPPUNIT_ASSERT(pNode != NULL);
const CEvaluationNodeDelay* pDelayNode = dynamic_cast<const CEvaluationNodeDelay*>(pNode);
CPPUNIT_ASSERT(pDelayNode != NULL);
const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pDelayNode->getChild());
CPPUNIT_ASSERT(pObjectNode != NULL);
CCopasiObjectName objectCN = pObjectNode->getObjectCN();
CPPUNIT_ASSERT(!objectCN.empty());
std::vector<CCopasiContainer*> listOfContainers;
listOfContainers.push_back(pModel);
const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
CPPUNIT_ASSERT(pObject != NULL);
CPPUNIT_ASSERT(pObject->isReference() == true);
CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Concentration"));
CPPUNIT_ASSERT(pObject->getObjectParent() == pB);
const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pObjectNode->getSibling());
CPPUNIT_ASSERT(pNumberNode != NULL);
CPPUNIT_ASSERT(((CEvaluationNodeNumber::SubType)CEvaluationNode::subType(pNumberNode->getType())) == CEvaluationNodeNumber::DOUBLE);
CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 0.5) / 0.5) < 1e-3);
CPPUNIT_ASSERT(pNumberNode->getSibling() == NULL);
CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
const CModelValue* pModelValue = pModel->getModelValues()[0];
CPPUNIT_ASSERT(pModelValue != NULL);
CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::FIXED);
CPPUNIT_ASSERT(pModel->getReactions().size() == 0);
//CPPUNIT_ASSERT(CCopasiMessage::size() == 2);
CCopasiMessage message = CCopasiMessage::getLastMessage();
CPPUNIT_ASSERT(message.getType() == CCopasiMessage::WARNING);
std::string s = message.getText();
CPPUNIT_ASSERT(!s.empty());
CPPUNIT_ASSERT(s.find(std::string("COPASI does not support time delays. Calculations on this model will most likely lead to unusable results.")) != std::string::npos);
// right now, we don't care about the last message since it is a units
// warning from libSBML
}
示例15: assert
void CQEventWidget1::deleteEvent()
{
assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];
CModel * pModel = pDataModel->getModel();
if (pModel == NULL)
return;
pDataModel->getModel()->removeEvent(mKey);
mpEvent = NULL;
protectedNotify(ListViews::EVENT, ListViews::DELETE, mKey);
mpListView->switchToOtherWidget(116, "");
}