ENH: drop variant modify values if inconsistant
Change-Id: I6c3e487e4b222df63f91aceccff13c3afd002ab8 Jira: none
This commit is contained in:
parent
b49d4ca153
commit
9801a10f7f
|
@ -716,7 +716,7 @@ void Sidebar::priv::sync_extruder_list()
|
||||||
for (auto ams : obj->amsList) {
|
for (auto ams : obj->amsList) {
|
||||||
// Main (first) extruder at right
|
// Main (first) extruder at right
|
||||||
if (ams.second->nozzle == 0) ++right;
|
if (ams.second->nozzle == 0) ++right;
|
||||||
else ++left;
|
else if(ams.second->nozzle == 1) ++left;
|
||||||
}
|
}
|
||||||
AMSCountPopupWindow::SetAMSCount(0, left, obj->vt_slot.size() > 1);
|
AMSCountPopupWindow::SetAMSCount(0, left, obj->vt_slot.size() > 1);
|
||||||
AMSCountPopupWindow::SetAMSCount(1, right, 1);
|
AMSCountPopupWindow::SetAMSCount(1, right, 1);
|
||||||
|
|
|
@ -909,9 +909,7 @@ void Tab::update_changed_ui()
|
||||||
template<class T>
|
template<class T>
|
||||||
void add_correct_opts_to_options_list(const std::string &opt_key, std::map<std::string, int>& map, Tab *tab, const int& value)
|
void add_correct_opts_to_options_list(const std::string &opt_key, std::map<std::string, int>& map, Tab *tab, const int& value)
|
||||||
{
|
{
|
||||||
T *opt_cur = static_cast<T*>(tab->m_config->option(opt_key));
|
map.emplace(opt_key + "#0", value);
|
||||||
for (size_t i = 0; i < opt_cur->values.size(); i++)
|
|
||||||
map.emplace(opt_key + "#" + std::to_string(i), value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tab::init_options_list()
|
void Tab::init_options_list()
|
||||||
|
@ -925,19 +923,10 @@ void Tab::init_options_list()
|
||||||
m_options_list.emplace(opt_key, m_opt_status_value);
|
m_options_list.emplace(opt_key, m_opt_status_value);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
switch (m_config->option(opt_key)->type())
|
if (m_config->option(opt_key)->is_vector())
|
||||||
{
|
m_options_list.emplace(opt_key + "#0", m_opt_status_value);
|
||||||
case coInts: add_correct_opts_to_options_list<ConfigOptionInts >(opt_key, m_options_list, this, m_opt_status_value); break;
|
else
|
||||||
case coBools: add_correct_opts_to_options_list<ConfigOptionBools >(opt_key, m_options_list, this, m_opt_status_value); break;
|
m_options_list.emplace(opt_key, m_opt_status_value);
|
||||||
case coFloats: add_correct_opts_to_options_list<ConfigOptionFloats >(opt_key, m_options_list, this, m_opt_status_value); break;
|
|
||||||
case coStrings: add_correct_opts_to_options_list<ConfigOptionStrings >(opt_key, m_options_list, this, m_opt_status_value); break;
|
|
||||||
case coPercents:add_correct_opts_to_options_list<ConfigOptionPercents >(opt_key, m_options_list, this, m_opt_status_value); break;
|
|
||||||
case coFloatsOrPercents: add_correct_opts_to_options_list<ConfigOptionFloatsOrPercents>(opt_key, m_options_list, this, m_opt_status_value); break;
|
|
||||||
case coPoints: add_correct_opts_to_options_list<ConfigOptionPoints >(opt_key, m_options_list, this, m_opt_status_value); break;
|
|
||||||
// BBS
|
|
||||||
case coEnums: add_correct_opts_to_options_list<ConfigOptionInts >(opt_key, m_options_list, this, m_opt_status_value); break;
|
|
||||||
default: m_options_list.emplace(opt_key, m_opt_status_value); break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -946,6 +935,13 @@ void TabPrinter::init_options_list()
|
||||||
Tab::init_options_list();
|
Tab::init_options_list();
|
||||||
if (m_printer_technology == ptFFF)
|
if (m_printer_technology == ptFFF)
|
||||||
m_options_list.emplace("extruders_count", m_opt_status_value);
|
m_options_list.emplace("extruders_count", m_opt_status_value);
|
||||||
|
for (size_t i = 1; i < m_extruders_count; ++i) {
|
||||||
|
auto extruder_page = m_pages[3 + i];
|
||||||
|
for (auto group : extruder_page->m_optgroups) {
|
||||||
|
for (auto & opt : group->opt_map())
|
||||||
|
m_options_list.emplace(opt.first, m_opt_status_value);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabPrinter::msw_rescale()
|
void TabPrinter::msw_rescale()
|
||||||
|
@ -1119,7 +1115,8 @@ void Tab::on_roll_back_value(const bool to_sys /*= true*/)
|
||||||
//}
|
//}
|
||||||
for (const auto &kvp : group->opt_map()) {
|
for (const auto &kvp : group->opt_map()) {
|
||||||
const std::string &opt_key = kvp.first;
|
const std::string &opt_key = kvp.first;
|
||||||
if ((m_options_list[opt_key] & os) == 0)
|
auto iter = m_options_list.find(opt_key);
|
||||||
|
if (iter != m_options_list.end() && (iter->second & os) == 0)
|
||||||
to_sys ? group->back_to_sys_value(opt_key) : group->back_to_initial_value(opt_key);
|
to_sys ? group->back_to_sys_value(opt_key) : group->back_to_initial_value(opt_key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4743,12 +4740,12 @@ bool Tab::select_preset(std::string preset_name, bool delete_current /*=false*/,
|
||||||
Preset *to_be_selected = m_presets->find_preset(preset_name, false, true);
|
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* 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"));
|
ConfigOptionStrings* to_select_opt2 = dynamic_cast <ConfigOptionStrings *>(to_be_selected->config.option("printer_extruder_variant"));
|
||||||
no_transfer = cur_opt2->values != to_select_opt2->values;
|
bool no_transfer_variant = cur_opt2->values != to_select_opt2->values;
|
||||||
for (PresetUpdate &pu : updates) {
|
for (PresetUpdate &pu : updates) {
|
||||||
pu.old_preset_dirty = (old_printer_technology == pu.technology) && pu.presets->current_is_dirty();
|
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);
|
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)
|
if (!canceled)
|
||||||
canceled = pu.old_preset_dirty && !pu.new_preset_compatible && !may_discard_current_dirty_preset(pu.presets, preset_name, no_transfer) && !force_select;
|
canceled = pu.old_preset_dirty && !pu.new_preset_compatible && !may_discard_current_dirty_preset(pu.presets, preset_name, false, no_transfer_variant) && !force_select;
|
||||||
}
|
}
|
||||||
if (!canceled) {
|
if (!canceled) {
|
||||||
for (PresetUpdate &pu : updates) {
|
for (PresetUpdate &pu : updates) {
|
||||||
|
@ -4921,7 +4918,7 @@ bool Tab::select_preset(std::string preset_name, bool delete_current /*=false*/,
|
||||||
|
|
||||||
// If the current preset is dirty, the user is asked whether the changes may be discarded.
|
// If the current preset is dirty, the user is asked whether the changes may be discarded.
|
||||||
// if the current preset was not dirty, or the user agreed to discard the changes, 1 is returned.
|
// if the current preset was not dirty, or the user agreed to discard the changes, 1 is returned.
|
||||||
bool Tab::may_discard_current_dirty_preset(PresetCollection* presets /*= nullptr*/, const std::string& new_printer_name /*= ""*/, bool no_transfer)
|
bool Tab::may_discard_current_dirty_preset(PresetCollection *presets /*= nullptr*/, const std::string &new_printer_name /*= ""*/, bool no_transfer, bool no_transfer_variant)
|
||||||
{
|
{
|
||||||
if (presets == nullptr) presets = m_presets;
|
if (presets == nullptr) presets = m_presets;
|
||||||
|
|
||||||
|
@ -4960,6 +4957,25 @@ bool Tab::may_discard_current_dirty_preset(PresetCollection* presets /*= nullptr
|
||||||
else if (dlg.transfer_changes()) // move selected changes
|
else if (dlg.transfer_changes()) // move selected changes
|
||||||
{
|
{
|
||||||
std::vector<std::string> selected_options = dlg.get_selected_options();
|
std::vector<std::string> selected_options = dlg.get_selected_options();
|
||||||
|
if (!no_transfer && no_transfer_variant) {
|
||||||
|
auto & options_list = wxGetApp().get_tab(presets->type())->m_options_list;
|
||||||
|
bool has_variants = false;
|
||||||
|
for (auto &opt : selected_options) {
|
||||||
|
if (auto n = opt.find('#'); n != std::string::npos) {
|
||||||
|
auto iter = options_list.lower_bound(opt.substr(0, n));
|
||||||
|
if (iter == options_list.end() || opt.compare(0, n, iter->first)) {
|
||||||
|
has_variants = true;
|
||||||
|
opt.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (has_variants) {
|
||||||
|
auto msg = _L("Parameters related to the extruder model will be discarded because the extruder model list for the front and rear printers is inconsistent.");
|
||||||
|
MessageDialog(this, msg, _L("Use Modified Value"), wxOK | wxICON_WARNING).ShowModal();
|
||||||
|
selected_options.erase(std::remove(selected_options.begin(), selected_options.end(), ""), selected_options.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (m_type == presets->type()) // move changes for the current preset from this tab
|
if (m_type == presets->type()) // move changes for the current preset from this tab
|
||||||
{
|
{
|
||||||
if (m_type == Preset::TYPE_PRINTER) {
|
if (m_type == Preset::TYPE_PRINTER) {
|
||||||
|
|
|
@ -334,7 +334,7 @@ public:
|
||||||
void update_preset_choice();
|
void update_preset_choice();
|
||||||
// Select a new preset, possibly delete the current one.
|
// Select a new preset, possibly delete the current one.
|
||||||
bool select_preset(std::string preset_name = "", bool delete_current = false, const std::string& last_selected_ph_printer_name = "", bool force_select = false);
|
bool select_preset(std::string preset_name = "", bool delete_current = false, const std::string& last_selected_ph_printer_name = "", bool force_select = false);
|
||||||
bool may_discard_current_dirty_preset(PresetCollection* presets = nullptr, const std::string& new_printer_name = "", bool no_transfer = false);
|
bool may_discard_current_dirty_preset(PresetCollection* presets = nullptr, const std::string& new_printer_name = "", bool no_transfer = false, bool no_transfer_variant = false);
|
||||||
|
|
||||||
virtual void clear_pages();
|
virtual void clear_pages();
|
||||||
virtual void update_description_lines();
|
virtual void update_description_lines();
|
||||||
|
|
Loading…
Reference in New Issue