Tech ENABLE_GCODE_VIEWER -> removed legend texture from GLCanvas3D

This commit is contained in:
enricoturri1966 2020-04-18 11:49:20 +02:00
parent 3a07e8730f
commit 179dbc7d0e
4 changed files with 34 additions and 5 deletions

View File

@ -513,7 +513,7 @@ void GCodeViewer::render_shells() const
void GCodeViewer::render_overlay() const
{
static const ImVec4 ORANGE(1.0f, 0.49f, 0.22f, 1.0f);
static const float ICON_SIZE = 20.0f;
static const float ICON_BORDER_SIZE = 20.0f;
static const ImU32 ICON_BORDER_COLOR = ImGui::GetColorU32(ImVec4(0.0f, 0.0f, 0.0f, 1.0f));
if (!m_legend_enabled || m_roles.empty())
@ -550,11 +550,11 @@ void GCodeViewer::render_overlay() const
for (ExtrusionRole role : m_roles)
{
ImVec2 pos(ImGui::GetCursorPosX() + 2.0f, ImGui::GetCursorPosY() + 2.0f);
draw_list->AddRect(ImVec2(pos.x, pos.y), ImVec2(pos.x + ICON_SIZE, pos.y + ICON_SIZE), ICON_BORDER_COLOR, 0.0f, 0);
draw_list->AddRect(ImVec2(pos.x, pos.y), ImVec2(pos.x + ICON_BORDER_SIZE, pos.y + ICON_BORDER_SIZE), ICON_BORDER_COLOR, 0.0f, 0);
const std::array<float, 4>& role_color = m_extrusions.role_colors[static_cast<unsigned int>(role)];
ImU32 fill_color = ImGui::GetColorU32(ImVec4(role_color[0], role_color[1], role_color[2], role_color[3]));
draw_list->AddRectFilled(ImVec2(pos.x + 1.0f, pos.y + 1.0f), ImVec2(pos.x + ICON_SIZE - 1.0f, pos.y + ICON_SIZE - 1.0f), fill_color);
ImGui::SetCursorPosX(pos.x + ICON_SIZE + 4.0f);
draw_list->AddRectFilled(ImVec2(pos.x + 1.0f, pos.y + 1.0f), ImVec2(pos.x + ICON_BORDER_SIZE - 1.0f, pos.y + ICON_BORDER_SIZE - 1.0f), fill_color);
ImGui::SetCursorPosX(pos.x + ICON_BORDER_SIZE + 4.0f);
ImGui::AlignTextToFramePadding();
imgui.text(Slic3r::I18N::translate(ExtrusionEntity::role_to_string(role)));
}

View File

@ -901,6 +901,7 @@ void GLCanvas3D::WarningTexture::msw_rescale(const GLCanvas3D& canvas)
generate(m_msg_text, canvas, true, m_is_colored_red);
}
#if !ENABLE_GCODE_VIEWER
const unsigned char GLCanvas3D::LegendTexture::Squares_Border_Color[3] = { 64, 64, 64 };
const unsigned char GLCanvas3D::LegendTexture::Default_Background_Color[3] = { (unsigned char)(DEFAULT_BG_LIGHT_COLOR[0] * 255.0f), (unsigned char)(DEFAULT_BG_LIGHT_COLOR[1] * 255.0f), (unsigned char)(DEFAULT_BG_LIGHT_COLOR[2] * 255.0f) };
const unsigned char GLCanvas3D::LegendTexture::Error_Background_Color[3] = { (unsigned char)(ERROR_BG_LIGHT_COLOR[0] * 255.0f), (unsigned char)(ERROR_BG_LIGHT_COLOR[1] * 255.0f), (unsigned char)(ERROR_BG_LIGHT_COLOR[2] * 255.0f) };
@ -1267,6 +1268,7 @@ void GLCanvas3D::LegendTexture::render(const GLCanvas3D& canvas) const
GLTexture::render_sub_texture(m_id, left, right, bottom, top, uvs);
}
}
#endif // !ENABLE_GCODE_VIEWER
void GLCanvas3D::Labels::render(const std::vector<const ModelInstance*>& sorted_instances) const
{
@ -1574,7 +1576,9 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar
, m_dirty(true)
, m_initialized(false)
, m_apply_zoom_to_volumes_filter(false)
#if !ENABLE_GCODE_VIEWER
, m_legend_texture_enabled(false)
#endif // !ENABLE_GCODE_VIEWER
, m_picking_enabled(false)
, m_moving_enabled(false)
, m_dynamic_background_enabled(false)
@ -2953,6 +2957,7 @@ void GLCanvas3D::load_preview(const std::vector<std::string>& str_tool_colors, c
_update_toolpath_volumes_outside_state();
_show_warning_texture_if_needed(WarningTexture::ToolpathOutside);
#if !ENABLE_GCODE_VIEWER
if (color_print_values.empty())
reset_legend_texture();
else {
@ -2961,6 +2966,7 @@ void GLCanvas3D::load_preview(const std::vector<std::string>& str_tool_colors, c
const std::vector<float> tool_colors = _parse_colors(str_tool_colors);
_generate_legend_texture(preview_data, tool_colors);
}
#endif // !ENABLE_GCODE_VIEWER
}
void GLCanvas3D::bind_event_handlers()
@ -4080,6 +4086,7 @@ Vec2d GLCanvas3D::get_local_mouse_position() const
return Vec2d(factor * mouse_pos.x, factor * mouse_pos.y);
}
#if !ENABLE_GCODE_VIEWER
void GLCanvas3D::reset_legend_texture()
{
if (m_legend_texture.get_id() != 0)
@ -4088,6 +4095,7 @@ void GLCanvas3D::reset_legend_texture()
m_legend_texture.reset();
}
}
#endif // !ENABLE_GCODE_VIEWER
void GLCanvas3D::set_tooltip(const std::string& tooltip) const
{
@ -5556,7 +5564,9 @@ void GLCanvas3D::_render_overlays() const
_render_gizmos_overlay();
_render_warning_texture();
#if !ENABLE_GCODE_VIEWER
_render_legend_texture();
#endif // !ENABLE_GCODE_VIEWER
// main toolbar and undoredo toolbar need to be both updated before rendering because both their sizes are needed
// to correctly place them
@ -5600,6 +5610,7 @@ void GLCanvas3D::_render_warning_texture() const
m_warning_texture.render(*this);
}
#if !ENABLE_GCODE_VIEWER
void GLCanvas3D::_render_legend_texture() const
{
if (!m_legend_texture_enabled)
@ -5607,6 +5618,7 @@ void GLCanvas3D::_render_legend_texture() const
m_legend_texture.render(*this);
}
#endif // !ENABLE_GCODE_VIEWER
void GLCanvas3D::_render_volumes_for_picking() const
{
@ -7096,10 +7108,12 @@ std::vector<float> GLCanvas3D::_parse_colors(const std::vector<std::string>& col
return output;
}
#if !ENABLE_GCODE_VIEWER
void GLCanvas3D::_generate_legend_texture(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors)
{
m_legend_texture.generate(preview_data, tool_colors, *this, true);
}
#endif // !ENABLE_GCODE_VIEWER
void GLCanvas3D::_set_warning_texture(WarningTexture::Warning warning, bool state)
{

View File

@ -345,6 +345,7 @@ private:
bool generate(const std::string& msg, const GLCanvas3D& canvas, bool compress, bool red_colored = false);
};
#if !ENABLE_GCODE_VIEWER
class LegendTexture : public GUI::GLTexture
{
static const int Px_Title_Offset = 5;
@ -371,6 +372,7 @@ private:
void render(const GLCanvas3D& canvas) const;
};
#endif // !ENABLE_GCODE_VIEWER
#if ENABLE_RENDER_STATISTICS
struct RenderStats
@ -445,7 +447,9 @@ private:
std::unique_ptr<RetinaHelper> m_retina_helper;
#endif
bool m_in_render;
#if !ENABLE_GCODE_VIEWER
LegendTexture m_legend_texture;
#endif // !ENABLE_GCODE_VIEWER
WarningTexture m_warning_texture;
wxTimer m_timer;
#if !ENABLE_NON_STATIC_CANVAS_MANAGER
@ -483,7 +487,9 @@ private:
bool m_initialized;
bool m_apply_zoom_to_volumes_filter;
mutable std::vector<int> m_hover_volume_idxs;
#if !ENABLE_GCODE_VIEWER
bool m_legend_texture_enabled;
#endif // !ENABLE_GCODE_VIEWER
bool m_picking_enabled;
bool m_moving_enabled;
bool m_dynamic_background_enabled;
@ -679,7 +685,9 @@ public:
Size get_canvas_size() const;
Vec2d get_local_mouse_position() const;
#if !ENABLE_GCODE_VIEWER
void reset_legend_texture();
#endif // !ENABLE_GCODE_VIEWER
void set_tooltip(const std::string& tooltip) const;
@ -790,7 +798,9 @@ private:
#endif // ENABLE_RENDER_SELECTION_CENTER
void _render_overlays() const;
void _render_warning_texture() const;
#if !ENABLE_GCODE_VIEWER
void _render_legend_texture() const;
#endif // !ENABLE_GCODE_VIEWER
void _render_volumes_for_picking() const;
void _render_current_gizmo() const;
void _render_gizmos_overlay() const;
@ -852,8 +862,10 @@ private:
void _update_sla_shells_outside_state();
void _show_warning_texture_if_needed(WarningTexture::Warning warning);
#if !ENABLE_GCODE_VIEWER
// generates the legend texture in dependence of the current shown view type
void _generate_legend_texture(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors);
#endif // !ENABLE_GCODE_VIEWER
// generates a warning texture containing the given message
void _set_warning_texture(WarningTexture::Warning warning, bool state);

View File

@ -479,8 +479,9 @@ void Preview::reload_print(bool keep_volumes)
m_canvas->reset_volumes();
#if ENABLE_GCODE_VIEWER
m_canvas->reset_gcode_toolpaths();
#endif // ENABLE_GCODE_VIEWER
#else
m_canvas->reset_legend_texture();
#endif // ENABLE_GCODE_VIEWER
m_loaded = false;
#ifdef __linux__
m_volumes_cleanup_required = false;
@ -937,7 +938,9 @@ void Preview::load_print_as_fff(bool keep_z_range)
if (! has_layers)
{
reset_sliders(true);
#if !ENABLE_GCODE_VIEWER
m_canvas->reset_legend_texture();
#endif // !ENABLE_GCODE_VIEWER
m_canvas_widget->Refresh();
return;
}