14{
15 auto opposite_one_color = [](const std::string& color) {
16 ColorRGB rgb;
19 };
20 auto opposite_two_colors = [](const std::string& a, const std::string& b) {
24 };
25
27#if 1
29
30 auto before_tick_it = std::lower_bound(
ticks.begin(),
ticks.end(), tick);
31 if (before_tick_it ==
ticks.end()) {
32 while (before_tick_it !=
ticks.begin())
33 if (--before_tick_it; before_tick_it->type ==
ColorChange)
break;
34 if (before_tick_it->type ==
ColorChange)
return opposite_one_color(before_tick_it->color);
35 return opposite_one_color((*
m_colors)[0]);
36 }
37
38 if (before_tick_it ==
ticks.begin()) {
39 const std::string &frst_color = (*m_colors)[0];
40 if (before_tick_it->type ==
ColorChange)
return opposite_two_colors(frst_color, before_tick_it->color);
41
42 auto next_tick_it = before_tick_it;
43 while (next_tick_it !=
ticks.end())
44 if (++next_tick_it; next_tick_it->type ==
ColorChange)
break;
45 if (next_tick_it->type ==
ColorChange)
return opposite_two_colors(frst_color, next_tick_it->color);
46
47 return opposite_one_color(frst_color);
48 }
49
50 std::string frst_color = "";
52 frst_color = before_tick_it->color;
53 else {
54 auto next_tick_it = before_tick_it;
55 while (next_tick_it !=
ticks.end())
56 if (++next_tick_it; next_tick_it->type ==
ColorChange) {
57 frst_color = next_tick_it->color;
58 break;
59 }
60 }
61
62 while (before_tick_it !=
ticks.begin())
63 if (--before_tick_it; before_tick_it->type ==
ColorChange)
break;
64
66 if (frst_color.empty()) return opposite_one_color(before_tick_it->color);
67 return opposite_two_colors(before_tick_it->color, frst_color);
68 }
69
70 if (frst_color.empty())
return opposite_one_color((*
m_colors)[0]);
71 return opposite_two_colors((*
m_colors)[0], frst_color);
72#else
74 if (
ticks.empty())
return colors[0];
75 m_default_color_idx++;
76
77 return colors[m_default_color_idx % colors.size()];
78#endif
79 }
80
81 std::string color = (*m_colors)[extruder - 1];
82
85 auto before_tick_it = std::lower_bound(
ticks.begin(),
ticks.end(), tick);
86 while (before_tick_it !=
ticks.begin()) {
87 --before_tick_it;
88 if (before_tick_it->type ==
ColorChange && before_tick_it->extruder == extruder) {
89 color = before_tick_it->color;
90 break;
91 }
92 }
93 }
94
95
96
97 }
98 return color;
99}
static const std::vector< std::string > & get()
Definition GCode.hpp:211
std::vector< std::string > * m_colors
Definition TickCode.hpp:31
static wxColour decode_color(const std::string &color)
Definition SliceInfoPanel.cpp:51
std::string encode_color(const ColorRGB &color)
Definition Color.cpp:397
ColorRGB opposite(const ColorRGB &color)
Definition Color.cpp:281