mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-16 17:45:53 +08:00
Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer
This commit is contained in:
commit
0dfeee6caf
@ -138,7 +138,7 @@ bool Field::is_matched(const std::string& string, const std::string& pattern)
|
|||||||
|
|
||||||
static wxString na_value() { return _(L("N/A")); }
|
static wxString na_value() { return _(L("N/A")); }
|
||||||
|
|
||||||
void Field::get_value_by_opt_type(wxString& str)
|
void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true*/)
|
||||||
{
|
{
|
||||||
switch (m_opt.type) {
|
switch (m_opt.type) {
|
||||||
case coInt:
|
case coInt:
|
||||||
@ -150,7 +150,7 @@ void Field::get_value_by_opt_type(wxString& str)
|
|||||||
case coFloat:{
|
case coFloat:{
|
||||||
if (m_opt.type == coPercent && !str.IsEmpty() && str.Last() == '%')
|
if (m_opt.type == coPercent && !str.IsEmpty() && str.Last() == '%')
|
||||||
str.RemoveLast();
|
str.RemoveLast();
|
||||||
else if (!str.IsEmpty() && str.Last() == '%') {
|
else if (check_value && !str.IsEmpty() && str.Last() == '%') {
|
||||||
wxString label = m_Label->GetLabel();
|
wxString label = m_Label->GetLabel();
|
||||||
if (label.Last() == '\n') label.RemoveLast();
|
if (label.Last() == '\n') label.RemoveLast();
|
||||||
while (label.Last() == ' ') label.RemoveLast();
|
while (label.Last() == ' ') label.RemoveLast();
|
||||||
@ -169,12 +169,12 @@ void Field::get_value_by_opt_type(wxString& str)
|
|||||||
{
|
{
|
||||||
if (m_opt.nullable && str == na_value())
|
if (m_opt.nullable && str == na_value())
|
||||||
val = ConfigOptionFloatsNullable::nil_value();
|
val = ConfigOptionFloatsNullable::nil_value();
|
||||||
else if (!str.ToCDouble(&val))
|
else if (check_value && !str.ToCDouble(&val))
|
||||||
{
|
{
|
||||||
show_error(m_parent, _(L("Invalid numeric input.")));
|
show_error(m_parent, _(L("Invalid numeric input.")));
|
||||||
set_value(double_to_string(val), true);
|
set_value(double_to_string(val), true);
|
||||||
}
|
}
|
||||||
if (m_opt.min > val || val > m_opt.max)
|
if (check_value && (m_opt.min > val || val > m_opt.max))
|
||||||
{
|
{
|
||||||
show_error(m_parent, _(L("Input value is out of range")));
|
show_error(m_parent, _(L("Input value is out of range")));
|
||||||
if (m_opt.min > val) val = m_opt.min;
|
if (m_opt.min > val) val = m_opt.min;
|
||||||
@ -192,12 +192,12 @@ void Field::get_value_by_opt_type(wxString& str)
|
|||||||
double val;
|
double val;
|
||||||
// Replace the first occurence of comma in decimal number.
|
// Replace the first occurence of comma in decimal number.
|
||||||
str.Replace(",", ".", false);
|
str.Replace(",", ".", false);
|
||||||
if (!str.ToCDouble(&val))
|
if (check_value && !str.ToCDouble(&val))
|
||||||
{
|
{
|
||||||
show_error(m_parent, _(L("Invalid numeric input.")));
|
show_error(m_parent, _(L("Invalid numeric input.")));
|
||||||
set_value(double_to_string(val), true);
|
set_value(double_to_string(val), true);
|
||||||
}
|
}
|
||||||
else if ((m_opt.sidetext.rfind("mm/s") != std::string::npos && val > m_opt.max ||
|
else if (check_value && (m_opt.sidetext.rfind("mm/s") != std::string::npos && val > m_opt.max ||
|
||||||
m_opt.sidetext.rfind("mm ") != std::string::npos && val > 1) &&
|
m_opt.sidetext.rfind("mm ") != std::string::npos && val > 1) &&
|
||||||
(m_value.empty() || std::string(str.ToUTF8().data()) != boost::any_cast<std::string>(m_value)))
|
(m_value.empty() || std::string(str.ToUTF8().data()) != boost::any_cast<std::string>(m_value)))
|
||||||
{
|
{
|
||||||
@ -206,7 +206,7 @@ void Field::get_value_by_opt_type(wxString& str)
|
|||||||
const wxString msg_text = wxString::Format(_(L("Do you mean %s%% instead of %s %s?\n"
|
const wxString msg_text = wxString::Format(_(L("Do you mean %s%% instead of %s %s?\n"
|
||||||
"Select YES if you want to change this value to %s%%, \n"
|
"Select YES if you want to change this value to %s%%, \n"
|
||||||
"or NO if you are sure that %s %s is a correct value.")), stVal, stVal, sidetext, stVal, stVal, sidetext);
|
"or NO if you are sure that %s %s is a correct value.")), stVal, stVal, sidetext, stVal, stVal, sidetext);
|
||||||
wxMessageDialog dialog(m_parent, msg_text, _(L("Parameter validation")), wxICON_WARNING | wxYES | wxNO);
|
wxMessageDialog dialog(m_parent, msg_text, _(L("Parameter validation")) + ": " + m_opt_id , wxICON_WARNING | wxYES | wxNO);
|
||||||
if (dialog.ShowModal() == wxID_YES) {
|
if (dialog.ShowModal() == wxID_YES) {
|
||||||
set_value(wxString::Format("%s%%", stVal), false/*true*/);
|
set_value(wxString::Format("%s%%", stVal), false/*true*/);
|
||||||
str += "%%";
|
str += "%%";
|
||||||
@ -396,8 +396,9 @@ void TextCtrl::set_value(const boost::any& value, bool change_event/* = false*/)
|
|||||||
|
|
||||||
if (!change_event) {
|
if (!change_event) {
|
||||||
wxString ret_str = static_cast<wxTextCtrl*>(window)->GetValue();
|
wxString ret_str = static_cast<wxTextCtrl*>(window)->GetValue();
|
||||||
// update m_value to correct work of next value_was_changed()
|
// update m_value to correct work of next value_was_changed(),
|
||||||
get_value_by_opt_type(ret_str);
|
// but don't check/change inputed value and don't show a warning message
|
||||||
|
get_value_by_opt_type(ret_str, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ public:
|
|||||||
virtual wxWindow* getWindow() { return nullptr; }
|
virtual wxWindow* getWindow() { return nullptr; }
|
||||||
|
|
||||||
bool is_matched(const std::string& string, const std::string& pattern);
|
bool is_matched(const std::string& string, const std::string& pattern);
|
||||||
void get_value_by_opt_type(wxString& str);
|
void get_value_by_opt_type(wxString& str, const bool check_value = true);
|
||||||
|
|
||||||
/// Factory method for generating new derived classes.
|
/// Factory method for generating new derived classes.
|
||||||
template<class T>
|
template<class T>
|
||||||
|
@ -1071,9 +1071,11 @@ const std::vector<std::string>& ObjectList::get_options_for_bundle(const wxStrin
|
|||||||
return empty;
|
return empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool improper_category(const std::string& category, const int extruders_cnt)
|
static bool improper_category(const std::string& category, const int extruders_cnt, const bool is_object_settings = true)
|
||||||
{
|
{
|
||||||
return category.empty() || (extruders_cnt == 1 && (category == "Extruders" || category == "Wipe options" ));
|
return category.empty() ||
|
||||||
|
extruders_cnt == 1 && (category == "Extruders" || category == "Wipe options" ) ||
|
||||||
|
!is_object_settings && category == "Support material";
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectList::get_options_menu(settings_menu_hierarchy& settings_menu, const bool is_part)
|
void ObjectList::get_options_menu(settings_menu_hierarchy& settings_menu, const bool is_part)
|
||||||
@ -1087,7 +1089,7 @@ void ObjectList::get_options_menu(settings_menu_hierarchy& settings_menu, const
|
|||||||
{
|
{
|
||||||
auto const opt = config.def()->get(option);
|
auto const opt = config.def()->get(option);
|
||||||
auto category = opt->category;
|
auto category = opt->category;
|
||||||
if (improper_category(category, extruders_cnt))
|
if (improper_category(category, extruders_cnt, !is_part))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const std::string& label = !opt->full_label.empty() ? opt->full_label : opt->label;
|
const std::string& label = !opt->full_label.empty() ? opt->full_label : opt->label;
|
||||||
@ -1404,7 +1406,7 @@ wxMenuItem* ObjectList::append_menu_item_settings(wxMenu* menu_)
|
|||||||
menu->SetFirstSeparator();
|
menu->SetFirstSeparator();
|
||||||
|
|
||||||
// Add frequently settings
|
// Add frequently settings
|
||||||
create_freq_settings_popupmenu(menu);
|
create_freq_settings_popupmenu(menu, sel_vol==nullptr);
|
||||||
|
|
||||||
if (mode == comAdvanced)
|
if (mode == comAdvanced)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -1598,7 +1600,7 @@ wxMenu* ObjectList::create_settings_popupmenu(wxMenu *parent_menu)
|
|||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectList::create_freq_settings_popupmenu(wxMenu *menu)
|
void ObjectList::create_freq_settings_popupmenu(wxMenu *menu, const bool is_object_settings/* = true*/)
|
||||||
{
|
{
|
||||||
// Add default settings bundles
|
// Add default settings bundles
|
||||||
const SettingsBundle& bundle = printer_technology() == ptFFF ?
|
const SettingsBundle& bundle = printer_technology() == ptFFF ?
|
||||||
@ -1607,7 +1609,7 @@ void ObjectList::create_freq_settings_popupmenu(wxMenu *menu)
|
|||||||
const int extruders_cnt = extruders_count();
|
const int extruders_cnt = extruders_count();
|
||||||
|
|
||||||
for (auto& it : bundle) {
|
for (auto& it : bundle) {
|
||||||
if (improper_category(it.first, extruders_cnt))
|
if (improper_category(it.first, extruders_cnt, is_object_settings))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
append_menu_item(menu, wxID_ANY, _(it.first), "",
|
append_menu_item(menu, wxID_ANY, _(it.first), "",
|
||||||
@ -2262,7 +2264,7 @@ SettingsBundle ObjectList::get_item_settings_bundle(const DynamicPrintConfig* co
|
|||||||
for (auto& opt_key : opt_keys)
|
for (auto& opt_key : opt_keys)
|
||||||
{
|
{
|
||||||
auto category = config->def()->get(opt_key)->category;
|
auto category = config->def()->get(opt_key)->category;
|
||||||
if (improper_category(category, extruders_cnt))
|
if (improper_category(category, extruders_cnt, is_object_settings))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
std::vector< std::string > new_category;
|
std::vector< std::string > new_category;
|
||||||
|
@ -241,7 +241,7 @@ public:
|
|||||||
void create_part_popupmenu(wxMenu*menu);
|
void create_part_popupmenu(wxMenu*menu);
|
||||||
void create_instance_popupmenu(wxMenu*menu);
|
void create_instance_popupmenu(wxMenu*menu);
|
||||||
wxMenu* create_settings_popupmenu(wxMenu *parent_menu);
|
wxMenu* create_settings_popupmenu(wxMenu *parent_menu);
|
||||||
void create_freq_settings_popupmenu(wxMenu *parent_menu);
|
void create_freq_settings_popupmenu(wxMenu *parent_menu, const bool is_object_settings = true);
|
||||||
|
|
||||||
void update_opt_keys(t_config_option_keys& t_optopt_keys, const bool is_object);
|
void update_opt_keys(t_config_option_keys& t_optopt_keys, const bool is_object);
|
||||||
|
|
||||||
|
@ -589,13 +589,11 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config
|
|||||||
switch (opt->type) {
|
switch (opt->type) {
|
||||||
case coFloatOrPercent:{
|
case coFloatOrPercent:{
|
||||||
const auto &value = *config.option<ConfigOptionFloatOrPercent>(opt_key);
|
const auto &value = *config.option<ConfigOptionFloatOrPercent>(opt_key);
|
||||||
|
|
||||||
|
text_value = double_to_string(value.value);
|
||||||
if (value.percent)
|
if (value.percent)
|
||||||
{
|
|
||||||
text_value = wxString::Format(_T("%i"), int(value.value));
|
|
||||||
text_value += "%";
|
text_value += "%";
|
||||||
}
|
|
||||||
else
|
|
||||||
text_value = double_to_string(value.value);
|
|
||||||
ret = text_value;
|
ret = text_value;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user