mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 12:11:15 -06:00 
			
		
		
		
	PlaceholderParser: implemented round(), digits() and zdigits() macros.
round() rounds to an integer. This is a popular request, for example #3472 digits(value, num_digits, num_decimals) rounds to num_digits and num_decimals, left filled with spaces. digits(value, num_digits) the same as digits(value, num_digits, 0) Neither decimal separator nor any decimals after decimal separator are emitted. zdigits(...) is the same as digits(...) only left filled with zeros. If the result does not fit num_digits, the result is never trimmed.
This commit is contained in:
		
							parent
							
								
									0f145920d9
								
							
						
					
					
						commit
						3216448bbc
					
				
					 2 changed files with 79 additions and 3 deletions
				
			
		|  | @ -51,6 +51,20 @@ SCENARIO("Placeholder parser scripting", "[PlaceholderParser]") { | |||
|     SECTION("math: max(13.4, -1238.1)") { REQUIRE(std::stod(parser.process("{max(13.4, -1238.1)}")) == Approx(13.4)); } | ||||
|     SECTION("math: int(13.4)") { REQUIRE(parser.process("{int(13.4)}") == "13"); } | ||||
|     SECTION("math: int(-13.4)") { REQUIRE(parser.process("{int(-13.4)}") == "-13"); } | ||||
|     SECTION("math: round(13.4)") { REQUIRE(parser.process("{round(13.4)}") == "13"); } | ||||
|     SECTION("math: round(-13.4)") { REQUIRE(parser.process("{round(-13.4)}") == "-13"); } | ||||
|     SECTION("math: round(13.6)") { REQUIRE(parser.process("{round(13.6)}") == "14"); } | ||||
|     SECTION("math: round(-13.6)") { REQUIRE(parser.process("{round(-13.6)}") == "-14"); } | ||||
|     SECTION("math: digits(5, 15)") { REQUIRE(parser.process("{digits(5, 15)}") == "              5"); } | ||||
|     SECTION("math: digits(5., 15)") { REQUIRE(parser.process("{digits(5., 15)}") == "              5"); } | ||||
|     SECTION("math: zdigits(5, 15)") { REQUIRE(parser.process("{zdigits(5, 15)}") == "000000000000005"); } | ||||
|     SECTION("math: zdigits(5., 15)") { REQUIRE(parser.process("{zdigits(5., 15)}") == "000000000000005"); } | ||||
|     SECTION("math: digits(5, 15, 8)") { REQUIRE(parser.process("{digits(5, 15, 8)}") == "     5.00000000"); } | ||||
|     SECTION("math: digits(5., 15, 8)") { REQUIRE(parser.process("{digits(5, 15, 8)}") == "     5.00000000"); } | ||||
|     SECTION("math: zdigits(5, 15, 8)") { REQUIRE(parser.process("{zdigits(5, 15, 8)}") == "000005.00000000"); } | ||||
|     SECTION("math: zdigits(5., 15, 8)") { REQUIRE(parser.process("{zdigits(5, 15, 8)}") == "000005.00000000"); } | ||||
|     SECTION("math: digits(13.84375892476, 15, 8)") { REQUIRE(parser.process("{digits(13.84375892476, 15, 8)}") == "    13.84375892"); } | ||||
|     SECTION("math: zdigits(13.84375892476, 15, 8)") { REQUIRE(parser.process("{zdigits(13.84375892476, 15, 8)}") == "000013.84375892"); } | ||||
| 
 | ||||
|     // Test the "coFloatOrPercent" and "xxx_extrusion_width" substitutions.
 | ||||
|     // first_layer_extrusion_width ratio_over first_layer_heigth.
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Vojtech Bubnik
						Vojtech Bubnik