本文整理汇总了C++中CCopasiDataModel类的典型用法代码示例。如果您正苦于以下问题:C++ CCopasiDataModel类的具体用法?C++ CCopasiDataModel怎么用?C++ CCopasiDataModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CCopasiDataModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SliderSettingsDialog
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;
}
示例2: getObjectDataModel
bool CReportDefinition::preCompileTable(const std::vector< CCopasiContainer * > & listOfContainer)
{
bool success = true;
mHeaderVector.clear();
mBodyVector.clear();
mFooterVector.clear();
std::vector<CRegisteredObjectName>::const_iterator it = mTableVector.begin();
std::vector<CRegisteredObjectName>::const_iterator end = mTableVector.end();
CCopasiDataModel* pDataModel = getObjectDataModel();
CCopasiObject * pObject;
for (; it != end; ++it)
{
pObject = pDataModel->ObjectFromName(listOfContainer, *it);
if (pObject != NULL)
{
addTableElement(pObject);
}
else
{
CCopasiMessage(CCopasiMessage::WARNING, MCCopasiTask + 6, it->c_str());
}
}
return success;
}
示例3: 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;
}
示例4: assert
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, "");
}
示例5: btnCommitClicked
void CQReportDefinition::btnCopyReportClicked()
{
btnCommitClicked();
CCopasiDataModel* pDataModel = mpObject->getObjectDataModel();
if (pDataModel == NULL) return;
CReportDefinition * pRep = new CReportDefinition(*dynamic_cast<CReportDefinition*>(CCopasiRootContainer::getKeyFactory()->get(mKey)));
std::string baseName = pRep->getObjectName() + "_copy";
std::string name = baseName;
int i = 1;
while (pDataModel->getReportDefinitionList()->getIndex(name) != C_INVALID_INDEX)
{
i++;
name = baseName + TO_UTF8(QString::number(i));
}
pRep->setObjectName(name);
pDataModel->getReportDefinitionList()->add(pRep, true);
std::string key = pRep->getKey();
protectedNotify(ListViews::REPORT, ListViews::ADD, key);
enter(key);
mpListView->switchToOtherWidget(C_INVALID_INDEX, key);
}
示例6: 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());
}
示例7: setFilter
void CCopasiSelectionDialog::setFilter(const CQSimpleSelectionTree::ObjectClasses & classes)
{
CCopasiDataModel * pDataModel = ListViews::dataModel(this);
assert(pDataModel != NULL);
this->mpSelectionWidget->populateTree(pDataModel->getModel(), classes);
}
示例8: QModelIndex
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);
}
示例9: QModelIndex
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());
}
示例10:
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);
}
示例11: 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"));
}
示例12: 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);
}
示例13:
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
}
示例14:
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.
}
示例15: loadReportDefinitionVector
void CQReportDefinitionSelect::loadReportDefinitionVector()
{
CCopasiDataModel* pDataModel = mpListView->getDataModel();
assert(pDataModel != NULL);
CReportDefinitionVector* pReportDefinitionVector = pDataModel->getReportDefinitionList();
unsigned C_INT32 i;
for (i = 0; i < pReportDefinitionVector->size(); i++)
mpComboDefinition->
insertItem(mpComboDefinition->count(), FROM_UTF8(pReportDefinitionVector->operator[](i).getObjectName()));
// if it is an empty list
if (mpComboDefinition->count() == 0)
{
std::string name = "ReportDefinition_0";
pDataModel->getReportDefinitionList()->createReportDefinition(name, "");
mpComboDefinition->insertItem(mpComboDefinition->count(), FROM_UTF8(name));
mpComboDefinition->setCurrentIndex(1);
mpReport->setReportDefinition(&pDataModel->getReportDefinitionList()->operator[](0)); //first one report definition
mpReport->setAppend(mpCheckAppend->isChecked());
mpReport->setConfirmOverwrite(mpCheckConfirmOverwrite->isChecked());
mpReport->setTarget(TO_UTF8(mpEditTarget->text()));
mpListView->getDataModelGUI()->notify(ListViews::REPORT, ListViews::CHANGE, ""); //notify Table Definition to
if (CQMessageBox::question(NULL, "No Report Template Defined",
"No report definition defined, COPASI has already created a new one for you.\n Do you want to switch to the GUI to edit it?",
QMessageBox::Ok | QMessageBox::No, QMessageBox::Ok) == QMessageBox::Ok)
slotEdit();
return;
}
if (!mpReport->getReportDefinition())
{
C_INT32 row;
row = mpComboDefinition->currentIndex();
mpReport->setReportDefinition(&pReportDefinitionVector->operator[](row));
mpReport->setAppend(mpCheckAppend->isChecked());
mpReport->setConfirmOverwrite(mpCheckConfirmOverwrite->isChecked());
mpReport->setTarget(TO_UTF8(mpEditTarget->text()));
return;
}
else
{
C_INT32 i;
// no use to compare the last one
for (i = mpComboDefinition->count() - 1; i >= 1; i--)
if (mpComboDefinition->itemText(i) == FROM_UTF8(mpReport->getReportDefinition()->getObjectName()))
break;
mpComboDefinition->setCurrentIndex(i);
mpCheckAppend->setChecked(mpReport->append());
mpCheckConfirmOverwrite->setChecked(mpReport->confirmOverwrite());
mpEditTarget->setText(FROM_UTF8(mpReport->getTarget()));
}
}