OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::TickCodeInfo Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/TickCode.hpp>

Collaboration diagram for Slic3r::GUI::TickCodeInfo:

Public Member Functions

bool empty () const
void set_pause_print_msg (const std::string &message)
bool add_tick (const int tick, CustomGCode::Type type, int extruder, double print_z)
bool edit_tick (std::set< TickCode >::iterator it, double print_z)
void switch_code (CustomGCode::Type type_from, CustomGCode::Type type_to)
bool switch_code_for_tick (std::set< TickCode >::iterator it, CustomGCode::Type type_to, const int extruder)
void erase_all_ticks_with_code (CustomGCode::Type type)
bool has_tick_with_code (CustomGCode::Type type)
bool has_tick (int tick)
void suppress_plus (bool suppress)
void suppress_minus (bool suppress)
bool suppressed_plus ()
bool suppressed_minus ()
void set_default_colors (bool default_colors_on)
void set_extruder_colors (std::vector< std::string > *extruder_colors)

Public Attributes

std::set< TickCode > ticks {}
CustomGCode::Mode mode = CustomGCode::Undef

Private Member Functions

std::string get_color_for_tick (TickCode tick, CustomGCode::Type type, const int extruder)

Private Attributes

std::string pause_print_msg
bool m_suppress_plus = false
bool m_suppress_minus = false
bool m_use_default_colors = false
std::vector< std::string > * m_colors { nullptr }

Detailed Description

Member Function Documentation

◆ add_tick()

bool Slic3r::GUI::TickCodeInfo::add_tick ( const int tick,
CustomGCode::Type type,
int extruder,
double print_z )
103{
104 std::string color;
105 std::string extra;
106 if (type == Custom) // custom Gcode
107 {
108 //extra = get_custom_code(custom_gcode, print_z);
109 //if (extra.empty()) return false;
110 //custom_gcode = extra;
111 } else if (type == PausePrint) {
112 //BBS do not set pause extra message
113 //extra = get_pause_print_msg(pause_print_msg, print_z);
114 //if (extra.empty()) return false;
115 pause_print_msg = extra;
116 }
117 else {
118 color = get_color_for_tick(TickCode{ tick }, type, extruder);
119 if (color.empty()) return false;
120 }
121
123
124 ticks.emplace(TickCode{tick, type, extruder, color, extra});
125
126 return true;
127}
bool m_use_default_colors
Definition TickCode.hpp:29
CustomGCode::Mode mode
Definition TickCode.hpp:37
std::string get_color_for_tick(TickCode tick, CustomGCode::Type type, const int extruder)
Definition TickCode.cpp:13
std::string pause_print_msg
Definition TickCode.hpp:26
std::set< TickCode > ticks
Definition TickCode.hpp:36
@ SingleExtruder
Definition CustomGCode.hpp:56
@ PausePrint
Definition CustomGCode.hpp:20
@ Custom
Definition CustomGCode.hpp:23

References Slic3r::CustomGCode::Custom, get_color_for_tick(), m_use_default_colors, mode, pause_print_msg, Slic3r::CustomGCode::PausePrint, Slic3r::CustomGCode::SingleExtruder, and ticks.

Here is the call graph for this function:

◆ edit_tick()

bool Slic3r::GUI::TickCodeInfo::edit_tick ( std::set< TickCode >::iterator it,
double print_z )
130{
131 std::string edited_value;
132 //TODO
133 /* BBS
134 if (it->type == ColorChange)
135 edited_value = get_new_color(it->color);
136 else if (it->type == PausePrint)
137 edited_value = get_pause_print_msg(it->extra, print_z);
138 else
139 edited_value = get_custom_code(it->type == Template ? gcode(Template) : it->extra, print_z);
140 */
141 if (edited_value.empty()) return false;
142
143 TickCode changed_tick = *it;
144 if (it->type == ColorChange) {
145 if (it->color == edited_value) return false;
146 changed_tick.color = edited_value;
147 } else if (it->type == Template) {
148 //if (gcode(Template) == edited_value) return false;
149 //changed_tick.extra = edited_value;
150 //changed_tick.type = Custom;
151 ;
152 } else if (it->type == Custom || it->type == PausePrint) {
153 if (it->extra == edited_value) return false;
154 changed_tick.extra = edited_value;
155 }
156
157 ticks.erase(it);
158 ticks.emplace(changed_tick);
159
160 return true;
161}
@ Template
Definition CustomGCode.hpp:22
@ ColorChange
Definition CustomGCode.hpp:19

References Slic3r::GUI::TickCode::color, Slic3r::CustomGCode::ColorChange, Slic3r::CustomGCode::Custom, Slic3r::GUI::TickCode::extra, Slic3r::CustomGCode::PausePrint, Slic3r::CustomGCode::Template, and ticks.

◆ empty()

bool Slic3r::GUI::TickCodeInfo::empty ( ) const
inline
39{ return ticks.empty(); }

References ticks.

◆ erase_all_ticks_with_code()

void Slic3r::GUI::TickCodeInfo::erase_all_ticks_with_code ( CustomGCode::Type type)
193{
194 for (auto it{ticks.begin()}, end{ticks.end()}; it != end;) {
195 if (it->type == type)
196 it = ticks.erase(it);
197 else
198 ++it;
199 }
200}
T * end(Slic3r::Mat< N, M, T > &mat)
Definition Point.hpp:841

References ticks.

◆ get_color_for_tick()

std::string Slic3r::GUI::TickCodeInfo::get_color_for_tick ( TickCode tick,
CustomGCode::Type type,
const int extruder )
private
14{
15 auto opposite_one_color = [](const std::string& color) {
16 ColorRGB rgb;
17 decode_color(color, rgb);
18 return encode_color(opposite(rgb));
19 };
20 auto opposite_two_colors = [](const std::string& a, const std::string& b) {
21 ColorRGB rgb1; decode_color(a, rgb1);
22 ColorRGB rgb2; decode_color(b, rgb2);
23 return encode_color(opposite(rgb1, rgb2));
24 };
25
27#if 1
28 if (ticks.empty()) return opposite_one_color((*m_colors)[0]);
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 = "";
51 if (before_tick_it->type == ColorChange)
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
65 if (before_tick_it->type == ColorChange) {
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
73 const std::vector<std::string> &colors = ColorPrintColors::get();
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
83 if (type == ColorChange) {
84 if (!ticks.empty()) {
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 //TODO
96 //color = get_new_color(color);
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

References Slic3r::CustomGCode::ColorChange, Slic3r::GUI::decode_color(), Slic3r::encode_color(), Slic3r::ColorPrintColors::get(), m_colors, m_use_default_colors, mode, Slic3r::opposite(), Slic3r::CustomGCode::SingleExtruder, and ticks.

Referenced by add_tick(), and switch_code_for_tick().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ has_tick()

bool Slic3r::GUI::TickCodeInfo::has_tick ( int tick)
210{ return ticks.find(TickCode{tick}) != ticks.end(); }

References ticks.

◆ has_tick_with_code()

bool Slic3r::GUI::TickCodeInfo::has_tick_with_code ( CustomGCode::Type type)
203{
204 for (const TickCode &tick : ticks)
205 if (tick.type == type) return true;
206
207 return false;
208}

References ticks.

◆ set_default_colors()

void Slic3r::GUI::TickCodeInfo::set_default_colors ( bool default_colors_on)
inline
55{ m_use_default_colors = default_colors_on; }

References m_use_default_colors.

◆ set_extruder_colors()

void Slic3r::GUI::TickCodeInfo::set_extruder_colors ( std::vector< std::string > * extruder_colors)
inline
57{ m_colors = extruder_colors; }

References m_colors.

◆ set_pause_print_msg()

void Slic3r::GUI::TickCodeInfo::set_pause_print_msg ( const std::string & message)
inline
40{ pause_print_msg = message; }

References pause_print_msg.

◆ suppress_minus()

void Slic3r::GUI::TickCodeInfo::suppress_minus ( bool suppress)
inline
52{ m_suppress_minus = suppress; }
bool m_suppress_minus
Definition TickCode.hpp:28

References m_suppress_minus.

◆ suppress_plus()

void Slic3r::GUI::TickCodeInfo::suppress_plus ( bool suppress)
inline
51{ m_suppress_plus = suppress; }
bool m_suppress_plus
Definition TickCode.hpp:27

References m_suppress_plus.

◆ suppressed_minus()

bool Slic3r::GUI::TickCodeInfo::suppressed_minus ( )
inline
54{ return m_suppress_minus; }

References m_suppress_minus.

◆ suppressed_plus()

bool Slic3r::GUI::TickCodeInfo::suppressed_plus ( )
inline
53{ return m_suppress_plus; }

References m_suppress_plus.

◆ switch_code()

void Slic3r::GUI::TickCodeInfo::switch_code ( CustomGCode::Type type_from,
CustomGCode::Type type_to )
164{
165 for (auto it{ticks.begin()}, end{ticks.end()}; it != end;)
166 if (it->type == type_from) {
167 TickCode tick = *it;
168 tick.type = type_to;
169 tick.extruder = 1;
170 ticks.erase(it);
171 it = ticks.emplace(tick).first;
172 } else
173 ++it;
174}

References Slic3r::GUI::TickCode::extruder, ticks, and Slic3r::GUI::TickCode::type.

◆ switch_code_for_tick()

bool Slic3r::GUI::TickCodeInfo::switch_code_for_tick ( std::set< TickCode >::iterator it,
CustomGCode::Type type_to,
const int extruder )
177{
178 const std::string color = get_color_for_tick(*it, type_to, extruder);
179 if (color.empty()) return false;
180
181 TickCode changed_tick = *it;
182 changed_tick.type = type_to;
183 changed_tick.extruder = extruder;
184 changed_tick.color = color;
185
186 ticks.erase(it);
187 ticks.emplace(changed_tick);
188
189 return true;
190}

References Slic3r::GUI::TickCode::color, Slic3r::GUI::TickCode::extruder, get_color_for_tick(), ticks, and Slic3r::GUI::TickCode::type.

Here is the call graph for this function:

Member Data Documentation

◆ m_colors

std::vector<std::string>* Slic3r::GUI::TickCodeInfo::m_colors { nullptr }
private
31{ nullptr };// reference to IMSlider::m_extruder_colors

Referenced by get_color_for_tick(), and set_extruder_colors().

◆ m_suppress_minus

bool Slic3r::GUI::TickCodeInfo::m_suppress_minus = false
private

Referenced by suppress_minus(), and suppressed_minus().

◆ m_suppress_plus

bool Slic3r::GUI::TickCodeInfo::m_suppress_plus = false
private

Referenced by suppress_plus(), and suppressed_plus().

◆ m_use_default_colors

bool Slic3r::GUI::TickCodeInfo::m_use_default_colors = false
private

◆ mode

CustomGCode::Mode Slic3r::GUI::TickCodeInfo::mode = CustomGCode::Undef

Referenced by add_tick(), and get_color_for_tick().

◆ pause_print_msg

std::string Slic3r::GUI::TickCodeInfo::pause_print_msg
private

Referenced by add_tick(), and set_pause_print_msg().

◆ ticks


The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/TickCode.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/TickCode.cpp