Skip to content

Commit

Permalink
Simulation Experiment view: fixed a couple of GUI glitches (#2332).
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Apr 25, 2020
1 parent e64c399 commit 5536aa7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 25 deletions.
Expand Up @@ -996,17 +996,15 @@ void SimulationExperimentViewSimulationWidget::initialize(bool pReloading)

mRunPauseResumeSimulationAction->setEnabled(voi != nullptr);

// Update our simulation mode or clear our simulation results
// (should there be some) in case we are reloading ourselves
// Note: to clear our simualtion data will also update our
// simulation mode, so we are fine...
// Clear our simulation results, in case we are reloading ourselves,
// and update our simulation mode

if (pReloading) {
clearSimulationResults(pReloading);
} else {
updateSimulationMode();
clearSimulationResults();
}

updateSimulationMode();

// Initialise our contents widget and make sure that we have the
// required type(s) of solvers

Expand Down Expand Up @@ -1099,7 +1097,7 @@ void SimulationExperimentViewSimulationWidget::initialize(bool pReloading)

// Initialise our simulation

initializeSimulation(pReloading);
initializeSimulation();

// Now, we can safely update our parameters widget since our model
// parameters have been computed
Expand All @@ -1126,7 +1124,7 @@ void SimulationExperimentViewSimulationWidget::initialize(bool pReloading)
initializeGui(mValidSimulationEnvironment);

if (mValidSimulationEnvironment) {
initializeSimulation(pReloading);
initializeSimulation();
}
}
mContentsWidget->setUpdatesEnabled(true);
Expand Down Expand Up @@ -1458,7 +1456,7 @@ void SimulationExperimentViewSimulationWidget::resetAllModelParameters()

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

void SimulationExperimentViewSimulationWidget::clearSimulationResults(bool pReloading)
void SimulationExperimentViewSimulationWidget::clearSimulationResults()
{
setUpdatesEnabled(false);
// Clear our simulation results
Expand All @@ -1467,7 +1465,7 @@ void SimulationExperimentViewSimulationWidget::clearSimulationResults(bool pRelo
// were to have several graph panels since they would try to
// realign themselves)...

mSimulation->results()->reset(pReloading);
mSimulation->results()->reset();
setUpdatesEnabled(true);
}

Expand Down Expand Up @@ -2716,13 +2714,13 @@ void SimulationExperimentViewSimulationWidget::initializeGui(bool pValidSimulati

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

void SimulationExperimentViewSimulationWidget::initializeSimulation(bool pReloading)
void SimulationExperimentViewSimulationWidget::initializeSimulation()
{
// Reset both the simulation's data and results (well, initialise in the
// case of its data)

mSimulation->data()->reset();
mSimulation->results()->reset(pReloading);
mSimulation->results()->reset();

// Retrieve our simulation and solvers properties since they may have an
// effect on our parameter values (as well as result in some solver
Expand Down
Expand Up @@ -311,7 +311,7 @@ class SimulationExperimentViewSimulationWidget : public Core::Widget

bool furtherInitialize();
void initializeGui(bool pValidSimulationEnvironment);
void initializeSimulation(bool pReloading = false);
void initializeSimulation();

void initializeTrackers(bool pInitialzeGraphPanelsWidgetSizes = false);

Expand Down Expand Up @@ -356,7 +356,7 @@ class SimulationExperimentViewSimulationWidget : public Core::Widget
void exportDone(DataStore::DataStoreExporter *pDataStoreExporter);

public slots:
void clearSimulationResults(bool pReloading = false);
void clearSimulationResults();

private slots:
void runPauseResumeSimulation();
Expand Down
14 changes: 5 additions & 9 deletions src/plugins/support/SimulationSupport/src/simulation.cpp
Expand Up @@ -985,25 +985,21 @@ void SimulationResults::reload()

mDataDataStores.clear();

reset(true);
reset();
}

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

void SimulationResults::reset(bool pReloading)
void SimulationResults::reset()
{
// Reset our data store by deleting it and then recreating it

deleteDataStore();
createDataStore();

// Let people know that we have been reset, but only if we are not reloading
// since otherwise our GUI may crash due our checking for results (see
// https://github.com/opencor/opencor/issues/2290)
// Let people know that we have been reset

if (!pReloading) {
emit resultsReset();
}
emit resultsReset();
}

//==============================================================================
Expand Down Expand Up @@ -1527,7 +1523,7 @@ void Simulation::save()
// will disable its reset buttons), but only if we have / still have a
// runtime

if (mRuntime != nullptr) {
if ((mRuntime != nullptr) && (mFileType == FileType::CellmlFile)) {
mData->updateInitialValues();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/support/SimulationSupport/src/simulation.h
Expand Up @@ -317,7 +317,7 @@ class SIMULATIONSUPPORT_EXPORT SimulationResults : public SimulationObject
public slots:
void reload();

void reset(bool pReloading = false);
void reset();

int runsCount() const;

Expand Down

0 comments on commit 5536aa7

Please sign in to comment.