mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-22 10:22:08 +00:00
NEW: Official filament color selection approved
- Add a filament picker dialog for official color selection - Enable displaying multiple filament colors in the picker dialog and preview sidebar - Introduce two new config options: - `filament_multi_colors` - `filament_color_types` to both the application config and the 3MF config jira: STUDIO-12346 Change-Id: I66f8c1ec9147df4f5948c8a329c1737551280e63 (cherry picked from commit 522dc0bbca49033a1ba9725ca7f6c3ea729691a6)
This commit is contained in:
@@ -2923,14 +2923,15 @@ std::map<int, DynamicPrintConfig> Sidebar::build_filament_ams_list(MachineObject
|
||||
tray_config.set_key_value("tray_name", new ConfigOptionStrings{ name });
|
||||
tray_config.set_key_value("filament_colour", new ConfigOptionStrings{into_u8(wxColour("#" + tray.color).GetAsString(wxC2S_HTML_SYNTAX))});
|
||||
tray_config.set_key_value("filament_exist", new ConfigOptionBools{tray.is_exists});
|
||||
tray_config.set_key_value("filament_multi_colors", new ConfigOptionStrings{});
|
||||
tray_config.set_key_value("filament_multi_colour", new ConfigOptionStrings{});
|
||||
tray_config.set_key_value("filament_colour_type", new ConfigOptionStrings{std::to_string(tray.ctype)});
|
||||
std::optional<FilamentBaseInfo> info;
|
||||
if (wxGetApp().preset_bundle) {
|
||||
info = wxGetApp().preset_bundle->get_filament_by_filament_id(tray.setting_id);
|
||||
}
|
||||
tray_config.set_key_value("filament_is_support", new ConfigOptionBools{ info.has_value() ? info->is_support : false});
|
||||
for (int i = 0; i < tray.cols.size(); ++i) {
|
||||
tray_config.opt<ConfigOptionStrings>("filament_multi_colors")->values.push_back(into_u8(wxColour("#" + tray.cols[i]).GetAsString(wxC2S_HTML_SYNTAX)));
|
||||
tray_config.opt<ConfigOptionStrings>("filament_multi_colour")->values.push_back(into_u8(wxColour("#" + tray.cols[i]).GetAsString(wxC2S_HTML_SYNTAX)));
|
||||
}
|
||||
return tray_config;
|
||||
};
|
||||
@@ -5809,11 +5810,42 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
||||
*wipe_tower_y = *file_wipe_tower_y;
|
||||
|
||||
ConfigOptionStrings* filament_color = proj_cfg.opt<ConfigOptionStrings>("filament_colour");
|
||||
ConfigOptionInts* filament_map = proj_cfg.opt<ConfigOptionInts>("filament_map", true);
|
||||
if (filament_color && filament_color->size() != filament_map->size()) {
|
||||
filament_map->values.resize(filament_color->size(), 1);
|
||||
if (filament_color) {
|
||||
size_t filament_count = filament_color->size();
|
||||
|
||||
// Sync filament map
|
||||
ConfigOptionInts* filament_map = proj_cfg.opt<ConfigOptionInts>("filament_map", true);
|
||||
if (filament_map->size() != filament_count) {
|
||||
filament_map->values.resize(filament_count, 1);
|
||||
}
|
||||
|
||||
// Sync filament multi colour
|
||||
ConfigOptionStrings* filament_multi_color = proj_cfg.opt<ConfigOptionStrings>("filament_multi_colour", true);
|
||||
if (filament_multi_color->size() != filament_count) {
|
||||
filament_multi_color->values.resize(filament_count);
|
||||
}
|
||||
// If there is no multi-color data or color is not match, use single color as default value
|
||||
for (size_t i = 0; i < filament_count; i++) {
|
||||
std::vector<std::string> colors = Slic3r::split_string(filament_multi_color->values[i], ',');
|
||||
if (i >= filament_multi_color->values.size() || colors.empty() || colors[0] != filament_color->values[i] ) {
|
||||
filament_multi_color->values[i] = filament_color->values[i];
|
||||
}
|
||||
}
|
||||
// Sync filament colour type
|
||||
ConfigOptionStrings* filament_color_type = proj_cfg.opt<ConfigOptionStrings>("filament_colour_type", true);
|
||||
if (filament_color_type && filament_color_type->size() != filament_count) {
|
||||
filament_color_type->values.resize(filament_count);
|
||||
|
||||
for (size_t i = 0; i < filament_count; i++) {
|
||||
if (i >= filament_color_type->values.size() || filament_color_type->values[i].empty()) {
|
||||
filament_color_type->values[i] = "1";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Update filament combobox after loading config
|
||||
wxGetApp().plater()->sidebar().update_presets(Preset::TYPE_FILAMENT);
|
||||
}
|
||||
}
|
||||
if (!silence) wxGetApp().app_config->update_config_dir(path.parent_path().string());
|
||||
@@ -15501,6 +15533,26 @@ std::vector<std::string> Plater::get_extruder_colors_from_plater_config(const GC
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> Plater::get_filament_colors_render_info() const
|
||||
{
|
||||
const Slic3r::DynamicPrintConfig* config = &wxGetApp().preset_bundle->project_config;
|
||||
std::vector<std::string> color_packs;
|
||||
if (!config->has("filament_multi_colour")) return color_packs;
|
||||
|
||||
color_packs = (config->option<ConfigOptionStrings>("filament_multi_colour"))->values;
|
||||
return color_packs;
|
||||
}
|
||||
|
||||
std::vector<std::string> Plater::get_filament_color_render_type() const
|
||||
{
|
||||
const Slic3r::DynamicPrintConfig *config = &wxGetApp().preset_bundle->project_config;
|
||||
std::vector<std::string> ctype;
|
||||
if (!config->has("filament_colour_type")) return ctype;
|
||||
|
||||
ctype = (config->option<ConfigOptionStrings>("filament_colour_type"))->values;
|
||||
return ctype;
|
||||
}
|
||||
|
||||
/* Get vector of colors used for rendering of a Preview scene in "Color print" mode
|
||||
* It consists of extruder colors and colors, saved in model.custom_gcode_per_print_z
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user