From 81a2a04dd008b2a3a1df540ee98d17b9055df0c2 Mon Sep 17 00:00:00 2001 From: Guillaumebeuzeboc Date: Wed, 21 Nov 2018 00:24:01 +0100 Subject: [PATCH] feat(rotZ): add rotation around z if middle is pressed --- src/main.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index b6c55e3..b26dbbe 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,7 +2,6 @@ #include #include #include -//#include #include #include #include @@ -55,18 +54,28 @@ class GLWidget : public QGLWidget{ void mouseMoveEvent(QMouseEvent *event){ - if (event->buttons() & Qt::LeftButton) { + if (event->buttons() & Qt::MidButton) { + if (is_dragging_){ + double tmp_rot_x_ = (event->y() - last_dragging_y_) * 0.003; + trans_tmp_ << cos(tmp_rot_x_), -sin(tmp_rot_x_), 0.0, 0.0, + sin(tmp_rot_x_), cos(tmp_rot_x_), 0.0, 0.0, + 0.0 , 0.0, 1.0, 0.0, + 0.0 , 0.0, 0.0, 1.0; + trans_ = trans_tmp_ * trans_; + }else{ + is_dragging_ = true; + } + } + else if (event->buttons() & Qt::LeftButton) { if(is_dragging_) { trans_tmp_ << 1.0, 0.0, 0.0, (event->x() - last_dragging_x_) * 0.005, 0.0, 1.0, 0.0, -(event->y() - last_dragging_y_) * 0.005, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0; trans_ = trans_tmp_ * trans_; - } else{ is_dragging_ = true; - } } else if (event->buttons() & Qt::RightButton) { @@ -86,7 +95,6 @@ class GLWidget : public QGLWidget{ } else{ is_dragging_ = true; - } }