mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2026-01-04 05:50:37 -07:00
Merge e2f5d589fa into 506fde8f86
This commit is contained in:
commit
09870d7b8d
4 changed files with 42 additions and 6 deletions
|
|
@ -318,6 +318,10 @@ void AppConfig::set_defaults()
|
|||
set_bool("remember_printer_config", true);
|
||||
}
|
||||
|
||||
if (get("group_filament_presets").empty()) {
|
||||
set("group_filament_presets", "1"); // All "0" / None "1" / By Vendor "2" / By Type "3"
|
||||
}
|
||||
|
||||
if (get("enable_high_low_temp_mixed_printing").empty()){
|
||||
set_bool("enable_high_low_temp_mixed_printing", false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ std::tuple<wxBoxSizer*, ComboBox*> PreferencesDialog::create_item_combobox_base(
|
|||
return {m_sizer_combox, combobox};
|
||||
}
|
||||
|
||||
wxBoxSizer* PreferencesDialog::create_item_combobox(wxString title, wxString tooltip, std::string param, std::vector<wxString> vlist)
|
||||
wxBoxSizer* PreferencesDialog::create_item_combobox(wxString title, wxString tooltip, std::string param, std::vector<wxString> vlist, std::function<void(wxString)> onchange)
|
||||
{
|
||||
unsigned int current_index = 0;
|
||||
|
||||
|
|
@ -90,8 +90,10 @@ wxBoxSizer* PreferencesDialog::create_item_combobox(wxString title, wxString too
|
|||
auto [sizer, combobox] = create_item_combobox_base(title, tooltip, param, vlist, current_index);
|
||||
|
||||
//// save config
|
||||
combobox->GetDropDown().Bind(wxEVT_COMBOBOX, [this, param](wxCommandEvent& e) {
|
||||
combobox->GetDropDown().Bind(wxEVT_COMBOBOX, [this, param, onchange](wxCommandEvent& e) {
|
||||
app_config->set(param, std::to_string(e.GetSelection()));
|
||||
if (onchange)
|
||||
onchange(std::to_string(e.GetSelection()));
|
||||
e.Skip();
|
||||
});
|
||||
|
||||
|
|
@ -1289,6 +1291,10 @@ void PreferencesDialog::create_items()
|
|||
auto item_remember_printer = create_item_checkbox(_L("Remember printer configuration"), _L("If enabled, Orca will remember and switch filament/process configuration for each printer automatically."), "remember_printer_config");
|
||||
g_sizer->Add(item_remember_printer);
|
||||
|
||||
auto item_filament_preset_grouping = create_item_combobox(_L("Group user filament presets"), _L("Groups user filament presets depends on selection"),
|
||||
"group_filament_presets", {_L("All"), _L("None"), _L("By type"), _L("By vendor")}, [](wxString value) {wxGetApp().plater()->sidebar().update_presets(Preset::TYPE_FILAMENT);});
|
||||
g_sizer->Add(item_filament_preset_grouping);
|
||||
|
||||
//// GENERAL > Features
|
||||
g_sizer->Add(create_item_title(_L("Features")), 1, wxEXPAND);
|
||||
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public:
|
|||
std::vector<wxFlexGridSizer*> f_sizers;
|
||||
|
||||
wxBoxSizer *create_item_title(wxString title);
|
||||
wxBoxSizer *create_item_combobox(wxString title, wxString tooltip, std::string param, std::vector<wxString> vlist);
|
||||
wxBoxSizer *create_item_combobox(wxString title, wxString tooltip, std::string param, std::vector<wxString> vlist, std::function<void(wxString)> onchange = {});
|
||||
wxBoxSizer *create_item_combobox(wxString title, wxString tooltip, std::string param, std::vector<wxString> vlist, std::vector<std::string> config_name_index);
|
||||
wxBoxSizer *create_item_region_combobox(wxString title, wxString tooltip);
|
||||
wxBoxSizer *create_item_language_combobox(wxString title, wxString tooltip);
|
||||
|
|
|
|||
|
|
@ -1174,7 +1174,7 @@ void PlaterPresetComboBox::update()
|
|||
|
||||
bitmap_key += single_bar ? filament_rgb : filament_rgb + extruder_rgb;
|
||||
#endif
|
||||
if (preset.is_system) {
|
||||
if (1) { // preset.is_system ORCA allow caching vendor and type values for all presets instead just system ones
|
||||
if (!preset.is_compatible && preset_filament_vendors.count(name) > 0)
|
||||
continue;
|
||||
else if (preset.is_compatible && preset_filament_vendors.count(name) > 0)
|
||||
|
|
@ -1285,9 +1285,29 @@ void PlaterPresetComboBox::update()
|
|||
}
|
||||
return l->first < r->first;
|
||||
});
|
||||
// ORCA add sorting support for vendor / type for user presets
|
||||
if (groupName == "by_vendor" || groupName == "by_type" ){
|
||||
auto by = groupName == "by_vendor" ? preset_filament_vendors : preset_filament_types;
|
||||
std::sort(list.begin(), list.end(), [&by](auto *l, auto *r) {
|
||||
auto get_key = [&](auto* item) -> std::pair<bool, std::string> {
|
||||
std::string str = by.count(item->first) ? by.at(item->first) : "";
|
||||
std::transform(str.begin(), str.end(), str.begin(), [](unsigned char c) { return std::tolower(c);});
|
||||
return {!str.empty(), str}; // is_valid, lower_case
|
||||
};
|
||||
auto [l_valid, l_lower] = get_key(l);
|
||||
auto [r_valid, r_lower] = get_key(r);
|
||||
return (l_valid != r_valid) ? l_valid > r_valid
|
||||
: (l_lower != r_lower) ? l_lower < r_lower
|
||||
: l->first < r->first;
|
||||
});
|
||||
}
|
||||
bool unsupported = group == "Unsupported presets";
|
||||
for (auto it : list) {
|
||||
auto groupName2 = groupByGroup ? groupName : preset_filament_vendors[it->first];
|
||||
// ORCA add sorting support for vendor / type for user presets
|
||||
auto groupName2 = groupName == "by_type" ? (preset_filament_types[it->first].empty() ? _L("Unspecified") : preset_filament_types[it->first])
|
||||
: groupName == "by_vendor" ? (preset_filament_vendors[it->first].empty() ? _L("Unspecified") : preset_filament_vendors[it->first])
|
||||
: groupByGroup ? groupName
|
||||
: preset_filament_vendors[it->first];
|
||||
int index = Append(it->first, *it->second, groupName2, nullptr, unsupported ? DD_ITEM_STYLE_DISABLED : 0);
|
||||
if (unsupported)
|
||||
set_label_marker(index, LABEL_ITEM_DISABLED);
|
||||
|
|
@ -1311,7 +1331,13 @@ void PlaterPresetComboBox::update()
|
|||
|
||||
//BBS: add project embedded preset logic
|
||||
add_presets(project_embedded_presets, selected_user_preset, L("Project-inside presets"), _L("Project") + " ");
|
||||
add_presets(nonsys_presets, selected_user_preset, L("User presets"), _L("Custom") + " ");
|
||||
// ORCA add sorting support for vendor / type for user presets
|
||||
auto group_filament_presets = wxGetApp().app_config->get("group_filament_presets");
|
||||
auto group_filament_presets_by = group_filament_presets == "0" ? (_L("Custom") + " ") // Append all to "Custom" sub menu
|
||||
: group_filament_presets == "2" ? "by_type" // Create sub menus with filament type
|
||||
: group_filament_presets == "3" ? "by_vendor" // Create sub menus with filament vendor
|
||||
: ""; // Use without sub menu
|
||||
add_presets(nonsys_presets, selected_user_preset, L("User presets"), group_filament_presets_by);
|
||||
// BBS: move system to the end
|
||||
add_presets(system_presets, selected_system_preset, L("System presets"), _L("System"));
|
||||
add_presets(uncompatible_presets, {}, L("Unsupported presets"), _L("Unsupported") + " ");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue