mirror of
https://git.mirrors.martin98.com/https://github.com/bambulab/BambuStudio.git
synced 2025-09-29 11:23:14 +08:00
ENH: UnsavedChangesDialog support extruder variant
Change-Id: Ifd021461d23b385b71dedbe9cc864eeee1a2541b Jira: STUDIO-7711
This commit is contained in:
parent
c49c0c8f72
commit
2aed1142ec
@ -94,7 +94,7 @@ void OptionsSearcher::append_options(DynamicPrintConfig *config, Preset::Type ty
|
|||||||
|
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
|
|
||||||
if ((type == Preset::TYPE_SLA_MATERIAL || type == Preset::TYPE_PRINTER) && opt_key != "printable_area")
|
if ((type == Preset::TYPE_SLA_MATERIAL || type == Preset::TYPE_PRINTER || type == Preset::TYPE_PRINT) && opt_key != "printable_area")
|
||||||
switch (config->option(opt_key)->type()) {
|
switch (config->option(opt_key)->type()) {
|
||||||
case coInts: change_opt_key<ConfigOptionInts>(opt_key, config, cnt); break;
|
case coInts: change_opt_key<ConfigOptionInts>(opt_key, config, cnt); break;
|
||||||
case coBools: change_opt_key<ConfigOptionBools>(opt_key, config, cnt); break;
|
case coBools: change_opt_key<ConfigOptionBools>(opt_key, config, cnt); break;
|
||||||
@ -107,6 +107,9 @@ void OptionsSearcher::append_options(DynamicPrintConfig *config, Preset::Type ty
|
|||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type == Preset::TYPE_FILAMENT && filament_options_with_variant.find(opt_key) != filament_options_with_variant.end())
|
||||||
|
opt_key += "#0";
|
||||||
|
|
||||||
wxString label = opt.full_label.empty() ? opt.label : opt.full_label;
|
wxString label = opt.full_label.empty() ? opt.label : opt.full_label;
|
||||||
|
|
||||||
std::string key = get_key(opt_key, type);
|
std::string key = get_key(opt_key, type);
|
||||||
@ -301,12 +304,34 @@ const Option &OptionsSearcher::get_option(size_t pos_in_filter) const
|
|||||||
return options[found[pos_in_filter].option_idx];
|
return options[found[pos_in_filter].option_idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
const Option &OptionsSearcher::get_option(const std::string &opt_key, Preset::Type type) const
|
const Option &OptionsSearcher::get_option(const std::string &opt_key, Preset::Type type, int &variant_index) const
|
||||||
{
|
{
|
||||||
auto it = std::lower_bound(options.begin(), options.end(), Option({boost::nowide::widen(get_key(opt_key, type))}));
|
std::string opt_key2 = opt_key;
|
||||||
|
if (auto n = opt_key.find('#'); n != std::string::npos) {
|
||||||
|
variant_index = std::atoi(opt_key.c_str() + n + 1);
|
||||||
|
opt_key2 = opt_key.substr(0, n);
|
||||||
|
}
|
||||||
|
auto it = std::lower_bound(options.begin(), options.end(), Option({boost::nowide::widen(get_key(opt_key2, type))}));
|
||||||
// BBS: return the 0th option when not found in searcher caused by mode difference
|
// BBS: return the 0th option when not found in searcher caused by mode difference
|
||||||
// assert(it != options.end());
|
// assert(it != options.end());
|
||||||
if (it == options.end()) return options[0];
|
if (it == options.end()) return options[0];
|
||||||
|
if (it->opt_key() == opt_key2) {
|
||||||
|
variant_index = -1;
|
||||||
|
} else if (it->opt_key() != opt_key) {
|
||||||
|
auto it2 = it;
|
||||||
|
while (it2 != options.end() && it2->opt_key() != opt_key && it2->opt_key().compare(0, opt_key2.length(), opt_key2) == 0)
|
||||||
|
++it2;
|
||||||
|
if (it2->opt_key() == opt_key)
|
||||||
|
it = it2;
|
||||||
|
if (it2 == it)
|
||||||
|
variant_index = -2;
|
||||||
|
} else {
|
||||||
|
auto it2 = it;
|
||||||
|
++it2;
|
||||||
|
if (it2 != options.end() && it2->opt_key().compare(0, opt_key2.length(), opt_key2) == 0
|
||||||
|
&& printer_options_with_variant_1.find(opt_key2) == printer_options_with_variant_1.end())
|
||||||
|
variant_index = -2;
|
||||||
|
}
|
||||||
|
|
||||||
return options[it - options.begin()];
|
return options[it - options.begin()];
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ public:
|
|||||||
|
|
||||||
const FoundOption &operator[](const size_t pos) const noexcept { return found[pos]; }
|
const FoundOption &operator[](const size_t pos) const noexcept { return found[pos]; }
|
||||||
const Option & get_option(size_t pos_in_filter) const;
|
const Option & get_option(size_t pos_in_filter) const;
|
||||||
const Option & get_option(const std::string &opt_key, Preset::Type type) const;
|
const Option & get_option(const std::string &opt_key, Preset::Type type, int &variant_index) const;
|
||||||
Option get_option(const std::string &opt_key, const wxString &label, Preset::Type type) const;
|
Option get_option(const std::string &opt_key, const wxString &label, Preset::Type type) const;
|
||||||
|
|
||||||
const std::vector<FoundOption> &found_options() { return found; }
|
const std::vector<FoundOption> &found_options() { return found; }
|
||||||
|
@ -5915,7 +5915,7 @@ void Tab::switch_excluder(int extruder_id, bool reload)
|
|||||||
}
|
}
|
||||||
page->m_opt_id_map.clear();
|
page->m_opt_id_map.clear();
|
||||||
for (auto group : page->m_optgroups) {
|
for (auto group : page->m_optgroups) {
|
||||||
if (is_extruder && group->title == "Type") {
|
if (is_extruder && (group->title == "Type" || group->title == "Layer height limits" || group->title == "Position")) {
|
||||||
for (auto &opt : group->opt_map())
|
for (auto &opt : group->opt_map())
|
||||||
page->m_opt_id_map.insert({opt.first, opt.first});
|
page->m_opt_id_map.insert({opt.first, opt.first});
|
||||||
continue;
|
continue;
|
||||||
|
@ -1459,21 +1459,23 @@ void UnsavedChangesDialog::update_list()
|
|||||||
|
|
||||||
// group
|
// group
|
||||||
for (auto i = 0; i < m_presetitems.size(); i++) {
|
for (auto i = 0; i < m_presetitems.size(); i++) {
|
||||||
if (class_g_list.count(m_presetitems[i].group_name) <= 0) {
|
auto name = m_presetitems[i].category_name + ":" + m_presetitems[i].group_name;
|
||||||
|
if (class_g_list.count(name) <= 0) {
|
||||||
std::vector<PresetItem> vp;
|
std::vector<PresetItem> vp;
|
||||||
vp.push_back(m_presetitems[i]);
|
vp.push_back(m_presetitems[i]);
|
||||||
class_g_list.emplace(m_presetitems[i].group_name, vp);
|
class_g_list.emplace(name, vp);
|
||||||
} else {
|
} else {
|
||||||
//for (auto iter = class_g_list.begin(); iter != class_g_list.end(); iter++) iter->second.push_back(m_presetitems[i]);
|
//for (auto iter = class_g_list.begin(); iter != class_g_list.end(); iter++) iter->second.push_back(m_presetitems[i]);
|
||||||
class_g_list[m_presetitems[i].group_name].push_back(m_presetitems[i]);
|
class_g_list[name].push_back(m_presetitems[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// category
|
// category
|
||||||
for (auto i = 0; i < m_presetitems.size(); i++) {
|
for (auto i = 0; i < m_presetitems.size(); i++) {
|
||||||
|
auto name = m_presetitems[i].category_name + ":" + m_presetitems[i].group_name;
|
||||||
if (class_c_list.count(m_presetitems[i].category_name) <= 0) {
|
if (class_c_list.count(m_presetitems[i].category_name) <= 0) {
|
||||||
std::vector<wxString> vp;
|
std::vector<wxString> vp;
|
||||||
vp.push_back(m_presetitems[i].group_name);
|
vp.push_back(name);
|
||||||
class_c_list.emplace(m_presetitems[i].category_name, vp);
|
class_c_list.emplace(m_presetitems[i].category_name, vp);
|
||||||
category_list.push_back(m_presetitems[i].category_name);
|
category_list.push_back(m_presetitems[i].category_name);
|
||||||
} else {
|
} else {
|
||||||
@ -1481,9 +1483,9 @@ void UnsavedChangesDialog::update_list()
|
|||||||
iter->second.push_back(m_presetitems[i].group_name);*/
|
iter->second.push_back(m_presetitems[i].group_name);*/
|
||||||
//class_c_list[m_presetitems[i].category_name].push_back(m_presetitems[i].group_name);
|
//class_c_list[m_presetitems[i].category_name].push_back(m_presetitems[i].group_name);
|
||||||
std::vector<wxString>::iterator it;
|
std::vector<wxString>::iterator it;
|
||||||
it = find(class_c_list[m_presetitems[i].category_name].begin(), class_c_list[m_presetitems[i].category_name].end(), m_presetitems[i].group_name);
|
it = find(class_c_list[m_presetitems[i].category_name].begin(), class_c_list[m_presetitems[i].category_name].end(), name);
|
||||||
if (it == class_c_list[m_presetitems[i].category_name].end()) {
|
if (it == class_c_list[m_presetitems[i].category_name].end()) {
|
||||||
class_c_list[m_presetitems[i].category_name].push_back(m_presetitems[i].group_name);
|
class_c_list[m_presetitems[i].category_name].push_back(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1535,7 +1537,7 @@ void UnsavedChangesDialog::update_list()
|
|||||||
|
|
||||||
wxBoxSizer *sizer_left_v = new wxBoxSizer(wxVERTICAL);
|
wxBoxSizer *sizer_left_v = new wxBoxSizer(wxVERTICAL);
|
||||||
|
|
||||||
auto text_left = new wxStaticText(panel_left, wxID_ANY, gname, wxDefaultPosition, wxSize(-1, -1), 0);
|
auto text_left = new wxStaticText(panel_left, wxID_ANY, class_g_list[gname][0].group_name, wxDefaultPosition, wxSize(-1, -1), 0);
|
||||||
text_left->SetFont(::Label::Head_13);
|
text_left->SetFont(::Label::Head_13);
|
||||||
text_left->Wrap(-1);
|
text_left->Wrap(-1);
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
@ -1686,7 +1688,7 @@ void UnsavedChangesDialog::update_tree(Preset::Type type, PresetCollection* pres
|
|||||||
//m_tree->model->AddPreset(type, from_u8(presets->get_edited_preset().name), old_pt);
|
//m_tree->model->AddPreset(type, from_u8(presets->get_edited_preset().name), old_pt);
|
||||||
|
|
||||||
// Collect dirty options.
|
// Collect dirty options.
|
||||||
const bool deep_compare = (type == Preset::TYPE_PRINTER || type == Preset::TYPE_SLA_MATERIAL);
|
const bool deep_compare = (type == Preset::TYPE_PRINTER || type == Preset::TYPE_PRINT || type == Preset::TYPE_FILAMENT || type == Preset::TYPE_SLA_MATERIAL);
|
||||||
auto dirty_options = presets->current_dirty_options(deep_compare);
|
auto dirty_options = presets->current_dirty_options(deep_compare);
|
||||||
|
|
||||||
// process changes of extruders count
|
// process changes of extruders count
|
||||||
@ -1704,14 +1706,30 @@ void UnsavedChangesDialog::update_tree(Preset::Type type, PresetCollection* pres
|
|||||||
m_presetitems.push_back(pi);
|
m_presetitems.push_back(pi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto variant_key = Preset::get_iot_type_string(type) + "_extruder_variant";
|
||||||
|
auto id_key = Preset::get_iot_type_string(type) + "_extruder_id";
|
||||||
|
auto extruder_variant = dynamic_cast<ConfigOptionStrings const *>(old_config.option(variant_key));
|
||||||
|
auto extruder_id = dynamic_cast<ConfigOptionInts const *>(old_config.option(id_key));
|
||||||
|
|
||||||
for (const std::string& opt_key : dirty_options) {
|
for (const std::string& opt_key : dirty_options) {
|
||||||
const Search::Option& option = searcher.get_option(opt_key, type);
|
int variant_index = -2;
|
||||||
if (option.opt_key() != opt_key) {
|
const Search::Option &option = searcher.get_option(opt_key, type, variant_index);
|
||||||
|
if (option.opt_key() != opt_key && variant_index < -1) {
|
||||||
// When founded option isn't the correct one.
|
// When founded option isn't the correct one.
|
||||||
// It can be for dirty_options: "default_print_profile", "printer_model", "printer_settings_id",
|
// It can be for dirty_options: "default_print_profile", "printer_model", "printer_settings_id",
|
||||||
// because of they don't exist in searcher
|
// because of they don't exist in searcher
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
auto category = option.category_local;
|
||||||
|
if (variant_index >= 0) {
|
||||||
|
if (boost::nowide::narrow(category).find("Extruder ") == 0)
|
||||||
|
category = category.substr(0, 8);
|
||||||
|
if (extruder_id)
|
||||||
|
category = category + (wxString(" {") + (extruder_id->values[variant_index] == 1 ? _L("Left: ") : _L("Right: "))
|
||||||
|
+ L(extruder_variant->values[variant_index]) + "}");
|
||||||
|
else
|
||||||
|
category = category + (" {" + L(extruder_variant->values[variant_index]) + "}");
|
||||||
|
}
|
||||||
|
|
||||||
/*m_tree->Append(opt_key, type, option.category_local, option.group_local, option.label_local,
|
/*m_tree->Append(opt_key, type, option.category_local, option.group_local, option.label_local,
|
||||||
get_string_value(opt_key, old_config), get_string_value(opt_key, new_config), category_icon_map.at(option.category));*/
|
get_string_value(opt_key, old_config), get_string_value(opt_key, new_config), category_icon_map.at(option.category));*/
|
||||||
@ -1719,7 +1737,7 @@ void UnsavedChangesDialog::update_tree(Preset::Type type, PresetCollection* pres
|
|||||||
|
|
||||||
//PresetItem pi = {opt_key, type, 1983};
|
//PresetItem pi = {opt_key, type, 1983};
|
||||||
//m_presetitems.push_back()
|
//m_presetitems.push_back()
|
||||||
PresetItem pi = {type, opt_key, option.category_local, option.group_local, option.label_local, get_string_value(opt_key, old_config), get_string_value(opt_key, new_config)};
|
PresetItem pi = {type, opt_key, category, option.group_local, option.label_local, get_string_value(opt_key, old_config), get_string_value(opt_key, new_config)};
|
||||||
m_presetitems.push_back(pi);
|
m_presetitems.push_back(pi);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user