Invalidate print when G-code substitution is changed
+ DiffDialog: Fixed get_string_value() for "gcode_substitution" + some code refactoring : For PresetCollection added is_independent_from_extruder_number_option(opt_key) to check if option is from the list of options with vector variable, which is independent from number of extruders
This commit is contained in:
parent
3a81dd5c5a
commit
106e520a10
@ -1133,6 +1133,20 @@ void add_correct_opts_to_diff(const std::string &opt_key, t_config_option_keys&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// list of options with vector variable, which is independent from number of extruders
|
||||||
|
static const std::vector<std::string> independent_from_extruder_number_options = {
|
||||||
|
"bed_shape",
|
||||||
|
"filament_ramming_parameters",
|
||||||
|
"gcode_substitutions",
|
||||||
|
"compatible_prints",
|
||||||
|
"compatible_printers"
|
||||||
|
};
|
||||||
|
|
||||||
|
bool PresetCollection::is_independent_from_extruder_number_option(const std::string& opt_key)
|
||||||
|
{
|
||||||
|
return std::find(independent_from_extruder_number_options.begin(), independent_from_extruder_number_options.end(), opt_key) != independent_from_extruder_number_options.end();
|
||||||
|
}
|
||||||
|
|
||||||
// Use deep_diff to correct return of changed options, considering individual options for each extruder.
|
// 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)
|
inline t_config_option_keys deep_diff(const ConfigBase &config_this, const ConfigBase &config_other)
|
||||||
{
|
{
|
||||||
@ -1142,7 +1156,7 @@ inline t_config_option_keys deep_diff(const ConfigBase &config_this, const Confi
|
|||||||
const ConfigOption *other_opt = config_other.option(opt_key);
|
const ConfigOption *other_opt = config_other.option(opt_key);
|
||||||
if (this_opt != nullptr && other_opt != nullptr && *this_opt != *other_opt)
|
if (this_opt != nullptr && other_opt != nullptr && *this_opt != *other_opt)
|
||||||
{
|
{
|
||||||
if (opt_key == "bed_shape" || opt_key == "thumbnails" || opt_key == "compatible_prints" || opt_key == "compatible_printers") {
|
if (PresetCollection::is_independent_from_extruder_number_option(opt_key)) {
|
||||||
// Scalar variable, or a vector variable, which is independent from number of extruders,
|
// Scalar variable, or a vector variable, which is independent from number of extruders,
|
||||||
// thus the vector is presented to the user as a single input.
|
// thus the vector is presented to the user as a single input.
|
||||||
diff.emplace_back(opt_key);
|
diff.emplace_back(opt_key);
|
||||||
|
@ -556,6 +556,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
static bool is_dirty(const Preset *edited, const Preset *reference);
|
static bool is_dirty(const Preset *edited, const Preset *reference);
|
||||||
static std::vector<std::string> dirty_options(const Preset *edited, const Preset *reference, const bool deep_compare = false);
|
static std::vector<std::string> dirty_options(const Preset *edited, const Preset *reference, const bool deep_compare = false);
|
||||||
|
static bool is_independent_from_extruder_number_option(const std::string& opt_key);
|
||||||
private:
|
private:
|
||||||
// Type of this PresetCollection: TYPE_PRINT, TYPE_FILAMENT or TYPE_PRINTER.
|
// Type of this PresetCollection: TYPE_PRINT, TYPE_FILAMENT or TYPE_PRINTER.
|
||||||
Preset::Type m_type;
|
Preset::Type m_type;
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "libslic3r/Exception.hpp"
|
#include "libslic3r/Exception.hpp"
|
||||||
#include "libslic3r/Utils.hpp"
|
#include "libslic3r/Utils.hpp"
|
||||||
#include "libslic3r/AppConfig.hpp"
|
#include "libslic3r/AppConfig.hpp"
|
||||||
|
#include "libslic3r/Preset.hpp"
|
||||||
#include "I18N.hpp"
|
#include "I18N.hpp"
|
||||||
|
|
||||||
namespace Slic3r { namespace GUI {
|
namespace Slic3r { namespace GUI {
|
||||||
@ -596,8 +597,7 @@ void ConfigOptionsGroup::back_to_config_value(const DynamicPrintConfig& config,
|
|||||||
}
|
}
|
||||||
else if (m_opt_map.find(opt_key) == m_opt_map.end() ||
|
else if (m_opt_map.find(opt_key) == m_opt_map.end() ||
|
||||||
// This option don't have corresponded field
|
// This option don't have corresponded field
|
||||||
opt_key == "bed_shape" || opt_key == "filament_ramming_parameters" || opt_key == "gcode_substitutions" ||
|
PresetCollection::is_independent_from_extruder_number_option(opt_key) ) {
|
||||||
opt_key == "compatible_printers" || opt_key == "compatible_prints" ) {
|
|
||||||
value = get_config_value(config, opt_key);
|
value = get_config_value(config, opt_key);
|
||||||
this->change_opt_value(opt_key, value);
|
this->change_opt_value(opt_key, value);
|
||||||
return;
|
return;
|
||||||
|
@ -532,8 +532,7 @@ void Tab::update_label_colours()
|
|||||||
else
|
else
|
||||||
color = &m_modified_label_clr;
|
color = &m_modified_label_clr;
|
||||||
}
|
}
|
||||||
if (opt.first == "bed_shape" || opt.first == "filament_ramming_parameters" ||
|
if (PresetCollection::is_independent_from_extruder_number_option(opt.first)) {
|
||||||
opt.first == "compatible_prints" || opt.first == "compatible_printers" ) {
|
|
||||||
if (m_colored_Label_colors.find(opt.first) != m_colored_Label_colors.end())
|
if (m_colored_Label_colors.find(opt.first) != m_colored_Label_colors.end())
|
||||||
m_colored_Label_colors.at(opt.first) = *color;
|
m_colored_Label_colors.at(opt.first) = *color;
|
||||||
continue;
|
continue;
|
||||||
@ -574,8 +573,7 @@ void Tab::decorate()
|
|||||||
Field* field = nullptr;
|
Field* field = nullptr;
|
||||||
wxColour* colored_label_clr = nullptr;
|
wxColour* colored_label_clr = nullptr;
|
||||||
|
|
||||||
if (opt.first == "bed_shape" || opt.first == "filament_ramming_parameters" ||
|
if(PresetCollection::is_independent_from_extruder_number_option(opt.first))
|
||||||
opt.first == "compatible_prints" || opt.first == "compatible_printers")
|
|
||||||
colored_label_clr = (m_colored_Label_colors.find(opt.first) == m_colored_Label_colors.end()) ? nullptr : &m_colored_Label_colors.at(opt.first);
|
colored_label_clr = (m_colored_Label_colors.find(opt.first) == m_colored_Label_colors.end()) ? nullptr : &m_colored_Label_colors.at(opt.first);
|
||||||
|
|
||||||
if (!colored_label_clr) {
|
if (!colored_label_clr) {
|
||||||
@ -4115,7 +4113,8 @@ wxSizer* TabPrint::create_substitutions_widget(wxWindow* parent)
|
|||||||
|
|
||||||
m_subst_manager.init(m_config, parent, grid_sizer);
|
m_subst_manager.init(m_config, parent, grid_sizer);
|
||||||
m_subst_manager.set_cb_edited_substitution([this]() {
|
m_subst_manager.set_cb_edited_substitution([this]() {
|
||||||
update_changed_ui();
|
update_dirty();
|
||||||
|
wxGetApp().mainframe->on_config_changed(m_config); // invalidate print
|
||||||
});
|
});
|
||||||
|
|
||||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
@ -1156,6 +1156,14 @@ static wxString get_string_value(std::string opt_key, const DynamicPrintConfig&
|
|||||||
out.RemoveLast(1);
|
out.RemoveLast(1);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
if (opt_key == "gcode_substitutions") {
|
||||||
|
if (!strings->empty())
|
||||||
|
for (size_t id = 0; id < strings->size(); id += 3)
|
||||||
|
out += from_u8(strings->get_at(id)) + ";\t" +
|
||||||
|
from_u8(strings->get_at(id + 1)) + ";\t" +
|
||||||
|
from_u8(strings->get_at(id + 2)) + ";\n";
|
||||||
|
return out;
|
||||||
|
}
|
||||||
if (!strings->empty() && opt_idx < strings->values.size())
|
if (!strings->empty() && opt_idx < strings->values.size())
|
||||||
return from_u8(strings->get_at(opt_idx));
|
return from_u8(strings->get_at(opt_idx));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user