[F] React on mouse pressing ig view only.
parent
f56432f713
commit
fd7f07068c
|
@ -128,14 +128,27 @@ 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)
|
||||
{
|
||||
GLfloat dx = 180 * GLfloat(pEvent->x() - mPosition_Pressed_LMB.x()) / mGLView->width();
|
||||
|
@ -163,6 +176,7 @@ void MainWindow::mouseMoveEvent(QMouseEvent* pEvent)
|
|||
mGLView->updateGL();
|
||||
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;
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
Loading…
Reference in New Issue