Import Geant4 10.7.0 source tree
This commit is contained in:
@@ -22,8 +22,10 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4GenericMessenger
|
||||
//
|
||||
//
|
||||
// Author: P.Mato, CERN - 27 September 2012
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4GenericMessenger.hh"
|
||||
#include "G4Types.hh"
|
||||
@@ -36,206 +38,283 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
class G4InvalidUICommand: public std::bad_cast {
|
||||
public:
|
||||
G4InvalidUICommand() {}
|
||||
virtual const char* what() const throw() {
|
||||
return "G4InvalidUICommand: command does not exists or is of invalid type";
|
||||
}
|
||||
class G4InvalidUICommand : public std::bad_cast
|
||||
{
|
||||
public:
|
||||
|
||||
G4InvalidUICommand() {}
|
||||
virtual const char* what() const throw()
|
||||
{
|
||||
return "G4InvalidUICommand: command does not exist or is of invalid type";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
G4GenericMessenger::G4GenericMessenger(void* obj, const G4String& dir, const G4String& doc): directory(dir), object(obj) {
|
||||
G4GenericMessenger::G4GenericMessenger(void* obj, const G4String& dir,
|
||||
const G4String& doc)
|
||||
: directory(dir)
|
||||
, object(obj)
|
||||
{
|
||||
// Check if parent commnand is already existing.
|
||||
// In fact there is no way to check this. UImanager->GetTree()->FindPath() will always rerurn NULL is a dicrectory is given
|
||||
size_t pos = dir.find_last_of('/', dir.size()-2);
|
||||
while(pos != 0 && pos != std::string::npos) {
|
||||
G4UIdirectory* d = new G4UIdirectory(dir.substr(0,pos+1).c_str());
|
||||
// In fact there is no way to check this. UImanager->GetTree()->FindPath()
|
||||
// will always rerurn NULL is a dicrectory is given
|
||||
std::size_t pos = dir.find_last_of('/', dir.size() - 2);
|
||||
while(pos != 0 && pos != std::string::npos)
|
||||
{
|
||||
G4UIdirectory* d = new G4UIdirectory(dir.substr(0, pos + 1).c_str());
|
||||
G4String guidance = "Commands for ";
|
||||
guidance += dir.substr(1,pos-1);
|
||||
guidance += dir.substr(1, pos - 1);
|
||||
d->SetGuidance(guidance);
|
||||
pos = dir.find_last_of('/', pos-1);
|
||||
pos = dir.find_last_of('/', pos - 1);
|
||||
}
|
||||
dircmd = new G4UIdirectory(dir);
|
||||
dircmd->SetGuidance(doc);
|
||||
}
|
||||
|
||||
G4GenericMessenger::~G4GenericMessenger() {
|
||||
G4GenericMessenger::~G4GenericMessenger()
|
||||
{
|
||||
delete dircmd;
|
||||
for (std::map<G4String, Property>::iterator i = properties.begin(); i != properties.end(); i++) delete i->second.command;
|
||||
for (std::map<G4String, Method>::iterator i = methods.begin(); i != methods.end(); i++) delete i->second.command;
|
||||
for(auto i = properties.cbegin(); i != properties.cend(); ++i)
|
||||
delete i->second.command;
|
||||
for(auto i = methods.cbegin(); i != methods.cend(); ++i)
|
||||
delete i->second.command;
|
||||
}
|
||||
|
||||
|
||||
G4GenericMessenger::Command&
|
||||
G4GenericMessenger::DeclareProperty(const G4String& name, const G4AnyType& var, const G4String& doc) {
|
||||
G4String fullpath = directory+name;
|
||||
G4UIcommand* cmd = new G4UIcommand(fullpath.c_str(), this);
|
||||
if(doc != "") cmd->SetGuidance(doc);
|
||||
G4GenericMessenger::Command& G4GenericMessenger::DeclareProperty(
|
||||
const G4String& name, const G4AnyType& var, const G4String& doc)
|
||||
{
|
||||
G4String fullpath = directory + name;
|
||||
G4UIcommand* cmd = new G4UIcommand(fullpath.c_str(), this);
|
||||
if(doc != "")
|
||||
cmd->SetGuidance(doc);
|
||||
char ptype;
|
||||
if(var.TypeInfo() == typeid(int) || var.TypeInfo() == typeid(long) ||
|
||||
var.TypeInfo() == typeid(unsigned int) || var.TypeInfo() == typeid(unsigned long)) ptype = 'i';
|
||||
else if(var.TypeInfo() == typeid(float) || var.TypeInfo() == typeid(double)) ptype = 'd';
|
||||
else if(var.TypeInfo() == typeid(bool)) ptype = 'b';
|
||||
else if(var.TypeInfo() == typeid(G4String)) ptype = 's';
|
||||
else ptype = 's';
|
||||
var.TypeInfo() == typeid(unsigned int) ||
|
||||
var.TypeInfo() == typeid(unsigned long))
|
||||
ptype = 'i';
|
||||
else if(var.TypeInfo() == typeid(float) || var.TypeInfo() == typeid(double))
|
||||
ptype = 'd';
|
||||
else if(var.TypeInfo() == typeid(bool))
|
||||
ptype = 'b';
|
||||
else if(var.TypeInfo() == typeid(G4String))
|
||||
ptype = 's';
|
||||
else
|
||||
ptype = 's';
|
||||
cmd->SetParameter(new G4UIparameter("value", ptype, false));
|
||||
return properties[name] = Property(var, cmd);
|
||||
}
|
||||
|
||||
|
||||
G4GenericMessenger::Command& G4GenericMessenger::DeclarePropertyWithUnit
|
||||
(const G4String& name, const G4String& defaultUnit, const G4AnyType& var, const G4String& doc) {
|
||||
if(var.TypeInfo()!=typeid(float) && var.TypeInfo()!=typeid(double) && var.TypeInfo()!= typeid(G4ThreeVector))
|
||||
{ return DeclareProperty(name,var,doc); }
|
||||
G4String fullpath = directory+name;
|
||||
G4GenericMessenger::Command& G4GenericMessenger::DeclarePropertyWithUnit(
|
||||
const G4String& name, const G4String& defaultUnit, const G4AnyType& var,
|
||||
const G4String& doc)
|
||||
{
|
||||
if(var.TypeInfo() != typeid(float) && var.TypeInfo() != typeid(double) &&
|
||||
var.TypeInfo() != typeid(G4ThreeVector))
|
||||
{
|
||||
return DeclareProperty(name, var, doc);
|
||||
}
|
||||
G4String fullpath = directory + name;
|
||||
G4UIcommand* cmd;
|
||||
if(var.TypeInfo()==typeid(float) || var.TypeInfo()==typeid(double))
|
||||
if(var.TypeInfo() == typeid(float) || var.TypeInfo() == typeid(double))
|
||||
{
|
||||
cmd = new G4UIcmdWithADoubleAndUnit(fullpath.c_str(), this);
|
||||
(static_cast<G4UIcmdWithADoubleAndUnit*>(cmd))->SetParameterName("value",false,false);
|
||||
(static_cast<G4UIcmdWithADoubleAndUnit*>(cmd))
|
||||
->SetParameterName("value", false, false);
|
||||
(static_cast<G4UIcmdWithADoubleAndUnit*>(cmd))->SetDefaultUnit(defaultUnit);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd = new G4UIcmdWith3VectorAndUnit(fullpath.c_str(), this);
|
||||
(static_cast<G4UIcmdWith3VectorAndUnit*>(cmd))->SetParameterName("valueX","valueY","valueZ",false,false);
|
||||
(static_cast<G4UIcmdWith3VectorAndUnit*>(cmd))
|
||||
->SetParameterName("valueX", "valueY", "valueZ", false, false);
|
||||
(static_cast<G4UIcmdWith3VectorAndUnit*>(cmd))->SetDefaultUnit(defaultUnit);
|
||||
}
|
||||
|
||||
if(doc != "") cmd->SetGuidance(doc);
|
||||
if(doc != "")
|
||||
cmd->SetGuidance(doc);
|
||||
return properties[name] = Property(var, cmd);
|
||||
}
|
||||
|
||||
|
||||
G4GenericMessenger::Command&
|
||||
G4GenericMessenger::DeclareMethod(const G4String& name, const G4AnyMethod& fun, const G4String& doc) {
|
||||
G4String fullpath = directory+name;
|
||||
G4UIcommand* cmd = new G4UIcommand(fullpath.c_str(), this);
|
||||
if(doc != "") cmd->SetGuidance(doc);
|
||||
for (size_t i = 0; i < fun.NArg(); i++) {
|
||||
G4GenericMessenger::Command& G4GenericMessenger::DeclareMethod(
|
||||
const G4String& name, const G4AnyMethod& fun, const G4String& doc)
|
||||
{
|
||||
G4String fullpath = directory + name;
|
||||
G4UIcommand* cmd = new G4UIcommand(fullpath.c_str(), this);
|
||||
if(doc != "")
|
||||
cmd->SetGuidance(doc);
|
||||
for(std::size_t i = 0; i < fun.NArg(); ++i)
|
||||
{
|
||||
cmd->SetParameter(new G4UIparameter("arg", 's', false));
|
||||
}
|
||||
return methods[name] = Method(fun, object, cmd);
|
||||
}
|
||||
|
||||
G4GenericMessenger::Command& G4GenericMessenger::DeclareMethodWithUnit
|
||||
(const G4String& name, const G4String& defaultUnit, const G4AnyMethod& fun, const G4String& doc) {
|
||||
G4String fullpath = directory+name;
|
||||
if(fun.NArg()!=1) {
|
||||
G4GenericMessenger::Command& G4GenericMessenger::DeclareMethodWithUnit(
|
||||
const G4String& name, const G4String& defaultUnit, const G4AnyMethod& fun,
|
||||
const G4String& doc)
|
||||
{
|
||||
G4String fullpath = directory + name;
|
||||
if(fun.NArg() != 1)
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
ed<<"G4GenericMessenger::DeclareMethodWithUnit() does not support a method that has more than\n"
|
||||
<<"one arguments (or no argument). Please use G4GenericMessenger::DeclareMethod method for\n"
|
||||
<<"your command <"<<fullpath<<">.";
|
||||
G4Exception("G4GenericMessenger::DeclareMethodWithUnit()","Intercom70002",FatalException,ed);
|
||||
ed << "G4GenericMessenger::DeclareMethodWithUnit() does not support a "
|
||||
"method that has more than\n"
|
||||
<< "one arguments (or no argument). Please use "
|
||||
"G4GenericMessenger::DeclareMethod method for\n"
|
||||
<< "your command <" << fullpath << ">.";
|
||||
G4Exception("G4GenericMessenger::DeclareMethodWithUnit()", "Intercom70002",
|
||||
FatalException, ed);
|
||||
}
|
||||
G4UIcommand* cmd = new G4UIcmdWithADoubleAndUnit(fullpath.c_str(), this);
|
||||
(static_cast<G4UIcmdWithADoubleAndUnit*>(cmd))->SetParameterName("value",false,false);
|
||||
(static_cast<G4UIcmdWithADoubleAndUnit*>(cmd))
|
||||
->SetParameterName("value", false, false);
|
||||
(static_cast<G4UIcmdWithADoubleAndUnit*>(cmd))->SetDefaultUnit(defaultUnit);
|
||||
if(doc != "") cmd->SetGuidance(doc);
|
||||
if(doc != "")
|
||||
cmd->SetGuidance(doc);
|
||||
return methods[name] = Method(fun, object, cmd);
|
||||
}
|
||||
|
||||
|
||||
G4String G4GenericMessenger::GetCurrentValue(G4UIcommand* command) {
|
||||
if ( properties.find(command->GetCommandName()) != properties.end()) {
|
||||
G4String G4GenericMessenger::GetCurrentValue(G4UIcommand* command)
|
||||
{
|
||||
if(properties.find(command->GetCommandName()) != properties.cend())
|
||||
{
|
||||
Property& p = properties[command->GetCommandName()];
|
||||
return p.variable.ToString();
|
||||
}
|
||||
else if ( methods.find(command->GetCommandName()) != methods.end()) {
|
||||
G4cout<<" GetCurrentValue() is not available for a command defined by G4GenericMessenger::DeclareMethod()."<<G4endl;
|
||||
else if(methods.find(command->GetCommandName()) != methods.cend())
|
||||
{
|
||||
G4cout << " GetCurrentValue() is not available for a command defined by "
|
||||
"G4GenericMessenger::DeclareMethod()."
|
||||
<< G4endl;
|
||||
return G4String();
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
throw G4InvalidUICommand();
|
||||
}
|
||||
}
|
||||
|
||||
void G4GenericMessenger::SetNewValue(G4UIcommand* command, G4String newValue) {
|
||||
void G4GenericMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
{
|
||||
// Check if there are units on this commands
|
||||
if (typeid(*command) == typeid(G4UIcmdWithADoubleAndUnit)) {
|
||||
newValue = G4UIcommand::ConvertToString(G4UIcommand::ConvertToDimensionedDouble(newValue));
|
||||
if(typeid(*command) == typeid(G4UIcmdWithADoubleAndUnit))
|
||||
{
|
||||
newValue = G4UIcommand::ConvertToString(
|
||||
G4UIcommand::ConvertToDimensionedDouble(newValue));
|
||||
}
|
||||
else if (typeid(*command) == typeid(G4UIcmdWith3VectorAndUnit)) {
|
||||
newValue = G4UIcommand::ConvertToString(G4UIcommand::ConvertToDimensioned3Vector(newValue));
|
||||
else if(typeid(*command) == typeid(G4UIcmdWith3VectorAndUnit))
|
||||
{
|
||||
newValue = G4UIcommand::ConvertToString(
|
||||
G4UIcommand::ConvertToDimensioned3Vector(newValue));
|
||||
}
|
||||
|
||||
if ( properties.find(command->GetCommandName()) != properties.end()) {
|
||||
|
||||
if(properties.find(command->GetCommandName()) != properties.cend())
|
||||
{
|
||||
Property& p = properties[command->GetCommandName()];
|
||||
p.variable.FromString(newValue);
|
||||
}
|
||||
else if (methods.find(command->GetCommandName()) != methods.end()) {
|
||||
else if(methods.find(command->GetCommandName()) != methods.cend())
|
||||
{
|
||||
Method& m = methods[command->GetCommandName()];
|
||||
if(m.method.NArg() == 0)
|
||||
m.method.operator()(m.object);
|
||||
else if (m.method.NArg() > 0) {
|
||||
m.method.operator()(m.object,newValue);
|
||||
else if(m.method.NArg() > 0)
|
||||
{
|
||||
m.method.operator()(m.object, newValue);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
throw G4InvalidUICommand();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void G4GenericMessenger::SetGuidance(const G4String& s) {
|
||||
void G4GenericMessenger::SetGuidance(const G4String& s)
|
||||
{
|
||||
dircmd->SetGuidance(s);
|
||||
}
|
||||
|
||||
G4GenericMessenger::Command& G4GenericMessenger::Command::SetUnit(const G4String& unit, UnitSpec spec) {
|
||||
G4GenericMessenger::Command& G4GenericMessenger::Command::SetUnit(
|
||||
const G4String& unit, UnitSpec spec)
|
||||
{
|
||||
// Change the type of command (unfortunatelly this is done a posteriory)
|
||||
// We need to delete the old command before creating the new one and therefore we need to recover the information
|
||||
// before the deletetion
|
||||
if ( G4Threading::IsMultithreadedApplication() ) {
|
||||
// We need to delete the old command before creating the new one and therefore
|
||||
// we need to recover the information before the deletetion
|
||||
if(G4Threading::IsMultithreadedApplication())
|
||||
{
|
||||
G4String cmdpath = command->GetCommandPath();
|
||||
G4ExceptionDescription ed;
|
||||
ed<<"G4GenericMessenger::Command::SetUnit() is thread-unsafe and should not be used\n"
|
||||
<<"in multi-threaded mode. For your command <"<<cmdpath<<">, use\n"
|
||||
<<" DeclarePropertyWithUnit(const G4String& name, const G4String& defaultUnit,\n"
|
||||
<<" const G4AnyType& variable, const G4String& doc)\n"
|
||||
<<"or\n"
|
||||
<<" DeclareMethodWithUnit(const G4String& name, const G4String& defaultUnit,\n"
|
||||
<<" const G4AnyType& variable, const G4String& doc)\n"
|
||||
<<"to define a command with a unit <"<<unit<<">.";
|
||||
if(spec!=UnitDefault) { ed<<"\nPlease use a default unit instead of unit category."; }
|
||||
G4Exception("G4GenericMessenger::Command::SetUnit()","Intercom70001",FatalException,ed);
|
||||
ed << "G4GenericMessenger::Command::SetUnit() is thread-unsafe and should "
|
||||
"not be used\n"
|
||||
<< "in multi-threaded mode. For your command <" << cmdpath << ">, use\n"
|
||||
<< " DeclarePropertyWithUnit(const G4String& name, const G4String& "
|
||||
"defaultUnit,\n"
|
||||
<< " const G4AnyType& variable, const G4String& "
|
||||
"doc)\n"
|
||||
<< "or\n"
|
||||
<< " DeclareMethodWithUnit(const G4String& name, const G4String& "
|
||||
"defaultUnit,\n"
|
||||
<< " const G4AnyType& variable, const G4String& "
|
||||
"doc)\n"
|
||||
<< "to define a command with a unit <" << unit << ">.";
|
||||
if(spec != UnitDefault)
|
||||
{
|
||||
ed << "\nPlease use a default unit instead of unit category.";
|
||||
}
|
||||
G4Exception("G4GenericMessenger::Command::SetUnit()", "Intercom70001",
|
||||
FatalException, ed);
|
||||
return *this;
|
||||
}
|
||||
|
||||
G4String cmdpath = command->GetCommandPath();
|
||||
G4String cmdpath = command->GetCommandPath();
|
||||
G4UImessenger* messenger = command->GetMessenger();
|
||||
G4String range = command->GetRange();
|
||||
G4String range = command->GetRange();
|
||||
std::vector<G4String> guidance;
|
||||
G4String par_name = command->GetParameter(0)->GetParameterName();
|
||||
G4String par_name = command->GetParameter(0)->GetParameterName();
|
||||
G4bool par_omitable = command->GetParameter(0)->IsOmittable();
|
||||
for (size_t i = 0; i < command->GetGuidanceEntries(); ++i) guidance.push_back(command->GetGuidanceLine(i));
|
||||
// Before deleting the command we need to add a fake one to avoid deleting the directory entry and with its guidance
|
||||
G4UIcommand tmp((cmdpath+"_tmp").c_str(), messenger);
|
||||
for(std::size_t i = 0; i < command->GetGuidanceEntries(); ++i)
|
||||
guidance.push_back(command->GetGuidanceLine(i));
|
||||
// Before deleting the command we need to add a fake one to avoid deleting
|
||||
// the directory entry and with its guidance
|
||||
G4UIcommand tmp((cmdpath + "_tmp").c_str(), messenger);
|
||||
delete command;
|
||||
|
||||
if (*type == typeid(float) || *type == typeid(double) ) {
|
||||
G4UIcmdWithADoubleAndUnit* cmd_t = new G4UIcmdWithADoubleAndUnit(cmdpath, messenger);
|
||||
if(spec == UnitDefault) cmd_t->SetDefaultUnit(unit);
|
||||
else if(spec == UnitCategory) cmd_t->SetUnitCategory(unit);
|
||||
if(*type == typeid(float) || *type == typeid(double))
|
||||
{
|
||||
G4UIcmdWithADoubleAndUnit* cmd_t =
|
||||
new G4UIcmdWithADoubleAndUnit(cmdpath, messenger);
|
||||
if(spec == UnitDefault)
|
||||
cmd_t->SetDefaultUnit(unit);
|
||||
else if(spec == UnitCategory)
|
||||
cmd_t->SetUnitCategory(unit);
|
||||
cmd_t->SetParameterName(par_name, par_omitable);
|
||||
command = cmd_t;
|
||||
}
|
||||
else if (*type == typeid(G4ThreeVector)) {
|
||||
G4UIcmdWith3VectorAndUnit* cmd_t = new G4UIcmdWith3VectorAndUnit(cmdpath, messenger);
|
||||
if(spec == UnitDefault) cmd_t->SetDefaultUnit(unit);
|
||||
else if(spec == UnitCategory) cmd_t->SetUnitCategory(unit);
|
||||
else if(*type == typeid(G4ThreeVector))
|
||||
{
|
||||
G4UIcmdWith3VectorAndUnit* cmd_t =
|
||||
new G4UIcmdWith3VectorAndUnit(cmdpath, messenger);
|
||||
if(spec == UnitDefault)
|
||||
cmd_t->SetDefaultUnit(unit);
|
||||
else if(spec == UnitCategory)
|
||||
cmd_t->SetUnitCategory(unit);
|
||||
command = cmd_t;
|
||||
}
|
||||
else {
|
||||
G4cerr << "Only parameters of type <double> or <float> can be associated with units" << G4endl;
|
||||
else
|
||||
{
|
||||
G4cerr << "Only parameters of type <double> or <float> can be associated "
|
||||
"with units"
|
||||
<< G4endl;
|
||||
return *this;
|
||||
}
|
||||
for (size_t i = 0; i < guidance.size(); i++) command->SetGuidance(guidance[i]);
|
||||
for(std::size_t i = 0; i < guidance.size(); ++i)
|
||||
command->SetGuidance(guidance[i]);
|
||||
command->SetRange(range);
|
||||
return *this;
|
||||
}
|
||||
|
||||
G4GenericMessenger::Command& G4GenericMessenger::Command::SetParameterName(const G4String& name,G4bool omittable, G4bool currentAsDefault) {
|
||||
G4GenericMessenger::Command& G4GenericMessenger::Command::SetParameterName(
|
||||
const G4String& name, G4bool omittable, G4bool currentAsDefault)
|
||||
{
|
||||
G4UIparameter* theParam = command->GetParameter(0);
|
||||
theParam->SetParameterName(name);
|
||||
theParam->SetOmittable(omittable);
|
||||
@@ -243,17 +322,18 @@ G4GenericMessenger::Command& G4GenericMessenger::Command::SetParameterName(const
|
||||
return *this;
|
||||
}
|
||||
|
||||
G4GenericMessenger::Command& G4GenericMessenger::Command::SetCandidates(const G4String& candList) {
|
||||
G4UIparameter * theParam = command->GetParameter(0);
|
||||
G4GenericMessenger::Command& G4GenericMessenger::Command::SetCandidates(
|
||||
const G4String& candList)
|
||||
{
|
||||
G4UIparameter* theParam = command->GetParameter(0);
|
||||
theParam->SetParameterCandidates(candList);
|
||||
return *this;
|
||||
}
|
||||
|
||||
G4GenericMessenger::Command& G4GenericMessenger::Command::SetDefaultValue(const G4String& defVal) {
|
||||
G4UIparameter * theParam = command->GetParameter(0);
|
||||
G4GenericMessenger::Command& G4GenericMessenger::Command::SetDefaultValue(
|
||||
const G4String& defVal)
|
||||
{
|
||||
G4UIparameter* theParam = command->GetParameter(0);
|
||||
theParam->SetDefaultValue(defVal);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4LocalThreadCoutMessenger
|
||||
//
|
||||
// Author: M.Asai, 2013
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4LocalThreadCoutMessenger.hh"
|
||||
|
||||
@@ -36,71 +40,90 @@
|
||||
#include "G4UIparameter.hh"
|
||||
#include "G4Tokenizer.hh"
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4LocalThreadCoutMessenger::G4LocalThreadCoutMessenger()
|
||||
{
|
||||
{
|
||||
coutDir = new G4UIdirectory("/control/cout/");
|
||||
coutDir->SetGuidance("Control cout/cerr for local thread.");
|
||||
|
||||
coutFileNameCmd = new G4UIcommand("/control/cout/setCoutFile",this);
|
||||
coutFileNameCmd->SetGuidance("Send G4cout stream to a file dedicated to a thread. ");
|
||||
coutFileNameCmd->SetGuidance("To have a display output, use special keyword \"**Screen**\".");
|
||||
coutFileNameCmd->SetGuidance("If append flag is true output is appended to file,");
|
||||
coutFileNameCmd = new G4UIcommand("/control/cout/setCoutFile", this);
|
||||
coutFileNameCmd->SetGuidance(
|
||||
"Send G4cout stream to a file dedicated to a thread. ");
|
||||
coutFileNameCmd->SetGuidance(
|
||||
"To have a display output, use special keyword \"**Screen**\".");
|
||||
coutFileNameCmd->SetGuidance(
|
||||
"If append flag is true output is appended to file,");
|
||||
coutFileNameCmd->SetGuidance("otherwise file output is overwritten.");
|
||||
coutFileNameCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
G4UIparameter* pp = new G4UIparameter("fileName",'s',true);
|
||||
coutFileNameCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
G4UIparameter* pp = new G4UIparameter("fileName", 's', true);
|
||||
pp->SetDefaultValue("**Screen**");
|
||||
coutFileNameCmd->SetParameter(pp);
|
||||
pp= new G4UIparameter("append",'b',true);
|
||||
pp = new G4UIparameter("append", 'b', true);
|
||||
pp->SetDefaultValue(true);
|
||||
coutFileNameCmd->SetParameter(pp);
|
||||
|
||||
cerrFileNameCmd = new G4UIcommand("/control/cout/setCerrFile",this);
|
||||
cerrFileNameCmd->SetGuidance("Send G4cerr stream to a file dedicated to a thread. ");
|
||||
cerrFileNameCmd->SetGuidance("To have a display output, use special keyword \"**Screen**\".");
|
||||
cerrFileNameCmd->SetGuidance("If append flag is true output is appended to file,");
|
||||
cerrFileNameCmd = new G4UIcommand("/control/cout/setCerrFile", this);
|
||||
cerrFileNameCmd->SetGuidance(
|
||||
"Send G4cerr stream to a file dedicated to a thread. ");
|
||||
cerrFileNameCmd->SetGuidance(
|
||||
"To have a display output, use special keyword \"**Screen**\".");
|
||||
cerrFileNameCmd->SetGuidance(
|
||||
"If append flag is true output is appended to file,");
|
||||
cerrFileNameCmd->SetGuidance("otherwise file output is overwritten.");
|
||||
cerrFileNameCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
pp = new G4UIparameter("fileName",'s',true);
|
||||
cerrFileNameCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
pp = new G4UIparameter("fileName", 's', true);
|
||||
pp->SetDefaultValue("**Screen**");
|
||||
cerrFileNameCmd->SetParameter(pp);
|
||||
pp= new G4UIparameter("append",'b',true);
|
||||
pp = new G4UIparameter("append", 'b', true);
|
||||
pp->SetDefaultValue(true);
|
||||
cerrFileNameCmd->SetParameter(pp);
|
||||
|
||||
bufferCoutCmd = new G4UIcmdWithABool("/control/cout/useBuffer",this);
|
||||
bufferCoutCmd = new G4UIcmdWithABool("/control/cout/useBuffer", this);
|
||||
bufferCoutCmd->SetGuidance("Send cout and/or cerr stream to a buffer.");
|
||||
bufferCoutCmd->SetGuidance("The buffered text will be printed at the end of the job");
|
||||
bufferCoutCmd->SetGuidance("for each thread at a time, so that output of each thread is grouped.");
|
||||
bufferCoutCmd->SetGuidance("This command has no effect if output goes to a file.");
|
||||
bufferCoutCmd->SetParameterName("flag",true);
|
||||
bufferCoutCmd->SetGuidance(
|
||||
"The buffered text will be printed at the end of the job");
|
||||
bufferCoutCmd->SetGuidance(
|
||||
"for each thread at a time, so that output of each thread is grouped.");
|
||||
bufferCoutCmd->SetGuidance(
|
||||
"This command has no effect if output goes to a file.");
|
||||
bufferCoutCmd->SetParameterName("flag", true);
|
||||
bufferCoutCmd->SetDefaultValue(true);
|
||||
bufferCoutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
bufferCoutCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
|
||||
prefixCmd = new G4UIcmdWithAString("/control/cout/prefixString",this);
|
||||
prefixCmd->SetGuidance("Set the prefix string for each cout/cerr line from a thread.");
|
||||
prefixCmd->SetParameterName("prefix",true);
|
||||
prefixCmd = new G4UIcmdWithAString("/control/cout/prefixString", this);
|
||||
prefixCmd->SetGuidance(
|
||||
"Set the prefix string for each cout/cerr line from a thread.");
|
||||
prefixCmd->SetParameterName("prefix", true);
|
||||
prefixCmd->SetDefaultValue("G4WT");
|
||||
prefixCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
prefixCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
|
||||
ignoreCmd = new G4UIcmdWithAnInteger("/control/cout/ignoreThreadsExcept",this);
|
||||
ignoreCmd =
|
||||
new G4UIcmdWithAnInteger("/control/cout/ignoreThreadsExcept", this);
|
||||
ignoreCmd->SetGuidance("Omit cout from threads except the specified one.");
|
||||
ignoreCmd->SetGuidance("This command takes effect only if cout destination is screen without buffering.");
|
||||
ignoreCmd->SetGuidance("If specified thread ID is greater than the number of threads,");
|
||||
ignoreCmd->SetGuidance("no cout is displayed from worker threads. -1 to reset.");
|
||||
ignoreCmd->SetGuidance("This command takes effect only if cout destination "
|
||||
"is screen without buffering.");
|
||||
ignoreCmd->SetGuidance(
|
||||
"If specified thread ID is greater than the number of threads,");
|
||||
ignoreCmd->SetGuidance(
|
||||
"no cout is displayed from worker threads. -1 to reset.");
|
||||
ignoreCmd->SetGuidance("This command does not affect to cerr.");
|
||||
ignoreCmd->SetParameterName("threadID",true);
|
||||
ignoreCmd->SetParameterName("threadID", true);
|
||||
ignoreCmd->SetDefaultValue(0);
|
||||
ignoreCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
ignoreCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
|
||||
ignoreInitCmd = new G4UIcmdWithABool("/control/cout/ignoreInitializationCout",this);
|
||||
ignoreInitCmd->SetGuidance("Omit cout from threads during initialization, as they should be identical to the master thread.");
|
||||
ignoreInitCmd->SetGuidance("This command takes effect only if cout destination is screen without buffering.");
|
||||
ignoreInitCmd =
|
||||
new G4UIcmdWithABool("/control/cout/ignoreInitializationCout", this);
|
||||
ignoreInitCmd->SetGuidance("Omit cout from threads during initialization, as "
|
||||
"they should be identical to the master thread.");
|
||||
ignoreInitCmd->SetGuidance("This command takes effect only if cout "
|
||||
"destination is screen without buffering.");
|
||||
ignoreInitCmd->SetGuidance("This command does not affect to cerr.");
|
||||
ignoreInitCmd->SetParameterName("IgnoreInit",true);
|
||||
ignoreInitCmd->SetParameterName("IgnoreInit", true);
|
||||
ignoreInitCmd->SetDefaultValue(true);
|
||||
ignoreInitCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
ignoreInitCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4LocalThreadCoutMessenger::~G4LocalThreadCoutMessenger()
|
||||
{
|
||||
delete coutFileNameCmd;
|
||||
@@ -112,30 +135,39 @@ G4LocalThreadCoutMessenger::~G4LocalThreadCoutMessenger()
|
||||
delete coutDir;
|
||||
}
|
||||
|
||||
void G4LocalThreadCoutMessenger::SetNewValue(G4UIcommand* command,G4String newVal)
|
||||
{
|
||||
G4UImanager * UI = G4UImanager::GetUIpointer();
|
||||
// --------------------------------------------------------------------
|
||||
void G4LocalThreadCoutMessenger::SetNewValue(G4UIcommand* command,
|
||||
G4String newVal)
|
||||
{
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
if(command == coutFileNameCmd)
|
||||
{
|
||||
G4Tokenizer next(newVal);
|
||||
G4String fn = next();
|
||||
G4bool af = StoB(next());
|
||||
UI->SetCoutFileName(fn,af);
|
||||
G4bool af = StoB(next());
|
||||
UI->SetCoutFileName(fn, af);
|
||||
}
|
||||
else if(command == cerrFileNameCmd)
|
||||
{
|
||||
G4Tokenizer next(newVal);
|
||||
G4String fn = next();
|
||||
G4bool af = StoB(next());
|
||||
UI->SetCerrFileName(fn,af);
|
||||
G4bool af = StoB(next());
|
||||
UI->SetCerrFileName(fn, af);
|
||||
}
|
||||
else if(command == bufferCoutCmd)
|
||||
{ UI->SetThreadUseBuffer(StoB(newVal)); }
|
||||
{
|
||||
UI->SetThreadUseBuffer(StoB(newVal));
|
||||
}
|
||||
else if(command == prefixCmd)
|
||||
{ UI->SetThreadPrefixString(newVal); }
|
||||
{
|
||||
UI->SetThreadPrefixString(newVal);
|
||||
}
|
||||
else if(command == ignoreCmd)
|
||||
{ UI->SetThreadIgnore(StoI(newVal)); }
|
||||
{
|
||||
UI->SetThreadIgnore(StoI(newVal));
|
||||
}
|
||||
else if(command == ignoreInitCmd)
|
||||
{ UI->SetThreadIgnoreInit(StoB(newVal)); }
|
||||
{
|
||||
UI->SetThreadIgnoreInit(StoB(newVal));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
#include "G4ProfilerMessenger.hh"
|
||||
|
||||
#include "G4Profiler.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithABool.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4TiMemory.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
using Type = G4ProfileType;
|
||||
|
||||
G4ProfilerMessenger::G4ProfilerMessenger()
|
||||
{
|
||||
profileDirectory = new G4UIdirectory("/profiler/");
|
||||
profileDirectory->SetGuidance("Profiler controls.");
|
||||
|
||||
profileOutputDirectory = new G4UIdirectory("/profiler/output/");
|
||||
profileOutputDirectory->SetGuidance(
|
||||
"Control the output modes of the profiler.");
|
||||
|
||||
#define CREATE_DIR(IDX, DIR, GUIDANCE) \
|
||||
profileTypeDirs.at(IDX) = new G4UIdirectory(DIR); \
|
||||
profileTypeDirs.at(IDX)->SetGuidance(GUIDANCE)
|
||||
|
||||
CREATE_DIR(Type::Run, "/profiler/run/",
|
||||
"Profiler controls at the G4Run level");
|
||||
CREATE_DIR(Type::Event, "/profiler/event/",
|
||||
"Profiler controls at the G4Event level");
|
||||
CREATE_DIR(Type::Track, "/profiler/track/",
|
||||
"Profiler controls at the G4Track level");
|
||||
CREATE_DIR(Type::Step, "/profiler/step/",
|
||||
"Profiler controls at the G4Step level");
|
||||
CREATE_DIR(Type::User, "/profiler/user/",
|
||||
"Profiler controls within user code");
|
||||
|
||||
#define SET_ENABLED_CMD(IDX, CMD, CMDLINE, DEFAULT, GUIDANCE) \
|
||||
profileEnableCmds.at(IDX).second = CMDLINE; \
|
||||
profileEnableCmds.at(IDX).first = new G4UIcmdWithABool(CMD, this); \
|
||||
profileEnableCmds.at(IDX).first->SetDefaultValue(DEFAULT); \
|
||||
profileEnableCmds.at(IDX).first->SetGuidance(GUIDANCE); \
|
||||
profileEnableCmds.at(IDX).first->AvailableForStates(G4State_PreInit, \
|
||||
G4State_Idle)
|
||||
|
||||
SET_ENABLED_CMD(Type::Run, "/profiler/run/enable", "run", true,
|
||||
"Record metrics for each G4Run");
|
||||
SET_ENABLED_CMD(Type::Event, "/profiler/event/enable", "event", true,
|
||||
"Record metrics for each G4Event");
|
||||
SET_ENABLED_CMD(Type::Track, "/profiler/track/enable", "track", false,
|
||||
"Record metrics for each G4Track");
|
||||
SET_ENABLED_CMD(Type::Step, "/profiler/step/enable", "step", false,
|
||||
"Record metrics for each G4Step");
|
||||
SET_ENABLED_CMD(Type::User, "/profiler/user/enable", "user", true,
|
||||
"Record metrics for user specified profiling instances");
|
||||
|
||||
#define SET_COMPONENTS_CMD(IDX, CMD, CMDLINE, DEFAULTS, GUIDANCE) \
|
||||
profileCompCmds.at(IDX).second = CMDLINE; \
|
||||
profileCompCmds.at(IDX).first = new G4UIcmdWithAString(CMD, this); \
|
||||
profileCompCmds.at(IDX).first->SetDefaultValue(DEFAULTS); \
|
||||
profileCompCmds.at(IDX).first->SetGuidance(GUIDANCE); \
|
||||
profileCompCmds.at(IDX).first->AvailableForStates(G4State_PreInit, \
|
||||
G4State_Idle)
|
||||
|
||||
G4String comps = "wall_clock, cpu_clock, cpu_util, peak_rss";
|
||||
|
||||
SET_COMPONENTS_CMD(
|
||||
Type::Run, "/profiler/run/components", "--run-components", comps,
|
||||
"Measurment types to record for each G4Run (see `timemory-avail -s`)");
|
||||
SET_COMPONENTS_CMD(
|
||||
Type::Event, "/profiler/event/components", "--event-components", comps,
|
||||
"Measurment types to record for each G4Event (see `timemory-avail -s`)");
|
||||
SET_COMPONENTS_CMD(
|
||||
Type::Track, "/profiler/track/components", "--track-components", comps,
|
||||
"Measurment types to record for each G4Track (see `timemory-avail -s`)");
|
||||
SET_COMPONENTS_CMD(
|
||||
Type::Step, "/profiler/step/components", "--step-components", comps,
|
||||
"Measurment types to record for each G4Step (see `timemory-avail -s`)");
|
||||
SET_COMPONENTS_CMD(Type::User, "/profiler/user/components",
|
||||
"--user-components", comps,
|
||||
"Measurment types to record for user specified profiling "
|
||||
"instances (see `timemory-avail -s`)");
|
||||
|
||||
#define SET_OUTPUT_CMD(CMD, CMDLINE, DEFAULT, GUIDANCE) \
|
||||
profileGeneralCmds.push_back({ new G4UIcmdWithABool(CMD, this), CMDLINE }); \
|
||||
profileGeneralCmds.back().first->SetDefaultValue(DEFAULT); \
|
||||
profileGeneralCmds.back().first->SetGuidance(GUIDANCE); \
|
||||
profileGeneralCmds.back().first->AvailableForStates(G4State_PreInit, \
|
||||
G4State_Idle)
|
||||
|
||||
SET_OUTPUT_CMD("/profiler/output/dart", "--dart", false,
|
||||
"Enabled Dart output (CTest/CDash data tracking)");
|
||||
SET_OUTPUT_CMD("/profiler/output/json", "--json", true,
|
||||
"Enabled JSON output");
|
||||
SET_OUTPUT_CMD("/profiler/output/text", "--text", true,
|
||||
"Enabled text output");
|
||||
SET_OUTPUT_CMD("/profiler/output/cout", "--cout", false,
|
||||
"Enabled output to console");
|
||||
SET_OUTPUT_CMD("/profiler/output/plot", "--plot", false,
|
||||
"Enabled plotting JSON output");
|
||||
|
||||
SET_OUTPUT_CMD("/profiler/tree", "--tree", true,
|
||||
"Display the results as a call-stack hierarchy.");
|
||||
SET_OUTPUT_CMD("/profiler/flat", "--flat", false,
|
||||
"Display the results as a flat call-stack");
|
||||
SET_OUTPUT_CMD("/profiler/timeline", "--timeline", false,
|
||||
"Do not merge duplicate entries at the same call-stack "
|
||||
"position. May be combined with tree or flat profiles.");
|
||||
SET_OUTPUT_CMD(
|
||||
"/profiler/per_thread", "--per-thread", false,
|
||||
"Display the results for each individual thread (default: aggregation)");
|
||||
SET_OUTPUT_CMD(
|
||||
"/profiler/per_event", "--per-event", false,
|
||||
"Display the results for each individual G4event (default: aggregation)");
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
G4ProfilerMessenger::~G4ProfilerMessenger()
|
||||
{
|
||||
delete profileDirectory;
|
||||
for(auto& itr : profileTypeDirs)
|
||||
delete itr;
|
||||
for(auto& itr : profileEnableCmds)
|
||||
delete itr.first;
|
||||
for(auto& itr : profileGeneralCmds)
|
||||
delete itr.first;
|
||||
for(auto& itr : profileCompCmds)
|
||||
delete itr.first;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void G4ProfilerMessenger::SetNewValue(G4UIcommand* command, G4String value)
|
||||
{
|
||||
for(size_t i = 0; i < static_cast<size_t>(G4ProfileType::TypeEnd); ++i)
|
||||
{
|
||||
G4UIcmdWithABool* ui = profileEnableCmds.at(i).first;
|
||||
if(command == ui)
|
||||
{
|
||||
G4Profiler::SetEnabled(i, ui->GetNewBoolValue(value));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// pass the commands to the timemory argparser
|
||||
std::vector<std::string> command_line = { "G4ProfilerMessenger" };
|
||||
|
||||
for(auto& itr : profileGeneralCmds)
|
||||
{
|
||||
G4UIcmdWithABool* ui = itr.first;
|
||||
if(command == ui)
|
||||
{
|
||||
command_line.push_back(itr.second);
|
||||
command_line.push_back(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for(auto& itr : profileCompCmds)
|
||||
{
|
||||
G4UIcmdWithAString* ui = itr.first;
|
||||
if(command == ui)
|
||||
{
|
||||
command_line.push_back(itr.second);
|
||||
#if defined(GEANT4_USE_TIMEMORY)
|
||||
for(auto vitr : tim::delimit(value, ", ;"))
|
||||
command_line.push_back(vitr);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(command_line.size() > 1)
|
||||
G4Profiler::Configure(command_line);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
@@ -23,39 +23,46 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4UIaliasList
|
||||
//
|
||||
//
|
||||
// Author: M.Asai, 1 October 2001
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4UIaliasList.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
G4UIaliasList::G4UIaliasList()
|
||||
{ }
|
||||
// --------------------------------------------------------------------
|
||||
G4UIaliasList::G4UIaliasList() {}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4UIaliasList::~G4UIaliasList()
|
||||
{
|
||||
G4int i;
|
||||
G4int n_treeEntry = alias.size();
|
||||
for( i=0; i < n_treeEntry; i++ )
|
||||
{ delete alias[i];
|
||||
delete value[i]; }
|
||||
for(G4int i = 0; i < n_treeEntry; ++i)
|
||||
{
|
||||
delete alias[i];
|
||||
delete value[i];
|
||||
}
|
||||
}
|
||||
|
||||
G4bool G4UIaliasList::operator==(const G4UIaliasList &right) const
|
||||
// --------------------------------------------------------------------
|
||||
G4bool G4UIaliasList::operator==(const G4UIaliasList& right) const
|
||||
{
|
||||
return ( this == &right );
|
||||
return (this == &right);
|
||||
}
|
||||
|
||||
G4bool G4UIaliasList::operator!=(const G4UIaliasList &right) const
|
||||
// --------------------------------------------------------------------
|
||||
G4bool G4UIaliasList::operator!=(const G4UIaliasList& right) const
|
||||
{
|
||||
return ( this != &right );
|
||||
return (this != &right);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIaliasList::AddNewAlias(const char* aliasName, const char* aliasValue)
|
||||
{
|
||||
if(FindAlias(aliasName))
|
||||
{
|
||||
G4cerr << "Alias <" << aliasName << "> already exist. Command ignored."
|
||||
G4cerr << "Alias <" << aliasName << "> already exists. Command ignored."
|
||||
<< G4endl;
|
||||
return;
|
||||
}
|
||||
@@ -65,64 +72,75 @@ void G4UIaliasList::AddNewAlias(const char* aliasName, const char* aliasValue)
|
||||
value.push_back(newValue);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIaliasList::RemoveAlias(const char* aliasName)
|
||||
{
|
||||
G4int i = FindAliasID(aliasName);
|
||||
if(i<0)
|
||||
if(i < 0)
|
||||
{
|
||||
G4cerr << "Alias <" << aliasName << "> does not exist. Command ignored."
|
||||
<< G4endl;
|
||||
return;
|
||||
}
|
||||
alias.erase(alias.begin()+i);
|
||||
value.erase(value.begin()+i);
|
||||
alias.erase(alias.begin() + i);
|
||||
value.erase(value.begin() + i);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIaliasList::ChangeAlias(const char* aliasName, const char* aliasValue)
|
||||
{
|
||||
G4int i = FindAliasID(aliasName);
|
||||
if(i<0)
|
||||
if(i < 0)
|
||||
{
|
||||
AddNewAlias(aliasName,aliasValue);
|
||||
AddNewAlias(aliasName, aliasValue);
|
||||
return;
|
||||
}
|
||||
*(value[i]) = aliasValue;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4String* G4UIaliasList::FindAlias(const char* aliasName)
|
||||
{
|
||||
G4int i = FindAliasID(aliasName);
|
||||
if(i<0)
|
||||
{ return 0; }
|
||||
if(i < 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return value[i];
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4int G4UIaliasList::FindAliasID(const char* aliasName)
|
||||
{
|
||||
G4int i_entry = alias.size();
|
||||
for(G4int i=0;i<i_entry;i++)
|
||||
{ if(*(alias[i])==aliasName) return i; }
|
||||
for(G4int i = 0; i < i_entry; ++i)
|
||||
{
|
||||
if(*(alias[i]) == aliasName)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void G4UIaliasList::List()
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIaliasList::List()
|
||||
{
|
||||
G4int i_entry = alias.size();
|
||||
for(G4int i1=0;i1<i_entry-1;i1++)
|
||||
for(G4int i2=i1+1;i2<i_entry;i2++)
|
||||
{
|
||||
if(*(alias[i1])>*(alias[i2]))
|
||||
for(G4int i1 = 0; i1 < i_entry - 1; ++i1)
|
||||
for(G4int i2 = i1 + 1; i2 < i_entry; ++i2)
|
||||
{
|
||||
G4String* tmp = alias[i1];
|
||||
alias[i1] = alias[i2];
|
||||
alias[i2] = tmp;
|
||||
tmp = value[i1];
|
||||
value[i1] = value[i2];
|
||||
value[i2] = tmp;
|
||||
if(*(alias[i1]) > *(alias[i2]))
|
||||
{
|
||||
G4String* tmp = alias[i1];
|
||||
alias[i1] = alias[i2];
|
||||
alias[i2] = tmp;
|
||||
tmp = value[i1];
|
||||
value[i1] = value[i2];
|
||||
value[i2] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
for(G4int i = 0; i < i_entry; ++i)
|
||||
{
|
||||
G4cout << " " << *(alias[i]) << " : " << *(value[i]) << G4endl;
|
||||
}
|
||||
|
||||
for(G4int i=0;i<i_entry;i++)
|
||||
{ G4cout << " " << *(alias[i]) << " : " << *(value[i]) << G4endl; }
|
||||
}
|
||||
|
||||
|
||||
+116
-104
@@ -23,198 +23,213 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4UIbatch
|
||||
//
|
||||
// ====================================================================
|
||||
// G4UIbatch.cc
|
||||
//
|
||||
// ====================================================================
|
||||
// Author: M.Asai, 2000
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4UIbatch.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// --------------------------------------------------------------------
|
||||
static void Tokenize(const G4String& str, std::vector<G4String>& tokens)
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
{
|
||||
const char* delimiter= " ";
|
||||
const char* delimiter = " ";
|
||||
|
||||
G4String::size_type pos0= str.find_first_not_of(delimiter);
|
||||
G4String::size_type pos = str.find_first_of(delimiter, pos0);
|
||||
G4String::size_type pos0 = str.find_first_not_of(delimiter);
|
||||
G4String::size_type pos = str.find_first_of(delimiter, pos0);
|
||||
|
||||
while (pos != G4String::npos || pos0 != G4String::npos) {
|
||||
if (str[pos0] == '\"') {
|
||||
pos = str.find_first_of("\"", pos0+1);
|
||||
if(pos != G4String::npos) pos++;
|
||||
while(pos != G4String::npos || pos0 != G4String::npos)
|
||||
{
|
||||
if(str[pos0] == '\"')
|
||||
{
|
||||
pos = str.find_first_of("\"", pos0 + 1);
|
||||
if(pos != G4String::npos)
|
||||
pos++;
|
||||
}
|
||||
if (str[pos0] == '\'') {
|
||||
pos = str.find_first_of("\'", pos0+1);
|
||||
if(pos != G4String::npos) pos++;
|
||||
if(str[pos0] == '\'')
|
||||
{
|
||||
pos = str.find_first_of("\'", pos0 + 1);
|
||||
if(pos != G4String::npos)
|
||||
pos++;
|
||||
}
|
||||
|
||||
tokens.push_back(str.substr(pos0, pos-pos0));
|
||||
tokens.push_back(str.substr(pos0, pos - pos0));
|
||||
pos0 = str.find_first_not_of(delimiter, pos);
|
||||
pos = str.find_first_of(delimiter, pos0);
|
||||
pos = str.find_first_of(delimiter, pos0);
|
||||
}
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// --------------------------------------------------------------------
|
||||
G4UIbatch::G4UIbatch(const char* fileName, G4UIsession* prevSession)
|
||||
: G4UIsession(1),
|
||||
previousSession(prevSession), isOpened(false)
|
||||
////////////////////////////////////////////////////////////////////
|
||||
: G4UIsession(1)
|
||||
, previousSession(prevSession)
|
||||
{
|
||||
macroStream.open(fileName, std::ios::in);
|
||||
if(macroStream.fail()) {
|
||||
G4cerr << "ERROR: Can not open a macro file <"
|
||||
<< fileName << ">. Set macro path with \"/control/macroPath\" if needed."
|
||||
if(macroStream.fail())
|
||||
{
|
||||
G4cerr << "ERROR: Can not open a macro file <" << fileName
|
||||
<< ">. Set macro path with \"/control/macroPath\" if needed."
|
||||
<< G4endl;
|
||||
lastRC = fParameterUnreadable;
|
||||
} else {
|
||||
isOpened= true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isOpened = true;
|
||||
}
|
||||
|
||||
G4UImanager::GetUIpointer()-> SetSession(this);
|
||||
G4UImanager::GetUIpointer()->SetSession(this);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////
|
||||
// --------------------------------------------------------------------
|
||||
G4UIbatch::~G4UIbatch()
|
||||
///////////////////////
|
||||
{
|
||||
if(isOpened) macroStream.close();
|
||||
if(isOpened)
|
||||
macroStream.close();
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// --------------------------------------------------------------------
|
||||
G4String G4UIbatch::ReadCommand()
|
||||
/////////////////////////////////
|
||||
{
|
||||
enum { BUFSIZE= 4096 };
|
||||
static G4ThreadLocal char *linebuf = 0 ; if (!linebuf) linebuf = new char [BUFSIZE];
|
||||
enum
|
||||
{
|
||||
BUFSIZE = 4096
|
||||
};
|
||||
static G4ThreadLocal char* linebuf = 0;
|
||||
if(!linebuf)
|
||||
linebuf = new char[BUFSIZE];
|
||||
const char ctrM = 0x0d;
|
||||
|
||||
G4String cmdtotal= "";
|
||||
G4bool qcontinued= false;
|
||||
while(macroStream.good()) {
|
||||
G4String cmdtotal = "";
|
||||
G4bool qcontinued = false;
|
||||
while(macroStream.good())
|
||||
{
|
||||
macroStream.getline(linebuf, BUFSIZE);
|
||||
|
||||
G4String cmdline(linebuf);
|
||||
|
||||
// TAB-> ' ' conversion
|
||||
str_size nb=0;
|
||||
while ((nb= cmdline.find('\t',nb)) != G4String::npos) {
|
||||
str_size nb = 0;
|
||||
while((nb = cmdline.find('\t', nb)) != G4String::npos)
|
||||
{
|
||||
cmdline.replace(nb, 1, " ");
|
||||
}
|
||||
|
||||
// strip
|
||||
cmdline= cmdline.strip(G4String::both);
|
||||
cmdline= cmdline.strip(G4String::trailing, ctrM);
|
||||
cmdline = cmdline.strip(G4String::both);
|
||||
cmdline = cmdline.strip(G4String::trailing, ctrM);
|
||||
|
||||
// skip null line if single line
|
||||
if(!qcontinued && cmdline.size()==0) continue;
|
||||
if(!qcontinued && cmdline.size() == 0)
|
||||
continue;
|
||||
|
||||
// '#' is treated as echoing something
|
||||
if(cmdline[(size_t)0]=='#') return cmdline;
|
||||
if(cmdline[(std::size_t) 0] == '#')
|
||||
return cmdline;
|
||||
|
||||
// tokenize...
|
||||
std::vector<G4String> tokens;
|
||||
Tokenize(cmdline, tokens);
|
||||
qcontinued= false;
|
||||
for (G4int i=0; i< G4int(tokens.size()); i++) {
|
||||
qcontinued = false;
|
||||
for(G4int i = 0; i < G4int(tokens.size()); ++i)
|
||||
{
|
||||
// string after '#" is ignored
|
||||
if(tokens[i][(size_t)0] == '#' ) break;
|
||||
if(tokens[i][(std::size_t) 0] == '#')
|
||||
break;
|
||||
// '\' or '_' is treated as continued line.
|
||||
if(tokens[i] == '\\' || tokens[i] == '_' ) {
|
||||
qcontinued= true;
|
||||
if(tokens[i] == '\\' || tokens[i] == '_')
|
||||
{
|
||||
qcontinued = true;
|
||||
// check nothing after line continuation character
|
||||
if( i != G4int(tokens.size())-1) {
|
||||
G4Exception("G4UIbatch::ReadCommand","UI0003",
|
||||
JustWarning,
|
||||
"unexpected character after line continuation character");
|
||||
if(i != G4int(tokens.size()) - 1)
|
||||
{
|
||||
G4Exception("G4UIbatch::ReadCommand", "UI0003", JustWarning,
|
||||
"unexpected character after line continuation character");
|
||||
}
|
||||
break; // stop parsing
|
||||
break; // stop parsing
|
||||
}
|
||||
cmdtotal+= tokens[i];
|
||||
cmdtotal+= " ";
|
||||
cmdtotal += tokens[i];
|
||||
cmdtotal += " ";
|
||||
}
|
||||
|
||||
if(qcontinued) continue; // read the next line
|
||||
if(qcontinued)
|
||||
continue; // read the next line
|
||||
|
||||
if(cmdtotal.size() != 0) break;
|
||||
if(macroStream.eof()) break;
|
||||
if(cmdtotal.size() != 0)
|
||||
break;
|
||||
if(macroStream.eof())
|
||||
break;
|
||||
}
|
||||
|
||||
// strip again
|
||||
cmdtotal= cmdtotal.strip(G4String::both);
|
||||
cmdtotal = cmdtotal.strip(G4String::both);
|
||||
|
||||
// finally,
|
||||
if(macroStream.eof() && cmdtotal.size()==0) {
|
||||
if(macroStream.eof() && cmdtotal.size() == 0)
|
||||
{
|
||||
return "exit";
|
||||
}
|
||||
|
||||
return cmdtotal;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
// --------------------------------------------------------------------
|
||||
G4int G4UIbatch::ExecCommand(const G4String& command)
|
||||
/////////////////////////////////////////////////////
|
||||
{
|
||||
G4UImanager* UI= G4UImanager::GetUIpointer();
|
||||
G4int rc= UI-> ApplyCommand(command);
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
G4int rc = UI->ApplyCommand(command);
|
||||
|
||||
switch(rc) {
|
||||
case fCommandSucceeded:
|
||||
break;
|
||||
case fCommandNotFound:
|
||||
G4cerr << "***** COMMAND NOT FOUND <"
|
||||
<< command << "> *****" << G4endl;
|
||||
break;
|
||||
case fIllegalApplicationState:
|
||||
G4cerr << "***** Illegal application state <"
|
||||
<< command << "> *****" << G4endl;
|
||||
break;
|
||||
default:
|
||||
G4int pn= rc%100;
|
||||
G4cerr << "***** Illegal parameter (" << pn << ") <"
|
||||
<< command << "> *****" << G4endl;
|
||||
switch(rc)
|
||||
{
|
||||
case fCommandSucceeded:
|
||||
break;
|
||||
case fCommandNotFound:
|
||||
G4cerr << "***** COMMAND NOT FOUND <" << command << "> *****" << G4endl;
|
||||
break;
|
||||
case fIllegalApplicationState:
|
||||
G4cerr << "***** Illegal application state <" << command << "> *****"
|
||||
<< G4endl;
|
||||
break;
|
||||
default:
|
||||
G4int pn = rc % 100;
|
||||
G4cerr << "***** Illegal parameter (" << pn << ") <" << command
|
||||
<< "> *****" << G4endl;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
G4UIsession * G4UIbatch::SessionStart()
|
||||
///////////////////////////////////////
|
||||
// --------------------------------------------------------------------
|
||||
G4UIsession* G4UIbatch::SessionStart()
|
||||
{
|
||||
if(!isOpened) return previousSession;
|
||||
if(!isOpened)
|
||||
return previousSession;
|
||||
|
||||
while(1) {
|
||||
while(1)
|
||||
{
|
||||
G4String newCommand = ReadCommand();
|
||||
|
||||
if(newCommand == "exit") {
|
||||
if(newCommand == "exit")
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// just echo something
|
||||
if( newCommand[(size_t)0] == '#') {
|
||||
if(G4UImanager::GetUIpointer()-> GetVerboseLevel()==2) {
|
||||
if(newCommand[(std::size_t) 0] == '#')
|
||||
{
|
||||
if(G4UImanager::GetUIpointer()->GetVerboseLevel() == 2)
|
||||
{
|
||||
G4cout << newCommand << G4endl;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// execute command
|
||||
G4int rc= ExecCommand(newCommand);
|
||||
if(rc != fCommandSucceeded) {
|
||||
G4int rc = ExecCommand(newCommand);
|
||||
if(rc != fCommandSucceeded)
|
||||
{
|
||||
G4cerr << G4endl << "***** Batch is interrupted!! *****" << G4endl;
|
||||
lastRC = rc;
|
||||
break;
|
||||
@@ -224,10 +239,8 @@ G4UIsession * G4UIbatch::SessionStart()
|
||||
return previousSession;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIbatch::PauseSessionStart(const G4String& Prompt)
|
||||
/////////////////////////////////////////////////////////
|
||||
{
|
||||
G4cout << "Pause session <" << Prompt << "> start." << G4endl;
|
||||
|
||||
@@ -235,4 +248,3 @@ void G4UIbatch::PauseSessionStart(const G4String& Prompt)
|
||||
|
||||
G4cout << "Pause session <" << Prompt << "> Terminate." << G4endl;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,46 +23,52 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4UIbridge
|
||||
//
|
||||
// ====================================================================
|
||||
// G4UIbridge.cc
|
||||
//
|
||||
// ====================================================================
|
||||
// Author: A.Dotti, 2013
|
||||
// --------------------------------------------------------------------
|
||||
#include "G4UIbridge.hh"
|
||||
#include "G4UImanager.hh"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// --------------------------------------------------------------------
|
||||
G4UIbridge::G4UIbridge(G4UImanager* localUI, G4String dir)
|
||||
: localUImanager(localUI)
|
||||
////////////////////////////////////////////////////////////////////
|
||||
: localUImanager(localUI)
|
||||
{
|
||||
// make sure dirName starts and ends with '/'
|
||||
if(dir(0,1)=="/")
|
||||
{ dirName = dir; }
|
||||
if(dir(0, 1) == "/")
|
||||
{
|
||||
dirName = dir;
|
||||
}
|
||||
else
|
||||
{ dirName = "/"+dir; }
|
||||
if(dirName(dirName.length()-1,1)!="/")
|
||||
{ dirName += "/"; }
|
||||
{
|
||||
dirName = "/" + dir;
|
||||
}
|
||||
if(dirName(dirName.length() - 1, 1) != "/")
|
||||
{
|
||||
dirName += "/";
|
||||
}
|
||||
|
||||
// register to the master G4UImanager
|
||||
G4UImanager* masterUI = G4UImanager::GetMasterUIpointer();
|
||||
if(masterUI)
|
||||
{ masterUI->RegisterBridge(this); }
|
||||
{
|
||||
masterUI->RegisterBridge(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
G4Exception("G4UIbridge::G4UIbridge()","UI7001",FatalException,
|
||||
"G4UImanager for the master thread is not yet instantiated. Instantiate G4MTRunManager first.");
|
||||
G4Exception("G4UIbridge::G4UIbridge()", "UI7001", FatalException,
|
||||
"G4UImanager for the master thread is not yet instantiated. "
|
||||
"Instantiate G4MTRunManager first.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////
|
||||
// --------------------------------------------------------------------
|
||||
G4UIbridge::~G4UIbridge()
|
||||
///////////////////////
|
||||
{;}
|
||||
{
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
// --------------------------------------------------------------------
|
||||
G4int G4UIbridge::ApplyCommand(const G4String& aCmd)
|
||||
/////////////////////////////////
|
||||
{ return localUImanager->ApplyCommand(aCmd); }
|
||||
|
||||
{
|
||||
return localUImanager->ApplyCommand(aCmd);
|
||||
}
|
||||
|
||||
@@ -23,54 +23,60 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4UIcmdWith3Vector
|
||||
//
|
||||
//
|
||||
//
|
||||
// Author: M.Asai, 1998
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4UIcmdWith3Vector.hh"
|
||||
|
||||
G4UIcmdWith3Vector::G4UIcmdWith3Vector
|
||||
(const char * theCommandPath,G4UImessenger * theMessenger)
|
||||
:G4UIcommand(theCommandPath,theMessenger)
|
||||
// --------------------------------------------------------------------
|
||||
G4UIcmdWith3Vector::G4UIcmdWith3Vector(const char* theCommandPath,
|
||||
G4UImessenger* theMessenger)
|
||||
: G4UIcommand(theCommandPath, theMessenger)
|
||||
{
|
||||
G4UIparameter * dblParamX = new G4UIparameter('d');
|
||||
G4UIparameter* dblParamX = new G4UIparameter('d');
|
||||
SetParameter(dblParamX);
|
||||
G4UIparameter * dblParamY = new G4UIparameter('d');
|
||||
G4UIparameter* dblParamY = new G4UIparameter('d');
|
||||
SetParameter(dblParamY);
|
||||
G4UIparameter * dblParamZ = new G4UIparameter('d');
|
||||
G4UIparameter* dblParamZ = new G4UIparameter('d');
|
||||
SetParameter(dblParamZ);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4ThreeVector G4UIcmdWith3Vector::GetNew3VectorValue(const char* paramString)
|
||||
{
|
||||
return ConvertTo3Vector(paramString);
|
||||
}
|
||||
|
||||
void G4UIcmdWith3Vector::SetParameterName
|
||||
(const char * theNameX,const char * theNameY,const char * theNameZ,
|
||||
G4bool omittable,G4bool currentAsDefault)
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcmdWith3Vector::SetParameterName(const char* theNameX,
|
||||
const char* theNameY,
|
||||
const char* theNameZ,
|
||||
G4bool omittable,
|
||||
G4bool currentAsDefault)
|
||||
{
|
||||
G4UIparameter * theParamX = GetParameter(0);
|
||||
G4UIparameter* theParamX = GetParameter(0);
|
||||
theParamX->SetParameterName(theNameX);
|
||||
theParamX->SetOmittable(omittable);
|
||||
theParamX->SetCurrentAsDefault(currentAsDefault);
|
||||
G4UIparameter * theParamY = GetParameter(1);
|
||||
G4UIparameter* theParamY = GetParameter(1);
|
||||
theParamY->SetParameterName(theNameY);
|
||||
theParamY->SetOmittable(omittable);
|
||||
theParamY->SetCurrentAsDefault(currentAsDefault);
|
||||
G4UIparameter * theParamZ = GetParameter(2);
|
||||
G4UIparameter* theParamZ = GetParameter(2);
|
||||
theParamZ->SetParameterName(theNameZ);
|
||||
theParamZ->SetOmittable(omittable);
|
||||
theParamZ->SetCurrentAsDefault(currentAsDefault);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcmdWith3Vector::SetDefaultValue(G4ThreeVector vec)
|
||||
{
|
||||
G4UIparameter * theParamX = GetParameter(0);
|
||||
G4UIparameter* theParamX = GetParameter(0);
|
||||
theParamX->SetDefaultValue(vec.x());
|
||||
G4UIparameter * theParamY = GetParameter(1);
|
||||
G4UIparameter* theParamY = GetParameter(1);
|
||||
theParamY->SetDefaultValue(vec.y());
|
||||
G4UIparameter * theParamZ = GetParameter(2);
|
||||
G4UIparameter* theParamZ = GetParameter(2);
|
||||
theParamZ->SetDefaultValue(vec.z());
|
||||
}
|
||||
|
||||
|
||||
@@ -23,9 +23,10 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4UIcmdWith3VectorAndUnit
|
||||
//
|
||||
//
|
||||
//
|
||||
// Author: M.Asai, 1998
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4UIcmdWith3VectorAndUnit.hh"
|
||||
#include "G4Tokenizer.hh"
|
||||
@@ -33,37 +34,43 @@
|
||||
#include "G4UIcommandStatus.hh"
|
||||
#include <sstream>
|
||||
|
||||
G4UIcmdWith3VectorAndUnit::G4UIcmdWith3VectorAndUnit
|
||||
(const char * theCommandPath,G4UImessenger * theMessenger)
|
||||
:G4UIcommand(theCommandPath,theMessenger)
|
||||
// --------------------------------------------------------------------
|
||||
G4UIcmdWith3VectorAndUnit::G4UIcmdWith3VectorAndUnit(
|
||||
const char* theCommandPath, G4UImessenger* theMessenger)
|
||||
: G4UIcommand(theCommandPath, theMessenger)
|
||||
{
|
||||
G4UIparameter * dblParamX = new G4UIparameter('d');
|
||||
G4UIparameter* dblParamX = new G4UIparameter('d');
|
||||
SetParameter(dblParamX);
|
||||
G4UIparameter * dblParamY = new G4UIparameter('d');
|
||||
G4UIparameter* dblParamY = new G4UIparameter('d');
|
||||
SetParameter(dblParamY);
|
||||
G4UIparameter * dblParamZ = new G4UIparameter('d');
|
||||
G4UIparameter* dblParamZ = new G4UIparameter('d');
|
||||
SetParameter(dblParamZ);
|
||||
G4UIparameter * untParam = new G4UIparameter('s');
|
||||
G4UIparameter* untParam = new G4UIparameter('s');
|
||||
SetParameter(untParam);
|
||||
untParam->SetParameterName("Unit");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4int G4UIcmdWith3VectorAndUnit::DoIt(G4String parameterList)
|
||||
{
|
||||
std::vector<G4String> token_vector;
|
||||
G4Tokenizer tkn(parameterList);
|
||||
G4String str;
|
||||
while( (str = tkn()) != "" ) {
|
||||
while((str = tkn()) != "")
|
||||
{
|
||||
token_vector.push_back(str);
|
||||
}
|
||||
|
||||
// convert a value in default unit
|
||||
G4String converted_parameter;
|
||||
G4String default_unit = GetParameter(3)-> GetDefaultValue();
|
||||
if (default_unit != "" && token_vector.size() >= 4) {
|
||||
if(CategoryOf(token_vector[3])!=CategoryOf(default_unit))
|
||||
{ return fParameterOutOfCandidates+3; }
|
||||
G4double value_given = ValueOf(token_vector[3]);
|
||||
G4String default_unit = GetParameter(3)->GetDefaultValue();
|
||||
if(default_unit != "" && token_vector.size() >= 4)
|
||||
{
|
||||
if(CategoryOf(token_vector[3]) != CategoryOf(default_unit))
|
||||
{
|
||||
return fParameterOutOfCandidates + 3;
|
||||
}
|
||||
G4double value_given = ValueOf(token_vector[3]);
|
||||
G4double value_default = ValueOf(default_unit);
|
||||
G4double x = ConvertToDouble(token_vector[0]) * value_given / value_default;
|
||||
G4double y = ConvertToDouble(token_vector[1]) * value_given / value_default;
|
||||
@@ -77,23 +84,30 @@ G4int G4UIcmdWith3VectorAndUnit::DoIt(G4String parameterList)
|
||||
converted_parameter += ConvertToString(z);
|
||||
converted_parameter += " ";
|
||||
converted_parameter += default_unit;
|
||||
for ( size_t i=4 ; i< token_vector.size(); i++) {
|
||||
for(std::size_t i = 4; i < token_vector.size(); ++i)
|
||||
{
|
||||
converted_parameter += " ";
|
||||
converted_parameter += token_vector[i];
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
converted_parameter = parameterList;
|
||||
}
|
||||
|
||||
return G4UIcommand::DoIt(converted_parameter);
|
||||
}
|
||||
|
||||
G4ThreeVector G4UIcmdWith3VectorAndUnit::GetNew3VectorValue(const char* paramString)
|
||||
// --------------------------------------------------------------------
|
||||
G4ThreeVector G4UIcmdWith3VectorAndUnit::GetNew3VectorValue(
|
||||
const char* paramString)
|
||||
{
|
||||
return ConvertToDimensioned3Vector(paramString);
|
||||
}
|
||||
|
||||
G4ThreeVector G4UIcmdWith3VectorAndUnit::GetNew3VectorRawValue(const char* paramString)
|
||||
// --------------------------------------------------------------------
|
||||
G4ThreeVector G4UIcmdWith3VectorAndUnit::GetNew3VectorRawValue(
|
||||
const char* paramString)
|
||||
{
|
||||
G4double vx;
|
||||
G4double vy;
|
||||
@@ -101,9 +115,10 @@ G4ThreeVector G4UIcmdWith3VectorAndUnit::GetNew3VectorRawValue(const char* param
|
||||
char unts[30];
|
||||
std::istringstream is(paramString);
|
||||
is >> vx >> vy >> vz >> unts;
|
||||
return G4ThreeVector(vx,vy,vz);
|
||||
return G4ThreeVector(vx, vy, vz);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4double G4UIcmdWith3VectorAndUnit::GetNewUnitValue(const char* paramString)
|
||||
{
|
||||
G4double vx;
|
||||
@@ -116,76 +131,90 @@ G4double G4UIcmdWith3VectorAndUnit::GetNewUnitValue(const char* paramString)
|
||||
return ValueOf(unt);
|
||||
}
|
||||
|
||||
G4String G4UIcmdWith3VectorAndUnit::ConvertToStringWithBestUnit(G4ThreeVector vec)
|
||||
// --------------------------------------------------------------------
|
||||
G4String G4UIcmdWith3VectorAndUnit::ConvertToStringWithBestUnit(
|
||||
G4ThreeVector vec)
|
||||
{
|
||||
G4UIparameter* unitParam = GetParameter(3);
|
||||
G4String canList = unitParam->GetParameterCandidates();
|
||||
G4String canList = unitParam->GetParameterCandidates();
|
||||
G4Tokenizer candidateTokenizer(canList);
|
||||
G4String aToken = candidateTokenizer();
|
||||
|
||||
std::ostringstream os;
|
||||
os << G4BestUnit(vec,CategoryOf(aToken));
|
||||
os << G4BestUnit(vec, CategoryOf(aToken));
|
||||
G4String st = os.str();
|
||||
|
||||
return st;
|
||||
}
|
||||
|
||||
G4String G4UIcmdWith3VectorAndUnit::ConvertToStringWithDefaultUnit(G4ThreeVector vec)
|
||||
// --------------------------------------------------------------------
|
||||
G4String G4UIcmdWith3VectorAndUnit::ConvertToStringWithDefaultUnit(
|
||||
G4ThreeVector vec)
|
||||
{
|
||||
G4UIparameter* unitParam = GetParameter(3);
|
||||
G4String st;
|
||||
if(unitParam->IsOmittable())
|
||||
{ st = ConvertToString(vec,unitParam->GetDefaultValue()); }
|
||||
{
|
||||
st = ConvertToString(vec, unitParam->GetDefaultValue());
|
||||
}
|
||||
else
|
||||
{ st = ConvertToStringWithBestUnit(vec); }
|
||||
{
|
||||
st = ConvertToStringWithBestUnit(vec);
|
||||
}
|
||||
return st;
|
||||
}
|
||||
|
||||
void G4UIcmdWith3VectorAndUnit::SetParameterName
|
||||
(const char * theNameX,const char * theNameY,const char * theNameZ,
|
||||
G4bool omittable,G4bool currentAsDefault)
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcmdWith3VectorAndUnit::SetParameterName(const char* theNameX,
|
||||
const char* theNameY,
|
||||
const char* theNameZ,
|
||||
G4bool omittable,
|
||||
G4bool currentAsDefault)
|
||||
{
|
||||
G4UIparameter * theParamX = GetParameter(0);
|
||||
G4UIparameter* theParamX = GetParameter(0);
|
||||
theParamX->SetParameterName(theNameX);
|
||||
theParamX->SetOmittable(omittable);
|
||||
theParamX->SetCurrentAsDefault(currentAsDefault);
|
||||
G4UIparameter * theParamY = GetParameter(1);
|
||||
G4UIparameter* theParamY = GetParameter(1);
|
||||
theParamY->SetParameterName(theNameY);
|
||||
theParamY->SetOmittable(omittable);
|
||||
theParamY->SetCurrentAsDefault(currentAsDefault);
|
||||
G4UIparameter * theParamZ = GetParameter(2);
|
||||
G4UIparameter* theParamZ = GetParameter(2);
|
||||
theParamZ->SetParameterName(theNameZ);
|
||||
theParamZ->SetOmittable(omittable);
|
||||
theParamZ->SetCurrentAsDefault(currentAsDefault);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcmdWith3VectorAndUnit::SetDefaultValue(G4ThreeVector vec)
|
||||
{
|
||||
G4UIparameter * theParamX = GetParameter(0);
|
||||
G4UIparameter* theParamX = GetParameter(0);
|
||||
theParamX->SetDefaultValue(vec.x());
|
||||
G4UIparameter * theParamY = GetParameter(1);
|
||||
G4UIparameter* theParamY = GetParameter(1);
|
||||
theParamY->SetDefaultValue(vec.y());
|
||||
G4UIparameter * theParamZ = GetParameter(2);
|
||||
G4UIparameter* theParamZ = GetParameter(2);
|
||||
theParamZ->SetDefaultValue(vec.z());
|
||||
}
|
||||
|
||||
void G4UIcmdWith3VectorAndUnit::SetUnitCategory(const char * unitCategory)
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcmdWith3VectorAndUnit::SetUnitCategory(const char* unitCategory)
|
||||
{
|
||||
SetUnitCandidates(UnitsList(unitCategory));
|
||||
}
|
||||
|
||||
void G4UIcmdWith3VectorAndUnit::SetUnitCandidates(const char * candidateList)
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcmdWith3VectorAndUnit::SetUnitCandidates(const char* candidateList)
|
||||
{
|
||||
G4UIparameter * untParam = GetParameter(3);
|
||||
G4String canList = candidateList;
|
||||
G4UIparameter* untParam = GetParameter(3);
|
||||
G4String canList = candidateList;
|
||||
untParam->SetParameterCandidates(canList);
|
||||
}
|
||||
|
||||
void G4UIcmdWith3VectorAndUnit::SetDefaultUnit(const char * defUnit)
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcmdWith3VectorAndUnit::SetDefaultUnit(const char* defUnit)
|
||||
{
|
||||
G4UIparameter * untParam = GetParameter(3);
|
||||
G4UIparameter* untParam = GetParameter(3);
|
||||
untParam->SetOmittable(true);
|
||||
untParam->SetDefaultValue(defUnit);
|
||||
SetUnitCategory(CategoryOf(defUnit));
|
||||
}
|
||||
|
||||
|
||||
@@ -23,37 +23,41 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4UIcmdWithABool
|
||||
//
|
||||
//
|
||||
//
|
||||
// Author: M.Asai, 1998
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4UIcmdWithABool.hh"
|
||||
|
||||
G4UIcmdWithABool::G4UIcmdWithABool
|
||||
(const char * theCommandPath,G4UImessenger * theMessenger)
|
||||
:G4UIcommand(theCommandPath,theMessenger)
|
||||
// --------------------------------------------------------------------
|
||||
G4UIcmdWithABool::G4UIcmdWithABool(const char* theCommandPath,
|
||||
G4UImessenger* theMessenger)
|
||||
: G4UIcommand(theCommandPath, theMessenger)
|
||||
{
|
||||
G4UIparameter * blParam = new G4UIparameter('b');
|
||||
G4UIparameter* blParam = new G4UIparameter('b');
|
||||
SetParameter(blParam);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4bool G4UIcmdWithABool::GetNewBoolValue(const char* paramString)
|
||||
{
|
||||
return ConvertToBool(paramString);
|
||||
}
|
||||
|
||||
void G4UIcmdWithABool::SetParameterName
|
||||
(const char * theName,G4bool omittable,G4bool currentAsDefault)
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcmdWithABool::SetParameterName(const char* theName, G4bool omittable,
|
||||
G4bool currentAsDefault)
|
||||
{
|
||||
G4UIparameter * theParam = GetParameter(0);
|
||||
G4UIparameter* theParam = GetParameter(0);
|
||||
theParam->SetParameterName(theName);
|
||||
theParam->SetOmittable(omittable);
|
||||
theParam->SetCurrentAsDefault(currentAsDefault);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcmdWithABool::SetDefaultValue(G4bool defVal)
|
||||
{
|
||||
G4UIparameter * theParam = GetParameter(0);
|
||||
G4UIparameter* theParam = GetParameter(0);
|
||||
theParam->SetDefaultValue(defVal);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,37 +23,41 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4UIcmdWithADouble
|
||||
//
|
||||
//
|
||||
//
|
||||
// Author: M.Asai, 1998
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4UIcmdWithADouble.hh"
|
||||
|
||||
G4UIcmdWithADouble::G4UIcmdWithADouble
|
||||
(const char * theCommandPath,G4UImessenger * theMessenger)
|
||||
:G4UIcommand(theCommandPath,theMessenger)
|
||||
// --------------------------------------------------------------------
|
||||
G4UIcmdWithADouble::G4UIcmdWithADouble(const char* theCommandPath,
|
||||
G4UImessenger* theMessenger)
|
||||
: G4UIcommand(theCommandPath, theMessenger)
|
||||
{
|
||||
G4UIparameter * dblParam = new G4UIparameter('d');
|
||||
G4UIparameter* dblParam = new G4UIparameter('d');
|
||||
SetParameter(dblParam);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4double G4UIcmdWithADouble::GetNewDoubleValue(const char* paramString)
|
||||
{
|
||||
return ConvertToDouble(paramString);
|
||||
}
|
||||
|
||||
void G4UIcmdWithADouble::SetParameterName
|
||||
(const char * theName,G4bool omittable,G4bool currentAsDefault)
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcmdWithADouble::SetParameterName(const char* theName, G4bool omittable,
|
||||
G4bool currentAsDefault)
|
||||
{
|
||||
G4UIparameter * theParam = GetParameter(0);
|
||||
G4UIparameter* theParam = GetParameter(0);
|
||||
theParam->SetParameterName(theName);
|
||||
theParam->SetOmittable(omittable);
|
||||
theParam->SetCurrentAsDefault(currentAsDefault);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcmdWithADouble::SetDefaultValue(G4double defVal)
|
||||
{
|
||||
G4UIparameter * theParam = GetParameter(0);
|
||||
G4UIparameter* theParam = GetParameter(0);
|
||||
theParam->SetDefaultValue(defVal);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,9 +23,10 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4UIcmdWithADoubleAndUnit
|
||||
//
|
||||
//
|
||||
//
|
||||
// Author: M.Asai, 1998
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4Tokenizer.hh"
|
||||
@@ -34,57 +35,69 @@
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
G4UIcmdWithADoubleAndUnit::G4UIcmdWithADoubleAndUnit
|
||||
(const char * theCommandPath,G4UImessenger * theMessenger)
|
||||
:G4UIcommand(theCommandPath,theMessenger)
|
||||
// --------------------------------------------------------------------
|
||||
G4UIcmdWithADoubleAndUnit::G4UIcmdWithADoubleAndUnit(
|
||||
const char* theCommandPath, G4UImessenger* theMessenger)
|
||||
: G4UIcommand(theCommandPath, theMessenger)
|
||||
{
|
||||
G4UIparameter * dblParam = new G4UIparameter('d');
|
||||
G4UIparameter* dblParam = new G4UIparameter('d');
|
||||
SetParameter(dblParam);
|
||||
G4UIparameter * untParam = new G4UIparameter('s');
|
||||
G4UIparameter* untParam = new G4UIparameter('s');
|
||||
SetParameter(untParam);
|
||||
untParam->SetParameterName("Unit");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4int G4UIcmdWithADoubleAndUnit::DoIt(G4String parameterList)
|
||||
{
|
||||
std::vector<G4String> token_vector;
|
||||
G4Tokenizer tkn(parameterList);
|
||||
G4String str;
|
||||
while( (str = tkn()) != "" ) {
|
||||
while((str = tkn()) != "")
|
||||
{
|
||||
token_vector.push_back(str);
|
||||
}
|
||||
|
||||
// convert a value in default unit
|
||||
G4String converted_parameter;
|
||||
G4String default_unit = GetParameter(1)-> GetDefaultValue();
|
||||
if (default_unit != "" && token_vector.size() >= 2) {
|
||||
if(CategoryOf(token_vector[1])!=CategoryOf(default_unit))
|
||||
{ return fParameterOutOfCandidates+1; }
|
||||
G4double value_given = ValueOf(token_vector[1]);
|
||||
G4String default_unit = GetParameter(1)->GetDefaultValue();
|
||||
if(default_unit != "" && token_vector.size() >= 2)
|
||||
{
|
||||
if(CategoryOf(token_vector[1]) != CategoryOf(default_unit))
|
||||
{
|
||||
return fParameterOutOfCandidates + 1;
|
||||
}
|
||||
G4double value_given = ValueOf(token_vector[1]);
|
||||
G4double value_default = ValueOf(default_unit);
|
||||
G4double value = ConvertToDouble(token_vector[0])
|
||||
* value_given / value_default;
|
||||
G4double value =
|
||||
ConvertToDouble(token_vector[0]) * value_given / value_default;
|
||||
// reconstruct parameter list
|
||||
converted_parameter += ConvertToString(value);
|
||||
converted_parameter += " ";
|
||||
converted_parameter += default_unit;
|
||||
for ( size_t i=2 ; i< token_vector.size(); i++) {
|
||||
for(std::size_t i = 2; i < token_vector.size(); ++i)
|
||||
{
|
||||
converted_parameter += " ";
|
||||
converted_parameter += token_vector[i];
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
converted_parameter = parameterList;
|
||||
}
|
||||
|
||||
return G4UIcommand::DoIt(converted_parameter);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4double G4UIcmdWithADoubleAndUnit::GetNewDoubleValue(const char* paramString)
|
||||
{
|
||||
return ConvertToDimensionedDouble(paramString);
|
||||
}
|
||||
|
||||
G4double G4UIcmdWithADoubleAndUnit::GetNewDoubleRawValue(const char* paramString)
|
||||
// --------------------------------------------------------------------
|
||||
G4double G4UIcmdWithADoubleAndUnit::GetNewDoubleRawValue(
|
||||
const char* paramString)
|
||||
{
|
||||
G4double vl;
|
||||
char unts[30];
|
||||
@@ -95,6 +108,7 @@ G4double G4UIcmdWithADoubleAndUnit::GetNewDoubleRawValue(const char* paramString
|
||||
return vl;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4double G4UIcmdWithADoubleAndUnit::GetNewUnitValue(const char* paramString)
|
||||
{
|
||||
G4double vl;
|
||||
@@ -107,62 +121,73 @@ G4double G4UIcmdWithADoubleAndUnit::GetNewUnitValue(const char* paramString)
|
||||
return ValueOf(unt);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4String G4UIcmdWithADoubleAndUnit::ConvertToStringWithBestUnit(G4double val)
|
||||
{
|
||||
G4UIparameter* unitParam = GetParameter(1);
|
||||
G4String canList = unitParam->GetParameterCandidates();
|
||||
G4String canList = unitParam->GetParameterCandidates();
|
||||
G4Tokenizer candidateTokenizer(canList);
|
||||
G4String aToken = candidateTokenizer();
|
||||
std::ostringstream os;
|
||||
os << G4BestUnit(val,CategoryOf(aToken));
|
||||
os << G4BestUnit(val, CategoryOf(aToken));
|
||||
|
||||
G4String st = os.str();
|
||||
return st;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4String G4UIcmdWithADoubleAndUnit::ConvertToStringWithDefaultUnit(G4double val)
|
||||
{
|
||||
G4UIparameter* unitParam = GetParameter(1);
|
||||
G4String st;
|
||||
if(unitParam->IsOmittable())
|
||||
{ st = ConvertToString(val,unitParam->GetDefaultValue()); }
|
||||
{
|
||||
st = ConvertToString(val, unitParam->GetDefaultValue());
|
||||
}
|
||||
else
|
||||
{ st = ConvertToStringWithBestUnit(val); }
|
||||
{
|
||||
st = ConvertToStringWithBestUnit(val);
|
||||
}
|
||||
return st;
|
||||
}
|
||||
|
||||
void G4UIcmdWithADoubleAndUnit::SetParameterName
|
||||
(const char * theName,G4bool omittable,G4bool currentAsDefault)
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcmdWithADoubleAndUnit::SetParameterName(const char* theName,
|
||||
G4bool omittable,
|
||||
G4bool currentAsDefault)
|
||||
{
|
||||
G4UIparameter * theParam = GetParameter(0);
|
||||
G4UIparameter* theParam = GetParameter(0);
|
||||
theParam->SetParameterName(theName);
|
||||
theParam->SetOmittable(omittable);
|
||||
theParam->SetCurrentAsDefault(currentAsDefault);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcmdWithADoubleAndUnit::SetDefaultValue(G4double defVal)
|
||||
{
|
||||
G4UIparameter * theParam = GetParameter(0);
|
||||
G4UIparameter* theParam = GetParameter(0);
|
||||
theParam->SetDefaultValue(defVal);
|
||||
}
|
||||
|
||||
void G4UIcmdWithADoubleAndUnit::SetUnitCategory(const char * unitCategory)
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcmdWithADoubleAndUnit::SetUnitCategory(const char* unitCategory)
|
||||
{
|
||||
SetUnitCandidates(UnitsList(unitCategory));
|
||||
}
|
||||
|
||||
void G4UIcmdWithADoubleAndUnit::SetUnitCandidates(const char * candidateList)
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcmdWithADoubleAndUnit::SetUnitCandidates(const char* candidateList)
|
||||
{
|
||||
G4UIparameter * untParam = GetParameter(1);
|
||||
G4String canList = candidateList;
|
||||
G4UIparameter* untParam = GetParameter(1);
|
||||
G4String canList = candidateList;
|
||||
untParam->SetParameterCandidates(canList);
|
||||
}
|
||||
|
||||
void G4UIcmdWithADoubleAndUnit::SetDefaultUnit(const char * defUnit)
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcmdWithADoubleAndUnit::SetDefaultUnit(const char* defUnit)
|
||||
{
|
||||
G4UIparameter * untParam = GetParameter(1);
|
||||
G4UIparameter* untParam = GetParameter(1);
|
||||
untParam->SetOmittable(true);
|
||||
untParam->SetDefaultValue(defUnit);
|
||||
SetUnitCategory(CategoryOf(defUnit));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4UIcmdWithALongInt
|
||||
//
|
||||
// Author: M.Asai, 2020
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4UIcmdWithALongInt.hh"
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4UIcmdWithALongInt::G4UIcmdWithALongInt(const char* theCommandPath,
|
||||
G4UImessenger* theMessenger)
|
||||
: G4UIcommand(theCommandPath, theMessenger)
|
||||
{
|
||||
G4UIparameter* longParam = new G4UIparameter('l');
|
||||
SetParameter(longParam);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4long G4UIcmdWithALongInt::GetNewLongIntValue(const char* paramString)
|
||||
{
|
||||
return ConvertToLongInt(paramString);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcmdWithALongInt::SetParameterName(const char* theName,
|
||||
G4bool omittable,
|
||||
G4bool currentAsDefault)
|
||||
{
|
||||
G4UIparameter* theParam = GetParameter(0);
|
||||
theParam->SetParameterName(theName);
|
||||
theParam->SetOmittable(omittable);
|
||||
theParam->SetCurrentAsDefault(currentAsDefault);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcmdWithALongInt::SetDefaultValue(G4long defVal)
|
||||
{
|
||||
G4UIparameter* theParam = GetParameter(0);
|
||||
theParam->SetDefaultValue(defVal);
|
||||
}
|
||||
@@ -23,39 +23,43 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4UIcmdWithAString
|
||||
//
|
||||
//
|
||||
//
|
||||
// Author: M.Asai, 1998
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
|
||||
G4UIcmdWithAString::G4UIcmdWithAString
|
||||
(const char * theCommandPath,G4UImessenger * theMessenger)
|
||||
:G4UIcommand(theCommandPath,theMessenger)
|
||||
// --------------------------------------------------------------------
|
||||
G4UIcmdWithAString::G4UIcmdWithAString(const char* theCommandPath,
|
||||
G4UImessenger* theMessenger)
|
||||
: G4UIcommand(theCommandPath, theMessenger)
|
||||
{
|
||||
G4UIparameter * strParam = new G4UIparameter('s');
|
||||
G4UIparameter* strParam = new G4UIparameter('s');
|
||||
SetParameter(strParam);
|
||||
}
|
||||
|
||||
void G4UIcmdWithAString::SetParameterName
|
||||
(const char * theName,G4bool omittable,G4bool currentAsDefault)
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcmdWithAString::SetParameterName(const char* theName, G4bool omittable,
|
||||
G4bool currentAsDefault)
|
||||
{
|
||||
G4UIparameter * theParam = GetParameter(0);
|
||||
G4UIparameter* theParam = GetParameter(0);
|
||||
theParam->SetParameterName(theName);
|
||||
theParam->SetOmittable(omittable);
|
||||
theParam->SetCurrentAsDefault(currentAsDefault);
|
||||
}
|
||||
|
||||
void G4UIcmdWithAString::SetCandidates(const char * candidateList)
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcmdWithAString::SetCandidates(const char* candidateList)
|
||||
{
|
||||
G4UIparameter * theParam = GetParameter(0);
|
||||
G4String canList = candidateList;
|
||||
G4UIparameter* theParam = GetParameter(0);
|
||||
G4String canList = candidateList;
|
||||
theParam->SetParameterCandidates(canList);
|
||||
}
|
||||
|
||||
void G4UIcmdWithAString::SetDefaultValue(const char * defVal)
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcmdWithAString::SetDefaultValue(const char* defVal)
|
||||
{
|
||||
G4UIparameter * theParam = GetParameter(0);
|
||||
G4UIparameter* theParam = GetParameter(0);
|
||||
theParam->SetDefaultValue(defVal);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,37 +23,42 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4UIcmdWithAnInteger
|
||||
//
|
||||
//
|
||||
//
|
||||
// Author: M.Asai, 1998
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4UIcmdWithAnInteger.hh"
|
||||
|
||||
G4UIcmdWithAnInteger::G4UIcmdWithAnInteger
|
||||
(const char * theCommandPath,G4UImessenger * theMessenger)
|
||||
:G4UIcommand(theCommandPath,theMessenger)
|
||||
// --------------------------------------------------------------------
|
||||
G4UIcmdWithAnInteger::G4UIcmdWithAnInteger(const char* theCommandPath,
|
||||
G4UImessenger* theMessenger)
|
||||
: G4UIcommand(theCommandPath, theMessenger)
|
||||
{
|
||||
G4UIparameter * intParam = new G4UIparameter('i');
|
||||
G4UIparameter* intParam = new G4UIparameter('i');
|
||||
SetParameter(intParam);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4int G4UIcmdWithAnInteger::GetNewIntValue(const char* paramString)
|
||||
{
|
||||
return ConvertToInt(paramString);
|
||||
}
|
||||
|
||||
void G4UIcmdWithAnInteger::SetParameterName
|
||||
(const char * theName,G4bool omittable,G4bool currentAsDefault)
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcmdWithAnInteger::SetParameterName(const char* theName,
|
||||
G4bool omittable,
|
||||
G4bool currentAsDefault)
|
||||
{
|
||||
G4UIparameter * theParam = GetParameter(0);
|
||||
G4UIparameter* theParam = GetParameter(0);
|
||||
theParam->SetParameterName(theName);
|
||||
theParam->SetOmittable(omittable);
|
||||
theParam->SetCurrentAsDefault(currentAsDefault);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcmdWithAnInteger::SetDefaultValue(G4int defVal)
|
||||
{
|
||||
G4UIparameter * theParam = GetParameter(0);
|
||||
G4UIparameter* theParam = GetParameter(0);
|
||||
theParam->SetDefaultValue(defVal);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,14 +23,16 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4UIcmdWithoutParameter
|
||||
//
|
||||
//
|
||||
//
|
||||
// Author: M.Asai, 1998
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
|
||||
G4UIcmdWithoutParameter::G4UIcmdWithoutParameter
|
||||
(const char * theCommandPath,G4UImessenger * theMessenger)
|
||||
:G4UIcommand(theCommandPath,theMessenger)
|
||||
{;}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4UIcmdWithoutParameter::G4UIcmdWithoutParameter(const char* theCommandPath,
|
||||
G4UImessenger* theMessenger)
|
||||
: G4UIcommand(theCommandPath, theMessenger)
|
||||
{
|
||||
}
|
||||
|
||||
+1210
-788
File diff suppressed because it is too large
Load Diff
@@ -23,117 +23,138 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4UIcommandTree
|
||||
//
|
||||
//
|
||||
// Author: Makoto Asai (SLAC), 1998
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4UIcommandTree.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include <fstream>
|
||||
#include "G4ios.hh"
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4UIcommandTree::G4UIcommandTree()
|
||||
:guidance(NULL),broadcastCommands(true)
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
G4UIcommandTree::G4UIcommandTree(const char * thePathName)
|
||||
:guidance(NULL),broadcastCommands(true)
|
||||
// --------------------------------------------------------------------
|
||||
G4UIcommandTree::G4UIcommandTree(const char* thePathName)
|
||||
{
|
||||
pathName = thePathName;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4UIcommandTree::~G4UIcommandTree()
|
||||
{
|
||||
G4int i;
|
||||
G4int n_treeEntry = tree.size();
|
||||
for( i=0; i < n_treeEntry; i++ )
|
||||
{ delete tree[i]; }
|
||||
for(i = 0; i < n_treeEntry; ++i)
|
||||
{
|
||||
delete tree[i];
|
||||
}
|
||||
}
|
||||
|
||||
G4bool G4UIcommandTree::operator==(const G4UIcommandTree &right) const
|
||||
// --------------------------------------------------------------------
|
||||
G4bool G4UIcommandTree::operator==(const G4UIcommandTree& right) const
|
||||
{
|
||||
return ( pathName == right.GetPathName() );
|
||||
return (pathName == right.GetPathName());
|
||||
}
|
||||
|
||||
G4bool G4UIcommandTree::operator!=(const G4UIcommandTree &right) const
|
||||
// --------------------------------------------------------------------
|
||||
G4bool G4UIcommandTree::operator!=(const G4UIcommandTree& right) const
|
||||
{
|
||||
return ( pathName != right.GetPathName() );
|
||||
return (pathName != right.GetPathName());
|
||||
}
|
||||
|
||||
void G4UIcommandTree::AddNewCommand(G4UIcommand *newCommand, G4bool workerThreadOnly)
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcommandTree::AddNewCommand(G4UIcommand* newCommand,
|
||||
G4bool workerThreadOnly)
|
||||
{
|
||||
G4String commandPath = newCommand->GetCommandPath();
|
||||
G4String commandPath = newCommand->GetCommandPath();
|
||||
G4String remainingPath = commandPath;
|
||||
remainingPath.remove(0,pathName.length());
|
||||
if( remainingPath.isNull() )
|
||||
remainingPath.remove(0, pathName.length());
|
||||
if(remainingPath.isNull())
|
||||
{
|
||||
if(!guidance)
|
||||
{
|
||||
guidance = newCommand;
|
||||
if(!(newCommand->ToBeBroadcasted())) broadcastCommands = false;
|
||||
if(workerThreadOnly) newCommand->SetWorkerThreadOnly();
|
||||
if(!(newCommand->ToBeBroadcasted()))
|
||||
broadcastCommands = false;
|
||||
if(workerThreadOnly)
|
||||
newCommand->SetWorkerThreadOnly();
|
||||
}
|
||||
return;
|
||||
}
|
||||
G4int i = remainingPath.first('/');
|
||||
if( i == G4int(std::string::npos) )
|
||||
if(i == G4int(std::string::npos))
|
||||
{
|
||||
// Find command
|
||||
G4int n_commandEntry = command.size();
|
||||
for( G4int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
|
||||
for(G4int i_thCommand = 0; i_thCommand < n_commandEntry; ++i_thCommand)
|
||||
{
|
||||
if( remainingPath == command[i_thCommand]->GetCommandName() )
|
||||
{ return; }
|
||||
if(remainingPath == command[i_thCommand]->GetCommandName())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(!broadcastCommands) newCommand->SetToBeBroadcasted(false);
|
||||
if(workerThreadOnly) newCommand->SetWorkerThreadOnly();
|
||||
command.push_back( newCommand );
|
||||
if(!broadcastCommands)
|
||||
newCommand->SetToBeBroadcasted(false);
|
||||
if(workerThreadOnly)
|
||||
newCommand->SetWorkerThreadOnly();
|
||||
command.push_back(newCommand);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Find path
|
||||
G4String nextPath = pathName;
|
||||
nextPath.append(remainingPath(0,i+1));
|
||||
nextPath.append(remainingPath(0, i + 1));
|
||||
G4int n_treeEntry = tree.size();
|
||||
for( G4int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
|
||||
for(G4int i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree)
|
||||
{
|
||||
if( nextPath == tree[i_thTree]->GetPathName() )
|
||||
{
|
||||
if(!broadcastCommands) newCommand->SetToBeBroadcasted(false);
|
||||
tree[i_thTree]->AddNewCommand( newCommand, workerThreadOnly );
|
||||
return;
|
||||
if(nextPath == tree[i_thTree]->GetPathName())
|
||||
{
|
||||
if(!broadcastCommands)
|
||||
newCommand->SetToBeBroadcasted(false);
|
||||
tree[i_thTree]->AddNewCommand(newCommand, workerThreadOnly);
|
||||
return;
|
||||
}
|
||||
}
|
||||
G4UIcommandTree * newTree = new G4UIcommandTree( nextPath );
|
||||
tree.push_back( newTree );
|
||||
if(!broadcastCommands) newCommand->SetToBeBroadcasted(false);
|
||||
newTree->AddNewCommand( newCommand, workerThreadOnly );
|
||||
G4UIcommandTree* newTree = new G4UIcommandTree(nextPath);
|
||||
tree.push_back(newTree);
|
||||
if(!broadcastCommands)
|
||||
newCommand->SetToBeBroadcasted(false);
|
||||
newTree->AddNewCommand(newCommand, workerThreadOnly);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void G4UIcommandTree::RemoveCommand(G4UIcommand *aCommand, G4bool workerThreadOnly)
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcommandTree::RemoveCommand(G4UIcommand* aCommand,
|
||||
G4bool workerThreadOnly)
|
||||
{
|
||||
if(workerThreadOnly && !(aCommand->IsWorkerThreadOnly())) return;
|
||||
G4String commandPath = aCommand->GetCommandPath();
|
||||
if(workerThreadOnly && !(aCommand->IsWorkerThreadOnly()))
|
||||
return;
|
||||
G4String commandPath = aCommand->GetCommandPath();
|
||||
G4String remainingPath = commandPath;
|
||||
remainingPath.remove(0,pathName.length());
|
||||
if( remainingPath.isNull() )
|
||||
remainingPath.remove(0, pathName.length());
|
||||
if(remainingPath.isNull())
|
||||
{
|
||||
guidance = NULL;
|
||||
guidance = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
G4int i = remainingPath.first('/');
|
||||
if( i == G4int(std::string::npos) )
|
||||
if(i == G4int(std::string::npos))
|
||||
{
|
||||
// Find command
|
||||
G4int n_commandEntry = command.size();
|
||||
for( G4int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
|
||||
for(G4int i_thCommand = 0; i_thCommand < n_commandEntry; ++i_thCommand)
|
||||
{
|
||||
if( remainingPath == command[i_thCommand]->GetCommandName() )
|
||||
{
|
||||
command.erase(command.begin()+i_thCommand);
|
||||
if(remainingPath == command[i_thCommand]->GetCommandName())
|
||||
{
|
||||
command.erase(command.begin() + i_thCommand);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -142,191 +163,223 @@ void G4UIcommandTree::RemoveCommand(G4UIcommand *aCommand, G4bool workerThreadOn
|
||||
{
|
||||
// Find path
|
||||
G4String nextPath = pathName;
|
||||
nextPath.append(remainingPath(0,i+1));
|
||||
nextPath.append(remainingPath(0, i + 1));
|
||||
G4int n_treeEntry = tree.size();
|
||||
for( G4int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
|
||||
for(G4int i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree)
|
||||
{
|
||||
if( nextPath == tree[i_thTree]->GetPathName() )
|
||||
{
|
||||
tree[i_thTree]->RemoveCommand( aCommand );
|
||||
G4int n_commandRemain = tree[i_thTree]->GetCommandEntry();
|
||||
G4int n_treeRemain = tree[i_thTree]-> GetTreeEntry();
|
||||
if(n_commandRemain == 0 && n_treeRemain == 0)
|
||||
{
|
||||
G4UIcommandTree * emptyTree = tree[i_thTree];
|
||||
tree.erase(tree.begin()+i_thTree);
|
||||
delete emptyTree;
|
||||
}
|
||||
break;
|
||||
if(nextPath == tree[i_thTree]->GetPathName())
|
||||
{
|
||||
tree[i_thTree]->RemoveCommand(aCommand);
|
||||
G4int n_commandRemain = tree[i_thTree]->GetCommandEntry();
|
||||
G4int n_treeRemain = tree[i_thTree]->GetTreeEntry();
|
||||
if(n_commandRemain == 0 && n_treeRemain == 0)
|
||||
{
|
||||
G4UIcommandTree* emptyTree = tree[i_thTree];
|
||||
tree.erase(tree.begin() + i_thTree);
|
||||
delete emptyTree;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// L. Garnier 01.28.08 This function has not a good name. In fact, it try
|
||||
// to match a command name, not a path. It should be rename as FindCommandName
|
||||
|
||||
G4UIcommand * G4UIcommandTree::FindPath(const char* commandPath) const
|
||||
// --------------------------------------------------------------------
|
||||
G4UIcommand* G4UIcommandTree::FindPath(const char* commandPath) const
|
||||
{
|
||||
// This function tries to match a command name
|
||||
|
||||
G4String remainingPath = commandPath;
|
||||
if( remainingPath.index( pathName ) == std::string::npos )
|
||||
{ return NULL; }
|
||||
remainingPath.remove(0,pathName.length());
|
||||
if(remainingPath.index(pathName) == std::string::npos)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
remainingPath.remove(0, pathName.length());
|
||||
G4int i = remainingPath.first('/');
|
||||
if( i == G4int(std::string::npos) )
|
||||
if(i == G4int(std::string::npos))
|
||||
{
|
||||
// Find command
|
||||
G4int n_commandEntry = command.size();
|
||||
for( G4int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
|
||||
for(G4int i_thCommand = 0; i_thCommand < n_commandEntry; ++i_thCommand)
|
||||
{
|
||||
if( remainingPath == command[i_thCommand]->GetCommandName() )
|
||||
{ return command[i_thCommand]; }
|
||||
if(remainingPath == command[i_thCommand]->GetCommandName())
|
||||
{
|
||||
return command[i_thCommand];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Find path
|
||||
G4String nextPath = pathName;
|
||||
nextPath.append(remainingPath(0,i+1));
|
||||
nextPath.append(remainingPath(0, i + 1));
|
||||
G4int n_treeEntry = tree.size();
|
||||
for( G4int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
|
||||
for(G4int i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree)
|
||||
{
|
||||
if( nextPath == tree[i_thTree]->GetPathName() )
|
||||
{ return tree[i_thTree]->FindPath( commandPath ); }
|
||||
if(nextPath == tree[i_thTree]->GetPathName())
|
||||
{
|
||||
return tree[i_thTree]->FindPath(commandPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Try to match a command or a path with the one given.
|
||||
* @commandPath : command or path to match
|
||||
* @return the commandTree found or NULL if not
|
||||
*/
|
||||
// --------------------------------------------------------------------
|
||||
G4UIcommandTree* G4UIcommandTree::FindCommandTree(const char* commandPath)
|
||||
{
|
||||
// Try to match a command or a path with the one given.
|
||||
// @commandPath : command or path to match
|
||||
// @return the commandTree found or nullptr if not
|
||||
|
||||
G4String remainingPath = commandPath;
|
||||
if( remainingPath.index( pathName ) == std::string::npos )
|
||||
{ return NULL; }
|
||||
remainingPath.remove(0,pathName.length());
|
||||
if(remainingPath.index(pathName) == std::string::npos)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
remainingPath.remove(0, pathName.length());
|
||||
G4int i = remainingPath.first('/');
|
||||
if( i != G4int(std::string::npos) )
|
||||
if(i != G4int(std::string::npos))
|
||||
{
|
||||
// Find path
|
||||
G4String nextPath = pathName;
|
||||
nextPath.append(remainingPath(0,i+1));
|
||||
nextPath.append(remainingPath(0, i + 1));
|
||||
G4int n_treeEntry = tree.size();
|
||||
for( G4int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
|
||||
for(G4int i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree)
|
||||
{
|
||||
if (tree[i_thTree]->GetPathName() == commandPath) {
|
||||
if(tree[i_thTree]->GetPathName() == commandPath)
|
||||
{
|
||||
return tree[i_thTree];
|
||||
}
|
||||
else if( nextPath == tree[i_thTree]->GetPathName() ) {
|
||||
return tree[i_thTree]->FindCommandTree( commandPath );
|
||||
else if(nextPath == tree[i_thTree]->GetPathName())
|
||||
{
|
||||
return tree[i_thTree]->FindCommandTree(commandPath);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return this;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4String G4UIcommandTree::CompleteCommandPath(const G4String& aCommandPath)
|
||||
{
|
||||
G4String pName = aCommandPath;
|
||||
G4String pName = aCommandPath;
|
||||
G4String remainingPath = aCommandPath;
|
||||
G4String empty = "";
|
||||
G4String matchingPath = empty;
|
||||
G4String empty = "";
|
||||
G4String matchingPath = empty;
|
||||
|
||||
// find the tree
|
||||
G4int jpre= pName.last('/');
|
||||
if(jpre != G4int(G4String::npos)) pName.remove(jpre+1);
|
||||
G4int jpre = pName.last('/');
|
||||
if(jpre != G4int(G4String::npos))
|
||||
pName.remove(jpre + 1);
|
||||
G4UIcommandTree* aTree = FindCommandTree(pName);
|
||||
|
||||
if (!aTree) {
|
||||
if(!aTree)
|
||||
{
|
||||
return empty;
|
||||
}
|
||||
|
||||
if( pName.index( pName ) == std::string::npos ) return empty;
|
||||
|
||||
if(pName.index(pName) == std::string::npos)
|
||||
return empty;
|
||||
|
||||
std::vector<G4String> paths;
|
||||
|
||||
// list matched directories/commands
|
||||
G4String strtmp;
|
||||
G4int nMatch= 0;
|
||||
G4int nMatch = 0;
|
||||
|
||||
G4int Ndir = aTree->GetTreeEntry();
|
||||
G4int Ncmd = aTree->GetCommandEntry();
|
||||
|
||||
int Ndir= aTree-> GetTreeEntry();
|
||||
int Ncmd= aTree-> GetCommandEntry();
|
||||
|
||||
// directory ...
|
||||
for(G4int idir=1; idir<=Ndir; idir++) {
|
||||
G4String fpdir= aTree-> GetTree(idir)-> GetPathName();
|
||||
for(G4int idir = 1; idir <= Ndir; ++idir)
|
||||
{
|
||||
G4String fpdir = aTree->GetTree(idir)->GetPathName();
|
||||
// matching test
|
||||
if( fpdir.index(remainingPath, 0) == 0) {
|
||||
if(nMatch==0) {
|
||||
if(fpdir.index(remainingPath, 0) == 0)
|
||||
{
|
||||
if(nMatch == 0)
|
||||
{
|
||||
matchingPath = fpdir;
|
||||
} else {
|
||||
matchingPath = GetFirstMatchedString(fpdir,matchingPath);
|
||||
}
|
||||
nMatch++;
|
||||
else
|
||||
{
|
||||
matchingPath = GetFirstMatchedString(fpdir, matchingPath);
|
||||
}
|
||||
++nMatch;
|
||||
paths.push_back(fpdir);
|
||||
}
|
||||
}
|
||||
|
||||
if (paths.size()>=2) {
|
||||
G4cout << "Matching directories :" << G4endl;
|
||||
for( unsigned int i_thCommand = 0; i_thCommand < paths.size(); i_thCommand++ ) {
|
||||
G4cout << paths[i_thCommand] << G4endl;
|
||||
|
||||
if(paths.size() >= 2)
|
||||
{
|
||||
G4cout << "Matching directories :" << G4endl;
|
||||
for(unsigned int i_thCommand = 0; i_thCommand < paths.size(); ++i_thCommand)
|
||||
{
|
||||
G4cout << paths[i_thCommand] << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// command ...
|
||||
std::vector<G4String> commands;
|
||||
|
||||
for(G4int icmd=1; icmd<=Ncmd; icmd++){
|
||||
G4String fpcmd= aTree-> GetPathName() +
|
||||
aTree-> GetCommand(icmd) -> GetCommandName();
|
||||
for(G4int icmd = 1; icmd <= Ncmd; ++icmd)
|
||||
{
|
||||
G4String fpcmd =
|
||||
aTree->GetPathName() + aTree->GetCommand(icmd)->GetCommandName();
|
||||
// matching test
|
||||
if( fpcmd.index(remainingPath, 0) ==0) {
|
||||
if(nMatch==0) {
|
||||
matchingPath= fpcmd + " ";
|
||||
} else {
|
||||
strtmp= fpcmd + " ";
|
||||
matchingPath= GetFirstMatchedString(matchingPath, strtmp);
|
||||
if(fpcmd.index(remainingPath, 0) == 0)
|
||||
{
|
||||
if(nMatch == 0)
|
||||
{
|
||||
matchingPath = fpcmd + " ";
|
||||
}
|
||||
else
|
||||
{
|
||||
strtmp = fpcmd + " ";
|
||||
matchingPath = GetFirstMatchedString(matchingPath, strtmp);
|
||||
}
|
||||
nMatch++;
|
||||
commands.push_back(fpcmd+" ");
|
||||
commands.push_back(fpcmd + " ");
|
||||
}
|
||||
}
|
||||
|
||||
if (commands.size()>=2) {
|
||||
G4cout << "Matching commands :" << G4endl;
|
||||
for( unsigned int i_thCommand = 0; i_thCommand < commands.size(); i_thCommand++ ) {
|
||||
G4cout << commands[i_thCommand] << G4endl;
|
||||
if(commands.size() >= 2)
|
||||
{
|
||||
G4cout << "Matching commands :" << G4endl;
|
||||
for(unsigned int i_thCommand = 0; i_thCommand < commands.size();
|
||||
++i_thCommand)
|
||||
{
|
||||
G4cout << commands[i_thCommand] << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
return matchingPath;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
G4String G4UIcommandTree::GetFirstMatchedString(const G4String& str1,
|
||||
const G4String& str2) const
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// --------------------------------------------------------------------
|
||||
G4String G4UIcommandTree::GetFirstMatchedString(const G4String& str1,
|
||||
const G4String& str2) const
|
||||
{
|
||||
int nlen1= str1.length();
|
||||
int nlen2= str2.length();
|
||||
G4int nlen1 = str1.length();
|
||||
G4int nlen2 = str2.length();
|
||||
|
||||
int nmin = nlen1<nlen2 ? nlen1 : nlen2;
|
||||
G4int nmin = nlen1 < nlen2 ? nlen1 : nlen2;
|
||||
|
||||
G4String strMatched;
|
||||
for(size_t i=0; G4int(i)<nmin; i++){
|
||||
if(str1[i]==str2[i]) {
|
||||
strMatched+= str1[i];
|
||||
} else {
|
||||
for(size_t i = 0; G4int(i) < nmin; ++i)
|
||||
{
|
||||
if(str1[i] == str2[i])
|
||||
{
|
||||
strMatched += str1[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -334,186 +387,250 @@ G4String G4UIcommandTree::GetFirstMatchedString(const G4String& str1,
|
||||
return strMatched;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcommandTree::ListCurrent() const
|
||||
{
|
||||
G4cout << "Command directory path : " << pathName << G4endl;
|
||||
if( guidance != NULL ) guidance->List();
|
||||
if(guidance != nullptr)
|
||||
guidance->List();
|
||||
G4cout << " Sub-directories : " << G4endl;
|
||||
G4int n_treeEntry = tree.size();
|
||||
for( G4int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
|
||||
{
|
||||
for(G4int i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree)
|
||||
{
|
||||
G4cout << " " << tree[i_thTree]->GetPathName();
|
||||
if(tree[i_thTree]->GetGuidance() &&
|
||||
tree[i_thTree]->GetGuidance()->IsWorkerThreadOnly())
|
||||
{ G4cout << " @ "; }
|
||||
{
|
||||
G4cout << " @ ";
|
||||
}
|
||||
else
|
||||
{ G4cout << " "; }
|
||||
{
|
||||
G4cout << " ";
|
||||
}
|
||||
G4cout << tree[i_thTree]->GetTitle() << G4endl;
|
||||
}
|
||||
G4cout << " Commands : " << G4endl;
|
||||
G4int n_commandEntry = command.size();
|
||||
for( G4int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
|
||||
for(G4int i_thCommand = 0; i_thCommand < n_commandEntry; ++i_thCommand)
|
||||
{
|
||||
G4cout << " " << command[i_thCommand]->GetCommandName();
|
||||
if(command[i_thCommand]->IsWorkerThreadOnly())
|
||||
{ G4cout << " @ "; }
|
||||
{
|
||||
G4cout << " @ ";
|
||||
}
|
||||
else
|
||||
{ G4cout << " * "; }
|
||||
{
|
||||
G4cout << " * ";
|
||||
}
|
||||
G4cout << command[i_thCommand]->GetTitle() << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcommandTree::ListCurrentWithNum() const
|
||||
{
|
||||
G4cout << "Command directory path : " << pathName << G4endl;
|
||||
if( guidance != NULL ) guidance->List();
|
||||
if(guidance != nullptr)
|
||||
guidance->List();
|
||||
G4int i = 0;
|
||||
G4cout << " Sub-directories : " << G4endl;
|
||||
G4int n_treeEntry = tree.size();
|
||||
for( G4int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
|
||||
for(G4int i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree)
|
||||
{
|
||||
i++;
|
||||
G4cout << " " << i << ") " << tree[i_thTree]->GetPathName()
|
||||
<< " " << tree[i_thTree]->GetTitle() << G4endl;
|
||||
++i;
|
||||
G4cout << " " << i << ") " << tree[i_thTree]->GetPathName() << " "
|
||||
<< tree[i_thTree]->GetTitle() << G4endl;
|
||||
}
|
||||
G4cout << " Commands : " << G4endl;
|
||||
G4int n_commandEntry = command.size();
|
||||
for( G4int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
|
||||
for(G4int i_thCommand = 0; i_thCommand < n_commandEntry; ++i_thCommand)
|
||||
{
|
||||
i++;
|
||||
G4cout << " " << i << ") " << command[i_thCommand]->GetCommandName()
|
||||
<< " * " << command[i_thCommand]->GetTitle() << G4endl;
|
||||
++i;
|
||||
G4cout << " " << i << ") " << command[i_thCommand]->GetCommandName()
|
||||
<< " * " << command[i_thCommand]->GetTitle() << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcommandTree::List() const
|
||||
{
|
||||
ListCurrent();
|
||||
G4int n_commandEntry = command.size();
|
||||
for( G4int i_thCommand = 0; i_thCommand < n_commandEntry; i_thCommand++ )
|
||||
for(G4int i_thCommand = 0; i_thCommand < n_commandEntry; ++i_thCommand)
|
||||
{
|
||||
command[i_thCommand]->List();
|
||||
}
|
||||
G4int n_treeEntry = tree.size();
|
||||
for( G4int i_thTree = 0; i_thTree < n_treeEntry; i_thTree++ )
|
||||
for(G4int i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree)
|
||||
{
|
||||
tree[i_thTree]->List();
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4String G4UIcommandTree::CreateFileName(const char* pName)
|
||||
{
|
||||
G4String fn = pName;
|
||||
G4int idxs;
|
||||
while((idxs=fn.index("/"))!=G4int(std::string::npos))
|
||||
{ fn(idxs) = '_'; }
|
||||
while((idxs = fn.index("/")) != G4int(std::string::npos))
|
||||
{
|
||||
fn(idxs) = '_';
|
||||
}
|
||||
fn += ".html";
|
||||
return fn;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4String G4UIcommandTree::ModStr(const char* strS)
|
||||
{
|
||||
G4String sx;
|
||||
G4String str = strS;
|
||||
for(G4int i=0;i<G4int(str.length());i++)
|
||||
for(G4int i = 0; i < G4int(str.length()); ++i)
|
||||
{
|
||||
char c = str(i);
|
||||
switch(c)
|
||||
{
|
||||
case '<':
|
||||
sx += "<"; break;
|
||||
case '>':
|
||||
sx += ">"; break;
|
||||
case '&':
|
||||
sx += "&"; break;
|
||||
default:
|
||||
sx += c;
|
||||
case '<':
|
||||
sx += "<";
|
||||
break;
|
||||
case '>':
|
||||
sx += ">";
|
||||
break;
|
||||
case '&':
|
||||
sx += "&";
|
||||
break;
|
||||
default:
|
||||
sx += c;
|
||||
}
|
||||
}
|
||||
return sx;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcommandTree::CreateHTML()
|
||||
{
|
||||
G4String ofileName = CreateFileName(pathName);
|
||||
std::ofstream oF(ofileName, std::ios::out);
|
||||
|
||||
oF << "<html><head><title>Commands in " << ModStr(pathName) << "</title></head>" << G4endl;
|
||||
oF << "<body bgcolor=\"#ffffff\"><h2>" << ModStr(pathName) << "</h2><p>" << G4endl;
|
||||
oF << "<html><head><title>Commands in " << ModStr(pathName)
|
||||
<< "</title></head>" << G4endl;
|
||||
oF << "<body bgcolor=\"#ffffff\"><h2>" << ModStr(pathName) << "</h2><p>"
|
||||
<< G4endl;
|
||||
|
||||
if( guidance != nullptr )
|
||||
if(guidance != nullptr)
|
||||
{
|
||||
for(size_t i=0;i<guidance->GetGuidanceEntries();++i)
|
||||
{ oF << ModStr(guidance->GetGuidanceLine(i)) << "<br>" << G4endl; }
|
||||
for(std::size_t i = 0; i < guidance->GetGuidanceEntries(); ++i)
|
||||
{
|
||||
oF << ModStr(guidance->GetGuidanceLine(i)) << "<br>" << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
oF << "<p><hr><p>" << G4endl;
|
||||
|
||||
|
||||
oF << "<h2>Sub-directories : </h2><dl>" << G4endl;
|
||||
for( size_t i_thTree = 0; i_thTree < tree.size(); ++i_thTree )
|
||||
for(std::size_t i_thTree = 0; i_thTree < tree.size(); ++i_thTree)
|
||||
{
|
||||
oF << "<p><br><p><dt><a href=\"" << CreateFileName(tree[i_thTree]->GetPathName())
|
||||
<< "\">" << ModStr(tree[i_thTree]->GetPathName()) << "</a>" << G4endl;
|
||||
oF << "<p><br><p><dt><a href=\""
|
||||
<< CreateFileName(tree[i_thTree]->GetPathName()) << "\">"
|
||||
<< ModStr(tree[i_thTree]->GetPathName()) << "</a>" << G4endl;
|
||||
oF << "<p><dd>" << ModStr(tree[i_thTree]->GetTitle()) << G4endl;
|
||||
tree[i_thTree]->CreateHTML();
|
||||
}
|
||||
|
||||
oF << "</dl><p><hr><p>" << G4endl;
|
||||
|
||||
|
||||
oF << "<h2>Commands : </h2><dl>" << G4endl;
|
||||
for( size_t i_thCommand = 0; i_thCommand < command.size(); ++i_thCommand )
|
||||
for(std::size_t i_thCommand = 0; i_thCommand < command.size(); ++i_thCommand)
|
||||
{
|
||||
G4UIcommand* cmd = command[i_thCommand];
|
||||
oF << "<p><br><p><dt><b>" << ModStr(cmd->GetCommandName());
|
||||
if(cmd->GetParameterEntries()>0)
|
||||
if(cmd->GetParameterEntries() > 0)
|
||||
{
|
||||
for(size_t i_thParam=0;i_thParam<cmd->GetParameterEntries();++i_thParam)
|
||||
{ oF << " [<i>" << ModStr(cmd->GetParameter(i_thParam)->GetParameterName()) << "</i>]"; }
|
||||
for(std::size_t i_thParam = 0; i_thParam < cmd->GetParameterEntries();
|
||||
++i_thParam)
|
||||
{
|
||||
oF << " [<i>"
|
||||
<< ModStr(cmd->GetParameter(i_thParam)->GetParameterName())
|
||||
<< "</i>]";
|
||||
}
|
||||
}
|
||||
oF << "</b>" << G4endl;
|
||||
oF << "<p><dd>" << G4endl;
|
||||
for(size_t i=0;i<cmd->GetGuidanceEntries();++i)
|
||||
{ oF << ModStr(cmd->GetGuidanceLine(i)) << "<br>" << G4endl; }
|
||||
for(std::size_t i = 0; i < cmd->GetGuidanceEntries(); ++i)
|
||||
{
|
||||
oF << ModStr(cmd->GetGuidanceLine(i)) << "<br>" << G4endl;
|
||||
}
|
||||
if(!(cmd->GetRange()).isNull())
|
||||
{ oF << "<p><dd>Range : " << ModStr(cmd->GetRange()) << G4endl; }
|
||||
{
|
||||
oF << "<p><dd>Range : " << ModStr(cmd->GetRange()) << G4endl;
|
||||
}
|
||||
std::vector<G4ApplicationState>* availabelStateList = cmd->GetStateList();
|
||||
if(availabelStateList->size()==6)
|
||||
{ oF << "<p><dd>Available at all Geant4 states." << G4endl; }
|
||||
if(availabelStateList->size() == 6)
|
||||
{
|
||||
oF << "<p><dd>Available at all Geant4 states." << G4endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
oF << "<p><dd>Available Geant4 state(s) : ";
|
||||
for(size_t ias=0;ias<availabelStateList->size();++ias)
|
||||
{ oF << G4StateManager::GetStateManager()->GetStateString((*availabelStateList)[ias]) << " " << G4endl; }
|
||||
for(std::size_t ias = 0; ias < availabelStateList->size(); ++ias)
|
||||
{
|
||||
oF << G4StateManager::GetStateManager()->GetStateString(
|
||||
(*availabelStateList)[ias])
|
||||
<< " " << G4endl;
|
||||
}
|
||||
}
|
||||
if(cmd->GetParameterEntries()>0)
|
||||
if(cmd->GetParameterEntries() > 0)
|
||||
{
|
||||
oF << "<p><dd>Parameters<table border=1>" << G4endl;
|
||||
for(size_t i_thParam=0;i_thParam<cmd->GetParameterEntries();++i_thParam)
|
||||
for(std::size_t i_thParam = 0; i_thParam < cmd->GetParameterEntries();
|
||||
++i_thParam)
|
||||
{
|
||||
G4UIparameter* prm = cmd->GetParameter(i_thParam);
|
||||
oF << "<tr><td>" << ModStr(prm->GetParameterName()) << G4endl;
|
||||
oF << "<td>type " << prm->GetParameterType() << G4endl;
|
||||
oF << "<td>";
|
||||
if(prm->IsOmittable())
|
||||
{
|
||||
{
|
||||
oF << "Omittable : ";
|
||||
if(prm->GetCurrentAsDefault())
|
||||
{ oF << "current value is used as the default value." << G4endl; }
|
||||
{
|
||||
oF << "current value is used as the default value." << G4endl;
|
||||
}
|
||||
else
|
||||
{ oF << "default value = " << prm->GetDefaultValue() << G4endl; }
|
||||
{
|
||||
oF << "default value = " << prm->GetDefaultValue() << G4endl;
|
||||
}
|
||||
}
|
||||
oF << "<td>";
|
||||
if(!(prm->GetParameterRange()).isNull())
|
||||
{ oF << "Parameter range : " << ModStr(prm->GetParameterRange()) << G4endl; }
|
||||
{
|
||||
oF << "Parameter range : " << ModStr(prm->GetParameterRange())
|
||||
<< G4endl;
|
||||
}
|
||||
else if(!(prm->GetParameterCandidates()).isNull())
|
||||
{ oF << "Parameter candidates : " << ModStr(prm->GetParameterCandidates()) << G4endl; }
|
||||
{
|
||||
oF << "Parameter candidates : "
|
||||
<< ModStr(prm->GetParameterCandidates()) << G4endl;
|
||||
}
|
||||
}
|
||||
oF << "</table>" << G4endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
oF << "</dl></body></html>" << G4endl;
|
||||
oF.close();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4UIcommandTree* G4UIcommandTree::GetTree(const char* comNameC)
|
||||
{
|
||||
G4String comName = comNameC;
|
||||
for(std::size_t i = 0; i < tree.size(); ++i)
|
||||
{
|
||||
if(comName == tree[i]->GetPathName())
|
||||
{
|
||||
return tree[i];
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -23,8 +23,10 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4UIcontrolMessenger
|
||||
//
|
||||
//
|
||||
// Author: Makoto Asai, SLAC - 2001
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "G4UIcontrolMessenger.hh"
|
||||
@@ -43,289 +45,326 @@
|
||||
|
||||
#include "G4ios.hh"
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4UIcontrolMessenger::G4UIcontrolMessenger()
|
||||
{
|
||||
controlDirectory = new G4UIdirectory("/control/");
|
||||
controlDirectory->SetGuidance("UI control commands.");
|
||||
|
||||
macroPathCommand = new G4UIcmdWithAString("/control/macroPath",this);
|
||||
macroPathCommand->SetGuidance("Set macro search path"
|
||||
macroPathCommand = new G4UIcmdWithAString("/control/macroPath", this);
|
||||
macroPathCommand->SetGuidance("Set macro search path"
|
||||
" with colon-separated list.");
|
||||
macroPathCommand->SetParameterName("path",false);
|
||||
macroPathCommand->SetParameterName("path", false);
|
||||
|
||||
ExecuteCommand = new G4UIcmdWithAString("/control/execute",this);
|
||||
ExecuteCommand = new G4UIcmdWithAString("/control/execute", this);
|
||||
ExecuteCommand->SetGuidance("Execute a macro file.");
|
||||
ExecuteCommand->SetParameterName("fileName",false);
|
||||
ExecuteCommand->SetParameterName("fileName", false);
|
||||
ExecuteCommand->SetToBeBroadcasted(false);
|
||||
|
||||
loopCommand = new G4UIcommand("/control/loop",this);
|
||||
loopCommand = new G4UIcommand("/control/loop", this);
|
||||
loopCommand->SetGuidance("Execute a macro file more than once.");
|
||||
loopCommand->SetGuidance("Loop counter can be used as an aliased variable.");
|
||||
G4UIparameter* param1 = new G4UIparameter("macroFile",'s',false);
|
||||
G4UIparameter* param1 = new G4UIparameter("macroFile", 's', false);
|
||||
loopCommand->SetParameter(param1);
|
||||
G4UIparameter* param2 = new G4UIparameter("counterName",'s',false);
|
||||
G4UIparameter* param2 = new G4UIparameter("counterName", 's', false);
|
||||
loopCommand->SetParameter(param2);
|
||||
G4UIparameter* param3 = new G4UIparameter("initialValue",'d',false);
|
||||
G4UIparameter* param3 = new G4UIparameter("initialValue", 'd', false);
|
||||
loopCommand->SetParameter(param3);
|
||||
G4UIparameter* param4 = new G4UIparameter("finalValue",'d',false);
|
||||
G4UIparameter* param4 = new G4UIparameter("finalValue", 'd', false);
|
||||
loopCommand->SetParameter(param4);
|
||||
G4UIparameter* param5 = new G4UIparameter("stepSize",'d',true);
|
||||
G4UIparameter* param5 = new G4UIparameter("stepSize", 'd', true);
|
||||
param5->SetDefaultValue(1.0);
|
||||
loopCommand->SetParameter(param5);
|
||||
loopCommand->SetToBeBroadcasted(false);
|
||||
|
||||
foreachCommand = new G4UIcommand("/control/foreach",this);
|
||||
foreachCommand = new G4UIcommand("/control/foreach", this);
|
||||
foreachCommand->SetGuidance("Execute a macro file more than once.");
|
||||
foreachCommand->SetGuidance("Loop counter can be used as an aliased variable.");
|
||||
foreachCommand->SetGuidance(
|
||||
"Loop counter can be used as an aliased variable.");
|
||||
foreachCommand->SetGuidance("Values must be separated by a space.");
|
||||
G4UIparameter* param6 = new G4UIparameter("macroFile",'s',false);
|
||||
G4UIparameter* param6 = new G4UIparameter("macroFile", 's', false);
|
||||
foreachCommand->SetParameter(param6);
|
||||
G4UIparameter* param7 = new G4UIparameter("counterName",'s',false);
|
||||
G4UIparameter* param7 = new G4UIparameter("counterName", 's', false);
|
||||
foreachCommand->SetParameter(param7);
|
||||
G4UIparameter* param8 = new G4UIparameter("valueList",'s',false);
|
||||
G4UIparameter* param8 = new G4UIparameter("valueList", 's', false);
|
||||
foreachCommand->SetParameter(param8);
|
||||
foreachCommand->SetToBeBroadcasted(false);
|
||||
|
||||
suppressAbortionCommand = new G4UIcmdWithAnInteger("/control/suppressAbortion",this);
|
||||
suppressAbortionCommand->SetGuidance("Suppress the program abortion caused by G4Exception.");
|
||||
suppressAbortionCommand->SetGuidance("Suppression level = 0 : no suppression");
|
||||
suppressAbortionCommand->SetGuidance(" = 1 : suppress during EventProc state");
|
||||
suppressAbortionCommand->SetGuidance(" = 2 : full suppression, i.e. no abortion by G4Exception");
|
||||
suppressAbortionCommand->SetGuidance("When abortion is suppressed, you will get error messages issued by G4Exception,");
|
||||
suppressAbortionCommand->SetGuidance("and there is NO guarantee for the correct result after the G4Exception error message.");
|
||||
suppressAbortionCommand->SetParameterName("level",true);
|
||||
|
||||
suppressAbortionCommand =
|
||||
new G4UIcmdWithAnInteger("/control/suppressAbortion", this);
|
||||
suppressAbortionCommand->SetGuidance(
|
||||
"Suppress the program abortion caused by G4Exception.");
|
||||
suppressAbortionCommand->SetGuidance(
|
||||
"Suppression level = 0 : no suppression");
|
||||
suppressAbortionCommand->SetGuidance(
|
||||
" = 1 : suppress during EventProc state");
|
||||
suppressAbortionCommand->SetGuidance(
|
||||
" = 2 : full suppression, i.e. no abortion by "
|
||||
"G4Exception");
|
||||
suppressAbortionCommand->SetGuidance(
|
||||
"When abortion is suppressed, you will get error messages issued by "
|
||||
"G4Exception,");
|
||||
suppressAbortionCommand->SetGuidance(
|
||||
"and there is NO guarantee for the correct result after the G4Exception "
|
||||
"error message.");
|
||||
suppressAbortionCommand->SetParameterName("level", true);
|
||||
suppressAbortionCommand->SetRange("level >= 0 && level <= 2");
|
||||
suppressAbortionCommand->SetDefaultValue(0);
|
||||
|
||||
verboseCommand = new G4UIcmdWithAnInteger("/control/verbose",this);
|
||||
verboseCommand = new G4UIcmdWithAnInteger("/control/verbose", this);
|
||||
verboseCommand->SetGuidance("Applied command will also be shown on screen.");
|
||||
verboseCommand->SetGuidance("This command is useful with MACRO file.");
|
||||
verboseCommand->SetGuidance(" 0 : silent");
|
||||
verboseCommand->SetGuidance(" 1 : only the valid commands are shown.");
|
||||
verboseCommand->SetGuidance(" 2 : comment lines are also shown (default).");
|
||||
verboseCommand->SetParameterName("switch",true);
|
||||
verboseCommand->SetParameterName("switch", true);
|
||||
verboseCommand->SetRange("switch >= 0 && switch <=2");
|
||||
verboseCommand->SetDefaultValue(2);
|
||||
|
||||
doublePrecCommand = new G4UIcmdWithABool("/control/useDoublePrecision",this);
|
||||
doublePrecCommand->SetGuidance("Use double precision for printing out the current parameter value(s).");
|
||||
doublePrecCommand->SetParameterName("useDoublePrecision",true);
|
||||
|
||||
doublePrecCommand = new G4UIcmdWithABool("/control/useDoublePrecision", this);
|
||||
doublePrecCommand->SetGuidance(
|
||||
"Use double precision for printing out the current parameter value(s).");
|
||||
doublePrecCommand->SetParameterName("useDoublePrecision", true);
|
||||
doublePrecCommand->SetDefaultValue(true);
|
||||
|
||||
historyCommand = new G4UIcmdWithAString("/control/saveHistory",this);
|
||||
historyCommand = new G4UIcmdWithAString("/control/saveHistory", this);
|
||||
historyCommand->SetGuidance("Store command history to a file.");
|
||||
historyCommand->SetGuidance("Defaul file name is G4history.macro.");
|
||||
historyCommand->SetParameterName("fileName",true);
|
||||
historyCommand->SetParameterName("fileName", true);
|
||||
historyCommand->SetDefaultValue("G4History.macro");
|
||||
|
||||
stopStoreHistoryCommand
|
||||
= new G4UIcmdWithoutParameter("/control/stopSavingHistory",this);
|
||||
|
||||
stopStoreHistoryCommand =
|
||||
new G4UIcmdWithoutParameter("/control/stopSavingHistory", this);
|
||||
stopStoreHistoryCommand->SetGuidance("Stop saving history file.");
|
||||
|
||||
aliasCommand = new G4UIcommand("/control/alias",this);
|
||||
aliasCommand = new G4UIcommand("/control/alias", this);
|
||||
aliasCommand->SetGuidance("Set an alias.");
|
||||
aliasCommand->SetGuidance("String can be aliased by this command.");
|
||||
aliasCommand->SetGuidance("The string may contain one or more spaces,");
|
||||
aliasCommand->SetGuidance("the string must be enclosed by double quotes (\").");
|
||||
aliasCommand->SetGuidance(
|
||||
"the string must be enclosed by double quotes (\").");
|
||||
aliasCommand->SetGuidance("To use an alias, enclose the alias name with");
|
||||
aliasCommand->SetGuidance("parenthesis \"{\" and \"}\".");
|
||||
G4UIparameter* aliasNameParam = new G4UIparameter("aliasName",'s',false);
|
||||
G4UIparameter* aliasNameParam = new G4UIparameter("aliasName", 's', false);
|
||||
aliasCommand->SetParameter(aliasNameParam);
|
||||
G4UIparameter* aliasValueParam = new G4UIparameter("aliasValue",'s',false);
|
||||
G4UIparameter* aliasValueParam = new G4UIparameter("aliasValue", 's', false);
|
||||
aliasCommand->SetParameter(aliasValueParam);
|
||||
|
||||
unaliasCommand = new G4UIcmdWithAString("/control/unalias",this);
|
||||
unaliasCommand = new G4UIcmdWithAString("/control/unalias", this);
|
||||
unaliasCommand->SetGuidance("Remove an alias.");
|
||||
unaliasCommand->SetParameterName("aliasName",false);
|
||||
unaliasCommand->SetParameterName("aliasName", false);
|
||||
|
||||
listAliasCommand = new G4UIcmdWithoutParameter("/control/listAlias",this);
|
||||
listAliasCommand = new G4UIcmdWithoutParameter("/control/listAlias", this);
|
||||
listAliasCommand->SetGuidance("List aliases.");
|
||||
|
||||
getEnvCmd = new G4UIcmdWithAString("/control/getEnv",this);
|
||||
getEnvCmd->SetGuidance("Get a shell environment variable and define it as an alias.");
|
||||
getEnvCmd = new G4UIcmdWithAString("/control/getEnv", this);
|
||||
getEnvCmd->SetGuidance(
|
||||
"Get a shell environment variable and define it as an alias.");
|
||||
|
||||
getValCmd = new G4UIcommand("/control/getVal",this);
|
||||
getValCmd->SetGuidance("Get the current value of the UI command and define it as an alias.");
|
||||
getValCmd->SetGuidance("Command is ignored if the UI command does not support GetCurrentValue().");
|
||||
getValCmd = new G4UIcommand("/control/getVal", this);
|
||||
getValCmd->SetGuidance(
|
||||
"Get the current value of the UI command and define it as an alias.");
|
||||
getValCmd->SetGuidance(
|
||||
"Command is ignored if the UI command does not support GetCurrentValue().");
|
||||
getValCmd->SetGuidance(" Syntax : <alias_name> <UI_command> <iIdx>");
|
||||
G4UIparameter* aliName = new G4UIparameter("alias_name",'s',false);
|
||||
G4UIparameter* aliName = new G4UIparameter("alias_name", 's', false);
|
||||
getValCmd->SetParameter(aliName);
|
||||
G4UIparameter* comName = new G4UIparameter("UI_command",'s',false);
|
||||
G4UIparameter* comName = new G4UIparameter("UI_command", 's', false);
|
||||
getValCmd->SetParameter(comName);
|
||||
G4UIparameter* iIdxParam = new G4UIparameter("iIdx",'i',true);
|
||||
G4UIparameter* iIdxParam = new G4UIparameter("iIdx", 'i', true);
|
||||
iIdxParam->SetDefaultValue(0);
|
||||
getValCmd->SetParameter(iIdxParam);
|
||||
|
||||
echoCmd = new G4UIcmdWithAString("/control/echo",this);
|
||||
echoCmd = new G4UIcmdWithAString("/control/echo", this);
|
||||
echoCmd->SetGuidance("Display the aliased value.");
|
||||
|
||||
shellCommand = new G4UIcmdWithAString("/control/shell",this);
|
||||
shellCommand = new G4UIcmdWithAString("/control/shell", this);
|
||||
shellCommand->SetGuidance("Execute a (Unix) SHELL command.");
|
||||
|
||||
ManualCommand = new G4UIcmdWithAString("/control/manual",this);
|
||||
ManualCommand = new G4UIcmdWithAString("/control/manual", this);
|
||||
ManualCommand->SetGuidance("Display all of sub-directories and commands.");
|
||||
ManualCommand->SetGuidance("Directory path should be given by FULL-PATH.");
|
||||
ManualCommand->SetParameterName("dirPath",true);
|
||||
ManualCommand->SetParameterName("dirPath", true);
|
||||
ManualCommand->SetDefaultValue("/");
|
||||
ManualCommand->SetToBeBroadcasted(false);
|
||||
|
||||
HTMLCommand = new G4UIcmdWithAString("/control/createHTML",this);
|
||||
HTMLCommand->SetGuidance("Generate HTML files for all of sub-directories and commands.");
|
||||
HTMLCommand = new G4UIcmdWithAString("/control/createHTML", this);
|
||||
HTMLCommand->SetGuidance(
|
||||
"Generate HTML files for all of sub-directories and commands.");
|
||||
HTMLCommand->SetGuidance("Directory path should be given by FULL-PATH.");
|
||||
HTMLCommand->SetParameterName("dirPath",true);
|
||||
HTMLCommand->SetParameterName("dirPath", true);
|
||||
HTMLCommand->SetDefaultValue("/");
|
||||
HTMLCommand->SetToBeBroadcasted(false);
|
||||
|
||||
maxStoredHistCommand = new G4UIcmdWithAnInteger("/control/maximumStoredHistory",this);
|
||||
maxStoredHistCommand->SetGuidance("Set maximum number of stored UI commands.");
|
||||
maxStoredHistCommand->SetParameterName("max",true);
|
||||
maxStoredHistCommand =
|
||||
new G4UIcmdWithAnInteger("/control/maximumStoredHistory", this);
|
||||
maxStoredHistCommand->SetGuidance(
|
||||
"Set maximum number of stored UI commands.");
|
||||
maxStoredHistCommand->SetParameterName("max", true);
|
||||
maxStoredHistCommand->SetDefaultValue(20);
|
||||
|
||||
ifCommand = new G4UIcommand("/control/if",this);
|
||||
ifCommand = new G4UIcommand("/control/if", this);
|
||||
ifCommand->SetGuidance("Execute a macro file if the expression is true.");
|
||||
ifCommand->SetGuidance(" Syntax : <double> <comp> <double> <macro_file>");
|
||||
G4UIparameter* leftParam = new G4UIparameter("left",'d',false);
|
||||
G4UIparameter* leftParam = new G4UIparameter("left", 'd', false);
|
||||
ifCommand->SetParameter(leftParam);
|
||||
G4UIparameter* compParam = new G4UIparameter("comp",'s',false);
|
||||
G4UIparameter* compParam = new G4UIparameter("comp", 's', false);
|
||||
compParam->SetParameterCandidates("> >= < <= == !=");
|
||||
ifCommand->SetParameter(compParam);
|
||||
G4UIparameter* rightParam = new G4UIparameter("right",'d',false);
|
||||
G4UIparameter* rightParam = new G4UIparameter("right", 'd', false);
|
||||
ifCommand->SetParameter(rightParam);
|
||||
G4UIparameter* macroFileParam = new G4UIparameter("macroFile",'s',false);
|
||||
G4UIparameter* macroFileParam = new G4UIparameter("macroFile", 's', false);
|
||||
ifCommand->SetParameter(macroFileParam);
|
||||
ifCommand->SetToBeBroadcasted(false);
|
||||
|
||||
doifCommand = new G4UIcommand("/control/doif",this);
|
||||
doifCommand = new G4UIcommand("/control/doif", this);
|
||||
doifCommand->SetGuidance("Execute a UI command if the expression is true.");
|
||||
doifCommand->SetGuidance(" Syntax : <double> <comp> <double> <UI_command>");
|
||||
G4UIparameter* doleftParam = new G4UIparameter("left",'d',false);
|
||||
G4UIparameter* doleftParam = new G4UIparameter("left", 'd', false);
|
||||
doifCommand->SetParameter(doleftParam);
|
||||
G4UIparameter* docompParam = new G4UIparameter("comp",'s',false);
|
||||
G4UIparameter* docompParam = new G4UIparameter("comp", 's', false);
|
||||
docompParam->SetParameterCandidates("> >= < <= == !=");
|
||||
doifCommand->SetParameter(docompParam);
|
||||
G4UIparameter* dorightParam = new G4UIparameter("right",'d',false);
|
||||
G4UIparameter* dorightParam = new G4UIparameter("right", 'd', false);
|
||||
doifCommand->SetParameter(dorightParam);
|
||||
G4UIparameter* comParam = new G4UIparameter("UI_command",'s',false);
|
||||
G4UIparameter* comParam = new G4UIparameter("UI_command", 's', false);
|
||||
doifCommand->SetParameter(comParam);
|
||||
doifCommand->SetToBeBroadcasted(false);
|
||||
|
||||
addCommand = new G4UIcommand("/control/add",this);
|
||||
addCommand = new G4UIcommand("/control/add", this);
|
||||
addCommand->SetGuidance("Define a new alias as the sum of two values.");
|
||||
addCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>");
|
||||
addCommand->SetGuidance(" <new_alias> may be an already existing alias. If it is the case,");
|
||||
addCommand->SetGuidance(
|
||||
" <new_alias> may be an already existing alias. If it is the case,");
|
||||
addCommand->SetGuidance(" aliased value is alternated.");
|
||||
G4UIparameter* newAlias1 = new G4UIparameter("new_alias",'s',false);
|
||||
G4UIparameter* newAlias1 = new G4UIparameter("new_alias", 's', false);
|
||||
addCommand->SetParameter(newAlias1);
|
||||
G4UIparameter* val1a = new G4UIparameter("value1",'d',false);
|
||||
G4UIparameter* val1a = new G4UIparameter("value1", 'd', false);
|
||||
addCommand->SetParameter(val1a);
|
||||
G4UIparameter* val1b = new G4UIparameter("value2",'d',false);
|
||||
G4UIparameter* val1b = new G4UIparameter("value2", 'd', false);
|
||||
addCommand->SetParameter(val1b);
|
||||
addCommand->SetToBeBroadcasted(false);
|
||||
|
||||
subtractCommand = new G4UIcommand("/control/subtract",this);
|
||||
subtractCommand->SetGuidance("Define a new alias as the subtraction of two values.");
|
||||
subtractCommand = new G4UIcommand("/control/subtract", this);
|
||||
subtractCommand->SetGuidance(
|
||||
"Define a new alias as the subtraction of two values.");
|
||||
subtractCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>");
|
||||
subtractCommand->SetGuidance(" <new_alias> may be an already existing alias. If it is the case,");
|
||||
subtractCommand->SetGuidance(
|
||||
" <new_alias> may be an already existing alias. If it is the case,");
|
||||
subtractCommand->SetGuidance(" aliased value is alternated.");
|
||||
G4UIparameter* newAlias2 = new G4UIparameter("new_alias",'s',false);
|
||||
G4UIparameter* newAlias2 = new G4UIparameter("new_alias", 's', false);
|
||||
subtractCommand->SetParameter(newAlias2);
|
||||
G4UIparameter* val2a = new G4UIparameter("value1",'d',false);
|
||||
G4UIparameter* val2a = new G4UIparameter("value1", 'd', false);
|
||||
subtractCommand->SetParameter(val2a);
|
||||
G4UIparameter* val2b = new G4UIparameter("value2",'d',false);
|
||||
G4UIparameter* val2b = new G4UIparameter("value2", 'd', false);
|
||||
subtractCommand->SetParameter(val2b);
|
||||
subtractCommand->SetToBeBroadcasted(false);
|
||||
|
||||
multiplyCommand = new G4UIcommand("/control/multiply",this);
|
||||
multiplyCommand->SetGuidance("Define a new alias as the multiplication of two values.");
|
||||
multiplyCommand = new G4UIcommand("/control/multiply", this);
|
||||
multiplyCommand->SetGuidance(
|
||||
"Define a new alias as the multiplication of two values.");
|
||||
multiplyCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>");
|
||||
multiplyCommand->SetGuidance(" <new_alias> may be an already existing alias. If it is the case,");
|
||||
multiplyCommand->SetGuidance(
|
||||
" <new_alias> may be an already existing alias. If it is the case,");
|
||||
multiplyCommand->SetGuidance(" aliased value is alternated.");
|
||||
G4UIparameter* newAlias3 = new G4UIparameter("new_alias",'s',false);
|
||||
G4UIparameter* newAlias3 = new G4UIparameter("new_alias", 's', false);
|
||||
multiplyCommand->SetParameter(newAlias3);
|
||||
G4UIparameter* val3a = new G4UIparameter("value1",'d',false);
|
||||
G4UIparameter* val3a = new G4UIparameter("value1", 'd', false);
|
||||
multiplyCommand->SetParameter(val3a);
|
||||
G4UIparameter* val3b = new G4UIparameter("value2",'d',false);
|
||||
G4UIparameter* val3b = new G4UIparameter("value2", 'd', false);
|
||||
multiplyCommand->SetParameter(val3b);
|
||||
multiplyCommand->SetToBeBroadcasted(false);
|
||||
|
||||
divideCommand = new G4UIcommand("/control/divide",this);
|
||||
divideCommand->SetGuidance("Define a new alias as the division of two values.");
|
||||
divideCommand = new G4UIcommand("/control/divide", this);
|
||||
divideCommand->SetGuidance(
|
||||
"Define a new alias as the division of two values.");
|
||||
divideCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>");
|
||||
divideCommand->SetGuidance(" <new_alias> may be an already existing alias. If it is the case,");
|
||||
divideCommand->SetGuidance(
|
||||
" <new_alias> may be an already existing alias. If it is the case,");
|
||||
divideCommand->SetGuidance(" aliased value is alternated.");
|
||||
G4UIparameter* newAlias4 = new G4UIparameter("new_alias",'s',false);
|
||||
G4UIparameter* newAlias4 = new G4UIparameter("new_alias", 's', false);
|
||||
divideCommand->SetParameter(newAlias4);
|
||||
G4UIparameter* val4a = new G4UIparameter("value1",'d',false);
|
||||
G4UIparameter* val4a = new G4UIparameter("value1", 'd', false);
|
||||
divideCommand->SetParameter(val4a);
|
||||
G4UIparameter* val4b = new G4UIparameter("value2",'d',false);
|
||||
G4UIparameter* val4b = new G4UIparameter("value2", 'd', false);
|
||||
val4b->SetParameterRange("value2 != 0.");
|
||||
divideCommand->SetParameter(val4b);
|
||||
divideCommand->SetToBeBroadcasted(false);
|
||||
|
||||
remainderCommand = new G4UIcommand("/control/remainder",this);
|
||||
remainderCommand->SetGuidance("Define a new alias as the remainder of two values.");
|
||||
remainderCommand = new G4UIcommand("/control/remainder", this);
|
||||
remainderCommand->SetGuidance(
|
||||
"Define a new alias as the remainder of two values.");
|
||||
remainderCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>");
|
||||
remainderCommand->SetGuidance(" <new_alias> may be an already existing alias. If it is the case,");
|
||||
remainderCommand->SetGuidance(
|
||||
" <new_alias> may be an already existing alias. If it is the case,");
|
||||
remainderCommand->SetGuidance(" aliased value is alternated.");
|
||||
G4UIparameter* newAlias5 = new G4UIparameter("new_alias",'s',false);
|
||||
G4UIparameter* newAlias5 = new G4UIparameter("new_alias", 's', false);
|
||||
remainderCommand->SetParameter(newAlias5);
|
||||
G4UIparameter* val5a = new G4UIparameter("value1",'i',false);
|
||||
G4UIparameter* val5a = new G4UIparameter("value1", 'i', false);
|
||||
remainderCommand->SetParameter(val5a);
|
||||
G4UIparameter* val5b = new G4UIparameter("value2",'i',false);
|
||||
G4UIparameter* val5b = new G4UIparameter("value2", 'i', false);
|
||||
val4b->SetParameterRange("value2 != 0");
|
||||
remainderCommand->SetParameter(val5b);
|
||||
remainderCommand->SetToBeBroadcasted(false);
|
||||
|
||||
strifCommand = new G4UIcommand("/control/strif",this);
|
||||
strifCommand = new G4UIcommand("/control/strif", this);
|
||||
strifCommand->SetGuidance("Execute a macro file if the expression is true.");
|
||||
strifCommand->SetGuidance(" Syntax : <string> <comp> <string> <macro_file>");
|
||||
G4UIparameter* strleftParam = new G4UIparameter("left",'s',false);
|
||||
G4UIparameter* strleftParam = new G4UIparameter("left", 's', false);
|
||||
strifCommand->SetParameter(strleftParam);
|
||||
G4UIparameter* strcompParam = new G4UIparameter("comp",'s',false);
|
||||
G4UIparameter* strcompParam = new G4UIparameter("comp", 's', false);
|
||||
strcompParam->SetParameterCandidates("== !=");
|
||||
strifCommand->SetParameter(strcompParam);
|
||||
G4UIparameter* strrightParam = new G4UIparameter("right",'s',false);
|
||||
G4UIparameter* strrightParam = new G4UIparameter("right", 's', false);
|
||||
strifCommand->SetParameter(strrightParam);
|
||||
G4UIparameter* strmacroFileParam = new G4UIparameter("macroFile",'s',false);
|
||||
G4UIparameter* strmacroFileParam = new G4UIparameter("macroFile", 's', false);
|
||||
strifCommand->SetParameter(strmacroFileParam);
|
||||
strifCommand->SetToBeBroadcasted(false);
|
||||
|
||||
strdoifCommand = new G4UIcommand("/control/strdoif",this);
|
||||
strdoifCommand->SetGuidance("Execute a UI command if the expression is true.");
|
||||
strdoifCommand->SetGuidance(" Syntax : <string> <comp> <string> <UI_command>");
|
||||
G4UIparameter* strdoleftParam = new G4UIparameter("left",'s',false);
|
||||
strdoifCommand = new G4UIcommand("/control/strdoif", this);
|
||||
strdoifCommand->SetGuidance(
|
||||
"Execute a UI command if the expression is true.");
|
||||
strdoifCommand->SetGuidance(
|
||||
" Syntax : <string> <comp> <string> <UI_command>");
|
||||
G4UIparameter* strdoleftParam = new G4UIparameter("left", 's', false);
|
||||
strdoifCommand->SetParameter(strdoleftParam);
|
||||
G4UIparameter* strdocompParam = new G4UIparameter("comp",'s',false);
|
||||
G4UIparameter* strdocompParam = new G4UIparameter("comp", 's', false);
|
||||
strdocompParam->SetParameterCandidates("== !=");
|
||||
strdoifCommand->SetParameter(strdocompParam);
|
||||
G4UIparameter* strdorightParam = new G4UIparameter("right",'s',false);
|
||||
G4UIparameter* strdorightParam = new G4UIparameter("right", 's', false);
|
||||
strdoifCommand->SetParameter(strdorightParam);
|
||||
G4UIparameter* strdomacroFileParam = new G4UIparameter("UI_command",'s',false);
|
||||
G4UIparameter* strdomacroFileParam =
|
||||
new G4UIparameter("UI_command", 's', false);
|
||||
strdoifCommand->SetParameter(strdomacroFileParam);
|
||||
strdoifCommand->SetToBeBroadcasted(false);
|
||||
|
||||
ifBatchCommand = new G4UIcmdWithAString("/control/ifBatch",this);
|
||||
ifBatchCommand->SetGuidance("Execute a macro file if program is running in batch mode.");
|
||||
ifBatchCommand->SetParameterName("macroFile",false);
|
||||
ifBatchCommand = new G4UIcmdWithAString("/control/ifBatch", this);
|
||||
ifBatchCommand->SetGuidance(
|
||||
"Execute a macro file if program is running in batch mode.");
|
||||
ifBatchCommand->SetParameterName("macroFile", false);
|
||||
ifBatchCommand->SetToBeBroadcasted(false);
|
||||
|
||||
ifInteractiveCommand = new G4UIcmdWithAString("/control/ifInteractive",this);
|
||||
ifInteractiveCommand->SetGuidance("Execute a macro file if program is running in interactive mode.");
|
||||
ifInteractiveCommand->SetParameterName("macroFile",false);
|
||||
ifInteractiveCommand = new G4UIcmdWithAString("/control/ifInteractive", this);
|
||||
ifInteractiveCommand->SetGuidance(
|
||||
"Execute a macro file if program is running in interactive mode.");
|
||||
ifInteractiveCommand->SetParameterName("macroFile", false);
|
||||
ifInteractiveCommand->SetToBeBroadcasted(false);
|
||||
|
||||
doifBatchCommand = new G4UIcmdWithAString("/control/doifBatch",this);
|
||||
doifBatchCommand->SetGuidance("Execute a UI command if program is running in batch mode.");
|
||||
doifBatchCommand->SetParameterName("UIcommand",false);
|
||||
doifBatchCommand = new G4UIcmdWithAString("/control/doifBatch", this);
|
||||
doifBatchCommand->SetGuidance(
|
||||
"Execute a UI command if program is running in batch mode.");
|
||||
doifBatchCommand->SetParameterName("UIcommand", false);
|
||||
doifBatchCommand->SetToBeBroadcasted(false);
|
||||
|
||||
doifInteractiveCommand = new G4UIcmdWithAString("/control/doifInteractive",this);
|
||||
doifInteractiveCommand->SetGuidance("Execute a UI command if program is running in interactive mode.");
|
||||
doifInteractiveCommand->SetParameterName("UIcommand",false);
|
||||
doifInteractiveCommand =
|
||||
new G4UIcmdWithAString("/control/doifInteractive", this);
|
||||
doifInteractiveCommand->SetGuidance(
|
||||
"Execute a UI command if program is running in interactive mode.");
|
||||
doifInteractiveCommand->SetParameterName("UIcommand", false);
|
||||
doifInteractiveCommand->SetToBeBroadcasted(false);
|
||||
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4UIcontrolMessenger::~G4UIcontrolMessenger()
|
||||
{
|
||||
delete macroPathCommand;
|
||||
@@ -344,7 +383,7 @@ G4UIcontrolMessenger::~G4UIcontrolMessenger()
|
||||
delete echoCmd;
|
||||
delete shellCommand;
|
||||
delete loopCommand;
|
||||
delete foreachCommand;
|
||||
delete foreachCommand;
|
||||
delete HTMLCommand;
|
||||
delete maxStoredHistCommand;
|
||||
delete ifCommand;
|
||||
@@ -360,118 +399,127 @@ G4UIcontrolMessenger::~G4UIcontrolMessenger()
|
||||
delete ifInteractiveCommand;
|
||||
delete doifBatchCommand;
|
||||
delete doifInteractiveCommand;
|
||||
|
||||
delete controlDirectory;
|
||||
}
|
||||
|
||||
void G4UIcontrolMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcontrolMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
{
|
||||
G4UImanager * UI = G4UImanager::GetUIpointer();
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
|
||||
if( command == macroPathCommand) {
|
||||
UI-> SetMacroSearchPath(newValue);
|
||||
UI-> ParseMacroSearchPath();
|
||||
}
|
||||
if(command==ExecuteCommand)
|
||||
if(command == macroPathCommand)
|
||||
{
|
||||
UI->SetMacroSearchPath(newValue);
|
||||
UI->ParseMacroSearchPath();
|
||||
}
|
||||
if(command == ExecuteCommand)
|
||||
{
|
||||
command->ResetFailure();
|
||||
UI-> ExecuteMacroFile(UI-> FindMacroPath(newValue));
|
||||
UI->ExecuteMacroFile(UI->FindMacroPath(newValue));
|
||||
if(UI->GetLastReturnCode() != 0)
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
ed << "Command aborted (" << UI->GetLastReturnCode() << ")";
|
||||
command->CommandFailed(UI->GetLastReturnCode(),ed);
|
||||
command->CommandFailed(UI->GetLastReturnCode(), ed);
|
||||
}
|
||||
}
|
||||
if(command==suppressAbortionCommand)
|
||||
if(command == suppressAbortionCommand)
|
||||
{
|
||||
G4StateManager::GetStateManager()->SetSuppressAbortion(suppressAbortionCommand->GetNewIntValue(newValue));
|
||||
G4StateManager::GetStateManager()->SetSuppressAbortion(
|
||||
suppressAbortionCommand->GetNewIntValue(newValue));
|
||||
}
|
||||
if(command==verboseCommand)
|
||||
if(command == verboseCommand)
|
||||
{
|
||||
UI->SetVerboseLevel(verboseCommand->GetNewIntValue(newValue));
|
||||
}
|
||||
if(command==doublePrecCommand)
|
||||
if(command == doublePrecCommand)
|
||||
{
|
||||
G4UImanager::UseDoublePrecisionStr(doublePrecCommand->GetNewBoolValue(newValue));
|
||||
G4UImanager::UseDoublePrecisionStr(
|
||||
doublePrecCommand->GetNewBoolValue(newValue));
|
||||
}
|
||||
if(command==historyCommand)
|
||||
if(command == historyCommand)
|
||||
{
|
||||
UI->StoreHistory(newValue);
|
||||
UI->StoreHistory(newValue);
|
||||
}
|
||||
if(command==stopStoreHistoryCommand)
|
||||
if(command == stopStoreHistoryCommand)
|
||||
{
|
||||
UI->StoreHistory(false);
|
||||
UI->StoreHistory(false);
|
||||
}
|
||||
if(command==ManualCommand)
|
||||
if(command == ManualCommand)
|
||||
{
|
||||
UI->ListCommands(newValue);
|
||||
}
|
||||
if(command==aliasCommand)
|
||||
if(command == aliasCommand)
|
||||
{
|
||||
UI->SetAlias(newValue);
|
||||
}
|
||||
if(command==unaliasCommand)
|
||||
if(command == unaliasCommand)
|
||||
{
|
||||
UI->RemoveAlias(newValue);
|
||||
}
|
||||
if(command==listAliasCommand)
|
||||
if(command == listAliasCommand)
|
||||
{
|
||||
UI->ListAlias();
|
||||
}
|
||||
if(command==getEnvCmd)
|
||||
if(command == getEnvCmd)
|
||||
{
|
||||
command->ResetFailure();
|
||||
if(std::getenv(newValue))
|
||||
{
|
||||
{
|
||||
G4String st = newValue;
|
||||
st += " ";
|
||||
st += std::getenv(newValue);
|
||||
UI->SetAlias(st.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
ed << "<" << newValue << "> is not defined as a shell variable. Command ignored.";
|
||||
ed << "<" << newValue
|
||||
<< "> is not defined as a shell variable. Command ignored.";
|
||||
command->CommandFailed(ed);
|
||||
}
|
||||
}
|
||||
if(command==getValCmd)
|
||||
if(command == getValCmd)
|
||||
{
|
||||
G4Tokenizer next(newValue);
|
||||
G4String aliName = next();
|
||||
G4String com = next();
|
||||
G4String curVal = UI->GetCurrentValues(com);
|
||||
G4String com = next();
|
||||
G4String curVal = UI->GetCurrentValues(com);
|
||||
if(!(curVal.isNull()))
|
||||
{
|
||||
{
|
||||
G4String theValue = curVal;
|
||||
G4String iIdx = next();
|
||||
G4String iIdx = next();
|
||||
if(!(iIdx.isNull()))
|
||||
{
|
||||
G4int idx = StoI(iIdx);
|
||||
G4Tokenizer nextVal(curVal);
|
||||
for(G4int i = 0;i<=idx;i++)
|
||||
{ theValue = nextVal(); }
|
||||
for(G4int i = 0; i <= idx; i++)
|
||||
{
|
||||
theValue = nextVal();
|
||||
}
|
||||
}
|
||||
G4String st = "/control/alias ";
|
||||
st += aliName + " " + theValue;
|
||||
UI->ApplyCommand(st);
|
||||
}
|
||||
}
|
||||
if(command==echoCmd)
|
||||
{ G4cout << UI->SolveAlias(newValue) << G4endl; }
|
||||
if(command==shellCommand)
|
||||
if(command == echoCmd)
|
||||
{
|
||||
G4cout << UI->SolveAlias(newValue) << G4endl;
|
||||
}
|
||||
if(command == shellCommand)
|
||||
{
|
||||
command->ResetFailure();
|
||||
int rc = system(newValue);
|
||||
if ( rc < 0 )
|
||||
{
|
||||
if(rc < 0)
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
ed << "<" << newValue << "> is not a valid shell command. Command ignored.";
|
||||
ed << "<" << newValue
|
||||
<< "> is not a valid shell command. Command ignored.";
|
||||
command->CommandFailed(ed);
|
||||
}
|
||||
}
|
||||
if(command==loopCommand)
|
||||
if(command == loopCommand)
|
||||
{
|
||||
command->ResetFailure();
|
||||
UI->LoopS(newValue);
|
||||
@@ -479,10 +527,10 @@ void G4UIcontrolMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
ed << "Command aborted (" << UI->GetLastReturnCode() << ")";
|
||||
command->CommandFailed(UI->GetLastReturnCode(),ed);
|
||||
command->CommandFailed(UI->GetLastReturnCode(), ed);
|
||||
}
|
||||
}
|
||||
if(command==foreachCommand)
|
||||
if(command == foreachCommand)
|
||||
{
|
||||
command->ResetFailure();
|
||||
UI->ForeachS(newValue);
|
||||
@@ -490,211 +538,253 @@ void G4UIcontrolMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
ed << "Command aborted (" << UI->GetLastReturnCode() << ")";
|
||||
command->CommandFailed(UI->GetLastReturnCode(),ed);
|
||||
command->CommandFailed(UI->GetLastReturnCode(), ed);
|
||||
}
|
||||
}
|
||||
if(command==HTMLCommand)
|
||||
if(command == HTMLCommand)
|
||||
{
|
||||
UI->CreateHTML(newValue);
|
||||
}
|
||||
if(command==maxStoredHistCommand)
|
||||
if(command == maxStoredHistCommand)
|
||||
{
|
||||
UI->SetMaxHistSize(maxStoredHistCommand->GetNewIntValue(newValue));
|
||||
}
|
||||
if(command==ifCommand)
|
||||
if(command == ifCommand)
|
||||
{
|
||||
G4Tokenizer next(newValue);
|
||||
G4double l = StoD(next());
|
||||
G4double l = StoD(next());
|
||||
G4String comp = next();
|
||||
G4double r = StoD(next());
|
||||
G4String mac = next();
|
||||
G4bool x = false;
|
||||
if(comp==">") x = (l>r);
|
||||
else if(comp==">=") x = (l>=r);
|
||||
else if(comp=="<") x = (l<r);
|
||||
else if(comp=="<=") x = (l<=r);
|
||||
else if(comp=="==") x = (l==r);
|
||||
else if(comp=="!=") x = (l!=r);
|
||||
if(x) UI->ExecuteMacroFile(mac);
|
||||
G4double r = StoD(next());
|
||||
G4String mac = next();
|
||||
G4bool x = false;
|
||||
if(comp == ">")
|
||||
x = (l > r);
|
||||
else if(comp == ">=")
|
||||
x = (l >= r);
|
||||
else if(comp == "<")
|
||||
x = (l < r);
|
||||
else if(comp == "<=")
|
||||
x = (l <= r);
|
||||
else if(comp == "==")
|
||||
x = (l == r);
|
||||
else if(comp == "!=")
|
||||
x = (l != r);
|
||||
if(x)
|
||||
UI->ExecuteMacroFile(mac);
|
||||
}
|
||||
if(command==doifCommand)
|
||||
if(command == doifCommand)
|
||||
{
|
||||
G4Tokenizer next(newValue);
|
||||
G4double l = StoD(next());
|
||||
G4double l = StoD(next());
|
||||
G4String comp = next();
|
||||
G4double r = StoD(next());
|
||||
G4double r = StoD(next());
|
||||
|
||||
G4String c1 = next();
|
||||
G4String ca;
|
||||
while(!((ca=next()).isNull()))
|
||||
while(!((ca = next()).isNull()))
|
||||
{
|
||||
c1 += " ";
|
||||
c1 += ca;
|
||||
}
|
||||
if(c1(0)=='"')
|
||||
if(c1(0) == '"')
|
||||
{
|
||||
G4String strippedValue;
|
||||
if(c1(c1.length()-1)=='"')
|
||||
{ strippedValue = c1(1,c1.length()-2); }
|
||||
if(c1(c1.length() - 1) == '"')
|
||||
{
|
||||
strippedValue = c1(1, c1.length() - 2);
|
||||
}
|
||||
else
|
||||
{ strippedValue = c1(1,c1.length()-1); }
|
||||
{
|
||||
strippedValue = c1(1, c1.length() - 1);
|
||||
}
|
||||
c1 = strippedValue;
|
||||
}
|
||||
|
||||
G4bool x = false;
|
||||
if(comp==">") x = (l>r);
|
||||
else if(comp==">=") x = (l>=r);
|
||||
else if(comp=="<") x = (l<r);
|
||||
else if(comp=="<=") x = (l<=r);
|
||||
else if(comp=="==") x = (l==r);
|
||||
else if(comp=="!=") x = (l!=r);
|
||||
if(x) UI->ApplyCommand(c1);
|
||||
if(comp == ">")
|
||||
x = (l > r);
|
||||
else if(comp == ">=")
|
||||
x = (l >= r);
|
||||
else if(comp == "<")
|
||||
x = (l < r);
|
||||
else if(comp == "<=")
|
||||
x = (l <= r);
|
||||
else if(comp == "==")
|
||||
x = (l == r);
|
||||
else if(comp == "!=")
|
||||
x = (l != r);
|
||||
if(x)
|
||||
UI->ApplyCommand(c1);
|
||||
}
|
||||
if(command==addCommand)
|
||||
if(command == addCommand)
|
||||
{
|
||||
G4Tokenizer next(newValue);
|
||||
G4String newA = next();
|
||||
G4double l = StoD(next());
|
||||
G4double r = StoD(next());
|
||||
G4String st = "/control/alias ";
|
||||
G4double l = StoD(next());
|
||||
G4double r = StoD(next());
|
||||
G4String st = "/control/alias ";
|
||||
st += newA;
|
||||
st += " ";
|
||||
st += DtoS(l+r);
|
||||
st += DtoS(l + r);
|
||||
UI->ApplyCommand(st);
|
||||
}
|
||||
if(command==subtractCommand)
|
||||
if(command == subtractCommand)
|
||||
{
|
||||
G4Tokenizer next(newValue);
|
||||
G4String newA = next();
|
||||
G4double l = StoD(next());
|
||||
G4double r = StoD(next());
|
||||
G4String st = "/control/alias ";
|
||||
G4double l = StoD(next());
|
||||
G4double r = StoD(next());
|
||||
G4String st = "/control/alias ";
|
||||
st += newA;
|
||||
st += " ";
|
||||
st += DtoS(l-r);
|
||||
st += DtoS(l - r);
|
||||
UI->ApplyCommand(st);
|
||||
}
|
||||
if(command==multiplyCommand)
|
||||
if(command == multiplyCommand)
|
||||
{
|
||||
G4Tokenizer next(newValue);
|
||||
G4String newA = next();
|
||||
G4double l = StoD(next());
|
||||
G4double r = StoD(next());
|
||||
G4String st = "/control/alias ";
|
||||
G4double l = StoD(next());
|
||||
G4double r = StoD(next());
|
||||
G4String st = "/control/alias ";
|
||||
st += newA;
|
||||
st += " ";
|
||||
st += DtoS(l*r);
|
||||
st += DtoS(l * r);
|
||||
UI->ApplyCommand(st);
|
||||
}
|
||||
if(command==divideCommand)
|
||||
if(command == divideCommand)
|
||||
{
|
||||
G4Tokenizer next(newValue);
|
||||
G4String newA = next();
|
||||
G4double l = StoD(next());
|
||||
G4double r = StoD(next());
|
||||
G4String st = "/control/alias ";
|
||||
G4double l = StoD(next());
|
||||
G4double r = StoD(next());
|
||||
G4String st = "/control/alias ";
|
||||
st += newA;
|
||||
st += " ";
|
||||
st += DtoS(l/r);
|
||||
st += DtoS(l / r);
|
||||
UI->ApplyCommand(st);
|
||||
}
|
||||
if(command==remainderCommand)
|
||||
if(command == remainderCommand)
|
||||
{
|
||||
G4Tokenizer next(newValue);
|
||||
G4String newA = next();
|
||||
G4int l = StoI(next());
|
||||
G4int r = StoI(next());
|
||||
G4String st = "/control/alias ";
|
||||
G4int l = StoI(next());
|
||||
G4int r = StoI(next());
|
||||
G4String st = "/control/alias ";
|
||||
st += newA;
|
||||
st += " ";
|
||||
st += DtoS(l%r);
|
||||
st += DtoS(l % r);
|
||||
UI->ApplyCommand(st);
|
||||
}
|
||||
if(command==strifCommand)
|
||||
if(command == strifCommand)
|
||||
{
|
||||
G4Tokenizer next(newValue);
|
||||
G4String l = next();
|
||||
G4String l = next();
|
||||
G4String comp = next();
|
||||
G4String r = next();
|
||||
G4String mac = next();
|
||||
G4bool x = false;
|
||||
if(comp=="==") { x = (l==r); }
|
||||
else if(comp=="!=") { x = (l!=r); }
|
||||
if(x) UI->ExecuteMacroFile(mac);
|
||||
G4String r = next();
|
||||
G4String mac = next();
|
||||
G4bool x = false;
|
||||
if(comp == "==")
|
||||
{
|
||||
x = (l == r);
|
||||
}
|
||||
else if(comp == "!=")
|
||||
{
|
||||
x = (l != r);
|
||||
}
|
||||
if(x)
|
||||
UI->ExecuteMacroFile(mac);
|
||||
}
|
||||
if(command==strdoifCommand)
|
||||
if(command == strdoifCommand)
|
||||
{
|
||||
G4Tokenizer next(newValue);
|
||||
G4String l = next();
|
||||
G4String l = next();
|
||||
G4String comp = next();
|
||||
G4String r = next();
|
||||
G4String r = next();
|
||||
|
||||
G4String c1 = next();
|
||||
G4String ca;
|
||||
while(!((ca=next()).isNull()))
|
||||
while(!((ca = next()).isNull()))
|
||||
{
|
||||
c1 += " ";
|
||||
c1 += ca;
|
||||
}
|
||||
if(c1(0)=='"')
|
||||
if(c1(0) == '"')
|
||||
{
|
||||
G4String strippedValue;
|
||||
if(c1(c1.length()-1)=='"')
|
||||
{ strippedValue = c1(1,c1.length()-2); }
|
||||
if(c1(c1.length() - 1) == '"')
|
||||
{
|
||||
strippedValue = c1(1, c1.length() - 2);
|
||||
}
|
||||
else
|
||||
{ strippedValue = c1(1,c1.length()-1); }
|
||||
{
|
||||
strippedValue = c1(1, c1.length() - 1);
|
||||
}
|
||||
c1 = strippedValue;
|
||||
}
|
||||
|
||||
G4bool x = false;
|
||||
if(comp=="==") { x = (l==r); }
|
||||
else if(comp=="!=") { x = (l!=r); }
|
||||
if(x) UI->ApplyCommand(c1);
|
||||
if(comp == "==")
|
||||
{
|
||||
x = (l == r);
|
||||
}
|
||||
else if(comp == "!=")
|
||||
{
|
||||
x = (l != r);
|
||||
}
|
||||
if(x)
|
||||
UI->ApplyCommand(c1);
|
||||
}
|
||||
if(command==ifBatchCommand)
|
||||
if(command == ifBatchCommand)
|
||||
{
|
||||
if(G4UIsession::InSession()==0) UI->ExecuteMacroFile(UI->FindMacroPath(newValue));
|
||||
if(G4UIsession::InSession() == 0)
|
||||
UI->ExecuteMacroFile(UI->FindMacroPath(newValue));
|
||||
}
|
||||
if(command==ifInteractiveCommand)
|
||||
if(command == ifInteractiveCommand)
|
||||
{
|
||||
if(G4UIsession::InSession()>0) UI->ExecuteMacroFile(UI->FindMacroPath(newValue));
|
||||
if(G4UIsession::InSession() > 0)
|
||||
UI->ExecuteMacroFile(UI->FindMacroPath(newValue));
|
||||
}
|
||||
if(command==doifBatchCommand)
|
||||
if(command == doifBatchCommand)
|
||||
{
|
||||
if(G4UIsession::InSession()==0) UI->ApplyCommand(newValue);
|
||||
if(G4UIsession::InSession() == 0)
|
||||
UI->ApplyCommand(newValue);
|
||||
}
|
||||
if(command==doifInteractiveCommand)
|
||||
if(command == doifInteractiveCommand)
|
||||
{
|
||||
if(G4UIsession::InSession()>0) UI->ApplyCommand(newValue);
|
||||
if(G4UIsession::InSession() > 0)
|
||||
UI->ApplyCommand(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
G4String G4UIcontrolMessenger::GetCurrentValue(G4UIcommand * command)
|
||||
// --------------------------------------------------------------------
|
||||
G4String G4UIcontrolMessenger::GetCurrentValue(G4UIcommand* command)
|
||||
{
|
||||
G4UImanager * UI = G4UImanager::GetUIpointer();
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
G4String currentValue;
|
||||
|
||||
if( command == macroPathCommand ) {
|
||||
currentValue = UI-> GetMacroSearchPath();
|
||||
|
||||
if(command == macroPathCommand)
|
||||
{
|
||||
currentValue = UI->GetMacroSearchPath();
|
||||
}
|
||||
if(command==verboseCommand)
|
||||
if(command == verboseCommand)
|
||||
{
|
||||
currentValue = verboseCommand->ConvertToString(UI->GetVerboseLevel());
|
||||
}
|
||||
if(command==doublePrecCommand)
|
||||
if(command == doublePrecCommand)
|
||||
{
|
||||
currentValue = doublePrecCommand->ConvertToString(G4UImanager::DoublePrecisionStr());
|
||||
currentValue =
|
||||
doublePrecCommand->ConvertToString(G4UImanager::DoublePrecisionStr());
|
||||
}
|
||||
if(command==suppressAbortionCommand)
|
||||
if(command == suppressAbortionCommand)
|
||||
{
|
||||
currentValue = suppressAbortionCommand->ConvertToString(G4StateManager::GetStateManager()->GetSuppressAbortion());
|
||||
currentValue = suppressAbortionCommand->ConvertToString(
|
||||
G4StateManager::GetStateManager()->GetSuppressAbortion());
|
||||
}
|
||||
if(command==maxStoredHistCommand)
|
||||
if(command == maxStoredHistCommand)
|
||||
{
|
||||
currentValue = maxStoredHistCommand->ConvertToString(UI->GetMaxHistSize());
|
||||
}
|
||||
|
||||
|
||||
return currentValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -23,17 +23,23 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4UIdirectory
|
||||
//
|
||||
//
|
||||
//
|
||||
// Author: Makoto Asai, 1998
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4UIdirectory.hh"
|
||||
|
||||
G4UIdirectory::G4UIdirectory(char * theCommandPath,G4bool commandsToBeBroadcasted)
|
||||
:G4UIcommand(theCommandPath,NULL,commandsToBeBroadcasted)
|
||||
{;}
|
||||
|
||||
G4UIdirectory::G4UIdirectory(const char * theCommandPath,G4bool commandsToBeBroadcasted)
|
||||
:G4UIcommand(theCommandPath,NULL,commandsToBeBroadcasted)
|
||||
{;}
|
||||
// --------------------------------------------------------------------
|
||||
G4UIdirectory::G4UIdirectory(char* theCommandPath,
|
||||
G4bool commandsToBeBroadcasted)
|
||||
: G4UIcommand(theCommandPath, nullptr, commandsToBeBroadcasted)
|
||||
{
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4UIdirectory::G4UIdirectory(const char* theCommandPath,
|
||||
G4bool commandsToBeBroadcasted)
|
||||
: G4UIcommand(theCommandPath, nullptr, commandsToBeBroadcasted)
|
||||
{
|
||||
}
|
||||
|
||||
+409
-331
File diff suppressed because it is too large
Load Diff
@@ -23,8 +23,10 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4UImessenger
|
||||
//
|
||||
//
|
||||
// Author: Makoto Asai, 1998
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4UImessenger.hh"
|
||||
#include "G4UImanager.hh"
|
||||
@@ -34,36 +36,49 @@
|
||||
#include "G4ios.hh"
|
||||
#include <sstream>
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4UImessenger::G4UImessenger()
|
||||
: baseDir(NULL), baseDirName(""), commandsShouldBeInMaster(false)
|
||||
{
|
||||
{
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4UImessenger::G4UImessenger(const G4String& path, const G4String& dsc,
|
||||
G4bool commandsToBeBroadcasted)
|
||||
: baseDir(NULL), baseDirName(""), commandsShouldBeInMaster(false)
|
||||
{
|
||||
CreateDirectory(path, dsc, commandsToBeBroadcasted);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4UImessenger::~G4UImessenger()
|
||||
{
|
||||
if(baseDir) delete baseDir;
|
||||
delete baseDir;
|
||||
}
|
||||
|
||||
G4String G4UImessenger::GetCurrentValue(G4UIcommand*)
|
||||
{
|
||||
// --------------------------------------------------------------------
|
||||
G4String G4UImessenger::GetCurrentValue(G4UIcommand*)
|
||||
{
|
||||
G4String nullString;
|
||||
return nullString;
|
||||
}
|
||||
|
||||
void G4UImessenger::SetNewValue(G4UIcommand*,G4String)
|
||||
{ ; }
|
||||
// --------------------------------------------------------------------
|
||||
void G4UImessenger::SetNewValue(G4UIcommand*, G4String)
|
||||
{
|
||||
}
|
||||
|
||||
G4bool G4UImessenger::operator == (const G4UImessenger& messenger) const {
|
||||
// --------------------------------------------------------------------
|
||||
G4bool G4UImessenger::operator==(const G4UImessenger& messenger) const
|
||||
{
|
||||
return this == &messenger;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4bool G4UImessenger::operator!=(const G4UImessenger& messenger) const
|
||||
{
|
||||
return this != &messenger;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4String G4UImessenger::ItoS(G4int i)
|
||||
{
|
||||
std::ostringstream os;
|
||||
@@ -71,6 +86,7 @@ G4String G4UImessenger::ItoS(G4int i)
|
||||
return G4String(os.str());
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4String G4UImessenger::DtoS(G4double a)
|
||||
{
|
||||
std::ostringstream os;
|
||||
@@ -78,13 +94,16 @@ G4String G4UImessenger::DtoS(G4double a)
|
||||
return G4String(os.str());
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4String G4UImessenger::BtoS(G4bool b)
|
||||
{
|
||||
G4String vl = "0";
|
||||
if(b) vl = "true";
|
||||
if(b)
|
||||
vl = "true";
|
||||
return vl;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4int G4UImessenger::StoI(G4String str)
|
||||
{
|
||||
G4int vl;
|
||||
@@ -94,6 +113,17 @@ G4int G4UImessenger::StoI(G4String str)
|
||||
return vl;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4long G4UImessenger::StoL(G4String str)
|
||||
{
|
||||
G4long vl;
|
||||
const char* t = str;
|
||||
std::istringstream is(t);
|
||||
is >> vl;
|
||||
return vl;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4double G4UImessenger::StoD(G4String str)
|
||||
{
|
||||
G4double vl;
|
||||
@@ -103,37 +133,45 @@ G4double G4UImessenger::StoD(G4String str)
|
||||
return vl;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4bool G4UImessenger::StoB(G4String str)
|
||||
{
|
||||
G4String v = str;
|
||||
v.toUpper();
|
||||
G4bool vl = false;
|
||||
if( v=="Y" || v=="YES" || v=="1" || v=="T" || v=="TRUE" )
|
||||
{ vl = true; }
|
||||
if(v == "Y" || v == "YES" || v == "1" || v == "T" || v == "TRUE")
|
||||
{
|
||||
vl = true;
|
||||
}
|
||||
return vl;
|
||||
}
|
||||
|
||||
|
||||
void G4UImessenger::AddUIcommand(G4UIcommand * newCommand)
|
||||
// --------------------------------------------------------------------
|
||||
void G4UImessenger::AddUIcommand(G4UIcommand* newCommand)
|
||||
{
|
||||
G4cerr << "Warning : Old style definition of G4UIcommand <"
|
||||
G4cerr << "Warning : Old style definition of G4UIcommand <"
|
||||
<< newCommand->GetCommandPath() << ">." << G4endl;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4UImessenger::CreateDirectory(const G4String& path, const G4String& dsc,
|
||||
G4bool commandsToBeBroadcasted)
|
||||
G4bool commandsToBeBroadcasted)
|
||||
{
|
||||
G4UImanager* ui = G4UImanager::GetUIpointer();
|
||||
|
||||
G4String fullpath = path;
|
||||
if(fullpath(fullpath.length()-1) != '/') fullpath.append("/");
|
||||
if(fullpath(fullpath.length() - 1) != '/')
|
||||
fullpath.append("/");
|
||||
|
||||
G4UIcommandTree* tree= ui-> GetTree()-> FindCommandTree(fullpath.c_str());
|
||||
if (tree) {
|
||||
baseDirName = tree-> GetPathName();
|
||||
} else {
|
||||
baseDir = new G4UIdirectory(fullpath.c_str(),commandsToBeBroadcasted);
|
||||
G4UIcommandTree* tree = ui->GetTree()->FindCommandTree(fullpath.c_str());
|
||||
if(tree != nullptr)
|
||||
{
|
||||
baseDirName = tree->GetPathName();
|
||||
}
|
||||
else
|
||||
{
|
||||
baseDir = new G4UIdirectory(fullpath.c_str(), commandsToBeBroadcasted);
|
||||
baseDirName = fullpath;
|
||||
baseDir-> SetGuidance(dsc.c_str());
|
||||
baseDir->SetGuidance(dsc.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -23,37 +23,63 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4UIsession
|
||||
//
|
||||
//
|
||||
//
|
||||
// ---------------------------------------------------------------------
|
||||
// Author: Makoto Asai, 1998
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4UIsession.hh"
|
||||
|
||||
G4int G4UIsession::inSession = 0;
|
||||
G4UIsession::G4UIsession() : ifBatch(0) , lastRC(0)
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4UIsession::G4UIsession()
|
||||
{
|
||||
inSession++;
|
||||
++inSession;
|
||||
}
|
||||
|
||||
G4UIsession::G4UIsession(G4int iBatch) : ifBatch(iBatch) , lastRC(0)
|
||||
{;}
|
||||
// --------------------------------------------------------------------
|
||||
G4UIsession::G4UIsession(G4int iBatch)
|
||||
: ifBatch(iBatch)
|
||||
{
|
||||
}
|
||||
|
||||
G4UIsession::~G4UIsession()
|
||||
{ if(!ifBatch) { inSession--; } }
|
||||
// --------------------------------------------------------------------
|
||||
G4UIsession::~G4UIsession()
|
||||
{
|
||||
if(!ifBatch)
|
||||
{
|
||||
--inSession;
|
||||
}
|
||||
}
|
||||
|
||||
G4UIsession * G4UIsession::SessionStart() { return nullptr; }
|
||||
// --------------------------------------------------------------------
|
||||
G4UIsession* G4UIsession::SessionStart()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void G4UIsession::PauseSessionStart(const G4String&) {;}
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIsession::PauseSessionStart(const G4String&)
|
||||
{
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4int G4UIsession::InSession()
|
||||
{
|
||||
return inSession;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4int G4UIsession::ReceiveG4cout(const G4String& coutString)
|
||||
{
|
||||
std::cout << coutString << std::flush;
|
||||
std::cout << coutString << std::flush;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4int G4UIsession::ReceiveG4cerr(const G4String& cerrString)
|
||||
{
|
||||
std::cerr << cerrString << std::flush;
|
||||
std::cerr << cerrString << std::flush;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,12 +23,10 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4UnitsMessenger
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
// Author: Michel Maire, 1998
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4UnitsMessenger.hh"
|
||||
|
||||
@@ -36,31 +34,28 @@
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4UnitsMessenger::G4UnitsMessenger()
|
||||
{
|
||||
{
|
||||
UnitsTableDir = new G4UIdirectory("/units/");
|
||||
UnitsTableDir->SetGuidance("Available units.");
|
||||
|
||||
ListCmd = new G4UIcmdWithoutParameter("/units/list",this);
|
||||
|
||||
ListCmd = new G4UIcmdWithoutParameter("/units/list", this);
|
||||
ListCmd->SetGuidance("full list of available units.");
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4UnitsMessenger::~G4UnitsMessenger()
|
||||
{
|
||||
delete ListCmd;
|
||||
delete UnitsTableDir;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
void G4UnitsMessenger::SetNewValue(G4UIcommand* command,G4String)
|
||||
{
|
||||
if (command == ListCmd)
|
||||
{ G4UnitDefinition::PrintUnitsTable(); }
|
||||
// --------------------------------------------------------------------
|
||||
void G4UnitsMessenger::SetNewValue(G4UIcommand* command, G4String)
|
||||
{
|
||||
if(command == ListCmd)
|
||||
{
|
||||
G4UnitDefinition::PrintUnitsTable();
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
@@ -23,26 +23,26 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4VGlobalFastSimulationManager
|
||||
//
|
||||
//
|
||||
//
|
||||
// Abstract interface for GEANT4 Global Fast Simulation Manager.
|
||||
// P. Mora de Freitas & M. Verderi 14/April/1999.
|
||||
// Authors: P. Mora de Freitas & M. Verderi, 14 April 1999
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4VGlobalFastSimulationManager.hh"
|
||||
|
||||
G4ThreadLocal G4VGlobalFastSimulationManager*
|
||||
G4VGlobalFastSimulationManager::fpConcreteInstance = 0;
|
||||
G4ThreadLocal G4VGlobalFastSimulationManager*
|
||||
G4VGlobalFastSimulationManager::fpConcreteInstance = nullptr;
|
||||
|
||||
G4VGlobalFastSimulationManager*
|
||||
G4VGlobalFastSimulationManager::GetConcreteInstance ()
|
||||
// --------------------------------------------------------------------
|
||||
G4VGlobalFastSimulationManager*
|
||||
G4VGlobalFastSimulationManager::GetConcreteInstance()
|
||||
{
|
||||
return fpConcreteInstance;
|
||||
}
|
||||
|
||||
void
|
||||
G4VGlobalFastSimulationManager::
|
||||
SetConcreteInstance (G4VGlobalFastSimulationManager* m)
|
||||
// --------------------------------------------------------------------
|
||||
void G4VGlobalFastSimulationManager::SetConcreteInstance(
|
||||
G4VGlobalFastSimulationManager* m)
|
||||
{
|
||||
fpConcreteInstance = m;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user