NEW: show cost of filament in GUI

Signed-off-by: qing.zhang <qing.zhang@bambulab.com>
Change-Id: If28f6e969728fb5edd9cb35d6bc6d0a6c155d96e
(cherry picked from commit a4b8e620794f611c2f94f639cec49ec7c8fe8926)
This commit is contained in:
qing.zhang 2022-08-15 14:58:46 +08:00 committed by Lane.Wei
parent 663df48a95
commit ef46654cca
11 changed files with 38 additions and 5 deletions

View File

@ -1,7 +1,7 @@
{
"name": "Bambulab",
"url": "http://www.bambulab.com/Parameters/vendor/BBL.json",
"version": "01.01.01.03",
"version": "01.01.01.04",
"force_update": "0",
"description": "the initial version of BBL configurations",
"machine_model_list": [

View File

@ -8,6 +8,9 @@
"filament_flow_ratio": [
"0.95"
],
"filament_cost": [
"24.99"
],
"filament_vendor": [
"Bambu Lab"
]

View File

@ -20,6 +20,9 @@
"filament_type": [
"PA-CF"
],
"filament_cost": [
"44.99"
],
"nozzle_temperature": [
"280"
]

View File

@ -8,6 +8,9 @@
"filament_vendor": [
"Bambu Lab"
],
"filament_cost": [
"34.99"
],
"filament_flow_ratio": [
"0.94"
]

View File

@ -9,7 +9,7 @@
"Bambu Lab"
],
"filament_cost": [
"25.4"
"24.99"
],
"filament_flow_ratio": [
"0.98"

View File

@ -9,7 +9,7 @@
"Bambu Lab"
],
"filament_cost": [
"25.4"
"24.99"
],
"filament_density": [
"1.32"

View File

@ -23,6 +23,9 @@
"fan_cooling_layer_time": [
"10"
],
"filament_cost": [
"34.99"
],
"slow_down_layer_time":[
"6"
]

View File

@ -26,6 +26,9 @@
"hot_plate_temp_initial_layer": [
"40"
],
"filament_cost": [
"29.99"
],
"slow_down_layer_time": [
"8"
]

View File

@ -14,6 +14,9 @@
"nozzle_temperature_initial_layer": [
"230"
],
"filament_cost": [
"36.99"
],
"nozzle_temperature": [
"230"
]

View File

@ -990,7 +990,7 @@ void PrintConfigDef::init_fff_params()
def->tooltip = L("Filament price. For statistics only");
def->sidetext = L("money/kg");
def->min = 0;
def->mode = comDevelop;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloats { 0. });
def = this->add("filament_settings_id", coStrings);

View File

@ -4998,6 +4998,7 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
ImGui::SameLine();
imgui.title(time_title);
std::string filament_str = _u8L("Filament");
std::string cost_str = _u8L("Cost");
std::string prepare_str = _u8L("Prepare time");
std::string print_str = _u8L("Model printing time");
std::string total_str = _u8L("Total");
@ -5006,7 +5007,10 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
if (time_mode.layers_times.empty())
max_len += ImGui::CalcTextSize(total_str.c_str()).x;
else {
max_len += std::max(ImGui::CalcTextSize(print_str.c_str()).x ,std::max(std::max(ImGui::CalcTextSize(prepare_str.c_str()).x, ImGui::CalcTextSize(total_str.c_str()).x), ImGui::CalcTextSize(filament_str.c_str()).x));
max_len += std::max(ImGui::CalcTextSize(cost_str.c_str()).x,
std::max(ImGui::CalcTextSize(print_str.c_str()).x,
std::max(std::max(ImGui::CalcTextSize(prepare_str.c_str()).x, ImGui::CalcTextSize(total_str.c_str()).x),
ImGui::CalcTextSize(filament_str.c_str()).x)));
}
//BBS display filament cost
@ -5031,6 +5035,17 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
auto it = std::find_if(time_mode.roles_times.begin(), time_mode.roles_times.end(), [role](const std::pair<ExtrusionRole, float>& item) { return role == item.first; });
return (it != time_mode.roles_times.end()) ? it->second : 0.0f;
};
//BBS: display cost of filaments
ImGui::Dummy({window_padding, window_padding});
ImGui::SameLine();
imgui.text(cost_str + ":");
ImGui::SameLine(max_len);
//char buf[64];
::sprintf(buf, "%.2f", ps.total_cost);
imgui.text(buf);
//BBS: start gcode is prepeare time
if (role_time(erCustom) != 0.0f) {
ImGui::Dummy({ window_padding, window_padding });