diff --git a/resources/icons/change_extruder.svg b/resources/icons/change_extruder.svg
new file mode 100644
index 000000000..fe8de635d
--- /dev/null
+++ b/resources/icons/change_extruder.svg
@@ -0,0 +1,9 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp
index 2a74de41d..9d196cbd2 100644
--- a/src/libslic3r/GCode.cpp
+++ b/src/libslic3r/GCode.cpp
@@ -1709,8 +1709,47 @@ void GCode::process_layer(
//
// gcode += "M600\n";
// }
- if (colorprint_change) {
+
+ // don't save "tool_change" code to GCode
+ if (colorprint_change && custom_code != "tool_change") {
const bool single_material_print = print.config().nozzle_diameter.size() == 1;
+
+ if (custom_code == "M600") // color change
+ {
+ // add tag for analyzer
+ gcode += "; " + GCodeAnalyzer::Color_Change_Tag + ",T" + std::to_string(m600_before_extruder) + "\n";
+ // add tag for time estimator
+ gcode += "; " + GCodeTimeEstimator::Color_Change_Tag + "\n";
+
+ if (!single_material_print && m600_before_extruder >= 0 && first_extruder_id != m600_before_extruder
+ // && !MMU1
+ ) {
+ gcode += "M601\n"; // pause print
+ gcode += "M117 Change filament for Extruder " + std::to_string(m600_before_extruder) + "\n";
+ }
+ else
+ gcode += custom_code + "\n";
+ }
+ else
+ {
+ if (custom_code == "M601") // Pause print
+ {
+ // add tag for analyzer
+ gcode += "; " + GCodeAnalyzer::Pause_Print_Tag + "\n";
+ // add tag for time estimator
+ //gcode += "; " + GCodeTimeEstimator::Pause_Print_Tag + "\n";
+ }
+ else // custom Gcode
+ {
+ // add tag for analyzer
+ gcode += "; " + GCodeAnalyzer::Custom_Code_Tag + "\n";
+ // add tag for time estimator
+ //gcode += "; " + GCodeTimeEstimator::Custom_Code_Tag + "\n";
+ }
+ gcode += custom_code + "\n";
+ }
+
+ /*
if (single_material_print || custom_code != "tool_change")
{
// add tag for analyzer
@@ -1730,6 +1769,7 @@ void GCode::process_layer(
else
gcode += custom_code + "\n";
}
+ */
}
@@ -2039,6 +2079,12 @@ void GCode::process_layer(
if (m_cooling_buffer)
gcode = m_cooling_buffer->process_layer(gcode, layer.id());
+ // add tag for analyzer
+ if (gcode.find(GCodeAnalyzer::Pause_Print_Tag) != gcode.npos)
+ gcode += "\n; " + GCodeAnalyzer::End_Pause_Print_Or_Custom_Code_Tag + "\n";
+ else if (gcode.find(GCodeAnalyzer::Custom_Code_Tag) != gcode.npos)
+ gcode += "\n; " + GCodeAnalyzer::End_Pause_Print_Or_Custom_Code_Tag + "\n";
+
#ifdef HAS_PRESSURE_EQUALIZER
// Apply pressure equalization if enabled;
// printf("G-code before filter:\n%s\n", gcode.c_str());
diff --git a/src/libslic3r/GCode/Analyzer.cpp b/src/libslic3r/GCode/Analyzer.cpp
index 3f0b8735f..f73f4b4ba 100644
--- a/src/libslic3r/GCode/Analyzer.cpp
+++ b/src/libslic3r/GCode/Analyzer.cpp
@@ -29,6 +29,9 @@ const std::string GCodeAnalyzer::Mm3_Per_Mm_Tag = "_ANALYZER_MM3_PER_MM:";
const std::string GCodeAnalyzer::Width_Tag = "_ANALYZER_WIDTH:";
const std::string GCodeAnalyzer::Height_Tag = "_ANALYZER_HEIGHT:";
const std::string GCodeAnalyzer::Color_Change_Tag = "_ANALYZER_COLOR_CHANGE";
+const std::string GCodeAnalyzer::Pause_Print_Tag = "_ANALYZER_PAUSE_PRINT";
+const std::string GCodeAnalyzer::Custom_Code_Tag = "_ANALYZER_CUSTOM_CODE";
+const std::string GCodeAnalyzer::End_Pause_Print_Or_Custom_Code_Tag = "_ANALYZER_END_PAUSE_PRINT_OR_CUSTOM_CODE";
const double GCodeAnalyzer::Default_mm3_per_mm = 0.0;
const float GCodeAnalyzer::Default_Width = 0.0f;
@@ -118,6 +121,8 @@ void GCodeAnalyzer::set_extruder_offsets(const GCodeAnalyzer::ExtruderOffsetsMap
void GCodeAnalyzer::set_extruders_count(unsigned int count)
{
m_extruders_count = count;
+ for (unsigned int i=0; i GCodeMovesList;
typedef std::map TypeToMovesMap;
typedef std::map ExtruderOffsetsMap;
+ typedef std::map ExtruderToColorMap;
private:
struct State
@@ -102,7 +106,7 @@ private:
float start_extrusion;
float position[Num_Axis];
float origin[Num_Axis];
- unsigned int cur_cp_color_id = 0;
+ unsigned int cp_color_counter = 0;
};
private:
@@ -113,6 +117,8 @@ private:
unsigned int m_extruders_count;
GCodeFlavor m_gcode_flavor;
+ ExtruderToColorMap m_extruder_color;
+
// The output of process_layer()
std::string m_process_output;
@@ -212,7 +218,13 @@ private:
void _process_height_tag(const std::string& comment, size_t pos);
// Processes color change tag
- void _process_color_change_tag();
+ void _process_color_change_tag(int extruder);
+
+ // Processes pause print and custom gcode tag
+ void _process_pause_print_or_custom_code_tag();
+
+ // Processes new layer tag
+ void _process_end_pause_print_or_custom_code_tag();
void _set_units(EUnits units);
EUnits _get_units() const;
diff --git a/src/libslic3r/GCode/PreviewData.cpp b/src/libslic3r/GCode/PreviewData.cpp
index dc4e8cf48..69f685fd4 100644
--- a/src/libslic3r/GCode/PreviewData.cpp
+++ b/src/libslic3r/GCode/PreviewData.cpp
@@ -513,7 +513,7 @@ GCodePreviewData::LegendItemsList GCodePreviewData::get_legend_items(const std::
is_single_material_print ? --i : ++i)
{
Color color;
- ::memcpy((void*)color.rgba, (const void*)(tool_colors.data() + (i % color_cnt) * 4), 4 * sizeof(float));
+ ::memcpy((void*)color.rgba, (const void*)(tool_colors.data() + i * 4), 4 * sizeof(float));
items.emplace_back(cp_items[i], color);
}
diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp
index f6fe759d9..6943aa248 100644
--- a/src/slic3r/GUI/GLCanvas3D.cpp
+++ b/src/slic3r/GUI/GLCanvas3D.cpp
@@ -4874,7 +4874,7 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c
--it_n;
if (it_n->gcode == "tool_change") {
is_tool_change = true;
- if (it_n->extruder == it->extruder)
+ if (it_n->extruder == it->extruder || (it_n->extruder == 0 && it->extruder == extruder))
return get_m600_color_idx(it);
break;
}
@@ -5296,12 +5296,14 @@ void GLCanvas3D::_load_gcode_extrusion_paths(const GCodePreviewData& preview_dat
}
case GCodePreviewData::Extrusion::ColorPrint:
{
- int color_cnt = (int)tool_colors.size() / 4;
+ // int color_cnt = (int)tool_colors.size() / 4;
+
+ // int val = int(value);
+ // while (val >= color_cnt)
+ // val -= color_cnt;
+
+ unsigned int val = unsigned int(value) >= INT_MAX ? tool_colors.size()*4 - 1 : value;
- int val = int(value);
- while (val >= color_cnt)
- val -= color_cnt;
-
GCodePreviewData::Color color;
::memcpy((void*)color.rgba, (const void*)(tool_colors.data() + val * 4), 4 * sizeof(float));