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 Jan 29, 2018
1 parent 3192b70 commit fb259f6
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ void BiosignalmlDataStoreExporter::execute(QString &pErrorMessage) const

try {
// Create and populate a recording
// Note: although a variable of integration may not officially be
// visible to a user, we still need to export it since it's needed
// by BioSignalML...
// Note: although a VOI may not officially be visible to a user, we
// still need to export it since it's needed by BioSignalML...

DataStore::DataStoreVariable *voi = dataStore->voi();
std::string recordingUri = QUrl::fromLocalFile(dataStoreData->fileName()).toEncoded().toStdString();
Expand All @@ -100,9 +99,8 @@ void BiosignalmlDataStoreExporter::execute(QString &pErrorMessage) const

clock->set_label(voi->label().toStdString());

// Determine what should be exported (minus the variable of
// integration, which should always be exported in the case of a
// BioSignalML file)
// Determine what should be exported (minus the VOI, which should
// always be exported in the case of a BioSignalML file)

DataStore::DataStoreVariables variables = mDataStoreData->variables();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,16 @@ void CsvDataStoreExporter::execute(QString &pErrorMessage) const
QFile file(Core::temporaryFileName());

if (file.open(QIODevice::WriteOnly)) {
// Determine whether we need to export the variable of integration and,
// if so, remove it from our variables since it gets exported separately
// Determine whether we need to export the VOI and, if so, remove it
// from our variables since it gets exported separately

DataStore::DataStore *dataStore = mDataStoreData->dataStore();
DataStore::DataStoreVariables variables = mDataStoreData->variables();
DataStore::DataStoreVariable *voi = variables.contains(dataStore->voi())?dataStore->voi():0;

variables.removeOne(voi);

// Retrieve the different values for our variable of integration and
// sets of variables
// Retrieve the different values for our VOI and sets of variables
// Note #1: this is needed when we have two runs with different
// starting/ending points and/or point intervals...
// Note #2: after our for loop, our list may contain duplicates and may
Expand Down
10 changes: 5 additions & 5 deletions src/plugins/dataStore/DataStore/src/datastoredialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ DataStoreDialog::DataStoreDialog(DataStore *pDataStore, const bool &pIncludeVoi,
this, SLOT(reject()));

// Populate our tree view with the data store's variables and, or not, the
// variable of integration
// VOI
// Note: indeed, in some cases (e.g. CSV export), we want to list all the
// variables including the variable of integration while in some other
// cases (e.g. BioSignalML export), we don't want to list the variable
// of integration (since, to respect the BioSignalML format, the
// variable of integration must absolutely be exported)...
// variables including the VOI while in some other cases (e.g.
// BioSignalML export), we don't want to list the VOI (since, to
// respect the BioSignalML format, the VOI must absolutely be
// exported)...

mModel = new QStandardItemModel(this);

Expand Down
21 changes: 10 additions & 11 deletions src/plugins/datastoreinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,8 @@ QString DataStore::uri() const

int DataStore::runsCount() const
{
// Return our number of runs, i.e. the number of runs for our variable of
// integration, for example
// Return our number of runs, i.e. the number of runs for our VOI, for
// example

return mVoi->runsCount();
}
Expand All @@ -431,7 +431,7 @@ int DataStore::runsCount() const

bool DataStore::addRun(const quint64 &pCapacity)
{
// Try to add a run to our variable of integration and all our variables
// Try to add a run to our VOI and all our variables

int oldRunsCount = mVoi->runsCount();

Expand All @@ -441,8 +441,8 @@ bool DataStore::addRun(const quint64 &pCapacity)
foreach (DataStoreVariable *variable, mVariables)
variable->addRun(pCapacity);
} catch (...) {
// We couldn't add a run to our variable of integration and all our
// variables, so only keep the number of runs we used to have
// We couldn't add a run to our VOI and all our variables, so only keep
// the number of runs we used to have

mVoi->keepRuns(oldRunsCount);

Expand All @@ -459,8 +459,7 @@ bool DataStore::addRun(const quint64 &pCapacity)

quint64 DataStore::size(const int &pRun) const
{
// Return our size, i.e. the size of our variable of integration, for
// example
// Return our size, i.e. the size of our VOI, for example

return mVoi->size(pRun);
}
Expand All @@ -469,7 +468,7 @@ quint64 DataStore::size(const int &pRun) const

DataStoreVariable * DataStore::voi() const
{
// Return our variable of integration
// Return our VOI

return mVoi;
}
Expand All @@ -489,8 +488,8 @@ DataStoreVariables DataStore::variables()

DataStoreVariables DataStore::voiAndVariables()
{
// Return our variable of integration, if any, and all our variables, after
// making sure that they are sorted
// Return our VOI, if any, and all our variables, after making sure that
// they are sorted

DataStoreVariables res = DataStoreVariables();

Expand Down Expand Up @@ -543,7 +542,7 @@ DataStoreVariables DataStore::addVariables(double *pValues, const int &pCount)
void DataStore::addValues(const double &pVoiValue)
{
// Set the value at the mSize position of all our variables including our
// variable of integration, which value is directly given to us
// VOI, which value is directly given to us

if (mVoi)
mVoi->addValue(pVoiValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ void SimulationExperimentViewInformationParametersWidget::initialize(SimulationS
mNeedClearing = false;
}

// Check whether our model's variable of integration is among our model's
// parameters (i.e. it is defined in the main CellML file)
// Check whether our model's VOI is among our model's parameters (i.e. it is
// defined in the main CellML file)

CellMLSupport::CellmlFileRuntime *runtime = pSimulation->runtime();

Expand Down Expand Up @@ -406,9 +406,8 @@ void SimulationExperimentViewInformationParametersWidget::populateContextMenu(Ce

retranslateContextMenu();

// Create a connection to handle the graph requirement against our variable
// of integration, and keep track of the parameter associated with our first
// main menu item
// Create a connection to handle the graph requirement against our VOI, and
// keep track of the parameter associated with our first main menu item

if (mVoiAccessible) {
connect(voiAction, SIGNAL(triggered(bool)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -849,18 +849,18 @@ void SimulationExperimentViewSimulationWidget::initialize(const bool &pReloading
information += OutputTab+"<strong>"+tr("Runtime:")+"</strong> ";

if (voi) {
// A variable of integration could be retrieved for our CellML file,
// so we can also output the model type
// A VOI could be retrieved for our CellML file, so we can also
// output the model type

information += "<span"+OutputGood+">"+tr("valid")+"</span>."+OutputBrLn
+QString(OutputTab+"<strong>"+tr("Model type:")+"</strong> <span"+OutputInfo+">%1</span>."+OutputBrLn).arg(runtime->needNlaSolver()?tr("DAE"):tr("ODE"));
} else {
// We couldn't retrieve a variable of integration, which means that
// we either don't have a runtime or we have one, but it's not valid
// or it's valid but we really don't have a variable of integration
// Note: in the case of a valid runtime and no variable of
// integration, we really shouldn't consider the runtime to be
// valid, hence we handle this case here...
// We couldn't retrieve a VOI, which means that we either don't have
// a runtime or we have one, but it's not valid or it's valid but we
// really don't have a VOI
// Note: in the case of a valid runtime and no VOI, we really
// shouldn't consider the runtime to be valid, hence we handle
// this case here...

mErrorType = InvalidCellmlFile;

Expand All @@ -869,8 +869,8 @@ void SimulationExperimentViewSimulationWidget::initialize(const bool &pReloading
information += "<span"+OutputBad+">"+(runtime?tr("invalid"):tr("none"))+"</span>."+OutputBrLn;

if (validRuntime) {
// We have a valid runtime, but no variable of integration,
// which means that the model doesn't contain any ODE or DAE
// We have a valid runtime, but no VOI, which means that the
// model doesn't contain any ODE or DAE

information += OutputTab+"<span"+OutputBad+"><strong>"+tr("Error:")+"</strong> "+tr("the model must have at least one ODE or DAE")+".</span>"+OutputBrLn;
} else {
Expand Down Expand Up @@ -904,7 +904,7 @@ void SimulationExperimentViewSimulationWidget::initialize(const bool &pReloading

if (!atLeastOneBlockingSedmlIssue && !atLeastOneBlockingCombineIssue) {
// Enable/disable our run/pause action depending on whether we have a
// variable of integration
// VOI

mRunPauseResumeSimulationAction->setEnabled(voi);

Expand Down Expand Up @@ -3437,9 +3437,9 @@ bool SimulationExperimentViewSimulationWidget::updatePlot(GraphPanelWidget::Grap
}

// Check all the graphs associated with the given plot and see whether any
// of them uses the variable of integration as parameter X and/or Y, and if
// so then asks the plot to use the starting/ending points as the
// minimum/maximum values for the X and/or Y axes
// of them uses the VOI as parameter X and/or Y, and if so then asks the
// plot to use the starting/ending points as the minimum/maximum values for
// the X and/or Y axes

bool hasData = pPlot->hasData();

Expand Down
17 changes: 8 additions & 9 deletions src/plugins/support/CellMLSupport/src/cellmlfileruntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -797,15 +797,14 @@ void CellmlFileRuntime::update()
} else if ( parameter->name().compare(voiName)
|| (parameter->componentHierarchy() != voiComponentHierarchy)) {
// The CellML API wrongly validated a model that has more
// more than one variable of integration (at least,
// according to the CellML API), but this is clearly wrong
// (not to mention that it crashes OpenCOR), so let the user
// know about it
// more than one VOI (at least, according to the CellML
// API), but this is clearly wrong (not to mention that it
// crashes OpenCOR), so let the user know about it
// Note: we check the name and component hierarchy of the
// parameter against those of our current variable of
// integration since the CellML API may generate
// different targets that refer to the same CellML
// variable (!?), as is for example the case with
// parameter against those of our current VOI since
// the CellML API may generate different targets that
// refer to the same CellML variable (!?), as is for
// example the case with
// [CellMLSupport]/tests/data/bond_graph_model_old.cellml...

mIssues << CellmlFileIssue(CellmlFileIssue::Error,
Expand Down Expand Up @@ -924,7 +923,7 @@ void CellmlFileRuntime::update()

CellmlFileRuntimeParameter *CellmlFileRuntime::voi() const
{
// Return our variable of integration, if any
// Return our VOI, if any

return mVoi;
}
Expand Down
14 changes: 7 additions & 7 deletions src/plugins/support/CellMLSupport/tests/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ void Tests::runtimeTests()
// Now, we do the same for some proper CellML 1.1 models:
// - Hodgking-Huxley model, which is somewhat 'complex' in terms of
// imports, etc.;
// - An 'old' version of a bond graph model implementation where the
// variable of integration is not visible in the main CellML file (so the
// idea is to ensure that the model is still considered valid even though
// the variable of integration is not directly visible);
// - An 'old' version of a bond graph model implementation where the VOI
// is not visible in the main CellML file (so the idea is to ensure that
// the model is still considered valid even though the VOI is not
// directly visible);
// - A 'new' version of a bond graph model implementation where the
// variable of integration is now visible in the main CellML file (as
// well as some other model parameters); and
// VOI is now visible in the main CellML file (as well as some other
// model parameters); and
// - A model (Noble 1962) that imports its units (and no components) from a
// child model; and
// - A somewhat comprehensive model (Faville 2008).
Expand All @@ -123,7 +123,7 @@ void Tests::runtimeTests()
"1.1", OpenCOR::fileContents(OpenCOR::fileName("src/plugins/support/CellMLSupport/tests/data/faville_model_2008.out")));

// Finally, test a CellML file that has, according to the CellML API at
// least, several variables of integration
// least, several VOIs

doRuntimeTest(OpenCOR::fileName("src/plugins/support/CellMLSupport/tests/data/calcium_transient.cellml"),
"1.1", QStringList(), false);
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/support/SimulationSupport/src/simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,8 @@ void SimulationResults::createDataStore()
mStates = mDataStore->addVariables(data->states(), runtime->statesCount());
mAlgebraic = mDataStore->addVariables(data->algebraic(), runtime->algebraicCount());

// Customise our variable of integration, as well as our constant, rate,
// state and algebraic variables
// Customise our VOI, as well as our constant, rate, state and algebraic
// variables

for (int i = 0, iMax = runtime->parameters().count(); i < iMax; ++i) {
CellMLSupport::CellmlFileRuntimeParameter *parameter = runtime->parameters()[i];
Expand Down

0 comments on commit fb259f6

Please sign in to comment.