Added perl callback for gizmo flatten
This commit is contained in:
parent
1516c46d0b
commit
781df150a1
@ -153,16 +153,15 @@ sub new {
|
||||
};
|
||||
|
||||
# callback to react to gizmo rotate
|
||||
# omitting last three parameters means rotation around Z
|
||||
# otherwise they are the components of the rotation axis vector
|
||||
my $on_gizmo_rotate = sub {
|
||||
my ($angle) = @_;
|
||||
$self->rotate(rad2deg($angle), Z, 'absolute');
|
||||
};
|
||||
|
||||
# callback to react to gizmo flatten
|
||||
my $on_gizmo_flatten = sub {
|
||||
my ($angle, $axis_x, $axis_y, $axis_z) = @_;
|
||||
if (!defined $axis_x) {
|
||||
$self->rotate(rad2deg($angle), Z, 'absolute');
|
||||
}
|
||||
else {
|
||||
$self->rotate(rad2deg($angle), undef, 'absolute', $axis_x, $axis_y, $axis_z) if $angle != 0;
|
||||
}
|
||||
$self->rotate(rad2deg($angle), undef, 'absolute', $axis_x, $axis_y, $axis_z) if $angle != 0;
|
||||
};
|
||||
|
||||
# callback to update object's geometry info while using gizmos
|
||||
@ -263,6 +262,7 @@ sub new {
|
||||
Slic3r::GUI::_3DScene::register_on_enable_action_buttons_callback($self->{canvas3D}, $enable_action_buttons);
|
||||
Slic3r::GUI::_3DScene::register_on_gizmo_scale_uniformly_callback($self->{canvas3D}, $on_gizmo_scale_uniformly);
|
||||
Slic3r::GUI::_3DScene::register_on_gizmo_rotate_callback($self->{canvas3D}, $on_gizmo_rotate);
|
||||
Slic3r::GUI::_3DScene::register_on_gizmo_flatten_callback($self->{canvas3D}, $on_gizmo_flatten);
|
||||
Slic3r::GUI::_3DScene::register_on_update_geometry_info_callback($self->{canvas3D}, $on_update_geometry_info);
|
||||
Slic3r::GUI::_3DScene::register_action_add_callback($self->{canvas3D}, $on_action_add);
|
||||
Slic3r::GUI::_3DScene::register_action_delete_callback($self->{canvas3D}, $on_action_delete);
|
||||
|
@ -2044,6 +2044,11 @@ void _3DScene::register_on_gizmo_rotate_callback(wxGLCanvas* canvas, void* callb
|
||||
s_canvas_mgr.register_on_gizmo_rotate_callback(canvas, callback);
|
||||
}
|
||||
|
||||
void _3DScene::register_on_gizmo_flatten_callback(wxGLCanvas* canvas, void* callback)
|
||||
{
|
||||
s_canvas_mgr.register_on_gizmo_flatten_callback(canvas, callback);
|
||||
}
|
||||
|
||||
void _3DScene::register_on_update_geometry_info_callback(wxGLCanvas* canvas, void* callback)
|
||||
{
|
||||
s_canvas_mgr.register_on_update_geometry_info_callback(canvas, callback);
|
||||
|
@ -556,6 +556,7 @@ public:
|
||||
static void register_on_enable_action_buttons_callback(wxGLCanvas* canvas, void* callback);
|
||||
static void register_on_gizmo_scale_uniformly_callback(wxGLCanvas* canvas, void* callback);
|
||||
static void register_on_gizmo_rotate_callback(wxGLCanvas* canvas, void* callback);
|
||||
static void register_on_gizmo_flatten_callback(wxGLCanvas* canvas, void* callback);
|
||||
static void register_on_update_geometry_info_callback(wxGLCanvas* canvas, void* callback);
|
||||
|
||||
static void register_action_add_callback(wxGLCanvas* canvas, void* callback);
|
||||
|
@ -2699,6 +2699,12 @@ void GLCanvas3D::register_on_gizmo_rotate_callback(void* callback)
|
||||
m_on_gizmo_rotate_callback.register_callback(callback);
|
||||
}
|
||||
|
||||
void GLCanvas3D::register_on_gizmo_flatten_callback(void* callback)
|
||||
{
|
||||
if (callback != nullptr)
|
||||
m_on_gizmo_flatten_callback.register_callback(callback);
|
||||
}
|
||||
|
||||
void GLCanvas3D::register_on_update_geometry_info_callback(void* callback)
|
||||
{
|
||||
if (callback != nullptr)
|
||||
@ -3016,7 +3022,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||
if (normal(0) != 0.0 || normal(1) != 0.0 || normal(2) != 0.0) {
|
||||
Vec3d axis = normal(2) > 0.999 ? Vec3d::UnitX() : normal.cross(-Vec3d::UnitZ()).normalized();
|
||||
float angle = acos(clamp(-1.0, 1.0, -normal(2)));
|
||||
m_on_gizmo_rotate_callback.call(angle, (float)axis(0), (float)axis(1), (float)axis(2));
|
||||
m_on_gizmo_flatten_callback.call(angle, (float)axis(0), (float)axis(1), (float)axis(2));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3759,6 +3765,7 @@ void GLCanvas3D::_deregister_callbacks()
|
||||
m_on_enable_action_buttons_callback.deregister_callback();
|
||||
m_on_gizmo_scale_uniformly_callback.deregister_callback();
|
||||
m_on_gizmo_rotate_callback.deregister_callback();
|
||||
m_on_gizmo_flatten_callback.deregister_callback();
|
||||
m_on_update_geometry_info_callback.deregister_callback();
|
||||
|
||||
m_action_add_callback.deregister_callback();
|
||||
|
@ -501,6 +501,7 @@ private:
|
||||
PerlCallback m_on_enable_action_buttons_callback;
|
||||
PerlCallback m_on_gizmo_scale_uniformly_callback;
|
||||
PerlCallback m_on_gizmo_rotate_callback;
|
||||
PerlCallback m_on_gizmo_flatten_callback;
|
||||
PerlCallback m_on_update_geometry_info_callback;
|
||||
|
||||
PerlCallback m_action_add_callback;
|
||||
@ -623,6 +624,7 @@ public:
|
||||
void register_on_enable_action_buttons_callback(void* callback);
|
||||
void register_on_gizmo_scale_uniformly_callback(void* callback);
|
||||
void register_on_gizmo_rotate_callback(void* callback);
|
||||
void register_on_gizmo_flatten_callback(void* callback);
|
||||
void register_on_update_geometry_info_callback(void* callback);
|
||||
|
||||
void register_action_add_callback(void* callback);
|
||||
|
@ -700,6 +700,13 @@ void GLCanvas3DManager::register_on_gizmo_rotate_callback(wxGLCanvas* canvas, vo
|
||||
it->second->register_on_gizmo_rotate_callback(callback);
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::register_on_gizmo_flatten_callback(wxGLCanvas* canvas, void* callback)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
if (it != m_canvases.end())
|
||||
it->second->register_on_gizmo_flatten_callback(callback);
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::register_on_update_geometry_info_callback(wxGLCanvas* canvas, void* callback)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
|
@ -163,6 +163,7 @@ public:
|
||||
void register_on_enable_action_buttons_callback(wxGLCanvas* canvas, void* callback);
|
||||
void register_on_gizmo_scale_uniformly_callback(wxGLCanvas* canvas, void* callback);
|
||||
void register_on_gizmo_rotate_callback(wxGLCanvas* canvas, void* callback);
|
||||
void register_on_gizmo_flatten_callback(wxGLCanvas* canvas, void* callback);
|
||||
void register_on_update_geometry_info_callback(wxGLCanvas* canvas, void* callback);
|
||||
|
||||
void register_action_add_callback(wxGLCanvas* canvas, void* callback);
|
||||
|
@ -651,6 +651,13 @@ register_on_gizmo_rotate_callback(canvas, callback)
|
||||
CODE:
|
||||
_3DScene::register_on_gizmo_rotate_callback((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), (void*)callback);
|
||||
|
||||
void
|
||||
register_on_gizmo_flatten_callback(canvas, callback)
|
||||
SV *canvas;
|
||||
SV *callback;
|
||||
CODE:
|
||||
_3DScene::register_on_gizmo_flatten_callback((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), (void*)callback);
|
||||
|
||||
void
|
||||
register_on_update_geometry_info_callback(canvas, callback)
|
||||
SV *canvas;
|
||||
|
Loading…
Reference in New Issue
Block a user