#5098 - Fixed no preview after language change
This commit is contained in:
parent
2618992c8b
commit
a72fb79f72
2 changed files with 37 additions and 39 deletions
src/slic3r/GUI
|
@ -412,6 +412,9 @@ void GCodeViewer::refresh(const GCodeProcessor::Result& gcode_result, const std:
|
||||||
|
|
||||||
void GCodeViewer::reset()
|
void GCodeViewer::reset()
|
||||||
{
|
{
|
||||||
|
m_initialized = false;
|
||||||
|
m_gl_data_initialized = false;
|
||||||
|
|
||||||
m_moves_count = 0;
|
m_moves_count = 0;
|
||||||
for (TBuffer& buffer : m_buffers) {
|
for (TBuffer& buffer : m_buffers) {
|
||||||
buffer.reset();
|
buffer.reset();
|
||||||
|
@ -439,46 +442,39 @@ void GCodeViewer::reset()
|
||||||
void GCodeViewer::render() const
|
void GCodeViewer::render() const
|
||||||
{
|
{
|
||||||
auto init_gl_data = [this]() {
|
auto init_gl_data = [this]() {
|
||||||
static bool first_run = true;
|
// initializes opengl data of TBuffers
|
||||||
if (first_run) {
|
for (size_t i = 0; i < m_buffers.size(); ++i) {
|
||||||
// initializes opengl data of TBuffers
|
TBuffer& buffer = m_buffers[i];
|
||||||
for (size_t i = 0; i < m_buffers.size(); ++i) {
|
switch (buffer_type(i)) {
|
||||||
TBuffer& buffer = m_buffers[i];
|
default: { break; }
|
||||||
switch (buffer_type(i))
|
case EMoveType::Tool_change:
|
||||||
{
|
case EMoveType::Color_change:
|
||||||
default: { break; }
|
case EMoveType::Pause_Print:
|
||||||
case EMoveType::Tool_change:
|
case EMoveType::Custom_GCode:
|
||||||
case EMoveType::Color_change:
|
case EMoveType::Retract:
|
||||||
case EMoveType::Pause_Print:
|
case EMoveType::Unretract: {
|
||||||
case EMoveType::Custom_GCode:
|
buffer.shader = wxGetApp().is_glsl_version_greater_or_equal_to(1, 20) ? "options_120" : "options_110";
|
||||||
case EMoveType::Retract:
|
break;
|
||||||
case EMoveType::Unretract:
|
}
|
||||||
{
|
case EMoveType::Extrude: {
|
||||||
buffer.shader = wxGetApp().is_glsl_version_greater_or_equal_to(1, 20) ? "options_120" : "options_110";
|
buffer.shader = "gouraud_light";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EMoveType::Extrude:
|
case EMoveType::Travel: {
|
||||||
{
|
buffer.shader = "toolpaths_lines";
|
||||||
buffer.shader = "gouraud_light";
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
case EMoveType::Travel:
|
|
||||||
{
|
|
||||||
buffer.shader = "toolpaths_lines";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// initializes tool marker
|
|
||||||
m_sequential_view.marker.init();
|
|
||||||
|
|
||||||
// initializes point sizes
|
|
||||||
std::array<int, 2> point_sizes;
|
|
||||||
::glGetIntegerv(GL_ALIASED_POINT_SIZE_RANGE, point_sizes.data());
|
|
||||||
m_detected_point_sizes = { static_cast<float>(point_sizes[0]), static_cast<float>(point_sizes[1]) };
|
|
||||||
first_run = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// initializes tool marker
|
||||||
|
m_sequential_view.marker.init();
|
||||||
|
|
||||||
|
// initializes point sizes
|
||||||
|
std::array<int, 2> point_sizes;
|
||||||
|
::glGetIntegerv(GL_ALIASED_POINT_SIZE_RANGE, point_sizes.data());
|
||||||
|
m_detected_point_sizes = { static_cast<float>(point_sizes[0]), static_cast<float>(point_sizes[1]) };
|
||||||
|
m_gl_data_initialized = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER_STATISTICS
|
#if ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
|
@ -487,7 +483,8 @@ void GCodeViewer::render() const
|
||||||
|
|
||||||
// OpenGL data must be initialized after the glContext has been created.
|
// OpenGL data must be initialized after the glContext has been created.
|
||||||
// This is ensured when this method is called by GLCanvas3D::_render_gcode().
|
// This is ensured when this method is called by GLCanvas3D::_render_gcode().
|
||||||
init_gl_data();
|
if (!m_gl_data_initialized)
|
||||||
|
init_gl_data();
|
||||||
|
|
||||||
if (m_roles.empty())
|
if (m_roles.empty())
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -388,6 +388,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_initialized{ false };
|
bool m_initialized{ false };
|
||||||
|
mutable bool m_gl_data_initialized{ false };
|
||||||
unsigned int m_last_result_id{ 0 };
|
unsigned int m_last_result_id{ 0 };
|
||||||
size_t m_moves_count{ 0 };
|
size_t m_moves_count{ 0 };
|
||||||
mutable std::vector<TBuffer> m_buffers{ static_cast<size_t>(EMoveType::Extrude) };
|
mutable std::vector<TBuffer> m_buffers{ static_cast<size_t>(EMoveType::Extrude) };
|
||||||
|
|
Loading…
Add table
Reference in a new issue