infill pattern: gui field to enum conversion fixed.

Scattered rectilinear now is really scat recti.
This commit is contained in:
supermerill 2019-08-23 23:55:41 +02:00
parent e03079b68d
commit f61087df02
2 changed files with 31 additions and 31 deletions

View File

@ -1043,7 +1043,7 @@ void PrintConfigDef::init_fff_params()
def->enum_values.push_back("hilbertcurve"); def->enum_values.push_back("hilbertcurve");
def->enum_values.push_back("archimedeanchords"); def->enum_values.push_back("archimedeanchords");
def->enum_values.push_back("octagramspiral"); def->enum_values.push_back("octagramspiral");
def->enum_values.push_back("rectilineargapfill"); def->enum_values.push_back("scatteredrectilinear");
def->enum_labels.push_back(L("Rectilinear")); def->enum_labels.push_back(L("Rectilinear"));
def->enum_labels.push_back(L("Grid")); def->enum_labels.push_back(L("Grid"));
def->enum_labels.push_back(L("Triangles")); def->enum_labels.push_back(L("Triangles"));

View File

@ -838,35 +838,36 @@ void Choice::set_value(const boost::any& value, bool change_event)
field->SetValue(text_value); field->SetValue(text_value);
} }
else else
field->SetSelection(idx); field->SetSelection(idx);
break; break;
} }
case coEnum: { case coEnum: {
int val = boost::any_cast<int>(value); int val = boost::any_cast<int>(value);
if (m_opt_id == "top_fill_pattern" || m_opt_id == "bottom_fill_pattern" || m_opt_id == "solid_fill_pattern") if (m_opt_id == "top_fill_pattern" || m_opt_id == "bottom_fill_pattern" || m_opt_id == "solid_fill_pattern"
{ || m_opt_id == "fill_pattern" || m_opt_id == "support_fill_pattern")
if (!m_opt.enum_values.empty()) { {
std::string key; if (!m_opt.enum_values.empty()) {
t_config_enum_values map_names = ConfigOptionEnum<InfillPattern>::get_enum_values(); std::string key;
for (auto it : map_names) { t_config_enum_values map_names = ConfigOptionEnum<InfillPattern>::get_enum_values();
if (val == it.second) { for (auto it : map_names) {
key = it.first; if (val == it.second) {
break; key = it.first;
} break;
} }
}
size_t idx = 0; size_t idx = 0;
for (auto el : m_opt.enum_values) for (auto el : m_opt.enum_values)
{ {
if (el.compare(key) == 0) if (el.compare(key) == 0)
break; break;
++idx; ++idx;
} }
val = idx == m_opt.enum_values.size() ? 0 : idx; val = idx == m_opt.enum_values.size() ? 0 : idx;
} }
else else
val = 0; val = 0;
} else if (m_opt_id.compare("perimeter_loop_seam") == 0) { } else if (m_opt_id.compare("perimeter_loop_seam") == 0) {
if (!m_opt.enum_values.empty()) { if (!m_opt.enum_values.empty()) {
std::string key; std::string key;
@ -934,7 +935,8 @@ boost::any& Choice::get_value()
if (m_opt.type == coEnum) if (m_opt.type == coEnum)
{ {
int ret_enum = field->GetSelection(); int ret_enum = field->GetSelection();
if (m_opt_id == "top_fill_pattern" || m_opt_id == "bottom_fill_pattern" || m_opt_id == "solid_fill_pattern" || m_opt_id == "support_material_interface_pattern") if (m_opt_id == "top_fill_pattern" || m_opt_id == "bottom_fill_pattern" || m_opt_id == "solid_fill_pattern"
|| m_opt_id == "support_material_interface_pattern" || m_opt_id == "fill_pattern")
{ {
if (!m_opt.enum_values.empty()) { if (!m_opt.enum_values.empty()) {
std::string key = m_opt.enum_values[ret_enum]; std::string key = m_opt.enum_values[ret_enum];
@ -946,8 +948,6 @@ boost::any& Choice::get_value()
else else
m_value = static_cast<InfillPattern>(0); m_value = static_cast<InfillPattern>(0);
} }
if (m_opt_id.compare("fill_pattern") == 0)
m_value = static_cast<InfillPattern>(ret_enum);
else if (m_opt_id.compare("gcode_flavor") == 0) else if (m_opt_id.compare("gcode_flavor") == 0)
m_value = static_cast<GCodeFlavor>(ret_enum); m_value = static_cast<GCodeFlavor>(ret_enum);
else if (m_opt_id.compare("support_material_pattern") == 0) else if (m_opt_id.compare("support_material_pattern") == 0)