mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	Support for forward compatibility of configurations, user and system
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.
			
			
This commit is contained in:
		
							parent
							
								
									ad336e2cc0
								
							
						
					
					
						commit
						0f3cabb5d9
					
				
					 47 changed files with 643 additions and 314 deletions
				
			
		|  | @ -9,7 +9,7 @@ SCENARIO("Generic config validation performs as expected.", "[Config]") { | |||
|     GIVEN("A config generated from default options") { | ||||
|         Slic3r::DynamicPrintConfig config = Slic3r::DynamicPrintConfig::full_print_config(); | ||||
|         WHEN( "perimeter_extrusion_width is set to 250%, a valid value") { | ||||
|             config.set_deserialize("perimeter_extrusion_width", "250%"); | ||||
|             config.set_deserialize_strict("perimeter_extrusion_width", "250%"); | ||||
|             THEN( "The config is read as valid.") { | ||||
|                 REQUIRE(config.validate().empty()); | ||||
|             } | ||||
|  | @ -40,7 +40,7 @@ SCENARIO("Config accessor functions perform as expected.", "[Config]") { | |||
|             } | ||||
|         } | ||||
|         WHEN("A boolean option is set to a string value representing a 0 or 1") { | ||||
|             CHECK_NOTHROW(config.set_deserialize("gcode_comments", "1")); | ||||
|             CHECK_NOTHROW(config.set_deserialize_strict("gcode_comments", "1")); | ||||
|             THEN("The underlying value is set correctly.") { | ||||
|                 REQUIRE(config.opt<ConfigOptionBool>("gcode_comments")->getBool() == true); | ||||
|             } | ||||
|  | @ -59,7 +59,7 @@ SCENARIO("Config accessor functions perform as expected.", "[Config]") { | |||
|             } | ||||
|         } | ||||
|         WHEN("A numeric option is set from serialized string") { | ||||
|             config.set_deserialize("bed_temperature", "100"); | ||||
|             config.set_deserialize_strict("bed_temperature", "100"); | ||||
|             THEN("The underlying value is set correctly.") { | ||||
|                 REQUIRE(config.opt<ConfigOptionInts>("bed_temperature")->get_at(0) == 100); | ||||
|             } | ||||
|  | @ -92,7 +92,7 @@ SCENARIO("Config accessor functions perform as expected.", "[Config]") { | |||
|         } | ||||
|         WHEN("A numeric option is set to a non-numeric value.") { | ||||
|             THEN("A BadOptionTypeException exception is thown.") { | ||||
|                 REQUIRE_THROWS_AS(config.set_deserialize("perimeter_speed", "zzzz"), BadOptionTypeException); | ||||
|                 REQUIRE_THROWS_AS(config.set_deserialize_strict("perimeter_speed", "zzzz"), BadOptionTypeException); | ||||
|             } | ||||
|             THEN("The value does not change.") { | ||||
|                 REQUIRE(config.opt<ConfigOptionFloat>("perimeter_speed")->getFloat() == 60.0); | ||||
|  | @ -117,7 +117,7 @@ SCENARIO("Config accessor functions perform as expected.", "[Config]") { | |||
|             } | ||||
|         } | ||||
|         WHEN("A float or percent is set as a percent through the string interface.") { | ||||
|             config.set_deserialize("first_layer_extrusion_width", "100%"); | ||||
|             config.set_deserialize_strict("first_layer_extrusion_width", "100%"); | ||||
|             THEN("Value and percent flag are 100/true") { | ||||
|                 auto tmp = config.opt<ConfigOptionFloatOrPercent>("first_layer_extrusion_width"); | ||||
|                 REQUIRE(tmp->percent == true); | ||||
|  | @ -125,7 +125,7 @@ SCENARIO("Config accessor functions perform as expected.", "[Config]") { | |||
|             } | ||||
|         } | ||||
|         WHEN("A float or percent is set as a float through the string interface.") { | ||||
|             config.set_deserialize("first_layer_extrusion_width", "100"); | ||||
|             config.set_deserialize_strict("first_layer_extrusion_width", "100"); | ||||
|             THEN("Value and percent flag are 100/false") { | ||||
|                 auto tmp = config.opt<ConfigOptionFloatOrPercent>("first_layer_extrusion_width"); | ||||
|                 REQUIRE(tmp->percent == false); | ||||
|  | @ -195,7 +195,7 @@ SCENARIO("Config ini load/save interface", "[Config]") { | |||
|     WHEN("new_from_ini is called") { | ||||
| 		Slic3r::DynamicPrintConfig config; | ||||
| 		std::string path = std::string(TEST_DATA_DIR) + "/test_config/new_from_ini.ini"; | ||||
| 		config.load_from_ini(path); | ||||
| 		config.load_from_ini(path, ForwardCompatibilitySubstitutionRule::Disable); | ||||
|         THEN("Config object contains ini file options.") { | ||||
| 			REQUIRE(config.option_throw<ConfigOptionStrings>("filament_colour", false)->values.size() == 1); | ||||
| 			REQUIRE(config.option_throw<ConfigOptionStrings>("filament_colour", false)->values.front() == "#ABCD"); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Vojtech Bubnik
						Vojtech Bubnik