diff --git a/modules/gfx/src/entity.cc b/modules/gfx/src/entity.cc index 87754017859d3ffea6f55642ecad4673a3f885b2..7094c5d579f609a3695b39c62aac1620fd03d1ac 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 052f5c9f2d94298eb0b84e2367383ff9ece45aee..0938781ac087e73e54c7f53b6cd4870c325eef3a 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 c24691c4463aaf276c11ebac494eca384840b661..ee663099d35393bb0ea9698f87256fbc90056bd0 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 + } } }