Switch to template types for vectors

This commit is contained in:
jmsgrogan 2023-01-30 14:53:49 +00:00
parent 9f036d6438
commit 8192ef78e8
105 changed files with 1614 additions and 1424 deletions

View file

@ -2,9 +2,12 @@
#include "TestUtils.h"
#include "Path.h"
#include "PostscriptReader.h"
TEST_CASE(TestPath, "geometry")
{
GeometryPath path;
path.buildFromPostscript("M11 39h7.5V26.5h11V39H37V19.5L24 9.75 11 19.5Zm-3 3V18L24 6l16 12v24H26.5V29.5h-5V42Zm16-17.65Z");
PostscriptReader reader;
reader.read(&path, "M11 39h7.5V26.5h11V39H37V19.5L24 9.75 11 19.5Zm-3 3V18L24 6l16 12v24H26.5V29.5h-5V42Zm16-17.65Z");
};

View file

@ -8,20 +8,20 @@
#include "PathNode.h"
#include "PolygonNode.h"
void addRect(const Point& loc, std::vector<std::unique_ptr<MaterialNode> >& nodes, double radius = 0.0)
void addRect(const Point2& loc, std::vector<std::unique_ptr<MaterialNode> >& nodes, double radius = 0.0)
{
auto node = std::make_unique<RectangleNode>(loc, 150.0, 100.0);
auto node = std::make_unique<RectangleNode>(Transform(loc), 150.0, 100.0);
node->setRadius(radius);
nodes.push_back(std::move(node));
}
void addCircle(const Point& loc, std::vector<std::unique_ptr<MaterialNode> >& nodes, double minorRadius = 0.0)
void addCircle(const Point2& loc, std::vector<std::unique_ptr<MaterialNode> >& nodes, double minorRadius = 0.0)
{
const auto radius = 50.0;
auto centre_loc = loc;
centre_loc.move(0.0, radius);
centre_loc.moveBy(0.0, radius);
auto node = std::make_unique<CircleNode>(centre_loc, radius);
auto node = std::make_unique<CircleNode>(Transform(centre_loc), radius);
if (minorRadius != 0.0)
{
@ -31,31 +31,31 @@ void addCircle(const Point& loc, std::vector<std::unique_ptr<MaterialNode> >& no
nodes.push_back(std::move(node));
}
void addLine(const Point& loc, std::vector<std::unique_ptr<MaterialNode> >& nodes)
void addLine(const Point2& loc, std::vector<std::unique_ptr<MaterialNode> >& nodes)
{
std::vector<Point> points = { Point(150.0, 100.0) };
auto node = std::make_unique<LineNode>(loc, points);
std::vector<Point2> points = { Point2(150.0, 100.0) };
auto node = std::make_unique<LineNode>(Transform(loc), points);
nodes.push_back(std::move(node));
}
void addPath(const Point& loc, const std::string& path, std::vector<std::unique_ptr<MaterialNode> >& nodes)
void addPath(const Point2& loc, const std::string& path, std::vector<std::unique_ptr<MaterialNode> >& nodes)
{
auto node = std::make_unique<PathNode>(loc, path);
auto node = std::make_unique<PathNode>(Transform(loc), path);
nodes.push_back(std::move(node));
}
void addPolygon(const Point& loc, std::vector<std::unique_ptr<MaterialNode> >& nodes)
void addPolygon(const Point2& loc, std::vector<std::unique_ptr<MaterialNode> >& nodes)
{
auto p0 = Point{ 0.0, 0.0 };
auto p1 = Point{ 150.0, 0.0 };
auto p2 = Point{ 75.0, 75.0 };
auto p0 = Point2{ 0.0, 0.0 };
auto p1 = Point2{ 150.0, 0.0 };
auto p2 = Point2{ 75.0, 75.0 };
auto node = std::make_unique<PolygonNode>(loc);
auto node = std::make_unique<PolygonNode>(Transform(loc));
node->setPoints({ p0, p1, p2 });
nodes.push_back(std::move(node));
}
void addShapes(const Point& start_loc, std::vector<std::unique_ptr<MaterialNode> >& nodes, bool use_fill = false)
void addShapes(const Point2& start_loc, std::vector<std::unique_ptr<MaterialNode> >& nodes, bool use_fill = false)
{
auto loc = start_loc;
@ -63,31 +63,31 @@ void addShapes(const Point& start_loc, std::vector<std::unique_ptr<MaterialNode>
addRect(loc, nodes);
loc.move(250, 0);
loc.moveBy(250, 0);
addCircle(loc, nodes);
loc.move(100, 0);
loc.moveBy(100, 0);
addLine(loc, nodes);
loc.move(200, 0);
loc.moveBy(200, 0);
addPolygon(loc, nodes);
loc = Point(10, 150);
loc = Point2(10, 150);
addRect(loc, nodes, 10.0);
loc.move(250, 0);
loc.moveBy(250, 0);
addCircle(loc, nodes, 75.0);
loc.move(100, 0);
loc.moveBy(100, 0);
addPath(loc, "M0 0 h150 v100 h-150Z", nodes);
loc = Point(10, 300);
loc = Point2(10, 300);
addPath(loc, "M0 0 h150 q50 50 0 100 h-150Z", nodes);
loc.move(250, 0);
loc.moveBy(250, 0);
addPath(loc, "M0 0 h150 c25 25 25 75 0 100 h-150Z", nodes);
loc.move(250, 0);
loc.moveBy(250, 0);
addPath(loc, "M0 0 h150 a50 50 0 0 1 0 100 h-150Z", nodes);
if (use_fill)
@ -105,7 +105,7 @@ TEST_CASE(TestD2dOffScreenRendering_Outlines, "graphics")
std::vector<std::unique_ptr<MaterialNode> > nodes;
auto loc = Point(10, 10);
auto loc = Point2(10, 10);
addShapes(loc, nodes, false);
@ -125,7 +125,7 @@ TEST_CASE(TestD2dOffScreenRendering_Fill, "graphics")
std::vector<std::unique_ptr<MaterialNode> > nodes;
auto loc = Point(10, 10);
auto loc = Point2(10, 10);
addShapes(loc, nodes, true);

View file

@ -18,7 +18,7 @@ TEST_CASE(TestPlotting, "[publishing]")
PlotSeries series("Series-1");
std::vector<Point> data{ {0.0, 0.0}, {10.0, 40.0}, {20.0, 80.0} };
std::vector<Point2> data{ {0.0, 0.0}, {10.0, 40.0}, {20.0, 80.0} };
series.setData(data);
plot->addSeries(series);