From 99bd054e990feb1b2a01e1641935fcad87117911 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 25 Jul 2019 17:24:00 +0200 Subject: [PATCH] Fixed updating of an option list for additional settings --- src/slic3r/GUI/GUI_ObjectList.cpp | 24 +++++++----------------- src/slic3r/GUI/GUI_ObjectList.hpp | 4 ++-- src/slic3r/GUI/GUI_ObjectSettings.cpp | 10 ++-------- src/slic3r/GUI/Plater.cpp | 3 ++- 4 files changed, 13 insertions(+), 28 deletions(-) diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index 8d5c3fda9..a247a92f8 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -1566,9 +1566,9 @@ void ObjectList::create_freq_settings_popupmenu(wxMenu *menu) #endif } -void ObjectList::update_opt_keys(t_config_option_keys& opt_keys) +void ObjectList::update_opt_keys(t_config_option_keys& opt_keys, const bool is_object) { - auto full_current_opts = get_options(false); + auto full_current_opts = get_options(!is_object); for (int i = opt_keys.size()-1; i >= 0; --i) if (find(full_current_opts.begin(), full_current_opts.end(), opt_keys[i]) == full_current_opts.end()) opt_keys.erase(opt_keys.begin() + i); @@ -2161,16 +2161,15 @@ void ObjectList::part_selection_changed() panel.Thaw(); } -SettingsBundle ObjectList::get_item_settings_bundle(const DynamicPrintConfig* config, const bool is_layers_range_settings) +SettingsBundle ObjectList::get_item_settings_bundle(const DynamicPrintConfig* config, const bool is_object_settings) { auto opt_keys = config->keys(); if (opt_keys.empty()) return SettingsBundle(); - update_opt_keys(opt_keys); // update options list according to print technology + update_opt_keys(opt_keys, is_object_settings); // update options list according to print technology - if (opt_keys.size() == 1 && opt_keys[0] == "extruder" || - is_layers_range_settings && opt_keys.size() == 2) + if (opt_keys.empty()) return SettingsBundle(); const int extruders_cnt = wxGetApp().extruders_edited_cnt(); @@ -2201,24 +2200,15 @@ wxDataViewItem ObjectList::add_settings_item(wxDataViewItem parent_item, const D if (!parent_item) return ret; - const bool is_layers_range_settings = m_objects_model->GetItemType(parent_item) == itLayer; - SettingsBundle cat_options = get_item_settings_bundle(config, is_layers_range_settings); + const bool is_object_settings = m_objects_model->GetItemType(parent_item) == itObject; + SettingsBundle cat_options = get_item_settings_bundle(config, is_object_settings); if (cat_options.empty()) return ret; std::vector categories; categories.reserve(cat_options.size()); for (auto& cat : cat_options) - { - if (cat.second.size() == 1 && - (cat.second[0] == "extruder" || is_layers_range_settings && cat.second[0] == "layer_height")) - continue; - categories.push_back(cat.first); - } - - if (categories.empty()) - return ret; if (m_objects_model->GetItemType(parent_item) & itInstance) parent_item = m_objects_model->GetTopParent(parent_item); diff --git a/src/slic3r/GUI/GUI_ObjectList.hpp b/src/slic3r/GUI/GUI_ObjectList.hpp index 5c971c40f..39558d1c5 100644 --- a/src/slic3r/GUI/GUI_ObjectList.hpp +++ b/src/slic3r/GUI/GUI_ObjectList.hpp @@ -238,7 +238,7 @@ public: wxMenu* create_settings_popupmenu(wxMenu *parent_menu); void create_freq_settings_popupmenu(wxMenu *parent_menu); - void update_opt_keys(t_config_option_keys& t_optopt_keys); + void update_opt_keys(t_config_option_keys& t_optopt_keys, const bool is_object); void load_subobject(ModelVolumeType type); void load_part(ModelObject* model_object, std::vector> &volumes_info, ModelVolumeType type); @@ -266,7 +266,7 @@ public: wxBoxSizer* get_sizer() {return m_sizer;} int get_selected_obj_idx() const; DynamicPrintConfig& get_item_config(const wxDataViewItem& item) const; - SettingsBundle get_item_settings_bundle(const DynamicPrintConfig* config, const bool is_layers_range_settings); + SettingsBundle get_item_settings_bundle(const DynamicPrintConfig* config, const bool is_object_settings); void changed_object(const int obj_idx = -1) const; void part_selection_changed(); diff --git a/src/slic3r/GUI/GUI_ObjectSettings.cpp b/src/slic3r/GUI/GUI_ObjectSettings.cpp index 8728156ac..78c64e03e 100644 --- a/src/slic3r/GUI/GUI_ObjectSettings.cpp +++ b/src/slic3r/GUI/GUI_ObjectSettings.cpp @@ -77,8 +77,8 @@ bool ObjectSettings::update_settings_list() if (!item || !objects_model->IsSettingsItem(item) || !config || objects_ctrl->multiple_selection()) return false; - const bool is_layers_range_settings = objects_model->GetItemType(objects_model->GetParent(item)) == itLayer; - SettingsBundle cat_options = objects_ctrl->get_item_settings_bundle(config, is_layers_range_settings); + const bool is_object_settings = objects_model->GetItemType(objects_model->GetParent(item)) == itObject; + SettingsBundle cat_options = objects_ctrl->get_item_settings_bundle(config, is_object_settings); if (!cat_options.empty()) { @@ -107,10 +107,6 @@ bool ObjectSettings::update_settings_list() for (auto& cat : cat_options) { - if (cat.second.size() == 1 && - (cat.second[0] == "extruder" || is_layers_range_settings && cat.second[0] == "layer_height")) - continue; - categories.push_back(cat.first); auto optgroup = std::make_shared(m_og->ctrl_parent(), _(cat.first), config, false, extra_column); @@ -131,8 +127,6 @@ bool ObjectSettings::update_settings_list() const bool is_extruders_cat = cat.first == "Extruders"; for (auto& opt : cat.second) { - if (opt == "extruder" || is_layers_range_settings && opt == "layer_height") - continue; Option option = optgroup->get_option(opt); option.opt.width = 12; if (is_extruders_cat) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 1e9260d07..eb807aa57 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -3799,6 +3799,7 @@ void Plater::priv::undo_redo_to(std::vector::const_iterator model.wipe_tower.position = Vec2d(config.opt_float("wipe_tower_x"), config.opt_float("wipe_tower_y")); model.wipe_tower.rotation = config.opt_float("wipe_tower_rotation_angle"); } + const int layer_range_idx = it_snapshot->snapshot_data.layer_range_idx; // Flags made of Snapshot::Flags enum values. unsigned int new_flags = it_snapshot->snapshot_data.flags; UndoRedo::SnapshotData top_snapshot_data; @@ -3858,7 +3859,7 @@ void Plater::priv::undo_redo_to(std::vector::const_iterator new_selected_layerroot_on_sidebar ? ObjectList::SELECTION_MODE::smLayerRoot : ObjectList::SELECTION_MODE::smUndef); if (new_selected_settings_on_sidebar || new_selected_layer_on_sidebar) - this->sidebar->obj_list()->set_selected_layers_range_idx(it_snapshot->snapshot_data.layer_range_idx); + this->sidebar->obj_list()->set_selected_layers_range_idx(layer_range_idx); this->update_after_undo_redo(temp_snapshot_was_taken); // Enable layer editing after the Undo / Redo jump.