Skip to content

Commit

Permalink
Convert the parameters to base unit when exporting to csv (#8212)
Browse files Browse the repository at this point in the history
Fixes #8206
  • Loading branch information
adeas31 committed Nov 24, 2021
1 parent 7bb55ae commit a1b67a1
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions OMEdit/OMEditLIB/Plotting/PlotWindowContainer.cpp
Expand Up @@ -581,17 +581,19 @@ void PlotWindowContainer::exportVariables()
// write time data
data << QString::number(timeVector.at(i));
foreach (PlotCurve *pPlotCurve, pPlotWindow->getPlot()->getPlotCurvesList()) {
double value;
if (pPlotCurve && pPlotCurve->mYAxisVector.size() > i) { // parameters have just start and stop points in the dataset
OMCInterface::convertUnits_res convertUnit = MainWindow::instance()->getOMCProxy()->convertUnits(pPlotCurve->getYDisplayUnit(), pPlotCurve->getYUnit());
if (convertUnit.unitsCompatible) {
data << StringHandler::number(Utilities::convertUnit(pPlotCurve->mYAxisVector.at(i), convertUnit.offset, convertUnit.scaleFactor));
} else {
data << StringHandler::number(pPlotCurve->mYAxisVector.at(i));
}
value = pPlotCurve->mYAxisVector.at(i);
} else if (pPlotCurve && pPlotCurve->mYAxisVector.size() > 0) { // Set last value to have constant values for parameters
data << StringHandler::number(pPlotCurve->mYAxisVector.last());
} else { // otherwise set value to 0. But perhaps we should never reach there.
data << StringHandler::number(0);
value = pPlotCurve->mYAxisVector.last();
} else { // otherwise set value to 0.0 but perhaps we should never reach there.
value = 0.0;
}
OMCInterface::convertUnits_res convertUnit = MainWindow::instance()->getOMCProxy()->convertUnits(pPlotCurve->getYDisplayUnit(), pPlotCurve->getYUnit());
if (convertUnit.unitsCompatible) {
data << StringHandler::number(Utilities::convertUnit(value, convertUnit.offset, convertUnit.scaleFactor));
} else {
data << StringHandler::number(value);
}
}
contents.append(data.join(",")).append("\n");
Expand Down

0 comments on commit a1b67a1

Please sign in to comment.