From 96054d054fea14290bef1c329e669810048768d6 Mon Sep 17 00:00:00 2001 From: Ansgar Philippsen <ansgar.philippsen@gmail.com> Date: Thu, 15 Nov 2012 11:35:54 -0500 Subject: [PATCH] fixed manip tool mouse bindings; fixed manip tool breaking picking --- modules/gfx/src/entity.cc | 9 +++-- modules/gfx/src/gfx_object.cc | 5 +++ modules/gui/src/tools/manipulator.cc | 51 ++++++++++++++++++---------- 3 files changed, 46 insertions(+), 19 deletions(-) diff --git a/modules/gfx/src/entity.cc b/modules/gfx/src/entity.cc index 877540178..7094c5d57 100644 --- a/modules/gfx/src/entity.cc +++ b/modules/gfx/src/entity.cc @@ -396,12 +396,17 @@ mol::AtomHandle Entity::PickAtom(const geom::Line3& line, Real line_width) { mol::AtomHandle picked_atom; if (!this->IsVisible()) - return picked_atom; + return picked_atom; + geom::Mat4 it=GetTF().GetInvertedMatrix(); + geom::Vec3 l1=geom::Vec3(it*geom::Vec4(line.At(0.0))); + geom::Vec3 l2=geom::Vec3(it*geom::Vec4(line.At(1.0))); + geom::Line3 tf_line(l1,l2); + for (RendererMap::iterator i=renderer_.begin(), e=renderer_.end(); i!=e; ++i) { impl::EntityRenderer* r=i->second; if (r->HasDataToRender() && r->IsEnabled()) { - r->PickAtom(line, line_width, picked_atom); + r->PickAtom(tf_line, line_width, picked_atom); } } return picked_atom; diff --git a/modules/gfx/src/gfx_object.cc b/modules/gfx/src/gfx_object.cc index 052f5c9f2..0938781ac 100644 --- a/modules/gfx/src/gfx_object.cc +++ b/modules/gfx/src/gfx_object.cc @@ -544,6 +544,11 @@ void GfxObj::OnInput(const InputEvent& e) trans+=geom::Vec3(0.0, -fy*e.GetDelta(), 0.0)*rot; } transform_.SetTrans(trans); + } else if (e.GetCommand()==INPUT_COMMAND_TRANSZ) { + float currz=transform_.GetTrans()[2]; + float delta=currz*pow(1.01f,-e.GetDelta())-currz; + transform_.ApplyZAxisTranslation(delta); + transformed=true; } if (transformed) { GfxObjP obj=dyn_cast<GfxObj>(this->shared_from_this()); diff --git a/modules/gui/src/tools/manipulator.cc b/modules/gui/src/tools/manipulator.cc index c24691c44..ee663099d 100644 --- a/modules/gui/src/tools/manipulator.cc +++ b/modules/gui/src/tools/manipulator.cc @@ -39,27 +39,44 @@ Manipulator::Manipulator(): void Manipulator::MouseMove(const MouseEvent& event) { - if (event.GetButtons()==MouseEvent::LeftButton) { - if (event.IsShiftPressed()) { - SendCommand(gfx::INPUT_COMMAND_TRANSX, - static_cast<Real>(event.GetDelta().x())); - SendCommand(gfx::INPUT_COMMAND_TRANSY, - static_cast<Real>(-event.GetDelta().y())); - } else { - SendCommand(gfx::INPUT_COMMAND_ROTY, - static_cast<Real>(event.GetDelta().x())); // rotation around y - SendCommand(gfx::INPUT_COMMAND_ROTX, - static_cast<Real>(event.GetDelta().y())); // rotation around x - } - } else if (event.GetButtons()==MouseEvent::MiddleButton) { + static bool warn=true; + // reference is GLCanvas::HandleMouseMoveEvent + if (event.GetButtons() & MouseEvent::LeftButton) { + if (event.GetButtons() & MouseEvent::MiddleButton) { if (event.IsShiftPressed()) { - // rotation around z + // slab in view, ignore here + } else { Real d=static_cast<Real>(event.GetDelta().x()+event.GetDelta().y()); - SendCommand(gfx::INPUT_COMMAND_ROTZ, d); + SendCommand(gfx::INPUT_COMMAND_ROTZ, -d); + } + } else { + if (event.IsShiftPressed()) { + SendCommand(gfx::INPUT_COMMAND_TRANSX, + static_cast<Real>(event.GetDelta().x())); + SendCommand(gfx::INPUT_COMMAND_TRANSY, + static_cast<Real>(-event.GetDelta().y())); } else { - SendCommand(gfx::INPUT_COMMAND_TRANSZ, - static_cast<Real>(event.GetDelta().y())); // translate along z + SendCommand(gfx::INPUT_COMMAND_ROTY, + static_cast<Real>(event.GetDelta().x())); // rotation around y + SendCommand(gfx::INPUT_COMMAND_ROTX, + static_cast<Real>(event.GetDelta().y())); // rotation around x + } + } + } else if (event.GetButtons() & MouseEvent::MiddleButton) { + if (event.IsShiftPressed()) { + if(warn) { + LOG_WARNING("Manipulation Tool: MMB + Shift for z rotation is deprecated; use LMB+MMB instead"); + warn=false; } + // rotation around z + // WHY? this does not match the scene view transformation, which has a slab tf here + // will be removed in a next update... + Real d=static_cast<Real>(event.GetDelta().x()+event.GetDelta().y()); + SendCommand(gfx::INPUT_COMMAND_ROTZ, d); + } else { + SendCommand(gfx::INPUT_COMMAND_TRANSZ, + static_cast<Real>(event.GetDelta().y())); // translate along z + } } } -- GitLab