0f3cabb5d9
config bundles, project files (3MFs, AMFs). When loading these files, the caller may decide whether to substitute some of the configuration values the current PrusaSlicer version does not understand with some reasonable default value, and whether to report it. If substitution is disabled, an exception is being thrown as before this commit. If substitution is enabled, list of substitutions is returned by the API to be presented to the user. This allows us to introduce for example new firmware flavor key in PrusaSlicer 2.4 while letting PrusaSlicer 2.3.2 to fall back to some default and to report it to the user. When slicing from command line, substutions are performed by default and reported into the console, however substitutions may be either disabled or made silent with the new "config-compatibility" command line option. Substitute enums and bools only. Allow booleans to be parsed as true: "1", "enabled", "on" case insensitive false: "0", "disabled", "off" case insensitive This will allow us in the future for example to switch the draft_shield boolean to an enum with the following values: "disabled" / "enabled" / "limited". Added "enum_bitmask.hpp" - support for type safe sets of options. See for example PresetBundle::load_configbundle(... LoadConfigBundleAttributes flags) for an example of intended usage. WIP: GUI for reporting the list of config substitutions needs to be implemented by @YuSanka.
97 lines
4.2 KiB
C++
97 lines
4.2 KiB
C++
#include <catch2/catch.hpp>
|
|
|
|
#include <memory>
|
|
|
|
#include "libslic3r/GCodeWriter.hpp"
|
|
|
|
using namespace Slic3r;
|
|
|
|
SCENARIO("lift() is not ignored after unlift() at normal values of Z", "[GCodeWriter]") {
|
|
GIVEN("A config from a file and a single extruder.") {
|
|
GCodeWriter writer;
|
|
GCodeConfig &config = writer.config;
|
|
config.load(std::string(TEST_DATA_DIR) + "/fff_print_tests/test_gcodewriter/config_lift_unlift.ini", ForwardCompatibilitySubstitutionRule::Disable);
|
|
|
|
std::vector<unsigned int> extruder_ids {0};
|
|
writer.set_extruders(extruder_ids);
|
|
writer.set_extruder(0);
|
|
|
|
WHEN("Z is set to 203") {
|
|
double trouble_Z = 203;
|
|
writer.travel_to_z(trouble_Z);
|
|
AND_WHEN("GcodeWriter::Lift() is called") {
|
|
REQUIRE(writer.lift().size() > 0);
|
|
AND_WHEN("Z is moved post-lift to the same delta as the config Z lift") {
|
|
REQUIRE(writer.travel_to_z(trouble_Z + config.retract_lift.values[0]).size() == 0);
|
|
AND_WHEN("GCodeWriter::Unlift() is called") {
|
|
REQUIRE(writer.unlift().size() == 0); // we're the same height so no additional move happens.
|
|
THEN("GCodeWriter::Lift() emits gcode.") {
|
|
REQUIRE(writer.lift().size() > 0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
WHEN("Z is set to 500003") {
|
|
double trouble_Z = 500003;
|
|
writer.travel_to_z(trouble_Z);
|
|
AND_WHEN("GcodeWriter::Lift() is called") {
|
|
REQUIRE(writer.lift().size() > 0);
|
|
AND_WHEN("Z is moved post-lift to the same delta as the config Z lift") {
|
|
REQUIRE(writer.travel_to_z(trouble_Z + config.retract_lift.values[0]).size() == 0);
|
|
AND_WHEN("GCodeWriter::Unlift() is called") {
|
|
REQUIRE(writer.unlift().size() == 0); // we're the same height so no additional move happens.
|
|
THEN("GCodeWriter::Lift() emits gcode.") {
|
|
REQUIRE(writer.lift().size() > 0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
WHEN("Z is set to 10.3") {
|
|
double trouble_Z = 10.3;
|
|
writer.travel_to_z(trouble_Z);
|
|
AND_WHEN("GcodeWriter::Lift() is called") {
|
|
REQUIRE(writer.lift().size() > 0);
|
|
AND_WHEN("Z is moved post-lift to the same delta as the config Z lift") {
|
|
REQUIRE(writer.travel_to_z(trouble_Z + config.retract_lift.values[0]).size() == 0);
|
|
AND_WHEN("GCodeWriter::Unlift() is called") {
|
|
REQUIRE(writer.unlift().size() == 0); // we're the same height so no additional move happens.
|
|
THEN("GCodeWriter::Lift() emits gcode.") {
|
|
REQUIRE(writer.lift().size() > 0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// The test above will fail for trouble_Z == 9007199254740992, where trouble_Z + 1.5 will be rounded to trouble_Z + 2.0 due to double mantisa overflow.
|
|
}
|
|
}
|
|
|
|
SCENARIO("set_speed emits values with fixed-point output.", "[GCodeWriter]") {
|
|
|
|
GIVEN("GCodeWriter instance") {
|
|
GCodeWriter writer;
|
|
WHEN("set_speed is called to set speed to 99999.123") {
|
|
THEN("Output string is G1 F99999.123") {
|
|
REQUIRE_THAT(writer.set_speed(99999.123), Catch::Equals("G1 F99999.123\n"));
|
|
}
|
|
}
|
|
WHEN("set_speed is called to set speed to 1") {
|
|
THEN("Output string is G1 F1.000") {
|
|
REQUIRE_THAT(writer.set_speed(1.0), Catch::Equals("G1 F1.000\n"));
|
|
}
|
|
}
|
|
WHEN("set_speed is called to set speed to 203.200022") {
|
|
THEN("Output string is G1 F203.200") {
|
|
REQUIRE_THAT(writer.set_speed(203.200022), Catch::Equals("G1 F203.200\n"));
|
|
}
|
|
}
|
|
WHEN("set_speed is called to set speed to 203.200522") {
|
|
THEN("Output string is G1 F203.201") {
|
|
REQUIRE_THAT(writer.set_speed(203.200522), Catch::Equals("G1 F203.201\n"));
|
|
}
|
|
}
|
|
}
|
|
}
|