Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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#ifdef G4VIS_BUILD_OIQT_DRIVER
30
31#include <stdlib.h>
32#include <string.h>
33
34#include "G4ios.hh"
35
36#include "G4SoQt.hh"
37//#include "G4Qt.hh"
38//#include "G4UImanager.hh"
39
40#include <Inventor/Qt/SoQt.h>
41#include <QMainWindow>
42
43#include <qwidget.h>
44#include <qapplication.h>
45
46#ifndef G4GMAKE
47#include "moc_G4SoQt.cpp"
48#endif
49
50G4SoQt* G4SoQt::instance = NULL;
51
52static G4bool QtInited = FALSE;
53
54/***************************************************************************/
55G4SoQt* G4SoQt::getInstance()
56{
57 if (instance==NULL) {
58 instance = new G4SoQt();
59 }
60 return instance;
61 // return G4SoQt::getInstance(0, NULL, (char*)"Geant4");
62}
63
64/***************************************************************************/
65//G4SoQt* G4SoQt::getInstance(int a_argn, char** a_args, char* a_class)
66//{
67// if (instance==NULL) {
68// instance = new G4SoQt();
69// }
70// return instance;
71//}
72
73/***************************************************************************/
74G4SoQt::G4SoQt()
75// FWJ command-line arguments omitted for time being
76//G4SoQt* G4SoQt(int a_argn, char** a_args, char*)
77{
78 externalApp = false;
79
80 // FWJ in G4Qt this is used. qApp is Qt global pointer
81 // to the (one and only one) QApplication object:
82 // new QApplication (*p_argn, args);
83 // if(!qApp) {
84
85 // FWJ detects existence of Qt UI or other running qApp
86 if (qApp) externalApp = true;
87
88 QWidget* mainWin = SoQt::init("Geant4");
89
90 // FWJ Cf Xt:
91 QtInited = TRUE;
92
93 // FWJ DEBUG
94 // G4cout << "G4SoQt: mainWin=" << mainWin << G4endl;
95 // G4cout << "G4SoQt: toplevelwidget=" << SoQt::getTopLevelWidget() << G4endl;
96
97// FWJ CAN'T GET MENUBAR THIS WAY OR BY CAST
98 // QWidget* toplevel = SoQt::getTopLevelWidget();
99 // QMenuBar* menubar = QMainWindow::menuBar();
100 // G4cout << "G4OpenInventorQtExaminerViewer menubar=" << menubar << G4endl;
101
102
103 // FWJ will this work?
104 SetMainInteractor(mainWin);
105 // SetMainInteractor(qApp);
106 // AddDispatcher ((G4DispatchFunction)XtDispatchEvent);
107
108// FWJ no locale for now (see G4Qt.cc)
109
110}
111
112/***************************************************************************/
113G4SoQt::~G4SoQt()
114{
115 if(this==instance) {
116 instance = NULL;
117 }
118}
119
120G4bool G4SoQt::Inited()
121{
122 return QtInited;
123}
124
125/***************************************************************************/
126void* G4SoQt::GetEvent()
127{
128 return 0;
129}
130
131
132/***************************************************************************/
133void G4SoQt::FlushAndWaitExecution()
134{
135 // FWJ the following is used in G4Qt:
136 // if(!qApp) return;
137 // This starts the Qt main loop:
138 // qApp->processEvents();
139
140 // FWJ no, should be done in secondaryLoop()!
141 // SoQt::mainLoop();
142}
143/***************************************************************************/
144void G4SoQt::SecondaryLoop()
145{
146 // FWJ DEBUG
147 if (externalApp) return;
148
149 // G4cout <<
150 // "ENTERING OIQT VIEWER SECONDARY LOOP" << G4endl;
151 // else
152 G4cout <<
153 "ENTERING OIQT VIEWER SECONDARY LOOP... PRESS E KEY TO EXIT" << G4endl;
154
155 SoQt::mainLoop();
156}
157/***************************************************************************/
158void G4SoQt::ExitSecondaryLoop()
159{
160 // FWJ DEBUG
161 // G4cout << "G4SoQt: EXIT SECONDARY LOOP externalApp=" <<
162 // externalApp << G4endl;
163
164 if (externalApp) return;
165 SoQt::exitMainLoop();
166}
167/***************************************************************************/
168bool G4SoQt::IsExternalApp()
169{
170 return externalApp;
171}
172
173#endif
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