DoubleSlider: Implemented code for check of used extruders for MustiAsSingle mode

This commit is contained in:
YuSanka 2020-01-15 15:35:56 +01:00
parent 1844fca780
commit 15f873dd74
3 changed files with 23 additions and 2 deletions

View File

@ -486,7 +486,8 @@ void ToolOrdering::assign_custom_gcodes(const Print &print)
print_z_below = it_lt_below->print_z; print_z_below = it_lt_below->print_z;
if (custom_gcode.print_z > print_z_below + 0.5 * EPSILON) { if (custom_gcode.print_z > print_z_below + 0.5 * EPSILON) {
// The custom G-code applies to the current layer. // The custom G-code applies to the current layer.
if (custom_gcode.gcode != ColorChangeCode || extruder_printing_above[unsigned(custom_gcode.extruder - 1)]) if ( custom_gcode.gcode != ColorChangeCode ||
(custom_gcode.extruder <= num_extruders && extruder_printing_above[unsigned(custom_gcode.extruder - 1)]))
// If it is color change, it will actually be useful as the exturder above will print. // If it is color change, it will actually be useful as the exturder above will print.
lt.custom_gcode = &custom_gcode; lt.custom_gcode = &custom_gcode;
// Consume that custom G-code event. // Consume that custom G-code event.

View File

@ -382,6 +382,7 @@ public:
// Accessed by SupportMaterial // Accessed by SupportMaterial
const PrintRegion* get_region(size_t idx) const { return m_regions[idx]; } const PrintRegion* get_region(size_t idx) const { return m_regions[idx]; }
const ToolOrdering& get_tool_ordering() const { return m_wipe_tower_data.tool_ordering; } // #ys_FIXME just for testing
protected: protected:
// methods for handling regions // methods for handling regions

View File

@ -5,6 +5,7 @@
#include "libslic3r/Utils.hpp" #include "libslic3r/Utils.hpp"
#include "libslic3r/Model.hpp" #include "libslic3r/Model.hpp"
#include "libslic3r/Print.hpp"
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/bmpcbox.h> #include <wx/bmpcbox.h>
@ -3487,7 +3488,25 @@ int DoubleSlider::get_extruder_for_tick(int tick)
std::set<int> DoubleSlider::get_used_extruders_for_tick(int tick) std::set<int> DoubleSlider::get_used_extruders_for_tick(int tick)
{ {
if (m_mode == mmMultiExtruder) if (m_mode == mmMultiExtruder)
return {}; // #ys_FIXME: correct fill used_extruders_for_tick for mmMultiExtruder {
// #ys_FIXME: get tool ordering from _correct_ place
const Slic3r::ToolOrdering& tool_ordering = Slic3r::GUI::wxGetApp().plater()->fff_print().get_tool_ordering();
if (tool_ordering.empty())
return {};
std::set<int> used_extruders;
auto it_layer_tools = std::lower_bound(tool_ordering.begin(), tool_ordering.end(), Slic3r::LayerTools(m_values[tick]));
for (; it_layer_tools != tool_ordering.end(); it_layer_tools++)
{
const std::vector<unsigned>& extruders = it_layer_tools->extruders;
for (const auto& extruder : extruders)
used_extruders.emplace(extruder+1);
}
return used_extruders;
}
const int default_initial_extruder = m_mode == mmMultiAsSingle ? std::max(m_only_extruder, 1) : 1; const int default_initial_extruder = m_mode == mmMultiAsSingle ? std::max(m_only_extruder, 1) : 1;
if (m_ticks.empty()) if (m_ticks.empty())