Skip to content

Commit

Permalink
Some minor cleaning up.
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Nov 18, 2019
1 parent 5ef67f0 commit 0ef8fc0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
Expand Up @@ -592,10 +592,8 @@ void SimulationExperimentViewWidget::clearSimulationResults(const QString &pFile
SimulationExperimentViewSimulationWidget *simulationWidget = mSimulationWidgets.value(pFileName);

if (simulationWidget != nullptr) {
return;
simulationWidget->clearSimulationResults();
}

simulationWidget->clearSimulationResults();
}

//==============================================================================
Expand Down
28 changes: 14 additions & 14 deletions src/plugins/support/SimulationSupport/src/simulation.cpp
Expand Up @@ -712,7 +712,7 @@ void SimulationData::createArrays()
mStatesArray = new DataStore::DataStoreArray(quint64(runtime->statesCount()));
mAlgebraicArray = new DataStore::DataStoreArray(quint64(runtime->algebraicCount()));

// Create DataStoreValues to hold properties of our model's arrays
// Create our various values to hold our model's arrays

mConstantsValues = new DataStore::DataStoreValues(mConstantsArray);
mRatesValues = new DataStore::DataStoreValues(mRatesArray);
Expand All @@ -721,13 +721,13 @@ void SimulationData::createArrays()

// Create our various arrays to keep track of our various initial values

mDummyStates = new double[mStatesArray->size()]{};
mInitialConstants = new double[mConstantsArray->size()];
mInitialStates = new double[mStatesArray->size()];
mDummyStates = new double[mStatesArray->size()]{};
} else {
mConstantsArray = mRatesArray = mStatesArray = mAlgebraicArray = nullptr;
mConstantsValues = mRatesValues = mStatesValues = mAlgebraicValues = nullptr;
mDummyStates = mInitialConstants = mInitialStates = nullptr;
mInitialConstants = mInitialStates = mDummyStates = nullptr;
}
}

Expand Down Expand Up @@ -764,16 +764,16 @@ void SimulationData::deleteArrays()
delete mStatesValues;
delete mAlgebraicValues;

delete[] mDummyStates;
delete[] mInitialConstants;
delete[] mInitialStates;
delete[] mDummyStates;

// Reset our various arrays
// Note: this shouldn't be needed, but better be safe than sorry...

mConstantsArray = mRatesArray = mStatesArray = mAlgebraicArray = nullptr;
mConstantsValues = mRatesValues = mStatesValues = mAlgebraicValues = nullptr;
mDummyStates = mInitialConstants = mInitialStates = nullptr;
mInitialConstants = mInitialStates = mDummyStates = nullptr;
}

//==============================================================================
Expand Down Expand Up @@ -834,7 +834,7 @@ void SimulationResults::createDataStore()

mDataStore = new DataStore::DataStore(mSimulation->cellmlFile()->xmlBase());

mPointsVariables = mDataStore->voi();
mPoints = mDataStore->voi();

mConstantsVariables = mDataStore->addVariables(simulationData->constants(), runtime->constantsCount());
mRatesVariables = mDataStore->addVariables(simulationData->rates(), runtime->ratesCount());
Expand All @@ -855,11 +855,11 @@ void SimulationResults::createDataStore()
CellMLSupport::CellmlFileRuntimeParameter::Type parameterType = parameter->type();

if (parameterType == CellMLSupport::CellmlFileRuntimeParameter::Type::Voi) {
mPointsVariables->setType(int(parameter->type()));
mPointsVariables->setUri(uri(runtime->voi()->componentHierarchy(),
mPoints->setType(int(parameter->type()));
mPoints->setUri(uri(runtime->voi()->componentHierarchy(),
runtime->voi()->name()));
mPointsVariables->setLabel(runtime->voi()->name());
mPointsVariables->setUnit(runtime->voi()->unit());
mPoints->setLabel(runtime->voi()->name());
mPoints->setUnit(runtime->voi()->unit());
} else if ( (parameterType == CellMLSupport::CellmlFileRuntimeParameter::Type::Constant)
|| (parameterType == CellMLSupport::CellmlFileRuntimeParameter::Type::ComputedConstant)) {
variable = mConstantsVariables[parameter->index()];
Expand Down Expand Up @@ -926,7 +926,7 @@ void SimulationResults::deleteDataStore()

mDataStore = nullptr;

mPointsVariables = nullptr;
mPoints = nullptr;

mConstantsVariables = DataStore::DataStoreVariables();
mRatesVariables = DataStore::DataStoreVariables();
Expand Down Expand Up @@ -1186,8 +1186,8 @@ double * SimulationResults::points(int pRun) const
{
// Return our points for the given run

return (mPointsVariables != nullptr)?
mPointsVariables->values(pRun):
return (mPoints != nullptr)?
mPoints->values(pRun):
nullptr;
}

Expand Down Expand Up @@ -1255,7 +1255,7 @@ DataStore::DataStoreVariable * SimulationResults::pointsVariable() const
{
// Return our points variable

return mPointsVariables;
return mPoints;
}

//==============================================================================
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/support/SimulationSupport/src/simulation.h
Expand Up @@ -196,9 +196,9 @@ class SIMULATIONSUPPORT_EXPORT SimulationData : public SimulationObject
DataStore::DataStoreValues *mStatesValues = nullptr;
DataStore::DataStoreValues *mAlgebraicValues = nullptr;

double *mDummyStates = nullptr;
double *mInitialConstants = nullptr;
double *mInitialStates = nullptr;
double *mDummyStates = nullptr;

QMap<DataStore::DataStore *, double *> mData;

Expand Down Expand Up @@ -287,7 +287,7 @@ class SIMULATIONSUPPORT_EXPORT SimulationResults : public SimulationObject
private:
DataStore::DataStore *mDataStore = nullptr;

DataStore::DataStoreVariable *mPointsVariables = nullptr;
DataStore::DataStoreVariable *mPoints = nullptr;

DataStore::DataStoreVariables mConstantsVariables;
DataStore::DataStoreVariables mRatesVariables;
Expand Down
Expand Up @@ -328,9 +328,8 @@ void SimulationSupportPythonWrapper::error(const QString &pErrorMessage)
void SimulationSupportPythonWrapper::clearResults(Simulation *pSimulation)
{
// Ask our widget to clear our results

// Note: we get the widget to do this as it needs to clear all
// associated graphs...
// Note: we get the widget to do this as it needs to clear all associated
// graphs...

emit pSimulation->clearResults(pSimulation->fileName());
}
Expand Down

0 comments on commit 0ef8fc0

Please sign in to comment.