コード例 #1
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])));
}
コード例 #2
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;
    }
}