mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-01 05:12:00 +08:00
New gcode visualization integration - Removed dependency on Slic3r::GCodeProcessorResult from new visualizer
This commit is contained in:
parent
02cffb04ef
commit
7be092d200
@ -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<size_t>(PrintEstimatedStatistics::ETimeMode::Count); ++i) {
|
||||
ret.times[static_cast<size_t>(convert(static_cast<PrintEstimatedStatistics::ETimeMode>(i)))] = result.print_statistics.modes[i].time;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1358,7 +1374,7 @@ void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& pr
|
||||
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
|
||||
|
@ -12,13 +12,19 @@
|
||||
|
||||
#include "PathVertex.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace libvgcode {
|
||||
|
||||
struct GCodeInputData
|
||||
{
|
||||
//
|
||||
// List of path vertices
|
||||
//
|
||||
std::vector<PathVertex> vertices;
|
||||
|
||||
//
|
||||
// Total time for each time mode
|
||||
//
|
||||
std::array<float, static_cast<size_t>(ETimeMode::COUNT)> times{ 0.0f, 0.0f };
|
||||
};
|
||||
|
||||
} // namespace libvgcode
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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<size_t>(m_settings.time_mode) >= stats.modes.size();
|
||||
bool force_normal_mode = static_cast<size_t>(m_settings.time_mode) >= gcode_data.times.size();
|
||||
if (!force_normal_mode) {
|
||||
const float normal_time = stats.modes[static_cast<size_t>(ETimeMode::Normal)].time;
|
||||
const float mode_time = stats.modes[static_cast<size_t>(m_settings.time_mode)].time;
|
||||
const float normal_time = gcode_data.times[static_cast<size_t>(ETimeMode::Normal)];
|
||||
const float mode_time = gcode_data.times[static_cast<size_t>(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;
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user