19#include "BDSColours.hh"
20#include "BDSVisManager.hh"
22#include "G4UIterminal.hh"
28#include "G4VisExecutive.hh"
33#include "G4UImanager.hh"
35#include "G4UIExecutive.hh"
41#include "G4TrajectoryDrawByCharge.hh"
42#include "G4Version.hh"
45#include "BDSDetectorConstruction.hh"
46#include "BDSMessenger.hh"
47#include "BDSUtilities.hh"
48#include "BDSVisCommandSceneAddQueryMagneticField.hh"
50BDSVisManager::BDSVisManager(
const G4String& visMacroFileNameIn,
51 const G4String& geant4MacroFileNameIn,
53 visMacroFileName(visMacroFileNameIn),
54 geant4MacroFileName(geant4MacroFileNameIn)
56 visManager =
new G4VisExecutive();
62BDSVisManager::~BDSVisManager()
71 G4UIsession* session =
new G4UIterminal(
new G4UItcsh);
73 G4UIsession* session =
new G4UIterminal();
78 G4cout<< __METHOD_NAME__ <<
"Initializing Visualisation Manager"<<G4endl;
81 visManager->Initialize();
84 G4TrajectoryDrawByCharge* trajModel1 =
new G4TrajectoryDrawByCharge(
"bdsim_traj_by_charge");
86 trajModel1->Set(G4TrajectoryDrawByCharge::Charge::Neutral, *(colours->GetColour(
"traj_neutral")));
87 trajModel1->Set(G4TrajectoryDrawByCharge::Charge::Positive, *(colours->GetColour(
"traj_positive")));
88 trajModel1->Set(G4TrajectoryDrawByCharge::Charge::Negative, *(colours->GetColour(
"traj_negative")));
89 visManager->RegisterModel(trajModel1);
90 visManager->SelectTrajectoryModel(trajModel1->Name());
94 G4UIExecutive* session2 =
new G4UIExecutive(argc, argv);
97 G4UImanager* UIManager = G4UImanager::GetUIpointer();
100 G4String macroPaths = bdsimExecPath +
"../share/bdsim/vis:@CMAKE_BINARY_DIR@/vis:./";
101 G4cout << __METHOD_NAME__ <<
"Setting macro path to: " << macroPaths << G4endl;
102 UIManager->ApplyCommand(
"/control/macroPath "+macroPaths);
105 G4String visMacPath = visMacName;
106 if (visMacName.empty())
108#ifdef G4VIS_USE_OPENGLQT
109 visMacName =
"bdsim_default_vis.mac";
111 visMacName =
"bdsim_default_dawnfile.mac";
114 visMacPath = UIManager->FindMacroPath(visMacName);
115 G4cout << __METHOD_NAME__ <<
"Visualisation macro name: " << visMacName << G4endl;
116 G4cout << __METHOD_NAME__ <<
"Visualisation macro path: " << visMacPath << G4endl;
117 if (visMacPath == visMacName)
119 G4cout << __METHOD_NAME__ <<
"bdsim_default_vis.mac missing from BDSIM installation directory." << G4endl;
127 std::cout << __METHOD_NAME__ <<
"ERROR: visualisation file " << visMacPath <<
" not present!" << G4endl;
130 G4cout << __METHOD_NAME__ <<
"Using visualisation macro: " << visMacName << G4endl;
133 UIManager->ApplyCommand(
"/control/execute " + visMacPath);
138 G4cout << __METHOD_NAME__ <<
"Applying geant4MacroFileName: " <<
geant4MacroFileName << G4endl;
142#if G4VERSION_NUMBER < 1030
143 if (session2->IsGUI())
145 UIManager->ApplyCommand(
"/control/execute bdsim_default_icons.mac");
146 UIManager->ApplyCommand(
"/gui/addIcon \"Run beam on\" user_icon \"/run/beamOn 1\" run.png");
147 UIManager->ApplyCommand(
"/control/execute bdsim_default_gui.mac");
152 session2->SessionStart();
static BDSColours * Instance()
singleton pattern
Class that constructs a Geant4 model of an accelerator.
Scene describer for adding magnetic field lines according to a query.
G4String visMacroFileName
Full macro file path to run for visualisation.
G4String geant4MacroFileName
Full macro file path for optional macro to run afterwards.
void StartSession(int argc, char **argv)
Start interactive mode.
G4bool FileExists(const G4String &filename)
Checks if filename exists.
std::string GetBDSIMExecPath()