Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4OpenGLImmediateWtViewer.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27// $Id$
28//
29//
30// Class G4OpenGLImmediateWtViewer : a class derived from G4OpenGLWtViewer and
31// G4OpenGLImmediateViewer.
32
33#ifdef G4VIS_BUILD_OPENGLWT_DRIVER
34
37
38// Qt class
39#include <qevent.h>
40
41#include "G4ios.hh"
42
43G4OpenGLImmediateWtViewer::G4OpenGLImmediateWtViewer
44(//G4OpenGLImmediateSceneHandler& sceneHandler,
45 /*Wt::WContainerWidget *aParent,*/ const G4String& name)/*:
46 G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name),
47 G4OpenGLViewer (sceneHandler),
48 G4OpenGLImmediateViewer (sceneHandler)//,
49// Wt::WPaintedWidget(aParent)
50*/
51{
52
53#ifdef G4DEBUG_VIS_OGL
54 printf("G4OpenGLImmediateWtViewer INIT\n");
55#endif
56
57 /**
58 fQtViewer = new G4OpenGLImmediateQtViewer(sceneHandler, name);
59
60 this->mouseWentDown().connect(this,&G4OpenGLImmediateWtViewer::WtMousePressEvent);
61 this->keyPressed().connect(this,&G4OpenGLImmediateWtViewer::WtKeyPressEvent);
62 this->mouseWheel().connect(this,&G4OpenGLImmediateWtViewer::WtWheelEvent);
63 this->doubleClicked().connect(this,&G4OpenGLImmediateWtViewer::WtMouseDoubleClickEvent);
64 this->mouseMoved().connect(this,&G4OpenGLImmediateWtViewer::WtMouseMoveEvent);
65 */
66 // this->mouseWentUp().connect(this,&G4OpenGLImmediateWtViewer::WtMouseReleaseEvent);
67}
68
69G4OpenGLImmediateWtViewer::~G4OpenGLImmediateWtViewer() {
70}
71
72
73
74void G4OpenGLImmediateWtViewer::DrawView() {
75#ifdef G4DEBUG_VIS_OGL
76 printf("G4OpenGLImmediateWtViewer DrawView\n");
77#endif
78 fQtViewer->updateQWidget();
79 // FIXME et printEPS
80}
81
82
83void G4OpenGLImmediateWtViewer::WtMousePressEvent(Wt::WMouseEvent event)
84{
85#ifdef G4DEBUG_VIS_OGL
86 printf("G4OpenGLImmediateWtViewer mousePress\n");
87#endif
88 // boutons et position
89 fQtViewer->G4MousePressEvent(ConvertWtMouseEventToQt(event));
90}
91
92void G4OpenGLImmediateWtViewer::WtKeyPressEvent (Wt::WKeyEvent event)
93{
94#ifdef G4DEBUG_VIS_OGL
95 printf("G4OpenGLImmediateWtViewer keyPressEvent\n");
96#endif
97 fQtViewer->G4keyPressEvent(ConvertWtKeyEventToQt(event));
98}
99
100void G4OpenGLImmediateWtViewer::WtWheelEvent (Wt::WMouseEvent event)
101{
102#ifdef G4DEBUG_VIS_OGL
103 printf("G4OpenGLImmediateWtViewer wheelEvent\n");
104#endif
105 fQtViewer->G4wheelEvent(ConvertWtWheelEventToQt(event));
106}
107
108/**
109 void G4OpenGLImmediateWtViewer::WtShowEvent (QShowEvent *)
110 {
111 fHasToRepaint = true;
112 }
113*/
114
115/**
116 * This function was build in order to make a zoom on double clic event.
117 * It was think to build a rubberband on the zoom area, but never work fine
118 */
119void G4OpenGLImmediateWtViewer::WtMouseDoubleClickEvent(Wt::WMouseEvent )
120{
121#ifdef G4DEBUG_VIS_OGL
122 printf("G4OpenGLImmediateWtViewer mouseDoubleClickEvent\n");
123#endif
124 fQtViewer->G4MouseDoubleClickEvent();
125}
126
127/**
128 void G4OpenGLImmediateWtViewer::WtMouseReleaseEvent(Wt::WMouseEvent )
129 {
130 G4MouseReleaseEvent();
131 }
132*/
133
134void G4OpenGLImmediateWtViewer::WtMouseMoveEvent(Wt::WMouseEvent event)
135{
136#ifdef G4DEBUG_VIS_OGL
137 printf("G4OpenGLImmediateWtViewer mouseMoveEvent\n");
138#endif
139 fQtViewer->G4MouseMoveEvent(ConvertWtMouseEventToQt(event));
140}
141
142
143/**
144 void G4OpenGLImmediateWtViewer::contextMenuEvent(QContextMenuEvent *e)
145 {
146 G4manageContextMenuEvent(e);
147 }
148*/
149
150
151void G4OpenGLImmediateWtViewer::paintEvent(Wt::WPaintDevice * painter) {
152#ifdef G4DEBUG_VIS_OGL
153 printf("G4OpenGLImmediateWtViewer paintEvent\n");
154#endif
155 fQtViewer->updateQWidget();
156}
157
158
159
160
161
162void G4OpenGLImmediateWtViewer::ShowView (
163)
164//////////////////////////////////////////////////////////////////////////////
165//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
166{
167#ifdef G4DEBUG_VIS_OGL
168 printf("G4OpenGLImmediateWtViewer ShowView\n");
169#endif
170 fQtViewer->activateWindow();
171}
172
173
174QMouseEvent * G4OpenGLImmediateWtViewer::ConvertWtMouseEventToQt(Wt::WMouseEvent event) {
175 Qt::MouseButton bt;
176 if (event.button() == (Wt::WMouseEvent::NoButton)) {
177 bt = Qt::NoButton;
178 } else if (event.button() == (Wt::WMouseEvent::LeftButton)) {
179 bt = Qt::LeftButton;
180 } else if (event.button() == (Wt::WMouseEvent::RightButton)) {
181 bt = Qt::RightButton;
182 } else if (event.button() == (Wt::WMouseEvent::MiddleButton)) {
183 bt = Qt::MidButton;
184 }
185
186 Qt::KeyboardModifiers km;
187 if (event.modifiers() == Wt::NoModifier) {
188 km = Qt::NoModifier;
189 } else if (event.modifiers() == Wt::ControlModifier) {
190 km = Qt::ControlModifier;
191 } else if (event.modifiers() == Wt::ShiftModifier) {
192 km = Qt::ShiftModifier;
193 } else if (event.modifiers() == Wt::AltModifier) {
194 km = Qt::AltModifier;
195 } else if (event.modifiers() == Wt::MetaModifier) {
196 km = Qt::MetaModifier;
197 }
198 QPoint pt = QPoint(event.widget().x,event.widget().y);
199 QMouseEvent *e = new QMouseEvent(QEvent::None, pt, bt, bt, km);
200 return e;
201}
202
203
204QWheelEvent * G4OpenGLImmediateWtViewer::ConvertWtWheelEventToQt(Wt::WMouseEvent event) {
205 Qt::MouseButton bt;
206 if (event.button() == (Wt::WMouseEvent::NoButton)) {
207 bt = Qt::NoButton;
208 } else if (event.button() == (Wt::WMouseEvent::LeftButton)) {
209 bt = Qt::LeftButton;
210 } else if (event.button() == (Wt::WMouseEvent::RightButton)) {
211 bt = Qt::RightButton;
212 } else if (event.button() == (Wt::WMouseEvent::MiddleButton)) {
213 bt = Qt::MidButton;
214 }
215
216 Qt::KeyboardModifiers km;
217 if (event.modifiers() == Wt::NoModifier) {
218 km = Qt::NoModifier;
219 } else if (event.modifiers() == Wt::ControlModifier) {
220 km = Qt::ControlModifier;
221 } else if (event.modifiers() == Wt::ShiftModifier) {
222 km = Qt::ShiftModifier;
223 } else if (event.modifiers() == Wt::AltModifier) {
224 km = Qt::AltModifier;
225 } else if (event.modifiers() == Wt::MetaModifier) {
226 km = Qt::MetaModifier;
227 }
228 QPoint pt = QPoint(event.widget().x,event.widget().y);
229 QWheelEvent *e = new QWheelEvent( pt, event.wheelDelta (), bt, km);
230 return e;
231}
232
233
234QKeyEvent * G4OpenGLImmediateWtViewer::ConvertWtKeyEventToQt(Wt::WKeyEvent event) {
235
236 Qt::KeyboardModifiers km;
237 if (event.modifiers() == Wt::NoModifier) {
238 km = Qt::NoModifier;
239 } else if (event.modifiers() == Wt::ControlModifier) {
240 km = Qt::ControlModifier;
241 } else if (event.modifiers() == Wt::ShiftModifier) {
242 km = Qt::ShiftModifier;
243 } else if (event.modifiers() == Wt::AltModifier) {
244 km = Qt::AltModifier;
245 } else if (event.modifiers() == Wt::MetaModifier) {
246 km = Qt::MetaModifier;
247 }
248 QKeyEvent *e = new QKeyEvent( QEvent::None, event.charCode(), km );
249 return e;
250}
251#endif