Import Geant4 11.3.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2024-06-28 13:08:51 +02:00
parent f7b23877ed
commit e58e650b32
5232 changed files with 239416 additions and 244360 deletions
@@ -45,6 +45,8 @@
#include "G4THitsMap.hh"
#include "G4PseudoScene.hh"
#include <map>
class G4Scene;
class G4VGraphicsSystem;
class G4AttHolder;
@@ -451,6 +453,7 @@ protected:
G4int fNestingDepth; // For Begin/EndPrimitives.
const G4VisAttributes* fpVisAttribs; // Working vis attributes.
const G4Transform3D fIdentityTransformation;
std::map<G4VPhysicalVolume*,G4String> fProblematicVolumes;
private:
@@ -171,25 +171,25 @@ public: // With description
class SceneTreeScene: public G4PseudoScene {
// G4PhysicalVolumeModel sends touchables to this scene
public:
SceneTreeScene() = default;
SceneTreeScene(G4VViewer*, G4PhysicalVolumeModel*);
~SceneTreeScene() = default;
void SetViewer(G4VViewer* pViewer) {fpViewer = pViewer;}
void SetModel(G4VModel* pModel); // ...and more (see .cc)
private:
void ProcessVolume(const G4VSolid& solid) override;
std::list<G4SceneTreeItem>::iterator FindOrInsertModel
(const G4String& modelType,const G4String& modelID);
std::list<G4SceneTreeItem>::iterator FindOrInsertTouchable
(const G4String& modelID, G4SceneTreeItem& mother,
G4int depth, const G4String& partialPathString, const G4String& fullPathString);
G4VViewer* fpViewer = nullptr;
G4VModel* fpModel = nullptr;
G4int fMaximumExpandedDepth = 0; // To be calculated in SetModel
G4PhysicalVolumeModel* fpPVModel = nullptr;
std::list<G4SceneTreeItem>::iterator fModelIter; // Points to scene tree item for this model
G4int fMaximumExpandedDepth = 0; // To be calculated in constructor
const G4int fMaximumExpanded = 30; // So as not to swamp the GUI
};
SceneTreeScene& AccessSceneTreeScene() {return fSceneTreeScene;}
void InsertModelInSceneTree(G4VModel*);
const G4SceneTreeItem& GetSceneTree() {return fSceneTree;}
G4SceneTreeItem& AccessSceneTree() {return fSceneTree;}
void UpdateGUISceneTree(); // A utility
const G4int fMaxNTouchables = 10000; // Limits memory to about 50 MB
G4bool fCurtailDescent = false; // Flag to curtail descent into PV model for scene tree
//////////////////////////////////////////////////////////////
// Access functions.
@@ -258,7 +258,6 @@ protected:
G4ViewParameters fDefaultVP; // Default view parameters.
G4double fKernelVisitElapsedTimeSeconds = 999.; // Default to a large number
// Note: fKernelVisitElapsedTimeSeconds is measured in ProcessView().
SceneTreeScene fSceneTreeScene; // G4PhysicalVolumeModel sends touchables to this scene
G4SceneTreeItem fSceneTree;
//////////////////////////////////////////////////////////////
@@ -126,15 +126,19 @@ public: // With description
private:
const G4String& GetDefaultGraphicsSystemName() override;
void SetDefaultsByArgument(const G4String& system);
void SetDefaultsByEnvironment();
void SetDefaultsByFile(int argc, char** argv);
void SetDefaultsByBatch();
void SetDefaultsByBuildFlags();
G4bool fSelected;
void RegisterGraphicsSystems();
void RegisterModelFactories();
int fUserArgc;
char** fUserArgv;
G4String fUserSpecifiedSystem;
G4bool fSelected;
void RegisterGraphicsSystems() override;
void RegisterModelFactories() override;
};
@@ -149,6 +149,8 @@
#include <cstdlib>
#include <sstream>
#define G4warn G4cout
// The inline keyword prevents the compiler making an external
// reference even though they cannot actually be inlined since they
// are virtual functions. This prevents a "multiple definition" error
@@ -160,31 +162,54 @@
inline
G4VisExecutive::G4VisExecutive(int argc, char** argv, const G4String& system,
const G4String& verbosityString):
const G4String& verbosityString):
G4VisManager(verbosityString),
fSelected(false)
{
if (!fSelected) SetDefaultsByArgument(system);
if (!fSelected) SetDefaultsByEnvironment();
if (!fSelected) SetDefaultsByFile(argc, argv);
if (!fSelected) SetDefaultsByBatch();
if (!fSelected) SetDefaultsByBuildFlags();
fUserArgc = argc;
fUserArgv = argv;
fUserSpecifiedSystem = system;
}
inline
G4VisExecutive::G4VisExecutive (const G4String& verbosityString):
G4VisManager(verbosityString),
fSelected(false)
G4VisManager(verbosityString)
, fUserArgc(0) // >0 if argc is provided by the user...
, fUserArgv(nullptr)
, fSelected(false)
{}
inline
const G4String& G4VisExecutive::GetDefaultGraphicsSystemName ()
{
if (!fSelected) SetDefaultsByEnvironment();
if (!fSelected) SetDefaultsByBatch();
if (!fSelected) SetDefaultsByBuildFlags();
if (fSelected) return fDefaultGraphicsSystemName;
if (fUserArgc > 0) SetDefaultsByArgument(fUserSpecifiedSystem);
if (!fSelected) SetDefaultsByEnvironment();
if (!fSelected && fUserArgc > 0) SetDefaultsByFile(fUserArgc, fUserArgv);
if (!fSelected) { SetDefaultsByBatch();
if (fSelected) { // No UI session
// Deal with this later - the user may have specified a system
// on the command line - see G4VisCommandSceneHandlerCreate.
return fDefaultGraphicsSystemName;
}
}
if (!fSelected) SetDefaultsByBuildFlags();
if (GetVerbosity() >= warnings) {
G4warn << "Default graphics system is: " << fDefaultGraphicsSystemName
<< " (based on " << fDefaultGraphicsSystemBasis << ")."
<< "\nDefault window size hint is: " << fDefaultXGeometryString
<< " (based on " << fDefaultXGeometryStringBasis << ")."
<< "\nNote: Parameters specified on the command line will override these defaults."
<< "\n Use \"vis/open\" without parameters to get these defaults."
<< G4endl;
}
return fDefaultGraphicsSystemName;
}
inline
void G4VisExecutive::SetDefaultsByArgument(const G4String& system)
{
// 1st priority: selection by G4VisExecuitive argument
// 1st priority: selection by G4VisExecutive argument
if (!system.empty()) {
fDefaultGraphicsSystemName = system;
fDefaultGraphicsSystemBasis = "G4VisExecuitive argument";
@@ -277,10 +302,10 @@ void G4VisExecutive::SetDefaultsByBatch()
G4UIsession* session = G4UImanager::GetUIpointer()->GetBaseSession();
if (session == nullptr // Usual case - pure batch
|| dynamic_cast<G4UIbatch*>(session)) { // From a macro from batch
// Choose an offscreen or file-writing system
fDefaultGraphicsSystemName = "TSG_OFFSCREEN";
fDefaultGraphicsSystemBasis = "batch session";
fSelected = true;
// Actually, in this case, we wish to force the user to specify a driver
fDefaultGraphicsSystemName = "NO_UI_SESSION";
fDefaultGraphicsSystemBasis = "no UI session";
fSelected = true; // To prevent any further selection
}
}
@@ -311,8 +336,8 @@ void G4VisExecutive::SetDefaultsByBuildFlags()
fSelected = true;
}
inline void
G4VisExecutive::RegisterGraphicsSystems () {
inline
void G4VisExecutive::RegisterGraphicsSystems () {
// Graphics Systems not needing external packages or libraries...
RegisterGraphicsSystem (new G4ASCIITree);
@@ -331,7 +356,6 @@ G4VisExecutive::RegisterGraphicsSystems () {
// super-abbreviated names and fallback names where approproiate.
#ifdef G4VIS_USE_OPENGLQT
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
G4VGraphicsSystem* ogliqt = new G4OpenGLImmediateQt;
G4VGraphicsSystem* oglsqt = new G4OpenGLStoredQt;
RegisterGraphicsSystem(ogliqt);
@@ -340,7 +364,6 @@ G4VisExecutive::RegisterGraphicsSystems () {
oglsqt->AddNickname("OGL");
oglsqt->AddNickname("OGLS");
#endif
#endif
#ifdef G4VIS_USE_OPENGLXM
G4VGraphicsSystem* oglixm = new G4OpenGLImmediateXm;
@@ -482,12 +505,6 @@ G4VisExecutive::RegisterGraphicsSystems () {
#ifdef G4VIS_USE_TOOLSSG_QT_GLES
tsg_qt_gles->AddNickname("TSG");
# if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
if (GetVerbosity() >= startup) {
G4cout << " Qt6: Asking ToolsSG to stand in for OpenGL" << G4endl;
tsg_qt_gles->AddNickname("OGL");
}
# endif
#elif defined(G4VIS_USE_TOOLSSG_XT_GLES)
tsg_xt_gles->AddNickname("TSG");
#elif defined(G4VIS_USE_TOOLSSG_X11_GLES)
@@ -338,6 +338,10 @@ public: // With description
virtual void SetUpForAThread();
// This method is invoked by G4WorkerRunManager
virtual void EventReadyForVis(const G4Event*);
// This is invoked by G4SubEvtRunManager.
// The event is passed to EndOfEventKernel.
static G4ThreadFunReturnType G4VisSubThread(G4ThreadFunArgType);
// Vis sub-thread function.
@@ -362,6 +366,11 @@ private:
// This is called on change of state (G4ApplicationState). It is
// used to draw hits, digis and trajectories if included in the
// current scene at the end of event, as required.
G4bool Relinquishable (G4int eventID, G4int nKeptEvents, G4int nRequests);
void EndOfEventKernel (const G4Event* event);
void EndOfEventCleanup
(const G4Event* currentEvent,
G4int eventID); // See EndOfEventKernel: can be == -2?
void EndOfRun ();
@@ -402,6 +411,8 @@ public: // With description
G4bool GetTransientsDrawnThisEvent () const;
G4bool GetDrawEventOnlyIfToBeKept () const;
const G4Event* GetRequestedEvent () const;
G4int GetNKeepForPostProcessingRequests () const;
G4int GetNKeepTheEventRequests () const;
G4int GetNKeepRequests () const;
G4bool GetReviewingKeptEvents () const;
G4bool GetAbortReviewKeptEvents () const;
@@ -412,7 +423,10 @@ public: // With description
G4int GetMaxEventQueueSize () const;
G4bool GetWaitOnEventQueueFull () const;
#endif
const G4String& GetDefaultGraphicsSystemName() const;
virtual const G4String& GetDefaultGraphicsSystemName();
// The above has to be virtual so that the derived class, G4VisExecutive,
// can override and non-const because on first pass it may/should
// determine these defaults.
const G4String& GetDefaultXGeometryString () const;
const G4String& GetDefaultGraphicsSystemBasis() const;
const G4String& GetDefaultXGeometryStringBasis() const;
@@ -484,19 +498,18 @@ protected:
void RegisterMessengers (); // Command messengers.
const G4int fVerbose;
const G4int fVerbose;
// No longer used. Use fVerbosity and access functions instead.
// fVerbose is kept for backwards compatibility for some user
// examples. (It is used in the derived user vis managers to print
// available graphics systems.) It is initialised to 1 in the
// constructor and cannot be changed.
static Verbosity fVerbosity;
static Verbosity fVerbosity;
G4String fDefaultGraphicsSystemName;
G4String fDefaultXGeometryString;
G4String fDefaultGraphicsSystemBasis;
G4String fDefaultXGeometryStringBasis;
G4String fDefaultGraphicsSystemName;
G4String fDefaultXGeometryString;
G4String fDefaultGraphicsSystemBasis;
G4String fDefaultXGeometryStringBasis;
private:
@@ -538,7 +551,8 @@ private:
G4bool fTransientsDrawnThisRun;
G4bool fTransientsDrawnThisEvent;
G4int fNoOfEventsDrawnThisRun;
G4int fNKeepRequests;
G4int fNKeepForPostProcessingRequests;
G4int fNKeepTheEventRequests;
G4bool fEventKeepingSuspended;
G4bool fDrawEventOnlyIfToBeKept;
const G4Event* fpRequestedEvent; // If non-zero, scene handler uses.
@@ -98,8 +98,12 @@ inline const G4Event* G4VisManager::GetRequestedEvent() const {
return fpRequestedEvent;
}
inline G4int G4VisManager::GetNKeepRequests () const {
return fNKeepRequests;
inline G4int G4VisManager::GetNKeepForPostProcessingRequests () const {
return fNKeepForPostProcessingRequests;
}
inline G4int G4VisManager::GetNKeepTheEventRequests () const {
return fNKeepTheEventRequests;
}
inline G4bool G4VisManager::GetReviewingKeptEvents() const {
@@ -134,7 +138,7 @@ inline G4bool G4VisManager::GetWaitOnEventQueueFull () const {
#endif
inline const G4String& G4VisManager::GetDefaultGraphicsSystemName () const {
inline const G4String& G4VisManager::GetDefaultGraphicsSystemName () {
return fDefaultGraphicsSystemName;
}