本文整理汇总了C++中CCompartment::setInitialValue方法的典型用法代码示例。如果您正苦于以下问题:C++ CCompartment::setInitialValue方法的具体用法?C++ CCompartment::setInitialValue怎么用?C++ CCompartment::setInitialValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCompartment
的用法示例。
在下文中一共展示了CCompartment::setInitialValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: insertNewRows
void CQCompartmentDM::insertNewRows(int position, int rows, int column, const QVariant & value)
{
beginInsertRows(QModelIndex(), position, position + rows - 1);
for (int row = 0; row < rows; ++row)
{
QString name = createNewName(column == COL_NAME_COMPARTMENTS ? value.toString() : "compartment", COL_NAME_COMPARTMENTS);
CCompartment * pComp = mpDataModel->getModel()->createCompartment(TO_UTF8(name));
if (pComp == NULL)
continue;
if (column == COL_TYPE_COMPARTMENTS)
{
pComp->setStatus(CModelEntity::StatusName.toEnum(TO_UTF8(value.toString())));
}
if (column == COL_IVOLUME)
{
pComp->setInitialValue(value.toDouble());
}
CUndoData UndoData(CUndoData::Type::INSERT, pComp);
ListViews::addUndoMetaData(this, UndoData);
emit signalNotifyChanges(mpDataModel->recordData(UndoData));
}
endInsertRows();
}
示例2: addCompartment
void CQCompartment::addCompartment(UndoCompartmentData *pSData)
{
assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];
assert(pDataModel != NULL);
CModel * pModel = pDataModel->getModel();
assert(pModel != NULL);
//reinsert all the Compartments
CCompartment *pCompartment = pModel->createCompartment(pSData->getName());
pCompartment->setInitialValue(pSData->getInitialValue());
pCompartment->setStatus(pSData->getStatus());
std::string key = pCompartment->getKey();
protectedNotify(ListViews::COMPARTMENT, ListViews::ADD, key);
//restore all the dependencies
//reinsert all the species
QList <UndoSpecieData *> *pSpecieData = pSData->getSpecieDependencyObjects();
QList <UndoSpecieData *>::const_iterator i;
for (i = pSpecieData->begin(); i != pSpecieData->end(); ++i)
{
UndoSpecieData * data = *i;
// beginInsertRows(QModelIndex(), 1, 1);
CMetab *pSpecie = pModel->createMetabolite(data->getName(), data->getCompartment(), data->getIConc(), data->getStatus());
protectedNotify(ListViews::METABOLITE, ListViews::ADD, pSpecie->getKey());
//endInsertRows();
}
//reinsert the dependency reaction
QList <UndoReactionData *> *pReactionData = pSData->getReactionDependencyObjects();
QList <UndoReactionData *>::const_iterator j;
for (j = pReactionData->begin(); j != pReactionData->end(); ++j)
{
//UndoReactionData * rData = dynamic_cast<UndoReactionData*>(*j);
UndoReactionData * rData = *j;
//TODO check if reaction already exist in the model, better idea may be implemented in the future
bool exist = false;
for (int ii = 0; ii < (int)pModel->getReactions().size(); ++ii)
{
if (pModel->getReactions()[ii]->getObjectName() == rData->getName())
{
exist = true;
ii = ii + pModel->getReactions().size() + 1; //jump out of the loop reaction exist already
}
else
{
exist = false;
}
}
if (!exist)
{
protectedNotify(ListViews::METABOLITE, ListViews::ADD, ""); //Refresh all dependency species.
CReaction *pRea = pModel->createReaction(rData->getName());
rData->getRi()->writeBackToReaction(pRea);
protectedNotify(ListViews::REACTION, ListViews::ADD, pRea->getKey());
}
}
mpListView->switchToOtherWidget(C_INVALID_INDEX, key);
}