3DScene zoom functions moved to c++
This commit is contained in:
commit
7519e34507
@ -67,7 +67,6 @@ __PACKAGE__->mk_accessors( qw(_quat init
|
|||||||
|
|
||||||
_legend_enabled
|
_legend_enabled
|
||||||
_warning_enabled
|
_warning_enabled
|
||||||
_apply_zoom_to_volumes_filter
|
|
||||||
_mouse_dragging
|
_mouse_dragging
|
||||||
|
|
||||||
) );
|
) );
|
||||||
@ -201,7 +200,9 @@ sub new {
|
|||||||
$self->_legend_enabled(0);
|
$self->_legend_enabled(0);
|
||||||
$self->_warning_enabled(0);
|
$self->_warning_enabled(0);
|
||||||
$self->use_plain_shader(0);
|
$self->use_plain_shader(0);
|
||||||
$self->_apply_zoom_to_volumes_filter(0);
|
#==============================================================================================================================
|
||||||
|
# $self->_apply_zoom_to_volumes_filter(0);
|
||||||
|
#==============================================================================================================================
|
||||||
$self->_mouse_dragging(0);
|
$self->_mouse_dragging(0);
|
||||||
|
|
||||||
# Collection of GLVolume objects
|
# Collection of GLVolume objects
|
||||||
@ -793,8 +794,6 @@ sub select_view {
|
|||||||
# $self->_stheta(GIMBALL_LOCK_THETA_MAX) if $self->_stheta > GIMBALL_LOCK_THETA_MAX;
|
# $self->_stheta(GIMBALL_LOCK_THETA_MAX) if $self->_stheta > GIMBALL_LOCK_THETA_MAX;
|
||||||
# $self->_stheta(0) if $self->_stheta < 0;
|
# $self->_stheta(0) if $self->_stheta < 0;
|
||||||
#==============================================================================================================================
|
#==============================================================================================================================
|
||||||
# View everything.
|
|
||||||
$self->zoom_to_bounding_box($bb);
|
|
||||||
$self->on_viewport_changed->() if $self->on_viewport_changed;
|
$self->on_viewport_changed->() if $self->on_viewport_changed;
|
||||||
$self->Refresh;
|
$self->Refresh;
|
||||||
}
|
}
|
||||||
@ -895,35 +894,31 @@ sub get_zoom_to_bounding_box_factor {
|
|||||||
return $min_ratio;
|
return $min_ratio;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub zoom_to_bounding_box {
|
|
||||||
my ($self, $bb) = @_;
|
|
||||||
# Calculate the zoom factor needed to adjust viewport to bounding box.
|
|
||||||
my $zoom = $self->get_zoom_to_bounding_box_factor($bb);
|
|
||||||
if (defined $zoom) {
|
|
||||||
#==============================================================================================================================
|
#==============================================================================================================================
|
||||||
Slic3r::GUI::_3DScene::set_camera_zoom($self, $zoom);
|
#sub zoom_to_bounding_box {
|
||||||
|
# my ($self, $bb) = @_;
|
||||||
|
# # Calculate the zoom factor needed to adjust viewport to bounding box.
|
||||||
|
# my $zoom = $self->get_zoom_to_bounding_box_factor($bb);
|
||||||
|
# if (defined $zoom) {
|
||||||
# $self->_zoom($zoom);
|
# $self->_zoom($zoom);
|
||||||
#==============================================================================================================================
|
# # center view around bounding box center
|
||||||
# center view around bounding box center
|
|
||||||
#==============================================================================================================================
|
|
||||||
Slic3r::GUI::_3DScene::set_camera_target($self, $bb->center);
|
|
||||||
# $self->_camera_target($bb->center);
|
# $self->_camera_target($bb->center);
|
||||||
#==============================================================================================================================
|
# $self->on_viewport_changed->() if $self->on_viewport_changed;
|
||||||
$self->on_viewport_changed->() if $self->on_viewport_changed;
|
|
||||||
#==============================================================================================================================
|
|
||||||
$self->Resize($self->GetSizeWH) if Slic3r::GUI::_3DScene::is_shown_on_screen($self);
|
|
||||||
# $self->Resize($self->GetSizeWH) if $self->IsShownOnScreen;
|
# $self->Resize($self->GetSizeWH) if $self->IsShownOnScreen;
|
||||||
|
# $self->Refresh;
|
||||||
|
# }
|
||||||
|
#}
|
||||||
#==============================================================================================================================
|
#==============================================================================================================================
|
||||||
$self->Refresh;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sub zoom_to_bed {
|
sub zoom_to_bed {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
if ($self->bed_shape) {
|
#==============================================================================================================================
|
||||||
$self->zoom_to_bounding_box($self->bed_bounding_box);
|
Slic3r::GUI::_3DScene::zoom_to_bed($self);
|
||||||
}
|
# if ($self->bed_shape) {
|
||||||
|
# $self->zoom_to_bounding_box($self->bed_bounding_box);
|
||||||
|
# }
|
||||||
|
#==============================================================================================================================
|
||||||
}
|
}
|
||||||
|
|
||||||
#==============================================================================================================================
|
#==============================================================================================================================
|
||||||
@ -938,29 +933,41 @@ sub zoom_to_bed {
|
|||||||
|
|
||||||
sub zoom_to_volumes {
|
sub zoom_to_volumes {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
$self->_apply_zoom_to_volumes_filter(1);
|
#==============================================================================================================================
|
||||||
$self->zoom_to_bounding_box($self->volumes_bounding_box);
|
Slic3r::GUI::_3DScene::zoom_to_volumes($self);
|
||||||
$self->_apply_zoom_to_volumes_filter(0);
|
|
||||||
|
# $self->_apply_zoom_to_volumes_filter(1);
|
||||||
|
# $self->zoom_to_bounding_box($self->volumes_bounding_box);
|
||||||
|
# $self->_apply_zoom_to_volumes_filter(0);
|
||||||
|
#==============================================================================================================================
|
||||||
}
|
}
|
||||||
|
|
||||||
sub volumes_bounding_box {
|
sub volumes_bounding_box {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
my $bb = Slic3r::Geometry::BoundingBoxf3->new;
|
#==============================================================================================================================
|
||||||
foreach my $v (@{$self->volumes}) {
|
return Slic3r::GUI::_3DScene::get_volumes_bounding_box($self);
|
||||||
$bb->merge($v->transformed_bounding_box) if (! $self->_apply_zoom_to_volumes_filter || $v->zoom_to_volumes);
|
|
||||||
}
|
# my $bb = Slic3r::Geometry::BoundingBoxf3->new;
|
||||||
return $bb;
|
# foreach my $v (@{$self->volumes}) {
|
||||||
|
# $bb->merge($v->transformed_bounding_box) if (! $self->_apply_zoom_to_volumes_filter || $v->zoom_to_volumes);
|
||||||
|
# }
|
||||||
|
# return $bb;
|
||||||
|
#==============================================================================================================================
|
||||||
}
|
}
|
||||||
|
|
||||||
sub bed_bounding_box {
|
sub bed_bounding_box {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
my $bb = Slic3r::Geometry::BoundingBoxf3->new;
|
#==============================================================================================================================
|
||||||
if ($self->bed_shape) {
|
return Slic3r::GUI::_3DScene::get_bed_bounding_box($self);
|
||||||
$bb->merge_point(Slic3r::Pointf3->new(@$_, 0)) for @{$self->bed_shape};
|
|
||||||
}
|
# my $bb = Slic3r::Geometry::BoundingBoxf3->new;
|
||||||
return $bb;
|
# if ($self->bed_shape) {
|
||||||
|
# $bb->merge_point(Slic3r::Pointf3->new(@$_, 0)) for @{$self->bed_shape};
|
||||||
|
# }
|
||||||
|
# return $bb;
|
||||||
|
#==============================================================================================================================
|
||||||
}
|
}
|
||||||
|
|
||||||
sub max_bounding_box {
|
sub max_bounding_box {
|
||||||
|
@ -1767,6 +1767,16 @@ void _3DScene::set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape)
|
|||||||
return s_canvas_mgr.set_bed_shape(canvas, 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)
|
BoundingBoxf3 _3DScene::get_max_bounding_box(wxGLCanvas* canvas)
|
||||||
{
|
{
|
||||||
return s_canvas_mgr.get_max_bounding_box(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);
|
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)
|
void _3DScene::register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback)
|
||||||
{
|
{
|
||||||
s_canvas_mgr.register_on_viewport_changed_callback(canvas, callback);
|
s_canvas_mgr.register_on_viewport_changed_callback(canvas, callback);
|
||||||
|
@ -551,6 +551,8 @@ public:
|
|||||||
|
|
||||||
static void set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape);
|
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 BoundingBoxf3 get_max_bounding_box(wxGLCanvas* canvas);
|
||||||
|
|
||||||
static bool is_dirty(wxGLCanvas* canvas);
|
static bool is_dirty(wxGLCanvas* canvas);
|
||||||
@ -575,6 +577,9 @@ public:
|
|||||||
static Pointf3 get_camera_target(wxGLCanvas* canvas);
|
static Pointf3 get_camera_target(wxGLCanvas* canvas);
|
||||||
static void set_camera_target(wxGLCanvas* canvas, const Pointf3* target);
|
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 register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback);
|
||||||
|
|
||||||
// static void _glew_init();
|
// static void _glew_init();
|
||||||
|
@ -336,6 +336,18 @@ BoundingBoxf3 GLCanvas3D::max_bounding_box() const
|
|||||||
return bb;
|
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)
|
void GLCanvas3D::register_on_viewport_changed_callback(void* callback)
|
||||||
{
|
{
|
||||||
if (callback != nullptr)
|
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)
|
void GLCanvas3D::_zoom_to_bounding_box(const BoundingBoxf3& bbox)
|
||||||
{
|
{
|
||||||
// Calculate the zoom factor needed to adjust viewport to bounding box.
|
// Calculate the zoom factor needed to adjust viewport to bounding box.
|
||||||
|
@ -129,14 +129,15 @@ public:
|
|||||||
BoundingBoxf3 volumes_bounding_box() const;
|
BoundingBoxf3 volumes_bounding_box() const;
|
||||||
BoundingBoxf3 max_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 register_on_viewport_changed_callback(void* callback);
|
||||||
|
|
||||||
void on_size(wxSizeEvent& evt);
|
void on_size(wxSizeEvent& evt);
|
||||||
void on_idle(wxIdleEvent& evt);
|
void on_idle(wxIdleEvent& evt);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _zoom_to_bed();
|
|
||||||
void _zoom_to_volumes();
|
|
||||||
void _zoom_to_bounding_box(const BoundingBoxf3& bbox);
|
void _zoom_to_bounding_box(const BoundingBoxf3& bbox);
|
||||||
std::pair<int, int> _get_canvas_size() const;
|
std::pair<int, int> _get_canvas_size() const;
|
||||||
float _get_zoom_to_bounding_box_factor(const BoundingBoxf3& bbox) const;
|
float _get_zoom_to_bounding_box_factor(const BoundingBoxf3& bbox) const;
|
||||||
|
@ -180,6 +180,18 @@ void GLCanvas3DManager::set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape)
|
|||||||
it->second->set_bed_shape(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)
|
BoundingBoxf3 GLCanvas3DManager::get_max_bounding_box(wxGLCanvas* canvas)
|
||||||
{
|
{
|
||||||
CanvasesMap::const_iterator it = _get_canvas(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);
|
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)
|
void GLCanvas3DManager::register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback)
|
||||||
{
|
{
|
||||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||||
|
@ -61,6 +61,8 @@ public:
|
|||||||
|
|
||||||
void set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape);
|
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);
|
BoundingBoxf3 get_max_bounding_box(wxGLCanvas* canvas);
|
||||||
|
|
||||||
bool is_dirty(wxGLCanvas* canvas) const;
|
bool is_dirty(wxGLCanvas* canvas) const;
|
||||||
@ -85,6 +87,9 @@ public:
|
|||||||
Pointf3 get_camera_target(wxGLCanvas* canvas) const;
|
Pointf3 get_camera_target(wxGLCanvas* canvas) const;
|
||||||
void set_camera_target(wxGLCanvas* canvas, const Pointf3* target);
|
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);
|
void register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -214,6 +214,22 @@ set_bed_shape(canvas, shape)
|
|||||||
Pointfs shape;
|
Pointfs shape;
|
||||||
CODE:
|
CODE:
|
||||||
_3DScene::set_bed_shape((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), shape);
|
_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>
|
Clone<BoundingBoxf3>
|
||||||
get_max_bounding_box(canvas)
|
get_max_bounding_box(canvas)
|
||||||
@ -344,6 +360,18 @@ set_camera_target(canvas, target)
|
|||||||
CODE:
|
CODE:
|
||||||
_3DScene::set_camera_target((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), target);
|
_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
|
void
|
||||||
register_on_viewport_changed_callback(canvas, callback)
|
register_on_viewport_changed_callback(canvas, callback)
|
||||||
SV *canvas;
|
SV *canvas;
|
||||||
|
Loading…
Reference in New Issue
Block a user