Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYRenderWindowInteractor.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012-2024> <EDF-DTG> <FRANCE>
3  * This file is part of Code_TYMPAN (R).
4  * Code_TYMPAN (R) is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * Code_TYMPAN (R) is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  * You should have received a copy of the GNU General Public License along
13  * with Code_TYMPAN (R). If not, see <https://www.gnu.org/licenses/>.
14  */
15 
16 // Added by qt3to4:
17 #include <QMouseEvent>
18 #include <QKeyEvent>
19 #include <QWheelEvent>
21 
30 #include <qcursor.h>
31 #include <qpoint.h>
32 
34  : TYRenderWindow(pParent, name)
35 {
36  init();
37 }
38 
40 {
41  setMouseTracking(true);
42 
43  setCursor(Qt::CrossCursor);
44 }
45 
47 
49 {
50  makeCurrent();
51  QPoint coords = toViewport(pEvent->pos());
52  emit(mousePressed(coords.x(), coords.y(), pEvent->button(), pEvent->modifiers()));
53 }
54 
56 {
57  makeCurrent();
58  QPoint coords = toViewport(pEvent->pos());
59  emit(mouseReleased(coords.x(), coords.y(), pEvent->button(), pEvent->modifiers()));
60 }
61 
63 {
64  makeCurrent();
65  QPoint coords = toViewport(pEvent->pos());
66  emit(mouseDoubleClicked(coords.x(), coords.y(), pEvent->button(), pEvent->modifiers()));
67 }
68 
70 {
71  makeCurrent();
72  QPoint coords = toViewport(pEvent->pos());
73  emit(mouseMoved(coords.x(), coords.y(), pEvent->buttons(), pEvent->modifiers()));
74 }
75 
76 void TYRenderWindowInteractor::wheelEvent(QWheelEvent* pEvent)
77 {
78  makeCurrent();
79  QPoint coords = toViewport(pEvent->position().toPoint());
80  if (hasFocus())
81  {
82  QPoint numPixels = pEvent->pixelDelta();
83  QPoint numDegrees = pEvent->angleDelta();
84  if (!numPixels.isNull())
85  {
86  emit(wheeled(coords.x(), coords.y(), numPixels.y(), pEvent->modifiers()));
87  }
88  else if (!numDegrees.isNull())
89  {
90  QPoint numSteps = numDegrees;
91  emit(wheeled(coords.x(), coords.y(), numSteps.y(), pEvent->modifiers()));
92  }
93  }
94  pEvent->accept();
95 }
96 
98 {
99  makeCurrent();
100  if (pEvent->isAutoRepeat())
101  {
102  // pEvent->ignore();
103  }
104  else
105  {
106  emit(keyPressed(pEvent->key()));
107  // pEvent->accept();
108  }
109 }
110 
112 {
113  makeCurrent();
114  if (pEvent->isAutoRepeat())
115  {
116  // pEvent->ignore();
117  }
118  else
119  {
120  emit(keyReleased(pEvent->key()));
121  // pEvent->accept();
122  }
123 }
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 QOpenGLWidget de Qt pour Tympan.
QPoint toViewport(QPoint point)