mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-13 09:47:58 -06:00
GCode Preview - Customizable extrusion role colors by editing 3DPreview.pm
This commit is contained in:
parent
3f006dc11a
commit
f4522cd2fc
6 changed files with 87 additions and 0 deletions
|
@ -107,6 +107,48 @@ void Print::set_gcode_preview_shells_visible(bool visible)
|
|||
gcode_preview.shell.is_visible = visible;
|
||||
}
|
||||
|
||||
void Print::set_gcode_extrusion_paths_colors(const std::vector<std::string>& colors)
|
||||
{
|
||||
unsigned int size = (unsigned int)colors.size();
|
||||
|
||||
if (size % 2 != 0)
|
||||
return;
|
||||
|
||||
for (unsigned int i = 0; i < size; i += 2)
|
||||
{
|
||||
const std::string& color_str = colors[i + 1];
|
||||
|
||||
if (color_str.size() == 6)
|
||||
{
|
||||
bool valid = true;
|
||||
for (int c = 0; c < 6; ++c)
|
||||
{
|
||||
if (::isxdigit(color_str[c]) == 0)
|
||||
{
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (valid)
|
||||
{
|
||||
unsigned int color;
|
||||
std::stringstream ss;
|
||||
ss << std::hex << color_str;
|
||||
ss >> color;
|
||||
|
||||
float den = 1.0f / 255.0f;
|
||||
|
||||
float r = (float)((color & 0xFF0000) >> 16) * den;
|
||||
float g = (float)((color & 0x00FF00) >> 8) * den;
|
||||
float b = (float)(color & 0x0000FF) * den;
|
||||
|
||||
gcode_preview.set_extrusion_role_color(colors[i], r, g, b, 1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PrintRegion* Print::add_region()
|
||||
{
|
||||
regions.push_back(new PrintRegion(this));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue