38#define NewString(str) \
39 ((str) != NULL ? (strcpy((char*)malloc((unsigned)strlen(str) + 1), str)) : NULL)
47,secondaryLoopEnabled(
TRUE)
48,alreadyInSecondaryLoop(
FALSE)
50,parentInteractor(NULL)
51,createdInteractor(NULL)
64 for(
G4int argi=0;argi<argc;argi++) {
65 if(argv[argi]!=NULL) free(argv[argi]);
75 secondaryLoopEnabled =
TRUE;
76 alreadyInSecondaryLoop =
FALSE;
77 exitSecondaryLoop = 0;
89 for(
G4int argi=0;argi<argc;argi++) {
90 if(argv[argi]!=NULL) free(argv[argi]);
98 argv = (
char**)malloc(a_argc *
sizeof(
char*));
101 for(
G4int argi=0;argi<a_argc;argi++) {
102 argv[argi] = (
char*)
NewString (a_argv[argi]);
114 if(a_argc!=NULL) *a_argc = argc;
124 mainInteractor = a_main;
132 return mainInteractor;
140 secondaryLoopEnabled =
TRUE;
148 secondaryLoopEnabled =
FALSE;
157 if(a_dispatcher==NULL)
return;
158 if(std::find(dispatchers.begin(),dispatchers.end(),a_dispatcher)!=dispatchers.end())
return;
159 dispatchers.push_back(a_dispatcher);
168 std::vector<G4DispatchFunction>::iterator it;
169 for (it = dispatchers.begin(); it != dispatchers.end(); it++) {
170 if (*it == a_dispatcher) {
171 dispatchers.erase(it);
183 G4int dispatchern = dispatchers.size();
185 for(
G4int count=0;count<dispatchern;count++) {
186 func = dispatchers[count];
188 if(func(a_event)==
true)
return;
199 if(a_preAction==NULL)
return;
200 if(std::find(preActions.begin(),preActions.end(),a_preAction)!=preActions.end())
return;
201 preActions.push_back(a_preAction);
209 G4int preActionn = preActions.size();
210 for(
G4int count=0;count<preActionn;count++) {
211 if(preActions[count]!=NULL) preActions[count]();
221 if(a_postAction==NULL)
return;
222 if(std::find(postActions.begin(),postActions.end(),a_postAction)!=postActions.end())
return;
223 postActions.push_back(a_postAction);
231 G4int postActionn = postActions.size();
232 for(
G4int count=0;count<postActionn;count++) {
233 if(postActions[count]!=NULL) postActions[count]();
244 if(secondaryLoopEnabled==
FALSE)
return;
246 if (alreadyInSecondaryLoop==
FALSE) {
247 G4cout <<
"------------------------------------------" <<
G4endl;
248 G4cout <<
"You have entered a viewer secondary X event loop." <<
G4endl;
249 G4cout <<
"Quit it with an 'Escape' viewer button" <<
G4endl;
250 alreadyInSecondaryLoop =
TRUE;
251 exitSecondaryLoop = 0;
257 if(event==NULL)
break;
259 if(exitSecondaryLoop!=0)
break;
272 if(secondaryLoopEnabled==
FALSE)
return;
273 if(a_code==0) a_code = 1;
274 exitSecondaryLoop = a_code;
275 alreadyInSecondaryLoop =
FALSE;
285 return exitSecondaryLoop;
294 if(a_shell==NULL)
return;
295 if(std::find(shells.begin(),shells.end(),a_shell)!=shells.end())
return;
296 shells.push_back(a_shell);
305 std::vector<G4Interactor>::iterator it;
306 for (it = shells.begin(); it != shells.end(); it++) {
307 if (*it == a_shell) {
320 parentInteractor = a_interactor;
328 return parentInteractor;
337 createdInteractor = a_interactor;
345 return createdInteractor;
354 creationString = a_string;
362 return creationString;
G4bool(* G4DispatchFunction)(void *)
void(* G4SecondaryLoopAction)()
G4DLLIMPORT std::ostream G4cout
void AddDispatcher(G4DispatchFunction)
char ** GetArguments(int *)
void SetCreatedInteractor(G4Interactor)
void SetMainInteractor(G4Interactor)
void AddSecondaryLoopPostAction(G4SecondaryLoopAction)
void SetParentInteractor(G4Interactor)
void EnableSecondaryLoop()
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)