Geant4-11
G4SoQt.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27// F.W. Jones 05012018
28
29#include <stdlib.h>
30#include <string.h>
31
32#include "G4ios.hh"
33
34#include "G4SoQt.hh"
35//#include "G4Qt.hh"
36//#include "G4UImanager.hh"
37
38#include <Inventor/Qt/SoQt.h>
39#include <QMainWindow>
40
41#include <qwidget.h>
42#include <qapplication.h>
43
44#ifndef G4GMAKE
45#include "moc_G4SoQt.cpp"
46#endif
47
49
51
52
53/***************************************************************************/
55{
56 if (instance==NULL) {
57 instance = new G4SoQt();
58 }
59 return instance;
60}
61
62
63/***************************************************************************/
65// FWJ command-line arguments omitted for time being
66//G4SoQt* G4SoQt(int a_argn, char** a_args, char*)
67{
68 externalApp = false;
69
70 // FWJ in G4Qt this is used. qApp is Qt global pointer
71 // to the (one and only one) QApplication object:
72 // new QApplication (*p_argn, args);
73 // if(!qApp) {
74
75 // FWJ detects existence of Qt UI or other running qApp
76 if (qApp) externalApp = true;
77
78 QWidget* mainWin = SoQt::init("Geant4");
79
80 // FWJ Cf Xt:
81 QtInited = TRUE;
82
83 // FWJ DEBUG
84 // G4cout << "G4SoQt: mainWin=" << mainWin << G4endl;
85 // G4cout << "G4SoQt: toplevelwidget=" << SoQt::getTopLevelWidget() << G4endl;
86
87// FWJ CAN'T GET MENUBAR THIS WAY OR BY CAST
88 // QWidget* toplevel = SoQt::getTopLevelWidget();
89 // QMenuBar* menubar = QMainWindow::menuBar();
90 // G4cout << "G4OpenInventorQtExaminerViewer menubar=" << menubar << G4endl;
91
92
93 // FWJ will this work?
94 SetMainInteractor(mainWin);
95 // SetMainInteractor(qApp);
96 // AddDispatcher ((G4DispatchFunction)XtDispatchEvent);
97
98// FWJ no locale for now (see G4Qt.cc)
99
100}
101
102/***************************************************************************/
104{
105 if(this==instance) {
106 instance = NULL;
107 }
108}
109
111{
112 return QtInited;
113}
114
115/***************************************************************************/
117{
118 return 0;
119}
120
121
122/***************************************************************************/
124{
125 // FWJ the following is used in G4Qt:
126 // if(!qApp) return;
127 // This starts the Qt main loop:
128 // qApp->processEvents();
129
130 // FWJ no, should be done in secondaryLoop()!
131 // SoQt::mainLoop();
132}
133
134
135/***************************************************************************/
137{
138 if (externalApp) return;
139
140 // FWJ DEBUG
141 // G4cout <<
142 // "ENTERING OIQT VIEWER SECONDARY LOOP" << G4endl;
143 // else
144
145 G4cout <<
146 "ENTERING OIQT VIEWER SECONDARY LOOP... PRESS E KEY TO EXIT" << G4endl;
147
148 SoQt::mainLoop();
149}
150
151
152/***************************************************************************/
154{
155 // FWJ DEBUG
156 // G4cout << "G4SoQt: EXIT SECONDARY LOOP externalApp=" <<
157 // externalApp << G4endl;
158
159 if (externalApp) return;
160 SoQt::exitMainLoop();
161}
162/***************************************************************************/
164{
165 return externalApp;
166}
static G4bool QtInited
Definition: G4SoQt.cc:50
bool G4bool
Definition: G4Types.hh:86
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
#define TRUE
Definition: Globals.hh:27
#define FALSE
Definition: Globals.hh:23
Definition: G4SoQt.hh:46
G4SoQt()
Definition: G4SoQt.cc:64
static G4SoQt * getInstance()
Definition: G4SoQt.cc:54
static G4SoQt * instance
Definition: G4SoQt.hh:65
bool externalApp
Definition: G4SoQt.hh:68
virtual ~G4SoQt()
Definition: G4SoQt.cc:103
G4bool Inited()
Definition: G4SoQt.cc:110
void FlushAndWaitExecution()
Definition: G4SoQt.cc:123
void ExitSecondaryLoop()
Definition: G4SoQt.cc:153
bool IsExternalApp()
Definition: G4SoQt.cc:163
void SecondaryLoop()
Definition: G4SoQt.cc:136
void * GetEvent()
Definition: G4SoQt.cc:116
void SetMainInteractor(G4Interactor)