ENH: support styles to sets
Change-Id: I18d4add12907d4d4a10980c1f1244e287934c34c (cherry picked from commit 8ead53319222a2ab4bd76b434afcd657e5045fc7)
This commit is contained in:
parent
b3c4447191
commit
54e47bba33
|
@ -429,6 +429,19 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
|
|||
m_support_material_overhangs_queried = false;
|
||||
}
|
||||
|
||||
if (config->opt_bool("enable_support")) {
|
||||
auto support_type = config->opt_enum<SupportType>("support_type");
|
||||
auto support_style = config->opt_enum<SupportMaterialStyle>("support_style");
|
||||
std::set<int> enum_set_normal = {0, 1, 2};
|
||||
std::set<int> enum_set_tree = {0, 3, 4, 5};
|
||||
auto & set = is_tree(support_type) ? enum_set_tree : enum_set_normal;
|
||||
if (set.find(support_style) == set.end()) {
|
||||
DynamicPrintConfig new_conf = *config;
|
||||
new_conf.set_key_value("support_style", new ConfigOptionEnum<SupportMaterialStyle>(smsDefault));
|
||||
apply(config, &new_conf);
|
||||
}
|
||||
}
|
||||
|
||||
if (config->option<ConfigOptionPercent>("sparse_infill_density")->value == 100) {
|
||||
std::string sparse_infill_pattern = config->option<ConfigOptionEnum<InfillPattern>>("sparse_infill_pattern")->serialize();
|
||||
const auto &top_fill_pattern_values = config->def()->get("top_surface_pattern")->enum_values;
|
||||
|
|
|
@ -1291,10 +1291,10 @@ void Choice::set_value(const boost::any& value, bool change_event)
|
|||
if (m_opt_id.compare("host_type") == 0 && val != 0 &&
|
||||
m_opt.enum_values.size() > field->GetCount()) // for case, when PrusaLink isn't used as a HostType
|
||||
val--;
|
||||
if (m_opt_id == "top_surface_pattern" || m_opt_id == "bottom_surface_pattern" || m_opt_id == "sparse_infill_pattern")
|
||||
if (m_opt_id == "top_surface_pattern" || m_opt_id == "bottom_surface_pattern" || m_opt_id == "sparse_infill_pattern" || m_opt_id == "support_style")
|
||||
{
|
||||
std::string key;
|
||||
const t_config_enum_values& map_names = ConfigOptionEnum<InfillPattern>::get_enum_values();
|
||||
const t_config_enum_values& map_names = *m_opt.enum_keys_map;
|
||||
for (auto it : map_names)
|
||||
if (val == it.second) {
|
||||
key = it.first;
|
||||
|
@ -1370,9 +1370,9 @@ boost::any& Choice::get_value()
|
|||
// BBS
|
||||
if (m_opt.type == coEnum || m_opt.type == coEnums)
|
||||
{
|
||||
if (m_opt_id == "top_surface_pattern" || m_opt_id == "bottom_surface_pattern" || m_opt_id == "sparse_infill_pattern") {
|
||||
if (m_opt_id == "top_surface_pattern" || m_opt_id == "bottom_surface_pattern" || m_opt_id == "sparse_infill_pattern" || m_opt_id == "support_style") {
|
||||
const std::string& key = m_opt.enum_values[field->GetSelection()];
|
||||
m_value = int(ConfigOptionEnum<InfillPattern>::get_enum_values().at(key));
|
||||
m_value = int(m_opt.enum_keys_map->at(key));
|
||||
}
|
||||
// Support ThirdPartyPrinter
|
||||
else if (m_opt_id.compare("host_type") == 0 && m_opt.enum_values.size() > field->GetCount()) {
|
||||
|
|
|
@ -1416,6 +1416,13 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value)
|
|||
}
|
||||
}
|
||||
|
||||
// BBS set support style to default when support type changes
|
||||
if (opt_key == "support_type") {
|
||||
DynamicPrintConfig new_conf = *m_config;
|
||||
new_conf.set_key_value("support_style", new ConfigOptionEnum<SupportMaterialStyle>(smsDefault));
|
||||
m_config_manipulation.apply(m_config, &new_conf);
|
||||
}
|
||||
|
||||
// BBS popup a message to ask the user to set optimum parameters for tree support
|
||||
if (opt_key == "support_type" || opt_key == "support_style") {
|
||||
if (is_tree_slim(m_config->opt_enum<SupportType>("support_type"), m_config->opt_enum<SupportMaterialStyle>("support_style")) &&
|
||||
|
@ -2061,6 +2068,27 @@ void TabPrint::toggle_options()
|
|||
if (!m_active_page) return;
|
||||
|
||||
m_config_manipulation.toggle_print_fff_options(m_config, m_type < Preset::TYPE_COUNT);
|
||||
|
||||
Field *field = m_active_page->get_field("support_style");
|
||||
auto support_type = m_config->opt_enum<SupportType>("support_type");
|
||||
if (auto choice = dynamic_cast<Choice*>(field)) {
|
||||
auto def = print_config_def.get("support_style");
|
||||
std::vector<int> enum_set_normal = {0, 1, 2};
|
||||
std::vector<int> enum_set_tree = {0, 3, 4, 5};
|
||||
auto & set = is_tree(support_type) ? enum_set_tree : enum_set_normal;
|
||||
auto & opt = const_cast<ConfigOptionDef &>(field->m_opt);
|
||||
auto cb = dynamic_cast<ComboBox *>(choice->window);
|
||||
int n = cb->GetSelection();
|
||||
opt.enum_values.clear();
|
||||
opt.enum_labels.clear();
|
||||
cb->Clear();
|
||||
for (auto i : set) {
|
||||
opt.enum_values.push_back(def->enum_values[i]);
|
||||
opt.enum_labels.push_back(def->enum_labels[i]);
|
||||
cb->Append(def->enum_labels[i]);
|
||||
}
|
||||
cb->SetSelection(n >= cb->GetCount() ? cb->GetCount() - 1 : n);
|
||||
}
|
||||
}
|
||||
|
||||
void TabPrint::update()
|
||||
|
|
Loading…
Reference in New Issue