Example #1
0
int main(int argc, char *argv[])
{
  // Fix for Issue 1377, if locale is not set to the default one, some
  // numbers will be displayed in the systems default locale:
  setlocale(LC_ALL, "C");

  // Fix of Issue with Text centering on OSX Mavericks
#ifdef Q_OS_MACX

  if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_8)
    {
      // fix Mac OS X 10.9 (mavericks) font issue
      // https://bugreports.qt-project.org/browse/QTBUG-32789
      QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande");
    }

#endif

  CQCopasiApplication a(argc, argv);

  a.setAttribute(Qt::AA_DontShowIconsInMenus, false);

  Q_INIT_RESOURCE(copasi);

  // Parse the commandline options
  try
    {
      // Create the root container.
      CCopasiRootContainer::init(argc, argv, true);
    }
  catch (copasi::option_error & msg)
    {
      CQMessageBox::critical(NULL, "Initialization Error",
                             msg.what(),
                             QMessageBox::Ok , QMessageBox::Ok);

      return 1;
    }

#ifdef Darwin
  std::string PluginDir;

  COptions::getValue("CopasiDir", PluginDir);
  PluginDir += "/Contents/plugins";

  QApplication::setLibraryPaths(QStringList(FROM_UTF8(PluginDir)));
#endif // Darwin

  // Create the global data model.
  CCopasiRootContainer::addDatamodel();

  // Create the main application window.
  CopasiUI3Window *pWindow = CopasiUI3Window::create();

#ifdef COPASI_SBW_INTEGRATION

  if (COptions::compareValue("SBWRegister", true))
    goto finish;

#endif // COPASI_SBW_INTEGRATION

  if (pWindow != NULL)
    {
      a.setMainWindow(pWindow);
      a.exec();
    }

finish:

  try // To suppress any access violations during destruction works only under Windows
    {
      pdelete(pWindow);
      CCopasiRootContainer::destroy();
    }
  catch (...)
    {}

  return 0;
}
Example #2
0
pgsCast::~pgsCast()
{
	pdelete(m_var);
}
Example #3
0
void CQTrajectoryWidget::destroy()
{
  pdelete(mpTrajectoryProblem);
}
Example #4
0
bool CTrajectoryTask::initialize(const OutputFlag & of,
                                 COutputHandler * pOutputHandler,
                                 std::ostream * pOstream)
{
  assert(mpProblem && mpMethod);

  mpTrajectoryProblem = dynamic_cast<CTrajectoryProblem *>(mpProblem);
  assert(mpTrajectoryProblem);

  mpTrajectoryMethod = dynamic_cast<CTrajectoryMethod *>(mpMethod);
  assert(mpTrajectoryMethod);

  mpTrajectoryMethod->setProblem(mpTrajectoryProblem);

  bool success = mpMethod->isValidProblem(mpProblem);

  CCopasiParameter * pParameter = mpMethod->getParameter("Integrate Reduced Model");

  if (pParameter != NULL)
    mUpdateMoieties = *pParameter->getValue().pBOOL;
  else
    mUpdateMoieties = false;

  pdelete(mpCurrentState);
  mpCurrentState = new CState(mpTrajectoryProblem->getModel()->getState());
  mpCurrentTime = &mpCurrentState->getTime();

  //mpOutputStartTime = & mpTrajectoryProblem->getOutputStartTime();

  // Handle the time series as a regular output.
  mTimeSeriesRequested = mpTrajectoryProblem->timeSeriesRequested();

  if ((pOutputHandler != NULL) &&
      mTimeSeriesRequested &&
      (of & CCopasiTask::TIME_SERIES))
    {
      mTimeSeries.allocate(mpTrajectoryProblem->getStepNumber());
      pOutputHandler->addInterface(&mTimeSeries);
    }
  else
    {
      mTimeSeries.clear();
    }

  mpTrajectoryProblem->getModel()->getMathModel()->getProcessQueue().setContinueSimultaneousEvents(mpTrajectoryProblem->getContinueSimultaneousEvents());

  if (mpTrajectoryProblem->getStartInSteadyState())
    {
      mpSteadyState =
        dynamic_cast<CSteadyStateTask *>((*mpTrajectoryProblem->getObjectDataModel()->getTaskList())["Steady-State"]);

      if (mpSteadyState == NULL) fatalError();

      mpSteadyState->initialize(CCopasiTask::NO_OUTPUT, NULL, NULL);
    }
  else
    {
      mpSteadyState = NULL;
    }

  if (!CCopasiTask::initialize(of, pOutputHandler, pOstream)) success = false;

  return success;
}
CreateNewGlobalQuantityCommand::~CreateNewGlobalQuantityCommand()
{
  pdelete(mpGlobalQuantityData);
}
Example #6
0
CPraxis::~CPraxis()
{
  pdelete(mpRandom);
}
Example #7
0
/*
 *  Destroys the object and frees any allocated resources
 */
CQPlotsWidget::~CQPlotsWidget()
{
  pdelete(mpProxyModel);
  pdelete(mpPlotDM);
  // no need to delete child widgets, Qt does it all for us
}
Example #8
0
UndoEventData::~UndoEventData()
{
  // TODO Auto-generated destructor stub
  pdelete(this->mEventAssignmentData);
}
Example #9
0
DeleteEventCommand::~DeleteEventCommand()
{
  // TODO Auto-generated destructor stub
  pdelete(mpEventData);
}
Example #10
0
CompartmentDataChangeCommand::~CompartmentDataChangeCommand()
{
  pdelete(mpCompartmentUndoData);
}
 // freeing the memory allocated above
 foreach(UndoGlobalQuantityData * data, mpGlobalQuantityData)
 {
   pdelete(data);
 }
Example #12
0
/*
 *  Destroys the object and frees any allocated resources
 */
CQMathMatrixWidget::~CQMathMatrixWidget()
{
  pdelete(mpJacobianAnn);
  pdelete(mpJacobianAnnRed);
}
Example #13
0
void CQSpeciesDetail::copy()
{
  if (mpMetab == NULL) return;

  CModel * pModel = NULL;

  if (mpMetab) pModel = mpDataModel->getModel();

  if (pModel == NULL) return; // for getting compartments and initializing cModelExpObj

  // Create and customize compartment choices dialog
  CQNameSelectionDialog * pDialog = new CQNameSelectionDialog(this);
  pDialog->setWindowTitle("Choose a compartment");
  pDialog->mpLblName->setText("compartment");
  pDialog->mpSelectionBox->clear();
  pDialog->mpSelectionBox->setDuplicatesEnabled(false);
  pDialog->mpSelectionBox->setEditable(false); // at least for now, unless we want to add new compartment creation here.

  // Use CModelExpansion for duplication
  CModelExpansion cModelExpObj = CModelExpansion(pModel);
  CModelExpansion::SetOfModelElements sourceObjects;
  CModelExpansion::ElementsMap origToCopyMapping;

  // for comboBox compartment list and setting compartment
  CCopasiVectorNS< CCompartment > & Compartments = pModel->getCompartments();

  CCopasiVectorN< CCompartment >::const_iterator it = Compartments.begin();
  CCopasiVectorN< CCompartment >::const_iterator end = Compartments.end();
  QStringList SelectionList;

  // Collect and load list of compartment names in comboBox
  for (; it != end; ++it)
    {
      SelectionList.append(FROM_UTF8(it->getObjectName()));
    }

  pDialog->setSelectionList(SelectionList);

  //Set the current compartment as the default
  mpCurrentCompartment = mpMetab->getCompartment();
  // to use here, and for testing if compartment changed after executing the dialog
  int origCompartmentIndex = pDialog->mpSelectionBox->findText(FROM_UTF8(mpCurrentCompartment->getObjectName()));
  pDialog->mpSelectionBox->setCurrentIndex(origCompartmentIndex);

  it = Compartments.begin(); // Reuse Compartments iterator to set compartment choice

  if (pDialog->exec() != QDialog::Rejected)
    {
      // Put species in different compartment (without name modification) by making
      // duplicateMetab think the other compartment was duplicated from the original
      if (origCompartmentIndex != pDialog->mpSelectionBox->currentIndex())
        {
          sourceObjects.addCompartment(mpMetab->getCompartment());
          origToCopyMapping.add(mpMetab->getCompartment(), (it + pDialog->mpSelectionBox->currentIndex()).constCast());
        }

      sourceObjects.addMetab(mpMetab);
      cModelExpObj.duplicateMetab(mpMetab, "_copy", sourceObjects, origToCopyMapping);

      protectedNotify(ListViews::COMPARTMENT, ListViews::DELETE, "");//Refresh all
      protectedNotify(ListViews::METABOLITE, ListViews::DELETE, ""); //Refresh all
      protectedNotify(ListViews::REACTION, ListViews::DELETE, "");   //Refresh all
      mpListView->switchToOtherWidget(C_INVALID_INDEX, origToCopyMapping.getDuplicateKey(mKey));
    }

  pdelete(pDialog);
}
Example #14
0
void CQFittingResult::init()
{
  unsigned C_INT32 i, imax;

  // Set up the parameters table
  mpParameters->setNumCols(mpParameters->numCols() + 1);
  mpParameters->horizontalHeader()->setLabel(mpParameters->numCols() - 1, tr("Parameter"));
  mpParameters->setNumCols(mpParameters->numCols() + 1);
  mpParameters->horizontalHeader()->setLabel(mpParameters->numCols() - 1, tr("Value"));
  mpParameters->setNumCols(mpParameters->numCols() + 1);
  mpParameters->horizontalHeader()->setLabel(mpParameters->numCols() - 1, tr("Std. Deviation"));
  mpParameters->setNumCols(mpParameters->numCols() + 1);
  mpParameters->horizontalHeader()->setLabel(mpParameters->numCols() - 1, tr("Coeff. of Variation [%]"));
  mpParameters->setNumCols(mpParameters->numCols() + 1);
  mpParameters->horizontalHeader()->setLabel(mpParameters->numCols() - 1, tr("Gradient"));
  mpParameters->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7, (QSizePolicy::SizeType)5, 0, 0, mpParameters->sizePolicy().hasHeightForWidth()));
  mpParameters->setNumRows(0);
  mpParameters->setNumCols(5);
  mpParameters->setReadOnly(true);

  for (i = 0, imax = mpParameters->numCols(); i != imax; i++)
    mpParameters->adjustColumn(i);

  // Set up the experiments table
  mpExperiments->setNumCols(mpExperiments->numCols() + 1);
  mpExperiments->horizontalHeader()->setLabel(mpExperiments->numCols() - 1, tr("Experiment"));
  mpExperiments->setNumCols(mpExperiments->numCols() + 1);
  mpExperiments->horizontalHeader()->setLabel(mpExperiments->numCols() - 1, tr("Objective Value"));
  mpExperiments->setNumCols(mpExperiments->numCols() + 1);
  mpExperiments->horizontalHeader()->setLabel(mpExperiments->numCols() - 1, tr("Root Mean Square"));
  mpExperiments->setNumCols(mpExperiments->numCols() + 1);
  mpExperiments->horizontalHeader()->setLabel(mpExperiments->numCols() - 1, tr("Error Mean"));
  mpExperiments->setNumCols(mpExperiments->numCols() + 1);
  mpExperiments->horizontalHeader()->setLabel(mpExperiments->numCols() - 1, tr("Error Mean Std. Deviation"));
  mpExperiments->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7, (QSizePolicy::SizeType)5, 0, 0, mpExperiments->sizePolicy().hasHeightForWidth()));
  mpExperiments->setNumRows(0);
  mpExperiments->setNumCols(5);
  mpExperiments->setReadOnly(true);

  for (i = 0, imax = mpExperiments->numCols(); i != imax; i++)
    mpExperiments->adjustColumn(i);

  // Set up the experiments table
  mpValues->setNumCols(mpValues->numCols() + 1);
  mpValues->horizontalHeader()->setLabel(mpValues->numCols() - 1, tr("Fitted Value"));
  mpValues->setNumCols(mpValues->numCols() + 1);
  mpValues->horizontalHeader()->setLabel(mpValues->numCols() - 1, tr("Objective Value"));
  mpValues->setNumCols(mpValues->numCols() + 1);
  mpValues->horizontalHeader()->setLabel(mpValues->numCols() - 1, tr("Root Mean Square"));
  mpValues->setNumCols(mpValues->numCols() + 1);
  mpValues->horizontalHeader()->setLabel(mpValues->numCols() - 1, tr("Error Mean"));
  mpValues->setNumCols(mpValues->numCols() + 1);
  mpValues->horizontalHeader()->setLabel(mpValues->numCols() - 1, tr("Error Mean Std. Deviation"));
  mpValues->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7, (QSizePolicy::SizeType)5, 0, 0, mpValues->sizePolicy().hasHeightForWidth()));
  mpValues->setNumRows(0);
  mpValues->setNumCols(5);
  mpValues->setReadOnly(true);

  for (i = 0, imax = mpValues->numCols(); i != imax; i++)
    mpValues->adjustColumn(i);

  mpCorrelations->setLegendEnabled(false);
  mpFisherInformation->setLegendEnabled(false);


#ifndef COPASI_CROSSVALIDATION
  pdelete(mpCrossValidations);
  pdelete(mpCrossValidationValues);
#endif // not COPASI_CROSSVALIDATION
}
Example #15
0
CQEFMResultWidget::~CQEFMResultWidget()
{
  pdelete(mpProxyModelNetReactions);
  pdelete(mpProxyModelReactions);
  pdelete(mpProxyModelSpecies);
}
Example #16
0
CFitItem::~CFitItem()
{pdelete(mpLocalMethod);}
Example #17
0
void CQRDFTreeView::clear()
{
  mNode2Item.clear();
  pdelete(mpGraph);
  mpTreeWidget->clear();
}
Example #18
0
// virtual
CMathObject::~CMathObject()
{
  pdelete(mpExpression);
}
Example #19
0
pgsAssign::~pgsAssign()
{
	pdelete(m_var);
}
Example #20
0
CPlotSelectionDialog::~CPlotSelectionDialog()
{
  pdelete(this->mpOKButton);
  pdelete(this->mpCancelButton);
  pdelete(this->mpExpertCheckBox);
  pdelete(this->mpXAxisLabel);
  pdelete(this->mpYAxisLabel);
  pdelete(this->mpXAxisSimpleSelectionWidget);
  pdelete(this->mpYAxisSimpleSelectionWidget);
  pdelete(this->mpXAxisObjectBrowserWidget);
  pdelete(this->mpYAxisObjectBrowserWidget);
  pdelete(this->mpXAxisSelectionBox);
  pdelete(this->mpYAxisSelectionBox);
  pdelete(this->mpSplitter);
  pdelete(this->mpButtonBox);
  pdelete(this->mpMainLayout);
  pdelete(this->mpXAxisTmpVector);
  pdelete(this->mpYAxisTmpVector);
}
Example #21
0
void CTrajectoryTask::cleanup()
{
  pdelete(mpCurrentState);
}
Example #22
0
bool CQFittingWidget::loadTask()
{
  CFitTask * pTask =
    dynamic_cast< CFitTask * >(mpTask);

  if (!pTask) return false;

  loadCommon();
  loadMethod();

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

  if (!pProblem) return false;

  pdelete(mpExperimentSet)
  CExperimentSet * pExperimentSet =
    dynamic_cast<CExperimentSet *>(pProblem->getGroup("Experiment Set"));
  mpExperimentSet = new CExperimentSet(*pExperimentSet, NO_PARENT);

  mExperimentKeyMap.clear();
  size_t i, imax = mpExperimentSet->getExperimentCount();

  for (i = 0; i < imax; i++)
    mExperimentKeyMap[pExperimentSet->getExperiment(i)->CCopasiParameter::getKey()] =
      mpExperimentSet->getExperiment(i)->CCopasiParameter::getKey();

  pdelete(mpCrossValidationSet)
  CCrossValidationSet * pCrossValidationSet =
    dynamic_cast<CCrossValidationSet *>(pProblem->getGroup("Validation Set"));
  mpCrossValidationSet = new CCrossValidationSet(*pCrossValidationSet, NO_PARENT);

  mCrossValidationKeyMap.clear();
  imax = mpCrossValidationSet->getExperimentCount();

  for (i = 0; i < imax; i++)
    mCrossValidationKeyMap[pCrossValidationSet->getExperiment(i)->CCopasiParameter::getKey()] =
      mpCrossValidationSet->getExperiment(i)->CCopasiParameter::getKey();

  mpCheckRandomize->setChecked(pProblem->getRandomizeStartValues());
  mpCreateParameterSets->setChecked(pProblem->getCreateParameterSets());
  mpCheckStatistics->setChecked(pProblem->getCalculateStatistics());

  mpParameters->load(mpDataModel, pProblem->getGroup("OptimizationItemList"), &mExperimentKeyMap, &mCrossValidationKeyMap);

  if (CCopasiMessage::peekLastMessage().getType() == CCopasiMessage::ERROR)
    {
      CQMessageBox::critical(this, "Error loading Parameter estimation task",
                             CCopasiMessage::getAllMessageText().c_str(),
                             QMessageBox::Ok | QMessageBox::Default,
                             QMessageBox::NoButton);
    }

  mpParameters->setExperimentSet(const_cast<const CExperimentSet *&>(mpExperimentSet));
  mpParameters->setCrossValidationSet(const_cast<const CCrossValidationSet *&>(mpCrossValidationSet));

  mpConstraints->load(mpDataModel, pProblem->getGroup("OptimizationConstraintList"), &mExperimentKeyMap, &mCrossValidationKeyMap);
  mpConstraints->setExperimentSet(const_cast<const CExperimentSet *&>(mpExperimentSet));
  mpConstraints->setCrossValidationSet(const_cast<const CCrossValidationSet *&>(mpCrossValidationSet));

  mChanged = false;

  return true;
}
Example #23
0
CILDMModifiedMethod::~CILDMModifiedMethod()
{
  pdelete(mpState);
}
Example #24
0
void CQFittingWidget::destroy()
{
  pdelete(mpExperimentSet);
  pdelete(mpCrossValidationSet);
}
Example #25
0
int
waitup(int echildok, int *retstatus)
{
	Envy *e;
	int pid;
	int slot;
	Symtab *s;
	Word *w;
	Job *j;
	char buf[ERRMAX];
	Bufblock *bp;
	int uarg = 0;
	int done;
	Node *n;
	Process *p;
	extern int runerrs;

	/* first check against the proces slist */
	if(retstatus)
		for(p = phead; p; p = p->f)
			if(p->pid == *retstatus){
				*retstatus = p->status;
				pdelete(p);
				return(-1);
			}
again:		/* rogue processes */
	pid = waitfor(buf);
	if(pid == -1){
		if(echildok > 0)
			return(1);
		else {
			fprint(2, "mk: (waitup %d) ", echildok);
			perror("mk wait");
			Exit();
		}
	}
	if(DEBUG(D_EXEC))
		fprint(1, "waitup got pid=%d, status='%s'\n", pid, buf);
	if(retstatus && pid == *retstatus){
		*retstatus = buf[0]? 1:0;
		return(-1);
	}
	slot = pidslot(pid);
	if(slot < 0){
		if(DEBUG(D_EXEC))
			fprint(2, "mk: wait returned unexpected process %d\n", pid);
		pnew(pid, buf[0]? 1:0);
		goto again;
	}
	j = events[slot].job;
	usage();
	nrunning--;
	events[slot].pid = -1;
	if(buf[0]){
		e = buildenv(j, slot);
		bp = newbuf();
		shprint(j->r->recipe, e, bp);
		front(bp->start);
		fprint(2, "mk: %s: exit status=%s", bp->start, buf);
		freebuf(bp);
		for(n = j->n, done = 0; n; n = n->next)
			if(n->flags&DELETE){
				if(done++ == 0)
					fprint(2, ", deleting");
				fprint(2, " '%s'", n->name);
				delete(n->name);
			}
		fprint(2, "\n");
		if(kflag){
			runerrs++;
			uarg = 1;
		} else {
			jobs = 0;
			Exit();
		}
	}
	for(w = j->t; w; w = w->next){
		if((s = symlook(w->s, S_NODE, 0)) == 0)
			continue;	/* not interested in this node */
		update(uarg, s->u.ptr);
	}
	if(nrunning < nproclimit)
		sched();
	return(0);
}
Example #26
0
pgsGenRegex::~pgsGenRegex()
{
	pdelete(m_regex);
	pdelete(m_seed);
}
Example #27
0
/*
 *  Destroys the object and frees any allocated resources
 */
CQParameterSetsWidget::~CQParameterSetsWidget()
{
  pdelete(mpProxyModel);
  pdelete(mpParameterSetsDM);
  // no need to delete child widgets, Qt does it all for us
}
Example #28
0
CCompressedColumnFormat::~CCompressedColumnFormat()
{
  pdelete(mpValue);
  pdelete(mpRowIndex);
  pdelete(mpColumnStart);
}
Example #29
0
/*
 *  Destroys the object and frees any allocated resources
 */
CQFunctionsWidget::~CQFunctionsWidget()
{
  pdelete(mpProxyModel);
  pdelete(mpFunctionDM);
  // no need to delete child widgets, Qt does it all for us
}
Example #30
0
TaskWidget::~TaskWidget()
{
  pdelete(mpTaskThread);
}