예제 #1
0
void CQArrayAnnotationsWidget::fillTable1(size_t rowIndex,
    const CCopasiAbstractArray::index_type & index)
{
#ifdef DEBUG_UI
  qDebug() << "-- in fillTable0 B -- \n";
#endif

  if (!mpArray) return;

  assert(rowIndex < index.size());

  mpContentTable->setColumnCount(1);
  mpContentTable->setRowCount((int) mpArray->size()[rowIndex]);

  mpContentTable->setHorizontalHeaderItem(0, new QTableWidgetItem(""));

  size_t i, imax = mpArray->size()[rowIndex];

  CCopasiAbstractArray::index_type Index = index;

  //automatic color scaling
  if (mAutomaticColorScaling)
    {
      mpColorScale->startAutomaticParameterCalculation();

      for (i = 0; i < imax; ++i)
        {
          Index[rowIndex] = i;
          mpColorScale->passValue((*mpArray->array())[Index]);
        }

      mpColorScale->finishAutomaticParameterCalculation();
    }

  //table contents and annotations
  const std::vector<std::string> & rowdescr = mpArray->getAnnotationsString(rowIndex);

  for (i = 0; i < imax; ++i)
    {
      Index[rowIndex] = i;
      QTableWidgetItem * pItem = new QTableWidgetItem(FROM_UTF8(rowdescr[i]));
      mpContentTable->setVerticalHeaderItem((int) i, pItem);

      pItem = new QTableWidgetItem(QString::number((*mpArray->array())[Index]));
      mpContentTable->setItem((int) i, 0, pItem);

      if (mpColorScale != NULL)
        {
          pItem->setBackground(QBrush(mpColorScale->getColor((*mpArray->array())[Index])));
        }
    }

  mOneDimensional = true;

  mpContentTable->resizeRowsToContents();
  mpContentTable->resizeColumnsToContents();

  if (mpStack->currentIndex() == 1)
    fillBarChart();
}
예제 #2
0
void CQArrayAnnotationsWidget::fillTable0()
{
#ifdef DEBUG_UI
  qDebug() << "-- in fillTable0 C -- \n";
#endif

  if (!mpArray) return;

  mpContentTable->setColumnCount(0);
  mpContentTable->setRowCount(0);
  mpContentTable->setColumnCount(1);
  mpContentTable->setRowCount(1);

  mpContentTable->setHorizontalHeaderItem(0, new QTableWidgetItem(""));
  mpContentTable->setVerticalHeaderItem(0, new QTableWidgetItem(""));

  CCopasiAbstractArray::index_type index; index.resize(0);
  //mpContentTable->verticalHeader()->setLabel(i, FROM_UTF8(rowdescr[i]));
  mpContentTable->setItem(0, 0, new QTableWidgetItem(QString::number((*mpArray->array())[index])));
}
예제 #3
0
void CQArrayAnnotationsWidget::fillTableN(size_t rowIndex, size_t colIndex,
    const CCopasiAbstractArray::index_type & index)
{
#ifdef DEBUG_UI
  qDebug() << "-- in fillTable0 A -- \n";
#endif

  if (!mpArray) return;

  assert(rowIndex < index.size());
  assert(colIndex < index.size());

  mpContentTable->setColumnCount((int) mpArray->size()[colIndex]);
  mpContentTable->setRowCount((int) mpArray->size()[rowIndex]);

  std::vector<std::string> rowdescr = mpArray->getAnnotationsString(rowIndex);
  std::vector<std::string> coldescr = mpArray->getAnnotationsString(colIndex);

  size_t i, imax = mpArray->size()[rowIndex];
  size_t j, jmax = mpArray->size()[colIndex];

  if (jmax == 0) return;

  int TableWidth = mpContentTable->size().width();
  mpContentTable->verticalHeader()->setMaximumWidth(TableWidth / std::min< size_t >(jmax, 5));
  mpContentTable->verticalHeader()->setTextElideMode(Qt::ElideRight);
  mpContentTable->horizontalHeader()->setTextElideMode(Qt::ElideRight);

  QString DisplayName;

  //annotations
  for (i = 0; i < imax; ++i)
    {
      DisplayName = FROM_UTF8(rowdescr[i]);
      QTableWidgetItem * pItem = new QTableWidgetItem(DisplayName);
      pItem->setToolTip(DisplayName);
      mpContentTable->setVerticalHeaderItem(i, pItem);
    }

  for (j = 0; j < jmax; ++j)
    {
      // :TODO: This is a hack we need a smarter way possibly using getObjectDisplayName.
      DisplayName = FROM_UTF8(coldescr[j]).replace("; {", "\n{");
      QTableWidgetItem * pItem = new QTableWidgetItem(DisplayName);
      pItem->setToolTip(DisplayName);
      mpContentTable->setHorizontalHeaderItem((int) j, pItem);;

#ifdef DEBUG_UI
      qDebug() << "text on col " << j << " = " << FROM_UTF8(coldescr[j]).replace("; {", "\n{");
#endif
    }

  CCopasiAbstractArray::index_type Index = index;

  //automatic color scaling
  if (mAutomaticColorScaling)
    {
      mpColorScale->startAutomaticParameterCalculation();

      for (i = 0; i < imax; ++i)
        for (j = 0; j < jmax; ++j)
          {
            Index[rowIndex] = i;
            Index[colIndex] = j;
            mpColorScale->passValue((*mpArray->array())[Index]);
          }

      mpColorScale->finishAutomaticParameterCalculation();
    }

  //table contents
  for (i = 0; i < imax; ++i)
    for (j = 0; j < jmax; ++j)
      {
        Index[rowIndex] = i;
        Index[colIndex] = j;

        QTableWidgetItem * pItem = new QTableWidgetItem(QString::number((*mpArray->array())[Index]));
        mpContentTable->setItem((int) i, (int) j, pItem);

        if (mpColorScale != NULL)
          {
            pItem->setBackground(QBrush(mpColorScale->getColor((*mpArray->array())[Index])));
          }
      }

  mOneDimensional = false;

  mpContentTable->resizeRowsToContents();
  mpContentTable->resizeColumnsToContents();

//  if (mpStack->id(mpStack->visibleWidget()) == 1)
  if (mpStack->currentIndex() == 1)
    fillBarChart();
}
예제 #4
0
std::vector<const CCopasiObject*>
CCopasiSelectionDialog::chooseCellMatrix(const CArrayAnnotation * pArrayAnnotation, bool single, bool value, std::string caption)
{
  std::vector< const CCopasiObject* > returnVector;

  if (single)
    {returnVector.resize(1); returnVector[0] = NULL;}
  else
    returnVector.resize(0);

  if (!pArrayAnnotation) return returnVector;

  //handle zero-dimensional array
  if (pArrayAnnotation->size().size() == 0)
    {
      CCopasiAbstractArray::index_type index;
      index.resize(0);
      returnVector.resize(1);
      returnVector[0] = static_cast< const CCopasiObject * >(pArrayAnnotation->addElementReference(index));
      return returnVector;
    }

  CQMatrixDialog * pDialog = new CQMatrixDialog();

  pDialog->setWindowTitle(tr(TO_UTF8(FROM_UTF8(caption) + "Cell Selection of " + FROM_UTF8(pArrayAnnotation->getObjectName()))));
  pDialog->setArray(pArrayAnnotation, single);

  int Result = pDialog->exec();

  if (Result == QDialog::Accepted)
    {
      CCopasiAbstractArray::index_type index;
      index.resize(pArrayAnnotation->dimensionality());

      if (index.size() > 2)
        CQMessageBox::warning(0, "Dimensionality Problem", "Need more handle for high dimension of array",
                              QMessageBox::Ok | QMessageBox::Default, QMessageBox::NoButton);

      if (single)
        {
          // single cell selection
          if (value)
            {
              index[0] = pDialog->mpCBRow->currentIndex();

              if (index.size() > 1)
                index[1] = pDialog->mpCBColumn->currentIndex();

              returnVector[0] = static_cast< const CCopasiObject * >(pArrayAnnotation->addElementReference(index));
            }

          return returnVector;
        }

      // multi cell selection

      //if "All" is selected for both rows and columns, and an object with numerical value
      //is not requested, return the array annotation as such
      if (pDialog->mpCBRow->currentIndex() == 0 && pDialog->mpCBColumn->currentIndex() == 0
          && !value)
        {
          // whole matrix should be chosen -> the object itself will be returned
          returnVector.resize(1);
          returnVector[0] = (CCopasiObject *) pArrayAnnotation;
          return returnVector;
        }

      size_t minRows, maxRows, minCols, maxCols;
      size_t i, j;

      if (pDialog->mpCBRow->currentIndex())
        {
          // not ALL option
          minRows = pDialog->mpCBRow->currentIndex() - 1;
          maxRows = minRows + 1;
        }
      else
        {
          // ALL option
          minRows = 0;
          maxRows = pArrayAnnotation->size()[0];
        }

      if (index.size() == 2)
        {
          if (pDialog->mpCBColumn->currentIndex())
            {
              // not ALL option
              minCols = pDialog->mpCBColumn->currentIndex() - 1;
              maxCols = minCols + 1;
            }
          else
            {
              // ALL option
              minCols = 0;
              maxCols = pArrayAnnotation->size()[1];
            }

          for (i = minRows; i < maxRows; ++i)
            {
              for (j = minCols; j < maxCols; ++j)
                {
                  returnVector.push_back(static_cast< const CCopasiObject * >(pArrayAnnotation->addElementReference((int) i, (int) j)));
                }
            }
        }

      if (index.size() == 1)
        {
          for (i = minRows; i < maxRows; ++i)
            {
              returnVector.push_back(static_cast< const CCopasiObject * >(pArrayAnnotation->addElementReference((int) i)));
            }
        }

      return returnVector;
    }

  else
    {
      // Rejected case
      if (single)
        returnVector[0] = NULL;

      return returnVector;
    }
}