From df20d5a8deb3371bc8de6db42885d8c1680216df Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Sun, 18 Nov 2018 11:40:06 -0600 Subject: [PATCH] Add private methods to get the selected preset name(s). --- src/GUI/Plater/PresetChooser.cpp | 17 +++++++++++++++++ src/GUI/Plater/PresetChooser.hpp | 6 ++++++ 2 files changed, 23 insertions(+) diff --git a/src/GUI/Plater/PresetChooser.cpp b/src/GUI/Plater/PresetChooser.cpp index d1636ffac..f9acce43d 100644 --- a/src/GUI/Plater/PresetChooser.cpp +++ b/src/GUI/Plater/PresetChooser.cpp @@ -127,6 +127,23 @@ bool PresetChooser::prompt_unsaved_changes() { return true; } +std::vector PresetChooser::_get_selected_presets(preset_t group) const { + const auto& choosers { this->preset_choosers[get_preset(group)] }; + std::vector selected; + selected.reserve(choosers.size()); + + for (auto* chooser : choosers) { + selected.push_back(chooser->GetString(chooser->GetSelection())); + } + return selected; +} + +wxString PresetChooser::_get_selected_preset(preset_t group, size_t index) const { + auto selected { this->_get_selected_presets(group) }; + if (index > selected.size()) { return wxString(""); } + return selected.at(index); +} + void PresetChooser::_on_change_combobox(preset_t preset, wxBitmapComboBox* choice) { // Prompt for unsaved changes and undo selections if cancelled and return early diff --git a/src/GUI/Plater/PresetChooser.hpp b/src/GUI/Plater/PresetChooser.hpp index f7338a2f5..97c7e50ce 100644 --- a/src/GUI/Plater/PresetChooser.hpp +++ b/src/GUI/Plater/PresetChooser.hpp @@ -79,6 +79,12 @@ private: void _on_select_preset(preset_t preset); + /// Return the vector of strings representing the selected preset names. + std::vector _get_selected_presets(preset_t group) const; + + /// Fetch the preset name corresponding to the chooser index + wxString _get_selected_preset(preset_t group, size_t index) const; + }; }} // Slic3r::GUI