Folllow-up 8c36ea00f4
: Code refactoring for other related places
This commit is contained in:
parent
8c36ea00f4
commit
32d5d2e8ce
5 changed files with 16 additions and 14 deletions
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <array>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
namespace Slic3r {
|
||||
|
@ -155,6 +156,13 @@ public:
|
|||
const std::string& new_name, const std::vector<std::string>& options);
|
||||
|
||||
static const char *PRUSA_BUNDLE;
|
||||
|
||||
static std::array<Preset::Type, 3> types_list(PrinterTechnology pt) {
|
||||
if (pt == ptFFF)
|
||||
return { Preset::TYPE_PRINTER, Preset::TYPE_PRINT, Preset::TYPE_FILAMENT };
|
||||
return { Preset::TYPE_PRINTER, Preset::TYPE_SLA_PRINT, Preset::TYPE_SLA_MATERIAL };
|
||||
}
|
||||
|
||||
private:
|
||||
std::pair<PresetsConfigSubstitutions, std::string> load_system_presets(ForwardCompatibilitySubstitutionRule compatibility_rule);
|
||||
// Merge one vendor's presets with the other vendor's presets, report duplicates.
|
||||
|
|
|
@ -307,9 +307,7 @@ void MainFrame::bind_diff_dialog()
|
|||
auto process_options = [this](std::function<void(Preset::Type)> process) {
|
||||
const Preset::Type diff_dlg_type = diff_dialog.view_type();
|
||||
if (diff_dlg_type == Preset::TYPE_INVALID) {
|
||||
for (const Preset::Type& type : diff_dialog.printer_technology() == ptFFF ?
|
||||
std::initializer_list<Preset::Type>{Preset::TYPE_PRINTER, Preset::TYPE_PRINT, Preset::TYPE_FILAMENT} :
|
||||
std::initializer_list<Preset::Type>{ Preset::TYPE_PRINTER, Preset::TYPE_SLA_PRINT, Preset::TYPE_SLA_MATERIAL } )
|
||||
for (const Preset::Type& type : diff_dialog.types_list() )
|
||||
process(type);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -141,11 +141,7 @@ const Preset* SavePresetDialog::Item::get_existing_preset() const
|
|||
if (m_presets)
|
||||
return m_presets->find_preset(m_preset_name, false);
|
||||
|
||||
const auto types = m_printer_technology == ptFFF ?
|
||||
std::initializer_list<Preset::Type>{Preset::TYPE_PRINTER, Preset::TYPE_PRINT, Preset::TYPE_FILAMENT } :
|
||||
std::initializer_list<Preset::Type>{Preset::TYPE_PRINTER, Preset::TYPE_SLA_PRINT, Preset::TYPE_SLA_MATERIAL };
|
||||
|
||||
for (auto type : types) {
|
||||
for (const Preset::Type& type : PresetBundle::types_list(m_printer_technology)) {
|
||||
const PresetCollection& presets = wxGetApp().preset_bundle->get_presets(type);
|
||||
if (const Preset* preset = presets.find_preset(m_preset_name, false))
|
||||
return preset;
|
||||
|
|
|
@ -1571,11 +1571,9 @@ void DiffPresetDialog::create_tree()
|
|||
m_tree->GetColumn(DiffModel::colToggle)->SetHidden(true);
|
||||
}
|
||||
|
||||
static std::array<Preset::Type, 3> types_list(PrinterTechnology pt)
|
||||
std::array<Preset::Type, 3> DiffPresetDialog::types_list() const
|
||||
{
|
||||
if (pt == ptFFF)
|
||||
return { Preset::TYPE_PRINTER, Preset::TYPE_PRINT, Preset::TYPE_FILAMENT };
|
||||
return { Preset::TYPE_PRINTER, Preset::TYPE_SLA_PRINT, Preset::TYPE_SLA_MATERIAL };
|
||||
return PresetBundle::types_list(m_pr_technology);
|
||||
}
|
||||
|
||||
void DiffPresetDialog::create_buttons()
|
||||
|
@ -1605,7 +1603,7 @@ void DiffPresetDialog::create_buttons()
|
|||
bool enable = m_tree->has_selection();
|
||||
if (enable) {
|
||||
if (m_view_type == Preset::TYPE_INVALID) {
|
||||
for (const Preset::Type& type : types_list(m_pr_technology))
|
||||
for (const Preset::Type& type : types_list())
|
||||
if (!enable_transfer(type)) {
|
||||
enable = false;
|
||||
break;
|
||||
|
@ -2030,7 +2028,7 @@ bool DiffPresetDialog::is_save_confirmed()
|
|||
|
||||
std::vector<Preset::Type> types_for_save;
|
||||
|
||||
for (const Preset::Type& type : types_list(m_pr_technology)) {
|
||||
for (const Preset::Type& type : types_list()) {
|
||||
if (!m_tree->options(type, true).empty()) {
|
||||
types_for_save.emplace_back(type);
|
||||
presets_to_save.emplace_back(PresetToSave{ type, get_left_preset_name(type), get_right_preset_name(type), get_right_preset_name(type) });
|
||||
|
|
|
@ -416,6 +416,8 @@ public:
|
|||
|
||||
std::vector<std::string> get_selected_options(Preset::Type type) const { return m_tree->options(type, true); }
|
||||
|
||||
std::array<Preset::Type, 3> types_list() const;
|
||||
|
||||
protected:
|
||||
void on_dpi_changed(const wxRect& suggested_rect) override;
|
||||
void on_sys_color_changed() override;
|
||||
|
|
Loading…
Reference in a new issue