32 #ifdef G4VIS_BUILD_OPENGLQT_DRIVER
38 #ifdef G4MULTITHREADED
42 #include <qapplication.h>
43 #include <qtabwidget.h>
45 G4OpenGLStoredQtViewer::G4OpenGLStoredQtViewer
46 (G4OpenGLStoredSceneHandler& sceneHandler,
48 G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name),
49 G4OpenGLViewer (sceneHandler),
50 G4OpenGLQtViewer (sceneHandler),
51 G4OpenGLStoredViewer (sceneHandler),
54 fQGLWidgetInitialiseCompleted =
false;
57 QGLWidget::setAttribute (Qt::WA_NoSystemBackground);
59 setFocusPolicy(Qt::StrongFocus);
60 fHasToRepaint =
false;
61 fPaintEventLock =
false;
62 fUpdateGLLock =
false;
64 if (fViewId < 0)
return;
67 G4OpenGLStoredQtViewer::~G4OpenGLStoredQtViewer() {
74 void G4OpenGLStoredQtViewer::Initialise() {
77 fQGLWidgetInitialiseCompleted =
false;
78 CreateMainWindow (
this,QString(GetName()));
80 glDrawBuffer (GL_BACK);
83 if (QGLWidget::parentWidget()) {
84 QTabWidget *parentTab =
dynamic_cast<QTabWidget*
> (QGLWidget::parentWidget()->parent()) ;
86 parentTab->setCurrentIndex(parentTab->count()-1);
90 fQGLWidgetInitialiseCompleted =
true;
93 void G4OpenGLStoredQtViewer::initializeGL () {
97 if (fSceneHandler.GetScene() == 0) {
118 (lastVP.
IsCulling () != fVP.IsCulling ()) ||
123 fVP.GetCBDAlgorithmNumber()) ||
124 (lastVP.
IsSection () != fVP.IsSection ()) ||
128 (lastVP.
IsCutaway () != fVP.IsCutaway ()) ||
131 (lastVP.
IsExplode () != fVP.IsExplode ()) ||
134 fVP.GetDefaultVisAttributes()->
GetColour()) ||
136 fVP.GetDefaultTextVisAttributes()->
GetColour()) ||
138 (lastVP.
IsPicking () != fVP.IsPicking ()))
143 if (fMouseOnSceneTree) {
145 fMouseOnSceneTree =
false;
176 if (lastVP.
GetCBDParameters().size() != fVP.GetCBDParameters().size())
return true;
187 G4bool G4OpenGLStoredQtViewer::POSelected(
size_t POListIndex)
189 return isTouchableVisible(POListIndex);
192 G4bool G4OpenGLStoredQtViewer::TOSelected(
size_t)
197 void G4OpenGLStoredQtViewer::DrawView () {
201 void G4OpenGLStoredQtViewer::ComputeView () {
212 if (!fNeedKernelVisit) {
213 KernelVisitDecision ();
215 G4bool kernelVisitWasNeeded = fNeedKernelVisit;
218 if (kernelVisitWasNeeded) {
219 displaySceneTreeComponent();
229 HaloingSecondPass ();
238 if (!kernelVisitWasNeeded) {
244 if (fVP.IsCutaway() &&
260 fHasToRepaint =
true;
267 void G4OpenGLStoredQtViewer::resizeGL(
272 if ((aWidth > 0) && (aHeight > 0)) {
273 ResizeWindow(aWidth,aHeight);
274 fHasToRepaint = sizeHasChanged();
284 void G4OpenGLStoredQtViewer::paintGL()
286 updateToolbarAndMouseContextMenu();
288 if (fPaintEventLock) {
291 fPaintEventLock =
true;
292 if ((getWinWidth() == 0) && (getWinHeight() == 0)) {
296 if (!fQGLWidgetInitialiseCompleted) {
297 fPaintEventLock =
false;
303 if ( !fHasToRepaint) {
308 if (!isMaximized() && !isFullScreen()) {
309 sw = normalGeometry().width();
310 sh = normalGeometry().height();
312 sw = frameGeometry().width();
313 sh = frameGeometry().height();
315 if ((getWinWidth() == (
unsigned int)sw) &&(getWinHeight() == (
unsigned int)sh)) {
320 glDrawBuffer (GL_BACK);
327 fHasToRepaint =
false;
329 fPaintEventLock =
false;
332 void G4OpenGLStoredQtViewer::paintEvent(QPaintEvent *) {
333 if (! fQGLWidgetInitialiseCompleted) {
337 fHasToRepaint = isFramebufferReady();
338 if ( fHasToRepaint) {
347 void G4OpenGLStoredQtViewer::mousePressEvent(QMouseEvent *event)
349 G4MousePressEvent(event);
352 void G4OpenGLStoredQtViewer::keyPressEvent (QKeyEvent * event)
354 G4keyPressEvent(event);
357 void G4OpenGLStoredQtViewer::keyReleaseEvent (QKeyEvent * event)
359 G4keyReleaseEvent(event);
362 void G4OpenGLStoredQtViewer::wheelEvent (QWheelEvent * event)
367 void G4OpenGLStoredQtViewer::showEvent (QShowEvent *)
369 if (fQGLWidgetInitialiseCompleted) {
370 fHasToRepaint =
true;
378 void G4OpenGLStoredQtViewer::mouseDoubleClickEvent(QMouseEvent *)
380 G4MouseDoubleClickEvent();
383 void G4OpenGLStoredQtViewer::mouseReleaseEvent(QMouseEvent *event)
385 G4MouseReleaseEvent(event);
388 void G4OpenGLStoredQtViewer::mouseMoveEvent(QMouseEvent *event)
390 G4MouseMoveEvent(event);
394 void G4OpenGLStoredQtViewer::contextMenuEvent(QContextMenuEvent *
e)
396 G4manageContextMenuEvent(e);
399 void G4OpenGLStoredQtViewer::updateQWidget() {
404 if (! isCurrentWidget()){
408 fUpdateGLLock =
true;
416 updateViewerPropertiesTableWidget();
417 updateSceneTreeWidget();
418 fUpdateGLLock =
false;
421 void G4OpenGLStoredQtViewer::ShowView (
440 void G4OpenGLStoredQtViewer::DisplayTimePOColourModification (
443 c = getColorForPoIndex(poIndex);