Commit 84fe346d authored by CGoGN GIT Supervisor's avatar CGoGN GIT Supervisor
Browse files

Merge branch 'master' of /home/kraemer/CGoGN

* 'master' of /home/kraemer/CGoGN:
  QTgl -> ajout evenement mouseClick
parents 86d40771 dc1e629f
...@@ -274,10 +274,15 @@ public: ...@@ -274,10 +274,15 @@ public:
*/ */
virtual void cb_mouseRelease(int button, int x, int y) {} virtual void cb_mouseRelease(int button, int x, int y) {}
/**
* Mouse button has been clicked
*/
virtual void cb_mouseClick(int button, int x, int y) {}
/** /**
* the mouse has been move (with button still pressed) * the mouse has been move (with button still pressed)
*/ */
virtual void cb_mouseMove(int x, int y) {} virtual void cb_mouseMove(int button, int x, int y) {}
/** /**
* key press CB (context is ok) * key press CB (context is ok)
......
...@@ -70,6 +70,7 @@ protected: ...@@ -70,6 +70,7 @@ protected:
std::stack<glm::mat4> m_stack_mv; std::stack<glm::mat4> m_stack_mv;
int m_current_button; int m_current_button;
QPoint clickPoint;
int beginx; int beginx;
int beginy; int beginy;
int newModel; int newModel;
...@@ -101,17 +102,20 @@ public: ...@@ -101,17 +102,20 @@ public:
void resizeGL(int width, int height); void resizeGL(int width, int height);
void mousePressEvent(QMouseEvent *event); public:
void mousePressEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent *event); void mouseClickEvent(QMouseEvent* event);
void mouseMoveEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent* event);
void keyPressEvent(QKeyEvent *event); void keyPressEvent(QKeyEvent* event);
void keyReleaseEvent(QKeyEvent *event); void keyReleaseEvent(QKeyEvent* event);
void wheelEvent ( QWheelEvent * event ); void wheelEvent(QWheelEvent* event);
bool Shift() { return m_state_modifier & Qt::ShiftModifier; } bool Shift() { return m_state_modifier & Qt::ShiftModifier; }
......
...@@ -152,20 +152,32 @@ void GLWidget::mousePressEvent(QMouseEvent* event) ...@@ -152,20 +152,32 @@ void GLWidget::mousePressEvent(QMouseEvent* event)
{ {
beginx = event->x(); beginx = event->x();
beginy = event->y(); beginy = event->y();
clickPoint = event->pos();
m_current_button = event->button(); m_current_button = event->button();
if (m_cbs) if (m_cbs)
m_cbs->cb_mousePress(event->button(), event->x(), event->y()); m_cbs->cb_mousePress(event->button(), event->x(), getHeight() - event->y());
} }
void GLWidget::mouseReleaseEvent(QMouseEvent* event) void GLWidget::mouseReleaseEvent(QMouseEvent* event)
{ {
if (m_cbs) if (m_cbs)
m_cbs->cb_mouseRelease(event->button(), event->x(), event->y()); m_cbs->cb_mouseRelease(event->button(), event->x(), getHeight() - event->y());
if(event->pos() == clickPoint)
mouseClickEvent(event) ;
}
void GLWidget::mouseClickEvent(QMouseEvent* event)
{
if (m_cbs)
m_cbs->cb_mouseClick(event->button(), event->x(), getHeight() - event->y());
} }
void GLWidget::mouseMoveEvent(QMouseEvent* event) void GLWidget::mouseMoveEvent(QMouseEvent* event)
{ {
if(m_state_modifier == Qt::NoModifier)
{
int x = event->x(); int x = event->x();
int y = event->y(); int y = event->y();
...@@ -175,7 +187,7 @@ void GLWidget::mouseMoveEvent(QMouseEvent* event) ...@@ -175,7 +187,7 @@ void GLWidget::mouseMoveEvent(QMouseEvent* event)
{ {
float wl; float wl;
if (m_cbs->trans_z() > -20.0f) if (m_cbs->trans_z() > -20.0f)
wl = 20.0f/foc; wl = 20.0f / foc;
else else
wl = -2.0f * m_cbs->trans_z() / foc; wl = -2.0f * m_cbs->trans_z() / foc;
m_cbs->trans_x() += wl / W * (x - beginx); m_cbs->trans_x() += wl / W * (x - beginx);
...@@ -206,9 +218,10 @@ void GLWidget::mouseMoveEvent(QMouseEvent* event) ...@@ -206,9 +218,10 @@ void GLWidget::mouseMoveEvent(QMouseEvent* event)
beginy = y; beginy = y;
newModel = 1; newModel = 1;
updateGL(); updateGL();
}
if (m_cbs) if (m_cbs)
m_cbs->cb_mouseMove(event->x(), event->y()); m_cbs->cb_mouseMove(event->button(), event->x(), getHeight() - event->y());
} }
void GLWidget::wheelEvent ( QWheelEvent * event ) void GLWidget::wheelEvent ( QWheelEvent * event )
...@@ -249,7 +262,7 @@ void GLWidget::keyReleaseEvent(QKeyEvent *event) ...@@ -249,7 +262,7 @@ void GLWidget::keyReleaseEvent(QKeyEvent *event)
int k = event->key(); int k = event->key();
if ( (k >= 65) && (k <= 91) && (event->modifiers() != Qt::ShiftModifier) ) if ( (k >= 65) && (k <= 91) && (event->modifiers() != Qt::ShiftModifier) )
k+=32; k += 32;
if (m_cbs) if (m_cbs)
m_cbs->cb_keyRelease(k); m_cbs->cb_keyRelease(k);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment