Example #1
0
/*
 *  Constructs a CQGlobalQuantitiesWidget which is a child of 'parent', with the
 *  name 'name'.'
 */
CQGlobalQuantitiesWidget::CQGlobalQuantitiesWidget(QWidget* parent, const char* name)
  : CopasiWidget(parent, name)
{
  setupUi(this);

  //Create Source Data Model.
  mpGlobalQuantityDM = new CQGlobalQuantityDM(this);

  //Create the Proxy Model for sorting/filtering and set its properties.
  mpProxyModel = new CQSortFilterProxyModel();
  mpProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
  mpProxyModel->setFilterKeyColumn(-1);

  //Setting values for Types comboBox
  mpTypeDelegate = new CQIndexComboDelegate(this, mpGlobalQuantityDM->getTypes());
  mpTblGlobalQuantities->setItemDelegateForColumn(COL_TYPE_GQ, mpTypeDelegate);

  mpTblGlobalQuantities->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
  mpTblGlobalQuantities->verticalHeader()->hide();
  mpTblGlobalQuantities->sortByColumn(COL_ROW_NUMBER, Qt::AscendingOrder);

  // Connect the table widget
  connect(mpGlobalQuantityDM, SIGNAL(notifyGUI(ListViews::ObjectType, ListViews::Action, const std::string)),
          this, SLOT(protectedNotify(ListViews::ObjectType, ListViews::Action, const std::string)));
  connect(mpGlobalQuantityDM, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),
          this, SLOT(dataChanged(const QModelIndex&, const QModelIndex&)));
  connect(mpLEFilter, SIGNAL(textChanged(const QString &)),
          this, SLOT(slotFilterChanged()));

  CopasiUI3Window *  pWindow = dynamic_cast<CopasiUI3Window * >(parent->parent());
  mpGlobalQuantityDM->setUndoStack(pWindow->getUndoStack());
}
Example #2
0
/*
 *  Constructs a CQEventWidget1 which is a child of 'parent', with the
 *  name 'name'.'
 */
CQEventWidget1::CQEventWidget1(QWidget * parent, const char * name):
  CopasiWidget(parent, name),
  mKeyToCopy("")
{
  setupUi(this);

  init();

#ifdef COPASI_UNDO
  CopasiUI3Window *  pWindow = dynamic_cast<CopasiUI3Window * >(parent->parent());
  setUndoStack(pWindow->getUndoStack());
#endif
}
Example #3
0
void CQTabWidget::load()
{
  if (mpObject != NULL)
    {
      mpEditName->setText(FROM_UTF8(mpObject->getObjectName()));

      if (mObjectType == ListViews::ObjectType::FUNCTION)
        {
          bool readOnly = static_cast< const CFunction * >(mpObject)->isReadOnly();

          mpEditName->setReadOnly(readOnly);
          mpBtnCommit->setEnabled(!readOnly);
          mpBtnRevert->setEnabled(!readOnly);
          mpBtnDelete->setEnabled(!readOnly);
        }
      else if (mObjectType == ListViews::ObjectType::UNIT)
        {
          bool readOnly = static_cast< const CUnitDefinition * >(mpObject)->isReadOnly();

          mpEditName->setReadOnly(readOnly);
          mpBtnCommit->setEnabled(!readOnly);
          mpBtnRevert->setEnabled(!readOnly);
          mpBtnDelete->setEnabled(!readOnly);
        }

#ifdef COPASI_Provenance

      if (mObjectType == ListViews::ObjectType::METABOLITE ||
          mObjectType == ListViews::ObjectType::COMPARTMENT ||
          mObjectType == ListViews::ObjectType::REACTION ||
          mObjectType == ListViews::ObjectType::EVENT ||
          mObjectType == ListViews::ObjectType::MODELVALUE)
        {
          CopasiUI3Window *  pWindow = dynamic_cast<CopasiUI3Window *>(CopasiUI3Window::getMainWindow());

          if (pWindow) //Probably could just assume the Main Window exists
            {
              QList<QString> VersioningPath = pWindow->getVersionHierarchy()->getVersionsPathToCurrentModel();
              mpEntityProvenanceDialog->load(mpUndoStack, FROM_UTF8(mpObject->getObjectName()), FROM_UTF8(CRootContainer::getConfiguration()->getWorkingDirectory()), VersioningPath);
            }
        }

#endif
    }
  else
    {
      mpEditName->setText("");
    }
}
Example #4
0
bool TaskWidget::commonAfterRunTask()
{
  if (!mpTask) return false;

  if (CRootContainer::getConfiguration()->displayPopulations())
    {

      if (dynamic_cast<COptTask*>(mpTask) != NULL || dynamic_cast<CFitTask*>(mpTask) != NULL)
        {
          CopasiUI3Window* pWindow = CopasiUI3Window::getMainWindow();
          CQOptPopulation* pPopWidget = pWindow->getPopulationDisplay();
          COptPopulationMethod* pMethod = dynamic_cast<COptPopulationMethod*>(mpTask->getMethod());
          pPopWidget->setMethod(NULL);

          if (pMethod != NULL)
            {
              mpDataModel->removeInterface(pPopWidget);
            }
        }
    }

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

  mpTask->setCallBack(NULL);

  CCopasiMessage::clearDeque();

  assert(mpDataModel != NULL);
  mpDataModel->finish();

  CMathContainer * pContainer = mpTask->getMathContainer();
  protectedNotify(ListViews::ObjectType::STATE, ListViews::CHANGE, pContainer->getModel().getKey());

  unsetCursor();
  CopasiUI3Window::getMainWindow()->suspendAutoSave(false);

  return loadTask();
}
Example #5
0
/*
 *  Constructs a CQSpeciesDetail which is a child of 'parent', with the
 *  name 'name'.'
 */
CQSpeciesDetail::CQSpeciesDetail(QWidget* parent, const char* name) :
  CopasiWidget(parent, name),
  mChanged(false),
  mpMetab(NULL),
  mpCurrentCompartment(NULL),
  mItemToType(),
  mInitialNumber(0.0),
  mInitialConcentration(0.0),
  mExpressionValid(false),
  mInitialExpressionValid(false)
{
  setupUi(this);

  mpComboBoxType->insertItem(mpComboBoxType->count(), FROM_UTF8(CModelEntity::StatusName[CModelEntity::REACTIONS]));
  mpComboBoxType->insertItem(mpComboBoxType->count(), FROM_UTF8(CModelEntity::StatusName[CModelEntity::FIXED]));
  mpComboBoxType->insertItem(mpComboBoxType->count(), FROM_UTF8(CModelEntity::StatusName[CModelEntity::ASSIGNMENT]));
  mpComboBoxType->insertItem(mpComboBoxType->count(), FROM_UTF8(CModelEntity::StatusName[CModelEntity::ODE]));

  mItemToType.push_back(CModelEntity::REACTIONS);
  mItemToType.push_back(CModelEntity::FIXED);
  mItemToType.push_back(CModelEntity::ASSIGNMENT);
  mItemToType.push_back(CModelEntity::ODE);

//  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
//  int Width = fontMetrics().width("Concentration (" +
//                                  FROM_UTF8(CCopasiRootContainer::getDatamodelList()->operator[](0).getModel()->getConcentrationUnitsDisplayString()) +
//                                  ")");
//

//  mpLblValue->setMinimumWidth(Width);

  mpExpressionEMW->mpExpressionWidget->setExpressionType(CQExpressionWidget::TransientExpression);

  mpInitialExpressionEMW->mpExpressionWidget->setExpressionType(CQExpressionWidget::InitialExpression);

  mpReactionTable->verticalHeader()->hide();
  mpReactionTable->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
  mpReactionTable->horizontalHeader()->hide();
  mpReactionTable->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);

  CopasiUI3Window *  pWindow = dynamic_cast<CopasiUI3Window * >(parent->parent());
  setUndoStack(pWindow->getUndoStack());
}
Example #6
0
/*
 *  Constructs a CQCompartment which is a child of 'parent', with the
 *  name 'name'.'
 */
CQCompartment::CQCompartment(QWidget* parent, const char* name):
  CopasiWidget(parent, name),
  mItemToType(),
  mpCompartment(NULL),
  mChanged(false),
  mExpressionValid(true),
  mInitialExpressionValid(true)
{
  setupUi(this);

  mpComboBoxType->insertItem(mpComboBoxType->count(), FROM_UTF8(CModelEntity::StatusName[CModelEntity::FIXED]));
  mpComboBoxType->insertItem(mpComboBoxType->count(), FROM_UTF8(CModelEntity::StatusName[CModelEntity::ASSIGNMENT]));
  mpComboBoxType->insertItem(mpComboBoxType->count(), FROM_UTF8(CModelEntity::StatusName[CModelEntity::ODE]));

  mItemToType.push_back(CModelEntity::FIXED);
  mItemToType.push_back(CModelEntity::ASSIGNMENT);
  mItemToType.push_back(CModelEntity::ODE);

  mpMetaboliteTable->horizontalHeader()->hide();

  mExpressionValid = false;
  mpExpressionEMW->mpExpressionWidget->setExpressionType(CQExpressionWidget::TransientExpression);

  mInitialExpressionValid = false;
  mpInitialExpressionEMW->mpExpressionWidget->setExpressionType(CQExpressionWidget::InitialExpression);

#ifdef COPASI_EXTUNIT
  mpLblDim->show();
  mpComboBoxDim->show();
#else
  mpLblDim->hide();
  mpComboBoxDim->hide();
#endif

#ifdef COPASI_UNDO
  CopasiUI3Window *  pWindow = dynamic_cast<CopasiUI3Window * >(parent->parent());
  setUndoStack(pWindow->getUndoStack());
#endif
}
Example #7
0
void WizardDialog::textBrowser_anchorClicked(const QUrl & url)
{
  QString name = url.fragment();

  // std::cout << name.toUtf8().data() << std::endl;

  CopasiUI3Window * pMainWindow = dynamic_cast<CopasiUI3Window *>(copasiMainWindow);

  if (name == "Model Settings")
    {
      if (pMainWindow)
        pMainWindow->getMainWidget()->switchToOtherWidget(ListViews::WidgetType::Model, std::string());
    }
  else if (name == "Reaction Overview")
    {
      if (pMainWindow)
        pMainWindow->getMainWidget()->switchToOtherWidget(ListViews::WidgetType::Reactions, std::string());
    }
  else if (name == "Report Definition")
    {
      if (pMainWindow)
        pMainWindow->getMainWidget()->switchToOtherWidget(ListViews::WidgetType::ReportTemplates, std::string());
    }
  else if (name == "Step 1")
    {
      buttonGroup->button(0)->setChecked(true);
      buttonGroup2_clicked(this->buttonGroup->checkedId());
    }
  else if (name == "Time Course")
    {
      if (pMainWindow)
        pMainWindow->getMainWidget()->switchToOtherWidget(ListViews::WidgetType::TimeCourse, std::string());
    }
  else if (name == "Plot Definition Overview")
    {
      if (pMainWindow)
        pMainWindow->getMainWidget()->switchToOtherWidget(ListViews::WidgetType::Plots, std::string());
    }
  else
    {
      CQMessageBox::information(this, "Error", "Link not found",
                                QMessageBox::Ok, QMessageBox::Ok);
    }
}
Example #8
0
bool TaskWidget::commonBeforeRunTask()
{
  // save the state of the widget
  if (!saveTask())
    {
      CQMessageBox::critical(this, "Simulation Error",
                             CCopasiMessage::getAllMessageText().c_str(),
                             QMessageBox::Ok | QMessageBox::Default, QMessageBox::NoButton);
      return false;
    }

  if (!mpTask) return false;

  if (mProgressBar != NULL)
    {
      //CQMessageBox::critical(this, "Task in Progress",
      //                       "A task is currently running, another cannot be started before the current task ended.",
      //                       QMessageBox::Ok | QMessageBox::Default, QMessageBox::NoButton);
      return false;
    }

  // if overwrite is enabled and the file exists, then ask
  if (!mpTask->getReport().getTarget().empty() &&
      mpTask->getReport().confirmOverwrite())
    {
      // The target might be a relative path
      std::string Target = mpTask->getReport().getTarget();

      if (CDirEntry::isRelativePath(Target) &&
          !CDirEntry::makePathAbsolute(Target, mpDataModel->getReferenceDirectory()))
        Target = CDirEntry::fileName(Target);

      if (CDirEntry::exist(Target) &&
          QMessageBox::question(this,
                                QString("Confirm Overwrite"),
                                QString("The report file already exists. Would you like to overwrite it? \n\n(You can disable this dialog by clicking the 'Report' button.)"),
                                QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
        return false;
    }

  //set mouse cursor
  setCursor(Qt::WaitCursor);

  //handle autosave feature
  CopasiUI3Window::getMainWindow()->autoSave();
  CopasiUI3Window::getMainWindow()->suspendAutoSave(true);

  //create progress bar
  mProgressBar = CProgressBar::create();
  mpTask->setCallBack(mProgressBar);

  CCopasiMessage::clearDeque();

  // create population display if needed
  if (CRootContainer::getConfiguration()->displayPopulations())
    {

      if (dynamic_cast<COptTask*>(mpTask) != NULL || dynamic_cast<CFitTask*>(mpTask) != NULL)
        {
          CopasiUI3Window* pWindow = CopasiUI3Window::getMainWindow();
          CQOptPopulation* pPopWidget = pWindow->getPopulationDisplay();
          COptPopulationMethod* pMethod = dynamic_cast<COptPopulationMethod*>(mpTask->getMethod());
          pPopWidget->setMethod(pMethod);

          if (pMethod != NULL)
            {
              pPopWidget->addToMainWindow(pWindow);
              pPopWidget->show();
              mpDataModel->addInterface(pPopWidget);
            }
        }
    }

  return true;
}