diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index 1f00db49d5..0b13745e13 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -439,7 +439,7 @@ const std::vector& Preset::filament_options() { static std::vector s_opts { "filament_colour", "filament_diameter", "filament_type", "filament_soluble", "filament_notes", "filament_max_volumetric_speed", - "extrusion_multiplier", "filament_density", "filament_cost", "filament_loading_speed", "filament_loading_speed_start", "filament_load_time", + "extrusion_multiplier", "filament_density", "filament_cost", "filament_spool_weight", "filament_loading_speed", "filament_loading_speed_start", "filament_load_time", "filament_unloading_speed", "filament_unloading_speed_start", "filament_unload_time", "filament_toolchange_delay", "filament_cooling_moves", "filament_cooling_initial_speed", "filament_cooling_final_speed", "filament_ramming_parameters", "filament_minimal_purge_on_wipe_tower", "temperature", "first_layer_temperature", "bed_temperature", "first_layer_bed_temperature", "fan_always_on", "cooling", "min_fan_speed", diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 47d48dd405..4e4c90fb2f 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -98,6 +98,7 @@ bool Print::invalidate_state_by_config_options(const std::vectormin = 0; def->set_default_value(new ConfigOptionFloats { 0. }); + def = this->add("filament_spool_weight", coFloats); + def->label = L("Spool weight"); + def->tooltip = L("Enter weight of the spool without filament. This is only for statistical information."); + def->sidetext = L("g"); + def->min = 0; + def->set_default_value(new ConfigOptionFloats { 0. }); + def = this->add("filament_settings_id", coStrings); def->set_default_value(new ConfigOptionStrings { "" }); def->cli = ConfigOptionDef::nocli; diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 790e15af68..4f887c7c03 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -683,6 +683,7 @@ public: ConfigOptionStrings filament_type; ConfigOptionBools filament_soluble; ConfigOptionFloats filament_cost; + ConfigOptionFloats filament_spool_weight; ConfigOptionFloats filament_max_volumetric_speed; ConfigOptionFloats filament_loading_speed; ConfigOptionFloats filament_loading_speed_start; @@ -759,6 +760,7 @@ protected: OPT_PTR(filament_type); OPT_PTR(filament_soluble); OPT_PTR(filament_cost); + OPT_PTR(filament_spool_weight); OPT_PTR(filament_max_volumetric_speed); OPT_PTR(filament_loading_speed); OPT_PTR(filament_loading_speed_start); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 4b31f10d75..763a906f51 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1156,7 +1156,43 @@ void Sidebar::update_sliced_info_sizer() new_label = imperial_units ? _L("Used Filament (in³)") : _L("Used Filament (mm³)"); info_text = wxString::Format("%.2f", imperial_units ? ps.total_extruded_volume * koef : ps.total_extruded_volume); p->sliced_info->SetTextAndShow(siFilament_mm3, info_text, new_label); - p->sliced_info->SetTextAndShow(siFilament_g, ps.total_weight == 0.0 ? "N/A" : wxString::Format("%.2f", ps.total_weight)); + + if (ps.total_weight == 0.0) + p->sliced_info->SetTextAndShow(siFilament_g, "N/A"); + else { + new_label = _L("Used Filament (g)"); + info_text = wxString::Format("%.2f", ps.total_weight); + + const std::vector& filament_presets = wxGetApp().preset_bundle->filament_presets; + const PresetCollection& filaments = wxGetApp().preset_bundle->filaments; + + if (ps.filament_stats.size() > 1) + new_label += ":"; + + for (auto filament : ps.filament_stats) { + const Preset* filament_preset = filaments.find_preset(filament_presets[filament.first], false); + if (filament_preset) { + double filament_weight; + if (ps.filament_stats.size() == 1) + filament_weight = ps.total_weight; + else { + double filament_density = filament_preset->config.opt_float("filament_density", 0); + filament_weight = filament.second * filament_density * 2.4052f * 0.001; // assumes 1.75mm filament diameter; + + new_label += "\n - " + format_wxstr(_L("Filament at extruder %1%"), filament.first + 1); + info_text += wxString::Format("\n%.2f", filament_weight); + } + + double spool_weight = filament_preset->config.opt_float("filament_spool_weight", 0); + if (spool_weight != 0.0) { + new_label += "\n " + _L("(weight with spool)"); + info_text += wxString::Format(" (%.2f)\n", filament_weight + spool_weight); + } + } + } + + p->sliced_info->SetTextAndShow(siFilament_g, info_text, new_label); + } new_label = _L("Cost"); if (is_wipe_tower) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 3b2f26668b..940b4eeb2e 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1785,6 +1785,19 @@ void TabFilament::build() optgroup->append_single_option_line("extrusion_multiplier"); optgroup->append_single_option_line("filament_density"); optgroup->append_single_option_line("filament_cost"); + optgroup->append_single_option_line("filament_spool_weight"); + + optgroup->m_on_change = [this, optgroup](t_config_option_key opt_key, boost::any value) + { + update_dirty(); + if (opt_key == "filament_spool_weight") { + // Change of this option influences for an update of "Sliced Info" + wxGetApp().sidebar().update_sliced_info_sizer(); + wxGetApp().sidebar().Layout(); + } + else + on_value_change(opt_key, value); + }; // optgroup = page->new_optgroup(_(L("Temperature")) + wxString(" °C", wxConvUTF8)); optgroup = page->new_optgroup(L("Temperature"));