Exemplo n.º 1
0
void CQExpandModelData::slotOK()
{
  CModelExpansion::SetOfModelElements modelelements;
  std::set<std::string> metabkeys;
  
  std::map<QTreeWidgetItem*, const CCompartment*>::const_iterator it;
  for (it=mItemCompartmentMap.begin(); it != mItemCompartmentMap.end(); ++it)
  {
    if (it->first->checkState(0)==Qt::Checked)
    { //the compartment is included
      modelelements.addCompartment(it->second);
      
      //check whether diffusion is requested for the metabolites inside
      size_t i;
      for (i=0; i<it->first->childCount(); ++i)
      {
        if (it->first->child(i)->checkState(1)==Qt::Checked)
        {
          std::map<QTreeWidgetItem*, const CMetab*>::const_iterator itMetab = mItemMetabMap.find(it->first->child(i));
          const CMetab* pMetab=NULL;
          if (itMetab != mItemMetabMap.end())
            metabkeys.insert(itMetab->second->getKey());
        }
        
      }
      
      
    }
  }

  CModelExpansion me(pModel);
  modelelements.fillDependencies(pModel);
  
  int multx, multy;
  multx=mpLineEditSizeX->text().toInt();
  multy=mpLineEditSizeY->text().toInt();
  
  if (mpRadioButtonLin->isChecked())
    me.createLinearArray(modelelements, multx, metabkeys);
  else if (mpRadioButtonRec->isChecked())
    me.createRectangularArray(modelelements, multx, multy, metabkeys);
  
  accept();

  
  // std::string name =  static_cast<std::string >(mpBoxCompartmentName->currentText().toUtf8());     //toStdString();

}
Exemplo n.º 2
0
void CQCompartment::copy()
{
  CModel * pModel = mpDataModel->getModel();
  CModelExpansion cModelExpObj = CModelExpansion(pModel);
  CModelExpansion::SetOfModelElements compartmentObjectsToCopy;
  CModelExpansion::ElementsMap origToCopyMappings;

  CQCompartmentCopyOptions * pDialog = new CQCompartmentCopyOptions(this);
  pDialog->exec();

  bool success = false;

  switch (pDialog->result())
    {
      case QDialog::Rejected:
        break;

      case CQCompartmentCopyOptions::COMP:      //compartment only

        compartmentObjectsToCopy.addObject(mpObject);
        success = true;
        break;

      case CQCompartmentCopyOptions::SPECIES: // include the species
      {
        compartmentObjectsToCopy.addObject(mpObject);
        CDataVectorNS < CMetab > & Metabolites = mpCompartment->getMetabolites();
        CDataVectorNS < CMetab >::const_iterator itMetab;

        for (itMetab = Metabolites.begin(); itMetab != Metabolites.end(); ++itMetab)
          {
            compartmentObjectsToCopy.addMetab(itMetab);
          }
      }

      success = true;
      break;

      case CQCompartmentCopyOptions::INTREAC:    //also include the internal reactions
      {
        compartmentObjectsToCopy.addObject(mpObject);

        // Get all the compartment's species first
        CDataVectorNS < CMetab > & Metabolites = mpCompartment->getMetabolites();
        CDataVectorNS < CMetab >::const_iterator itMetab;

        for (itMetab = Metabolites.begin(); itMetab != Metabolites.end(); ++itMetab)
          {
            compartmentObjectsToCopy.addMetab(itMetab);
          }

        // Now get the reactions which are not multi-compartment
        CDataVectorN< CReaction >::const_iterator it = pModel->getReactions().begin();
        CDataVectorN< CReaction >::const_iterator end = pModel->getReactions().end();
        CReactionInterface * pRi = new CReactionInterface();

        for (; it != end; ++it)
          {
            pRi->init(*it);

            if (!pRi->isMulticompartment())
              {
                if (pRi->getChemEqInterface().getCompartment()->getCN() == mObjectCN)
                  compartmentObjectsToCopy.addReaction(it);
              }
          }

        pdelete(pRi);
        success = true;
        break;
      }

      case CQCompartmentCopyOptions::ALLREAC:    //get everything in compartment

        compartmentObjectsToCopy.addObject(mpObject);
        compartmentObjectsToCopy.fillDependencies(pModel);
        success = true;
        break;
    }

  pdelete(pDialog);

  if (success)
    {
      CUndoData UndoData(cModelExpObj.duplicate(compartmentObjectsToCopy, "_copy", origToCopyMappings));
      const CDataObject * pObject = origToCopyMappings.getDuplicateFromObject(mpObject);

      ListViews::addUndoMetaData(this, UndoData);
      UndoData.addMetaDataProperty("Widget Object CN (after)", pObject->getCN());
      UndoData.addMetaDataProperty("Widget Object Name (after)", pObject->getObjectName());

      slotNotifyChanges(mpDataModel->recordData(UndoData));

      if (pObject != NULL)
        {
          mpListView->switchToOtherWidget(ListViews::WidgetType::CompartmentDetail, pObject->getCN());
        }
    }
}
Exemplo n.º 3
0
void CQCompartment::copy()
{
  CModel * pModel = mpDataModel->getModel();
  CModelExpansion cModelExpObj = CModelExpansion(pModel);
  CModelExpansion::SetOfModelElements compartmentObjectsToCopy;
  CModelExpansion::ElementsMap origToCopyMappings;

  CQCompartmentCopyOptions * pDialog = new CQCompartmentCopyOptions(this);
  pDialog->exec();

  bool success = false;

  switch (pDialog->result())
    {
      case QDialog::Rejected:
        break;

      case CQCompartmentCopyOptions::COMP:      //compartment only

        compartmentObjectsToCopy.addObject(mpObject);
        success = true;
        break;

      case CQCompartmentCopyOptions::SPECIES: // include the species
      {
        compartmentObjectsToCopy.addObject(mpObject);
        CCopasiVectorNS < CMetab > & Metabolites = mpCompartment->getMetabolites();
        CCopasiVectorNS < CMetab >::const_iterator itMetab;

        for (itMetab = Metabolites.begin(); itMetab != Metabolites.end(); ++itMetab)
          {
            compartmentObjectsToCopy.addMetab(*itMetab);
          }
      }

      success = true;
      break;

      case CQCompartmentCopyOptions::INTREAC:    //also include the internal reactions
      {
        compartmentObjectsToCopy.addObject(mpObject);

        // Get all the compartment's species first
        CCopasiVectorNS < CMetab > & Metabolites = mpCompartment->getMetabolites();
        CCopasiVectorNS < CMetab >::const_iterator itMetab;

        for (itMetab = Metabolites.begin(); itMetab != Metabolites.end(); ++itMetab)
          {
            compartmentObjectsToCopy.addMetab(*itMetab);
          }

        // Now get the reactions which are not multi-compartment
        CCopasiVectorN< CReaction >::const_iterator it = pModel->getReactions().begin();
        CCopasiVectorN< CReaction >::const_iterator end = pModel->getReactions().end();
        CReactionInterface * pRi = new CReactionInterface(pModel);

        for (; it != end; ++it)
          {
            pRi->initFromReaction((*it)->getKey());

            if (!pRi->isMulticompartment())
              {
                if (pRi->getChemEqInterface().getCompartment()->getKey() == mKey)
                  compartmentObjectsToCopy.addReaction(*it);
              }
          }

        pdelete(pRi);
        success = true;
        break;
      }

      case CQCompartmentCopyOptions::ALLREAC:    //get everything in compartment

        compartmentObjectsToCopy.addObject(mpObject);
        compartmentObjectsToCopy.fillDependencies(pModel);
        success = true;
        break;
    }

  pdelete(pDialog);

  if (success)
    {
      cModelExpObj.duplicate(compartmentObjectsToCopy, "_copy", origToCopyMappings);

      protectedNotify(ListViews::COMPARTMENT, ListViews::DELETE, "");//Refresh all
      protectedNotify(ListViews::METABOLITE, ListViews::DELETE, ""); //Refresh all
      protectedNotify(ListViews::REACTION, ListViews::DELETE, "");   //Refresh all
      mpListView->switchToOtherWidget(C_INVALID_INDEX, origToCopyMappings.getDuplicateKey(mKey));
    }
}