mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 05:15:59 +08:00
Added a check that first layer height is not expressed as a percentage (related to https://github.com/prusa3d/PrusaSlicer/issues/7418)
first_layer_height cannot be changed to ConfigOptionFloat, that would break loading of old 3MFs. The relative values from 3MFs should already be converted to absolute in `Preset::normalize`, what is missing is the UI check. + Code refactoring for OptionsGroup::create_single_option_line(): Don't clear label value in an Option. This value is used in Field::get_value_by_opt_type() to show error "%s doesn't support percentage". => At functions OG_CustomCtrl::CtrlLine::render() and OG_CustomCtrl::CtrlLine::get_pos() added check if current line has more than one option. => Draw option's label only when line has several options.
This commit is contained in:
parent
091585076c
commit
d8ecc191da
@ -1210,6 +1210,7 @@ void PrintConfigDef::init_fff_params()
|
|||||||
def->tooltip = L("When printing with very low layer heights, you might still want to print a thicker "
|
def->tooltip = L("When printing with very low layer heights, you might still want to print a thicker "
|
||||||
"bottom layer to improve adhesion and tolerance for non perfect build plates.");
|
"bottom layer to improve adhesion and tolerance for non perfect build plates.");
|
||||||
def->sidetext = L("mm");
|
def->sidetext = L("mm");
|
||||||
|
def->min = 0;
|
||||||
def->ratio_over = "layer_height";
|
def->ratio_over = "layer_height";
|
||||||
def->set_default_value(new ConfigOptionFloatOrPercent(0.35, false));
|
def->set_default_value(new ConfigOptionFloatOrPercent(0.35, false));
|
||||||
|
|
||||||
|
@ -291,6 +291,16 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
|
|||||||
case coString:
|
case coString:
|
||||||
case coStrings:
|
case coStrings:
|
||||||
case coFloatOrPercent: {
|
case coFloatOrPercent: {
|
||||||
|
if (m_opt.type == coFloatOrPercent && m_opt.opt_key == "first_layer_height" && !str.IsEmpty() && str.Last() == '%') {
|
||||||
|
// Workaroud to avoid of using of the % for first layer height
|
||||||
|
// see https://github.com/prusa3d/PrusaSlicer/issues/7418
|
||||||
|
wxString label = m_opt.full_label.empty() ? _(m_opt.label) : _(m_opt.full_label);
|
||||||
|
show_error(m_parent, from_u8((boost::format(_utf8(L("%s doesn't support percentage"))) % label).str()));
|
||||||
|
const wxString stVal = double_to_string(0.01, 2);
|
||||||
|
set_value(stVal, true);
|
||||||
|
m_value = into_u8(stVal);;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (m_opt.type == coFloatOrPercent && !str.IsEmpty() && str.Last() != '%')
|
if (m_opt.type == coFloatOrPercent && !str.IsEmpty() && str.Last() != '%')
|
||||||
{
|
{
|
||||||
double val = 0.;
|
double val = 0.;
|
||||||
|
@ -167,13 +167,14 @@ wxPoint OG_CustomCtrl::get_pos(const Line& line, Field* field_in/* = nullptr*/)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_multioption_line = option_set.size() > 1;
|
||||||
for (auto opt : option_set) {
|
for (auto opt : option_set) {
|
||||||
Field* field = opt_group->get_field(opt.opt_id);
|
Field* field = opt_group->get_field(opt.opt_id);
|
||||||
correct_line_height(ctrl_line.height, field->getWindow());
|
correct_line_height(ctrl_line.height, field->getWindow());
|
||||||
|
|
||||||
ConfigOptionDef option = opt.opt;
|
ConfigOptionDef option = opt.opt;
|
||||||
// add label if any
|
// add label if any
|
||||||
if (!option.label.empty()) {
|
if (is_multioption_line && !option.label.empty()) {
|
||||||
//! To correct translation by context have to use wxGETTEXT_IN_CONTEXT macro from wxWidget 3.1.1
|
//! To correct translation by context have to use wxGETTEXT_IN_CONTEXT macro from wxWidget 3.1.1
|
||||||
label = (option.label == L_CONTEXT("Top", "Layers") || option.label == L_CONTEXT("Bottom", "Layers")) ?
|
label = (option.label == L_CONTEXT("Top", "Layers") || option.label == L_CONTEXT("Bottom", "Layers")) ?
|
||||||
_CTX(option.label, "Layers") : _(option.label);
|
_CTX(option.label, "Layers") : _(option.label);
|
||||||
@ -595,11 +596,12 @@ void OG_CustomCtrl::CtrlLine::render(wxDC& dc, wxCoord v_pos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t bmp_rect_id = 0;
|
size_t bmp_rect_id = 0;
|
||||||
|
bool is_multioption_line = option_set.size() > 1;
|
||||||
for (const Option& opt : option_set) {
|
for (const Option& opt : option_set) {
|
||||||
field = ctrl->opt_group->get_field(opt.opt_id);
|
field = ctrl->opt_group->get_field(opt.opt_id);
|
||||||
ConfigOptionDef option = opt.opt;
|
ConfigOptionDef option = opt.opt;
|
||||||
// add label if any
|
// add label if any
|
||||||
if (!option.label.empty()) {
|
if (is_multioption_line && !option.label.empty()) {
|
||||||
//! To correct translation by context have to use wxGETTEXT_IN_CONTEXT macro from wxWidget 3.1.1
|
//! To correct translation by context have to use wxGETTEXT_IN_CONTEXT macro from wxWidget 3.1.1
|
||||||
label = (option.label == L_CONTEXT("Top", "Layers") || option.label == L_CONTEXT("Bottom", "Layers")) ?
|
label = (option.label == L_CONTEXT("Top", "Layers") || option.label == L_CONTEXT("Bottom", "Layers")) ?
|
||||||
_CTX(option.label, "Layers") : _(option.label);
|
_CTX(option.label, "Layers") : _(option.label);
|
||||||
|
@ -507,15 +507,13 @@ void OptionsGroup::clear(bool destroy_custom_ctrl)
|
|||||||
m_fields.clear();
|
m_fields.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
Line OptionsGroup::create_single_option_line(const Option& option, const std::string& path/* = std::string()*/) const {
|
Line OptionsGroup::create_single_option_line(const Option& option, const std::string& path/* = std::string()*/) const
|
||||||
// Line retval{ _(option.opt.label), _(option.opt.tooltip) };
|
{
|
||||||
wxString tooltip = _(option.opt.tooltip);
|
wxString tooltip = _(option.opt.tooltip);
|
||||||
edit_tooltip(tooltip);
|
edit_tooltip(tooltip);
|
||||||
Line retval{ _(option.opt.label), tooltip };
|
Line retval{ _(option.opt.label), tooltip };
|
||||||
retval.label_path = path;
|
retval.label_path = path;
|
||||||
Option tmp(option);
|
retval.append_option(option);
|
||||||
tmp.opt.label = std::string("");
|
|
||||||
retval.append_option(tmp);
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user