mirror of https://github.com/CGAL/cgal
Center the camera on the cursor at first tick of optical zoom
This commit is contained in:
parent
121a23d964
commit
b116a92be3
|
|
@ -1167,7 +1167,6 @@ protected:
|
|||
QMap<WheelBindingPrivate, MouseActionPrivate> wheelBinding_;
|
||||
QMap<ClickBindingPrivate, qglviewer::ClickAction> clickBinding_;
|
||||
::Qt::Key currentlyPressedKey_;
|
||||
bool z_is_pressed;
|
||||
// S t a t e F i l e
|
||||
QString stateFileName_;
|
||||
|
||||
|
|
@ -1212,6 +1211,9 @@ protected:
|
|||
bool is_sharing;
|
||||
bool is_linked;
|
||||
QOpenGLContext* shared_context;
|
||||
// Zoom
|
||||
bool _first_tick;
|
||||
|
||||
public:
|
||||
//! Is used to know if the openGL context is 4.3 or ES 2.0.
|
||||
//! @returns `true` if the context is 4.3.
|
||||
|
|
|
|||
|
|
@ -155,6 +155,7 @@ void CGAL::QGLViewer::defaultConstructor() {
|
|||
is_sharing = false;
|
||||
is_linked = false;
|
||||
shared_context = nullptr;
|
||||
_first_tick = true;
|
||||
}
|
||||
|
||||
CGAL_INLINE_FUNCTION
|
||||
|
|
@ -1544,6 +1545,17 @@ void CGAL::QGLViewer::wheelEvent(QWheelEvent *e) {
|
|||
MouseActionPrivate map = wheelBinding_[wbp];
|
||||
switch (map.handler) {
|
||||
case qglviewer::CAMERA:
|
||||
if(currentlyPressedKey_ == ::Qt::Key_Z && _first_tick)
|
||||
{
|
||||
_first_tick = false;
|
||||
makeCurrent();
|
||||
//orient camera to the cursor.
|
||||
bool found = false;
|
||||
qglviewer::Vec point;
|
||||
point = camera()->pointUnderPixel(mapFromGlobal(QCursor::pos()), found);
|
||||
if(found)
|
||||
camera()->lookAt(point);
|
||||
}
|
||||
camera()->frame()->startAction(map.action, map.withConstraint);
|
||||
camera()->frame()->wheelEvent(e, camera());
|
||||
break;
|
||||
|
|
@ -2263,21 +2275,11 @@ void CGAL::QGLViewer::keyPressEvent(QKeyEvent *e) {
|
|||
|
||||
const ::Qt::Key key = ::Qt::Key(e->key());
|
||||
|
||||
const ::Qt::KeyboardModifiers modifiers = e->modifiers();
|
||||
|
||||
if(key == ::Qt::Key_Z && ! e->isAutoRepeat())
|
||||
{
|
||||
makeCurrent();
|
||||
//orient camera to the cursor.
|
||||
bool found = false;
|
||||
qglviewer::Vec point;
|
||||
point = camera()->pointUnderPixel(mapFromGlobal(QCursor::pos()), found);
|
||||
if(!found)
|
||||
return;
|
||||
camera()->lookAt(point);
|
||||
update();
|
||||
return;
|
||||
_first_tick = true;
|
||||
}
|
||||
const ::Qt::KeyboardModifiers modifiers = e->modifiers();
|
||||
QMap<qglviewer::KeyboardAction, unsigned int>::ConstIterator it = keyboardBinding_
|
||||
.begin(),
|
||||
end =
|
||||
|
|
|
|||
Loading…
Reference in New Issue