Even if I need the interactive session to temporanely try to compile the simulation I commented the lines of point 3, but now I get the errors and the warnings reported in the attached error log: error log.txt (8.3 KB)
@bmorgan maybe, you know how to make working the simulation on windows?
G4UItcsh.hh isn’t built on Windows as it’s not supported on that platform, so the application as coded can only work on Unix systems. To make it work on Windows, you can either:
Rewrite the block to only support terminal sessions, but across platforms:
The compilers on Windows should always define the _WIN32 macro, but I’m not a regular Windows user, so you should check. You can also add additional logic to select different sessions as explained in the relevant section of the Application Developer Manual
Use the G4UIExecutive helper as shown in the examples, and described in the Application Developer Manual. This will select a “best” UI depending on how Geant4 was configured, or a UI can be selected using env vars or a control file.
Hi @bmorgan sorry for late reply but I’ve just read your message!
I used first option and it works!
I’ve one more question please.
Usually, in my simulations, I run the simulation without the macro and I can automatically see the interactive simulation by QT.
Using this simulation, running the simulation without the macro i.e.
C:\SimLuna\21nep\Build\Release>SimLuna.exe
I get
*************************************************************
Geant4 version Name: geant4-11-00-patch-03 [MT] (16-September-2022)
Copyright : Geant4 Collaboration
References : NIM A 506 (2003), 250-303
: IEEE-TNS 53 (2006), 270-278
: NIM A 835 (2016), 186-225
WWW : http://geant4.org/
**************************************************************
Visualization Manager instantiating with verbosity "warnings (3)"...
Visualization Manager initialising...
Registering graphics systems...
You have successfully registered the following graphics systems.
Registered graphics systems are:
ASCIITree (ATree)
DAWNFILE (DAWNFILE)
G4HepRepFile (HepRepFile)
RayTracer (RayTracer)
VRML2FILE (VRML2FILE)
gMocrenFile (gMocrenFile)
OpenGLImmediateQt (OGLIQt, OGLI)
OpenGLStoredQt (OGLSQt, OGL, OGLS)
Qt3D (Qt3D)
Registering model factories...
You have successfully registered the following model factories.
Registered model factories:
generic
drawByAttribute
drawByCharge
drawByOriginVolume
drawByParticleID
drawByEncounteredVolume
Registered models:
None
Registered filter factories:
attributeFilter
chargeFilter
originVolumeFilter
particleFilter
encounteredVolumeFilter
Registered filters:
None
You have successfully registered the following user vis actions.
Run Duration User Vis Actions: none
End of Event User Vis Actions: none
End of Run User Vis Actions: none
Some /vis commands (optionally) take a string to specify colour.
"/vis/list" to see available colours.
PreInit>
These walk through the various ways of setting UI/Vis up, but in short, you probably want to use G4UIExecutive and G4VisExecutive as these should set up all available sessions/drivers. Note that in this case, your CMakeLists.txt script should find Geant4 as:
find_package(Geant4 REQUIRED ui_all vis_all)
so all the compile/link flags enable everything.
In the case of G4UIExecutive it will select “best” session at runtime, to Qt if available, falling back to terminal otherwise. The session can also be selected as documented in How to Set Up an Interactive Session.
G4UItcsh is not a “visualization method.” It is a simple shell based (specifically, tcsh) interface to let you type commands. For visualization, you may have your version of Geant4 compiled with OpenGL, in which case you may be able to use /vis/open OGL to get a visualization window. You will obviously NOT get the Qt interface, since you don’t have Qt installed.
As @mkelsey notes, what UI and what Vis drivers are available depends both on how you built Geant4 itself, but also on how you configure your application. It’s this later case that was outline above. By finding Geant4 in CMake via:
find_package(Geant4 REQUIRED ui_all vis_all)
this tells CMake to set up compiling and linking of the application with all UI and Vis drivers available in the found install. The second part to this is in the use of G4UIexecutive and G4VisExecutive in the application’s main() program, as shown in the basic and other examples.
Think of these as “builders” that construct and make available the interface/drivers. A given application can only have one UI at a time, so G4UIexecutive constructs the “best” available given what’s available in the install: Qt, then Xm/Xt, then terminal with G4tcsh if available, or G4csh otherwise. Multiple vis drivers can however be loaded, and that’s what G4VisExecutive does, with the log message:
You have successfully registered the following graphics systems.
Registered graphics systems are:
showing what’s available in this build of the application. This may not show every single driver available from the Geant4 install compiled/linked to, but it should do if you use CMake and find Geant4 with the ui_all vis_all component arguments to find_package.
TLDR; yes, I suggest you use the G4UIexecutive/G4VisExecutive pairing as this together with the find_package call as outline will enable all available drivers in the application.
Thank you the both @mkelsey and @bmorgan
As I wrote, I modified the code to choose if use G4UItcsh or VIS (i.e. the one working with QT) and I’m able to use QT now.
In the original code, only G4UItcsh was implemented …then how could the developer get eps images like this one:
Right, that’s visualisation though - whilst there can only be one UI session at a time, it is possible (IIRC) to have multiple vis drivers open. E.g. visualize in G4UIQt with OpenGL, but write out either that view or a totally separate one with gl2ps or DAWN. That’s really a question for the Visualisation category though.