mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 09:17:52 -06:00
Generate gizmos' tooltip on demand
This commit is contained in:
parent
ffe404fc5b
commit
a0ed240af1
10 changed files with 83 additions and 78 deletions
|
@ -31,6 +31,22 @@ GLGizmoMove3D::~GLGizmoMove3D()
|
|||
::gluDeleteQuadric(m_quadric);
|
||||
}
|
||||
|
||||
std::string GLGizmoMove3D::get_tooltip() const
|
||||
{
|
||||
const Selection& selection = m_parent.get_selection();
|
||||
bool show_position = selection.is_single_full_instance();
|
||||
const Vec3d& position = selection.get_bounding_box().center();
|
||||
|
||||
if (m_hover_id == 0 || m_grabbers[0].dragging)
|
||||
return "X: " + format(show_position ? position(0) : m_displacement(0), 2);
|
||||
else if (m_hover_id == 1 || m_grabbers[1].dragging)
|
||||
return "Y: " + format(show_position ? position(1) : m_displacement(1), 2);
|
||||
else if (m_hover_id == 2 || m_grabbers[2].dragging)
|
||||
return "Z: " + format(show_position ? position(2) : m_displacement(2), 2);
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
bool GLGizmoMove3D::on_init()
|
||||
{
|
||||
for (int i = 0; i < 3; ++i)
|
||||
|
@ -85,22 +101,6 @@ void GLGizmoMove3D::on_render() const
|
|||
{
|
||||
const Selection& selection = m_parent.get_selection();
|
||||
|
||||
bool show_position = selection.is_single_full_instance();
|
||||
const Vec3d& position = selection.get_bounding_box().center();
|
||||
|
||||
if ((show_position && (m_hover_id == 0)) || m_grabbers[0].dragging)
|
||||
set_tooltip("X: " + format(show_position ? position(0) : m_displacement(0), 2));
|
||||
else if (!m_grabbers[0].dragging && (m_hover_id == 0))
|
||||
set_tooltip("X");
|
||||
else if ((show_position && (m_hover_id == 1)) || m_grabbers[1].dragging)
|
||||
set_tooltip("Y: " + format(show_position ? position(1) : m_displacement(1), 2));
|
||||
else if (!m_grabbers[1].dragging && (m_hover_id == 1))
|
||||
set_tooltip("Y");
|
||||
else if ((show_position && (m_hover_id == 2)) || m_grabbers[2].dragging)
|
||||
set_tooltip("Z: " + format(show_position ? position(2) : m_displacement(2), 2));
|
||||
else if (!m_grabbers[2].dragging && (m_hover_id == 2))
|
||||
set_tooltip("Z");
|
||||
|
||||
glsafe(::glClear(GL_DEPTH_BUFFER_BIT));
|
||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue