Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer into et_gcode_z_offset

This commit is contained in:
enricoturri1966 2022-01-20 13:46:03 +01:00
commit 803d797bd7
11 changed files with 63 additions and 13 deletions

View File

@ -2,6 +2,7 @@
#include "../Utils.hpp"
#include <cctype> // isalpha
#include <boost/algorithm/string/replace.hpp>
namespace Slic3r {

View File

@ -74,7 +74,8 @@ 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);
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.
if (axis != UNKNOWN_AXIS)

View File

@ -4,6 +4,7 @@
#include <charconv>
#endif
#include <stdexcept>
#include <sstream>
#include <fast_float/fast_float.h>

View File

@ -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<std::string> independent_from_extruder_number_options = {
"bed_shape",
"thumbnails",
"filament_ramming_parameters",
"gcode_substitutions",
"compatible_prints",

View File

@ -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<size_t>(idx) + 1, 1, new_line);
text_len++;
}
else // space
text[idx] = new_line;
cur_len = i - static_cast<size_t>(idx);
}
}
return text;
}
}
}

View File

@ -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() {}

View File

@ -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);
}
//-------------------------------------------------------------------------------------------

View File

@ -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 {

View File

@ -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<int>(LoadType::OpenProject), static_cast<int>(LoadType::LoadConfig)) - 1;

View File

@ -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) {

View File

@ -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());