37#define NewString(str) \
38 ((str) != NULL ? (strcpy((char*)malloc((unsigned)strlen(str) + 1), str)) : NULL)
46,secondaryLoopEnabled(
TRUE)
47,alreadyInSecondaryLoop(
FALSE)
49,parentInteractor(NULL)
50,createdInteractor(NULL)
63 for(
G4int argi=0;argi<argc;++argi) {
64 if(argv[argi]!=NULL)
free(argv[argi]);
74 secondaryLoopEnabled =
TRUE;
75 alreadyInSecondaryLoop =
FALSE;
76 exitSecondaryLoop = 0;
88 for(
G4int argi=0;argi<argc;++argi) {
89 if(argv[argi]!=NULL)
free(argv[argi]);
97 argv = (
char**)malloc(a_argc *
sizeof(
char*));
100 for(
G4int argi=0;argi<a_argc;++argi) {
101 argv[argi] = (
char*)
NewString (a_argv[argi]);
113 if(a_argc!=NULL) *a_argc = argc;
123 mainInteractor = a_main;
131 return mainInteractor;
139 secondaryLoopEnabled =
TRUE;
147 secondaryLoopEnabled =
FALSE;
156 if(a_dispatcher==NULL)
return;
157 if(std::find(dispatchers.cbegin(),dispatchers.cend(),a_dispatcher)!=dispatchers.cend())
return;
158 dispatchers.push_back(a_dispatcher);
167 std::vector<G4DispatchFunction>::iterator it;
168 for (it = dispatchers.begin(); it != dispatchers.end(); ++it) {
169 if (*it == a_dispatcher) {
170 dispatchers.erase(it);
182 std::size_t dispatchern = dispatchers.size();
184 for(std::size_t count=0;count<dispatchern;++count) {
185 func = dispatchers[count];
187 if(func(a_event)==
true)
return;
198 if(a_preAction==NULL)
return;
199 if(std::find(preActions.cbegin(),preActions.cend(),a_preAction)!=preActions.cend())
return;
200 preActions.push_back(a_preAction);
208 std::size_t preActionn = preActions.size();
209 for(std::size_t count=0;count<preActionn;++count) {
210 if(preActions[count]!=NULL) preActions[count]();
220 if(a_postAction==NULL)
return;
221 if(std::find(postActions.cbegin(),postActions.cend(),a_postAction)!=postActions.cend())
return;
222 postActions.push_back(a_postAction);
230 std::size_t postActionn = postActions.size();
231 for(std::size_t count=0;count<postActionn;++count) {
232 if(postActions[count]!=NULL) postActions[count]();
243 if(secondaryLoopEnabled==
FALSE)
return;
245 if (alreadyInSecondaryLoop==
FALSE) {
246 G4cout <<
"------------------------------------------" <<
G4endl;
247 G4cout <<
"You have entered a viewer secondary X event loop." <<
G4endl;
248 G4cout <<
"Quit it with an 'Escape' viewer button" <<
G4endl;
249 alreadyInSecondaryLoop =
TRUE;
250 exitSecondaryLoop = 0;
256 if(event==NULL)
break;
258 if(exitSecondaryLoop!=0)
break;
271 if(secondaryLoopEnabled==
FALSE)
return;
272 if(a_code==0) a_code = 1;
273 exitSecondaryLoop = a_code;
274 alreadyInSecondaryLoop =
FALSE;
284 return exitSecondaryLoop;
293 if(a_shell==NULL)
return;
294 if(std::find(shells.cbegin(),shells.cend(),a_shell)!=shells.cend())
return;
295 shells.push_back(a_shell);
304 std::vector<G4Interactor>::iterator it;
305 for (it = shells.begin(); it != shells.end(); ++it) {
306 if (*it == a_shell) {
319 parentInteractor = a_interactor;
327 return parentInteractor;
336 createdInteractor = a_interactor;
344 return createdInteractor;
353 creationString = a_string;
361 return creationString;
G4bool(* G4DispatchFunction)(void *)
void(* G4SecondaryLoopAction)()
G4GLOB_DLL std::ostream G4cout
void AddDispatcher(G4DispatchFunction)
char ** GetArguments(int *)
void SetCreatedInteractor(G4Interactor)
void SetMainInteractor(G4Interactor)
void AddSecondaryLoopPostAction(G4SecondaryLoopAction)
void SetParentInteractor(G4Interactor)
void EnableSecondaryLoop()
virtual void SecondaryLoop()
G4Interactor GetMainInteractor()
virtual ~G4VInteractorManager()
G4Interactor GetParentInteractor()
void DisableSecondaryLoop()
char * GetCreationString()
G4Interactor GetCreatedInteractor()
void SecondaryLoopPostActions()
int GetExitSecondaryLoopCode()
virtual void * GetEvent()=0
void SecondaryLoopPreActions()
void RemoveShell(G4Interactor)
void DispatchEvent(void *)
void RemoveDispatcher(G4DispatchFunction)
virtual G4bool Inited()=0
void AddSecondaryLoopPreAction(G4SecondaryLoopAction)
void SetCreationString(char *)
void SetArguments(int, char **)
void RequireExitSecondaryLoop(int)
void AddShell(G4Interactor)