mirror of
https://github.com/FULU-Foundation/OrcaSlicer-bambulab.git
synced 2026-05-20 10:50:33 -07:00
Added class GCodeViewer -> basic render of gcode toolpaths using dedicated shaders
This commit is contained in:
63
src/slic3r/GUI/GCodeViewer.hpp
Normal file
63
src/slic3r/GUI/GCodeViewer.hpp
Normal file
@@ -0,0 +1,63 @@
|
||||
#ifndef slic3r_GCodeViewer_hpp_
|
||||
#define slic3r_GCodeViewer_hpp_
|
||||
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
|
||||
#include "GLShader.hpp"
|
||||
#include "libslic3r/GCode/GCodeProcessor.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
class GCodeViewer
|
||||
{
|
||||
struct Buffer
|
||||
{
|
||||
unsigned int vbo_id{ 0 };
|
||||
std::vector<float> data;
|
||||
|
||||
static size_t stride(GCodeProcessor::EMoveType type)
|
||||
{
|
||||
return 3 * sizeof(float);
|
||||
}
|
||||
|
||||
static size_t record_size(GCodeProcessor::EMoveType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case GCodeProcessor::EMoveType::Tool_change:
|
||||
case GCodeProcessor::EMoveType::Retract:
|
||||
case GCodeProcessor::EMoveType::Unretract: { return 3; }
|
||||
case GCodeProcessor::EMoveType::Extrude:
|
||||
case GCodeProcessor::EMoveType::Travel: { return 6; }
|
||||
default: { return 0; }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
std::vector<Buffer> m_buffers{ static_cast<size_t>(GCodeProcessor::EMoveType::Extrude) };
|
||||
std::vector<Shader> m_shaders{ static_cast<size_t>(GCodeProcessor::EMoveType::Extrude) };
|
||||
unsigned int m_last_result_id{ 0 };
|
||||
|
||||
public:
|
||||
GCodeViewer() = default;
|
||||
~GCodeViewer() { reset_buffers(); }
|
||||
|
||||
bool init() { return init_shaders(); }
|
||||
void generate(const GCodeProcessor::Result& gcode_result);
|
||||
void render() const;
|
||||
|
||||
private:
|
||||
bool init_shaders();
|
||||
void reset_buffers();
|
||||
};
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
|
||||
#endif // slic3r_GCodeViewer_hpp_
|
||||
|
||||
Reference in New Issue
Block a user