41  TVersion=
"T1.0a"; JVersion=
"J1.0a";
 
   54   GetNewTreeStructure(tree,0);
 
   55   GetNewTreeValues(tree,0);
 
   56   previousTreeCommands = newTreeCommands;
 
   57   previousTreeParams = newTreeParams;
 
   58   previousTreePCP = newTreePCP;
 
   80     ExecuteCommand(newCommand);
 
   89   promptCharacter = msg;
 
   90   G4cout << 
"@@PROMPT \"" << promptCharacter << 
"\"" << 
G4endl;
 
   95     ExecuteCommand(newCommand);
 
  100 void G4UIGAG::ExecuteCommand(
const G4String& aCommand)
 
  103   if(aCommand.length()<2) 
return;
 
  105   G4int paramIndex = returnVal % 100;
 
  106   G4int commandStatus  = returnVal - paramIndex;
 
  110     switch(commandStatus) {
 
  118       G4cerr << 
"illegal application state -- command refused" << 
G4endl;
 
  122       G4cerr << 
"Parameter is wrong type and/or is not omittable (index " << paramIndex << 
")" << 
G4endl;
 
  125       G4cerr << 
"Parameter is out of candidate list (index " << paramIndex << 
")" << 
G4endl;
 
  130       G4cerr << 
"command refused (" << commandStatus << 
")" << 
G4endl;
 
  133     switch(commandStatus) {
 
  136         GetNewTreeStructure(tree,0);
 
  137         GetNewTreeValues(tree,0);
 
  138         if (CommandUpdated()) {
 
  139            NotifyCommandUpdate();
 
  143         previousTreeCommands = newTreeCommands;
 
  144         previousTreeParams = newTreeParams;
 
  145         previousTreePCP = newTreePCP;
 
  152       G4cout << 
"@@ErrResult \"Illegal application state -- command refused\"" << 
G4endl;
 
  155       G4cout << 
"@@ErrResult \"Parameter Out of Range.\"" << 
G4endl;
 
  158       G4cout << 
"@@ErrResult \"Parameter is wrong type and/or is not omittable.\"" << 
G4endl;
 
  162       G4cout << 
"@@ErrResult \"Parameter Out of Candidates.\"" << 
G4endl;
 
  166       G4cout << 
"@@ErrResult \"command refused (" << commandStatus << 
")\"" << 
G4endl;
 
  174   std::cout << coutString << std::flush;
 
  180   std::cerr << cerrString << std::flush;
 
  186   promptCharacter = aPrompt;
 
  197       G4cout << 
"@@PROMPT \"" << promptCharacter << 
"\"" << 
G4endl;
 
  200       G4cout << promptCharacter << 
"> " << std::flush;
 
  205     if (!
G4cin.good()) { 
G4cin.clear(); newCommand = nullString; iExit=
false;
break;}
 
  208     if( newCommand.length() < 1) { 
break; }
 
  210     while( newCommand(newCommand.length()-1) == 
'_' )
 
  213       newCommand.
remove(newCommand.length()-1);
 
  215       if (!
G4cin.good()) { 
G4cin.clear(); newCommand = nullString; iExit=
false;
break;}
 
  216       newCommand.
append(newLine);
 
  220     if( nC.length() < 1) { 
break; }
 
  223     if( nC == 
"@@GAGmodeJAVA" ) {
 
  226       SendCommandProperties(tree);
 
  229     else if( nC == 
"@@GAGmodeTcl" ) {
 
  232       SendCommandProperties(tree);
 
  235     else if( nC(0) == 
'#' )
 
  238     else if( nC == 
"ls"  || nC(0,3) == 
"ls " )
 
  239     { ListDirectory( nC ); }
 
  240     else if( nC == 
"pwd" )
 
  242     else if( nC(0,2) == 
"cd"  || nC(0,3) == 
"cd " )
 
  243     { ChangeDirectory( nC ); }
 
  244     else if(  nC == 
"help" || nC(0,5) == 
"help ")
 
  245     { TerminalHelp( nC ); }
 
  246     else if( nC(0) == 
'?' )
 
  247     { ShowCurrent( nC ); }
 
  248     else if( nC(0,4) == 
"hist"   || nC == 
"history")
 
  251       for(
int i=0;i<nh;i++)
 
  254     else if( nC(0) == 
'!' )
 
  259       std::istringstream is((
char*)tt);
 
  269       { 
G4cerr << 
"history " << vl << 
" is not found." << 
G4endl; }
 
  271     else if( nC(0,4) == 
"exit" )
 
  277       G4cerr << 
"Please abrot it using \"/run/abort\" command first" << 
G4endl;
 
  278       G4cerr << 
" and use \"continue\" command until the application" << 
G4endl;
 
  281       G4cout << 
"@@ErrResult \"You are now processing RUN.\"" << 
G4endl;
 
  287         newCommand = nullString;
 
  291     else if(  nC == 
"cont" || nC == 
"continue" )
 
  294       newCommand = nullString;
 
  300   return GetFullPath(newCommand);
 
  309   if( newCommand(0) == 
'/' ) 
 
  310   { tmpString = newCommand; }
 
  311   else if( newCommand(0,3) == 
"../" )
 
  314      unsigned i_direc = 0;
 
  315     while( i_direc < newCommand.length() )
 
  317       if( newCommand(i_direc,3) == 
"../" )
 
  326     tmpString.
append( newCommand( i_direc, newCommand.length()-i_direc ) );
 
  332     tmpString.
append( newCommand );
 
  342 void G4UIGAG::ShowCurrent(
const G4String& newCommand )
 
  344   G4String theCommand = GetFullPath(newCommand.substr(1,newCommand.length()-1));
 
  346   if( ! (curV.
isNull()||curV(0)==
'\0' ) ) {
 
  348       G4cout << 
"Current value(s) of the parameter(s) : " << curV << 
G4endl;
 
  355       G4cout << 
"@@ErrResult \"Current value is not available.\"" << 
G4endl;
 
  359 void G4UIGAG::ChangeDirectory(
const G4String& newCommand )
 
  362   if( newCommand.length() <= 3 )
 
  366     G4String aNewPrefix = newCommand.substr(3,newCommand.length()-3);
 
  368     if( newPrefix(0) == 
'/' )
 
  370     else if( newPrefix(0) != 
'.' )
 
  375     { 
prefix = ModifyPrefix( newPrefix ); }
 
  379   if( FindDirPath( 
prefix ) == NULL )
 
  386 void G4UIGAG::ListDirectory(
const G4String& newCommand )
 
  389   if( newCommand.length() <= 3 )
 
  393     G4String newPrefix = newCommand.substr(3,newCommand.length()-3);
 
  395     if( newPrefix(0) == 
'/' )
 
  396     { targetDir = newPrefix; }
 
  397     else if( newPrefix(0) != 
'.' )
 
  400       targetDir += newPrefix;
 
  403     { targetDir = ModifyPrefix(newPrefix); }
 
  405   if( targetDir( targetDir.length() - 1 ) != 
'/' )
 
  406   { targetDir += 
"/"; }
 
  408   if( commandTree == NULL )
 
  409   { 
G4cout << 
"Directory <" << targetDir << 
"> is not found." << 
G4endl; }
 
  414 void G4UIGAG::TerminalHelp(
const G4String& newCommand)
 
  418   if( i != std::string::npos )
 
  420     G4String newValue = newCommand.substr(i+1,newCommand.length()-(i+1));
 
  422     if( newValue(0) != 
'/' )
 
  425     if( theCommand != NULL ) 
 
  432       G4cout << 
"Command <" << newValue << 
" is not found." << 
G4endl;
 
  440    unsigned prefixIndex = 1;
 
  441   while( prefixIndex < 
prefix.length()-1 )
 
  443     int ii = 
prefix.index(
"/",prefixIndex);
 
  453     G4cout << 
G4endl << 
"Type the number ( 0:end, -n:n level back ) : "<<std::flush;
 
  457       G4cin.ignore(30,
'\n');
 
  461       if( iFloor < 0 ) iFloor = 0;
 
  463     else if(j == 0) { 
break;}
 
  468         if( j <= n_tree + floor[iFloor]->GetCommandEntry() )
 
  476         floor[iFloor+1] = floor[iFloor]->
GetTree(i);
 
  487   G4cin.getline( temp, 100 );
 
  495     if( newCommand.substr(0,2) == 
".." )
 
  497       if( newPrefix != 
"/" )
 
  499     G4String tmpString = newPrefix(0,newPrefix.length()-1);
 
  500         newPrefix = newPrefix(0,tmpString.
last(
'/')+1); 
 
  505       newPrefix += newCommand;
 
  508     if( newCommand == 
".." || newCommand == 
"../" )
 
  510     newCommand = newCommand.substr(3,newCommand.length()-3);
 
  519   while( idx < newCommand.length()-1 )
 
  521     int i = newCommand.
index(
"/",idx);
 
  523     if( comTree == NULL ) 
 
  540     CodeGenJavaTree(tree, 0);  
 
  542     CodeGenJavaParams(tree, 0);
 
  545     CodeGenTclTree(tree,0);  
 
  547     CodeGenTclParams(tree, 0);
 
  557     CodeGenJavaParams(tree, 0);
 
  559     CodeGenTclParams(tree, 0);
 
  565   int treeEntry, commandEntry;
 
  570     for(
int i=0; i<commandEntry; i++){
 
  574   if(treeEntry == 0) 
return; 
 
  576   for(
int j=0; j<treeEntry; j++){
 
  577     CodeGenJavaTree(tree->
GetTree(j+1), level+1);
 
  583   int treeEntry, commandEntry, i;
 
  590   for(i=0; i<commandEntry; i++) {
 
  593   if( treeEntry == 0 )  
return;     
 
  595   for(i=0; i< treeEntry; i++) {
 
  600     CodeGenJavaParams(treeLink, level+1); 
 
  604 void G4UIGAG::SendAParamProperty(
G4UIcommand * Comp)
 
  606   int guidanceEntry, parameterEntry;
 
  615   for (
int j=0; j<guidanceEntry; j++){
 
  619       for(
int i=0; i< (
int)title.length(); i++){
 
  622     if ( c[0] == 
'\n' || c[0] == 
'\r') {
 
  632   for( 
int par=0; par<parameterEntry; par++) {
 
  647   int treeEntry, commandEntry;
 
  652   for(
int com=0; com<commandEntry; com++) {
 
  658   if( treeEntry == 0 ) 
return;     
 
  660   for( 
int i=0; i<treeEntry; i++) {
 
  661     SendDisableList(tree->
GetTree(i+1), level+1); 
 
  671   int treeEntry, commandEntry, guidanceEntry;
 
  674   G4String commandPath, pathName, title1, title2;
 
  678   for(
int com=0; com<commandEntry; com++){
 
  683     if (guidanceEntry == 0){
 
  684       title2 = 
"...Title not available...";
 
  690     for(i=0; i< (
int)title1.length(); i++){
 
  696       } 
else if ( c[0] == 
'\n' || c[0] == 
'\r') {
 
  701     if (j >= guidanceEntry) 
break;
 
  705     G4cout << commandPath << 
" @@title \""<< title2 <<
"\""<< 
G4endl;
 
  708   if(treeEntry == 0) 
return; 
 
  710   for(i=0; i< treeEntry; i++){
 
  715     for(
int k=0; k<(
int)title1.length(); k++){
 
  725     G4cout << pathName << 
"  @@title \"" << title1  << 
"\""<<
G4endl;
 
  726     CodeGenTclTree(t, level+1);
 
  732   int treeEntry, commandEntry;
 
  737   for(
int com=0; com<commandEntry; com++) {
 
  739     SendATclParamProperty(Comp);
 
  741   if( treeEntry == 0 ) 
return;     
 
  743   for( 
int i=0; i<treeEntry; i++) {
 
  744     CodeGenTclParams(tree->
GetTree(i+1), level+1); 
 
  749 void G4UIGAG::SendATclParamProperty(
G4UIcommand * Comp)
 
  756     G4cout << commandPath << 
" @@param " << parameterEntry << 
G4endl;
 
  757     G4cout << 
"@@command_range \"" << commandRange << 
"\"" << 
G4endl;
 
  758     for( 
int par=0; par<parameterEntry; par++) {
 
  765       for(
int i=0; i<(
int)guide1.length(); i++){
 
  773       G4cout << 
" @@param_guide : \"" << guide2 << 
"\""<<
G4endl; 
 
  784 void G4UIGAG::NotifyStateChange(
void)
 
  791      G4cout << 
"@@State \"" << stateString << 
"\"" << 
G4endl;
 
  793      SendDisableList(tree, 0);
 
  798 void G4UIGAG::NotifyCommandUpdate(
void)
 
  801   SendCommandProperties(tree);
 
  804 void G4UIGAG::NotifyParameterUpdate(
G4UIcommand* com)
 
  807     SendAParamProperty(com);
 
  809     SendATclParamProperty(com);
 
  813 void G4UIGAG::UpdateState(
void)
 
  819    if( newState != previousState ) 
 
  822       previousState = newState; 
 
  826 int G4UIGAG::CommandUpdated(
void)
 
  829   int pEntry= previousTreeCommands.size();
 
  830   int nEntry= newTreeCommands.size();
 
  832   for( i=0; i<pEntry; i++) {      
 
  833       for( j=0; j<nEntry; j++) {
 
  834          if( previousTreeCommands[i] == newTreeCommands[j]) 
break;
 
  841   for( i=0; i<nEntry; i++) {      
 
  842       for( j=0; j<pEntry; j++) {
 
  843          if( newTreeCommands[i] == previousTreeCommands[j]) 
break;
 
  865   if( level==0 ) { newTreeCommands.clear();}
 
  866   for(
int com=0; com<commandEntry; com++){
 
  869       newTreeCommands.push_back( commandPath + 
" " + title );
 
  872   if(treeEntry == 0) 
return; 
 
  874   for(
int i=0; i< treeEntry; i++){
 
  878     newTreeCommands.push_back( pathName + 
" " + title );
 
  879     GetNewTreeStructure(t, level+1);
 
  883 void G4UIGAG::UpdateParamVal(
void)
 
  888   int pEntry= previousTreeParams.size();
 
  889   int nEntry= newTreeParams.size();
 
  892   if (pEntry != nEntry) 
return; 
 
  893   for( i=0; i<nEntry; i++) {
 
  894     if( previousTreeParams[i] != newTreeParams[i]){
 
  895        Comp = newTreePCP[i];
 
  897             << 
" command is updated." <<
G4endl; 
 
  898        NotifyParameterUpdate(Comp);
 
  947    if( level==0 ) { newTreeParams.clear(); }
 
  948    for(
int com=0; com<commandEntry; com++) {
 
  952       param = commandPath +
" ";
 
  953       for( 
int par=0; par< parameterEntry; par++) {
 
  962      newTreeParams.push_back( param + 
"\n"); 
 
  963      newTreePCP.push_back( Comp ); 
 
  965    if( treeEntry == 0 )  
return;     
 
  966    for( 
int i=0; i< treeEntry; i++) {
 
  968       GetNewTreeValues(t, level+1);