diff --git a/src/libslic3r/TextConfiguration.hpp b/src/libslic3r/TextConfiguration.hpp index b612a4c2d..ae97af512 100644 --- a/src/libslic3r/TextConfiguration.hpp +++ b/src/libslic3r/TextConfiguration.hpp @@ -225,7 +225,7 @@ struct FontItem // undo / redo stack recovery template void serialize(Archive &ar){ - ar(name, path, (int) type, prop); + ar(name, path, type, prop); } }; diff --git a/tests/libslic3r/test_emboss.cpp b/tests/libslic3r/test_emboss.cpp index 1ebc3e6c7..f1a937544 100644 --- a/tests/libslic3r/test_emboss.cpp +++ b/tests/libslic3r/test_emboss.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include // only debug visualization @@ -337,6 +337,41 @@ TEST_CASE("Cut surface", "[]") //its_write_obj(its, "C:/data/temp/projected.obj"); } +#include +#include +#include +TEST_CASE("UndoRedo serialization", "[Emboss]") +{ + TextConfiguration tc; + tc.text = "Dovede-li se člověk zasmát sám sobě, nevyjde ze smíchu po celý život."; + FontItem& fi = tc.font_item; + fi.name = "Seneca"; + fi.path = "Simply the best"; + fi.type = FontItem::Type::file_path; + FontProp &fp = fi.prop; + fp.angle = 100.; + fp.distance = 10.; + fp.char_gap = 1; + fp.use_surface = true; + tc.fix_3mf_tr = Transform3d::Identity(); + + std::stringstream ss; // any stream can be used + { + cereal::BinaryOutputArchive oarchive(ss); // Create an output archive + + oarchive(tc); + } // archive goes out of scope, ensuring all contents are flushed + + TextConfiguration tc_loaded; + { + cereal::BinaryInputArchive iarchive(ss); // Create an input archive + iarchive(tc_loaded); + } + CHECK(tc.font_item == tc_loaded.font_item); + CHECK(tc.text == tc_loaded.text); + CHECK(tc.fix_3mf_tr.has_value() == tc_loaded.fix_3mf_tr.has_value()); +} + #include #include