Add svg conversion.
This commit is contained in:
parent
1f85954e98
commit
dfbc87cb09
33 changed files with 602 additions and 79 deletions
|
@ -1,7 +1,8 @@
|
|||
set(PUBLISHING_UNIT_TEST_FILES
|
||||
publishing/TestPdfWriter.cpp
|
||||
publishing/TestDocumentConverter.cpp
|
||||
publishing/TestSvgConverter.cpp
|
||||
publishing/TestSvgConverter.cpp
|
||||
publishing/TestSvgToNodeConverter.cpp
|
||||
publishing/TestLatexConverter.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "SvgWriter.h"
|
||||
#include "SvgDocument.h"
|
||||
#include "SvgConverter.h"
|
||||
#include "SvgPainter.h"
|
||||
#include "Scene.h"
|
||||
|
||||
#include "CircleNode.h"
|
||||
|
@ -24,13 +24,10 @@ TEST_CASE(TestSvgConverter, "[publishing]")
|
|||
//rectangle.setFillColor({255, 0, 0});
|
||||
//scene.addNode(&rectangle);
|
||||
|
||||
SvgConverter converter;
|
||||
auto svg_document = converter.convert(&scene);
|
||||
SvgPainter painter;
|
||||
auto svg_document = painter.paint(&scene);
|
||||
svg_document->setViewBox(0, 0, 200, 200);
|
||||
|
||||
SvgWriter writer;
|
||||
auto content = writer.toString(svg_document.get());
|
||||
|
||||
auto outFile = std::make_unique<File>(TestUtils::getTestOutputDir(__FILE__) / "scene.svg");
|
||||
outFile->writeText(content);
|
||||
writer.toFile(TestUtils::getTestOutputDir(__FILE__) / "scene.svg", svg_document.get());
|
||||
}
|
||||
|
|
25
test/publishing/TestSvgToNodeConverter.cpp
Normal file
25
test/publishing/TestSvgToNodeConverter.cpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
#include "TestFramework.h"
|
||||
#include "TestRenderUtils.h"
|
||||
#include "TestUtils.h"
|
||||
|
||||
#include "SvgReader.h"
|
||||
#include "SvgWriter.h"
|
||||
|
||||
#include "SvgNode.h"
|
||||
|
||||
TEST_CASE(TestSvgToNodeConverter, "publishing")
|
||||
{
|
||||
SvgReader svg_reader;
|
||||
auto svg_doc = svg_reader.read(TestUtils::getTestDataDir() / "circles.svg");
|
||||
|
||||
SvgWriter svg_writer;
|
||||
svg_writer.toFile(TestUtils::getTestOutputDir(__FILE__) / "TestSvgToNodeConverter.svg", svg_doc.get());
|
||||
|
||||
TestRenderer renderer;
|
||||
|
||||
auto svg_node = std::make_unique<SvgNode>(Point(0.0, 0.0));
|
||||
svg_node->setContent(std::move(svg_doc));
|
||||
renderer.getScene()->addNode(svg_node.get());
|
||||
|
||||
renderer.write(TestUtils::getTestOutputDir(__FILE__) / "TestSvgToNodeConverter.png");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue