mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 00:37:51 -06:00
Color change - handling Color Change data stored for different
printer configuration: ss -> sm : Just apply the color changes of the original ss project at the active extruder. ss -> mm : There are no tool changes stored. Ignore color changes, they are invalid because they are extruder non-specific. sm -> ss : Apply tool changes as color changes (tool changes remember the target color), apply original color changes. sm -> mm : Ignore both color changes and tool changes. mm -> ss/sm : Ignore both color changes and tool changes.
This commit is contained in:
parent
acf5bfd8e2
commit
fb235cb675
4 changed files with 45 additions and 17 deletions
|
@ -130,7 +130,8 @@ ToolOrdering::ToolOrdering(const Print &print, unsigned int first_extruder, bool
|
|||
// Do it only if all the objects were configured to be printed with a single extruder.
|
||||
std::vector<std::pair<double, unsigned int>> per_layer_extruder_switches;
|
||||
if (auto num_extruders = unsigned(print.config().nozzle_diameter.size());
|
||||
num_extruders > 1 && print.object_extruders().size() == 1) {
|
||||
num_extruders > 1 && print.object_extruders().size() == 1 && // the current Print's configuration is CustomGCode::MultiAsSingle
|
||||
print.model().custom_gcode_per_print_z.mode == CustomGCode::MultiAsSingle) {
|
||||
// Printing a single extruder platter on a printer with more than 1 extruder (or single-extruder multi-material).
|
||||
// There may be custom per-layer tool changes available at the model.
|
||||
per_layer_extruder_switches = custom_tool_changes(print.model().custom_gcode_per_print_z, num_extruders);
|
||||
|
@ -466,11 +467,19 @@ void ToolOrdering::assign_custom_gcodes(const Print &print)
|
|||
if (custom_gcode_per_print_z.gcodes.empty())
|
||||
return;
|
||||
|
||||
unsigned int num_extruders = *std::max_element(m_all_printing_extruders.begin(), m_all_printing_extruders.end()) + 1;
|
||||
std::vector<unsigned char> extruder_printing_above(num_extruders, false);
|
||||
auto custom_gcode_it = custom_gcode_per_print_z.gcodes.rbegin();
|
||||
auto num_extruders = unsigned(print.config().nozzle_diameter.size());
|
||||
CustomGCode::Mode mode =
|
||||
(num_extruders == 1) ? CustomGCode::SingleExtruder :
|
||||
print.object_extruders().size() == 1 ? CustomGCode::MultiAsSingle : CustomGCode::MultiExtruder;
|
||||
CustomGCode::Mode model_mode = print.model().custom_gcode_per_print_z.mode;
|
||||
std::vector<unsigned char> extruder_printing_above(num_extruders, false);
|
||||
auto custom_gcode_it = custom_gcode_per_print_z.gcodes.rbegin();
|
||||
// Tool changes and color changes will be ignored, if the model's tool/color changes were entered in mm mode and the print is in non mm mode
|
||||
// or vice versa.
|
||||
bool ignore_tool_and_color_changes = (mode == CustomGCode::MultiExtruder) != (model_mode == CustomGCode::MultiExtruder);
|
||||
// If printing on a single extruder machine, make the tool changes trigger color change (M600) events.
|
||||
bool tool_changes_as_color_changes = num_extruders == 1;
|
||||
bool tool_changes_as_color_changes = mode == CustomGCode::SingleExtruder && model_mode == CustomGCode::MultiAsSingle;
|
||||
|
||||
// From the last layer to the first one:
|
||||
for (auto it_lt = m_layer_tools.rbegin(); it_lt != m_layer_tools.rend(); ++ it_lt) {
|
||||
LayerTools < = *it_lt;
|
||||
|
@ -490,9 +499,16 @@ void ToolOrdering::assign_custom_gcodes(const Print &print)
|
|||
print_z_below = it_lt_below->print_z;
|
||||
if (custom_gcode.print_z > print_z_below + 0.5 * EPSILON) {
|
||||
// The custom G-code applies to the current layer.
|
||||
if ( tool_changes_as_color_changes || custom_gcode.gcode != ColorChangeCode ||
|
||||
(custom_gcode.extruder <= int(num_extruders) && extruder_printing_above[unsigned(custom_gcode.extruder - 1)]))
|
||||
bool color_change = custom_gcode.gcode == ColorChangeCode;
|
||||
bool tool_change = custom_gcode.gcode == ToolChangeCode;
|
||||
bool pause_or_custom_gcode = ! color_change && ! tool_change;
|
||||
bool apply_color_change = ! ignore_tool_and_color_changes &&
|
||||
// If it is color change, it will actually be useful as the exturder above will print.
|
||||
(color_change ?
|
||||
mode == CustomGCode::SingleExtruder ||
|
||||
(custom_gcode.extruder <= int(num_extruders) && extruder_printing_above[unsigned(custom_gcode.extruder - 1)]) :
|
||||
tool_change && tool_changes_as_color_changes);
|
||||
if (pause_or_custom_gcode || apply_color_change)
|
||||
lt.custom_gcode = &custom_gcode;
|
||||
// Consume that custom G-code event.
|
||||
++ custom_gcode_it;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue