ENH: config apply_only vector at index
Change-Id: I7bf5a44b2d3db2e21207696b6ef7e41a499da078 Jira: STUDIO-7747
This commit is contained in:
parent
99048f668c
commit
5f30ee389e
|
@ -451,6 +451,17 @@ void ConfigBase::apply_only(const ConfigBase &other, const t_config_option_keys
|
|||
if (my_opt == nullptr) {
|
||||
// opt_key does not exist in this ConfigBase and it cannot be created, because it is not defined by this->def().
|
||||
// This is only possible if other is of DynamicConfig type.
|
||||
if (auto n = opt_key.find('#'); n != std::string::npos) {
|
||||
auto opt_key2 = opt_key.substr(0, n);
|
||||
auto my_opt2 = dynamic_cast<ConfigOptionVectorBase*>(this->option(opt_key2, true));
|
||||
if (my_opt2) {
|
||||
int index = std::atoi(opt_key.c_str() + n + 1);
|
||||
auto other_opt = other.option(opt_key2);
|
||||
if (other_opt)
|
||||
my_opt2->set_at(other_opt, index, index);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (ignore_nonexistent)
|
||||
continue;
|
||||
throw UnknownOptionException(opt_key);
|
||||
|
|
|
@ -1739,6 +1739,7 @@ void Tab::apply_searcher()
|
|||
|
||||
void Tab::cache_config_diff(const std::vector<std::string>& selected_options)
|
||||
{
|
||||
m_cache_options = selected_options;
|
||||
m_cache_config.apply_only(m_presets->get_edited_preset().config, selected_options);
|
||||
}
|
||||
|
||||
|
@ -1751,8 +1752,9 @@ void Tab::apply_config_from_cache()
|
|||
was_applied = static_cast<TabPrinter*>(this)->apply_extruder_cnt_from_cache();
|
||||
|
||||
if (!m_cache_config.empty()) {
|
||||
m_presets->get_edited_preset().config.apply(m_cache_config);
|
||||
m_presets->get_edited_preset().config.apply_only(m_cache_config, m_cache_options);
|
||||
m_cache_config.clear();
|
||||
m_cache_options.clear();
|
||||
|
||||
was_applied = true;
|
||||
}
|
||||
|
@ -4737,11 +4739,15 @@ bool Tab::select_preset(std::string preset_name, bool delete_current /*=false*/,
|
|||
{ Preset::Type::TYPE_FILAMENT, &m_preset_bundle->filaments, ptFFF },
|
||||
//{ Preset::Type::TYPE_SLA_MATERIAL, &m_preset_bundle->sla_materials,ptSLA }
|
||||
};
|
||||
Preset *to_be_selected = m_presets->find_preset(preset_name, false, true);
|
||||
ConfigOptionStrings* cur_opt2 = dynamic_cast <ConfigOptionStrings *>(m_presets->get_edited_preset().config.option("printer_extruder_variant"));
|
||||
ConfigOptionStrings* to_select_opt2 = dynamic_cast <ConfigOptionStrings *>(to_be_selected->config.option("printer_extruder_variant"));
|
||||
no_transfer = cur_opt2->values != to_select_opt2->values;
|
||||
for (PresetUpdate &pu : updates) {
|
||||
pu.old_preset_dirty = (old_printer_technology == pu.technology) && pu.presets->current_is_dirty();
|
||||
pu.new_preset_compatible = (new_printer_technology == pu.technology) && is_compatible_with_printer(pu.presets->get_edited_preset_with_vendor_profile(), new_printer_preset_with_vendor_profile);
|
||||
if (!canceled)
|
||||
canceled = pu.old_preset_dirty && !pu.new_preset_compatible && !may_discard_current_dirty_preset(pu.presets, preset_name) && !force_select;
|
||||
canceled = pu.old_preset_dirty && !pu.new_preset_compatible && !may_discard_current_dirty_preset(pu.presets, preset_name, no_transfer) && !force_select;
|
||||
}
|
||||
if (!canceled) {
|
||||
for (PresetUpdate &pu : updates) {
|
||||
|
|
|
@ -274,6 +274,7 @@ protected:
|
|||
m_highlighter;
|
||||
|
||||
DynamicPrintConfig m_cache_config;
|
||||
std::vector<std::string> m_cache_options;
|
||||
|
||||
|
||||
bool m_page_switch_running = false;
|
||||
|
|
Loading…
Reference in New Issue