当前位置: 首页>>代码示例>>C++>>正文


C++ CCompartment::getKey方法代码示例

本文整理汇总了C++中CCompartment::getKey方法的典型用法代码示例。如果您正苦于以下问题:C++ CCompartment::getKey方法的具体用法?C++ CCompartment::getKey怎么用?C++ CCompartment::getKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCompartment的用法示例。


在下文中一共展示了CCompartment::getKey方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: addCompartments

bool CModelAdd::addCompartments(std::string name)
{

  size_t i, imax = mmModel->getCompartments().size();

  for (i = 0; i < imax; ++i)
    {
      const CCompartment* sourceComp = &mmModel->getCompartments()[i];

      if (!sourceComp) return false;

      //create new compartment

      std::string newName = sourceComp->getObjectName() + "_" + name;

      CCompartment* newComp = mpModel->createCompartment(newName, sourceComp->getInitialValue());

      if (!newComp) return false;

      newComp->setStatus(sourceComp->getStatus());

      newComp->setDimensionality(sourceComp->getDimensionality());

      keyMap[sourceComp->getKey()] = newComp->getKey();
      nameMap[sourceComp->getObjectName()] = newName;
    }

  return true;
}
开发者ID:jonasfoe,项目名称:COPASI,代码行数:29,代码来源:CModelMerging.cpp

示例2: deleteSpecieRow

void CQSpecieDM::deleteSpecieRow(UndoSpeciesData *pSpecieData)
{
  GET_MODEL_OR_RETURN(pModel);

  switchToWidget(CCopasiUndoCommand::SPECIES);

  CMetab * pSpecies = dynamic_cast< CMetab * >(pSpecieData->getObject(pModel));

  if (pSpecies == NULL) return;

  size_t Index = pModel->getMetabolites().getIndex(pSpecies);

  removeRow((int) Index);

  if (!pSpecieData->getCreatedCompartment()) return;

  Index = pModel->getCompartments().getIndex(pSpecieData->getCompartment());

  if (Index == C_INVALID_INDEX) return;

  CCompartment* pComp = &pModel->getCompartments()[Index];

  if (pComp == NULL) return;

  std::string key = pComp->getKey();
  pModel->removeCompartment(Index);
  emit notifyGUI(ListViews::COMPARTMENT, ListViews::DELETE, key);
}
开发者ID:jonasfoe,项目名称:COPASI,代码行数:28,代码来源:CQSpecieDM.cpp

示例3: notifyGUI

QList <UndoSpeciesData *> CQSpecieDM::insertNewSpecieRow(int position, int rows, const QModelIndex&index, const QVariant& value)
{
  QList <UndoSpeciesData *> result;
  GET_MODEL_OR(pModel, return result);

  bool createdCompartment = false;

  if (pModel->getCompartments().size() == 0)
    {
      CCompartment* pComp = pModel->createCompartment("compartment");
      createdCompartment = true;

      if (mNotify)
        {
          emit notifyGUI(ListViews::COMPARTMENT, ListViews::ADD, pComp->getKey());
        }
    }

  beginInsertRows(QModelIndex(), position, position + rows - 1);

  int column = index.column();

  for (int row = 0; row < rows; ++row)
    {
      QString name = createNewName(index.isValid() && column == COL_NAME_SPECIES ? value.toString() : "species", COL_NAME_SPECIES);

      QString compartment = index.isValid() && column == COL_COMPARTMENT ? value.toString() : "";

      double initial = index.isValid() && column == COL_ICONCENTRATION ? value.toDouble() : 1.0;

      CModelEntity::Status status = index.isValid() && column == COL_TYPE_SPECIES ?
                                    (CModelEntity::Status) mItemToType[value.toInt()] : CModelEntity::REACTIONS;

      mpSpecies =
        pModel->createMetabolite(TO_UTF8(name), TO_UTF8(compartment), initial, status);

      if (mpSpecies == NULL)
        continue;

      if (mNotify)
        {
          emit notifyGUI(ListViews::METABOLITE, ListViews::ADD, mpSpecies->getKey());
        }

      UndoSpeciesData* data = new UndoSpeciesData(mpSpecies);
      data->setCreatedCompartment(row == 0 && createdCompartment);
      result.append(data);
    }

  endInsertRows();
  return result;
}
开发者ID:jonasfoe,项目名称:COPASI,代码行数:52,代码来源:CQSpecieDM.cpp

示例4: createDependentObjects

void UndoDependentData::createDependentObjects(CModel *pModel, QList<UndoCompartmentData *> *pCompartmentData)
{
  if (pModel == NULL || pCompartmentData == NULL || pCompartmentData->empty())
    return;

  //reaction may further has dependencies, these must be taken care of
  QList <UndoCompartmentData *>::const_iterator rs;

  for (rs = pCompartmentData->begin(); rs != pCompartmentData->end(); ++rs)
    {
      UndoCompartmentData * data = *rs;

      CCompartment* pCompartment = data->createObjectIn(pModel);

      if (pCompartment == NULL)
        continue;

      updateGUI(ListViews::COMPARTMENT, ListViews::ADD, pCompartment->getKey());
    }
}
开发者ID:jonasfoe,项目名称:COPASI,代码行数:20,代码来源:UndoDependentData.cpp

示例5: deleteCompartment

void CQCompartment::deleteCompartment(UndoCompartmentData *pCompartmentData)
{
  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
  CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];
  assert(pDataModel != NULL);

  CModel * pModel = pDataModel->getModel();
  assert(pModel != NULL);

  CCompartment * pCompartment = pModel->getCompartments()[pCompartmentData->getName()];
  std::string key = pCompartment->getKey();
  pModel->removeCompartment(key);
  mpCompartment = NULL;

#undef DELETE
  protectedNotify(ListViews::COMPARTMENT, ListViews::DELETE, key);
  protectedNotify(ListViews::COMPARTMENT, ListViews::DELETE, "");//Refresh all as there may be dependencies.

  mpListView->switchToOtherWidget(111, "");
}
开发者ID:PriKalra,项目名称:COPASI,代码行数:20,代码来源:CQCompartment.cpp

示例6: duplicateCompartment

void CModelExpansion::duplicateCompartment(const CCompartment* source, const std::string & index, const SetOfModelElements & sourceSet, ElementsMap & emap)
{
  //if the source object has already been duplicated: do nothing
  if (emap.exists(source))
    return;

  //try creating the object until we find a name that is not yet used
  CCompartment* newObj;
  std::ostringstream infix;

  do
    {
      std::ostringstream name;
      name << source->getObjectName() << infix.str() << index;
      newObj = mpModel->createCompartment(name.str(), source->getInitialValue());
      infix << "_";
    }
  while (!newObj);

  //add duplicated object to the map
  emap.add(source, newObj);

  //now copy the contents of the object
  newObj->setDimensionality(source->getDimensionality());

  //status
  newObj->setStatus(source->getStatus());

  //expression (for assignment or ODE)
  newObj->setExpression(source->getExpression());
  updateExpression(newObj->getExpressionPtr(), index, sourceSet, emap);

  //initial expression
  newObj->setInitialExpression(source->getInitialExpression());
  updateExpression(newObj->getInitialExpressionPtr(), index, sourceSet, emap);

  newObj->setNotes(source->getNotes());
  newObj->setMiriamAnnotation(source->getMiriamAnnotation(), newObj->getKey(), source->getKey());
}
开发者ID:PriKalra,项目名称:COPASI,代码行数:39,代码来源:CModelExpansion.cpp

示例7: preprocess

bool CODEExporterC::preprocess(const CModel* copasiModel)

{
  size_t n[3] = {0, 0, 0};
  size_t n_c[3] = {0, 0, 0};
  size_t i, j;
  size_t dependent;

  setReservedNames();

  NameMap[timeKey] = translateTimeVariableName();

  const CCopasiVector< CMetab > & metabs = copasiModel->getMetabolitesX();
  size_t metabs_size = metabs.size();

  for (i = 0; i < metabs_size; i++)
    {
      CMetab * metab = metabs[i];

      //if (metab->isUsed())
      {
        std::string smname;
        std::string name;
        dependent = metab->isDependent();

        smname = setExportName(metab->getStatus(), n, dependent);
        name = setConcentrationName(metab->getStatus(), n_c, dependent);

        NameMap[metab->getKey()] = name;

        std::ostringstream smKey;
        smKey << "sm_" << metab->getKey();

        NameMap[smKey.str()] = smname;

        if ((metab->getStatus() == CModelEntity::REACTIONS && !metab->isDependent()) || metab->getStatus() == CModelEntity::ODE)
          {
            std::ostringstream odeKey;
            odeKey << "ode_" << metab->getKey();

            NameMap[odeKey.str()] = setODEName(smname);
          }
      }
    }

  size_t comps_size = copasiModel->getCompartments().size();
  const CCopasiVector< CCompartment > & comps = copasiModel->getCompartments();

  for (i = 0; i < comps_size; i++)
    {
      CCompartment * comp = comps[i];

      std::string name;
      dependent = 0;

      name = setExportName(comp->getStatus(), n, dependent);
      NameMap[comp->getKey()] = name;

      if (comp->getStatus() == CModelEntity::ODE)
        {
          std::ostringstream odeKey;
          odeKey << "ode_" << comp->getKey();

          NameMap[odeKey.str()] = setODEName(name);
        }
    }

  size_t modvals_size = copasiModel->getModelValues().size();
  const CCopasiVector< CModelValue > & modvals = copasiModel->getModelValues();

  for (i = 0; i < modvals_size; i++)
    {
      CModelValue* modval = modvals[i];
      std::string name = setExportName(modval->getStatus(), n, 0);
      NameMap[modval->getKey()] = name;

      if (modval->getStatus() == CModelEntity::ODE)
        {
          std::ostringstream odeKey;
          odeKey << "ode_" << modval->getKey();
          NameMap[odeKey.str()] = setODEName(name);
        }
    }

  size_t reacs_size = copasiModel->getReactions().size();

  const CCopasiVector< CReaction > & reacs = copasiModel->getReactions();

  std::set<std::string> tmpset;

  for (i = 0; i < reacs_size; ++i)
    {
      size_t params_size;

      params_size = reacs[i]->getParameters().size();

      for (j = 0; j < params_size; ++j)
        {
          if (!reacs[i]->isLocalParameter(reacs[i]->getParameters().getParameter(j)->getObjectName()))
            continue;
//.........这里部分代码省略.........
开发者ID:sachiinb,项目名称:COPASI,代码行数:101,代码来源:CODEExporterC.cpp

示例8: 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);
}
开发者ID:PriKalra,项目名称:COPASI,代码行数:67,代码来源:CQCompartment.cpp


注:本文中的CCompartment::getKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。