56 for(i = 0; i < n_treeEntry; ++i)
79 G4String remainingPath = commandPath;
80 remainingPath.erase(0,
pathName.length());
81 if(remainingPath.empty())
99 G4int i = remainingPath.find(
'/');
100 if(i ==
G4int(std::string::npos))
104 for(
G4int i_thCommand = 0; i_thCommand < n_commandEntry; ++i_thCommand)
106 if(remainingPath ==
command[i_thCommand]->GetCommandName())
112 ed <<
"Command <" << commandPath <<
"> already exist. New command is not added.";
113 G4Exception(
"G4UIcommandTree::AddNewCommand",
"UI_ComTree_001",
128 for(; j !=
command.end(); ++j) {
129 if (newCommand->
GetCommandPath() < (*j)->GetCommandPath()) {
break; }
134 {
command.push_back(newCommand); }
141 nextPath.append(remainingPath.substr(0, i + 1));
143 for(
G4int i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree)
149 tree[i_thTree]->AddNewCommand(newCommand, workerThreadOnly);
157 auto j =
tree.begin();
158 for(; j !=
tree.end(); ++j) {
159 if (newTree->
GetPathName() < (*j)->GetPathName()) {
break; }
161 tree.insert(j,newTree);
164 {
tree.push_back(newTree); }
182 G4String remainingPath = commandPath;
183 remainingPath.erase(0,
pathName.length());
184 if(remainingPath.empty())
190 G4int i = remainingPath.find(
'/');
191 if(i ==
G4int(std::string::npos))
195 for(
G4int i_thCommand = 0; i_thCommand < n_commandEntry; ++i_thCommand)
197 if(remainingPath ==
command[i_thCommand]->GetCommandName())
208 nextPath.append(remainingPath.substr(0, i + 1));
210 for(
G4int i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree)
214 tree[i_thTree]->RemoveCommand(aCommand);
215 G4int n_commandRemain =
tree[i_thTree]->GetCommandEntry();
216 G4int n_treeRemain =
tree[i_thTree]->GetTreeEntry();
217 if(n_commandRemain == 0 && n_treeRemain == 0)
220 tree.erase(
tree.begin() + i_thTree);
235 G4String remainingPath = commandPath;
236 if(remainingPath.find(
pathName) == std::string::npos)
240 remainingPath.erase(0,
pathName.length());
241 G4int i = remainingPath.find(
'/');
242 if(i ==
G4int(std::string::npos))
246 for(
G4int i_thCommand = 0; i_thCommand < n_commandEntry; ++i_thCommand)
248 if(remainingPath ==
command[i_thCommand]->GetCommandName())
258 nextPath.append(remainingPath.substr(0, i + 1));
260 for(
G4int i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree)
264 return tree[i_thTree]->FindPath(commandPath);
278 G4String remainingPath = commandPath;
279 if(remainingPath.find(
pathName) == std::string::npos)
283 remainingPath.erase(0,
pathName.length());
284 G4int i = remainingPath.find(
'/');
285 if(i !=
G4int(std::string::npos))
289 nextPath.append(remainingPath.substr(0, i + 1));
291 for(
G4int i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree)
295 return tree[i_thTree];
299 return tree[i_thTree]->FindCommandTree(commandPath);
314 G4String remainingPath = aCommandPath;
319 auto jpre = pName.rfind(
'/');
320 if(jpre != G4String::npos)
321 pName.erase(jpre + 1);
329 if(pName.find(pName) == std::string::npos)
332 std::vector<G4String> paths;
342 for(
G4int idir = 1; idir <= Ndir; ++idir)
346 if(fpdir.find(remainingPath, 0) == 0)
350 matchingPath = fpdir;
357 paths.push_back(fpdir);
361 if(paths.size() >= 2)
364 for(
unsigned int i_thCommand = 0; i_thCommand < paths.size(); ++i_thCommand)
371 std::vector<G4String> commands;
373 for(
G4int icmd = 1; icmd <= Ncmd; ++icmd)
378 if(fpcmd.find(remainingPath, 0) == 0)
382 matchingPath = fpcmd +
" ";
386 strtmp = fpcmd +
" ";
390 commands.push_back(fpcmd +
" ");
394 if(commands.size() >= 2)
397 for(
unsigned int i_thCommand = 0; i_thCommand < commands.size();
411 G4int nlen1 = str1.length();
412 G4int nlen2 = str2.length();
414 G4int nmin = nlen1 < nlen2 ? nlen1 : nlen2;
417 for(
size_t i = 0;
G4int(i) < nmin; ++i)
419 if(str1[i] == str2[i])
421 strMatched += str1[i];
440 for(
G4int i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree)
442 G4cout <<
" " <<
tree[i_thTree]->GetPathName();
456 for(
G4int i_thCommand = 0; i_thCommand < n_commandEntry; ++i_thCommand)
459 if(
command[i_thCommand]->IsWorkerThreadOnly())
480 for(
G4int i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree)
483 G4cout <<
" " << i <<
") " <<
tree[i_thTree]->GetPathName() <<
" "
488 for(
G4int i_thCommand = 0; i_thCommand < n_commandEntry; ++i_thCommand)
491 G4cout <<
" " << i <<
") " <<
command[i_thCommand]->GetCommandName()
501 for(
G4int i_thCommand = 0; i_thCommand < n_commandEntry; ++i_thCommand)
506 for(
G4int i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree)
508 tree[i_thTree]->List();
517 while((idxs = fn.find(
"/")) !=
G4int(std::string::npos))
530 for(
G4int i = 0; i <
G4int(str.length()); ++i)
555 std::ofstream oF(ofileName, std::ios::out);
558 <<
"</title></head>" <<
G4endl;
560 table,table td,table th { \
561 border:1px solid #eee \
563 table td,table th { \
570 text-decoration:none; \
571 transition-duration:0.3s \
577 border-collapse:collapse; \
584 letter-spacing:-1px; \
585 line-height:1.15em; \
586 margin-bottom:0.5em; \
587 word-wrap:break-word \
592 letter-spacing:-1px; \
593 line-height:1.15em; \
594 margin-bottom:0.5em; \
595 word-wrap:break-word \
601 padding:15px 0 15px 0; \
602 border-bottom:2px #eee solid; \
603 word-wrap:break-word \
610 -webkit-box-sizing:border-box; \
611 -moz-box-sizing:border-box; \
612 -ms-box-sizing:border-box; \
613 box-sizing:border-box; \
619 display:inline-block; \
620 background-color:#fff; \
621 padding: 25px 35px 20px 30px; \
622 -webkit-box-sizing:border-box; \
623 -moz-box-sizing:border-box; \
624 -ms-box-sizing:border-box; \
625 box-sizing:border-box \
628 oF <<
"<body bgcolor=\"#ffffff\">" <<
G4endl;
632 oF <<
"<div class=\"sidebar\">" << sideBar <<
"</div>" <<
G4endl;
635 oF <<
"<div class=\"context\">";
645 if (
tree.size() >0 ){
648 menu +=
"<h2>Sub-directories </h2><table>";
649 newSideBar +=
"<h2><a href=\"" + ofileName +
"\">Top level </a></h2><table>";
651 for(std::size_t i_thTree = 0; i_thTree <
tree.size(); ++i_thTree)
653 newSideBar +=
"<tr><td><a href=\""
658 for(std::size_t i_thTree = 0; i_thTree <
tree.size(); ++i_thTree)
660 menu +=
"<tr><td><a href=\""
666 newSideBar +=
"</table>";
667 for(std::size_t i_thTree = 0; i_thTree <
tree.size(); ++i_thTree)
670 tree[i_thTree]->CreateHTML(newSideBar);
677 oF <<
"<h2>Commands </h2>" <<
G4endl;
680 oF <<
"<table>" <<
G4endl;
681 for(std::size_t i_thCommand = 0; i_thCommand <
command.size(); ++i_thCommand)
685 oF <<
"</a></td></tr>" <<
G4endl;
687 oF <<
"</table>" <<
G4endl;
688 for(std::size_t i_thCommand = 0; i_thCommand <
command.size(); ++i_thCommand)
712 std::vector<G4ApplicationState>* availabelStateList = cmd->
GetStateList();
713 if(availabelStateList->size() == 6)
715 oF <<
"<p>Available at all Geant4 states." <<
G4endl;
719 oF <<
"<p>Available Geant4 state(s) : ";
720 for(std::size_t ias = 0; ias < availabelStateList->size(); ++ias)
723 (*availabelStateList)[ias])
729 oF <<
"<p>Parameters<table border=1>" <<
G4endl;
739 oF <<
"Omittable : ";
742 oF <<
"current value is used as the default value." <<
G4endl;
757 oF <<
"Parameter candidates : "
761 oF <<
"</table>" <<
G4endl;
765 oF <<
"</div></body></html>" <<
G4endl;
773 for(std::size_t i = 0; i <
tree.size(); ++i)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4GLOB_DLL std::ostream G4cout
G4String GetStateString(const G4ApplicationState &aState) const
static G4StateManager * GetStateManager()
G4String CreateFileName(const char *pName)
G4bool operator!=(const G4UIcommandTree &right) const
G4int GetCommandEntry() const
const G4UIcommand * GetGuidance() const
std::vector< G4UIcommandTree * > tree
G4UIcommand * GetCommand(G4int i)
const G4String & GetPathName() const
G4int GetTreeEntry() const
G4UIcommandTree * GetTree(G4int i)
G4bool operator==(const G4UIcommandTree &right) const
void AddNewCommand(G4UIcommand *newCommand, G4bool workerThreadOnly=false)
G4int createHTMLTreeLevel
G4String ModStr(const char *strS)
G4UIcommandTree * FindCommandTree(const char *commandPath)
void ListCurrentWithNum() const
const G4String GetTitle() const
G4String CompleteCommandPath(const G4String &commandPath)
G4String GetFirstMatchedString(const G4String &, const G4String &) const
G4UIcommand * FindPath(const char *commandPath) const
std::vector< G4UIcommand * > command
void CreateHTML(G4String="")
void RemoveCommand(G4UIcommand *aCommand, G4bool workerThreadOnly=false)
void SetToBeBroadcasted(G4bool val)
G4bool IsWorkerThreadOnly() const
std::size_t GetParameterEntries() const
const G4String & GetGuidanceLine(G4int i) const
G4UIparameter * GetParameter(G4int i) const
G4bool ToBeBroadcasted() const
const G4String & GetCommandPath() const
std::size_t GetGuidanceEntries() const
std::vector< G4ApplicationState > * GetStateList()
void SetWorkerThreadOnly(G4bool val=true)
const G4String & GetCommandName() const
const G4String & GetRange() const
void SetDefaultSortFlag(G4bool val)
G4int GetVerboseLevel() const
static G4UImanager * GetUIpointer()
const G4String & GetParameterCandidates() const
G4bool IsOmittable() const
const G4String & GetParameterRange() const
G4bool GetCurrentAsDefault() const
char GetParameterType() const
const G4String & GetParameterName() const
const G4String & GetDefaultValue() const