GCodeViewer -> Toggle visibility of shells

This commit is contained in:
enricoturri1966 2020-04-15 14:31:39 +02:00
parent bc05ab985c
commit cc774dece7
7 changed files with 363 additions and 180 deletions

View file

@ -4,11 +4,13 @@
#if ENABLE_GCODE_VIEWER
#include "GLShader.hpp"
#include "3DScene.hpp"
#include "libslic3r/GCode/GCodeProcessor.hpp"
#include <vector>
namespace Slic3r {
class Print;
namespace GUI {
class GCodeViewer
@ -18,26 +20,34 @@ class GCodeViewer
unsigned int vbo_id{ 0 };
Shader shader;
std::vector<float> data;
size_t data_size{ 0 };
bool visible{ false };
void reset();
static size_t vertex_size() { return 3; }
static size_t vertex_size_bytes() { return vertex_size() * sizeof(float); }
};
struct Shells
{
GLVolumeCollection volumes;
bool visible{ false };
Shader shader;
};
std::vector<Buffer> m_buffers{ static_cast<size_t>(GCodeProcessor::EMoveType::Extrude) };
unsigned int m_last_result_id{ 0 };
std::vector<double> m_layers_zs;
Shells m_shells;
public:
GCodeViewer() = default;
~GCodeViewer() { reset(); }
bool init() { set_toolpath_visible(GCodeProcessor::EMoveType::Extrude, true); return init_shaders(); }
void generate(const GCodeProcessor::Result& gcode_result);
void load(const GCodeProcessor::Result& gcode_result, const Print& print, bool initialized);
void reset();
void render() const;
@ -46,8 +56,15 @@ public:
bool is_toolpath_visible(GCodeProcessor::EMoveType type) const;
void set_toolpath_visible(GCodeProcessor::EMoveType type, bool visible);
bool are_shells_visible() const { return m_shells.visible; }
void set_shells_visible(bool visible) { m_shells.visible = visible; }
private:
bool init_shaders();
void load_toolpaths(const GCodeProcessor::Result& gcode_result);
void load_shells(const Print& print, bool initialized);
void render_toolpaths() const;
void render_shells() const;
};
} // namespace GUI