From 4b4d1c2f2a208d9647f17d2dcc5bf9f53d74f33f Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Wed, 19 Jan 2022 12:08:00 +0100 Subject: [PATCH 1/7] #7773 - Fixed GCodeReader::parse_line_internal() to skip whitespaces between axis digit and axis value --- src/libslic3r/GCodeReader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libslic3r/GCodeReader.cpp b/src/libslic3r/GCodeReader.cpp index aa04e69f2a..0fd09d920c 100644 --- a/src/libslic3r/GCodeReader.cpp +++ b/src/libslic3r/GCodeReader.cpp @@ -74,7 +74,7 @@ const char* GCodeReader::parse_line_internal(const char *ptr, const char *end, G if (axis != NUM_AXES_WITH_UNKNOWN) { // Try to parse the numeric value. double v; - auto [pend, ec] = fast_float::from_chars(++ c, end, v); + auto [pend, ec] = fast_float::from_chars(c, end, v); if (pend != c && is_end_of_word(*pend)) { // The axis value has been parsed correctly. if (axis != UNKNOWN_AXIS) From ab171441aaa9d0206f22ff45f590fc9015cea47a Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Wed, 19 Jan 2022 13:26:58 +0100 Subject: [PATCH 2/7] Follow-up of 4b4d1c2f2a208d9647f17d2dcc5bf9f53d74f33f - Restored line deleted by mistake --- src/libslic3r/GCodeReader.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libslic3r/GCodeReader.cpp b/src/libslic3r/GCodeReader.cpp index 0fd09d920c..c8a9b790fc 100644 --- a/src/libslic3r/GCodeReader.cpp +++ b/src/libslic3r/GCodeReader.cpp @@ -74,6 +74,7 @@ const char* GCodeReader::parse_line_internal(const char *ptr, const char *end, G if (axis != NUM_AXES_WITH_UNKNOWN) { // Try to parse the numeric value. double v; + c = skip_whitespaces(++c); auto [pend, ec] = fast_float::from_chars(c, end, v); if (pend != c && is_end_of_word(*pend)) { // The axis value has been parsed correctly. From 6b83ded66916843d9581c179133d03a3633f5b7b Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 19 Jan 2022 15:01:35 +0100 Subject: [PATCH 3/7] LockButton: Deleted unnecessary call of UpdateDarkUI() + Added some smarter update on SetLock() --- src/slic3r/GUI/wxExtensions.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/wxExtensions.cpp b/src/slic3r/GUI/wxExtensions.cpp index 01a553a81a..273bebdfb6 100644 --- a/src/slic3r/GUI/wxExtensions.cpp +++ b/src/slic3r/GUI/wxExtensions.cpp @@ -587,8 +587,10 @@ void LockButton::OnButton(wxCommandEvent& event) void LockButton::SetLock(bool lock) { - m_is_pushed = lock; - update_button_bitmaps(); + if (m_is_pushed != lock) { + m_is_pushed = lock; + update_button_bitmaps(); + } } void LockButton::msw_rescale() @@ -603,7 +605,6 @@ void LockButton::msw_rescale() void LockButton::update_button_bitmaps() { - Slic3r::GUI::wxGetApp().UpdateDarkUI(this); SetBitmap(m_is_pushed ? m_bmp_lock_closed.bmp() : m_bmp_lock_open.bmp()); SetBitmapHover(m_is_pushed ? m_bmp_lock_closed_f.bmp() : m_bmp_lock_open_f.bmp()); From 667842ec8b2eb544887465acd7879d08621d35b5 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 19 Jan 2022 15:16:00 +0100 Subject: [PATCH 4/7] Implemented get_wraped_wxString() to wrap the message text inside the MessageDialog and RichMessageDialog --- src/slic3r/GUI/MsgDialog.cpp | 41 ++++++++++++++++++++++++++++++++++-- src/slic3r/GUI/MsgDialog.hpp | 6 ++++-- src/slic3r/GUI/Plater.cpp | 2 +- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/MsgDialog.cpp b/src/slic3r/GUI/MsgDialog.cpp index 4b0a9d8639..622b8d9307 100644 --- a/src/slic3r/GUI/MsgDialog.cpp +++ b/src/slic3r/GUI/MsgDialog.cpp @@ -245,7 +245,7 @@ MessageDialog::MessageDialog(wxWindow* parent, long style/* = wxOK*/) : MsgDialog(parent, caption.IsEmpty() ? wxString::Format(_L("%s info"), SLIC3R_APP_NAME) : caption, wxEmptyString, style) { - add_msg_content(this, content_sizer, message); + add_msg_content(this, content_sizer, get_wraped_wxString(message)); finalize(); } @@ -258,7 +258,7 @@ RichMessageDialog::RichMessageDialog(wxWindow* parent, long style/* = wxOK*/) : MsgDialog(parent, caption.IsEmpty() ? wxString::Format(_L("%s info"), SLIC3R_APP_NAME) : caption, wxEmptyString, style) { - add_msg_content(this, content_sizer, message); + add_msg_content(this, content_sizer, get_wraped_wxString(message)); m_checkBox = new wxCheckBox(this, wxID_ANY, m_checkBoxText); wxGetApp().UpdateDarkUI(m_checkBox); @@ -291,6 +291,43 @@ InfoDialog::InfoDialog(wxWindow* parent, const wxString &title, const wxString& finalize(); } +wxString get_wraped_wxString(const wxString& text_in, size_t line_len /*=80*/) +{ +#ifdef __WXMSW__ + char slash = '\\'; +#else + char slash = '/'; +#endif + char space = ' '; + char new_line = '\n'; + + wxString text = text_in; + + int idx = -1; + size_t cur_len = 0; + size_t text_len = text.Len(); + + for (size_t i = 0; i < text_len; i++) { + cur_len++; + if (text[i] == space || text[i] == slash) + idx = i; + if (text[i] == new_line) { + idx = -1; + cur_len = 0; + continue; + } + if (cur_len >= line_len && idx >= 0) { + if (text[idx] == slash) { + text.insert(static_cast(idx) + 1, 1, new_line); + text_len++; + } + else // space + text[idx] = new_line; + cur_len = i - static_cast(idx); + } + } + return text; +} } } diff --git a/src/slic3r/GUI/MsgDialog.hpp b/src/slic3r/GUI/MsgDialog.hpp index 17d9354950..874629343f 100644 --- a/src/slic3r/GUI/MsgDialog.hpp +++ b/src/slic3r/GUI/MsgDialog.hpp @@ -89,6 +89,8 @@ public: virtual ~WarningDialog() = default; }; +wxString get_wraped_wxString(const wxString& text_in, size_t line_len = 80); + #ifdef _WIN32 // Generic static line, used intead of wxStaticLine class StaticLine: public wxTextCtrl @@ -283,7 +285,7 @@ public: const wxString& message, const wxString& caption = wxEmptyString, long style = wxOK) - : wxMessageDialog(parent, message, caption, style) {} + : wxMessageDialog(parent, get_wraped_wxString(message), caption, style) {} ~MessageDialog() {} }; @@ -295,7 +297,7 @@ public: const wxString& message, const wxString& caption = wxEmptyString, long style = wxOK) - : wxRichMessageDialog(parent, message, caption, style) { + : wxRichMessageDialog(parent, get_wraped_wxString(message), caption, style) { this->SetEscapeId(wxID_CANCEL); } ~RichMessageDialog() {} diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 2a4ba6f48a..26aef38ff2 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -5265,7 +5265,7 @@ ProjectDropDialog::ProjectDropDialog(const std::string& filename) _L("Import config only") }; main_sizer->Add(new wxStaticText(this, wxID_ANY, - _L("Select an action to apply to the file") + ": " + from_u8(filename)), 0, wxEXPAND | wxALL, 10); + get_wraped_wxString(_L("Select an action to apply to the file") + ": " + from_u8(filename))), 0, wxEXPAND | wxALL, 10); m_action = std::clamp(std::stoi(wxGetApp().app_config->get("drop_project_action")), static_cast(LoadType::OpenProject), static_cast(LoadType::LoadConfig)) - 1; From 06cca525d020cadf8dc2cd99b545c208cb6678f0 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 19 Jan 2022 15:16:23 +0100 Subject: [PATCH 5/7] Added a missing include for gcc --- src/libslic3r/GCode/FindReplace.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libslic3r/GCode/FindReplace.cpp b/src/libslic3r/GCode/FindReplace.cpp index ee21a249ab..334bd740ea 100644 --- a/src/libslic3r/GCode/FindReplace.cpp +++ b/src/libslic3r/GCode/FindReplace.cpp @@ -2,6 +2,7 @@ #include "../Utils.hpp" #include // isalpha +#include namespace Slic3r { From e0883910dd6c89568b68b7a8d1a5445c53864e9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hejl?= Date: Wed, 19 Jan 2022 15:35:07 +0100 Subject: [PATCH 6/7] Added a missing include (Clang 12 without PCH). --- src/libslic3r/LocalesUtils.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libslic3r/LocalesUtils.cpp b/src/libslic3r/LocalesUtils.cpp index d321072335..da372ba3fd 100644 --- a/src/libslic3r/LocalesUtils.cpp +++ b/src/libslic3r/LocalesUtils.cpp @@ -4,6 +4,7 @@ #include #endif #include +#include #include From ded855d0c279f0544eb2f33106a4d6ec7fa770bb Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 20 Jan 2022 10:06:15 +0100 Subject: [PATCH 7/7] Fix for #7781 - Entering value in Thumbnail setting causes PrusaSlicer to crash Follow-up 106e520a - During code refactoring "thumbnails" option wasn't correctly processed --- src/libslic3r/Preset.cpp | 1 + src/slic3r/GUI/OptionsGroup.cpp | 9 +++++++-- src/slic3r/GUI/OptionsGroup.hpp | 1 + src/slic3r/GUI/Tab.cpp | 4 ++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index ba1c440a3e..e65b604df1 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -1136,6 +1136,7 @@ void add_correct_opts_to_diff(const std::string &opt_key, t_config_option_keys& // list of options with vector variable, which is independent from number of extruders static const std::vector independent_from_extruder_number_options = { "bed_shape", + "thumbnails", "filament_ramming_parameters", "gcode_substitutions", "compatible_prints", diff --git a/src/slic3r/GUI/OptionsGroup.cpp b/src/slic3r/GUI/OptionsGroup.cpp index 828806a1f5..0b81a65b87 100644 --- a/src/slic3r/GUI/OptionsGroup.cpp +++ b/src/slic3r/GUI/OptionsGroup.cpp @@ -596,8 +596,8 @@ void ConfigOptionsGroup::back_to_config_value(const DynamicPrintConfig& config, value = int(nozzle_diameter->values.size()); } else if (m_opt_map.find(opt_key) == m_opt_map.end() || - // This option don't have corresponded field - PresetCollection::is_independent_from_extruder_number_option(opt_key) ) { + // This option doesn't have corresponded field + is_option_without_field(opt_key) ) { value = get_config_value(config, opt_key); this->change_opt_value(opt_key, value); return; @@ -980,6 +980,11 @@ bool OptionsGroup::launch_browser(const std::string& path_end) return wxGetApp().open_browser_with_warning_dialog(OptionsGroup::get_url(path_end), wxGetApp().mainframe->m_tabpanel); } +bool OptionsGroup::is_option_without_field(const std::string& opt_key) +{ + return opt_key!= "thumbnails" // "thumbnails" has related field + && PresetCollection::is_independent_from_extruder_number_option(opt_key); +} //------------------------------------------------------------------------------------------- diff --git a/src/slic3r/GUI/OptionsGroup.hpp b/src/slic3r/GUI/OptionsGroup.hpp index 67c3fbdbde..9218b4d7fe 100644 --- a/src/slic3r/GUI/OptionsGroup.hpp +++ b/src/slic3r/GUI/OptionsGroup.hpp @@ -225,6 +225,7 @@ protected: public: static wxString get_url(const std::string& path_end); static bool launch_browser(const std::string& path_end); + static bool is_option_without_field(const std::string& opt_key); }; class ConfigOptionsGroup: public OptionsGroup { diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 23787f4b70..57d5b6649a 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -532,7 +532,7 @@ void Tab::update_label_colours() else color = &m_modified_label_clr; } - if (PresetCollection::is_independent_from_extruder_number_option(opt.first)) { + if (OptionsGroup::is_option_without_field(opt.first)) { if (m_colored_Label_colors.find(opt.first) != m_colored_Label_colors.end()) m_colored_Label_colors.at(opt.first) = *color; continue; @@ -573,7 +573,7 @@ void Tab::decorate() Field* field = nullptr; wxColour* colored_label_clr = nullptr; - if(PresetCollection::is_independent_from_extruder_number_option(opt.first)) + if(OptionsGroup::is_option_without_field(opt.first)) colored_label_clr = (m_colored_Label_colors.find(opt.first) == m_colored_Label_colors.end()) ? nullptr : &m_colored_Label_colors.at(opt.first); if (!colored_label_clr) {