Example #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;
}
Example #3
0
bool CQPlotSubwidget::saveToPlotSpec()
{
  CPlotSpecification *pspec = dynamic_cast< CPlotSpecification * >(mpObject);

  if (!pspec) return true;

  pspec->cleanup();

  //title
  if (pspec->getTitle() != TO_UTF8(titleLineEdit->text()))
    {
      pspec->setTitle(TO_UTF8(titleLineEdit->text()));
      protectedNotify(ListViews::ObjectType::PLOT, ListViews::RENAME, mObjectCN);
    }

  //active?
  pspec->setActive(activeCheckBox->isChecked());
  //scales
  pspec->setLogX(checkLogX->isChecked());
  pspec->setLogY(checkLogY->isChecked());
  // task types
  pspec->setTaskTypes(mTaskTypes);

  //curves
  CPlotItem *item;
  storeChanges();
  QMap<QString, CPlotItem *>::iterator it;

  for (it = mList.begin(); it != mList.end(); ++it)
    {
      CPlotItem *currentItem = (*it);

      if (currentItem == NULL) continue;

      item = new CPlotItem(*currentItem, NO_PARENT);
      pspec->getItems().add(item, true);
    }

  // :TODO Bug 322: This should only be called when actual changes have been saved.
  // However we do not check whether the scan item are changed we delete all
  // and create them new.
  if (true)
    {
      if (mpDataModel != NULL)
        {
          mpDataModel->changed();
        }

      // mChanged = false;
    }

  return true;
}
Example #4
0
void CQPlotsWidget::slotBtnDeactivateAllClicked()
{
  CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];
  assert(pDataModel != NULL);

  if (!pDataModel->getModel())
    return;

  for (size_t i = 0; i < pDataModel->getPlotDefinitionList()->size(); i++)
    {
      CPlotSpecification *pPS = static_cast<CPlotSpecification *>(pDataModel->getPlotDefinitionList()->operator[](i));
      pPS->setActive(false);
    }

  mpTblPlots->doItemsLayout();
}
Example #5
0
CPlotSpecification::CPlotSpecification(const CPlotSpecification & src,
                                       const CCopasiContainer * pParent):
    CPlotItem(src, pParent),
    items(src.getItems(), this),
    mActive(src.mActive)
{initObjects();}