Пример #1
0
void CQCompartment::deleteCompartment()
{
  if (mpCompartment == NULL) return;

  QMessageBox::StandardButton choice =
    CQMessageBox::confirmDelete(this, "compartment",
                                FROM_UTF8(mpCompartment->getObjectName()),
                                mpCompartment->getDeletedObjects());

  switch (choice)
    {
      case QMessageBox::Ok:
      {
        CModel * pModel = mpCompartment->getModel();
        assert(pModel != NULL);
        pModel->removeCompartment(mKey);

        protectedNotify(ListViews::COMPARTMENT, ListViews::DELETE, mKey);
        protectedNotify(ListViews::COMPARTMENT, ListViews::DELETE, ""); //Refresh all as there may be dependencies.
        break;
      }

      default:
        break;
    }

  switchToWidget(CCopasiUndoCommand::COMPARTMENTS);
}
Пример #2
0
void CQSpeciesDetail::slotBtnDelete()
{
  if (mpMetab == NULL) return;

  CModel * pModel = const_cast< CModel *>(mpMetab->getModel());

  if (pModel == NULL) return;

  QMessageBox::StandardButton choice =
    CQMessageBox::confirmDelete(this, "species",
                                FROM_UTF8(mpMetab->getObjectName()),
                                mpMetab->getDeletedObjects());

  switch (choice)
    {
      case QMessageBox::Ok:
      {
        pModel->removeMetabolite(mKey);

#undef DELETE
        protectedNotify(ListViews::METABOLITE, ListViews::DELETE, mKey);
        protectedNotify(ListViews::METABOLITE, ListViews::DELETE, "");//Refresh all as there may be dependencies.
        //TODO notify about reactions
        break;
      }

      default:
        break;
    }
}
Пример #3
0
//! Slot for being activated whenever Delete button is clicked
void FunctionWidget1::slotBtnDelete()
{
  CFunctionDB * pFunctionDB = CCopasiRootContainer::getFunctionList();

  if (pFunctionDB == NULL)
    return;

  CEvaluationTree * pFunction = dynamic_cast<CEvaluationTree *>(CCopasiRootContainer::getKeyFactory()->get(mKey));

  if (pFunction == NULL)
    return;

  QMessageBox::StandardButton choice =
    CQMessageBox::confirmDelete(NULL, "function",
                                FROM_UTF8(pFunction->getObjectName()),
                                pFunction->getDeletedObjects());

  /* Check if user chooses to deleted Functions */
  switch (choice)
    {
      case QMessageBox::Ok:                                                    // Yes or Enter
      {
        CCopasiRootContainer::getFunctionList()->removeFunction(mKey);

        protectedNotify(ListViews::FUNCTION, ListViews::DELETE, mKey);
        protectedNotify(ListViews::FUNCTION, ListViews::DELETE, "");//Refresh all as there may be dependencies.
        break;
      }

      default:                                                    // No or Escape
        break;
    }
}
Пример #4
0
void CQCompartment::deleteCompartment()
{

  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
  CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];
  assert(pDataModel != NULL);
  CModel * pModel = pDataModel->getModel();

  if (pModel == NULL) return;

  if (mpCompartment == NULL) return;

  QMessageBox::StandardButton choice =
    CQMessageBox::confirmDelete(this, "compartment",
                                FROM_UTF8(mpCompartment->getObjectName()),
                                mpCompartment->getDeletedObjects());

  switch (choice)
    {
      case QMessageBox::Ok:
      {
        pDataModel->getModel()->removeCompartment(mKey);

        protectedNotify(ListViews::COMPARTMENT, ListViews::DELETE, mKey);
        protectedNotify(ListViews::COMPARTMENT, ListViews::DELETE, ""); //Refresh all as there may be dependencies.
        break;
      }

      default:
        break;
    }

  mpListView->switchToOtherWidget(111, "");
}
Пример #5
0
void CQCompartment::slotBtnDelete()
{
  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
  CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];
  assert(pDataModel != NULL);
  CModel * pModel = pDataModel->getModel();

  if (pModel == NULL) return;

  if (mpCompartment == NULL) return;

  QMessageBox::StandardButton choice =
    CQMessageBox::confirmDelete(this, "compartment",
                                FROM_UTF8(mpCompartment->getObjectName()),
                                mpCompartment->getDeletedObjects());

  switch (choice)
    {
      case QMessageBox::Ok:
      {
        unsigned C_INT32 Index =
          pDataModel->getModel()->getCompartments().getIndex(mpCompartment->getObjectName());
        pDataModel->getModel()->removeCompartment(mKey);
        std::string deletedKey = mKey;
        //std::string moveToKey = "";

        unsigned C_INT32 Size =
          pDataModel->getModel()->getCompartments().size();

        QObject *pParent = parent();
        CTabWidget * pTabWidget = NULL;

        while (pParent != NULL &&
               (pTabWidget = dynamic_cast< CTabWidget *>(pParent)) == NULL)
          {
            pParent = pParent->parent();
          }

        if (pTabWidget != NULL)
          {
            if (Size > 0)
              pTabWidget->enter(pDataModel->getModel()->getCompartments()[std::min(Index, Size - 1)]->getKey());
            else
              pTabWidget->enter("");
          }

        protectedNotify(ListViews::COMPARTMENT, ListViews::DELETE, deletedKey);
        protectedNotify(ListViews::COMPARTMENT, ListViews::DELETE, ""); //Refresh all as there may be dependencies.
        break;
      }

      default:
        break;
    }
}
Пример #6
0
void CQSpeciesDetail::slotBtnDelete()
{
  if (mpMetab == NULL) return;

  CModel * pModel = const_cast< CModel *>(mpMetab->getModel());

  if (pModel == NULL) return;

  QMessageBox::StandardButton choice =
    CQMessageBox::confirmDelete(this, "species",
                                FROM_UTF8(mpMetab->getObjectName()),
                                mpMetab->getDeletedObjects());

  switch (choice)
    {
      case QMessageBox::Ok:
      {
        unsigned C_INT32 index =
          pModel->getMetabolites().getIndex(CCopasiRootContainer::getKeyFactory()->get(mKey));

        pModel->removeMetabolite(mKey);
        std::string deletedKey = mKey;

        unsigned C_INT32 size =
          pModel->getMetabolites().size();

        QObject *pParent = parent();
        CTabWidget * pTabWidget = NULL;

        while (pParent != NULL &&
               (pTabWidget = dynamic_cast< CTabWidget *>(pParent)) == NULL)
          {
            pParent = pParent->parent();
          }

        if (pTabWidget != NULL)
          {
            if (size > 0)
              pTabWidget->enter(pModel->getMetabolites()[std::min(index, size - 1)]->getKey());
            else
              pTabWidget->enter("");
          }

#undef DELETE
        protectedNotify(ListViews::METABOLITE, ListViews::DELETE, deletedKey);
        protectedNotify(ListViews::METABOLITE, ListViews::DELETE, "");//Refresh all as there may be dependencies.
        //TODO notify about reactions
        break;
      }

      default:
        break;
    }
}
Пример #7
0
/// Slot to create a new event; activated whenever the New button is clicked
void CQEventWidget1::slotBtnNew()
{
#ifdef COPASI_UNDO
  mpUndoStack->push(new CreateNewEventCommand(this));
#else
  // save the current setting values
  saveToEvent();

  // standard name
  std::string name = "event_1";

  // if the standard name already exists then creating the new event will fail
  // thus, a growing index will automatically be added to the standard name
  int i = 1;
  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);

  while (!(*CCopasiRootContainer::getDatamodelList())[0]->getModel()->createEvent(name))
    {
      i++;
      name = "event_";
      name += TO_UTF8(QString::number(i));
    }

  std::string key = (*CCopasiRootContainer::getDatamodelList())[0]->getModel()->getEvents()[name]->getKey();
  protectedNotify(ListViews::EVENT, ListViews::ADD, key);
  mpListView->switchToOtherWidget(C_INVALID_INDEX, key);
#endif
}
Пример #8
0
void CQReportDefinition::btnCopyReportClicked()
{
  btnCommitClicked();

  CCopasiDataModel* pDataModel = mpObject->getObjectDataModel();

  if (pDataModel == NULL) return;

  CReportDefinition * pRep = new CReportDefinition(*dynamic_cast<CReportDefinition*>(CCopasiRootContainer::getKeyFactory()->get(mKey)));

  std::string baseName = pRep->getObjectName() + "_copy";
  std::string name = baseName;

  int i = 1;

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

  pRep->setObjectName(name);

  pDataModel->getReportDefinitionList()->add(pRep, true);

  std::string key = pRep->getKey();
  protectedNotify(ListViews::REPORT, ListViews::ADD, key);
  enter(key);
  mpListView->switchToOtherWidget(C_INVALID_INDEX, key);
}
Пример #9
0
void CQCompartment::slotBtnNew()
{
#ifdef COPASI_UNDO
  mpUndoStack->push(new CreateNewCompartmentCommand(this));
#else
  leave();

  std::string name = "compartment_1";
  int i = 1;

  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);

  while (!(mpCompartment = (*CCopasiRootContainer::getDatamodelList())[0]->getModel()->createCompartment(name)))
    {
      i++;
      name = "compartment_";
      name += TO_UTF8(QString::number(i));
    }

  std::string key = mpCompartment->getKey();

  protectedNotify(ListViews::COMPARTMENT, ListViews::ADD, key);
  mpListView->switchToOtherWidget(C_INVALID_INDEX, key);

#endif
}
Пример #10
0
void CQPlotSubwidget::deletePlot()
{
  size_t Index, Size;
  assert(mpDataModel != NULL);

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

  CPlotSpecification *pspec = dynamic_cast< CPlotSpecification * >(mpObject);

  if (!pspec) return;

  Index = mpDataModel->getPlotDefinitionList()->CDataVector<CPlotSpecification>::getIndex(pspec);
  mpDataModel->getPlotDefinitionList()->CDataVector<CPlotSpecification>::remove(Index);

  std::string deletedObjectCN = mObjectCN;

  Size = mpDataModel->getPlotDefinitionList()->size();

  if (Size > 0)
    enter(mpDataModel->getPlotDefinitionList()->operator[](std::min(Index, Size - 1)).getCN());
  else
    enter(std::string());

  //ListViews::
  protectedNotify(ListViews::ObjectType::PLOT, ListViews::DELETE, deletedObjectCN);
}
Пример #11
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);
}
Пример #12
0
bool CQTabWidget::save()
{
  // mpObject can not be trusted
  mpObject = CCopasiRootContainer::getKeyFactory()->get(mKey);

  if (mpObject == NULL) return false;

  if (mpObject->getObjectName() != TO_UTF8(mpEditName->text()))
    {
      if (!mpObject->setObjectName(TO_UTF8(mpEditName->text())))
        {
          QString msg;
          msg = "Unable to rename " + FROM_UTF8(ListViews::ObjectTypeName[mObjectType]).toLower() + " '" + FROM_UTF8(mpObject->getObjectName()) + "'\n"
                + "to '" + mpEditName->text() + "' since a " + FROM_UTF8(ListViews::ObjectTypeName[mObjectType]).toLower() + " with that name already exists.\n";

          CQMessageBox::information(this,
                                    "Unable to rename " + FROM_UTF8(ListViews::ObjectTypeName[mObjectType]),
                                    msg,
                                    QMessageBox::Ok, QMessageBox::Ok);

          mpEditName->setText(FROM_UTF8(mpObject->getObjectName()));
        }
      else
        {
          protectedNotify(mObjectType, ListViews::RENAME, mKey);

          if (mpDataModel != NULL)
            {
              mpDataModel->changed();
            }
        }
    }

  return true;
}
Пример #13
0
void ReactionsWidget1::slotNewFunction()
{
  // FunctionWidget1 * fw = new FunctionWidget1(NULL);
  // fw->show();
  // TODO: we could think about calling the function widget as a dialogue here...

  std::string name = std::string("Rate Law for ") + mpObject->getObjectName();
  std::string nname = name;
  size_t i = 0;
  CCopasiVectorN<CFunction>& FunctionList
    = CCopasiRootContainer::getFunctionList()->loadedFunctions();
  CFunction* pFunc;

  while (FunctionList.getIndex(nname) != C_INVALID_INDEX)
    {
      i++;
      nname = name + "_";
      nname += TO_UTF8(QString::number(i));
    }

  CCopasiRootContainer::getFunctionList()->add(pFunc = new CKinFunction(nname), true);
  protectedNotify(ListViews::FUNCTION, ListViews::ADD, pFunc->getKey());

  mpListView->switchToOtherWidget(C_INVALID_INDEX, pFunc->getKey());
}
Пример #14
0
bool TaskWidget::commonAfterRunTask()
{
  if (!mpTask) return false;

  if (mProgressBar != NULL)
    {
      mProgressBar->finish();
      mProgressBar->deleteLater();
      mProgressBar = NULL;
    }

  mpTask->setCallBack(NULL);

  CCopasiMessage::clearDeque();

  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
  (*CCopasiRootContainer::getDatamodelList())[0]->finish();

  // Update all values shown in the GUI
  CModel * pModel = (*CCopasiRootContainer::getDatamodelList())[0]->getModel();
  pModel->updateSimulatedValues(true);
  pModel->updateNonSimulatedValues();

  protectedNotify(ListViews::STATE, ListViews::CHANGE, (*CCopasiRootContainer::getDatamodelList())[0]->getModel()->getKey());
  unsetCursor();
  CopasiUI3Window::getMainWindow()->suspendAutoSave(false);

  return loadTask();
}
Пример #15
0
//Undo methods
void CQSpeciesDetail::createNewSpecies()
{
  GET_MODEL_OR_RETURN(pModel);

  leave();

  if (pModel->getCompartments().size() == 0)
    pModel->createCompartment("compartment");

  std::string name = "species_1";
  int i = 1;

  while (!(mpMetab = pModel->createMetabolite(name, "", 1.0, CModelEntity::REACTIONS)))
    {
      i++;
      name = "species_";
      name += TO_UTF8(QString::number(i));
    }

  switch (mFramework)
    {
      case 0:
        mpMetab->setInitialConcentration(1.0);
        break;

      case 1:
        mpMetab->setInitialValue(100.0);
        break;
    }

  std::string key = mpMetab->getKey();
  protectedNotify(ListViews::METABOLITE, ListViews::ADD, key);
  mpListView->switchToOtherWidget(C_INVALID_INDEX, key);
}
Пример #16
0
void CQSpeciesDetail::deleteSpecies(UndoSpeciesData *pSData)
{
  GET_MODEL_OR_RETURN(pModel);

  switchToWidget(CCopasiUndoCommand::SPECIES);

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

  if (pSpecies == NULL) return;

  std::string key = pSpecies->getKey();
  pModel->removeMetabolite(key);

#undef DELETE
  protectedNotify(ListViews::METABOLITE, ListViews::DELETE, key); //mKey);
  protectedNotify(ListViews::METABOLITE, ListViews::DELETE, "");//Refresh all as there may be dependencies.
}
Пример #17
0
void CQCompartment::addCompartment(UndoCompartmentData *pData)
{
  //reinsert all the Compartments
  CModel * pModel = mpCompartment->getModel();
  assert(pModel != NULL);
  pData->restoreObjectIn(pModel);
  protectedNotify(ListViews::COMPARTMENT, ListViews::ADD, pData->getKey());
  switchToWidget(C_INVALID_INDEX, pData->getKey());
}
Пример #18
0
void CQNotes::save()
{
  if (mpObject != NULL &&
      mValidity == QValidator::Acceptable)
    {
      const std::string * pNotes = NULL;

      if (dynamic_cast< CModelEntity * >(mpObject))
        pNotes = &static_cast< CModelEntity * >(mpObject)->getNotes();
      else if (dynamic_cast< CEvent * >(mpObject))
        pNotes = &static_cast< CEvent * >(mpObject)->getNotes();
      else if (dynamic_cast< CReaction * >(mpObject))
        pNotes = &static_cast< CReaction * >(mpObject)->getNotes();
      else if (dynamic_cast< CFunction * >(mpObject))
        pNotes = &static_cast< CFunction * >(mpObject)->getNotes();
      else if (dynamic_cast< CReportDefinition * >(mpObject))
        pNotes = & static_cast< CReportDefinition * >(mpObject)->getComment();

      if (pNotes &&
          mpEdit->toPlainText() != FROM_UTF8(*pNotes))
        {
          std::string PlainText = TO_UTF8(mpEdit->toPlainText());

          if (mpValidatorXML->needsWrap())
            {
              // We wrap the HTML in a body element if it does not contain a top level html or body element.
              PlainText = "<body xmlns=\"http://www.w3.org/1999/xhtml\">" + PlainText + "</body>";
            }

          if (dynamic_cast< CModelEntity * >(mpObject))
            static_cast< CModelEntity * >(mpObject)->setNotes(PlainText);
          else if (dynamic_cast< CEvent * >(mpObject))
            static_cast< CEvent * >(mpObject)->setNotes(PlainText);
          else if (dynamic_cast< CReaction * >(mpObject))
            static_cast< CReaction * >(mpObject)->setNotes(PlainText);
          else if (dynamic_cast< CFunction * >(mpObject))
            static_cast< CFunction * >(mpObject)->setNotes(PlainText);
          else if (dynamic_cast< CReportDefinition * >(mpObject))
            static_cast< CReportDefinition * >(mpObject)->setComment(PlainText);

          mChanged = true;
        }
    }

  if (mChanged)
    {
      if (mpDataModel != NULL)
        {
          mpDataModel->changed();
        }

      protectedNotify(ListViews::MODEL, ListViews::CHANGE, mKey);
      mChanged = false;
    }

  return;
}
Пример #19
0
void CQCompartment::deleteCompartment(UndoCompartmentData *pCompartmentData)
{
  switchToWidget(CCopasiUndoCommand::COMPARTMENTS);

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

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

  if (pComp == NULL) return;

  std::string key = pComp->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.
}
Пример #20
0
void CQNotes::save()
{
  if (mpObject != NULL &&
      mValidity == QValidator::Acceptable)
    {
      QString Notes;

      CAnnotation * pAnnotation = CAnnotation::castObject(mpObject);
      CReportDefinition * pReportDefinition = static_cast< CReportDefinition * >(mpObject);

      if (pAnnotation != NULL)
        {
          Notes = FROM_UTF8(pAnnotation->getNotes());
        }
      else if (pReportDefinition != NULL)
        {
          Notes = FROM_UTF8(pReportDefinition->getComment());
        }

      if (mpEdit->toPlainText() != Notes)
        {
          std::string PlainText = TO_UTF8(mpEdit->toPlainText());

          if (mpValidatorXML->needsWrap())
            {
              // We wrap the HTML in a body element if it does not contain a top level html or body element.
              PlainText = "<body xmlns=\"http://www.w3.org/1999/xhtml\">" + PlainText + "</body>";
            }

          if (pAnnotation != NULL)
            {
              pAnnotation->setNotes(PlainText);
            }
          else if (pReportDefinition != NULL)
            {
              pReportDefinition->setComment(PlainText);
            }

          mChanged = true;
        }
    }

  if (mChanged)
    {
      if (mpDataModel != NULL)
        {
          mpDataModel->changed();
        }

      protectedNotify(ListViews::MODEL, ListViews::CHANGE, mKey);
      mChanged = false;
    }

  return;
}
Пример #21
0
void CQReportDefinition::btnDeleteReportClicked()
{
    if (mpDataModel == NULL)
        return;

    std::set< const CCopasiObject * > Tasks;
    std::set< const CCopasiObject * > DeletedObjects;
    DeletedObjects.insert(mpObject);

    QMessageBox::StandardButton choice =
        CQMessageBox::confirmDelete(this, "report",
                                    FROM_UTF8(mpObject->getObjectName()),
                                    DeletedObjects);

    switch (choice)
    {
    case QMessageBox::Ok:
    {
        CCopasiVector< CReportDefinition > * pReportList = mpDataModel->getReportDefinitionList();

        if (pReportList == NULL)
            return;

        if (mpDataModel->appendDependentTasks(DeletedObjects, Tasks))
        {
            std::set< const CCopasiObject * >::iterator it = Tasks.begin();
            std::set< const CCopasiObject * >::iterator end = Tasks.end();

            for (; it != end; ++it)
            {
                const CCopasiTask * pTask = static_cast< const CCopasiTask *>(*it);
                const_cast< CCopasiTask * >(pTask)->getReport().setReportDefinition(NULL);
            }
        }

        size_t Index = pReportList->getIndex(mpObject);
        std::string DeletedKey = mpObject->getKey();

        pReportList->remove(Index);

        size_t Size = pReportList->size();

        if (Size > 0)
            enter((*pReportList)[std::min(Index, Size - 1)]->getKey());
        else
            enter("");

        protectedNotify(ListViews::REPORT, ListViews::DELETE, DeletedKey);
        break;
    }

    default:
        break;
    }
}
Пример #22
0
void CQEventWidget1::deleteEvent(UndoEventData *pEventData)
{
  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
  CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];
  assert(pDataModel != NULL);

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

  CEvent * pEvent = pModel->getEvents()[pEventData->getName()];
  std::string key = pEvent->getKey();
  pModel->removeEvent(key);
  mpEvent = NULL;

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

  mpListView->switchToOtherWidget(116, "");
}
Пример #23
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;
}
Пример #24
0
// Just added 5/18/04
void ReactionsWidget1::slotBtnDelete()
{
  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
  CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];
  assert(pDataModel != NULL);
  CModel * pModel = pDataModel->getModel();

  if (pModel == NULL)
    return;

  CReaction * pReaction =
    dynamic_cast< CReaction * >(CCopasiRootContainer::getKeyFactory()->get(mKey));

  if (pReaction == NULL) return;

  QMessageBox::StandardButton choice =
    CQMessageBox::confirmDelete(NULL, "reaction",
                                FROM_UTF8(pReaction->getObjectName()),
                                pReaction->getDeletedObjects());

  switch (choice)
    {
      case QMessageBox::Ok:                                                     // Yes or Enter
      {
        pDataModel->getModel()->removeReaction(mKey);

        mpRi->setFunctionWithEmptyMapping("");

        protectedNotify(ListViews::REACTION, ListViews::DELETE, mKey);
        protectedNotify(ListViews::REACTION, ListViews::DELETE, "");//Refresh all as there may be dependencies.
        break;
      }

      default:                                                     // No or Escape
        break;
    }
}
Пример #25
0
void CQCompartment::slotBtnDelete()
{
#ifdef COPASI_UNDO
  mpUndoStack->push(new DeleteCompartmentCommand(this));
#else
  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
  CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];
  assert(pDataModel != NULL);
  CModel * pModel = pDataModel->getModel();

  if (pModel == NULL) return;

  if (mpCompartment == NULL) return;

  QMessageBox::StandardButton choice =
    CQMessageBox::confirmDelete(this, "compartment",
                                FROM_UTF8(mpCompartment->getObjectName()),
                                mpCompartment->getDeletedObjects());

  switch (choice)
    {
      case QMessageBox::Ok:
      {
        pDataModel->getModel()->removeCompartment(mKey);

        protectedNotify(ListViews::COMPARTMENT, ListViews::DELETE, mKey);
        protectedNotify(ListViews::COMPARTMENT, ListViews::DELETE, ""); //Refresh all as there may be dependencies.
        break;
      }

      default:
        break;
    }

#endif
}
Пример #26
0
bool ScanWidget::taskFinishedEvent()
{
  if (!mpTask) return false;

  CScanProblem* pProblem = dynamic_cast<CScanProblem*>(mpTask->getProblem());

  if (!pProblem) return false;

  if (pProblem->getSubtask() != CTaskEnum::Task::parameterFitting)
    return false;

  protectedNotify(ListViews::ObjectType::MODELPARAMETERSET, ListViews::ADD);

  return true;
}
Пример #27
0
void CQSpeciesDetail::addSpecies(UndoSpeciesData *pSData)
{
  GET_MODEL_OR_RETURN(pModel);

  //reinsert the species
  CMetab *pSpecies =  pSData->restoreObjectIn(pModel);

  if (pSpecies == NULL)
    return;

  std::string key = pSpecies->getKey();

  protectedNotify(ListViews::METABOLITE, ListViews::ADD, key);

  mpListView->switchToOtherWidget(C_INVALID_INDEX, key);
}
Пример #28
0
void TaskWidget::assistantBtnClicked()
{
  if (!mpTask) return;

  saveTask(); //this is necessary since the output may use information from the problem

  DefaultPlotDialog * pDlg = new DefaultPlotDialog(this);
  pDlg->setTask(mpTask);

  if (pDlg->exec() == QDialog::Accepted)
    {
      protectedNotify(ListViews::ObjectType::PLOT, ListViews::ADD, std::string());
    }

  if (pDlg)delete pDlg;
}
Пример #29
0
bool FunctionWidget1::saveToFunction()
{
  CFunction* func = dynamic_cast<CFunction*>(CCopasiRootContainer::getKeyFactory()->get(mKey));

  if (!func) return false;

  //radio buttons
  TriLogic tmpl;

  if (RadioButton1->isChecked() == true)
    {
      tmpl = TriTrue;
    }
  else if (RadioButton2->isChecked() == true)
    {
      tmpl = TriFalse;
    }
  else
    {
      tmpl = TriUnspecified;
    }

  if (tmpl != func->isReversible())
    {
      func->setReversible(tmpl);
      flagChanged = true;
    }

  if (flagChanged)
    {
      copyFunctionContentsToFunction(mpFunction, func);

      protectedNotify(ListViews::FUNCTION, ListViews::CHANGE, mKey);

      if (mpDataModel != NULL)
        {
          mpDataModel->changed();
        }

      flagChanged = false;
    }

  func->compile();

  return true;
}
Пример #30
0
void CQEventWidget1::deleteEvent()
{

  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
  CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];

  CModel * pModel = pDataModel->getModel();

  if (pModel == NULL)
    return;

  pDataModel->getModel()->removeEvent(mKey);

  mpEvent = NULL;

  protectedNotify(ListViews::EVENT, ListViews::DELETE, mKey);
  mpListView->switchToOtherWidget(116, "");
}