[F] React on mouse pressing ig view only.

pull/1981/head
smalcom 2018-05-24 13:05:50 +03:00
parent f56432f713
commit fd7f07068c
2 changed files with 40 additions and 25 deletions

View File

@ -128,13 +128,26 @@ void MainWindow::LogError(const QString& pMessage)
void MainWindow::mousePressEvent(QMouseEvent* pEvent)
{
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 = pEvent->pos();
mPosition_Pressed_LMB = ms_pt;
else if(pEvent->button() & Qt::RightButton)
mPosition_Pressed_RMB = pEvent->pos();
mPosition_Pressed_RMB = ms_pt;
}
else
{
mPosition_Pressed_Valid = false;
}
}
void MainWindow::mouseMoveEvent(QMouseEvent* pEvent)
{
if(mPosition_Pressed_Valid)
{
if(pEvent->buttons() & Qt::LeftButton)
{
@ -164,6 +177,7 @@ void MainWindow::mouseMoveEvent(QMouseEvent* pEvent)
mPosition_Pressed_RMB = pEvent->pos();
}
}
}
void MainWindow::keyPressEvent(QKeyEvent* pEvent)
{
@ -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;

View File

@ -36,6 +36,7 @@ private:
CLoggerView* mLoggerView;///< Pointer to logging object.
Assimp::Importer mImporter;///< Assimp importer.
const aiScene* mScene;///< Pointer to loaded scene (\ref aiScene).
bool mPosition_Pressed_Valid;///< Mouse button pressed on GLView.
QPoint mPosition_Pressed_LMB;///< Position where was pressed left mouse button.
QPoint mPosition_Pressed_RMB;///< Position where was pressed right mouse button.