Commit dc1e629f authored by Pierre Kraemer's avatar Pierre Kraemer

QTgl -> ajout evenement mouseClick

parent eeaa15ab
......@@ -272,10 +272,15 @@ public:
*/
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)
*/
virtual void cb_mouseMove(int x, int y) {}
virtual void cb_mouseMove(int button, int x, int y) {}
/**
* key press CB (context is ok)
......
......@@ -69,6 +69,7 @@ protected:
std::stack<glm::mat4> m_stack_mv;
int m_current_button;
QPoint clickPoint;
int beginx;
int beginy;
int newModel;
......@@ -100,17 +101,20 @@ public:
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; }
......
......@@ -148,20 +148,32 @@ void GLWidget::mousePressEvent(QMouseEvent* event)
{
beginx = event->x();
beginy = event->y();
clickPoint = event->pos();
m_current_button = event->button();
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)
{
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)
{
if(m_state_modifier == Qt::NoModifier)
{
int x = event->x();
int y = event->y();
......@@ -171,7 +183,7 @@ void GLWidget::mouseMoveEvent(QMouseEvent* event)
{
float wl;
if (m_cbs->trans_z() > -20.0f)
wl = 20.0f/foc;
wl = 20.0f / foc;
else
wl = -2.0f * m_cbs->trans_z() / foc;
m_cbs->trans_x() += wl / W * (x - beginx);
......@@ -202,9 +214,10 @@ void GLWidget::mouseMoveEvent(QMouseEvent* event)
beginy = y;
newModel = 1;
updateGL();
}
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 )
......@@ -245,7 +258,7 @@ void GLWidget::keyReleaseEvent(QKeyEvent *event)
int k = event->key();
if ( (k >= 65) && (k <= 91) && (event->modifiers() != Qt::ShiftModifier) )
k+=32;
k += 32;
if (m_cbs)
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