Updated UI for the "infill_anchor" parameter

This commit is contained in:
YuSanka 2020-11-18 17:00:08 +01:00
parent 620f94331c
commit 03b336145f
3 changed files with 40 additions and 41 deletions

View File

@ -1057,6 +1057,19 @@ void PrintConfigDef::init_fff_params()
"If expressed as percentage (example: 15%) it is calculated over infill extrusion width.");
def->sidetext = L("mm or %");
def->ratio_over = "infill_extrusion_width";
def->gui_type = "f_enum_open";
def->enum_values.push_back("0");
def->enum_values.push_back("1");
def->enum_values.push_back("2");
def->enum_values.push_back("5");
def->enum_values.push_back("10");
def->enum_values.push_back("1000");
def->enum_labels.push_back(L("0 (unprintable)"));
def->enum_labels.push_back("1 mm");
def->enum_labels.push_back("2 mm");
def->enum_labels.push_back("5 mm");
def->enum_labels.push_back("10 mm");
def->enum_labels.push_back(L("1000 (unlimited)"));
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloatOrPercent(300, true));

View File

@ -867,7 +867,7 @@ void Choice::BUILD() {
if (m_is_editable) {
temp->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e) {
e.Skip();
if (m_opt.type == coStrings) {
if (m_opt.type == coStrings || m_opt.type == coFloatOrPercent) {
on_change_field();
return;
}
@ -898,59 +898,42 @@ void Choice::set_selection()
choice_ctrl* field = dynamic_cast<choice_ctrl*>(window);
switch (m_opt.type) {
case coFloat:
case coPercent: {
double val = m_opt.default_value->getFloat();
text_value = val - int(val) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 1);
size_t idx = 0;
for (auto el : m_opt.enum_values)
{
if (el == text_value)
break;
++idx;
}
// if (m_opt.type == coPercent) text_value += "%";
idx == m_opt.enum_values.size() ?
field->SetValue(text_value) :
field->SetSelection(idx);
break;
}
case coEnum:{
int id_value = m_opt.get_default_value<ConfigOptionEnum<SeamPosition>>()->value; //!!
field->SetSelection(id_value);
break;
}
case coFloat:
case coPercent: {
double val = m_opt.default_value->getFloat();
text_value = val - int(val) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 1);
break;
}
case coInt:{
int val = m_opt.default_value->getInt(); //!!
text_value = wxString::Format(_T("%i"), int(val));
size_t idx = 0;
for (auto el : m_opt.enum_values)
{
if (el == text_value)
break;
++idx;
}
idx == m_opt.enum_values.size() ?
field->SetValue(text_value) :
field->SetSelection(idx);
text_value = wxString::Format(_T("%i"), int(m_opt.default_value->getInt()));
break;
}
case coStrings:{
text_value = m_opt.get_default_value<ConfigOptionStrings>()->get_at(m_opt_idx);
break;
}
case coFloatOrPercent: {
text_value = double_to_string(m_opt.default_value->getFloat());
if (m_opt.get_default_value<ConfigOptionFloatOrPercent>()->percent)
text_value += "%";
break;
}
default: break;
}
size_t idx = 0;
for (auto el : m_opt.enum_values)
{
if (!text_value.IsEmpty()) {
int idx = 0;
for (auto el : m_opt.enum_values) {
if (el == text_value)
break;
++idx;
}
idx == m_opt.enum_values.size() ?
field->SetValue(text_value) :
field->SetSelection(idx);
break;
}
default: break;
idx == m_opt.enum_values.size() ? field->SetValue(text_value) : field->SetSelection(idx);
}
}
@ -984,6 +967,7 @@ void Choice::set_value(const boost::any& value, bool change_event)
case coInt:
case coFloat:
case coPercent:
case coFloatOrPercent:
case coString:
case coStrings: {
wxString text_value;
@ -1137,7 +1121,9 @@ boost::any& Choice::get_value()
(ret_str != m_opt.enum_values[ret_enum] && ret_str != _(m_opt.enum_labels[ret_enum])))
// modifies ret_string!
get_value_by_opt_type(ret_str);
else
else if (m_opt.type == coFloatOrPercent)
m_value = m_opt.enum_values[ret_enum];
else
m_value = atof(m_opt.enum_values[ret_enum].c_str());
}
else

View File

@ -1422,9 +1422,9 @@ void TabPrint::build()
optgroup = page->new_optgroup(L("Infill"));
optgroup->append_single_option_line("fill_density", category_path + "fill-density");
optgroup->append_single_option_line("fill_pattern", category_path + "fill-pattern");
optgroup->append_single_option_line("infill_anchor", category_path + "fill-pattern");
optgroup->append_single_option_line("top_fill_pattern", category_path + "top-fill-pattern");
optgroup->append_single_option_line("bottom_fill_pattern", category_path + "bottom-fill-pattern");
optgroup->append_single_option_line("infill_anchor", category_path + "fill-pattern");
optgroup = page->new_optgroup(L("Ironing"));
optgroup->append_single_option_line("ironing");