Esempio n. 1
0
void CQPlotSubwidget::copyPlot()
{
  leaveProtected();
  CDataModel *pDataModel = mpObject->getObjectDataModel();

  if (pDataModel == NULL) return;

  CPlotSpecification *pPl = new CPlotSpecification(*dynamic_cast<CPlotSpecification *>(mpObject), NO_PARENT);
  std::string baseName = pPl->getObjectName() + "_copy";
  std::string name = baseName;
  int i = 1;

  while (pDataModel->getPlotDefinitionList()->getIndex(name) != C_INVALID_INDEX)
    {
      i++;
      name = baseName + TO_UTF8(QString::number(i));
    }

  pPl->setObjectName(name);
  pDataModel->getPlotDefinitionList()->add(pPl, true);
  std::string cn = pPl->CCopasiParameter::getCN();
  protectedNotify(ListViews::ObjectType::PLOT, ListViews::ADD, cn);
  enter(cn);
  mpListView->switchToOtherWidget(ListViews::WidgetType::PlotDetail, cn);
}
CPlotSpecification* COutputDefinitionVector::createPlotSpec(const std::string & name,
    CPlotItem::Type type)
{
  unsigned C_INT32 i;
  for (i = 0; i < size(); i++)
    if ((*this)[i]->getObjectName() == name)
      return NULL; // duplicate name

  CPlotSpecification* pNewPlotSpec = new CPlotSpecification(name, this, type);
  pNewPlotSpec->setObjectName(name);

  add(pNewPlotSpec);
  return pNewPlotSpec;
}