mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2026-03-10 21:37:06 -06:00
FIX: filament variant index & override nil value
Change-Id: I828fff09df39a60d59af516c969466d9b09e503f Jira: none (cherry picked from commit 1745657e222b8e9d7c96fcca16581b2deac526c6)
This commit is contained in:
parent
4bb326db16
commit
013d2d8d6e
4 changed files with 40 additions and 24 deletions
|
|
@ -2853,17 +2853,27 @@ void add_correct_opts_to_diff(const std::string &opt_key, t_config_option_keys&
|
|||
for (int i = 0; i < int(opt_cur->values.size()); i++)
|
||||
{
|
||||
int init_id = i <= opt_init_max_id ? i : 0;
|
||||
if (opt_cur->values[i] != opt_init->values[init_id]
|
||||
&& (strict || !(opt_cur->is_nil(i) || opt_init->is_nil(init_id))))
|
||||
vec.emplace_back(opt_key + "#" + std::to_string(i));
|
||||
if (opt_cur->values[i] != opt_init->values[init_id]) {
|
||||
if (opt_cur->nullable()) {
|
||||
if (opt_cur->is_nil(i)) {
|
||||
if (strict && !opt_init->is_nil(init_id))
|
||||
vec.emplace_back(opt_key + "#" + std::to_string(i));
|
||||
} else {
|
||||
if (strict || !opt_init->is_nil(init_id))
|
||||
vec.emplace_back(opt_key + "#" + std::to_string(i));
|
||||
}
|
||||
} else {
|
||||
vec.emplace_back(opt_key + "#" + std::to_string(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Use deep_diff to correct return of changed options, considering individual options for each extruder.
|
||||
inline t_config_option_keys deep_diff(const ConfigBase &config_this, const ConfigBase &config_other, bool strict = false)
|
||||
inline t_config_option_keys deep_diff(const ConfigBase &config_this, const ConfigBase &config_other, bool strict = true)
|
||||
{
|
||||
t_config_option_keys diff;
|
||||
t_config_option_keys keys = config_this.keys();
|
||||
t_config_option_keys keys;
|
||||
if (strict) {
|
||||
t_config_option_keys keys_this = config_this.keys();
|
||||
t_config_option_keys keys_other = config_other.keys();
|
||||
|
|
|
|||
|
|
@ -951,7 +951,7 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config
|
|||
{
|
||||
case coPercents:
|
||||
case coFloats: {
|
||||
if (config.option(opt_key)->is_nil())
|
||||
if (opt_index < 0 ? config.option(opt_key)->is_nil() : dynamic_cast<ConfigOptionVectorBase const*>(config.option(opt_key))->is_nil(opt_index))
|
||||
ret = _(L("N/A"));
|
||||
else {
|
||||
double val = opt->type == coFloats ?
|
||||
|
|
@ -961,7 +961,7 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config
|
|||
}
|
||||
break;
|
||||
case coFloatsOrPercents: {
|
||||
if (config.option(opt_key)->is_nil())
|
||||
if (opt_index < 0 ? config.option(opt_key)->is_nil() : dynamic_cast<ConfigOptionVectorBase const*>(config.option(opt_key))->is_nil(opt_index))
|
||||
ret = _(L("N/A"));
|
||||
else {
|
||||
const auto& value = config.option<ConfigOptionFloatsOrPercentsNullable>(opt_key)->get_at(idx);
|
||||
|
|
|
|||
|
|
@ -1203,9 +1203,6 @@ bool Sidebar::priv::switch_diameter(bool single)
|
|||
|
||||
bool Sidebar::priv::sync_extruder_list(bool &only_external_material)
|
||||
{
|
||||
auto printer_tab = dynamic_cast<TabPrinter *>(wxGetApp().get_tab(Preset::TYPE_PRINTER));
|
||||
printer_tab->set_extruder_volume_type(0, NozzleVolumeType::nvtHighFlow);
|
||||
printer_tab->set_extruder_volume_type(1, NozzleVolumeType::nvtStandard);
|
||||
MachineObject *obj = wxGetApp().getDeviceManager()->get_selected_machine();
|
||||
auto printer_name = plater->get_selected_printer_name_in_combox();
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << __LINE__ << " begin sync_extruder_list";
|
||||
|
|
@ -2913,7 +2910,8 @@ std::map<int, DynamicPrintConfig> Sidebar::build_filament_ams_list(MachineObject
|
|||
if (!obj) return filament_ams_list;
|
||||
|
||||
auto build_tray_config = [](AmsTray const &tray, std::string const &name, std::string ams_id, std::string slot_id) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": name %1% setting_id %2% color %3%") % name % tray.setting_id % tray.color;
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("build_filament_ams_list: name %1% setting_id %2% type %3% color %4%")
|
||||
% name % tray.setting_id % tray.type % tray.color;
|
||||
DynamicPrintConfig tray_config;
|
||||
tray_config.set_key_value("filament_id", new ConfigOptionStrings{tray.setting_id});
|
||||
tray_config.set_key_value("tag_uid", new ConfigOptionStrings{tray.tag_uid});
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@
|
|||
|
||||
namespace Slic3r {
|
||||
|
||||
t_config_option_keys deep_diff(const ConfigBase &config_this, const ConfigBase &config_other, bool strict = false);
|
||||
t_config_option_keys deep_diff(const ConfigBase &config_this, const ConfigBase &config_other, bool strict = true);
|
||||
|
||||
namespace GUI {
|
||||
|
||||
|
|
@ -923,10 +923,14 @@ void Tab::update_changed_ui()
|
|||
it.second = m_opt_status_value;
|
||||
|
||||
for (auto opt_key : dirty_options) {
|
||||
m_options_list[opt_key] &= ~osInitValue;
|
||||
auto iter = m_options_list.find(opt_key);
|
||||
if (iter != m_options_list.end())
|
||||
iter->second &= ~osInitValue;
|
||||
}
|
||||
for (auto opt_key : nonsys_options) {
|
||||
m_options_list[opt_key] &= ~osSystemValue;
|
||||
auto iter = m_options_list.find(opt_key);
|
||||
if (iter != m_options_list.end())
|
||||
iter->second &= ~osSystemValue;
|
||||
}
|
||||
|
||||
decorate();
|
||||
|
|
@ -994,8 +998,12 @@ void TabFilament::init_options_list()
|
|||
if (!m_options_list.empty())
|
||||
m_options_list.clear();
|
||||
|
||||
for (const std::string& opt_key : m_config->keys())
|
||||
m_options_list.emplace(opt_key, m_opt_status_value);
|
||||
for (const std::string &opt_key : m_config->keys()) {
|
||||
if (filament_options_with_variant.find(opt_key) == filament_options_with_variant.end())
|
||||
m_options_list.emplace(opt_key, m_opt_status_value);
|
||||
else
|
||||
m_options_list.emplace(opt_key + "#0", m_opt_status_value);
|
||||
}
|
||||
}
|
||||
|
||||
void Tab::get_sys_and_mod_flags(const std::string& opt_key, bool& sys_page, bool& modified_page)
|
||||
|
|
@ -2876,11 +2884,11 @@ void TabPrintModel::update_model_config()
|
|||
std::vector<std::string> global_diffs; // all diff keys to global config
|
||||
for (auto & config : m_object_configs) {
|
||||
all_keys = concat(all_keys, variant_keys(config.second->get()));
|
||||
auto diffs = deep_diff(config.second->get(), global_config);
|
||||
auto diffs = deep_diff(config.second->get(), global_config, false);
|
||||
global_diffs = concat(global_diffs, diffs);
|
||||
diff_config.apply_only(config.second->get(), diffs);
|
||||
if (&config.second->get() == &local_config) continue;
|
||||
local_diffs = concat(local_diffs, deep_diff(local_config, config.second->get(), true));
|
||||
local_diffs = concat(local_diffs, deep_diff(local_config, config.second->get()));
|
||||
}
|
||||
m_null_keys = intersect(global_diffs, local_diffs);
|
||||
m_config->apply(diff_config);
|
||||
|
|
@ -3565,9 +3573,9 @@ void TabFilament::update_filament_overrides_page(const DynamicPrintConfig* print
|
|||
// "filament_seam_gap"
|
||||
};
|
||||
|
||||
const int extruder_idx = 0; // #ys_FIXME
|
||||
const int extruder_idx = m_variant_combo->GetSelection(); // #ys_FIXME
|
||||
|
||||
const bool have_retract_length = m_config->option("filament_retraction_length")->is_nil() ||
|
||||
const bool have_retract_length = dynamic_cast<ConfigOptionVectorBase *>(m_config->option("filament_retraction_length"))->is_nil(extruder_idx) ||
|
||||
m_config->opt_float("filament_retraction_length", extruder_idx) > 0;
|
||||
|
||||
for (const std::string& opt_key : opt_keys)
|
||||
|
|
@ -3575,24 +3583,24 @@ void TabFilament::update_filament_overrides_page(const DynamicPrintConfig* print
|
|||
bool is_checked = opt_key=="filament_retraction_length" ? true : have_retract_length;
|
||||
m_overrides_options[opt_key]->Enable(is_checked);
|
||||
|
||||
is_checked &= !m_config->option(opt_key)->is_nil();
|
||||
is_checked &= !dynamic_cast<ConfigOptionVectorBase*>(m_config->option(opt_key))->is_nil(extruder_idx);
|
||||
m_overrides_options[opt_key]->SetValue(is_checked);
|
||||
|
||||
Field* field = optgroup->get_fieldc(opt_key, extruder_idx);
|
||||
Field* field = optgroup->get_fieldc(opt_key, 0);
|
||||
if (field == nullptr) continue;
|
||||
|
||||
if (opt_key == "filament_long_retractions_when_cut") {
|
||||
int machine_enabled_level = printers_config->option<ConfigOptionInt>(
|
||||
"enable_long_retraction_when_cut")->value;
|
||||
bool machine_enabled = machine_enabled_level == LongRectrationLevel::EnableFilament;
|
||||
toggle_line(opt_key, machine_enabled);
|
||||
toggle_line(opt_key, machine_enabled, extruder_idx + 256);
|
||||
field->toggle(is_checked && machine_enabled);
|
||||
} else if (opt_key == "filament_retraction_distances_when_cut") {
|
||||
int machine_enabled_level = printers_config->option<ConfigOptionInt>(
|
||||
"enable_long_retraction_when_cut")->value;
|
||||
bool machine_enabled = machine_enabled_level == LongRectrationLevel::EnableFilament;
|
||||
bool filament_enabled = m_config->option<ConfigOptionBools>("filament_long_retractions_when_cut")->values[extruder_idx] == 1;
|
||||
toggle_line(opt_key, filament_enabled && machine_enabled);
|
||||
toggle_line(opt_key, filament_enabled && machine_enabled, extruder_idx + 256);
|
||||
field->toggle(is_checked && filament_enabled && machine_enabled);
|
||||
} else {
|
||||
if (!is_checked) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue