ENH: add cost info when loading GCode file

Add total cost infomation when loading Gcode file

jira:STUDIO-4353

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: I930cb141e2a0b3cf328515f6543707c8bd5d620a
This commit is contained in:
xun.zhang
2023-09-13 18:14:17 +08:00
committed by Lane.Wei
parent 81bab138b5
commit 6a5e3b3646
3 changed files with 33 additions and 0 deletions

View File

@@ -9027,6 +9027,20 @@ void Plater::load_gcode(const wxString& filename)
current_print.apply(this->model(), wxGetApp().preset_bundle->full_config());
//BBS: add cost info when drag in gcode
auto& ps = current_result->print_statistics;
double total_cost = 0.0;
for (auto& volumes_map : { ps.volumes_per_extruder,ps.flush_per_filament ,ps.wipe_tower_volumes_per_extruder }) {
for (auto volume : volumes_map) {
size_t extruder_id = volume.first;
double density = current_result->filament_densities.at(extruder_id);
double cost = current_result->filament_costs.at(extruder_id);
double weight = volume.second * density * 0.001;
total_cost += weight * cost * 0.001;
}
}
current_print.print_statistics().total_cost = total_cost;
current_print.set_gcode_file_ready();
// show results