#4402 - Review and merge of #6106 Temperature visualization in preview and G-code Viewer by combolek
This commit is contained in:
parent
2d52e155a5
commit
c9666ea257
@ -678,6 +678,8 @@ void GCodeProcessor::apply_config(const PrintConfig& config)
|
||||
m_extruder_colors[i] = static_cast<unsigned char>(i);
|
||||
}
|
||||
|
||||
m_extruder_temps.resize(extruders_count);
|
||||
|
||||
m_filament_diameters.resize(config.filament_diameter.values.size());
|
||||
for (size_t i = 0; i < config.filament_diameter.values.size(); ++i) {
|
||||
m_filament_diameters[i] = static_cast<float>(config.filament_diameter.values[i]);
|
||||
@ -776,6 +778,8 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config)
|
||||
m_extruder_colors[i] = static_cast<unsigned char>(i);
|
||||
}
|
||||
|
||||
m_extruder_temps.resize(m_result.extruders_count);
|
||||
|
||||
const ConfigOptionFloats* filament_load_time = config.option<ConfigOptionFloats>("filament_load_time");
|
||||
if (filament_load_time != nullptr) {
|
||||
m_time_processor.filament_load_times.resize(filament_load_time->values.size());
|
||||
@ -910,6 +914,10 @@ void GCodeProcessor::reset()
|
||||
for (size_t i = 0; i < Min_Extruder_Count; ++i) {
|
||||
m_extruder_colors[i] = static_cast<unsigned char>(i);
|
||||
}
|
||||
m_extruder_temps.resize(Min_Extruder_Count);
|
||||
for (size_t i = 0; i < Min_Extruder_Count; ++i) {
|
||||
m_extruder_temps[i] = 0.0f;
|
||||
}
|
||||
|
||||
m_filament_diameters = std::vector<float>(Min_Extruder_Count, 1.75f);
|
||||
m_extruded_last_z = 0.0f;
|
||||
@ -1123,9 +1131,11 @@ void GCodeProcessor::process_gcode_line(const GCodeReader::GCodeLine& line)
|
||||
case 1: { process_M1(line); break; } // Sleep or Conditional stop
|
||||
case 82: { process_M82(line); break; } // Set extruder to absolute mode
|
||||
case 83: { process_M83(line); break; } // Set extruder to relative mode
|
||||
case 104: { process_M104(line); break; } // Set extruder temperature
|
||||
case 106: { process_M106(line); break; } // Set fan speed
|
||||
case 107: { process_M107(line); break; } // Disable fan
|
||||
case 108: { process_M108(line); break; } // Set tool (Sailfish)
|
||||
case 109: { process_M109(line); break; } // Set extruder temperature and wait
|
||||
case 132: { process_M132(line); break; } // Recall stored home offsets
|
||||
case 135: { process_M135(line); break; } // Set tool (MakerWare)
|
||||
case 201: { process_M201(line); break; } // Set max printing acceleration
|
||||
@ -2211,6 +2221,13 @@ void GCodeProcessor::process_M83(const GCodeReader::GCodeLine& line)
|
||||
m_e_local_positioning_type = EPositioningType::Relative;
|
||||
}
|
||||
|
||||
void GCodeProcessor::process_M104(const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
float new_temp;
|
||||
if (line.has_value('S', new_temp))
|
||||
m_extruder_temps[m_extruder_id] = new_temp;
|
||||
}
|
||||
|
||||
void GCodeProcessor::process_M106(const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
if (!line.has('P')) {
|
||||
@ -2243,6 +2260,21 @@ void GCodeProcessor::process_M108(const GCodeReader::GCodeLine& line)
|
||||
process_T(cmd.substr(pos));
|
||||
}
|
||||
|
||||
void GCodeProcessor::process_M109(const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
float new_temp;
|
||||
if (line.has_value('R', new_temp)) {
|
||||
float val;
|
||||
if (line.has_value('T', val)) {
|
||||
size_t eid = static_cast<size_t>(val);
|
||||
if (eid < m_extruder_temps.size())
|
||||
m_extruder_temps[eid] = new_temp;
|
||||
}
|
||||
else
|
||||
m_extruder_temps[m_extruder_id] = new_temp;
|
||||
}
|
||||
}
|
||||
|
||||
void GCodeProcessor::process_M132(const GCodeReader::GCodeLine& line)
|
||||
{
|
||||
// This command is used by Makerbot to load the current home position from EEPROM
|
||||
@ -2531,6 +2563,7 @@ void GCodeProcessor::store_move_vertex(EMoveType type)
|
||||
m_height,
|
||||
m_mm3_per_mm,
|
||||
m_fan_speed,
|
||||
m_extruder_temps[m_extruder_id],
|
||||
static_cast<float>(m_result.moves.size())
|
||||
};
|
||||
m_result.moves.emplace_back(vertex);
|
||||
|
@ -121,6 +121,7 @@ namespace Slic3r {
|
||||
private:
|
||||
using AxisCoords = std::array<float, 4>;
|
||||
using ExtruderColors = std::vector<unsigned char>;
|
||||
using ExtruderTemps = std::vector<float>;
|
||||
|
||||
enum class EUnits : unsigned char
|
||||
{
|
||||
@ -211,6 +212,7 @@ namespace Slic3r {
|
||||
float height{ 0.0f }; // mm
|
||||
float mm3_per_mm{ 0.0f };
|
||||
float fan_speed{ 0.0f }; // percentage
|
||||
float temperature{ 0.0f }; // Celsius degrees
|
||||
float time{ 0.0f }; // s
|
||||
|
||||
float volumetric_rate() const { return feedrate * mm3_per_mm; }
|
||||
@ -320,6 +322,7 @@ namespace Slic3r {
|
||||
float height{ 0.0f }; // mm
|
||||
float mm3_per_mm{ 0.0f };
|
||||
float fan_speed{ 0.0f }; // percentage
|
||||
float temperature{ 0.0f }; // Celsius degrees
|
||||
float time{ 0.0f }; // s
|
||||
|
||||
float volumetric_rate() const { return feedrate * mm3_per_mm; }
|
||||
@ -468,6 +471,7 @@ namespace Slic3r {
|
||||
ExtrusionRole m_extrusion_role;
|
||||
unsigned char m_extruder_id;
|
||||
ExtruderColors m_extruder_colors;
|
||||
ExtruderTemps m_extruder_temps;
|
||||
std::vector<float> m_filament_diameters;
|
||||
float m_extruded_last_z;
|
||||
unsigned int m_g1_line_id;
|
||||
@ -586,6 +590,9 @@ namespace Slic3r {
|
||||
// Set extruder to relative mode
|
||||
void process_M83(const GCodeReader::GCodeLine& line);
|
||||
|
||||
// Set extruder temperature
|
||||
void process_M104(const GCodeReader::GCodeLine& line);
|
||||
|
||||
// Set fan speed
|
||||
void process_M106(const GCodeReader::GCodeLine& line);
|
||||
|
||||
@ -595,6 +602,9 @@ namespace Slic3r {
|
||||
// Set tool (Sailfish)
|
||||
void process_M108(const GCodeReader::GCodeLine& line);
|
||||
|
||||
// Set extruder temperature and wait
|
||||
void process_M109(const GCodeReader::GCodeLine& line);
|
||||
|
||||
// Recall stored home offsets
|
||||
void process_M132(const GCodeReader::GCodeLine& line);
|
||||
|
||||
|
@ -180,11 +180,13 @@ void GCodeViewer::TBuffer::add_path(const GCodeProcessor::MoveVertex& move, unsi
|
||||
// use rounding to reduce the number of generated paths
|
||||
#if ENABLE_SPLITTED_VERTEX_BUFFER
|
||||
paths.push_back({ move.type, move.extrusion_role, move.delta_extruder,
|
||||
round_to_nearest(move.height, 2), round_to_nearest(move.width, 2), move.feedrate, move.fan_speed,
|
||||
round_to_nearest(move.height, 2), round_to_nearest(move.width, 2),
|
||||
move.feedrate, move.fan_speed, move.temperature,
|
||||
move.volumetric_rate(), move.extruder_id, move.cp_color_id, { { endpoint, endpoint } } });
|
||||
#else
|
||||
paths.push_back({ move.type, move.extrusion_role, endpoint, endpoint, move.delta_extruder,
|
||||
round_to_nearest(move.height, 2), round_to_nearest(move.width, 2), move.feedrate, move.fan_speed,
|
||||
round_to_nearest(move.height, 2), round_to_nearest(move.width, 2),
|
||||
move.feedrate, move.fan_speed, move.temperature,
|
||||
move.volumetric_rate(), move.extruder_id, move.cp_color_id });
|
||||
#endif // ENABLE_SPLITTED_VERTEX_BUFFER
|
||||
}
|
||||
@ -492,6 +494,7 @@ void GCodeViewer::refresh(const GCodeProcessor::Result& gcode_result, const std:
|
||||
m_extrusions.ranges.height.update_from(round_to_nearest(curr.height, 2));
|
||||
m_extrusions.ranges.width.update_from(round_to_nearest(curr.width, 2));
|
||||
m_extrusions.ranges.fan_speed.update_from(curr.fan_speed);
|
||||
m_extrusions.ranges.temperature.update_from(curr.temperature);
|
||||
m_extrusions.ranges.volumetric_rate.update_from(round_to_nearest(curr.volumetric_rate(), 2));
|
||||
[[fallthrough]];
|
||||
}
|
||||
@ -2725,6 +2728,7 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
|
||||
case EViewType::Width: { color = m_extrusions.ranges.width.get_color_at(path.width); break; }
|
||||
case EViewType::Feedrate: { color = m_extrusions.ranges.feedrate.get_color_at(path.feedrate); break; }
|
||||
case EViewType::FanSpeed: { color = m_extrusions.ranges.fan_speed.get_color_at(path.fan_speed); break; }
|
||||
case EViewType::Temperature: { color = m_extrusions.ranges.temperature.get_color_at(path.temperature); break; }
|
||||
case EViewType::VolumetricRate: { color = m_extrusions.ranges.volumetric_rate.get_color_at(path.volumetric_rate); break; }
|
||||
case EViewType::Tool: { color = m_tool_colors[path.extruder_id]; break; }
|
||||
case EViewType::ColorPrint: {
|
||||
@ -3184,6 +3188,7 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
|
||||
case EViewType::Width: { color = m_extrusions.ranges.width.get_color_at(path.width); break; }
|
||||
case EViewType::Feedrate: { color = m_extrusions.ranges.feedrate.get_color_at(path.feedrate); break; }
|
||||
case EViewType::FanSpeed: { color = m_extrusions.ranges.fan_speed.get_color_at(path.fan_speed); break; }
|
||||
case EViewType::Temperature: { color = m_extrusions.ranges.temperature.get_color_at(path.temperature); break; }
|
||||
case EViewType::VolumetricRate: { color = m_extrusions.ranges.volumetric_rate.get_color_at(path.volumetric_rate); break; }
|
||||
case EViewType::Tool: { color = m_tool_colors[path.extruder_id]; break; }
|
||||
case EViewType::ColorPrint: {
|
||||
@ -4014,6 +4019,7 @@ void GCodeViewer::render_legend() const
|
||||
case EViewType::Width: { imgui.title(_u8L("Width (mm)")); break; }
|
||||
case EViewType::Feedrate: { imgui.title(_u8L("Speed (mm/s)")); break; }
|
||||
case EViewType::FanSpeed: { imgui.title(_u8L("Fan Speed (%)")); break; }
|
||||
case EViewType::Temperature: { imgui.title(_u8L("Temperature (°C)")); break; }
|
||||
case EViewType::VolumetricRate: { imgui.title(_u8L("Volumetric flow rate (mm³/s)")); break; }
|
||||
case EViewType::Tool: { imgui.title(_u8L("Tool")); break; }
|
||||
case EViewType::ColorPrint: { imgui.title(_u8L("Color Print")); break; }
|
||||
@ -4048,6 +4054,7 @@ void GCodeViewer::render_legend() const
|
||||
case EViewType::Width: { append_range(m_extrusions.ranges.width, 3); break; }
|
||||
case EViewType::Feedrate: { append_range(m_extrusions.ranges.feedrate, 1); break; }
|
||||
case EViewType::FanSpeed: { append_range(m_extrusions.ranges.fan_speed, 0); break; }
|
||||
case EViewType::Temperature: { append_range(m_extrusions.ranges.temperature, 0); break; }
|
||||
case EViewType::VolumetricRate: { append_range(m_extrusions.ranges.volumetric_rate, 3); break; }
|
||||
case EViewType::Tool:
|
||||
{
|
||||
|
@ -179,6 +179,7 @@ class GCodeViewer
|
||||
float width{ 0.0f };
|
||||
float feedrate{ 0.0f };
|
||||
float fan_speed{ 0.0f };
|
||||
float temperature{ 0.0f };
|
||||
float volumetric_rate{ 0.0f };
|
||||
unsigned char extruder_id{ 0 };
|
||||
unsigned char cp_color_id{ 0 };
|
||||
@ -407,6 +408,8 @@ class GCodeViewer
|
||||
Range fan_speed;
|
||||
// Color mapping by volumetric extrusion rate.
|
||||
Range volumetric_rate;
|
||||
// Color mapping by extrusion temperature.
|
||||
Range temperature;
|
||||
|
||||
void reset() {
|
||||
height.reset();
|
||||
@ -414,6 +417,7 @@ class GCodeViewer
|
||||
feedrate.reset();
|
||||
fan_speed.reset();
|
||||
volumetric_rate.reset();
|
||||
temperature.reset();
|
||||
}
|
||||
};
|
||||
|
||||
@ -626,6 +630,7 @@ public:
|
||||
Width,
|
||||
Feedrate,
|
||||
FanSpeed,
|
||||
Temperature,
|
||||
VolumetricRate,
|
||||
Tool,
|
||||
ColorPrint,
|
||||
|
@ -211,6 +211,7 @@ bool Preview::init(wxWindow* parent, Model* model)
|
||||
m_choice_view_type->Append(_L("Width"));
|
||||
m_choice_view_type->Append(_L("Speed"));
|
||||
m_choice_view_type->Append(_L("Fan speed"));
|
||||
m_choice_view_type->Append(_L("Temperature"));
|
||||
m_choice_view_type->Append(_L("Volumetric flow rate"));
|
||||
m_choice_view_type->Append(_L("Tool"));
|
||||
m_choice_view_type->Append(_L("Color Print"));
|
||||
|
Loading…
Reference in New Issue
Block a user