mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-22 12:45:17 +00:00
FIX: parameters modify of printer preset
Ensure correct behavior when modifying parameters of printer preset Change-Id: Ic627a8e202bf4224b742336cc43ac611ddc5c997 (cherry picked from commit 366a14d8f715cbeca3d0f70a4727d91b6f0ca82e)
This commit is contained in:
@@ -7160,11 +7160,15 @@ std::set<std::string> filament_options_with_variant = {
|
|||||||
"filament_extruder_variant"
|
"filament_extruder_variant"
|
||||||
};
|
};
|
||||||
|
|
||||||
std::set<std::string> printer_options_with_variant_1 = {
|
// Parameters that are the same as the number of extruders
|
||||||
/*"extruder_type",
|
std::set<std::string> printer_extruder_options = {
|
||||||
|
"extruder_type",
|
||||||
"nozzle_diameter",
|
"nozzle_diameter",
|
||||||
"nozzle_volume_type".
|
"nozzle_volume_type"
|
||||||
"min_layer_height",
|
};
|
||||||
|
|
||||||
|
std::set<std::string> printer_options_with_variant_1 = {
|
||||||
|
/*"min_layer_height",
|
||||||
"max_layer_height",*/
|
"max_layer_height",*/
|
||||||
//"retraction_length",
|
//"retraction_length",
|
||||||
"z_hop",
|
"z_hop",
|
||||||
@@ -7439,6 +7443,33 @@ void handle_legacy_sla(DynamicPrintConfig &config)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t DynamicPrintConfig::get_parameter_size(const std::string& param_name, size_t extruder_nums)
|
||||||
|
{
|
||||||
|
if (extruder_nums > 1) {
|
||||||
|
size_t volume_type_size = 2;
|
||||||
|
auto nozzle_volume_type_opt = dynamic_cast<const ConfigOptionEnumsGeneric *>(this->option("nozzle_volume_type"));
|
||||||
|
if (nozzle_volume_type_opt) {
|
||||||
|
volume_type_size = nozzle_volume_type_opt->values.size();
|
||||||
|
}
|
||||||
|
if (printer_options_with_variant_1.count(param_name) > 0) {
|
||||||
|
return extruder_nums * volume_type_size;
|
||||||
|
}
|
||||||
|
else if (printer_options_with_variant_2.count(param_name) > 0) {
|
||||||
|
return extruder_nums * volume_type_size * 2;
|
||||||
|
}
|
||||||
|
else if (filament_options_with_variant.count(param_name) > 0) {
|
||||||
|
return extruder_nums * volume_type_size;
|
||||||
|
}
|
||||||
|
else if (print_options_with_variant.count(param_name) > 0) {
|
||||||
|
return extruder_nums * volume_type_size;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return extruder_nums;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return extruder_nums;
|
||||||
|
}
|
||||||
|
|
||||||
void DynamicPrintConfig::set_num_extruders(unsigned int num_extruders)
|
void DynamicPrintConfig::set_num_extruders(unsigned int num_extruders)
|
||||||
{
|
{
|
||||||
const auto &defaults = FullPrintConfig::defaults();
|
const auto &defaults = FullPrintConfig::defaults();
|
||||||
@@ -7450,8 +7481,9 @@ void DynamicPrintConfig::set_num_extruders(unsigned int num_extruders)
|
|||||||
auto *opt = this->option(key, false);
|
auto *opt = this->option(key, false);
|
||||||
assert(opt != nullptr);
|
assert(opt != nullptr);
|
||||||
assert(opt->is_vector());
|
assert(opt->is_vector());
|
||||||
if (opt != nullptr && opt->is_vector())
|
if (opt != nullptr && opt->is_vector()) {
|
||||||
static_cast<ConfigOptionVectorBase*>(opt)->resize(num_extruders, defaults.option(key));
|
static_cast<ConfigOptionVectorBase*>(opt)->resize(get_parameter_size(key, num_extruders), defaults.option(key));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -576,6 +576,7 @@ public:
|
|||||||
//return the changed param set
|
//return the changed param set
|
||||||
t_config_option_keys normalize_fdm_2(int num_objects, int used_filaments = 0);
|
t_config_option_keys normalize_fdm_2(int num_objects, int used_filaments = 0);
|
||||||
|
|
||||||
|
size_t get_parameter_size(const std::string& param_name, size_t extruder_nums);
|
||||||
void set_num_extruders(unsigned int num_extruders);
|
void set_num_extruders(unsigned int num_extruders);
|
||||||
|
|
||||||
// BBS
|
// BBS
|
||||||
@@ -609,6 +610,7 @@ public:
|
|||||||
|
|
||||||
bool is_custom_defined();
|
bool is_custom_defined();
|
||||||
};
|
};
|
||||||
|
extern std::set<std::string> printer_extruder_options;
|
||||||
extern std::set<std::string> print_options_with_variant;
|
extern std::set<std::string> print_options_with_variant;
|
||||||
extern std::set<std::string> filament_options_with_variant;
|
extern std::set<std::string> filament_options_with_variant;
|
||||||
extern std::set<std::string> printer_options_with_variant_1;
|
extern std::set<std::string> printer_options_with_variant_1;
|
||||||
|
|||||||
@@ -24,15 +24,22 @@ namespace Slic3r { namespace GUI {
|
|||||||
|
|
||||||
// BBS: new layout
|
// BBS: new layout
|
||||||
constexpr int titleWidth = 20;
|
constexpr int titleWidth = 20;
|
||||||
|
|
||||||
|
// get the param index of cur_exturder
|
||||||
int get_extruder_idx(const DynamicPrintConfig& config, const std::string &opt_key, int cur_extruder_id)
|
int get_extruder_idx(const DynamicPrintConfig& config, const std::string &opt_key, int cur_extruder_id)
|
||||||
{
|
{
|
||||||
|
if (printer_extruder_options.find(opt_key) != printer_extruder_options.end()) {
|
||||||
|
return cur_extruder_id;
|
||||||
|
}
|
||||||
|
|
||||||
int extruder_count = wxGetApp().preset_bundle->get_printer_extruder_count();
|
int extruder_count = wxGetApp().preset_bundle->get_printer_extruder_count();
|
||||||
if (extruder_count == 1 || cur_extruder_id == -1)
|
if (extruder_count == 1 || cur_extruder_id == -1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
assert(cur_extruder_id < extruder_count);
|
assert(cur_extruder_id < extruder_count);
|
||||||
auto opt_extruder_type = dynamic_cast<const ConfigOptionEnumsGeneric *>(config.option("extruder_type"));
|
const DynamicPrintConfig& cur_printer_config = wxGetApp().preset_bundle->printers.get_selected_preset().config;
|
||||||
auto opt_nozzle_volume_type = dynamic_cast<const ConfigOptionEnumsGeneric *>(config.option("nozzle_volume_type"));
|
auto opt_extruder_type = dynamic_cast<const ConfigOptionEnumsGeneric *>(cur_printer_config.option("extruder_type"));
|
||||||
|
auto opt_nozzle_volume_type = dynamic_cast<const ConfigOptionEnumsGeneric *>(cur_printer_config.option("nozzle_volume_type"));
|
||||||
|
|
||||||
if (!opt_extruder_type || !opt_nozzle_volume_type)
|
if (!opt_extruder_type || !opt_nozzle_volume_type)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -745,6 +752,7 @@ void ConfigOptionsGroup::back_to_config_value(const DynamicPrintConfig& config,
|
|||||||
auto opt_id = m_opt_map.find(opt_key)->first;
|
auto opt_id = m_opt_map.find(opt_key)->first;
|
||||||
std::string opt_short_key = m_opt_map.at(opt_id).first;
|
std::string opt_short_key = m_opt_map.at(opt_id).first;
|
||||||
int opt_index = m_opt_map.at(opt_id).second;
|
int opt_index = m_opt_map.at(opt_id).second;
|
||||||
|
opt_index = get_extruder_idx(*m_config, opt_short_key, opt_index);
|
||||||
value = get_config_value(config, opt_short_key, opt_index);
|
value = get_config_value(config, opt_short_key, opt_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1270,17 +1278,11 @@ void ExtruderOptionsGroup::on_change_OG(const t_config_option_key& opt_id, const
|
|||||||
auto itOption = it->second;
|
auto itOption = it->second;
|
||||||
const std::string& opt_key = itOption.first;
|
const std::string& opt_key = itOption.first;
|
||||||
|
|
||||||
auto opt = m_config->option(opt_key);
|
|
||||||
const ConfigOptionVectorBase* opt_vec = dynamic_cast<const ConfigOptionVectorBase*>(opt);
|
|
||||||
if (opt_vec != nullptr) {
|
|
||||||
for (int opt_index = 0; opt_index < opt_vec->size(); opt_index++) {
|
|
||||||
this->change_opt_value(opt_key, value, opt_index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
int opt_index = itOption.second;
|
int opt_index = itOption.second;
|
||||||
this->change_opt_value(opt_key, value, opt_index == -1 ? 0 : opt_index);
|
if (printer_extruder_options.find(opt_key) == printer_extruder_options.end()) {
|
||||||
|
opt_index = get_extruder_idx(*m_config, itOption.first, itOption.second);
|
||||||
}
|
}
|
||||||
|
this->change_opt_value(opt_key, value, opt_index == -1 ? 0 : opt_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
OptionsGroup::on_change_OG(opt_id, value);
|
OptionsGroup::on_change_OG(opt_id, value);
|
||||||
|
|||||||
@@ -872,15 +872,26 @@ std::vector<std::string> Tab::filter_diff_option(const std::vector<std::string>
|
|||||||
}
|
}
|
||||||
return std::make_pair(param_name, index);
|
return std::make_pair(param_name, index);
|
||||||
}
|
}
|
||||||
return std::make_pair(value, 0);
|
return std::make_pair(value, -1);
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<std::string> diff_options;
|
std::vector<std::string> diff_options;
|
||||||
for (std::string option : options) {
|
for (std::string option : options) {
|
||||||
auto name_to_index = get_name_and_index(option);
|
auto name_to_index = get_name_and_index(option);
|
||||||
int active_index = get_extruder_idx(*m_config, name_to_index.first, m_active_page->m_extruder_idx);
|
if (name_to_index.second == -1) {
|
||||||
if (active_index == name_to_index.second) {
|
diff_options.emplace_back(option);
|
||||||
std::string name_to_extruder_id = name_to_index.first + "#" + std::to_string(m_active_page->m_extruder_idx);
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t nozzle_nums = wxGetApp().preset_bundle->get_printer_extruder_count();
|
||||||
|
std::vector<int> support_indexes;
|
||||||
|
for (size_t i = 0; i < nozzle_nums; ++i) {
|
||||||
|
support_indexes.push_back(get_extruder_idx(*m_config, name_to_index.first, i));
|
||||||
|
}
|
||||||
|
auto iter = std::find(support_indexes.begin(), support_indexes.end(), name_to_index.second);
|
||||||
|
if (iter != support_indexes.end()) {
|
||||||
|
int extruder_id = std::distance(support_indexes.begin(), iter);
|
||||||
|
std::string name_to_extruder_id = name_to_index.first + "#" + std::to_string(extruder_id);
|
||||||
diff_options.emplace_back(name_to_extruder_id);
|
diff_options.emplace_back(name_to_extruder_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -909,6 +920,7 @@ void Tab::update_changed_ui()
|
|||||||
it.second = m_opt_status_value;
|
it.second = m_opt_status_value;
|
||||||
|
|
||||||
dirty_options = filter_diff_option(dirty_options);
|
dirty_options = filter_diff_option(dirty_options);
|
||||||
|
nonsys_options = filter_diff_option(nonsys_options);
|
||||||
|
|
||||||
for (auto opt_key : dirty_options) {
|
for (auto opt_key : dirty_options) {
|
||||||
m_options_list[opt_key] &= ~osInitValue;
|
m_options_list[opt_key] &= ~osInitValue;
|
||||||
@@ -4464,11 +4476,11 @@ if (is_marlin_flavor)
|
|||||||
//# build page
|
//# build page
|
||||||
//const wxString& page_name = wxString::Format(_L("Extruder %d"), int(extruder_idx + 1));
|
//const wxString& page_name = wxString::Format(_L("Extruder %d"), int(extruder_idx + 1));
|
||||||
auto page = add_options_page(page_name, "custom-gcode_extruder", true); // ORCA: icon only visible on placeholders
|
auto page = add_options_page(page_name, "custom-gcode_extruder", true); // ORCA: icon only visible on placeholders
|
||||||
page->m_extruder_idx = extruder_idx;
|
|
||||||
m_pages.insert(m_pages.begin() + n_before_extruders + extruder_idx, page);
|
m_pages.insert(m_pages.begin() + n_before_extruders + extruder_idx, page);
|
||||||
|
|
||||||
auto optgroup = page->new_optgroup(L("Size"), L"param_extruder_size");
|
auto optgroup = page->new_optgroup(L("Size"), L"param_extruder_size");
|
||||||
optgroup->append_single_option_line("nozzle_diameter", "", extruder_idx);
|
optgroup->append_single_option_line("nozzle_diameter", "", extruder_idx);
|
||||||
|
optgroup->append_single_option_line("nozzle_volume_type", "", extruder_idx);
|
||||||
|
|
||||||
optgroup->m_on_change = [this, extruder_idx](const t_config_option_key& opt_key, boost::any value)
|
optgroup->m_on_change = [this, extruder_idx](const t_config_option_key& opt_key, boost::any value)
|
||||||
{
|
{
|
||||||
@@ -4502,7 +4514,6 @@ if (is_marlin_flavor)
|
|||||||
load_config(new_conf);
|
load_config(new_conf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update_dirty();
|
update_dirty();
|
||||||
on_value_change(opt_key, value);
|
on_value_change(opt_key, value);
|
||||||
update();
|
update();
|
||||||
@@ -6148,7 +6159,12 @@ wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &dep
|
|||||||
return sizer;
|
return sizer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabPrinter::set_extruder_volume_type(int extruder_id, NozzleVolumeType type) {}
|
void TabPrinter::set_extruder_volume_type(int extruder_id, NozzleVolumeType type)
|
||||||
|
{
|
||||||
|
auto nozzle_volumes = m_config->option<ConfigOptionEnumsGeneric>("nozzle_volume_type");
|
||||||
|
assert(nozzle_volumes->values.size() > (size_t)extruder_id);
|
||||||
|
nozzle_volumes->values[extruder_id] = type;
|
||||||
|
}
|
||||||
|
|
||||||
// Return a callback to create a TabPrinter widget to edit bed shape
|
// Return a callback to create a TabPrinter widget to edit bed shape
|
||||||
wxSizer* TabPrinter::create_bed_shape_widget(wxWindow* parent)
|
wxSizer* TabPrinter::create_bed_shape_widget(wxWindow* parent)
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ public:
|
|||||||
// BBS
|
// BBS
|
||||||
bool m_split_multi_line = false;
|
bool m_split_multi_line = false;
|
||||||
bool m_option_label_at_right = false;
|
bool m_option_label_at_right = false;
|
||||||
int m_extruder_idx = 0; // if is multi extruder, recorde the page is belong to which extruder
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::vector <ConfigOptionsGroupShp> m_optgroups;
|
std::vector <ConfigOptionsGroupShp> m_optgroups;
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ int ComboBox::Append(const wxString &item,
|
|||||||
icons.push_back(bitmap);
|
icons.push_back(bitmap);
|
||||||
datas.push_back(clientData);
|
datas.push_back(clientData);
|
||||||
types.push_back(wxClientData_None);
|
types.push_back(wxClientData_None);
|
||||||
|
SetClientDataType(wxClientData_Void);
|
||||||
drop.Invalidate();
|
drop.Invalidate();
|
||||||
return texts.size() - 1;
|
return texts.size() - 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user