mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-01 04:02:02 +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
|
// mapping from Slic3r::GCodeProcessorResult to libvgcode::GCodeInputData
|
||||||
static libvgcode::GCodeInputData convert(const GCodeProcessorResult& result)
|
static libvgcode::GCodeInputData convert(const GCodeProcessorResult& result)
|
||||||
{
|
{
|
||||||
@ -224,6 +236,10 @@ static libvgcode::GCodeInputData convert(const GCodeProcessorResult& result)
|
|||||||
}
|
}
|
||||||
ret.vertices.shrink_to_fit();
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1356,9 +1372,9 @@ void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& pr
|
|||||||
|
|
||||||
// convert data from PrusaSlicer format to libvgcode format
|
// convert data from PrusaSlicer format to libvgcode format
|
||||||
libvgcode::GCodeInputData data = convert(gcode_result);
|
libvgcode::GCodeInputData data = convert(gcode_result);
|
||||||
|
|
||||||
// send data to the viewer
|
// send data to the viewer
|
||||||
m_new_viewer.load(gcode_result, std::move(data));
|
m_new_viewer.load(std::move(data));
|
||||||
#else
|
#else
|
||||||
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
// avoid processing if called with the same gcode_result
|
// avoid processing if called with the same gcode_result
|
||||||
|
@ -12,13 +12,19 @@
|
|||||||
|
|
||||||
#include "PathVertex.hpp"
|
#include "PathVertex.hpp"
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace libvgcode {
|
namespace libvgcode {
|
||||||
|
|
||||||
struct GCodeInputData
|
struct GCodeInputData
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
// List of path vertices
|
||||||
|
//
|
||||||
std::vector<PathVertex> 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
|
} // namespace libvgcode
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
//################################################################################################################################
|
//################################################################################################################################
|
||||||
// PrusaSlicer development only -> !!!TO BE REMOVED!!!
|
// PrusaSlicer development only -> !!!TO BE REMOVED!!!
|
||||||
#if ENABLE_NEW_GCODE_VIEWER
|
#if ENABLE_NEW_GCODE_VIEWER
|
||||||
|
|
||||||
#include "libslic3r/GCode/GCodeProcessor.hpp"
|
|
||||||
//################################################################################################################################
|
//################################################################################################################################
|
||||||
|
|
||||||
namespace libvgcode {
|
namespace libvgcode {
|
||||||
@ -28,9 +26,9 @@ void Viewer::reset()
|
|||||||
m_impl.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)
|
void Viewer::render(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix)
|
||||||
|
@ -14,14 +14,6 @@
|
|||||||
#include "Types.hpp"
|
#include "Types.hpp"
|
||||||
#include "GCodeInputData.hpp"
|
#include "GCodeInputData.hpp"
|
||||||
|
|
||||||
//################################################################################################################################
|
|
||||||
// PrusaSlicer development only -> !!!TO BE REMOVED!!!
|
|
||||||
namespace Slic3r {
|
|
||||||
struct GCodeProcessorResult;
|
|
||||||
class Print;
|
|
||||||
} // namespace Slic3r
|
|
||||||
//################################################################################################################################
|
|
||||||
|
|
||||||
namespace libvgcode {
|
namespace libvgcode {
|
||||||
|
|
||||||
class Viewer
|
class Viewer
|
||||||
@ -36,7 +28,7 @@ public:
|
|||||||
|
|
||||||
void init();
|
void init();
|
||||||
void reset();
|
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);
|
void render(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix);
|
||||||
|
|
||||||
EViewType get_view_type() const;
|
EViewType get_view_type() const;
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
//################################################################################################################################
|
//################################################################################################################################
|
||||||
// PrusaSlicer development only -> !!!TO BE REMOVED!!!
|
// PrusaSlicer development only -> !!!TO BE REMOVED!!!
|
||||||
#if ENABLE_NEW_GCODE_VIEWER
|
#if ENABLE_NEW_GCODE_VIEWER
|
||||||
#include "libslic3r/GCode/GCodeProcessor.hpp"
|
|
||||||
#include "slic3r/GUI/GUI_App.hpp"
|
#include "slic3r/GUI/GUI_App.hpp"
|
||||||
#include "slic3r/GUI/ImGuiWrapper.hpp"
|
#include "slic3r/GUI/ImGuiWrapper.hpp"
|
||||||
//################################################################################################################################
|
//################################################################################################################################
|
||||||
@ -472,16 +471,15 @@ void ViewerImpl::reset()
|
|||||||
delete_buffers(m_positions_buf_id);
|
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) {
|
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) >= gcode_data.times.size();
|
||||||
bool force_normal_mode = static_cast<size_t>(m_settings.time_mode) >= stats.modes.size();
|
|
||||||
if (!force_normal_mode) {
|
if (!force_normal_mode) {
|
||||||
const float normal_time = stats.modes[static_cast<size_t>(ETimeMode::Normal)].time;
|
const float normal_time = gcode_data.times[static_cast<size_t>(ETimeMode::Normal)];
|
||||||
const float mode_time = stats.modes[static_cast<size_t>(m_settings.time_mode)].time;
|
const float mode_time = gcode_data.times[static_cast<size_t>(m_settings.time_mode)];
|
||||||
force_normal_mode = mode_time == 0.0f ||
|
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)
|
if (force_normal_mode)
|
||||||
m_settings.time_mode = ETimeMode::Normal;
|
m_settings.time_mode = ETimeMode::Normal;
|
||||||
|
@ -24,14 +24,6 @@
|
|||||||
#include "Layers.hpp"
|
#include "Layers.hpp"
|
||||||
#include "ExtrusionRoles.hpp"
|
#include "ExtrusionRoles.hpp"
|
||||||
|
|
||||||
//################################################################################################################################
|
|
||||||
// PrusaSlicer development only -> !!!TO BE REMOVED!!!
|
|
||||||
namespace Slic3r {
|
|
||||||
struct GCodeProcessorResult;
|
|
||||||
class Print;
|
|
||||||
} // namespace Slic3r
|
|
||||||
//################################################################################################################################
|
|
||||||
|
|
||||||
namespace libvgcode {
|
namespace libvgcode {
|
||||||
|
|
||||||
struct GCodeInputData;
|
struct GCodeInputData;
|
||||||
@ -57,10 +49,10 @@ public:
|
|||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Setup all the variables used for visualization and coloring of the toolpaths
|
// Setup all the variables used for visualization of the toolpaths
|
||||||
// from the gcode moves contained in the given gcode_result.
|
// 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
|
// Update the visibility property of toolpaths
|
||||||
|
Loading…
x
Reference in New Issue
Block a user