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

Method xyFunctionCurve

tests/backend/Retransform/RetransformTest.cpp:1964–2053  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1962}
1963
1964void RetransformTest::xyFunctionCurve() {
1965 Project project;
1966 auto* ws = new Worksheet(QStringLiteral("Worksheet"));
1967 QVERIFY(ws != nullptr);
1968 project.addChild(ws);
1969
1970 RetransformCallCounter c;
1971
1972 auto* p = new CartesianPlot(QStringLiteral("plot"));
1973 p->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axis are created
1974 QVERIFY(p != nullptr);
1975 ws->addChild(p);
1976 c.aspectAdded(p);
1977 const auto& axes = p->children<Axis>();
1978 QCOMPARE(axes.count(), 2);
1979 c.aspectAdded(axes.at(0));
1980 c.aspectAdded(axes.at(1));
1981
1982 p->addChild(new XYEquationCurve(QLatin1String("eq")));
1983
1984 auto equationCurves = p->children(AspectType::XYEquationCurve);
1985 QCOMPARE(equationCurves.count(), 1);
1986 auto* equationCurve = static_cast<XYEquationCurve*>(equationCurves.at(0));
1987 XYEquationCurve::EquationData data;
1988 data.count = 100;
1989 data.expression1 = QStringLiteral("x");
1990 data.expression2 = QString();
1991 data.min = QStringLiteral("1");
1992 data.max = QStringLiteral("100");
1993 data.type = XYEquationCurve::EquationType::Cartesian;
1994 equationCurve->setEquationData(data);
1995
1996 c.aspectAdded(equationCurve);
1997
1998 QCOMPARE(equationCurve->xColumn()->rowCount(), data.count);
1999
2000 p->addChild(new XYFunctionCurve(QLatin1String("eq2")));
2001 auto functionCurves = p->children(AspectType::XYFunctionCurve);
2002 QCOMPARE(functionCurves.count(), 1);
2003 auto* functionCurve = static_cast<XYFunctionCurve*>(functionCurves.at(0));
2004
2005 c.aspectAdded(functionCurve);
2006
2007 c.resetRetransformCount();
2008
2009 functionCurve->setFunction(QStringLiteral("2*x"), {QStringLiteral("x")}, {equationCurve});
2010
2011 {
2012 const auto stat = c.statistic(false);
2013 QCOMPARE(stat.count(), 4); // equationCurve, functionCurve, xAxis and yAxis are inside
2014 QCOMPARE(stat.contains(equationCurve->path()), true);
2015 QCOMPARE(stat.contains(functionCurve->path()), true);
2016 QCOMPARE(stat.contains(axes.at(0)->path()), true);
2017 QCOMPARE(stat.contains(axes.at(1)->path()), true);
2018 QVERIFY(c.calledExact(1, false));
2019 QCOMPARE(c.logsXScaleRetransformed.count(), 0); // only the y range changed
2020 QCOMPARE(c.logsYScaleRetransformed.count(), 1);
2021 }

Callers

nothing calls this directly

Calls 15

setEquationDataMethod · 0.80
resetRetransformCountMethod · 0.80
setFunctionMethod · 0.80
statisticMethod · 0.80
calledExactMethod · 0.80
QStringClass · 0.50
addChildMethod · 0.45
setTypeMethod · 0.45
aspectAddedMethod · 0.45
countMethod · 0.45
childrenMethod · 0.45
rowCountMethod · 0.45

Tested by

no test coverage detected