bool CQTrajectoryWidget::loadTask() { CTrajectoryTask * pTask = dynamic_cast< CTrajectoryTask * >(mpTask); if (!pTask) return false; loadCommon(); loadMethod(); showUnits(); CTrajectoryProblem* TrajectoryProblem = dynamic_cast<CTrajectoryProblem *>(pTask->getProblem()); assert(TrajectoryProblem); pdelete(mpTrajectoryProblem); mpTrajectoryProblem = new CTrajectoryProblem(*TrajectoryProblem, NO_PARENT); //numbers mpEditIntervalSize->setText(QString::number(TrajectoryProblem->getStepSize())); mpEditIntervals->setText(QString::number(TrajectoryProblem->getStepNumber())); mpEditDuration->setText(QString::number(TrajectoryProblem->getDuration())); mpCheckAutomaticInterval->setChecked(TrajectoryProblem->getAutomaticStepSize()); assert(CCopasiRootContainer::getDatamodelList()->size() > 0); C_FLOAT64 InitialTime = CCopasiRootContainer::getDatamodelList()->operator[](0).getModel()->getInitialTime(); bool Delayed; if (TrajectoryProblem->getStepSize() > 0.0) Delayed = (TrajectoryProblem->getOutputStartTime() - InitialTime) > std::numeric_limits< C_FLOAT64 >::min(); else Delayed = (InitialTime - TrajectoryProblem->getOutputStartTime()) > std::numeric_limits< C_FLOAT64 >::min(); mpCheckDelay->setChecked(Delayed); mpEditDelay->setEnabled(Delayed); mpEditDelay->setText(QString::number(TrajectoryProblem->getOutputStartTime())); mpCheckOutputEvent->setChecked(TrajectoryProblem->getOutputEvent()); mpCheckContinueEvents->setChecked(TrajectoryProblem->getContinueSimultaneousEvents()); mpCheckStartInSteadyState->setChecked(TrajectoryProblem->getStartInSteadyState()); //store time series checkbox mpCheckSave->setChecked(TrajectoryProblem->timeSeriesRequested()); checkTimeSeries(); updateIntervals(); mpValidatorDuration->saved(); mpValidatorIntervalSize->saved(); mpValidatorIntervals->saved(); mpValidatorDelay->saved(); return true; }
bool CQTrajectoryWidget::saveTask() { CTrajectoryTask * pTask = dynamic_cast< CTrajectoryTask * >(mpTask); if (!pTask) return false; saveCommon(); saveMethod(); CTrajectoryProblem* trajectoryproblem = dynamic_cast<CTrajectoryProblem *>(pTask->getProblem()); assert(trajectoryproblem); //numbers if (mpEditIntervalSize->hasAcceptableInput() && trajectoryproblem->getStepSize() != mpEditIntervalSize->text().toDouble()) { trajectoryproblem->setStepSize(mpEditIntervalSize->text().toDouble()); mChanged = true; } else if (mpEditIntervals->hasAcceptableInput() && trajectoryproblem->getStepNumber() != mpEditIntervals->text().toULong()) { trajectoryproblem->setStepNumber(mpEditIntervals->text().toLong()); mChanged = true; } if (mpEditDuration->hasAcceptableInput() && trajectoryproblem->getDuration() != mpEditDuration->text().toDouble()) { trajectoryproblem->setDuration(mpEditDuration->text().toDouble()); mChanged = true; } if (mpCheckAutomaticInterval->isChecked() != trajectoryproblem->getAutomaticStepSize()) { trajectoryproblem->setAutomaticStepSize(mpCheckAutomaticInterval->isChecked()); mChanged = true; } C_FLOAT64 StartTime = mpEditDelay->text().toDouble(); if (mpCheckDelay->isChecked()) { if (mpEditDelay->hasAcceptableInput() && StartTime != trajectoryproblem->getOutputStartTime()) { trajectoryproblem->setOutputStartTime(StartTime); mChanged = true; } } else { assert(CCopasiRootContainer::getDatamodelList()->size() > 0); C_FLOAT64 InitialTime = CCopasiRootContainer::getDatamodelList()->operator[](0).getModel()->getInitialTime(); if (trajectoryproblem->getStepSize() > 0.0) { if (StartTime > InitialTime) { trajectoryproblem->setOutputStartTime(InitialTime); mChanged = true; } } else { if (StartTime < InitialTime) { trajectoryproblem->setOutputStartTime(InitialTime); mChanged = true; } } } if (trajectoryproblem->timeSeriesRequested() != mpCheckSave->isChecked()) { trajectoryproblem->setTimeSeriesRequested(mpCheckSave->isChecked()); mChanged = true; } if (trajectoryproblem->getOutputEvent() != mpCheckOutputEvent->isChecked()) { trajectoryproblem->setOutputEvent(mpCheckOutputEvent->isChecked()); mChanged = true; } if (trajectoryproblem->getContinueSimultaneousEvents() != mpCheckContinueEvents->isChecked()) { trajectoryproblem->setContinueSimultaneousEvents(mpCheckContinueEvents->isChecked()); mChanged = true; } if (trajectoryproblem->getStartInSteadyState() != mpCheckStartInSteadyState->isChecked()) { trajectoryproblem->setStartInSteadyState(mpCheckStartInSteadyState->isChecked()); mChanged = true; } mpValidatorDuration->saved(); mpValidatorIntervalSize->saved(); mpValidatorIntervals->saved(); mpValidatorDelay->saved(); return true; }