As an example of using the enum_bitmask infrastructure for type safe

sets of optional boolean parameters, the cut function "keep upper",
"keep lower" and "flip lower" boolean parameters were converted into
a single type safe enum_bitmask. Such a coding style is certainly
wordier than the original code, but much safer and more readable
than the error prone "boolean, boolean, boolean" function call
parameter list.
This commit is contained in:
Vojtech Bubnik 2021-06-27 17:36:25 +02:00
parent 0f3cabb5d9
commit e4e8c5df12
6 changed files with 38 additions and 26 deletions

View file

@ -9,6 +9,7 @@
#include "Selection.hpp"
#include "libslic3r/enum_bitmask.hpp"
#include "libslic3r/Preset.hpp"
#include "libslic3r/BoundingBox.hpp"
#include "libslic3r/GCode/GCodeProcessor.hpp"
@ -24,6 +25,8 @@ namespace Slic3r {
class Model;
class ModelObject;
enum class ModelObjectCutAttribute : int;
using ModelObjectCutAttributes = enum_bitmask<ModelObjectCutAttribute>;
class ModelInstance;
class Print;
class SLAPrint;
@ -204,7 +207,7 @@ public:
void convert_unit(ConversionType conv_type);
void toggle_layers_editing(bool enable);
void cut(size_t obj_idx, size_t instance_idx, coordf_t z, bool keep_upper = true, bool keep_lower = true, bool rotate_lower = false);
void cut(size_t obj_idx, size_t instance_idx, coordf_t z, ModelObjectCutAttributes attributes);
void export_gcode(bool prefer_removable);
void export_stl(bool extended = false, bool selection_only = false);