mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-19 11:23:42 +00:00
ENH: Display and modification of printer presets
Change-Id: I6a38704864fd4994a845686a299bec67f1b9b9b3 (cherry picked from commit 5b0d5259571d2b1c629ba7d88101134ec4548708)
This commit is contained in:
@@ -7605,7 +7605,7 @@ bool DynamicPrintConfig::support_different_extruders(int& extruder_count)
|
|||||||
return (variant_set.size() > 1);
|
return (variant_set.size() > 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DynamicPrintConfig::get_index_for_extruder(int extruder_id, std::string id_name, ExtruderType extruder_type, NozzleVolumeType nozzle_volume_type, std::string variant_name)
|
int DynamicPrintConfig::get_index_for_extruder(int extruder_id, std::string id_name, ExtruderType extruder_type, NozzleVolumeType nozzle_volume_type, std::string variant_name) const
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
|
|||||||
@@ -604,7 +604,7 @@ public:
|
|||||||
//BBS
|
//BBS
|
||||||
bool is_using_different_extruders();
|
bool is_using_different_extruders();
|
||||||
bool support_different_extruders(int& extruder_count);
|
bool support_different_extruders(int& extruder_count);
|
||||||
int get_index_for_extruder(int extruder_id, std::string id_name, ExtruderType extruder_type, NozzleVolumeType nozzle_volume_type, std::string variant_name);
|
int get_index_for_extruder(int extruder_id, std::string id_name, ExtruderType extruder_type, NozzleVolumeType nozzle_volume_type, std::string variant_name) const;
|
||||||
void update_values_to_printer_extruders(DynamicPrintConfig& printer_config, std::set<std::string>& key_set, std::string id_name, std::string variant_name, unsigned int stride = 1, unsigned int extruder_id = 0);
|
void update_values_to_printer_extruders(DynamicPrintConfig& printer_config, std::set<std::string>& key_set, std::string id_name, std::string variant_name, unsigned int stride = 1, unsigned int extruder_id = 0);
|
||||||
|
|
||||||
bool is_custom_defined();
|
bool is_custom_defined();
|
||||||
|
|||||||
@@ -24,6 +24,48 @@ namespace Slic3r { namespace GUI {
|
|||||||
|
|
||||||
// BBS: new layout
|
// BBS: new layout
|
||||||
constexpr int titleWidth = 20;
|
constexpr int titleWidth = 20;
|
||||||
|
int get_extruder_idx(const DynamicPrintConfig& config, const std::string &opt_key, int cur_extruder_id)
|
||||||
|
{
|
||||||
|
int extruder_count = wxGetApp().preset_bundle->get_printer_extruder_count();
|
||||||
|
if (extruder_count == 1 || cur_extruder_id == -1)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
assert(cur_extruder_id < extruder_count);
|
||||||
|
auto opt_extruder_type = dynamic_cast<const ConfigOptionEnumsGeneric *>(config.option("extruder_type"));
|
||||||
|
auto opt_nozzle_volume_type = dynamic_cast<const ConfigOptionEnumsGeneric *>(config.option("nozzle_volume_type"));
|
||||||
|
|
||||||
|
if (!opt_extruder_type || !opt_nozzle_volume_type)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ExtruderType extruder_type = (ExtruderType) (opt_extruder_type->get_at(cur_extruder_id));
|
||||||
|
NozzleVolumeType nozzle_volume_type = (NozzleVolumeType) (opt_nozzle_volume_type->get_at(cur_extruder_id));
|
||||||
|
|
||||||
|
std::string id_name, variant_name;
|
||||||
|
if (printer_options_with_variant_1.count(opt_key) > 0) { // printer parameter
|
||||||
|
id_name = "printer_extruder_id";
|
||||||
|
variant_name = "printer_extruder_variant";
|
||||||
|
} else if (printer_options_with_variant_2.count(opt_key) > 0) {
|
||||||
|
id_name = "printer_extruder_id";
|
||||||
|
variant_name = "printer_extruder_variant";
|
||||||
|
} else if (filament_options_with_variant.count(opt_key) > 0) {
|
||||||
|
id_name = "filament_extruder_id";
|
||||||
|
variant_name = "filament_extruder_variant";
|
||||||
|
} else if (print_options_with_variant.count(opt_key) > 0) {
|
||||||
|
id_name = "print_extruder_id";
|
||||||
|
variant_name = "print_extruder_variant";
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// variant index
|
||||||
|
int variant_index = config.get_index_for_extruder(cur_extruder_id + 1, id_name, extruder_type, nozzle_volume_type, variant_name);
|
||||||
|
if (variant_index < 0) {
|
||||||
|
assert(false);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return variant_index;
|
||||||
|
}
|
||||||
|
|
||||||
const t_field& OptionsGroup::build_field(const Option& opt) {
|
const t_field& OptionsGroup::build_field(const Option& opt) {
|
||||||
return build_field(opt.opt_id, opt.opt);
|
return build_field(opt.opt_id, opt.opt);
|
||||||
@@ -643,8 +685,7 @@ void ConfigOptionsGroup::on_change_OG(const t_config_option_key& opt_id, const b
|
|||||||
|
|
||||||
auto itOption = it->second;
|
auto itOption = it->second;
|
||||||
const std::string &opt_key = itOption.first;
|
const std::string &opt_key = itOption.first;
|
||||||
int opt_index = itOption.second;
|
int opt_index = get_extruder_idx(*m_config, itOption.first, itOption.second);
|
||||||
|
|
||||||
this->change_opt_value(opt_key, value, opt_index == -1 ? 0 : opt_index);
|
this->change_opt_value(opt_key, value, opt_index == -1 ? 0 : opt_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -733,7 +774,7 @@ void ConfigOptionsGroup::reload_config()
|
|||||||
// option key (may be scalar or vector)
|
// option key (may be scalar or vector)
|
||||||
const std::string &opt_key = kvp.second.first;
|
const std::string &opt_key = kvp.second.first;
|
||||||
// index in the vector option, zero for scalars
|
// index in the vector option, zero for scalars
|
||||||
int opt_index = kvp.second.second;
|
int opt_index = get_extruder_idx(*m_config, kvp.second.first, kvp.second.second);
|
||||||
const ConfigOptionDef &option = m_options.at(opt_id).opt;
|
const ConfigOptionDef &option = m_options.at(opt_id).opt;
|
||||||
this->set_value(opt_id, config_value(opt_key, opt_index, option.gui_flags == "serialized"));
|
this->set_value(opt_id, config_value(opt_key, opt_index, option.gui_flags == "serialized"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
|
|
||||||
namespace Slic3r { namespace GUI {
|
namespace Slic3r { namespace GUI {
|
||||||
|
|
||||||
|
extern int get_extruder_idx(const DynamicPrintConfig& config, const std::string &opt_key, int cur_extruder_id);
|
||||||
|
|
||||||
// Thrown if the building of a parameter page is canceled.
|
// Thrown if the building of a parameter page is canceled.
|
||||||
class UIBuildCanceled : public std::exception {};
|
class UIBuildCanceled : public std::exception {};
|
||||||
class OG_CustomCtrl;
|
class OG_CustomCtrl;
|
||||||
|
|||||||
@@ -859,6 +859,35 @@ void Tab::decorate()
|
|||||||
m_active_page->refresh();
|
m_active_page->refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> Tab::filter_diff_option(const std::vector<std::string> &options)
|
||||||
|
{
|
||||||
|
auto get_name_and_index = [](const std::string& value) -> std::pair<std::string, int>{
|
||||||
|
size_t pos = value.find("#");
|
||||||
|
if (pos != std::string::npos) {
|
||||||
|
std::string param_name = value.substr(0, pos);
|
||||||
|
std::string number_str = value.substr(pos + 1);
|
||||||
|
int index = 0;
|
||||||
|
if (!number_str.empty()) {
|
||||||
|
index = std::stoi(number_str);
|
||||||
|
}
|
||||||
|
return std::make_pair(param_name, index);
|
||||||
|
}
|
||||||
|
return std::make_pair(value, 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<std::string> diff_options;
|
||||||
|
for (std::string option : options) {
|
||||||
|
auto name_to_index = get_name_and_index(option);
|
||||||
|
int active_index = get_extruder_idx(*m_config, name_to_index.first, m_active_page->m_extruder_idx);
|
||||||
|
if (active_index == name_to_index.second) {
|
||||||
|
std::string name_to_extruder_id = name_to_index.first + "#" + std::to_string(m_active_page->m_extruder_idx);
|
||||||
|
diff_options.emplace_back(name_to_extruder_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return diff_options;
|
||||||
|
}
|
||||||
|
|
||||||
// Update UI according to changes
|
// Update UI according to changes
|
||||||
void Tab::update_changed_ui()
|
void Tab::update_changed_ui()
|
||||||
{
|
{
|
||||||
@@ -879,8 +908,14 @@ void Tab::update_changed_ui()
|
|||||||
for (auto& it : m_options_list)
|
for (auto& it : m_options_list)
|
||||||
it.second = m_opt_status_value;
|
it.second = m_opt_status_value;
|
||||||
|
|
||||||
for (auto opt_key : dirty_options) m_options_list[opt_key] &= ~osInitValue;
|
dirty_options = filter_diff_option(dirty_options);
|
||||||
for (auto opt_key : nonsys_options) m_options_list[opt_key] &= ~osSystemValue;
|
|
||||||
|
for (auto opt_key : dirty_options) {
|
||||||
|
m_options_list[opt_key] &= ~osInitValue;
|
||||||
|
}
|
||||||
|
for (auto opt_key : nonsys_options) {
|
||||||
|
m_options_list[opt_key] &= ~osSystemValue;
|
||||||
|
}
|
||||||
|
|
||||||
update_custom_dirty();
|
update_custom_dirty();
|
||||||
|
|
||||||
@@ -4429,6 +4464,7 @@ if (is_marlin_flavor)
|
|||||||
//# build page
|
//# build page
|
||||||
//const wxString& page_name = wxString::Format(_L("Extruder %d"), int(extruder_idx + 1));
|
//const wxString& page_name = wxString::Format(_L("Extruder %d"), int(extruder_idx + 1));
|
||||||
auto page = add_options_page(page_name, "custom-gcode_extruder", true); // ORCA: icon only visible on placeholders
|
auto page = add_options_page(page_name, "custom-gcode_extruder", true); // ORCA: icon only visible on placeholders
|
||||||
|
page->m_extruder_idx = extruder_idx;
|
||||||
m_pages.insert(m_pages.begin() + n_before_extruders + extruder_idx, page);
|
m_pages.insert(m_pages.begin() + n_before_extruders + extruder_idx, page);
|
||||||
|
|
||||||
auto optgroup = page->new_optgroup(L("Size"), L"param_extruder_size");
|
auto optgroup = page->new_optgroup(L("Size"), L"param_extruder_size");
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ public:
|
|||||||
// BBS
|
// BBS
|
||||||
bool m_split_multi_line = false;
|
bool m_split_multi_line = false;
|
||||||
bool m_option_label_at_right = false;
|
bool m_option_label_at_right = false;
|
||||||
|
int m_extruder_idx = 0; // if is multi extruder, recorde the page is belong to which extruder
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::vector <ConfigOptionsGroupShp> m_optgroups;
|
std::vector <ConfigOptionsGroupShp> m_optgroups;
|
||||||
@@ -434,6 +435,7 @@ protected:
|
|||||||
void update_preset_description_line();
|
void update_preset_description_line();
|
||||||
void update_frequently_changed_parameters();
|
void update_frequently_changed_parameters();
|
||||||
void set_tooltips_text();
|
void set_tooltips_text();
|
||||||
|
std::vector<std::string> filter_diff_option(const std::vector<std::string> &options);
|
||||||
|
|
||||||
ConfigManipulation m_config_manipulation;
|
ConfigManipulation m_config_manipulation;
|
||||||
ConfigManipulation get_config_manipulation();
|
ConfigManipulation get_config_manipulation();
|
||||||
|
|||||||
Reference in New Issue
Block a user