32#ifdef G4VIS_BUILD_OPENGLQT_DRIVER
42#include <qapplication.h>
43#include <qtabwidget.h>
45G4OpenGLStoredQtViewer::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;
67G4OpenGLStoredQtViewer::~G4OpenGLStoredQtViewer() {
74void 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;
93void 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 ()) ||
137 fVP.GetDefaultVisAttributes()->
GetColour()) ||
139 fVP.GetDefaultTextVisAttributes()->
GetColour()) ||
141 (lastVP.
IsPicking () != fVP.IsPicking ()))
146 if (fMouseOnSceneTree) {
148 fMouseOnSceneTree =
false;
179 if (lastVP.
GetCBDParameters().size() != fVP.GetCBDParameters().size())
return true;
190G4bool G4OpenGLStoredQtViewer::POSelected(
size_t POListIndex)
192 return isTouchableVisible(POListIndex);
195G4bool G4OpenGLStoredQtViewer::TOSelected(
size_t)
200void G4OpenGLStoredQtViewer::DrawView () {
204void G4OpenGLStoredQtViewer::ComputeView () {
215 if (!fNeedKernelVisit) {
216 KernelVisitDecision ();
219 G4bool kernelVisitWasNeeded = fNeedKernelVisit;
222 if (kernelVisitWasNeeded) {
223 displaySceneTreeComponent();
233 HaloingSecondPass ();
242 if (!kernelVisitWasNeeded) {
248 if (fVP.IsCutaway() &&
264 fHasToRepaint =
true;
271void G4OpenGLStoredQtViewer::resizeGL(
276 if ((aWidth > 0) && (aHeight > 0)) {
277 ResizeWindow(aWidth,aHeight);
278 fHasToRepaint = sizeHasChanged();
288void G4OpenGLStoredQtViewer::paintGL()
290 updateToolbarAndMouseContextMenu();
292 if (fPaintEventLock) {
295 fPaintEventLock =
true;
296 if ((getWinWidth() == 0) && (getWinHeight() == 0)) {
300 if (!fQGLWidgetInitialiseCompleted) {
301 fPaintEventLock =
false;
307 if ( !fHasToRepaint) {
312 if (!isMaximized() && !isFullScreen()) {
313 sw = normalGeometry().width();
314 sh = normalGeometry().height();
316 sw = frameGeometry().width();
317 sh = frameGeometry().height();
319 if ((getWinWidth() == (
unsigned int)sw) &&(getWinHeight() == (
unsigned int)sh)) {
324 glDrawBuffer (GL_BACK);
331 fHasToRepaint =
false;
333 fPaintEventLock =
false;
336void G4OpenGLStoredQtViewer::paintEvent(QPaintEvent *) {
337 if (! fQGLWidgetInitialiseCompleted) {
341 fHasToRepaint = isFramebufferReady();
342 if ( fHasToRepaint) {
351void G4OpenGLStoredQtViewer::mousePressEvent(QMouseEvent *event)
353 G4MousePressEvent(event);
356void G4OpenGLStoredQtViewer::keyPressEvent (QKeyEvent * event)
358 G4keyPressEvent(event);
361void G4OpenGLStoredQtViewer::keyReleaseEvent (QKeyEvent * event)
363 G4keyReleaseEvent(event);
366void G4OpenGLStoredQtViewer::wheelEvent (QWheelEvent * event)
371void G4OpenGLStoredQtViewer::showEvent (QShowEvent *)
373 if (fQGLWidgetInitialiseCompleted) {
374 fHasToRepaint =
true;
382void G4OpenGLStoredQtViewer::mouseDoubleClickEvent(QMouseEvent *)
384 G4MouseDoubleClickEvent();
387void G4OpenGLStoredQtViewer::mouseReleaseEvent(QMouseEvent *event)
389 G4MouseReleaseEvent(event);
392void G4OpenGLStoredQtViewer::mouseMoveEvent(QMouseEvent *event)
394 G4MouseMoveEvent(event);
398void G4OpenGLStoredQtViewer::contextMenuEvent(QContextMenuEvent *e)
400 G4manageContextMenuEvent(e);
403void G4OpenGLStoredQtViewer::updateQWidget() {
408 if (! isCurrentWidget()){
412 fUpdateGLLock =
true;
420 updateViewerPropertiesTableWidget();
421 updateSceneTreeWidget();
422 fUpdateGLLock =
false;
425void G4OpenGLStoredQtViewer::ShowView (
444void G4OpenGLStoredQtViewer::DisplayTimePOColourModification (
447 c = getColorForPoIndex(poIndex);
static G4bool GetColour(const G4String &key, G4Colour &result)
const std::vector< G4ModelingParameters::VisAttributesModifier > & GetVisAttributesModifiers() const
G4int GetNoOfSides() const
G4double GetExplodeFactor() const
G4int GetNumberOfCloudPoints() const
G4bool IsMarkerNotHidden() const
G4double GetGlobalLineWidthScale() const
const G4Colour & GetBackgroundColour() const
const G4VisAttributes * GetDefaultTextVisAttributes() const
const std::vector< G4double > & GetCBDParameters() const
G4int GetCBDAlgorithmNumber() const
G4double GetGlobalMarkerScale() const
G4bool IsCullingInvisible() const
const G4VisAttributes * GetDefaultVisAttributes() const
G4bool IsDensityCulling() const
G4double GetVisibleDensity() const
G4bool IsCullingCovered() const
const G4Plane3D & GetSectionPlane() const
DrawingStyle GetDrawingStyle() const
G4bool IsAuxEdgeVisible() const
const G4Colour & GetColour() const
const char * name(G4int ptype)