MCPcopy Create free account
hub / github.com/KDE/labplot / loadCurves

Method loadCurves

src/backend/datasources/projects/OriginProjectParser.cpp:1733–2110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1731}
1732
1733void OriginProjectParser::loadCurves(const Origin::GraphLayer& layer, CartesianPlot* plot, int layerIndex, bool preview) {
1734 DEBUG(Q_FUNC_INFO << "layer " << layerIndex)
1735
1736 int curveIndex = 1;
1737 for (const auto& originCurve : layer.curves) {
1738 QString dataName(QString::fromStdString(originCurve.dataName));
1739 DEBUG(Q_FUNC_INFO << ", NEW CURVE. data name = " << STDSTRING(dataName))
1740 DEBUG(Q_FUNC_INFO << ", curve x column name = " << originCurve.xColumnName)
1741 DEBUG(Q_FUNC_INFO << ", curve y column name = " << originCurve.yColumnName)
1742 DEBUG(Q_FUNC_INFO << ", curve x data name = " << originCurve.xDataName)
1743
1744 if (dataName.isEmpty()) // formula may be empty?
1745 continue;
1746
1747 Plot* childPlot{nullptr};
1748
1749 // handle the different data sources for plots (spreadsheet, workbook, matrix and function)
1750 switch (dataName.at(0).toLatin1()) {
1751 case 'T': // Spreadsheet
1752 case 'E': { // Workbook
1753 // determine the used columns first
1754 QString containerName = dataName.right(dataName.length() - 2); // strip "E_" or "T_"
1755 const auto& sheet = getSpreadsheetByName(containerName);
1756 QString tableName = containerName;
1757 if (dataName.startsWith(QStringLiteral("E_"))) // container is a workbook
1758 tableName += QLatin1Char('/') + QString::fromStdString(sheet.name);
1759
1760 QString xColumnName = QLatin1String(originCurve.xColumnName.c_str());
1761 QString yColumnName = QLatin1String(originCurve.yColumnName.c_str());
1762 QString xColumnPath = tableName + QLatin1Char('/') + xColumnName;
1763 QString yColumnPath = tableName + QLatin1Char('/') + yColumnName;
1764 DEBUG(Q_FUNC_INFO << ", x/y column path = \"" << STDSTRING(xColumnPath) << "\" \"" << STDSTRING(yColumnPath) << "\"")
1765
1766 const auto type = originCurve.type;
1767 DEBUG(Q_FUNC_INFO << ", curve type = " << (int)type)
1768 switch (type) {
1769 case Origin::GraphCurve::Line:
1770 case Origin::GraphCurve::Scatter:
1771 case Origin::GraphCurve::LineSymbol:
1772 case Origin::GraphCurve::ErrorBar:
1773 case Origin::GraphCurve::XErrorBar:
1774 case Origin::GraphCurve::YErrorBar:
1775 case Origin::GraphCurve::XYErrorBar: {
1776 const auto columnName(QString::fromStdString(originCurve.yColumnName));
1777 const auto& column = sheet.columns[findColumnByName(sheet, columnName)];
1778 QString shortName = columnName, curveName = columnName;
1779 QString longName, unit, comments;
1780 if (column.comment.length() > 0) {
1781 auto columnInfo = QString::fromStdString(column.comment); // long name(, unit(, comment))
1782 DEBUG(Q_FUNC_INFO << ", y column full comment = \"" << column.comment << "\"")
1783 if (columnInfo.contains(QLatin1Char('@'))) // remove @ options
1784 columnInfo.truncate(columnInfo.indexOf(QLatin1Char('@')));
1785
1786 parseColumnInfo(columnInfo, longName, unit, comments);
1787 }
1788 if (longName.isEmpty())
1789 longName = shortName;
1790 if (comments.isEmpty())

Callers

nothing calls this directly

Calls 15

lengthMethod · 0.80
toStdStringMethod · 0.80
argMethod · 0.80
replaceMethod · 0.80
setYColumnPathMethod · 0.80
setLegendVisibleMethod · 0.80
setYErrorTypeMethod · 0.80
setYPlusColumnPathMethod · 0.80
setXErrorTypeMethod · 0.80
setXPlusColumnPathMethod · 0.80
setDataColumnPathsMethod · 0.80
as_doubleMethod · 0.80

Tested by

no test coverage detected