Tool marker NOT rendered by the new visualization code

This commit is contained in:
enricoturri1966 2023-10-31 13:06:05 +01:00 committed by Lukas Matena
parent c1ca2097bb
commit 5c06f05cf9
16 changed files with 52 additions and 47 deletions

View File

@ -61,7 +61,7 @@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#define ENABLE_NEW_GCODE_VIEWER 1 #define ENABLE_NEW_GCODE_VIEWER 1
#define ENABLE_NEW_GCODE_VIEWER_DEBUG (1 && ENABLE_NEW_GCODE_VIEWER) #define ENABLE_NEW_GCODE_VIEWER_DEBUG (0 && ENABLE_NEW_GCODE_VIEWER)
#define ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS (1 && ENABLE_NEW_GCODE_VIEWER) #define ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS (1 && ENABLE_NEW_GCODE_VIEWER)
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

View File

@ -730,7 +730,7 @@ void GCodeViewer::SequentialView::GCodeWindow::render(float top, float bottom, s
} }
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
void GCodeViewer::SequentialView::render(float legend_height, bool show_marker) void GCodeViewer::SequentialView::render(float legend_height, bool show_marker)
{ {
if (show_marker) if (show_marker)
@ -739,7 +739,7 @@ void GCodeViewer::SequentialView::render(float legend_height, bool show_marker)
void GCodeViewer::SequentialView::render(float legend_height) void GCodeViewer::SequentialView::render(float legend_height)
{ {
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // ENABLE_NEW_GCODE_VIEWER #endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
marker.render(); marker.render();
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ -1225,14 +1225,14 @@ void GCodeViewer::render()
std::memcpy(converted_view_matrix.data(), view_matrix.data(), 16 * sizeof(float)); std::memcpy(converted_view_matrix.data(), view_matrix.data(), 16 * sizeof(float));
libvgcode::Mat4x4f converted_projetion_matrix; libvgcode::Mat4x4f converted_projetion_matrix;
std::memcpy(converted_projetion_matrix.data(), projection_matrix.data(), 16 * sizeof(float)); std::memcpy(converted_projetion_matrix.data(), projection_matrix.data(), 16 * sizeof(float));
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
libvgcode::Vec3f converted_tool_marker_position; libvgcode::Vec3f converted_tool_marker_position;
std::memcpy(converted_tool_marker_position.data(), m_sequential_view.current_position.data(), 3 * sizeof(float)); std::memcpy(converted_tool_marker_position.data(), m_sequential_view.current_position.data(), 3 * sizeof(float));
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
m_new_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_new_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);
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
m_new_viewer.set_tool_marker_position(converted_tool_marker_position); m_new_viewer.set_tool_marker_position(converted_tool_marker_position);
m_new_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_new_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_NO_COG_AND_TOOL_MARKERS
m_new_viewer.render(converted_view_matrix, converted_projetion_matrix); m_new_viewer.render(converted_view_matrix, converted_projetion_matrix);
} }
else else
@ -1248,13 +1248,13 @@ void GCodeViewer::render()
m_sequential_view.marker.set_world_offset(m_sequential_view.current_offset); m_sequential_view.marker.set_world_offset(m_sequential_view.current_offset);
m_sequential_view.marker.set_z_offset(m_z_offset); m_sequential_view.marker.set_z_offset(m_z_offset);
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
m_sequential_view.render(legend_height, !m_use_new_viewer); m_sequential_view.render(legend_height, !m_use_new_viewer);
#else #else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
m_sequential_view.render(legend_height); m_sequential_view.render(legend_height);
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // ENABLE_NEW_GCODE_VIEWER #endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
} }
} }
@ -1263,12 +1263,11 @@ void GCodeViewer::render()
#endif // ENABLE_GCODE_VIEWER_STATISTICS #endif // ENABLE_GCODE_VIEWER_STATISTICS
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER_DEBUG #if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
if (m_use_new_viewer) { if (m_use_new_viewer) {
ImGuiWrapper& imgui = *Slic3r::GUI::wxGetApp().imgui(); ImGuiWrapper& imgui = *Slic3r::GUI::wxGetApp().imgui();
imgui.begin(std::string("LibVGCode Viewer Controller"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse); imgui.begin(std::string("LibVGCode Viewer Controller"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
imgui.checkbox("Cog marker fixed screen size", m_cog_marker_fixed_screen_size); imgui.checkbox("Cog marker fixed screen size", m_cog_marker_fixed_screen_size);
if (ImGui::BeginTable("Cog", 2)) { if (ImGui::BeginTable("Cog", 2)) {
@ -1280,7 +1279,6 @@ void GCodeViewer::render()
ImGui::EndTable(); ImGui::EndTable();
} }
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
imgui.checkbox("Tool marker fixed screen size", m_tool_marker_fixed_screen_size); imgui.checkbox("Tool marker fixed screen size", m_tool_marker_fixed_screen_size);
if (ImGui::BeginTable("Tool", 2)) { if (ImGui::BeginTable("Tool", 2)) {
@ -1296,7 +1294,7 @@ void GCodeViewer::render()
imgui.end(); imgui.end();
} }
#endif // ENABLE_NEW_GCODE_VIEWER_DEBUG #endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
} }
@ -4827,7 +4825,7 @@ void GCodeViewer::render_legend(float& legend_height)
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if ENABLE_NEW_GCODE_VIEWER
#if ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
if (type != Preview::OptionType::CenterOfGravity) if (type != Preview::OptionType::CenterOfGravity && type != Preview::OptionType::ToolMarker && type != Preview::OptionType::Shells)
#endif // ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #endif // ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
m_new_viewer.toggle_option_visibility((libvgcode::EOptionType)type); m_new_viewer.toggle_option_visibility((libvgcode::EOptionType)type);
#endif // ENABLE_NEW_GCODE_VIEWER #endif // ENABLE_NEW_GCODE_VIEWER

View File

@ -813,13 +813,13 @@ public:
std::vector<unsigned int> gcode_ids; std::vector<unsigned int> gcode_ids;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER #if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
void render(float legend_height, bool show_marker); void render(float legend_height, bool show_marker);
#else #else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void render(float legend_height); void render(float legend_height);
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // ENABLE_NEW_GCODE_VIEWER #endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
}; };

View File

@ -12,8 +12,6 @@
#include "Types.hpp" #include "Types.hpp"
#include <cstdint>
namespace libvgcode { namespace libvgcode {
class CogMarker class CogMarker

View File

@ -12,8 +12,6 @@
#include "Types.hpp" #include "Types.hpp"
#include <cstdint>
namespace libvgcode { namespace libvgcode {
struct PathVertex struct PathVertex

View File

@ -29,7 +29,10 @@ public:
bool operator != (const Range& other) const; bool operator != (const Range& other) const;
private: private:
// [0] = min, [1] = max //
// [0] = min
// [1] = max
//
std::array<uint32_t, 2> m_range{ 0, 0 }; std::array<uint32_t, 2> m_range{ 0, 0 };
}; };

View File

@ -37,9 +37,9 @@ struct Settings
{ EOptionType::CustomGCodes, false }, { EOptionType::CustomGCodes, false },
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
{ EOptionType::CenterOfGravity, false }, { EOptionType::CenterOfGravity, false },
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
{ EOptionType::Shells, false }, { EOptionType::Shells, false },
{ EOptionType::ToolMarker, true } { EOptionType::ToolMarker, true }
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
} }; } };
std::map<EGCodeExtrusionRole, bool> extrusion_roles_visibility{ { std::map<EGCodeExtrusionRole, bool> extrusion_roles_visibility{ {

View File

@ -252,7 +252,6 @@ static const char* Cog_Marker_Fragment_Shader =
" vec3 color = delta.x * delta.y * delta.z > 0.0 ? BLACK : WHITE;\n" " vec3 color = delta.x * delta.y * delta.z > 0.0 ? BLACK : WHITE;\n"
" out_color = intensity * vec4(color, 1.0);\n" " out_color = intensity * vec4(color, 1.0);\n"
"}\n"; "}\n";
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
static const char* Tool_Marker_Vertex_Shader = static const char* Tool_Marker_Vertex_Shader =
"#version 150\n" "#version 150\n"
@ -294,6 +293,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_NO_COG_AND_TOOL_MARKERS
} // namespace libvgcode } // namespace libvgcode

View File

@ -15,7 +15,7 @@
//################################################################################################################################ //################################################################################################################################
// PrusaSlicer development only -> !!!TO BE REMOVED!!! // PrusaSlicer development only -> !!!TO BE REMOVED!!!
#if ENABLE_NEW_GCODE_VIEWER #if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
//################################################################################################################################ //################################################################################################################################
namespace libvgcode { namespace libvgcode {
@ -208,5 +208,5 @@ void ToolMarker::set_alpha(float alpha)
//################################################################################################################################ //################################################################################################################################
// PrusaSlicer development only -> !!!TO BE REMOVED!!! // PrusaSlicer development only -> !!!TO BE REMOVED!!!
#endif // ENABLE_NEW_GCODE_VIEWER #endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
//################################################################################################################################ //################################################################################################################################

View File

@ -7,13 +7,11 @@
//################################################################################################################################ //################################################################################################################################
// PrusaSlicer development only -> !!!TO BE REMOVED!!! // PrusaSlicer development only -> !!!TO BE REMOVED!!!
#if ENABLE_NEW_GCODE_VIEWER #if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
//################################################################################################################################ //################################################################################################################################
#include "Types.hpp" #include "Types.hpp"
#include <cstdint>
namespace libvgcode { namespace libvgcode {
class ToolMarker class ToolMarker
@ -57,7 +55,7 @@ private:
//################################################################################################################################ //################################################################################################################################
// PrusaSlicer development only -> !!!TO BE REMOVED!!! // PrusaSlicer development only -> !!!TO BE REMOVED!!!
#endif // ENABLE_NEW_GCODE_VIEWER #endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
//################################################################################################################################ //################################################################################################################################
#endif // VGCODE_TOOLMARKER_HPP #endif // VGCODE_TOOLMARKER_HPP

View File

@ -11,14 +11,27 @@
//################################################################################################################################ //################################################################################################################################
#include <array> #include <array>
#include <cstdint>
namespace libvgcode { namespace libvgcode {
static constexpr float PI = 3.141592f; static constexpr float PI = 3.141592f;
using Vec3f = std::array<float, 3>; using Vec3f = std::array<float, 3>;
// 4 by 4 square matrix with column-major order //
// 4 by 4 square matrix with column-major order:
// | a[0] a[4] a[8] a[12] |
// | a[1] a[5] a[9] a[13] |
// | a[2] a[6] a[10] a[14] |
// | a[3] a[7] a[11] a[15] |
//
using Mat4x4f = std::array<float, 16>; using Mat4x4f = std::array<float, 16>;
//
// [0] = red
// [1] = green
// [2] = blue
// values should belong to [0..1]
//
using Color = std::array<float, 3>; using Color = std::array<float, 3>;
// Alias for GCodeViewer::EViewType defined into GCodeViewer.hpp // Alias for GCodeViewer::EViewType defined into GCodeViewer.hpp
@ -90,9 +103,9 @@ enum class EOptionType : uint8_t
CustomGCodes, CustomGCodes,
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
CenterOfGravity, CenterOfGravity,
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
Shells, Shells,
ToolMarker, ToolMarker,
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
COUNT COUNT
}; };

View File

@ -12,7 +12,6 @@
#include "Types.hpp" #include "Types.hpp"
#include <cstdint>
#include <vector> #include <vector>
namespace libvgcode { namespace libvgcode {

View File

@ -133,7 +133,6 @@ void Viewer::set_cog_marker_scale_factor(float factor)
{ {
m_impl.set_cog_marker_scale_factor(factor); m_impl.set_cog_marker_scale_factor(factor);
} }
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
const Vec3f& Viewer::get_tool_marker_position() const const Vec3f& Viewer::get_tool_marker_position() const
{ {
@ -174,6 +173,7 @@ 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_NO_COG_AND_TOOL_MARKERS
} // namespace libvgcode } // namespace libvgcode

View File

@ -79,7 +79,6 @@ public:
float get_cog_marker_scale_factor() const; float get_cog_marker_scale_factor() const;
void set_cog_marker_scale_factor(float factor); void set_cog_marker_scale_factor(float factor);
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
const Vec3f& get_tool_marker_position() const; const Vec3f& get_tool_marker_position() const;
void set_tool_marker_position(const Vec3f& position); void set_tool_marker_position(const Vec3f& position);
@ -92,6 +91,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_NO_COG_AND_TOOL_MARKERS
private: private:
ViewerImpl m_impl; ViewerImpl m_impl;

View File

@ -520,7 +520,6 @@ void ViewerImpl::init()
m_uni_cog_marker_projection_matrix != -1); m_uni_cog_marker_projection_matrix != -1);
m_cog_marker.init(32, 1.0f); m_cog_marker.init(32, 1.0f);
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
// tool marker shader // tool marker shader
m_tool_marker_shader_id = init_shader("tool_marker", Tool_Marker_Vertex_Shader, Tool_Marker_Fragment_Shader); m_tool_marker_shader_id = init_shader("tool_marker", Tool_Marker_Vertex_Shader, Tool_Marker_Fragment_Shader);
@ -539,6 +538,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_NO_COG_AND_TOOL_MARKERS
} }
void ViewerImpl::load(const Slic3r::GCodeProcessorResult& gcode_result, const std::vector<std::string>& str_tool_colors) void ViewerImpl::load(const Slic3r::GCodeProcessorResult& gcode_result, const std::vector<std::string>& str_tool_colors)
@ -862,9 +862,9 @@ void ViewerImpl::render(const Mat4x4f& view_matrix, const Mat4x4f& projection_ma
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_NO_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 !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
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_NO_COG_AND_TOOL_MARKERS #endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
@ -1043,7 +1043,6 @@ float ViewerImpl::get_cog_marker_scale_factor() const
{ {
return m_cog_marker_scale_factor; return m_cog_marker_scale_factor;
} }
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
const Vec3f& ViewerImpl::get_tool_marker_position() const const Vec3f& ViewerImpl::get_tool_marker_position() const
{ {
@ -1070,12 +1069,10 @@ float ViewerImpl::get_tool_marker_alpha() const
return m_tool_marker.get_alpha(); return m_tool_marker.get_alpha();
} }
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
void ViewerImpl::set_cog_marker_scale_factor(float factor) void ViewerImpl::set_cog_marker_scale_factor(float factor)
{ {
m_cog_marker_scale_factor = std::max(factor, 0.001f); m_cog_marker_scale_factor = std::max(factor, 0.001f);
} }
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
void ViewerImpl::set_tool_marker_position(const Vec3f& position) void ViewerImpl::set_tool_marker_position(const Vec3f& position)
{ {
@ -1101,6 +1098,7 @@ void ViewerImpl::set_tool_marker_alpha(float alpha)
{ {
m_tool_marker.set_alpha(alpha); m_tool_marker.set_alpha(alpha);
} }
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
static void delete_textures(unsigned int& id) static void delete_textures(unsigned int& id)
{ {
@ -1433,7 +1431,6 @@ void ViewerImpl::render_cog_marker(const Mat4x4f& view_matrix, const Mat4x4f& pr
glsafe(glUseProgram(curr_shader)); glsafe(glUseProgram(curr_shader));
} }
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
void ViewerImpl::render_tool_marker(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix) void ViewerImpl::render_tool_marker(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix)
{ {
@ -1479,6 +1476,7 @@ void ViewerImpl::render_tool_marker(const Mat4x4f& view_matrix, const Mat4x4f& p
glsafe(glUseProgram(curr_shader)); glsafe(glUseProgram(curr_shader));
} }
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
#if ENABLE_NEW_GCODE_VIEWER_DEBUG #if ENABLE_NEW_GCODE_VIEWER_DEBUG
void ViewerImpl::render_debug_window() void ViewerImpl::render_debug_window()
@ -1563,7 +1561,6 @@ void ViewerImpl::render_debug_window()
ImGui::EndTable(); ImGui::EndTable();
} }
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
ImGui::Separator(); ImGui::Separator();
@ -1601,6 +1598,7 @@ void ViewerImpl::render_debug_window()
ImGui::EndTable(); ImGui::EndTable();
} }
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
} }
imgui.end(); imgui.end();

View File

@ -15,8 +15,8 @@
#include "OptionTemplate.hpp" #include "OptionTemplate.hpp"
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
#include "CogMarker.hpp" #include "CogMarker.hpp"
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
#include "ToolMarker.hpp" #include "ToolMarker.hpp"
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
#include "PathVertex.hpp" #include "PathVertex.hpp"
#include "Bitset.hpp" #include "Bitset.hpp"
#include "ColorRange.hpp" #include "ColorRange.hpp"
@ -110,24 +110,24 @@ public:
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
Vec3f get_cog_marker_position() const; Vec3f get_cog_marker_position() const;
float get_cog_marker_scale_factor() const; float get_cog_marker_scale_factor() const;
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
const Vec3f& get_tool_marker_position() const; const Vec3f& get_tool_marker_position() const;
float get_tool_marker_offset_z() const; float get_tool_marker_offset_z() const;
float get_tool_marker_scale_factor() const; float get_tool_marker_scale_factor() const;
const Color& get_tool_marker_color() const; const Color& get_tool_marker_color() const;
float get_tool_marker_alpha() const; float get_tool_marker_alpha() const;
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
// //
// Properties setters // Properties setters
// //
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
void set_cog_marker_scale_factor(float factor); void set_cog_marker_scale_factor(float factor);
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
void set_tool_marker_position(const Vec3f& position); void set_tool_marker_position(const Vec3f& position);
void set_tool_marker_offset_z(float offset_z); void set_tool_marker_offset_z(float offset_z);
void set_tool_marker_scale_factor(float factor); void set_tool_marker_scale_factor(float factor);
void set_tool_marker_color(const Color& color); void set_tool_marker_color(const Color& color);
void set_tool_marker_alpha(float size); void set_tool_marker_alpha(float size);
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
private: private:
Settings m_settings; Settings m_settings;
@ -152,13 +152,13 @@ private:
// //
CogMarker m_cog_marker; CogMarker m_cog_marker;
float m_cog_marker_scale_factor{ 1.0f }; float m_cog_marker_scale_factor{ 1.0f };
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
// //
// The OpenGL element used to represent the tool nozzle // The OpenGL element used to represent the tool nozzle
// //
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_NO_COG_AND_TOOL_MARKERS
// //
// cpu buffer to store vertices // cpu buffer to store vertices
@ -229,7 +229,6 @@ private:
int m_uni_cog_marker_scale_factor{ -1 }; int m_uni_cog_marker_scale_factor{ -1 };
int m_uni_cog_marker_view_matrix{ -1 }; int m_uni_cog_marker_view_matrix{ -1 };
int m_uni_cog_marker_projection_matrix{ -1 }; int m_uni_cog_marker_projection_matrix{ -1 };
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
// //
// Cache for OpenGL uniforms id for tool marker shader // Cache for OpenGL uniforms id for tool marker shader
@ -239,6 +238,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_NO_COG_AND_TOOL_MARKERS
// //
// gpu buffers to store positions // gpu buffers to store positions
@ -274,8 +274,8 @@ private:
void render_options(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix); void render_options(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix);
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS #if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
void render_cog_marker(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix); void render_cog_marker(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix);
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
void render_tool_marker(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix); void render_tool_marker(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix);
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
#if ENABLE_NEW_GCODE_VIEWER_DEBUG #if ENABLE_NEW_GCODE_VIEWER_DEBUG
// Debug // Debug