33 #ifdef G4VIS_BUILD_OPENGLQT_DRIVER
40 #include <qapplication.h>
42 G4OpenGLStoredQtViewer::G4OpenGLStoredQtViewer
43 (G4OpenGLStoredSceneHandler& sceneHandler,
45 G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name),
46 G4OpenGLViewer (sceneHandler),
47 G4OpenGLQtViewer (sceneHandler),
48 G4OpenGLStoredViewer (sceneHandler),
53 QGLWidget::setAttribute (Qt::WA_NoSystemBackground);
55 setFocusPolicy(Qt::StrongFocus);
56 fHasToRepaint =
false;
57 fIsRepainting =
false;
59 resize(fVP.GetWindowSizeHintX(),fVP.GetWindowSizeHintY());
61 if (fViewId < 0)
return;
64 G4OpenGLStoredQtViewer::~G4OpenGLStoredQtViewer() {
71 void G4OpenGLStoredQtViewer::Initialise() {
73 #ifdef G4DEBUG_VIS_OGL
74 printf(
"G4OpenGLStoredQtViewer::Initialise 1\n");
77 fReadyToPaint =
false;
78 CreateMainWindow (
this,QString(GetName()));
80 glDrawBuffer (GL_BACK);
85 void G4OpenGLStoredQtViewer::initializeGL () {
89 #ifdef G4DEBUG_VIS_OGL
90 printf(
"G4OpenGLStoredQtViewer::InitialiseGL () 1 %d\n",
this);
93 if (fSceneHandler.GetScene() == 0) {
103 QCoreApplication::sendPostedEvents () ;
105 #ifdef G4DEBUG_VIS_OGL
106 printf(
"G4OpenGLStoredQtViewer::InitialiseGL END\n");
119 (lastVP.
IsCulling () != fVP.IsCulling ()) ||
123 (lastVP.
IsSection () != fVP.IsSection ()) ||
127 (lastVP.
IsCutaway () != fVP.IsCutaway ()) ||
130 (lastVP.
IsExplode () != fVP.IsExplode ()) ||
133 fVP.GetDefaultVisAttributes()->
GetColour()) ||
135 fVP.GetDefaultTextVisAttributes()->
GetColour()) ||
137 (lastVP.
IsPicking () != fVP.IsPicking ())
175 G4bool G4OpenGLStoredQtViewer::POSelected(
size_t POListIndex)
177 return isTouchableVisible(POListIndex);
180 G4bool G4OpenGLStoredQtViewer::TOSelected(
size_t)
185 void G4OpenGLStoredQtViewer::DrawView () {
189 void G4OpenGLStoredQtViewer::ComputeView () {
191 #ifdef G4DEBUG_VIS_OGL
192 printf(
"G4OpenGLStoredQtViewer::ComputeView %d %d VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",getWinWidth(), getWinHeight());
203 if (!fNeedKernelVisit) {
204 KernelVisitDecision ();
206 G4bool kernelVisitWasNeeded = fNeedKernelVisit;
212 #ifdef G4DEBUG_VIS_OGL
213 printf(
"G4OpenGLStoredQtViewer::ComputeView DANS LE IF\n");
220 HaloingSecondPass ();
229 if (!kernelVisitWasNeeded) {
230 #ifdef G4DEBUG_VIS_OGL
231 printf(
"************************** G4OpenGLStoredQtViewer::ComputeView Don't need kernel Visit \n");
236 #ifdef G4DEBUG_VIS_OGL
237 printf(
"************************** G4OpenGLStoredQtViewer::ComputeView need kernel Visit \n");
241 if (fVP.IsCutaway() &&
246 #ifdef G4DEBUG_VIS_OGL
247 printf(
"*************************** CASE 4 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n");
260 #ifdef G4DEBUG_VIS_OGL
261 printf(
"G4OpenGLStoredQtViewer::ComputeView %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",getWinWidth(), getWinHeight());
263 fHasToRepaint =
true;
270 void G4OpenGLStoredQtViewer::resizeGL(
275 if ((aWidth > 0) && (aHeight > 0)) {
276 ResizeWindow(aWidth,aHeight);
277 fHasToRepaint = sizeHasChanged();
287 void G4OpenGLStoredQtViewer::paintGL()
289 updateToolbarAndMouseContextMenu();
291 #ifdef G4DEBUG_VIS_OGL
292 printf(
"G4OpenGLStoredQtViewer::paintGL \n");
297 fIsRepainting =
true;
298 if ((getWinWidth() == 0) && (getWinHeight() == 0)) {
302 #ifdef G4DEBUG_VIS_OGL
303 printf(
"G4OpenGLStoredQtViewer::paintGL ready:%d fHasTo:%d??\n",fReadyToPaint,fHasToRepaint);
305 if (!fReadyToPaint) {
312 if ( !fHasToRepaint) {
317 if (!isMaximized() && !isFullScreen()) {
318 sw = normalGeometry().width();
319 sh = normalGeometry().height();
321 sw = frameGeometry().width();
322 sh = frameGeometry().height();
324 if ((getWinWidth() == (
unsigned int)sw) &&(getWinHeight() == (
unsigned int)sh)) {
328 #ifdef G4DEBUG_VIS_OGL
329 printf(
"G4OpenGLStoredQtViewer::paintGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV ready %d\n",fReadyToPaint);
337 fHasToRepaint =
false;
340 displaySceneTreeComponent();
341 #ifdef G4DEBUG_VIS_OGL
342 printf(
"G4OpenGLStoredQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ready %d\n",fReadyToPaint);
344 fIsRepainting =
false;
347 void G4OpenGLStoredQtViewer::paintEvent(QPaintEvent *) {
348 if ( fHasToRepaint) {
353 void G4OpenGLStoredQtViewer::mousePressEvent(QMouseEvent *event)
355 G4MousePressEvent(event);
358 void G4OpenGLStoredQtViewer::keyPressEvent (QKeyEvent * event)
360 G4keyPressEvent(event);
363 void G4OpenGLStoredQtViewer::wheelEvent (QWheelEvent * event)
368 void G4OpenGLStoredQtViewer::showEvent (QShowEvent *)
370 fHasToRepaint =
true;
377 void G4OpenGLStoredQtViewer::mouseDoubleClickEvent(QMouseEvent *)
379 G4MouseDoubleClickEvent();
382 void G4OpenGLStoredQtViewer::mouseReleaseEvent(QMouseEvent *)
384 G4MouseReleaseEvent();
387 void G4OpenGLStoredQtViewer::mouseMoveEvent(QMouseEvent *event)
389 G4MouseMoveEvent(event);
393 void G4OpenGLStoredQtViewer::contextMenuEvent(QContextMenuEvent *e)
395 G4manageContextMenuEvent(e);
398 void G4OpenGLStoredQtViewer::updateQWidget() {
401 fHasToRepaint=
false;
404 void G4OpenGLStoredQtViewer::ShowView (
420 void G4OpenGLStoredQtViewer::DisplayTimePOColourModification (
423 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