Fixed update of "Cost" field in "Sliced Info" box after a change of any material's options

("bottle_cost", "bottle_volume", "bottle_weight", "material_density")
This commit is contained in:
YuSanka 2020-01-08 15:23:46 +01:00
parent ca950d1a00
commit 07c1c3d1dc
2 changed files with 6 additions and 8 deletions

View File

@ -1192,9 +1192,9 @@ void Sidebar::update_sliced_info_sizer()
{ {
double material_cost = cfg->option("bottle_cost")->getFloat() / double material_cost = cfg->option("bottle_cost")->getFloat() /
cfg->option("bottle_volume")->getFloat(); cfg->option("bottle_volume")->getFloat();
str_total_cost = wxString::Format("%.2f", material_cost*(ps.objects_used_material + ps.support_used_material) / 1000); str_total_cost = wxString::Format("%.3f", material_cost*(ps.objects_used_material + ps.support_used_material) / 1000);
} }
p->sliced_info->SetTextAndShow(siCost, str_total_cost); p->sliced_info->SetTextAndShow(siCost, str_total_cost, "Cost");
wxString t_est = std::isnan(ps.estimated_print_time) ? "N/A" : get_time_dhms(float(ps.estimated_print_time)); wxString t_est = std::isnan(ps.estimated_print_time) ? "N/A" : get_time_dhms(float(ps.estimated_print_time));
p->sliced_info->SetTextAndShow(siEstimatedTime, t_est, _(L("Estimated printing time")) + " :"); p->sliced_info->SetTextAndShow(siEstimatedTime, t_est, _(L("Estimated printing time")) + " :");

View File

@ -3448,7 +3448,7 @@ void TabSLAMaterial::build()
new_conf.set_key_value("bottle_weight", new ConfigOptionFloat(new_bottle_weight)); new_conf.set_key_value("bottle_weight", new ConfigOptionFloat(new_bottle_weight));
} }
if (opt_key == "bottle_weight") { if (opt_key == "bottle_weight") {
double new_bottle_volume = boost::any_cast<double>(value)/(new_conf.option("material_density")->getFloat() * 1000); double new_bottle_volume = boost::any_cast<double>(value)/new_conf.option("material_density")->getFloat() * 1000;
new_conf.set_key_value("bottle_volume", new ConfigOptionFloat(new_bottle_volume)); new_conf.set_key_value("bottle_volume", new ConfigOptionFloat(new_bottle_volume));
} }
if (opt_key == "material_density") { if (opt_key == "material_density") {
@ -3459,12 +3459,10 @@ void TabSLAMaterial::build()
load_config(new_conf); load_config(new_conf);
update_dirty(); update_dirty();
on_value_change(opt_key, value);
if (opt_key == "bottle_volume" || opt_key == "bottle_cost") { // Change of any from those options influences for an update of "Sliced Info"
wxGetApp().sidebar().update_sliced_info_sizer(); wxGetApp().sidebar().update_sliced_info_sizer();
wxGetApp().sidebar().Layout(); wxGetApp().sidebar().Layout();
}
}; };
optgroup = page->new_optgroup(_(L("Layers"))); optgroup = page->new_optgroup(_(L("Layers")));