adding separate config values for support tree algorithms

Realize config matrix on supports tab
This commit is contained in:
tamasmeszaros 2022-12-14 13:14:25 +01:00
parent 878f3b30dd
commit 6238595ac6
5 changed files with 90 additions and 76 deletions

View File

@ -3277,6 +3277,9 @@ void PrintConfigDef::init_sla_support_params(const std::string &prefix)
{ {
ConfigOptionDef* def; ConfigOptionDef* def;
constexpr const char * pretext_unavailable = L("Unavailable for this method.\n");
std::string pretext;
def = this->add(prefix + "support_head_front_diameter", coFloat); def = this->add(prefix + "support_head_front_diameter", coFloat);
def->label = L("Pinhead front diameter"); def->label = L("Pinhead front diameter");
def->category = L("Supports"); def->category = L("Supports");
@ -3326,20 +3329,28 @@ void PrintConfigDef::init_sla_support_params(const std::string &prefix)
def->mode = comExpert; def->mode = comExpert;
def->set_default_value(new ConfigOptionPercent(50)); def->set_default_value(new ConfigOptionPercent(50));
pretext = "";
if (prefix == "branching")
pretext = pretext_unavailable;
def = this->add(prefix + "support_max_bridges_on_pillar", coInt); def = this->add(prefix + "support_max_bridges_on_pillar", coInt);
def->label = L("Max bridges on a pillar"); def->label = L("Max bridges on a pillar");
def->tooltip = L( def->tooltip = pretext + L(
"Maximum number of bridges that can be placed on a pillar. Bridges " "Maximum number of bridges that can be placed on a pillar. Bridges "
"hold support point pinheads and connect to pillars as small branches."); "hold support point pinheads and connect to pillars as small branches.");
def->min = 0; def->min = 0;
def->max = 50; def->max = 50;
def->mode = comExpert; def->mode = comExpert;
def->set_default_value(new ConfigOptionInt(3)); def->set_default_value(new ConfigOptionInt(prefix == "branching" ? 2 : 3));
pretext = "";
if (prefix.empty())
pretext = pretext_unavailable;
def = this->add(prefix + "support_max_weight_on_model", coFloat); def = this->add(prefix + "support_max_weight_on_model", coFloat);
def->label = L("Max weight on model"); def->label = L("Max weight on model");
def->category = L("Supports"); def->category = L("Supports");
def->tooltip = L( def->tooltip = pretext + L(
"Maximum weight of sub-trees that terminate on the model instead of the print bed. The weight is the sum of the lenghts of all " "Maximum weight of sub-trees that terminate on the model instead of the print bed. The weight is the sum of the lenghts of all "
"branches emanating from the endpoint."); "branches emanating from the endpoint.");
def->sidetext = L("mm"); def->sidetext = L("mm");
@ -3347,9 +3358,13 @@ void PrintConfigDef::init_sla_support_params(const std::string &prefix)
def->mode = comExpert; def->mode = comExpert;
def->set_default_value(new ConfigOptionFloat(10.)); def->set_default_value(new ConfigOptionFloat(10.));
pretext = "";
if (prefix == "branching")
pretext = pretext_unavailable;
def = this->add(prefix + "support_pillar_connection_mode", coEnum); def = this->add(prefix + "support_pillar_connection_mode", coEnum);
def->label = L("Pillar connection mode"); def->label = L("Pillar connection mode");
def->tooltip = L("Controls the bridge type between two neighboring pillars." def->tooltip = pretext + L("Controls the bridge type between two neighboring pillars."
" Can be zig-zag, cross (double zig-zag) or dynamic which" " Can be zig-zag, cross (double zig-zag) or dynamic which"
" will automatically switch between the first two depending" " will automatically switch between the first two depending"
" on the distance of the two pillars."); " on the distance of the two pillars.");
@ -3373,12 +3388,16 @@ void PrintConfigDef::init_sla_support_params(const std::string &prefix)
def = this->add(prefix + "support_pillar_widening_factor", coFloat); def = this->add(prefix + "support_pillar_widening_factor", coFloat);
def->label = L("Pillar widening factor"); def->label = L("Pillar widening factor");
def->category = L("Supports"); def->category = L("Supports");
def->tooltip = L(
"Merging bridges or pillars into another pillars can " pretext = "";
if (prefix.empty())
pretext = pretext_unavailable;
def->tooltip = pretext +
L("Merging bridges or pillars into another pillars can "
"increase the radius. Zero means no increase, one means " "increase the radius. Zero means no increase, one means "
"full increase. The exact amount of increase is unspecified and can " "full increase. The exact amount of increase is unspecified and can "
"change in the future. What is garanteed is that thickness will not " "change in the future.");
"exceed \"support_base_diameter\"");
def->min = 0; def->min = 0;
def->max = 1; def->max = 1;
@ -3434,13 +3453,22 @@ void PrintConfigDef::init_sla_support_params(const std::string &prefix)
def->sidetext = L("mm"); def->sidetext = L("mm");
def->min = 0; def->min = 0;
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(15.0));
double default_val = 15.0;
if (prefix == "branching")
default_val = 5.0;
def->set_default_value(new ConfigOptionFloat(default_val));
pretext = "";
if (prefix == "branching")
pretext = pretext_unavailable;
def = this->add(prefix + "support_max_pillar_link_distance", coFloat); def = this->add(prefix + "support_max_pillar_link_distance", coFloat);
def->label = L("Max pillar linking distance"); def->label = L("Max pillar linking distance");
def->category = L("Supports"); def->category = L("Supports");
def->tooltip = L("The max distance of two pillars to get linked with each other." def->tooltip = pretext + L("The max distance of two pillars to get linked with each other."
" A zero value will prohibit pillar cascading."); " A zero value will prohibit pillar cascading.");
def->sidetext = L("mm"); def->sidetext = L("mm");
def->min = 0; // 0 means no linking def->min = 0; // 0 means no linking
def->mode = comAdvanced; def->mode = comAdvanced;
@ -3801,7 +3829,7 @@ void PrintConfigDef::init_sla_params()
def->enum_labels[0] = L("Default"); def->enum_labels[0] = L("Default");
def->enum_labels[1] = L("Branching"); def->enum_labels[1] = L("Branching");
// TODO: def->enum_labels[2] = L("Organic"); // TODO: def->enum_labels[2] = L("Organic");
def->mode = comAdvanced; def->mode = comSimple;
def->set_default_value(new ConfigOptionEnum(sla::SupportTreeType::Default)); def->set_default_value(new ConfigOptionEnum(sla::SupportTreeType::Default));
init_sla_support_params(""); init_sla_support_params("");

View File

@ -380,6 +380,8 @@ inline IntegerOnly<I, I> fast_round_up(double a)
return a == 0.49999999999999994 ? I(0) : I(floor(a + 0.5)); return a == 0.49999999999999994 ? I(0) : I(floor(a + 0.5));
} }
template<class T> using SamePair = std::pair<T, T>;
} // namespace Slic3r } // namespace Slic3r
#endif // _libslic3r_h_ #endif // _libslic3r_h_

View File

@ -390,29 +390,28 @@ void ConfigManipulation::toggle_print_sla_options(DynamicPrintConfig* config)
toggle_field("support_critical_angle", supports_en && is_default_tree); toggle_field("support_critical_angle", supports_en && is_default_tree);
toggle_field("support_max_bridge_length", supports_en && is_default_tree); toggle_field("support_max_bridge_length", supports_en && is_default_tree);
toggle_field("support_max_pillar_link_distance", supports_en && is_default_tree); toggle_field("support_max_pillar_link_distance", supports_en && is_default_tree);
toggle_field("support_pillar_widening_factor", supports_en && is_default_tree); toggle_field("support_pillar_widening_factor", false);
toggle_field("support_max_weight_on_model", supports_en && is_default_tree); toggle_field("support_max_weight_on_model", false);
toggle_field("support_points_density_relative", supports_en && is_default_tree);
toggle_field("support_points_minimal_distance", supports_en && is_default_tree);
toggle_field("branchingsupport_head_front_diameter", supports_en && is_branching_tree); toggle_field("branchingsupport_head_front_diameter", supports_en && is_branching_tree);
toggle_field("branchingsupport_head_penetration", supports_en && is_branching_tree); toggle_field("branchingsupport_head_penetration", supports_en && is_branching_tree);
toggle_field("branchingsupport_head_width", supports_en && is_branching_tree); toggle_field("branchingsupport_head_width", supports_en && is_branching_tree);
toggle_field("branchingsupport_pillar_diameter", supports_en && is_branching_tree); toggle_field("branchingsupport_pillar_diameter", supports_en && is_branching_tree);
toggle_field("branchingsupport_small_pillar_diameter_percent", supports_en && is_branching_tree); toggle_field("branchingsupport_small_pillar_diameter_percent", supports_en && is_branching_tree);
toggle_field("branchingsupport_max_bridges_on_pillar", supports_en && is_branching_tree); toggle_field("branchingsupport_max_bridges_on_pillar", false);
toggle_field("branchingsupport_pillar_connection_mode", supports_en && is_branching_tree); toggle_field("branchingsupport_pillar_connection_mode", false);
toggle_field("branchingsupport_buildplate_only", supports_en && is_branching_tree); toggle_field("branchingsupport_buildplate_only", supports_en && is_branching_tree);
toggle_field("branchingsupport_base_diameter", supports_en && is_branching_tree); toggle_field("branchingsupport_base_diameter", supports_en && is_branching_tree);
toggle_field("branchingsupport_base_height", supports_en && is_branching_tree); toggle_field("branchingsupport_base_height", supports_en && is_branching_tree);
toggle_field("branchingsupport_base_safety_distance", supports_en && is_branching_tree); toggle_field("branchingsupport_base_safety_distance", supports_en && is_branching_tree);
toggle_field("branchingsupport_critical_angle", supports_en && is_branching_tree); toggle_field("branchingsupport_critical_angle", supports_en && is_branching_tree);
toggle_field("branchingsupport_max_bridge_length", supports_en && is_branching_tree); toggle_field("branchingsupport_max_bridge_length", supports_en && is_branching_tree);
toggle_field("branchingsupport_max_pillar_link_distance", supports_en && is_branching_tree); toggle_field("branchingsupport_max_pillar_link_distance", false);
toggle_field("branchingsupport_pillar_widening_factor", supports_en && is_branching_tree); toggle_field("branchingsupport_pillar_widening_factor", supports_en && is_branching_tree);
toggle_field("branchingsupport_max_weight_on_model", supports_en && is_branching_tree); toggle_field("branchingsupport_max_weight_on_model", supports_en && is_branching_tree);
toggle_field("branchingsupport_points_density_relative", supports_en && is_branching_tree);
toggle_field("branchingsupport_points_minimal_distance", supports_en && is_branching_tree); toggle_field("support_points_density_relative", supports_en);
toggle_field("support_points_minimal_distance", supports_en);
bool pad_en = config->opt_bool("pad_enable"); bool pad_en = config->opt_bool("pad_enable");

View File

@ -4821,29 +4821,46 @@ void TabSLAMaterial::update()
wxGetApp().mainframe->on_config_changed(m_config); wxGetApp().mainframe->on_config_changed(m_config);
} }
void TabSLAPrint::build_sla_support_params(const std::string &prefix, static void add_options_into_line(ConfigOptionsGroupShp &optgroup,
const std::vector<SamePair<std::string>> &prefixes,
const std::string &optkey)
{
auto opt = optgroup->get_option(prefixes.front().first + optkey);
Line line{ opt.opt.label, "" };
line.full_width = 1;
for (auto &prefix : prefixes) {
opt = optgroup->get_option(prefix.first + optkey);
opt.opt.label = prefix.second;
opt.opt.width = 12; // TODO
line.append_option(opt);
}
optgroup->append_line(line);
}
void TabSLAPrint::build_sla_support_params(const std::vector<SamePair<std::string>> &prefixes,
const Slic3r::GUI::PageShp &page) const Slic3r::GUI::PageShp &page)
{ {
auto optgroup = page->new_optgroup(L("Support head")); auto optgroup = page->new_optgroup(L("Support head"));
optgroup->append_single_option_line(prefix + "support_head_front_diameter"); add_options_into_line(optgroup, prefixes, "support_head_front_diameter");
optgroup->append_single_option_line(prefix + "support_head_penetration"); add_options_into_line(optgroup, prefixes, "support_head_penetration");
optgroup->append_single_option_line(prefix + "support_head_width"); add_options_into_line(optgroup, prefixes, "support_head_width");
optgroup = page->new_optgroup(L("Support pillar")); optgroup = page->new_optgroup(L("Support pillar"));
optgroup->append_single_option_line(prefix + "support_pillar_diameter"); add_options_into_line(optgroup, prefixes, "support_pillar_diameter");
optgroup->append_single_option_line(prefix + "support_small_pillar_diameter_percent"); add_options_into_line(optgroup, prefixes, "support_small_pillar_diameter_percent");
optgroup->append_single_option_line(prefix + "support_max_bridges_on_pillar"); add_options_into_line(optgroup, prefixes, "support_max_bridges_on_pillar");
optgroup->append_single_option_line(prefix + "support_pillar_connection_mode"); add_options_into_line(optgroup, prefixes, "support_pillar_connection_mode");
optgroup->append_single_option_line(prefix + "support_buildplate_only"); add_options_into_line(optgroup, prefixes, "support_buildplate_only");
optgroup->append_single_option_line(prefix + "support_pillar_widening_factor"); add_options_into_line(optgroup, prefixes, "support_pillar_widening_factor");
optgroup->append_single_option_line(prefix + "support_max_weight_on_model"); add_options_into_line(optgroup, prefixes, "support_max_weight_on_model");
optgroup->append_single_option_line(prefix + "support_base_diameter"); add_options_into_line(optgroup, prefixes, "support_base_diameter");
optgroup->append_single_option_line(prefix + "support_base_height"); add_options_into_line(optgroup, prefixes, "support_base_height");
optgroup->append_single_option_line(prefix + "support_base_safety_distance"); add_options_into_line(optgroup, prefixes, "support_base_safety_distance");
// Mirrored parameter from Pad page for toggling elevation on the same page // Mirrored parameter from Pad page for toggling elevation on the same page
optgroup->append_single_option_line(prefix + "support_object_elevation"); add_options_into_line(optgroup, prefixes, "support_object_elevation");
Line line{ "", "" }; Line line{ "", "" };
line.full_width = 1; line.full_width = 1;
@ -4853,9 +4870,9 @@ void TabSLAPrint::build_sla_support_params(const std::string &prefix,
optgroup->append_line(line); optgroup->append_line(line);
optgroup = page->new_optgroup(L("Connection of the support sticks and junctions")); optgroup = page->new_optgroup(L("Connection of the support sticks and junctions"));
optgroup->append_single_option_line(prefix + "support_critical_angle"); add_options_into_line(optgroup, prefixes, "support_critical_angle");
optgroup->append_single_option_line(prefix + "support_max_bridge_length"); add_options_into_line(optgroup, prefixes, "support_max_bridge_length");
optgroup->append_single_option_line(prefix + "support_max_pillar_link_distance"); add_options_into_line(optgroup, prefixes, "support_max_pillar_link_distance");
} }
void TabSLAPrint::build() void TabSLAPrint::build()
@ -4871,46 +4888,11 @@ void TabSLAPrint::build()
page = add_options_page(L("Supports"), "support"/*"sla_supports"*/); page = add_options_page(L("Supports"), "support"/*"sla_supports"*/);
// page = add_options_page(L("Branching"), "supports");
optgroup = page->new_optgroup(L("Supports")); optgroup = page->new_optgroup(L("Supports"));
optgroup->append_single_option_line("supports_enable"); optgroup->append_single_option_line("supports_enable");
optgroup->append_single_option_line("support_tree_type"); optgroup->append_single_option_line("support_tree_type");
build_sla_support_params("", page); build_sla_support_params({{"", "Default"}, {"branching", "Branching"}}, page);
build_sla_support_params("branching", page);
// optgroup = page->new_optgroup(L("Support head"));
// optgroup->append_single_option_line("support_head_front_diameter");
// optgroup->append_single_option_line("support_head_penetration");
// optgroup->append_single_option_line("support_head_width");
// optgroup = page->new_optgroup(L("Support pillar"));
// optgroup->append_single_option_line("support_pillar_diameter");
// optgroup->append_single_option_line("support_small_pillar_diameter_percent");
// optgroup->append_single_option_line("support_max_bridges_on_pillar");
// optgroup->append_single_option_line("support_pillar_connection_mode");
// optgroup->append_single_option_line("support_buildplate_only");
// optgroup->append_single_option_line("support_pillar_widening_factor");
// optgroup->append_single_option_line("support_max_weight_on_model");
// optgroup->append_single_option_line("support_base_diameter");
// optgroup->append_single_option_line("support_base_height");
// optgroup->append_single_option_line("support_base_safety_distance");
// // Mirrored parameter from Pad page for toggling elevation on the same page
// optgroup->append_single_option_line("support_object_elevation");
// Line line{ "", "" };
// line.full_width = 1;
// line.widget = [this](wxWindow* parent) {
// return description_line_widget(parent, &m_support_object_elevation_description_line);
// };
// optgroup->append_line(line);
// optgroup = page->new_optgroup(L("Connection of the support sticks and junctions"));
// optgroup->append_single_option_line("support_critical_angle");
// optgroup->append_single_option_line("support_max_bridge_length");
// optgroup->append_single_option_line("support_max_pillar_link_distance");
optgroup = page->new_optgroup(L("Automatic generation")); optgroup = page->new_optgroup(L("Automatic generation"));
optgroup->append_single_option_line("support_points_density_relative"); optgroup->append_single_option_line("support_points_density_relative");

View File

@ -526,7 +526,10 @@ public:
class TabSLAPrint : public Tab class TabSLAPrint : public Tab
{ {
void build_sla_support_params(const std::string &prefix, // Methods are a vector of method prefix -> method label pairs
// method prefix is the prefix whith which all the config values are prefixed
// for a particular method. The label is the friendly name for the method
void build_sla_support_params(const std::vector<SamePair<std::string>> &methods,
const Slic3r::GUI::PageShp &page); const Slic3r::GUI::PageShp &page);
public: public: