Merge branch 'et_colorprint_no_m600' of https://github.com/prusa3d/PrusaSlicer
This commit is contained in:
commit
56080bee8d
5 changed files with 79 additions and 43 deletions
|
@ -1522,7 +1522,13 @@ void GCode::process_layer(
|
|||
|
||||
// we should add or not colorprint_change in respect to nozzle_diameter count instead of really used extruders count
|
||||
if (colorprint_change && print./*extruders()*/config().nozzle_diameter.size()==1)
|
||||
{
|
||||
// add tag for analyzer
|
||||
gcode += "; " + GCodeAnalyzer::Color_Change_Tag + "\n";
|
||||
// add tag for time estimator
|
||||
gcode += "; " + GCodeTimeEstimator::Color_Change_Tag + "\n";
|
||||
gcode += "M600\n";
|
||||
}
|
||||
|
||||
|
||||
// Extrude skirt at the print_z of the raft layers and normal object layers
|
||||
|
|
|
@ -25,6 +25,7 @@ const std::string GCodeAnalyzer::Extrusion_Role_Tag = "_ANALYZER_EXTR_ROLE:";
|
|||
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 double GCodeAnalyzer::Default_mm3_per_mm = 0.0;
|
||||
const float GCodeAnalyzer::Default_Width = 0.0f;
|
||||
|
@ -240,11 +241,6 @@ void GCodeAnalyzer::_process_gcode_line(GCodeReader&, const GCodeReader::GCodeLi
|
|||
{
|
||||
switch (::atoi(&cmd[1]))
|
||||
{
|
||||
case 600: // Set color change
|
||||
{
|
||||
_processM600(line);
|
||||
break;
|
||||
}
|
||||
case 82: // Set extruder to absolute mode
|
||||
{
|
||||
_processM82(line);
|
||||
|
@ -517,12 +513,6 @@ void GCodeAnalyzer::_reset_cached_position()
|
|||
}
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_processM600(const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
m_state.cur_cp_color_id++;
|
||||
_set_cp_color_id(m_state.cur_cp_color_id);
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_processT(const std::string& cmd)
|
||||
{
|
||||
if (cmd.length() > 1)
|
||||
|
@ -579,6 +569,14 @@ bool GCodeAnalyzer::_process_tags(const GCodeReader::GCodeLine& line)
|
|||
return true;
|
||||
}
|
||||
|
||||
// color change tag
|
||||
pos = comment.find(Color_Change_Tag);
|
||||
if (pos != comment.npos)
|
||||
{
|
||||
_process_color_change_tag();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -608,6 +606,12 @@ void GCodeAnalyzer::_process_height_tag(const std::string& comment, size_t pos)
|
|||
_set_height((float)::strtod(comment.substr(pos + Height_Tag.length()).c_str(), nullptr));
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_process_color_change_tag()
|
||||
{
|
||||
m_state.cur_cp_color_id++;
|
||||
_set_cp_color_id(m_state.cur_cp_color_id);
|
||||
}
|
||||
|
||||
void GCodeAnalyzer::_set_units(GCodeAnalyzer::EUnits units)
|
||||
{
|
||||
m_state.units = units;
|
||||
|
@ -945,12 +949,12 @@ void GCodeAnalyzer::_calc_gcode_preview_travel(GCodePreviewData& preview_data, s
|
|||
polyline = Polyline3();
|
||||
|
||||
// add both vertices of the move
|
||||
polyline.append(Vec3crd(scale_(move.start_position.x()), scale_(move.start_position.y()), scale_(move.start_position.z())));
|
||||
polyline.append(Vec3crd(scale_(move.end_position.x()), scale_(move.end_position.y()), scale_(move.end_position.z())));
|
||||
polyline.append(Vec3crd((int)scale_(move.start_position.x()), (int)scale_(move.start_position.y()), (int)scale_(move.start_position.z())));
|
||||
polyline.append(Vec3crd((int)scale_(move.end_position.x()), (int)scale_(move.end_position.y()), (int)scale_(move.end_position.z())));
|
||||
}
|
||||
else
|
||||
// append end vertex of the move to current polyline
|
||||
polyline.append(Vec3crd(scale_(move.end_position.x()), scale_(move.end_position.y()), scale_(move.end_position.z())));
|
||||
polyline.append(Vec3crd((int)scale_(move.end_position.x()), (int)scale_(move.end_position.y()), (int)scale_(move.end_position.z())));
|
||||
|
||||
// update current values
|
||||
position = move.end_position;
|
||||
|
@ -994,7 +998,7 @@ void GCodeAnalyzer::_calc_gcode_preview_retractions(GCodePreviewData& preview_da
|
|||
cancel_callback();
|
||||
|
||||
// store position
|
||||
Vec3crd position(scale_(move.start_position.x()), scale_(move.start_position.y()), scale_(move.start_position.z()));
|
||||
Vec3crd position((int)scale_(move.start_position.x()), (int)scale_(move.start_position.y()), (int)scale_(move.start_position.z()));
|
||||
preview_data.retraction.positions.emplace_back(position, move.data.width, move.data.height);
|
||||
}
|
||||
|
||||
|
@ -1021,7 +1025,7 @@ void GCodeAnalyzer::_calc_gcode_preview_unretractions(GCodePreviewData& preview_
|
|||
cancel_callback();
|
||||
|
||||
// store position
|
||||
Vec3crd position(scale_(move.start_position.x()), scale_(move.start_position.y()), scale_(move.start_position.z()));
|
||||
Vec3crd position((int)scale_(move.start_position.x()), (int)scale_(move.start_position.y()), (int)scale_(move.start_position.z()));
|
||||
preview_data.unretraction.positions.emplace_back(position, move.data.width, move.data.height);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ public:
|
|||
static const std::string Mm3_Per_Mm_Tag;
|
||||
static const std::string Width_Tag;
|
||||
static const std::string Height_Tag;
|
||||
static const std::string Color_Change_Tag;
|
||||
|
||||
static const double Default_mm3_per_mm;
|
||||
static const float Default_Width;
|
||||
|
@ -177,9 +178,6 @@ private:
|
|||
// Repetier: Go to stored position
|
||||
void _processM402(const GCodeReader::GCodeLine& line);
|
||||
|
||||
// Set color change
|
||||
void _processM600(const GCodeReader::GCodeLine& line);
|
||||
|
||||
// Processes T line (Select Tool)
|
||||
void _processT(const std::string& command);
|
||||
void _processT(const GCodeReader::GCodeLine& line);
|
||||
|
@ -200,6 +198,9 @@ private:
|
|||
// Processes height tag
|
||||
void _process_height_tag(const std::string& comment, size_t pos);
|
||||
|
||||
// Processes color change tag
|
||||
void _process_color_change_tag();
|
||||
|
||||
void _set_units(EUnits units);
|
||||
EUnits _get_units() const;
|
||||
|
||||
|
|
|
@ -168,10 +168,14 @@ namespace Slic3r {
|
|||
}
|
||||
#endif // ENABLE_MOVE_STATS
|
||||
|
||||
const std::string GCodeTimeEstimator::Normal_First_M73_Output_Placeholder_Tag = "; NORMAL_FIRST_M73_OUTPUT_PLACEHOLDER";
|
||||
const std::string GCodeTimeEstimator::Silent_First_M73_Output_Placeholder_Tag = "; SILENT_FIRST_M73_OUTPUT_PLACEHOLDER";
|
||||
const std::string GCodeTimeEstimator::Normal_Last_M73_Output_Placeholder_Tag = "; NORMAL_LAST_M73_OUTPUT_PLACEHOLDER";
|
||||
const std::string GCodeTimeEstimator::Silent_Last_M73_Output_Placeholder_Tag = "; SILENT_LAST_M73_OUTPUT_PLACEHOLDER";
|
||||
const std::string GCodeTimeEstimator::Normal_First_M73_Output_Placeholder_Tag = "; _TE_NORMAL_FIRST_M73_OUTPUT_PLACEHOLDER";
|
||||
const std::string GCodeTimeEstimator::Silent_First_M73_Output_Placeholder_Tag = "; _TE_SILENT_FIRST_M73_OUTPUT_PLACEHOLDER";
|
||||
const std::string GCodeTimeEstimator::Normal_Last_M73_Output_Placeholder_Tag = "; _TE_NORMAL_LAST_M73_OUTPUT_PLACEHOLDER";
|
||||
const std::string GCodeTimeEstimator::Silent_Last_M73_Output_Placeholder_Tag = "; _TE_SILENT_LAST_M73_OUTPUT_PLACEHOLDER";
|
||||
|
||||
// temporary human readable form to use until not removed from gcode by the new post-process method
|
||||
const std::string GCodeTimeEstimator::Color_Change_Tag = "PRINT_COLOR_CHANGE";
|
||||
// const std::string GCodeTimeEstimator::Color_Change_Tag = "_TE_COLOR_CHANGE";
|
||||
|
||||
GCodeTimeEstimator::GCodeTimeEstimator(EMode mode)
|
||||
: m_mode(mode)
|
||||
|
@ -814,6 +818,11 @@ namespace Slic3r {
|
|||
void GCodeTimeEstimator::_process_gcode_line(GCodeReader&, const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
PROFILE_FUNC();
|
||||
|
||||
// processes 'special' comments contained in line
|
||||
if (_process_tags(line))
|
||||
return;
|
||||
|
||||
std::string cmd = line.cmd();
|
||||
if (cmd.length() > 1)
|
||||
{
|
||||
|
@ -921,11 +930,6 @@ namespace Slic3r {
|
|||
_processM566(line);
|
||||
break;
|
||||
}
|
||||
case 600: // Set color change
|
||||
{
|
||||
_processM600(line);
|
||||
break;
|
||||
}
|
||||
case 702: // MK3 MMU2: Process the final filament unload.
|
||||
{
|
||||
_processM702(line);
|
||||
|
@ -1396,18 +1400,6 @@ namespace Slic3r {
|
|||
set_axis_max_jerk(E, line.e() * MMMIN_TO_MMSEC);
|
||||
}
|
||||
|
||||
void GCodeTimeEstimator::_processM600(const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
PROFILE_FUNC();
|
||||
m_needs_color_times = true;
|
||||
_calculate_time();
|
||||
if (m_color_time_cache != 0.0f)
|
||||
{
|
||||
m_color_times.push_back(m_color_time_cache);
|
||||
m_color_time_cache = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void GCodeTimeEstimator::_processM702(const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
PROFILE_FUNC();
|
||||
|
@ -1439,6 +1431,33 @@ namespace Slic3r {
|
|||
}
|
||||
}
|
||||
|
||||
bool GCodeTimeEstimator::_process_tags(const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
std::string comment = line.comment();
|
||||
|
||||
// color change tag
|
||||
size_t pos = comment.find(Color_Change_Tag);
|
||||
if (pos != comment.npos)
|
||||
{
|
||||
_process_color_change_tag();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void GCodeTimeEstimator::_process_color_change_tag()
|
||||
{
|
||||
PROFILE_FUNC();
|
||||
m_needs_color_times = true;
|
||||
_calculate_time();
|
||||
if (m_color_time_cache != 0.0f)
|
||||
{
|
||||
m_color_times.push_back(m_color_time_cache);
|
||||
m_color_time_cache = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void GCodeTimeEstimator::_simulate_st_synchronize()
|
||||
{
|
||||
PROFILE_FUNC();
|
||||
|
|
|
@ -22,6 +22,8 @@ namespace Slic3r {
|
|||
static const std::string Normal_Last_M73_Output_Placeholder_Tag;
|
||||
static const std::string Silent_Last_M73_Output_Placeholder_Tag;
|
||||
|
||||
static const std::string Color_Change_Tag;
|
||||
|
||||
enum EMode : unsigned char
|
||||
{
|
||||
Normal,
|
||||
|
@ -425,15 +427,19 @@ namespace Slic3r {
|
|||
// Set allowable instantaneous speed change
|
||||
void _processM566(const GCodeReader::GCodeLine& line);
|
||||
|
||||
// Set color change
|
||||
void _processM600(const GCodeReader::GCodeLine& line);
|
||||
|
||||
// Unload the current filament into the MK3 MMU2 unit at the end of print.
|
||||
void _processM702(const GCodeReader::GCodeLine& line);
|
||||
|
||||
// Processes T line (Select Tool)
|
||||
void _processT(const GCodeReader::GCodeLine& line);
|
||||
|
||||
// Processes the tags
|
||||
// Returns true if any tag has been processed
|
||||
bool _process_tags(const GCodeReader::GCodeLine& line);
|
||||
|
||||
// Processes color change tag
|
||||
void _process_color_change_tag();
|
||||
|
||||
// Simulates firmware st_synchronize() call
|
||||
void _simulate_st_synchronize();
|
||||
|
||||
|
|
Loading…
Reference in a new issue