stuff-from-scratch/test/publishing/TestPlotting.cpp

33 lines
852 B
C++
Raw Normal View History

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