Implemented possibility to show resin colors from the Plater (Bottles with resin are colored now in preset combobox)

+ Added nsvgParseFromFileWithReplace() to replace some colors before parsing from SVG file
+ Thumbnails are saved with selected resin color in SL1 or SL1S files
+ "white" folder is deleted from "icons" now. THere is no needed anymore.
This commit is contained in:
YuSanka 2021-11-09 17:00:57 +01:00
parent 69731b1d96
commit e8be7b2ecd
100 changed files with 109 additions and 2126 deletions

View file

@ -419,7 +419,7 @@ int mode_icon_px_size()
wxBitmap create_menu_bitmap(const std::string& bmp_name)
{
return create_scaled_bitmap(bmp_name, nullptr, 16, false, true);
return create_scaled_bitmap(bmp_name, nullptr, 16, false, "", true);
}
// win is used to get a correct em_unit value
@ -429,6 +429,7 @@ wxBitmap create_scaled_bitmap( const std::string& bmp_name_in,
wxWindow *win/* = nullptr*/,
const int px_cnt/* = 16*/,
const bool grayscale/* = false*/,
const std::string& new_color/* = std::string()*/, // color witch will used instead of orange
const bool menu_bitmap/* = false*/)
{
static Slic3r::GUI::BitmapCache cache;
@ -446,7 +447,7 @@ wxBitmap create_scaled_bitmap( const std::string& bmp_name_in,
Slic3r::GUI::wxGetApp().dark_mode();
// Try loading an SVG first, then PNG if SVG is not found:
wxBitmap *bmp = cache.load_svg(bmp_name, width, height, grayscale, dark_mode);
wxBitmap *bmp = cache.load_svg(bmp_name, width, height, grayscale, dark_mode, new_color);
if (bmp == nullptr) {
bmp = cache.load_png(bmp_name, width, height, grayscale);
}
@ -459,6 +460,33 @@ wxBitmap create_scaled_bitmap( const std::string& bmp_name_in,
return *bmp;
}
wxBitmap create_scaled_bitmap(const std::string& bmp_name_in,
const std::string& new_color, // color witch will used instead of orange
wxWindow* win,
const int px_cnt/* = 16*/,
const bool grayscale/* = false*/)
{
static Slic3r::GUI::BitmapCache cache;
unsigned int width = 0;
unsigned int height = (unsigned int)(em_unit(win) * px_cnt * 0.1f + 0.5f);
std::string bmp_name = bmp_name_in;
auto it = boost::find_last(bmp_name, ".png");
assert(it == bmp_name.end()); // this function works just with SVGs
bool dark_mode = Slic3r::GUI::wxGetApp().dark_mode();
// Try loading an SVG first, then PNG if SVG is not found:
wxBitmap* bmp = cache.load_svg(bmp_name, width, height, grayscale, dark_mode, new_color);
if (bmp == nullptr) {
// Neither SVG nor PNG has been found, raise error
throw Slic3r::RuntimeError("Could not load bitmap: " + bmp_name);
}
return *bmp;
}
std::vector<wxBitmap*> get_extruder_color_icons(bool thin_icon/* = false*/)
{
static Slic3r::GUI::BitmapCache bmp_cache;