Commit Graph

11 Commits

Author SHA1 Message Date
Vojtech Bubnik
7afabcde95 PlaceholderParser: Implemented one_of() matching function:
1st parameter is the text to match against,
the rest of the parameters are pattern to be matched:
either strings, then the match is exact,
or regex enclosed in //
or regex string starting with ~

For example
one_of("a", "a", "b")
	finds a in "a", "b"
one_of("abc", /.*a.*/)
	matches "abc" using regular expression /.*a.*/
2023-03-20 15:55:18 +01:00
Vojtech Bubnik
b9d8fe7118 WIP: PlaceholderParser support for writable output variables. 2023-03-20 07:48:38 +01:00
PavelMikus
5b0c270b30 Merge remote-tracking branch 'origin/master' into pm_anchor_bridges_on_sparse_infill 2023-03-01 16:45:26 +01:00
Vojtech Bubnik
55533397f9 PlaceholderPareser: new is_null() function to test whether a variable
has a "nil" value or not.
Implements SPE-1539
2023-02-28 18:30:04 +01:00
Vojtech Bubnik
1a5533d571 PlaceholderParser:
1) Implemented access to coEnum values, they are returned as strings.
2) Fixed some possible memory leaks.
3) Fixed some possible union type punning issues.
2023-01-04 13:38:18 +01:00
Vojtech Bubnik
3216448bbc 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.
2021-10-29 13:36:26 +02:00
Vojtech Bubnik
0f3cabb5d9 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.
2021-06-27 16:57:05 +02:00
Vojtech Bubnik
542d95a593 Fixing unit tests 2021-04-21 15:31:06 +02:00
bubnikv
059bdb4711 Implemented handling of complex ConfigOptionFloatOrPercent chains
by the PlaceholderParser.

Namely, all the options with the "ratio_over" reference are now handled
correctly by the PlaceholderParser with the exception
of the "first_layer_extrusion_width", which overrides speed of extrusions
by their respective extrusion type.

Also the various extrusion widths (extrusion_width, first_layer_extrusion_width,
external_perimeter_extrusion_width etc.) produce the same numbers
as if ran through the back-end, with the assumption of not overriding
layer height by the variable layer height editing tool or layer height
modifiers.
2020-02-04 15:27:38 +01:00
bubnikv
094cef26d4 Fix of the new PlaceholderParser int() conversion.
Fixes https://github.com/prusa3d/PrusaSlicer/pull/3271
Also some old errors (typos, UBs) were fixed.
2020-01-21 17:12:06 +01:00
bubnikv
05ea01bdcc Ported PlaceholderParser unit tests to C++. 2020-01-21 12:10:09 +01:00