2 #include "clipper/clipper.hpp"
3 #include "common/common.hpp"
4 #include "nlohmann/json_fwd.hpp"
6 #include "util/uuid.hpp"
14 enum class RulesCheckErrorLevel { NOT_RUN, PASS, WARN, FAIL, DISABLED };
16 Color rules_check_error_level_to_color(RulesCheckErrorLevel lev);
17 std::string rules_check_error_level_to_string(RulesCheckErrorLevel lev);
24 RulesCheckErrorLevel level = RulesCheckErrorLevel::NOT_RUN;
28 bool has_location =
false;
29 ClipperLib::Paths error_polygons;
31 json serialize()
const;
38 json serialize()
const;
40 RulesCheckErrorLevel level = RulesCheckErrorLevel::NOT_RUN;
43 std::deque<RulesCheckError> errors;
46 typedef std::function<void(
const std::string &)> check_status_cb_t;
51 virtual void load_from_json(
const json &j) = 0;
52 virtual json serialize()
const = 0;
53 virtual std::set<RuleID> get_rule_ids()
const = 0;
55 virtual const Rule *get_rule(RuleID
id)
const = 0;
56 Rule *get_rule(RuleID
id);
57 Rule *get_rule_nc(RuleID
id)
62 virtual const Rule *get_rule(RuleID
id,
const UUID &uu)
const = 0;
63 Rule *get_rule(RuleID
id,
const UUID &uu);
65 virtual std::map<UUID, const Rule *> get_rules(RuleID
id)
const = 0;
66 std::map<UUID, Rule *> get_rules(RuleID
id);
67 std::map<UUID, Rule *> get_rules_nc(RuleID
id)
72 template <
typename T = Rule> std::vector<const T *> get_rules_sorted(RuleID
id)
const
74 auto rs = get_rules(
id);
75 std::vector<const T *> rv;
76 rv.reserve(rs.size());
78 rv.push_back(
dynamic_cast<const T *
>(it.second));
80 std::sort(rv.begin(), rv.end(), [](
auto a,
auto b) { return a->order < b->order; });
84 template <
typename T = Rule> std::vector<T *> get_rules_sorted(RuleID
id)
87 auto rs =
static_cast<const Rules *
>(
this)->get_rules_sorted<T>(
id);
89 std::transform(rs.begin(), rs.end(), std::back_inserter(r), [](
auto x) { return const_cast<T *>(x); });
93 virtual void remove_rule(RuleID
id,
const UUID &uu) = 0;
94 virtual Rule *add_rule(RuleID
id) = 0;
95 void move_rule(RuleID
id,
const UUID &uu,
int dir);
100 void fix_order(RuleID
id);