Geant4-11
G4ToolsSGQtGLES.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// Guy Barrand 12th March 2021
27
28#include "G4ToolsSGQtGLES.hh"
29
30//
31#define G4TOOLSSG_QT_VIEWER_IN_TAB
32
33#ifdef G4TOOLSSG_QT_VIEWER_IN_TAB
34#include "G4ToolsSGQtViewer.hh"
35#else
36#include "G4ToolsSGViewer.hh"
37#include <tools/Qt/sg_viewer>
38#endif
39
40#include <tools/argcv>
41
44("TOOLSSG_QT_GLES",
45 "TSG_QT_GLES",
46 "TOOLSSG_QT_GLES is a graphics driver based on the g4tools tools/sg scene graph logic where\n\
47 the rendering is done with GLES and the windowing is done with Qt.",
48 parent::threeDInteractive)
49,fSGSession(nullptr)
50{}
51
53 delete fSGSession;
54}
55
57 if(fSGSession) return; //done.
58 int* argc = new int;
59 char** argv = nullptr;
60 std::vector<std::string> args;args.push_back("");
61 tools::new_argcv(args,*argc,argv);
62 fSGSession = new tools::Qt::session(G4cout,*argc,argv);
63 if(!fSGSession->is_valid()) {
64 G4cerr << "G4ToolsSGQtGLES::Initialise : session::is_valid() failed." << G4endl;
65 delete fSGSession;
66 fSGSession = nullptr;
67 return;
68 }
69}
70
72 G4VSceneHandler* pScene = new G4ToolsSGSceneHandler(*this, a_name);
73 return pScene;
74}
75
78 if(!fSGSession) return nullptr;
79 G4VViewer* pView =
80#ifdef G4TOOLSSG_QT_VIEWER_IN_TAB
82#else
84#endif
85 if (pView) {
86 if (pView->GetViewId() < 0) {
87 G4cerr << "G4ToolsSGQtGLES::CreateViewer:"
88 << " ERROR flagged by negative view id in G4ToolsSGViewer creation."
89 << "\n Destroying view and returning null pointer." << G4endl;
90 delete pView;
91 pView = nullptr;
92 }
93 }
94 if (!pView) {
95 G4cerr << "G4ToolsSGQtGLES::CreateViewer: ERROR: null pointer on new G4ToolsSGViewer." << G4endl;
96 return nullptr;
97 }
98 return pView;
99}
100
102{
103 G4bool isCompatible = false;
104// G4UImanager* ui = G4UImanager::GetUIpointer();
105// G4UIsession* session = ui->GetSession();
106//
107// // If session is a batch session, it may be:
108// // a) this is a batch job (the user has not instantiated any UI session);
109// // b) we are currently processing a UI command, in which case the UI
110// // manager creates a temporary batch session and to find out if there is
111// // a genuine UI session that the user has instantiated we must drill
112// // down through previous sessions to a possible non-batch session.
113// while (G4UIbatch* batch = dynamic_cast<G4UIbatch*>(session)) {
114// session = batch->GetPreviousSession();
115// }
116//
117// // Qt windows are only appropriate in a Qt session.
118// if (session) {
119// // If non-zero, this is the originating non-batch session
120// // The user has instantiated a UI session...
121// if (dynamic_cast<G4UIQt*>(session)) {
122// // ...and it's a G4UIQt session, which is OK.
123 isCompatible = true;
124// }
125// }
126 return isCompatible;
127}
bool G4bool
Definition: G4Types.hh:86
static char ** args
Definition: G4Xt.cc:51
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4VViewer * CreateViewer(G4VSceneHandler &, const G4String &name="")
tools::Qt::session * fSGSession
G4bool IsUISessionCompatible() const
virtual ~G4ToolsSGQtGLES()
G4VSceneHandler * CreateSceneHandler(const G4String &name="")
G4int GetViewId() const
static G4UIterminal * session