mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2026-03-13 06:46:11 -06:00
ENH: config apply_only vector at index
Change-Id: I7bf5a44b2d3db2e21207696b6ef7e41a499da078 Jira: STUDIO-7747 (cherry picked from commit 5f30ee389e804f3a71021cdec231a0c92d21d83c)
This commit is contained in:
parent
53a1827731
commit
193ab1da34
3 changed files with 20 additions and 2 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -1891,6 +1891,7 @@ void Tab::apply_searcher()
|
|||
|
||||
void Tab::cache_config_diff(const std::vector<std::string>& selected_options, const DynamicPrintConfig* config/* = nullptr*/)
|
||||
{
|
||||
m_cache_options = selected_options;
|
||||
m_cache_config.apply_only(config ? *config : m_presets->get_edited_preset().config, selected_options);
|
||||
}
|
||||
|
||||
|
|
@ -1903,8 +1904,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;
|
||||
}
|
||||
|
|
@ -5269,11 +5271,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 && !may_discard_current_dirty_preset(pu.presets, preset_name) && !pu.new_preset_compatible && !force_select;
|
||||
canceled = pu.old_preset_dirty && !may_discard_current_dirty_preset(pu.presets, preset_name, no_transfer) && !pu.new_preset_compatible && !force_select;
|
||||
}
|
||||
if (!canceled) {
|
||||
for (PresetUpdate &pu : updates) {
|
||||
|
|
|
|||
|
|
@ -277,6 +277,7 @@ protected:
|
|||
m_highlighter;
|
||||
|
||||
DynamicPrintConfig m_cache_config;
|
||||
std::vector<std::string> m_cache_options;
|
||||
|
||||
|
||||
bool m_page_switch_running = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue