3DScene's idle even handler moved to c++
This commit is contained in:
parent
a12e3c1cc9
commit
986630c2dc
@ -236,16 +236,14 @@ sub new {
|
||||
#=======================================================================================================================
|
||||
# EVT_SIZE($self, sub { $self->_dirty(1) });
|
||||
#=======================================================================================================================
|
||||
EVT_IDLE($self, sub {
|
||||
#==============================================================================================================================
|
||||
return unless Slic3r::GUI::_3DScene::is_dirty($self);
|
||||
return unless Slic3r::GUI::_3DScene::is_shown_on_screen($self);
|
||||
# EVT_IDLE($self, sub {
|
||||
# return unless $self->_dirty;
|
||||
# return if !$self->IsShownOnScreen;
|
||||
# $self->Resize( $self->GetSizeWH );
|
||||
# $self->Refresh;
|
||||
# });
|
||||
#==============================================================================================================================
|
||||
$self->Resize( $self->GetSizeWH );
|
||||
$self->Refresh;
|
||||
});
|
||||
EVT_MOUSEWHEEL($self, \&mouse_wheel_event);
|
||||
EVT_MOUSE_EVENTS($self, \&mouse_event);
|
||||
# EVT_KEY_DOWN($self, sub {
|
||||
|
@ -305,13 +305,6 @@ void GLCanvas3D::set_camera_target(const Pointf3& target)
|
||||
m_camera.set_target(target);
|
||||
}
|
||||
|
||||
void GLCanvas3D::on_size(wxSizeEvent& evt)
|
||||
{
|
||||
std::cout << "GLCanvas3D::on_size: " << (void*)this << std::endl;
|
||||
|
||||
set_dirty(true);
|
||||
}
|
||||
|
||||
BoundingBoxf3 GLCanvas3D::bed_bounding_box() const
|
||||
{
|
||||
return m_bed.get_bounding_box();
|
||||
@ -338,6 +331,24 @@ BoundingBoxf3 GLCanvas3D::max_bounding_box() const
|
||||
return bb;
|
||||
}
|
||||
|
||||
void GLCanvas3D::on_size(wxSizeEvent& evt)
|
||||
{
|
||||
set_dirty(true);
|
||||
}
|
||||
|
||||
void GLCanvas3D::on_idle(wxIdleEvent& evt)
|
||||
{
|
||||
if (!is_dirty() || !is_shown_on_screen())
|
||||
return;
|
||||
|
||||
if (m_canvas != nullptr)
|
||||
{
|
||||
std::pair<int, int> size = _get_canvas_size();
|
||||
resize((unsigned int)size.first, (unsigned int)size.second);
|
||||
m_canvas->Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void GLCanvas3D::_zoom_to_bed()
|
||||
{
|
||||
_zoom_to_bounding_box(bed_bounding_box());
|
||||
@ -355,5 +366,15 @@ void GLCanvas3D::_zoom_to_bounding_box(const BoundingBoxf3& bbox)
|
||||
// >>>>>>>>>>>>>>>>>>>> TODO <<<<<<<<<<<<<<<<<<<<<<<<
|
||||
}
|
||||
|
||||
std::pair<int, int> GLCanvas3D::_get_canvas_size() const
|
||||
{
|
||||
std::pair<int, int> ret(0, 0);
|
||||
|
||||
if (m_canvas != nullptr)
|
||||
m_canvas->GetSize(&ret.first, &ret.second);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
@ -6,6 +6,7 @@
|
||||
class wxGLCanvas;
|
||||
class wxGLContext;
|
||||
class wxSizeEvent;
|
||||
class wxIdleEvent;
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
@ -120,16 +121,18 @@ public:
|
||||
const Pointf3& get_camera_target() const;
|
||||
void set_camera_target(const Pointf3& target);
|
||||
|
||||
void on_size(wxSizeEvent& evt);
|
||||
|
||||
BoundingBoxf3 bed_bounding_box() const;
|
||||
BoundingBoxf3 volumes_bounding_box() const;
|
||||
BoundingBoxf3 max_bounding_box() const;
|
||||
|
||||
void on_size(wxSizeEvent& evt);
|
||||
void on_idle(wxIdleEvent& evt);
|
||||
|
||||
private:
|
||||
void _zoom_to_bed();
|
||||
void _zoom_to_volumes();
|
||||
void _zoom_to_bounding_box(const BoundingBoxf3& bbox);
|
||||
std::pair<int, int> _get_canvas_size() const;
|
||||
};
|
||||
|
||||
} // namespace GUI
|
||||
|
@ -78,6 +78,7 @@ bool GLCanvas3DManager::add(wxGLCanvas* canvas, wxGLContext* context)
|
||||
return false;
|
||||
|
||||
canvas->Bind(wxEVT_SIZE, [canvas3D](wxSizeEvent& evt) { canvas3D->on_size(evt); });
|
||||
canvas->Bind(wxEVT_IDLE, [canvas3D](wxIdleEvent& evt) { canvas3D->on_idle(evt); });
|
||||
|
||||
m_canvases.insert(CanvasesMap::value_type(canvas, canvas3D));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user