Skip to content

Commit

Permalink
Merge f3b5d1d into e766ebe
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Apr 5, 2019
2 parents e766ebe + f3b5d1d commit 1b2fdb2
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 14 deletions.
Expand Up @@ -1014,10 +1014,10 @@ void SimulationExperimentViewSimulationWidget::initialize(bool pReloadingView)
information += QString(OutputTab+"<span"+OutputBad+"><strong>[%1:%2] %3</strong> %4.</span>"+OutputBrLn).arg(sedmlFileIssue.line())
.arg(sedmlFileIssue.column())
.arg(issueType)
.arg(Core::formatMessage(sedmlFileIssue.message()));
.arg(Core::formatMessage(sedmlFileIssue.message().toHtmlEscaped()));
} else {
information += QString(OutputTab+"<span"+OutputBad+"><strong>%1</strong> %2.</span>"+OutputBrLn).arg(issueType)
.arg(Core::formatMessage(sedmlFileIssue.message()));
.arg(Core::formatMessage(sedmlFileIssue.message().toHtmlEscaped()));
}
}
}
Expand Down Expand Up @@ -1937,7 +1937,6 @@ bool SimulationExperimentViewSimulationWidget::createSedmlFile(SEDMLSupport::Sed
int graphPlotCounter;
bool logAxisX;
bool logAxisY;
char padding[2]; // Just for alignment
} GraphsData;

SimulationExperimentViewInformationGraphPanelAndGraphsWidget *graphPanelAndGraphsWidget = mContentsWidget->informationWidget()->graphPanelAndGraphsWidget();
Expand Down
35 changes: 28 additions & 7 deletions src/plugins/support/SEDMLSupport/src/sedmlfile.cpp
Expand Up @@ -145,6 +145,20 @@ libsedml::SedDocument * SedmlFile::sedmlDocument()

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

bool SedmlFile::isSedmlFile() const
{
// Return whether our current SED-ML document is indeed a SED-ML file
// Note: a non-SED-ML file will result in our SED-ML document having one
// error of id libsedml::SedNotSchemaConformant. So, we use this fact
// to determine whether our current SED-ML document is indeed a SED-ML
// file...

return (mSedmlDocument->getNumErrors() != 1)
|| (mSedmlDocument->getError(0)->getErrorId() != libsedml::SedNotSchemaConformant);
}

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

bool SedmlFile::hasErrors() const
{
// Return whether our current SED-ML document has errors, be they normal
Expand All @@ -161,7 +175,7 @@ bool SedmlFile::load()
// Check whether the file is already loaded and without any (fatal) errors

if (!mLoadingNeeded)
return !hasErrors();
return isSedmlFile();

mLoadingNeeded = false;

Expand All @@ -171,7 +185,7 @@ bool SedmlFile::load()
new libsedml::SedDocument(1, 3):
libsedml::readSedML(mFileName.toUtf8().constData());

return !hasErrors();
return isSedmlFile();
}

//==============================================================================
Expand Down Expand Up @@ -292,14 +306,20 @@ bool SedmlFile::isValid(const QString &pFileContents, SedmlFileIssues &pIssues)
break;
}

// Add the issue to our list, but only if it's not already in there
// Note: indeed, for some reasons, libSEDML may generate several copies
// of the same error...

static const QRegularExpression TrailingEmptyLinesRegEx = QRegularExpression("[\\n]*$");

QString errorMessage = QString::fromStdString(error->getMessage()).remove(TrailingEmptyLinesRegEx);
SedmlFileIssue issue = SedmlFileIssue(issueType,
int(error->getLine()),
int(error->getColumn()),
errorMessage);

pIssues << SedmlFileIssue(issueType,
int(error->getLine()),
int(error->getColumn()),
errorMessage);
if (!pIssues.contains(issue))
pIssues << issue;
}

// Only consider our SED-ML document valid if it has no (fatal) errors
Expand Down Expand Up @@ -502,7 +522,8 @@ bool SedmlFile::isSupported()
}

// Make sure that the first simulation algorithm annotation, if any,
// contains at least the kind of information we would expect
// contains at least the kind of information we would expect, i.e.
// solver properties that somehow don't have KiSAO ids

annotation = firstSimulationAlgorithm->getAnnotation();

Expand Down
2 changes: 2 additions & 0 deletions src/plugins/support/SEDMLSupport/src/sedmlfile.h
Expand Up @@ -147,6 +147,8 @@ class SEDMLSUPPORT_EXPORT SedmlFile : public StandardSupport::StandardFile

void reset() override;

bool isSedmlFile() const;

bool hasErrors() const;

bool validListPropertyValue(const libsbml::XMLNode &pPropertyNode,
Expand Down
12 changes: 12 additions & 0 deletions src/plugins/support/SEDMLSupport/src/sedmlfileissue.cpp
Expand Up @@ -48,6 +48,18 @@ SedmlFileIssue::SedmlFileIssue(Type pType, const QString &pMessage) :

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

bool SedmlFileIssue::operator==(const SedmlFileIssue &pIssue) const
{
// Return whether we are the same as the given issue

return (mType == pIssue.mType)
&& (mLine == pIssue.mLine)
&& (mColumn == pIssue.mColumn)
&& !mMessage.compare(pIssue.mMessage);
}

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

SedmlFileIssue::Type SedmlFileIssue::type() const
{
// Return the issue's type
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/support/SEDMLSupport/src/sedmlfileissue.h
Expand Up @@ -57,6 +57,8 @@ class SEDMLSUPPORT_EXPORT SedmlFileIssue
const QString &pMessage);
explicit SedmlFileIssue(Type pType, const QString &pMessage);

bool operator==(const SedmlFileIssue &pIssue) const;

Type type() const;
int line() const;
int column() const;
Expand Down
11 changes: 7 additions & 4 deletions src/plugins/support/SimulationSupport/src/simulation.cpp
Expand Up @@ -1148,7 +1148,7 @@ void Simulation::retrieveFileDetails(bool pRecreateRuntime)

mRuntime = mCellmlFile?mCellmlFile->runtime(true):nullptr;
} else {
if (mCellmlFile)
if (mCellmlFile && mRuntime)
mRuntime->update(mCellmlFile, false);
}
}
Expand Down Expand Up @@ -1185,10 +1185,13 @@ void Simulation::save()
// Make sure that our initial values are up to date and check for
// modifications (which results in people being told that there are no
// modifications, meaning that a view like the Simulation Experiment view
// will disable its reset buttons)
// will disable its reset buttons), but only if we have / still have a
// runtime

mData->updateInitialValues();
mData->checkForModifications();
if (mRuntime) {
mData->updateInitialValues();
mData->checkForModifications();
}
}

//==============================================================================
Expand Down

0 comments on commit 1b2fdb2

Please sign in to comment.