mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-15 02:37:51 -06:00
Added imgui debug dialog for camera statistics
This commit is contained in:
parent
c5e4ada75b
commit
783a527109
4 changed files with 36 additions and 1 deletions
|
@ -13,6 +13,8 @@
|
||||||
#define ENABLE_RENDER_SELECTION_CENTER 0
|
#define ENABLE_RENDER_SELECTION_CENTER 0
|
||||||
// Shows an imgui dialog with render related data
|
// Shows an imgui dialog with render related data
|
||||||
#define ENABLE_RENDER_STATISTICS 0
|
#define ENABLE_RENDER_STATISTICS 0
|
||||||
|
// Shows an imgui dialog with camera related data
|
||||||
|
#define ENABLE_CAMERA_STATISTICS 1
|
||||||
|
|
||||||
|
|
||||||
//====================
|
//====================
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
#include "Camera.hpp"
|
#include "Camera.hpp"
|
||||||
#include "3DScene.hpp"
|
#include "3DScene.hpp"
|
||||||
|
#if ENABLE_CAMERA_STATISTICS
|
||||||
|
#include "GUI_App.hpp"
|
||||||
|
#endif // ENABLE_CAMERA_STATISTICS
|
||||||
|
|
||||||
#include <GL/glew.h>
|
#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(-m_theta, 1.0f, 0.0f, 0.0f)); // pitch
|
||||||
glsafe(::glRotatef(phi, 0.0f, 0.0f, 1.0f)); // yaw
|
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(::glTranslated(-m_target(0), -m_target(1), -m_target(2))); // target to origin
|
||||||
|
|
||||||
glsafe(::glGetDoublev(GL_MODELVIEW_MATRIX, m_view_matrix.data()));
|
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
|
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));
|
glsafe(::glMatrixMode(GL_PROJECTION));
|
||||||
|
|
|
@ -64,6 +64,10 @@ public:
|
||||||
void apply_view_matrix() const;
|
void apply_view_matrix() const;
|
||||||
void apply_projection(const BoundingBoxf3& box) const;
|
void apply_projection(const BoundingBoxf3& box) const;
|
||||||
|
|
||||||
|
#if ENABLE_CAMERA_STATISTICS
|
||||||
|
void debug_render() const;
|
||||||
|
#endif // ENABLE_CAMERA_STATISTICS
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void apply_ortho_projection(double x_min, double x_max, double y_min, double y_max, double z_min, double z_max) const;
|
void apply_ortho_projection(double x_min, double x_max, double y_min, double y_max, double z_min, double z_max) const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1700,6 +1700,10 @@ void GLCanvas3D::render()
|
||||||
imgui.end();
|
imgui.end();
|
||||||
#endif // ENABLE_RENDER_STATISTICS
|
#endif // ENABLE_RENDER_STATISTICS
|
||||||
|
|
||||||
|
#if ENABLE_CAMERA_STATISTICS
|
||||||
|
m_camera.debug_render();
|
||||||
|
#endif // ENABLE_CAMERA_STATISTICS
|
||||||
|
|
||||||
wxGetApp().imgui()->render();
|
wxGetApp().imgui()->render();
|
||||||
|
|
||||||
m_canvas->SwapBuffers();
|
m_canvas->SwapBuffers();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue