Tech ENABLE_TRAVEL_TIME - Show estimated time for travel moves in legend when they are visible
This commit is contained in:
parent
89ed41750a
commit
eee8d97f49
4 changed files with 83 additions and 6 deletions
|
@ -189,6 +189,9 @@ void GCodeProcessor::TimeMachine::reset()
|
||||||
max_travel_acceleration = 0.0f;
|
max_travel_acceleration = 0.0f;
|
||||||
extrude_factor_override_percentage = 1.0f;
|
extrude_factor_override_percentage = 1.0f;
|
||||||
time = 0.0f;
|
time = 0.0f;
|
||||||
|
#if ENABLE_TRAVEL_TIME
|
||||||
|
travel_time = 0.0f;
|
||||||
|
#endif // ENABLE_TRAVEL_TIME
|
||||||
stop_times = std::vector<StopTime>();
|
stop_times = std::vector<StopTime>();
|
||||||
curr.reset();
|
curr.reset();
|
||||||
prev.reset();
|
prev.reset();
|
||||||
|
@ -303,9 +306,17 @@ void GCodeProcessor::TimeMachine::calculate_time(size_t keep_last_n_blocks)
|
||||||
const TimeBlock& block = blocks[i];
|
const TimeBlock& block = blocks[i];
|
||||||
float block_time = block.time();
|
float block_time = block.time();
|
||||||
time += block_time;
|
time += block_time;
|
||||||
|
#if ENABLE_TRAVEL_TIME
|
||||||
|
if (block.move_type == EMoveType::Travel)
|
||||||
|
travel_time += block_time;
|
||||||
|
else
|
||||||
|
roles_time[static_cast<size_t>(block.role)] += block_time;
|
||||||
|
#endif // ENABLE_TRAVEL_TIME
|
||||||
gcode_time.cache += block_time;
|
gcode_time.cache += block_time;
|
||||||
moves_time[static_cast<size_t>(block.move_type)] += block_time;
|
moves_time[static_cast<size_t>(block.move_type)] += block_time;
|
||||||
|
#if !ENABLE_TRAVEL_TIME
|
||||||
roles_time[static_cast<size_t>(block.role)] += block_time;
|
roles_time[static_cast<size_t>(block.role)] += block_time;
|
||||||
|
#endif // !ENABLE_TRAVEL_TIME
|
||||||
if (block.layer_id > 0) {
|
if (block.layer_id > 0) {
|
||||||
if (block.layer_id >= layers_time.size()) {
|
if (block.layer_id >= layers_time.size()) {
|
||||||
size_t curr_size = layers_time.size();
|
size_t curr_size = layers_time.size();
|
||||||
|
@ -1327,6 +1338,18 @@ std::string GCodeProcessor::get_time_dhm(PrintEstimatedStatistics::ETimeMode mod
|
||||||
return (mode < PrintEstimatedStatistics::ETimeMode::Count) ? short_time(get_time_dhms(m_time_processor.machines[static_cast<size_t>(mode)].time)) : std::string("N/A");
|
return (mode < PrintEstimatedStatistics::ETimeMode::Count) ? short_time(get_time_dhms(m_time_processor.machines[static_cast<size_t>(mode)].time)) : std::string("N/A");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_TRAVEL_TIME
|
||||||
|
float GCodeProcessor::get_travel_time(PrintEstimatedStatistics::ETimeMode mode) const
|
||||||
|
{
|
||||||
|
return (mode < PrintEstimatedStatistics::ETimeMode::Count) ? m_time_processor.machines[static_cast<size_t>(mode)].travel_time : 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GCodeProcessor::get_travel_time_dhm(PrintEstimatedStatistics::ETimeMode mode) const
|
||||||
|
{
|
||||||
|
return (mode < PrintEstimatedStatistics::ETimeMode::Count) ? short_time(get_time_dhms(m_time_processor.machines[static_cast<size_t>(mode)].travel_time)) : std::string("N/A");
|
||||||
|
}
|
||||||
|
#endif // ENABLE_TRAVEL_TIME
|
||||||
|
|
||||||
std::vector<std::pair<CustomGCode::Type, std::pair<float, float>>> GCodeProcessor::get_custom_gcode_times(PrintEstimatedStatistics::ETimeMode mode, bool include_remaining) const
|
std::vector<std::pair<CustomGCode::Type, std::pair<float, float>>> GCodeProcessor::get_custom_gcode_times(PrintEstimatedStatistics::ETimeMode mode, bool include_remaining) const
|
||||||
{
|
{
|
||||||
std::vector<std::pair<CustomGCode::Type, std::pair<float, float>>> ret;
|
std::vector<std::pair<CustomGCode::Type, std::pair<float, float>>> ret;
|
||||||
|
@ -3332,6 +3355,9 @@ void GCodeProcessor::update_estimated_times_stats()
|
||||||
auto update_mode = [this](PrintEstimatedStatistics::ETimeMode mode) {
|
auto update_mode = [this](PrintEstimatedStatistics::ETimeMode mode) {
|
||||||
PrintEstimatedStatistics::Mode& data = m_result.print_statistics.modes[static_cast<size_t>(mode)];
|
PrintEstimatedStatistics::Mode& data = m_result.print_statistics.modes[static_cast<size_t>(mode)];
|
||||||
data.time = get_time(mode);
|
data.time = get_time(mode);
|
||||||
|
#if ENABLE_TRAVEL_TIME
|
||||||
|
data.travel_time = get_travel_time(mode);
|
||||||
|
#endif // ENABLE_TRAVEL_TIME
|
||||||
data.custom_gcode_times = get_custom_gcode_times(mode, true);
|
data.custom_gcode_times = get_custom_gcode_times(mode, true);
|
||||||
data.moves_times = get_moves_time(mode);
|
data.moves_times = get_moves_time(mode);
|
||||||
data.roles_times = get_roles_time(mode);
|
data.roles_times = get_roles_time(mode);
|
||||||
|
|
|
@ -44,6 +44,9 @@ namespace Slic3r {
|
||||||
struct Mode
|
struct Mode
|
||||||
{
|
{
|
||||||
float time;
|
float time;
|
||||||
|
#if ENABLE_TRAVEL_TIME
|
||||||
|
float travel_time;
|
||||||
|
#endif // ENABLE_TRAVEL_TIME
|
||||||
std::vector<std::pair<CustomGCode::Type, std::pair<float, float>>> custom_gcode_times;
|
std::vector<std::pair<CustomGCode::Type, std::pair<float, float>>> custom_gcode_times;
|
||||||
std::vector<std::pair<EMoveType, float>> moves_times;
|
std::vector<std::pair<EMoveType, float>> moves_times;
|
||||||
std::vector<std::pair<ExtrusionRole, float>> roles_times;
|
std::vector<std::pair<ExtrusionRole, float>> roles_times;
|
||||||
|
@ -51,6 +54,9 @@ namespace Slic3r {
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
time = 0.0f;
|
time = 0.0f;
|
||||||
|
#if ENABLE_TRAVEL_TIME
|
||||||
|
travel_time = 0.0f;
|
||||||
|
#endif // ENABLE_TRAVEL_TIME
|
||||||
custom_gcode_times.clear();
|
custom_gcode_times.clear();
|
||||||
moves_times.clear();
|
moves_times.clear();
|
||||||
roles_times.clear();
|
roles_times.clear();
|
||||||
|
@ -250,6 +256,9 @@ namespace Slic3r {
|
||||||
float max_travel_acceleration; // mm/s^2
|
float max_travel_acceleration; // mm/s^2
|
||||||
float extrude_factor_override_percentage;
|
float extrude_factor_override_percentage;
|
||||||
float time; // s
|
float time; // s
|
||||||
|
#if ENABLE_TRAVEL_TIME
|
||||||
|
float travel_time; // s
|
||||||
|
#endif // ENABLE_TRAVEL_TIME
|
||||||
struct StopTime
|
struct StopTime
|
||||||
{
|
{
|
||||||
unsigned int g1_line_id;
|
unsigned int g1_line_id;
|
||||||
|
@ -593,6 +602,10 @@ namespace Slic3r {
|
||||||
|
|
||||||
float get_time(PrintEstimatedStatistics::ETimeMode mode) const;
|
float get_time(PrintEstimatedStatistics::ETimeMode mode) const;
|
||||||
std::string get_time_dhm(PrintEstimatedStatistics::ETimeMode mode) const;
|
std::string get_time_dhm(PrintEstimatedStatistics::ETimeMode mode) const;
|
||||||
|
#if ENABLE_TRAVEL_TIME
|
||||||
|
float get_travel_time(PrintEstimatedStatistics::ETimeMode mode) const;
|
||||||
|
std::string get_travel_time_dhm(PrintEstimatedStatistics::ETimeMode mode) const;
|
||||||
|
#endif // ENABLE_TRAVEL_TIME
|
||||||
std::vector<std::pair<CustomGCode::Type, std::pair<float, float>>> get_custom_gcode_times(PrintEstimatedStatistics::ETimeMode mode, bool include_remaining) const;
|
std::vector<std::pair<CustomGCode::Type, std::pair<float, float>>> get_custom_gcode_times(PrintEstimatedStatistics::ETimeMode mode, bool include_remaining) const;
|
||||||
|
|
||||||
std::vector<std::pair<EMoveType, float>> get_moves_time(PrintEstimatedStatistics::ETimeMode mode) const;
|
std::vector<std::pair<EMoveType, float>> get_moves_time(PrintEstimatedStatistics::ETimeMode mode) const;
|
||||||
|
|
|
@ -71,10 +71,19 @@
|
||||||
|
|
||||||
// Enable fixing loading of gcode files generated with SuperSlicer in GCodeViewer
|
// Enable fixing loading of gcode files generated with SuperSlicer in GCodeViewer
|
||||||
#define ENABLE_FIX_SUPERSLICER_GCODE_IMPORT (1 && ENABLE_2_4_0_ALPHA3)
|
#define ENABLE_FIX_SUPERSLICER_GCODE_IMPORT (1 && ENABLE_2_4_0_ALPHA3)
|
||||||
|
|
||||||
|
|
||||||
|
//====================
|
||||||
|
// 2.4.0.alpha4 techs
|
||||||
|
//====================
|
||||||
|
#define ENABLE_2_4_0_ALPHA4 1
|
||||||
|
|
||||||
// Enable changes in preview layout
|
// Enable changes in preview layout
|
||||||
#define ENABLE_PREVIEW_LAYOUT (1 && ENABLE_2_4_0_ALPHA3)
|
#define ENABLE_PREVIEW_LAYOUT (1 && ENABLE_2_4_0_ALPHA4)
|
||||||
// Enable coloring of toolpaths in preview by layer time
|
// Enable coloring of toolpaths in preview by layer time
|
||||||
#define ENABLE_PREVIEW_LAYER_TIME (1 && ENABLE_2_4_0_ALPHA3)
|
#define ENABLE_PREVIEW_LAYER_TIME (1 && ENABLE_2_4_0_ALPHA4)
|
||||||
|
// Enable showing time estimate for travel moves in legend
|
||||||
|
#define ENABLE_TRAVEL_TIME (1 && ENABLE_2_4_0_ALPHA4)
|
||||||
|
|
||||||
|
|
||||||
#endif // _prusaslicer_technologies_h_
|
#endif // _prusaslicer_technologies_h_
|
||||||
|
|
|
@ -3433,7 +3433,25 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
imgui.text(label);
|
imgui.text(label);
|
||||||
|
#if ENABLE_TRAVEL_TIME
|
||||||
|
if (!time.empty()) {
|
||||||
|
ImGui::SameLine(offsets[0]);
|
||||||
|
imgui.text(time);
|
||||||
|
ImGui::SameLine(offsets[1]);
|
||||||
|
pos = ImGui::GetCursorScreenPos();
|
||||||
|
const float width = std::max(1.0f, percent_bar_size * percent / max_percent);
|
||||||
|
draw_list->AddRectFilled({ pos.x, pos.y + 2.0f }, { pos.x + width, pos.y + icon_size - 2.0f },
|
||||||
|
ImGui::GetColorU32(ImGuiWrapper::COL_ORANGE_LIGHT));
|
||||||
|
ImGui::Dummy({ percent_bar_size, icon_size });
|
||||||
|
ImGui::SameLine();
|
||||||
|
char buf[64];
|
||||||
|
::sprintf(buf, "%.1f%%", 100.0f * percent);
|
||||||
|
ImGui::TextUnformatted((percent > 0.0f) ? buf : "");
|
||||||
|
}
|
||||||
|
else if (used_filament_m > 0.0) {
|
||||||
|
#else
|
||||||
if (used_filament_m > 0.0) {
|
if (used_filament_m > 0.0) {
|
||||||
|
#endif // ENABLE_TRAVEL_TIME
|
||||||
char buf[64];
|
char buf[64];
|
||||||
ImGui::SameLine(offsets[0]);
|
ImGui::SameLine(offsets[0]);
|
||||||
::sprintf(buf, imperial_units ? "%.2f in" : "%.2f m", used_filament_m);
|
::sprintf(buf, imperial_units ? "%.2f in" : "%.2f m", used_filament_m);
|
||||||
|
@ -3600,7 +3618,7 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||||
std::vector<float> percents;
|
std::vector<float> percents;
|
||||||
std::vector<double> used_filaments_m;
|
std::vector<double> used_filaments_m;
|
||||||
std::vector<double> used_filaments_g;
|
std::vector<double> used_filaments_g;
|
||||||
float max_percent = 0.0f;
|
float max_time_percent = 0.0f;
|
||||||
|
|
||||||
if (m_view_type == EViewType::FeatureType) {
|
if (m_view_type == EViewType::FeatureType) {
|
||||||
// calculate offsets to align time/percentage data
|
// calculate offsets to align time/percentage data
|
||||||
|
@ -3611,7 +3629,7 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||||
auto [time, percent] = role_time_and_percent(role);
|
auto [time, percent] = role_time_and_percent(role);
|
||||||
times.push_back((time > 0.0f) ? short_time(get_time_dhms(time)) : "");
|
times.push_back((time > 0.0f) ? short_time(get_time_dhms(time)) : "");
|
||||||
percents.push_back(percent);
|
percents.push_back(percent);
|
||||||
max_percent = std::max(max_percent, percent);
|
max_time_percent = std::max(max_time_percent, percent);
|
||||||
auto [used_filament_m, used_filament_g] = used_filament_per_role(role);
|
auto [used_filament_m, used_filament_g] = used_filament_per_role(role);
|
||||||
used_filaments_m.push_back(used_filament_m);
|
used_filaments_m.push_back(used_filament_m);
|
||||||
used_filaments_g.push_back(used_filament_g);
|
used_filaments_g.push_back(used_filament_g);
|
||||||
|
@ -3747,13 +3765,17 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||||
{
|
{
|
||||||
case EViewType::FeatureType:
|
case EViewType::FeatureType:
|
||||||
{
|
{
|
||||||
|
#if ENABLE_TRAVEL_TIME
|
||||||
|
max_time_percent = std::max(max_time_percent, time_mode.travel_time / time_mode.time);
|
||||||
|
#endif // ENABLE_TRAVEL_TIME
|
||||||
|
|
||||||
for (size_t i = 0; i < m_roles.size(); ++i) {
|
for (size_t i = 0; i < m_roles.size(); ++i) {
|
||||||
ExtrusionRole role = m_roles[i];
|
ExtrusionRole role = m_roles[i];
|
||||||
if (role >= erCount)
|
if (role >= erCount)
|
||||||
continue;
|
continue;
|
||||||
const bool visible = is_visible(role);
|
const bool visible = is_visible(role);
|
||||||
append_item(EItemType::Rect, Extrusion_Role_Colors[static_cast<unsigned int>(role)], labels[i],
|
append_item(EItemType::Rect, Extrusion_Role_Colors[static_cast<unsigned int>(role)], labels[i],
|
||||||
visible, times[i], percents[i], max_percent, offsets, used_filaments_m[i], used_filaments_g[i], [this, role, visible]() {
|
visible, times[i], percents[i], max_time_percent, offsets, used_filaments_m[i], used_filaments_g[i], [this, role, visible]() {
|
||||||
m_extrusions.role_visibility_flags = visible ? m_extrusions.role_visibility_flags & ~(1 << role) : m_extrusions.role_visibility_flags | (1 << role);
|
m_extrusions.role_visibility_flags = visible ? m_extrusions.role_visibility_flags & ~(1 << role) : m_extrusions.role_visibility_flags | (1 << role);
|
||||||
// update buffers' render paths
|
// update buffers' render paths
|
||||||
refresh_render_paths(false, false);
|
refresh_render_paths(false, false);
|
||||||
|
@ -3765,6 +3787,13 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_TRAVEL_TIME
|
||||||
|
if (m_buffers[buffer_id(EMoveType::Travel)].visible)
|
||||||
|
append_item(EItemType::Line, Travel_Colors[0], _u8L("Travel"), true, short_time(get_time_dhms(time_mode.travel_time)),
|
||||||
|
time_mode.travel_time / time_mode.time, max_time_percent, offsets, 0.0f, 0.0f);
|
||||||
|
#endif // ENABLE_TRAVEL_TIME
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EViewType::Height: { append_range(m_extrusions.ranges.height, 3); break; }
|
case EViewType::Height: { append_range(m_extrusions.ranges.height, 3); break; }
|
||||||
|
@ -3783,7 +3812,7 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||||
for (unsigned char extruder_id : m_extruder_ids) {
|
for (unsigned char extruder_id : m_extruder_ids) {
|
||||||
append_item(EItemType::Rect, m_tool_colors[extruder_id], _u8L("Extruder") + " " + std::to_string(extruder_id + 1),
|
append_item(EItemType::Rect, m_tool_colors[extruder_id], _u8L("Extruder") + " " + std::to_string(extruder_id + 1),
|
||||||
true, "", 0.0f, 0.0f, offsets, used_filaments_m[i], used_filaments_g[i]);
|
true, "", 0.0f, 0.0f, offsets, used_filaments_m[i], used_filaments_g[i]);
|
||||||
i++;
|
++i;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue