Beispiel #1
0
/*!
    Load any saved values to the screen
 */
void CQModelValue::load()
{
  if (mpModelValue == NULL) return;

  // Unit expression
  mpEditUnits->setText(FROM_UTF8(mpModelValue->getUnitExpression()));

  // Update the unit labels
  slotUnitChanged();

  // Type
  mpComboBoxType->setCurrentIndex(mpComboBoxType->findText(FROM_UTF8(CModelEntity::StatusName[mpModelValue->getStatus()])));

  // Initial Value
  mpEditInitialValue->setText(convertToQString(mpModelValue->getInitialValue()));

  // Current Value
  mpEditCurrentValue->setText(convertToQString(mpModelValue->getValue()));

  // Rate
  mpEditRate->setText(convertToQString(mpModelValue->getRate()));

  // Expression
  mpExpressionEMW->mpExpressionWidget->setExpression(mpModelValue->getExpression());

  // Update Expression Widget
  mpExpressionEMW->updateWidget();

  // Initial Expression
  mpInitialExpressionEMW->mpExpressionWidget->setExpression(mpModelValue->getInitialExpression());

  // Update Initial Expression Widget
  mpInitialExpressionEMW->updateWidget();

  // Noise Expression
  mpNoiseExpressionWidget->mpExpressionWidget->setExpression(mpModelValue->getNoiseExpression());
  mpNoiseExpressionWidget->updateWidget();
  mpBoxAddNoise->setChecked(mpModelValue->hasNoise());

  // Type dependent display of values
  slotTypeChanged(mpComboBoxType->currentText());

  // Use Initial Expression
  if (mpModelValue->getStatus() == CModelEntity::Status::ASSIGNMENT ||
      mpModelValue->getInitialExpression() == "")
    {
      mpBoxUseInitialExpression->setChecked(false);
      //      slotInitialTypeChanged(false);
    }
  else
    {
      mpBoxUseInitialExpression->setChecked(true);
      //      slotInitialTypeChanged(true);
    }

  mpDependencies->loadFrom(mpObject);

  mChanged = false;
}
Beispiel #2
0
void CQCompartment::load()
{
  if (mpCompartment == NULL) return;

  //Dimensionality
  mpComboBoxDim->setCurrentIndex(mpCompartment->getDimensionality());
  // slotDimesionalityChanged(mpCompartment->getDimensionality());

  // Simulation Type
  mpComboBoxType->setCurrentIndex(mpComboBoxType->findText(FROM_UTF8(CModelEntity::StatusName[mpCompartment->getStatus()])));

  // Initial Volume
  mpEditInitialVolume->setText(convertToQString(mpCompartment->getInitialValue()));

  // Transient Volume
  mpEditCurrentVolume->setText(convertToQString(mpCompartment->getValue()));

  // Concentration Rate
  mpEditRate->setText(convertToQString(mpCompartment->getRate()));

  // Expression
  mpExpressionEMW->mpExpressionWidget->setExpression(mpCompartment->getExpression());
  mpExpressionEMW->updateWidget();

  // Initial Expression
  mpInitialExpressionEMW->mpExpressionWidget->setExpression(mpCompartment->getInitialExpression());
  mpInitialExpressionEMW->updateWidget();

  // Noise Expression
  mpNoiseExpressionWidget->mpExpressionWidget->setExpression(mpCompartment->getNoiseExpression());
  mpNoiseExpressionWidget->updateWidget();
  mpBoxAddNoise->setChecked(mpCompartment->hasNoise());

  // Type dependent display of values
  slotTypeChanged(mpComboBoxType->currentText());

  // Use Initial Expression
  if (mpCompartment->getStatus() == CModelEntity::Status::ASSIGNMENT ||
      mpCompartment->getInitialExpression() == "")
    {
      mpBoxUseInitialExpression->setChecked(false);
    }
  else
    {
      mpBoxUseInitialExpression->setChecked(true);
    }

  loadMetaboliteTable();

  mChanged = false;
  return;
}
Beispiel #3
0
void CScanWidgetRandom::initFromObject(const CDataObject *obj)
{
  mpObject = obj;

  if (obj)
    {
      lineEditObject->setText(FROM_UTF8(obj->getObjectDisplayName()));

      if (obj->hasFlag(CDataObject::ValueDbl))
        {
          C_FLOAT64 value = *(C_FLOAT64*)obj->getValuePointer();
          C_INT32 type = comboBoxType->currentIndex();

          if (type == 0) //uniform
            {
              lineEditMin->setText(convertToQString(value * 0.5));
              lineEditMax->setText(convertToQString(value * 2));
            }

          if (type == 1) //normal
            {
              lineEditMin->setText(convertToQString(value));
              lineEditMax->setText(convertToQString(value * 0.1));
            }

          if (type == 2) //poisson
            {
              lineEditMin->setText(convertToQString(value));
              lineEditMax->setText("");
            }
        }
    }
  else
    {
      lineEditObject->setText("");
      lineEditMin->setText("");
      lineEditMax->setText("");
    }
}
Beispiel #4
0
bool InitializeEventsXMLFile(EventsFile& eventsFile)
{
    bool rv = true;
    osCpuid cpuInfo;
    int model = cpuInfo.getModel();

    osFilePath eventFilePath;
    EventEngine eventEngine;

    // Construct the path for family specific Events XML files
    if (osGetCurrentApplicationDllsPath(eventFilePath) || osGetCurrentApplicationPath(eventFilePath))
    {
        eventFilePath.clearFileName();
        eventFilePath.clearFileExtension();

        eventFilePath.appendSubDirectory(L"Data");
        eventFilePath.appendSubDirectory(L"Events");

        const gtString eventFilePathStr = eventFilePath.fileDirectoryAsString();

        if (!eventEngine.Initialize(convertToQString(eventFilePathStr)))
        {
            rv = false;
        }
    }

    if (rv)
    {
        // Get event file path
        QString eventFile;
        eventFile = eventEngine.GetEventFilePath(cpuInfo.getFamily(), model);

        // Initialize event file
        if (!eventsFile.Open(eventFile))
        {
            rv = false;
        }
    }

    return rv;
}
Beispiel #5
0
void CQCompartment::save()
{
  if (mpCompartment == NULL) return;

  mIgnoreUpdates = true;

  CData OldData(mpCompartment->toData());

#ifdef COPASI_EXTUNIT

  //Dimensionality
  if ((C_INT32)mpCompartment->getDimensionality() != mpComboBoxDim->currentIndex()) //this makes assumptions about the order of entries in the combo box!
    {
      mpCompartment->setDimensionality((unsigned C_INT32) mpComboBoxDim->currentIndex());
      mChanged = true;
    }

#endif

  // Type
  if (mpCompartment->getStatus() != CModelEntity::StatusName.toEnum(TO_UTF8(mpComboBoxType-> currentText())))
    {
      mpCompartment->setStatus(CModelEntity::StatusName.toEnum(TO_UTF8(mpComboBoxType->currentText())));
      mChanged = true;
    }

  // Initial Volume
  if (convertToQString(mpCompartment->getInitialValue()) != mpEditInitialVolume->text())
    {
      mpCompartment->setInitialValue(mpEditInitialVolume->text().toDouble());
      mChanged = true;
    }

  // Expression
  if (mpCompartment->getExpression() != mpExpressionEMW->mpExpressionWidget->getExpression())
    {
      mpCompartment->setExpression(mpExpressionEMW->mpExpressionWidget->getExpression());
      mChanged = true;
    }

  // Initial Expression
  if (CModelEntity::StatusName.toEnum(TO_UTF8(mpComboBoxType-> currentText())) != CModelEntity::Status::ASSIGNMENT)
    {
      if (mpBoxUseInitialExpression->isChecked() &&
          mpCompartment->getInitialExpression() != mpInitialExpressionEMW->mpExpressionWidget->getExpression())
        {
          mpCompartment->setInitialExpression(mpInitialExpressionEMW->mpExpressionWidget->getExpression());
          mChanged = true;
        }
      else if (!mpBoxUseInitialExpression->isChecked() &&
               mpCompartment->getInitialExpression() != "")
        {
          mpCompartment->setInitialExpression("");
          mChanged = true;
        }
    }

  // Add Noise
  if (mpCompartment->hasNoise() != mpBoxAddNoise->isChecked())
    {
      mpCompartment->setHasNoise(mpBoxAddNoise->isChecked());
      mChanged = true;
    }

  // Noise Expression
  if (mpCompartment->getNoiseExpression() != mpNoiseExpressionWidget->mpExpressionWidget->getExpression())
    {
      mpCompartment->setNoiseExpression(mpNoiseExpressionWidget->mpExpressionWidget->getExpression());
      mChanged = true;
    }

  mIgnoreUpdates = false;

  if (mChanged)
    {
      CUndoData UndoData;
      mpCompartment->createUndoData(UndoData, CUndoData::Type::CHANGE, OldData, static_cast< CCore::Framework >(mFramework));
      ListViews::addUndoMetaData(this, UndoData);

      slotNotifyChanges(mpDataModel->applyData(UndoData));
      load();
    }
}
Beispiel #6
0
QVariant CQCompartmentDM::data(const QModelIndex &index, int role) const
{
  if (!index.isValid())
    return QVariant();

  if (index.row() >= rowCount())
    return QVariant();

  if (index.column() > 0 && role == Qt::ForegroundRole && !(flags(index) & Qt::ItemIsEditable))
    return QColor(Qt::darkGray);

  if (role == Qt::DisplayRole || role == Qt::EditRole)
    {
      if (isDefaultRow(index))
        {
          switch (index.column())
            {
              case COL_ROW_NUMBER:
                return QVariant(QString(""));

              case COL_NAME_COMPARTMENTS:
                return QVariant(QString("New Compartment"));

              case COL_TYPE_COMPARTMENTS:
                return QVariant(QString(FROM_UTF8(CModelEntity::StatusName[CModelEntity::Status::FIXED])));

              case COL_IVOLUME:
                return QVariant(convertToQString(1.0));

              default:
                return QVariant(QString(""));
            }
        }
      else
        {
          CCompartment & Compartment = mpCompartments->operator[](index.row());
          const CExpression * pExpression = NULL;

          switch (index.column())
            {
              case COL_ROW_NUMBER:
                return QVariant(index.row() + 1);

              case COL_NAME_COMPARTMENTS:
                return QVariant(QString(FROM_UTF8(Compartment.getObjectName())));

              case COL_TYPE_COMPARTMENTS:
                return QVariant(QString(FROM_UTF8(CModelEntity::StatusName[Compartment.getStatus()])));

              case COL_UNIT_COMPARTMENTS:
                return QVariant(mUnits[Compartment.getDimensionality()]);

              case COL_IVOLUME:

                if (role == Qt::EditRole)
                  return QVariant(convertToQString(Compartment.getInitialValue()));
                else
                  return QVariant(Compartment.getInitialValue());

              case COL_VOLUME:
                return QVariant(Compartment.getValue());

              case COL_RATE_COMPARTMENTS:
                return QVariant(Compartment.getRate());

              case COL_IEXPRESSION_COMPARTMENTS:
              {
                pExpression = Compartment.getInitialExpressionPtr();

                if (pExpression != NULL)
                  return QVariant(QString(FROM_UTF8(pExpression->getDisplayString())));
                else
                  return QVariant();
              }

              case COL_EXPRESSION_COMPARTMENTS:
              {
                pExpression = Compartment.getExpressionPtr();

                if (pExpression != NULL)
                  return QVariant(QString(FROM_UTF8(pExpression->getDisplayString())));
                else
                  return QVariant();
              }

              case COL_NEXPRESSION_COMPARTMENTS:
              {
                pExpression = Compartment.getNoiseExpressionPtr();

                if (Compartment.hasNoise() && pExpression != NULL)
                  return QVariant(QString(FROM_UTF8(pExpression->getDisplayString())));
                else
                  return QVariant();
              }
            }
        }
    }

  return QVariant();
}
Beispiel #7
0
/*!
    Save any inputs and set them as initial setting values
 */
void CQModelValue::save()
{
  if (mpModelValue == NULL) return;

  mIgnoreUpdates = true;

  CData OldData(mpModelValue->toData());

  // set status
  if (CModelEntity::StatusName[mpModelValue->getStatus()] != TO_UTF8(mpComboBoxType->currentText()))
    {
      mpModelValue->setStatus(CModelEntity::StatusName.toEnum(TO_UTF8(mpComboBoxType->currentText()), CModelEntity::Status::FIXED));
      mChanged = true;
    }

  // set initial value
  if (convertToQString(mpModelValue->getInitialValue()) != mpEditInitialValue->text() &&
      mpModelValue->getStatus() != CModelEntity::Status::ASSIGNMENT)
    {
      mpModelValue->setInitialValue(mpEditInitialValue->text().toDouble());
      mChanged = true;
    }

  // set expression
  if (mpModelValue->getExpression() != mpExpressionEMW->mpExpressionWidget->getExpression())
    {
      mpModelValue->setExpression(mpExpressionEMW->mpExpressionWidget->getExpression());
      mChanged = true;
    }

  // set initial expression
  if (mpModelValue->getStatus() != CModelEntity::Status::ASSIGNMENT)
    {
      if (mpBoxUseInitialExpression->isChecked() &&
          mpModelValue->getInitialExpression() != mpInitialExpressionEMW->mpExpressionWidget->getExpression())
        {
          mpModelValue->setInitialExpression(mpInitialExpressionEMW->mpExpressionWidget->getExpression());
          mChanged = true;
        }
      else if (!mpBoxUseInitialExpression->isChecked() &&
               mpModelValue->getInitialExpression() != "")
        {
          mpModelValue->setInitialExpression("");
          mChanged = true;
        }
    }

  // Add Noise
  if (mpModelValue->hasNoise() != mpBoxAddNoise->isChecked())
    {
      mpModelValue->setHasNoise(mpBoxAddNoise->isChecked());
      mChanged = true;
    }

  // Noise Expression
  if (mpModelValue->getNoiseExpression() != mpNoiseExpressionWidget->mpExpressionWidget->getExpression())
    {
      mpModelValue->setNoiseExpression(mpNoiseExpressionWidget->mpExpressionWidget->getExpression());
      mChanged = true;
    }

  // set unit
  if (mpModelValue->getUnitExpression() != TO_UTF8(mpEditUnits->text()))
    {
      mpModelValue->setUnitExpression(TO_UTF8(mpEditUnits->text()));
      mChanged = true;
    }

  mIgnoreUpdates = false;

  if (mChanged)
    {
      CUndoData UndoData;
      mpModelValue->createUndoData(UndoData, CUndoData::Type::CHANGE, OldData, static_cast< CCore::Framework >(mFramework));
      ListViews::addUndoMetaData(this, UndoData);

      slotNotifyChanges(mpDataModel->recordData(UndoData));
      load();
    }

  mChanged = false;
}
void PaintWidget::paintEvent(QPaintEvent *)
{

  if (mVector.size() == 0) return;

  if (mClear) return;

  int position;
  int space = 35;

  int maxScaleValue = -1000;
  int minScaleValue = 1000;
  unsigned C_INT32 j;

  for (j = 0; j < mVector.size(); ++j)
    {
      if (fabs(mVector[j]) == std::numeric_limits<C_FLOAT64>::infinity())
        continue;

      if ((int)(log10(fabs(mVector[j])) + 1) > maxScaleValue)
        maxScaleValue = (int)(log10(fabs(mVector[j])) + 1);

      if ((int)(log10(fabs(mVector[j])) - 1) < minScaleValue)
        minScaleValue = (int)(log10(fabs(mVector[j])) - 1);
    }

  int scaleValueRange = maxScaleValue - minScaleValue;

  QPainter paint(this);
  paint.save();

  //paint.setWindow(0, 0, 1000, 1000);
  QRect v = paint.viewport();

  //paint.setFont(QFont("Courier", 15));

  //Legend
  paint.setPen(QPen(QColor(180, 0, 0), 5));
  paint.drawLine(space, space, space, space + 10);
  paint.setPen(QPen(QColor(0, 0, 0), 1));
  paint.drawText(space + 5, space + 10, " - negative time scale values");

  paint.setPen(QPen(QColor(0, 180, 0), 5));
  paint.drawLine(space, space + 20, space, space + 30);
  paint.setPen(QPen(QColor(0, 0, 0), 1));
  paint.drawText(space + 5, space + 30, " - positive time scale values");

  //axis
  paint.setPen(QPen(QColor(100, 100, 100), 1));
  int yCentre = v.bottom() - space - 30;
  int scaleBegin = space;
  int scaleEnd = v.right() - space; //(maxScaleValue - minScaleValue) * (1000 - 2 * space) / scaleValueRange + space;
  int axisLength = scaleEnd - scaleBegin;
  paint.drawLine(scaleBegin, yCentre, scaleEnd, yCentre);

  //tics
  C_INT32 i;

  for (i = 0; i <= scaleValueRange; i++)
    {
      position = scaleBegin + (int)(i * axisLength / scaleValueRange);
      paint.drawLine(position, yCentre + 10, position, yCentre);
      paint.drawText(position - 5, yCentre + 30, QString::number(minScaleValue + i));
    }

  paint.setPen(QPen(QColor(0, 180, 0), 1));

  //values
  int yTop = yCentre - 50;
  int xText = v.right() - space - 230;
  int yText = space + 30;

  for (j = 0; j < mVector.size(); j++)
    {
      position = scaleBegin + (int)((log10(fabs(mVector[j])) - minScaleValue) * axisLength / scaleValueRange);

      if ((uint)mSelection == (uint)(mVector.size() - 1 - j))
        {
          if (mVector[j] < 0)
            paint.setPen(QPen(QColor(180, 20, 20), 4));
          else
            paint.setPen(QPen(QColor(20, 180, 20), 4));

          paint.drawLine(position, yCentre - 1, position, yTop);
          paint.setPen(QPen(QColor(200, 200, 200), 1));
          //          paint.setFont(QFont("Courier", 20));
          paint.drawLine(xText, yText, position + 1, yTop - 1);
          paint.drawLine(xText, yText, scaleEnd, yText);
          paint.setPen(QPen(QColor(0, 0, 0), 1));

          if (mVector[j] < 0)
            paint.drawText(xText + 1, yText - 15, " log10 (|" + convertToQString(mVector[j]) + "|) = " + convertToQString(log10(fabs(mVector[j]))));
          else
            paint.drawText(xText + 1, yText - 15, " log10 (" + convertToQString(fabs(mVector[j])) + ") = " + convertToQString(log10(fabs(mVector[j]))));

          paint.drawText(scaleBegin + scaleEnd / 2 - 50, yCentre + 50, " log timescale");
        }
      else
        {
          if (mVector[j] < 0)
            paint.setPen(QPen(QColor(180, 20, 20), 2));
          else
            paint.setPen(QPen(QColor(20, 180, 20), 2));

          paint.drawLine(position, yCentre - 1, position, yTop);
        }
    }

  paint.restore();
}
Beispiel #9
0
void CScanWidgetRandom::changeType()
{
  C_INT32 type = comboBoxType->currentIndex();
  C_FLOAT64 value = 0.0;

  if (mpObject != NULL)
    value = *(C_FLOAT64*)mpObject->getValuePointer();

  switch (type)
    {
      case 0: // uniform
        lineEditMin->setEnabled(true);
        lineEditMax->setEnabled(true);

        labelMin->setText("min");
        labelMax->setText("max");

        if (mpObject != NULL)
          {
            lineEditMin->setText(convertToQString(value * 0.5));
            lineEditMax->setText(convertToQString(value * 2));
          }
        else
          {
            lineEditMin->setText("");
            lineEditMax->setText("");
          }

        break;

      case 1: // normal
        lineEditMin->setEnabled(true);
        lineEditMax->setEnabled(true);

        labelMin->setText("mean");
        labelMax->setText("standard deviation");

        if (mpObject != NULL)
          {
            lineEditMin->setText(convertToQString(value));
            lineEditMax->setText(convertToQString(value * 0.1));
          }
        else
          {
            lineEditMin->setText("");
            lineEditMax->setText("");
          }

        break;

      case 2: // Poisson
        lineEditMin->setEnabled(true);
        lineEditMax->setEnabled(false);

        labelMin->setText("mean");
        labelMax->setText("");

        if (mpObject != NULL)
          lineEditMin->setText(convertToQString(value));
        else
          lineEditMin->setText("");

        lineEditMax->setText("");

        break;

      case 3: // Gamma
        lineEditMin->setEnabled(true);
        lineEditMax->setEnabled(true);

        labelMin->setText("shape");
        labelMax->setText("scale");

        if (mpObject != NULL)
          {
            lineEditMin->setText(convertToQString(1.0 * value));
            lineEditMax->setText(convertToQString(0.1));
          }
        else
          {
            lineEditMin->setText("");
            lineEditMax->setText("");
          }

        break;
    }
}