3DScene mouse event handler move to c++ completed
This commit is contained in:
parent
6bf009edee
commit
94d608c6c1
3 changed files with 51 additions and 45 deletions
|
@ -38,12 +38,6 @@ __PACKAGE__->mk_accessors( qw(_quat init
|
||||||
on_viewport_changed
|
on_viewport_changed
|
||||||
on_select
|
on_select
|
||||||
volumes
|
volumes
|
||||||
|
|
||||||
_drag_volume_idx
|
|
||||||
_drag_start_pos
|
|
||||||
_drag_volume_center_offset
|
|
||||||
_drag_start_xy
|
|
||||||
_dragged
|
|
||||||
) );
|
) );
|
||||||
#__PACKAGE__->mk_accessors( qw(_quat _dirty init
|
#__PACKAGE__->mk_accessors( qw(_quat _dirty init
|
||||||
# enable_picking
|
# enable_picking
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
|
|
||||||
|
static const float TRACKBALLSIZE = 0.8f;
|
||||||
static const float GIMBALL_LOCK_THETA_MAX = 180.0f;
|
static const float GIMBALL_LOCK_THETA_MAX = 180.0f;
|
||||||
static const float GROUND_Z = -0.02f;
|
static const float GROUND_Z = -0.02f;
|
||||||
|
|
||||||
|
@ -1084,6 +1085,16 @@ void GLCanvas3D::Drag::set_start_position_3D(const Pointf3& position)
|
||||||
m_start_position_3D = position;
|
m_start_position_3D = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GLCanvas3D::Drag::is_start_position_2D_defined() const
|
||||||
|
{
|
||||||
|
return (m_start_position_2D != Point(INT_MAX, INT_MAX));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GLCanvas3D::Drag::is_start_position_3D_defined() const
|
||||||
|
{
|
||||||
|
return (m_start_position_3D != Pointf3(DBL_MAX, DBL_MAX, DBL_MAX));
|
||||||
|
}
|
||||||
|
|
||||||
const Vectorf3& GLCanvas3D::Drag::get_volume_center_offset() const
|
const Vectorf3& GLCanvas3D::Drag::get_volume_center_offset() const
|
||||||
{
|
{
|
||||||
return m_volume_center_offset;
|
return m_volume_center_offset;
|
||||||
|
@ -2131,45 +2142,43 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
if (get_layers_editing_state() == 1)
|
if (get_layers_editing_state() == 1)
|
||||||
perform_layer_editing_action(pos.y, evt.ShiftDown(), evt.RightIsDown());
|
perform_layer_editing_action(pos.y, evt.ShiftDown(), evt.RightIsDown());
|
||||||
}
|
}
|
||||||
// } elsif($e->LeftIsDown) {
|
else if (evt.LeftIsDown())
|
||||||
//# if dragging over blank area with left button, rotate
|
{
|
||||||
// if (defined $self->_drag_start_pos) {
|
// if dragging over blank area with left button, rotate
|
||||||
// my $orig = $self->_drag_start_pos;
|
if (m_drag.is_start_position_3D_defined())
|
||||||
// if (TURNTABLE_MODE) {
|
{
|
||||||
// # Turntable mode is enabled by default.
|
Pointf3 orig = m_drag.get_start_position_3D();
|
||||||
// Slic3r::GUI::_3DScene::set_camera_phi($self, Slic3r::GUI::_3DScene::get_camera_phi($self) + ($pos->x - $orig->x) * TRACKBALLSIZE);
|
set_camera_phi(get_camera_phi() + ((float)pos.x - (float)orig.x) * TRACKBALLSIZE);
|
||||||
// Slic3r::GUI::_3DScene::set_camera_theta($self, Slic3r::GUI::_3DScene::get_camera_theta($self) - ($pos->y - $orig->y) * TRACKBALLSIZE);
|
set_camera_theta(get_camera_theta() - ((float)pos.y - (float)orig.y) * TRACKBALLSIZE);
|
||||||
// }
|
|
||||||
// else {
|
m_on_viewport_changed_callback.call();
|
||||||
// my $size = $self->GetClientSize;
|
|
||||||
// my @quat = trackball(
|
m_canvas->Refresh();
|
||||||
// $orig->x / ($size->width / 2) - 1,
|
m_canvas->Update();
|
||||||
// 1 - $orig->y / ($size->height / 2), # /
|
}
|
||||||
// $pos->x / ($size->width / 2) - 1,
|
m_drag.set_start_position_3D(Pointf3((coordf_t)pos.x, (coordf_t)pos.y, 0.0));
|
||||||
// 1 - $pos->y / ($size->height / 2), # /
|
}
|
||||||
// );
|
else if (evt.MiddleIsDown() || evt.RightIsDown())
|
||||||
// $self->_quat(mulquats($self->_quat, \@quat));
|
{
|
||||||
// }
|
// If dragging over blank area with right button, pan.
|
||||||
// $self->on_viewport_changed->() if $self->on_viewport_changed;
|
if (m_drag.is_start_position_2D_defined())
|
||||||
// $self->Refresh;
|
{
|
||||||
// $self->Update;
|
// get point in model space at Z = 0
|
||||||
// }
|
float z = 0.0f;
|
||||||
// $self->_drag_start_pos($pos);
|
const Pointf3& cur_pos = _mouse_to_3d(pos, &z);
|
||||||
// } elsif($e->MiddleIsDown || $e->RightIsDown) {
|
Pointf3 orig = _mouse_to_3d(m_drag.get_start_position_2D(), &z);
|
||||||
// # If dragging over blank area with right button, pan.
|
Pointf3 camera_target = get_camera_target();
|
||||||
// if (defined $self->_drag_start_xy) {
|
camera_target.translate(orig.vector_to(cur_pos).negative());
|
||||||
// # get point in model space at Z = 0
|
set_camera_target(camera_target);
|
||||||
// my $cur_pos = $self->mouse_to_3d($e->GetX, $e->GetY, 0);
|
|
||||||
// my $orig = $self->mouse_to_3d($self->_drag_start_xy->x, $self->_drag_start_xy->y, 0);
|
m_on_viewport_changed_callback.call();
|
||||||
// my $camera_target = Slic3r::GUI::_3DScene::get_camera_target($self);
|
|
||||||
// $camera_target->translate(@{$orig->vector_to($cur_pos)->negative});
|
m_canvas->Refresh();
|
||||||
// Slic3r::GUI::_3DScene::set_camera_target($self, $camera_target);
|
m_canvas->Update();
|
||||||
// $self->on_viewport_changed->() if $self->on_viewport_changed;
|
}
|
||||||
// $self->Refresh;
|
|
||||||
// $self->Update;
|
m_drag.set_start_position_2D(pos);
|
||||||
// }
|
}
|
||||||
// $self->_drag_start_xy($pos);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
else if (evt.LeftUp() || evt.MiddleUp() || evt.RightUp())
|
else if (evt.LeftUp() || evt.MiddleUp() || evt.RightUp())
|
||||||
{
|
{
|
||||||
|
|
|
@ -324,6 +324,9 @@ public:
|
||||||
const Pointf3& get_start_position_3D() const;
|
const Pointf3& get_start_position_3D() const;
|
||||||
void set_start_position_3D(const Pointf3& position);
|
void set_start_position_3D(const Pointf3& position);
|
||||||
|
|
||||||
|
bool is_start_position_2D_defined() const;
|
||||||
|
bool is_start_position_3D_defined() const;
|
||||||
|
|
||||||
const Vectorf3& get_volume_center_offset() const;
|
const Vectorf3& get_volume_center_offset() const;
|
||||||
void set_volume_center_offset(const Vectorf3& offset);
|
void set_volume_center_offset(const Vectorf3& offset);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue