mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-12 13:18:57 +08:00
Fix of #6832, SPE-1956: total toolchanges not counted correctly when wipe tower is disabled
This commit is contained in:
parent
aa0bc7489f
commit
eeedeeca13
@ -720,6 +720,7 @@ namespace DoExport {
|
||||
const FullPrintConfig &config,
|
||||
const std::vector<Extruder> &extruders,
|
||||
unsigned int initial_extruder_id,
|
||||
int total_toolchanges,
|
||||
PrintStatistics &print_statistics,
|
||||
bool export_binary_data,
|
||||
bgcode::binarize::BinaryData &binary_data)
|
||||
@ -727,7 +728,7 @@ namespace DoExport {
|
||||
std::string filament_stats_string_out;
|
||||
|
||||
print_statistics.clear();
|
||||
print_statistics.total_toolchanges = std::max(0, wipe_tower_data.number_of_toolchanges);
|
||||
print_statistics.total_toolchanges = total_toolchanges;
|
||||
print_statistics.initial_extruder_id = initial_extruder_id;
|
||||
std::vector<std::string> filament_types;
|
||||
if (! extruders.empty()) {
|
||||
@ -1161,7 +1162,7 @@ void GCodeGenerator::_do_export(Print& print, GCodeOutputStream &file, Thumbnail
|
||||
// For the start / end G-code to do the priming and final filament pull in case there is no wipe tower provided.
|
||||
this->placeholder_parser().set("has_wipe_tower", has_wipe_tower);
|
||||
this->placeholder_parser().set("has_single_extruder_multi_material_priming", has_wipe_tower && print.config().single_extruder_multi_material_priming);
|
||||
this->placeholder_parser().set("total_toolchanges", std::max(0, print.wipe_tower_data().number_of_toolchanges)); // Check for negative toolchanges (single extruder mode) and set to 0 (no tool change).
|
||||
this->placeholder_parser().set("total_toolchanges", tool_ordering.toolchanges_count());
|
||||
{
|
||||
BoundingBoxf bbox(print.config().bed_shape.values);
|
||||
assert(bbox.defined);
|
||||
@ -1389,6 +1390,7 @@ void GCodeGenerator::_do_export(Print& print, GCodeOutputStream &file, Thumbnail
|
||||
this->config(),
|
||||
m_writer.extruders(),
|
||||
initial_extruder_id,
|
||||
tool_ordering.toolchanges_count(),
|
||||
// Modifies
|
||||
print.m_print_statistics,
|
||||
export_to_binary_gcode,
|
||||
|
@ -836,4 +836,20 @@ void WipingExtrusions::ensure_perimeters_infills_order(const Print& print, const
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int ToolOrdering::toolchanges_count() const
|
||||
{
|
||||
std::vector<unsigned int> tools_in_order;
|
||||
for (const LayerTools& lt : m_layer_tools)
|
||||
tools_in_order.insert(tools_in_order.end(), lt.extruders.begin(), lt.extruders.end());
|
||||
assert(std::find(tools_in_order.begin(), tools_in_order.end(), (unsigned int)(-1)) == tools_in_order.end());
|
||||
for (size_t i=1; i<tools_in_order.size(); ++i)
|
||||
if (tools_in_order[i] == tools_in_order[i-1])
|
||||
tools_in_order[i-1] = (unsigned int)(-1);
|
||||
tools_in_order.erase(std::remove(tools_in_order.begin(), tools_in_order.end(), (unsigned int)(-1)), tools_in_order.end());
|
||||
if (tools_in_order.size() > 1 && tools_in_order.back() == tools_in_order[tools_in_order.size()-2])
|
||||
tools_in_order.pop_back();
|
||||
return std::max(0, int(tools_in_order.size())-1); // 5 tools = 4 toolchanges
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
|
@ -165,6 +165,7 @@ public:
|
||||
bool empty() const { return m_layer_tools.empty(); }
|
||||
std::vector<LayerTools>& layer_tools() { return m_layer_tools; }
|
||||
bool has_wipe_tower() const { return ! m_layer_tools.empty() && m_first_printing_extruder != (unsigned int)-1 && m_layer_tools.front().wipe_tower_partitions > 0; }
|
||||
int toolchanges_count() const;
|
||||
|
||||
private:
|
||||
void initialize_layers(std::vector<coordf_t> &zs);
|
||||
|
@ -1502,8 +1502,7 @@ void Sidebar::update_sliced_info_sizer()
|
||||
p->sliced_info->SetTextAndShow(siEstimatedTime, info_text, new_label);
|
||||
}
|
||||
|
||||
// if there is a wipe tower, insert number of toolchanges info into the array:
|
||||
p->sliced_info->SetTextAndShow(siWTNumbetOfToolchanges, is_wipe_tower ? wxString::Format("%.d", ps.total_toolchanges) : "N/A");
|
||||
p->sliced_info->SetTextAndShow(siWTNumbetOfToolchanges, ps.total_toolchanges > 0 ? wxString::Format("%.d", ps.total_toolchanges) : "N/A");
|
||||
|
||||
// Hide non-FFF sliced info parameters
|
||||
p->sliced_info->SetTextAndShow(siMateril_unit, "N/A");
|
||||
|
Loading…
x
Reference in New Issue
Block a user