Beispiel #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();

}
Beispiel #2
0
void CQSpeciesDetail::copy()
{
  if (mpMetab == NULL) return;

  CModel * pModel = NULL;
  if (mpMetab) pModel = mpDataModel->getModel();

  if (pModel == NULL) return; // for getting compartments and initializing cModelExpObj

  // Create and customize compartment choices dialog
  CQNameSelectionDialog * pDialog = new CQNameSelectionDialog(this);
  pDialog->setWindowTitle("Choose a compartment");
  pDialog->mpLblName->setText("compartment");
  pDialog->mpSelectionBox->clear();
  pDialog->mpSelectionBox->setDuplicatesEnabled(false);
  pDialog->mpSelectionBox->setEditable(false); // at least for now, unless we want to add new compartment creation here.

  // Use CModelExpansion for duplication
  CModelExpansion cModelExpObj = CModelExpansion(pModel);
  CModelExpansion::SetOfModelElements sourceObjects;
  CModelExpansion::ElementsMap origToCopyMapping;

  // for comboBox compartment list and setting compartment
  CCopasiVectorNS< CCompartment > & Compartments = pModel->getCompartments();

  CCopasiVectorN< CCompartment >::const_iterator it = Compartments.begin();
  CCopasiVectorN< CCompartment >::const_iterator end = Compartments.end();
  QStringList SelectionList;

  // Collect and load list of compartment names in comboBox
  for (; it != end; ++it)
    {
      SelectionList.append(FROM_UTF8((*it)->getObjectName()));
    }

  pDialog->setSelectionList(SelectionList);

  //Set the current compartment as the default
  mpCurrentCompartment = mpMetab->getCompartment();
  // to use here, and for testing if compartment changed after executing the dialog
  int origCompartmentIndex = pDialog->mpSelectionBox->findText(FROM_UTF8(mpCurrentCompartment->getObjectName()));
  pDialog->mpSelectionBox->setCurrentIndex(origCompartmentIndex);

  it = Compartments.begin(); // Reuse Compartments iterator to set compartment choice

  if (pDialog->exec() != QDialog::Rejected)
    {
      // Put species in different compartment (without name modification) by making
      // duplicateMetab think the other compartment was duplicated from the original
      if(origCompartmentIndex != pDialog->mpSelectionBox->currentIndex())
        {
          sourceObjects.addCompartment(mpMetab->getCompartment());
          origToCopyMapping.add(mpMetab->getCompartment(),*(it + pDialog->mpSelectionBox->currentIndex()));
        }

      sourceObjects.addMetab(mpMetab);
      cModelExpObj.duplicateMetab(mpMetab, "_copy", sourceObjects, origToCopyMapping);

      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, origToCopyMapping.getDuplicateKey(mKey));
    }

  pdelete(pDialog);
}