New gcode visualization library - Tool marker rendering

This commit is contained in:
enricoturri1966 2024-01-25 12:58:27 +01:00 committed by Lukas Matena
parent 9120c93e7b
commit 344dfac25b
6 changed files with 3 additions and 30 deletions

View File

@ -387,11 +387,7 @@ public:
float get_cog_marker_scale_factor() const;
void set_cog_marker_scale_factor(float factor);
bool is_tool_marker_enabled() const;
void enable_tool_marker(bool value);
const Vec3& get_tool_marker_position() const;
void set_tool_marker_position(const Vec3& position);
float get_tool_marker_offset_z() const;
void set_tool_marker_offset_z(float offset_z);

View File

@ -32,9 +32,6 @@ public:
void shutdown();
void render();
bool is_enabled() const { return m_enabled; }
void enable(bool value) { m_enabled = value; }
const Vec3& get_position() const { return m_position; }
void set_position(const Vec3& position) { m_position = position; }
@ -53,7 +50,6 @@ public:
size_t size_in_bytes_gpu() const { return m_size_in_bytes_gpu; }
private:
bool m_enabled{ false };
Vec3 m_position{ 0.0f, 0.0f, 0.0f };
float m_offset_z{ 0.5f };
Color m_color{ 255, 255, 255 };

View File

@ -368,26 +368,11 @@ void Viewer::set_cog_marker_scale_factor(float factor)
m_impl->set_cog_marker_scale_factor(factor);
}
bool Viewer::is_tool_marker_enabled() const
{
return m_impl->is_tool_marker_enabled();
}
void Viewer::enable_tool_marker(bool value)
{
m_impl->enable_tool_marker(value);
}
const Vec3& Viewer::get_tool_marker_position() const
{
return m_impl->get_tool_marker_position();
}
void Viewer::set_tool_marker_position(const Vec3& position)
{
m_impl->set_tool_marker_position(position);
}
float Viewer::get_tool_marker_offset_z() const
{
return m_impl->get_tool_marker_offset_z();

View File

@ -1445,9 +1445,11 @@ void ViewerImpl::render_tool_marker(const Mat4x4& view_matrix, const Mat4x4& pro
if (m_tool_marker_shader_id == 0)
return;
if (!m_tool_marker.is_enabled())
if (m_view_range.get_visible()[1] == m_view_range.get_enabled()[1])
return;
m_tool_marker.set_position(get_current_vertex().position);
int curr_shader;
glsafe(glGetIntegerv(GL_CURRENT_PROGRAM, &curr_shader));
const bool curr_cull_face = glIsEnabled(GL_CULL_FACE);

View File

@ -173,11 +173,7 @@ public:
float get_cog_marker_scale_factor() const { return m_cog_marker_scale_factor; }
void set_cog_marker_scale_factor(float factor) { m_cog_marker_scale_factor = std::max(factor, 0.001f); }
bool is_tool_marker_enabled() const { return m_tool_marker.is_enabled(); }
void enable_tool_marker(bool value) { m_tool_marker.enable(value); }
const Vec3& get_tool_marker_position() const { return m_tool_marker.get_position(); }
void set_tool_marker_position(const Vec3& position) { m_tool_marker.set_position(position); }
float get_tool_marker_offset_z() const { return m_tool_marker.get_offset_z(); }
void set_tool_marker_offset_z(float offset_z) { m_tool_marker.set_offset_z(offset_z); }

View File

@ -3849,8 +3849,6 @@ void GCodeViewer::render_toolpaths()
const libvgcode::Mat4x4 converted_projetion_matrix = libvgcode::convert(static_cast<Matrix4f>(camera.get_projection_matrix().matrix().cast<float>()));
#if VGCODE_ENABLE_COG_AND_TOOL_MARKERS
m_viewer.set_cog_marker_scale_factor(m_cog_marker_fixed_screen_size ? 10.0f * m_cog_marker_size * camera.get_inv_zoom() : m_cog_marker_size);
m_viewer.enable_tool_marker(m_viewer.get_view_enabled_range()[1] != m_viewer.get_view_visible_range()[1]);
m_viewer.set_tool_marker_position(m_viewer.get_current_vertex().position);
m_viewer.set_tool_marker_scale_factor(m_tool_marker_fixed_screen_size ? 10.0f * m_tool_marker_size * camera.get_inv_zoom() : m_tool_marker_size);
#endif // VGCODE_ENABLE_COG_AND_TOOL_MARKERS
m_viewer.render(converted_view_matrix, converted_projetion_matrix);