Add dirty state into Gizmo (hint by @DavidKocik)
This commit is contained in:
parent
cce3041a95
commit
8fab4885c7
@ -2239,6 +2239,8 @@ void GLCanvas3D::on_idle(wxIdleEvent& evt)
|
|||||||
bool mouse3d_controller_applied = wxGetApp().plater()->get_mouse3d_controller().apply(wxGetApp().plater()->get_camera());
|
bool mouse3d_controller_applied = wxGetApp().plater()->get_mouse3d_controller().apply(wxGetApp().plater()->get_camera());
|
||||||
m_dirty |= mouse3d_controller_applied;
|
m_dirty |= mouse3d_controller_applied;
|
||||||
m_dirty |= wxGetApp().plater()->get_notification_manager()->update_notifications(*this);
|
m_dirty |= wxGetApp().plater()->get_notification_manager()->update_notifications(*this);
|
||||||
|
auto gizmo = wxGetApp().plater()->canvas3D()->get_gizmos_manager().get_current();
|
||||||
|
if (gizmo != nullptr) m_dirty |= gizmo->update_items_state();
|
||||||
|
|
||||||
if (!m_dirty)
|
if (!m_dirty)
|
||||||
return;
|
return;
|
||||||
@ -2780,10 +2782,10 @@ void GLCanvas3D::on_timer(wxTimerEvent& evt)
|
|||||||
|
|
||||||
void GLCanvas3D::on_render_timer(wxTimerEvent& evt)
|
void GLCanvas3D::on_render_timer(wxTimerEvent& evt)
|
||||||
{
|
{
|
||||||
m_dirty = true;
|
|
||||||
// wxWakeUpIdle();
|
|
||||||
// no need to wake up idle
|
// no need to wake up idle
|
||||||
// right after this event, idle event is fired
|
// right after this event, idle event is fired
|
||||||
|
// m_dirty = true;
|
||||||
|
// wxWakeUpIdle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -85,6 +85,7 @@ GLGizmoBase::GLGizmoBase(GLCanvas3D& parent, const std::string& icon_filename, u
|
|||||||
, m_dragging(false)
|
, m_dragging(false)
|
||||||
, m_imgui(wxGetApp().imgui())
|
, m_imgui(wxGetApp().imgui())
|
||||||
, m_first_input_window_render(true)
|
, m_first_input_window_render(true)
|
||||||
|
, m_dirty(false)
|
||||||
{
|
{
|
||||||
m_base_color = DEFAULT_BASE_COLOR;
|
m_base_color = DEFAULT_BASE_COLOR;
|
||||||
m_drag_color = DEFAULT_DRAG_COLOR;
|
m_drag_color = DEFAULT_DRAG_COLOR;
|
||||||
@ -154,6 +155,14 @@ void GLGizmoBase::update(const UpdateData& data)
|
|||||||
on_update(data);
|
on_update(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GLGizmoBase::update_items_state()
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> g(m_dirty_access);
|
||||||
|
bool res = m_dirty;
|
||||||
|
m_dirty = false;
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
|
||||||
std::array<float, 4> GLGizmoBase::picking_color_component(unsigned int id) const
|
std::array<float, 4> GLGizmoBase::picking_color_component(unsigned int id) const
|
||||||
{
|
{
|
||||||
static const float INV_255 = 1.0f / 255.0f;
|
static const float INV_255 = 1.0f / 255.0f;
|
||||||
@ -209,6 +218,11 @@ std::string GLGizmoBase::format(float value, unsigned int decimals) const
|
|||||||
return Slic3r::string_printf("%.*f", decimals, value);
|
return Slic3r::string_printf("%.*f", decimals, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLGizmoBase::set_dirty() {
|
||||||
|
std::lock_guard<std::mutex> g(m_dirty_access);
|
||||||
|
m_dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
void GLGizmoBase::render_input_window(float x, float y, float bottom_limit)
|
void GLGizmoBase::render_input_window(float x, float y, float bottom_limit)
|
||||||
{
|
{
|
||||||
on_render_input_window(x, y, bottom_limit);
|
on_render_input_window(x, y, bottom_limit);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef slic3r_GLGizmoBase_hpp_
|
#ifndef slic3r_GLGizmoBase_hpp_
|
||||||
#define slic3r_GLGizmoBase_hpp_
|
#define slic3r_GLGizmoBase_hpp_
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
#include "libslic3r/Point.hpp"
|
#include "libslic3r/Point.hpp"
|
||||||
|
|
||||||
#include "slic3r/GUI/I18N.hpp"
|
#include "slic3r/GUI/I18N.hpp"
|
||||||
@ -153,6 +154,7 @@ public:
|
|||||||
bool is_dragging() const { return m_dragging; }
|
bool is_dragging() const { return m_dragging; }
|
||||||
|
|
||||||
void update(const UpdateData& data);
|
void update(const UpdateData& data);
|
||||||
|
bool update_items_state();
|
||||||
|
|
||||||
void render() { m_tooltip.clear(); on_render(); }
|
void render() { m_tooltip.clear(); on_render(); }
|
||||||
void render_for_picking() { on_render_for_picking(); }
|
void render_for_picking() { on_render_for_picking(); }
|
||||||
@ -187,6 +189,12 @@ protected:
|
|||||||
void render_grabbers_for_picking(const BoundingBoxf3& box) const;
|
void render_grabbers_for_picking(const BoundingBoxf3& box) const;
|
||||||
|
|
||||||
std::string format(float value, unsigned int decimals) const;
|
std::string format(float value, unsigned int decimals) const;
|
||||||
|
|
||||||
|
void set_dirty();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::mutex m_dirty_access;
|
||||||
|
bool m_dirty;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Produce an alpha channel checksum for the red green blue components. The alpha channel may then be used to verify, whether the rgb components
|
// Produce an alpha channel checksum for the red green blue components. The alpha channel may then be used to verify, whether the rgb components
|
||||||
|
@ -266,6 +266,7 @@ void GLGizmoSimplify::process()
|
|||||||
};
|
};
|
||||||
std::function<void(int)> statusfn = [&](int percent) {
|
std::function<void(int)> statusfn = [&](int percent) {
|
||||||
m_progress = percent;
|
m_progress = percent;
|
||||||
|
set_dirty();
|
||||||
m_parent.schedule_extra_frame(0);
|
m_parent.schedule_extra_frame(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -290,6 +291,7 @@ void GLGizmoSimplify::process()
|
|||||||
m_state = State::settings;
|
m_state = State::settings;
|
||||||
}
|
}
|
||||||
// need to render last status fn to change bar graph to buttons
|
// need to render last status fn to change bar graph to buttons
|
||||||
|
set_dirty();
|
||||||
m_parent.schedule_extra_frame(0);
|
m_parent.schedule_extra_frame(0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user