Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYRenderWindowInteractor.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012> <EDF-R&D> <FRANCE>
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  * See the GNU General Public License for more details.
11  * You should have received a copy of the GNU General Public License along
12  * with this program; if not, write to the Free Software Foundation, Inc.,
13  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
14  */
15 
16 // Added by qt3to4:
17 #include <QMouseEvent>
18 #include <QKeyEvent>
19 #include <QWheelEvent>
21 
30 #include <qcursor.h>
31 
33  : TYRenderWindow(pParent, name)
34 {
35  init();
36 }
37 
38 TYRenderWindowInteractor::TYRenderWindowInteractor(QGLFormat glf, QWidget* pParent, const char* name)
39  : TYRenderWindow(glf, pParent, name)
40 {
41  init();
42 }
43 
45 {
46  setMouseTracking(true);
47 
48  setCursor(Qt::CrossCursor);
49 }
50 
52 
54 {
55  emit(mousePressed(pEvent->x(), pEvent->y(), pEvent->button(), pEvent->modifiers()));
56 }
57 
59 {
60  emit(mouseReleased(pEvent->x(), pEvent->y(), pEvent->button(), pEvent->modifiers()));
61 }
62 
64 {
65  emit(mouseDoubleClicked(pEvent->x(), pEvent->y(), pEvent->button(), pEvent->modifiers()));
66 }
67 
69 {
70  emit(mouseMoved(pEvent->x(), pEvent->y(), pEvent->buttons(), pEvent->modifiers()));
71 }
72 
73 void TYRenderWindowInteractor::wheelEvent(QWheelEvent* pEvent)
74 {
75  if (hasFocus())
76  {
77  QPoint numPixels = pEvent->pixelDelta();
78  QPoint numDegrees = pEvent->angleDelta();
79  if (!numPixels.isNull())
80  {
81  emit(wheeled(pEvent->position().toPoint().x(), pEvent->position().toPoint().y(), numPixels.y(),
82  pEvent->modifiers()));
83  }
84  else if (!numDegrees.isNull())
85  {
86  QPoint numSteps = numDegrees;
87  emit(wheeled(pEvent->position().toPoint().x(), pEvent->position().toPoint().y(), numSteps.y(),
88  pEvent->modifiers()));
89  }
90  }
91  pEvent->accept();
92 }
93 
95 {
96  if (pEvent->isAutoRepeat())
97  {
98  // pEvent->ignore();
99  }
100  else
101  {
102  emit(keyPressed(pEvent->key()));
103  // pEvent->accept();
104  }
105 }
106 
108 {
109  if (pEvent->isAutoRepeat())
110  {
111  // pEvent->ignore();
112  }
113  else
114  {
115  emit(keyReleased(pEvent->key()));
116  // pEvent->accept();
117  }
118 }
Le role de cette classe est limite a emettre des signaux pouvant etre utilise pour interagir sur le r...
const char * name
virtual void mouseMoveEvent(QMouseEvent *pEvent)
void mouseMoved(int x, int y, Qt::MouseButtons button, Qt::KeyboardModifiers state)
TYRenderWindowInteractor(QWidget *pParent=0, const char *name=0)
virtual void wheelEvent(QWheelEvent *pEvent)
void mouseDoubleClicked(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state)
virtual void mouseDoubleClickEvent(QMouseEvent *pEvent)
virtual void mousePressEvent(QMouseEvent *pEvent)
virtual void keyReleaseEvent(QKeyEvent *pEvent)
virtual void mouseReleaseEvent(QMouseEvent *pEvent)
void keyPressed(int key)
void wheeled(int x, int y, int delta, Qt::KeyboardModifiers state)
void mousePressed(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state)
virtual void keyPressEvent(QKeyEvent *pEvent)
void mouseReleased(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state)
void keyReleased(int key)
Combine QGLWidget de Qt pour Tympan.