diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index 3375a282b..fdc5ef7d2 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -13,6 +13,8 @@ #define ENABLE_RENDER_SELECTION_CENTER 0 // Shows an imgui dialog with render related data #define ENABLE_RENDER_STATISTICS 0 +// Shows an imgui dialog with camera related data +#define ENABLE_CAMERA_STATISTICS 1 //==================== diff --git a/src/slic3r/GUI/Camera.cpp b/src/slic3r/GUI/Camera.cpp index 5f7a7ce4b..a9edb7626 100644 --- a/src/slic3r/GUI/Camera.cpp +++ b/src/slic3r/GUI/Camera.cpp @@ -2,6 +2,9 @@ #include "Camera.hpp" #include "3DScene.hpp" +#if ENABLE_CAMERA_STATISTICS +#include "GUI_App.hpp" +#endif // ENABLE_CAMERA_STATISTICS #include <GL/glew.h> @@ -109,7 +112,6 @@ void Camera::apply_view_matrix() const glsafe(::glRotatef(-m_theta, 1.0f, 0.0f, 0.0f)); // pitch glsafe(::glRotatef(phi, 0.0f, 0.0f, 1.0f)); // yaw - glsafe(::glTranslated(-m_target(0), -m_target(1), -m_target(2))); // target to origin glsafe(::glGetDoublev(GL_MODELVIEW_MATRIX, m_view_matrix.data())); @@ -144,6 +146,29 @@ void Camera::apply_projection(const BoundingBoxf3& box) const } } +#if ENABLE_CAMERA_STATISTICS +void Camera::debug_render() const +{ + ImGuiWrapper& imgui = *wxGetApp().imgui(); + imgui.set_next_window_bg_alpha(0.5f); + imgui.begin(std::string("Camera statistics"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse); + + Vec3f position = get_position().cast<float>(); + Vec3f target = m_target.cast<float>(); + Vec3f forward = get_dir_forward().cast<float>(); + Vec3f right = get_dir_right().cast<float>(); + Vec3f up = get_dir_up().cast<float>(); + + ImGui::InputFloat3("Position", position.data(), "%.6f", ImGuiInputTextFlags_ReadOnly); + ImGui::InputFloat3("Target", target.data(), "%.6f", ImGuiInputTextFlags_ReadOnly); + ImGui::Separator(); + ImGui::InputFloat3("Forward", forward.data(), "%.6f", ImGuiInputTextFlags_ReadOnly); + ImGui::InputFloat3("Right", right.data(), "%.6f", ImGuiInputTextFlags_ReadOnly); + ImGui::InputFloat3("Up", up.data(), "%.6f", ImGuiInputTextFlags_ReadOnly); + imgui.end(); +} +#endif // ENABLE_CAMERA_STATISTICS + void Camera::apply_ortho_projection(double x_min, double x_max, double y_min, double y_max, double z_min, double z_max) const { glsafe(::glMatrixMode(GL_PROJECTION)); diff --git a/src/slic3r/GUI/Camera.hpp b/src/slic3r/GUI/Camera.hpp index f0d22fd67..1f217be28 100644 --- a/src/slic3r/GUI/Camera.hpp +++ b/src/slic3r/GUI/Camera.hpp @@ -64,6 +64,10 @@ public: void apply_view_matrix() const; void apply_projection(const BoundingBoxf3& box) const; +#if ENABLE_CAMERA_STATISTICS + void debug_render() const; +#endif // ENABLE_CAMERA_STATISTICS + private: void apply_ortho_projection(double x_min, double x_max, double y_min, double y_max, double z_min, double z_max) const; }; diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index ed9c1bd60..f01d1a3ad 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1700,6 +1700,10 @@ void GLCanvas3D::render() imgui.end(); #endif // ENABLE_RENDER_STATISTICS +#if ENABLE_CAMERA_STATISTICS + m_camera.debug_render(); +#endif // ENABLE_CAMERA_STATISTICS + wxGetApp().imgui()->render(); m_canvas->SwapBuffers();