| 1 | // this :
|
|---|
| 2 | #include <G4Lab/UIOnX.h>
|
|---|
| 3 |
|
|---|
| 4 | // Geant4 :
|
|---|
| 5 | #include <G4UImanager.hh>
|
|---|
| 6 |
|
|---|
| 7 | // Lib :
|
|---|
| 8 | #include <Slash/Core/ISession.h>
|
|---|
| 9 | #include <Lib/Out.h>
|
|---|
| 10 |
|
|---|
| 11 | // OnX :
|
|---|
| 12 | #include <Slash/UI/IUI.h>
|
|---|
| 13 | #include <OnX/Core/Main.h>
|
|---|
| 14 |
|
|---|
| 15 | // G4Lab :
|
|---|
| 16 | #include <G4Lab/Manager.h>
|
|---|
| 17 |
|
|---|
| 18 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 19 | G4Lab::UIOnX::UIOnX(
|
|---|
| 20 | G4RunManager& aRunManager
|
|---|
| 21 | ,const std::string& aGUI
|
|---|
| 22 | ,int aArgc
|
|---|
| 23 | ,char** aArgv
|
|---|
| 24 | )
|
|---|
| 25 | :fOnX(0)
|
|---|
| 26 | ,fUI(0)
|
|---|
| 27 | ,fManager(0)
|
|---|
| 28 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 29 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
|---|
| 30 | {
|
|---|
| 31 | std::vector<std::string> args;
|
|---|
| 32 | for(int index=0;index<aArgc;index++) args.push_back(aArgv[index]);
|
|---|
| 33 | if(aGUI!="") args.push_back(aGUI); //Should be the last argument.
|
|---|
| 34 | fOnX = new OnX::Main(false,false,args);
|
|---|
| 35 | if(!fOnX->isValid()) {
|
|---|
| 36 | delete fOnX;
|
|---|
| 37 | fOnX = 0;
|
|---|
| 38 | return;
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | Slash::Core::ISession* session = fOnX->session();
|
|---|
| 42 | if(session) {
|
|---|
| 43 | // An IGeant4Manager to pass the G4RunManager to the scripting.
|
|---|
| 44 | fManager = new Manager(*session,"Geant4Manager",&aRunManager);
|
|---|
| 45 | // Declare our Manager to the OnX session.
|
|---|
| 46 | // It must be done prior the creation of the UI (in order that the
|
|---|
| 47 | // initialize callbacks script execute properly).
|
|---|
| 48 | session->addManager(fManager);
|
|---|
| 49 | }
|
|---|
| 50 |
|
|---|
| 51 | G4UImanager* uiManager = G4UImanager::GetUIpointer();
|
|---|
| 52 | if(uiManager) {
|
|---|
| 53 | uiManager->SetSession(this);
|
|---|
| 54 | //uiManager->SetCoutDestination(this);
|
|---|
| 55 | }
|
|---|
| 56 | }
|
|---|
| 57 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 58 | G4Lab::UIOnX::~UIOnX(
|
|---|
| 59 | )
|
|---|
| 60 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 61 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
|---|
| 62 | {
|
|---|
| 63 | G4UImanager* uiManager = G4UImanager::GetUIpointer();
|
|---|
| 64 | if(uiManager) {
|
|---|
| 65 | uiManager->SetSession(NULL);
|
|---|
| 66 | //uiManager->SetCoutDestination(NULL);
|
|---|
| 67 | }
|
|---|
| 68 |
|
|---|
| 69 | delete fOnX;
|
|---|
| 70 | }
|
|---|
| 71 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 72 | bool G4Lab::UIOnX::isValid(
|
|---|
| 73 | ) const
|
|---|
| 74 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 75 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
|---|
| 76 | {
|
|---|
| 77 | if(!fOnX) return false;
|
|---|
| 78 | if(!fOnX->session()) return false;
|
|---|
| 79 | return true;
|
|---|
| 80 | }
|
|---|
| 81 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 82 | bool G4Lab::UIOnX::createUI(
|
|---|
| 83 | const std::string& aDriver
|
|---|
| 84 | ,const std::string& aFile
|
|---|
| 85 | ,bool aShow
|
|---|
| 86 | )
|
|---|
| 87 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 88 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
|---|
| 89 | {
|
|---|
| 90 | if(!fUI) {
|
|---|
| 91 | if(!fOnX) return false;
|
|---|
| 92 | fUI = fOnX->createUI(aDriver,aFile,aShow);
|
|---|
| 93 | }
|
|---|
| 94 | if(!fUI) return false;
|
|---|
| 95 | return true;
|
|---|
| 96 | }
|
|---|
| 97 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 98 | G4UIsession* G4Lab::UIOnX::SessionStart(
|
|---|
| 99 | )
|
|---|
| 100 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 101 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
|---|
| 102 | {
|
|---|
| 103 | if(!fUI) {
|
|---|
| 104 | if(!fOnX) return 0;
|
|---|
| 105 | fUI = fOnX->createUI("","",true);
|
|---|
| 106 | }
|
|---|
| 107 | if(!fUI) return 0;
|
|---|
| 108 | fUI->steer();
|
|---|
| 109 | return this;
|
|---|
| 110 | }
|
|---|
| 111 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 112 | void G4Lab::UIOnX::PauseSessionStart(
|
|---|
| 113 | G4String aState
|
|---|
| 114 | )
|
|---|
| 115 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 116 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
|---|
| 117 | {
|
|---|
| 118 | if(!fOnX) return;
|
|---|
| 119 |
|
|---|
| 120 | Lib::Out out(fOnX->session()->printer());
|
|---|
| 121 | out << "G4UIOnX::PauseSessionStart : debug : " << aState << Lib::endl;
|
|---|
| 122 |
|
|---|
| 123 | if(aState=="G4_pause> ") {
|
|---|
| 124 | //SecondaryLoop("Pause, type continue to exit this state");
|
|---|
| 125 | }
|
|---|
| 126 |
|
|---|
| 127 | if(aState=="EndOfEvent") {
|
|---|
| 128 | // Picking with feed back in event data Done here !!!
|
|---|
| 129 | //SecondaryLoop("End of event, type continue to exit this state");
|
|---|
| 130 | }
|
|---|
| 131 | }
|
|---|
| 132 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 133 | Slash::Core::ISession* G4Lab::UIOnX::session(
|
|---|
| 134 | )
|
|---|
| 135 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 136 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
|---|
| 137 | {
|
|---|
| 138 | if(!fOnX) return 0;
|
|---|
| 139 | return fOnX->session();
|
|---|
| 140 | }
|
|---|
| 141 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 142 | Slash::Core::IWriter* G4Lab::UIOnX::printer(
|
|---|
| 143 | )
|
|---|
| 144 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 145 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
|---|
| 146 | {
|
|---|
| 147 | if(!fOnX) return 0;
|
|---|
| 148 | Slash::Core::ISession* session = fOnX->session();
|
|---|
| 149 | if(!session) return 0;
|
|---|
| 150 | return &(session->printer());
|
|---|
| 151 | }
|
|---|
| 152 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 153 | void G4Lab::UIOnX::addManager(
|
|---|
| 154 | Slash::Core::IManager* aManager
|
|---|
| 155 | )
|
|---|
| 156 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 157 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
|---|
| 158 | {
|
|---|
| 159 | if(!fOnX) return;
|
|---|
| 160 | Slash::Core::ISession* session = fOnX->session();
|
|---|
| 161 | if(!session) return;
|
|---|
| 162 | session->addManager(aManager);
|
|---|
| 163 | }
|
|---|
| 164 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 165 | void G4Lab::UIOnX::addAccessor(
|
|---|
| 166 | Slash::Data::IAccessor* aAccessor
|
|---|
| 167 | )
|
|---|
| 168 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 169 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
|---|
| 170 | {
|
|---|
| 171 | if(!fManager) return;
|
|---|
| 172 | fManager->addAccessor(aAccessor);
|
|---|
| 173 | }
|
|---|
| 174 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 175 | AIDA::IAnalysisFactory* G4Lab::UIOnX::findAIDA(
|
|---|
| 176 | )
|
|---|
| 177 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 178 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
|---|
| 179 | {
|
|---|
| 180 | if(!fManager) return 0;
|
|---|
| 181 | return fManager->findAIDA();
|
|---|
| 182 | }
|
|---|