2023-01-24 17:15:25 +00:00
|
|
|
#include "TestFramework.h"
|
|
|
|
#include "TestUtils.h"
|
|
|
|
#include "TestRenderUtils.h"
|
|
|
|
|
|
|
|
#include "Plot.h"
|
|
|
|
#include "PlotNode.h"
|
2023-01-28 16:58:26 +00:00
|
|
|
#include "PlotSeriesNode.h"
|
|
|
|
#include "PlotCaptionNode.h"
|
|
|
|
#include "EquationNode.h"
|
|
|
|
#include "TextNode.h"
|
|
|
|
#include "LineNode.h"
|
2023-01-24 17:15:25 +00:00
|
|
|
|
|
|
|
TEST_CASE(TestPlotting, "[publishing]")
|
|
|
|
{
|
2023-01-28 16:58:26 +00:00
|
|
|
auto plot = std::make_unique<Plot>();
|
|
|
|
plot->setXAxisCaption("X Axis");
|
|
|
|
plot->setYAxisCaption("Y Axis");
|
2023-01-24 17:15:25 +00:00
|
|
|
|
2023-01-28 16:58:26 +00:00
|
|
|
PlotSeries series("Series-1");
|
2023-01-24 17:15:25 +00:00
|
|
|
|
2023-01-30 14:53:49 +00:00
|
|
|
std::vector<Point2> data{ {0.0, 0.0}, {10.0, 40.0}, {20.0, 80.0} };
|
2023-01-28 16:58:26 +00:00
|
|
|
series.setData(data);
|
|
|
|
plot->addSeries(series);
|
2023-01-24 17:15:25 +00:00
|
|
|
|
2023-01-28 16:58:26 +00:00
|
|
|
Point loc(10, 10);
|
|
|
|
auto plot_node = std::make_unique<PlotNode>(Transform(loc));
|
|
|
|
plot_node->setAxisEndStyle(LineEndNode::Style::CLOSED_ARROW);
|
2023-01-24 17:15:25 +00:00
|
|
|
|
2023-01-28 16:58:26 +00:00
|
|
|
plot_node->setContent(plot.get());
|
2023-01-24 17:15:25 +00:00
|
|
|
|
2023-01-28 16:58:26 +00:00
|
|
|
TestRenderer renderer(800, 800);
|
2023-01-24 17:15:25 +00:00
|
|
|
|
2023-01-28 16:58:26 +00:00
|
|
|
auto scene = renderer.getScene();
|
|
|
|
scene->addNode(plot_node.get());
|
2023-01-24 17:15:25 +00:00
|
|
|
|
2023-01-28 16:58:26 +00:00
|
|
|
renderer.writeSvg(TestUtils::getTestOutputDir(__FILE__) / "plot.svg");
|
|
|
|
renderer.write(TestUtils::getTestOutputDir(__FILE__) / "plot.png");
|
|
|
|
}
|