New gcode visualization - Refactoring + added missing headers

This commit is contained in:
enricoturri1966 2023-12-20 11:37:08 +01:00 committed by Lukas Matena
parent 1e3fa49cae
commit c7c594c302
16 changed files with 152 additions and 145 deletions

View File

@ -7,6 +7,8 @@
#include "../include/Types.hpp" #include "../include/Types.hpp"
#include <cfloat>
namespace libvgcode { namespace libvgcode {
// //

View File

@ -7,6 +7,8 @@
#include "Types.hpp" #include "Types.hpp"
#include <cfloat>
namespace libvgcode { namespace libvgcode {
// //
@ -42,9 +44,12 @@ struct PathVertex
// Segment volumetric rate // Segment volumetric rate
// //
float volumetric_rate{ 0.0f }; float volumetric_rate{ 0.0f };
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
//
// Segment weight
//
float weight{ 0.0f }; float weight{ 0.0f };
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS
// //
// Segment extrusion role // Segment extrusion role
// //

View File

@ -5,7 +5,7 @@
#ifndef VGCODE_TYPES_HPP #ifndef VGCODE_TYPES_HPP
#define VGCODE_TYPES_HPP #define VGCODE_TYPES_HPP
#define ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS 1 #define ENABLE_COG_AND_TOOL_MARKERS 0
#include <array> #include <array>
#include <vector> #include <vector>
@ -152,10 +152,10 @@ enum class EOptionType : uint8_t
ColorChanges, ColorChanges,
PausePrints, PausePrints,
CustomGCodes, CustomGCodes,
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
CenterOfGravity, CenterOfGravity,
ToolMarker, ToolMarker,
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS
COUNT COUNT
}; };

View File

@ -172,7 +172,7 @@ public:
float get_wipes_radius() const; float get_wipes_radius() const;
void set_wipes_radius(float radius); void set_wipes_radius(float radius);
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
// //
// Returns the position of the center of gravity of the toolpaths. // Returns the position of the center of gravity of the toolpaths.
// It does not take in account extrusions of type: // It does not take in account extrusions of type:
@ -204,7 +204,7 @@ public:
float get_tool_marker_alpha() const; float get_tool_marker_alpha() const;
void set_tool_marker_alpha(float alpha); void set_tool_marker_alpha(float alpha);
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS
private: private:
ViewerImpl* m_impl{ nullptr }; ViewerImpl* m_impl{ nullptr };

View File

@ -10,7 +10,7 @@
#include <assert.h> #include <assert.h>
#include <algorithm> #include <algorithm>
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
namespace libvgcode { namespace libvgcode {
@ -157,4 +157,4 @@ Vec3 CogMarker::get_position() const
} // namespace libvgcode } // namespace libvgcode
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS

View File

@ -7,7 +7,7 @@
#include "../include/Types.hpp" #include "../include/Types.hpp"
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
namespace libvgcode { namespace libvgcode {
@ -57,6 +57,6 @@ private:
} // namespace libvgcode } // namespace libvgcode
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS
#endif // VGCODE_COGMARKER_HPP #endif // VGCODE_COGMARKER_HPP

View File

@ -31,10 +31,10 @@ struct Settings
{ EOptionType::ColorChanges, false }, { EOptionType::ColorChanges, false },
{ EOptionType::PausePrints, false }, { EOptionType::PausePrints, false },
{ EOptionType::CustomGCodes, false }, { EOptionType::CustomGCodes, false },
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
{ EOptionType::CenterOfGravity, false }, { EOptionType::CenterOfGravity, false },
{ EOptionType::ToolMarker, true } { EOptionType::ToolMarker, true }
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS
} }; } };
std::map<EGCodeExtrusionRole, bool> extrusion_roles_visibility{ { std::map<EGCodeExtrusionRole, bool> extrusion_roles_visibility{ {

View File

@ -5,7 +5,7 @@
#ifndef VGCODE_SHADERS_HPP #ifndef VGCODE_SHADERS_HPP
#define VGCODE_SHADERS_HPP #define VGCODE_SHADERS_HPP
// needed for tech ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS // needed for tech ENABLE_COG_AND_TOOL_MARKERS
#include "../include/Types.hpp" #include "../include/Types.hpp"
namespace libvgcode { namespace libvgcode {
@ -203,7 +203,7 @@ static const char* Options_Fragment_Shader =
" fragmentColor = vec4(color, 1.0);\n" " fragmentColor = vec4(color, 1.0);\n"
"}\n"; "}\n";
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
static const char* Cog_Marker_Vertex_Shader = static const char* Cog_Marker_Vertex_Shader =
"#version 150\n" "#version 150\n"
"const vec3 light_top_dir = vec3(-0.4574957, 0.4574957, 0.7624929);\n" "const vec3 light_top_dir = vec3(-0.4574957, 0.4574957, 0.7624929);\n"
@ -291,7 +291,7 @@ static const char* Tool_Marker_Fragment_Shader =
"void main() {\n" "void main() {\n"
" fragment_color = color;\n" " fragment_color = color;\n"
"}\n"; "}\n";
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS
} // namespace libvgcode } // namespace libvgcode

View File

@ -8,7 +8,7 @@
#include <cmath> #include <cmath>
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
namespace libvgcode { namespace libvgcode {
@ -158,4 +158,4 @@ void ToolMarker::render()
} // namespace libvgcode } // namespace libvgcode
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS

View File

@ -7,7 +7,7 @@
#include "../include/Types.hpp" #include "../include/Types.hpp"
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
#include <algorithm> #include <algorithm>
namespace libvgcode { namespace libvgcode {
@ -55,6 +55,6 @@ private:
} // namespace libvgcode } // namespace libvgcode
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS
#endif // VGCODE_TOOLMARKER_HPP #endif // VGCODE_TOOLMARKER_HPP

View File

@ -357,7 +357,7 @@ void Viewer::set_wipes_radius(float radius)
m_impl->set_wipes_radius(radius); m_impl->set_wipes_radius(radius);
} }
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
Vec3 Viewer::get_cog_position() const Vec3 Viewer::get_cog_position() const
{ {
return m_impl->get_cog_marker_position(); return m_impl->get_cog_marker_position();
@ -432,6 +432,6 @@ void Viewer::set_tool_marker_alpha(float alpha)
{ {
m_impl->set_tool_marker_alpha(alpha); m_impl->set_tool_marker_alpha(alpha);
} }
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS
} // namespace libvgcode } // namespace libvgcode

View File

@ -385,7 +385,7 @@ void ViewerImpl::init()
m_option_template.init(16); m_option_template.init(16);
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
// cog marker shader // cog marker shader
m_cog_marker_shader_id = init_shader("cog_marker", Cog_Marker_Vertex_Shader, Cog_Marker_Fragment_Shader); m_cog_marker_shader_id = init_shader("cog_marker", Cog_Marker_Vertex_Shader, Cog_Marker_Fragment_Shader);
@ -418,7 +418,7 @@ void ViewerImpl::init()
m_uni_tool_marker_color_base != -1); m_uni_tool_marker_color_base != -1);
m_tool_marker.init(32, 2.0f, 4.0f, 1.0f, 8.0f); m_tool_marker.init(32, 2.0f, 4.0f, 1.0f, 8.0f);
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS
m_initialized = true; m_initialized = true;
} }
@ -432,9 +432,9 @@ void ViewerImpl::reset()
m_used_extruders_ids.clear(); m_used_extruders_ids.clear();
m_vertices.clear(); m_vertices.clear();
m_valid_lines_bitset.clear(); m_valid_lines_bitset.clear();
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
m_cog_marker.reset(); m_cog_marker.reset();
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS
m_enabled_segments_count = 0; m_enabled_segments_count = 0;
m_enabled_options_count = 0; m_enabled_options_count = 0;
@ -482,7 +482,7 @@ void ViewerImpl::load(GCodeInputData&& gcode_data)
m_used_extruders_ids.emplace_back(v.extruder_id); m_used_extruders_ids.emplace_back(v.extruder_id);
if (i > 0) { if (i > 0) {
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
// updates calculation for center of gravity // updates calculation for center of gravity
if (v.type == EMoveType::Extrude && if (v.type == EMoveType::Extrude &&
v.role != EGCodeExtrusionRole::Skirt && v.role != EGCodeExtrusionRole::Skirt &&
@ -492,7 +492,7 @@ void ViewerImpl::load(GCodeInputData&& gcode_data)
v.role != EGCodeExtrusionRole::Custom) { v.role != EGCodeExtrusionRole::Custom) {
m_cog_marker.update(0.5f * (v.position + m_vertices[i - 1].position), v.weight); m_cog_marker.update(0.5f * (v.position + m_vertices[i - 1].position), v.weight);
} }
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS
} }
} }
@ -727,12 +727,12 @@ void ViewerImpl::render(const Mat4x4& view_matrix, const Mat4x4& projection_matr
render_segments(view_matrix, projection_matrix, camera_position); render_segments(view_matrix, projection_matrix, camera_position);
render_options(view_matrix, projection_matrix); render_options(view_matrix, projection_matrix);
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
if (m_settings.options_visibility.at(EOptionType::ToolMarker)) if (m_settings.options_visibility.at(EOptionType::ToolMarker))
render_tool_marker(view_matrix, projection_matrix); render_tool_marker(view_matrix, projection_matrix);
if (m_settings.options_visibility.at(EOptionType::CenterOfGravity)) if (m_settings.options_visibility.at(EOptionType::CenterOfGravity))
render_cog_marker(view_matrix, projection_matrix); render_cog_marker(view_matrix, projection_matrix);
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS
} }
void ViewerImpl::set_view_type(EViewType type) void ViewerImpl::set_view_type(EViewType type)
@ -1220,7 +1220,7 @@ void ViewerImpl::render_options(const Mat4x4& view_matrix, const Mat4x4& project
glsafe(glActiveTexture(curr_active_texture)); glsafe(glActiveTexture(curr_active_texture));
} }
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
void ViewerImpl::render_cog_marker(const Mat4x4& view_matrix, const Mat4x4& projection_matrix) void ViewerImpl::render_cog_marker(const Mat4x4& view_matrix, const Mat4x4& projection_matrix)
{ {
if (m_cog_marker_shader_id == 0) if (m_cog_marker_shader_id == 0)
@ -1299,6 +1299,6 @@ void ViewerImpl::render_tool_marker(const Mat4x4& view_matrix, const Mat4x4& pro
glsafe(glUseProgram(curr_shader)); glsafe(glUseProgram(curr_shader));
} }
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS
} // namespace libvgcode } // namespace libvgcode

View File

@ -8,10 +8,10 @@
#include "Settings.hpp" #include "Settings.hpp"
#include "SegmentTemplate.hpp" #include "SegmentTemplate.hpp"
#include "OptionTemplate.hpp" #include "OptionTemplate.hpp"
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
#include "CogMarker.hpp" #include "CogMarker.hpp"
#include "ToolMarker.hpp" #include "ToolMarker.hpp"
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS
#include "../include/PathVertex.hpp" #include "../include/PathVertex.hpp"
#include "../include/ColorRange.hpp" #include "../include/ColorRange.hpp"
#include "Bitset.hpp" #include "Bitset.hpp"
@ -160,7 +160,7 @@ public:
float get_wipes_radius() const { return m_wipes_radius; } float get_wipes_radius() const { return m_wipes_radius; }
void set_wipes_radius(float radius); void set_wipes_radius(float radius);
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
Vec3 get_cog_marker_position() const { return m_cog_marker.get_position(); } Vec3 get_cog_marker_position() const { return m_cog_marker.get_position(); }
float get_cog_marker_scale_factor() const { return m_cog_marker_scale_factor; } float get_cog_marker_scale_factor() const { return m_cog_marker_scale_factor; }
@ -183,7 +183,7 @@ public:
float get_tool_marker_alpha() const { return m_tool_marker.get_alpha(); } float get_tool_marker_alpha() const { return m_tool_marker.get_alpha(); }
void set_tool_marker_alpha(float alpha) { m_tool_marker.set_alpha(alpha); } void set_tool_marker_alpha(float alpha) { m_tool_marker.set_alpha(alpha); }
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS
private: private:
Settings m_settings; Settings m_settings;
@ -212,7 +212,7 @@ private:
// //
OptionTemplate m_option_template; OptionTemplate m_option_template;
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
// //
// The OpenGL element used to represent the center of gravity // The OpenGL element used to represent the center of gravity
// //
@ -224,7 +224,7 @@ private:
// //
ToolMarker m_tool_marker; ToolMarker m_tool_marker;
float m_tool_marker_scale_factor{ 1.0f }; float m_tool_marker_scale_factor{ 1.0f };
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS
// //
// cpu buffer to store vertices // cpu buffer to store vertices
@ -259,10 +259,10 @@ private:
// //
unsigned int m_segments_shader_id{ 0 }; unsigned int m_segments_shader_id{ 0 };
unsigned int m_options_shader_id{ 0 }; unsigned int m_options_shader_id{ 0 };
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
unsigned int m_cog_marker_shader_id{ 0 }; unsigned int m_cog_marker_shader_id{ 0 };
unsigned int m_tool_marker_shader_id{ 0 }; unsigned int m_tool_marker_shader_id{ 0 };
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS
// //
// Cache for OpenGL uniforms id for segments shader // Cache for OpenGL uniforms id for segments shader
@ -285,7 +285,7 @@ private:
int m_uni_options_colors_tex_id{ -1 }; int m_uni_options_colors_tex_id{ -1 };
int m_uni_options_segment_index_tex_id{ -1 }; int m_uni_options_segment_index_tex_id{ -1 };
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
// //
// Cache for OpenGL uniforms id for cog marker shader // Cache for OpenGL uniforms id for cog marker shader
// //
@ -302,7 +302,7 @@ private:
int m_uni_tool_marker_view_matrix{ -1 }; int m_uni_tool_marker_view_matrix{ -1 };
int m_uni_tool_marker_projection_matrix{ -1 }; int m_uni_tool_marker_projection_matrix{ -1 };
int m_uni_tool_marker_color_base{ -1 }; int m_uni_tool_marker_color_base{ -1 };
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS
// //
// gpu buffers to store positions // gpu buffers to store positions
@ -335,10 +335,10 @@ private:
void update_heights_widths(); void update_heights_widths();
void render_segments(const Mat4x4& view_matrix, const Mat4x4& projection_matrix, const Vec3& camera_position); void render_segments(const Mat4x4& view_matrix, const Mat4x4& projection_matrix, const Vec3& camera_position);
void render_options(const Mat4x4& view_matrix, const Mat4x4& projection_matrix); void render_options(const Mat4x4& view_matrix, const Mat4x4& projection_matrix);
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
void render_cog_marker(const Mat4x4& view_matrix, const Mat4x4& projection_matrix); void render_cog_marker(const Mat4x4& view_matrix, const Mat4x4& projection_matrix);
void render_tool_marker(const Mat4x4& view_matrix, const Mat4x4& projection_matrix); void render_tool_marker(const Mat4x4& view_matrix, const Mat4x4& projection_matrix);
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS
// //
// Palette used to render extrusion moves by extrusion roles // Palette used to render extrusion moves by extrusion roles

View File

@ -193,11 +193,11 @@ void GCodeViewer::TBuffer::add_path(const GCodeProcessorResult::MoveVertex& move
#endif // !ENABLE_NEW_GCODE_VIEWER #endif // !ENABLE_NEW_GCODE_VIEWER
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
#if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
void GCodeViewer::COG::render()
#else
void GCodeViewer::COG::render(bool fixed_screen_size) void GCodeViewer::COG::render(bool fixed_screen_size)
#endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #else
void GCodeViewer::COG::render()
#endif // ENABLE_COG_AND_TOOL_MARKERS
#else #else
void GCodeViewer::COG::render() void GCodeViewer::COG::render()
#endif // ENABLE_NEW_GCODE_VIEWER #endif // ENABLE_NEW_GCODE_VIEWER
@ -206,12 +206,12 @@ void GCodeViewer::COG::render()
return; return;
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
#if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
init();
#else
fixed_screen_size = true; fixed_screen_size = true;
init(fixed_screen_size); init(fixed_screen_size);
#endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #else
init();
#endif // ENABLE_COG_AND_TOOL_MARKERS
#else #else
init(); init();
#endif // ENABLE_NEW_GCODE_VIEWER #endif // ENABLE_NEW_GCODE_VIEWER
@ -227,11 +227,11 @@ void GCodeViewer::COG::render()
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
Transform3d model_matrix = Geometry::translation_transform(cog()) * Geometry::scale_transform(m_scale_factor); Transform3d model_matrix = Geometry::translation_transform(cog()) * Geometry::scale_transform(m_scale_factor);
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
#if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
if (m_fixed_screen_size) {
#else
if (fixed_screen_size) { if (fixed_screen_size) {
#endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #else
if (m_fixed_screen_size) {
#endif // ENABLE_COG_AND_TOOL_MARKERS
#else #else
if (m_fixed_screen_size) { if (m_fixed_screen_size) {
#endif // ENABLE_NEW_GCODE_VIEWER #endif // ENABLE_NEW_GCODE_VIEWER
@ -916,9 +916,9 @@ void GCodeViewer::SequentialView::GCodeWindow::render(float top, float bottom, s
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
void GCodeViewer::SequentialView::render(float legend_height, const libvgcode::Viewer* viewer, uint32_t gcode_id) void GCodeViewer::SequentialView::render(float legend_height, const libvgcode::Viewer* viewer, uint32_t gcode_id)
{ {
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
if (viewer == nullptr) if (viewer == nullptr)
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS
marker.render(); marker.render();
marker.render_position_window(viewer); marker.render_position_window(viewer);
#else #else
@ -1151,7 +1151,7 @@ void GCodeViewer::load_as_gcode(const GCodeProcessorResult& gcode_result, const
m_viewer.reset_default_extrusion_roles_colors(); m_viewer.reset_default_extrusion_roles_colors();
m_viewer.load(std::move(data)); m_viewer.load(std::move(data));
#if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if !ENABLE_COG_AND_TOOL_MARKERS
const size_t vertices_count = m_viewer.get_vertices_count(); const size_t vertices_count = m_viewer.get_vertices_count();
m_cog.reset(); m_cog.reset();
for (size_t i = 1; i < vertices_count; ++i) { for (size_t i = 1; i < vertices_count; ++i) {
@ -1167,7 +1167,7 @@ void GCodeViewer::load_as_gcode(const GCodeProcessorResult& gcode_result, const
m_cog.add_segment(curr_pos, prev_pos, curr.volumetric_rate / curr.feedrate * (curr_pos - prev_pos).norm()); m_cog.add_segment(curr_pos, prev_pos, curr.volumetric_rate / curr.feedrate * (curr_pos - prev_pos).norm());
} }
} }
#endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // !ENABLE_COG_AND_TOOL_MARKERS
const libvgcode::AABox bbox = m_viewer.get_bounding_box(wxGetApp().is_gcode_viewer() ? libvgcode::EBBoxType::Full : libvgcode::EBBoxType::ExtrusionNoCustom); const libvgcode::AABox bbox = m_viewer.get_bounding_box(wxGetApp().is_gcode_viewer() ? libvgcode::EBBoxType::Full : libvgcode::EBBoxType::ExtrusionNoCustom);
m_paths_bounding_box.min = libvgcode::convert(bbox[0]).cast<double>(); m_paths_bounding_box.min = libvgcode::convert(bbox[0]).cast<double>();
@ -1492,7 +1492,7 @@ void GCodeViewer::render()
#endif // !ENABLE_NEW_GCODE_VIEWER #endif // !ENABLE_NEW_GCODE_VIEWER
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
if (is_legend_shown()) { if (is_legend_shown()) {
ImGuiWrapper& imgui = *Slic3r::GUI::wxGetApp().imgui(); ImGuiWrapper& imgui = *Slic3r::GUI::wxGetApp().imgui();
const Size cnv_size = wxGetApp().plater()->get_current_canvas3D()->get_canvas_size(); const Size cnv_size = wxGetApp().plater()->get_current_canvas3D()->get_canvas_size();
@ -1525,7 +1525,7 @@ void GCodeViewer::render()
imgui.end(); imgui.end();
} }
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS
#endif // ENABLE_NEW_GCODE_VIEWER #endif // ENABLE_NEW_GCODE_VIEWER
} }
@ -3853,12 +3853,12 @@ void GCodeViewer::render_toolpaths()
const Camera& camera = wxGetApp().plater()->get_camera(); const Camera& camera = wxGetApp().plater()->get_camera();
libvgcode::Mat4x4 converted_view_matrix = libvgcode::convert(static_cast<Matrix4f>(camera.get_view_matrix().matrix().cast<float>())); libvgcode::Mat4x4 converted_view_matrix = libvgcode::convert(static_cast<Matrix4f>(camera.get_view_matrix().matrix().cast<float>()));
libvgcode::Mat4x4 converted_projetion_matrix = libvgcode::convert(static_cast<Matrix4f>(camera.get_projection_matrix().matrix().cast<float>())); libvgcode::Mat4x4 converted_projetion_matrix = libvgcode::convert(static_cast<Matrix4f>(camera.get_projection_matrix().matrix().cast<float>()));
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if 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.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.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_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); 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 // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS
m_viewer.render(converted_view_matrix, converted_projetion_matrix); m_viewer.render(converted_view_matrix, converted_projetion_matrix);
#if ENABLE_NEW_GCODE_VIEWER_DEBUG #if ENABLE_NEW_GCODE_VIEWER_DEBUG
@ -3949,7 +3949,7 @@ void GCodeViewer::render_toolpaths()
ImGui::EndTable(); ImGui::EndTable();
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
ImGui::Separator(); ImGui::Separator();
if (ImGui::BeginTable("Cog", 2)) { if (ImGui::BeginTable("Cog", 2)) {
@ -4001,7 +4001,7 @@ void GCodeViewer::render_toolpaths()
ImGui::EndTable(); ImGui::EndTable();
} }
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS
} }
ImGui::Separator(); ImGui::Separator();
@ -5566,7 +5566,9 @@ void GCodeViewer::render_legend(float& legend_height)
std::function<void(ImGuiWindow& window, const ImVec2& pos, float size)> draw_callback) { std::function<void(ImGuiWindow& window, const ImVec2& pos, float size)> draw_callback) {
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
bool active = false; bool active = false;
#if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
active = (type == Preview::OptionType::Shells) ? m_shells.visible : m_viewer.is_option_visible(libvgcode::convert(type));
#else
switch (type) switch (type)
{ {
case Preview::OptionType::CenterOfGravity: { active = m_cog.is_visible(); break; } case Preview::OptionType::CenterOfGravity: { active = m_cog.is_visible(); break; }
@ -5574,9 +5576,7 @@ void GCodeViewer::render_legend(float& legend_height)
case Preview::OptionType::Shells: { active = m_shells.visible; break; } case Preview::OptionType::Shells: { active = m_shells.visible; break; }
default: { active = m_viewer.is_option_visible(libvgcode::convert(type)); break; } default: { active = m_viewer.is_option_visible(libvgcode::convert(type)); break; }
} }
#else #endif // ENABLE_COG_AND_TOOL_MARKERS
active = (type == Preview::OptionType::Shells) ? m_shells.visible : m_viewer.is_option_visible(libvgcode::convert(type));
#endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS
#else #else
auto is_flag_set = [](unsigned int flags, unsigned int flag) { auto is_flag_set = [](unsigned int flags, unsigned int flag) {
return (flags & (1 << flag)) != 0; return (flags & (1 << flag)) != 0;
@ -5596,28 +5596,28 @@ void GCodeViewer::render_legend(float& legend_height)
const libvgcode::Interval& view_visible_range = m_viewer.get_view_visible_range(); const libvgcode::Interval& view_visible_range = m_viewer.get_view_visible_range();
const libvgcode::Interval& view_enabled_range = m_viewer.get_view_enabled_range(); const libvgcode::Interval& view_enabled_range = m_viewer.get_view_enabled_range();
bool keep_visible_range = false; bool keep_visible_range = false;
#if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
switch (type) if (type == Preview::OptionType::Shells)
{ m_shells.visible = !active;
case Preview::OptionType::CenterOfGravity: { m_cog.set_visible(!active); break; } else {
case Preview::OptionType::ToolMarker: { m_sequential_view.marker.set_visible(!active); break; } m_viewer.toggle_option_visibility(libvgcode::convert(type));
case Preview::OptionType::Shells: { m_shells.visible = !active; break; } if (view_visible_range != view_enabled_range)
default: { keep_visible_range = true;
m_viewer.toggle_option_visibility(libvgcode::convert(type)); }
if (view_visible_range != view_enabled_range)
keep_visible_range = true;
break;
}
}
#else #else
if (type == Preview::OptionType::Shells) switch (type)
m_shells.visible = !active; {
else { case Preview::OptionType::CenterOfGravity: { m_cog.set_visible(!active); break; }
m_viewer.toggle_option_visibility(libvgcode::convert(type)); case Preview::OptionType::ToolMarker: { m_sequential_view.marker.set_visible(!active); break; }
if (view_visible_range != view_enabled_range) case Preview::OptionType::Shells: { m_shells.visible = !active; break; }
keep_visible_range = true; default: {
} m_viewer.toggle_option_visibility(libvgcode::convert(type));
#endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS if (view_visible_range != view_enabled_range)
keep_visible_range = true;
break;
}
}
#endif // ENABLE_COG_AND_TOOL_MARKERS
std::optional<int> view_visible_range_min; std::optional<int> view_visible_range_min;
std::optional<int> view_visible_range_max; std::optional<int> view_visible_range_max;
if (keep_visible_range) { if (keep_visible_range) {

View File

@ -14,7 +14,7 @@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
#include "LibVGCode/LibVGCodeWrapper.hpp" #include "LibVGCode/LibVGCodeWrapper.hpp"
// needed for tech ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS // needed for tech ENABLE_COG_AND_TOOL_MARKERS
#include "LibVGCode/include/Types.hpp" #include "LibVGCode/include/Types.hpp"
#endif // ENABLE_NEW_GCODE_VIEWER #endif // ENABLE_NEW_GCODE_VIEWER
@ -399,10 +399,10 @@ class GCodeViewer
GLModel m_model; GLModel m_model;
bool m_visible{ false }; bool m_visible{ false };
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
#if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if !ENABLE_COG_AND_TOOL_MARKERS
// whether or not to render the model with fixed screen size // whether or not to render the model with fixed screen size
bool m_fixed_screen_size{ true }; bool m_fixed_screen_size{ true };
#endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // !ENABLE_COG_AND_TOOL_MARKERS
#else #else
// whether or not to render the model with fixed screen size // whether or not to render the model with fixed screen size
bool m_fixed_screen_size{ true }; bool m_fixed_screen_size{ true };
@ -413,11 +413,11 @@ class GCodeViewer
public: public:
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
#if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
void render(); void render(bool fixed_screen_size);
#else #else
void render(bool fixed_screen_size); void render();
#endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS
#else #else
void render(); void render();
#endif // ENABLE_NEW_GCODE_VIEWER #endif // ENABLE_NEW_GCODE_VIEWER
@ -447,11 +447,11 @@ class GCodeViewer
private: private:
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
#if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
void init() {
#else
void init(bool fixed_screen_size) { void init(bool fixed_screen_size) {
#endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #else
void init() {
#endif // ENABLE_COG_AND_TOOL_MARKERS
#else #else
void init() { void init() {
#endif // ENABLE_NEW_GCODE_VIEWER #endif // ENABLE_NEW_GCODE_VIEWER
@ -459,11 +459,11 @@ class GCodeViewer
return; return;
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
#if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
const float radius = m_fixed_screen_size ? 10.0f : 1.0f;
#else
const float radius = fixed_screen_size ? 10.0f : 1.0f; const float radius = fixed_screen_size ? 10.0f : 1.0f;
#endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #else
const float radius = m_fixed_screen_size ? 10.0f : 1.0f;
#endif // ENABLE_COG_AND_TOOL_MARKERS
#else #else
const float radius = m_fixed_screen_size ? 10.0f : 1.0f; const float radius = m_fixed_screen_size ? 10.0f : 1.0f;
#endif // ENABLE_NEW_GCODE_VIEWER #endif // ENABLE_NEW_GCODE_VIEWER
@ -857,13 +857,13 @@ private:
Shells m_shells; Shells m_shells;
COG m_cog; COG m_cog;
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
// whether or not to render the cog model with fixed screen size // whether or not to render the cog model with fixed screen size
bool m_cog_marker_fixed_screen_size{ true }; bool m_cog_marker_fixed_screen_size{ true };
float m_cog_marker_size{ 1.0f }; float m_cog_marker_size{ 1.0f };
bool m_tool_marker_fixed_screen_size{ false }; bool m_tool_marker_fixed_screen_size{ false };
float m_tool_marker_size{ 1.0f }; float m_tool_marker_size{ 1.0f };
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS
bool m_legend_visible{ true }; bool m_legend_visible{ true };
bool m_legend_enabled{ true }; bool m_legend_enabled{ true };
#else #else
@ -919,11 +919,11 @@ public:
void reset(); void reset();
void render(); void render();
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
#if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
void render_cog() { m_cog.render(); }
#else
void render_cog() { m_cog.render(m_cog_marker_fixed_screen_size); } void render_cog() { m_cog.render(m_cog_marker_fixed_screen_size); }
#endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #else
void render_cog() { m_cog.render(); }
#endif // ENABLE_COG_AND_TOOL_MARKERS
bool has_data() const { return !m_viewer.get_extrusion_roles().empty(); } bool has_data() const { return !m_viewer.get_extrusion_roles().empty(); }
#else #else
void render_cog() { m_cog.render(); } void render_cog() { m_cog.render(); }
@ -1018,10 +1018,10 @@ public:
void load_shells(const Print& print); void load_shells(const Print& print);
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
#if !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
float get_cog_marker_scale_factor() const { return m_viewer.get_cog_marker_scale_factor(); } float get_cog_marker_scale_factor() const { return m_viewer.get_cog_marker_scale_factor(); }
void set_cog_marker_scale_factor(float factor) { return m_viewer.set_cog_marker_scale_factor(factor); } void set_cog_marker_scale_factor(float factor) { return m_viewer.set_cog_marker_scale_factor(factor); }
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_COG_AND_TOOL_MARKERS
#endif // ENABLE_NEW_GCODE_VIEWER #endif // ENABLE_NEW_GCODE_VIEWER
private: private:

View File

@ -116,13 +116,13 @@ EOptionType convert(const Slic3r::GUI::Preview::OptionType& type)
case Slic3r::GUI::Preview::OptionType::ColorChanges: { return EOptionType::ColorChanges; } case Slic3r::GUI::Preview::OptionType::ColorChanges: { return EOptionType::ColorChanges; }
case Slic3r::GUI::Preview::OptionType::PausePrints: { return EOptionType::PausePrints; } case Slic3r::GUI::Preview::OptionType::PausePrints: { return EOptionType::PausePrints; }
case Slic3r::GUI::Preview::OptionType::CustomGCodes: { return EOptionType::CustomGCodes; } case Slic3r::GUI::Preview::OptionType::CustomGCodes: { return EOptionType::CustomGCodes; }
#if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
case Slic3r::GUI::Preview::OptionType::CenterOfGravity: { return EOptionType::COUNT; }
case Slic3r::GUI::Preview::OptionType::ToolMarker: { return EOptionType::COUNT; }
#else
case Slic3r::GUI::Preview::OptionType::CenterOfGravity: { return EOptionType::CenterOfGravity; } case Slic3r::GUI::Preview::OptionType::CenterOfGravity: { return EOptionType::CenterOfGravity; }
case Slic3r::GUI::Preview::OptionType::ToolMarker: { return EOptionType::ToolMarker; } case Slic3r::GUI::Preview::OptionType::ToolMarker: { return EOptionType::ToolMarker; }
#endif // !ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #else
case Slic3r::GUI::Preview::OptionType::CenterOfGravity: { return EOptionType::COUNT; }
case Slic3r::GUI::Preview::OptionType::ToolMarker: { return EOptionType::COUNT; }
#endif // ENABLE_COG_AND_TOOL_MARKERS
default: { return EOptionType::COUNT; } default: { return EOptionType::COUNT; }
} }
} }
@ -197,31 +197,31 @@ GCodeInputData convert(const Slic3r::GCodeProcessorResult& result, float travels
// to allow libvgcode to properly detect the start/end of a path we need to add a 'phantom' vertex // to allow libvgcode to properly detect the start/end of a path we need to add a 'phantom' vertex
// equal to the current one with the exception of the position, which should match the previous move position, // equal to the current one with the exception of the position, which should match the previous move position,
// and the times, which are set to zero // and the times, which are set to zero
#if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
const libvgcode::PathVertex vertex = { convert(prev.position), height, width, curr.feedrate, curr.fan_speed,
curr.temperature, curr.volumetric_rate(), extrusion_role, curr_type,
static_cast<uint32_t>(curr.gcode_id), static_cast<uint32_t>(curr.layer_id),
static_cast<uint8_t>(curr.extruder_id), static_cast<uint8_t>(curr.cp_color_id), { 0.0f, 0.0f } };
#else
const libvgcode::PathVertex vertex = { convert(prev.position), height, width, curr.feedrate, curr.fan_speed, const libvgcode::PathVertex vertex = { convert(prev.position), height, width, curr.feedrate, curr.fan_speed,
curr.temperature, curr.volumetric_rate(), 0.0f, extrusion_role, curr_type, curr.temperature, curr.volumetric_rate(), 0.0f, extrusion_role, curr_type,
static_cast<uint32_t>(curr.gcode_id), static_cast<uint32_t>(curr.layer_id), static_cast<uint32_t>(curr.gcode_id), static_cast<uint32_t>(curr.layer_id),
static_cast<uint8_t>(curr.extruder_id), static_cast<uint8_t>(curr.cp_color_id), { 0.0f, 0.0f } }; static_cast<uint8_t>(curr.extruder_id), static_cast<uint8_t>(curr.cp_color_id), { 0.0f, 0.0f } };
#endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #else
const libvgcode::PathVertex vertex = { convert(prev.position), height, width, curr.feedrate, curr.fan_speed,
curr.temperature, curr.volumetric_rate(), extrusion_role, curr_type,
static_cast<uint32_t>(curr.gcode_id), static_cast<uint32_t>(curr.layer_id),
static_cast<uint8_t>(curr.extruder_id), static_cast<uint8_t>(curr.cp_color_id), { 0.0f, 0.0f } };
#endif // ENABLE_COG_AND_TOOL_MARKERS
ret.vertices.emplace_back(vertex); ret.vertices.emplace_back(vertex);
} }
} }
#if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
const libvgcode::PathVertex vertex = { convert(curr.position), height, width, curr.feedrate, curr.fan_speed,
curr.temperature, curr.volumetric_rate(), extrusion_role, curr_type, static_cast<uint32_t>(curr.gcode_id),
static_cast<uint32_t>(curr.layer_id), static_cast<uint8_t>(curr.extruder_id), static_cast<uint8_t>(curr.cp_color_id), curr.time };
#else
const libvgcode::PathVertex vertex = { convert(curr.position), height, width, curr.feedrate, curr.fan_speed, const libvgcode::PathVertex vertex = { convert(curr.position), height, width, curr.feedrate, curr.fan_speed,
curr.temperature, curr.volumetric_rate(), curr.mm3_per_mm * (curr.position - prev.position).norm(), curr.temperature, curr.volumetric_rate(), curr.mm3_per_mm * (curr.position - prev.position).norm(),
extrusion_role, curr_type, static_cast<uint32_t>(curr.gcode_id), static_cast<uint32_t>(curr.layer_id), extrusion_role, curr_type, static_cast<uint32_t>(curr.gcode_id), static_cast<uint32_t>(curr.layer_id),
static_cast<uint8_t>(curr.extruder_id), static_cast<uint8_t>(curr.cp_color_id), curr.time }; static_cast<uint8_t>(curr.extruder_id), static_cast<uint8_t>(curr.cp_color_id), curr.time };
#endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #else
const libvgcode::PathVertex vertex = { convert(curr.position), height, width, curr.feedrate, curr.fan_speed,
curr.temperature, curr.volumetric_rate(), extrusion_role, curr_type, static_cast<uint32_t>(curr.gcode_id),
static_cast<uint32_t>(curr.layer_id), static_cast<uint8_t>(curr.extruder_id), static_cast<uint8_t>(curr.cp_color_id), curr.time };
#endif // ENABLE_COG_AND_TOOL_MARKERS
ret.vertices.emplace_back(vertex); ret.vertices.emplace_back(vertex);
} }
ret.vertices.shrink_to_fit(); ret.vertices.shrink_to_fit();
@ -246,15 +246,15 @@ static void convert_lines_to_vertices(const Slic3r::Lines& lines, const std::vec
if (ii == 0) { if (ii == 0) {
// add a dummy vertex at the start, to separate the current line from the others // add a dummy vertex at the start, to separate the current line from the others
const Slic3r::Vec2f a = unscale(line.a).cast<float>(); const Slic3r::Vec2f a = unscale(line.a).cast<float>();
#if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
libvgcode::PathVertex vertex = { convert(Slic3r::Vec3f(a.x(), a.y(), top_z)), heights[i], widths[i], 0.0f, 0.0f,
0.0f, 0.0f, extrusion_role, EMoveType::Noop, 0, static_cast<uint32_t>(layer_id),
static_cast<uint8_t>(extruder_id), static_cast<uint8_t>(color_id), { 0.0f, 0.0f } };
#else
libvgcode::PathVertex vertex = { convert(Slic3r::Vec3f(a.x(), a.y(), top_z)), heights[i], widths[i], 0.0f, 0.0f, libvgcode::PathVertex vertex = { convert(Slic3r::Vec3f(a.x(), a.y(), top_z)), heights[i], widths[i], 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, extrusion_role, EMoveType::Noop, 0, static_cast<uint32_t>(layer_id), 0.0f, 0.0f, 0.0f, extrusion_role, EMoveType::Noop, 0, static_cast<uint32_t>(layer_id),
static_cast<uint8_t>(extruder_id), static_cast<uint8_t>(color_id), { 0.0f, 0.0f } }; static_cast<uint8_t>(extruder_id), static_cast<uint8_t>(color_id), { 0.0f, 0.0f } };
#endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #else
libvgcode::PathVertex vertex = { convert(Slic3r::Vec3f(a.x(), a.y(), top_z)), heights[i], widths[i], 0.0f, 0.0f,
0.0f, 0.0f, extrusion_role, EMoveType::Noop, 0, static_cast<uint32_t>(layer_id),
static_cast<uint8_t>(extruder_id), static_cast<uint8_t>(color_id), { 0.0f, 0.0f } };
#endif // ENABLE_COG_AND_TOOL_MARKERS
vertices.emplace_back(vertex); vertices.emplace_back(vertex);
// add the starting vertex of the segment // add the starting vertex of the segment
vertex.type = EMoveType::Extrude; vertex.type = EMoveType::Extrude;
@ -262,15 +262,15 @@ static void convert_lines_to_vertices(const Slic3r::Lines& lines, const std::vec
} }
// add the ending vertex of the segment // add the ending vertex of the segment
const Slic3r::Vec2f b = unscale(line.b).cast<float>(); const Slic3r::Vec2f b = unscale(line.b).cast<float>();
#if ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #if ENABLE_COG_AND_TOOL_MARKERS
const libvgcode::PathVertex vertex = { convert(Slic3r::Vec3f(b.x(), b.y(), top_z)), heights[i], widths[i], 0.0f, 0.0f,
0.0f, 0.0f, extrusion_role, EMoveType::Extrude, 0, static_cast<uint32_t>(layer_id),
static_cast<uint8_t>(extruder_id), static_cast<uint8_t>(color_id), { 0.0f, 0.0f } };
#else
const libvgcode::PathVertex vertex = { convert(Slic3r::Vec3f(b.x(), b.y(), top_z)), heights[i], widths[i], 0.0f, 0.0f, const libvgcode::PathVertex vertex = { convert(Slic3r::Vec3f(b.x(), b.y(), top_z)), heights[i], widths[i], 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, extrusion_role, EMoveType::Extrude, 0, static_cast<uint32_t>(layer_id), 0.0f, 0.0f, 0.0f, extrusion_role, EMoveType::Extrude, 0, static_cast<uint32_t>(layer_id),
static_cast<uint8_t>(extruder_id), static_cast<uint8_t>(color_id), { 0.0f, 0.0f } }; static_cast<uint8_t>(extruder_id), static_cast<uint8_t>(color_id), { 0.0f, 0.0f } };
#endif // ENABLE_NEW_GCODE_VIEWER_NO_COG_AND_TOOL_MARKERS #else
const libvgcode::PathVertex vertex = { convert(Slic3r::Vec3f(b.x(), b.y(), top_z)), heights[i], widths[i], 0.0f, 0.0f,
0.0f, 0.0f, extrusion_role, EMoveType::Extrude, 0, static_cast<uint32_t>(layer_id),
static_cast<uint8_t>(extruder_id), static_cast<uint8_t>(color_id), { 0.0f, 0.0f } };
#endif // ENABLE_COG_AND_TOOL_MARKERS
vertices.emplace_back(vertex); vertices.emplace_back(vertex);
} }
} }