mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-16 14:16:00 +08:00
Folllow-up 8c36ea00f4
: Code refactoring for other related places
This commit is contained in:
parent
8c36ea00f4
commit
32d5d2e8ce
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <array>
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
@ -155,6 +156,13 @@ public:
|
|||||||
const std::string& new_name, const std::vector<std::string>& options);
|
const std::string& new_name, const std::vector<std::string>& options);
|
||||||
|
|
||||||
static const char *PRUSA_BUNDLE;
|
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:
|
private:
|
||||||
std::pair<PresetsConfigSubstitutions, std::string> load_system_presets(ForwardCompatibilitySubstitutionRule compatibility_rule);
|
std::pair<PresetsConfigSubstitutions, std::string> load_system_presets(ForwardCompatibilitySubstitutionRule compatibility_rule);
|
||||||
// Merge one vendor's presets with the other vendor's presets, report duplicates.
|
// 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) {
|
auto process_options = [this](std::function<void(Preset::Type)> process) {
|
||||||
const Preset::Type diff_dlg_type = diff_dialog.view_type();
|
const Preset::Type diff_dlg_type = diff_dialog.view_type();
|
||||||
if (diff_dlg_type == Preset::TYPE_INVALID) {
|
if (diff_dlg_type == Preset::TYPE_INVALID) {
|
||||||
for (const Preset::Type& type : diff_dialog.printer_technology() == ptFFF ?
|
for (const Preset::Type& type : diff_dialog.types_list() )
|
||||||
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 } )
|
|
||||||
process(type);
|
process(type);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -141,11 +141,7 @@ const Preset* SavePresetDialog::Item::get_existing_preset() const
|
|||||||
if (m_presets)
|
if (m_presets)
|
||||||
return m_presets->find_preset(m_preset_name, false);
|
return m_presets->find_preset(m_preset_name, false);
|
||||||
|
|
||||||
const auto types = m_printer_technology == ptFFF ?
|
for (const Preset::Type& type : PresetBundle::types_list(m_printer_technology)) {
|
||||||
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) {
|
|
||||||
const PresetCollection& presets = wxGetApp().preset_bundle->get_presets(type);
|
const PresetCollection& presets = wxGetApp().preset_bundle->get_presets(type);
|
||||||
if (const Preset* preset = presets.find_preset(m_preset_name, false))
|
if (const Preset* preset = presets.find_preset(m_preset_name, false))
|
||||||
return preset;
|
return preset;
|
||||||
|
@ -1571,11 +1571,9 @@ void DiffPresetDialog::create_tree()
|
|||||||
m_tree->GetColumn(DiffModel::colToggle)->SetHidden(true);
|
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 PresetBundle::types_list(m_pr_technology);
|
||||||
return { Preset::TYPE_PRINTER, Preset::TYPE_PRINT, Preset::TYPE_FILAMENT };
|
|
||||||
return { Preset::TYPE_PRINTER, Preset::TYPE_SLA_PRINT, Preset::TYPE_SLA_MATERIAL };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiffPresetDialog::create_buttons()
|
void DiffPresetDialog::create_buttons()
|
||||||
@ -1605,7 +1603,7 @@ void DiffPresetDialog::create_buttons()
|
|||||||
bool enable = m_tree->has_selection();
|
bool enable = m_tree->has_selection();
|
||||||
if (enable) {
|
if (enable) {
|
||||||
if (m_view_type == Preset::TYPE_INVALID) {
|
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)) {
|
if (!enable_transfer(type)) {
|
||||||
enable = false;
|
enable = false;
|
||||||
break;
|
break;
|
||||||
@ -2030,7 +2028,7 @@ bool DiffPresetDialog::is_save_confirmed()
|
|||||||
|
|
||||||
std::vector<Preset::Type> types_for_save;
|
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()) {
|
if (!m_tree->options(type, true).empty()) {
|
||||||
types_for_save.emplace_back(type);
|
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) });
|
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::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:
|
protected:
|
||||||
void on_dpi_changed(const wxRect& suggested_rect) override;
|
void on_dpi_changed(const wxRect& suggested_rect) override;
|
||||||
void on_sys_color_changed() override;
|
void on_sys_color_changed() override;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user