Next improvements and fixing of the crash on "Output options" tab selection.

Follow-up d22809bf0d
This commit is contained in:
YuSanka 2022-12-13 14:01:13 +01:00 committed by Pavel Mikuš
parent f04545f1e6
commit 2159caf03b
5 changed files with 19 additions and 42 deletions

View file

@ -1215,18 +1215,19 @@ 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 = {
static const std::set<std::string> independent_from_extruder_number_options = {
"bed_shape",
"thumbnails",
"compatible_printers",
"compatible_prints",
"filament_ramming_parameters",
"gcode_substitutions",
"compatible_prints",
"compatible_printers"
"post_process",
"thumbnails",
};
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();
return independent_from_extruder_number_options.find(opt_key) != independent_from_extruder_number_options.end();
}
// Use deep_diff to correct return of changed options, considering individual options for each extruder.

View file

@ -1001,10 +1001,18 @@ bool OptionsGroup::launch_browser(const std::string& path_end)
return wxGetApp().open_browser_with_warning_dialog(OptionsGroup::get_url(path_end), wxGetApp().mainframe->m_tabpanel);
}
// list of options, which doesn't have a related filed
static const std::set<std::string> options_without_field = {
"compatible_printers",
"compatible_prints",
"bed_shape",
"filament_ramming_parameters",
"gcode_substitutions",
};
bool OptionsGroup::is_option_without_field(const std::string& opt_key)
{
return opt_key!= "thumbnails" // "thumbnails" has related field
&& PresetCollection::is_independent_from_extruder_number_option(opt_key);
return options_without_field.find(opt_key) != options_without_field.end();
}

View file

@ -117,7 +117,7 @@ void OptionsSearcher::append_options(DynamicPrintConfig* config, Preset::Type ty
int cnt = 0;
if ( (type == Preset::TYPE_SLA_MATERIAL || type == Preset::TYPE_PRINTER || type == Preset::TYPE_PRINT) && opt_key != "bed_shape" && opt_key != "thumbnails")
if ( type != Preset::TYPE_FILAMENT && !PresetCollection::is_independent_from_extruder_number_option(opt_key) )
switch (config->option(opt_key)->type())
{
case coInts: change_opt_key<ConfigOptionInts >(opt_key, config, cnt); break;

View file

@ -647,7 +647,7 @@ void Tab::init_options_list()
m_options_list.clear();
for (const std::string& opt_key : m_config->keys())
emplace_option(opt_key);
emplace_option(opt_key, m_type != Preset::TYPE_FILAMENT && !PresetCollection::is_independent_from_extruder_number_option(opt_key));
}
template<class T>
@ -677,44 +677,14 @@ void Tab::emplace_option(const std::string& opt_key, bool respect_vec_values/* =
m_options_list.emplace(opt_key, m_opt_status_value);
}
void TabPrint::init_options_list()
{
m_options_list.clear();
for (const std::string& opt_key : m_config->keys())
emplace_option(opt_key, true);
}
void TabPrinter::init_options_list()
{
m_options_list.clear();
Tab::init_options_list();
for (const std::string& opt_key : m_config->keys())
{
if (opt_key == "bed_shape" || opt_key == "thumbnails") {
m_options_list.emplace(opt_key, m_opt_status_value);
continue;
}
emplace_option(opt_key, true);
}
if (m_printer_technology == ptFFF)
m_options_list.emplace("extruders_count", m_opt_status_value);
}
void TabSLAMaterial::init_options_list()
{
m_options_list.clear();
for (const std::string& opt_key : m_config->keys())
{
if (opt_key == "compatible_prints" || opt_key == "compatible_printers") {
m_options_list.emplace(opt_key, m_opt_status_value);
continue;
}
emplace_option(opt_key, true);
}
}
void Tab::get_sys_and_mod_flags(const std::string& opt_key, bool& sys_page, bool& modified_page)
{
auto opt = m_options_list.find(opt_key);

View file

@ -417,7 +417,6 @@ public:
void toggle_options() override;
void update() override;
void clear_pages() override;
void init_options_list() override;
bool supports_printer_technology(const PrinterTechnology tech) const override { return tech == ptFFF; }
wxSizer* create_manage_substitution_widget(wxWindow* parent);
wxSizer* create_substitutions_widget(wxWindow* parent);
@ -522,7 +521,6 @@ public:
void build() override;
void toggle_options() override;
void update() override;
void init_options_list() override;
bool supports_printer_technology(const PrinterTechnology tech) const override { return tech == ptSLA; }
};