3DScene zoom functions moved to c++

This commit is contained in:
Enrico Turri 2018-05-15 10:32:38 +02:00
commit 7519e34507
8 changed files with 143 additions and 51 deletions

View file

@ -1767,6 +1767,16 @@ void _3DScene::set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape)
return s_canvas_mgr.set_bed_shape(canvas, shape);
}
BoundingBoxf3 _3DScene::get_bed_bounding_box(wxGLCanvas* canvas)
{
return s_canvas_mgr.get_bed_bounding_box(canvas);
}
BoundingBoxf3 _3DScene::get_volumes_bounding_box(wxGLCanvas* canvas)
{
return s_canvas_mgr.get_volumes_bounding_box(canvas);
}
BoundingBoxf3 _3DScene::get_max_bounding_box(wxGLCanvas* canvas)
{
return s_canvas_mgr.get_max_bounding_box(canvas);
@ -1847,6 +1857,16 @@ void _3DScene::set_camera_target(wxGLCanvas* canvas, const Pointf3* target)
s_canvas_mgr.set_camera_target(canvas, target);
}
void _3DScene::zoom_to_bed(wxGLCanvas* canvas)
{
s_canvas_mgr.zoom_to_bed(canvas);
}
void _3DScene::zoom_to_volumes(wxGLCanvas* canvas)
{
s_canvas_mgr.zoom_to_volumes(canvas);
}
void _3DScene::register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback)
{
s_canvas_mgr.register_on_viewport_changed_callback(canvas, callback);

View file

@ -551,6 +551,8 @@ public:
static void set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape);
static BoundingBoxf3 get_bed_bounding_box(wxGLCanvas* canvas);
static BoundingBoxf3 get_volumes_bounding_box(wxGLCanvas* canvas);
static BoundingBoxf3 get_max_bounding_box(wxGLCanvas* canvas);
static bool is_dirty(wxGLCanvas* canvas);
@ -575,6 +577,9 @@ public:
static Pointf3 get_camera_target(wxGLCanvas* canvas);
static void set_camera_target(wxGLCanvas* canvas, const Pointf3* target);
static void zoom_to_bed(wxGLCanvas* canvas);
static void zoom_to_volumes(wxGLCanvas* canvas);
static void register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback);
// static void _glew_init();

View file

@ -336,6 +336,18 @@ BoundingBoxf3 GLCanvas3D::max_bounding_box() const
return bb;
}
void GLCanvas3D::zoom_to_bed()
{
_zoom_to_bounding_box(bed_bounding_box());
}
void GLCanvas3D::zoom_to_volumes()
{
m_apply_zoom_to_volumes_filter = true;
_zoom_to_bounding_box(volumes_bounding_box());
m_apply_zoom_to_volumes_filter = false;
}
void GLCanvas3D::register_on_viewport_changed_callback(void* callback)
{
if (callback != nullptr)
@ -360,18 +372,6 @@ void GLCanvas3D::on_idle(wxIdleEvent& evt)
}
}
void GLCanvas3D::_zoom_to_bed()
{
_zoom_to_bounding_box(bed_bounding_box());
}
void GLCanvas3D::_zoom_to_volumes()
{
m_apply_zoom_to_volumes_filter = true;
_zoom_to_bounding_box(volumes_bounding_box());
m_apply_zoom_to_volumes_filter = false;
}
void GLCanvas3D::_zoom_to_bounding_box(const BoundingBoxf3& bbox)
{
// Calculate the zoom factor needed to adjust viewport to bounding box.

View file

@ -129,14 +129,15 @@ public:
BoundingBoxf3 volumes_bounding_box() const;
BoundingBoxf3 max_bounding_box() const;
void zoom_to_bed();
void zoom_to_volumes();
void register_on_viewport_changed_callback(void* callback);
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;
float _get_zoom_to_bounding_box_factor(const BoundingBoxf3& bbox) const;

View file

@ -180,6 +180,18 @@ void GLCanvas3DManager::set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape)
it->second->set_bed_shape(shape);
}
BoundingBoxf3 GLCanvas3DManager::get_bed_bounding_box(wxGLCanvas* canvas)
{
CanvasesMap::const_iterator it = _get_canvas(canvas);
return (it != m_canvases.end()) ? it->second->bed_bounding_box() : BoundingBoxf3();
}
BoundingBoxf3 GLCanvas3DManager::get_volumes_bounding_box(wxGLCanvas* canvas)
{
CanvasesMap::const_iterator it = _get_canvas(canvas);
return (it != m_canvases.end()) ? it->second->volumes_bounding_box() : BoundingBoxf3();
}
BoundingBoxf3 GLCanvas3DManager::get_max_bounding_box(wxGLCanvas* canvas)
{
CanvasesMap::const_iterator it = _get_canvas(canvas);
@ -289,6 +301,20 @@ void GLCanvas3DManager::set_camera_target(wxGLCanvas* canvas, const Pointf3* tar
it->second->set_camera_target(*target);
}
void GLCanvas3DManager::zoom_to_bed(wxGLCanvas* canvas)
{
CanvasesMap::iterator it = _get_canvas(canvas);
if (it != m_canvases.end())
it->second->zoom_to_bed();
}
void GLCanvas3DManager::zoom_to_volumes(wxGLCanvas* canvas)
{
CanvasesMap::iterator it = _get_canvas(canvas);
if (it != m_canvases.end())
it->second->zoom_to_volumes();
}
void GLCanvas3DManager::register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback)
{
CanvasesMap::iterator it = _get_canvas(canvas);

View file

@ -61,6 +61,8 @@ public:
void set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape);
BoundingBoxf3 get_bed_bounding_box(wxGLCanvas* canvas);
BoundingBoxf3 get_volumes_bounding_box(wxGLCanvas* canvas);
BoundingBoxf3 get_max_bounding_box(wxGLCanvas* canvas);
bool is_dirty(wxGLCanvas* canvas) const;
@ -85,6 +87,9 @@ public:
Pointf3 get_camera_target(wxGLCanvas* canvas) const;
void set_camera_target(wxGLCanvas* canvas, const Pointf3* target);
void zoom_to_bed(wxGLCanvas* canvas);
void zoom_to_volumes(wxGLCanvas* canvas);
void register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback);
private:

View file

@ -214,6 +214,22 @@ set_bed_shape(canvas, shape)
Pointfs shape;
CODE:
_3DScene::set_bed_shape((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), shape);
Clone<BoundingBoxf3>
get_bed_bounding_box(canvas)
SV *canvas;
CODE:
RETVAL = _3DScene::get_bed_bounding_box((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"));
OUTPUT:
RETVAL
Clone<BoundingBoxf3>
get_volumes_bounding_box(canvas)
SV *canvas;
CODE:
RETVAL = _3DScene::get_volumes_bounding_box((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"));
OUTPUT:
RETVAL
Clone<BoundingBoxf3>
get_max_bounding_box(canvas)
@ -344,6 +360,18 @@ set_camera_target(canvas, target)
CODE:
_3DScene::set_camera_target((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), target);
void
zoom_to_bed(canvas)
SV *canvas;
CODE:
_3DScene::zoom_to_bed((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"));
void
zoom_to_volumes(canvas)
SV *canvas;
CODE:
_3DScene::zoom_to_volumes((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"));
void
register_on_viewport_changed_callback(canvas, callback)
SV *canvas;