2020-04-14 08:02:08 +00:00
|
|
|
#ifndef slic3r_GCodeViewer_hpp_
|
|
|
|
#define slic3r_GCodeViewer_hpp_
|
|
|
|
|
|
|
|
#if ENABLE_GCODE_VIEWER
|
|
|
|
|
|
|
|
#include "GLShader.hpp"
|
2020-04-15 12:31:39 +00:00
|
|
|
#include "3DScene.hpp"
|
2020-04-14 08:02:08 +00:00
|
|
|
#include "libslic3r/GCode/GCodeProcessor.hpp"
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace Slic3r {
|
2020-04-15 12:31:39 +00:00
|
|
|
class Print;
|
2020-04-14 08:02:08 +00:00
|
|
|
namespace GUI {
|
|
|
|
|
|
|
|
class GCodeViewer
|
|
|
|
{
|
|
|
|
struct Buffer
|
|
|
|
{
|
|
|
|
unsigned int vbo_id{ 0 };
|
2020-04-14 14:40:08 +00:00
|
|
|
Shader shader;
|
2020-04-14 08:02:08 +00:00
|
|
|
std::vector<float> data;
|
2020-04-15 12:31:39 +00:00
|
|
|
size_t data_size{ 0 };
|
2020-04-14 14:40:08 +00:00
|
|
|
bool visible{ false };
|
2020-04-14 08:02:08 +00:00
|
|
|
|
2020-04-14 14:40:08 +00:00
|
|
|
void reset();
|
|
|
|
|
|
|
|
static size_t vertex_size() { return 3; }
|
|
|
|
static size_t vertex_size_bytes() { return vertex_size() * sizeof(float); }
|
2020-04-14 08:02:08 +00:00
|
|
|
};
|
|
|
|
|
2020-04-15 12:31:39 +00:00
|
|
|
struct Shells
|
|
|
|
{
|
|
|
|
GLVolumeCollection volumes;
|
|
|
|
bool visible{ false };
|
|
|
|
Shader shader;
|
|
|
|
};
|
|
|
|
|
2020-04-14 08:02:08 +00:00
|
|
|
std::vector<Buffer> m_buffers{ static_cast<size_t>(GCodeProcessor::EMoveType::Extrude) };
|
2020-04-14 14:40:08 +00:00
|
|
|
|
2020-04-14 08:02:08 +00:00
|
|
|
unsigned int m_last_result_id{ 0 };
|
2020-04-14 14:40:08 +00:00
|
|
|
std::vector<double> m_layers_zs;
|
2020-04-15 12:31:39 +00:00
|
|
|
Shells m_shells;
|
2020-04-14 08:02:08 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
GCodeViewer() = default;
|
2020-04-14 14:40:08 +00:00
|
|
|
~GCodeViewer() { reset(); }
|
2020-04-14 08:02:08 +00:00
|
|
|
|
2020-04-14 14:40:08 +00:00
|
|
|
bool init() { set_toolpath_visible(GCodeProcessor::EMoveType::Extrude, true); return init_shaders(); }
|
2020-04-15 12:31:39 +00:00
|
|
|
void load(const GCodeProcessor::Result& gcode_result, const Print& print, bool initialized);
|
2020-04-14 14:40:08 +00:00
|
|
|
void reset();
|
2020-04-14 08:02:08 +00:00
|
|
|
void render() const;
|
|
|
|
|
2020-04-14 14:40:08 +00:00
|
|
|
const std::vector<double>& get_layers_zs() const { return m_layers_zs; };
|
|
|
|
|
|
|
|
bool is_toolpath_visible(GCodeProcessor::EMoveType type) const;
|
|
|
|
void set_toolpath_visible(GCodeProcessor::EMoveType type, bool visible);
|
|
|
|
|
2020-04-15 12:31:39 +00:00
|
|
|
bool are_shells_visible() const { return m_shells.visible; }
|
|
|
|
void set_shells_visible(bool visible) { m_shells.visible = visible; }
|
|
|
|
|
2020-04-14 08:02:08 +00:00
|
|
|
private:
|
|
|
|
bool init_shaders();
|
2020-04-15 12:31:39 +00:00
|
|
|
void load_toolpaths(const GCodeProcessor::Result& gcode_result);
|
|
|
|
void load_shells(const Print& print, bool initialized);
|
|
|
|
void render_toolpaths() const;
|
|
|
|
void render_shells() const;
|
2020-04-14 08:02:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace GUI
|
|
|
|
} // namespace Slic3r
|
|
|
|
|
|
|
|
#endif // ENABLE_GCODE_VIEWER
|
|
|
|
|
|
|
|
#endif // slic3r_GCodeViewer_hpp_
|
|
|
|
|