Merge branch 'ys_tilt_next'

This commit is contained in:
Lukas Matena 2025-02-12 17:13:37 +01:00
commit 98bb570090
8 changed files with 147 additions and 75 deletions

View File

@ -107,16 +107,15 @@ std::string to_json(const SLAPrint& print, const ConfMap &m)
switch (opt->type()) {
case coFloats: {
auto values = static_cast<const ConfigOptionFloats*>(opt);
// those options have to be exported in ms instead of s
below_node.put<double>(get_key(opt_key), int(1000 * values->get_at(0)));
above_node.put<double>(get_key(opt_key), int(1000 * values->get_at(1)));
double koef = opt_key == "tower_hop_height" ? 1000000. : 1000.; // export in nm (instead of mm), resp. in ms (instead of s)
below_node.put<double>(get_key(opt_key), int(koef * values->get_at(0)));
above_node.put<double>(get_key(opt_key), int(koef * values->get_at(1)));
}
break;
case coInts: {
auto values = static_cast<const ConfigOptionInts*>(opt);
int koef = opt_key == "tower_hop_height" ? 1000000 : 1;
below_node.put<int>(get_key(opt_key), koef * values->get_at(0));
above_node.put<int>(get_key(opt_key), koef * values->get_at(1));
below_node.put<int>(get_key(opt_key), values->get_at(0));
above_node.put<int>(get_key(opt_key), values->get_at(1));
}
break;
case coBools: {

View File

@ -334,7 +334,7 @@ void Preset::normalize(DynamicPrintConfig &config)
first_layer_height->percent = false;
}
// handle_legacy_sla(config); // it looks like the best place for call it, is handle_legacy_composite
handle_legacy_sla(config);
}
std::string Preset::remove_invalid_keys(DynamicPrintConfig &config, const DynamicPrintConfig &default_config)

View File

@ -4758,14 +4758,14 @@ void PrintConfigDef::init_sla_tilt_params()
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloats({ 0., 0.}));
def = this->add("tower_hop_height", coInts);
def = this->add("tower_hop_height", coFloats);
def->full_label = L("Tower hop height");
def->tooltip = L("The height of the tower raise.");
def->sidetext = L("mm");
def->min = 0;
def->max = 100;
def->mode = comExpert;
def->set_default_value(new ConfigOptionInts({ 0, 0}));
def->set_default_value(new ConfigOptionFloats({ 0., 0.}));
def = this->add("tower_speed", coEnums);
def->full_label = L("Tower speed");
@ -5086,8 +5086,6 @@ void PrintConfigDef::handle_legacy_composite(DynamicPrintConfig &config)
}
config.set_key_value("wiping_volumes_use_custom_matrix", new ConfigOptionBool(custom));
}
handle_legacy_sla(config);
}
const PrintConfigDef print_config_def;
@ -5199,14 +5197,14 @@ const std::map<std::string, ConfigOptionFloats> tilt_options_floats_defs =
{"delay_before_exposure", ConfigOptionFloats({ 3., 3., 0., 1., 3.5, 3.5, 0., 0. }) } ,
{"delay_after_exposure", ConfigOptionFloats({ 0., 0., 0., 0., 0., 0., 0., 0. }) } ,
{"tilt_down_offset_delay", ConfigOptionFloats({ 0., 0., 0., 0., 0., 0., 0., 0. }) } ,
{"tilt_down_delay", ConfigOptionFloats({ 0., 0., 0., 0.5, 0., 0., 0., 0. }) } ,
{"tilt_down_delay", ConfigOptionFloats({ 0., 0., 0., 0., 0., 0., 0., 0. }) } ,
{"tilt_up_offset_delay", ConfigOptionFloats({ 0., 0., 0., 0., 0., 0., 0., 0. }) } ,
{"tilt_up_delay", ConfigOptionFloats({ 0., 0., 0., 0., 0., 0., 0., 0. }) } ,
{"tower_hop_height", ConfigOptionFloats({ 0., 0., 0., 0., 5., 5., 0., 0. }) } ,
};
const std::map<std::string, ConfigOptionInts> tilt_options_ints_defs =
{
{"tower_hop_height", ConfigOptionInts({ 0, 0, 0, 0, 5, 5, 0, 0 }) } ,
{"tilt_down_offset_steps", ConfigOptionInts({ 0, 0, 0, 0, 2200, 2200, 0, 0 }) } ,
{"tilt_down_cycles", ConfigOptionInts({ 1, 1, 1, 1, 1, 1, 0, 0 }) } ,
{"tilt_up_offset_steps", ConfigOptionInts({ 1200, 1200, 600, 600, 2200, 2200, 0, 0 }) } ,
@ -5242,11 +5240,11 @@ const std::map<std::string, ConfigOptionFloats> tilt_options_floats_sl1_defs =
{"tilt_down_delay", ConfigOptionFloats({ 0., 0., 0., 0., 0., 0., 0., 0. }) } ,
{"tilt_up_offset_delay", ConfigOptionFloats({ 0., 0., 0., 0., 1., 1., 0., 0. }) } ,
{"tilt_up_delay", ConfigOptionFloats({ 0., 0., 0., 0., 0., 0., 0., 0. }) } ,
{"tower_hop_height", ConfigOptionFloats({ 0., 0., 0., 0., 5., 5., 0., 0. }) } ,
};
const std::map<std::string, ConfigOptionInts> tilt_options_ints_sl1_defs =
{
{"tower_hop_height", ConfigOptionInts({ 0, 0, 0, 0, 5, 5, 0, 0 }) } ,
{"tilt_down_offset_steps", ConfigOptionInts({ 650, 650, 0, 0, 2200, 2200, 0, 0 }) } ,
{"tilt_down_cycles", ConfigOptionInts({ 1, 1, 1, 1, 1, 1, 0, 0 }) } ,
{"tilt_up_offset_steps", ConfigOptionInts({ 400, 400, 400, 400, 2200, 2200, 0, 0 }) } ,
@ -5299,57 +5297,60 @@ void handle_legacy_sla(DynamicPrintConfig &config)
!config.has("tilt_down_offset_delay") // Config from old PS doesn't contain any of tilt options, so check it
) {
int tilt_mode = config.option("material_print_speed")->getInt();
const bool is_sl1_model = config.opt_string("printer_model") == "SL1";
update_tilts_by_mode(config, tilt_mode, is_sl1_model);
}
}
const std::map<std::string, ConfigOptionFloats> floats_defs = is_sl1_model ? tilt_options_floats_sl1_defs : tilt_options_floats_defs;
const std::map<std::string, ConfigOptionInts> ints_defs = is_sl1_model ? tilt_options_ints_sl1_defs : tilt_options_ints_defs;
const std::map<std::string, ConfigOptionBools> bools_defs = is_sl1_model ? tilt_options_bools_sl1_defs : tilt_options_bools_defs;
const std::map<std::string, ConfigOptionEnums<TowerSpeeds>> tower_enums_defs = is_sl1_model ? tower_tilt_options_enums_sl1_defs : tower_tilt_options_enums_defs;
const std::map<std::string, ConfigOptionEnums<TiltSpeeds>> tilt_enums_defs = is_sl1_model ? tilt_options_enums_sl1_defs : tilt_options_enums_defs;
void update_tilts_by_mode(DynamicPrintConfig& config, int tilt_mode, bool is_sl1_model)
{
const std::map<std::string, ConfigOptionFloats> floats_defs = is_sl1_model ? tilt_options_floats_sl1_defs : tilt_options_floats_defs;
const std::map<std::string, ConfigOptionInts> ints_defs = is_sl1_model ? tilt_options_ints_sl1_defs : tilt_options_ints_defs;
const std::map<std::string, ConfigOptionBools> bools_defs = is_sl1_model ? tilt_options_bools_sl1_defs : tilt_options_bools_defs;
const std::map<std::string, ConfigOptionEnums<TowerSpeeds>> tower_enums_defs = is_sl1_model ? tower_tilt_options_enums_sl1_defs : tower_tilt_options_enums_defs;
const std::map<std::string, ConfigOptionEnums<TiltSpeeds>> tilt_enums_defs = is_sl1_model ? tilt_options_enums_sl1_defs : tilt_options_enums_defs;
for (const std::string& opt_key : tilt_options()) {
switch (config.def()->get(opt_key)->type) {
case coFloats: {
ConfigOptionFloats values = floats_defs.at(opt_key);
double val1 = values.get_at(2 * tilt_mode);
double val2 = values.get_at(2 * tilt_mode + 1);
config.set_key_value(opt_key, new ConfigOptionFloats({ val1, val2 }));
for (const std::string& opt_key : tilt_options()) {
switch (config.def()->get(opt_key)->type) {
case coFloats: {
ConfigOptionFloats values = floats_defs.at(opt_key);
double val1 = values.get_at(2 * tilt_mode);
double val2 = values.get_at(2 * tilt_mode + 1);
config.set_key_value(opt_key, new ConfigOptionFloats({ val1, val2 }));
}
break;
case coInts: {
auto values = ints_defs.at(opt_key);
int val1 = values.get_at(2 * tilt_mode);
int val2 = values.get_at(2 * tilt_mode + 1);
config.set_key_value(opt_key, new ConfigOptionInts({ val1, val2 }));
}
break;
case coBools: {
auto values = bools_defs.at(opt_key);
bool val1 = values.get_at(2 * tilt_mode);
bool val2 = values.get_at(2 * tilt_mode + 1);
config.set_key_value(opt_key, new ConfigOptionBools({ val1, val2 }));
}
break;
case coEnums: {
int val1, val2;
if (opt_key == "tower_speed") {
auto values = tower_enums_defs.at(opt_key);
val1 = values.get_at(2 * tilt_mode);
val2 = values.get_at(2 * tilt_mode + 1);
}
break;
case coInts: {
auto values = ints_defs.at(opt_key);
int val1 = values.get_at(2 * tilt_mode);
int val2 = values.get_at(2 * tilt_mode + 1);
config.set_key_value(opt_key, new ConfigOptionInts({ val1, val2 }));
}
break;
case coBools: {
auto values = bools_defs.at(opt_key);
bool val1 = values.get_at(2 * tilt_mode);
bool val2 = values.get_at(2 * tilt_mode + 1);
config.set_key_value(opt_key, new ConfigOptionBools({ val1, val2 }));
}
break;
case coEnums: {
int val1, val2;
if (opt_key == "tower_speed") {
auto values = tower_enums_defs.at(opt_key);
val1 = values.get_at(2 * tilt_mode);
val2 = values.get_at(2 * tilt_mode + 1);
}
else {
auto values = tilt_enums_defs.at(opt_key);
val1 = values.get_at(2 * tilt_mode);
val2 = values.get_at(2 * tilt_mode + 1);
}
config.set_key_value(opt_key, new ConfigOptionEnumsGeneric({ val1, val2 }));
}
break;
case coNone:
default:
break;
else {
auto values = tilt_enums_defs.at(opt_key);
val1 = values.get_at(2 * tilt_mode);
val2 = values.get_at(2 * tilt_mode + 1);
}
config.set_key_value(opt_key, new ConfigOptionEnumsGeneric({ val1, val2 }));
}
break;
case coNone:
default:
break;
}
}
}

View File

@ -378,6 +378,7 @@ public:
// This vector containes list of parameters for preview of tilt profiles
const std::vector<std::string>& tilt_options();
void update_tilts_by_mode(DynamicPrintConfig& config, int tilt_mode, bool is_sl1_model);
void handle_legacy_sla(DynamicPrintConfig &config);
class StaticPrintConfig : public StaticConfig
@ -1247,7 +1248,7 @@ PRINT_CONFIG_CLASS_DEFINE(
//tilt params
((ConfigOptionFloats, delay_before_exposure))
((ConfigOptionFloats, delay_after_exposure))
((ConfigOptionInts, tower_hop_height))
((ConfigOptionFloats, tower_hop_height))
((ConfigOptionEnums<TowerSpeeds>, tower_speed))
((ConfigOptionBools, use_tilt))
((ConfigOptionEnums<TiltSpeeds>, tilt_down_initial_speed))

View File

@ -695,8 +695,8 @@ std::string SLAPrint::validate(std::vector<std::string>*) const
}
}
if ((!m_material_config.use_tilt.get_at(0) && m_material_config.tower_hop_height.get_at(0) == 0)
|| (!m_material_config.use_tilt.get_at(1) && m_material_config.tower_hop_height.get_at(1) == 0))
if ((!m_material_config.use_tilt.get_at(0) && is_approx(m_material_config.tower_hop_height.get_at(0), 0.))
|| (!m_material_config.use_tilt.get_at(1) && is_approx(m_material_config.tower_hop_height.get_at(1), 0.)))
return _u8L("Disabling the 'Use tilt' function causes the object to separate away from the film in the "
"vertical direction only. Therefore, it is necessary to set the 'Tower hop height' parameter "
"to reasonable value. The recommended value is 5 mm.");

View File

@ -1041,7 +1041,7 @@ struct ExposureProfile {
tilt_down_delay_ms = int(1000 * config.tilt_down_delay.get_at(opt_id));
tilt_up_offset_delay_ms = int(1000 * config.tilt_up_offset_delay.get_at(opt_id));
tilt_up_delay_ms = int(1000 * config.tilt_up_delay.get_at(opt_id));
tower_hop_height_nm = config.tower_hop_height.get_at(opt_id) * 1000000;
tower_hop_height_nm = int(config.tower_hop_height.get_at(opt_id) * 1000000);
tilt_down_offset_steps = config.tilt_down_offset_steps.get_at(opt_id);
tilt_down_cycles = config.tilt_down_cycles.get_at(opt_id);
tilt_up_offset_steps = config.tilt_up_offset_steps.get_at(opt_id);

View File

@ -38,6 +38,7 @@
#include "Search.hpp"
#include "OG_CustomCtrl.hpp"
#include <tuple>
#include <wx/app.h>
#include <wx/button.h>
#include <wx/scrolwin.h>
@ -3674,13 +3675,6 @@ void TabPrinter::update_fff()
toggle_options();
}
bool Tab::is_prusa_printer() const
{
const Preset& edited_preset = m_preset_bundle->printers.get_edited_preset();
std::string printer_model = edited_preset.trim_vendor_repo_prefix(edited_preset.config.opt_string("printer_model"));
return SLAPrint::is_prusa_print(printer_model);
}
void TabPrinter::update_sla()
{
}
@ -5493,10 +5487,10 @@ static void append_tilt_options_line(ConfigOptionsGroupShp optgroup, const std::
optgroup->append_line(line);
}
void TabSLAMaterial::build_tilt_group(Slic3r::GUI::PageShp page)
static void create_tilt_legend(ConfigOptionsGroupShp optgroup)
{
// Legend
std::vector<std::pair<std::string, std::string>> legend_columns = {
std::vector<std::pair<std::string, std::string>> columns = {
// TRN: This is a label of a column of parameters in settings to be used when the area is below certain threshold.
{L("Below"),
L("Values in this column are applied when layer area is smaller than area_fill.")},
@ -5504,8 +5498,27 @@ void TabSLAMaterial::build_tilt_group(Slic3r::GUI::PageShp page)
{L("Above"),
L("Values in this column are applied when layer area is larger than area_fill.")},
};
create_legend(page, legend_columns, comExpert/*, true*/);
auto legend = [columns](wxWindow* parent) {
auto legend_sizer = new wxBoxSizer(wxHORIZONTAL);
legend_sizer->Add(new wxStaticText(parent, wxID_ANY, "", wxDefaultPosition, wxSize(25*em_unit(parent), -1)));
for (auto& [name, tooltip] : columns) {
auto legend_item = new wxStaticText(parent, wxID_ANY, _(name), wxDefaultPosition, wxSize(20*em_unit(parent), -1));
legend_item->SetToolTip(_(tooltip));
legend_sizer->Add(legend_item);
}
return legend_sizer;
};
Line line = Line{ "", "" };
line.full_width = 1;
line.append_widget(legend);
optgroup->append_line(line);
}
void TabSLAMaterial::build_tilt_group(Slic3r::GUI::PageShp page)
{
// TRN: 'Profile' in this context denotes a group of parameters used to configure
// layer separation procedure for SLA printers.
auto optgroup = page->new_optgroup(L("Profile settings"));
@ -5518,10 +5531,50 @@ void TabSLAMaterial::build_tilt_group(Slic3r::GUI::PageShp page)
update();
};
create_line_with_tilt_defaults(optgroup);
create_tilt_legend(optgroup);
for (const std::string& opt_key : tilt_options())
append_tilt_options_line(optgroup, opt_key);
}
std::vector<std::tuple<wxString, wxString, int>> default_tilt_buttons = {
{ _L("Fast"), _L("Set default values for fast print speed"), SLAMaterialSpeed::slamsFast },
{ _L("Slow"), _L("Set default values for slow print speed"), SLAMaterialSpeed::slamsSlow },
{ _L("High viscosity"), _L("Set default values for high viscosity print speed"), SLAMaterialSpeed::slamsHighViscosity }
};
void TabSLAMaterial::create_line_with_tilt_defaults(ConfigOptionsGroupShp optgroup)
{
auto print_speed_btns = [this](wxWindow* parent) {
m_tilt_defaults_sizer = new wxBoxSizer(wxHORIZONTAL);
auto grid_sizer = new wxGridSizer(3, 0, 0);
for (const auto& [label, tooltip, material_speed] : default_tilt_buttons) {
ScalableButton* btn;
add_scaled_button(parent, &btn, "cog", label + " ", wxBU_EXACTFIT);
btn->SetToolTip(tooltip);
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
int tilt_mode = int(material_speed);
btn->Bind(wxEVT_BUTTON, [this, tilt_mode](wxCommandEvent&) {
DynamicPrintConfig new_conf = *m_config;
update_tilts_by_mode(new_conf, tilt_mode, false);
load_config(new_conf);
});
grid_sizer->Add(btn, 1, wxEXPAND | wxRIGHT, 5);
}
m_tilt_defaults_sizer->Add(grid_sizer, 0, wxALIGN_CENTRE_VERTICAL);
return m_tilt_defaults_sizer;
};
Line line = Line{ "", "" };
line.full_width = 1;
line.append_widget(print_speed_btns);
optgroup->append_line(line);
}
std::vector<std::string> disable_tilt_options = {
"tilt_down_initial_speed"
,"tilt_down_offset_steps"
@ -5589,14 +5642,28 @@ void TabSLAMaterial::update_description_lines()
Tab::update_description_lines();
}
std::string Tab::printer_model() const
{
const Preset& edited_preset = m_preset_bundle->printers.get_edited_preset();
return edited_preset.trim_vendor_repo_prefix(edited_preset.config.opt_string("printer_model"));
}
bool Tab::is_prusa_printer() const
{
return SLAPrint::is_prusa_print(printer_model());
}
void TabSLAMaterial::update_sla_prusa_specific_visibility()
{
if (m_active_page && m_active_page->title() == "Material printing profile") {
for (auto& title : { "", "Profile settings" }) {
auto og_it = std::find_if(m_active_page->m_optgroups.begin(), m_active_page->m_optgroups.end(),
[title](const ConfigOptionsGroupShp og) { return og->title == title; });
if (og_it != m_active_page->m_optgroups.end())
if (og_it != m_active_page->m_optgroups.end()) {
og_it->get()->Show(m_mode >= comAdvanced && is_prusa_printer());
const std::string pr_model = printer_model();
m_tilt_defaults_sizer->Show(pr_model == "SL1S" || pr_model == "M1");
}
}
auto og_it = std::find_if(m_active_page->m_optgroups.begin(), m_active_page->m_optgroups.end(),
@ -5616,6 +5683,7 @@ void TabSLAMaterial::clear_pages()
over_opt.second = nullptr;
m_z_correction_to_mm_description = nullptr;
m_tilt_defaults_sizer = nullptr;
}
void TabSLAMaterial::msw_rescale()

View File

@ -426,6 +426,7 @@ protected:
void update_frequently_changed_parameters();
void fill_icon_descriptions();
void set_tooltips_text();
std::string printer_model() const;
virtual bool select_preset_by_name(const std::string& name_w_suffix, bool force);
virtual bool save_current_preset(const std::string& new_name, bool detach);
@ -569,9 +570,11 @@ class TabSLAMaterial : public Tab
void update_line_with_near_label_widget(ConfigOptionsGroupShp optgroup, const std::string& opt_key, bool is_checked = true);
void add_material_overrides_page();
void update_material_overrides_page();
void create_line_with_tilt_defaults(ConfigOptionsGroupShp optgroup);
std::map<std::string, wxWindow*> m_overrides_options;
ogStaticText* m_z_correction_to_mm_description = nullptr;
wxSizer* m_tilt_defaults_sizer { nullptr };
public:
TabSLAMaterial(wxBookCtrlBase* parent) :