mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 15:56:05 +08:00
Added buttons for set default tilt values
SPE-2666
This commit is contained in:
parent
7e4ac102f4
commit
9896788693
@ -5299,57 +5299,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
@ -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) :
|
||||
|
Loading…
x
Reference in New Issue
Block a user