mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-16 10:55:53 +08:00
fix layer duration color
This commit is contained in:
parent
cd3ea9c7c2
commit
4d4293c921
@ -470,6 +470,7 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename)
|
||||
|
||||
const std::vector<std::pair<GCodeProcessor::EProducer, std::string>> GCodeProcessor::Producers = {
|
||||
{ EProducer::PrusaSlicer, "PrusaSlicer" },
|
||||
{ EProducer::SuperSlicer, "SuperSlicer" },
|
||||
{ EProducer::Cura, "Cura_SteamEngine" },
|
||||
{ EProducer::Simplify3D, "Simplify3D" },
|
||||
{ EProducer::CraftWare, "CraftWare" },
|
||||
@ -785,11 +786,11 @@ void GCodeProcessor::process_file(const std::string& filename, std::function<voi
|
||||
if (comment.length() > 1 && detect_producer(comment))
|
||||
m_parser.quit_parsing_file();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// if the gcode was produced by PrusaSlicer,
|
||||
// if the gcode was produced by SuperSlicer,
|
||||
// extract the config from it
|
||||
if (m_producer == EProducer::PrusaSlicer) {
|
||||
if (m_producer == EProducer::SuperSlicer) {
|
||||
DynamicPrintConfig config;
|
||||
config.apply(FullPrintConfig::defaults());
|
||||
config.load_from_gcode_file(filename);
|
||||
@ -824,10 +825,20 @@ void GCodeProcessor::process_file(const std::string& filename, std::function<voi
|
||||
|
||||
update_estimated_times_stats();
|
||||
|
||||
|
||||
// post-process to add M73 lines into the gcode
|
||||
if (m_time_processor.export_remaining_time_enabled)
|
||||
m_time_processor.post_process(filename);
|
||||
|
||||
//update times for resuts
|
||||
for (size_t i = 0; i < m_result.moves.size(); i++) {
|
||||
size_t layer_id = m_result.moves[i].layer_duration;
|
||||
std::vector<float>& layer_times = m_result.time_statistics.modes[0].layers_times;
|
||||
if (layer_times.size() > layer_id - 1 && layer_id > 0)
|
||||
m_result.moves[i].layer_duration = layer_times[layer_id - 1];
|
||||
else
|
||||
m_result.moves[i].layer_duration = 0;
|
||||
}
|
||||
#if ENABLE_GCODE_VIEWER_DATA_CHECKING
|
||||
std::cout << "\n";
|
||||
m_mm3_per_mm_compare.output();
|
||||
@ -1002,7 +1013,7 @@ void GCodeProcessor::process_tags(const std::string& comment)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_producers_enabled || m_producer == EProducer::PrusaSlicer) {
|
||||
if (!m_producers_enabled || m_producer == EProducer::PrusaSlicer || m_producer == EProducer::SuperSlicer) {
|
||||
// height tag
|
||||
pos = comment.find(Height_Tag);
|
||||
if (pos != comment.npos) {
|
||||
@ -1098,6 +1109,7 @@ bool GCodeProcessor::process_producers_tags(const std::string& comment)
|
||||
switch (m_producer)
|
||||
{
|
||||
case EProducer::PrusaSlicer: { return process_prusaslicer_tags(comment); }
|
||||
case EProducer::SuperSlicer: { return process_prusaslicer_tags(comment); }
|
||||
case EProducer::Cura: { return process_cura_tags(comment); }
|
||||
case EProducer::Simplify3D: { return process_simplify3d_tags(comment); }
|
||||
case EProducer::CraftWare: { return process_craftware_tags(comment); }
|
||||
@ -1490,7 +1502,7 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line)
|
||||
m_mm3_per_mm_compare.update(area_toolpath_cross_section, m_extrusion_role);
|
||||
#endif // ENABLE_GCODE_VIEWER_DATA_CHECKING
|
||||
|
||||
if ((m_producers_enabled && m_producer != EProducer::PrusaSlicer) || m_height == 0.0f) {
|
||||
if ((m_producers_enabled && (m_producer != EProducer::PrusaSlicer && m_producer != EProducer::SuperSlicer) ) || m_height == 0.0f) {
|
||||
if (m_end_position[Z] > m_extruded_last_z + EPSILON) {
|
||||
m_height = m_end_position[Z] - m_extruded_last_z;
|
||||
#if ENABLE_GCODE_VIEWER_DATA_CHECKING
|
||||
@ -2108,7 +2120,8 @@ void GCodeProcessor::store_move_vertex(EMoveType type)
|
||||
m_height,
|
||||
m_mm3_per_mm,
|
||||
m_fan_speed,
|
||||
static_cast<float>(m_result.moves.size()),
|
||||
m_layer_id, //layer_duration: set later
|
||||
m_time_processor.machines[0].time, //time: set later
|
||||
m_temperature
|
||||
};
|
||||
m_result.moves.emplace_back(vertex);
|
||||
|
@ -252,6 +252,7 @@ namespace Slic3r {
|
||||
float height{ 0.0f }; // mm
|
||||
float mm3_per_mm{ 0.0f };
|
||||
float fan_speed{ 0.0f }; // percentage
|
||||
float layer_duration{ 0.0f }; // s
|
||||
float time{ 0.0f }; // s
|
||||
float temperature{ 0.0f }; // °
|
||||
|
||||
@ -387,6 +388,7 @@ namespace Slic3r {
|
||||
{
|
||||
Unknown,
|
||||
PrusaSlicer,
|
||||
SuperSlicer,
|
||||
Cura,
|
||||
Simplify3D,
|
||||
CraftWare,
|
||||
|
@ -148,7 +148,7 @@ void GCodeViewer::TBuffer::add_path(const GCodeProcessor::MoveVertex& move, unsi
|
||||
// use rounding to reduce the number of generated paths
|
||||
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.volumetric_rate(), 2), move.extruder_id, move.cp_color_id, move.time, move.time, move.temperature });
|
||||
round_to_nearest(move.volumetric_rate(), 2), move.extruder_id, move.cp_color_id, move.layer_duration, move.time, move.temperature });
|
||||
}
|
||||
|
||||
float GCodeViewer::Extrusions::Range::step_size(bool log) const
|
||||
@ -166,7 +166,7 @@ float GCodeViewer::Extrusions::Range::step_size(bool log) const
|
||||
GCodeViewer::Color GCodeViewer::Extrusions::Range::get_color_at(float value, bool log) const
|
||||
{
|
||||
// Input value scaled to the colors range
|
||||
const float step = step_size();
|
||||
const float step = step_size(log);
|
||||
float global_t;
|
||||
if (log)
|
||||
{
|
||||
@ -391,7 +391,8 @@ 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.layer_duration.update_from(curr.time);
|
||||
if(curr.layer_duration > 0.f)
|
||||
m_extrusions.ranges.layer_duration.update_from(curr.layer_duration);
|
||||
m_extrusions.ranges.elapsed_time.update_from(curr.time);
|
||||
m_extrusions.ranges.volumetric_rate.update_from(round_to_nearest(curr.volumetric_rate(), 2));
|
||||
m_extrusions.ranges.extruder_temp.update_from(curr.temperature);
|
||||
@ -2188,11 +2189,28 @@ void GCodeViewer::render_legend() const
|
||||
else if (range.count == 2) {
|
||||
append_range_item(static_cast<int>(Range_Colors.size()) - 1, range.max, decimals);
|
||||
append_range_item(0, range.min, decimals);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
float step_size = range.step_size();
|
||||
for (int i = static_cast<int>(Range_Colors.size()) - 1; i >= 0; --i) {
|
||||
append_range_item(i, range.min + static_cast<float>(i) * step_size, decimals);
|
||||
append_range_item(i, range.min + static_cast<float>(i)* step_size, decimals);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
auto append_range_time = [this, draw_list, &imgui, append_item](const Extrusions::Range& range, bool is_log) {
|
||||
if (range.count == 1)
|
||||
// single item use case
|
||||
append_item(EItemType::Rect, Range_Colors[0], get_time_dhms(range.min));
|
||||
else if (range.count == 2) {
|
||||
append_item(EItemType::Rect, Range_Colors[static_cast<int>(Range_Colors.size()) - 1], get_time_dhms(range.max));
|
||||
append_item(EItemType::Rect, Range_Colors[0], get_time_dhms(range.min));
|
||||
} else {
|
||||
float step_size = range.step_size(is_log);
|
||||
for (int i = static_cast<int>(Range_Colors.size()) - 1; i >= 0; --i) {
|
||||
if(!is_log)
|
||||
append_item(EItemType::Rect, Range_Colors[i], get_time_dhms(range.min + static_cast<float>(i)* step_size));
|
||||
else
|
||||
append_item(EItemType::Rect, Range_Colors[i], get_time_dhms(std::exp(std::log(range.min) + static_cast<float>(i) * step_size)));
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -2312,7 +2330,7 @@ void GCodeViewer::render_legend() const
|
||||
case EViewType::FanSpeed: { imgui.title(_u8L("Fan Speed (%)")); break; }
|
||||
case EViewType::LayerTime: { imgui.title(_u8L("Layer Time")); break; }
|
||||
case EViewType::LayerTimeLog: { imgui.title(_u8L("Layer Time (log)")); break; }
|
||||
case EViewType::Chronology: { imgui.title(_u8L("Chronology(%)")); break; }
|
||||
case EViewType::Chronology: { imgui.title(_u8L("Chronology")); break; }
|
||||
case EViewType::VolumetricRate: { imgui.title(_u8L("Volumetric flow rate (mm³/s)")); break; }
|
||||
case EViewType::Tool: { imgui.title(_u8L("Tool")); break; }
|
||||
case EViewType::Filament: { imgui.title(_u8L("Filament")); break; }
|
||||
@ -2348,9 +2366,9 @@ 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::LayerTime: { append_range(m_extrusions.ranges.layer_duration, 0); break; }
|
||||
case EViewType::LayerTimeLog: { append_range(m_extrusions.ranges.layer_duration, 0); break; }
|
||||
case EViewType::Chronology: { append_range(m_extrusions.ranges.elapsed_time, 0); break; }
|
||||
case EViewType::LayerTime: { append_range_time(m_extrusions.ranges.layer_duration, false); break; }
|
||||
case EViewType::LayerTimeLog: { append_range_time(m_extrusions.ranges.layer_duration, true); break; }
|
||||
case EViewType::Chronology: { append_range_time(m_extrusions.ranges.elapsed_time, false); break; }
|
||||
case EViewType::VolumetricRate: { append_range(m_extrusions.ranges.volumetric_rate, 3); break; }
|
||||
case EViewType::Tool:
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user