48 G4UIcommandCommonConstructorCode(comStr);
54void G4UIcommand::G4UIcommandCommonConstructorCode(
const char* theCommandPath)
56 commandPath = theCommandPath;
57 commandName = theCommandPath;
58 auto commandNameIndex = (
G4int)commandName.rfind(
'/');
59 commandName.erase(0, commandNameIndex + 1);
78 if (messenger ==
nullptr) {
81 ed <<
"A UI command <" << commandPath <<
"> is defined without vaild messenger.";
84 else if (commandPath.back() !=
'/') {
86 ed <<
"G4UIcommand Warning : \n"
87 <<
" <" << commandPath <<
"> must be a directory."
88 <<
" '/' is appended.";
100 if (fUImanager !=
nullptr) {
104 for (
const auto& p : parameter) {
125 std::size_t n_parameterEntry = parameter.size();
126 if (n_parameterEntry != 0) {
130 for (std::size_t i_thParameter = 0; i_thParameter < n_parameterEntry; ++i_thParameter) {
131 if (i_thParameter > 0) {
132 correctParameters.append(
" ");
134 aToken = parameterToken();
135 if (aToken.length() > 0 && aToken[0] ==
'"') {
136 while (aToken.back() !=
'"' || (aToken.length() == 1 && aToken[0] ==
'"')) {
137 G4String additionalToken = parameterToken();
138 if (additionalToken.empty()) {
142 aToken += additionalToken;
145 else if (i_thParameter == n_parameterEntry - 1
146 && parameter[i_thParameter]->GetParameterType() ==
's')
149 while (!((anotherToken = parameterToken()).empty())) {
150 std::size_t idxs = anotherToken.find(
'#');
151 if (idxs == std::string::npos) {
153 aToken += anotherToken;
157 aToken += anotherToken.substr(0, idxs);
166 if (aToken.empty() || aToken ==
"!") {
167 if (parameter[i_thParameter]->IsOmittable()) {
168 if (parameter[i_thParameter]->GetCurrentAsDefault()) {
169 G4Tokenizer cvSt(messenger->GetCurrentValue(
this));
171 for (std::size_t ii = 0; ii < i_thParameter; ++ii) {
173 if (parVal[0] ==
'"') {
174 while (parVal.back() !=
'"') {
176 if (additionalToken.empty()) {
180 parVal += additionalToken;
185 if (aCVToken[0] ==
'"') {
186 while (aCVToken.back() !=
'"') {
188 if (additionalToken.empty()) {
192 aCVToken += additionalToken;
195 correctParameters.append(aCVToken);
198 correctParameters.append(parameter[i_thParameter]->GetDefaultValue());
206 G4int stat = parameter[i_thParameter]->CheckNewValue(aToken);
208 return stat +
G4int(i_thParameter);
210 correctParameters.append(aToken);
223 messenger->SetNewValue(
this, std::move(correctParameters));
230 return messenger->GetCurrentValue(
this);
236 availabelStateList = {s1};
242 availabelStateList = {s1, s2};
249 availabelStateList = {s1, s2, s3};
256 availabelStateList = {s1, s2, s3, s4};
264 availabelStateList = {s1, s2, s3, s4, s5};
272 for (
const auto& s : availabelStateList) {
273 if (s == currentState) {
298 auto ucatIter = std::find_if(std::cbegin(UTbl), std::cend(UTbl), [&unitCategory](
const auto& ud) {
299 return ud->GetName() == unitCategory;
302 if (ucatIter == std::cend(UTbl)) {
303 G4cerr <<
"Unit category <" << unitCategory <<
"> is not defined." <<
G4endl;
311 for (
const auto& uDef : UCnt) {
312 symList += uDef->GetSymbol();
314 nameList += uDef->GetName();
327 if (commandPath.back() !=
'/') {
331 G4cout <<
" ---- available only in worker thread" <<
G4endl;
335 for (
const auto& i_thGuidance : commandGuidance) {
339 if (!rangeExpression.empty()) {
340 G4cout <<
" Range of parameters : " << rangeExpression <<
G4endl;
343 for (
const auto& i_thParameter : parameter) {
344 i_thParameter->List();
352 return boolVal ?
"1" :
"0";
370 std::ostringstream os;
372 os << std::setprecision(17);
381 std::ostringstream os;
383 os << std::setprecision(17);
385 os << doubleValue /
ValueOf(unitName) <<
" " << unitName;
392 std::ostringstream os;
394 os << std::setprecision(17);
396 os << vec.
x() <<
" " << vec.
y() <<
" " << vec.
z();
405 std::ostringstream os;
407 os << std::setprecision(17);
409 os << vec.
x() / uv <<
" " << vec.
y() / uv <<
" " << vec.
z() / uv <<
" " << unitName;
417 return (v ==
"Y" || v ==
"YES" || v ==
"1" || v ==
"T" || v ==
"TRUE");
444 std::istringstream is(st);
457 std::istringstream is(st);
458 is >> vx >> vy >> vz;
469 std::istringstream is(st);
470 is >> vx >> vy >> vz >> unts;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
CLHEP::Hep3Vector G4ThreeVector
std::vector< G4UnitDefinition * > G4UnitsContainer
std::vector< G4UnitsCategory * > G4UnitsTable
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
const G4ApplicationState & GetCurrentState() const
static G4StateManager * GetStateManager()
static G4ThreeVector ConvertTo3Vector(const char *st)
static G4String CategoryOf(const char *unitName)
static G4double ValueOf(const char *unitName)
void SetCommandType(CommandType)
static G4long ConvertToLongInt(const char *st)
virtual G4int DoIt(const G4String ¶meterList)
G4bool operator==(const G4UIcommand &right) const
static G4String ConvertToString(G4bool boolVal)
const G4String & GetCommandPath() const
G4int CheckNewValue(const char *newValue)
static G4int ConvertToInt(const char *st)
static G4String UnitsList(const char *unitCategory)
static G4bool ConvertToBool(const char *st)
static G4double ConvertToDouble(const char *st)
static G4double ConvertToDimensionedDouble(const char *st)
void AvailableForStates(G4ApplicationState s1)
G4bool operator!=(const G4UIcommand &right) const
static G4ThreeVector ConvertToDimensioned3Vector(const char *st)
G4String GetCurrentValue()
static G4bool DoublePrecisionStr()
static G4UImanager * GetMasterUIpointer()
void AddNewCommand(G4UIcommand *newCommand)
void RemoveCommand(G4UIcommand *aCommand)
static G4UImanager * GetUIpointer()
G4bool CommandsShouldBeInMaster() const
static G4double GetValueOf(const G4String &)
static G4String GetCategory(const G4String &)
static G4UnitsTable & GetUnitsTable()
void rstrip(G4String &str, char ch=' ')
Remove trailing characters from string.
G4String to_upper_copy(G4String str)
Return uppercase copy of string.
G4bool RangeCheck(const G4UIparameter &p, const char *value)
T StoT(const G4String &s)