|
@@ -128,40 +128,54 @@ void MainWindow::LogError(const QString& pMessage)
|
|
|
|
|
|
void MainWindow::mousePressEvent(QMouseEvent* pEvent)
|
|
|
{
|
|
|
- if(pEvent->button() & Qt::LeftButton)
|
|
|
- mPosition_Pressed_LMB = pEvent->pos();
|
|
|
- else if(pEvent->button() & Qt::RightButton)
|
|
|
- mPosition_Pressed_RMB = pEvent->pos();
|
|
|
+const QPoint ms_pt = pEvent->pos();
|
|
|
+
|
|
|
+ // Check if GLView is pointed.
|
|
|
+ if(childAt(ms_pt) == mGLView)
|
|
|
+ {
|
|
|
+ mPosition_Pressed_Valid = true;
|
|
|
+ if(pEvent->button() & Qt::LeftButton)
|
|
|
+ mPosition_Pressed_LMB = ms_pt;
|
|
|
+ else if(pEvent->button() & Qt::RightButton)
|
|
|
+ mPosition_Pressed_RMB = ms_pt;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ mPosition_Pressed_Valid = false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void MainWindow::mouseMoveEvent(QMouseEvent* pEvent)
|
|
|
{
|
|
|
- if(pEvent->buttons() & Qt::LeftButton)
|
|
|
+ if(mPosition_Pressed_Valid)
|
|
|
{
|
|
|
- GLfloat dx = 180 * GLfloat(pEvent->x() - mPosition_Pressed_LMB.x()) / mGLView->width();
|
|
|
- GLfloat dy = 180 * GLfloat(pEvent->y() - mPosition_Pressed_LMB.y()) / mGLView->height();
|
|
|
+ if(pEvent->buttons() & Qt::LeftButton)
|
|
|
+ {
|
|
|
+ GLfloat dx = 180 * GLfloat(pEvent->x() - mPosition_Pressed_LMB.x()) / mGLView->width();
|
|
|
+ GLfloat dy = 180 * GLfloat(pEvent->y() - mPosition_Pressed_LMB.y()) / mGLView->height();
|
|
|
|
|
|
- if(pEvent->modifiers() & Qt::ShiftModifier)
|
|
|
- mGLView->Camera_RotateScene(dy, 0, dx);// Rotate around oX and oZ axises.
|
|
|
- else
|
|
|
- mGLView->Camera_RotateScene(dy, dx, 0);// Rotate around oX and oY axises.
|
|
|
+ if(pEvent->modifiers() & Qt::ShiftModifier)
|
|
|
+ mGLView->Camera_RotateScene(dy, 0, dx);// Rotate around oX and oZ axises.
|
|
|
+ else
|
|
|
+ mGLView->Camera_RotateScene(dy, dx, 0);// Rotate around oX and oY axises.
|
|
|
|
|
|
- mGLView->updateGL();
|
|
|
- mPosition_Pressed_LMB = pEvent->pos();
|
|
|
- }
|
|
|
+ mGLView->updateGL();
|
|
|
+ mPosition_Pressed_LMB = pEvent->pos();
|
|
|
+ }
|
|
|
|
|
|
- if(pEvent->buttons() & Qt::RightButton)
|
|
|
- {
|
|
|
- GLfloat dx = 180 * GLfloat(pEvent->x() - mPosition_Pressed_RMB.x()) / mGLView->width();
|
|
|
- GLfloat dy = 180 * GLfloat(pEvent->y() - mPosition_Pressed_RMB.y()) / mGLView->height();
|
|
|
+ if(pEvent->buttons() & Qt::RightButton)
|
|
|
+ {
|
|
|
+ GLfloat dx = 180 * GLfloat(pEvent->x() - mPosition_Pressed_RMB.x()) / mGLView->width();
|
|
|
+ GLfloat dy = 180 * GLfloat(pEvent->y() - mPosition_Pressed_RMB.y()) / mGLView->height();
|
|
|
|
|
|
- if(pEvent->modifiers() & Qt::ShiftModifier)
|
|
|
- mGLView->Camera_Rotate(dy, 0, dx);// Rotate around oX and oZ axises.
|
|
|
- else
|
|
|
- mGLView->Camera_Rotate(dy, dx, 0);// Rotate around oX and oY axises.
|
|
|
+ if(pEvent->modifiers() & Qt::ShiftModifier)
|
|
|
+ mGLView->Camera_Rotate(dy, 0, dx);// Rotate around oX and oZ axises.
|
|
|
+ else
|
|
|
+ mGLView->Camera_Rotate(dy, dx, 0);// Rotate around oX and oY axises.
|
|
|
|
|
|
- mGLView->updateGL();
|
|
|
- mPosition_Pressed_RMB = pEvent->pos();
|
|
|
+ mGLView->updateGL();
|
|
|
+ mPosition_Pressed_RMB = pEvent->pos();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -198,7 +212,7 @@ GLfloat step;
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
|
|
: QMainWindow(parent), ui(new Ui::MainWindow),
|
|
|
- mScene(nullptr)
|
|
|
+ mScene(nullptr), mPosition_Pressed_Valid(false)
|
|
|
{
|
|
|
using namespace Assimp;
|
|
|
|