Skip to content

Commit

Permalink
Graph panel widget: can now customise the font size of the (main) tit…
Browse files Browse the repository at this point in the history
…le (#2271).
  • Loading branch information
agarny committed Jan 13, 2020
1 parent 6569e61 commit a8f292b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
16 changes: 15 additions & 1 deletion src/misc/furtherinitialize.cpp.inl
Expand Up @@ -198,6 +198,16 @@ QString Simulation::furtherInitialize() const

if ( (QString::fromStdString(sedmlPlot2dPropertiesNode.getURI()) == SEDMLSupport::OpencorNamespace)
&& (QString::fromStdString(sedmlPlot2dPropertiesNode.getName()) == SEDMLSupport::Properties)) {
#ifdef GUI_SUPPORT
std::string versionValue = sedmlPlot2dPropertiesNode.getAttrValue(qPrintable(SEDMLSupport::Version));
int version = SEDMLSupport::VersionValue;

try {
version = versionValue.empty()?1:std::stoi(versionValue);
} catch (...) {
}
#endif

for (uint k = 0, kMax = sedmlPlot2dPropertiesNode.getNumChildren(); k < kMax; ++k) {
libsbml::XMLNode &sedmlPlot2dPropertyNode = sedmlPlot2dPropertiesNode.getChild(k);

Expand All @@ -208,7 +218,11 @@ QString Simulation::furtherInitialize() const
if (sedmlPlot2dPropertyNodeName == SEDMLSupport::BackgroundColor) {
graphPanelProperties[0]->setValue(sedmlPlot2dPropertyNodeValue);
} else if (sedmlPlot2dPropertyNodeName == SEDMLSupport::FontSize) {
graphPanelProperties[1]->setValue(sedmlPlot2dPropertyNodeValue);
if (version == 1) {
graphPanelProperties[1]->setValue(QString::number(2*sedmlPlot2dPropertyNodeValue.toInt()));
} else {
graphPanelProperties[1]->setValue(sedmlPlot2dPropertyNodeValue);
}

// Note: the below is in case we are dealing
// with an old SED-ML file where we had
Expand Down
Expand Up @@ -1987,10 +1987,12 @@ bool SimulationExperimentViewSimulationWidget::createSedmlFile(SEDMLSupport::Sed

// Add our properties as an annotation

sedmlPlot2d->appendAnnotation(QString(R"(<%1 xmlns="%2">)"
" %3"
sedmlPlot2d->appendAnnotation(QString(R"(<%1 %2="%3" xmlns="%4">)"
" %5"
"</%1>").arg(SEDMLSupport::Properties,
SEDMLSupport::OpencorNamespace,
SEDMLSupport::Version)
.arg(SEDMLSupport::VersionValue)
.arg(SEDMLSupport::OpencorNamespace,
annotation).toStdString());

// Keep track of the graph panel's graphs, if any
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/support/SEDMLSupport/src/sedmlfile.h
Expand Up @@ -67,6 +67,8 @@ namespace SEDMLSupport {
//==============================================================================

static const auto OpencorNamespace = QStringLiteral("http://www.opencor.ws/");
static const auto Version = QStringLiteral("version");
static const auto VersionValue = 2;
static const auto VariableDegree = QStringLiteral("variableDegree");
static const auto SolverProperties = QStringLiteral("solverProperties");
static const auto SolverProperty = QStringLiteral("solverProperty");
Expand Down
Expand Up @@ -2458,10 +2458,7 @@ void GraphPanelPlotWidget::setTitle(const QString &pTitle)
QwtText title = QwtText(pTitle);
QFont newFont = title.font();

newFont.setPointSize(2*fontSize());
//---ISSUE2271--- WE WILL EVENTUALLY HAVE TO REMOVE THAT SCALING FACTOR AND,
// INSTEAD, HAVE THE MAIN FONT SIZE PROPERTY SCALED DOUBLED WHEN
// DEALING WITH AN OLD SED-ML FILE...
newFont.setPointSize(fontSize());

title.setColor(mSurroundingAreaForegroundColor);
title.setFont(newFont);
Expand Down

0 comments on commit a8f292b

Please sign in to comment.