Ejemplo n.º 1
0
std::vector< const CCopasiObject * > CCopasiSelectionDialog::getObjectVector(QWidget * parent,
    const CCopasiSimpleSelectionTree::ObjectClasses & classes,
    const std::vector< const CCopasiObject * > * pCurrentSelection)
{
  std::vector< const CCopasiObject * > Selection;

  if (pCurrentSelection)
    Selection = *pCurrentSelection;

  CCopasiSelectionDialog * pDialog = new CCopasiSelectionDialog(parent);
  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
  pDialog->setModel((*CCopasiRootContainer::getDatamodelList())[0]->getModel(), classes);
  pDialog->setSingleSelection(false);
  pDialog->setOutputVector(&Selection);

  if (pDialog->exec() == QDialog::Rejected && pCurrentSelection)
    return *pCurrentSelection;
  else
    //    return Selection;
    {
      if (classes == CCopasiSimpleSelectionTree::AnyObject)
        {
          std::vector<const CCopasiObject *> newSelection;

          std::vector< const CCopasiObject * >::iterator itSelection = Selection.begin();

          for (; itSelection != Selection.end(); ++itSelection)
            {
              // if the current object is an array then select firstly one cell of it
              const CArrayAnnotation * pArray;

              if ((pArray = dynamic_cast< const CArrayAnnotation * >(*itSelection)))
                {
                  // second parameter is false in order 'ALL' options on the matrix dialog to appear
                  std::vector<const CCopasiObject *> tmp = chooseCellMatrix(pArray, false, true); //TODO value flag
                  std::vector<const CCopasiObject *>::const_iterator tmpit, tmpitEnd = tmp.end();

                  for (tmpit = tmp.begin(); tmpit != tmpitEnd; ++tmpit)
                    newSelection.push_back(*tmpit);
                }
              // otherwise, just put it into newSelection
              else
                {
                  newSelection.push_back(*itSelection);
                }
            }

          return newSelection;
        }

      return Selection;
    }

  //  return Selection;
}
Ejemplo n.º 2
0
std::vector< const CCopasiObject * > CCopasiSelectionDialog::getObjectVector(QWidget * parent,
    const CQSimpleSelectionTree::ObjectClasses & classes,
    const std::vector< const CCopasiObject * > * pCurrentSelection)
{
  std::vector< const CCopasiObject * > Selection;

  if (pCurrentSelection)
    Selection = *pCurrentSelection;

  CCopasiSelectionDialog * pDialog = new CCopasiSelectionDialog(parent);
  pDialog->setWindowTitle("Select Items");
  pDialog->setToolTip("Select multiple items by holding down the Ctrl or Shift (or equivalent) key.");
  pDialog->setFilter(classes);
  pDialog->setSingleSelection(false);
  pDialog->setOutputVector(&Selection);

  if (pDialog->exec() == QDialog::Rejected && pCurrentSelection)
    return *pCurrentSelection;
  else
    //    return Selection;
    {
      std::vector<const CCopasiObject *> newSelection;

      std::vector< const CCopasiObject * >::iterator itSelection = Selection.begin();

      for (; itSelection != Selection.end(); ++itSelection)
        {
          // if the current object is an array then select firstly one cell of it
          const CArrayAnnotation * pArray;

          if ((pArray = dynamic_cast< const CArrayAnnotation * >(*itSelection)))
            {
              // second parameter is false in order 'ALL' options on the matrix dialog to appear
              std::vector<const CCopasiObject *> tmp = chooseCellMatrix(pArray, false, true); //TODO value flag
              std::vector<const CCopasiObject *>::const_iterator tmpit, tmpitEnd = tmp.end();

              for (tmpit = tmp.begin(); tmpit != tmpitEnd; ++tmpit)
                newSelection.push_back(*tmpit);
            }
          // otherwise, just put it into newSelection
          else
            {
              newSelection.push_back(*itSelection);
            }
        }

      return newSelection;
    }

  //  return Selection;
}
Ejemplo n.º 3
0
std::vector< const CCopasiObject * > CCopasiSelectionDialog::getObjectVector(QWidget * parent,
    const std::vector< const CCopasiObject * > & objectList,
    const std::vector< const CCopasiObject * > * pCurrentSelection)
{
  std::vector< const CCopasiObject * > Selection;

  if (pCurrentSelection)
    Selection = *pCurrentSelection;

  CCopasiSelectionDialog * pDialog = new CCopasiSelectionDialog(parent);
  pDialog->setWindowTitle("Select Items");
  pDialog->setToolTip("Select multiple items by holding down the Ctrl or Shift (or equivalent) key.");
  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
  pDialog->enableExpertMode(false);
  pDialog->setValidObjects(objectList);
  pDialog->setSingleSelection(false);
  pDialog->setOutputVector(&Selection);

  if (pDialog->exec() == QDialog::Rejected)
    {
      return Selection;
    }

  std::vector<const CCopasiObject *> newSelection;
  std::vector< const CCopasiObject * >::iterator itSelection = Selection.begin();
  std::vector< const CCopasiObject * >::iterator endSelection = Selection.end();

  for (; itSelection != endSelection; ++itSelection)
    {
      // if the current object is an array then select firstly one cell of it
      const CArrayAnnotation * pArray;

      if ((pArray = dynamic_cast< const CArrayAnnotation * >(*itSelection)))
        {
          // second parameter is false in order 'ALL' options on the matrix dialog to appear
          std::vector<const CCopasiObject *> tmp = chooseCellMatrix(pArray, false, true); //TODO value flag
          std::vector<const CCopasiObject *>::const_iterator tmpit, tmpitEnd = tmp.end();

          for (tmpit = tmp.begin(); tmpit != tmpitEnd; ++tmpit)
            newSelection.push_back(*tmpit);
        }
      // otherwise, just put it into newSelection
      else
        {
          newSelection.push_back(*itSelection);
        }
    }

  return newSelection;
}
Ejemplo n.º 4
0
const CCopasiObject *
CCopasiSelectionDialog::getObjectSingle(QWidget * parent,
                                        const CQSimpleSelectionTree::ObjectClasses & classes,
                                        const CCopasiObject * pCurrentObject)
{
  std::vector< const CCopasiObject * > Selection;

  if (pCurrentObject != NULL)
    Selection.push_back(pCurrentObject);

  CCopasiSelectionDialog * pDialog = new CCopasiSelectionDialog(parent);
  pDialog->setWindowTitle("Select Item");
  pDialog->setFilter(classes);
  pDialog->setSingleSelection(true);
  pDialog->setOutputVector(&Selection);

  int Result = pDialog->exec();

  if (Result == QDialog::Accepted && Selection.size() != 0)
    {
      const CCopasiObject *pObject = Selection[0];
      const CArrayAnnotation * pArray;

      // if the selected object is an array then select firstly one cell of it
      if ((pArray = dynamic_cast< const CArrayAnnotation * >(pObject)))
        {
          pObject = chooseCellMatrix(pArray, true, true)[0];

          if (!pObject) return NULL;
        }

      return pObject;
    }

  if (Result == QDialog::Rejected && pCurrentObject != NULL)
    return pCurrentObject;

  return NULL;
}