diff --git a/src/libslic3r/Config.hpp b/src/libslic3r/Config.hpp index b8a838f0d..3aac187cb 100644 --- a/src/libslic3r/Config.hpp +++ b/src/libslic3r/Config.hpp @@ -758,6 +758,8 @@ public: ConfigOptionIntsTempl() : ConfigOptionVector() {} explicit ConfigOptionIntsTempl(size_t n, int value) : ConfigOptionVector(n, value) {} explicit ConfigOptionIntsTempl(std::initializer_list il) : ConfigOptionVector(std::move(il)) {} + explicit ConfigOptionIntsTempl(const std::vector &v) : ConfigOptionVector(v) {} + explicit ConfigOptionIntsTempl(std::vector &&v) : ConfigOptionVector(std::move(v)) {} static ConfigOptionType static_type() { return coInts; } ConfigOptionType type() const override { return static_type(); } diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index ce646d1d3..27e47d5ea 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -677,7 +677,7 @@ namespace DoExport { print_statistics.total_weight = total_weight; print_statistics.total_cost = total_cost; - print_statistics.filament_stats = result.print_statistics.volumes_per_extruder; + print_statistics.filament_stats = result.print_statistics.volumes_per_extruder; } // if any reserved keyword is found, returns a std::vector containing the first MAX_COUNT keywords found @@ -984,19 +984,26 @@ namespace DoExport { static std::string update_print_stats_and_format_filament_stats( const bool has_wipe_tower, const WipeTowerData &wipe_tower_data, + const FullPrintConfig &config, const std::vector &extruders, + unsigned int initial_extruder_id, PrintStatistics &print_statistics) { std::string filament_stats_string_out; print_statistics.clear(); print_statistics.total_toolchanges = std::max(0, wipe_tower_data.number_of_toolchanges); + print_statistics.initial_extruder_id = initial_extruder_id; + std::vector filament_types; if (! extruders.empty()) { std::pair out_filament_used_mm ("; filament used [mm] = ", 0); std::pair out_filament_used_cm3("; filament used [cm3] = ", 0); std::pair out_filament_used_g ("; filament used [g] = ", 0); std::pair out_filament_cost ("; filament cost = ", 0); for (const Extruder &extruder : extruders) { + print_statistics.printing_extruders.emplace_back(extruder.id()); + filament_types.emplace_back(config.filament_type.get_at(extruder.id())); + double used_filament = extruder.used_filament() + (has_wipe_tower ? wipe_tower_data.used_filament[extruder.id()] : 0.f); double extruded_volume = extruder.extruded_volume() + (has_wipe_tower ? wipe_tower_data.used_filament[extruder.id()] * 2.4052f : 0.f); // assumes 1.75mm filament diameter double filament_weight = extruded_volume * extruder.filament_density() * 0.001; @@ -1036,6 +1043,13 @@ namespace DoExport { filament_stats_string_out += "\n" + out_filament_used_g.first; if (out_filament_cost.second) filament_stats_string_out += "\n" + out_filament_cost.first; + print_statistics.initial_filament_type = config.filament_type.values[initial_extruder_id]; + std::sort(filament_types.begin(), filament_types.end()); + print_statistics.printing_filament_types = filament_types.front(); + for (size_t i = 1; i < filament_types.size(); ++ i) { + print_statistics.printing_filament_types += ","; + print_statistics.printing_filament_types += filament_types[i]; + } } return filament_stats_string_out; } @@ -1486,7 +1500,9 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato file.write(DoExport::update_print_stats_and_format_filament_stats( // Const inputs has_wipe_tower, print.wipe_tower_data(), + this->config(), m_writer.extruders(), + initial_extruder_id, // Modifies print.m_print_statistics)); file.write("\n"); diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index acb4ee6a6..70c5756ef 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -1248,6 +1248,13 @@ DynamicConfig PrintStatistics::config() const config.set_key_value("total_weight", new ConfigOptionFloat(this->total_weight)); config.set_key_value("total_wipe_tower_cost", new ConfigOptionFloat(this->total_wipe_tower_cost)); config.set_key_value("total_wipe_tower_filament", new ConfigOptionFloat(this->total_wipe_tower_filament)); + config.set_key_value("initial_tool", new ConfigOptionInt(int(this->initial_extruder_id))); + config.set_key_value("initial_extruder", new ConfigOptionInt(int(this->initial_extruder_id))); + config.set_key_value("initial_filament_type", new ConfigOptionString(this->initial_filament_type)); + config.set_key_value("printing_filament_types", new ConfigOptionString(this->printing_filament_types)); + config.set_key_value("num_printing_extruders", new ConfigOptionInt(int(this->printing_extruders.size()))); +// config.set_key_value("printing_extruders", new ConfigOptionInts(std::vector(this->printing_extruders.begin(), this->printing_extruders.end()))); + return config; } @@ -1257,7 +1264,8 @@ DynamicConfig PrintStatistics::placeholders() for (const std::string &key : { "print_time", "normal_print_time", "silent_print_time", "used_filament", "extruded_volume", "total_cost", "total_weight", - "total_toolchanges", "total_wipe_tower_cost", "total_wipe_tower_filament"}) + "total_toolchanges", "total_wipe_tower_cost", "total_wipe_tower_filament", + "initial_tool", "initial_extruder", "initial_filament_type", "printing_filament_types", "num_printing_extruders" }) config.set_key_value(key, new ConfigOptionString(std::string("{") + key + "}")); return config; } diff --git a/src/libslic3r/Print.hpp b/src/libslic3r/Print.hpp index e818cad0d..c2babd53c 100644 --- a/src/libslic3r/Print.hpp +++ b/src/libslic3r/Print.hpp @@ -455,6 +455,10 @@ struct PrintStatistics double total_weight; double total_wipe_tower_cost; double total_wipe_tower_filament; + std::vector printing_extruders; + unsigned int initial_extruder_id; + std::string initial_filament_type; + std::string printing_filament_types; std::map filament_stats; // Config with the filled in print statistics. @@ -472,7 +476,11 @@ struct PrintStatistics total_weight = 0.; total_wipe_tower_cost = 0.; total_wipe_tower_filament = 0.; + initial_extruder_id = 0; + initial_filament_type.clear(); + printing_filament_types.clear(); filament_stats.clear(); + printing_extruders.clear(); } };