From e8be7b2ecd3a21676af73805f96157f37418f8e5 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Tue, 9 Nov 2021 17:00:57 +0100 Subject: [PATCH 1/6] 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. --- resources/icons/editor_menu.svg | 6 +- resources/icons/preview_menu.svg | 32 +++---- resources/icons/white/add_copies.svg | 19 ---- resources/icons/white/add_modifier.svg | 13 --- resources/icons/white/add_negative.svg | 15 --- resources/icons/white/add_part.svg | 19 ---- resources/icons/white/advanced+wrench.svg | 43 --------- resources/icons/white/advanced_plus.svg | 24 ----- resources/icons/white/cog.svg | 17 ---- resources/icons/white/colorchange_add_m.svg | 20 ---- resources/icons/white/compare.svg | 30 ------ resources/icons/white/cooling.svg | 25 ----- resources/icons/white/copy_menu.svg | 37 -------- resources/icons/white/delete.svg | 22 ----- resources/icons/white/delete_all_menu.svg | 31 ------ resources/icons/white/dot.svg | 8 -- resources/icons/white/dot_small.svg | 8 -- resources/icons/white/drop_to_bed.svg | 15 --- resources/icons/white/edit_gcode.svg | 15 --- resources/icons/white/edit_layers_all.svg | 25 ----- resources/icons/white/edit_layers_some.svg | 14 --- resources/icons/white/edit_uni.svg | 20 ---- resources/icons/white/editor_menu.svg | 20 ---- resources/icons/white/equal.svg | 15 --- resources/icons/white/error_tick.svg | 12 --- .../icons/white/exclamation_manifold.svg | 17 ---- resources/icons/white/exit.svg | 13 --- resources/icons/white/export_config.svg | 20 ---- .../icons/white/export_config_bundle.svg | 50 ---------- resources/icons/white/export_gcode.svg | 14 --- resources/icons/white/export_plate.svg | 15 --- resources/icons/white/export_plater.svg | 12 --- resources/icons/white/export_to_sd.svg | 22 ----- resources/icons/white/extruder+funnel.svg | 15 --- resources/icons/white/eye_closed.svg | 13 --- resources/icons/white/eye_open.svg | 11 --- resources/icons/white/flag_green.svg | 10 -- resources/icons/white/flag_red.svg | 10 -- resources/icons/white/funnel.svg | 15 --- resources/icons/white/hollowing.svg | 51 ---------- resources/icons/white/import_config.svg | 25 ----- .../icons/white/import_config_bundle.svg | 61 ------------ resources/icons/white/import_plate.svg | 38 -------- resources/icons/white/import_plater.svg | 17 ---- resources/icons/white/infill.svg | 35 ------- resources/icons/white/info.svg | 71 -------------- resources/icons/white/layers.svg | 27 ------ resources/icons/white/lock2_closed.svg | 10 -- resources/icons/white/lock_closed.svg | 10 -- resources/icons/white/lock_closed_f.svg | 10 -- resources/icons/white/lock_open_sys.svg | 11 --- resources/icons/white/machine+cog.svg | 30 ------ resources/icons/white/mirroring_off.svg | 23 ----- resources/icons/white/mirroring_on.svg | 23 ----- resources/icons/white/note.svg | 25 ----- resources/icons/white/notes.svg | 25 ----- resources/icons/white/number_of_copies.svg | 29 ------ resources/icons/white/open.svg | 11 --- resources/icons/white/output+page_white.svg | 20 ---- resources/icons/white/pad.svg | 83 ---------------- resources/icons/white/paste_menu.svg | 27 ------ resources/icons/white/pause_print.svg | 18 ---- resources/icons/white/plater.svg | 12 --- resources/icons/white/preview_menu.svg | 48 ---------- resources/icons/white/printer.svg | 14 --- resources/icons/white/re_slice.svg | 19 ---- resources/icons/white/redo_menu.svg | 13 --- resources/icons/white/remove_copies.svg | 15 --- resources/icons/white/remove_menu.svg | 44 --------- resources/icons/white/resin.svg | 10 -- resources/icons/white/save.svg | 25 ----- resources/icons/white/search.svg | 4 - resources/icons/white/set_separate_obj.svg | 29 ------ resources/icons/white/skirt+brim.svg | 15 --- resources/icons/white/sla_printer.svg | 14 --- resources/icons/white/split_object_SMALL.svg | 19 ---- resources/icons/white/split_parts_SMALL.svg | 18 ---- resources/icons/white/spool.svg | 21 ----- resources/icons/white/support.svg | 94 ------------------- resources/icons/white/support_blocker.svg | 48 ---------- resources/icons/white/support_enforcer.svg | 19 ---- resources/icons/white/switch_presets.svg | 52 ---------- resources/icons/white/test.svg | 37 -------- resources/icons/white/time.svg | 16 ---- resources/icons/white/undo_menu.svg | 13 --- resources/icons/white/upload_queue.svg | 29 ------ resources/icons/white/wrench.svg | 20 ---- src/libslic3r/PrintConfig.cpp | 4 +- src/nanosvg/nanosvg.h | 24 ++++- src/slic3r/GUI/3DScene.cpp | 12 +-- src/slic3r/GUI/BitmapCache.cpp | 51 +++------- src/slic3r/GUI/BitmapCache.hpp | 2 +- src/slic3r/GUI/Field.cpp | 2 +- src/slic3r/GUI/GLCanvas3D.cpp | 2 +- src/slic3r/GUI/ImGuiWrapper.cpp | 10 +- src/slic3r/GUI/Plater.cpp | 6 -- src/slic3r/GUI/PresetComboBoxes.cpp | 14 ++- src/slic3r/GUI/PresetComboBoxes.hpp | 2 +- src/slic3r/GUI/wxExtensions.cpp | 32 ++++++- src/slic3r/GUI/wxExtensions.hpp | 4 +- 100 files changed, 109 insertions(+), 2126 deletions(-) delete mode 100644 resources/icons/white/add_copies.svg delete mode 100644 resources/icons/white/add_modifier.svg delete mode 100644 resources/icons/white/add_negative.svg delete mode 100644 resources/icons/white/add_part.svg delete mode 100644 resources/icons/white/advanced+wrench.svg delete mode 100644 resources/icons/white/advanced_plus.svg delete mode 100644 resources/icons/white/cog.svg delete mode 100644 resources/icons/white/colorchange_add_m.svg delete mode 100644 resources/icons/white/compare.svg delete mode 100644 resources/icons/white/cooling.svg delete mode 100644 resources/icons/white/copy_menu.svg delete mode 100644 resources/icons/white/delete.svg delete mode 100644 resources/icons/white/delete_all_menu.svg delete mode 100644 resources/icons/white/dot.svg delete mode 100644 resources/icons/white/dot_small.svg delete mode 100644 resources/icons/white/drop_to_bed.svg delete mode 100644 resources/icons/white/edit_gcode.svg delete mode 100644 resources/icons/white/edit_layers_all.svg delete mode 100644 resources/icons/white/edit_layers_some.svg delete mode 100644 resources/icons/white/edit_uni.svg delete mode 100644 resources/icons/white/editor_menu.svg delete mode 100644 resources/icons/white/equal.svg delete mode 100644 resources/icons/white/error_tick.svg delete mode 100644 resources/icons/white/exclamation_manifold.svg delete mode 100644 resources/icons/white/exit.svg delete mode 100644 resources/icons/white/export_config.svg delete mode 100644 resources/icons/white/export_config_bundle.svg delete mode 100644 resources/icons/white/export_gcode.svg delete mode 100644 resources/icons/white/export_plate.svg delete mode 100644 resources/icons/white/export_plater.svg delete mode 100644 resources/icons/white/export_to_sd.svg delete mode 100644 resources/icons/white/extruder+funnel.svg delete mode 100644 resources/icons/white/eye_closed.svg delete mode 100644 resources/icons/white/eye_open.svg delete mode 100644 resources/icons/white/flag_green.svg delete mode 100644 resources/icons/white/flag_red.svg delete mode 100644 resources/icons/white/funnel.svg delete mode 100644 resources/icons/white/hollowing.svg delete mode 100644 resources/icons/white/import_config.svg delete mode 100644 resources/icons/white/import_config_bundle.svg delete mode 100644 resources/icons/white/import_plate.svg delete mode 100644 resources/icons/white/import_plater.svg delete mode 100644 resources/icons/white/infill.svg delete mode 100644 resources/icons/white/info.svg delete mode 100644 resources/icons/white/layers.svg delete mode 100644 resources/icons/white/lock2_closed.svg delete mode 100644 resources/icons/white/lock_closed.svg delete mode 100644 resources/icons/white/lock_closed_f.svg delete mode 100644 resources/icons/white/lock_open_sys.svg delete mode 100644 resources/icons/white/machine+cog.svg delete mode 100644 resources/icons/white/mirroring_off.svg delete mode 100644 resources/icons/white/mirroring_on.svg delete mode 100644 resources/icons/white/note.svg delete mode 100644 resources/icons/white/notes.svg delete mode 100644 resources/icons/white/number_of_copies.svg delete mode 100644 resources/icons/white/open.svg delete mode 100644 resources/icons/white/output+page_white.svg delete mode 100644 resources/icons/white/pad.svg delete mode 100644 resources/icons/white/paste_menu.svg delete mode 100644 resources/icons/white/pause_print.svg delete mode 100644 resources/icons/white/plater.svg delete mode 100644 resources/icons/white/preview_menu.svg delete mode 100644 resources/icons/white/printer.svg delete mode 100644 resources/icons/white/re_slice.svg delete mode 100644 resources/icons/white/redo_menu.svg delete mode 100644 resources/icons/white/remove_copies.svg delete mode 100644 resources/icons/white/remove_menu.svg delete mode 100644 resources/icons/white/resin.svg delete mode 100644 resources/icons/white/save.svg delete mode 100644 resources/icons/white/search.svg delete mode 100644 resources/icons/white/set_separate_obj.svg delete mode 100644 resources/icons/white/skirt+brim.svg delete mode 100644 resources/icons/white/sla_printer.svg delete mode 100644 resources/icons/white/split_object_SMALL.svg delete mode 100644 resources/icons/white/split_parts_SMALL.svg delete mode 100644 resources/icons/white/spool.svg delete mode 100644 resources/icons/white/support.svg delete mode 100644 resources/icons/white/support_blocker.svg delete mode 100644 resources/icons/white/support_enforcer.svg delete mode 100644 resources/icons/white/switch_presets.svg delete mode 100644 resources/icons/white/test.svg delete mode 100644 resources/icons/white/time.svg delete mode 100644 resources/icons/white/undo_menu.svg delete mode 100644 resources/icons/white/upload_queue.svg delete mode 100644 resources/icons/white/wrench.svg diff --git a/resources/icons/editor_menu.svg b/resources/icons/editor_menu.svg index 223efda0f5..253bd907db 100644 --- a/resources/icons/editor_menu.svg +++ b/resources/icons/editor_menu.svg @@ -4,15 +4,15 @@ viewBox="0 0 128 128" enable-background="new 0 0 128 128" xml:space="preserve"> - - + - diff --git a/resources/icons/preview_menu.svg b/resources/icons/preview_menu.svg index 725caf7b8a..9af677d3e3 100644 --- a/resources/icons/preview_menu.svg +++ b/resources/icons/preview_menu.svg @@ -4,40 +4,40 @@ viewBox="0 0 128 128" enable-background="new 0 0 128 128" xml:space="preserve"> - - - - + - - - - + - - - - + - - - + - - - - - - - - - - - - - - - diff --git a/resources/icons/white/add_modifier.svg b/resources/icons/white/add_modifier.svg deleted file mode 100644 index 09c3ce27dc..0000000000 --- a/resources/icons/white/add_modifier.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - diff --git a/resources/icons/white/add_negative.svg b/resources/icons/white/add_negative.svg deleted file mode 100644 index 0173d1f0de..0000000000 --- a/resources/icons/white/add_negative.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - diff --git a/resources/icons/white/add_part.svg b/resources/icons/white/add_part.svg deleted file mode 100644 index f4ee114320..0000000000 --- a/resources/icons/white/add_part.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - diff --git a/resources/icons/white/advanced+wrench.svg b/resources/icons/white/advanced+wrench.svg deleted file mode 100644 index 5e878cb3cc..0000000000 --- a/resources/icons/white/advanced+wrench.svg +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/resources/icons/white/advanced_plus.svg b/resources/icons/white/advanced_plus.svg deleted file mode 100644 index db532ec4b1..0000000000 --- a/resources/icons/white/advanced_plus.svg +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - diff --git a/resources/icons/white/cog.svg b/resources/icons/white/cog.svg deleted file mode 100644 index 773e4d65dd..0000000000 --- a/resources/icons/white/cog.svg +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - diff --git a/resources/icons/white/colorchange_add_m.svg b/resources/icons/white/colorchange_add_m.svg deleted file mode 100644 index 2266560daa..0000000000 --- a/resources/icons/white/colorchange_add_m.svg +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/resources/icons/white/compare.svg b/resources/icons/white/compare.svg deleted file mode 100644 index 7eafebfde6..0000000000 --- a/resources/icons/white/compare.svg +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - diff --git a/resources/icons/white/cooling.svg b/resources/icons/white/cooling.svg deleted file mode 100644 index 29bd04c368..0000000000 --- a/resources/icons/white/cooling.svg +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/resources/icons/white/copy_menu.svg b/resources/icons/white/copy_menu.svg deleted file mode 100644 index d660aab6a2..0000000000 --- a/resources/icons/white/copy_menu.svg +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/resources/icons/white/delete.svg b/resources/icons/white/delete.svg deleted file mode 100644 index 91d5ce74c5..0000000000 --- a/resources/icons/white/delete.svg +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/resources/icons/white/delete_all_menu.svg b/resources/icons/white/delete_all_menu.svg deleted file mode 100644 index 5d825c424c..0000000000 --- a/resources/icons/white/delete_all_menu.svg +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/icons/white/dot.svg b/resources/icons/white/dot.svg deleted file mode 100644 index 90fbaf7fb1..0000000000 --- a/resources/icons/white/dot.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - diff --git a/resources/icons/white/dot_small.svg b/resources/icons/white/dot_small.svg deleted file mode 100644 index 74df442086..0000000000 --- a/resources/icons/white/dot_small.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - diff --git a/resources/icons/white/drop_to_bed.svg b/resources/icons/white/drop_to_bed.svg deleted file mode 100644 index 76243f8976..0000000000 --- a/resources/icons/white/drop_to_bed.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - diff --git a/resources/icons/white/edit_gcode.svg b/resources/icons/white/edit_gcode.svg deleted file mode 100644 index 85836c0b49..0000000000 --- a/resources/icons/white/edit_gcode.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - diff --git a/resources/icons/white/edit_layers_all.svg b/resources/icons/white/edit_layers_all.svg deleted file mode 100644 index efb7d609f1..0000000000 --- a/resources/icons/white/edit_layers_all.svg +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - diff --git a/resources/icons/white/edit_layers_some.svg b/resources/icons/white/edit_layers_some.svg deleted file mode 100644 index 585a8df2f1..0000000000 --- a/resources/icons/white/edit_layers_some.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - diff --git a/resources/icons/white/edit_uni.svg b/resources/icons/white/edit_uni.svg deleted file mode 100644 index 661924763c..0000000000 --- a/resources/icons/white/edit_uni.svg +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - diff --git a/resources/icons/white/editor_menu.svg b/resources/icons/white/editor_menu.svg deleted file mode 100644 index 649d2c40fa..0000000000 --- a/resources/icons/white/editor_menu.svg +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/resources/icons/white/equal.svg b/resources/icons/white/equal.svg deleted file mode 100644 index febbb4c5f2..0000000000 --- a/resources/icons/white/equal.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - diff --git a/resources/icons/white/error_tick.svg b/resources/icons/white/error_tick.svg deleted file mode 100644 index f3de981f03..0000000000 --- a/resources/icons/white/error_tick.svg +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - diff --git a/resources/icons/white/exclamation_manifold.svg b/resources/icons/white/exclamation_manifold.svg deleted file mode 100644 index a18590167c..0000000000 --- a/resources/icons/white/exclamation_manifold.svg +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/resources/icons/white/exit.svg b/resources/icons/white/exit.svg deleted file mode 100644 index e5aebcfc22..0000000000 --- a/resources/icons/white/exit.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - diff --git a/resources/icons/white/export_config.svg b/resources/icons/white/export_config.svg deleted file mode 100644 index 22f8ebe1a6..0000000000 --- a/resources/icons/white/export_config.svg +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - diff --git a/resources/icons/white/export_config_bundle.svg b/resources/icons/white/export_config_bundle.svg deleted file mode 100644 index 99bd62b6c3..0000000000 --- a/resources/icons/white/export_config_bundle.svg +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/resources/icons/white/export_gcode.svg b/resources/icons/white/export_gcode.svg deleted file mode 100644 index 39f5225cbe..0000000000 --- a/resources/icons/white/export_gcode.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - diff --git a/resources/icons/white/export_plate.svg b/resources/icons/white/export_plate.svg deleted file mode 100644 index 18159d2a87..0000000000 --- a/resources/icons/white/export_plate.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - diff --git a/resources/icons/white/export_plater.svg b/resources/icons/white/export_plater.svg deleted file mode 100644 index e71b38a0aa..0000000000 --- a/resources/icons/white/export_plater.svg +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - diff --git a/resources/icons/white/export_to_sd.svg b/resources/icons/white/export_to_sd.svg deleted file mode 100644 index ebeacb9054..0000000000 --- a/resources/icons/white/export_to_sd.svg +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - diff --git a/resources/icons/white/extruder+funnel.svg b/resources/icons/white/extruder+funnel.svg deleted file mode 100644 index de6b227da2..0000000000 --- a/resources/icons/white/extruder+funnel.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - diff --git a/resources/icons/white/eye_closed.svg b/resources/icons/white/eye_closed.svg deleted file mode 100644 index 0cdd16ae00..0000000000 --- a/resources/icons/white/eye_closed.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - diff --git a/resources/icons/white/eye_open.svg b/resources/icons/white/eye_open.svg deleted file mode 100644 index 1b320da079..0000000000 --- a/resources/icons/white/eye_open.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - diff --git a/resources/icons/white/flag_green.svg b/resources/icons/white/flag_green.svg deleted file mode 100644 index 8479d0e9a9..0000000000 --- a/resources/icons/white/flag_green.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - diff --git a/resources/icons/white/flag_red.svg b/resources/icons/white/flag_red.svg deleted file mode 100644 index a9b1cf8fed..0000000000 --- a/resources/icons/white/flag_red.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - diff --git a/resources/icons/white/funnel.svg b/resources/icons/white/funnel.svg deleted file mode 100644 index b8a3408a78..0000000000 --- a/resources/icons/white/funnel.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - diff --git a/resources/icons/white/hollowing.svg b/resources/icons/white/hollowing.svg deleted file mode 100644 index 77f50b6b83..0000000000 --- a/resources/icons/white/hollowing.svg +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/icons/white/import_config.svg b/resources/icons/white/import_config.svg deleted file mode 100644 index 001277f738..0000000000 --- a/resources/icons/white/import_config.svg +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/resources/icons/white/import_config_bundle.svg b/resources/icons/white/import_config_bundle.svg deleted file mode 100644 index c16cd7b3c6..0000000000 --- a/resources/icons/white/import_config_bundle.svg +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/icons/white/import_plate.svg b/resources/icons/white/import_plate.svg deleted file mode 100644 index 7f888e3d78..0000000000 --- a/resources/icons/white/import_plate.svg +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - -]> - - - - - - - - - - - - - - - - - - - - diff --git a/resources/icons/white/import_plater.svg b/resources/icons/white/import_plater.svg deleted file mode 100644 index 1dc5aae6eb..0000000000 --- a/resources/icons/white/import_plater.svg +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/resources/icons/white/infill.svg b/resources/icons/white/infill.svg deleted file mode 100644 index 0860430998..0000000000 --- a/resources/icons/white/infill.svg +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/icons/white/info.svg b/resources/icons/white/info.svg deleted file mode 100644 index db227aa320..0000000000 --- a/resources/icons/white/info.svg +++ /dev/null @@ -1,71 +0,0 @@ - -image/svg+xml - - - - - - - - - - diff --git a/resources/icons/white/layers.svg b/resources/icons/white/layers.svg deleted file mode 100644 index cd71fab3a3..0000000000 --- a/resources/icons/white/layers.svg +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/icons/white/lock2_closed.svg b/resources/icons/white/lock2_closed.svg deleted file mode 100644 index 726c850a11..0000000000 --- a/resources/icons/white/lock2_closed.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - diff --git a/resources/icons/white/lock_closed.svg b/resources/icons/white/lock_closed.svg deleted file mode 100644 index 1665dc9a08..0000000000 --- a/resources/icons/white/lock_closed.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - diff --git a/resources/icons/white/lock_closed_f.svg b/resources/icons/white/lock_closed_f.svg deleted file mode 100644 index 412c93c164..0000000000 --- a/resources/icons/white/lock_closed_f.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - diff --git a/resources/icons/white/lock_open_sys.svg b/resources/icons/white/lock_open_sys.svg deleted file mode 100644 index c1aa64aec2..0000000000 --- a/resources/icons/white/lock_open_sys.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - diff --git a/resources/icons/white/machine+cog.svg b/resources/icons/white/machine+cog.svg deleted file mode 100644 index ec49265b81..0000000000 --- a/resources/icons/white/machine+cog.svg +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - diff --git a/resources/icons/white/mirroring_off.svg b/resources/icons/white/mirroring_off.svg deleted file mode 100644 index 2011d8f1b8..0000000000 --- a/resources/icons/white/mirroring_off.svg +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/resources/icons/white/mirroring_on.svg b/resources/icons/white/mirroring_on.svg deleted file mode 100644 index 1773b78add..0000000000 --- a/resources/icons/white/mirroring_on.svg +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/resources/icons/white/note.svg b/resources/icons/white/note.svg deleted file mode 100644 index 07c2a14cf9..0000000000 --- a/resources/icons/white/note.svg +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/icons/white/notes.svg b/resources/icons/white/notes.svg deleted file mode 100644 index 25de4191e8..0000000000 --- a/resources/icons/white/notes.svg +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/icons/white/number_of_copies.svg b/resources/icons/white/number_of_copies.svg deleted file mode 100644 index 7c9d78a801..0000000000 --- a/resources/icons/white/number_of_copies.svg +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/icons/white/open.svg b/resources/icons/white/open.svg deleted file mode 100644 index 0ea9ecdb2c..0000000000 --- a/resources/icons/white/open.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - diff --git a/resources/icons/white/output+page_white.svg b/resources/icons/white/output+page_white.svg deleted file mode 100644 index 0838740032..0000000000 --- a/resources/icons/white/output+page_white.svg +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - diff --git a/resources/icons/white/pad.svg b/resources/icons/white/pad.svg deleted file mode 100644 index cddb2da022..0000000000 --- a/resources/icons/white/pad.svg +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/icons/white/paste_menu.svg b/resources/icons/white/paste_menu.svg deleted file mode 100644 index 465c2faf08..0000000000 --- a/resources/icons/white/paste_menu.svg +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - diff --git a/resources/icons/white/pause_print.svg b/resources/icons/white/pause_print.svg deleted file mode 100644 index 73f747fffd..0000000000 --- a/resources/icons/white/pause_print.svg +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/resources/icons/white/plater.svg b/resources/icons/white/plater.svg deleted file mode 100644 index d637a5e7e7..0000000000 --- a/resources/icons/white/plater.svg +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - diff --git a/resources/icons/white/preview_menu.svg b/resources/icons/white/preview_menu.svg deleted file mode 100644 index 98095359c9..0000000000 --- a/resources/icons/white/preview_menu.svg +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/icons/white/printer.svg b/resources/icons/white/printer.svg deleted file mode 100644 index d94f6fd5c4..0000000000 --- a/resources/icons/white/printer.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - diff --git a/resources/icons/white/re_slice.svg b/resources/icons/white/re_slice.svg deleted file mode 100644 index b8d7dc7271..0000000000 --- a/resources/icons/white/re_slice.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - diff --git a/resources/icons/white/redo_menu.svg b/resources/icons/white/redo_menu.svg deleted file mode 100644 index 749f49a421..0000000000 --- a/resources/icons/white/redo_menu.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - diff --git a/resources/icons/white/remove_copies.svg b/resources/icons/white/remove_copies.svg deleted file mode 100644 index 5b277e45e9..0000000000 --- a/resources/icons/white/remove_copies.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - diff --git a/resources/icons/white/remove_menu.svg b/resources/icons/white/remove_menu.svg deleted file mode 100644 index 59360a33f4..0000000000 --- a/resources/icons/white/remove_menu.svg +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - diff --git a/resources/icons/white/resin.svg b/resources/icons/white/resin.svg deleted file mode 100644 index 81abfae0ce..0000000000 --- a/resources/icons/white/resin.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - diff --git a/resources/icons/white/save.svg b/resources/icons/white/save.svg deleted file mode 100644 index 3349a42dd5..0000000000 --- a/resources/icons/white/save.svg +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/icons/white/search.svg b/resources/icons/white/search.svg deleted file mode 100644 index 679bb30f71..0000000000 --- a/resources/icons/white/search.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/resources/icons/white/set_separate_obj.svg b/resources/icons/white/set_separate_obj.svg deleted file mode 100644 index de083c1c99..0000000000 --- a/resources/icons/white/set_separate_obj.svg +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/resources/icons/white/skirt+brim.svg b/resources/icons/white/skirt+brim.svg deleted file mode 100644 index 684e177d25..0000000000 --- a/resources/icons/white/skirt+brim.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - diff --git a/resources/icons/white/sla_printer.svg b/resources/icons/white/sla_printer.svg deleted file mode 100644 index 3d47e7da62..0000000000 --- a/resources/icons/white/sla_printer.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - diff --git a/resources/icons/white/split_object_SMALL.svg b/resources/icons/white/split_object_SMALL.svg deleted file mode 100644 index 4795cab512..0000000000 --- a/resources/icons/white/split_object_SMALL.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - diff --git a/resources/icons/white/split_parts_SMALL.svg b/resources/icons/white/split_parts_SMALL.svg deleted file mode 100644 index eba846c17f..0000000000 --- a/resources/icons/white/split_parts_SMALL.svg +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - diff --git a/resources/icons/white/spool.svg b/resources/icons/white/spool.svg deleted file mode 100644 index 7c9fbab977..0000000000 --- a/resources/icons/white/spool.svg +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/resources/icons/white/support.svg b/resources/icons/white/support.svg deleted file mode 100644 index 52b7c6b40e..0000000000 --- a/resources/icons/white/support.svg +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/icons/white/support_blocker.svg b/resources/icons/white/support_blocker.svg deleted file mode 100644 index 17401e2ab2..0000000000 --- a/resources/icons/white/support_blocker.svg +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/icons/white/support_enforcer.svg b/resources/icons/white/support_enforcer.svg deleted file mode 100644 index 0de2dc6a79..0000000000 --- a/resources/icons/white/support_enforcer.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - diff --git a/resources/icons/white/switch_presets.svg b/resources/icons/white/switch_presets.svg deleted file mode 100644 index efcc3670cc..0000000000 --- a/resources/icons/white/switch_presets.svg +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/resources/icons/white/test.svg b/resources/icons/white/test.svg deleted file mode 100644 index 639bbbde8e..0000000000 --- a/resources/icons/white/test.svg +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/icons/white/time.svg b/resources/icons/white/time.svg deleted file mode 100644 index d014286b5a..0000000000 --- a/resources/icons/white/time.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - diff --git a/resources/icons/white/undo_menu.svg b/resources/icons/white/undo_menu.svg deleted file mode 100644 index 4e2b69a601..0000000000 --- a/resources/icons/white/undo_menu.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - diff --git a/resources/icons/white/upload_queue.svg b/resources/icons/white/upload_queue.svg deleted file mode 100644 index 710e2be89d..0000000000 --- a/resources/icons/white/upload_queue.svg +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/resources/icons/white/wrench.svg b/resources/icons/white/wrench.svg deleted file mode 100644 index 714c5a82af..0000000000 --- a/resources/icons/white/wrench.svg +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index e165c731ff..39c033df61 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -3164,11 +3164,11 @@ void PrintConfigDef::init_sla_params() // SLA Material settings. - def = this->add("material_colour", coStrings); + def = this->add("material_colour", coString); def->label = L("Color"); def->tooltip = L("This is only used in the Slic3r interface as a visual help."); def->gui_type = ConfigOptionDef::GUIType::color; - def->set_default_value(new ConfigOptionStrings{ "#29B2B2" }); + def->set_default_value(new ConfigOptionString("#29B2B2")); def = this->add("material_type", coString); def->label = L("SLA material type"); diff --git a/src/nanosvg/nanosvg.h b/src/nanosvg/nanosvg.h index b9063213e0..4eaff9dadc 100644 --- a/src/nanosvg/nanosvg.h +++ b/src/nanosvg/nanosvg.h @@ -165,6 +165,11 @@ typedef struct NSVGimage // Parses SVG file from a file, returns SVG image as paths. NSVGimage* nsvgParseFromFile(const char* filename, const char* units, float dpi); +// Parses SVG file from a file, returns SVG image as paths. +// And makes replases befor parsing +// replace_map containes old_value->new_value +NSVGimage* nsvgParseFromFileWithReplace(const char* filename, const char* units, float dpi, const std::map& replace_map); + // Parses SVG file from a null terminated string, returns SVG image as paths. // Important note: changes the string. NSVGimage* nsvgParse(char* input, const char* units, float dpi); @@ -189,6 +194,8 @@ void nsvgDelete(NSVGimage* image); #include #include +#include + #define NSVG_PI (3.14159265358979323846264338327f) #define NSVG_KAPPA90 (0.5522847493f) // Length proportional to radius of a cubic bezier handle for 90deg arcs. @@ -2901,6 +2908,12 @@ NSVGimage* nsvgParse(char* input, const char* units, float dpi) NSVGimage* nsvgParseFromFile(const char* filename, const char* units, float dpi) { + return nsvgParseFromFileWithReplace(filename, units, dpi, { {} }); +} + +NSVGimage* nsvgParseFromFileWithReplace(const char* filename, const char* units, float dpi, const std::map& replaces) +{ + std::string str; FILE* fp = NULL; size_t size; char* data = NULL; @@ -2916,9 +2929,16 @@ NSVGimage* nsvgParseFromFile(const char* filename, const char* units, float dpi) if (fread(data, 1, size, fp) != size) goto error; data[size] = '\0'; // Must be null terminated. fclose(fp); - image = nsvgParse(data, units, dpi); - free(data); + if(replaces.empty()) + image = nsvgParse(data, units, dpi); + else { + str.assign(data); + for (auto val : replaces) + boost::replace_all(str, val.first, val.second); + image = nsvgParse(str.data(), units, dpi); + } + free(data); return image; error: diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index 6e7174baff..6bceaec097 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -1136,15 +1136,11 @@ void GLVolumeCollection::update_colors_by_extruder(const DynamicPrintConfig* con if (static_cast(config->opt_int("printer_technology")) == ptSLA) { - const ConfigOptionStrings* resin_clr = dynamic_cast(config->option("material_colour")); - if (resin_clr == nullptr) - return; - assert(resin_clr->values.size() == 1); - colors.resize(1); - - const std::string& txt_color = config->opt_string("material_colour", 0); - if (Slic3r::GUI::BitmapCache::parse_color(txt_color, rgb)) + const std::string& txt_color = config->opt_string("material_colour"); + if (Slic3r::GUI::BitmapCache::parse_color(txt_color, rgb)) { + colors.resize(1); colors[0].set(txt_color, rgb); + } } else { diff --git a/src/slic3r/GUI/BitmapCache.cpp b/src/slic3r/GUI/BitmapCache.cpp index 2c756c3b95..749fc5ef28 100644 --- a/src/slic3r/GUI/BitmapCache.cpp +++ b/src/slic3r/GUI/BitmapCache.cpp @@ -261,51 +261,28 @@ wxBitmap* BitmapCache::load_png(const std::string &bitmap_name, unsigned width, } wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_width, unsigned target_height, - const bool grayscale/* = false*/, const bool dark_mode/* = false*/) + const bool grayscale/* = false*/, const bool dark_mode/* = false*/, const std::string& new_color /*= ""*/) { std::string bitmap_key = bitmap_name + ( target_height !=0 ? "-h" + std::to_string(target_height) : "-w" + std::to_string(target_width)) + (m_scale != 1.0f ? "-s" + float_to_string_decimal_point(m_scale) : "") - + (grayscale ? "-gs" : ""); + + (dark_mode ? "-dm" : "") + + (grayscale ? "-gs" : "") + + new_color; - /* For the Dark mode of any platform, we should draw icons in respect to OS background - * Note: All standard(regular) icons are collected in "icons" folder, - * SVG-icons, which have "Dark mode" variant, are collected in "icons/white" folder - */ - std::string folder; + auto it = m_map.find(bitmap_key); + if (it != m_map.end()) + return it->second; + + // map of color replaces + std::map replaces; if (dark_mode) - { -#ifdef __WXMSW__ - folder = "white\\"; -#else - folder = "white/"; -#endif - auto it = m_map.find(folder + bitmap_key); - if (it != m_map.end()) - return it->second; - // It's expensive to check if the bitmap exists every time, but otherwise: - // For the case, when application was started in Light mode and then switched to the Dark, - // we will never get a white bitmaps, if check m_map.find(bitmap_key) - // before boost::filesystem::exists(var(folder + bitmap_name + ".svg")) - if (!boost::filesystem::exists(var(folder + bitmap_name + ".svg"))) { - folder.clear(); - - it = m_map.find(bitmap_key); - if (it != m_map.end()) - return it->second; - } + replaces["#808080"] = "#FFFFFF"; + if (!new_color.empty()) + replaces["#ED6B21"] = new_color; - bitmap_key = folder + bitmap_key; - } - else - { - auto it = m_map.find(bitmap_key); - if (it != m_map.end()) - return it->second; - } - - NSVGimage *image = ::nsvgParseFromFile(Slic3r::var(folder + bitmap_name + ".svg").c_str(), "px", 96.0f); + NSVGimage *image = ::nsvgParseFromFileWithReplace(Slic3r::var(bitmap_name + ".svg").c_str(), "px", 96.0f, replaces); if (image == nullptr) return nullptr; diff --git a/src/slic3r/GUI/BitmapCache.hpp b/src/slic3r/GUI/BitmapCache.hpp index 8147de9963..5fa8643b5a 100644 --- a/src/slic3r/GUI/BitmapCache.hpp +++ b/src/slic3r/GUI/BitmapCache.hpp @@ -33,7 +33,7 @@ public: // Load png from resources/icons. bitmap_key is given without the .png suffix. Bitmap will be rescaled to provided height/width if nonzero. wxBitmap* load_png(const std::string &bitmap_key, unsigned width = 0, unsigned height = 0, const bool grayscale = false); // Load svg from resources/icons. bitmap_key is given without the .svg suffix. SVG will be rasterized to provided height/width. - wxBitmap* load_svg(const std::string &bitmap_key, unsigned width = 0, unsigned height = 0, const bool grayscale = false, const bool dark_mode = false); + wxBitmap* load_svg(const std::string &bitmap_key, unsigned width = 0, unsigned height = 0, const bool grayscale = false, const bool dark_mode = false, const std::string& new_color = ""); wxBitmap mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency, bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false); wxBitmap mksolid(size_t width, size_t height, const unsigned char rgb[3], bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false) { return mksolid(width, height, rgb[0], rgb[1], rgb[2], wxALPHA_OPAQUE, suppress_scaling, border_width, dark_mode); } diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index 52a03eabf2..0a5635630a 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -1320,7 +1320,7 @@ void ColourPicker::BUILD() if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit); // Validate the color - wxString clr_str(m_opt.get_default_value()->get_at(m_opt_idx)); + wxString clr_str(m_opt.type == coString ? m_opt.get_default_value()->value : m_opt.get_default_value()->get_at(m_opt_idx)); wxColour clr(clr_str); if (clr_str.IsEmpty() || !clr.IsOk()) { clr = wxTransparentColour; diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 1c8a362c01..90e67cd8ac 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -4197,7 +4197,7 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const shader->set_uniform("emission_factor", 0.0f); for (GLVolume* vol : visible_volumes) { - shader->set_uniform("uniform_color", (vol->printable && !vol->is_outside) ? orange : gray); + shader->set_uniform("uniform_color", (vol->printable && !vol->is_outside) ? (current_printer_technology() == ptSLA ? vol->color : orange) : gray); // the volume may have been deactivated by an active gizmo bool is_active = vol->is_active; vol->is_active = true; diff --git a/src/slic3r/GUI/ImGuiWrapper.cpp b/src/slic3r/GUI/ImGuiWrapper.cpp index 32fe71f678..08e53b829e 100644 --- a/src/slic3r/GUI/ImGuiWrapper.cpp +++ b/src/slic3r/GUI/ImGuiWrapper.cpp @@ -1017,15 +1017,7 @@ std::vector ImGuiWrapper::load_svg(const std::string& bitmap_name { std::vector empty_vector; -#ifdef __WXMSW__ - std::string folder = "white\\"; -#else - std::string folder = "white/"; -#endif - if (!boost::filesystem::exists(Slic3r::var(folder + bitmap_name + ".svg"))) - folder.clear(); - - NSVGimage* image = ::nsvgParseFromFile(Slic3r::var(folder + bitmap_name + ".svg").c_str(), "px", 96.0f); + NSVGimage* image = ::nsvgParseFromFileWithReplace(Slic3r::var(bitmap_name + ".svg").c_str(), "px", 96.0f, { { "#808080", "#FFFFFF" } }); if (image == nullptr) return empty_vector; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index fe8c72fea6..ca4e3e0577 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -6221,14 +6221,8 @@ void Plater::on_config_change(const DynamicPrintConfig &config) continue; } } - if (opt_key == "material_colour") { update_scheduled = true; // update should be scheduled (for update 3DScene) - - // update material color in full config - std::vector material_colors = { config.opt_string("material_colour", (unsigned)0) }; - p->config->option("material_colour")->values = material_colors; - continue; } p->config->set_key_value(opt_key, config.option(opt_key)->clone()); diff --git a/src/slic3r/GUI/PresetComboBoxes.cpp b/src/slic3r/GUI/PresetComboBoxes.cpp index 5da3594582..acae695d2e 100644 --- a/src/slic3r/GUI/PresetComboBoxes.cpp +++ b/src/slic3r/GUI/PresetComboBoxes.cpp @@ -419,7 +419,7 @@ wxString PresetComboBox::separator(const std::string& label) wxBitmap* PresetComboBox::get_bmp( std::string bitmap_key, bool wide_icons, const std::string& main_icon_name, bool is_compatible/* = true*/, bool is_system/* = false*/, bool is_single_bar/* = false*/, - std::string filament_rgb/* = ""*/, std::string extruder_rgb/* = ""*/) + const std::string& filament_rgb/* = ""*/, const std::string& extruder_rgb/* = ""*/, const std::string& material_rgb/* = ""*/) { // If the filament preset is not compatible and there is a "red flag" icon loaded, show it left // to the filament color image. @@ -431,6 +431,7 @@ wxBitmap* PresetComboBox::get_bmp( std::string bitmap_key, bool wide_icons, con bool dark_mode = wxGetApp().dark_mode(); if (dark_mode) bitmap_key += ",dark"; + bitmap_key += material_rgb; wxBitmap* bmp = bitmap_cache().find(bitmap_key); if (bmp == nullptr) { @@ -457,7 +458,10 @@ wxBitmap* PresetComboBox::get_bmp( std::string bitmap_key, bool wide_icons, con { // Paint the color bars. bmps.emplace_back(bitmap_cache().mkclear(thin_space_icon_width, icon_height)); - bmps.emplace_back(create_scaled_bitmap(main_icon_name)); + if (m_type == Preset::TYPE_SLA_MATERIAL) + bmps.emplace_back(create_scaled_bitmap(main_icon_name, this, 16, false, material_rgb)); + else + bmps.emplace_back(create_scaled_bitmap(main_icon_name)); // Paint a lock at the system presets. bmps.emplace_back(bitmap_cache().mkclear(wide_space_icon_width, icon_height)); } @@ -789,7 +793,7 @@ void PlaterPresetComboBox::update() if (!preset.is_visible || (!preset.is_compatible && !is_selected)) continue; - std::string bitmap_key, filament_rgb, extruder_rgb; + std::string bitmap_key, filament_rgb, extruder_rgb, material_rgb; std::string bitmap_type_name = bitmap_key = m_type == Preset::TYPE_PRINTER && preset.printer_technology() == ptSLA ? "sla_printer" : m_main_bitmap_name; bool single_bar = false; @@ -803,10 +807,12 @@ void PlaterPresetComboBox::update() bitmap_key += single_bar ? filament_rgb : filament_rgb + extruder_rgb; } + else if (m_type == Preset::TYPE_SLA_MATERIAL) + material_rgb = is_selected ? m_preset_bundle->sla_materials.get_edited_preset().config.opt_string("material_colour") : preset.config.opt_string("material_colour"); wxBitmap* bmp = get_bmp(bitmap_key, wide_icons, bitmap_type_name, preset.is_compatible, preset.is_system || preset.is_default, - single_bar, filament_rgb, extruder_rgb); + single_bar, filament_rgb, extruder_rgb, material_rgb); assert(bmp); const std::string name = preset.alias.empty() ? preset.name : preset.alias; diff --git a/src/slic3r/GUI/PresetComboBoxes.hpp b/src/slic3r/GUI/PresetComboBoxes.hpp index f6a6eb3e83..654f836c54 100644 --- a/src/slic3r/GUI/PresetComboBoxes.hpp +++ b/src/slic3r/GUI/PresetComboBoxes.hpp @@ -122,7 +122,7 @@ protected: wxBitmap* get_bmp( std::string bitmap_key, bool wide_icons, const std::string& main_icon_name, bool is_compatible = true, bool is_system = false, bool is_single_bar = false, - std::string filament_rgb = "", std::string extruder_rgb = ""); + const std::string& filament_rgb = "", const std::string& extruder_rgb = "", const std::string& material_rgb = ""); wxBitmap* get_bmp( std::string bitmap_key, const std::string& main_icon_name, const std::string& next_icon_name, bool is_enabled = true, bool is_compatible = true, bool is_system = false); diff --git a/src/slic3r/GUI/wxExtensions.cpp b/src/slic3r/GUI/wxExtensions.cpp index 5e703a37b5..8aead7a7ca 100644 --- a/src/slic3r/GUI/wxExtensions.cpp +++ b/src/slic3r/GUI/wxExtensions.cpp @@ -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 get_extruder_color_icons(bool thin_icon/* = false*/) { static Slic3r::GUI::BitmapCache bmp_cache; diff --git a/src/slic3r/GUI/wxExtensions.hpp b/src/slic3r/GUI/wxExtensions.hpp index 25876bd235..f78621a5c0 100644 --- a/src/slic3r/GUI/wxExtensions.hpp +++ b/src/slic3r/GUI/wxExtensions.hpp @@ -51,7 +51,9 @@ int mode_icon_px_size(); wxBitmap create_menu_bitmap(const std::string& bmp_name); wxBitmap create_scaled_bitmap(const std::string& bmp_name, wxWindow *win = nullptr, - const int px_cnt = 16, const bool grayscale = false, const bool menu_bitmap = false); + 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); std::vector get_extruder_color_icons(bool thin_icon = false); From a3f6ce1ac6a37c10e078672215c93bc0d705cab0 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 10 Nov 2021 10:49:43 +0100 Subject: [PATCH 2/6] MsgDialog: Some code refactoring. Use style for whole Dialog instead of wxWindowID for just one default button --- src/slic3r/GUI/GUI_App.cpp | 2 +- src/slic3r/GUI/MsgDialog.cpp | 36 ++++++++++++-------------------- src/slic3r/GUI/MsgDialog.hpp | 3 +-- src/slic3r/GUI/Plater.cpp | 4 ++-- src/slic3r/GUI/UpdateDialogs.cpp | 23 +++++++------------- 5 files changed, 24 insertions(+), 44 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 9c16a782e3..9e92f1ac98 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -865,7 +865,7 @@ bool GUI_App::check_older_app_config(Semver current_version, bool backup) "\n\nIf you select yes, PrusaSlicer will copy all profiles and other files from found folder to the current one." "\nIf you select no, you will start with clean installation with configuration wizard.") , m_older_data_dir_path, last_semver.to_string()) - , _L("PrusaSlicer"), wxICON_QUESTION | wxYES_NO); + , _L("PrusaSlicer"), /*wxICON_QUESTION | */wxYES_NO); if (msg.ShowModal() == wxID_YES) { std::string snapshot_id; if (backup) { diff --git a/src/slic3r/GUI/MsgDialog.cpp b/src/slic3r/GUI/MsgDialog.cpp index 2515f0281b..1cf5224174 100644 --- a/src/slic3r/GUI/MsgDialog.cpp +++ b/src/slic3r/GUI/MsgDialog.cpp @@ -25,7 +25,7 @@ namespace Slic3r { namespace GUI { -MsgDialog::MsgDialog(wxWindow *parent, const wxString &title, const wxString &headline, wxWindowID button_id, wxBitmap bitmap) +MsgDialog::MsgDialog(wxWindow *parent, const wxString &title, const wxString &headline, long style, wxBitmap bitmap) : wxDialog(parent ? parent : dynamic_cast(wxGetApp().mainframe), wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) , boldfont(wxGetApp().normal_font()) , content_sizer(new wxBoxSizer(wxVERTICAL)) @@ -49,12 +49,6 @@ MsgDialog::MsgDialog(wxWindow *parent, const wxString &title, const wxString &he rightsizer->Add(content_sizer, 1, wxEXPAND); btn_sizer->AddStretchSpacer(); - if (button_id != wxID_NONE) { - auto *button = new wxButton(this, button_id); - button->SetFocus(); - btn_sizer->Add(button); - } - logo = new wxStaticBitmap(this, wxID_ANY, bitmap.IsOk() ? bitmap : wxNullBitmap); topsizer->Add(logo, 0, wxALL, BORDER); @@ -64,6 +58,8 @@ MsgDialog::MsgDialog(wxWindow *parent, const wxString &title, const wxString &he main_sizer->Add(new StaticLine(this), 0, wxEXPAND | wxLEFT | wxRIGHT, HORIZ_SPACING); main_sizer->Add(btn_sizer, 0, wxALL | wxEXPAND, VERT_SPACING); + apply_style(style); + SetSizerAndFit(main_sizer); } @@ -83,9 +79,9 @@ void MsgDialog::apply_style(long style) if (style & wxNO) add_btn(wxID_NO); if (style & wxCANCEL) add_btn(wxID_CANCEL); - logo->SetBitmap(create_scaled_bitmap(style & wxICON_WARNING ? "exclamation" : - style & wxICON_INFORMATION ? "info" : - style & wxICON_QUESTION ? "question" : "PrusaSlicer"/*"_192px_grayscale.png"*/, this, 84)); + logo->SetBitmap( create_scaled_bitmap(style & wxICON_WARNING ? "exclamation" : + style & wxICON_INFORMATION ? "info" : + style & wxICON_QUESTION ? "question" : "PrusaSlicer", this, 64, style & wxICON_ERROR)); } void MsgDialog::finalize() @@ -161,18 +157,17 @@ static void add_msg_content(wxWindow* parent, wxBoxSizer* content_sizer, wxStrin msg_escaped = std::string("
") + msg_escaped + "
"; html->SetPage("" + wxString::FromUTF8(msg_escaped.data()) + ""); content_sizer->Add(html, 1, wxEXPAND); + wxGetApp().UpdateDarkUI(html); } // ErrorDialog ErrorDialog::ErrorDialog(wxWindow *parent, const wxString &msg, bool monospaced_font) : MsgDialog(parent, wxString::Format(_(L("%s error")), SLIC3R_APP_NAME), - wxString::Format(_(L("%s has encountered an error")), SLIC3R_APP_NAME), - wxID_NONE) + wxString::Format(_(L("%s has encountered an error")), SLIC3R_APP_NAME), wxOK) , msg(msg) { add_msg_content(this, content_sizer, msg, monospaced_font); - add_btn(wxID_OK, true); // Use a small bitmap with monospaced font, as the error text will not be wrapped. logo->SetBitmap(create_scaled_bitmap("PrusaSlicer_192px_grayscale.png", this, monospaced_font ? 48 : /*1*/84)); @@ -189,10 +184,9 @@ WarningDialog::WarningDialog(wxWindow *parent, const wxString& caption/* = wxEmptyString*/, long style/* = wxOK*/) : MsgDialog(parent, caption.IsEmpty() ? wxString::Format(_L("%s warning"), SLIC3R_APP_NAME) : caption, - wxString::Format(_L("%s has a warning")+":", SLIC3R_APP_NAME), wxID_NONE) + wxString::Format(_L("%s has a warning")+":", SLIC3R_APP_NAME), style) { add_msg_content(this, content_sizer, message); - apply_style(style); finalize(); } @@ -203,10 +197,9 @@ MessageDialog::MessageDialog(wxWindow* parent, const wxString& message, const wxString& caption/* = wxEmptyString*/, long style/* = wxOK*/) - : MsgDialog(parent, caption.IsEmpty() ? wxString::Format(_L("%s info"), SLIC3R_APP_NAME) : caption, wxEmptyString, wxID_NONE) + : MsgDialog(parent, caption.IsEmpty() ? wxString::Format(_L("%s info"), SLIC3R_APP_NAME) : caption, wxEmptyString, style) { add_msg_content(this, content_sizer, message); - apply_style(style); finalize(); } @@ -217,16 +210,16 @@ RichMessageDialog::RichMessageDialog(wxWindow* parent, const wxString& message, const wxString& caption/* = wxEmptyString*/, long style/* = wxOK*/) - : MsgDialog(parent, caption.IsEmpty() ? wxString::Format(_L("%s info"), SLIC3R_APP_NAME) : caption, wxEmptyString, wxID_NONE) + : MsgDialog(parent, caption.IsEmpty() ? wxString::Format(_L("%s info"), SLIC3R_APP_NAME) : caption, wxEmptyString, style) { add_msg_content(this, content_sizer, message); m_checkBox = new wxCheckBox(this, wxID_ANY, m_checkBoxText); + wxGetApp().UpdateDarkUI(m_checkBox); m_checkBox->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent&) { m_checkBoxValue = m_checkBox->GetValue(); }); btn_sizer->Insert(0, m_checkBox, wxALIGN_CENTER_VERTICAL); - apply_style(style); finalize(); } @@ -245,13 +238,10 @@ int RichMessageDialog::ShowModal() // InfoDialog InfoDialog::InfoDialog(wxWindow* parent, const wxString &title, const wxString& msg) - : MsgDialog(parent, wxString::Format(_L("%s information"), SLIC3R_APP_NAME), title) + : MsgDialog(parent, wxString::Format(_L("%s information"), SLIC3R_APP_NAME), title, wxOK | wxICON_INFORMATION) , msg(msg) { add_msg_content(this, content_sizer, msg); - // Set info bitmap - logo->SetBitmap(create_scaled_bitmap("info", this, 84)); - finalize(); } diff --git a/src/slic3r/GUI/MsgDialog.hpp b/src/slic3r/GUI/MsgDialog.hpp index a4807fd06d..e49c29b857 100644 --- a/src/slic3r/GUI/MsgDialog.hpp +++ b/src/slic3r/GUI/MsgDialog.hpp @@ -41,8 +41,7 @@ protected: HORIZ_SPACING = 5, }; - // button_id is an id of a button that can be added by default, use wxID_NONE to disable - MsgDialog(wxWindow *parent, const wxString &title, const wxString &headline, wxWindowID button_id = wxID_OK, wxBitmap bitmap = wxNullBitmap); + MsgDialog(wxWindow *parent, const wxString &title, const wxString &headline, long style = wxOK, wxBitmap bitmap = wxNullBitmap); void add_btn(wxWindowID btn_id, bool set_focus = false); void apply_style(long style); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index ca4e3e0577..a85c4b0a04 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2487,7 +2487,7 @@ std::vector Plater::priv::load_files(const std::vector& input_ "The internal unit of PrusaSlicer are millimeters. Do you want to recalculate the dimensions of the object?", "The dimensions of some objects from file %s seem to be defined in meters.\n" "The internal unit of PrusaSlicer are millimeters. Do you want to recalculate the dimensions of these objects?", model.objects.size()), from_path(filename)) + "\n", - _L("The object is too small"), wxICON_WARNING | wxYES | wxNO); + _L("The object is too small"), wxICON_QUESTION | wxYES_NO); dlg.ShowCheckBox(_L("Apply to all the remaining small objects being loaded.")); int answer = dlg.ShowModal(); if (dlg.IsCheckBoxChecked()) @@ -2509,7 +2509,7 @@ std::vector Plater::priv::load_files(const std::vector& input_ "The internal unit of PrusaSlicer are millimeters. Do you want to recalculate the dimensions of the object?", "The dimensions of some objects from file %s seem to be defined in inches.\n" "The internal unit of PrusaSlicer are millimeters. Do you want to recalculate the dimensions of these objects?", model.objects.size()), from_path(filename)) + "\n", - _L("The object is too small"), wxICON_WARNING | wxYES | wxNO); + _L("The object is too small"), wxICON_QUESTION | wxYES_NO); dlg.ShowCheckBox(_L("Apply to all the remaining small objects being loaded.")); int answer = dlg.ShowModal(); if (dlg.IsCheckBoxChecked()) diff --git a/src/slic3r/GUI/UpdateDialogs.cpp b/src/slic3r/GUI/UpdateDialogs.cpp index de132b1848..d617ca6608 100644 --- a/src/slic3r/GUI/UpdateDialogs.cpp +++ b/src/slic3r/GUI/UpdateDialogs.cpp @@ -156,7 +156,7 @@ MsgUpdateConfig::~MsgUpdateConfig() {} //MsgUpdateForced MsgUpdateForced::MsgUpdateForced(const std::vector& updates) : - MsgDialog(nullptr, wxString::Format(_(L("%s incompatibility")), SLIC3R_APP_NAME), _(L("You must install a configuration update.")) + " ", wxID_NONE) + MsgDialog(nullptr, wxString::Format(_(L("%s incompatibility")), SLIC3R_APP_NAME), _(L("You must install a configuration update.")) + " ", wxICON_ERROR) { auto* text = new wxStaticText(this, wxID_ANY, wxString::Format(_(L( "%s will now start updates. Otherwise it won't be able to start.\n\n" @@ -165,7 +165,6 @@ MsgUpdateForced::MsgUpdateForced(const std::vector& updates) : "Updated configuration bundles:" )), SLIC3R_APP_NAME)); - logo->SetBitmap(create_scaled_bitmap("PrusaSlicer_192px_grayscale.png", this, 192)); text->Wrap(CONTENT_WIDTH * wxGetApp().em_unit()); content_sizer->Add(text); @@ -210,7 +209,7 @@ MsgUpdateForced::MsgUpdateForced(const std::vector& updates) : btn_exit->Bind(wxEVT_BUTTON, exiter); btn_ok->Bind(wxEVT_BUTTON, exiter); - Fit(); + finalize(); } MsgUpdateForced::~MsgUpdateForced() {} @@ -219,10 +218,8 @@ MsgUpdateForced::~MsgUpdateForced() {} MsgDataIncompatible::MsgDataIncompatible(const std::unordered_map &incompats) : MsgDialog(nullptr, wxString::Format(_(L("%s incompatibility")), SLIC3R_APP_NAME), - wxString::Format(_(L("%s configuration is incompatible")), SLIC3R_APP_NAME), wxID_NONE) + wxString::Format(_(L("%s configuration is incompatible")), SLIC3R_APP_NAME), /*wxID_NONE | */wxICON_ERROR) { - logo->SetBitmap(create_scaled_bitmap("PrusaSlicer_192px_grayscale.png", this, 192)); - auto *text = new wxStaticText(this, wxID_ANY, wxString::Format(_(L( "This version of %s is not compatible with currently installed configuration bundles.\n" "This probably happened as a result of running an older %s after using a newer one.\n\n" @@ -265,7 +262,7 @@ MsgDataIncompatible::MsgDataIncompatible(const std::unordered_mapBind(wxEVT_BUTTON, exiter); btn_reconf->Bind(wxEVT_BUTTON, exiter); - Fit(); + finalize(); } MsgDataIncompatible::~MsgDataIncompatible() {} @@ -303,9 +300,7 @@ MsgDataLegacy::MsgDataLegacy() : content_sizer->Add(link); content_sizer->AddSpacer(VERT_SPACING); - wxGetApp().UpdateDlgDarkUI(this); - - Fit(); + finalize(); } MsgDataLegacy::~MsgDataLegacy() {} @@ -314,7 +309,7 @@ MsgDataLegacy::~MsgDataLegacy() {} // MsgNoUpdate MsgNoUpdates::MsgNoUpdates() : - MsgDialog(nullptr, _(L("Configuration updates")), _(L("No updates available"))) + MsgDialog(nullptr, _(L("Configuration updates")), _(L("No updates available")), wxICON_ERROR) { auto* text = new wxStaticText(this, wxID_ANY, wxString::Format( @@ -327,11 +322,7 @@ MsgNoUpdates::MsgNoUpdates() : content_sizer->Add(text); content_sizer->AddSpacer(VERT_SPACING); - logo->SetBitmap(create_scaled_bitmap("PrusaSlicer_192px_grayscale.png", this, 192)); - - wxGetApp().UpdateDlgDarkUI(this); - - Fit(); + finalize(); } MsgNoUpdates::~MsgNoUpdates() {} From bfa91cbd9535c2edba914a48fd81eec6c7c2ce0f Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 9 Nov 2021 17:14:54 +0100 Subject: [PATCH 3/6] Windows: Include blacklisted libraries in SendSystemInfo data --- src/slic3r/GUI/SendSystemInfoDialog.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/slic3r/GUI/SendSystemInfoDialog.cpp b/src/slic3r/GUI/SendSystemInfoDialog.cpp index da6e57f888..4b11347e23 100644 --- a/src/slic3r/GUI/SendSystemInfoDialog.cpp +++ b/src/slic3r/GUI/SendSystemInfoDialog.cpp @@ -1,6 +1,7 @@ #include "SendSystemInfoDialog.hpp" #include "libslic3r/AppConfig.hpp" +#include "libslic3r/BlacklistedLibraryCheck.hpp" #include "libslic3r/Platform.hpp" #include "libslic3r/Utils.hpp" @@ -479,6 +480,29 @@ static std::string generate_system_info_json() hw_node.add_child("Monitors", monitors_node); data_node.add_child("Hardware", hw_node); +#ifdef _WIN32 + { + pt::ptree blacklisted_node; + std::vector blacklisted_libraries; + BlacklistedLibraryCheck::get_instance().get_blacklisted(blacklisted_libraries); + for (const std::wstring& str : blacklisted_libraries) { + std::string utf8; + const size_t num_bytes = WideCharToMultiByte(CP_UTF8, 0, str.c_str(), str.size(), utf8.data(), 0, 0, 0); + utf8.resize(num_bytes); + if (WideCharToMultiByte(CP_UTF8, 0, str.c_str(), str.size(), utf8.data(), num_bytes, 0, 0)) { + if (size_t last_bs_pos = utf8.find_last_of("\\"); last_bs_pos < utf8.size() - 1) { + // Remove anything before last backslash so we don't send the path to the DLL. + utf8.erase(0, last_bs_pos + 1); + } + pt::ptree node; // Create an unnamed node containing the value + node.put("", utf8); + blacklisted_node.push_back(std::make_pair("", node)); // Add this node to the list. + } + } + data_node.add_child("Blacklisted libraries", blacklisted_node); + } +#endif // _WIN32 + pt::ptree opengl_node; opengl_node.put("Version", OpenGLManager::get_gl_info().get_version()); opengl_node.put("GLSLVersion", OpenGLManager::get_gl_info().get_glsl_version()); From de1785760c613c757c4aa8c69118903220a445d1 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 10 Nov 2021 11:30:48 +0100 Subject: [PATCH 4/6] Follow up https://github.com/prusa3d/PrusaSlicer/commit/e8be7b2ecd3a21676af73805f96157f37418f8e5 - Remove unused code --- src/slic3r/GUI/wxExtensions.cpp | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/src/slic3r/GUI/wxExtensions.cpp b/src/slic3r/GUI/wxExtensions.cpp index 8aead7a7ca..01a553a81a 100644 --- a/src/slic3r/GUI/wxExtensions.cpp +++ b/src/slic3r/GUI/wxExtensions.cpp @@ -460,33 +460,6 @@ 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 get_extruder_color_icons(bool thin_icon/* = false*/) { static Slic3r::GUI::BitmapCache bmp_cache; From 8915d8bc91d243c56f2ed73d3aca6eef946c35f5 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 10 Nov 2021 11:37:49 +0100 Subject: [PATCH 5/6] Improvement of previous commit: - use boost::nowide instead of WinAPI for the encoding conversion - only add the node when it is not empty --- src/slic3r/GUI/SendSystemInfoDialog.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/slic3r/GUI/SendSystemInfoDialog.cpp b/src/slic3r/GUI/SendSystemInfoDialog.cpp index 4b11347e23..fb3205af3c 100644 --- a/src/slic3r/GUI/SendSystemInfoDialog.cpp +++ b/src/slic3r/GUI/SendSystemInfoDialog.cpp @@ -485,21 +485,18 @@ static std::string generate_system_info_json() pt::ptree blacklisted_node; std::vector blacklisted_libraries; BlacklistedLibraryCheck::get_instance().get_blacklisted(blacklisted_libraries); - for (const std::wstring& str : blacklisted_libraries) { - std::string utf8; - const size_t num_bytes = WideCharToMultiByte(CP_UTF8, 0, str.c_str(), str.size(), utf8.data(), 0, 0, 0); - utf8.resize(num_bytes); - if (WideCharToMultiByte(CP_UTF8, 0, str.c_str(), str.size(), utf8.data(), num_bytes, 0, 0)) { - if (size_t last_bs_pos = utf8.find_last_of("\\"); last_bs_pos < utf8.size() - 1) { - // Remove anything before last backslash so we don't send the path to the DLL. - utf8.erase(0, last_bs_pos + 1); - } - pt::ptree node; // Create an unnamed node containing the value - node.put("", utf8); - blacklisted_node.push_back(std::make_pair("", node)); // Add this node to the list. + for (const std::wstring& wstr : blacklisted_libraries) { + std::string utf8 = boost::nowide::narrow(wstr); + if (size_t last_bs_pos = utf8.find_last_of("\\"); last_bs_pos < utf8.size() - 1) { + // Remove anything before last backslash so we don't send the path to the DLL. + utf8.erase(0, last_bs_pos + 1); } + pt::ptree node; // Create an unnamed node containing the value + node.put("", utf8); + blacklisted_node.push_back(std::make_pair("", node)); // Add this node to the list. } - data_node.add_child("Blacklisted libraries", blacklisted_node); + if (! blacklisted_libraries.empty()) + data_node.add_child("Blacklisted libraries", blacklisted_node); } #endif // _WIN32 From f7db7c0a26a11a095536df3f0d47064f28b2011f Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Wed, 10 Nov 2021 12:07:43 +0100 Subject: [PATCH 6/6] #7282 - Fixed crash after splitting object into parts (missing or degenerate convex hulls) --- src/libslic3r/Model.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index e88188b449..55ca4b8da3 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -1860,18 +1860,17 @@ size_t ModelVolume::split(unsigned int max_extruders) size_t idx = 0; size_t ivolume = std::find(this->object->volumes.begin(), this->object->volumes.end(), this) - this->object->volumes.begin(); - std::string name = this->name; + const std::string name = this->name; unsigned int extruder_counter = 0; - Vec3d offset = this->get_offset(); + const Vec3d offset = this->get_offset(); for (TriangleMesh &mesh : meshes) { if (mesh.empty()) // Repair may have removed unconnected triangles, thus emptying the mesh. continue; - if (idx == 0) - { + if (idx == 0) { this->set_mesh(std::move(mesh)); this->calculate_convex_hull(); // Assign a new unique ID, so that a new GLVolume will be generated. @@ -1890,7 +1889,19 @@ size_t ModelVolume::split(unsigned int max_extruders) this->object->volumes[ivolume]->m_is_splittable = 0; ++ idx; } - + + // discard volumes for which the convex hull was not generated or is degenerate + size_t i = 0; + while (i < this->object->volumes.size()) { + std::shared_ptr hull = this->object->volumes[i]->get_convex_hull_shared_ptr(); + if (hull == nullptr || hull->its.vertices.empty() || hull->its.indices.empty()) { + this->object->delete_volume(i); + --idx; + --i; + } + ++i; + } + return idx; }