mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-05 18:20:46 +08:00
New gcode visualization library - Interface for estimated times
This commit is contained in:
parent
344dfac25b
commit
0da174908a
@ -303,6 +303,10 @@ public:
|
||||
//
|
||||
const PathVertex& get_vertex_at(size_t id) const;
|
||||
//
|
||||
// Return the total estimated time, in seconds, using the current time mode.
|
||||
//
|
||||
float get_estimated_time() const;
|
||||
//
|
||||
// Return the estimated time, in seconds, at the vertex with the given index
|
||||
// using the current time mode.
|
||||
//
|
||||
@ -338,15 +342,15 @@ public:
|
||||
//
|
||||
// Return the estimated time for the given role and the current time mode.
|
||||
//
|
||||
float get_extrusion_role_time(EGCodeExtrusionRole role) const;
|
||||
float get_extrusion_role_estimated_time(EGCodeExtrusionRole role) const;
|
||||
//
|
||||
// Return the estimated time for the travel moves and the current time mode.
|
||||
//
|
||||
float get_travels_time() const;
|
||||
float get_travels_estimated_time() const;
|
||||
//
|
||||
// Return the list of layers time for the current time mode.
|
||||
//
|
||||
std::vector<float> get_layers_times() const;
|
||||
std::vector<float> get_layers_estimated_times() const;
|
||||
//
|
||||
// Return the axes aligned bounding box containing all the given types.
|
||||
//
|
||||
|
@ -277,6 +277,11 @@ const PathVertex& Viewer::get_vertex_at(size_t id) const
|
||||
return m_impl->get_vertex_at(id);
|
||||
}
|
||||
|
||||
float Viewer::get_estimated_time() const
|
||||
{
|
||||
return m_impl->get_estimated_time();
|
||||
}
|
||||
|
||||
float Viewer::get_estimated_time_at(size_t id) const
|
||||
{
|
||||
return m_impl->get_estimated_time_at(id);
|
||||
@ -317,19 +322,19 @@ std::vector<ColorPrint> Viewer::get_color_prints(uint8_t extruder_id) const
|
||||
return m_impl->get_color_prints(extruder_id);
|
||||
}
|
||||
|
||||
float Viewer::get_extrusion_role_time(EGCodeExtrusionRole role) const
|
||||
float Viewer::get_extrusion_role_estimated_time(EGCodeExtrusionRole role) const
|
||||
{
|
||||
return m_impl->get_extrusion_role_time(role);
|
||||
return m_impl->get_extrusion_role_estimated_time(role);
|
||||
}
|
||||
|
||||
float Viewer::get_travels_time() const
|
||||
float Viewer::get_travels_estimated_time() const
|
||||
{
|
||||
return m_impl->get_travels_time();
|
||||
return m_impl->get_travels_estimated_time();
|
||||
}
|
||||
|
||||
std::vector<float> Viewer::get_layers_times() const
|
||||
std::vector<float> Viewer::get_layers_estimated_times() const
|
||||
{
|
||||
return m_impl->get_layers_times();
|
||||
return m_impl->get_layers_estimated_times();
|
||||
}
|
||||
|
||||
AABox Viewer::get_bounding_box(const std::vector<EMoveType>& types) const
|
||||
|
@ -446,6 +446,7 @@ void ViewerImpl::reset()
|
||||
m_extrusion_roles.reset();
|
||||
m_options.clear();
|
||||
m_used_extruders.clear();
|
||||
m_total_time = { 0.0f, 0.0f };
|
||||
m_travels_time = { 0.0f, 0.0f };
|
||||
m_vertices.clear();
|
||||
m_valid_lines_bitset.clear();
|
||||
@ -487,14 +488,13 @@ void ViewerImpl::load(GCodeInputData&& gcode_data)
|
||||
|
||||
m_settings.spiral_vase_mode = gcode_data.spiral_vase_mode;
|
||||
|
||||
std::array<float, TIME_MODES_COUNT> times{ 0.0f, 0.0f };
|
||||
for (size_t i = 0; i < m_vertices.size(); ++i) {
|
||||
const PathVertex& v = m_vertices[i];
|
||||
|
||||
m_layers.update(v, static_cast<uint32_t>(i));
|
||||
|
||||
for (size_t j = 0; j < TIME_MODES_COUNT; ++j) {
|
||||
times[j] += v.times[j];
|
||||
m_total_time[j] += v.times[j];
|
||||
if (v.type == EMoveType::Travel)
|
||||
m_travels_time[j] += v.times[j];
|
||||
}
|
||||
@ -510,7 +510,7 @@ void ViewerImpl::load(GCodeInputData&& gcode_data)
|
||||
if (estruder_it == m_used_extruders.end())
|
||||
estruder_it = m_used_extruders.insert({ v.extruder_id, std::vector<ColorPrint>() }).first;
|
||||
if (estruder_it->second.empty() || estruder_it->second.back().color_id != v.color_id) {
|
||||
const ColorPrint cp = { v.extruder_id, v.color_id, v.layer_id, times };
|
||||
const ColorPrint cp = { v.extruder_id, v.color_id, v.layer_id, m_total_time };
|
||||
estruder_it->second.emplace_back(cp);
|
||||
}
|
||||
}
|
||||
@ -541,6 +541,9 @@ void ViewerImpl::load(GCodeInputData&& gcode_data)
|
||||
m_valid_lines_bitset = BitSet<>(m_vertices.size());
|
||||
m_valid_lines_bitset.setAll();
|
||||
|
||||
if (m_settings.time_mode != ETimeMode::Normal && m_total_time[static_cast<size_t>(m_settings.time_mode)] == 0.0f)
|
||||
m_settings.time_mode = ETimeMode::Normal;
|
||||
|
||||
static constexpr const Vec3 ZERO = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
// buffers to send to gpu
|
||||
|
@ -127,18 +127,19 @@ public:
|
||||
const PathVertex& get_vertex_at(size_t id) const {
|
||||
return (id < m_vertices.size()) ? m_vertices[id] : PathVertex::DUMMY_PATH_VERTEX;
|
||||
}
|
||||
float get_estimated_time() const { return m_total_time[static_cast<size_t>(m_settings.time_mode)]; }
|
||||
float get_estimated_time_at(size_t id) const;
|
||||
Color get_vertex_color(const PathVertex& vertex) const;
|
||||
|
||||
size_t get_extrusion_roles_count() const { return m_extrusion_roles.get_roles_count(); }
|
||||
std::vector<EGCodeExtrusionRole> get_extrusion_roles() const { return m_extrusion_roles.get_roles(); }
|
||||
float get_extrusion_role_time(EGCodeExtrusionRole role) const { return m_extrusion_roles.get_time(role, m_settings.time_mode); }
|
||||
float get_extrusion_role_estimated_time(EGCodeExtrusionRole role) const { return m_extrusion_roles.get_time(role, m_settings.time_mode); }
|
||||
|
||||
size_t get_options_count() const { return m_options.size(); }
|
||||
const std::vector<EOptionType>& get_options() const { return m_options; }
|
||||
|
||||
float get_travels_time() const { return m_travels_time[static_cast<size_t>(m_settings.time_mode)]; }
|
||||
std::vector<float> get_layers_times() const { return m_layers.get_times(m_settings.time_mode); }
|
||||
float get_travels_estimated_time() const { return m_travels_time[static_cast<size_t>(m_settings.time_mode)]; }
|
||||
std::vector<float> get_layers_estimated_times() const { return m_layers.get_times(m_settings.time_mode); }
|
||||
|
||||
size_t get_tool_colors_count() const { return m_tool_colors.size(); }
|
||||
const Palette& get_tool_colors() const { return m_tool_colors; }
|
||||
@ -214,6 +215,10 @@ private:
|
||||
//
|
||||
ViewRange m_view_range;
|
||||
//
|
||||
// Detected total moves times
|
||||
//
|
||||
std::array<float, TIME_MODES_COUNT> m_total_time{ 0.0f, 0.0f };
|
||||
//
|
||||
// Detected travel moves times
|
||||
//
|
||||
std::array<float, TIME_MODES_COUNT> m_travels_time{ 0.0f, 0.0f };
|
||||
|
@ -4720,7 +4720,7 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
auto role_time_and_percent = [this, time_mode](libvgcode::EGCodeExtrusionRole role) {
|
||||
const float time = m_viewer.get_extrusion_role_time(role);
|
||||
const float time = m_viewer.get_extrusion_role_estimated_time(role);
|
||||
return std::make_pair(time, time / time_mode.time);
|
||||
};
|
||||
#else
|
||||
@ -4959,7 +4959,7 @@ void GCodeViewer::render_legend(float& legend_height)
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
{
|
||||
#if ENABLE_NEW_GCODE_VIEWER
|
||||
const float travels_time = m_viewer.get_travels_time();
|
||||
const float travels_time = m_viewer.get_travels_estimated_time();
|
||||
max_time_percent = std::max(max_time_percent, travels_time / time_mode.time);
|
||||
const std::vector<libvgcode::EGCodeExtrusionRole>& roles = m_viewer.get_extrusion_roles();
|
||||
for (size_t i = 0; i < roles.size(); ++i) {
|
||||
|
@ -963,7 +963,7 @@ public:
|
||||
std::transform(zs.begin(), zs.end(), std::back_inserter(ret), [](float z) { return static_cast<double>(z); });
|
||||
return ret;
|
||||
}
|
||||
std::vector<float> get_layers_times() const { return m_viewer.get_layers_times(); }
|
||||
std::vector<float> get_layers_times() const { return m_viewer.get_layers_estimated_times(); }
|
||||
#else
|
||||
const std::vector<double>& get_layers_zs() const { return m_layers.get_zs(); }
|
||||
#endif // ENABLE_NEW_GCODE_VIEWER
|
||||
|
Loading…
x
Reference in New Issue
Block a user