Center of gravity marker NOT rendered by the new visualization code

This commit is contained in:
enricoturri1966 2023-10-31 12:22:55 +01:00 committed by Lukas Matena
parent ddabc3312d
commit c1ca2097bb
13 changed files with 84 additions and 35 deletions

View File

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

View File

@ -192,27 +192,27 @@ void GCodeViewer::TBuffer::add_path(const GCodeProcessorResult::MoveVertex& move
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
void GCodeViewer::COG::render(bool fixed_screen_size)
#else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void GCodeViewer::COG::render()
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // ENABLE_NEW_GCODE_VIEWER
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
{
if (!m_visible)
return;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
fixed_screen_size = true;
init(fixed_screen_size);
#else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
init();
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // ENABLE_NEW_GCODE_VIEWER
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
GLShaderProgram* shader = wxGetApp().get_shader("toolpaths_cog");
@ -226,13 +226,13 @@ void GCodeViewer::COG::render()
const Camera& camera = wxGetApp().plater()->get_camera();
Transform3d model_matrix = Geometry::translation_transform(cog());
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
if (fixed_screen_size) {
#else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
if (m_fixed_size) {
if (m_fixed_screen_size) {
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // ENABLE_NEW_GCODE_VIEWER
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
const double inv_zoom = camera.get_inv_zoom();
model_matrix = model_matrix * Geometry::scale_transform(inv_zoom);
@ -1228,7 +1228,9 @@ void GCodeViewer::render()
libvgcode::Vec3f converted_tool_marker_position;
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);
#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_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.render(converted_view_matrix, converted_projetion_matrix);
@ -1266,6 +1268,7 @@ void GCodeViewer::render()
ImGuiWrapper& imgui = *Slic3r::GUI::wxGetApp().imgui();
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);
if (ImGui::BeginTable("Cog", 2)) {
@ -1277,6 +1280,7 @@ void GCodeViewer::render()
ImGui::EndTable();
}
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
imgui.checkbox("Tool marker fixed screen size", m_tool_marker_fixed_screen_size);
if (ImGui::BeginTable("Tool", 2)) {
@ -4822,7 +4826,10 @@ void GCodeViewer::render_legend(float& legend_height)
if (imgui.draw_radio_button(name, 1.5f * icon_size, active, draw_callback)) {
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
m_new_viewer.toggle_option_visibility((libvgcode::EOptionType)type);
#if ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
if (type != Preview::OptionType::CenterOfGravity)
#endif // ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
m_new_viewer.toggle_option_visibility((libvgcode::EOptionType)type);
#endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
unsigned int new_flags = set_flag(flags, flag, !active);

View File

@ -397,29 +397,29 @@ class GCodeViewer
GLModel m_model;
bool m_visible{ false };
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if !ENABLE_NEW_GCODE_VIEWER
#if ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// whether or not to render the model with fixed screen size
bool m_fixed_size{ true };
bool m_fixed_screen_size{ true };
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // !ENABLE_NEW_GCODE_VIEWER
#endif // ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
double m_total_mass{ 0.0 };
Vec3d m_position{ Vec3d::Zero() };
Vec3d m_total_position{ Vec3d::Zero() };
public:
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
void render(bool fixed_screen_size);
#else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void render();
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // ENABLE_NEW_GCODE_VIEWER
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void reset() {
m_position = Vec3d::Zero();
m_total_position = Vec3d::Zero();
m_total_mass = 0.0;
}
@ -428,33 +428,33 @@ class GCodeViewer
void add_segment(const Vec3d& v1, const Vec3d& v2, double mass) {
assert(mass > 0.0);
m_position += mass * 0.5 * (v1 + v2);
m_total_position += mass * 0.5 * (v1 + v2);
m_total_mass += mass;
}
Vec3d cog() const { return (m_total_mass > 0.0) ? (Vec3d)(m_position / m_total_mass) : Vec3d::Zero(); }
Vec3d cog() const { return (m_total_mass > 0.0) ? (Vec3d)(m_total_position / m_total_mass) : Vec3d::Zero(); }
private:
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
void init(bool fixed_screen_size) {
#else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void init() {
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // ENABLE_NEW_GCODE_VIEWER
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
if (m_model.is_initialized())
return;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
const float radius = fixed_screen_size ? 10.0f : 1.0f;
#else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
const float radius = m_fixed_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_NO_COG_AND_TOOL_MARKERS
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
m_model.init_from(smooth_sphere(32, radius));
}
@ -960,13 +960,13 @@ public:
void reset();
void render();
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
void render_cog() { m_cog.render(m_cog_marker_fixed_screen_size); }
#else
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void render_cog() { m_cog.render(); }
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // ENABLE_NEW_GCODE_VIEWER
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
bool has_data() const { return !m_roles.empty(); }
@ -1047,8 +1047,10 @@ public:
#if ENABLE_NEW_GCODE_VIEWER
bool use_gcode_viewer_2() const { return m_use_new_viewer; }
void toggle_use_gcode_viewer_2() { m_use_new_viewer = !m_use_new_viewer; }
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
float get_cog_marker_scale_factor() const { return m_new_viewer.get_cog_marker_scale_factor(); }
void set_cog_marker_scale_factor(float factor) { return m_new_viewer.set_cog_marker_scale_factor(factor); }
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
#endif // ENABLE_NEW_GCODE_VIEWER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

View File

@ -1948,7 +1948,7 @@ void GLCanvas3D::render()
_render_selection_center();
#endif // ENABLE_RENDER_SELECTION_CENTER
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#if ENABLE_NEW_GCODE_VIEWER
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
if (!m_main_toolbar.is_enabled()) {
if (!m_gcode_viewer.use_gcode_viewer_2())
_render_gcode_cog();
@ -1958,7 +1958,7 @@ void GLCanvas3D::render()
if (!m_main_toolbar.is_enabled())
_render_gcode_cog();
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#endif // ENABLE_NEW_GCODE_VIEWER
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// we need to set the mouse's scene position here because the depth buffer

View File

@ -17,7 +17,7 @@
//################################################################################################################################
// PrusaSlicer development only -> !!!TO BE REMOVED!!!
#if ENABLE_NEW_GCODE_VIEWER
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
//################################################################################################################################
namespace libvgcode {
@ -167,5 +167,5 @@ Vec3f CogMarker::get_position() const
//################################################################################################################################
// PrusaSlicer development only -> !!!TO BE REMOVED!!!
#endif // ENABLE_NEW_GCODE_VIEWER
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
//################################################################################################################################

View File

@ -7,7 +7,7 @@
//################################################################################################################################
// PrusaSlicer development only -> !!!TO BE REMOVED!!!
#if ENABLE_NEW_GCODE_VIEWER
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
//################################################################################################################################
#include "Types.hpp"
@ -64,7 +64,7 @@ private:
//################################################################################################################################
// PrusaSlicer development only -> !!!TO BE REMOVED!!!
#endif // ENABLE_NEW_GCODE_VIEWER
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
//################################################################################################################################
#endif // VGCODE_COGMARKER_HPP

View File

@ -35,7 +35,9 @@ struct Settings
{ EOptionType::ColorChanges, false },
{ EOptionType::PausePrints, false },
{ EOptionType::CustomGCodes, false },
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
{ EOptionType::CenterOfGravity, false },
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
{ EOptionType::Shells, false },
{ EOptionType::ToolMarker, true }
} };

View File

@ -205,6 +205,7 @@ static const char* Options_Fragment_Shader =
" fragmentColor = vec4(color, 1.0);\n"
"}\n";
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
static const char* Cog_Marker_Vertex_Shader =
"#version 150\n"
"const vec3 light_top_dir = vec3(-0.4574957, 0.4574957, 0.7624929);\n"
@ -251,6 +252,7 @@ static const char* Cog_Marker_Fragment_Shader =
" vec3 color = delta.x * delta.y * delta.z > 0.0 ? BLACK : WHITE;\n"
" out_color = intensity * vec4(color, 1.0);\n"
"}\n";
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
static const char* Tool_Marker_Vertex_Shader =
"#version 150\n"

View File

@ -88,7 +88,9 @@ enum class EOptionType : uint8_t
ColorChanges,
PausePrints,
CustomGCodes,
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
CenterOfGravity,
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
Shells,
ToolMarker,
COUNT

View File

@ -118,6 +118,7 @@ void Viewer::set_view_current_range(uint32_t min, uint32_t max)
m_impl.set_view_current_range(min, max);
}
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
Vec3f Viewer::get_cog_position() const
{
return m_impl.get_cog_marker_position();
@ -132,6 +133,7 @@ void Viewer::set_cog_marker_scale_factor(float 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
{

View File

@ -65,6 +65,7 @@ public:
//
void set_view_current_range(uint32_t min, uint32_t max);
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
//
// Returns the position of the center of gravity of the toolpaths.
// It does not take in account extrusions of type:
@ -78,6 +79,7 @@ public:
float get_cog_marker_scale_factor() const;
void set_cog_marker_scale_factor(float factor);
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
const Vec3f& get_tool_marker_position() const;
void set_tool_marker_position(const Vec3f& position);

View File

@ -505,6 +505,7 @@ void ViewerImpl::init()
m_option_template.init(16);
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
// cog marker shader
m_cog_marker_shader_id = init_shader("cog_marker", Cog_Marker_Vertex_Shader, Cog_Marker_Fragment_Shader);
@ -519,6 +520,7 @@ void ViewerImpl::init()
m_uni_cog_marker_projection_matrix != -1);
m_cog_marker.init(32, 1.0f);
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
// tool marker shader
m_tool_marker_shader_id = init_shader("tool_marker", Tool_Marker_Vertex_Shader, Tool_Marker_Fragment_Shader);
@ -573,7 +575,9 @@ void ViewerImpl::load(const Slic3r::GCodeProcessorResult& gcode_result, const st
last_result_id = gcode_result.id;
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
m_cog_marker.reset();
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
reset();
@ -633,6 +637,7 @@ void ViewerImpl::load(const Slic3r::GCodeProcessorResult& gcode_result, const st
m_vertices.emplace_back(vertex);
m_layers.update(static_cast<uint32_t>(curr.layer_id), static_cast<uint32_t>(m_vertices.size()));
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
// updates calculation for center of gravity
if (curr_type == EMoveType::Extrude &&
curr_role != EGCodeExtrusionRole::Skirt &&
@ -644,6 +649,7 @@ void ViewerImpl::load(const Slic3r::GCodeProcessorResult& gcode_result, const st
const Vec3f prev_pos = toVec3f(prev.position);
m_cog_marker.update(0.5f * (curr_pos + prev_pos), curr.mm3_per_mm * length(curr_pos - prev_pos));
}
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
}
m_vertices_map.shrink_to_fit();
m_vertices.shrink_to_fit();
@ -858,8 +864,10 @@ void ViewerImpl::render(const Mat4x4f& view_matrix, const Mat4x4f& projection_ma
render_options(view_matrix, projection_matrix);
if (m_settings.options_visibility.at(EOptionType::ToolMarker))
render_tool_marker(view_matrix, projection_matrix);
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
if (m_settings.options_visibility.at(EOptionType::CenterOfGravity))
render_cog_marker(view_matrix, projection_matrix);
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
#if ENABLE_NEW_GCODE_VIEWER_DEBUG
render_debug_window();
@ -1025,6 +1033,7 @@ const std::array<std::vector<float>, static_cast<size_t>(ETimeMode::COUNT)>& Vie
return m_layers_times;
}
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
Vec3f ViewerImpl::get_cog_marker_position() const
{
return m_cog_marker.get_position();
@ -1034,6 +1043,7 @@ float ViewerImpl::get_cog_marker_scale_factor() const
{
return m_cog_marker_scale_factor;
}
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
const Vec3f& ViewerImpl::get_tool_marker_position() const
{
@ -1060,10 +1070,12 @@ float ViewerImpl::get_tool_marker_alpha() const
return m_tool_marker.get_alpha();
}
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
void ViewerImpl::set_cog_marker_scale_factor(float factor)
{
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)
{
@ -1390,6 +1402,7 @@ void ViewerImpl::render_options(const Mat4x4f& view_matrix, const Mat4x4f& proje
glsafe(glActiveTexture(curr_active_texture));
}
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
void ViewerImpl::render_cog_marker(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix)
{
if (m_cog_marker_shader_id == 0)
@ -1420,6 +1433,7 @@ void ViewerImpl::render_cog_marker(const Mat4x4f& view_matrix, const Mat4x4f& pr
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)
{
@ -1429,8 +1443,8 @@ void ViewerImpl::render_tool_marker(const Mat4x4f& view_matrix, const Mat4x4f& p
int curr_shader;
glsafe(glGetIntegerv(GL_CURRENT_PROGRAM, &curr_shader));
const bool curr_cull_face = glIsEnabled(GL_CULL_FACE);
int curr_depth_mask;
glsafe(glGetIntegerv(GL_DEPTH_WRITEMASK, &curr_depth_mask));
GLboolean curr_depth_mask;
glsafe(glGetBooleanv(GL_DEPTH_WRITEMASK, &curr_depth_mask));
const bool curr_blend = glIsEnabled(GL_BLEND);
glcheck();
int curr_blend_func;
@ -1458,8 +1472,9 @@ void ViewerImpl::render_tool_marker(const Mat4x4f& view_matrix, const Mat4x4f& p
glsafe(glBlendFunc(GL_SRC_ALPHA, curr_blend_func));
if (!curr_blend)
glsafe(glDisable(GL_BLEND));
glsafe(glDepthMask(curr_depth_mask));
if (!curr_cull_face)
if (curr_depth_mask == GL_TRUE)
glsafe(glDepthMask(GL_TRUE));
if (curr_cull_face)
glsafe(glEnable(GL_CULL_FACE));
glsafe(glUseProgram(curr_shader));
@ -1535,6 +1550,7 @@ void ViewerImpl::render_debug_window()
ImGui::EndTable();
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
ImGui::Separator();
if (ImGui::BeginTable("Cog", 2)) {
@ -1547,6 +1563,7 @@ void ViewerImpl::render_debug_window()
ImGui::EndTable();
}
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
ImGui::Separator();

View File

@ -13,7 +13,9 @@
#include "Settings.hpp"
#include "SegmentTemplate.hpp"
#include "OptionTemplate.hpp"
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
#include "CogMarker.hpp"
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
#include "ToolMarker.hpp"
#include "PathVertex.hpp"
#include "Bitset.hpp"
@ -105,8 +107,10 @@ public:
// Properties getters
//
const std::array<std::vector<float>, static_cast<size_t>(ETimeMode::COUNT)>& get_layers_times() const;
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
Vec3f get_cog_marker_position() const;
float get_cog_marker_scale_factor() const;
#endif // !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
const Vec3f& get_tool_marker_position() const;
float get_tool_marker_offset_z() const;
float get_tool_marker_scale_factor() const;
@ -116,7 +120,9 @@ public:
//
// Properties setters
//
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
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_offset_z(float offset_z);
void set_tool_marker_scale_factor(float factor);
@ -140,11 +146,13 @@ private:
//
OptionTemplate m_option_template;
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
//
// The OpenGL element used to represent the center of gravity
//
CogMarker m_cog_marker;
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
@ -213,6 +221,7 @@ private:
int m_uni_options_colors_tex_id{ -1 };
int m_uni_options_segment_index_tex_id{ -1 };
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
//
// Cache for OpenGL uniforms id for cog marker shader
//
@ -220,6 +229,7 @@ private:
int m_uni_cog_marker_scale_factor{ -1 };
int m_uni_cog_marker_view_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
@ -262,7 +272,9 @@ private:
Color select_color(const PathVertex& v) const;
void render_segments(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix, const Vec3f& camera_position);
void render_options(const Mat4x4f& view_matrix, const Mat4x4f& projection_matrix);
#if !ENABLE_NEW_GCODE_NO_COG_AND_TOOL_MARKERS
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);
#if ENABLE_NEW_GCODE_VIEWER_DEBUG