33 #ifdef G4VIS_BUILD_OPENGLQT_DRIVER
39 #ifdef G4MULTITHREADED
43 #include <qapplication.h>
45 G4OpenGLStoredQtViewer::G4OpenGLStoredQtViewer
46 (G4OpenGLStoredSceneHandler& sceneHandler,
48 G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name),
49 G4OpenGLViewer (sceneHandler),
50 G4OpenGLQtViewer (sceneHandler),
51 G4OpenGLStoredViewer (sceneHandler),
56 QGLWidget::setAttribute (Qt::WA_NoSystemBackground);
58 setFocusPolicy(Qt::StrongFocus);
59 fHasToRepaint =
false;
60 fPaintEventLock =
false;
61 fUpdateGLLock =
false;
63 resize(fVP.GetWindowSizeHintX(),fVP.GetWindowSizeHintY());
65 if (fViewId < 0)
return;
68 G4OpenGLStoredQtViewer::~G4OpenGLStoredQtViewer() {
75 void G4OpenGLStoredQtViewer::Initialise() {
77 #ifdef G4DEBUG_VIS_OGL
78 printf(
"G4OpenGLStoredQtViewer::Initialise 1\n");
81 fQGLWidgetInitialiseCompleted =
false;
82 CreateMainWindow (
this,QString(GetName()));
84 glDrawBuffer (GL_BACK);
85 fQGLWidgetInitialiseCompleted =
true;
89 void G4OpenGLStoredQtViewer::initializeGL () {
93 #ifdef G4DEBUG_VIS_OGL
94 printf(
"G4OpenGLStoredQtViewer::InitialiseGL () 1 %d\n",
this);
97 if (fSceneHandler.GetScene() == 0) {
107 QCoreApplication::sendPostedEvents () ;
109 #ifdef G4DEBUG_VIS_OGL
110 printf(
"G4OpenGLStoredQtViewer::InitialiseGL END\n");
123 (lastVP.
IsCulling () != fVP.IsCulling ()) ||
127 (lastVP.
IsSection () != fVP.IsSection ()) ||
131 (lastVP.
IsCutaway () != fVP.IsCutaway ()) ||
134 (lastVP.
IsExplode () != fVP.IsExplode ()) ||
137 fVP.GetDefaultVisAttributes()->
GetColour()) ||
139 fVP.GetDefaultTextVisAttributes()->
GetColour()) ||
141 (lastVP.
IsPicking () != fVP.IsPicking ())
179 G4bool G4OpenGLStoredQtViewer::POSelected(
size_t POListIndex)
181 return isTouchableVisible(POListIndex);
184 G4bool G4OpenGLStoredQtViewer::TOSelected(
size_t)
189 void G4OpenGLStoredQtViewer::DrawView () {
190 #ifdef G4MULTITHREADED
199 void G4OpenGLStoredQtViewer::ComputeView () {
201 #ifdef G4DEBUG_VIS_OGL
202 printf(
"G4OpenGLStoredQtViewer::ComputeView %d %d VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",getWinWidth(), getWinHeight());
213 if (!fNeedKernelVisit) {
214 KernelVisitDecision ();
216 G4bool kernelVisitWasNeeded = fNeedKernelVisit;
219 if (fNeedKernelVisit) {
220 displaySceneTreeComponent();
224 #ifdef G4DEBUG_VIS_OGL
225 printf(
"G4OpenGLStoredQtViewer::ComputeView DANS LE IF\n");
232 HaloingSecondPass ();
241 if (!kernelVisitWasNeeded) {
242 #ifdef G4DEBUG_VIS_OGL
243 printf(
"************************** G4OpenGLStoredQtViewer::ComputeView Don't need kernel Visit \n");
248 #ifdef G4DEBUG_VIS_OGL
249 printf(
"************************** G4OpenGLStoredQtViewer::ComputeView need kernel Visit \n");
253 if (fVP.IsCutaway() &&
258 #ifdef G4DEBUG_VIS_OGL
259 printf(
"*************************** CASE 4 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n");
272 #ifdef G4DEBUG_VIS_OGL
273 printf(
"G4OpenGLStoredQtViewer::ComputeView %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",getWinWidth(), getWinHeight());
275 fHasToRepaint =
true;
282 void G4OpenGLStoredQtViewer::resizeGL(
287 if ((aWidth > 0) && (aHeight > 0)) {
288 ResizeWindow(aWidth,aHeight);
289 fHasToRepaint = sizeHasChanged();
299 void G4OpenGLStoredQtViewer::paintGL()
301 updateToolbarAndMouseContextMenu();
303 #ifdef G4DEBUG_VIS_OGL
304 printf(
"G4OpenGLStoredQtViewer::paintGL \n");
306 if (fPaintEventLock) {
309 fPaintEventLock =
true;
310 if ((getWinWidth() == 0) && (getWinHeight() == 0)) {
314 #ifdef G4DEBUG_VIS_OGL
315 printf(
"G4OpenGLStoredQtViewer::paintGL ready:%d fHasTo:%d??\n",fReadyToPaint,fHasToRepaint);
317 if (!fQGLWidgetInitialiseCompleted) {
318 fPaintEventLock =
false;
324 if ( !fHasToRepaint) {
329 if (!isMaximized() && !isFullScreen()) {
330 sw = normalGeometry().width();
331 sh = normalGeometry().height();
333 sw = frameGeometry().width();
334 sh = frameGeometry().height();
336 if ((getWinWidth() == (
unsigned int)sw) &&(getWinHeight() == (
unsigned int)sh)) {
340 #ifdef G4DEBUG_VIS_OGL
341 printf(
"G4OpenGLStoredQtViewer::paintGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV ready %d\n",fReadyToPaint);
344 glDrawBuffer (GL_BACK);
351 fHasToRepaint =
false;
353 #ifdef G4DEBUG_VIS_OGL
354 printf(
"G4OpenGLStoredQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ready %d\n",fReadyToPaint);
356 fPaintEventLock =
false;
359 void G4OpenGLStoredQtViewer::paintEvent(QPaintEvent *) {
360 if (! fQGLWidgetInitialiseCompleted) {
363 if ( fHasToRepaint) {
372 void G4OpenGLStoredQtViewer::mousePressEvent(QMouseEvent *event)
374 G4MousePressEvent(event);
377 void G4OpenGLStoredQtViewer::keyPressEvent (QKeyEvent * event)
379 G4keyPressEvent(event);
382 void G4OpenGLStoredQtViewer::keyReleaseEvent (QKeyEvent * event)
384 G4keyReleaseEvent(event);
387 void G4OpenGLStoredQtViewer::wheelEvent (QWheelEvent * event)
392 void G4OpenGLStoredQtViewer::showEvent (QShowEvent *)
394 fHasToRepaint =
true;
401 void G4OpenGLStoredQtViewer::mouseDoubleClickEvent(QMouseEvent *)
403 G4MouseDoubleClickEvent();
406 void G4OpenGLStoredQtViewer::mouseReleaseEvent(QMouseEvent *event)
408 G4MouseReleaseEvent(event);
411 void G4OpenGLStoredQtViewer::mouseMoveEvent(QMouseEvent *event)
413 G4MouseMoveEvent(event);
417 void G4OpenGLStoredQtViewer::contextMenuEvent(QContextMenuEvent *e)
419 G4manageContextMenuEvent(e);
422 void G4OpenGLStoredQtViewer::updateQWidget() {
426 fUpdateGLLock =
true;
433 updateSceneTreeComponentTreeWidgetInfos();
434 fHasToRepaint=
false;
435 fUpdateGLLock =
false;
438 void G4OpenGLStoredQtViewer::ShowView (
455 void G4OpenGLStoredQtViewer::DisplayTimePOColourModification (
458 c = getColorForPoIndex(poIndex);
const G4Colour & GetBackgroundColour() const
G4double GetVisibleDensity() const
G4bool IsCullingInvisible() const
G4double GetExplodeFactor() const
static G4bool GetColour(const G4String &key, G4Colour &result)
const G4Colour & GetColour() const
G4bool IsDensityCulling() const
G4bool IsAuxEdgeVisible() const
G4bool IsCullingCovered() const
const G4VisAttributes * GetDefaultTextVisAttributes() const
G4int GetNoOfSides() const
DrawingStyle GetDrawingStyle() const
const G4VisAttributes * GetDefaultVisAttributes() const