예제 #1
0
/*!
   This slot function is called whenever the function description is changed.
 */
void FunctionWidget1::slotFcnDescriptionChanged(bool valid)
{

  if (mIgnoreFcnDescriptionChange ||
      (mpFunction == NULL))
    return;

  isValid = valid;

  if (isValid)
    {
      try
        {
          if (!mpFunction->setInfix(TO_UTF8(mpExpressionEMSW->getText())) ||
              !mpFunction->compile())
            {
              isValid = true;
            }
        }
      catch (...)
        {
          isValid = false;
        }
    }

  if (isValid)
    {
      flagChanged = true;
      //parameter table
      loadParameterTable();

      // application table
      loadUsageTable();
    }
  else
    {
      if (CCopasiMessage::peekLastMessage().getNumber() == MCFunction + 4)
        {
          CQMessageBox::critical(this, "Function Error",
                                 CCopasiMessage::getLastMessage().getText().c_str(),
                                 QMessageBox::Ok | QMessageBox::Default,
                                 QMessageBox::NoButton);
          CCopasiMessage::clearDeque();
        }
    }
}
예제 #2
0
//! Slot for changing the table value
void FunctionWidget1::slotTableValueChanged(const QString &string)
{
  int curRow = sender()->objectName().toInt();

  QComboBox *comboItem = (QComboBox *) sender();

  flagChanged = true;

  CFunctionParameters &functParam = mpFunction->getVariables();

  // surely, we are in COL_USAGE... thus we don't need to check it anymore
  CFunctionParameter::Role usage = (CFunctionParameter::Role)(comboItem->findText(string));
  functParam[curRow]->setUsage(usage);

  //update tables
  loadParameterTable();
  loadUsageTable();
}
예제 #3
0
bool CQLNAWidget::loadTask()
{
  CLNATask * pTask = dynamic_cast< CLNATask * >(mpTask);

  if (!pTask) return false;

  loadCommon();
//  loadMethod(); --> we cannot do that because of different structure -- 08.04.09

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

  if (!pProblem) return false;

  // instead calling loadMethod(), the following codes is used
  mpCheckSteadyState->setChecked(pProblem->isSteadyStateRequested());

  bool success = loadParameterTable();

  mChanged = false;

  return success;
}
예제 #4
0
bool FunctionWidget1::loadFromFunction(const CFunction* func)
{
  if (func != NULL)
    {
      pdelete(mpFunction);
      mpFunction = dynamic_cast<CFunction *>(CEvaluationTree::copy(*func));
      flagChanged = false;
    }

  if (mpFunction == NULL)
    return false;

  // function name
  /* Insert line breaks in the function description */
  std::string desc = mpFunction->getInfix();
  size_t l = 0;
  size_t n = 0;
  size_t len = desc.length();

  while (len - l > 65)
    {
      n = l;
      l = l + 65;

      while (l > n)
        {
          char ch = desc.at(l);

          if ((ch == '+') || (ch == '-') || (ch == '*') || (ch == '/') || (ch == ',') || (ch == ' '))
            break;

          l--;
        }

      // We did not find a suitable place to break the line
      if (l == n) l += 65;

      desc.insert(l, 1, '\n');
    }

  mReadOnly = (mpFunction->getType() == CFunction::PreDefined ||
               mpFunction->getType() == CFunction::MassAction);

  RadioButton1->setEnabled(!mReadOnly);
  RadioButton2->setEnabled(!mReadOnly);
  RadioButton3->setEnabled(!mReadOnly);

  mpExpressionEMSW->setReadOnly(mReadOnly);

  // formula expression
  mIgnoreFcnDescriptionChange = true;
  mpExpressionEMSW->mpExpressionWidget->setFunction(mpFunction->getInfix());
  mIgnoreFcnDescriptionChange = false;

  mpExpressionEMSW->updateWidget();

  //radio buttons
  loadReversibility(mpFunction->isReversible());

  //parameter table
  loadParameterTable();

  // application table
  loadUsageTable(/*pFunction->getVariables().getUsageRanges()*/);

  isValid = mpFunction->isUsable();

  flagChanged = false;

  return true;
}
예제 #5
0
void CQLNAWidget::slotSteadyStateChecked()
{
  loadParameterTable();
}