diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index e6e3d1b703..1733cb0c96 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -145,6 +145,18 @@ static libvgcode::EMoveType convert(EMoveType type) } } +// mapping from Slic3r::PrintEstimatedStatistics::ETimeMode to libvgcode::ETimeMode +static libvgcode::ETimeMode convert(const PrintEstimatedStatistics::ETimeMode& mode) +{ + switch (mode) + { + case PrintEstimatedStatistics::ETimeMode::Normal: { return libvgcode::ETimeMode::Normal; } + case PrintEstimatedStatistics::ETimeMode::Stealth: { return libvgcode::ETimeMode::Stealth; } + case PrintEstimatedStatistics::ETimeMode::Count: { return libvgcode::ETimeMode::COUNT; } + default: { return libvgcode::ETimeMode::COUNT; } + } +} + // mapping from Slic3r::GCodeProcessorResult to libvgcode::GCodeInputData static libvgcode::GCodeInputData convert(const GCodeProcessorResult& result) { @@ -224,6 +236,10 @@ static libvgcode::GCodeInputData convert(const GCodeProcessorResult& result) } ret.vertices.shrink_to_fit(); + for (size_t i = 0; i < static_cast(PrintEstimatedStatistics::ETimeMode::Count); ++i) { + ret.times[static_cast(convert(static_cast(i)))] = result.print_statistics.modes[i].time; + } + return ret; } @@ -1356,9 +1372,9 @@ void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& pr // convert data from PrusaSlicer format to libvgcode format libvgcode::GCodeInputData data = convert(gcode_result); - + // send data to the viewer - m_new_viewer.load(gcode_result, std::move(data)); + m_new_viewer.load(std::move(data)); #else //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // avoid processing if called with the same gcode_result diff --git a/src/slic3r/GUI/LibVGCode/GCodeInputData.hpp b/src/slic3r/GUI/LibVGCode/GCodeInputData.hpp index bf9645896b..631361c1e2 100644 --- a/src/slic3r/GUI/LibVGCode/GCodeInputData.hpp +++ b/src/slic3r/GUI/LibVGCode/GCodeInputData.hpp @@ -12,13 +12,19 @@ #include "PathVertex.hpp" -#include - namespace libvgcode { struct GCodeInputData { + // + // List of path vertices + // std::vector vertices; + + // + // Total time for each time mode + // + std::array(ETimeMode::COUNT)> times{ 0.0f, 0.0f }; }; } // namespace libvgcode diff --git a/src/slic3r/GUI/LibVGCode/Viewer.cpp b/src/slic3r/GUI/LibVGCode/Viewer.cpp index 640e211829..8803067b44 100644 --- a/src/slic3r/GUI/LibVGCode/Viewer.cpp +++ b/src/slic3r/GUI/LibVGCode/Viewer.cpp @@ -12,8 +12,6 @@ //################################################################################################################################ // PrusaSlicer development only -> !!!TO BE REMOVED!!! #if ENABLE_NEW_GCODE_VIEWER - -#include "libslic3r/GCode/GCodeProcessor.hpp" //################################################################################################################################ namespace libvgcode { @@ -28,9 +26,9 @@ void Viewer::reset() m_impl.reset(); } -void Viewer::load(const Slic3r::GCodeProcessorResult& gcode_result, GCodeInputData&& gcode_data) +void Viewer::load(GCodeInputData&& gcode_data) { - m_impl.load(gcode_result, std::move(gcode_data)); + m_impl.load(std::move(gcode_data)); } void Viewer::render(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix) diff --git a/src/slic3r/GUI/LibVGCode/Viewer.hpp b/src/slic3r/GUI/LibVGCode/Viewer.hpp index 323eae766a..8465445d83 100644 --- a/src/slic3r/GUI/LibVGCode/Viewer.hpp +++ b/src/slic3r/GUI/LibVGCode/Viewer.hpp @@ -14,14 +14,6 @@ #include "Types.hpp" #include "GCodeInputData.hpp" -//################################################################################################################################ -// PrusaSlicer development only -> !!!TO BE REMOVED!!! -namespace Slic3r { -struct GCodeProcessorResult; -class Print; -} // namespace Slic3r -//################################################################################################################################ - namespace libvgcode { class Viewer @@ -36,7 +28,7 @@ public: void init(); void reset(); - void load(const Slic3r::GCodeProcessorResult& gcode_result, GCodeInputData&& gcode_data); + void load(GCodeInputData&& gcode_data); void render(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix); EViewType get_view_type() const; diff --git a/src/slic3r/GUI/LibVGCode/ViewerImpl.cpp b/src/slic3r/GUI/LibVGCode/ViewerImpl.cpp index 590cc2d8ef..1923359fc0 100644 --- a/src/slic3r/GUI/LibVGCode/ViewerImpl.cpp +++ b/src/slic3r/GUI/LibVGCode/ViewerImpl.cpp @@ -16,7 +16,6 @@ //################################################################################################################################ // PrusaSlicer development only -> !!!TO BE REMOVED!!! #if ENABLE_NEW_GCODE_VIEWER -#include "libslic3r/GCode/GCodeProcessor.hpp" #include "slic3r/GUI/GUI_App.hpp" #include "slic3r/GUI/ImGuiWrapper.hpp" //################################################################################################################################ @@ -472,16 +471,15 @@ void ViewerImpl::reset() delete_buffers(m_positions_buf_id); } -void ViewerImpl::load(const Slic3r::GCodeProcessorResult& gcode_result, GCodeInputData&& gcode_data) +void ViewerImpl::load(GCodeInputData&& gcode_data) { if (m_settings.time_mode != ETimeMode::Normal) { - const Slic3r::PrintEstimatedStatistics& stats = gcode_result.print_statistics; - bool force_normal_mode = static_cast(m_settings.time_mode) >= stats.modes.size(); + bool force_normal_mode = static_cast(m_settings.time_mode) >= gcode_data.times.size(); if (!force_normal_mode) { - const float normal_time = stats.modes[static_cast(ETimeMode::Normal)].time; - const float mode_time = stats.modes[static_cast(m_settings.time_mode)].time; + const float normal_time = gcode_data.times[static_cast(ETimeMode::Normal)]; + const float mode_time = gcode_data.times[static_cast(m_settings.time_mode)]; force_normal_mode = mode_time == 0.0f || - short_time(get_time_dhms(mode_time)) == short_time(get_time_dhms(normal_time)); // TO CHECK -> Is this necessary ? + short_time(get_time_dhms(mode_time)) == short_time(get_time_dhms(normal_time)); // TO CHECK -> Is this necessary ? } if (force_normal_mode) m_settings.time_mode = ETimeMode::Normal; diff --git a/src/slic3r/GUI/LibVGCode/ViewerImpl.hpp b/src/slic3r/GUI/LibVGCode/ViewerImpl.hpp index 4a865eeba2..494a9d1ccc 100644 --- a/src/slic3r/GUI/LibVGCode/ViewerImpl.hpp +++ b/src/slic3r/GUI/LibVGCode/ViewerImpl.hpp @@ -24,14 +24,6 @@ #include "Layers.hpp" #include "ExtrusionRoles.hpp" -//################################################################################################################################ -// PrusaSlicer development only -> !!!TO BE REMOVED!!! -namespace Slic3r { -struct GCodeProcessorResult; -class Print; -} // namespace Slic3r -//################################################################################################################################ - namespace libvgcode { struct GCodeInputData; @@ -57,10 +49,10 @@ public: void reset(); // - // Setup all the variables used for visualization and coloring of the toolpaths - // from the gcode moves contained in the given gcode_result. + // Setup all the variables used for visualization of the toolpaths + // from the given gcode data. // - void load(const Slic3r::GCodeProcessorResult& gcode_result, GCodeInputData&& gcode_data); + void load(GCodeInputData&& gcode_data); // // Update the visibility property of toolpaths