Added "Filament -> Spool weight" parameter

This commit is contained in:
YuSanka 2020-11-20 14:30:48 +01:00
parent d5e6b17d70
commit 5330b34d0a
6 changed files with 61 additions and 2 deletions

View file

@ -439,7 +439,7 @@ const std::vector<std::string>& Preset::filament_options()
{
static std::vector<std::string> 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",

View file

@ -98,6 +98,7 @@ bool Print::invalidate_state_by_config_options(const std::vector<t_config_option
"filament_density",
"filament_notes",
"filament_cost",
"filament_spool_weight",
"first_layer_acceleration",
"first_layer_bed_temperature",
"first_layer_speed",

View file

@ -806,6 +806,13 @@ void PrintConfigDef::init_fff_params()
def->min = 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;

View file

@ -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);

View file

@ -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<std::string>& 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)

View file

@ -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"));