Skip to content

Commit

Permalink
Merge fea48c9 into 0fb6c79
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Sep 20, 2018
2 parents 0fb6c79 + fea48c9 commit 3f61790
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 19 deletions.
1 change: 1 addition & 0 deletions doc/downloads/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var jsonData = { "versions": [
"changes": [
{ "change": "<strong>General:</strong> improved HiDPI support on Windows (see issue <a href=\"https://github.com/opencor/opencor/issues/1776\">#1776</a>)." },
{ "change": "<strong>Editor widget:</strong> properly highlight/replace text that was found using a regular expression (see issue <a href=\"https://github.com/opencor/opencor/issues/1816\">#1816</a>)." },
{ "change": "<strong>Simulation Experiment view:</strong> the resetting of model parameters is now more specific (see issue <a href=\"https://github.com/opencor/opencor/issues/1815\">#1815</a>)." },
{ "change": "<strong>Third-party libraries:</strong> upgraded <a href=\"http://www.llvm.org/\">LLVM</a>+<a href=\"http://clang.llvm.org/\">Clang</a> to version 7.0.0 (see issue <a href=\"https://github.com/opencor/opencor/issues/1814\">#1814</a>)." }
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,22 @@
<source>Reset Model Parameters</source>
<translation>Réinitialiser Paramètres Modèle</translation>
</message>
<message>
<source>Reset the state/rate model parameters or all the model parameters</source>
<translation>Réinitialiser les paramètres état/taux du modèle ou tous les paramètres du modèle</translation>
</message>
<message>
<source>States/Rates</source>
<translation>États/Taux</translation>
</message>
<message>
<source>Reset the state/rate model parameters</source>
<translation>Réinitialiser les paramètres état/taux du modèle</translation>
</message>
<message>
<source>All</source>
<translation>Tous</translation>
</message>
<message>
<source>Reset all the model parameters</source>
<translation>Réinitialiser tous les paramètres du modèle</translation>
Expand Down Expand Up @@ -384,10 +400,6 @@
<source>Remove the current graph panel</source>
<translation>Supprimer le panneau graphique actuel</translation>
</message>
<message>
<source>All</source>
<translation>Tous</translation>
</message>
<message>
<source>Remove all the graph panels</source>
<translation>Supprimer tous les panneaux graphiques</translation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ SimulationExperimentViewSimulationWidget::SimulationExperimentViewSimulationWidg
QKeySequence(Qt::ControlModifier|Qt::Key_F2), mToolBarWidget);
mResetModelParametersAction = Core::newAction(QIcon(":/oxygen/actions/view-refresh.png"),
mToolBarWidget);
mResetStateRateModelParametersAction = Core::newAction(mToolBarWidget);
mResetAllModelParametersAction = Core::newAction(mToolBarWidget);
mClearSimulationResultsAction = Core::newAction(QIcon(":/oxygen/actions/trash-empty.png"),
mToolBarWidget);
mDevelopmentModeAction = Core::newAction(true, QIcon(":/oxygen/actions/run-build-configure.png"),
Expand Down Expand Up @@ -191,6 +193,10 @@ SimulationExperimentViewSimulationWidget::SimulationExperimentViewSimulationWidg
this, &SimulationExperimentViewSimulationWidget::stopSimulation);
connect(mResetModelParametersAction, &QAction::triggered,
this, &SimulationExperimentViewSimulationWidget::resetModelParameters);
connect(mResetStateRateModelParametersAction, &QAction::triggered,
this, &SimulationExperimentViewSimulationWidget::resetStateRateModelParameters);
connect(mResetAllModelParametersAction, &QAction::triggered,
this, &SimulationExperimentViewSimulationWidget::resetAllModelParameters);
connect(mClearSimulationResultsAction, &QAction::triggered,
this, QOverload<>::of(&SimulationExperimentViewSimulationWidget::clearSimulationResults));
connect(mDevelopmentModeAction, &QAction::triggered,
Expand Down Expand Up @@ -256,6 +262,16 @@ SimulationExperimentViewSimulationWidget::SimulationExperimentViewSimulationWidg

// Create various tool buttons

QToolButton *resetModelParametersToolButton = new QToolButton(mToolBarWidget);
QMenu *resetModelParametersDropDownMenu = new QMenu(resetModelParametersToolButton);

resetModelParametersDropDownMenu->addAction(mResetStateRateModelParametersAction);
resetModelParametersDropDownMenu->addAction(mResetAllModelParametersAction);

resetModelParametersToolButton->setDefaultAction(mResetModelParametersAction);
resetModelParametersToolButton->setMenu(resetModelParametersDropDownMenu);
resetModelParametersToolButton->setPopupMode(QToolButton::MenuButtonPopup);

QToolButton *removeGraphPanelToolButton = new QToolButton(mToolBarWidget);
QMenu *removeGraphPanelDropDownMenu = new QMenu(removeGraphPanelToolButton);

Expand Down Expand Up @@ -335,7 +351,7 @@ SimulationExperimentViewSimulationWidget::SimulationExperimentViewSimulationWidg
mToolBarWidget->addAction(mRunPauseResumeSimulationAction);
mToolBarWidget->addAction(mStopSimulationAction);
mToolBarWidget->addSeparator();
mToolBarWidget->addAction(mResetModelParametersAction);
mToolBarWidget->addWidget(resetModelParametersToolButton);
mToolBarWidget->addAction(mClearSimulationResultsAction);
mToolBarWidget->addSeparator();
mToolBarWidget->addWidget(mDelayWidget);
Expand Down Expand Up @@ -533,6 +549,10 @@ void SimulationExperimentViewSimulationWidget::retranslateUi()
I18nInterface::retranslateAction(mStopSimulationAction, tr("Stop Simulation"),
tr("Stop the simulation"));
I18nInterface::retranslateAction(mResetModelParametersAction, tr("Reset Model Parameters"),
tr("Reset the state/rate model parameters or all the model parameters"));
I18nInterface::retranslateAction(mResetStateRateModelParametersAction, tr("States/Rates"),
tr("Reset the state/rate model parameters"));
I18nInterface::retranslateAction(mResetAllModelParametersAction, tr("All"),
tr("Reset all the model parameters"));
I18nInterface::retranslateAction(mClearSimulationResultsAction, tr("Clear Simulation Results"),
tr("Clear the simulation results"));
Expand Down Expand Up @@ -1367,7 +1387,26 @@ void SimulationExperimentViewSimulationWidget::stopSimulation()

void SimulationExperimentViewSimulationWidget::resetModelParameters()
{
// Reset our model parameters
// Default action for our resetting of model parameters, i.e. reset all our
// model parameters

resetAllModelParameters();
}

//==============================================================================

void SimulationExperimentViewSimulationWidget::resetStateRateModelParameters()
{
// Reset our state/rate model parameters

mSimulation->reset(false);
}

//==============================================================================

void SimulationExperimentViewSimulationWidget::resetAllModelParameters()
{
// Reset all our model parameters

mSimulation->reset();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ class SimulationExperimentViewSimulationWidget : public Core::Widget
QAction *mRunPauseResumeSimulationAction;
QAction *mStopSimulationAction;
QAction *mResetModelParametersAction;
QAction *mResetStateRateModelParametersAction;
QAction *mResetAllModelParametersAction;
QAction *mClearSimulationResultsAction;
QAction *mDevelopmentModeAction;
QAction *mAddGraphPanelAction;
Expand Down Expand Up @@ -324,6 +326,8 @@ private slots:
void removeCurrentGraphPanel();
void removeAllGraphPanels();
void resetModelParameters();
void resetStateRateModelParameters();
void resetAllModelParameters();
void clearSimulationResults();
void sedmlExportSedmlFile();
void sedmlExportCombineArchive();
Expand Down
37 changes: 26 additions & 11 deletions src/plugins/support/SimulationSupport/src/simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ void SimulationData::addNlaSolverProperty(const QString &pName,

//==============================================================================

void SimulationData::reset(bool pInitialize)
void SimulationData::reset(bool pInitialize, bool pAll)
{
// Reset our parameter values which means both initialising our 'constants'
// and computing our 'computed constants' and 'variables'
Expand Down Expand Up @@ -374,6 +374,13 @@ void SimulationData::reset(bool pInitialize)
nlaSolver->setProperties(mNlaSolverProperties);
}

// Keep track of our constants (in case we don't want to reset them)

double *currentConstants = new double[runtime->constantsCount()] {};

if (!pAll)
memcpy(currentConstants, mConstants, size_t(runtime->constantsCount()*Solver::SizeOfDouble));

// Reset our parameter values

if (pInitialize) {
Expand All @@ -385,6 +392,22 @@ void SimulationData::reset(bool pInitialize)
runtime->initializeConstants()(mConstants, mRates, mStates);
}

// Keep track of our various initial values

if (pInitialize) {
memcpy(mInitialConstants, mConstants, size_t(runtime->constantsCount()*Solver::SizeOfDouble));
memcpy(mInitialStates, mStates, size_t(runtime->statesCount()*Solver::SizeOfDouble));
}

// Use our "current" constants, if needed

if (!pAll)
memcpy(mConstants, currentConstants, size_t(runtime->constantsCount()*Solver::SizeOfDouble));

delete[] currentConstants;

// Recompute our computed constants and variables

recomputeComputedConstantsAndVariables(mStartingPoint, pInitialize);

// Delete our NLA solver, if any
Expand All @@ -395,16 +418,8 @@ void SimulationData::reset(bool pInitialize)
Solver::unsetNlaSolver(runtime->address());
}

// Keep track of our various initial values

if (pInitialize) {
memcpy(mInitialConstants, mConstants, size_t(runtime->constantsCount()*Solver::SizeOfDouble));
memcpy(mInitialStates, mStates, size_t(runtime->statesCount()*Solver::SizeOfDouble));
}

// Let people know whether our data is 'cleaned', i.e. not modified, and ask
// our simulation worker to reset itself
// Note: no point in checking if we are initialising...

if (!pInitialize) {
emit modified(isModified());
Expand Down Expand Up @@ -1154,11 +1169,11 @@ bool Simulation::stop()

//==============================================================================

bool Simulation::reset()
bool Simulation::reset(bool pAll)
{
// Reset our data

mData->reset();
mData->reset(true, pAll);

// Reset our worker

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/support/SimulationSupport/src/simulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class SIMULATIONSUPPORT_EXPORT SimulationData : public QObject
void addNlaSolverProperty(const QString &pName, const QVariant &pValue,
bool pReset = true);

void reset(bool pInitialize = true);
void reset(bool pInitialize = true, bool pAll = true);

void recomputeComputedConstantsAndVariables(double pCurrentPoint,
bool pInitialize);
Expand Down Expand Up @@ -264,7 +264,7 @@ class SIMULATIONSUPPORT_EXPORT Simulation : public QObject
bool resume();
bool stop();

bool reset();
bool reset(bool pAll = true);

private:
QString mFileName;
Expand Down

0 comments on commit 3f61790

Please sign in to comment.