33 #ifdef G4VIS_BUILD_OPENGLQT_DRIVER
39 #ifdef G4MULTITHREADED
43 #include <qapplication.h>
44 #include <qtabwidget.h>
46 G4OpenGLStoredQtViewer::G4OpenGLStoredQtViewer
47 (G4OpenGLStoredSceneHandler& sceneHandler,
49 G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name),
50 G4OpenGLViewer (sceneHandler),
51 G4OpenGLQtViewer (sceneHandler),
52 G4OpenGLStoredViewer (sceneHandler),
55 fQGLWidgetInitialiseCompleted =
false;
58 QGLWidget::setAttribute (Qt::WA_NoSystemBackground);
60 setFocusPolicy(Qt::StrongFocus);
61 fHasToRepaint =
false;
62 fPaintEventLock =
false;
63 fUpdateGLLock =
false;
65 if (fViewId < 0)
return;
68 G4OpenGLStoredQtViewer::~G4OpenGLStoredQtViewer() {
75 void G4OpenGLStoredQtViewer::Initialise() {
78 fQGLWidgetInitialiseCompleted =
false;
79 CreateMainWindow (
this,QString(GetName()));
81 glDrawBuffer (GL_BACK);
84 if (QGLWidget::parentWidget()) {
85 QTabWidget *parentTab =
dynamic_cast<QTabWidget*
> (QGLWidget::parentWidget()->parent()) ;
87 parentTab->setCurrentIndex(parentTab->count()-1);
91 fQGLWidgetInitialiseCompleted =
true;
94 void G4OpenGLStoredQtViewer::initializeGL () {
98 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;
178 if (lastVP.
GetCBDParameters().size() != fVP.GetCBDParameters().size())
return true;
189 G4bool G4OpenGLStoredQtViewer::POSelected(
size_t POListIndex)
191 return isTouchableVisible(POListIndex);
194 G4bool G4OpenGLStoredQtViewer::TOSelected(
size_t)
199 void G4OpenGLStoredQtViewer::DrawView () {
203 void G4OpenGLStoredQtViewer::ComputeView () {
214 if (!fNeedKernelVisit) {
215 KernelVisitDecision ();
217 G4bool kernelVisitWasNeeded = fNeedKernelVisit;
220 if (kernelVisitWasNeeded) {
221 displaySceneTreeComponent();
231 HaloingSecondPass ();
240 if (!kernelVisitWasNeeded) {
246 if (fVP.IsCutaway() &&
262 fHasToRepaint =
true;
269 void G4OpenGLStoredQtViewer::resizeGL(
274 if ((aWidth > 0) && (aHeight > 0)) {
275 ResizeWindow(aWidth,aHeight);
276 fHasToRepaint = sizeHasChanged();
286 void G4OpenGLStoredQtViewer::paintGL()
288 updateToolbarAndMouseContextMenu();
290 if (fPaintEventLock) {
293 fPaintEventLock =
true;
294 if ((getWinWidth() == 0) && (getWinHeight() == 0)) {
298 if (!fQGLWidgetInitialiseCompleted) {
299 fPaintEventLock =
false;
305 if ( !fHasToRepaint) {
310 if (!isMaximized() && !isFullScreen()) {
311 sw = normalGeometry().width();
312 sh = normalGeometry().height();
314 sw = frameGeometry().width();
315 sh = frameGeometry().height();
317 if ((getWinWidth() == (
unsigned int)sw) &&(getWinHeight() == (
unsigned int)sh)) {
322 glDrawBuffer (GL_BACK);
329 fHasToRepaint =
false;
331 fPaintEventLock =
false;
334 void G4OpenGLStoredQtViewer::paintEvent(QPaintEvent *) {
335 if (! fQGLWidgetInitialiseCompleted) {
339 fHasToRepaint = isFramebufferReady();
340 if ( fHasToRepaint) {
349 void G4OpenGLStoredQtViewer::mousePressEvent(QMouseEvent *event)
351 G4MousePressEvent(event);
354 void G4OpenGLStoredQtViewer::keyPressEvent (QKeyEvent * event)
356 G4keyPressEvent(event);
359 void G4OpenGLStoredQtViewer::keyReleaseEvent (QKeyEvent * event)
361 G4keyReleaseEvent(event);
364 void G4OpenGLStoredQtViewer::wheelEvent (QWheelEvent * event)
369 void G4OpenGLStoredQtViewer::showEvent (QShowEvent *)
371 if (fQGLWidgetInitialiseCompleted) {
372 fHasToRepaint =
true;
380 void G4OpenGLStoredQtViewer::mouseDoubleClickEvent(QMouseEvent *)
382 G4MouseDoubleClickEvent();
385 void G4OpenGLStoredQtViewer::mouseReleaseEvent(QMouseEvent *event)
387 G4MouseReleaseEvent(event);
390 void G4OpenGLStoredQtViewer::mouseMoveEvent(QMouseEvent *event)
392 G4MouseMoveEvent(event);
396 void G4OpenGLStoredQtViewer::contextMenuEvent(QContextMenuEvent *
e)
398 G4manageContextMenuEvent(e);
401 void G4OpenGLStoredQtViewer::updateQWidget() {
406 if (! isCurrentWidget()){
410 fUpdateGLLock =
true;
418 updateViewerPropertiesTableWidget();
419 updateSceneTreeWidget();
420 fUpdateGLLock =
false;
423 void G4OpenGLStoredQtViewer::ShowView (
442 void G4OpenGLStoredQtViewer::DisplayTimePOColourModification (
445 c = getColorForPoIndex(poIndex);
const std::vector< G4ModelingParameters::VisAttributesModifier > & GetVisAttributesModifiers() const
G4double GetExplodeFactor() const
G4bool IsDensityCulling() const
G4bool IsAuxEdgeVisible() const
const std::vector< G4double > & GetCBDParameters() const
G4int GetCBDAlgorithmNumber() const
const G4VisAttributes * GetDefaultVisAttributes() const
G4int GetNoOfSides() const
G4bool IsCullingInvisible() const
DrawingStyle GetDrawingStyle() const
const G4Colour & GetBackgroundColour() const
const G4VisAttributes * GetDefaultTextVisAttributes() const
G4bool IsCullingCovered() const
G4double GetVisibleDensity() const
const G4Colour & GetColour() const
static G4bool GetColour(const G4String &key, G4Colour &result)